:root {
  --paper: #faf9f4;
  --surface: #ffffff;
  --surface-2: #eff4ee;
  --ink: #24313f;
  --muted: #6a7580;
  --line: #d9ded8;
  --sage: #657f6d;
  --sage-dark: #415d4c;
  --coral: #c96b5d;
  --blue: #416f8f;
  --gold: #c49a42;
  --danger: #a44942;
  --shadow: 0 18px 45px rgba(36, 49, 63, 0.14);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

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

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px 32px;
  border-bottom: 1px solid rgba(36, 49, 63, 0.1);
  background: rgba(250, 249, 244, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  color: var(--ink);
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--sage-dark);
  color: white;
  font-size: 0.85rem;
}

.topnav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.topnav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
  background: var(--surface-2);
  color: var(--sage-dark);
}

#app {
  min-height: calc(100vh - 72px);
}

.hero {
  min-height: 520px;
  display: grid;
  align-items: end;
  background-image:
    linear-gradient(90deg, rgba(22, 31, 40, 0.76), rgba(22, 31, 40, 0.28), rgba(22, 31, 40, 0.08)),
    var(--hero-image);
  background-position: center 24%;
  background-size: cover;
  color: white;
}

.hero-inner {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 72px 0 56px;
}

.eyebrow {
  margin: 0 0 12px;
  color: #f2cf84;
  font-size: 0.86rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 680px;
  margin: 0;
  font-size: 3.25rem;
  line-height: 1.05;
}

.hero p.hero-copy {
  max-width: 620px;
  margin: 18px 0 28px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.08rem;
  line-height: 1.7;
}

.hero-actions,
.page-actions,
.form-actions,
.preview-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
button.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 15px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

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

.button:disabled,
button.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.button.primary {
  background: var(--coral);
  color: white;
}

.button.secondary {
  border-color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.button.soft {
  background: var(--surface-2);
  color: var(--sage-dark);
}

.button.danger {
  border-color: rgba(164, 73, 66, 0.24);
  color: var(--danger);
}

.button svg,
.icon-button svg,
.upload-button svg,
.card-icon svg,
.file-chip svg,
.photo-chip svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.content-section {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0;
}

.content-section.compact {
  padding-top: 32px;
}

.mission-section {
  padding-bottom: 24px;
}

.mission-section .section-heading {
  align-items: flex-start;
}

.mission-section .section-heading > div {
  width: 100%;
}

.mission-section .section-heading p {
  max-width: none;
}

.section-heading,
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.section-heading h2,
.page-heading h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.14;
}

.section-heading p,
.page-heading p {
  max-width: 660px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

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

.theme-card,
.mode-card,
.gallery-card,
.question-card,
.sample-card,
.mode-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(36, 49, 63, 0.07);
}

.mode-card {
  min-height: 248px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-top: 5px solid var(--accent, var(--sage));
}

.ai-confirmation-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 32, 40, 0.46);
}

.ai-confirmation-dialog {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(20, 29, 38, 0.24);
}

.ai-confirmation-dialog h3 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.45;
}

.ai-confirmation-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.ai-confirmation-actions .button {
  min-width: 88px;
}

.gallery-consent-dialog p {
  margin: 14px 0;
  color: var(--muted);
  line-height: 1.6;
}

.gallery-consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  line-height: 1.45;
}

.gallery-consent-check input {
  margin-top: 3px;
}

.generate-storybook-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-top: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(36, 49, 63, 0.07);
}

.generate-storybook-copy h2 {
  margin: 6px 0 8px;
  font-size: 1.35rem;
}

.generate-storybook-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.generate-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.generate-storybook-action {
  flex: 0 0 auto;
}

.generate-storybook-action .button {
  min-height: 48px;
  white-space: nowrap;
}

.system-stat-sections {
  display: grid;
  gap: 22px;
}

.system-stat-section {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, var(--paper));
}

.system-stat-heading {
  margin-bottom: 14px;
}

.system-stat-heading h3 {
  margin: 5px 0 0;
  font-size: 1.12rem;
}

@media (max-width: 760px) {
  .generate-storybook-card {
    align-items: stretch;
    flex-direction: column;
  }

  .generate-storybook-action .button {
    width: 100%;
    white-space: normal;
  }
}

.mode-card.ai-card {
  --accent: var(--blue);
}

.mode-card.human-card {
  --accent: var(--sage);
}

.mode-card:hover {
  border-color: color-mix(in srgb, var(--accent, var(--sage)) 60%, var(--line));
  transform: translateY(-2px);
}

