:root {
  color-scheme: light;
  --ink: #15171a;
  --muted: #667085;
  --line: #d8dee8;
  --surface: #ffffff;
  --soft: #f5f7fb;
  --deep: #111827;
  --teal: #0f766e;
  --coral: #c2410c;
  --gold: #b7791f;
  --blue: #2563eb;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(17, 24, 39, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef2f7;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 0 28px;
  background: rgba(255, 255, 255, .88);
  border-bottom: 1px solid rgba(216, 222, 232, .9);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--coral));
  font-weight: 900;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-weight: 700;
}

.nav-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

main {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
}

.studio-hero {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.1fr);
  gap: 36px;
  align-items: center;
  min-height: 520px;
  padding: 54px 0 24px;
}

.hero-copy h1 {
  margin: 10px 0 18px;
  font-size: clamp(44px, 7vw, 96px);
  line-height: .92;
  letter-spacing: 0;
}

.hero-copy p {
  max-width: 620px;
  margin: 0;
  color: #475467;
  font-size: 18px;
  line-height: 1.75;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-visual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 220px 220px;
  gap: 14px;
}

.hero-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-visual img:first-child {
  grid-row: 1 / 3;
}

.workspace,
.admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, 520px) 1fr;
  gap: 20px;
  align-items: start;
}

.generator-panel,
.result-panel,
.admin-panel,
.login-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.generator-panel,
.result-panel,
.admin-panel {
  padding: 22px;
}

.panel-head,
.section-head,
.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 22px;
}

.panel-head p,
.section-head p,
.admin-head p,
.gallery-meta p,
.sample-card p {
  margin: 5px 0 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field span,
.check-row {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.code-editor {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.field textarea,
.code-editor {
  resize: vertical;
  line-height: 1.55;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.code-editor:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .12);
}

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide {
  grid-column: 1 / -1;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 5px;
  margin: 14px 0;
  border-radius: 8px;
  background: var(--soft);
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 7px;
  color: #475467;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.segmented input:checked + span {
  color: #fff;
  background: var(--deep);
}

.inline-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 850;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.button.primary {
  color: #fff;
  background: var(--deep);
  box-shadow: 0 10px 24px rgba(17, 24, 39, .2);
}

.button.subtle {
  color: var(--deep);
  background: var(--soft);
  border-color: var(--line);
}

.button.tiny {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.button.danger {
  color: var(--danger);
  background: #fff1f0;
}

.icon-button {
  width: 42px;
  padding: 0;
  background: var(--soft);
  border-color: var(--line);
}

.generate-button {
  width: 100%;
  margin-top: 8px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  min-height: 520px;
}

.empty-result,
.loading-grid {
  display: grid;
  place-items: center;
  grid-column: 1 / -1;
  min-height: 420px;
  border: 1px dashed #b8c2d4;
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
}

.empty-result.danger {
  color: var(--danger);
  background: #fff7f7;
}

.loading-grid {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
  padding: 18px;
}

.loading-grid span {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  background: linear-gradient(110deg, #e5eaf2 8%, #f8fafc 18%, #e5eaf2 33%);
  background-size: 200% 100%;
  animation: shine 1.2s linear infinite;
}

@keyframes shine {
  to {
    background-position-x: -200%;
  }
}

.result-card,
.gallery-item,
.sample-card {
  overflow: hidden;
  margin: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-card img,
.gallery-item img,
.sample-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #d8dee8;
}

.result-card figcaption,
.gallery-meta,
.sample-card div {
  padding: 12px;
}

.result-card figcaption,
.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.library-section {
  padding: 46px 0 70px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.gallery-meta strong {
  display: block;
  min-height: 42px;
  line-height: 1.35;
}

.admin-login {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-box {
  width: min(420px, 100%);
  padding: 28px;
}

.login-box h1 {
  margin: 16px 0 22px;
}

.admin-page {
  padding: 34px 0 70px;
}

.admin-head {
  align-items: center;
}

.admin-head h1 {
  margin: 8px 0;
  font-size: clamp(30px, 4vw, 52px);
}

.admin-column {
  display: grid;
  gap: 20px;
}

.provider-list {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.provider-row {
  display: grid;
  grid-template-columns: .8fr .8fr 1.5fr .8fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 16px;
}

.code-editor {
  min-height: 310px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 13px;
}

.flash,
.toast {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: #ecfdf3;
  color: #027a48;
  border: 1px solid #abefc6;
  font-weight: 700;
}

.flash.danger,
.toast.danger {
  color: var(--danger);
  background: #fff1f0;
  border-color: #fecdca;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  box-shadow: var(--shadow);
}

.error-state {
  display: grid;
  place-items: start;
  gap: 16px;
  min-height: 100vh;
  align-content: center;
}

@media (max-width: 980px) {
  .studio-hero,
  .workspace,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .hero-visual {
    grid-template-rows: 180px 180px;
  }

  .provider-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100% - 20px, 1440px);
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar nav {
    gap: 10px;
    font-size: 13px;
  }

  .studio-hero {
    min-height: auto;
    padding-top: 28px;
  }

  .hero-copy h1 {
    font-size: 44px;
  }

  .hero-visual {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, 170px);
  }

  .hero-visual img:first-child {
    grid-row: auto;
  }

  .grid-two,
  .segmented,
  .provider-row {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .section-head,
  .admin-head {
    display: grid;
  }
}
