[hidden] { display: none !important; }

:root {
  --ink: #24211d;
  --ink-soft: #575149;
  --muted: #777066;
  --cream: #f3efe6;
  --paper: #fbf9f4;
  --paper-deep: #eee8dc;
  --line: #d8d0c1;
  --line-dark: #b9ad9b;
  --accent: #8a572f;
  --accent-dark: #6d4224;
  --accent-pale: #eee0cf;
  --success: #476452;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --shadow: 0 24px 70px rgba(60, 48, 34, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(255, 255, 255, 0.75), transparent 32rem),
    var(--cream);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, label[for="imageInput"], select { -webkit-tap-highlight-color: transparent; }

.topbar {
  width: min(1180px, calc(100% - 48px));
  min-height: 82px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid rgba(108, 93, 74, 0.22);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.04rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 1rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.header-badge {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 650;
}

.header-badge span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(71, 100, 82, 0.12);
}

.page-shell { overflow: hidden; }

.hero {
  width: min(920px, calc(100% - 48px));
  margin: 0 auto;
  padding: 48px 0 44px;
  text-align: center;
}

.eyebrow, .section-kicker {
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.eyebrow::before, .eyebrow::after {
  content: "";
  display: inline-block;
  width: 34px;
  height: 1px;
  margin: 0 13px 4px;
  background: currentColor;
  opacity: 0.55;
}

.hero h1 {
  margin: 16px 0 18px;
  font-family: var(--serif);
  font-size: clamp(3rem, 6vw, 4.8rem);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.hero > p {
  max-width: 650px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: clamp(1.05rem, 2vw, 1.28rem);
  line-height: 1.5;
}

.hero-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 17px;
  margin-top: 24px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.hero-meta i { width: 28px; height: 1px; background: var(--line-dark); }

.workspace {
  position: relative;
  padding: 48px max(24px, calc((100vw - 1180px) / 2)) 90px;
  background: var(--paper);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.workspace::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}

.workspace > * { position: relative; }

.subscription-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  margin-bottom: 34px;
  padding: 24px 28px;
  border: 1px solid #cdbb9f;
  border-radius: 18px;
  background: linear-gradient(120deg, #f5ead9, #fffaf1);
  box-shadow: 0 12px 35px rgba(91, 65, 37, 0.08);
}
.subscription-card h2 { margin: 6px 0 5px; font-family: var(--serif); font-size: 1.65rem; font-weight: 600; }
.subscription-card p { margin: 0; color: var(--ink-soft); font-size: 0.82rem; }
.subscription-card .subscription-status { margin: 5px 0; font-weight: 700; }
.subscription-card .subscription-status.active { color: var(--accent-dark); }
.subscription-card .auth-message { grid-column: 2; text-align: center; }
.subscriber-pill { background: #e4ecdf; color: #42613c; }

.workspace-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 48px;
  margin-bottom: 26px;
}

.workspace-heading h2 {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 600;
  letter-spacing: -0.04em;
}

.workspace-heading > p {
  max-width: 405px;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  grid-template-rows: repeat(2, 1fr);
  gap: 22px;
  align-items: stretch;
}

.panel {
  min-height: 0;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
}

.upload-panel { grid-column: 1; grid-row: 1; }
.selection-panel { grid-column: 2; grid-row: 1; }
.review-panel { grid-column: 1; grid-row: 2; }
.generate-panel { grid-column: 2; grid-row: 2; }

.step-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 25px;
}

.step-number {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--serif);
  font-size: 0.8rem;
  font-weight: 700;
}

.step-heading h3 {
  margin: -2px 0 3px;
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.step-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}


.source-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--paper-deep);
}
.source-tab {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.source-tab.active {
  background: var(--paper);
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(75, 55, 32, 0.09);
}
.video-audio-settings { display: grid; gap: 12px; margin-top: 20px; }
.video-audio-settings[hidden] { display: none; }
.toggle-setting {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: var(--paper);
  cursor: pointer;
}
.toggle-setting > span:first-child { display: flex; flex-direction: column; gap: 4px; }
.toggle-setting strong { font-size: 0.8rem; }
.toggle-setting small { color: var(--muted); font-size: 0.72rem; line-height: 1.45; }
.toggle-setting input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-control {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #d9d0c2;
  transition: background 150ms ease;
}
.toggle-control::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgba(54, 42, 28, 0.25);
  transition: transform 150ms ease;
}
.toggle-setting input:checked + .toggle-control { background: var(--accent); }
.toggle-setting input:checked + .toggle-control::after { transform: translateX(18px); }
.toggle-setting input:focus-visible + .toggle-control { box-shadow: 0 0 0 3px rgba(138, 87, 47, 0.18); }
.toggle-setting.disabled { cursor: not-allowed; opacity: 0.55; }