.theme-card {
  min-height: 178px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-top: 5px solid var(--accent);
}

.theme-card:hover,
.gallery-card:hover {
  border-color: color-mix(in srgb, var(--accent, var(--sage)) 60%, var(--line));
  transform: translateY(-2px);
}

.card-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent, var(--sage)) 16%, white);
  color: var(--accent, var(--sage-dark));
}

.theme-card h3,
.mode-card h3,
.gallery-card h3,
.question-card h3,
.sample-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.theme-card p,
.mode-card p,
.gallery-card p,
.sample-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.94rem;
}

.story-flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.flow-step {
  min-height: 132px;
  padding: 16px;
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  border-radius: var(--radius);
}

.flow-step strong {
  display: block;
  margin-bottom: 8px;
}

.flow-step span {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.form-page,
.preview-page,
.gallery-page,
.admin-page,
.user-page {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 38px 0 56px;
}

.crumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--sage-dark);
  font-weight: 800;
}

.job-mode-crumb {
  flex-wrap: nowrap;
  white-space: nowrap;
  font-size: 2rem;
  line-height: 1.14;
}

.job-mode-crumb > svg {
  width: 1.2em;
  height: 1.2em;
  flex: 0 0 auto;
}

.job-mode-label {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  white-space: nowrap;
}

.interview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: start;
}

.mode-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: start;
}

.question-list {
  display: grid;
  gap: 14px;
}

.question-card {
  padding: 18px;
}

.mode-panel {
  padding: 18px;
}

.mode-panel h2 {
  margin: 7px 0 0;
  font-size: 1.18rem;
}

.mode-eyebrow {
  margin-bottom: 8px;
  color: var(--sage-dark);
}

.question-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.question-number {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--sage-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.question-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-2);
  color: var(--sage-dark);
}

.icon-button.danger:hover {
  border-color: rgba(164, 73, 66, 0.35);
  color: var(--danger);
}

.question-textarea {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fffdf9;
  color: var(--ink);
  line-height: 1.55;
}

.question-textarea:disabled,
select:disabled {
  cursor: not-allowed;
  background: #f2f1ed;
  color: #89909a;
}

.question-textarea:focus,
select:focus,
input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(65, 111, 143, 0.24);
  outline-offset: 2px;
}

.answer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 12px;
  margin-top: 12px;
}

.human-upload-grid {
  grid-template-columns: minmax(0, 1fr) 250px;
}

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

.input-grid.compact-grid,
.input-grid.question-language-grid {
  grid-template-columns: minmax(220px, 360px);
}

.field-block {
  display: grid;
  gap: 8px;
}

.question-source {
  max-width: 420px;
  margin-top: 14px;
}

.question-preview {
  margin-top: 14px;
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  padding: 13px 14px;
  background: var(--surface-2);
}

.question-preview p {
  margin: 6px 0 0;
  color: var(--ink);
  line-height: 1.55;
}

.upload-area,
.language-area {
  min-height: 78px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 9px;
  border: 1px dashed color-mix(in srgb, var(--sage) 40%, var(--line));
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfa;
}

.upload-button {
  width: fit-content;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 11px;
  background: var(--surface);
  color: var(--sage-dark);
  font-weight: 800;
  cursor: pointer;
}

.file-chip,
.photo-chip,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.9rem;
}

.file-chip span:nth-child(2),
.photo-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip button,
.photo-chip button {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

.file-chip button svg,
.photo-chip button svg {
  width: 15px;
  height: 15px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.88rem;
}

.language-area label,
.panel-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
}

.side-panel {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 96px;
}

.panel-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.panel-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.panel-block p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.speaker-profile-block {
  display: grid;
  gap: 10px;
}

.speaker-profile-block p {
  margin-bottom: 4px;
}

.speaker-characteristics-input {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fffdf9;
  color: var(--ink);
  line-height: 1.55;
}

.speaker-characteristics-input:focus {
  outline: 3px solid rgba(65, 111, 143, 0.24);
  outline-offset: 2px;
}

.chat-window {
  min-height: 300px;
  max-height: 460px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #fbfcfa;
}

.empty-chat {
  min-height: 170px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.empty-chat strong,
.empty-chat span {
  display: block;
}

.chat-message {
  width: min(88%, 640px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: var(--surface);
}

.chat-message span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.chat-message p {
  margin: 0;
  line-height: 1.55;
}

.chat-message.ai {
  border-color: color-mix(in srgb, var(--blue) 35%, var(--line));
}

.chat-message.elder {
  justify-self: end;
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--sage) 35%, var(--line));
}

.recorder-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: var(--surface);
}

.recorder-bar p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.recorder-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.recording-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.photo-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented-control label {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control label:has(input:checked) {
  border-color: var(--sage);
  background: var(--surface-2);
  color: var(--sage-dark);
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
  padding: 32px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 10px;
  font-size: 1.3rem;
}

.empty-state p {
  max-width: 520px;
  margin: 0 auto 18px;
  color: var(--muted);
  line-height: 1.65;
}

.pipeline-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  margin: 22px 0;
}

.pipeline-step {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}

.pipeline-step.complete {
  border-color: color-mix(in srgb, var(--sage) 46%, var(--line));
  background: var(--surface-2);
}

.pipeline-step.active {
  border-color: var(--blue);
  background: color-mix(in srgb, var(--blue) 9%, var(--surface));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 14%, transparent);
}

.pipeline-step.review,
.pipeline-step.failed {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}

.pipeline-step strong {
  display: block;
  margin-bottom: 6px;
}

.pipeline-step .pipeline-description {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.pipeline-step .pipeline-state {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.pipeline-step.complete .pipeline-state {
  color: var(--sage-dark);
}

.pipeline-step.active .pipeline-state {
  color: var(--blue);
}

.pipeline-step.review .pipeline-state,
.pipeline-step.failed .pipeline-state {
  color: var(--danger);
}

.storybook-shell {
  display: grid;
  gap: 18px;
}

.job-status-panel {
  display: grid;
  gap: 18px;
}

.job-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: 0 8px 24px rgba(36, 49, 63, 0.07);
}

.job-card h2 {
  margin: 14px 0 10px;
  font-size: 1.35rem;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 0.25s ease;
}

.progress-track.complete span {
  background: var(--sage);
}

.progress-track.failed span {
  background: var(--danger);
}

.job-ready-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-top: 12px;
}

.job-ready-head h2 {
  margin: 0 0 8px;
}

.job-ready-head p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.server-preview-shell {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #e9ddc8;
}

.server-preview-frame {
  width: 100%;
  height: min(76vh, 860px);
  min-height: 560px;
  display: block;
  border: 0;
  background: white;
}