.video-media-note {
  margin: 20px 0 0;
  border-left: 3px solid var(--accent);
  padding: 10px 13px;
  background: var(--accent-pale);
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.5;
}
.word-content { min-width: 0; }
.word-still {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 16 / 9;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper-deep);
  object-fit: cover;
}
.timestamp {
  display: inline-block;
  margin-left: 7px;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.dropzone {
  display: flex;
  min-height: 210px;
  padding: 28px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line-dark);
  border-radius: 16px;
  background: rgba(239, 232, 220, 0.42);
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone:hover {
  border-color: var(--accent);
  background: var(--accent-pale);
  transform: translateY(-1px);
}

.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload-icon { display: grid; place-items: center; width: 47px; height: 47px; margin-bottom: 14px; border-radius: 50%; background: var(--paper); color: var(--accent); box-shadow: 0 5px 18px rgba(75, 55, 32, 0.09); }
.upload-icon svg { width: 23px; height: 23px; }
.dropzone strong { color: var(--ink); font-family: var(--serif); font-size: 1.06rem; }
.dropzone > span:not(.upload-icon) { margin-top: 2px; font-size: 0.81rem; }
.dropzone small { max-width: 100%; margin-top: 15px; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.03em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  min-height: 48px;
  border: 0;
  border-radius: 9px;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.025em;
  text-decoration: none;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.button svg { width: 18px; height: 18px; transition: transform 160ms ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(75, 48, 27, 0.18); }
.button:hover:not(:disabled) svg { transform: translateX(2px); }
.button:disabled { cursor: wait; opacity: 0.58; }
.button-primary { color: #fffaf2; background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-dark); }
.upload-panel > .button { width: 100%; margin-top: 14px; }

.source {
  margin: 14px 0 0;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--paper-deep);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 0.79rem;
}
.source:empty { display: none; }
.transcript-selection { margin-top: 18px; }
.transcript-selection-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.transcript-selection-heading h4 { margin: 4px 0 0; font-family: var(--serif); font-size: 1.25rem; }
.selectable-transcript { max-height: 280px; white-space: pre-wrap; font-family: var(--serif); font-size: 1rem; line-height: 2.15; }
.transcript-token { border-bottom-style: dashed; border-bottom-color: var(--accent); }
.transcript-token.is-known { border-bottom-color: #328064; background: rgba(50, 128, 100, 0.13); color: #205d49; }
.transcript-token.is-selected { border-radius: 5px; background: var(--accent); color: #fffaf2; box-shadow: 0 0 0 2px rgba(138, 87, 47, 0.15); }
.transcript-selection-actions { display: grid; gap: 10px; margin-top: 12px; }
.transcript-selection-actions .button { width: 100%; }

.words-container { display: grid; gap: 10px; }
.empty-state { display: flex; min-height: 360px; padding: 36px; flex-direction: column; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 16px; background: rgba(239, 232, 220, 0.34); text-align: center; }
.empty-state > span { display: grid; place-items: center; width: 62px; height: 62px; margin-bottom: 18px; border: 1px solid var(--line-dark); border-radius: 50%; color: var(--accent); font-family: var(--serif); font-size: 1.55rem; }
.empty-state strong { font-family: var(--serif); font-size: 1.08rem; }
.empty-state p { max-width: 280px; margin: 7px 0 0; color: var(--muted); font-size: 0.8rem; }

.word-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 13px;
  width: 100%;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms ease;
}
.word-row:hover { border-color: var(--line-dark); transform: translateY(-1px); }
.word-row.selected { border-color: var(--accent); background: var(--accent-pale); }
.word-row input[type="checkbox"] { appearance: none; display: grid; place-items: center; width: 19px; height: 19px; margin: 2px 0 0; border: 1px solid var(--line-dark); border-radius: 5px; background: var(--paper); }
.word-row input[type="checkbox"]::after { content: ""; width: 9px; height: 5px; margin-top: -2px; border: solid white; border-width: 0 0 2px 2px; opacity: 0; transform: rotate(-45deg); }
.word-row input[type="checkbox"]:checked { border-color: var(--accent); background: var(--accent); }
.word-row input[type="checkbox"]:checked::after { opacity: 1; }
.ignore-word-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: -5px -5px 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: 400 1.35rem/1 var(--sans);
  transition: color 150ms ease, background 150ms ease;
}
.ignore-word-button:hover { color: var(--ink); background: var(--paper-deep); }
.ignore-word-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ignore-word-button:disabled { cursor: wait; opacity: 0.45; }
.word-main { margin-bottom: 4px; font-family: var(--serif); font-size: 1rem; font-weight: 700; }
.word-sub { color: var(--muted); font-size: 0.78rem; line-height: 1.45; }
.vocabulary-status { display: inline-flex; margin-left: 7px; padding: 2px 7px; border-radius: 999px; font-family: var(--sans); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; vertical-align: middle; }
.vocabulary-status.status-new { color: #475569; background: #e2e8f0; }
.vocabulary-status.status-learning { color: #92400e; background: #fef3c7; }
.vocabulary-status.status-known { color: #166534; background: #dcfce7; }
.vocabulary-status.status-ignored { color: #64748b; background: #f1f5f9; }
.save-vocabulary-button { display: block; margin-top: 10px; border: 0; border-bottom: 1px solid currentColor; padding: 0; background: transparent; color: var(--accent-dark); cursor: pointer; font-size: 0.72rem; font-weight: 750; }
.save-vocabulary-button.is-saved { color: var(--success); cursor: default; }
.save-vocabulary-button:disabled { cursor: wait; opacity: 0.55; }

.vocabulary-page { min-height: 620px; padding: 52px max(24px, calc((100vw - 1180px) / 2)) 90px; border-top: 1px solid var(--line); background: var(--paper); }
.vocabulary-page-heading { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 28px; }
.vocabulary-page-heading h2 { margin: 7px 0 6px; font-family: var(--serif); font-size: clamp(2.4rem, 5vw, 4rem); font-weight: 600; letter-spacing: -0.05em; }
.vocabulary-page-heading p { max-width: 620px; margin: 0; color: var(--muted); }
.vocabulary-toolbar { display: grid; grid-template-columns: auto minmax(220px, 420px) 1fr; align-items: center; gap: 12px; margin-bottom: 22px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-deep); }
.vocabulary-toolbar label { color: var(--ink-soft); font-size: 0.74rem; font-weight: 750; }
.vocabulary-toolbar input { height: 42px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; outline: none; background: #fff; color: var(--ink); }
.vocabulary-toolbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 87, 47, 0.1); }
.vocabulary-toolbar .selection-count { justify-self: end; }
.vocabulary-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.vocabulary-list .empty-state, .vocabulary-loading { grid-column: 1 / -1; }
.vocabulary-loading { color: var(--muted); text-align: center; }
.vocabulary-card { display: flex; min-height: 150px; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: #fffdf8; box-shadow: 0 8px 28px rgba(60, 48, 34, 0.06); }
.vocabulary-card h3 { margin: 8px 0 2px; font-family: var(--serif); font-size: 1.55rem; line-height: 1.1; }
.vocabulary-card p { margin: 0; color: var(--accent-dark); font-size: 0.85rem; }
.vocabulary-language { color: var(--muted); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.vocabulary-card-meta { display: flex; align-items: flex-end; flex-direction: column; gap: 10px; }
.vocabulary-card-meta small { color: var(--muted); font-size: 0.67rem; white-space: nowrap; }
.remove-vocabulary-button { display: grid; width: 28px; height: 28px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.25rem; line-height: 1; }
.remove-vocabulary-button:hover { background: var(--paper-deep); color: var(--ink); }
.remove-vocabulary-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.remove-vocabulary-button:disabled { cursor: wait; opacity: 0.45; }

.generate-panel { position: relative; padding-bottom: 26px; }
.generate-panel .step-heading { margin-bottom: 28px; }
.generate-heading { padding-right: 58px; }
.audio-settings-cog {
  position: absolute;
  top: 22px;
  right: 22px;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line-dark);
  border-radius: 50%;
  background: var(--paper);
  color: var(--accent);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  box-shadow: 0 5px 16px rgba(75, 55, 32, 0.08);
  transition: background 160ms ease, color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.audio-settings-cog:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 9px 22px rgba(75, 48, 27, 0.15); }
.audio-settings-cog:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.audio-settings-cog[hidden] { display: none; }
.field label { display: block; margin-bottom: 8px; color: var(--ink); font-size: 0.73rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.field input, .select-input { width: 100%; height: 49px; margin: 0; border: 1px solid var(--line); border-radius: 9px; padding: 0 14px; outline: none; background: var(--paper); color: var(--ink); transition: border-color 150ms ease, box-shadow 150ms ease; }
.field input:focus, .select-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 87, 47, 0.1); }
.deck-field { margin-bottom: 20px; }
.field-label { display: block; margin-bottom: 5px; color: var(--ink); font-size: 0.73rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.deck-settings-summary,
.audio-settings-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper-deep); }
.deck-settings-summary > div,
.audio-settings-summary > div { display: flex; min-width: 0; flex-direction: column; }
.deck-settings-summary strong,
.audio-settings-summary strong { font-family: var(--serif); }
.deck-settings-summary small,
.audio-settings-summary small { margin-top: 3px; color: var(--muted); font-size: 0.72rem; }
.button-secondary { border: 1px solid var(--line-dark); background: var(--paper); color: var(--ink); }
.select-wrap { position: relative; }
.select-wrap::after { content: "⌄"; position: absolute; right: 14px; top: 10px; color: var(--accent); pointer-events: none; }
.select-input { appearance: none; padding-right: 38px; }
.helper-text { margin: 7px 0 0; color: var(--muted); font-size: 0.75rem; }

.generate-footer { display: flex; justify-content: space-between; align-items: center; gap: 30px; margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.format-note { display: flex; align-items: center; gap: 12px; }
.format-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; background: var(--accent-pale); color: var(--accent); font-family: var(--serif); font-weight: 800; }
.format-note div { display: flex; flex-direction: column; }
.format-note strong { font-family: var(--serif); font-size: 0.9rem; }
.format-note small { color: var(--muted); font-size: 0.7rem; }
.button-generate { min-width: 210px; }

.deck-settings-dialog { width: min(920px, calc(100% - 32px)); max-height: calc(100vh - 40px); margin: auto; overflow: auto; border: 1px solid var(--line); border-radius: 20px; padding: 0; background: var(--paper); color: var(--ink); box-shadow: 0 28px 90px rgba(35, 28, 21, 0.3); }
.deck-settings-dialog::backdrop { background: rgba(36, 33, 29, 0.58); backdrop-filter: blur(3px); }
.deck-settings-dialog form { padding: 28px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 5px 0 4px; font-family: var(--serif); font-size: 2rem; }
.dialog-heading p { margin: 0; color: var(--muted); font-size: 0.84rem; }
.dialog-close { width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--paper-deep); color: var(--ink); cursor: pointer; font-size: 1.5rem; line-height: 1; }
.template-fields { display: grid; gap: 18px; padding: 22px 0; }
.voice-settings { margin: 0; border: 1px solid var(--line); border-radius: 11px; padding: 16px; background: var(--paper-deep); }
.voice-settings legend { padding: 0 6px; color: var(--ink); font-size: 0.73rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; }
.voice-settings > p { margin: 0 0 12px; color: var(--muted); font-size: 0.75rem; }
.voice-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.voice-options label { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: var(--paper); cursor: pointer; }
.voice-options input { accent-color: var(--accent); }
.voice-options span { display: flex; flex-direction: column; gap: 2px; }
.voice-options strong { font-size: 0.8rem; }
.voice-options small { color: var(--muted); font-size: 0.7rem; }
.template-editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.template-fields textarea { width: 100%; min-height: 210px; resize: vertical; border: 1px solid var(--line); border-radius: 9px; padding: 12px; outline: none; background: #fff; color: var(--ink); font: 0.76rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.template-fields textarea.styling-editor { min-height: 180px; }
.template-fields textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 87, 47, 0.1); }
.template-help { margin: 0; color: var(--muted); font-size: 0.76rem; line-height: 1.7; }
.template-help code { padding: 2px 4px; border-radius: 4px; background: var(--paper-deep); color: var(--accent-dark); }
.deck-settings-actions { display: flex; align-items: center; gap: 14px; padding-top: 20px; border-top: 1px solid var(--line); }
.deck-settings-actions .button-primary { margin-left: auto; }
.save-preference { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 0.78rem; cursor: pointer; }
.save-preference input { accent-color: var(--accent); }

.status { margin-top: 15px; color: var(--ink-soft); font-size: 0.8rem; }
.status:empty { display: none; }
.error-output { margin: 14px 0 0; max-height: 260px; overflow: auto; white-space: pre-wrap; border: 1px solid #d6aaa2; border-radius: 10px; padding: 13px; background: #f8eae6; color: #783d35; font-family: var(--sans); font-size: 0.78rem; }
.progress { margin-top: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper-deep); }
.progress-topline { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; color: var(--ink-soft); font-size: 0.76rem; }
.progress-track { width: 100%; height: 7px; overflow: hidden; border-radius: 999px; background: #d9d0c2; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.35s ease; }

footer { width: min(1180px, calc(100% - 48px)); min-height: 100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 0.75rem; }
footer span { color: var(--ink); font-weight: 750; }
footer p { margin: 0; font-family: var(--serif); font-style: italic; }

@media (max-width: 800px) {
  .subscription-card { grid-template-columns: 1fr; }
  .subscription-card .button { width: 100%; }
  .subscription-card .auth-message { grid-column: 1; }
  .topbar { grid-template-columns: 1fr auto; width: min(100% - 32px, 1180px); }
  .subtitle { display: none; }
  .hero { width: min(100% - 32px, 920px); padding: 42px 0 38px; }
  .hero h1 { font-size: clamp(2.8rem, 13vw, 4.2rem); }
  .workspace { padding: 42px 16px 64px; }
  .workspace-heading { display: block; }
  .workspace-heading > p { margin-top: 15px; }
  .workflow-grid { grid-template-columns: 1fr; grid-template-rows: none; }
  .upload-panel, .selection-panel, .review-panel, .generate-panel { grid-column: 1; grid-row: auto; }
  .review-panel { min-height: 0; }
}

@media (max-width: 520px) {
  .topbar { min-height: 72px; }
  .header-badge { font-size: 0; }
  .header-badge span { width: 8px; height: 8px; }
  .hero { text-align: left; }
  .eyebrow::before { display: none; }
  .eyebrow::after { width: 25px; margin-left: 10px; }
  .hero h1 { margin-top: 17px; }
  .hero > p { font-family: var(--sans); font-size: 0.96rem; line-height: 1.6; }
  .hero-meta { justify-content: flex-start; gap: 8px; font-size: 0.62rem; }
  .hero-meta i { width: 12px; }
  .panel { padding: 23px 19px; border-radius: 17px; }
  .step-heading { gap: 12px; }
  .step-heading p { font-size: 0.78rem; }
  .dropzone { min-height: 190px; padding: 20px; }
  .generate-heading { padding-right: 50px; }
  .audio-settings-cog { top: 18px; right: 18px; }
  .generate-footer { align-items: stretch; flex-direction: column; }
  .deck-settings-summary,
  .audio-settings-summary { align-items: stretch; flex-direction: column; }
  .template-editor-grid { grid-template-columns: 1fr; }
  .deck-settings-dialog form { padding: 21px 17px; }
  .deck-settings-actions { align-items: stretch; flex-direction: column; }
  .deck-settings-actions .button-primary { width: 100%; margin-left: 0; }
  .voice-options { grid-template-columns: 1fr; }
  .button-generate { width: 100%; }
  footer { width: calc(100% - 32px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

.account-summary {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.credit-pill {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 0.76rem;
  white-space: nowrap;
}
.credit-pill strong { color: var(--accent-dark); }
.text-button { padding: 0; border: 0; border-bottom: 1px solid currentColor; background: transparent; color: var(--accent-dark); cursor: pointer; font-size: 0.76rem; }
.account-menu { position: relative; }
.account-menu-button {
  display: inline-flex;
  height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px 3px 4px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 750;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.account-menu-button:hover, .account-menu-button[aria-expanded="true"] { border-color: var(--line-dark); background: #fffdf8; box-shadow: 0 5px 16px rgba(60, 48, 34, 0.08); }
.account-menu-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.account-menu-button svg { width: 14px; height: 14px; color: var(--muted); transition: transform 150ms ease; }
.account-menu-button[aria-expanded="true"] svg { transform: rotate(180deg); }
.account-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: var(--serif);
  font-size: 0.78rem;
}
.account-menu-dropdown {
  position: absolute;
  z-index: 20;
  top: calc(100% + 9px);
  right: 0;
  width: 286px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 7px;
  background: #fffdf8;
  box-shadow: 0 20px 50px rgba(47, 37, 26, 0.16);
}
.account-menu-identity { min-width: 0; padding: 10px 11px 12px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.account-menu-identity span { display: block; margin-bottom: 2px; color: var(--muted); font-size: 0.63rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.account-email { display: block; overflow: hidden; color: var(--ink); font-size: 0.76rem; text-overflow: ellipsis; white-space: nowrap; }
.account-menu-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 9px;
  padding: 9px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
.account-menu-item:hover, .account-menu-item:focus-visible { outline: none; background: var(--paper-deep); }
.account-menu-item > span:last-child { display: flex; min-width: 0; flex-direction: column; }
.account-menu-item strong { font-size: 0.77rem; }
.account-menu-item small { margin-top: 1px; color: var(--muted); font-size: 0.66rem; }
.account-menu-icon { display: grid; flex: 0 0 auto; width: 30px; height: 30px; place-items: center; border-radius: 8px; background: var(--accent-pale); color: var(--accent-dark); font-family: var(--serif); font-size: 0.76rem; font-weight: 750; }
.account-menu-divider { height: 1px; margin: 5px 4px; background: var(--line); }
.account-menu-signout { justify-content: center; padding: 8px; color: var(--muted); font-size: 0.72rem; font-weight: 750; }
#historyList { grid-template-columns: 1fr; gap: 20px; }
.history-card { display: block; padding: 26px; }
.history-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.history-card-title { min-width: 0; }
.history-card-content { min-width: 0; }
.history-card small { display: block; margin-top: 6px; color: var(--muted); }
.history-card .button { flex: 0 0 auto; }
.history-card-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.history-delete-button { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: 1.35rem; line-height: 1; cursor: pointer; }
.history-delete-button:hover, .history-delete-button:focus-visible { border-color: #ef4444; color: #b91c1c; background: #fff1f2; }
.history-delete-button:disabled { cursor: progress; opacity: 0.6; }
.history-previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; margin-top: 24px; }
.history-preview { display: grid; grid-template-columns: minmax(150px, 38%) minmax(0, 1fr); gap: 18px; min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.history-preview img { width: 100%; aspect-ratio: 1; border-radius: 11px; object-fit: cover; }
.history-preview-copy { min-width: 0; }
.history-preview strong, .history-preview span { display: block; }
.history-preview strong { font-family: var(--serif); font-size: 1.18rem; line-height: 1.2; }
.history-preview span { margin-top: 2px; color: var(--muted); font-size: 0.72rem; }
.history-preview p { margin-top: 7px; color: var(--ink); line-height: 1.5; }
.history-preview blockquote { margin: 10px 0 0; color: var(--ink-soft); font-size: 0.78rem; line-height: 1.55; }
.history-preview small { margin-top: 3px; }

@media (max-width: 640px) {
  .history-card { padding: 20px; }
  .history-card-header { flex-direction: column; }
  .history-card-header .button { width: 100%; }
  .history-card-actions { width: 100%; }
  .history-previews { margin-top: 20px; }
  .history-preview { grid-template-columns: 1fr; padding: 14px; }
  .history-preview img { max-height: 320px; }
}

.auth-panel {
  width: min(920px, calc(100% - 48px));
  margin: 0 auto 72px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr);
  gap: 48px;
  align-items: center;
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.auth-copy h2 { margin: 8px 0 12px; font-family: var(--serif); font-size: clamp(2rem, 4vw, 3rem); font-weight: 600; letter-spacing: -0.04em; line-height: 1.05; }
.auth-copy p { margin: 0; color: var(--ink-soft); }
.auth-form { display: grid; gap: 9px; }
.auth-form label { color: var(--ink-soft); font-size: 0.75rem; font-weight: 750; }
.auth-form input { width: 100%; height: 48px; border: 1px solid var(--line); border-radius: 9px; padding: 0 13px; outline: none; background: #fff; color: var(--ink); }
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 87, 47, 0.1); }
.auth-form .button { width: 100%; margin-top: 8px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 8px; padding: 4px; border-radius: 10px; background: var(--paper-deep); }
.auth-tab { border: 0; border-radius: 7px; padding: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 0.78rem; font-weight: 750; }
.auth-tab.active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 4px rgba(60, 48, 34, 0.1); }
.auth-message { min-height: 1.3em; margin: 2px 0 0; color: var(--success); font-size: 0.78rem; }
.auth-message.error { color: #8a3f35; }

@media (max-width: 800px) {
  .auth-panel { width: min(100% - 32px, 920px); grid-template-columns: 1fr; gap: 28px; margin-bottom: 48px; }
  .account-summary { gap: 8px; }
  .vocabulary-page-heading { align-items: flex-start; flex-direction: column; }
  .vocabulary-toolbar { grid-template-columns: 1fr auto; }
  .vocabulary-toolbar label { grid-column: 1 / -1; }
  .vocabulary-toolbar input { min-width: 0; }
}

@media (max-width: 520px) {
  .auth-panel { padding: 24px 20px; }
  .credit-pill { font-size: 0.7rem; }
  .subscriber-pill { display: none; }
  .account-menu-label { display: none; }
  .account-menu-button { padding-right: 7px; }
  .account-menu-dropdown { position: fixed; top: 66px; right: 16px; width: min(286px, calc(100vw - 32px)); }
  .text-button { font-size: 0.7rem; }
  .vocabulary-page { padding: 38px 16px 60px; }
  .vocabulary-page-heading .button { width: 100%; }
  .vocabulary-toolbar { grid-template-columns: 1fr; }
  .vocabulary-toolbar .selection-count { justify-self: start; }
}

.card-showcase {
  position: relative;
  padding: 52px 0 64px;
  border-top: 1px solid rgba(108, 93, 74, 0.16);
  border-bottom: 1px solid rgba(108, 93, 74, 0.16);
  background: var(--paper-deep);
}

.card-showcase::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.3;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
}

.showcase-heading {
  position: relative;
  width: min(1040px, calc(100% - 48px));
  margin: 0 auto 30px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.8fr);
  align-items: end;
  gap: 56px;
}

.showcase-heading h2 {
  max-width: 600px;
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1.04;
}

.showcase-heading p {
  margin: 0 0 4px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.65;
}

.demo-workspace {
  position: relative;
  width: min(1040px, calc(100% - 48px));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(108, 93, 74, 0.2);
  border-radius: 24px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: 0 24px 70px rgba(66, 51, 33, 0.13);
}

.demo-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(239, 233, 221, 0.66);
}

.demo-step {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.demo-step:not(:last-child)::after { content: "→"; margin-left: 5px; color: rgba(108, 93, 74, 0.38); }
.demo-step b { display: grid; width: 21px; height: 21px; place-items: center; border: 1px solid rgba(108, 93, 74, 0.3); border-radius: 50%; font-size: 0.62rem; }
.demo-step.is-active { color: var(--accent-dark); }
.demo-step.is-active b { border-color: var(--accent); background: var(--accent); color: #fff; }

.demo-grid { display: grid; grid-template-columns: minmax(0, 1.16fr) minmax(340px, 0.84fr); }
.demo-video-panel { padding: 24px; border-right: 1px solid var(--line); background: #25221e; }
.demo-video-frame { position: relative; overflow: hidden; border-radius: 15px; background: #111; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.25); }
.demo-video-frame video { display: block; width: 100%; aspect-ratio: 16 / 10; background: #111; object-fit: cover; }
.demo-video-label { position: absolute; top: 12px; left: 12px; padding: 6px 9px; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 999px; background: rgba(20, 18, 16, 0.72); color: rgba(255, 255, 255, 0.82); font-size: 0.61rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; backdrop-filter: blur(8px); }
.demo-video-hint { margin: 14px 2px 0; color: rgba(255, 255, 255, 0.55); font-size: 0.68rem; }
.demo-video-hint span { margin-right: 5px; color: #d2a678; }

.demo-transcript-panel { display: flex; min-width: 0; flex-direction: column; padding: 27px 26px 24px; }
.demo-panel-heading, .deck-result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.demo-panel-heading h3, .deck-result-heading h3 { margin: 5px 0 0; font-family: var(--serif); font-size: 1.65rem; font-weight: 600; letter-spacing: -0.035em; }
.selection-count { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; background: #e9dfcf; color: var(--accent-dark); font-size: 0.66rem; font-weight: 800; }

.transcript-lines { margin: 20px 0 17px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-deep); }
.transcript-lines p { margin: 0; font-family: var(--serif); font-size: 1rem; line-height: 2.25; }
.transcript-lines p + p { border-top: 1px solid rgba(108, 93, 74, 0.12); }
.transcript-lines .timestamp { display: inline-block; width: 42px; color: var(--muted); font-family: var(--sans); font-size: 0.61rem; vertical-align: 2px; }
.vocab-token { position: relative; border: 0; border-bottom: 1px dashed var(--accent); padding: 2px 3px; background: transparent; color: inherit; cursor: pointer; font: inherit; transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease; }
.vocab-token:hover { background: rgba(138, 87, 47, 0.1); }
.vocab-token:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.vocab-token.is-selected { border-bottom-color: transparent; border-radius: 5px; background: var(--accent); color: #fff; box-shadow: 0 3px 9px rgba(102, 60, 27, 0.2); }

.demo-word-list { display: grid; gap: 5px; margin-bottom: 18px; }
.demo-word-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) 20px; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; color: var(--muted); opacity: 0.46; transition: opacity 160ms ease, background 160ms ease; }
.demo-word-row > span:first-child { color: var(--ink); font-family: var(--serif); font-size: 0.98rem; }
.demo-word-row small { overflow: hidden; font-size: 0.65rem; text-overflow: ellipsis; white-space: nowrap; }
.word-check { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.66rem; opacity: 0; transform: scale(0.7); transition: opacity 160ms ease, transform 160ms ease; }
.demo-word-row.is-selected { background: rgba(138, 87, 47, 0.08); opacity: 1; }
.demo-word-row.is-selected .word-check { opacity: 1; transform: scale(1); }
.demo-create-button { width: 100%; margin-top: auto; }
.demo-create-button span { color: rgba(255, 255, 255, 0.68); font-weight: 600; }
.demo-selection-message { min-height: 1.1em; margin: 7px 0 -8px; color: #8a3f35; font-size: 0.68rem; text-align: center; }

.demo-deck-result { padding: 30px; border-top: 1px solid var(--line); background: #f7f1e7; }
.demo-deck-result:focus { outline: none; }
.deck-ready-badge { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border-radius: 999px; background: #e4ecdf; color: #42613c; font-size: 0.67rem; font-weight: 800; }
.deck-ready-badge span { display: grid; width: 17px; height: 17px; place-items: center; border-radius: 50%; background: #5d7a55; color: white; }
.deck-result-copy { margin: 8px 0 22px; color: var(--ink-soft); font-size: 0.82rem; }
.demo-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 340px)); justify-content: center; align-items: start; gap: 24px; }

.anki-card-back {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: #171614;
  color: #fff;
  box-shadow: 0 14px 34px rgba(49, 39, 28, 0.18);
  text-align: center;
}
.anki-card-topline { display: flex; align-items: center; justify-content: space-between; color: rgba(255, 255, 255, 0.48); font-size: 0.55rem; font-weight: 750; letter-spacing: 0.13em; text-transform: uppercase; }
.audio-cue { display: inline-flex; align-items: center; gap: 4px; }
.audio-cue svg { width: 13px; height: 13px; color: #d2a678; }
.anki-prompt { padding: 15px 5px 13px; border-bottom: 1px solid rgba(255, 255, 255, 0.2); font-family: var(--serif); font-size: 1.65rem; line-height: 1; }
.anki-answer { padding-top: 13px; }
.anki-answer strong { display: block; color: #f4eadc; font-family: var(--serif); font-size: 0.94rem; font-weight: 500; line-height: 1.25; }
.anki-reading { display: block; margin-top: 4px; color: #d2a678; font-size: 0.83rem; }
.anki-answer p { margin: 10px 0 4px; font-family: var(--serif); font-size: 0.86rem; line-height: 1.4; }
.anki-answer small { display: block; min-height: 34px; color: rgba(255, 255, 255, 0.62); font-size: 0.61rem; line-height: 1.4; }
.anki-answer img { display: block; width: 100%; height: auto; max-width: 100%; margin-top: 11px; border-radius: 9px; object-fit: contain; }
.demo-edit-button { display: block; margin: 22px auto 0; }

@media (max-width: 900px) {
  .demo-grid { grid-template-columns: 1fr; }
  .demo-video-panel { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (max-width: 800px) {
  .card-showcase { padding: 42px 0 48px; }
  .showcase-heading, .demo-workspace { width: min(100% - 32px, 1040px); }
  .showcase-heading { grid-template-columns: 1fr; gap: 15px; }
  .showcase-heading p { max-width: 600px; }
}

@media (max-width: 520px) {
  .showcase-heading { margin-bottom: 22px; }
  .showcase-heading h2 { font-size: 2.15rem; }
  .showcase-heading p { font-size: 0.84rem; }
  .demo-workspace { border-radius: 17px; }
  .demo-steps { justify-content: center; padding: 11px 8px; }
  .demo-step { gap: 4px; font-size: 0.55rem; letter-spacing: 0.03em; }
  .demo-step:not(:last-child)::after { margin-left: 1px; }
  .demo-step b { width: 18px; height: 18px; }
  .demo-video-panel { padding: 14px; }
  .demo-video-hint { line-height: 1.5; }
  .demo-transcript-panel { padding: 22px 17px 19px; }
  .demo-panel-heading h3, .deck-result-heading h3 { font-size: 1.42rem; }
  .transcript-lines { padding: 11px; }
  .transcript-lines p { font-size: 0.93rem; }
  .transcript-lines .timestamp { display: block; width: auto; height: 18px; }
  .demo-word-row { grid-template-columns: 58px minmax(0, 1fr) 20px; }
  .demo-deck-result { padding: 23px 16px; }
  .deck-result-heading { display: block; }
  .deck-ready-badge { margin-top: 12px; }
  .demo-card-grid { grid-template-columns: minmax(0, 290px); }
}

@media (prefers-reduced-motion: reduce) {
  .vocab-token, .demo-word-row, .word-check { transition: none; }
}

.audio-settings-dialog .checkbox-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--ink-soft); font-size: 0.82rem; font-weight: 700; }
.audio-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.audio-settings-grid label { display: flex; flex-direction: column; gap: 6px; color: var(--ink-soft); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; }
.audio-settings-grid input { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; background: #fffdf8; color: var(--ink); font: inherit; }
.audio-balancing-fields.disabled { opacity: 0.55; }
.kanji-toolbar { grid-template-columns: 1fr auto; }
.kanji-pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.kanji-pagination .button { min-height: 40px; padding: 0 14px; }
.kanji-pagination .button:disabled { cursor: not-allowed; opacity: 0.48; }
.kanji-list { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.kanji-detail-content { display: grid; grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); gap: 18px; align-items: start; }
.kanji-detail-card, .kanji-radical-panel { border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow-soft); padding: 24px; }
.kanji-detail-symbol { margin-top: 12px; font-size: clamp(5rem, 18vw, 9rem); font-weight: 800; line-height: 0.95; }
.kanji-detail-meaning { margin: 18px 0 0; color: var(--ink-soft); font-size: 1.2rem; font-weight: 800; }
.kanji-radical-panel h3 { margin: 0 0 16px; font-size: 1.4rem; }
.kanji-radical-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kanji-radical-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 16px; background: #fffdf8; padding: 14px; }
.kanji-radical-card strong { font-size: 2rem; line-height: 1; }
.kanji-radical-card span { color: var(--ink-soft); font-size: 0.92rem; font-weight: 700; line-height: 1.35; }
.kanji-card { min-height: 185px; }
.kanji-card-link { color: inherit; text-decoration: none; transition: transform 0.18s ease, box-shadow 0.18s ease; }
.kanji-card-link:hover, .kanji-card-link:focus-visible { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(74, 55, 31, 0.14); }
.kanji-card-link:focus-visible { outline: 3px solid rgba(163, 107, 43, 0.35); outline-offset: 3px; }
.kanji-card h3 { font-size: 3.2rem; line-height: 1; }
.kanji-radicals { margin-top: 14px; color: var(--ink-soft); font-size: 0.78rem; line-height: 1.45; }
@media (max-width: 720px) {
  .kanji-toolbar { grid-template-columns: 1fr; }
  .kanji-pagination { justify-content: flex-start; }
  .kanji-detail-content { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kanji-list { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .kanji-card { min-height: 0; gap: 6px; padding: 8px 5px; border-radius: 10px; }
  .kanji-card h3 { margin-top: 5px; font-size: clamp(1.45rem, 10vw, 2.2rem); }
  .kanji-card p { font-size: 0.62rem; line-height: 1.15; }
  .kanji-radicals { margin-top: 7px; font-size: 0.52rem; line-height: 1.25; }
}
.kanji-generate-button { width: 100%; margin-top: 22px; }
.kanji-card-status { min-height: 1.4em; margin-top: 12px; }

.kanji-meaning-form { display: grid; gap: 12px; margin-top: 18px; }
.kanji-meaning-form label, .kanji-radical-edit-card label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; }
.meaning-edit-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.kanji-meaning-form input, .kanji-radical-edit-card input { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 10px 11px; background: #fffdf8; color: var(--ink); font: inherit; text-transform: none; letter-spacing: normal; font-weight: 600; }
.kanji-meaning-form input.is-locked, .kanji-radical-edit-card input.is-locked { background: #ede8df; color: var(--muted); border-color: #d5cec1; cursor: default; }
.kanji-meaning-form input:focus, .kanji-radical-edit-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 87, 47, 0.1); outline: none; }
.meaning-edit-toggle { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line-dark); border-radius: 999px; background: #fffaf1; color: var(--accent-dark); cursor: pointer; font-weight: 900; line-height: 1; }
.meaning-edit-toggle:hover, .meaning-edit-toggle:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 87, 47, 0.1); outline: none; }
.meaning-edit-hint { margin: -4px 0 0; color: var(--muted); font-size: 0.76rem; }
.kanji-meaning-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.meaning-save-button { justify-self: start; }
.kanji-radical-edit-card { grid-template-columns: auto minmax(0, 1fr); }
.kanji-radical-meaning-editor { display: grid; gap: 6px; }
.kanji-radical-edit-card .text-button { grid-column: 2; justify-self: start; }

.generated-kanji-card {
  display: grid;
  gap: 12px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--paper-deep);
}

.generated-kanji-card h3 {
  margin: 0;
}

.generated-kanji-card img {
  width: min(100%, 320px);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}

.generated-kanji-card p,
.kanji-overwrite-warning {
  margin: 0;
}