.storybook-page {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(280px, 1.08fr);
  gap: 18px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.story-text {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
}

.story-text h2 {
  margin: 0;
  font-size: 1.35rem;
}

.story-text p {
  margin: 10px 0 0;
  color: #384657;
  font-size: 1.04rem;
  line-height: 1.75;
}

.meta-grid {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.story-image {
  min-height: 290px;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.story-image img {
  width: 100%;
  height: 310px;
  object-fit: cover;
}

.story-image figcaption {
  padding: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
  background: #fffdf9;
}

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

.gallery-card {
  overflow: hidden;
}

.gallery-card img {
  width: 100%;
  height: 190px;
  object-fit: cover;
}

.gallery-card-body {
  padding: 16px;
}

.reviewed-story {
  display: grid;
  gap: 16px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.reviewed-story-head,
.reviewed-story-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.reviewed-story-head h2 {
  margin: 5px 0 0;
}

.reviewed-story-head p,
.reviewed-story-summary {
  margin: 6px 0 0;
  line-height: 1.65;
}

.reviewed-story-pages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.reviewed-story-page {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.reviewed-story-page.flagged {
  border-color: color-mix(in srgb, var(--danger) 48%, var(--line));
  box-shadow: inset 4px 0 0 color-mix(in srgb, var(--danger) 70%, transparent);
}

.reviewed-story-editor {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.reviewed-story-editor textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  line-height: 1.65;
}

.reviewed-story-editor textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--blue) 20%, transparent);
  border-color: var(--blue);
}

.reviewed-story-page-head {
  color: var(--muted);
  font-size: 0.82rem;
}

.reviewed-story-page h3 {
  margin: 10px 0 8px;
  font-size: 1.05rem;
}

.reviewed-story-page p {
  margin: 0 0 12px;
  color: #384657;
  line-height: 1.75;
}

@media (max-width: 760px) {
  .reviewed-story-pages {
    grid-template-columns: 1fr;
  }

  .reviewed-story-head {
    flex-direction: column;
  }
}

.gallery-section + .gallery-section,
.gallery-empty-note + .gallery-section {
  margin-top: 30px;
}

.gallery-section-heading {
  margin-bottom: 14px;
}

.gallery-section-heading h2 {
  margin: 5px 0 0;
}

.gallery-section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.gallery-empty-note {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}

.gallery-cover-wrap {
  position: relative;
}

.gallery-sample-label {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  color: white;
  background: rgba(36, 49, 63, 0.82);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.gallery-sample-card {
  cursor: default;
}

.gallery-sample-card:hover {
  transform: none;
}

.gallery-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

.status-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.status-badge {
  min-height: 30px;
  color: var(--sage-dark);
  background: var(--surface-2);
  font-size: 0.82rem;
  font-weight: 800;
}

.status-badge.private {
  color: var(--danger);
  background: #fbefed;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.auth-shell {
  width: min(460px, 100%);
}

.auth-card,
.profile-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}

.auth-card {
  display: grid;
  gap: 14px;
}

.auth-card h2 {
  margin: 0;
  font-size: 1.18rem;
}

.auth-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.auth-card input {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
}

.auth-actions {
  display: grid;
  gap: 10px;
}

.user-workspace {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(0, 5fr);
  gap: 18px;
  align-items: start;
}

.user-sidebar {
  position: sticky;
  top: 96px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}

.user-sidebar button {
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.user-sidebar button:hover,
.user-sidebar button.active {
  background: var(--surface-2);
  color: var(--sage-dark);
}

.user-main-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  padding: 18px;
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-title-row h2 {
  margin: 0;
  font-size: 1.35rem;
}

.panel-title-row p {
  margin: 6px 0 0;
  line-height: 1.55;
}

.profile-panel-wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.password-card {
  max-width: 520px;
}

.password-card h3 {
  margin: 0;
  font-size: 1.08rem;
}

.compact-stats .stat-box {
  min-height: 104px;
}

.system-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.gallery-coming-soon {
  min-height: 300px;
}

.admin-management {
  margin-top: 0;
}

.admin-heading {
  margin-top: 18px;
}

.admin-management h3 {
  margin: 26px 0 12px;
  font-size: 1.05rem;
}

.admin-table {
  margin-bottom: 10px;
}

.profile-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.profile-panel strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.mini-progress {
  width: 150px;
  max-width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.mini-progress span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.job-language-summary {
  display: grid;
  gap: 4px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.job-language-summary span {
  overflow-wrap: anywhere;
}

.job-language-summary strong {
  color: var(--ink);
}

.stat-box {
  min-height: 124px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}

.stat-box strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  max-width: min(520px, calc(100% - 32px));
  transform: translate(-50%, 120%);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

@media (max-width: 980px) {
  .theme-grid,
  .mode-grid,
  .gallery-grid,
  .profile-panel,
  .system-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .story-flow,
  .pipeline-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .interview-layout,
  .mode-layout,
  .storybook-page,
  .job-ready-head {
    grid-template-columns: 1fr;
  }

  .job-ready-head {
    display: grid;
  }

  .side-panel {
    position: static;
  }

  .user-workspace {
    grid-template-columns: 1fr;
  }

  .user-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    padding: 12px 18px;
    flex-direction: column;
    gap: 10px;
  }

  .topnav {
    width: 100%;
    justify-content: flex-start;
  }

  .topnav a {
    padding: 0 9px;
    font-size: 0.9rem;
  }

  .hero {
    min-height: 500px;
    background-position: 58% 24%;
  }

  .hero-inner,
  .content-section,
  .form-page,
  .preview-page,
  .gallery-page,
  .admin-page,
  .user-page {
    width: min(100% - 28px, 1180px);
  }

  .hero h1 {
    font-size: 2.3rem;
  }

  .hero p.hero-copy {
    font-size: 1rem;
  }

  .section-heading,
  .page-heading {
    display: block;
  }

  .theme-grid,
  .mode-grid,
  .gallery-grid,
  .story-flow,
    .pipeline-strip,
    .admin-grid,
    .profile-panel,
    .system-grid,
    .answer-grid,
    .input-grid,
    .input-grid.compact-grid,
    .recorder-bar {
    grid-template-columns: 1fr;
  }

  .user-sidebar {
    grid-template-columns: 1fr;
  }

  .panel-title-row {
    display: grid;
  }

  .user-main-panel {
    padding: 14px;
  }

  .question-card,
  .mode-panel,
  .storybook-page,
  .panel-block {
    padding: 14px;
  }

  .mode-card {
    min-height: 210px;
  }

  .chat-message {
    width: 100%;
  }

  .recorder-actions {
    justify-content: flex-start;
  }

  .story-image img {
    height: 250px;
  }

  .server-preview-frame {
    min-height: 460px;
  }
}
