/* ===================================================================   Compri design system
   Neutral Daylight and Night, warm brown Paper, and blue Midnight palettes.
   Theme accents style surfaces and controls. Semantic colors retain their meaning.
   ========================================================================== */

.test-home-badge { display:inline-flex; text-decoration:none; color:var(--text); }
.test-home-badge span { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border:1px solid color-mix(in srgb,#8b72d9 45%,var(--border)); border-radius:999px; background:color-mix(in srgb,#8b72d9 12%,var(--bg)); font-size:.8rem; }
:root,
.theme-light,
.theme-system {
  --bg: #f5f5f5;
  --bg-accent: #eeeeee;
  --surface: #ffffff;
  --home-glass-opacity: 53.2%; /* Light glass: 76% × .7; text stays opaque. */
  --surface-subtle: #eeeeee;
  --surface-hover: #f7f7f7;
  --sidebar: #fafafa;
  --text: #202020;
  --text-secondary: #515151;
  --muted: #707070;
  --border: #e2e2e2;
  --border-strong: #c9c9c9;
  --accent: #333333;
  --accent-hover: #181818;
  --accent-soft: #ebebeb;
  --accent-ink: #303030;
  --accent-text: #ffffff;
  --marigold: #8a8a8a;
  --marigold-soft: #eeeeee;
  --marigold-ink: #555555;
  --coral: #777777;
  --coral-soft: #e9e9e9;
  --sky: #666666;
  --sky-soft: #ececec;
  --secondary: #202020;
  --secondary-text: #ffffff;
  --focus: rgba(51, 51, 51, .24);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .05);
  --shadow-raised: 0 2px 6px rgba(0, 0, 0, .06), 0 18px 48px rgba(0, 0, 0, .14);
  --highlight: #dedede;
  --selection: #d4d4d4;
  --scrim: rgba(0, 0, 0, .42);
  color-scheme: light;
}

/* Neutral Night palette, mirrored by Automatic's dark appearance below. */
:root[data-theme="dark"],
.theme-dark {
  --bg: #121212;
  --bg-accent: #181818;
  --surface: #1c1c1c;
  --home-glass-opacity: 82%;
  --surface-subtle: #242424;
  --surface-hover: #2b2b2b;
  --sidebar: #161616;
  --text: #ededed;
  --text-secondary: #bcbcbc;
  --muted: #969696;
  --border: #303030;
  --border-strong: #484848;
  --accent: #d6d6d6;
  --accent-hover: #eeeeee;
  --accent-soft: #303030;
  --accent-ink: #dedede;
  --accent-text: #181818;
  --marigold: #b8b8b8;
  --marigold-soft: #2e2e2e;
  --marigold-ink: #d0d0d0;
  --coral: #a3a3a3;
  --coral-soft: #2c2c2c;
  --sky: #c5c5c5;
  --sky-soft: #2d2d2d;
  --secondary: #ededed;
  --secondary-text: #161616;
  --focus: rgba(214, 214, 214, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .22);
  --shadow-raised: 0 2px 6px rgba(0, 0, 0, .3), 0 20px 50px rgba(0, 0, 0, .45);
  --highlight: #444444;
  --selection: #484848;
  --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"],
  .theme-system {
    --bg: #121212;
    --bg-accent: #181818;
    --surface: #1c1c1c;
    --home-glass-opacity: 82%;
    --surface-subtle: #242424;
    --surface-hover: #2b2b2b;
    --sidebar: #161616;
    --text: #ededed;
    --text-secondary: #bcbcbc;
    --muted: #969696;
    --border: #303030;
    --border-strong: #484848;
    --accent: #d6d6d6;
    --accent-hover: #eeeeee;
    --accent-soft: #303030;
    --accent-ink: #dedede;
    --accent-text: #181818;
    --marigold: #b8b8b8;
    --marigold-soft: #2e2e2e;
    --marigold-ink: #d0d0d0;
    --coral: #a3a3a3;
    --coral-soft: #2c2c2c;
    --sky: #c5c5c5;
    --sky-soft: #2d2d2d;
    --secondary: #ededed;
    --secondary-text: #161616;
    --focus: rgba(214, 214, 214, .3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .22);
    --shadow-raised: 0 2px 6px rgba(0, 0, 0, .3), 0 20px 50px rgba(0, 0, 0, .45);
    --highlight: #444444;
    --selection: #484848;
    --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

:root[data-theme="calm"],
.theme-calm {
  --bg: #f1eadc;
  --bg-accent: #e9ddca;
  --surface: #fbf7ee;
  --home-glass-opacity: 53.2%; /* Light glass: 76% × .7; text stays opaque. */
  --surface-subtle: #ece4d4;
  --surface-hover: #f6f0e3;
  --sidebar: #ece4d4;
  --text: #2e2a22;
  --text-secondary: #5b5446;
  --muted: #847b6b;
  --border: #ddd2bf;
  --border-strong: #c9bba3;
  --accent: #805b3f;
  --accent-hover: #67462f;
  --accent-soft: #eadcc8;
  --accent-ink: #624329;
  --accent-text: #ffffff;
  --marigold: #b78a55;
  --marigold-soft: #f1e3cd;
  --marigold-ink: #77552d;
  --coral: #9b6248;
  --coral-soft: #efddd1;
  --sky: #92745a;
  --sky-soft: #e9ded1;
  --secondary: #2e2a22;
  --secondary-text: #fbf7ee;
  --focus: rgba(128, 91, 63, .24);
  --shadow-sm: 0 1px 2px rgba(62, 49, 35, .06);
  --shadow: 0 1px 2px rgba(62, 49, 35, .05), 0 8px 24px rgba(62, 49, 35, .07);
  --shadow-raised: 0 2px 6px rgba(62, 49, 35, .08), 0 18px 46px rgba(62, 49, 35, .16);
  --highlight: #e4c99d;
  --selection: #dfc9aa;
  --scrim: rgba(46, 42, 34, .4);
  color-scheme: light;
}

:root[data-theme="tokyo-night"],
.theme-tokyo-night {
  --bg: #15161f;
  --bg-accent: #1a1d2c;
  --surface: #1b1d2a;
  --home-glass-opacity: 82%;
  --surface-subtle: #232638;
  --surface-hover: #292d42;
  --sidebar: #13141c;
  --text: #c8d0f5;
  --text-secondary: #a9b1d6;
  --muted: #7f88ad;
  --border: #2e3350;
  --border-strong: #434a6c;
  --accent: #7aa2f7;
  --accent-hover: #93b4fa;
  --accent-soft: #263255;
  --accent-ink: #a9c3fb;
  --accent-text: #11131c;
  --marigold: #e0af68;
  --marigold-soft: #3a3122;
  --marigold-ink: #ecc68f;
  --coral: #f7768e;
  --coral-soft: #3b2230;
  --sky: #7dcfff;
  --sky-soft: #1f3247;
  --secondary: #c8d0f5;
  --secondary-text: #15161f;
  --focus: rgba(122, 162, 247, .3);
  --shadow-sm: 0 1px 2px rgba(5, 5, 12, .3);
  --shadow: 0 1px 2px rgba(5, 5, 12, .3), 0 8px 24px rgba(5, 5, 12, .28);
  --shadow-raised: 0 2px 6px rgba(5, 5, 12, .35), 0 20px 50px rgba(5, 5, 12, .5);
  --highlight: #3d3a5c;
  --selection: #33466e;
  --scrim: rgba(5, 5, 12, .6);
  color-scheme: dark;
}

/* Status and identity colors are independent of decorative theme accents.
   Keep success green, errors red, and hints/corrections gold in every theme. */
:root,
.theme-light,
.theme-calm,
.theme-system {
  --xp: #a32bb4;
  --xp-soft: #f7e8fa;
  --success: #267347;
  --success-soft: #e4f3e9;
  --warning: #bd8414;
  --warning-soft: #fff3cf;
  --warning-ink: #805600;
  --danger: #bb3d36;
  --danger-soft: #fce9e6;
  --danger-text: #ffffff;
}
:root[data-theme="dark"],
:root[data-theme="tokyo-night"],
.theme-dark,
.theme-tokyo-night {
  --xp: #e69aef;
  --xp-soft: #39223e;
  --success: #78cb97;
  --success-soft: #163824;
  --warning: #eab75a;
  --warning-soft: #392d16;
  --warning-ink: #f4cc79;
  --danger: #f08c85;
  --danger-soft: #412521;
  --danger-text: #181818;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"],
  .theme-system {
    --xp: #e69aef;
    --xp-soft: #39223e;
    --success: #78cb97;
    --success-soft: #163824;
    --warning: #eab75a;
    --warning-soft: #392d16;
    --warning-ink: #f4cc79;
    --danger: #f08c85;
    --danger-soft: #412521;
    --danger-text: #181818;
  }
}
/* Experiences drawn over dark scrims (comics, role-play, Speaking Coach) keep the
   complete Night palette in every theme, so buttons, chips and word bubbles inside
   them stay readable on Daylight and Paper too. Their own rules later refine
   surfaces and borders for the glass look. */
.flashcard-stage.comic-stage, .roleplay-stage, .roleplay-panel, .reader-popup.coach-stage {
  --bg: #121212;
  --bg-accent: #181818;
  --surface: #1c1c1c;
  --surface-subtle: #242424;
  --surface-hover: #2b2b2b;
  --sidebar: #161616;
  --text: #ededed;
  --text-secondary: #bcbcbc;
  --muted: #969696;
  --border: #303030;
  --border-strong: #484848;
  --accent: #d6d6d6;
  --accent-hover: #eeeeee;
  --accent-soft: #303030;
  --accent-ink: #dedede;
  --accent-text: #181818;
  --marigold: #b8b8b8;
  --marigold-soft: #2e2e2e;
  --marigold-ink: #d0d0d0;
  --coral: #a3a3a3;
  --coral-soft: #2c2c2c;
  --sky: #c5c5c5;
  --sky-soft: #2d2d2d;
  --secondary: #ededed;
  --secondary-text: #161616;
  --focus: rgba(214, 214, 214, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .22);
  --shadow-raised: 0 2px 6px rgba(0, 0, 0, .3), 0 20px 50px rgba(0, 0, 0, .45);
  --highlight: #444444;
  --selection: #484848;
  --scrim: rgba(0, 0, 0, .6);
  --xp: #e69aef;
  --xp-soft: #39223e;
  --success: #78cb97;
  --success-soft: #163824;
  --warning: #eab75a;
  --warning-soft: #392d16;
  --warning-ink: #f4cc79;
  --danger: #f08c85;
  --danger-soft: #412521;
  --danger-text: #181818;
  color-scheme: dark;
}

:root {
  --avatar-start: #0f7a6a;
  --avatar-end: #397d5b;
  --avatar-text: #ffffff;
}

:root {
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-reading: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Charter, "Noto Serif", Georgia, serif;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ---------- Base ---------- */
/* Keep artwork edge to edge; only controls consume these insets. Floating
   panels read the same resolved values when fitting the visual viewport. */
:root {
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  /* WebKit’s native tap highlight can linger after a canceled long press. */
  -webkit-tap-highlight-color: transparent;
}
/* Use fast taps throughout the app while keeping panning and pinch zoom. */
* { box-sizing: border-box; touch-action: manipulation; }
html, body, #main { min-height: 100%; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--text); line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, h4 { color: var(--text); font-family: inherit; line-height: 1.2; }
h1 { margin-bottom: 10px; font-size: clamp(1.85rem, 3.2vw, 2.45rem); font-weight: 720; letter-spacing: -.028em; }
h2 { margin-bottom: 14px; font-size: 1.22rem; font-weight: 680; letter-spacing: -.015em; }
h3 { margin-bottom: 8px; font-size: 1.05rem; font-weight: 650; }
a { color: var(--accent); }
::selection { background: var(--selection); }
.theme-root { position: relative; isolation: isolate; min-height: 100vh; color: var(--text); background: var(--bg); transition: color .16s ease, background-color .16s ease; }
.shell-icon { display: block; flex: none; }

label { display: grid; gap: 7px; color: var(--text-secondary); font-size: .86rem; font-weight: 600; }
/* Focus keeps keyboard navigation, native controls and popup focus management
   working, without drawing browser outlines or app-specific focus rings. Selected
   states use their own borders/outlines independently of focus. */
:focus { outline: none; }
input, textarea, select { width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; padding: 11px 13px; background: var(--surface); color: var(--text); font-weight: 450; transition: border-color .15s ease, box-shadow .15s ease; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; line-height: 1.55; }
select { appearance: none; padding-right: 38px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 19px) 52%, calc(100% - 14px) 52%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; margin: 0; padding: 0; accent-color: var(--accent); flex: none; }
input[type="range"] { padding: 0; border: 0; accent-color: var(--accent); }
input[type="number"] { max-width: 160px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 10px; color: var(--text-secondary); font-size: .86rem; font-weight: 600; }

/* Reader words, practice tokens and inline links are buttons too, so the base
   rule stays border-free and only standard buttons get size and alignment. */
button { display: inline-flex; align-items: center; gap: 8px; width: fit-content; border: 0; border-radius: 10px; padding: 10px 17px; background: var(--accent); color: var(--accent-text); font-weight: 650; transition: background-color .15s ease, color .15s ease, box-shadow .15s ease, transform .1s ease; }
button:not([class]), button.secondary, button.danger-solid, button.ghost:not(.menu-item) { justify-content: center; }
/* Touch browsers can retain :hover after a tap or canceled drag. Keep every
   hover rule behind this primary-input query; focus, active and selected states
   stay outside it. Backdrops retain their normal pointer/touch hit areas. */
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button:hover { background: var(--accent-hover); } }
button:active { transform: translateY(1px); }
button:disabled { cursor: default; opacity: .55; transform: none; }
button.secondary { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-sm); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button.secondary:hover { background: var(--surface-hover); color: var(--text); } }
.button-link.secondary { border-color: var(--border-strong); background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
@media (hover: hover) and (pointer: fine) { .button-link.secondary:hover { background: var(--surface-hover); color: var(--text); } }
button.ghost, .button-link.ghost { padding: 8px 10px; background: transparent; color: var(--text-secondary); box-shadow: none; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button.ghost:hover, :where(:root:not([data-touch-input])) .button-link.ghost:hover { background: var(--surface-subtle); color: var(--text); } }
button.danger, .button-link.danger { color: var(--danger); }
@media (hover: hover) and (pointer: fine) { button.ghost.danger:hover { background: var(--danger-soft); color: var(--danger); } }
button.danger-solid { background: var(--danger); color: var(--danger-text); }
@media (hover: hover) and (pointer: fine) { button.danger-solid:hover { background: color-mix(in srgb, var(--danger) 86%, black); } }
button.icon-button, .icon-button { display: inline-grid; place-items: center; width: 38px; min-width: 38px; height: 38px; padding: 0; border-radius: 10px; background: transparent; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button.icon-button:hover { background: var(--surface-subtle); color: var(--text); } }
.icon-button.copy-text-button { width: 32px; min-width: 32px; height: 32px; flex: none; }
.copy-text-button > span { display: inline-flex; }
.sr-only, .copy-text-button > .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.copy-text-button .copy-text-check, .copy-text-button .copy-text-error { display: none; }
.copy-text-button[data-copy-state="copied"] .copy-text-icon, .copy-text-button[data-copy-state="error"] .copy-text-icon { display: none; }
.copy-text-button[data-copy-state="copied"] .copy-text-check { display: inline-flex; color: var(--success); }
.copy-text-button[data-copy-state="error"] .copy-text-error { display: inline-flex; color: var(--danger); }
.button-link { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: fit-content; padding: 9px 17px; border: 1px solid transparent; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-weight: 650; line-height: 1.25; text-decoration: none; transition: background-color .15s ease, border-color .15s ease; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .button-link:hover { background: var(--accent-hover); } }
.text-link { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-size: .9rem; font-weight: 600; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .text-link:hover { text-decoration: underline; text-underline-offset: 3px; } }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
a.nav-item, a.document-open { text-decoration: none; }

.muted { color: var(--muted); }
.error { color: var(--danger); }
p.error { padding: 10px 14px; border-radius: 10px; background: var(--danger-soft); font-size: .92rem; overflow-wrap: anywhere; }
.notice { margin-top: 14px; color: var(--success); font-weight: 600; }
hr { margin: 28px 0; border: 0; border-top: 1px solid var(--border); }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--accent-ink); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.lede { max-width: 640px; color: var(--text-secondary); font-size: 1.02rem; line-height: 1.6; }
.field-label { margin: 0; color: var(--text-secondary); font-size: .86rem; font-weight: 600; }
.field-help { margin: 0; color: var(--muted); font-size: .8rem; font-weight: 450; }
.pill, .tag { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: .74rem; font-weight: 650; }
.pill { padding: 4px 10px; }
.tag { margin-left: 8px; padding: 2px 9px; vertical-align: middle; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip { padding: 6px 11px; border-radius: 999px; background: var(--surface-subtle); color: var(--text-secondary); font-size: .84rem; }
.chip strong { margin-right: 4px; color: var(--text); }
.chip.linked { color: var(--text-secondary); font-weight: 500; }
.chip.removable { display: inline-flex; align-items: center; gap: 4px; padding: 5px 6px 5px 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 550; }
.chip.removable button { width: 24px; min-width: 24px; min-height: 24px; height: 24px; padding: 0; border-radius: 50%; background: transparent; color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .chip.removable button:hover { background: var(--surface-subtle); color: var(--text); } }
button.chip-button { min-height: 34px; padding: 6px 13px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: .86rem; font-weight: 550; }
.interest-emoji { font-size: 1rem; line-height: 1; }
@media (hover: hover) and (pointer: fine) { button.chip-button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); } }
button.chip-button.selected { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.meter { display: block; overflow: hidden; height: 6px; border-radius: 99px; background: var(--surface-subtle); }
.meter > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--marigold))); transition: width .4s var(--ease); }
.meter.small { height: 4px; }
.tip { display: flex; gap: 10px; margin: 16px 0 0; padding: 12px 14px; border-radius: 12px; background: var(--warning-soft); color: var(--warning-ink); font-size: .86rem; line-height: 1.5; }
.tip .shell-icon { margin-top: 1px; }
.loading-row { display: flex; align-items: center; gap: 12px; padding: 18px 2px; color: var(--muted); }
.loading-dots { display: inline-flex; gap: 5px; }
.loading-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: dot-bounce 1.1s infinite var(--ease); }
.loading-dots span:nth-child(2) { animation-delay: .15s; background: color-mix(in srgb, var(--accent) 60%, var(--marigold)); }
.loading-dots span:nth-child(3) { animation-delay: .3s; background: var(--marigold); }
@keyframes dot-bounce { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-4px); } }
.confirm-inline { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; color: var(--text-secondary); font-size: .88rem; }
.confirm-inline button { min-height: 34px; padding: 6px 12px; font-size: .86rem; }
.confirm-label { color: var(--text-secondary); font-size: .88rem; }

.switch-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: start; margin: 4px 0; padding: 14px 0; color: var(--text); font-weight: 500; cursor: pointer; }
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.flashcard-context-autoplay[data-disabled="true"] { opacity: .5; cursor: default; }
.switch-row input[type="checkbox"] { position: relative; width: 40px; height: 24px; margin-top: 1px; border: 0; border-radius: 99px; background: var(--border-strong); appearance: none; cursor: pointer; transition: background-color .18s ease; }
.switch-row input[type="checkbox"]::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); content: ""; transition: transform .18s var(--ease); }
.switch-row input[type="checkbox"]:checked { background: var(--accent); }
.switch-row input[type="checkbox"]:checked::after { background: var(--accent-text); transform: translateX(16px); }
.switch-copy { display: grid; gap: 3px; }
.switch-copy strong { font-size: .95rem; font-weight: 600; }
.switch-copy small { color: var(--muted); font-size: .84rem; font-weight: 450; line-height: 1.45; }
.option-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--text); font-weight: 500; }
.option-row input { width: auto; }
.inline-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: end; }
.inline-control button { white-space: nowrap; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.form-actions.end { justify-content: flex-end; }
.field-group { display: grid; gap: 10px; }
.more-options { border-top: 1px solid var(--border); padding-top: 14px; }
.more-options summary { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: .9rem; font-weight: 600; cursor: pointer; list-style: none; }
.more-options summary::-webkit-details-marker { display: none; }
.more-options summary::before { content: "+"; display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 6px; background: var(--surface-subtle); color: var(--muted); font-weight: 700; }
.more-options[open] summary::before { content: "–"; }
.more-options[open] summary { margin-bottom: 12px; }
.developer-panel { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin-top: 14px; padding: 10px 14px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-subtle); font-size: .84rem; }
.developer-panel .option-row { margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Brand ---------- */
/* Inline vector artwork in the text colour, so it follows every theme. */
.wordmark { display: inline-block; flex: none; width: 132px; height: auto; aspect-ratio: 1689 / 550; vertical-align: middle; color: inherit; fill: currentColor; overflow: visible; }
.wordmark.small { width: 104px; }
.app-header .wordmark { width: 100px; }
@media (max-width: 600px) { .app-header .wordmark { width: 90px; } }
@media (max-width: 380px) { .app-header .wordmark { width: 80px; } }
@media (max-width: 340px) { .app-header .wordmark { width: 52px; } }
@media (max-width: 380px) { .entry-topbar .wordmark { width: 104px; } }
@media (forced-colors: active) { .wordmark { color: CanvasText; forced-color-adjust: none; } }
/* The landing page's face (onboard/logo.js sets data-mood): the eyes open like
   lids, a sleepy peek and then wide, their pupils looking toward the pointer
   (--look-x, --look-y); the grin drops open as the quotes rise. The lid's
   scale applies after the look, so a pupil stays inside its opening eye. */
.wordmark-pupil { transform-box: fill-box; transform-origin: center; scale: 1 0; transform: translate(var(--look-x, 0px), var(--look-y, 0px)); transition: scale .2s ease-in, transform .14s ease-out; }
.wordmark[data-mood] .wordmark-pupil { scale: 1 1; transition: scale .6s linear(0, .3 20%, .34 32%, .22 44%, .92 70%, 1.08 84%, 1), transform .14s ease-out; }
.wordmark[data-mood] .wordmark-pupil + .wordmark-pupil { transition-delay: .05s, 0s; }
/* Looking, an eye moves within its quote's round end (--eye-x, --eye-y). */
.wordmark-eye { transform-box: fill-box; transform-origin: center; transform: scaleY(0); translate: var(--eye-x, 0px) var(--eye-y, 0px); transition: transform .2s ease-in, translate .14s ease-out; }
.wordmark-face { transition: transform .35s var(--ease); }
.wordmark-grin { transform-box: fill-box; transform-origin: 50% 0; transform: scale(.5, 0); opacity: 0; transition: transform .18s ease-in, opacity .18s ease-in; }
.wordmark[data-mood] .wordmark-eye { transform: none; transition: transform .45s cubic-bezier(.34, 1.56, .64, 1), translate .14s ease-out; }
.wordmark[data-mood] .wordmark-eye { transition: transform .6s linear(0, .3 20%, .34 32%, .22 44%, .92 70%, 1.08 84%, 1), translate .14s ease-out; }
.wordmark[data-mood] .wordmark-eye + .wordmark-eye { transition-delay: .05s, 0s; }
.wordmark[data-mood="happy"] .wordmark-face { transform: translate(3px, -13px); }
.wordmark[data-mood="happy"] .wordmark-grin { transform: none; opacity: 1; transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), opacity .12s ease-out; }
@media (prefers-reduced-motion: reduce) { .wordmark-eye, .wordmark-pupil, .wordmark-face, .wordmark-grin { transition: none !important; } }

/* ---------- Entry screens: loading, sign-in, onboarding, profile gateway ---------- */
.entry-shell { display: flex; flex-direction: column; align-items: center; min-height: 100dvh; padding: 0 max(20px, env(safe-area-inset-right)) max(48px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); background: radial-gradient(120% 60% at 50% -10%, var(--bg-accent), transparent 60%), var(--bg); }
.entry-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(1040px, 100%); padding: max(22px, env(safe-area-inset-top)) 0 26px; }
/* The language choice is available before setup, through sign-in, and in Settings. */
.entry-topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.entry-language { position: relative; flex: none; }
.entry-language-display { display: flex; align-items: center; gap: 8px; max-width: min(240px, 48vw); min-height: 44px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: .88rem; pointer-events: none; }
.entry-language-display > svg { flex: none; }
.entry-language-display > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-language select { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .entry-language:hover .entry-language-display { background: var(--surface-hover); } }
@media (max-width: 700px) {
  .entry-topbar-with-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
  .entry-topbar-actions { display: contents; }
  .entry-topbar-actions > .entry-language { grid-column: 2; grid-row: 1; }
  .entry-topbar-actions > .entry-link { grid-column: 1 / -1; grid-row: 2; justify-self: end; }
}
.entry-link { padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: .88rem; font-weight: 600; box-shadow: var(--shadow-sm); }
@media (hover: hover) and (pointer: fine) { .entry-link:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); } }
.entry-panel { width: min(520px, 100%); padding: clamp(26px, 5vw, 44px); border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow); }
.entry-panel h1 { font-size: clamp(1.8rem, 5vw, 2.3rem); }
.entry-panel form { display: grid; gap: 16px; margin-top: 22px; }
.entry-return { width: min(520px, 100%); }
.entry-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 520px); gap: 0; width: min(1040px, 100%); overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow); }
.entry-split > .entry-panel { width: 100%; border: 0; border-radius: 0; box-shadow: none; }
.entry-aside { position: relative; display: grid; align-content: center; gap: 28px; overflow: hidden; padding: 48px 44px; background: radial-gradient(circle at 15% 10%, rgba(236, 72, 153, .35), transparent 55%), linear-gradient(155deg, #5b4bd6, #33236f); color: #f1efff; }
.entry-aside::after { position: absolute; right: -70px; bottom: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(14, 165, 233, .22); filter:var(--app-blur-filter, blur(10px)); content: ""; }
.entry-aside-title { position: relative; z-index: 1; max-width: 360px; margin: 0; color: #fff; font-size: 1.65rem; font-weight: 720; line-height: 1.2; letter-spacing: -.025em; }
.entry-aside-list { position: relative; z-index: 1; display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.entry-aside-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; align-items: center; line-height: 1.4; }
.entry-aside-list li > span:last-child { display: grid; min-width: 0; gap: 1px; }
.entry-aside-list small { color: #cfc8ff; font-size: .78rem; font-weight: 600; }
.entry-aside-list strong { overflow-wrap: anywhere; color: #fff; font-size: 1rem; font-weight: 650; }
.entry-aside-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .16); color: #fff; }
.auth-back { margin: -8px 0 18px -10px; }
.auth-resend { margin: 12px 0 0 -10px; }
.auth-error { margin: 20px 0 0; }
.auth-recovery h1 { font-size: clamp(1.6rem, 5vw, 2rem); }
.auth-recovery .auth-error { overflow-wrap: anywhere; }
.auth-recovery-actions { display: grid; gap: 10px; margin-top: 22px; }
.auth-recovery-actions button { width: 100%; }
.auth-card form button[type="submit"] { width: 100%; padding-block: 13px; }
.extension-connect-account { margin-top: 18px; font-weight: 600; overflow-wrap: anywhere; }
.extension-connect .form-actions { margin-top: 22px; }
.extension-connect-switch { display: block; margin: 14px auto 0; }
.otp-input { font-size: 1.6rem; font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: .4em; text-align: center; }
.auth-loading-shell { justify-content: center; }
.lexicon-migration-shell { justify-content: center; }
.lexicon-migration h1 { font-size: clamp(1.5rem, 5vw, 1.9rem); }
.lexicon-migration-track { position: relative; height: 10px; margin-top: 22px; overflow: hidden; border-radius: 999px; background: var(--accent-soft); }
.lexicon-migration-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--accent); transition: width .4s ease; }
.lexicon-migration[aria-busy="true"] .lexicon-migration-fill { background-image: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); background-size: 200% 100%; background-color: var(--accent); animation: lexicon-migration-shimmer 1.6s linear infinite; }
@keyframes lexicon-migration-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .lexicon-migration-fill { transition: none; animation: none !important; } }
.lexicon-migration-stage { display: flex; flex-wrap: wrap; gap: 4px; margin: 12px 0 0; color: var(--muted); }
.lexicon-migration-stage strong { color: var(--text); font-weight: 600; }
.lexicon-migration-note.lexicon-migration-refresh { color: var(--warning); }
.lexicon-migration-note { margin: 14px 0 0; color: var(--muted); font-size: .92rem; }
.auth-loading { display: grid; justify-items: center; gap: 16px; color: var(--muted); text-align: center; }
.auth-loading p { margin: 0; }
.auth-loading-mark { animation: gentle-float 1.8s ease-in-out infinite; }
.auth-loading-mark .wordmark { width: 196px; color: var(--text); }
@keyframes gentle-float { 50% { transform: translateY(-6px); } }

.onboarding-card { width: min(860px, 100%); overflow-x: clip; }
.onboarding-topline { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.onboarding-steps { display: grid; flex: 1; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; min-width: min(100%, 420px); margin: 0; padding: 0; list-style: none; }
.onboarding-steps li { display: grid; gap: 7px; color: var(--muted); font-size: .76rem; font-weight: 600; }
.onboarding-step-bar { height: 5px; border-radius: 99px; background: var(--border); transition: background-color .3s ease; }
.onboarding-steps li.complete .onboarding-step-bar { background: color-mix(in srgb, var(--success) 45%, var(--border)); }
.onboarding-steps li.active { color: var(--accent-ink); }
.onboarding-steps li.active .onboarding-step-bar { background: var(--accent); }
.onboarding-step-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.onboarding-back { margin-left: -10px; }
.onboarding-screen { min-width: 0; }
.onboarding-question, .onboarding-answer { will-change: opacity, transform; }
.onboarding-question { animation: onboarding-question-forward .2s var(--ease) both; }
.onboarding-answer { animation: onboarding-answer-forward .22s var(--ease) .1s both; }
@keyframes onboarding-question-forward { from { opacity: 0; transform: translate3d(14px, 0, 0); } to { opacity: 1; transform: none; } }
@keyframes onboarding-answer-forward { from { opacity: 0; transform: translate3d(20px, 0, 0); } to { opacity: 1; transform: none; } }
.onboarding-form { display: grid; gap: 16px; }
.progressive-onboarding { margin: 0; }
.onboarding-flow { display: grid; gap: 10px; }
.onboarding-active-question { display: grid; gap: 22px; margin: 4px 0; padding: clamp(22px, 5vw, 40px); border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow); animation: progressive-question-in .26s var(--ease) both; }
.onboarding-active-question .onboarding-question h1 { max-width: 640px; margin-bottom: 8px; font-size: clamp(1.75rem, 4.6vw, 2.5rem); }
.onboarding-active-question .onboarding-question .lede { max-width: 600px; margin-bottom: 0; }
.onboarding-compact-answer { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 12px 16px; border: 1px solid var(--border); border-radius: 14px; background: color-mix(in srgb, var(--surface) 60%, transparent); color: var(--text); text-align: start; animation: progressive-answer-in .2s var(--ease) both; }
@media (hover: hover) and (pointer: fine) { .onboarding-compact-answer:hover { border-color: var(--border-strong); background: var(--surface); } }
.onboarding-compact-copy { display: grid; min-width: 0; gap: 1px; }
.onboarding-compact-copy small { overflow: hidden; color: var(--muted); font-size: .76rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.onboarding-compact-copy strong { overflow: hidden; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.onboarding-edit-label { color: var(--accent); font-size: .8rem; font-weight: 650; }
.onboarding-option-answer { display: grid; gap: 18px; }
.onboarding-continue { justify-self: end; justify-content: center; min-width: 140px; }
button.onboarding-skip { min-width: 0; padding-inline: 12px; }
@media (hover: hover) and (pointer: fine) { button.onboarding-skip:hover { background: none; color: var(--text); } }
.onboarding-review-screen { display: grid; gap: 22px; padding: clamp(22px, 5vw, 40px); border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow); animation: progressive-question-in .26s var(--ease) both; }
.onboarding-review-screen h1 { margin-bottom: 8px; font-size: clamp(1.75rem, 4.6vw, 2.5rem); }
.onboarding-review-screen h1:focus { outline: none; }
.onboarding-review-sections { display: grid; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-subtle); }
.onboarding-review-section { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.onboarding-review-section + .onboarding-review-section { border-top: 1px solid var(--border); }
.onboarding-review-copy { display: grid; min-width: 0; gap: 2px; }
.onboarding-review-copy h2 { margin: 0 0 2px; color: var(--muted); font-size: .78rem; font-weight: 600; }
.onboarding-review-copy p, .onboarding-review-copy > strong { margin: 0; font-size: .95rem; overflow-wrap: anywhere; }
.onboarding-review-sections { overflow:hidden; }
.onboarding-review-clickable { position:relative; transition:background-color .15s ease; }
@media (hover: hover) and (pointer: fine) { .onboarding-review-clickable:has(> .onboarding-review-row-action:hover:not(:disabled)) { background:var(--surface-hover); } }
.onboarding-review-row-action { position:absolute; inset:0; z-index:1; width:100%; height:100%; margin:0; padding:0; border:0; border-radius:0; background:none; box-shadow:none; }
.onboarding-review-row-action:is(:active,:focus-visible) { background:none; box-shadow:none; outline:none; transform:none; }
@media (hover: hover) and (pointer: fine) { .onboarding-review-row-action:is(:hover,:active,:focus-visible) { background:none; box-shadow:none; outline:none; transform:none; } }
.onboarding-review-remove { position:relative; z-index:2; }
.onboarding-review-language-section { display:block; }
.onboarding-review-language-header { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0; padding:0; }
.onboarding-review-language-header h2 { margin:0; color:var(--muted); font-size:.78rem; font-weight:600; }
.onboarding-review-language-header .icon-button { height:30px; }
.onboarding-review-language-list { display:grid; gap:0; margin:0; padding:0; list-style:none; }
.onboarding-review-language-list > li { display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:44px; padding:8px 0; }
.onboarding-review-language-list > li + li { border-top:1px solid var(--border); }
.onboarding-review-language-list > li:first-child { min-height:38px; padding-block:0; }
.onboarding-review-language-list p { min-width:0; margin:0; font-size:.95rem; overflow-wrap:anywhere; }
.onboarding-review-language-section .icon-button { flex:none; }
.onboarding-ui-language { display: grid; gap: 8px; }
.confirmation-submit { justify-self: end; justify-content: center; min-width: 180px; padding-block: 13px; }
@keyframes progressive-question-in { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }
@keyframes progressive-answer-in { from { opacity: 0; transform: translate3d(0, 6px, 0); } to { opacity: 1; transform: none; } }

.language-picker { display: grid; gap: 24px; }
.reader-popup.language-journey { inset:0; width:100vw; max-width:none; height:100dvh; max-height:none; margin:0; border:0; border-radius:0; background:transparent; color:#fff; box-shadow:none; }
.reader-popup.language-journey::backdrop { background:rgba(8,12,20,.86); backdrop-filter:blur(22px); -webkit-backdrop-filter:blur(22px); }
.language-journey > .reader-popup-heading { position:absolute; inset:0 0 auto; z-index:5; border:0; padding:max(18px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)); justify-content:flex-end; pointer-events:none; }
.language-journey > .reader-popup-heading h2 { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); }
.language-journey > .reader-popup-heading button { pointer-events:auto; color:#fff; background:rgba(255,255,255,.09); border:1px solid rgba(255,255,255,.16); width:46px; height:46px; border-radius:50%; }
/* Keep the list bounded through modal and embedded setup flex containers. */
.language-journey > .reader-popup-body { position:relative; display:flex; flex-direction:column; flex:1 1 0; min-height:0; height:auto; padding:0 28px max(48px,env(safe-area-inset-bottom)); overflow-y:hidden; isolation:isolate; }
.ukraine-donation-link { display:inline-block; max-width:100%; margin-block-start:.8rem; padding:.45rem .7rem; border-radius:8px; background:#172554; color:#ffdf00; font-size:1rem; font-weight:600; line-height:1.5; text-decoration:underline; text-underline-offset:.2em; overflow-wrap:anywhere; }
.ukraine-donation-link:visited { color:#ffdf00; }
@media (hover: hover) and (pointer: fine) { .ukraine-donation-link:hover { color:#fff18a; background:#1e3a6d; } }
.ukraine-donation-interstitial { width:min(640px,100%); min-height:65dvh; margin:auto; padding:clamp(24px,6vw,64px); display:flex; flex-direction:column; align-items:flex-start; justify-content:center; gap:28px; }
.ukraine-donation-interstitial h1 { margin:0; font-size:clamp(24px,4vw,36px); line-height:1.4; }
.ukraine-donation-interstitial h1 .ukraine-donation-link { font-size:inherit; margin:0; }
.language-journey-search,.language-journey-varieties { position:relative; z-index:2; width:min(760px,100%); margin:0 auto; }
.language-journey-search { display:flex; flex-direction:column; flex:1 1 0; height:auto; min-height:0; padding-top:27dvh; }
.language-journey-search > :not(.language-journey-results-frame) { flex-shrink:0; }
.language-journey-search > label { display:block; margin-bottom:20px; color:rgba(255,255,255,.82); font-size:clamp(20px,2.4vw,30px); font-weight:500; line-height:1.35; }
.language-journey .language-journey-input { display:block; width:100%; height:auto; padding:12px 0 18px; border:0; border-bottom:2px solid rgba(255,255,255,.36); border-radius:0; color:#fff; background:transparent; font-size:clamp(32px,5vw,60px); font-weight:600; line-height:1.2; letter-spacing:-.035em; box-shadow:none; }
.language-journey .language-journey-input:focus { outline:0; border-color:#fff; box-shadow:0 2px 0 rgba(255,255,255,.2); }
.language-journey .language-journey-input::placeholder { color:rgba(255,255,255,.32); }
.language-journey-search[data-browse="true"] { display:flex; flex-direction:column; flex:1 1 0; height:auto; min-height:0; padding-top:max(78px,env(safe-area-inset-top)); }
.language-journey-search[data-browse="true"] > label { font-size:clamp(18px,2.4vw,26px); margin-bottom:10px; flex-shrink:0; }
.language-journey-search[data-browse="true"] > .language-journey-input { font-size:clamp(28px,4vw,42px); flex-shrink:0; }
.language-journey-search[data-browse="true"] > .language-journey-back { align-self:flex-start; margin-bottom:12px; flex-shrink:0; }
@property --language-results-top-fade {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}
.language-journey-results-frame {
  flex:1 1 0; min-height:0; display:grid; grid-template-rows:minmax(0,1fr); margin-top:8px;
  --language-results-top-fade:0px;
  mask-image:linear-gradient(to bottom,transparent,#000 var(--language-results-top-fade),#000 calc(100% - 16px),transparent);
  transition:--language-results-top-fade .15s ease;
}
.language-journey-results-frame[data-scrolled] { --language-results-top-fade:16px; }
.language-journey-results-frame > .language-journey-results {
  display:block; min-height:0; margin:0; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable;
  padding:20px 8px 16px 4px; scroll-padding-block:20px 16px; touch-action:pan-y pinch-zoom;
}
.language-journey-group { display:grid; gap:10px; }
.language-journey-group + .language-journey-group { margin-top:24px; }
.language-journey-support-heading { color:rgba(255,255,255,.85); font-size:18px; line-height:1.4; font-weight:600; margin:0 0 8px; }
.language-journey-results { display:grid; gap:10px; margin-top:28px; padding-bottom:20px; animation:language-results-arrive .3s ease both; }
.language-journey .language-journey-tile { display:flex; align-items:center; gap:20px; width:100%; padding:20px 24px; min-height:88px; border:1px solid rgba(255,255,255,.16); border-radius:18px; color:#fff; background:rgba(255,255,255,.07); text-align:start; box-shadow:none; transition:background .18s,border-color .18s,transform .18s; }
@media (hover: hover) and (pointer: fine) { .language-journey .language-journey-tile:hover { background:rgba(255,255,255,.16); border-color:rgba(255,255,255,.4); transform:translateY(-1px); } }
.language-journey-names { display:grid; gap:4px; flex:1; min-width:0; }
.language-journey-names strong,.language-journey-region strong { font-size:clamp(20px,2.2vw,26px); font-weight:600; }
.language-journey-names small { color:rgba(255,255,255,.58); font-size:16px; font-weight:400; }
.language-journey-flags { display:flex; justify-content:flex-end; flex-wrap:wrap; gap:clamp(4px,.6vw,8px); max-width:52%; font-size:clamp(24px,calc(18px + 2vw),44px); line-height:1.25; }
.language-journey-tile > svg { flex:none; opacity:.6; }
.language-journey-varieties { display:flex; flex-direction:column; flex:1 1 0; height:auto; min-height:0; padding-top:max(80px,13dvh); }
.language-journey-varieties > .language-journey-results { overflow-y:auto; min-height:0; scrollbar-gutter:stable; padding-inline:4px 8px; }
.language-journey-varieties > :not(.language-journey-results) { flex-shrink:0; }
.language-journey .language-journey-back { display:inline-flex; align-items:center; gap:10px; margin-bottom:28px; padding:8px 0; color:rgba(255,255,255,.75); background:none; border:0; box-shadow:none; }
.language-journey-varieties h1 { color:#fff; font-size:clamp(30px,4.3vw,48px); line-height:1.15; font-weight:600; letter-spacing:-.025em; margin:0 0 32px; }
.language-journey-varieties h1:focus { outline:none; }
.language-journey-region-flag { font-size:36px; }
.language-journey-region-name { display:flex; align-items:center; flex-wrap:wrap; gap:8px 12px; flex:1; min-width:0; }
.language-uncommon-label { display:inline-block; flex:none; padding:3px 8px; border:1px solid currentColor; border-radius:999px; color:var(--muted); font-size:.7rem; font-weight:550; line-height:1.3; white-space:nowrap; }
.language-journey .language-uncommon-label { color:rgba(255,255,255,.65); }
.language-journey .language-support-notice { color:rgba(255,255,255,.65); }
.language-journey-empty { padding:20px 0; color:rgba(255,255,255,.8); font-size:20px; }
.language-journey .error { color:#ffb8b8; }
.language-journey .language-journey-suggest { margin-top:14px; padding:12px 26px; background:#fff; color:#141820; border:1px solid #fff; border-radius:12px; box-shadow:none; font-size:18px; }
@media (hover: hover) and (pointer: fine) { .language-journey .language-journey-suggest:hover { background:#e6eaf0; } }
@keyframes language-results-arrive { from {opacity:0;transform:translateY(8px)} to {opacity:1;transform:none} }
@media(max-width:600px) {
  .language-journey > .reader-popup-body { padding-inline:22px; }
  .language-journey-search { padding-top:28dvh; }
  .language-journey .language-journey-tile { padding:16px; gap:12px; min-height:80px; }
}
@media(prefers-reduced-motion:reduce) {
  .language-journey-results-frame { transition:none; }
  .language-journey-results { animation:none; }
  .language-journey .language-journey-tile { transition:none; transform:none; }
}
.language-search { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: center; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--muted); transition: border-color .15s ease, box-shadow .15s ease; }
.language-search:focus-within { border-color: var(--accent);  }
.language-search input, .language-search input:focus { min-width: 0; padding: 13px 0; border: 0; outline: 0; background: transparent; box-shadow: none; }
.language-section { display: grid; gap: 10px; }
.language-section h2 { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.language-support-heading { margin: 0; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.language-support-notice { margin: 0; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.language-card-names .language-support-note { margin-top: 4px; color: var(--muted); font-size: .75rem; line-height: 1.4; white-space: normal; overflow: visible; text-overflow: clip; }

.language-empty { margin: 0; padding: 18px 0; }
.language-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.language-grid.compact { max-height: 340px; padding: 2px; overflow-y: auto; }
.language-card { position: relative; display: grid; width: 100%; min-height: 68px; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px; align-items: center; padding: 10px 16px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-align: start; font-weight: 500; transition: border-color .14s ease, background-color .14s ease, transform .14s var(--ease), box-shadow .14s ease; }
@media (hover: hover) and (pointer: fine) { .language-card:hover { border-color: var(--accent); background: var(--surface); box-shadow: var(--shadow); transform: translateY(-1px); } }
.language-card.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.language-card-names { display: grid; gap: 2px; min-width: 0; }
.language-card-names strong, .language-card-names small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.language-card-names strong { font-weight: 650; }
.language-card-names small { color: var(--muted); font-weight: 500; }
.language-family { color: var(--muted); font-size: .62rem; font-weight: 700; letter-spacing: .08em; line-height: 1.1; text-transform: uppercase; }
.language-flags { display: flex; align-items: center; gap: 12px; margin-block: -16px; font-size: 4rem; line-height: 1; white-space: nowrap; }
.language-check { display: grid; grid-column: 3; grid-row: 1; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-text); }
.variety-selector { display: grid; gap: 8px; margin-top: 6px; }
.variety-grid { display: flex; flex-wrap: wrap; max-width: 100%; gap: 8px; padding: 2px; }
.variety-card { position: relative; display: inline-flex; flex: 0 0 auto; align-items: center; gap: 8px; min-height: 42px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: .9rem; font-weight: 550; text-align: start; }
@media (hover: hover) and (pointer: fine) { .variety-card:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); } }
.variety-card.selected { padding-inline-end: 36px; border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.variety-card .language-check { position: absolute; top: 50%; inset-inline-end: 9px; transform: translateY(-50%); }
.variety-flag { font-size: 1.1rem; }
.character-rendering-selector, .transliteration-selector { display: grid; gap: 8px; margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--border); }
.character-rendering-grid, .transliteration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.character-rendering-card, .transliteration-card { position: relative; display: grid; width: 100%; gap: 2px; padding-block: 12px; padding-inline: 14px 34px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-align: start; font-weight: 500; justify-content: stretch; justify-items: start; }
.character-rendering-card { grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; }
@media (hover: hover) and (pointer: fine) { .character-rendering-card:hover, .transliteration-card:hover { border-color: var(--accent); background: var(--surface); } }
.character-rendering-card.selected, .transliteration-card.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }
.character-sample { font-size: 1.3rem; font-weight: 700; }
.transliteration-name { font-weight: 650; }
.transliteration-sample { color: var(--muted); font-size: .8rem; }
.transliteration-description { margin-top: 4px; color: var(--text-secondary); font-size: .8rem; font-weight: 400; line-height: 1.45; }

.profile-gateway { width: min(760px, 100%); }
.profile-gateway h1 { max-width: 560px; }
.profile-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 26px 0 18px; }
.profile-choice { display: grid; width: 100%; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); text-align: start; font-weight: 500; }
@media (hover: hover) and (pointer: fine) { .profile-choice:hover { border-color: var(--accent); background: var(--surface); box-shadow: var(--shadow); } }
.profile-choice-copy { display: grid; gap: 2px; min-width: 0; }
.profile-choice-copy strong { font-size: 1.05rem; }
.profile-choice-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.profile-choice-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 14px; background: var(--accent-soft); font-size: 1.5rem; }
.profile-choice-arrow { color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .profile-choice:hover .profile-choice-arrow { color: var(--accent); } }
.gateway-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.profile-variety-screen { display: grid; gap: 18px; margin-top: 24px; }
.profile-variety-screen > button { justify-self: end; }

/* Landing page: a painted welcome for the chosen language behind frosted
   glass, one story moment to read and tap, then the features in detail, and a
   start button that docks at the bottom once the hero's button scrolls away. */
.landing { --landing-glass: color-mix(in srgb, var(--surface) 72%, transparent); --landing-glass-strong: color-mix(in srgb, var(--surface) 84%, transparent); --landing-glass-border: color-mix(in srgb, var(--border) 60%, transparent); --landing-ink-glass: rgba(12, 13, 17, .66); --landing-ink-border: rgba(255, 255, 255, .18); position: relative; padding-bottom: 140px; overflow-x: clip; background: transparent; }
.landing[data-palette="dark"] { --landing-glass: color-mix(in srgb, var(--surface) 64%, transparent); --landing-glass-strong: color-mix(in srgb, var(--surface) 78%, transparent); }
button.entry-logo { min-height: 0; padding: 4px 2px; border: 0; background: none; box-shadow: none; color: inherit; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { button.entry-logo:hover { background: none; opacity: .8; } }
.landing-topbar { position: relative; z-index: 3; }
.landing-topbar .entry-link, .landing-topbar .entry-language-display { background: var(--landing-glass-strong); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); }
.landing-theme-toggle { display: inline-grid; place-items: center; width: 44px; min-height: 44px; padding: 0; }
.landing-theme-toggle .landing-theme-icon { grid-area: 1 / 1; display: grid; place-items: center; transition: opacity .3s ease, transform .4s var(--ease); }
.landing-theme-toggle .landing-theme-icon[data-shown="false"] { opacity: 0; transform: rotate(-60deg) scale(.6); }
/* Keep entry actions visible on one row, reducing the language control first. */
.landing .landing-topbar {display:flex;gap:8px;}
.landing-topbar .entry-logo {flex:0 1 132px;min-width:56px;}
.landing-topbar .wordmark {width:100%;max-width:132px;}
.landing .landing-header-actions {display:flex;align-items:center;gap:8px;flex:none;}
.landing-topbar .landing-sign-in {min-height:44px;white-space:nowrap;}
.landing-topbar .landing-theme-toggle {flex:none;}
@media (max-width:800px) {
  .landing .landing-header-actions {gap:6px;}
  .landing-topbar .entry-language-display {justify-content:center;width:44px;height:44px;padding:0;border-radius:50%;}
  .landing-topbar .entry-language-display>span,.landing-topbar .entry-language-display>svg:last-child {display:none;}
  .landing-topbar .landing-sign-in {max-width:140px;white-space:normal;overflow-wrap:anywhere;}
}
@media (max-width:380px) {
  .landing-topbar .landing-sign-in {max-width:100px;padding-inline:10px;}
}

/* The painting sits behind everything and drifts more slowly than the page.
   Its lower edge and inline-start side dissolve into the page colour so copy
   and the sections below always have calm ground. */
.landing-backdrop { position: fixed; z-index: -1; top: 0; inset-inline: 0; height: 100dvh; overflow: hidden; pointer-events: none; background: radial-gradient(70% 60% at 80% 0%, color-mix(in srgb, var(--flag-2, var(--muted)) 16%, transparent), transparent 70%), radial-gradient(60% 50% at 10% 30%, color-mix(in srgb, var(--flag-1, var(--muted)) 10%, transparent), transparent 70%); transition: background .8s ease; }
.landing-backdrop-art { position: absolute; inset: 0; transform: translate3d(0, var(--landing-parallax, 0px), 0); animation: landing-backdrop-in .9s ease-in-out both; will-change: transform, opacity; }
/* Switching day and night cross-fades the two paintings and eases the page colours. */
.landing, .landing-glass-panel, .landing-topbar .entry-link, .landing-topbar .entry-language-display, .landing-reel { transition: background-color .6s ease, color .6s ease, border-color .6s ease; }
.landing-backdrop-art > img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 60% 30%; }
/* A flat 30% wash of the page colour calms the painting behind the glass,
   before its lower and inline-start edges dissolve fully. */
.landing-backdrop-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(color-mix(in srgb, var(--bg) 30%, transparent), color-mix(in srgb, var(--bg) 30%, transparent)), linear-gradient(180deg, color-mix(in srgb, var(--bg) 20%, transparent) 0%, transparent 18%, transparent 45%, color-mix(in srgb, var(--bg) 55%, transparent) 72%, var(--bg) 100%), linear-gradient(90deg, color-mix(in srgb, var(--bg) 42%, transparent) 0%, transparent 45%); }
@keyframes landing-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .landing-backdrop-art { animation: none; transform: none; } }

/* Shared glass: the app's Home tiles on light surfaces, the comic reader's ink
   scrims over art. Panels fall back to solid surfaces without backdrop support. */
.landing-glass-panel { position: relative; border: 1px solid var(--landing-glass-border); border-radius: 28px; background: var(--surface); box-shadow: 0 24px 70px rgb(0 0 0 / .12), 0 2px 8px rgb(0 0 0 / .05); }
.landing-glass { position: relative; border: 1px solid var(--landing-ink-border); border-radius: 18px; background: #16171b; color: #f5f5f6; box-shadow: 0 10px 36px rgb(0 0 0 / .32); }
@supports ((backdrop-filter: blur(14px)) or (-webkit-backdrop-filter: blur(14px))) {
  .landing-glass-panel { background: var(--landing-glass); -webkit-backdrop-filter: blur(22px) saturate(1.25); backdrop-filter: blur(22px) saturate(1.25); }
  .landing-glass { background: var(--landing-ink-glass); -webkit-backdrop-filter: blur(10px) saturate(1.2); backdrop-filter: blur(10px) saturate(1.2); }
}
@media (prefers-reduced-transparency: reduce) { .landing-glass-panel { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } .landing-glass { background: #16171b; -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* ----- Hero ----- */
/* One rounded card: the glass copy joins the story stage edge to edge. */
.landing-account-card {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:18px;width:min(1240px,100%);margin:clamp(8px,4vh,40px) 0 24px;padding:24px 32px}
.landing-account-card > div {min-width:0;overflow-wrap:anywhere;flex:1}
.landing-account-card strong {font-size:1.1rem}
.landing-account-card + .landing-hero {margin-top:0}
.landing .landing-account-card button.welcome-start {flex:none;width:auto;min-width:0;margin:0;justify-content:center}
@media(max-width:600px) {.landing-account-card {margin:8px 0 20px;padding:20px}.landing .landing-account-card button.welcome-start {width:100%;justify-content:center}}
.landing-hero { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); gap: 0; align-items: stretch; width: min(1240px, 100%); margin: clamp(8px, 4vh, 40px) 0 clamp(72px, 10vw, 128px); overflow: hidden; border: 1px solid var(--landing-glass-border); border-radius: 28px; box-shadow: 0 30px 80px rgb(0 0 0 / .32), 0 2px 10px rgb(0 0 0 / .12); }
.landing-hero-copy { --landing-copy-pad: clamp(24px, 3.6vw, 44px); display: grid; align-content: center; gap: 14px; padding: var(--landing-copy-pad); border: 0; border-radius: 0; box-shadow: none; }
.landing-hero h1 { margin: 0; font-size: clamp(2.1rem, 4.4vw, 3.4rem); line-height: 1.08; letter-spacing: -.035em; text-wrap: balance; }
.landing-hero-language { display: inline-flex; align-items: baseline; gap: .22em; padding: 0 .12em; border-radius: .25em; background: linear-gradient(120deg, color-mix(in srgb, var(--flag-1, var(--accent)) 26%, transparent), color-mix(in srgb, var(--flag-2, var(--accent)) 22%, transparent)); box-shadow: inset 0 -.14em color-mix(in srgb, var(--flag-1, var(--accent)) 55%, transparent); animation: landing-swap .55s var(--ease); }
.landing-hero-flag { font-size: .78em; line-height: 1; }
.landing-hero .lede { margin: 0; font-size: 1.08rem; line-height: 1.6; }
.landing-pick { margin: 8px 0 -4px; color: var(--text-secondary); font-size: .92rem; font-weight: 650; }
/* The headline's language reel: three copies of the popular languages drift
   under a fixed highlight, fading out at both edges to suggest the rest. */
.landing-reel { --landing-reel-fade: 16%; position: relative; display: flex; align-items: center; width: auto; height: 1.12em; margin: .06em calc(-1 * var(--landing-copy-pad, 0px)); overflow: hidden; background: color-mix(in srgb, var(--text) 7%, transparent); cursor: pointer; -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--landing-reel-fade), #000 calc(100% - var(--landing-reel-fade)), transparent); mask-image: linear-gradient(90deg, transparent, #000 var(--landing-reel-fade), #000 calc(100% - var(--landing-reel-fade)), transparent); -webkit-user-select: none; user-select: none; }
/* The fixed window in the middle; the active language carries its own pill through it. */
.landing-reel-highlight { position: absolute; z-index: 0; top: 50%; left: 50%; width: 5em; height: .92em; border: 1px solid color-mix(in srgb, var(--text) 28%, transparent); border-radius: .26em; background: color-mix(in srgb, var(--text) 5%, transparent); transform: translate(-50%, -50%); transition: width .35s var(--ease); pointer-events: none; }
.landing-reel-track { position: absolute; z-index: 1; top: 0; left: 0; display: flex; align-items: center; height: 100%; will-change: transform; }
button.landing-reel-item { display: inline-flex; flex: none; align-items: center; gap: .22em; min-height: 0; margin: 0 .18em; padding: .02em .32em; border: 0; border-radius: .24em; background: transparent; box-shadow: none; color: var(--text); font: inherit; font-size: .7em; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; white-space: nowrap; opacity: .38; transform: scale(.82); transition: opacity .3s ease, transform .3s var(--ease), background-color .3s ease, box-shadow .3s ease, color .6s ease; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { button.landing-reel-item:hover { opacity: .75; } }
button.landing-reel-item[data-active="true"] { opacity: 1; transform: none; background: linear-gradient(120deg, color-mix(in srgb, var(--flag-1, var(--accent)) 26%, transparent), color-mix(in srgb, var(--flag-2, var(--accent)) 22%, transparent)); box-shadow: inset 0 -.12em color-mix(in srgb, var(--flag-1, var(--accent)) 55%, transparent); }
.landing-reel-flag {flex:none;font-size:.8em;line-height:1;}
.landing-varieties { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 8px 0 12px; }
button.landing-variety { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; min-height: 44px; padding: 5px; border: 1px solid transparent; border-radius: 12px; background: transparent; box-shadow: none; font-size: 1.4rem; line-height: 1; cursor: pointer; transition: background-color .3s ease, border-color .3s ease; }
button.landing-variety[data-previewed="true"] { background: color-mix(in srgb, var(--flag-1, var(--accent)) 18%, transparent); border-color: var(--landing-glass-border); }
button.landing-variety[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 -3px var(--accent); }
@media (hover: hover) and (pointer: fine) { button.landing-variety:hover { background: color-mix(in srgb, var(--text) 12%, transparent); } }
button.landing-choose { display:flex; justify-content:center; width:100%; min-height:44px; margin:0; padding:12px 24px; border:0; background:var(--accent-text); box-shadow:none; color:var(--accent); font-size:.95rem; font-weight:600; text-align:center; }
@media (hover: hover) and (pointer: fine) { button.landing-choose:hover { background:color-mix(in srgb,var(--accent-text) 90%,var(--accent)); color:var(--accent-hover); } }
.landing-hero .button-row { display:grid; gap:10px; justify-items:stretch; width:100%; max-width:100%; margin-top:14px; }
.landing-hero .button-row :is(.welcome-start,.landing-choose,.landing-language-count) { width:100%; }
.landing button.welcome-start { width: 100%; min-width: min(320px, 100%); justify-content: center; padding: 16px 30px; border: 0; background: var(--accent); color: var(--accent-text); font-size: 1.05rem; box-shadow: 0 12px 32px -12px rgb(0 0 0 / .45); }
@media (hover: hover) and (pointer: fine) { .landing button.welcome-start:hover:not(:disabled) { background: var(--accent-hover); } }
.landing-language-count { width: min(320px, 100%); margin: 0; color: var(--text-secondary); font-size: .85rem; text-align: center; }
.landing-closing .landing-language-count { margin-top: 10px; }
@keyframes landing-swap { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ----- The reading moment: a picture-book page with a sentence on an ink scrim ----- */
.landing-hero-stage { position: relative; display: grid; min-width: 0; }
.landing-stage { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: clamp(460px, 50vw, 680px); height: 100%; overflow: hidden; background: #1b1c21; isolation: isolate; }
.landing-stage-art { position: absolute; inset: 0; z-index: 0; display: grid; place-items: center; background: radial-gradient(80% 70% at 70% 20%, color-mix(in srgb, var(--flag-2, #6b7280) 45%, #1b1c21), #15161a 75%); }
.landing-stage-art > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; animation: landing-backdrop-in 1s ease both; }
.landing-stage-painting, .landing-feature-painting { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 999px; background: rgba(12, 13, 17, .55); color: #f5f5f6; font-size: .88rem; font-weight: 600; }
.landing-stage-top { position: absolute; z-index: 2; inset: 16px 16px auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; pointer-events: none; }
.landing-stage-title { display: grid; gap: 1px; max-width: 70%; padding: 10px 16px; animation: landing-swap .5s var(--ease); }
.landing-stage-title strong { font-size: 1rem; line-height: 1.35; }
.landing-stage-title small { color: #d5d7de; font-size: .78rem; }
.landing-stage-panel { z-index: 2; margin: 14px; padding: clamp(14px, 2.4vw, 22px) clamp(16px, 2.6vw, 26px); border-radius: 22px; }
.landing-sentence { display: flex; flex-wrap: wrap; align-items: flex-end; row-gap: 10px; margin: 0; color: #fff; font-family: var(--font-reading); font-size: clamp(1.35rem, 2.6vw, 2.05rem); line-height: 1.3; }
.landing-sentence:is(:lang(zh), :lang(ja), :lang(ko), :lang(yue), :lang(th), :lang(ar), :lang(fa), :lang(he), :lang(hi)) { font-family: var(--font-sans); }
.landing-token { white-space: pre; }
.landing-unit { display: inline-flex; align-items: flex-end; }
.landing-unit > .landing-token { align-self: flex-start; }
button.landing-word { display: flex; flex-direction: column; align-items: center; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 8px; background: transparent; box-shadow: none; color: inherit; font: inherit; line-height: inherit; text-align: center; cursor: pointer; transition: background .18s ease; }
button.landing-word[aria-expanded="true"] { background: rgba(255, 255, 255, .16); }
@media (hover: hover) and (pointer: fine) { button.landing-word:hover { background: rgba(255, 255, 255, .16); } }
.landing-word-text { display: block; padding: 1px .08em; }
.landing-word-reading { display: none; min-height: 1.3em; padding: 2px 4px 0; color: #c9ccd6; font-family: var(--font-sans); font-size: max(.72rem, .42em); line-height: 1.3; }
.landing-sentence[data-readings="true"] .landing-word-reading { display: block; }
.landing-translation { margin: 10px 0 0; color: #e4e6ec; font-size: .98rem; line-height: 1.5; }
.landing-stage-loading { display: flex; align-items: center; gap: 10px; margin: 0; color: #f5f5f6; font-weight: 600; }
.landing-stage-lines { display: block; height: 56px; margin-top: 14px; border-radius: 6px; background: linear-gradient(100deg, rgba(255, 255, 255, .08) 30%, rgba(255, 255, 255, .18) 50%, rgba(255, 255, 255, .08) 70%) 0 0 / 200% 100%; animation: shimmer 1.6s linear infinite; }
.landing-stage-error { margin: 8px 0 12px; color: #d5d7de; font-size: .86rem; }
.landing-stage .secondary { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .25); color: #fff; }
@media (hover: hover) and (pointer: fine) { .landing-stage .secondary:hover:not(:disabled) { background: rgba(255, 255, 255, .18); } }

/* The word bubble: the reader's word menu, reduced to what a visitor needs. */
.landing-bubble { position: absolute; z-index: 4; left: 16px; bottom: 120px; display: grid; gap: 6px; width: min(300px, calc(100% - 32px)); padding: 14px 16px; border: 1px solid var(--landing-ink-border); border-radius: 18px; background: #202226; color: #f5f5f6; box-shadow: 0 18px 50px rgb(0 0 0 / .45); opacity: 0; transition: opacity .25s ease; }
/* Frosted over the scene, so the painting shows through the word help. */
@supports ((backdrop-filter: blur(14px)) or (-webkit-backdrop-filter: blur(14px))) { .landing-bubble { background: rgba(12, 13, 17, .5); -webkit-backdrop-filter: blur(16px) saturate(1.25); backdrop-filter: blur(16px) saturate(1.25); } .landing-bubble::after { background: rgba(12, 13, 17, .5); -webkit-backdrop-filter: blur(16px) saturate(1.25); backdrop-filter: blur(16px) saturate(1.25); } }
@media (prefers-reduced-transparency: reduce) { .landing-bubble, .landing-bubble::after { background: #202226; -webkit-backdrop-filter: none; backdrop-filter: none; } }
.landing-bubble[data-placed="true"] { opacity: 1; animation: landing-bubble-in .3s var(--ease); }
.landing-bubble::after { content: ""; position: absolute; left: calc(var(--landing-bubble-arrow, 50%) - 8px); bottom: -8px; width: 16px; height: 16px; border-right: 1px solid var(--landing-ink-border); border-bottom: 1px solid var(--landing-ink-border); background: #202226; transform: rotate(45deg); }
.landing-bubble[data-side="below"]::after { top: -8px; bottom: auto; border: 0; border-left: 1px solid var(--landing-ink-border); border-top: 1px solid var(--landing-ink-border); }
@keyframes landing-bubble-in { from { transform: translateY(6px); } to { transform: none; } }
.landing-bubble-header { display: flex; align-items: center; gap: 10px; }
.landing-bubble-header strong { min-width: 0; overflow-wrap: anywhere; font-family: var(--font-reading); font-size: 1.35rem; line-height: 1.2; }
.landing-bubble-header .tag { margin: 0; background: rgba(255, 255, 255, .14); color: #e4e6ec; }
.landing-bubble-header .icon-button { width: 30px; min-width: 30px; height: 30px; margin-inline-start: auto; padding: 4px; color: #d5d7de; }
@media (hover: hover) and (pointer: fine) { .landing-bubble-header .icon-button:hover { background: rgba(255, 255, 255, .14); color: #fff; } }
.landing-bubble p { margin: 0; }
.landing-bubble-reading { color: #c9ccd6; font-size: .9rem; }
.landing-bubble-meaning { font-size: 1.05rem; font-weight: 650; }
.landing-bubble-base { display: flex; align-items: baseline; gap: 8px; color: #c9ccd6; font-size: .86rem; }
.landing-bubble-base strong { color: #fff; font-family: var(--font-reading); font-size: 1rem; }
.landing-bubble-note { display: flex; gap: 8px; padding-top: 8px; border-top: 1px solid rgba(255, 255, 255, .14); color: #e4e6ec; font-size: .86rem; line-height: 1.45; }
.landing-bubble-note svg { flex: none; margin-top: 2px; color: #ffd166; }

/* ----- Features: each a painting with a glimpse of the real controls on glass ----- */
.landing-features { position: relative; z-index: 1; display: grid; gap: clamp(56px, 9vw, 112px); width: min(1180px, 100%); margin: 0; scroll-margin-top: 32px; }
.landing-feature { position: relative; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 0; align-items: stretch; overflow: hidden; border: 1px solid var(--landing-glass-border); border-radius: 28px; box-shadow: 0 30px 80px rgb(0 0 0 / .18); transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.landing-feature:is(:focus-within) { transform: translateY(-6px); border-color: var(--hue); box-shadow: 0 36px 88px rgb(0 0 0 / .26); }
@media (hover: hover) and (pointer: fine) { .landing-feature:is(:hover, :focus-within) { transform: translateY(-6px); border-color: var(--hue); box-shadow: 0 36px 88px rgb(0 0 0 / .26); } }
button.landing-feature-action { position: absolute; z-index: 2; inset: 0; display: block; width: 100%; height: 100%; margin: 0; padding: 0; border-radius: inherit; background: transparent; box-shadow: none; }
button.landing-feature-action:is(:focus-visible) { background: color-mix(in srgb, var(--hue) 5%, transparent); outline: none; }
@media (hover: hover) and (pointer: fine) { button.landing-feature-action:is(:hover, :focus-visible) { background: color-mix(in srgb, var(--hue) 5%, transparent); outline: none; } }
.landing-feature-cta { display: flex; align-items: center; gap: 10px; margin-top: 24px; color: var(--text); font-weight: 700; opacity: 0; transform: translateY(6px); transition: opacity .2s ease, transform .2s ease; }
.landing-feature-cta .shell-icon { flex: none; color: var(--hue); }
.landing-feature:is(:focus-within) .landing-feature-cta { opacity: 1; transform: none; }
@media (hover: hover) and (pointer: fine) { .landing-feature:is(:hover, :focus-within) .landing-feature-cta { opacity: 1; transform: none; } }
.landing-feature-painting:has(button) { z-index: 3; }
@media (hover: none) { .landing-feature-cta { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .landing-feature, .landing-feature-cta { transition: none; } .landing-feature:is(:focus-within) { transform: none; } @media (hover: hover) and (pointer: fine) { .landing-feature:is(:hover, :focus-within) { transform: none; } } }
.landing-feature.flipped .landing-feature-copy { order: -1; }
/* One rounded shape: the painting and the glass copy share edges with no gap. */
.landing-feature-copy { display: grid; align-content: center; padding: clamp(24px, 3.4vw, 40px); border: 0; border-radius: 0; box-shadow: none; }
.landing-feature-icon { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 16px; background: color-mix(in srgb, var(--hue) 18%, transparent); color: var(--hue); transform: rotate(-6deg); }
.landing-feature h2, .landing-closing h2 { margin: 14px 0 10px; font-size: clamp(1.55rem, 3.2vw, 2.2rem); line-height: 1.15; letter-spacing: -.02em; text-wrap: balance; }
.landing-feature .lede { margin: 0; }
.landing-feature ul { display: grid; gap: 10px; margin: 20px 0 0; padding: 0; list-style: none; }
.landing-feature li { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); }
.landing-feature li svg { flex: none; color: var(--hue); }
.landing-feature-art { position: relative; display: grid; place-items: center; min-height: clamp(280px, 34vw, 420px); overflow: hidden; border: 0; border-radius: 0; background: radial-gradient(circle at 18% 14%, color-mix(in srgb, var(--hue) 42%, transparent), transparent 55%), radial-gradient(circle at 88% 92%, color-mix(in srgb, var(--hue) 30%, transparent), transparent 50%), color-mix(in srgb, var(--hue) 8%, var(--surface)); }
.landing-feature-art > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: landing-backdrop-in 1s ease both; }
.landing-feature-painting { position: absolute; top: 16px; left: 16px; }
.landing-feature-art[data-ready="false"] .landing-feature-painting { background: color-mix(in srgb, var(--hue) 40%, rgba(12, 13, 17, .6)); }
.landing-vignette { position: absolute; right: 18px; bottom: 18px; display: grid; gap: 10px; width: min(340px, calc(100% - 36px)); padding: 16px 18px; border-radius: 20px; }
.landing-feature.flipped .landing-vignette { right: auto; left: 18px; }
.landing-reading { margin: 0; color: #fff; font-family: var(--font-reading); font-size: 1.25rem; line-height: 1.6; }
.landing-chunks { display: flex; flex-wrap: wrap; gap: 8px; }
.landing-chunk { display: grid; gap: 1px; padding: 8px 12px; border-bottom: 3px solid var(--hue); border-radius: 12px; background: color-mix(in srgb, var(--hue) 28%, rgba(255, 255, 255, .06)); }
.landing-chunk strong { font-family: var(--font-reading); font-size: 1.15rem; }
.landing-chunk small { color: color-mix(in srgb, var(--hue) 55%, #fff); font-size: .62rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.landing-chunk span { color: #e4e6ec; font-size: .82rem; }
.landing-grammar-note { display: flex; gap: 8px; margin: 0; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .14); color: #e4e6ec; font-size: .86rem; line-height: 1.45; }
.landing-grammar-note svg { flex: none; margin-top: 2px; color: #ffd166; }
.landing-stage-goal { display: grid; grid-template-columns: 1fr auto; gap: 0 12px; font-size: .9rem; }
.landing-stage-goal small { grid-column: 1; color: #c9ccd6; font-size: .6rem; letter-spacing: .1em; text-transform: uppercase; }
.landing-stage-goal strong { grid-column: 1; }
.landing-stage-goal span { grid-row: 1 / 3; grid-column: 2; align-self: center; color: #c9ccd6; }
.landing-stage-caption { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 255, 255, .1); font-family: var(--font-reading); font-size: 1.1rem; }
.landing-stage-help { display: inline-flex; align-items: center; gap: 6px; justify-self: end; padding: 6px 10px; border: 1px solid var(--landing-ink-border); border-radius: 999px; font-size: .74rem; font-weight: 650; }
.landing-phone-status { display: inline-flex; align-items: center; gap: 8px; justify-self: center; margin: 0; padding: 6px 12px; border: 1px solid var(--landing-ink-border); border-radius: 999px; font-size: .8rem; font-weight: 600; }
.landing-phone-status span { width: 8px; height: 8px; border-radius: 50%; background: var(--hue); box-shadow: 0 0 0 4px color-mix(in srgb, var(--hue) 30%, transparent); }
.landing-vignette > small { justify-self: center; color: #c9ccd6; font-size: .72rem; }
.landing-phone-caption { margin: 0; font-size: 1.05rem; font-weight: 500; line-height: 1.4; text-align: center; }
.landing-phone-controls { display: flex; align-items: center; justify-content: center; gap: 14px; }
.landing-phone-controls span { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.landing-phone-controls span.mic { width: 54px; height: 54px; background: var(--hue); color: #fff; }
.landing-spoken { color: #c9ccd6; }
.landing-speaking { padding: 1px 3px; border-radius: 5px; background: rgba(255, 255, 255, .2); box-shadow: inset 0 -3px #7cc4ff; }
.landing-player { display: flex; align-items: center; gap: 14px; }
.landing-player .welcome-bubble-audio { display: grid; flex: none; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: #fff; color: #16171b; }
.landing-player .tag { margin: 0; background: rgba(255, 255, 255, .14); color: #e4e6ec; }
.landing-wave { display: flex; flex: 1; align-items: center; gap: 4px; height: 28px; }
.landing-wave span { width: 4px; height: 40%; border-radius: 4px; background: var(--hue); animation: landing-wave 1.1s ease-in-out infinite; }
.landing-wave span:nth-child(2n) { animation-delay: .15s; }
.landing-wave span:nth-child(3n) { animation-delay: .3s; }
@keyframes landing-wave { 50% { height: 100%; } }
.landing-flashcard { display: grid; justify-items: center; gap: 6px; padding: 10px 0 4px; text-align: center; }
.landing-flashcard strong { font-family: var(--font-reading); font-size: 1.7rem; }
.landing-flashcard > span { color: #c9ccd6; }
.landing-flashcard-actions { display: flex; gap: 12px; margin-top: 8px; }
.landing-flashcard-actions span { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--landing-ink-border); border-radius: 50%; color: #e4e6ec; }
.landing-flashcard-actions span.good { border-color: var(--hue); background: var(--hue); color: #fff; }
.landing-goal { display: flex; align-items: center; justify-content: center; gap: 28px; }
.landing-ring { display: grid; width: 120px; height: 120px; place-items: center; align-content: center; border-radius: 50%; background: radial-gradient(closest-side, #202226 78%, transparent 79%), conic-gradient(var(--hue) calc(var(--progress) * 1%), rgba(255, 255, 255, .14) 0); }
.landing-ring strong { font-size: 1.8rem; line-height: 1; }
.landing-ring small { color: #c9ccd6; }
.landing-streak { display: grid; justify-items: center; gap: 4px; color: var(--hue); }
.landing-streak strong { font-size: 1.5rem; }

/* ----- Closing, catalog, dock ----- */
.landing-closing { position: relative; z-index: 1; display: grid; justify-items: center; width: min(760px, 100%); margin-top: clamp(56px, 9vw, 100px); padding: clamp(32px, 6vw, 56px); border-radius: 32px; background: linear-gradient(135deg, color-mix(in srgb, var(--flag-1, #ff7a59) 18%, transparent), color-mix(in srgb, var(--flag-2, #ec4899) 14%, transparent) 45%, color-mix(in srgb, var(--flag-3, #0ea5e9) 16%, transparent)), var(--landing-glass); text-align: center; }
.landing-closing .lede { margin: 0 0 24px; }
/* Extend the existing action over the card while keeping one keyboard target. */
.landing-closing { cursor: pointer; transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease; }
.landing-closing .welcome-start { position: static; transform: none; }
.landing-closing .welcome-start::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: 32px; }
@media (hover: hover) and (pointer: fine) { .landing-closing:hover { border-color: var(--border-strong); box-shadow: 0 28px 76px rgb(0 0 0 / .19), 0 3px 12px rgb(0 0 0 / .08); transform: translateY(-3px); } }
.landing-closing .welcome-start:focus-visible { outline: none; }
@media (prefers-reduced-motion: reduce) { .landing-closing { transition: none; } @media (hover: hover) and (pointer: fine) { .landing-closing:hover { transform: none; } } }
.reader-popup.landing-language-list ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: 8px; margin: 0; padding: 0; list-style: none; }
.landing-language-list li { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
.landing-language-list li:has(> .marketing-language-choice) { padding: 0; border: 0; }
button.marketing-language-choice { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: none; color: var(--text); text-align: start; }
@media (hover: hover) and (pointer: fine) { button.marketing-language-choice:hover { border-color: var(--border-strong); background: var(--surface-hover); } }
button.marketing-language-choice[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.landing-language-list li > span:last-child, .marketing-language-choice > span:last-child { display: grid; grid-template-columns: minmax(0, 1fr); flex: 1; min-width: 0; }
.landing-language-list strong, .landing-language-list small { min-width: 0; overflow-wrap: anywhere; line-height: 1.4; }
.landing-language-list small { color: var(--muted); white-space: normal; }
.landing-language-flags { flex: none; min-width: 2.4em; font-size: 1.1rem; letter-spacing: .1em; }
.landing-dock { position: fixed; z-index: 20; bottom: max(20px, env(safe-area-inset-bottom)); left: 50%; opacity: 0; pointer-events: none; transform: translate(-50%, 160%); transition: transform .45s cubic-bezier(.2, .9, .3, 1.15), opacity .3s ease; }
.landing-dock button.welcome-start { box-shadow: 0 14px 36px rgb(0 0 0 / .22); }
.landing[data-docked] .landing-dock { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
@media (max-width: 960px) {
  .landing-hero { grid-template-columns: 1fr; margin-top: 0; }
  .landing-hero-stage { order: -1; }
  /* Leave a visible stretch of artwork above the compact reading demonstration. */
  .landing-stage { min-height: clamp(440px, 100vw, 640px); padding-top: 180px; }
  .landing-stage-top { display: none; }
  .landing-stage-panel { padding: clamp(11.2px, 1.92vw, 17.6px) clamp(12.8px, 2.08vw, 20.8px); border-radius: 18px; }
  .landing-sentence { font-size: clamp(1.08rem, 2.08vw, 1.64rem); row-gap: 8px; }
  .landing-word-reading { font-size: max(.576rem, .42em); }
  .landing-translation { margin-top: 8px; font-size: .784rem; }
  .landing-bubble { width: min(240px, calc(100% - 32px)); gap: 5px; padding: 11px 13px; border-radius: 15px; }
  .landing-bubble-header { gap: 8px; }
  .landing-bubble-header strong { font-size: 1.08rem; }
  .landing-bubble-header .tag { padding: 2px 7px; font-size: .592rem; }
  .landing-bubble-header .icon-button { width: 24px; min-width: 24px; height: 24px; padding: 3px; }
  .landing-bubble-reading { font-size: .72rem; }
  .landing-bubble-meaning { font-size: .84rem; }
  .landing-bubble-note { gap: 6px; padding-top: 6px; font-size: .688rem; }
  .landing-stage :is(.landing-sentence-audio, .landing-bubble) .speech-button { width: 32px; height: 32px; min-width: 32px; }
  .landing-stage :is(.landing-sentence-audio, .landing-bubble) .speech-button .shell-icon { width: .8rem; height: .8rem; }
  .landing-feature { grid-template-columns: 1fr; }
  .landing-feature.flipped .landing-feature-copy { order: 0; }
}
@media (max-width: 600px) {
  .landing-hero-copy { padding: 22px 18px; }
  .landing button.welcome-start { width: 100%; }
  .landing-language-count { width: 100%; }
  .landing-stage-panel { margin: 10px; padding: 11px; border-radius: 15px; }
  .landing-vignette { right: 10px; bottom: 10px; width: calc(100% - 20px); padding: 12px 14px; }
  .landing-feature.flipped .landing-vignette { left: 10px; }
  .landing-dock { right: 16px; left: 16px; transform: translateY(160%); }
  .landing[data-docked] .landing-dock { transform: none; }
  .landing-dock button.welcome-start { width: 100%; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { .landing-dock { transition: opacity .2s ease; } .landing-wave span, .landing-hero-language, .landing-reel-item, .landing-stage-title, .landing-stage-art > img, .landing-feature-art > img { animation: none; } }

/* ---------- App shell ---------- */
.app-shell { --header-height: calc(60px + env(safe-area-inset-top)); --sidebar-width: calc(256px + env(safe-area-inset-left) + env(safe-area-inset-right)); --content-inset-start: var(--sidebar-width); display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100dvh; padding-top: var(--header-height); }
.app-shell.sidebar-collapsed { --sidebar-width: calc(76px + env(safe-area-inset-left) + env(safe-area-inset-right)); }
.app-header { position: fixed; z-index: 86; inset: 0 0 auto; height: var(--header-height); display: flex; align-items: center; gap: 12px; padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent); background: color-mix(in srgb, var(--sidebar) 66%, transparent); backdrop-filter: saturate(1.4) blur(18px); -webkit-backdrop-filter: saturate(1.4) blur(18px); }
.header-navigation { display: flex; flex: none; align-items: center; gap: 8px; }
.header-logo { display: inline-flex; align-items: center; flex: none; color: var(--text); border-radius: 4px; }
@media (hover: hover) and (pointer: fine) { .header-logo:hover { color: var(--text); opacity: .8; } }
.header-logo-home { gap: 8px; border-radius: 10px; }
@media (hover: hover) and (pointer: fine) { .header-logo-home:hover { background: var(--surface-subtle); opacity: 1; } }
@media (hover: hover) and (pointer: fine) { .header-logo-home:hover .header-home { color: inherit; } }
.header-logo[data-home-repeat-area="true"] { padding-inline-end: 48px; }
.header-screen-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.15rem; font-weight: 750; letter-spacing: -.025em; }
.header-home { display: inline-grid; place-items: center; flex: none; width: 40px; height: 40px; color: var(--text-secondary); }
.app-shell button.shell-icon-button { display: inline-grid; place-items: center; flex: none; width: 40px; min-width: 40px; height: 40px; padding: 0; border: 0; border-radius: 10px; background: transparent; color: var(--text-secondary); }
@media (hover: hover) and (pointer: fine) { .app-shell button.shell-icon-button:hover { background: var(--surface-subtle); color: var(--text); } }
.header-home .shell-icon { fill: currentColor; }
.sidebar { position: fixed; z-index: 79; top: var(--header-height); bottom: 0; inset-inline-start: 0; width: var(--sidebar-width); display: flex; flex-direction: column; gap: 6px; padding: 16px max(12px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); border-inline-end: 1px solid color-mix(in srgb, var(--border) 70%, transparent); background: color-mix(in srgb, var(--sidebar) 66%, transparent); backdrop-filter: saturate(1.4) blur(18px); -webkit-backdrop-filter: saturate(1.4) blur(18px); transition: width .2s var(--ease), transform .25s var(--ease); }
.app-header { transition: background-color .2s ease; }
:root[data-scrolled="true"] .app-header { background: color-mix(in srgb, var(--sidebar) 94%, transparent); }
@media (prefers-reduced-transparency: reduce) { .app-header, .sidebar { background: var(--sidebar); backdrop-filter: none; -webkit-backdrop-filter: none; } }
.sidebar-context { margin-bottom: 10px; }
.sidebar-scrim { display: none; }
.sidebar-copy { min-width: 0; }
.sidebar-collapsed .sidebar-copy { display: none; }
.sidebar-collapsed .sidebar { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
.sidebar-nav { display: grid; gap: 2px; min-height: 0; overflow-y: auto; padding: 3px; margin: -3px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 10px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--text-secondary); text-align: start; font-size: .95rem; font-weight: 600; transition: background-color .14s ease, color .14s ease; }
.nav-item .shell-icon { color: var(--muted); transition: color .14s ease; }
.sidebar-collapsed .nav-item { justify-content: center; padding-inline: 0; }
@media (hover: hover) and (pointer: fine) { .nav-item:hover { background: var(--surface-subtle); color: var(--text); } }
@media (hover: hover) and (pointer: fine) { .nav-item:hover .shell-icon { color: var(--text-secondary); } }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item.active .shell-icon { color: var(--accent); }
.app-shell > .workspace { grid-column: 2; min-width: 0; }

.profile-menu { position: relative; }
.profile-menu.is-open { z-index: 40; }
.language-menu-backdrop { position: fixed; inset: 0; z-index: 28; }
.profile-menu.is-open > .profile-menu-trigger { z-index: 31; }
.profile-menu-trigger { position: relative; display: grid; width: 100%; gap: 3px; padding-block: 10px; padding-inline: 12px 34px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-align: start; font-weight: 500; box-shadow: var(--shadow-sm); justify-content: stretch; }
@media (hover: hover) and (pointer: fine) { .profile-menu-trigger:hover { border-color: var(--border-strong); background: var(--surface); color: var(--text); } }
.profile-menu-trigger small { overflow: hidden; color: var(--muted); font-size: .72rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.profile-menu-label, .source-switcher label { color: var(--muted); font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.profile-menu .chevron { position: absolute; top: 50%; inset-inline-end: 11px; color: var(--muted); transform: translateY(-50%); }
.sidebar .learning-profile-trigger { display: flex; align-items: center; gap: 12px; min-height: 60px; }
.profile-menu-copy { display: grid; gap: 1px; }
.profile-menu-copy strong { font-size: 1rem; font-weight: 680; }
.learning-profile-flag { display: grid; flex: none; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--surface-subtle); font-size: 1.35rem; line-height: 1; }
.sidebar-collapsed .learning-profile-trigger { justify-content: center; width: 52px; min-height: 52px; padding: 6px; border-color: transparent; background: transparent; box-shadow: none; }
.profile-menu-popover { position: absolute; z-index: 32; top: calc(100% + 8px); inset-inline-start: 0; width: min(340px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 100px)); overflow-y: auto; padding: 8px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-raised); animation: popover-in .16s var(--ease) both; }
@keyframes popover-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.sidebar .profile-menu-popover { width: min(320px, calc(100vw - var(--sidebar-width) - 24px)); max-height: calc(100dvh - var(--header-height) - 40px); }
.sidebar-collapsed .sidebar .profile-menu .profile-menu-popover { top: 0; inset-inline-start: calc(100% + 12px); }
.profile-menu-list { display: grid; gap: 2px; margin: 0 0 6px; }
.profile-quick { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); text-align: start; font-weight: 500; }
@media (hover: hover) and (pointer: fine) { .profile-quick:hover { background: var(--surface-subtle); } }
.profile-quick.active { background: var(--accent-soft); color: var(--text); }
.profile-quick small { color: var(--muted); }
.menu-check { display: grid; color: var(--accent); }
.profile-menu-actions { display: grid; gap: 2px; padding-top: 6px; border-top: 1px solid var(--border); }
.menu-item { display: flex; width: 100%; align-items: center; justify-content: flex-start; gap: 11px; min-height: 42px; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: .92rem; font-weight: 550; text-align: start; text-decoration: none; }
.menu-item .shell-icon { color: var(--muted); }
@media (hover: hover) and (pointer: fine) { .menu-item:hover { background: var(--surface-subtle); color: var(--text); } }
.menu-item.danger, .menu-item.danger .shell-icon { color: var(--danger); }
@media (hover: hover) and (pointer: fine) { .menu-item.danger:hover { background: var(--danger-soft); } }
.language-menu-choice { display: flex; align-items: center; gap: 10px; min-width: 0; }
.language-menu-flag { flex: none; font-size: 1.25rem; }
.language-menu-names { display: grid; gap: 1px; min-width: 0; }
.language-menu-names strong { font-size: .92rem; font-weight: 650; }
.language-menu-names small { color: var(--muted); font-size: .76rem; }
.account-menu { flex: none; margin: 0; }
.app-header .header-daily-xp { display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: none; margin-inline-start: auto; min-height: 40px; padding: 6px; border: 0; border-radius: 10px; background: transparent; box-shadow: none; color: var(--text-secondary); font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .app-header .header-daily-xp:hover { background: var(--surface-subtle); color: var(--text); } }
.header-xp-ring { flex: none; color: var(--xp); }
.header-xp-track { stroke: var(--border-strong); }
.header-xp-fill { stroke: currentColor; transition: stroke-dasharray 350ms ease; }
.header-xp-goal, .header-xp-unit { color: var(--muted); font-weight: 450; }
@media (max-width: 380px) { .header-xp-goal { display: none; } }
@media (prefers-reduced-motion: reduce) { .header-xp-fill { transition: none; } }
.account-chip { display: flex; align-items: center; justify-content: center; width: 40px; min-height: 40px; padding: 2px; border: 0; border-radius: 50%; background: transparent; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .account-chip:hover { background: var(--surface-subtle); } }
.account-menu > .profile-menu-popover { inset-inline-end: 0; inset-inline-start: auto; max-height: min(720px, calc(100dvh - var(--header-height) - 16px)); }
/* The filtered header contains fixed descendants; extend dismissal over the page. */
.app-header .language-menu-backdrop { height: 100dvh; }
.account-menu-heading { display: flex; align-items: center; gap: 12px; padding: 8px 8px 12px; border-radius: var(--radius); color: var(--text); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .account-menu-heading:hover { background: var(--surface-subtle); } }
.account-menu-heading div { display: grid; min-width: 0; }
.account-menu-heading small { color: var(--muted); }
.profile-subscription-summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.profile-subscription-summary > div { display: grid; gap: 4px; }
.profile-subscription-summary .field-label { color: var(--muted); font-size: .82rem; }
.profile-subscription-summary strong { font-size: 1.15rem; }
.account-menu .token-budget-badge { margin: 8px 0; }
.account-menu .source-switcher { margin: 0 0 4px; }
.account-menu .source-switcher > .profile-menu-trigger { box-shadow: none; }
.avatar { display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; border-radius: 50%; background: linear-gradient(140deg, var(--avatar-start), var(--avatar-end)); color: var(--avatar-text); font-size: .95rem; font-weight: 750; text-transform: uppercase; }
.source-switcher { display: grid; gap: 4px; }
.context-error { color: var(--danger); line-height: 1.35; }

/* Compact screen titles are managed once by shell/screen_header.js. */
.screen-docked-header { position:absolute; top:calc(100% + 1px); inset-inline:var(--content-inset-start,0px) 0; min-height:48px; color:var(--text); border-bottom:1px solid var(--border); background:color-mix(in srgb,var(--sidebar) 94%,transparent); backdrop-filter:blur(18px); -webkit-backdrop-filter:blur(18px); opacity:0; visibility:hidden; pointer-events:none; transition:opacity .18s ease,visibility 0s .22s; }
.screen-docked-header[data-docked="true"] { opacity:1; visibility:visible; pointer-events:auto; transition-delay:0s; }
.screen-docked-inner { display:flex; align-items:center; gap:14px; width:min(1120px,100%); min-height:48px; margin-inline:auto; padding:2px clamp(20px,4.5vw,64px); }
.screen-title-group { flex:1; min-width:0; }
.screen-supertitle:not([hidden]) { display:block; margin:0 0 3px; color:var(--muted); font-size:.8rem; font-weight:650; line-height:1.25; }
.screen-docked-heading .screen-supertitle { margin-bottom:1px; font-size:.7rem; }
.screen-docked-title { margin:0; font-size:1.05rem; font-weight:720; line-height:1.3; letter-spacing:-.02em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.screen-docked-back { display:inline-flex; align-items:center; gap:5px; flex:0 1 auto; min-width:44px; max-width:38%; min-height:44px; padding:4px 7px; margin-inline-start:-7px; border-radius:7px; background:transparent; color:var(--text-secondary); font-size:.85rem; font-weight:550; text-decoration:none; box-shadow:none; transition:background-color .15s,color .15s; }
.screen-docked-back[hidden] { display:none; }
.screen-docked-back > span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.screen-docked-back .shell-icon { flex:none; }
@media (hover: hover) and (pointer: fine) { .screen-docked-back:hover { color:var(--text); background:var(--surface-subtle); } }
[data-screen-docked-source="true"] { visibility:hidden !important; pointer-events:none; }
[dir="rtl"] .screen-docked-back svg { transform:scaleX(-1); }
@media(prefers-reduced-motion:reduce) { .screen-docked-header,.screen-docked-back { transition:none; } }
@media(prefers-reduced-transparency:reduce) { .screen-docked-header { background:var(--sidebar); backdrop-filter:none; -webkit-backdrop-filter:none; } }

/* ---------- Page scaffolding ---------- */
.workspace { --workspace-gutter: clamp(20px, 4.5vw, 64px); --workspace-top: 44px; --page-column-width: 1000px; --page-title-size: clamp(1.85rem, 3.2vw, 2.45rem); width: min(1120px, 100%); margin: 0 auto; padding: var(--workspace-top) max(var(--workspace-gutter), env(safe-area-inset-right)) max(88px, env(safe-area-inset-bottom)) max(var(--workspace-gutter), env(safe-area-inset-left)); }
.page-header { max-width: 760px; margin-bottom: 28px; }
.page-header .lede { margin-bottom: 0; }
.page-back { margin: 0 0 18px -10px; }
.surface { padding: clamp(20px, 3vw, 30px); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.surface + .surface { margin-top: 18px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-heading h2 { margin: 0; }
.dashboard-grid { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(340px, 1.2fr); gap: 18px; align-items: start; }
.empty-state { display: grid; justify-items: center; padding: 44px 16px; color: var(--muted); text-align: center; }
.empty-state h3 { margin: 0 0 6px; color: var(--text); font-size: 1.1rem; }
.empty-state p { max-width: 420px; margin: 0; line-height: 1.55; }
.empty-glyph { position: relative; display: grid; width: 64px; height: 64px; margin-bottom: 16px; place-items: center; border-radius: 20px; background: var(--accent-soft); color: var(--accent); }
.empty-bubble { position: absolute; top: -6px; right: -8px; width: 20px; height: 20px; border-radius: 50% 50% 50% 0; background: var(--marigold); }
.book-cover { position: relative; display: grid; flex: none; width: 64px; height: 84px; place-items: center; overflow: hidden; border-radius: 6px 12px 12px 6px; background: var(--cover-bg); color: var(--cover-ink); box-shadow: inset 4px 0 0 rgba(0, 0, 0, .08), var(--shadow-sm); }
.book-cover::after { position: absolute; top: 9px; right: 9px; width: 11px; height: 11px; border-radius: 50% 50% 50% 0; background: var(--cover-dot); content: ""; }
.book-cover-initial { font-family: var(--font-reading); font-size: 1.9rem; font-weight: 600; line-height: 1; }
.book-cover.small { width: 44px; height: 56px; border-radius: 5px 9px 9px 5px; }
.book-cover.small::after { top: 6px; right: 6px; width: 8px; height: 8px; }
.book-cover.small .book-cover-initial { font-size: 1.3rem; }
.cover-0 { --cover-bg: var(--accent-soft); --cover-ink: var(--accent-ink); --cover-dot: var(--marigold); }
.cover-1 { --cover-bg: var(--marigold-soft); --cover-ink: var(--marigold-ink); --cover-dot: var(--accent); }
.cover-2 { --cover-bg: var(--coral-soft); --cover-ink: color-mix(in srgb, var(--coral) 70%, var(--text)); --cover-dot: var(--marigold); }
.cover-3 { --cover-bg: var(--sky-soft); --cover-ink: color-mix(in srgb, var(--sky) 70%, var(--text)); --cover-dot: var(--coral); }

/* ---------- Home ---------- */
/* Home tints derive from the selected variety's flag colours (--flag-1..3 are
   set inline on .home-dashboard); the XP accent is reserved for progress. */
.home-dashboard { --home-tint-soft: color-mix(in srgb, var(--flag-1) 14%, var(--surface)); --home-tint-ink: color-mix(in srgb, var(--flag-1) 62%, var(--text)); position: relative; }
/* Home spans the content area; its grid keeps the feed in a centred column. */
.workspace:has(.home-dashboard, .reading-library-page) { width: 100%; max-width: none; padding-inline: 0; }
:root { --activity-tile-max-width: 26rem; }
.home-dashboard, .reading-library-page {
  --activity-tile-max-width: 31.25rem;
  --recent-grid-gap: 16px;
  display: grid;
  grid-template-columns:
    minmax(max(var(--workspace-gutter, 24px), env(safe-area-inset-left)), 1fr)
    minmax(0, calc(2 * var(--activity-tile-max-width) + var(--recent-grid-gap)))
    minmax(max(var(--workspace-gutter, 24px), env(safe-area-inset-right)), 1fr);
}
.home-dashboard > :not(.home-flag-wash, .home-hero), .reading-library-page > * { grid-column: 2; min-width: 0; }
/* A large, faded wash of the flag's colours spans the top of Home behind the
   hero's lower edge, the goal card and the first rows, then dissolves. */
.home-flag-wash { position: fixed; z-index: -1; top: var(--header-height, 60px); inset-inline: var(--content-inset-start, 0px) 0; height: calc(100dvh - var(--header-height, 60px)); pointer-events: none; background: radial-gradient(62% 48% at 12% 36%, color-mix(in srgb, var(--flag-1) 34%, transparent), transparent 72%), radial-gradient(58% 44% at 56% 52%, color-mix(in srgb, var(--flag-2) 30%, transparent), transparent 72%), radial-gradient(52% 46% at 96% 30%, color-mix(in srgb, var(--flag-3) 26%, transparent), transparent 72%); -webkit-mask-image: linear-gradient(180deg, transparent 0, rgba(0, 0, 0, .55) 16%, #000 30%, #000 46%, transparent 100%); mask-image: linear-gradient(180deg, transparent 0, rgba(0, 0, 0, .55) 16%, #000 30%, #000 46%, transparent 100%); }
.home-dashboard > :not(.home-flag-wash) { position: relative; }
/* The Home heading spans the workspace edges. */
.home-hero { position: relative; grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-content: end; margin: 0; padding: 0 0 78px; }
.home-hero-copy { position: relative; z-index: 2; grid-column: 2; display: grid; gap: 6px; max-width: min(100%, 620px); }
/* The open language menu must rise above the goal card that overlaps the hero. */
.home-hero-copy:has(.profile-menu.is-open) { z-index: 41; }
.home-hero-eyebrow { margin: 0 0 4px; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.home-hero h1 { display: flex; align-items: center; gap: 20px; margin: 0; font-size: clamp(2.5rem, 4.5vw, 3.5rem); line-height: 1.15; }
.home-flag { flex: none; font-size: 1.15em; line-height: 1; letter-spacing: 0; }
@media (max-width: 760px) {
  .home-hero { padding-bottom: 64px; }
}
.search-field { display: flex; align-items: center; gap: 10px; padding: 5px 5px 5px 14px; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow-sm); transition: border-color .15s ease, box-shadow .15s ease; }
.search-field:focus-within { border-color: var(--accent);  }
.search-field input, .search-field input:focus { flex: 1; min-width: 0; padding: 8px 0; border: 0; outline: 0; background: transparent; box-shadow: none; }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-field button { flex: none; min-height: 38px; padding: 8px 16px; }
.search-field.large { padding: 7px 7px 7px 18px; border-radius: 16px; }
.search-field.large input { padding: 10px 0; font-size: 1.08rem; }
.search-field.large button { min-height: 44px; padding: 10px 22px; border-radius: 11px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.home-grid.has-sidebar { grid-template-columns: minmax(0, 1fr) 320px; }
.home-main { display: grid; gap: 28px; min-width: 0; }
.home-side { display: grid; gap: 18px; position: sticky; top: calc(var(--header-height) + 24px); }
.home-side .surface + .surface { margin-top: 0; }
.continue-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 22px; align-items: center; min-height: 140px; padding: 24px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: linear-gradient(135deg, var(--surface) 55%, var(--accent-soft)); color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: transform .16s var(--ease), box-shadow .16s ease, border-color .16s ease; }
@media (hover: hover) and (pointer: fine) { .continue-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow-raised); transform: translateY(-2px); } }
.continue-card.is-loading { background: linear-gradient(100deg, var(--surface) 30%, var(--surface-subtle) 50%, var(--surface) 70%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.continue-copy { display: grid; gap: 6px; min-width: 0; }
.continue-title { overflow: hidden; font-size: 1.35rem; font-weight: 700; letter-spacing: -.015em; text-overflow: ellipsis; white-space: nowrap; }
.continue-copy small { color: var(--muted); font-size: .88rem; }
.continue-copy .meter { max-width: 260px; margin-top: 4px; }
.continue-action { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 11px; background: var(--accent); color: var(--accent-text); font-weight: 650; }
@media (hover: hover) and (pointer: fine) { .continue-card:hover .continue-action { background: var(--accent-hover); } }
.first-story { position: relative; display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 30px; align-items: center; overflow: hidden; padding: 30px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: linear-gradient(135deg, var(--surface) 40%, var(--accent-soft)); box-shadow: var(--shadow); }
.first-story h2 { margin: 8px 0 8px; font-size: 1.6rem; letter-spacing: -.02em; }
.first-story p:not(.eyebrow) { max-width: 520px; margin-bottom: 20px; color: var(--text-secondary); line-height: 1.6; }
.first-story-art { position: relative; height: 150px; }
.first-story-page { position: absolute; inset: 14px 30px 0 10px; border-radius: 8px 18px 18px 8px; background: var(--surface); box-shadow: var(--shadow-raised), inset 6px 0 0 var(--accent-soft); background-image: linear-gradient(var(--border) 2px, transparent 2px); background-size: 100% 18px; background-position: 0 30px; background-clip: content-box; padding: 24px 22px 18px 26px; }
.first-story-bubble { position: absolute; top: 0; right: 4px; width: 54px; height: 54px; border-radius: 50% 50% 50% 0; background: var(--marigold); box-shadow: var(--shadow); animation: gentle-float 2.4s ease-in-out infinite; }
.home-recent { display: grid; gap: 0; }
.home-recent .section-heading { margin-bottom: 10px; }
.home-resume .section-heading h2, .home-recent .section-heading h2, .home-activities h2, .home-side h2 { margin: 0; font-size: 1.05rem; }
.home-recent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.home-recent-item { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .14s ease, box-shadow .14s ease; }
@media (hover: hover) and (pointer: fine) { .home-recent-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow); } }
.home-recent-copy { display: grid; gap: 2px; min-width: 0; }
.home-recent-copy strong { overflow: hidden; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.home-recent-copy small { color: var(--muted); font-size: .8rem; }
.home-activities { display: grid; gap: 12px; }
.activity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.activity-tile { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .14s ease, box-shadow .14s ease, transform .14s var(--ease); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .activity-tile:hover { border-color: var(--tone); box-shadow: var(--shadow); transform: translateY(-1px); } }
.activity-icon { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 13px; background: var(--tone-soft); color: var(--tone); }
.activity-copy { display: grid; gap: 4px; min-width: 0; }
.activity-copy strong { font-size: 1rem; font-weight: 650; }
.activity-copy small { color: var(--text-secondary); font-size: .87rem; line-height: 1.45; }
.activity-arrow { align-self: center; color: var(--border-strong); transition: color .14s ease, transform .14s var(--ease); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .activity-tile:hover .activity-arrow { color: var(--tone); transform: translateX(2px); } }
.tone-jade { --tone: var(--accent); --tone-soft: var(--accent-soft); }
.tone-marigold { --tone: var(--marigold-ink); --tone-soft: var(--marigold-soft); }
.tone-coral { --tone: var(--coral); --tone-soft: var(--coral-soft); }
.tone-sky { --tone: var(--sky); --tone-soft: var(--sky-soft); }
.getting-started h2 { margin-bottom: 4px; }
.getting-started > p.muted { margin: 0 0 10px; font-size: .86rem; }
.checklist { display: grid; gap: 2px; margin: 16px 0 0; padding: 0; list-style: none; }
.checklist li { display: flex; align-items: center; gap: 11px; padding: 8px 0; color: var(--text); font-size: .92rem; }
.checklist li.done { color: var(--muted); }
.checklist li.done span:last-child { text-decoration: line-through; text-decoration-color: var(--border-strong); }
.checklist-mark { display: grid; flex: none; width: 22px; height: 22px; place-items: center; border: 2px solid var(--border-strong); border-radius: 50%; }
.checklist li.done .checklist-mark { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.checklist-link { color: var(--text); font-weight: 600; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .checklist-link:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; } }

/* ---------- Dictionary ---------- */
.dictionary-page { width: 100%; max-width: var(--page-column-width, 1000px); margin-inline: auto; }
.dictionary-search { display: grid; gap: 12px; }
.dictionary-search .search-field .icon-button { width: 44px; padding: 0; }
.dictionary-context { margin-top: 4px; display: flex; gap: 8px; align-items: flex-start; }
.dictionary-context-field { flex: 1; min-width: 0; }
.dictionary-context > .icon-button { flex: none; width: 44px; height: 44px; }
.search-bar { display: block; }
.search-results { display: grid; gap: 10px; margin-top: 18px; }
.search-results-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-results-heading p { margin: 0; font-size: .86rem; }
.search-result-with-audio { position: relative; display: flex; align-items: center; gap: 8px; padding: 14px 14px 14px 10px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); transition: border-color .14s ease, box-shadow .14s ease; }
@media (hover: hover) and (pointer: fine) { .search-result-with-audio:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); } }
.search-result-with-audio > .search-result { flex: 1; min-width: 0; }
.search-result { display: grid; width: 100%; gap: 4px; padding: 0 4px; border: 0; border-radius: 0; background: transparent; color: inherit; text-align: start; }
/* Stretch the entry link over the card, with the independent audio control above it. */
a.search-result { text-decoration: none; }
a.search-result::after { content: ""; position: absolute; inset: 0; border-radius: 14px; }
a.search-result:focus-visible { outline: none; }
.search-result-with-audio > .speech-control { position: relative; z-index: 1; }
.search-result strong { font-size: 1.12rem; }
.search-result b { color: var(--accent-ink); font-weight: 650; }
.search-result small { color: var(--muted); font-size: .88rem; }
.definition-controls { margin-top: 20px; }
.definition-context { margin-bottom: 0; }
.definition-context-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.meaning-section-title { margin: 24px 0 8px; color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.entry-card { margin-top: 18px; }
.entry-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.entry-title h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.4rem); letter-spacing: -.02em; }
.metadata { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 22px; color: var(--muted); }
.metadata span + span::before { content: "·"; margin-right: 8px; }
.meaning { padding: 20px 0; border-top: 1px solid var(--border); }
.meaning h4 { margin: 0 0 10px; font-size: 1.1rem; line-height: 1.45; }
blockquote { margin: 14px 0; padding: 12px 16px; border-left: 3px solid var(--marigold); border-radius: 0 10px 10px 0; background: var(--surface-subtle); line-height: 1.55; }
blockquote small { display: block; margin-top: 5px; color: var(--muted); }
.word-list, .document-list { display: grid; }
.word-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 0; border-top: 1px solid var(--border); }
.word-row:first-child { border-top: 0; }
.word-row p { margin: 3px 0; color: var(--text-secondary); }
.word-row small { display: block; color: var(--muted); }
.variety-notes { display: grid; gap: 10px; margin: 18px 0 24px; padding: 17px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-subtle); }
.variety-notes h3 { margin: 0 0 3px; }
.variety-note { display: grid; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.variety-note:first-of-type { padding-top: 0; border-top: 0; }
.variety-note p { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 9px; margin: 0; color: var(--text-secondary); font-size: .88rem; }
.variety-note p span { color: var(--muted); font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }

/* ---------- Reading library and flows ---------- */
.reader-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; margin-bottom: 34px; }
.reader-action-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 22px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm); transition: border-color .14s ease, box-shadow .14s ease, transform .14s var(--ease); }
@media (hover: hover) and (pointer: fine) { .reader-action-card:hover { border-color: var(--tone, var(--accent)); box-shadow: var(--shadow); transform: translateY(-1px); } }
.reader-action-card.generate { --tone: var(--accent); --tone-soft: var(--accent-soft); background: linear-gradient(135deg, var(--surface) 50%, var(--accent-soft)); }
.reader-action-card.import { --tone: var(--marigold-ink); --tone-soft: var(--marigold-soft); }
.reader-action-icon { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 15px; background: var(--tone-soft, var(--accent-soft)); color: var(--tone, var(--accent)); }
.reader-action-copy { display: grid; gap: 4px; min-width: 0; }
.reader-action-copy strong { font-size: 1.12rem; font-weight: 680; }
.reader-action-copy small { color: var(--text-secondary); font-size: .9rem; line-height: 1.45; }
.reader-action-arrow { color: var(--border-strong); transition: color .14s ease, transform .14s var(--ease); }
@media (hover: hover) and (pointer: fine) { .reader-action-card:hover .reader-action-arrow { color: var(--tone, var(--accent)); transform: translateX(2px); } }
.reader-library .section-heading h2 { font-size: 1.15rem; }
.document-list { gap: 10px; }
.document-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 12px 12px 14px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); transition: border-color .14s ease, box-shadow .14s ease; }
@media (hover: hover) and (pointer: fine) { .document-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); } }
.document-open { display: flex; flex: 1; align-items: center; gap: 14px; min-width: 0; padding: 0; border-radius: 0; background: transparent; color: inherit; text-align: start; }
.document-copy { display: grid; gap: 3px; min-width: 0; }
.document-copy strong { overflow: hidden; color: var(--text); font-size: 1.02rem; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.document-copy small { color: var(--muted); font-size: .84rem; }
.document-copy .meter { width: min(220px, 100%); margin-top: 4px; }
.reader-creation-popup .reader-flow-card {max-width:none;border:0;border-radius:0;box-shadow:none;padding:0;background:transparent}
.reader-creation-description {margin:0 0 24px;font-size:.95rem}
.reader-creation-popup .reader-popup-body {padding:24px}
@media(max-width:600px) {.reader-creation-popup .reader-popup-body {padding:16px}.reader-creation-popup .level-picker {grid-template-columns:repeat(2,minmax(0,1fr))}}
.reader-flow-card { max-width: 780px; }
.reader-flow-card > form, .compose form { display: grid; gap: 22px; margin-top: 0; }
.generation-context { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.generation-context > div { display: grid; gap: 1px; }
.generation-context small { color: var(--muted); font-size: .78rem; font-weight: 600; }
.generation-context strong { color: var(--text); font-size: 1.05rem; }
.generation-flag { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 13px; background: var(--surface-subtle); font-size: 1.5rem; }
.document-type-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.document-type-option { position: relative; display: grid; grid-template-rows: 1fr auto; justify-items: center; align-items: center; gap: 12px; min-width: 0; min-height: 116px; margin: 0; padding: 18px 8px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text-secondary); cursor: pointer; transition: border-color .14s ease, background-color .14s ease; }
.document-type-option input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
.document-type-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.document-type-option:has(input:disabled) { opacity: .55; cursor: wait; }
@media (hover: hover) and (pointer: fine) { .document-type-option:hover:not(:has(input:disabled)) { border-color: var(--accent); } }
.document-type-label { display: flex; align-items: end; justify-content: center; min-height: 2.5em; font-size: clamp(.76rem, 2.5vw, .9rem); font-weight: 600; line-height: 1.25; text-align: center; overflow-wrap: anywhere; }
.document-type-check { position: absolute; top: 7px; right: 7px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: var(--accent-text); pointer-events: none; }
.idea-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.level-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.level-option { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; transition: border-color .14s ease, background-color .14s ease; }
@media (hover: hover) and (pointer: fine) { .level-option:hover { border-color: var(--accent); } }
.level-option.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.level-option input { position: absolute; opacity: 0; pointer-events: none; }
.level-code { display: grid; width: max-content; min-width:40px; padding-inline:6px; box-sizing:border-box; white-space:nowrap; height: 40px; place-items: center; border-radius: 11px; background: var(--surface-subtle); color: var(--text-secondary); font-size: .88rem; font-weight: 750; }
.level-option.selected .level-code { background: var(--accent); color: var(--accent-text); }
.level-copy { display: grid; gap: 1px; min-width: 0; }
.level-copy strong { font-size: .92rem; font-weight: 650; }
.level-copy small { color: var(--muted); font-size: .78rem; line-height: 1.35; }
.generation-status { display: flex; align-items: center; gap: 10px; margin: 18px 0 0; color: var(--accent-ink); font-weight: 650; }
/* Loading labels stay in place; only their text opacity changes. */
.loading-label { animation: loading-label-opacity 1.8s ease-in-out infinite; }
@keyframes loading-label-opacity { 0%,100% {opacity:.6;} 50% {opacity:1;} }
@media (prefers-reduced-motion: reduce) { .loading-label {animation:none;} }

/* ---------- Settings and profiles ---------- */
.settings-layout { display: grid; gap: 18px; max-width: 860px; }
.progress-profile-banner { display:flex; align-items:center; gap:16px; padding:18px 22px; margin:20px 0 28px; border:1px solid var(--border); border-radius:18px; background:var(--surface); }
.progress-profile-flag { display:flex; align-items:center; flex:none; font-size:1.9rem; }
.progress-profile-banner > div { display:grid; gap:3px; min-width:0; }
.progress-profile-banner strong { font-size:1.3rem; }
.progress-profile-banner .muted { font-size:.82rem; }
@media (max-width:550px) { .progress-profile-banner { flex-wrap:wrap; padding:16px; gap:12px; } }
.settings-layout .surface + .surface { margin-top: 0; }
.settings-card > form, .settings-language-fields { display: grid; gap: 20px; margin-top: 20px; }
.settings-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.settings-heading h2 { margin: 0; font-size: 1.12rem; }
.settings-heading p { margin: 3px 0 0; font-size: .88rem; }
.settings-heading-copy { flex: 1; min-width: 0; }
.settings-restore-defaults { flex: none; align-self: flex-start; width: 44px; height: 44px; margin: -3px -3px 0 0; color: var(--text-secondary); }
.settings-icon { display: grid; flex: none; width: 38px; height: 38px; place-items: center; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }
.advanced-settings > summary { list-style: none; cursor: pointer; }
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings > summary .settings-heading { margin-bottom: 0; }
.advanced-settings[open] > summary .settings-heading { margin-bottom: 8px; }
.advanced-settings .settings-icon { background: var(--surface-subtle); color: var(--muted); }
.settings-select-label { display: grid; max-width: 420px; gap: 7px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-option { position: relative; display: grid; width: 100%; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; gap: 10px; align-items: start; justify-items: stretch; padding: 10px 10px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-align: start; font-weight: 500; }
@media (hover: hover) and (pointer: fine) { .theme-option:hover { border-color: var(--border-strong); background: var(--surface-hover); } }
.theme-option.selected { border-color: var(--accent); background: var(--surface); box-shadow: inset 0 0 0 1px var(--accent); }
.theme-option-copy { display: grid; gap: 2px; padding: 0 2px; }
.theme-option-copy strong { font-size: .92rem; }
.theme-option-copy small { color: var(--muted); font-size: .76rem; font-weight: 450; line-height: 1.35; }
.theme-selected { position: absolute; top: 16px; right: 16px; display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; background: var(--accent); color: var(--accent-text); box-shadow: 0 0 0 2px var(--surface); }
.theme-preview { display: grid; width: 100%; height: 64px; grid-template-columns: 26% 1fr; overflow: hidden; border: 1px solid rgba(128, 128, 128, .3); border-radius: 9px; }
.theme-preview-sidebar { background: var(--preview-sidebar); }
.theme-preview-content { display: grid; align-content: center; gap: 6px; padding: 9px; background: var(--preview-bg); }
.theme-preview-line { width: 64%; height: 5px; border-radius: 99px; background: var(--preview-accent); }
.theme-preview-card { height: 20px; border: 1px solid var(--preview-border); border-radius: 5px; background: var(--preview-surface); }
.theme-preview-light { --preview-bg: #f5f5f5; --preview-sidebar: #fafafa; --preview-surface: #fff; --preview-border: #e2e2e2; --preview-accent: #333333; --preview-text: #202020; --preview-muted: #707070; }
.theme-preview-dark { --preview-bg: #121212; --preview-sidebar: #161616; --preview-surface: #242424; --preview-border: #484848; --preview-accent: #d6d6d6; --preview-text: #ededed; --preview-muted: #969696; }
.theme-preview-calm { --preview-bg: #f1eadc; --preview-sidebar: #ece4d4; --preview-surface: #fbf7ee; --preview-border: #ddd2bf; --preview-accent: #805b3f; --preview-text: #2e2a22; --preview-muted: #847b6b; }
.theme-preview-tokyo-night { --preview-bg: #15161f; --preview-sidebar: #13141c; --preview-surface: #232638; --preview-border: #434a6c; --preview-accent: #7aa2f7; --preview-text: #c8d0f5; --preview-muted: #7f88ad; }
.theme-preview-system { --preview-bg: linear-gradient(90deg, #f5f5f5 50%, #121212 50%); --preview-sidebar: #fafafa; --preview-surface: linear-gradient(90deg, #fff 50%, #242424 50%); --preview-border: rgba(128, 128, 128, .45); --preview-accent: linear-gradient(90deg, #333333 50%, #d6d6d6 50%); }
.theme-preview-system .theme-preview-content { background: var(--preview-bg); }
.theme-preview-system .theme-preview-line, .theme-preview-system .theme-preview-card { width: 100%; }
.theme-preview-system .theme-preview-card { background: var(--preview-surface); }
.account-summary { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.language-profile-flag { display: grid; flex: none; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: var(--surface-subtle); font-size: 1.35rem; }
.settings-add-language { border-style: dashed; }
.settings-fluent-varieties { display: grid; gap: 10px; }
.settings-languages-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.settings-spoken-language { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-subtle); }
.settings-spoken-language.is-explanation { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface-subtle)); }
.settings-language-header { display: flex; align-items: flex-start; gap: 4px; }
button.settings-language-disclosure { flex: 1; min-width: 0; padding: 4px 2px; min-height: 40px; gap: 9px; color: var(--text); background: transparent; text-align: start; }
@media (hover: hover) and (pointer: fine) { button.settings-language-disclosure:hover:not(:disabled) { background: var(--surface-hover); } }
button.settings-language-disclosure:disabled { opacity: 1; }
.settings-language-flag { flex: none; font-size: 1.25rem; line-height: 1.2; }
.settings-language-name { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.settings-language-name strong { font-size: .95rem; }
.settings-explanation-badge { color: var(--accent); font-size: .65rem; line-height: 1.3; font-weight: 650; }
.settings-language-chevron { flex: none; display: flex; margin-inline-start: auto; color: var(--muted); transition: transform .15s ease; }
.settings-language-chevron.expanded { transform: rotate(180deg); }
.settings-language-actions { flex: none; display: flex; align-items: center; gap: 1px; }
.settings-language-actions .icon-button { width: 38px; min-width: 38px; height: 40px; }
@media (hover: hover) and (pointer: fine) { .settings-language-actions .settings-language-remove:hover { color: var(--danger); background: var(--danger-soft); } }
.settings-language-summary { margin: 5px 2px 0; color: var(--muted); font-size: .78rem; line-height: 1.5; overflow-wrap: anywhere; }
.settings-language-options { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.settings-language-options > .field-label { margin-bottom: 8px; }
.selected-variety-summary { width: fit-content; margin: 0; padding: 10px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-subtle); color: var(--text-secondary); font-weight: 650; }
.add-profile-screen { max-width: 920px; }
.add-profile-screen .form-actions { margin-top: 18px; }
.experience-prompt { display: grid; gap: 4px; }
.experience-prompt p { margin: 0; font-weight: 400; }
.profile-form-actions { justify-content: space-between; }
.flashcard-learning-settings { display: grid; gap: 16px; }
.flashcard-learning-settings p.muted { margin: 0; }

.flashcard-dimension-priority { display: grid; gap: 8px; min-width: 0; }
.flashcard-dimension-heading { display: flex; align-items: center; gap: 6px; }
.flashcard-dimension-heading h3 { margin: 0; font-size: 1rem; }
.flashcard-priority-column { justify-self: end; color: var(--text-secondary); font-size: .75rem; }
.flashcard-priority-rows { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.flashcard-priority-row { position: relative; display: grid; grid-template-columns: auto auto minmax(0, 1fr) 5rem; gap: 8px; align-items: center; padding: 5px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-subtle); }
.flashcard-priority-handle { cursor: grab; touch-action: none; }
.flashcard-priority-rank { color: var(--text-secondary); font-size: .75rem; font-variant-numeric: tabular-nums; }
.flashcard-priority-row .flashcard-priority-label { display: block; margin: 0; }
.flashcard-priority-row input.flashcard-priority-minimum { min-width: 0; width: 100%; padding: 6px 8px; font-variant-numeric: tabular-nums; }
.flashcard-priority-row.is-dragging { opacity: .5; }
.flashcard-priority-row.drop-before::before, .flashcard-priority-row.drop-after::after { content: ""; position: absolute; inset-inline: 5px; height: 2px; border-radius: 2px; background: var(--accent); pointer-events: none; }
.flashcard-priority-row.drop-before::before { top: -5px; }
.flashcard-priority-row.drop-after::after { bottom: -5px; }
.flashcard-priority-info p { margin: 0 0 .75rem; font-size: .9rem; }
.flashcard-settings-actions { display: flex; align-items: center; gap: 8px; }

/* ---------- Word readings ---------- */
.word-transliteration { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .45em; color: var(--text-secondary); font-size: .86rem; font-weight: 400; line-height: 1.45; }
.word-transliteration-text { font-family: inherit; }
.word-transliteration-readings { display: inline-flex; flex-direction: column; gap: 2px; }
.word-transliteration-context, .word-transliteration-base { display: inline-flex; align-items: baseline; gap: .4em; }
.word-reading-label { color: var(--muted); font-size: .78em; min-width: 4.5em; }
.word-reading-note { color: var(--muted); cursor: help; font-size: .8em; }
.word-spelling-and-reading { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.reader-word-gloss-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-width: 0; }
.reader-word-gloss { font-size: .9rem; font-weight: 650; overflow-wrap: anywhere; }

/* ---------- Reader ---------- */
[data-range-reader] :is([data-reader-text], [data-range-text]) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
[data-range-reader] :is(.reader-word, .guided-word) { -webkit-tap-highlight-color: transparent; }
::highlight(reader-range) { background-color: Highlight; color: HighlightText; }
.reader-range-actions { position: fixed; inset: auto; z-index: 100; display: grid; gap: .5rem; width: max-content; max-width: calc(100vw - 24px); box-sizing: border-box; margin: 0; padding: .65rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); font: 1rem/1.4 var(--font-sans); text-align: start; }
.reader-range-heading, .reader-range-buttons { display: flex; align-items: center; gap: .35rem; }
.reader-range-heading { justify-content: space-between; padding-inline-start: .4rem; }
.reader-range-heading strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-range-buttons { flex-wrap: wrap; }
.reader-range-buttons > :is(button, a) { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 40px; margin: 0; border-radius: 9px; padding-inline: .65rem; font-size: .875rem; }

.reader-view { max-width: 920px; margin: 0 auto; }
.reader-text-editor > .ghost { margin-bottom: 18px; }
.reader-source-input { min-height: 320px; resize: vertical; line-height: 1.65; }
.reader-edit-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.reader-view .section-heading { align-items: flex-start; }
.reading-page { --reading-padding: clamp(22px, 5vw, 56px); margin-top: 22px; padding: 8px var(--reading-padding) var(--reading-padding); border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
/* Serif type suits Latin, Greek and Cyrillic pages; other scripts read best in their system sans. */
.progressive-reading:is(:lang(zh), :lang(ja), :lang(ko), :lang(yue), :lang(nan), :lang(hak), :lang(wuu), :lang(th), :lang(lo), :lang(km), :lang(my), :lang(ar), :lang(fa), :lang(ur), :lang(he), :lang(hi), :lang(bn), :lang(ta), :lang(te), :lang(ml), :lang(kn), :lang(gu), :lang(pa), :lang(si), :lang(am), :lang(ka), :lang(hy), :lang(bo)) { font-family: var(--font-sans); }
.reader-line { margin: 0; white-space: pre-wrap; font-family: inherit; font-size: 1.2rem; line-height: 1.9; }
.reader-word { display: inline; margin: 0; padding: 0; border-radius: 2px; background: transparent; color: inherit; font: inherit; font-weight: inherit; }
.reader-word, .grammar-tag { --grammar-color: #84909e; }
.reader-word { --word-progress-color: color-mix(in srgb, var(--muted) 45%, transparent); position: relative; border-radius: 4px; padding-bottom: 2px; background: color-mix(in srgb, var(--word-progress-color) var(--reader-progress-fill, 0%), transparent); }
/* Inset each word's progress line without spacing out its characters. Cloning
   the decoration keeps the inset on wrapped fragments, above any pronunciation. */
.reader-word-source {
    --progress-line-color: color-mix(in srgb, var(--word-progress-underline, transparent) var(--reader-progress-line, 100%), transparent);
    background-image: linear-gradient(var(--progress-line-color), var(--progress-line-color));
    background-size: calc(100% - .16em) 2px;
    background-position: center bottom;
    background-repeat: no-repeat;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}
.reader-word[data-associated="true"] { background: color-mix(in srgb, var(--word-progress-color) 20%, transparent); }
.reader-word:focus-visible { background: color-mix(in srgb, var(--word-progress-color) 35%, transparent); color: var(--text); }
.reader-word[aria-expanded="true"] { background: color-mix(in srgb, var(--word-progress-color) 55%, transparent); }
.grammar-noun { --grammar-color: #3299cf; }
.grammar-proper-noun { --grammar-color: #566bd9; }
.grammar-verb { --grammar-color: #d96470; }
.grammar-auxiliary { --grammar-color: #ce779f; }
.grammar-pronoun { --grammar-color: #a57bd9; }
.grammar-adjective { --grammar-color: #4aad85; }
.grammar-adverb { --grammar-color: #ca9c38; }
.grammar-particle { --grammar-color: #c08041; }
.grammar-determiner { --grammar-color: #819754; }
.grammar-article { --grammar-color: #a2a444; }
.grammar-preposition { --grammar-color: #49a5ad; }
.grammar-postposition { --grammar-color: #5a9d91; }
.grammar-conjunction { --grammar-color: #a58469; }
.grammar-interjection { --grammar-color: #d58856; }
.grammar-numeral { --grammar-color: #9a8ad3; }
.grammar-tag { background: color-mix(in srgb, var(--grammar-color) 18%, var(--surface)); color: color-mix(in srgb, var(--grammar-color) 55%, var(--text)); }
/* Part-of-speech colors in guided and full text reading (a reader preference, on
   by default): each classified word's text takes its kind's hue. */
[data-part-of-speech-colors="true"] :is(.reader-word, .guided-word):is(.grammar-noun, .grammar-proper-noun, .grammar-verb, .grammar-auxiliary, .grammar-pronoun, .grammar-adjective, .grammar-adverb, .grammar-particle, .grammar-determiner, .grammar-article, .grammar-preposition, .grammar-postposition, .grammar-conjunction, .grammar-interjection, .grammar-numeral) { color: color-mix(in srgb, var(--grammar-color) 74%, var(--text)); }
.reader-display-menu .reader-part-of-speech-icon { width: 18px; height: 18px; flex: none; }
.reader-part-of-speech-icon rect { fill: var(--grammar-color); transition: fill .15s ease, opacity .15s ease; }
.reader-part-of-speech-toggle[aria-pressed="false"] .reader-part-of-speech-icon rect { fill: none; stroke: currentColor; stroke-width: 1.25; opacity: .65; }
.reader-preparation { margin: 18px 0; padding: 20px 22px; border: 1px solid var(--border); border-radius: 18px; background: linear-gradient(135deg, var(--surface), var(--accent-soft)); color: var(--text); }
.reader-preparation-heading { display: block; margin-bottom: 16px; font-size: .95rem; }
.reader-preparation-steps { list-style: none; display: grid; gap: 0; margin: 0; padding: 0; }
.reader-preparation-steps li { position: relative; display: flex; align-items: center; gap: 11px; min-height: 38px; font-size: .9rem; color: var(--muted); }
.reader-preparation-steps li:not(:last-child)::after { content: ''; position: absolute; width: 1px; height: 14px; background: var(--border-strong); inset-inline-start: 11.5px; top: 31px; }
.reader-preparation-circle { position: relative; display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border: 1.5px solid var(--border-strong); border-radius: 50%; box-sizing: border-box; background: var(--surface); font-weight: 700; transition: background .2s ease, border-color .2s ease, color .2s ease; }
.reader-preparation-steps li[data-state="running"] { color: var(--text); font-weight: 650; }
.reader-preparation-steps li[data-state="running"] .reader-preparation-circle { border-color: var(--accent-soft); background: var(--accent-soft); }
.reader-preparation-steps li[data-state="running"] .reader-preparation-circle::after { content: ''; position: absolute; inset: -1.5px; border: 2px solid transparent; border-top-color: var(--accent); border-right-color: var(--accent); border-radius: 50%; animation: preparation-spin 1s linear infinite; }
.reader-preparation-steps li[data-state="complete"] { color: var(--text-secondary); }
.reader-preparation-steps li[data-state="complete"] .reader-preparation-circle { background: var(--success); border-color: var(--success); color: white; }
.reader-preparation-steps li[data-state="failed"] .reader-preparation-circle { border-color: var(--warning); color: var(--warning-ink); background: var(--warning-soft); }
.reader-preparation-steps small { margin-inline-start: auto; color: var(--muted); font-size: .75rem; text-align: end; }
.reader-preparation-note { margin: 12px 0 0; color: var(--text-secondary); font-size: .8rem; }
.progressive-reading[data-finishing-analysis="true"] .chunk-progress { display: none; }
.reader-preparation .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@keyframes preparation-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .reader-preparation-circle { transition: none; } .reader-preparation-steps li[data-state="running"] .reader-preparation-circle::after { animation: none; } }
.reader-prep-callout { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 4px 0 14px; padding: 14px 16px; border-radius: 14px; background: var(--warning-soft); color: var(--warning-ink); }
.reader-prep-callout p { flex: 1; min-width: 220px; margin: 0; font-size: .92rem; line-height: 1.5; }
.reader-prep-callout strong { color: var(--text); }
.reader-prep-icon { display: grid; flex: none; }
.reader-prep-callout button { padding: 8px 14px; }
.progressive-reading { position: relative; font-family: var(--font-reading); }
.progressive-reading .reader-line { display: inline; }
.reader-synopsis-pending { display: inline-flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); color: var(--text); }
.reader-synopsis-pending .word-illustration-spinner { width: 22px; height: 22px; border-width: 3px; }
.reader-synopsis-pending strong { font-size: .95rem; font-weight: 600; }
.chunk-progress { display: inline-block; width: .22em; height: .22em; margin-inline: .3em; vertical-align: middle; border-radius: 50%; background: var(--accent); animation: reader-loading-pulse 1.4s ease-in-out infinite; }
@keyframes reader-loading-pulse { 0%, 100% { opacity: .4; transform: scale(.75); } 50% { opacity: 1; transform: scale(1); } }
.reader-word-bubble { position: fixed; z-index: 65; width: min(390px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow: auto; padding: 18px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-raised); color: var(--text); font-family: var(--font-sans); font-size: .9rem; line-height: 1.5; }
.reader-word-bubble header { display: flex; align-items: center; gap: 8px; }
.reader-word-bubble header > strong { font-size: 1.15rem; }
.reader-word-bubble header .ghost { margin-left: auto; }
.reader-word-bubble p { margin: 10px 0; }
.reader-word-bubble.grammar-tooltip { pointer-events: none; width: min(330px, calc(100vw - 24px)); }
.reader-word-bubble .reader-word-header { display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; align-items: start; }
.reader-word-bubble.reader-word-detail-bubble { padding: 0; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.reader-word-fixed { container: word-bubble-header / inline-size; position: sticky; top: 0; z-index: 2; display: flow-root; padding: 18px 18px 0; background: var(--surface); }
.reader-word-fixed > .reader-word-header { padding-bottom: 10px; }
.reader-word-fixed::after { content: ''; position: absolute; inset: auto 18px 0; height: 1px; background: var(--border); opacity: 0; transition: opacity .15s ease; pointer-events: none; }
.reader-word-detail-bubble[data-scrolled="true"] > .reader-word-fixed::after { opacity: 1; }
/* Keep an opaque fallback in WebViews without backdrop filtering. The sticky
   header adds blur without stacking a second opaque tint. Tint the
   surface rather than the whole bubble so text and controls stay crisp. */
@supports ((backdrop-filter: blur(18px)) or (-webkit-backdrop-filter: blur(18px))) {
  .reader-word-bubble[data-frosted="true"] { background: color-mix(in srgb, var(--surface) var(--reader-bubble-opacity, 92%), transparent); -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2); }
  .reader-word-bubble[data-frosted="true"] > .reader-word-fixed { background: transparent; }
  .reader-word-bubble[data-frosted="true"][data-scrolled="true"] > .reader-word-fixed { background: transparent; -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
}
@media (prefers-reduced-transparency: reduce) {
  .reader-word-bubble[data-frosted="true"], .reader-word-bubble[data-frosted="true"] > .reader-word-fixed,
  .reader-word-bubble[data-frosted="true"][data-scrolled="true"] > .reader-word-fixed { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
.reader-word-body { padding: 0 18px 18px; }
.reader-word-fixed .word-learning-progress { border: 0; }
/* Word help opens compact. Grid tracks animate the actual content height so
   the existing floating observers can keep either reading surface on screen. */
.word-bubble-details-inner {min-width:0;}
.reader-word-title > .reader-character-title { display: inline-flex; flex-direction: column; gap: 4px; }
.reader-character-word { display: flex; flex-wrap: wrap; align-items: start; gap: 5px; }
.reader-character-cell { display: inline-grid; justify-items: center; align-items: start; gap: 3px; }
button.reader-subword-button.reader-title-character { display: grid; place-items: center; min-width: 38px; min-height: 40px; padding: 3px 7px; font-family: var(--font-reading); font-weight: 650; font-size: 1.55rem; line-height: 1.2; color: var(--text); }
.reader-title-literal { display: grid; place-items: center; min-height: 40px; padding-block: 3px; font-family: var(--font-reading); font-size: 1.55rem; font-weight: 650; line-height: 1.2; }
.reader-character-reading { max-width: 100%; color: var(--text-secondary); font-family: var(--font-sans); font-size: .76rem; font-weight: 400; line-height: 1.35; overflow-wrap: anywhere; text-align: center; }
.reader-character-shared-reading { text-align: start; }
.reader-word-title:has(.reader-character-title) { align-items: start; }
.reader-word-title:has(.reader-character-title) > .grammar-tag { margin-top: 6px; }
@media (max-height: 500px) {
  .word-info-bubble > .reader-word-fixed { position: static; }
}
@media (prefers-reduced-motion: reduce) {
  .word-bubble-details, .word-bubble-details[data-expanded="true"], .word-bubble-toggle .shell-icon { transition: none; }
}
.reader-word-help-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-block: 12px 4px; }
.reader-word-help-actions > button, .reader-word-help-actions .word-practice-button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 12px; font-size: .85rem; }
.reader-word-explanation { margin-top: 12px; }
.reader-explanation-placeholder { display: grid; gap: 12px; padding: 14px; border-radius: 12px; background: var(--surface-subtle); color: var(--muted); font-size: .85rem; }
.reader-explanation-skeleton { display: grid; gap: 8px; }
.reader-explanation-skeleton > span { height: 7px; border-radius: 4px; background: linear-gradient(100deg, var(--border) 30%, color-mix(in srgb, var(--border) 45%, white) 50%, var(--border) 70%) 0 0 / 200% 100%; animation: shimmer 1.6s linear infinite; }
.reader-explanation-skeleton > span:last-child { width: 65%; }
@media (prefers-reduced-motion: reduce) { .reader-explanation-skeleton > span { animation: none; background: var(--border); } }
.reader-word-description { margin-inline-start: calc(1.8rem + 8px); display: grid; gap: 6px; }
.word-practice-button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 10px; font-size: .8rem; white-space: nowrap; }
.word-practice-menu { display: grid; gap: 4px; }
.word-practice-menu > button { display: flex; align-items: center; gap: 12px; padding: 12px; text-align: start; border-radius: 12px; }
.word-practice-menu > button > span { display: grid; gap: 3px; }
.word-practice-menu small { color: var(--muted); font-weight: 400; }
.word-practice-popup { width: min(540px, calc(100vw - 24px)); }
.word-practice-heading { text-align: center; padding: 4px 0 18px; }
.word-practice-heading > div { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 8px; }
.word-practice-heading > .word-practice-title { gap: 6px; margin-top: 0; }
.word-practice-title .icon-button { width: 32px; height: 32px; padding: 6px; }
.word-practice-heading strong { font-size: clamp(2rem, 7vw, 3rem); overflow-wrap: anywhere; }
.word-practice-heading .icon-button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.word-practice-heading p { margin: 4px 0 0; }
.word-practice-popup .writing-canvas-wrap { width: min(300px, 100%); }
.word-practice-speaking { display: grid; gap: 14px; }
.word-practice-speaking > p { margin: 0; text-align: center; }
.word-practice-speaking audio { width: 100%; }
.word-practice-feedback { padding: 16px; margin: 12px 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-subtle); animation: popover-in .18s var(--ease); }
.word-practice-feedback > strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.word-practice-feedback p { margin: 8px 0 0; }
.reader-word-body > button.secondary { margin: 8px 8px 0 0; }
@media (prefers-reduced-motion: reduce) { .reader-word-fixed::after { transition: none; } }
.reader-word-header > .speech-control { display: contents; }
.reader-word-header > .speech-control > .speech-button { grid-column: 1; grid-row: 1; margin: 2px 0 0; }
.reader-word-header > .speech-control > :not(.speech-button) { grid-column: 1 / -1; justify-self: start; min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.reader-word-heading { grid-column: 2; grid-row: 1; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; }
.reader-word-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; min-width: 0; max-width: 100%; }
.reader-word-title > strong { min-width: 0; overflow-wrap: anywhere; font-size: 1.65rem; line-height: 1.25; }
.reader-word-title > .tag { flex: none; margin: 0; }
.reader-word-header-actions { grid-column: 3; grid-row: 1; display: flex; flex: none; align-items: center; gap: 4px; }
.reader-word-header-actions > .copy-diagnostic:not(:empty) { position: absolute; inset-inline-end: 18px; top: 56px; }
.reader-word-header-actions > .icon-button { width: 32px; min-width: 32px; height: 34px; padding: 0; }
.reader-word-header-actions > .copy-diagnostic:empty { display: none; }
.reader-word-description > .reader-word-gloss-row { flex-wrap: nowrap; align-items: center; }
.reader-word-gloss-row > .reader-word-gloss { flex: 1; min-width: 0; }
.reader-word-gloss-row > .reader-definition-expand { margin-inline-start: auto; }
/* Keep corner actions fixed while giving long titles the full row on phones. */
@container word-bubble-header (max-width: 300px) {
  .reader-word-bubble .reader-word-header { grid-template-columns: max-content minmax(0, 1fr); }
  .reader-word-header > .speech-control > .speech-button, .reader-word-heading { grid-row: 2; }
  .reader-word-header-actions { grid-column: 2; justify-self: end; }
}
.reader-word { touch-action: manipulation; }
.reader-word-form { flex-basis: 100%; min-width: 0; display: grid; gap: 4px; margin-top: 2px; }
.reader-word-base { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .85rem; }
.reader-word-base > .muted { font-size: .7rem; }
.reader-word-base .spoken-text { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.reader-word-base > .word-transliteration { margin: 0; }
.reader-word-form-info { display: inline-flex; align-items: center; }
.reader-word-form-info > .muted { font-size: .7rem; }
button.reader-word-form-trigger { display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 2px 0; border: 0; background: transparent; color: var(--muted); font-size: .7rem; font-weight: 400; white-space: normal; }
button.reader-word-form-trigger:is(:focus-visible, [aria-expanded="true"]) { color: var(--accent); background: transparent; }
@media (hover: hover) and (pointer: fine) { button.reader-word-form-trigger:is(:hover, :focus-visible, [aria-expanded="true"]) { color: var(--accent); background: transparent; } }
.reader-word-form-trigger > svg { flex: none; }
.reader-form-keywords { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
.reader-form-keywords > li { padding: 2px 7px; border-radius: 6px; background: var(--surface-subtle); color: var(--text-secondary); font-size: .7rem; line-height: 1.5; overflow-wrap: anywhere; }
.reader-word-header > .ghost { grid-column: 3; grid-row: 1; }
.reader-subwords { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
button.reader-subword-button { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 34px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-subtle); color: var(--text-secondary); font-size: .95rem; font-weight: 600; }
button.reader-subword-button[aria-expanded="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
@media (hover: hover) and (pointer: fine) { button.reader-subword-button:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); } }
.reader-word-bubble.reader-subword-popup { z-index: 90; width: min(310px, calc(100vw - 24px)); padding: 14px; border-radius: 13px; }
.reader-subword-popup header > strong { min-width: 0; overflow-wrap: anywhere; font-size: 1.35rem; }
.reader-subword-popup header > [data-subword-close] { margin-inline-start: auto; flex: none; }
.reader-subword-popup .reader-word-gloss-row { margin-top: 7px; }
.reader-subword-popup p:last-child { margin-bottom: 0; }
.reader-subword-lemma { color: var(--text-secondary); }
.word-learning-progress { margin: 8px 0; padding: 7px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.word-progress-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.word-bubble-progress-row { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.word-bubble-progress-row > .word-commonness { margin-inline-end: auto; }
.word-bubble-progress-row > .word-progress-inline { flex-basis: 100%; }
.word-progress-label { font-size: .73rem; font-weight: 500; }
.word-commonness { display: flex; align-items: center; gap: 7px; min-width: 0; color: var(--text-secondary); font-size: .75rem; font-weight: 500; }
.word-commonness-bars { display: flex; align-items: end; gap: 2px; flex: none; height: 14px; }
.word-commonness-bars > span { width: 3px; border-radius: 1px; background: var(--border); }
.word-commonness-bars > span.filled { background: var(--accent); }
button.word-progress-disclosure { display: flex; gap: 6px; min-width: 0; padding: 5px 0; background: transparent; color: var(--text); text-align: start; font-size: .8rem; font-weight: 650; }
.word-progress-disclosure .shell-icon { flex: none; transform: rotate(-90deg); transition: transform .15s ease; }
.word-progress-disclosure[aria-expanded="true"] .shell-icon { transform: none; }
button.word-progress-chip { display: grid; place-items: center; min-width: 34px; height: 32px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; font-size: .9rem; font-weight: 750; font-variant-numeric: tabular-nums; }
button.word-progress-chip.rated { background:hsl(var(--level-hue) 78% 48% / var(--retention-opacity,.15)); color:light-dark(var(--learning-ink-light,var(--text)),var(--learning-ink-dark,var(--text))); }
.skills-score { background:hsl(var(--level-hue) 78% 48% / .3); color:var(--text); }
button.word-progress-chip.unrated { background: var(--surface-subtle); color: var(--muted); font-size: .7rem; font-weight: 500; }
button.word-progress-chip[aria-expanded="true"] { border-color: var(--text-secondary); }
@media (hover: hover) and (pointer: fine) { button.word-progress-chip:hover:not(:disabled) { border-color: var(--text-secondary); } }
.word-progress-picker { display: none; position: fixed; inset: auto; z-index: 110; width: max-content; max-width: calc(100vw - 24px); margin: 0; padding: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-raised); font-family: var(--font-sans); }
.word-progress-picker { max-height: calc(100dvh - 24px); overflow-y: auto; box-sizing: border-box; }
.word-progress-picker > .word-progress-disclosure { min-height: 32px; border-top: 1px solid var(--border); padding-top: 8px; font-size: .73rem; font-weight: 500; }
.word-progress-picker:popover-open, .word-progress-picker.open { display: grid; gap: 6px; animation: popover-in .12s var(--ease); }
.word-progress-levels { display: flex; gap: 4px; }
button.word-progress-level { position: relative; display: grid; place-items: center; width: 36px; height: 36px; padding: 0 0 2px; border: 1px solid transparent; border-radius: 7px; background: hsl(var(--level-hue) 35% 50% / .08); color: var(--muted); font-size: 1rem; font-weight: 500; font-variant-numeric: tabular-nums; }
@media (hover: hover) and (pointer: fine) { button.word-progress-level:hover:not(:disabled) { background: hsl(var(--level-hue) 65% 48% / .18); color: var(--text); } }
button.word-progress-level.current { background: hsl(var(--level-hue) 78% 48% / .3); color: var(--text); font-weight: 800; }
button.word-progress-level.current::after { content: ""; position: absolute; bottom: 4px; left: 27%; right: 27%; height: 2px; border-radius: 1px; background: currentColor; }
button.word-progress-unrated { justify-content: center; width: 100%; padding: 5px 8px; border: 1px solid transparent; border-radius: 7px; background: var(--surface-subtle); color: var(--text-secondary); font-size: .73rem; font-weight: 500; }
button.word-progress-unrated[aria-pressed="true"] { border-color: var(--border-strong); color: var(--text); }
@media (hover: hover) and (pointer: fine) { button.word-progress-unrated:hover { border-color: var(--border-strong); color: var(--text); } }
.word-learning-skills .word-progress-row { margin-top: 4px; }
.word-learning-skills .word-progress-chip { height: 28px; font-size: .8rem; }
.word-learning-skills .word-progress-chip.unrated { font-size: .7rem; }
.word-progress-status { display: block; margin-top: 5px; color: var(--muted); font-size: .7rem; }
.reader-definition-expand { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-secondary); }
.reader-definition-expand:focus-visible { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .reader-definition-expand:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); } }
.reader-relation-arrow { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 61; color: var(--accent); overflow: visible; }
.reader-definition-layer { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 24px; }
.reader-definition-scrim { position: absolute; inset: 0; background: var(--scrim); backdrop-filter: blur(2px); }
.reader-definition-dialog { position: relative; display: flex; flex-direction: column; width: min(850px, 100%); max-height: calc(100dvh - 48px); border: 1px solid var(--border); border-radius: 20px; background: var(--bg); box-shadow: var(--shadow-raised); overflow: hidden; }
.reader-definition-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface); }
.reader-definition-toolbar strong { flex: 1; overflow-wrap: anywhere; }
.reader-definition-content { overflow: auto; padding: 18px; }
@media (max-width: 600px) { .reader-definition-layer { padding: 10px; } .reader-definition-content { padding: 10px; } .reader-definition-toolbar { gap: 4px; padding: 8px; } }
.line-error { color: var(--danger); font-family: inherit; }
.reader-word.line-error { color: var(--danger); border: 0; box-shadow: none; cursor: help; }
.reader-error-tooltip { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: .85rem; line-height: 1.5; font-weight: 400; }
.reader-word-bubble.reader-error-tooltip { width: min(600px, calc(100vw - 24px)); max-height: min(65vh, 500px); overflow-y: auto; pointer-events: auto; }
.reader-chunk-retry { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; min-height: 30px; margin-inline-start: 4px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--accent); font: inherit; font-size: .85em; vertical-align: middle; }
.reader-chunk-retry:disabled { opacity: .4; cursor: wait; }
.reader-retry-failed { margin-bottom: 12px; }
.reader-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; color: var(--muted); font-size: .88rem; }

.card-session { max-width: 720px; }
.flashcard { display: grid; min-height: 280px; margin: 22px 0; padding: 40px; place-items: center; border: 1px solid var(--border); border-radius: 18px; background: var(--surface-subtle); text-align: center; }
.flashcard h2 { margin: 0; font-size: clamp(2.3rem, 7vw, 4rem); }
.answer { width: 100%; padding-top: 24px; border-top: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: 1.4rem; }
.rating-row, .tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.tab { padding: 8px 14px; border-radius: 999px; background: var(--surface-subtle); color: var(--text-secondary); }
@media (hover: hover) and (pointer: fine) { .tab:hover { background: var(--surface-hover); } }
.tab.active { background: var(--accent); color: var(--accent-text); }
.result { margin-top: 20px; line-height: 1.65; }
.generated { white-space: pre-wrap; }

.reader-selection-controls { position: fixed; z-index: 70; inset: auto auto calc(14px + env(safe-area-inset-bottom)) 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; width: max-content; max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)); margin: 0; padding: 6px; border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-raised); color: var(--text); }
.reader-selection-controls .icon-button { width: 44px; min-width: 44px; height: 44px; border-radius: 13px; color: var(--text-secondary); touch-action: manipulation; }
.reader-selection-controls .icon-button:disabled { opacity: .3; }
.reader-selection-divider { width: 1px; height: 22px; margin-inline: 2px; background: var(--border); }
.reader-selection-controls::backdrop { background: transparent; pointer-events: none; }
.reader-group-outlines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.reader-group-outline { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; stroke-linecap: round; opacity: .65; }
.reader-group-outline[data-solid="true"] { stroke-width: 2; stroke-dasharray: none; opacity: .85; }
.reader-translation-text { white-space: pre-wrap; }
.reader-translation-bubble { max-height: min(60vh, 32rem); overflow-y: auto; }
.reader-group-fixed { padding-bottom: 12px; }
.reader-group-fixed header { flex-wrap: nowrap; }
.reader-group-fixed .speech-control { flex: none; }
.reader-group-header-actions { display: flex; align-items: center; gap: 4px; flex: none; margin-inline-start: auto; }

/* Playback state belongs to the shared player, including during native requests. */
.speech-control { position:relative; display: inline-flex; align-items: center; gap: .3rem; vertical-align: middle; }
.speech-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; min-width: 2rem; padding: 0;
  margin-inline: .25rem; border: 0; border-radius: 50%;
  color: var(--accent); background: var(--accent-soft); font-size: .72rem;
  vertical-align: middle; cursor: pointer;
}
.speech-button:focus-visible { background: var(--accent); color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) { .speech-button:hover { background: var(--accent); color: var(--accent-text); } }
.speech-button .shell-icon { width: 1rem; height: 1rem; }
.speech-button-icon { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.speech-button .speech-play { display: inline-flex; }
.speech-button .speech-pause, .speech-button .speech-loading { display: none; }
.speech-button .speech-loading { width: 1rem; height: 1rem; align-items: center; justify-content: center; }
.speech-loading-dot { width: .55rem; height: .55rem; border-radius: 50%; background: currentColor; }
.speech-button[data-state="playing"] .speech-play,
.speech-button[data-state="loading"] .speech-play { display: none; }
.speech-button[data-state="playing"] .speech-pause,
.speech-button[data-state="loading"] .speech-loading { display: inline-flex; }
/* Loading motion stays inside the spinner; the listening button stays still. */
.speech-button[data-state="loading"],
.speech-button[data-highlight-loading="true"] { animation: none; }
.speech-button[data-highlight-loading="true"] .speech-play,
.speech-button[data-highlight-loading="true"] .speech-pause { display: none; }
.speech-button[data-highlight-loading="true"] .speech-loading { display: inline-flex; }
.speech-button[data-state="error"] { color: var(--danger); border-color: var(--danger); }
.speech-error { position:absolute; inset-block-start:-5px; inset-inline-end:-3px; width:20px; height:20px; color:var(--danger); font-size:.75rem; font-weight:400; }
.speech-error:empty { display: none; }
.speech-error-trigger {display:grid;place-items:center;width:20px;min-width:20px;height:20px;padding:1px;border:1px solid currentColor;border-radius:50%;color:inherit;background:var(--surface);box-shadow:none;}
@media (hover: hover) and (pointer: fine) { .speech-error-trigger:hover {background:var(--danger-soft);color:var(--danger);} }
.anchored-popover.speech-error-popover {width:min(360px,calc(100vw - 24px));color:var(--text);font-size:.9rem;}
.speech-error-popover .anchored-popover-heading {gap:8px;}
.speech-error-popover .icon-button.error-details-button {color:var(--muted);}
.speech-error-message {margin:0;white-space:normal;overflow-wrap:anywhere;}
.reader-word-header > .speech-control > .speech-error {position:relative;inset:auto;grid-column:1;grid-row:1;justify-self:end;align-self:start;transform:translate(25%,-25%);}
.landing-sentence-audio { float: inline-end; margin-inline-start: 12px; margin-bottom: 8px; }
.landing-stage .speech-control { flex-wrap: wrap; }
.landing-stage .speech-button { width: 40px; height: 40px; min-width: 40px; margin: 0; color: #fff; background: rgb(255 255 255 / .16); border: 1px solid rgb(255 255 255 / .3); }
.landing-stage .speech-button:focus-visible { background: rgb(255 255 255 / .3); color: #fff; }
@media (hover: hover) and (pointer: fine) { .landing-stage .speech-button:hover { background: rgb(255 255 255 / .3); color: #fff; } }
.landing-stage .speech-error { max-width: 180px; color: #ffb4ab; }
.landing-bubble-header .speech-control { margin-inline-start: auto; }
.speech-button-labeled { width: auto; height: auto; margin: 0; gap: 6px; padding: 4px 14px 4px 4px; border-radius: 999px; color: var(--accent-ink); font-size: .9rem; font-weight: 650; text-align: start; }
.speech-button-labeled > .speech-button-icon { width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--accent); color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) { .speech-button-labeled:hover > .speech-button-icon { background: var(--accent-hover); } }
.search-result-with-audio { display: flex; align-items: center; gap: .35rem; }
.search-result-with-audio > .search-result { flex: 1; min-width: 0; }
@keyframes speech-pulse { 0%, 100% { opacity: .45; box-shadow: 0 0 0 0 var(--accent-soft); } 50% { opacity: 1; box-shadow: 0 0 0 5px var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) {
    .speech-button[data-state="loading"], .speech-button[data-highlight-loading="true"] { animation: none; }
    .speech-button .speech-loading-dot { animation: none; }
}

.reader-group-translation { margin-top: 12px; }
.reader-translation-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.reader-translation-disclosure { display: inline-flex; align-items: center; gap: 6px; padding-inline-start: 0; }

.reader-display-controls { margin: 20px 0 0; }
.reader-control-heading { margin: 0; font-size: .85rem; font-weight: 650; color: var(--text-secondary); }
.reader-display-toggles { display: grid; gap: 14px; margin: 16px 0 20px; }
.reader-font-size-control { display: flex; align-items: center; gap: 12px; }
.reader-font-size-control > label { flex: 1; min-width: 0; }
.reader-font-size-label { display: flex; justify-content: space-between; gap: 12px; }
.reader-font-size-label > span { color: var(--muted); font-variant-numeric: tabular-nums; }
.reader-font-size-control input { width: 100%; margin: 0; }
.reader-option-checkbox { display: flex; align-items: center; gap: 10px; margin: 0; font-size: .9rem; font-weight: 500; cursor: pointer; }
.reader-option-checkbox input { flex: 0 0 16px; width: 16px; height: 16px; margin: 0; }
.reader-display-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; align-items: start; }
.reader-display-grid .switch-row { grid-column: 1 / -1; padding: 10px 0; }
.reader-display-grid > label:not(.option-row):not(.switch-row) { display: grid; gap: 6px; }
.reader-display-grid .option-row { margin: 0; }
@media (max-width: 600px) { .reader-display-grid { grid-template-columns: 1fr; } }

.reader-word-bubble > button.secondary { margin: 8px 8px 0 0; }

/* Scenarios */
.roleplay-library-section > h2 { margin: 30px 0 14px; font-size: 1.15rem; }
.scenario-library { display:grid; grid-template-columns:repeat(auto-fill,minmax(250px,1fr)); gap:14px; }
.scenario-library-card { display: grid; align-content: start; gap: 6px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .14s ease, box-shadow .14s ease; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .scenario-library-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); } }
.scenario-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; }
.scenario-card-top .tag { margin: 0; background: var(--marigold-soft); color: var(--marigold-ink); }
.scenario-card-top .tag.done { background: var(--accent-soft); color: var(--accent-ink); }
.scenario-library-card h3 { margin: 4px 0 0; font-size: 1.08rem; line-height: 1.35; }
.scenario-library-card p { margin: 0 0 10px; font-size: .86rem; }
.scenario-library-card > .button-link, .scenario-library-card > .confirm-inline { margin-top: auto; }
.confirm-inline.start { justify-content: flex-start; }
.scenario-create { max-width:780px; }
.scenario-game-header { display:flex; align-items:center; justify-content:space-between; gap:18px; margin:12px 0 20px; }
.scenario-game-header h1 { margin:0; font-size:clamp(1.5rem,3vw,2.4rem); }
.scenario-progress { margin-bottom:18px; }
.scenario-progress progress { width:100%; accent-color:var(--accent); }
@keyframes scenario-pulse { 50% {opacity:.25} }
.scenario-objective { display:flex; flex-wrap:wrap; gap:16px 30px; margin-bottom:20px; border-left:4px solid var(--accent); }
.scenario-objective h2 { font-size:1.1rem; margin:0; max-width:600px; }
.scenario-objective ul { list-style:none; padding:0; margin:0; display:grid; gap:8px; }
.scenario-objective li { display:flex; gap:10px; color:var(--muted); font-size:.88rem; }
.scenario-objective li.complete { color:var(--success,#358269); }
.scenario-game-layout { display:grid; grid-template-columns:minmax(0,1.5fr) minmax(290px,1fr); gap:22px; align-items:start; }
.scenario-world { min-width:0; }
.scenario-canvas { display:block; width:100%; aspect-ratio:5/3; border-radius:18px; border:1px solid var(--border); background:#e5eee2; cursor:pointer; }
.scenario-scene-caption { margin:16px 4px; }
.scenario-scene-caption h2 { margin:0; font-size:1.2rem; }
.scenario-scene-caption p { color:var(--muted); font-size:.9rem; line-height:1.5; }
.scenario-people,.scenario-inventory { padding:18px; margin-top:16px; }
.scenario-person { padding:12px 0; border-top:1px solid var(--border); }
.scenario-person p,.scenario-person details,.scenario-item p { font-size:.82rem; color:var(--muted); }
.scenario-person .selected { outline:2px solid var(--accent); outline-offset:2px; }
.scenario-item { padding:10px 0; display:flex; align-items:center; gap:10px; }
.scenario-item-art { width:48px; height:48px; object-fit:contain; flex:none; }
.scenario-item-placeholder { display:grid; place-items:center; border-radius:12px; background:var(--surface-subtle); color:var(--muted); font-size:1.8rem; }
.scenario-item p { margin:4px 0; }
.scenario-conversation { padding:20px; position:sticky; top:20px; }
.scenario-conversation h2 { font-size:1.1rem; margin:0 0 16px; }
.scenario-event-log { display:flex; flex-direction:column; gap:12px; max-height:460px; overflow:auto; padding-right:5px; }
.scenario-event { padding:12px 14px; border-radius:14px; background:var(--surface-subtle); font-size:.92rem; overflow-wrap:anywhere; }
.scenario-event small { font-weight:700; color:var(--muted); font-size:.72rem; }
.scenario-event p { margin:6px 0 0; white-space:pre-wrap; line-height:1.5; }
.scenario-event.event-player { margin-left:22px; background:var(--accent-soft,#e7edfc); }
.scenario-event.event-action,.scenario-event.event-feedback { border-left:3px solid var(--border-strong); font-size:.82rem; }
.scenario-event .speech-control { margin-top:7px; max-width:100%; }
.scenario-audio-settings { display:flex; align-items:center; flex-wrap:wrap; gap:8px 12px; margin-bottom:16px; }
.scenario-audio-settings .checkbox-field { display:flex; align-items:center; gap:.5rem; margin:0; }
.scenario-audio-settings input[type="checkbox"] { width:auto; margin:0; accent-color:var(--accent); }
.scenario-audio-settings small { flex-basis:100%; color:var(--muted); }
.scenario-audio-settings button[hidden] { display:none; }
.scenario-event.event-speech:has(.speech-button[data-state="playing"]) { box-shadow:inset 3px 0 var(--accent); background:var(--accent-soft); }
.scenario-input { margin-top:20px; border-top:1px solid var(--border); padding-top:16px; }
.scenario-input label { font-size:.82rem; }
.scenario-input p { font-size:.72rem; }
.scenario-victory { display:flex; gap:20px; align-items:center; background:#e4f3dd; color:#254c2d; padding:24px; border-radius:18px; margin-bottom:20px; }
.scenario-victory > span { font-size:3rem; color:#6d9842; }
.scenario-victory h2,.scenario-victory p { margin:4px 0; }
.scenario-asset-errors { font-size:.8rem; color:var(--muted); margin:16px 0; overflow-wrap:anywhere; }
.scenario-error { border:1px solid var(--danger); margin-bottom:16px; }
@media(max-width:1050px) { .scenario-game-layout {grid-template-columns:1fr;} .scenario-conversation {position:static;} .scenario-event-log {max-height:380px;} }
@media(max-width:620px) { .scenario-intro,.scenario-game-header {align-items:flex-start;flex-direction:column;} .scenario-create-options {grid-template-columns:1fr;} }
@media(prefers-reduced-motion:reduce) { .scenario-pulse {animation:none;} }

.token-budget-badge { display:grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: center; width:100%; text-align:left; padding:12px; color:var(--text); background:var(--warning-soft); border:0; border-radius:12px; font-weight: 500; }
@media (hover: hover) and (pointer: fine) { .token-budget-badge:hover { background: color-mix(in srgb, var(--warning-soft) 80%, var(--warning)); } }
.token-budget-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 10px; background: var(--surface); color: var(--warning-ink); }
.token-budget-copy { display: grid; gap: 1px; min-width: 0; }
.token-budget-copy span,.token-budget-copy small { font-size:.74rem; color:var(--warning-ink); }
.token-budget-copy strong { font-size:1rem; color: var(--text); }
.token-budget-copy .token-budget-balance-allowance,
.token-budget-copy .token-budget-balance-extra,
.token-budget-copy .token-budget-balance-unit { font-size:inherit; color:inherit; }
.token-budget-copy .token-budget-balance-extra,
.token-budget-copy .token-budget-balance-unit,
.token-budget-copy [data-pool-emphasis="true"] .token-budget-balance-allowance { opacity:.65; font-weight:500; }
.token-budget-copy [data-pool-emphasis="true"] .token-budget-balance-extra { opacity:1; font-weight:inherit; }
.account-token-budget,.token-usage-history { margin-top:24px; }
.token-budget-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.token-budget-heading h2 { margin:0; }
.token-budget-balance { margin:24px 0 12px; }
.token-budget-balance strong { font-size:2.25rem; letter-spacing:-.05em; }
.token-budget-balance span { color:var(--muted); }
.account-token-budget progress { width:100%; height:10px; accent-color:var(--accent); }
.token-tier-options { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; margin:20px 0; }
.token-tier { border:1px solid var(--border); border-radius:16px; padding:20px; }
.token-tier.selected { border-color:var(--accent); background:var(--accent-soft); }
.token-tier h3 { margin:0; }
.token-tier p { font-size:.85rem; }
.token-tier button { width:100%; }
.subscription-settings { margin-top:24px; }
.billing-callout,.billing-ready-link,.billing-confirmation { padding:20px; margin:20px 0; border:1px solid var(--border); border-radius:16px; background:var(--accent-soft); }
.billing-callout p,.billing-ready-link p,.billing-confirmation p { margin:10px 0; line-height:1.6; }
.billing-current-plan { padding:24px 0; border-bottom:1px solid var(--border); }
.billing-current-plan > div:first-child { display:flex; align-items:center; flex-wrap:wrap; gap:16px; }
.billing-current-plan h3 { margin:0; }
.billing-current-plan small,.billing-callout small { display:inline; font-size:inherit; }
.billing-actions { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin:16px 0; }
.billing-intervals { display:flex; width:fit-content; border:1px solid var(--border); border-radius:14px; padding:4px; gap:4px; margin-top:24px; }
.billing-price { min-height:36px; }
.billing-price strong { font-size:1.5rem; color:var(--text); }
.billing-price span { color:var(--muted); }
.billing-terms { font-size:.85rem; line-height:1.7; }
.billing-ready-link a { display:inline-block; padding:12px 18px; background:var(--accent); color:var(--accent-text); border-radius:12px; font-weight:700; text-decoration:none; }
.billing-activity { margin-top:24px; }
.billing-activity ul { padding-left:20px; }
.billing-activity li { margin:12px 0; }
.billing-activity small { display:block; color:var(--muted); margin-top:4px; }
@media(max-width:720px) { .billing-actions > button {width:100%;} .billing-ready-link a {display:block;text-align:center;} }
.token-explanation { margin-top:24px; color:var(--muted); font-size:.85rem; line-height:1.6; }
.token-usage-history { min-width:0; }
.token-history-search { width:100%; max-width:32rem; }
.token-history-table-wrap { overflow-x:auto; margin-top:20px; }
.token-history-table { width:100%; border-collapse:collapse; font-size:.82rem; }
.token-history-table th { text-align:left; color:var(--muted); font-size:.75rem; }
.token-history-table th,.token-history-table td { padding:14px 12px; border-bottom:1px solid var(--border); vertical-align:top; }
.token-history-table td:first-child { min-width:220px; max-width:450px; overflow-wrap:anywhere; }
.token-history-table td:nth-child(2) { overflow-wrap:anywhere; max-width:170px; }
.token-history-table td small { display:block; color:var(--muted); font-size:.72rem; margin:6px 0; }
.token-history-table details { margin-top:10px; color:var(--muted); }
.token-history-table details p { font-size:.75rem; }
.token-history-table .token-charge { font-weight:700; white-space:nowrap; font-variant-numeric:tabular-nums; }
@media(max-width:720px) { .token-tier-options {grid-template-columns:1fr;} .token-budget-heading {align-items:flex-start;flex-wrap:wrap;} .token-budget-balance span {display:block;} }

.scenario-microphone { display: grid; gap: .65rem; padding: 1rem 0; border-top: 1px solid var(--border); }
.scenario-microphone-controls { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.scenario-microphone-controls button { touch-action: none; user-select: none; -webkit-user-select: none; }
.scenario-microphone-controls button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.scenario-microphone meter { width: 3.5rem; height: .7rem; }
.scenario-microphone small { display: block; line-height: 1.45; }
.scenario-microphone[data-state="transcribing"] meter { animation: scenario-mic-pulse 1s ease-in-out infinite; }
@keyframes scenario-mic-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .scenario-microphone[data-state="transcribing"] meter { animation: none; } }

.scenario-microphone .checkbox-field { display: flex; align-items: center; gap: .5rem; margin: 0; }
.scenario-microphone input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); }

/* Credit usage log and per-request details. */
button.credit-usage-charge { display: inline-flex; align-items: center; width: auto; min-height: 0; padding: 3px 7px; margin: 0 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-subtle); color: var(--text-secondary); font-size: .68rem; line-height: 1.35; font-weight: 500; vertical-align: middle; white-space: nowrap; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { button.credit-usage-charge:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); } }
.scenario-completion-warning { margin: 16px 0; border-left: 4px solid var(--warning); }
.scenario-completion-warning h2 { font-size: 1.1rem; margin: 0 0 8px; }
.scenario-completion-warning p { line-height: 1.5; }
.scenario-warning-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.credit-usage-entry { padding: 18px 0; border-top: 1px solid var(--border); }
.credit-usage-entry h3 { font-size: 1rem; margin: 0 0 10px; overflow-wrap: anywhere; }
.credit-usage-entry > small { display: block; margin: 6px 0; color: var(--muted); }
.credit-usage-entry dl { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(0, 2fr); gap: 8px 14px; font-size: .83rem; }
.credit-usage-entry dt { color: var(--muted); }
.credit-usage-entry dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) { .credit-usage-entry dl { grid-template-columns: 1fr; gap: 4px; } .credit-usage-entry dd { margin-bottom: 8px; } }

/* Markdown keeps semantic blocks while reader words remain interactive. */
.reader-markdown { font-size: calc(var(--reader-base-font-size, 1.15rem) * var(--reader-font-scale, 1)); line-height: 1.85; overflow-wrap: anywhere; }
.reader-unprocessed { color: var(--text-secondary); opacity: .5; }
.reader-markdown p { margin: 0 0 1em; }
.reader-markdown > :first-child { margin-top: 0; }
.reader-markdown > :last-child { margin-bottom: 0; }
.reader-markdown h1, .reader-markdown h2, .reader-markdown h3,
.reader-markdown h4, .reader-markdown h5, .reader-markdown h6 { margin: 1.3em 0 .55em; line-height: 1.4; font-weight: 700; letter-spacing: normal; }
.reader-markdown h1 { font-size: 1.65em; }
.reader-markdown h2 { font-size: 1.4em; }
.reader-markdown h3 { font-size: 1.2em; }
.reader-markdown h4, .reader-markdown h5, .reader-markdown h6 { font-size: 1em; }
.reader-markdown ul, .reader-markdown ol { margin: .65em 0 1em; padding-inline-start: 1.7em; }
.reader-markdown li { margin: .3em 0; }
.reader-markdown li > p { margin-bottom: .5em; }
.reader-markdown li > ul, .reader-markdown li > ol { margin-block: .25em; }
.reader-markdown blockquote { margin: 1em 0; padding: .25em 1em; border-inline-start: 3px solid var(--border-strong); color: var(--text-secondary); background: var(--surface-subtle); }
.reader-markdown blockquote > :last-child { margin-bottom: 0; }
.reader-markdown code { font-family: ui-monospace, monospace; font-size: .9em; padding: .12em .25em; border-radius: 4px; background: var(--surface-subtle); white-space: pre-wrap; }
.reader-markdown pre { margin: 1em 0; padding: 1em; border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; background: var(--surface-subtle); white-space: pre; }
.reader-markdown pre code { padding: 0; white-space: pre; }
.reader-markdown hr { border: 0; border-top: 1px solid var(--border-strong); margin: 1.5em 0; }
.reader-markdown-table { overflow-x: auto; margin: 1em 0; }
.reader-markdown table { width: 100%; border-collapse: collapse; }
.reader-markdown th, .reader-markdown td { border: 1px solid var(--border); padding: .4em .7em; text-align: start; }
.reader-markdown th { background: var(--surface-subtle); }
.reader-markdown-task { display: inline-block; width: 1em; margin-inline-end: .4em; vertical-align: baseline; }
.reader-markdown-link { text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: .2em; }
.reader-markdown-open-link { display: inline-block; font-size: .7em; padding-inline: .25em; color: var(--accent); text-decoration: none; }
.reader-markdown-literal { white-space: pre-wrap; }
.reader-word-bubble .reader-markdown { font-size: inherit; line-height: 1.6; }
.reader-word-bubble { margin: 0; inset: auto; font-style: normal; font-weight: 400; line-height: 1.5; text-align: start; text-transform: none; letter-spacing: normal; }
.inline-reader, .inline-reader-text { display: inline; }
.inline-reader-text { white-space: pre-wrap; line-height: inherit; }
.inline-reader .reader-word { line-height: inherit; }
.flashcard-context .inline-reader .reader-word { padding-bottom: 0; }
:is(.inline-reader, .flashcard-context)[aria-busy="true"] [data-analysis-pending] {
    background-image: linear-gradient(105deg, currentColor 35%, #93c5fd 46%, #e0f2fe 50%, #93c5fd 54%, currentColor 65%);
    background-size: 260% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 8px rgb(59 130 246 / .18);
    animation: inline-analysis-swipe 2.8s linear infinite, inline-analysis-glow 2.2s ease-in-out infinite;
}
@keyframes inline-analysis-swipe { from { background-position: 160% 0; } to { background-position: -160% 0; } }
@keyframes inline-analysis-glow { 0%, 100% { text-shadow: 0 0 6px rgb(59 130 246 / .14); } 50% { text-shadow: 0 0 10px rgb(59 130 246 / .36); } }
@media (prefers-reduced-motion: reduce) {
    :is(.inline-reader, .flashcard-context)[aria-busy="true"] [data-analysis-pending] { animation: none; background-image: none; -webkit-text-fill-color: currentColor; text-shadow: 0 0 8px rgb(59 130 246 / .25); }
}
@media (forced-colors: active) {
    :is(.inline-reader, .flashcard-context)[aria-busy="true"] [data-analysis-pending] { animation: none; background-image: none; -webkit-text-fill-color: CanvasText; text-shadow: none; }
}
/* Flashcard examples prepare silently until the learner interacts with them. */
.flashcard-context[data-analysis-interacted="false"] [data-analysis-pending] {
    animation: none;
    background-image: none;
    -webkit-text-fill-color: currentColor;
    text-shadow: none;
}
.inline-reader-retry { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; min-height: 36px; padding: 0 3px; margin: 0; background: transparent; color: var(--danger); font: inherit; font-size: .8em; vertical-align: baseline; }
.inline-reader-error-details { font-size: 1rem; font-style: normal; font-weight: 400; line-height: 1.5; text-align: start; }
.inline-reader-error-message { white-space: pre-wrap; overflow-wrap: anywhere; }
.reader-definition-layer[popover] { position: fixed; inset: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; border: 0; background: transparent; color: var(--text); box-sizing: border-box; }
.reader-relation-layer { position: fixed; inset: 0; margin: 0; padding: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; border: 0; background: transparent; pointer-events: none; overflow: visible; z-index: 61; }
@media (max-width: 600px) { .reading-page .reader-markdown { --reader-base-font-size: 1.08rem; } }

::highlight(compri-spoken-word) { background-color: #f9d766; color: #172238; }
.input-matching-instruction p::highlight(compri-spoken-word) { background-color: transparent; color: var(--text); }
.compri-speech-overlay { position: fixed; z-index: 10000; pointer-events: none; border-radius: 3px; background: rgba(246, 194, 43, .38); }

/* Document comprehension practice. */
.challenge-stars-total { color: var(--accent); font-weight: 750; }
.comprehension-stage .comprehension-session { grid-template-rows: auto minmax(0, 1fr); }
.comprehension-management { position: relative; z-index: 4; display: grid; gap: 14px; width: min(900px, 100%); justify-self: center; min-width: 0; }
.comprehension-stage .comprehension-topbar { min-height: 52px; padding-inline-start: 8px; gap: 8px; }
.challenge-navigation { display: flex; align-items: center; gap: 8px; padding: 0 6px; min-width: 0; color: #f3f4f6; }
.challenge-navigation > .icon-button { color: inherit; flex: none; }
.guided-progress.challenge-progress { flex: 1; }
.challenge-progress .guided-step { position: relative; cursor: pointer; }
.challenge-progress .guided-step::before { content: ""; position: absolute; inset: -10px 0; }
.challenge-question-translation { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; color: var(--text-secondary); font-size: 1rem; line-height: 1.65; }
.challenge-question-translation > .icon-button { flex: none; width: 36px; height: 36px; padding: 8px; border-radius: 50%; }
.challenge-question-translation > div { min-width: 0; padding-top: 4px; }
.challenge-question-translation p { margin: 0; }
.challenge-answer-actions > button[type="submit"] { margin-inline-start: auto; }
.comprehension-topbar > .icon-button { flex: none; }
.comprehension-topbar .study-source span { letter-spacing: .05em; }
.comprehension-topbar .challenge-question-menu { gap: 8px; }
.challenge-question-menu > button { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; align-items: baseline; gap: 10px; text-align: start; font-size: .85rem; line-height: 1.5; }
.challenge-question-menu > button[aria-current="step"] { background: var(--accent-soft); color: var(--accent-ink); }
.challenge-question-number { color: var(--muted); font-variant-numeric: tabular-nums; }
.study-scene.comprehension-scene { width: min(900px, 100%); grid-template-rows: minmax(0, 1fr) auto; }
.comprehension-scene .study-card { height: auto; max-height: 100%; display: flex; flex-direction: column; }
.comprehension-scene .study-card-scroll { height: auto; min-height: 0; }
.comprehension-scene .challenge-prompt { margin: 0; font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.65; font-weight: 550; }
.comprehension-scene .challenge-answer-dock { display: grid; gap: 10px; max-height: min(320px, calc(var(--study-height) * .48)); }
.challenge-answer-dock textarea { margin: 0; width: 100%; }
.challenge-answer-dock > p { margin: 0; font-size: .85rem; }
.challenge-answer-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.challenge-answer-actions > button { font-size: .85rem; }
.challenge-answer-note { margin: 0 0 5px; font-size: .78rem; }
.challenge-navigation .icon-button { width: 40px; height: 40px; padding: 8px; }
.challenge-feedback { margin-top: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); animation: challenge-reward .3s ease-out; }
.challenge-score { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.challenge-score span { font-size: 1.35rem; letter-spacing: 3px; }
.challenge-score .earned { color: var(--success); }
.challenge-score .unearned { color: var(--border-strong); }
.challenge-feedback h4 { margin: 0 0 12px; font-size: 1.05rem; }
.challenge-feedback p { margin: 12px 0; line-height: 1.6; }
.challenge-language { display: inline-flex; border-radius: 99px; padding: 4px 9px; font-size: .73rem; font-weight: 650; color: var(--text-secondary); background: var(--surface); }
.challenge-language.target { color: var(--success); border: 1px solid currentColor; }
.challenge-hint { border-left: 3px solid var(--warning); padding: 8px 12px; background: var(--surface); border-radius: 4px; }
.challenge-complete { padding: 13px 16px; border-radius: 10px; background: var(--success-soft); color: var(--success); font-weight: 700; line-height: 1.5; }
.challenge-history summary { color: var(--muted); cursor: pointer; font-size: .8rem; }
.challenge-history { margin-top: 16px; }
.challenge-history p { font-size: .8rem; overflow-wrap: anywhere; }
@keyframes challenge-reward { from { opacity: .5; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .challenge-feedback { animation: none; } }
@media (max-width: 520px) {
    .comprehension-stage .comprehension-topbar { gap: 2px; }
    .comprehension-topbar .study-source span { font-size: .55rem; }
    .comprehension-topbar .study-menu > summary { padding-inline: 7px; }
    .comprehension-topbar .study-menu > summary .challenge-stars-total { display: none; }
    .comprehension-scene .study-card-scroll { --study-card-padding: 20px; }
    .comprehension-scene .study-card-header { padding-block: 14px; }
    .challenge-feedback { padding: 14px; }
}
@media (max-height: 560px) {
    .comprehension-stage .comprehension-topbar { min-height: 40px; padding-block: 2px; }
    .comprehension-topbar > .icon-button, .comprehension-management .challenge-navigation .icon-button { width: 32px; height: 32px; padding: 6px; }
    .comprehension-management { gap: 8px; }
    .comprehension-scene .challenge-answer-dock { gap: 6px; padding: 10px 14px; }
    .challenge-answer-dock textarea { height: 56px; }
    .comprehension-topbar .study-source span { display: block; font-size: .55rem; }
}

.reader-practice-launch { display: flex; flex-wrap: wrap; gap: 8px; }
.reader-practice-launch :is(button, .button-link) { padding: 8px 14px; font-size: .9rem; }
.reader-group-activities { display: grid; gap: 20px; margin-block: 18px; }
.reader-group-activity { display: grid; gap: 8px; }
/* Speaking practice shares the floating study stage; only the passage scrolls. */
.practice-session { grid-column: 1; grid-row: 1 / -1; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 18px; min-height: 0; min-width: 0; height: 100%; }
.practice-studio .practice-topbar { gap: 8px; padding-inline-start: 8px; }
.practice-topbar h2 { flex: 1; min-width: 0; margin: 0; font-size: 1.05rem; line-height: 1.25; }
.practice-topbar > .icon-button { flex: none; }
.practice-loading { padding: 24px; margin: auto; }
.practice-reading-area { display: flex; flex-direction: column; gap: 14px; align-self: center; justify-self: center; width: min(1100px, 100%); max-height: 100%; min-height: 0; min-width: 0; }
.practice-progress { flex: none; }
.practice-progress .guided-progress-steps { flex-wrap: wrap; gap: 6px; }
.practice-progress .guided-progress-steps li { min-width: 10px; }
.practice-progress .guided-step { position: relative; height: 12px; border-radius: 6px; cursor: pointer; }
.practice-progress .guided-step::before { content: ""; position: absolute; inset: -8px 0; }
.practice-content { display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 14px; border: 1px solid var(--border); border-radius: 24px; background: var(--surface); box-shadow: 0 12px 40px rgb(0 0 0 / .25); }
.practice-passage { min-height: 0; overflow-y: auto; overscroll-behavior: contain; font-size: 1.35rem; line-height: 1.8; padding: 2px; scrollbar-gutter: stable; }
.practice-sentence-row { display: grid; grid-template-columns: 3.3rem minmax(0, 1fr); align-items: baseline; gap: 10px; width: 100%; padding: 8px 10px; margin: 0 0 4px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: var(--text); font: inherit; text-align: start; box-shadow: none; }
.practice-sentence-row:last-child { margin-bottom: 0; }
.practice-sentence-row[data-current="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
@media (hover: hover) and (pointer: fine) { .practice-sentence-row:hover { background: var(--surface-subtle); } }
.practice-sentence-grade { justify-self: stretch; padding: 3px 5px; border-radius: 7px; font-size: .75rem; font-weight: 650; line-height: 1.6; text-align: center; font-variant-numeric: tabular-nums; }
.practice-ungraded { color: var(--muted); }
.practice-sentence-text { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.practice-reading-unit { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; margin-inline: 2px; }
.practice-reading-unit > .practice-unit-text { white-space: nowrap; }
.practice-reading { color: var(--muted); font-size: .55em; font-weight: 400; line-height: 1.4; white-space: nowrap; padding-bottom: 4px; }
.practice-word { font: inherit; line-height: 1.5; padding: 1px 0; margin: 0; border: 0; border-bottom: 3px solid transparent; border-radius: 4px; color: var(--text); background: transparent; display: inline; }
.practice-word.provisional { border-bottom-style: dotted; opacity: .72; }
.practice-studio .score-4 { background: #d8f4e5; color: #145437; border-bottom-color: #20824c; }
.practice-studio .score-3 { background: #fff1b8; color: #65520b; border-bottom-color: #c5a126; }
.practice-studio .score-2 { background: #ffe0bd; color: #784010; border-bottom-color: #c07124; }
.practice-studio .score-1 { background: #ffdade; color: #812737; border-bottom-color: #bc4560; }
.practice-studio .practice-dock { width: min(760px, 100%); overflow: hidden; padding: 14px 18px; }
.practice-dock-actions { display: flex; align-items: flex-start; gap: 12px; }
.practice-audio-hint { flex: none; }
.practice-dock-actions .practice-controls { flex: 1; min-width: 0; }
.practice-controls { display: grid; grid-template-columns: minmax(0, max-content) auto minmax(24px, 64px); justify-content: center; align-items: center; gap: 6px 12px; }
.practice-controls[data-review="true"] { grid-template-columns: minmax(0, max-content) minmax(0, max-content); }
.practice-controls[data-review="true"] > :is(.practice-microphone, .recording-auto-button, meter) { display: none; }
.practice-controls[data-review="true"] > button { min-width: 0; max-width: 100%; padding-inline: 12px; font-size: .85rem; }
.practice-controls:not([data-review="true"]) .practice-retry { grid-column: 1 / -1; justify-self: center; }
.practice-controls meter { width: 100%; }
.practice-microphone { min-width: 0; }
.practice-microphone > :is(.practice-mic-idle, .practice-mic-recording, .practice-mic-busy) { display: none; flex: none; }
.practice-microphone[data-state="idle"] .practice-mic-idle,
.practice-microphone[data-state="recording"] .practice-mic-recording,
.practice-microphone[data-state="busy"] .practice-mic-busy { display: inline-flex; }
.practice-mic-busy { animation: word-image-spin 1.5s linear infinite; }
.practice-feedback-area { display: grid; gap: 8px; margin-top: 10px; }
.practice-feedback-area > p { margin: 0; font-size: .85rem; line-height: 1.5; }
.practice-transcript { padding: 8px 12px; background: var(--surface-subtle); border-radius: 10px; }
.practice-transcript strong { font-size: .75rem; color: var(--muted); }
.practice-transcript-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.practice-transcript-heading .speech-button-labeled { min-height: 30px; padding: 5px 9px; font-size: .75rem; }
.practice-transcript-heading .speech-control { flex: none; }
.practice-transcript p { margin: 2px 0 0; min-height: 1.5em; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.practice-feedback { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.practice-options, .practice-help { font-size: .9rem; line-height: 1.6; }
.practice-options summary { cursor: pointer; color: var(--muted); }
.practice-options > p:first-child, .practice-help > p:first-child { margin-top: 0; }
.practice-options > :last-child, .practice-help > :last-child { margin-bottom: 0; }
@media (max-width: 600px) {
    .practice-session { gap: 12px; }
    .practice-progress { flex-wrap: wrap; gap: 8px; }
    .practice-progress .guided-progress-steps { flex-basis: 100%; }
    .practice-topbar h2 { font-size: .95rem; }
    .practice-studio .practice-topbar { gap: 3px; }
    .practice-content { padding: 10px 6px; border-radius: 20px; }
    .practice-passage { font-size: 1.1rem; }
    .practice-sentence-row { grid-template-columns: 2.8rem minmax(0, 1fr); gap: 7px; padding: 7px; }
    .practice-studio .practice-dock { padding: 12px; }
    .practice-controls { grid-template-columns: minmax(0, max-content) auto minmax(16px, 40px); gap: 6px 8px; }
    .practice-microphone { padding: 10px 12px; font-size: .85rem; }
}
@media (max-height: 500px) {
    .practice-session { gap: 8px; }
    .practice-studio .practice-topbar { padding-block: 2px; }
    .practice-studio .practice-dock { padding: 8px 12px; }
    .practice-controls { gap: 3px 8px; }
    .practice-microphone { padding-block: 6px; font-size: .8rem; }
    .practice-transcript { display: flex; align-items: baseline; gap: 10px; padding: 6px 10px; }
    .practice-transcript-heading { flex: none; }
    .practice-transcript p { margin: 0; font-size: .85rem; -webkit-line-clamp: 1; }
    .practice-feedback-area { gap: 4px; margin-top: 6px; }
    .practice-feedback { -webkit-line-clamp: 2; }
    .practice-content { padding-block: 8px; }
}
@media (prefers-reduced-motion: reduce) { .practice-mic-busy { animation: none; } }

/* Scenario lobby and character studio */
.scenario-lobby-actions { display:flex; gap:12px; align-items:center; margin:20px 0; }
.scenario-play-button { padding:16px 44px; font-size:1.15rem; }
.scenario-lobby-preview { border-radius:20px; overflow:hidden; max-height:52vh; background:#233e36; }
.scenario-lobby-preview .scenario-canvas { width:100%; max-height:52vh; }
.scenario-lobby-premise { margin-top:20px; }
.character-studio-layout { display:grid; grid-template-columns:minmax(220px,.8fr) minmax(300px,1.2fr); gap:24px; margin:24px 0; }
.character-preview { text-align:center; background:radial-gradient(circle at 50% 35%,#e6f3e8,transparent 65%),var(--surface); }
.character-preview img { height:300px; width:250px; object-fit:contain; }
.character-preview p { color:var(--muted); font-size:.85rem; }
.character-placeholder { display: grid; justify-items: center; padding: 40px 0 20px; color: var(--accent); }
.character-prompt form { display:grid; gap:16px; }
.character-history { margin-top:24px; }
.character-version { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:20px 0; border-top:1px solid var(--border); }
.character-version p { margin:6px 0; overflow-wrap:anywhere; }
.character-version small { color:var(--muted); }
.character-version button { flex-shrink:0; }
/* Full-window stage: DOM controls retain keyboard access over the Canvas world. */
.scenario-immersive { position:fixed; inset:0; z-index:110; height:100dvh; overflow:hidden; color:#fff; background:radial-gradient(ellipse at 50% 30%,#46675d,#102c2b); isolation:isolate; }
.scenario-stage-frame { position:absolute; width:min(100vw,calc(max(180px,100dvh - var(--scenario-dock-space,160px)) * 1.66667)); aspect-ratio:5/3; top:calc(max(180px,100dvh - var(--scenario-dock-space,160px)) / 2); left:50%; transform:translate(-50%,-50%); }
.scenario-stage-frame .scenario-canvas { display:block; width:100%; height:100%; border:0; border-radius:0; }
.scenario-glass { color:#f7fffb; background:rgba(15,37,34,.76); border:1px solid rgba(235,255,246,.22); border-radius:16px; backdrop-filter:blur(16px); box-shadow:0 8px 30px #03171124; }
.scenario-immersive button { color:inherit; background:rgba(234,255,242,.14); border:1px solid rgba(235,255,246,.24); padding:9px 13px; border-radius:10px; font-size:.8rem; }
@media (hover: hover) and (pointer: fine) { .scenario-immersive button:hover:not(:disabled) { background:rgba(234,255,242,.27); } }
.scenario-immersive button:disabled { opacity:.44; cursor:default; }
.scenario-immersive .muted,.scenario-immersive small { color:#d5e7de; }
.scenario-immersive .error { color:#ffcebc; }
.scenario-objective-label { color:#cae897; font-size:.75rem; font-weight:700; }
.scenario-play-topbar { position:absolute; top:14px; left:16px; right:16px; display:flex; justify-content:space-between; align-items:start; gap:12px; pointer-events:none; }
.scenario-play-topbar > * { pointer-events:auto; }
.scenario-location { display:flex; align-items:center; gap:12px; padding:6px; max-width:34%; }
.scenario-location strong { font-size:.8rem; padding-right:12px; }
.scenario-play-tools { display:flex; gap:8px; }
.scenario-next-objective { position:absolute; top:14px; left:50%; transform:translateX(-50%); width:min(420px,36vw); display:grid; grid-template-columns:1fr auto; padding:12px 14px; gap:4px 12px; }
.scenario-next-objective .scenario-objective-label { grid-column:1; margin:0; }
.scenario-next-objective strong { grid-column:1; font-size:.8rem; line-height:1.4; }
.scenario-next-objective button { grid-column:2; grid-row:1/3; align-self:center; }
.scenario-objective-intro { position:absolute; left:50%; top:15%; transform:translateX(-50%); width:min(500px,80vw); padding:26px; z-index:8; max-height:65vh; overflow-y:auto; }
.scenario-objective-intro h2 { color:#fff; margin:0 0 20px; }
.scenario-objective-intro p { font-size:.95rem; line-height:1.5; }
.scenario-objective-reveal { animation:scenario-objective-enter .45s ease both; }
@keyframes scenario-objective-enter { from {opacity:0;transform:translateY(12px)} to {opacity:1;transform:translateY(0)} }
.scenario-stage-markers,.scenario-actor-bubbles { position:absolute; inset:0; pointer-events:none; }
.scenario-immersive .scenario-place { position:absolute; transform:translate(-50%,-30%); pointer-events:auto; display:flex; align-items:center; gap:5px; padding:3px 7px; background:#184c39c9; border:1px solid #d9ffe6; border-radius:30px; font-size:clamp(.55rem,1vw,.7rem); white-space:nowrap; box-shadow:0 3px 10px #102c2b30; }
.scenario-place.locked { background:#384942bb; }
.scenario-actor-bubble { position:absolute; transform:translate(-50%,-100%); width:clamp(155px,23vw,310px); max-height:32vh; overflow-y:auto; pointer-events:auto; border-radius:16px; box-shadow:0 10px 28px #17382928; scrollbar-width:thin; }
.scenario-speech-bubble { padding:12px 15px; background:rgba(255,255,247,.94); color:#18372e; border-bottom:1px solid #32533b20; }
.scenario-speech-bubble p { margin:0; font-size:.84rem; line-height:1.5; }
.scenario-immersive .scenario-speech-bubble .speech-button { color:#275a3e; background:#d4e2ce6b; width:29px; height:29px; min-width:29px; margin-top:5px; padding:4px; }
.scenario-action-bubble { background:#284c3ce8; padding:9px 13px; font-size:.73rem; color:#edf6df; border-bottom:1px solid #ffffff18; }
.scenario-action-bubble p { margin:3px 0; line-height:1.4; }
.scenario-action-bubble small { font-size:.6rem; text-transform:uppercase; letter-spacing:.1em; }
.scenario-inventory-panel { position:absolute; top:82px; right:16px; width:260px; padding:12px 15px; max-height:55vh; overflow-y:auto; z-index:5; }
.scenario-immersive summary { cursor:pointer; font-size:.8rem; font-weight:650; }
.scenario-inventory-panel p { font-size:.75rem; line-height:1.5; }
.scenario-inventory-stack { border-top:1px solid #ffffff26; margin-top:12px; padding-top:12px; }
.scenario-inventory-stack summary { display:flex; align-items:center; gap:10px; }
.scenario-inventory-stack summary::before { content:'▸'; }
.scenario-inventory-stack[open] summary::before { content:'▾'; }
.scenario-inventory-stack img { width:36px; height:36px; object-fit:contain; }
.scenario-inventory-stack summary strong { margin-left:auto; }
.scenario-inventory-stack label { font-size:.72rem; margin:10px 0; color:#f7fffb; }
.scenario-inventory-stack button { margin:5px 3px 0 0; }
.scenario-immersive input,.scenario-immersive textarea,.scenario-immersive select { color:#fff; background:#102c2ba8; border:1px solid #b3d1c35c; border-radius:9px; }
.scenario-immersive select option { color:#fff; background:#18372e; }
.scenario-history-wrap { position:absolute; left:16px; top:82px; width:290px; z-index:5; }
.scenario-history { padding:12px 15px; }
.scenario-history .scenario-event-log { max-height:43vh; height:auto; margin-top:12px; }
.scenario-history .scenario-event { font-size:.8rem; background:#ffffff0c; padding:10px; }
.scenario-history .scenario-event p { margin:5px 0; }
.scenario-history .scenario-audio-settings { border-color:#ffffff22; font-size:.7rem; }
.scenario-history .scenario-audio-settings label { color:#e4f7eb; }
.scenario-history .scenario-audio-settings small { font-size:.62rem; }
.scenario-play-bottom { position:absolute; bottom:14px; left:50%; transform:translateX(-50%); width:min(820px,calc(100% - 32px)); max-height:55vh; overflow-y:auto; pointer-events:none; display:grid; gap:8px; z-index:6; }
.scenario-play-bottom > * { pointer-events:auto; }
.scenario-live-status { justify-self:center; padding:8px 16px; margin:0; font-size:.8rem; }
.scenario-play-bottom > .error,.scenario-play-bottom > div.scenario-glass { padding:12px; margin:0; }
.scenario-action-tray { display:flex; flex-wrap:wrap; justify-content:center; gap:8px; }
.scenario-action-tray button { max-width:240px; background:#193e32d9; }
.scenario-input-dock { padding:10px 16px; }
.scenario-nearby { font-size:.67rem; margin:0 0 6px; color:#d6e9dc; }
.scenario-voice-row { display:flex; align-items:start; gap:12px; }
.scenario-voice-row > .scenario-microphone { flex:1; min-width:0; border:0; padding:0; margin:0; background:transparent; }
.scenario-voice-row > button { flex-shrink:0; }
.scenario-voice-row .scenario-microphone small { font-size:.62rem; margin:3px 0 0; }
.scenario-voice-row .scenario-microphone-controls { gap:8px; }
.scenario-voice-row .scenario-microphone-controls meter { width:50px; }
.scenario-draft { margin:10px 0 0; padding:12px 0 0; border-top:1px solid #ffffff24; }
.scenario-draft label { color:#d6e9dc; font-size:.7rem; }
.scenario-draft .form-actions { justify-content:flex-end; margin:8px 0 0; }
.scenario-draft button[type=submit] { background:#dcf58c; color:#163a27; }
.scenario-transcript-review { padding:8px 12px; background:#ffffff0d; border-radius:8px; }
.scenario-transcript-review strong { font-size:.65rem; color:#d6e9dc; }
.scenario-transcript-review p { margin:4px 0; font-size:.95rem; }
.scenario-popup-backdrop { position:absolute; inset:0; display:grid; place-items:center; padding:24px; background:#061c2773; z-index:20; }
.scenario-play-popup { width:min(1100px,95vw); max-height:90dvh; overflow-y:auto; padding:24px; background:#18332ef0; }
.scenario-play-popup > header { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-bottom:20px; }
.scenario-play-popup h2,.scenario-play-popup h3 { color:#fff; }
.scenario-play-popup li { padding:12px; line-height:1.5; }
.scenario-play-popup li.complete { color:#d6ed9d; }
.scenario-debug-tabs { display:flex; gap:8px; margin-bottom:18px; }
.scenario-debug-tabs button[aria-selected=true] { background:#dbef95; color:#19382b; }
.scenario-play-popup pre { color:#e0f2e7; background:#071f1b99; padding:18px; border-radius:12px; font-size:.72rem; white-space:pre-wrap; overflow-wrap:anywhere; }
.scenario-debug-assets { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:20px; }
.scenario-debug-assets article { min-width:0; border:1px solid #ffffff20; padding:14px; border-radius:12px; }
.scenario-debug-assets img { width:100%; height:220px; object-fit:contain; background:repeating-conic-gradient(#ffffff15 0% 25%,#ffffff08 0% 50%) 50% / 20px 20px; border-radius:10px; }
@media (prefers-reduced-motion:reduce) { .scenario-objective-reveal {animation:none;} }
@media (max-width:800px) {
 .scenario-play-topbar {top:8px;left:8px;right:8px;}
 .scenario-location {max-width:60%;}.scenario-location strong {display:none;}
 .scenario-next-objective {top:58px;width:calc(100% - 32px);max-width:450px;}
 .scenario-inventory-panel {top:140px;right:8px;width:220px;max-height:40vh;}
 .scenario-history-wrap {top:140px;left:8px;width:220px;}
 .scenario-history-wrap:has(details:not([open])) {width:auto;}
 .scenario-inventory-panel:not([open]) {width:auto;}
 .scenario-actor-bubble {width:180px;max-height:25vh;}
 .scenario-actor-bubble p {font-size:.73rem;}
 .scenario-play-bottom {width:calc(100% - 16px);bottom:8px;}
 .scenario-voice-row {gap:8px;}.scenario-input-dock {padding:10px;}
 .scenario-immersive button {font-size:.72rem;padding:8px 10px;}
 .character-studio-layout {grid-template-columns:1fr;}.character-preview img {height:220px;}
}

.character-prompt .checkbox-field { display:flex; align-items:center; gap:10px; margin:16px 0; }
.character-prompt .checkbox-field input { width:auto; margin:0; }

.scenario-actor-bubble.player-bubble-left { transform:translate(calc(-100% - 55px),-100%); }
.scenario-actor-bubble.player-bubble-right { transform:translate(55px,-100%); }

/* Official provider marks remain legible across the app's themes. */
.social-sign-in-buttons { display: grid; gap: 12px; margin: 24px 0; }
.social-provider { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 48px; width: 100%; border-radius: 8px; font-size: 1rem; font-weight: 500; }
.social-provider svg { flex: 0 0 auto; }
.social-provider-google { background: #fff; color: #1f1f1f; border: 1px solid #747775; }
@media (hover: hover) and (pointer: fine) { .social-provider-google:hover:not(:disabled) { background: #f2f2f2; color: #1f1f1f; } }
.social-provider-apple { background: #000; color: #fff; border: 1px solid #747775; }
@media (hover: hover) and (pointer: fine) { .social-provider-apple:hover:not(:disabled) { background: #222; color: #fff; } }
.auth-divider { display: flex; align-items: center; gap: 16px; margin: 22px 0; color: var(--muted); font-size: .85rem; }
.auth-divider::before, .auth-divider::after { content: ''; height: 1px; flex: 1; background: var(--border); }
.social-provider-unavailable { font-size: .85rem; }
.social-provider-unavailable button { padding: 4px 8px; font-size: inherit; }

/* Each word reserves the width of its longer row, so neighboring readings do
   not overlap in scripts such as Chinese that normally have no word spaces. */
.reader-word[data-has-reading="true"] { display: inline-grid; grid-template-columns: minmax(0, max-content); justify-items: center; vertical-align: baseline; margin-inline: .14em; margin-bottom: .35em; max-width: 100%; line-height: 1.45; }
.reader-word-reading { display: block; max-width: 100%; font-size: calc(.65em / max(1, var(--reader-font-scale, 1))); font-weight: 400; line-height: 1.35; color: color-mix(in srgb, var(--text) var(--reader-transliteration-visibility, 45%), transparent); white-space: normal; overflow-wrap: anywhere; user-select: none; }
.reader-pronunciation-controls { margin: 0; }

/* Generated explanation markup is rendered as ordinary text and word controls. */
button.explanation-target-link { display: inline; padding: 0; margin: 0; border: 0; border-radius: 2px; background: none; color: var(--accent); font: inherit; line-height: inherit; letter-spacing: inherit; text-align: inherit; text-transform: none; vertical-align: baseline; box-shadow: none; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: .18em; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { button.explanation-target-link:hover { background: var(--highlight); text-decoration-style: solid; } }
.target-word-popup { z-index: 90; }
.target-word-popup header > strong { min-width: 0; overflow-wrap: anywhere; }
.word-reading-note { position: relative; }
.word-reading-note > summary { cursor: pointer; list-style: none; }
.word-reading-note > summary::-webkit-details-marker { display: none; }
.word-reading-note[open] { flex-basis: 100%; }
.word-reading-note[open] > span { display: block; max-width: 32em; padding: .4em 0; color: var(--text-secondary); font-size: .85rem; }
.word-transliteration-context { flex-wrap: wrap; }
.scenario-action-option { display: flex; align-items: flex-start; gap: 4px; }
.scenario-action-help { max-width: 240px; padding: 10px; }
.scenario-action-help > summary { cursor: pointer; list-style: none; }
.scenario-action-help > summary::-webkit-details-marker { display: none; }
.scenario-action-help p { margin: 8px 0 0; font-size: .85rem; }

/* Contextual reader flashcards */
.reader-learning-heading { display: flex; align-items: center; gap: 10px; font-size: .9rem; font-weight: 600; }
.reader-learning-label { flex: 1; }
.reader-progress-info { display: inline-flex; flex: none; color: var(--muted); }
.reader-learning-heading strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.reader-learning-track { display: flex; width: 100%; height: 12px; overflow: hidden; border-radius: 99px; background: var(--border-strong); }
.reader-learning-segment { flex: 0 0 auto; height: 100%; transition: width .35s ease; }
.reader-learning-segment[data-level="5"], .reader-learning-swatch[data-level="5"] { background: var(--success); }
.reader-learning-segment[data-level="4"], .reader-learning-swatch[data-level="4"] { background: #8bb45a; }
.reader-learning-segment[data-level="3"], .reader-learning-swatch[data-level="3"] { background: #e3c14e; }
.reader-learning-segment[data-level="2"], .reader-learning-swatch[data-level="2"] { background: var(--warning); }
.reader-learning-segment[data-level="1"], .reader-learning-swatch[data-level="1"] { background: var(--danger); }
.reader-learning-segment[data-level="0"], .reader-learning-swatch[data-level="0"] { background: var(--border-strong); }
.reader-learning-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; list-style: none; margin: 0; padding: 0; font-size: .8rem; color: var(--text-secondary); }
.reader-learning-legend li { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: var(--surface-subtle); }
.reader-learning-legend li > span:nth-child(2) { flex: 1; }
@media (max-width: 600px) { .reader-learning-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.reader-learning-legend strong { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.reader-learning-swatch { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.reader-learning-explanation { margin-top: 20px; color: var(--text-secondary); font-size: .8rem; }
.reader-learning-explanation h3 { margin: 0; color: var(--text); font-size: .9rem; }
.reader-learning-explanation summary { cursor: pointer; font-weight: 600; }
.reader-learning-popup-summary { margin: 0 0 14px; }
.reader-learning-popup-summary > strong { display: block; text-align: end; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.reader-popup .reader-learning-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0; }
.reader-popup .reader-learning-legend li { padding: 0; background: none; gap: 6px; }
.reader-learning-explanation p { margin: 8px 0 0; font-size: .8rem; line-height: 1.5; }
@media (prefers-reduced-motion: reduce) { .reader-learning-segment { transition: none; } }
.reader-flashcard-toolbar, .flashcard-answer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.reader-flashcard-toolbar > button:first-child { padding: 8px 14px; font-size: .9rem; }
.reader-flashcard-toolbar label { margin: 0; }
.flashcard-legend { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: .8rem; margin-top: 12px; }
.flashcard-legend-gradient { flex: 0 0 64px; height: 9px; border-radius: 5px; background: linear-gradient(90deg, hsl(0 72% 48% / .5), hsl(60 72% 48% / .5), hsl(120 72% 48% / .5)); }
.flashcard-page { width: min(860px, 100%); margin-inline: auto; }
.flashcard-back-link { margin-bottom: 14px; }
.flashcard-page-heading { max-width: none; }
.flashcard-page-heading h1:focus { outline: none; }
.flashcard-page-source { color: var(--text-secondary); font-size: 1.1rem; overflow-wrap: anywhere; margin-bottom: 8px; }
.flashcard-page-heading > .muted { font-size: .85rem; }
.flashcard-settings { margin: 20px 0; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.flashcard-settings summary { cursor: pointer; font-weight: 650; }
.flashcard-settings > * + * { margin-top: 14px; }
.flashcard-pairs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.flashcard-settings fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px; min-width: 0; }
.flashcard-settings legend { font-size: .8rem; font-weight: 650; }
.flashcard-settings .option-row { font-size: .8rem; align-items: flex-start; margin: 8px 0; }
.flashcard-settings input[type="number"] { width: 80px; }
.flashcard-session-progress { display: flex; align-items: center; gap: 16px; font-size: .8rem; color: var(--muted); margin-bottom: 22px; }
.flashcard-session-progress progress { flex: 1; min-width: 50px; height: 7px; accent-color: var(--accent); }
.flashcard-preparation { padding: 14px 16px; margin-bottom: 22px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); font-size: .85rem; }
.flashcard-preparation p + p { margin-top: 6px; }
.flashcard-preparation progress { display: block; width: 100%; height: 6px; margin-top: 12px; accent-color: var(--accent); }
.flashcard-preparation button, .flashcard-preparation-error { margin-top: 12px; }
.flashcard-preparation-error { color: var(--text-secondary); overflow-wrap: anywhere; }
.flashcard-preparation-error summary { cursor: pointer; }
.flashcard-waiting { padding: clamp(20px, 4vw, 32px); font-size: 1rem; }
.flashcard-waiting h3 { margin: 8px 0 12px; font-size: 1.35rem; }
.flashcard-waiting > p:last-child { margin-top: 20px; font-size: .85rem; }
.reader-context-card { display: grid; gap: 20px; }
.flashcard-task > p + p { margin-top: 8px; font-size: .85rem; line-height: 1.5; }
.flashcard-task-summary { font-size: .85rem; color: var(--text-secondary); }
.flashcard-task-summary span { display: block; margin-top: 4px; color: var(--muted); font-size: .8rem; }
.flashcard-context { color: color-mix(in srgb, var(--text) 75%, transparent); padding: 30px 12px; border-radius: 14px; background: var(--surface-subtle); text-align: center; font-size: clamp(1.25rem, 4vw, 1.9rem); line-height: 1.65; overflow-wrap: anywhere; white-space: pre-wrap; }
.flashcard-context strong { color: var(--text); }
.flashcard-neighbor { color: color-mix(in srgb, var(--muted) 75%, transparent); font-weight: 400; }
.flashcard-focus { color: var(--text); padding: 0 .15em; font-weight: 750; }
.flashcard-writing-meaning { font-size: 1.15rem; font-weight: 600; text-align: center; }
.flashcard-cue-label { margin: 0 0 8px; color: var(--text-secondary); font-size: .85rem; font-weight: 400; line-height: 1.5; text-align: center; }
.flashcard-context-label { margin-top: 24px; }
.flashcard-writing-blank { display: inline-flex; flex-direction: column; align-items: center; vertical-align: top; min-width: 3em; }
.flashcard-writing-reading { font-size: .9rem; line-height: 1.5; font-weight: 400; color: var(--text-secondary); }
.flashcard-cue { display: flex; align-items: center; justify-content: center; gap: 14px; font-size: 1.05rem; text-align: center; }
.flashcard-reading-help { display: grid; justify-items: center; gap: 10px; margin-top: -6px; }
.flashcard-study-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 24px; }
.flashcard-study-controls > button { font-size: .8rem; }
.flashcard-audio-control { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; font-size: .85rem; color: var(--text-secondary); }
.flashcard-audio-control .speech-control { flex-wrap: wrap; justify-content: center; max-width: 100%; }
.flashcard-audio-control .speech-button { flex-shrink: 0; margin: 0; white-space: nowrap; }
.flashcard-audio-control .speech-error { flex-basis: 100%; }
.flashcard-reading-hint { width: 100%; text-align: center; }
.flashcard-reading-context { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: .45em; color: var(--text-secondary); font-size: 1.05rem; }
.flashcard-reading-context strong { color: var(--text); }
.flashcard-reading-context > * { min-width: 0; overflow-wrap: anywhere; }
.flashcard-response-method { display: flex; flex-wrap: wrap; gap: 8px; }
.flashcard-response-method button[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.flashcard-answer-actions { justify-content: space-between; }
.flashcard-submit-pending { display: flex; align-items: center; justify-content: center; min-width: 88px; min-height: 40px; margin-inline-start: auto; }
.flashcard-feedback { display: grid; justify-items: start; gap: 12px; padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-subtle); }
.flashcard-feedback h3 { font-size: 1.8rem; }
.flashcard-adjusted-note { color: var(--text-secondary); font-size: .85rem; }
.flashcard-adjustment { flex: none; }
button.flashcard-adjustment-toggle { width: 44px; min-width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; }
.flashcard-adjustment-options { display: grid; gap: 18px; }
.flashcard-adjustment-options p { font-size: .85rem; line-height: 1.5; }
.flashcard-adjustment-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.flashcard-adjustment-actions button { font-size: .8rem; }
.flashcard-score-picker { display: grid; justify-items: start; gap: 12px; border: 0; padding: 0; margin: 0; min-width: 0; }
.flashcard-score-picker legend { font-weight: 650; margin-bottom: 8px; }
.flashcard-score-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; width: 100%; }
.flashcard-score-options label { position: relative; display: grid; place-items: center; margin: 0; min-height: 44px; padding: 10px 4px; border: 1px solid hsl(var(--score-hue) 72% 48% / .5); border-radius: 8px; background: hsl(var(--score-hue) 72% 48% / .18); color: var(--text); cursor: pointer; font-weight: 650; }
@media (hover: hover) and (pointer: fine) { .flashcard-score-options label:hover { background: hsl(var(--score-hue) 72% 48% / .3); } }
.flashcard-score-options label.selected { border-color: hsl(var(--score-hue) 72% 48%); background: hsl(var(--score-hue) 72% 48% / .35); box-shadow: inset 0 0 0 1px hsl(var(--score-hue) 72% 48%); font-weight: 800; }
.flashcard-score-options label:has(input:disabled) { opacity: .5; cursor: default; }
.flashcard-score-options input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; }
.explanation-target-text { font-weight: 650; color: var(--text); }
.flashcard-score { --score-color: var(--warning-ink); width: min(100%, 320px); padding-bottom: 6px; }
.flashcard-score-low { --score-color: var(--danger); }
.flashcard-score-high { --score-color: var(--success); }
.flashcard-score-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px; }
.flashcard-score-label { margin: 0; color: var(--text-secondary); font-size: .75rem; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.flashcard-score-value { display: flex; align-items: baseline; gap: 7px; margin: 2px 0 0; }
.flashcard-score-value strong { color: var(--score-color); font-size: 2rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.flashcard-score-value span { color: var(--text-secondary); font-size: .85rem; }
.flashcard-score-verdict { padding: 5px 10px; border-radius: 20px; color: var(--score-color); background: color-mix(in srgb, var(--score-color) 10%, var(--surface)); font-size: .8rem; font-weight: 650; }
.flashcard-score-scale { display: flex; gap: 5px; margin-top: 10px; }
.flashcard-score-scale span { flex: 1; height: 5px; border-radius: 3px; background: var(--border); }
.flashcard-score-scale .filled { background: var(--score-color); }
.flashcard-history { margin-top: 24px; }
.flashcard-history summary { cursor: pointer; color: var(--text-secondary); }
.flashcard-history-row { display: grid; gap: 5px; padding: 12px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.flashcard-history-row small { color: var(--muted); }
.flashcard-history-score { color: var(--text-secondary); font-size: .8rem; font-weight: 600; }
.flashcard-finished { display: grid; gap: 16px; padding-block: 14px; }
.reader-flashcard-microphone { display: grid; gap: 10px; }
.reader-flashcard-microphone [hidden] { display: none !important; }
.reader-flashcard-microphone meter { width: 75px; }
@media (max-width: 520px) {
  .flashcard-pairs { grid-template-columns: 1fr; }
  .reader-flashcard-toolbar { align-items: flex-start; }
}

.flashcard-hints { display: grid; gap: 12px; justify-items: start; margin: 8px 0 20px; }
button.flashcard-hint-toggle { width: 44px; min-width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; }
.flashcard-hint-menu { display: grid; gap: 10px; }
.flashcard-hint-menu p { margin: 0; font-size: .85rem; }
.flashcard-hint-menu button { font-size: .85rem; padding: 10px 14px; text-align: start; }
.flashcard-hint-note { font-size: .8rem; color: var(--text-secondary); }
.flashcard-revealed-hint { width: 100%; padding: 16px; border: 1px dashed var(--border); border-radius: 12px; display: grid; gap: 12px; }
.flashcard-revealed-hint > .muted { font-size: .8rem; }
.flashcard-listening-prompt { background: var(--surface-subtle); padding: 24px; border-radius: 14px; text-align: center; display: grid; gap: 16px; }

/* Introduction-first, continuous reader practice. */
.flashcard-learning-progress { margin: 24px 0; display: grid; gap: 10px; }
.flashcard-learning-progress summary { cursor: pointer; color: var(--text-secondary); }
.flashcard-learning-progress summary > strong { float: right; color: var(--text); font-variant-numeric: tabular-nums; }
.flashcard-learning-track { width: 100%; height: 9px; overflow: hidden; border-radius: 12px; background: var(--border); margin-top: 10px; }
.flashcard-learning-track > span { display: block; height: 100%; border-radius: inherit; transition: width .2s; }
.flashcard-dimension-progress { display: grid; gap: 16px; padding: 20px 0; }
.flashcard-dimension-row { display: grid; grid-template-columns: 1fr auto; gap: 0 16px; }
.flashcard-dimension-row .topic-familiarity-track { grid-column: 1 / -1; }
.flashcard-learning-progress p { font-size: .8rem; line-height: 1.5; }
.flashcard-introduction { display: grid; gap: 18px; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-subtle); }
.flashcard-introduction h3 { font-size: 2rem; margin: 0; }
.flashcard-introduction-reading { color: var(--text-secondary); }
.flashcard-introduction-actions { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; }
.flashcard-introduction-actions .flashcard-introduction-reading { min-width: 0; overflow-wrap: anywhere; text-align: start; }
.flashcard-introduction-contexts { display: grid; gap: 14px; }
.flashcard-introduction-sentence { display: grid; gap: 8px; padding: 14px; background: var(--surface); border-radius: 10px; }
.flashcard-introduction-sentence p { white-space: pre-wrap; overflow-wrap: anywhere; }
.flashcard-example-row { display: flex; align-items: flex-start; gap: 10px; }
.flashcard-example-text { flex: 1; min-width: 0; font-size: 1.1rem; line-height: 2; }
.flashcard-example-actions { display: flex; flex-wrap: wrap; gap: 4px; width: 36px; flex: none; }
.flashcard-example-actions .speech-button { margin: 0; }
.flashcard-example-translation { padding-top: 10px; color: var(--text-secondary); line-height: 1.5; }
.stacked-reading { display: inline-flex; flex-direction: column; vertical-align: top; align-items: center; margin-inline: .12em; padding-block: .2em; line-height: 1.5; }
.stacked-reading > small { font-size: .68em; font-weight: 400; color: var(--muted); line-height: 1.4; }
.flashcard-familiarity { border: 0; padding: 0; margin: 0; min-width: 0; }
.flashcard-familiarity legend { font-weight: 650; margin-bottom: 10px; }
.flashcard-familiarity-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: clamp(4px, 1vw, 8px); margin-top: 14px; }
.flashcard-familiarity-options button { display: grid; grid-template-rows: auto 1fr; gap: 5px; align-items: start; width: 100%; min-width: 0; text-align: center; padding: 12px 4px; }
.flashcard-familiarity-options button, .flashcard-self-ratings > .flashcard-self-rating { background: hsl(var(--familiarity-hue) 72% 48% / .18); border: 1px solid hsl(var(--familiarity-hue) 72% 48% / .5); color: var(--text); }
@media (hover: hover) and (pointer: fine) { .flashcard-familiarity-options button:hover:not(:disabled), .flashcard-self-ratings > .flashcard-self-rating:hover:not(:disabled) { background: hsl(var(--familiarity-hue) 72% 48% / .3); border-color: hsl(var(--familiarity-hue) 72% 48%); } }
.flashcard-familiarity-options strong { font-size: 1.3rem; }
.flashcard-familiarity-options span { font-size: .75rem; line-height: 1.35; overflow-wrap: anywhere; }
.flashcard-learning-settings { display: grid; gap: 14px; }

/* Durable purchased and redeemed credit balances. */
.credit-pools { display: grid; gap: 18px; }
.credit-redemption { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.credit-redemption label { flex: 1; min-width: 180px; }
.credit-pool-list { padding: 0; margin: 0; list-style: none; display: grid; gap: 12px; }
.credit-pool-row { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 18px; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 12px; }
.credit-pool-summary { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.credit-pool-summary p { flex-basis: 100%; }
.credit-pool-expiry small { display: inline; font-size: inherit; }
.credit-pool-info-button { width: 36px; height: 36px; padding: 0; border-radius: 50%; font-size: 1.1rem; }
.credit-pool-expired { color: var(--text-secondary); background: var(--border); }
.credit-pool-bubble { max-height: calc(100dvh - 32px); overflow-y: auto; position: absolute; z-index: 40; top: 58px; right: 12px; width: min(340px, calc(100% - 24px)); padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-raised); }
.credit-pool-bubble header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.credit-pool-bubble dl { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; font-size: .85rem; }
.credit-pool-bubble dt { color: var(--text-secondary); }
.credit-pool-bubble dd { margin: 0; overflow-wrap: anywhere; }
.credit-pool-bubble small { font-size: inherit; }

/* Contextual vocabulary lists. */
.vocabulary-list-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 26px 0 18px; }
.vocabulary-list-link { display: inline-flex; gap: 10px; align-items: center; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: .9rem; font-weight: 600; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .vocabulary-list-link:hover { border-color: var(--border-strong); color: var(--text); } }
.vocabulary-list-link span { padding: 1px 8px; border-radius: 99px; background: var(--surface-subtle); font-size: .76rem; }
.vocabulary-list-link.active { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }
.vocabulary-list-link.active span { background: var(--surface); }
button.vocabulary-list-link.new-list { gap: 6px; border-style: dashed; background: transparent; color: var(--text-secondary); }
.vocabulary-list-create { display: grid; gap: 14px; }
.vocabulary-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 16px; }
.vocabulary-tools .search-field { flex: 1; min-width: min(260px, 100%); padding-block: 2px; }
.vocabulary-collection { display: grid; gap: 4px; }
.vocabulary-no-match { padding: 18px 0; }
.vocabulary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-bottom: 18px; }
.vocabulary-word { display: grid; align-content: start; gap: 8px; min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); overflow-wrap: anywhere; }
.vocabulary-word p, .vocabulary-word h3 { margin: 0; }
.vocabulary-word blockquote { margin: 4px 0; font-size: .92rem; }
.vocabulary-word-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vocabulary-word-heading h3 { font-size: 1.3rem; letter-spacing: -.01em; }
.vocabulary-reading { color: var(--text-secondary); font-size: .9rem; }
.vocabulary-tags, .vocabulary-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.vocabulary-tags .tag { margin: 0; text-decoration: none; }
.vocabulary-list-settings, .vocabulary-word-settings { margin: 4px 0 0; }
.vocabulary-word-settings > summary, .vocabulary-list-settings > summary { width: fit-content; color: var(--muted); font-size: .84rem; font-weight: 600; cursor: pointer; }
.vocabulary-list-settings { margin-bottom: 14px; }
.vocabulary-list-settings > label, .vocabulary-memberships { margin-top: 12px; }
.vocabulary-list-settings > label { max-width: 400px; }
.vocabulary-list-settings .vocabulary-actions { margin-top: 12px; }
.vocabulary-memberships .option-row { margin-top: 6px; }
.vocabulary-word-settings .vocabulary-actions { margin-top: 10px; }
.vocabulary-word-settings .vocabulary-actions button { padding: 7px 12px; font-size: .86rem; }
.vocabulary-actions + p { margin-top: 10px; font-size: .84rem; }
.vocabulary-empty { display: grid; justify-items: center; padding-bottom: 32px; }
.button-row.centered { justify-content: center; }
.vocabulary-save { position: relative; max-width: 100%; font-weight: normal; font-size: .9rem; }
.vocabulary-save > button { padding: 7px 13px; font-size: .86rem; }
.vocabulary-save > button.word-list-button { width: 32px; min-width: 32px; height: 32px; padding: 0; border-radius: 8px; }
.vocabulary-save > button.word-list-button.in-custom-list { background: var(--accent); color: var(--accent-text); }
@media (hover: hover) and (pointer: fine) { .vocabulary-save > button.word-list-button.in-custom-list:hover { background: var(--accent-hover); } }
.vocabulary-save-notice { position: absolute; inset-inline-end: 0; top: calc(100% + 4px); margin: 0; color: var(--muted); font-size: .75rem; white-space: nowrap; }
.vocabulary-save > .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.anchored-popover { display: none; pointer-events: auto; position: fixed; inset: auto; z-index: 120; width: min(380px, calc(100vw - 24px)); height: max-content; max-height: calc(100dvh - 24px); box-sizing: border-box; margin: 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-raised); font-family: var(--font-sans); font-size: .9rem; font-weight: normal; text-align: start; white-space: normal; }
.anchored-popover:popover-open, .anchored-popover.open { display: grid; align-content: start; gap: 12px; animation: popover-in .14s var(--ease); }
.anchored-popover-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.anchored-popover-heading h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; margin: 0; font-size: 1rem; }
.anchored-popover-heading > button { flex: none; }
.anchored-popover-heading[data-title-hidden="true"] { justify-content: flex-end; }
.popover-title-info { flex: none; display: flex; }
.popover-title-info > .icon-button { width: 30px; height: 30px; padding: 6px; }
.vocabulary-save-menu { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 12px; min-width: 0; }
.vocabulary-membership-options { display: grid; gap: 8px; max-height: min(40dvh, 300px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 2px; }
button.vocabulary-membership-option { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-align: start; white-space: normal; box-shadow: none; }
.vocabulary-membership-option > span:not(.vocabulary-list-art) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.vocabulary-membership-option > .vocabulary-list-art { flex: none; width: 30px; height: 30px; font-size: 1.25rem; border-radius: 7px; }
.vocabulary-membership-option > svg { flex: none; }
button.vocabulary-membership-option[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) { button.vocabulary-membership-option:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); } }
@media (hover: hover) and (pointer: fine) { button.vocabulary-membership-option[aria-pressed="true"]:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); } }
.vocabulary-membership-saving { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.vocabulary-membership-saving .word-illustration-spinner { width: 16px; height: 16px; }
.vocabulary-save-menu p { font-size: .85rem; margin: 0; line-height: 1.5; }
.vocabulary-inline-create { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; border-top: 1px solid var(--border); padding-top: 14px; }
.vocabulary-inline-create > label { flex: 1 1 140px; min-width: 0; }
.flashcard-introduction-step { display: grid; gap: 14px; }

/* ---------- Reading screen ---------- */
.reader-view { max-width: 860px; margin: 0 auto; }
.reader-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; }
.reader-title h1 { flex: 1 1 300px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0; font-size: clamp(1.7rem, 3.4vw, 2.3rem); line-height: 1.2; }
.reader-document-actions { position: sticky; top: calc(var(--header-height) + var(--screen-header-offset, 0px)); z-index: 78; isolation: isolate; container: reader-toolbar / inline-size; display: flex; flex-wrap: nowrap; align-items: center; gap: 12px; margin: 0 calc(10px - var(--reading-padding)) 8px; padding-block: 4px; }
.reader-document-actions::before { content: ""; position: absolute; z-index: -1; pointer-events: none; inset-block: 0; left: calc(var(--reader-toolbar-sidebar, var(--sidebar-width)) - var(--reader-toolbar-x, 0px)); width: calc(var(--reader-toolbar-viewport, 100%) - var(--reader-toolbar-sidebar, var(--sidebar-width))); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--sidebar) 92%, transparent); box-shadow: var(--shadow-sm); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); opacity: 0; transition: opacity .18s ease; }
.reader-document-actions[data-docked="true"]::before { opacity: 1; }
.reader-document-actions > .speech-control { min-width: 0; }
.reader-document-actions .speech-button-labeled { min-width: 0; }
.reader-display-actions { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }
.reader-document-actions > .reader-display-actions { flex-wrap: nowrap; min-width: 0; max-width: 100%; }
.reader-display-actions > button.icon-button { width: 44px; min-width: 44px; height: 44px; flex: none; color: var(--muted); background: transparent; }
.reader-display-menu { width:min(320px,calc(100vw - 24px)); }
.reader-display-menu-toggles { display:grid; gap:2px; }
.reader-display-toggle::after { content:""; box-sizing:border-box; flex:none; width:16px; height:16px; margin-inline-start:auto; border:1px solid var(--muted); border-radius:4px; }
.reader-display-toggle[aria-pressed="true"]::after { border-color:var(--accent-ink); background:var(--accent-ink); box-shadow:inset 0 0 0 3px var(--surface); }
.reader-display-menu .reader-more-settings { border-top:1px solid var(--border); border-start-start-radius:0; border-start-end-radius:0; }
.reading-page > .reader-document-actions .speech-button-labeled { width:auto; min-width:44px; padding-inline:8px; gap:6px; }
.reading-page > .reader-document-actions .speech-button-label { display:inline; }
.reading-page .reader-options-button { width:44px; min-width:44px; }
/* Fit the actual reader width, including sidebars and embedded readers. */
.reader-document-actions > .speech-control { flex: none; }
@container reader-toolbar (max-width: 440px) {
    .speech-button-labeled > .speech-button-label { display: none; }
    .speech-button-labeled { width: 44px; height: 44px; padding: 4px; gap: 0; }
}
@container reader-toolbar (max-width: 350px) {
    .reader-display-actions { gap: 0; }
    .reader-display-actions > button.icon-button,
    .speech-button-labeled { width: calc((100cqi - 12px) / 7); min-width: 0; padding: 0; }
    .speech-button-labeled > .speech-button-icon { width: min(2.25rem, 100%); }
}
.reader-display-actions > button[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); }
/* Touch browsers can leave :hover active after tapping. Keep these controls'
   base colors above the generic icon hover rule; keyboard focus stays visible. */
@media (hover: hover) and (pointer: fine) {
    .reader-display-actions > button.icon-button:hover { color: var(--text); background: var(--surface-subtle); }
    .reader-display-actions > button[aria-pressed="true"]:hover { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
}
.reader-progress-icon { display: block; }
.reader-progress-toggle[aria-pressed="true"] .reader-progress-icon-low { stroke: var(--danger); }
.reader-progress-toggle[aria-pressed="true"] .reader-progress-icon-medium { stroke: var(--warning); }
.reader-progress-toggle[aria-pressed="true"] .reader-progress-icon-high { stroke: var(--success); }
.reader-progress-icon-underlines { transition: opacity .15s ease; }
.reader-progress-toggle[aria-pressed="false"] .reader-progress-icon-underlines { opacity: .4; }
.reader-readings-icon { display: block; }
.reader-readings-icon-romanization { transition: opacity .15s ease; }
.reader-readings-toggle[aria-pressed="false"] .reader-readings-icon-romanization { opacity: .4; }
@media (prefers-reduced-motion: reduce) { .reader-readings-icon-romanization { transition: none; } }
/* Keep secondary reader controls accessible without taking space from the text. */
.reader-popup { inset: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); width: min(640px, calc(100vw - 24px)); max-width: calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 0; overflow: clip; border: 1px solid var(--border); border-radius: 20px; color: var(--text); background: var(--surface); box-shadow: var(--shadow-raised); }
.reader-popup[open] { display: flex; flex-direction: column; }
.reader-popup[data-wide="true"] { width: min(1000px, calc(100vw - 24px)); }
.reader-popup::backdrop { background: var(--scrim); }
.reader-popup-heading { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.reader-popup-heading h2 { min-width: 0; margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; }
.reader-popup-heading > button { flex: none; }
.reader-popup-body { min-width: 0; min-height: 0; padding: 20px; overflow-x: hidden; overflow-y: auto; overflow-wrap: anywhere; overscroll-behavior: contain; }
.reader-popup .flashcard-progress-matrix { padding: 20px 0 0; border: 0; border-top: 1px solid var(--border); border-radius: 0; }
.reader-popup .reader-text-actions { margin-top: 0; }
.reader-popup.settings-popup { width: min(920px, calc(100vw - 24px)); max-height: min(900px, calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom))); }
.settings-popup .reader-popup-body { background: var(--bg); }
.settings-popup .settings-layout { max-width: none; }
@media (max-width: 600px) { .reader-popup-heading { padding: 10px 14px; } .reader-popup-body { padding: 16px; } }
.reader-enrichment-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.reader-debug { min-width: 0; margin: 18px 0 0; padding: 16px; border-style: dashed; }
.reader-developer-settings { margin-top:16px; padding-top:16px; border-top:1px solid var(--border); }
.reader-debug-output { max-width: 100%; max-height: min(50dvh, 420px); margin: 14px 0 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .75rem; }
.chip-toggle { display: inline-flex; align-items: center; gap: 8px; width: fit-content; padding: 6px 12px 6px 9px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: .86rem; font-weight: 600; cursor: pointer; }
.chip-toggle:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); }
.chip-toggle input { width: 16px; height: 16px; }
.inline-select { display: inline-flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: .86rem; }
.inline-select select { width: auto; padding-block: 6px; }
.reader-page-count { font-variant-numeric: tabular-nums; }

/* ---------- Practice heroes (Words and Role-play) ---------- */
.practice-hero { position: relative; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 18px 28px; overflow: hidden; padding: 26px 28px; border: 1px solid var(--border); border-radius: var(--radius-xl); background: linear-gradient(135deg, var(--surface) 45%, var(--accent-soft)); box-shadow: var(--shadow); }
.practice-hero-copy { display: grid; gap: 6px; max-width: 560px; }
.practice-hero-copy h2 { margin: 2px 0 0; font-size: 1.5rem; letter-spacing: -.02em; }
.practice-hero-copy p:not(.eyebrow) { margin: 0; color: var(--text-secondary); line-height: 1.55; }
.practice-hero-copy .button-row { margin-top: 12px; }
button.practice-hero-button { padding: 13px 22px; font-size: 1rem; box-shadow: var(--shadow); }
.roleplay-hero { padding-right: 200px; }
.roleplay-art { position: absolute; right: 26px; bottom: 0; top: 0; width: 170px; }
.roleplay-bubble { position: absolute; display: block; border-radius: 22px; box-shadow: var(--shadow); }
.roleplay-bubble.one { top: 26px; left: 0; width: 120px; height: 52px; border-bottom-left-radius: 4px; background: var(--surface); background-image: linear-gradient(var(--border) 3px, transparent 3px), linear-gradient(var(--border) 3px, transparent 3px); background-size: 70px 3px, 50px 3px; background-position: 18px 18px, 18px 30px; background-repeat: no-repeat; }
.roleplay-bubble.two { top: 92px; right: 0; width: 120px; height: 52px; border-bottom-right-radius: 4px; background: var(--accent); background-image: linear-gradient(rgba(255,255,255,.55) 3px, transparent 3px), linear-gradient(rgba(255,255,255,.55) 3px, transparent 3px); background-size: 74px 3px, 44px 3px; background-position: 18px 18px, 18px 30px; background-repeat: no-repeat; }
.roleplay-bubble.three { top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; background: var(--marigold); box-shadow: none; animation: gentle-float 2.6s ease-in-out infinite; }
.choice-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice-card { position: relative; display: grid; align-content: start; gap: 3px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); font-weight: 500; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .choice-card:hover { border-color: var(--accent); } }
.choice-card.selected { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card strong { font-size: .95rem; }
.choice-card small { color: var(--muted); font-size: .82rem; line-height: 1.4; }

/* ===================================================================   Responsive layout
   ========================================================================== */
@media (max-width: 1080px) {
  .home-grid.has-sidebar { grid-template-columns: minmax(0, 1fr); }
  .home-side { position: static; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
}

@media (max-width: 900px) {
  .entry-split { grid-template-columns: 1fr; width: min(520px, 100%); }
  .entry-aside { display: none; }
  .level-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-actions { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .roleplay-hero { padding-right: 28px; }
  .roleplay-art { display: none; }
  .choice-cards { grid-template-columns: 1fr; }
  .reader-display-grid { grid-template-columns: 1fr; }
  .practice-hero { padding: 22px; }
  .app-shell, .app-shell.sidebar-collapsed { --sidebar-width: min(300px, 86vw); --content-inset-start: 0px; grid-template-columns: minmax(0, 1fr); }
  .app-shell > .workspace { grid-column: 1; }
  .reader-document-actions { --reader-toolbar-sidebar: 0px; }
  .app-header { gap: 6px; padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  /* Keep the drawer's frost on a dedicated layer so compositing its slide-in
     transition over the scrim does not flatten the page behind the blur. */
  .sidebar { z-index: 85; width: var(--sidebar-width); padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); box-shadow: var(--shadow-raised); transform: translateX(-104%); background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .sidebar::before { content: ""; position: absolute; z-index: -1; inset: 0; background: var(--sidebar); pointer-events: none; }
  @supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .sidebar::before { background: color-mix(in srgb, var(--sidebar) 88%, transparent); backdrop-filter: saturate(1.3) blur(24px); -webkit-backdrop-filter: saturate(1.3) blur(24px); }
  }
  .sidebar-collapsed .sidebar { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .sidebar-expanded .sidebar { transform: none; }
  .app-shell button.sidebar-scrim { display: none; }
  .sidebar-expanded button.sidebar-scrim { display: block; position: fixed; z-index: 84; inset: var(--header-height) 0 0; width: 100%; height: auto; padding: 0; border-radius: 0; background: var(--scrim); animation: fade-in .2s ease both; }
  .sidebar .profile-menu-popover, .sidebar-collapsed .sidebar .profile-menu .profile-menu-popover { top: calc(100% + 8px); inset-inline-start: 0; width: 100%; }
  .workspace { padding: 22px max(16px, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .page-header { margin-bottom: 20px; }
  h1 { font-size: 1.8rem; }
  .home-hero h1 { gap: 14px; font-size: 2.25rem; }
  .activity-grid { grid-template-columns: 1fr; }
  .continue-card { grid-template-columns: auto minmax(0, 1fr); gap: 16px; padding: 18px; }
  .continue-action { grid-column: 1 / -1; justify-content: center; }
  .first-story { grid-template-columns: 1fr; gap: 10px; padding: 22px; }
  .first-story-art { height: 96px; max-width: 150px; }
  .reader-action-card { padding: 18px; }
  .entry-topbar { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: 18px; }
}

@media (max-width: 540px) {
  .surface { padding: 18px; border-radius: 14px; }
  .row, .inline-control { grid-template-columns: 1fr; }
  .inline-control button { width: 100%; }
  .language-card { min-height: 60px; gap: 10px; padding: 8px 12px; }
  .language-flags { gap: 8px; margin-block: -10px; font-size: 2.9rem; }
  .character-rendering-grid, .transliteration-grid { grid-template-columns: 1fr; }
  .level-picker { grid-template-columns: 1fr; }
  .entry-shell { padding: 0 max(12px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .entry-panel { padding: 24px 20px; border-radius: 18px; }
  .onboarding-active-question, .onboarding-review-screen { padding: 22px 16px; border-radius: 18px; }
  .onboarding-steps li:not(.active) .onboarding-step-label { visibility: hidden; }
  .search-field.large { padding-left: 14px; }
  .search-field.large input { font-size: 1rem; }
  .search-field.large button { padding: 10px 14px; }
  .document-row { padding: 10px; }
  .reading-page { --reading-padding: 18px; padding-block: 8px 20px; border-radius: 14px; }
  .reader-line { font-size: 1.12rem; }
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rating-row { display: grid; grid-template-columns: 1fr 1fr; }
  .rating-row button { width: 100%; }
  .gateway-actions { flex-direction: column; align-items: stretch; }
  .gateway-actions button { width: 100%; }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .chunk-progress { animation: none; }
}

/* Character practice: warm paper, quiet grid, jade ink and gold guidance. */
.writing-practice { margin: 1.4rem 0; padding: clamp(1rem, 3vw, 1.6rem); border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(145deg, var(--surface), var(--bg-accent)); }
.writing-slots-row { display: flex; align-items: center; justify-content: center; gap: .5rem; margin: 0 0 1.3rem; }
.writing-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin: 0; }
.writing-restart { flex: none; }
.writing-slot { display: inline-flex; align-items: center; justify-content: center; min-width: 2.5rem; height: 3rem; padding: .2rem .45rem; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 1.25rem; font-weight: 600; transition: background .22s, border-color .22s, color .22s, transform .22s, box-shadow .22s; }
.writing-slot.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); transform: translateY(-2px); }
.writing-slot.correct { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.writing-slot.assisted { background: var(--warning-soft); color: var(--warning-ink); border-color: var(--warning); }
.writing-slot.wrong { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.writing-slot.ghost { color: var(--warning-ink); background: var(--warning-soft); border: 1.5px dashed var(--warning); opacity: .68; }
.writing-slot.literal { border-color: transparent; background: transparent; min-width: .5rem; padding: .1rem; }
.writing-canvas-wrap { position: relative; max-width: 390px; margin: 0 auto 1rem; border: 1px solid var(--border-strong); border-radius: 20px; overflow: hidden; background: radial-gradient(ellipse at 25% 15%, var(--surface), var(--surface-subtle)); box-shadow: inset 0 0 40px var(--surface), var(--shadow); }
.writing-canvas { display: block; width: 100%; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; cursor: crosshair; }
.writing-canvas-caption { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: .55rem; letter-spacing: .2em; color: var(--muted); pointer-events: none; opacity: .65; }
.writing-practice[data-disabled="true"] .writing-canvas { cursor: wait; opacity: .7; }
.writing-keyboard-label { display: flex; flex-direction: column; gap: .4rem; max-width: 390px; margin: 0 auto; }
.writing-keyboard { text-align: center; font-size: 1.2rem; padding: .9rem; }
.writing-keyboard[data-hinted="true"]::placeholder { color: var(--warning-ink); opacity: .7; }
.writing-practice[data-voice="true"] .writing-keyboard-label { display: none; }
.writing-status { text-align: center; min-height: 2.8em; color: var(--text-secondary); font-size: .9rem; margin: .8rem 0; }
.writing-status:empty { display: none; }
.writing-footer { display: flex; justify-content: flex-end; margin-top: 12px; }
.icon-button.writing-hint-button { border-radius: 50%; }
.writing-practice[data-kind="complete"] .writing-footer { display: none; }
.writing-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin: 1rem 0 .6rem; font-size: .75rem; }
.writing-key::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: .35rem; }
.writing-key.correct::before { background: var(--success); }
.writing-key.wrong::before { background: var(--danger); }
.writing-key.assisted::before { background: var(--warning); }
.writing-help, .writing-scoring { font-size: .8rem; line-height: 1.55; }
.writing-scoring { display: grid; gap: 10px; color: var(--muted); }
.writing-scoring h4, .writing-scoring p { margin: 0; }
.writing-scoring h4 { font-size: inherit; }
.writing-complete { text-align: center; font-weight: 650; color: var(--success); padding: .8rem; }
.writing-unavailable { padding: 1rem; background: var(--surface-subtle); border-radius: 12px; }
.writing-practice [hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .writing-slot { transition: none; } }

.reader-text-actions { margin: 12px 0; }
.reader-word-help-model { margin: 0 0 16px; font-size: .82rem; overflow-wrap: anywhere; }
.reader-word-help-model > span { color: var(--text-secondary); }

.word-compounds { margin: .65rem 0; font-size: .85rem; font-weight: 400; }
.word-compounds-label { color: var(--muted); font-size: .75rem; }
.word-compounds ul { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 0; padding: 0; list-style: none; }
.word-compounds li { display: flex; max-width: 220px; }
.word-compounds .explanation-target-link { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: .2rem; padding: .35rem .6rem; border: 1px solid var(--border); border-radius: .6rem; font-weight: 600; text-decoration: none; }
.word-compound-meaning { color: var(--text-secondary); font-size: .75rem; font-weight: 400; }
.word-compound-group { margin-block: .4rem; }

/* Optional story illustrations sit at the sentence they depict. */
.reader-illustration-controls { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.reader-illustration-controls p { font-size: .85rem; margin: 8px 0; }
.reader-illustration-controls label { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; }
.reader-illustration-status { display: flex; align-items: center; gap: 8px; color: var(--accent-ink); }
.reader-story-image { position: relative; margin: 1.4em auto; max-width: 900px; overflow: hidden; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); break-inside: avoid; }
.reader-story-image img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: contain; animation: fade-in .5s ease; }
.reader-story-image-placeholder { display: grid; place-content: center; gap: 10px; padding: 24px; aspect-ratio: 3 / 2; min-height: 0; box-sizing: border-box; justify-items: center; text-align: center; font: .9rem/1.5 var(--font-sans); background: radial-gradient(ellipse at 30% 20%, var(--accent-soft), var(--surface-subtle)); }

.story-image-toolbar { position: absolute; z-index: 1; color: #fff; background: rgb(20 25 32 / 32%); border: 1px solid rgb(255 255 255 / 24%); box-shadow: 0 2px 10px rgb(0 0 0 / 14%); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.story-image-toolbar { bottom: 12px; right: 12px; display: flex; align-items: center; gap: 4px; padding: 4px; border-radius: 14px; font: .8rem/1.5 var(--font-sans); direction: ltr; }
.story-image-history { display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.story-image-history .muted { color: inherit; min-width: 36px; text-align: center; }
.story-image-toolbar button.icon-button { width: 36px; min-width: 36px; height: 36px; padding: 0; color: inherit; border: 0; box-shadow: none; background: transparent; }
@media (hover: hover) and (pointer: fine) { .story-image-toolbar button.icon-button:hover:not(:disabled) { background: rgb(255 255 255 / 18%); color: #fff; } }
.story-image-history + .story-image-regenerate { margin-left: 4px; }
.story-image-regenerate[data-regenerating="true"] .shell-icon { animation: story-image-spin 1.5s linear infinite; }
.reader-story-image .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.reader-story-image .story-image-error { position: absolute; z-index: 2; left: 12px; right: 12px; bottom: 68px; margin: 0; padding: 10px 12px; max-height: calc(100% - 128px); overflow: auto; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); font: .85rem/1.5 var(--font-sans); }
@media (prefers-reduced-motion: reduce) { .story-image-regenerate[data-regenerating="true"] .shell-icon { animation: none; } }

/* Meaning-specific illustrations shared by reader bubbles and flashcards. */
.word-illustration { position: relative; width: min(100%, 240px); margin: 16px auto; overflow: hidden; border-radius: 16px; background: var(--surface-subtle); }
.word-illustration > img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: cover; animation: fade-in .3s ease both; }
.word-illustration-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; min-height: 150px; padding: 16px; color: var(--text-secondary); font-size: .78rem; text-align: center; }
.word-illustration-spinner { width: 28px; height: 28px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: word-image-spin 1s linear infinite; }
.passage-illustration { width: 100%; }
.passage-illustration > img { aspect-ratio: 3 / 2; }
.word-illustration-error { min-height: 110px; }
.word-illustration-error-detail { max-height: 5em; overflow: auto; overflow-wrap: anywhere; }
.word-illustration-error button { font-size: .8rem; padding: 6px 10px; }
@keyframes word-image-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .word-illustration > img, .word-illustration-spinner { animation: none; } }

/* Full-screen study: the app remains visible, softly out of focus behind it. */
.flashcard-stage { --study-height: 100dvh; --study-top: 0px; position: fixed; inset: var(--study-top) 0 auto; width: 100%; max-width: none; height: var(--study-height); max-height: none; margin: 0; padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border: 0; overflow: hidden; color: var(--text); background: transparent; }
.flashcard-stage { overscroll-behavior: none; }
/* Neutral dialog focus keeps keyboard shortcuts active without a viewport outline. */
.flashcard-stage:focus { outline: none; }
.flashcard-stage::backdrop { position: fixed; inset: 0; background: rgb(8 12 18 / .68); backdrop-filter: blur(12px) saturate(.55); -webkit-backdrop-filter: blur(12px) saturate(.55); animation: study-backdrop-in .3s ease both; }
.flashcard-stage[open], .study-session { display: grid; grid-template-rows: 56px minmax(0, 1fr); gap: 20px; }
.study-session { min-height: 0; height: 100%; grid-row: 1 / -1; grid-column: 1; }
.study-loading { grid-row: 2; place-self: center; display: flex; align-items: center; gap: 12px; padding: 14px 22px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); }
.study-topbar { position: relative; z-index: 4; display: flex; align-items: center; gap: 16px; width: min(760px, 100%); justify-self: center; padding: 6px 8px 6px 20px; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: 999px; background: color-mix(in srgb, var(--surface) 92%, transparent); box-shadow: 0 8px 32px rgb(0 0 0 / .2); }
.study-source { min-width: 0; flex: 1; display: grid; gap: 1px; }
.study-source span { font-size: .65rem; text-transform: uppercase; letter-spacing: .12em; color: var(--text-secondary); }
.study-source-summary { display: flex; align-items: center; gap: 4px; min-width: 0; }
.study-source .study-source-word-count { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; letter-spacing: normal; }
.study-source-modes { display: flex; align-items: center; gap: 3px; flex: none; }
.study-source .study-source-mode { display: inline-flex; align-items: center; }
.study-source strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .85rem; font-weight: 650; }
.study-management { display: flex; align-items: center; gap: 4px; }
.study-close { flex: none; border-radius: 50%; }
.study-menu > summary { display: flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; list-style: none; padding: 10px; border-radius: 999px; font-size: .8rem; font-variant-numeric: tabular-nums; }
.study-menu > summary::-webkit-details-marker { display: none; }
.study-menu[open] > summary { background: var(--accent-soft); color: var(--accent-ink); }
@media (hover: hover) and (pointer: fine) { .study-menu > summary:hover { background: var(--accent-soft); color: var(--accent-ink); } }
.study-menu-panel { position: absolute; top: calc(100% + 12px); right: 0; width: min(420px, 100%); max-height: calc(var(--study-height) - 108px); overflow: auto; overscroll-behavior: contain; padding: 22px; display: grid; gap: 14px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
.study-menu-panel h3 { margin: 0; font-size: 1.05rem; }
.study-menu-panel > p { font-size: .85rem; }
.study-menu-panel .flashcard-learning-progress, .study-menu-panel .flashcard-settings, .study-menu-panel .flashcard-preparation { margin: 0; }
.study-menu-panel .flashcard-history-row { padding-top: 0; }
.flashcard-session-word { display: grid; gap: 4px; overflow-wrap: anywhere; }
.flashcard-session-word > strong { font-size: 1.1rem; }
.flashcard-session-word > span { color: var(--text-secondary); font-size: .85rem; }
.flashcard-session-word-progress { display: grid; gap: 6px; text-align: end; font-size: .85rem; }
/* Reserve a stable answer area within each practice mode. */
.study-scene { grid-row: 2; min-width: 0; min-height: 0; width: min(660px, 100%); justify-self: center; container-type: inline-size; display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, clamp(130px, 30%, 280px)); gap: 18px; }
.flashcard-starting-status { grid-row: 1 / -1; place-self: center; display:flex; flex-direction:column; align-items:center; gap:12px; color:var(--text-secondary); }
@media (prefers-reduced-motion: reduce) { .flashcard-starting-status .loading-dots span { animation:none; } }
.study-question { display: contents; }
.study-question-cue { display: grid; justify-items: center; min-width: 0; text-align: center; }
.study-question-cue .flashcard-hints { justify-items: center; }
.study-card { position: relative; width: 100%; height: 100%; max-height: 200cqw; align-self: center; min-height: 0; overflow: hidden; isolation: isolate; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: 28px; background: var(--surface); box-shadow: 0 24px 70px rgb(0 0 0 / .28), 0 2px 8px rgb(0 0 0 / .1); animation: study-card-in .5s cubic-bezier(.16,1,.3,1) both; transform-origin: 50% 55%; }
.study-card::before { content: ''; position: absolute; z-index: 1; inset: 0 24px auto; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 22%, transparent), transparent); pointer-events: none; }
.study-card[data-kind="feedback"] { animation: study-card-flip .58s cubic-bezier(.2,.8,.2,1) both; }
.study-card-scroll { --study-card-padding: clamp(22px, 4vw, 36px); height: 100%; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; overflow-wrap: anywhere; }
.study-card-scroll:focus-visible {   border-radius: inherit; }
.flashcard-session .study-card-scroll:focus { outline: none; }
.study-card-body { padding: var(--study-card-padding); }
.study-card-header { position: sticky; top: 0; z-index: 3; padding: 22px var(--study-card-padding); background: var(--surface); }
.study-card-header::after { content: ''; position: absolute; inset: auto var(--study-card-padding) 0; height: 1px; background: var(--border); opacity: 0; transition: opacity .15s ease; pointer-events: none; }
.study-card[data-scrolled="true"] .study-card-header::after { opacity: 1; }
.study-card-header .study-card-eyebrow { margin: 0; }
.study-card-header + .study-card-body { padding-top: 14px; }
.study-card:not(:has(.study-card-header)) .study-card-body { min-height: 100%; display: grid; }
.study-card-eyebrow { color: var(--text-secondary); font-size: .68rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 22px; text-align: center; }
.study-card .flashcard-context { background: none; padding: 16px 0 28px; font-size: clamp(1.2rem, 3vw, 1.75rem); }
.study-card .flashcard-cue { display: block; font-size: 1.1rem; }
.study-card .flashcard-introduction, .study-card .flashcard-feedback { border: 0; background: none; padding: 0; border-radius: 0; }
.study-card .flashcard-introduction { text-align: center; justify-items: center; gap: 14px; }
.study-card .flashcard-introduction h3, .study-card .flashcard-feedback h3 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.2; letter-spacing: -.02em; }
.study-card .flashcard-introduction .study-card-eyebrow { margin-bottom: 0; }
.study-card .flashcard-introduction-contexts { width: 100%; text-align: start; margin-top: 10px; }
.study-card .flashcard-introduction-contexts h4 { font-size: .8rem; color: var(--text-secondary); }
.study-card .flashcard-introduction-sentence { background: var(--surface-subtle); }
.study-card .word-illustration { width: min(100%, 180px); margin-block: 8px; overflow: visible; background: transparent; }
.study-card .word-illustration[data-compact="true"] {width:min(100%,88px);transition:width .25s ease;}
.study-card .word-illustration[data-compact="true"][data-expanded="true"] {width:min(100%,180px);}
.word-illustration-zoom {position:absolute;inset:0;z-index:1;width:100%;height:100%;min-height:0;padding:0;border:0;border-radius:inherit;background:transparent;box-shadow:none;cursor:zoom-in;}
.word-illustration[data-expanded="true"] .word-illustration-zoom {cursor:zoom-out;}
.word-illustration-zoom:active {background:transparent;}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .word-illustration-zoom:hover { background:transparent; } }
.word-illustration[data-compact="true"] .word-image-report {z-index:2;}
.study-card .word-illustration[data-compact="true"] > .word-illustration-placeholder:not(.word-illustration-error) {min-height:0;padding:0;aspect-ratio:1;}
@media(prefers-reduced-motion:reduce) {.study-card .word-illustration[data-compact="true"] {transition:none;}}
.study-card .word-illustration > img { border-radius: 16px; }
.study-card .word-illustration .story-image-toolbar { position: static; width: fit-content; max-width: 100%; margin: 10px auto 0; background: var(--surface-subtle); color: var(--text); border-color: var(--border); box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
@media (hover: hover) and (pointer: fine) { .study-card .word-illustration .story-image-toolbar button.icon-button:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); } }
.study-card .flashcard-feedback { position: relative; }
.study-card .flashcard-score { width: 100%; }
.study-card .flashcard-task-summary { font-size: .76rem; }
.study-card .flashcard-hints { margin-bottom: 0; }
.study-card .flashcard-listening-prompt { background: var(--surface-subtle); }
.study-dock { align-self: end; justify-self: center; width: 100%; max-height: 100%; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 18px 22px; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: 24px; background: color-mix(in srgb, var(--surface) 96%, transparent); box-shadow: 0 12px 40px rgb(0 0 0 / .25); animation: study-dock-in .4s .1s ease both; }
/* Familiarity is a rapid sequence: keep answer targets stationary and usable
   immediately instead of replaying a delayed slide on every rating. */
.flashcard-session .study-introduction-dock { animation: none; }
.flashcard-session .study-card[data-kind="introduction"] { animation: study-familiarity-in .16s ease-out both; }
@keyframes study-familiarity-in { from { opacity: .6; } to { opacity: 1; } }
.study-dock-compact { width: fit-content; max-width: 100%; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px; }
.study-dock button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.study-answer-dock { display: grid; gap: 12px; }
.study-dock .flashcard-task { display: flex; align-items: center; justify-content: center; gap: 6px; }
.study-dock .flashcard-task-title { font-size: 1rem; margin: 0; text-align: center; }
.study-dock .flashcard-task-info { flex: 0 0 32px; width: 32px; height: 32px; padding: 6px; }
.flashcard-answer-help { display: grid; gap: 12px; font-size: .85rem; line-height: 1.5; }
.flashcard-answer-input { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: center; gap: 8px 10px; }
.flashcard-answer-editor { position: relative; grid-column: 1; grid-row: 1; min-width: 0; }
.study-dock .flashcard-answer-editor :is(input, textarea) { display: block; width: 100%; margin: 0; }
.flashcard-answer-editor[data-recording="true"] :is(input, textarea) { visibility: hidden; }
.flashcard-dictation { display: contents; }
.flashcard-dictation .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.flashcard-dictation-preview { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 4px; overflow: auto; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); }
.flashcard-dictation-preview strong { display: flex; align-items: center; gap: 6px; font-size: .65rem; line-height: 1.2; color: var(--text-secondary); }
.flashcard-dictation-preview p { margin: 0; font-size: 1rem; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; }
.study-dock .flashcard-dictation .flashcard-mic-button { touch-action: manipulation; }
.flashcard-dictation .flashcard-mic-button[data-state="recording"] { background: var(--danger); color: white; border-color: var(--danger); }
.flashcard-dictation .flashcard-mic-button[data-state="busy"] { background: var(--accent-soft); }
.study-dock .flashcard-answer-input :is(input, textarea) { grid-column: 1; grid-row: 1; min-width: 0; margin: 0; }
.flashcard-pronunciation-input { min-height: 56px; font-size: clamp(1.25rem, 3vw, 1.6rem); line-height: 1.4; }
.reader-flashcard-microphone[data-compact="true"],
.reader-flashcard-microphone[data-compact="true"] .reader-flashcard-toolbar { display: contents; }
.study-dock .flashcard-mic-button { grid-column: 2; grid-row: 1; width: 44px; height: 44px; border-radius: 50%; padding: 0; touch-action: none; user-select: none; }
.reader-flashcard-microphone[data-compact="true"] meter { grid-column: 2; width: 44px; height: 4px; }
.reader-flashcard-microphone[data-compact="true"]:not([data-state="hold"]) meter { display: none; }
.reader-flashcard-microphone[data-compact="true"] .ghost { grid-column: 1; justify-self: end; padding: 4px 8px; font-size: .75rem; }
.reader-flashcard-microphone[data-compact="true"] small { grid-column: 1 / -1; color: var(--muted); font-size: .75rem; }
.reader-flashcard-microphone[data-compact="true"] small.error { color: var(--danger); }
.reader-flashcard-microphone[data-compact="true"] small:empty { display: none; }
.study-dock .flashcard-response-method { justify-content: center; }
.study-dock .flashcard-response-method button { font-size: .75rem; padding: 6px 12px; }
.study-dock label { font-size: .78rem; margin: 0; }
.study-dock textarea { min-height: 56px; max-height: 120px; margin-top: 6px; resize: vertical; }
.study-dock .flashcard-answer-actions { gap: 8px; }
.study-dock .flashcard-answer-actions button { padding: 10px 18px; font-size: .85rem; }
.study-dock .flashcard-familiarity { text-align: center; }
.study-dock .flashcard-familiarity legend { width: 100%; font-size: .9rem; margin-bottom: 4px; }
.study-dock .flashcard-familiarity > p { font-size: .75rem; }
.study-dock .flashcard-familiarity-options { margin-top: 12px; }
.study-dock .flashcard-familiarity-options button { display: grid; border-radius: 14px; transition: transform .18s, background .18s; }
@media (hover: hover) and (pointer: fine) { .study-dock .flashcard-familiarity-options button:hover:not(:disabled) { transform: translateY(-3px); } }
.study-dock .flashcard-familiarity-options button:active:not(:disabled) { transform: scale(.94); }
.flashcard-familiarity-heading { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.flashcard-session .study-introduction-dock .flashcard-familiarity-options button { transition: background .12s; }
.flashcard-session .study-introduction-dock .flashcard-familiarity-options button:is(:active):not(:disabled) { transform: none; }
@media (hover: hover) and (pointer: fine) { .flashcard-session .study-introduction-dock .flashcard-familiarity-options button:is(:hover, :active):not(:disabled) { transform: none; } }
.study-dock .flashcard-skills-toggle { flex: 0 0 38px; width: 38px; height: 38px; padding: 8px; border-radius: 10px; }
.flashcard-skills-toggle[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.study-scene:has(.study-introduction-dock[data-separate="true"]) { grid-template-rows: minmax(0, 1fr) minmax(0, auto); }
.study-introduction-dock[data-separate="true"] { max-height: min(60dvh, 350px); }
.flashcard-introduction-skills { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.flashcard-introduction-skill { display: grid; grid-template-rows: 1fr auto; align-items: center; justify-items: center; gap: 8px; padding: 10px 6px; min-width: 0; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-subtle); }
.flashcard-introduction-skill > span { font-size: .75rem; line-height: 1.3; overflow-wrap: anywhere; }
.flashcard-introduction-skill .word-progress-chip { min-height: 36px; width: 100%; max-width: 90px; font-size: .8rem; }
.flashcard-introduction-confirm { display: flex; justify-content: flex-end; margin-top: 12px; }
.flashcard-introduction-confirm button { min-height: 42px; padding: 10px 20px; font-size: .85rem; }
.flashcard-introduction-confirm .word-illustration-spinner { width: 16px; height: 16px; }
@media (max-width: 520px) {
    .flashcard-introduction-skills { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.study-welcome { display: flex; min-height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.study-welcome > h2 { font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.025em; line-height: 1.2; }
.study-welcome > p { max-width: 440px; font-size: .95rem; color: var(--text-secondary); line-height: 1.65; }
.study-welcome .eyebrow { color: var(--accent-ink); font-size: .66rem; }
.study-welcome-icon { display: grid; place-items: center; width: 80px; height: 80px; border-radius: 26px; background: var(--accent-soft); color: var(--accent-ink); transform: rotate(-8deg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 15%, transparent); }
.study-welcome .flashcard-preparation { border: 0; margin: 0; padding: 0; background: none; }
.study-ready { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--text-secondary); animation: study-ready-out .4s ease 1s forwards; }
@keyframes study-ready-out { to { opacity: 0; } }
.study-status { position: absolute; z-index: 5; top: 76px; left: 50%; transform: translateX(-50%); max-width: min(600px, calc(100% - 32px)); padding: 6px 14px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); font-size: .75rem; }
.study-transitions { position: absolute; inset: 0; pointer-events: none; z-index: 2; overflow: hidden; perspective: 1000px; }
.study-departure { position: absolute; margin: 0; animation: none !important; pointer-events: none; }
.study-departure * { animation: none !important; }
@keyframes study-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes study-card-in { from { opacity: 0; transform: translateX(90px) rotate(4deg) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes study-card-flip { 0%, 30% { opacity: 0; transform: perspective(1000px) rotateY(-85deg) scale(.96); } 100% { opacity: 1; transform: perspective(1000px) rotateY(0) scale(1); } }
@keyframes study-dock-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (max-width: 520px) {
    .flashcard-stage { padding-inline: 10px; }
    .flashcard-stage[open], .study-session { gap: 14px; }
    .study-topbar { gap: 6px; padding-inline-start: 14px; }
    .study-management { gap: 0; }
    .study-menu > summary { padding: 9px; }
    .study-menu > summary span { font-size: .72rem; }
    .study-source strong { font-size: .76rem; }
    .study-scene { gap: 12px; }
    .study-card { border-radius: 23px; }
    .study-dock { border-radius: 20px; padding: 14px; }
    .study-dock .flashcard-familiarity-options span { font-size: .64rem; }
    .study-dock .flashcard-familiarity-options button { padding: 10px 2px; }
}
@media (max-height: 560px) {
    .flashcard-stage { padding-block: 8px; }
    .flashcard-stage[open], .study-session { grid-template-rows: 44px minmax(0, 1fr); gap: 10px; }
    .study-scene { gap: 10px; padding-top: 0; }
    .study-card-scroll { --study-card-padding: 24px; }
    .study-card-header { padding-block: 10px; }
    .study-card .study-card-header h3 { font-size: 1.5rem; }
    .study-card-header .flashcard-introduction { gap: 4px; }
    .study-card-body { padding-block: 18px; }
    .study-dock { padding: 12px 16px; }
    .study-dock .flashcard-task > .muted { display: none; }
    .study-source span { display: none; }
    .study-status { top: 56px; }
    .study-welcome { gap: 10px; }
    .study-welcome-icon { width: 50px; height: 50px; flex: none; border-radius: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .flashcard-stage::backdrop, .flashcard-stage *, .flashcard-stage *::before { animation: none !important; transition: none !important; }
}
.study-dock .flashcard-familiarity-options .study-familiarity-selected { opacity: 1; box-shadow: 0 0 0 2px var(--accent), 0 0 24px var(--accent-soft); transform: translateY(-3px); }

.study-obscured { filter:var(--app-blur-filter, blur(7px) saturate(.65)); }

/* Writing belongs in the answer dock; cues and their hints stay on the card.
   Give the dock more room while keeping both surfaces usable in short windows. */
.study-scene:has(.study-writing-dock) { grid-template-rows: minmax(0, 1fr) minmax(0, min(60%, 500px)); }
.study-answer-fields { display: contents; }
.study-writing-dock { padding: 0; gap: 0; overflow: hidden; grid-template-rows: minmax(0, 1fr) auto; }
.study-writing-dock .study-answer-fields { display: grid; gap: 14px; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 18px 22px 12px; }
.study-writing-dock > .flashcard-answer-actions { margin: 0; padding: 12px 22px; border-top: 1px solid var(--border); }
.study-writing-dock .writing-practice { margin: 0; padding: 0; min-width: 0; border: 0; background: none; }
.study-writing-dock .writing-slots-row { margin-bottom: 12px; gap: 6px; }
.study-writing-dock .writing-slots { gap: 6px; }
.study-writing-dock .writing-slot { min-width: 30px; height: 36px; font-size: 1rem; }
.study-writing-dock .writing-entry { min-width: 0; }
.study-writing-dock .writing-keyboard-label { margin: 0 auto; }
.study-writing-dock .writing-keyboard { margin: 0; padding: 10px 12px; font-size: 1rem; }
.study-writing-dock .writing-controls { min-width: 0; }
.study-writing-dock .writing-controls > .flashcard-response-method { margin-top: 10px; }
.study-writing-dock .writing-controls > .muted { font-size: .75rem; text-align: center; }
.study-writing-dock .writing-status { min-height: 1.5em; font-size: .75rem; margin: 8px 0; }
.study-writing-dock .flashcard-answer-actions .writing-hint-button { margin-inline-start: auto; width: 40px; height: 40px; padding: 8px; }
.study-writing-dock .writing-help, .study-writing-dock .writing-legend, .study-writing-dock .writing-scoring { font-size: .72rem; }
.study-writing-dock .writing-canvas-wrap { width: min(220px, 100%); margin-bottom: 0; }
.study-writing-dock .writing-practice[data-kind="stroke"] .writing-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: center; }
@media (max-width: 520px) {
    .study-writing-dock .study-answer-fields { padding: 14px 16px 10px; gap: 12px; }
    .study-writing-dock > .flashcard-answer-actions { padding: 10px 16px; }
    .study-writing-dock .writing-practice[data-kind="stroke"] .writing-workspace { grid-template-columns: minmax(0, 1fr); gap: 4px; }
    .study-writing-dock .writing-canvas-wrap { width: min(210px, 100%); }
}
@media (max-height: 560px) {
    .study-writing-dock .study-answer-fields { padding: 12px 16px; }
    .study-writing-dock > .flashcard-answer-actions { padding: 8px 16px; }
}

/* Grading turns only the card over; the learner's writing stays in its dock. */
.flashcard-back-heading { display: flex; align-items: flex-start; gap: 14px; }
.flashcard-card-list-action { position: absolute; top: 14px; right: 16px; }
.study-card-header:has(.flashcard-card-list-action) .flashcard-back-heading { padding-right: 44px; }
.study-card-header:has(.flashcard-card-list-action) > .flashcard-introduction > .study-card-eyebrow { padding-inline: 44px; }
.flashcard-back-heading > :first-child { flex: none; margin-top: 4px; }
.flashcard-back-heading > div { min-width: 0; }
.study-card .flashcard-back-heading h3 { margin: 0; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.2; overflow-wrap: anywhere; }
.flashcard-back-reading { margin: 8px 0 0; color: var(--text-secondary); font-size: 1rem; }
.study-scene:has(.study-feedback-actions) { grid-template-rows: minmax(100px, 1fr) minmax(0, auto) auto; }
.study-answer-dock[data-feedback="true"], .study-result-dock { max-height: min(38vh, 330px); }
.study-answer-feedback { display: grid; gap: 12px; font-size: .9rem; animation: study-dock-in .3s ease both; }
.study-answer-feedback p { margin: 0; }
.study-answer-feedback .flashcard-score { width: 100%; padding: 12px 16px; }
.study-submitted-answer { font-size: 1.1rem; }
.study-feedback-actions { animation: study-dock-in .4s .18s ease both; }
.study-writing-dock[data-feedback="true"] { overflow: auto; grid-template-rows: auto auto; }
.study-writing-dock[data-feedback="true"] .study-answer-fields { overflow: visible; }
.study-writing-dock > .study-answer-feedback { padding: 0 22px 18px; }
.study-writing-dock .flashcard-task, .study-writing-dock > .flashcard-answer-actions { max-height: 100px; opacity: 1; transition: opacity .22s, max-height .22s, padding .22s, border-color .22s; }
.study-writing-dock[data-complete="true"] .flashcard-task,
.study-writing-dock[data-complete="true"]:not([data-save-failed="true"]) > .flashcard-answer-actions,
.study-writing-dock[data-feedback="true"] .flashcard-task { opacity: 0; max-height: 0; padding-block: 0; overflow: hidden; pointer-events: none; border-color: transparent; visibility: hidden; transition: opacity .22s, max-height .22s, padding .22s, border-color .22s, visibility 0s .22s; }
.study-writing-dock[data-complete="true"] .study-answer-fields { gap: 0; }
.writing-workspace { max-height: 1000px; opacity: 1; transition: opacity .22s, max-height .22s; }
.writing-practice[data-kind="complete"] .writing-workspace { max-height: 0; opacity: 0; overflow: hidden; pointer-events: none; visibility: hidden; transition: opacity .22s, max-height .22s, visibility 0s .22s; }
.writing-practice[data-kind="complete"] .writing-slots-row { margin-bottom: 0; animation: writing-complete-in .25s ease both; }
.study-writing-dock .writing-practice[data-kind="complete"] .writing-slot { min-width: 38px; height: 46px; font-size: 1.5rem; }
@keyframes writing-complete-in { from { opacity: .8; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .writing-practice[data-kind="complete"] .writing-slots-row { animation: none; }
}
.study-answer-dock > [hidden] { display: none; }
.study-writing-dock[data-feedback="true"]:not([data-complete="true"]) .writing-workspace { display: none; }
.study-answer-dock .flashcard-answer-actions > [hidden] { display: none; }

/* Freehand character lookup: untouched ink beside eight selectable candidates. */
.writing-picker { display: grid; gap: 8px; min-width: 0; }
.writing-picker > input { width: 100%; min-width: 0; margin: 0; font-size: 1rem; }
.writing-candidate-area { position: relative; height: 108px; }
.writing-candidate-loading, .writing-lookup-message { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; overflow: auto; text-align: center; }
.writing-candidates { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; min-height: 108px; align-content: start; }
.writing-candidates .writing-candidate { display: flex; align-items: center; justify-content: center; width: 100%; min-width: 0; min-height: 50px; padding: 5px 3px; border-radius: 12px; }
.writing-candidate > span { font-size: 1.6rem; line-height: 1.2; font-weight: 500; }
.writing-lookup-status { min-height: 1.2em; margin: 0; font-size: .75rem; color: var(--text-secondary); }
.writing-lookup-status:empty { display: none; }
.writing-ink-tools { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.writing-ink-tools button { padding: 6px 12px; font-size: .8rem; }
.writing-practice [hidden] { display: none !important; }
.writing-status:empty { display: none; }
.word-practice-popup .writing-practice[data-kind="stroke"] .writing-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: 18px; }
@media (max-width: 620px) {
    .word-practice-popup .writing-practice[data-kind="stroke"] .writing-workspace { grid-template-columns: minmax(0, 1fr); }
    .study-scene:has(.study-writing-dock:not([data-feedback="true"])) { grid-template-rows: minmax(120px, 1fr) minmax(0, min(74%, 540px)); }
    .study-writing-dock .writing-canvas-wrap { width: min(160px, 100%); }
    .writing-candidates { min-height: 108px; }
    .writing-candidates .writing-candidate { min-height: 50px; }
}

/* Profile vocabulary: shared identities, with forms and contexts kept secondary. */
.vocabulary-progress-summary { margin-block: 0.75rem 1rem; }
.vocabulary-concept-link { color: inherit; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .vocabulary-concept-link:hover { text-decoration: underline; text-underline-offset: 0.2em; } }
.vocabulary-concept-link:focus-visible {   border-radius: 4px; }
.vocabulary-forms, .vocabulary-related, .vocabulary-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-block: 0.7rem; }
.vocabulary-related > .muted, .vocabulary-sources > .muted { flex-basis: 100%; }
.vocabulary-progress-summary .reader-learning-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }

/* Dictionary pages expand the same profile vocabulary identity used by the reader. */
.vocabulary-definition { display: grid; gap: 1rem; }
.vocabulary-entry-heading { display: grid; gap: 1rem; }
.vocabulary-headword-header { position: relative; display: grid; grid-template-columns: max-content minmax(0, 1fr) auto; align-items: start; gap: .5rem; }
.vocabulary-headword-header h1 { margin: 0; font: inherit; }
.vocabulary-headword-header h1 > strong { font-size: clamp(1.65rem, 4vw, 2.3rem); }
.vocabulary-headword-header .reader-word-header-actions { gap: .5rem; }
.vocabulary-entry-gloss { padding-inline-start: 2.5rem; }
.vocabulary-entry-gloss p { margin: 0; }
.vocabulary-entry-gloss .vocabulary-entry-meaning { margin-block-start: .2rem; font-size: 1.15rem; font-weight: 650; }
.vocabulary-entry-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.vocabulary-entry-images { width: min(100%, 44rem); margin-inline: auto; }
.vocabulary-entry-images .word-illustration { margin: 0 auto; }
.dictionary-entries > .entry, .dictionary-entries .contextual-meanings, .dictionary-entries .other-meanings { display: grid; gap: .75rem; }
.dictionary-entries .entry + .entry { margin-top: 1.5rem; }
.dictionary-entries .meaning-section-title { margin: .5rem 0 0; }
.dictionary-entries .entry-card, .dictionary-entries .dictionary-entry-section { margin: 0; }
.dictionary-entries .meaning { border: 1px solid var(--border); padding: clamp(18px, 3vw, 30px); }
.dictionary-entry-metadata .metadata { margin: 0; }
.dictionary-entry-section > h3 { margin: 0 0 .5rem; }
.dictionary-etymology > summary { font-weight: 650; cursor: pointer; }
.dictionary-etymology > p { margin-bottom: 0; }
.dictionary-related-words { padding: 0; margin: 0; list-style: none; }
.dictionary-related-word { display: grid; grid-template-columns: auto minmax(0, max-content) minmax(0, 1fr) auto; align-items: center; gap: .75rem; padding: .5rem 0; }
.dictionary-related-word + .dictionary-related-word { border-top: 1px solid var(--border); }
.dictionary-related-note { grid-column: 3; color: var(--text-secondary); overflow-wrap: anywhere; }
.dictionary-link-expand { grid-column: 4; grid-row: 1; }
@media (max-width: 480px) {
    .vocabulary-entry-gloss { padding-inline-start: 0; }
    .dictionary-related-word { grid-template-columns: auto minmax(0, 1fr) auto; gap: .25rem .5rem; }
    .dictionary-related-note { grid-column: 2 / -1; }
    .dictionary-link-expand { grid-column: 3; }
}
.dictionary-loading { display:grid; gap:1rem; }
.dictionary-loading > .surface { margin:0; }
.dictionary-generation { display:flex; align-items:center; gap:.75rem; padding:16px 20px; color:var(--muted); font-size:.9rem; }
.dictionary-loading-spinner { flex:none; width:20px; height:20px; }
.dictionary-definition-placeholder { display:grid; gap:24px; }
.dictionary-placeholder-meta { display:flex; gap:10px; }
.dictionary-placeholder-meaning, .dictionary-placeholder-example { display:grid; gap:12px; }
.dictionary-placeholder-example { padding:18px; border:1px solid var(--border); border-radius:12px; }
.dictionary-placeholder-block { display:block; max-width:100%; border-radius:5px; background:linear-gradient(100deg,var(--surface-subtle) 25%,color-mix(in srgb,var(--border-strong) 70%,var(--surface)) 50%,var(--surface-subtle) 75%) 0 0 / 200% 100%; animation:shimmer 1.6s linear infinite; }
.dictionary-placeholder-tag { width:80px; height:22px; border-radius:7px; }
.dictionary-placeholder-tag.short { width:50px; }
.dictionary-placeholder-label { width:100px; height:11px; margin-bottom:6px; }
.dictionary-placeholder-line { width:100%; height:16px; }
.dictionary-placeholder-line.medium { width:78%; }
.dictionary-placeholder-line.short { width:56%; }
@media (prefers-reduced-motion:reduce) { .dictionary-loading-spinner, .dictionary-placeholder-block { animation:none; } }

/* Guided reading: one sentence at a time inside the full-screen study stage.
   Role and grade hues are validated categorical/ordinal palettes; labels and
   scores always accompany them, so color is never the only signal. */
:is(.guided-stage, .comprehension-stage, .grammar-palette) {
  --role-subject-phrase: #2f8fd0; --role-key-verb: #d95462; --role-object-phrase: #9a6be0; --role-place-preposition: #119eaa;
  --role-time-preposition: #e07b2a; --role-adjective: #3fa46f; --role-adverb: #c99a12; --role-aux-verb: #d55fa0; --role-neutral: #858b94;
  --grade-1: #d64541; --grade-2: #e07b2a; --grade-3: #d4a20e; --grade-4: #3a9d5d; --grade-5: #2f86d6;
}
:root[data-theme="dark"] :is(.guided-stage, .comprehension-stage, .grammar-palette), :root[data-theme="tokyo-night"] :is(.guided-stage, .comprehension-stage, .grammar-palette), .theme-dark :is(.guided-stage, .comprehension-stage, .grammar-palette), .theme-tokyo-night :is(.guided-stage, .comprehension-stage, .grammar-palette) {
  --role-subject-phrase: #3b93d6; --role-key-verb: #e0606d; --role-object-phrase: #a07ae6; --role-place-preposition: #1aa7b2;
  --role-time-preposition: #d6741f; --role-adjective: #3fa877; --role-adverb: #b98500; --role-aux-verb: #d866a8; --role-neutral: #8d939c;
  --grade-1: #ef6b66; --grade-2: #e8873a; --grade-3: #d9ad2b; --grade-4: #4fb873; --grade-5: #5aa2e8;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] :is(.guided-stage, .comprehension-stage, .grammar-palette), .theme-system :is(.guided-stage, .comprehension-stage, .grammar-palette) {
    --role-subject-phrase: #3b93d6; --role-key-verb: #e0606d; --role-object-phrase: #a07ae6; --role-place-preposition: #1aa7b2;
    --role-time-preposition: #d6741f; --role-adjective: #3fa877; --role-adverb: #b98500; --role-aux-verb: #d866a8; --role-neutral: #8d939c;
    --grade-1: #ef6b66; --grade-2: #e8873a; --grade-3: #d9ad2b; --grade-4: #4fb873; --grade-5: #5aa2e8;
  }
}
.guided-role-subject-phrase { --role: var(--role-subject-phrase); }
.guided-role-key-verb { --role: var(--role-key-verb); }
.guided-role-aux-verb { --role: var(--role-aux-verb); }
.guided-role-object-phrase { --role: var(--role-object-phrase); }
.guided-role-place-preposition { --role: var(--role-place-preposition); }
.guided-role-time-preposition { --role: var(--role-time-preposition); }
.guided-role-adjective { --role: var(--role-adjective); }
.guided-role-adverb { --role: var(--role-adverb); }
/* Sentence structure slot categories reuse the guided reading role hues. */
.grammar-noun, .grammar-pronoun { --role: var(--role-subject-phrase); }
.grammar-verb { --role: var(--role-key-verb); }
.grammar-auxiliary { --role: var(--role-aux-verb); }
.grammar-adjective { --role: var(--role-adjective); }
.grammar-adverb { --role: var(--role-adverb); }
.grammar-preposition { --role: var(--role-place-preposition); }
.grammar-time { --role: var(--role-time-preposition); }
.grammar-conjunction { --role: var(--role-object-phrase); }
:is(.grammar-clause, .grammar-question-word, .grammar-determiner, .grammar-number, .grammar-measure-word, .grammar-particle, .grammar-other) { --role: var(--role-neutral); }
.guided-grade-1 { --grade: var(--grade-1); }
.guided-grade-2 { --grade: var(--grade-2); }
.guided-grade-3 { --grade: var(--grade-3); }
.guided-grade-4 { --grade: var(--grade-4); }
.guided-grade-5 { --grade: var(--grade-5); }

.guided-topbar-score { padding: 0 10px; font-size: .78rem; color: var(--text-secondary); white-space: nowrap; }
.guided-topbar-score strong { color: var(--text); font-size: .9rem; }
.guided-menu-panel .button-row, .guided-menu-panel > button { justify-self: start; }
.guided-error { display: flex; align-items: center; gap: 8px; top: auto; bottom: 18px; z-index: 6; color: var(--danger); }
.guided-error button { padding: 4px; color: inherit; }

.guided-scene { grid-row: 2; grid-column: 1; min-width: 0; min-height: 0; width: min(900px, 100%); justify-self: center; display: flex; flex-direction: column; gap: 14px; }
.guided-scene-message { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; color: #fff; }
.guided-scene-message p { display: flex; align-items: center; gap: 10px; }
.guided-scene-scroll { display: block; overflow: auto; overscroll-behavior: contain; border-radius: 28px; background: var(--surface); box-shadow: 0 24px 70px rgb(0 0 0 / .28); scrollbar-width: thin; }
.guided-top { flex: 0 1 auto; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; min-width: 0; min-height: 0; }

.guided-progress { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 6px; color: #f3f4f6; }
.guided-progress-label { flex: none; font-size: .72rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.guided-progress-steps { flex: 1; display: flex; gap: 3px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.guided-progress-steps li { flex: 1; min-width: 0; }
.guided-step { display: block; width: 100%; height: 8px; padding: 0; border: 0; border-radius: 4px; background: var(--step-background, rgb(255 255 255 / .22)); cursor: default; }
.guided-step.done { background: var(--grade); cursor: pointer; }
.guided-step.current { background: var(--step-current-background, rgb(255 255 255 / .7)); cursor: pointer; }
.guided-step.viewing { outline: 2px solid var(--step-outline, #fff); outline-offset: 2px; }
.guided-progress-meter { flex: 1; background: rgb(255 255 255 / .2); }

.guided-sentence-card { position: relative; max-height: min(52vh, calc(var(--study-height) * .52)); overflow: auto; overscroll-behavior: contain; padding: clamp(18px, 3.2vw, 32px); border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: 28px; background: var(--surface); box-shadow: 0 24px 70px rgb(0 0 0 / .28), 0 2px 8px rgb(0 0 0 / .1); scrollbar-width: thin;
  -webkit-mask-size: 230% 100%; mask-size: 230% 100%; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  animation: guided-sentence-in .95s cubic-bezier(.2, .75, .2, 1) backwards; }
[dir="rtl"] .guided-sentence-card, .guided-sentence-card:dir(rtl) { animation-name: guided-sentence-in-rtl; }
@keyframes guided-sentence-in-rtl {
  from { opacity: 0; transform: translateX(-32px); -webkit-mask-image: linear-gradient(270deg, #000 45%, transparent 55%); mask-image: linear-gradient(270deg, #000 45%, transparent 55%); -webkit-mask-position: 0 0; mask-position: 0 0; filter:var(--app-blur-filter, blur(3px)); }
  60% { opacity: 1; filter: none; }
  to { opacity: 1; transform: none; -webkit-mask-image: linear-gradient(270deg, #000 45%, transparent 55%); mask-image: linear-gradient(270deg, #000 45%, transparent 55%); -webkit-mask-position: 100% 0; mask-position: 100% 0; }
}
@keyframes guided-sentence-in {
  from { opacity: 0; transform: translateX(32px); -webkit-mask-image: linear-gradient(90deg, #000 45%, transparent 55%); mask-image: linear-gradient(90deg, #000 45%, transparent 55%); -webkit-mask-position: 100% 0; mask-position: 100% 0; filter:var(--app-blur-filter, blur(3px)); }
  60% { opacity: 1; filter: none; }
  to { opacity: 1; transform: none; -webkit-mask-image: linear-gradient(90deg, #000 45%, transparent 55%); mask-image: linear-gradient(90deg, #000 45%, transparent 55%); -webkit-mask-position: 0 0; mask-position: 0 0; }
}
.guided-sentence-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; color: var(--text-secondary); font-size: .68rem; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; }
.guided-sentence-meta .speech-button { width: 2rem; height: 2rem; }
.guided-sentence-actions { letter-spacing: normal; text-transform: none; }
.guided-sentence { --grammar-rows: 0; display: flex; flex-wrap: wrap; align-items: flex-start; row-gap: 16px; margin: 0; font-family: var(--font-reading); font-size: clamp(1.45rem, 3.8vw, 2.25rem); line-height: 1.3; color: var(--text); }
.guided-sentence:is(:lang(zh), :lang(ja), :lang(ko), :lang(yue), :lang(th), :lang(ar), :lang(fa), :lang(he), :lang(hi)) { font-family: var(--font-sans); }
.guided-token { display: inline-flex; flex-direction: column; align-items: stretch; min-width: 0; }
.guided-reading { display: block; height: 1.4em; max-width: 15em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-sans); font-size: max(.72rem, .42em); font-weight: 400; line-height: 1.4; text-align: center; color: var(--muted); }
.guided-text { white-space: pre; }
.guided-gap .guided-text { padding: 1px 0; border-bottom: 3px solid transparent; }
.guided-word { display: flex; flex-direction: column; align-items: stretch; gap: 0; width: auto; margin: 0; padding: 0; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; line-height: inherit; text-align: center; cursor: pointer; transition: background .18s, border-color .18s; }
.guided-word > .guided-text { display: block; padding: 1px .05em; border-bottom: 3px solid transparent; }
.guided-word[aria-expanded="true"] { background: var(--accent-soft); }
@media (hover: hover) and (pointer: fine) { :is(.reader-word, .guided-word):hover { background: color-mix(in srgb, var(--text) 12%, transparent); } }
.guided-cells { display: flex; flex-direction: column; gap: 3px; margin-top: calc(min(var(--grammar-rows), 1) * 6px); }
.guided-cell { position: relative; display: block; height: 18px; white-space: nowrap; font-family: var(--font-sans); font-size: 10px; font-weight: 650; line-height: 18px; letter-spacing: .02em; color: var(--text); background: color-mix(in srgb, var(--role) 32%, var(--surface)); box-shadow: inset 0 2px 0 var(--role); cursor: pointer; transition: opacity .15s, box-shadow .15s; }
button.guided-cell { display: block; width: 100%; padding: 0; border-radius: 0; color: var(--text); background: color-mix(in srgb, var(--role) 32%, var(--surface)); }
.guided-cell-label { position: absolute; z-index: 2; inset-inline-start: 5px; top: 0; pointer-events: none; }
.guided-cell.solo .guided-cell-label { inset-inline-end: 3px; overflow: hidden; text-overflow: ellipsis; }
.guided-cell.empty { background: transparent; box-shadow: none; cursor: default; }
.guided-cell.start { margin-inline-start: 2px; border-start-start-radius: 4px; border-end-start-radius: 4px; }
.guided-cell.end { margin-inline-end: 2px; border-start-end-radius: 4px; border-end-end-radius: 4px; }
.guided-sentence[data-highlight="true"] .guided-cell:not(.empty):not(.active) { opacity: .35; }
.guided-cell.active { box-shadow: inset 0 2px 0 var(--role), inset 0 -2px 0 var(--role); }

.guided-help { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; display: grid; align-content: start; gap: 12px; padding: 2px; scrollbar-width: thin; border-radius: 22px; container-type: size; }
.guided-panel { padding: 16px 20px; border: 1px solid color-mix(in srgb, var(--border) 75%, transparent); border-radius: 22px; background: color-mix(in srgb, var(--surface) 97%, transparent); box-shadow: 0 10px 34px rgb(0 0 0 / .2); animation: study-dock-in .35s ease both; }
.guided-panel h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-secondary); }
.guided-panel p { margin: 6px 0; }
.guided-loading { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); }
.guided-swatch { display: inline-block; flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--role); }
.guided-grammar-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.guided-grammar-heading h3 { margin: 0; }
.guided-part-words { min-width: 0; color: var(--text-secondary); font-family: var(--font-reading); font-size: 1rem; }
.guided-image { --guided-image-height: max(96px, calc(100cqh - 76px)); }
.guided-image-picture, .guided-image :is(.reader-story-image, .passage-illustration) > img { display: block; width: 100%; height: auto; max-height: var(--guided-image-height); aspect-ratio: auto; object-fit: contain; border-radius: 14px; }
.guided-image :is(.reader-story-image, .passage-illustration) { width: 100%; max-width: none; margin: 0; border: 0; box-shadow: none; }
.guided-image :is(.reader-story-image-placeholder, .word-illustration-placeholder) { max-height: var(--guided-image-height); }
.guided-image-placeholder { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 120px; border-radius: 14px; background: var(--surface-subtle); color: var(--text-secondary); font-size: .85rem; }

.guided-explainer { font-size: .9rem; line-height: 1.6; }
.guided-explainer > p:first-child { margin-top: 0; }
.guided-explainer > p:last-child { margin-bottom: 0; }
.guided-topbar > .icon-button { flex: none; }
.guided-response { flex: 0 0 auto; display: flex; flex-direction: column; gap: 12px; min-height: 0; max-height: calc(var(--study-height) * .55); width: 100%; }
.guided-feedback-panel { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; display: grid; gap: 10px; padding: 14px 18px; border: 1px solid var(--border); border-radius: 22px; background: var(--surface); box-shadow: 0 12px 40px rgb(0 0 0 / .25); scrollbar-width: thin; animation: study-dock-in .3s ease both; }
.guided-feedback-panel .guided-feedback { margin: 0; animation: none; }
.guided-feedback-panel .guided-score-line { padding-inline: 4px; }
.guided-dock { flex: 0 1 auto; display: grid; gap: 10px; width: 100%; max-height: min(46vh, calc(var(--study-height) * .46)); }
.guided-feedback-panel + .guided-dock { flex-shrink: 0; max-height: min(46vh, calc(var(--study-height) * .55 - 76px)); }
.guided-dock-toolbar { display: flex; align-items: center; gap: 6px; }
.guided-dock-toolbar .guided-skip { margin-inline-start: auto; }
.guided-dock-toolbar > button { font-size: .8rem; padding: 7px 12px; }
.guided-hint-actions { flex: 0 0 auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 10px; }
.guided-hint-actions .guided-hint-option { box-shadow: 0 10px 34px rgb(0 0 0 / .2); }
.guided-hint-option { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); text-align: start; }
@media (hover: hover) and (pointer: fine) { .guided-hint-option:hover:not(:disabled) { background: var(--surface-hover); } }
.guided-hint-option[aria-busy="true"] { opacity: 1; cursor: progress; }
.guided-hint-option span:not(.guided-hint-cost) { display: grid; gap: 2px; }
.guided-hint-option small { color: var(--text-secondary); font-size: .75rem; font-weight: 400; }
.guided-hint-cost { font-size: .78rem; font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.guided-translation { display: grid; gap: 8px; }
.guided-translation label { font-size: .78rem; font-weight: 650; }
.guided-answer-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; align-items: start; gap: 8px 10px; }
.guided-answer-row textarea { grid-column: 1; grid-row: 1 / span 2; min-width: 0; min-height: 56px; max-height: 120px; margin: 0; resize: vertical; font-size: 1rem; }
.guided-dock-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.guided-dock-actions button { padding: 10px 18px; font-size: .85rem; }
.guided-dock-actions small { opacity: .75; font-variant-numeric: tabular-nums; }
.guided-dock-review { display: grid; gap: 10px; }
.guided-dock-review p { margin: 0; font-size: .85rem; }
.guided-microphone [hidden] { display: none !important; }
.guided-microphone { display: contents; }
.guided-mic-button { grid-column: 2; grid-row: 1; width: 44px; height: 44px; padding: 0; border-radius: 50%; touch-action: none; user-select: none; -webkit-user-select: none; }
.guided-microphone meter { grid-column: 2; grid-row: 2; width: 44px; height: 4px; }
.guided-microphone .ghost { grid-column: 1 / -1; justify-self: end; }
/* The automatic-mic toggle sits under the mic button, below its level meter. */
.guided-answer-row .recording-auto-button { grid-column: 2; grid-row: 3; justify-self: center; }
.guided-mic-status { grid-column: 1 / -1; color: var(--text-secondary); font-size: .72rem; line-height: 1.3; }
.guided-mic-status:empty { display: none; }
.guided-feedback { display: grid; gap: 6px; padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, var(--grade, var(--muted)) 12%, var(--surface)); border-inline-start: 4px solid var(--grade, var(--border)); animation: study-dock-in .35s ease both; }
.guided-feedback p { margin: 0; font-size: .9rem; }
.guided-feedback > button { justify-self: start; font-size: .8rem; padding: 6px 10px; display: inline-flex; gap: 6px; align-items: center; }
.guided-reference { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--surface); }
.guided-reference span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: .7rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.guided-you-wrote span:first-child { color: var(--text-secondary); }
.guided-feedback-heading { display: flex; align-items: center; gap: 10px; }
.guided-grade-dots { display: inline-flex; gap: 3px; }
.guided-grade-dots span { width: 9px; height: 9px; border-radius: 50%; background: color-mix(in srgb, var(--grade, var(--muted)) 25%, var(--surface)); }
.guided-grade-dots span.on { background: var(--grade, var(--muted)); }
.guided-score-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 0; font-size: .8rem; }
.guided-score-total { font-variant-numeric: tabular-nums; }
.guided-score-total strong { font-size: 1.15rem; }
.guided-score-total::before { content: ''; display: inline-block; width: 10px; height: 10px; margin-inline-end: 6px; border-radius: 50%; background: var(--grade); }
.guided-score-info { flex: none; align-self: center; }

.guided-welcome, .guided-summary { display: grid; gap: 18px; max-width: 640px; margin: 0 auto; padding: clamp(24px, 5vw, 48px); }
.guided-welcome { justify-items: center; text-align: center; }
.guided-welcome h2 { margin: 0; font-size: clamp(1.7rem, 4vw, 2.4rem); letter-spacing: -.02em; }
.guided-welcome > p { margin: 0; color: var(--text-secondary); line-height: 1.65; }
.guided-steps { display: grid; gap: 10px; width: 100%; margin: 0; padding: 0; list-style: none; text-align: start; }
.guided-steps li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; background: var(--surface-subtle); font-size: .9rem; }
.guided-steps .shell-icon { flex: none; color: var(--accent-ink); }
.guided-start { display: inline-flex; align-items: center; gap: 8px; padding: 13px 26px; font-size: 1rem; }
.guided-last-score { display: flex; align-items: center; gap: 6px; margin: 0; }
.guided-scoring { width: 100%; text-align: start; font-size: .82rem; }
.guided-scoring ul { margin: 8px 0 0; padding-inline-start: 18px; color: var(--text-secondary); display: grid; gap: 4px; }

.guided-trend { width: 100%; margin: 0; }
.guided-trend figcaption { margin-bottom: 8px; color: var(--text-secondary); font-size: .75rem; font-weight: 650; text-align: start; }
.guided-trend-plot { position: relative; height: 140px; }
.guided-trend-area { position: absolute; inset: 20px 0 22px 30px; }
.guided-trend-grid { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--border); }
.guided-trend-grid span { position: absolute; right: calc(100% + 6px); top: -.65em; color: var(--muted); font-size: .62rem; font-variant-numeric: tabular-nums; }
.guided-trend-bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 8px; height: 100%; margin: 0; padding: 0; list-style: none; }
.guided-trend-bars li { flex: 1; max-width: 56px; height: 100%; display: flex; flex-direction: column; align-items: center; }
.guided-trend-column { position: relative; flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.guided-trend-bar { display: block; width: min(24px, 100%); border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--accent) 38%, var(--surface)); transition: background .15s; }
.guided-trend-bars li.latest .guided-trend-bar { background: var(--accent); }
@media (hover: hover) and (pointer: fine) {  .guided-trend-bars li:hover .guided-trend-bar { background: var(--accent); } }
.guided-trend-value { margin-bottom: 3px; font-size: .7rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.guided-trend-label { position: absolute; bottom: 0; transform: translateY(100%); padding-top: 4px; color: var(--muted); font-size: .65rem; }
.guided-trend-bars li { position: relative; }

.guided-summary-hero { display: grid; justify-items: center; gap: 4px; text-align: center; }
.guided-hero { display: flex; align-items: baseline; gap: 8px; margin: 0; }
.guided-hero strong { font-size: clamp(3rem, 9vw, 4.5rem); line-height: 1; letter-spacing: -.03em; }
.guided-hero span { color: var(--text-secondary); }
.guided-hero::before { content: ''; align-self: center; width: 14px; height: 14px; border-radius: 50%; background: var(--grade, var(--muted)); }
.guided-delta { margin: 0; font-size: .82rem; font-weight: 650; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.guided-delta.up { color: var(--success); }
.guided-delta.down { color: var(--danger); }
.guided-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.guided-stats > div { padding: 12px; border-radius: 14px; background: var(--surface-subtle); text-align: center; }
.guided-stats dt { color: var(--text-secondary); font-size: .72rem; }
.guided-stats dd { margin: 2px 0 0; font-size: 1.2rem; font-weight: 700; }
.guided-study, .guided-sentence-results { display: grid; gap: 10px; }
.guided-study h3, .guided-sentence-results h3 { margin: 0; font-size: 1rem; }
.guided-study > p { margin: 0; font-size: .82rem; }
.guided-study-words { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.guided-study-words li { display: grid; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; }
.guided-study-words strong { font-family: var(--font-reading); font-size: 1.05rem; }
.guided-study-words span { color: var(--text-secondary); font-size: .75rem; font-family: var(--font-sans); }
.guided-study .button-row button { display: inline-flex; align-items: center; gap: 8px; }
.guided-sentence-results ol { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.guided-sentence-results li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: var(--surface-subtle); font-size: .9rem; }
.guided-result-score { flex: none; min-width: 38px; padding: 2px 6px; border-radius: 8px; background: var(--grade); color: #fff; font-weight: 700; font-size: .8rem; text-align: center; font-variant-numeric: tabular-nums; }
.guided-grade-3.guided-result-score { color: #1f1a05; }
.guided-result-score.unread { background: var(--border); color: var(--text-secondary); }
.guided-result-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-reading); }
.guided-summary-actions { justify-content: center; }

/* Keep the sentence, hints, and full-width answer dock in one column. */
@media (min-width: 1100px) and (min-height: 560px) {
    .guided-scene:not(.guided-scene-scroll, .guided-scene-message) { width: min(1180px, 100%); }
}
@media (max-width: 520px) {
    .guided-scene { gap: 10px; }
    .guided-sentence-card { border-radius: 22px; padding: 16px; }
    .guided-sentence { font-size: clamp(1.3rem, 6.4vw, 1.7rem); row-gap: 12px; }
    .guided-topbar-score { display: none; }
    .guided-dock-toolbar span { display: none; }
    .guided-stats dd { font-size: 1rem; }
}
@media (max-height: 640px) {
    .guided-sentence-card { max-height: calc(var(--study-height) * .42); padding: 14px 18px; }
    .guided-sentence-meta { margin-bottom: 6px; }
}
/* On short screens, scroll the stack instead of shrinking text into slivers. */
@media (max-height: 500px) {
    .guided-scene:not(.guided-scene-scroll, .guided-scene-message) { overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
    .guided-top, .guided-help, .guided-response { flex: none; max-height: none; }
    .guided-help { container-type: normal; }
    .guided-image { --guided-image-height: 65vh; }
    .guided-sentence-card, .guided-dock, .guided-feedback-panel + .guided-dock { max-height: none; }
}
@media (prefers-reduced-motion: reduce) {
    .guided-sentence-card { animation: guided-fade .2s ease both; -webkit-mask-image: none; mask-image: none; }
}
@keyframes guided-fade { from { opacity: 0; } to { opacity: 1; } }

/* Learning history: neutral chrome, with semantic vocabulary colors preserved. */
.progress-page { max-width: 1080px; margin: 0 auto; display: grid; gap: 24px; }
.progress-page-heading { padding: 10px 0 4px; }
.progress-page-heading h1 { margin: 6px 0 10px; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.035em; }
.progress-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.progress-stat { min-width: 0; overflow-wrap: anywhere; }
.progress-languages-card { padding: 26px; }
.progress-language-list { display: grid; gap: 12px; list-style: none; margin: 0; padding: 0; }
.progress-language-row { display: flex; align-items: center; gap: 24px; padding: 20px; border: 1px solid var(--border); border-radius: 14px; }
.progress-language-row[data-selected="true"] { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent) 4%, transparent); }
.progress-language-identity { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }
.progress-language-flag { font-size: 1.7rem; flex-shrink: 0; }
.progress-language-identity h3 { margin: 0; font-size: 1rem; overflow-wrap: anywhere; }
.progress-language-identity small { display: block; margin-top: 5px; color: var(--muted); font-size: .73rem; }
.progress-language-metrics { display: grid; grid-template-columns: repeat(3, minmax(100px, 1fr)); gap: 24px; width: 53%; margin: 0; }
.progress-language-metrics dt { color: var(--muted); font-size: .75rem; line-height: 1.5; }
.progress-language-metrics dd { margin: 7px 0 0; font-size: 1.2rem; font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.progress-language-xp { color: var(--xp); }
.progress-achieved-level { display: inline-flex; padding: 3px 9px; border-radius: 7px; background: color-mix(in srgb, var(--accent) 12%, transparent); font-size: .95rem; }
.progress-no-level { color: var(--muted); font-size: .85rem; font-weight: 400; }
.progress-vocabulary-explanation { margin-top: 12px; font-size: .8rem; }
.progress-vocabulary-explanation summary { cursor: pointer; color: var(--muted); }
.progress-vocabulary-explanation p { line-height: 1.65; max-width: 740px; }
@media (max-width: 1000px) { .progress-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .progress-languages-card { padding: 18px; }
  .progress-language-row { flex-direction: column; align-items: stretch; gap: 18px; padding: 16px; }
  .progress-language-metrics { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
  .progress-language-metrics dd { font-size: 1.05rem; }
}
.progress-page .surface { margin: 0; }
.progress-stat { padding: 24px; display: flex; flex-direction: column; gap: 10px; }
.progress-stat > span, .progress-stat > .progress-metric-label { font-size: .85rem; color: var(--muted); font-weight: 650; }
.progress-metric-label {display:flex;align-items:center;gap:6px;}
button.progress-metric-info {display:inline-flex;align-items:center;justify-content:center;flex:none;width:30px;height:30px;padding:6px;color:var(--muted);border-radius:50%;}
.progress-metric-help {margin:0;line-height:1.65;color:var(--text-secondary);}
.progress-stat > strong { font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.progress-stat strong span { font-size: .95rem; letter-spacing: 0; font-weight: 500; color: var(--muted); }
.progress-stat small { font-size: .76rem; color: var(--muted); }
.progress-streak-details { display:grid; gap:6px; margin:0; font-size:.76rem; }
.progress-streak-details > div { display:flex; flex-wrap:wrap; gap:4px 10px; align-items:baseline; }
.progress-streak-details dt { color:var(--muted); }
.progress-streak-details dd { margin:0; color:var(--text); font-weight:650; font-variant-numeric:tabular-nums; }
.progress-calendar-card, .progress-chart-card { padding: 26px; }
.progress-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.progress-section-heading h2 { margin: 0 0 6px; font-size: 1.2rem; letter-spacing: -.02em; }
.progress-section-heading p { margin: 0; font-size: .85rem; max-width: 540px; }
.progress-section-heading > button { flex-shrink: 0; }
.progress-chart-title { display:flex; align-items:center; gap:6px; margin-bottom:6px; }
.progress-chart-title h2 { margin:0; }
.progress-graph-help { color:var(--text-secondary); font-size:.85rem; line-height:1.65; }
.progress-graph-help p { margin:0; }
.progress-graph-help p + p { margin-top:12px; }
button.progress-checked:disabled { opacity: 1; color: var(--success); background: color-mix(in srgb, var(--success) 10%, var(--surface)); border-color: transparent; }
.progress-calendar-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(200px, 1fr); gap: 32px; }
.progress-calendar-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.progress-calendar-heading h3 { margin: 0; font-size: .95rem; }
.progress-calendar-heading .icon-button { width: 34px; height: 34px; padding: 6px; }
.progress-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.progress-weekday { text-align: center; font-size: .7rem; color: var(--muted); padding-bottom: 5px; }
button.progress-calendar-day { width: 100%; position: relative; display: grid; place-items: center; min-height: 45px; padding: 10px 4px; border: 0; border-radius: 9px; background: var(--surface-subtle); color: var(--text-secondary); font-size: .85rem; box-shadow: none; isolation: isolate; overflow: hidden; }
button.progress-calendar-day::before { content: ''; position: absolute; inset: 0; border-radius: inherit; background: var(--accent); opacity: var(--activity-opacity, 0); z-index: -1; }
button.progress-calendar-day::after { content: ''; position: absolute; inset: 0; border-radius: inherit; border: var(--day-border-width, 0px) solid var(--day-border-color, transparent); box-sizing: border-box; pointer-events: none; }
button.progress-calendar-day.checked { background: var(--accent-soft); color: var(--text); --day-border-width: 1px; --day-border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
button.progress-calendar-day[data-strong="true"] { color: var(--accent-text); }
button.progress-calendar-day.today, button.progress-calendar-day.selected { --day-border-width: 2px; --day-border-color: var(--accent); }
button.progress-calendar-day:disabled { opacity: .28; }
.progress-day-icons { display:flex; gap:2px; min-height:12px; max-width:100%; justify-content:center; }
.progress-day-icons svg { width:clamp(8px, 2.2vw, 12px); height:12px; flex-shrink:1; min-width:0; }
.progress-calendar-legend { display:flex; flex-wrap:wrap; gap:8px 16px; margin:0 0 14px; font-size:.75rem; color:var(--text-secondary); }
.progress-calendar-legend span { display:inline-flex; align-items:center; gap:5px; }
.progress-day-detail { background: var(--surface-subtle); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; justify-content: center; }
.progress-day-detail > strong { font-size: 2.7rem; letter-spacing: -.035em; }
.progress-day-detail strong span { font-size: 1rem; color: var(--muted); }
.progress-day-detail p { font-size: .85rem; }
.progress-day-detail dl { margin: 12px 0 0; }
.progress-day-detail dl div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: .8rem; }
.progress-day-detail dd { margin: 0; font-variant-numeric: tabular-nums; }
.progress-footnote { margin: 18px 0 0; font-size: .75rem; color: var(--muted); line-height: 1.6; }
.progress-chart-filters { display: flex; gap: 10px; }
.progress-chart-filters label { display: grid; gap: 4px; font-size: .72rem; color: var(--muted); }
.progress-chart-filters select { min-width: 115px; padding: 7px 38px 7px 10px; font-size: .85rem; }
.progress-history-chart { min-width: 0; }
.progress-history-chart svg { width: 100%; height: 270px; display: block; overflow: visible; }
.progress-chart-gridline { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 5; }
.progress-chart-label { fill: var(--muted); font-size: 12px; }
.progress-xp-bar { fill: var(--xp); opacity: .78; transition: opacity .15s; }
.progress-history-chart g:focus .progress-xp-bar { opacity: 1; }
@media (hover: hover) and (pointer: fine) { .progress-history-chart g:hover .progress-xp-bar { opacity: 1; } }
.progress-word-segment[data-level="5"] { fill: var(--success); }
.progress-word-segment[data-level="4"] { fill: #8bb45a; }
.progress-word-segment[data-level="3"] { fill: #e3c14e; }
.progress-word-segment[data-level="2"] { fill: var(--warning); }
.progress-word-segment[data-level="1"] { fill: var(--danger); }
.progress-word-segment[data-level="0"] { fill: var(--border-strong); }
.progress-chart-readout { min-height: 44px; padding: 10px 0 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; font-size: .8rem; }
.progress-chart-readout > span:first-child { font-weight: 600; }
.progress-readout-level, .progress-chart-legend > span, .progress-chart-legend > button { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.progress-chart-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; margin: 10px 0 0; font-size: .76rem; color: var(--text-secondary); }
.progress-chart-legend .progress-unknown-toggle { border: 0; border-radius: 4px; background: transparent; color: inherit; font: inherit; padding: 5px 4px; margin: -5px -4px; min-height: 32px; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .progress-chart-legend .progress-unknown-toggle:hover { background: var(--surface-hover); color: var(--text); } }
.progress-legend-hidden { text-decoration: line-through; opacity: .6; }
.progress-points-line, .progress-points-halo { fill: none; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; }
.progress-points-line { stroke: var(--xp); stroke-width: 2.5; }
.progress-points-halo { stroke: var(--surface); stroke-width: 5; }
.progress-points-dot { fill: var(--xp); stroke: var(--surface); stroke-width: 1; pointer-events: none; }
.progress-points-swatch { width: 20px; height: 0; border-top: 3px solid var(--xp); }
.progress-chart-empty { font-size: .85rem; color: var(--muted); text-align: center; padding: 10px; }
@media (max-width: 760px) {
  .progress-page { gap: 16px; }
  .progress-summary { gap: 8px; }
  .progress-stat { padding: 15px 10px; }
  .progress-stat > strong { font-size: 1.7rem; }
  .progress-stat small { font-size: .68rem; }
  .progress-calendar-card, .progress-chart-card { padding: 18px 14px; }
  .progress-section-heading { flex-wrap: wrap; gap: 14px; }
  .progress-calendar-layout { grid-template-columns: 1fr; gap: 16px; }
  .progress-day-detail { padding: 16px; }
  .progress-day-detail[data-day-selected="false"] { display: none; }
  .progress-chart-filters { width: 100%; }
  .progress-chart-filters label { flex: 1; }
}

/* Saved, contextual phrase coaching shares the reader's text and controls. */
.how-to-say { width: 100%; max-width: 920px; margin-inline: auto; display: grid; gap: 22px; }
.how-to-say .surface + .surface { margin-top: 0; }
.saying-screen-title { margin: 0; }
.saying-create { display: grid; gap: 16px; padding: clamp(18px, 3vw, 28px); border-radius: 22px; }
.saying-create-compose { display: grid; gap: 10px; }
.saying-compose-title { font-size: clamp(1.6rem, 3.5vw, 2.2rem); font-weight: 750; line-height: 1.2; margin: 0 0 4px; }
.saying-compose-title label { cursor: text; font: inherit; color: var(--text); }
.saying-input { width: 100%; min-width: 0; font-size: 1.05rem; }
.saying-setting-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.saying-setting-field legend { font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.saying-settings-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.saying-setting-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; cursor: pointer; background: var(--surface); }
.saying-setting-tile[data-selected="true"] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.saying-setting-tile input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.saying-setting-tile strong { font-size: .92rem; }
.saying-setting-tile span { color: var(--muted); font-size: .78rem; font-weight: 400; line-height: 1.35; }
.saying-custom-setting { display: grid; gap: 6px; margin-top: 10px; font-size: .9rem; font-weight: 600; }
.saying-custom-setting input { font-weight: 400; }
.saying-submit-row { display: flex; justify-content: flex-end; }
.saying-library h2 { font-size: 1.05rem; margin: 0 0 10px; }
.saying-library-list { display: grid; gap: 8px; }
.saying-library-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-decoration: none; color: var(--text); border-radius: 14px; }
.saying-library-card > div { flex: 1; min-width: 0; display: grid; gap: 2px; }
.saying-library-card strong { overflow-wrap: anywhere; }
.saying-library-card .muted { font-size: .85rem; }
.saying-empty { display: flex; align-items: center; gap: 14px; border: 1px dashed var(--border-strong); border-radius: 18px; padding: 24px; color: var(--muted); }
.saying-document { gap: 14px; }
.saying-document .reader-document-actions { padding: 10px 14px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); }
.saying-pairs { display: grid; gap: 12px; }
.saying-pair { padding: clamp(16px, 2.5vw, 24px); border-radius: 20px; min-width: 0; }
.saying-request { color: var(--text-secondary); font-size: 1rem; margin: 0 0 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.saying-entry-heading { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
button.saying-request {display:block;background:transparent;border:0;padding:0;text-align:start;font-weight:400;border-radius:4px;}
@media (hover: hover) and (pointer: fine) { button.saying-request:hover:not(:disabled) {background:transparent;color:var(--text);} }
.saying-entry-heading .saying-request { flex: 1; min-width: 0; margin: 0; }
.saying-entry-actions { display: flex; align-items: center; gap: 3px; flex: none; }
.saying-entry-actions .icon-button { width: 32px; height: 32px; }
.saying-details-form, .saying-entry-edit { display: grid; gap: 12px; }
.saying-details-form {margin:0;}
.saying-details-form .saying-settings-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.saying-details-form > p, .saying-entry-edit > p { margin: 0; font-size: .85rem; }
.saying-entry-edit textarea { width: 100%; min-height: 100px; resize: vertical; }
.saying-entry-edit .button-row { justify-content: flex-end; }
.saying-setting-field:disabled .saying-setting-tile { cursor: default; opacity: .6; }
.saying-translation { font-size: calc(1.5rem * var(--reader-font-scale, 1)); line-height: 1.8; overflow-wrap: anywhere; }
.saying-translation .inline-reader-text { white-space: pre-wrap; }
.saying-pair-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.saying-pair-actions .copy-text-button { margin-left: auto; }
.saying-composer {position:static;}
.saying-composer form {display:grid;gap:10px;}

.saying-compose-row { display: flex; align-items: center; gap: 12px; }
.saying-compose-row input { flex: 1; }
.saying-compose-row button { flex-shrink: 0; }
.saying-compose-row button.saying-create-submit { display: inline-grid; place-items: center; width: 48px; min-width: 48px; height: 48px; padding: 0; }
.saying-create-submit .word-illustration-spinner { width: 22px; height: 22px; border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }
.saying-composer .error { margin: 12px 0 0; }
.document-delete { margin-top: 20px; }
.reader-popup.document-delete-confirmation { width: min(480px, calc(100vw - 24px)); }
.document-delete-confirmation .reader-popup-body > p:first-child { margin-top: 0; }
.document-delete-confirmation .button-row { justify-content: flex-end; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .saying-library-card:hover, :where(:root:not([data-touch-input])) .saying-setting-tile:hover { background: var(--surface-hover); } }
@media (max-width: 600px) {
  .saying-settings-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .saying-setting-tile { padding: 9px 10px; }
  .saying-partner { margin-inline-end: 0; }
  .saying-compose-row { gap: 8px; }
  .saying-compose-row button { padding-inline: 12px; }
}
.how-to-say .back-link { display: inline-flex; align-items: center; gap: 6px; width: fit-content; }
.how-to-say .sr-only, .saying-reply-editor .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.saying-reply-attachment { display: flex; align-items: center; gap: 8px; min-width: 0; }
.saying-reply-button { min-width: 0; max-width: 100%; font-size: .9rem; }
.saying-reply-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 36ch; font-weight: normal; }
.saying-reply-editor { display: grid; gap: 12px; }
.saying-reply-editor p { margin: 0; }
.saying-reply-editor textarea { width: 100%; resize: vertical; min-height: 110px; }
.saying-incoming { margin: 0 0 20px; padding: 12px 16px; border-inline-start: 3px solid var(--border); background: var(--surface-subtle); border-radius: 0 12px 12px 0; }
.saying-reply-label { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); }
.saying-incoming p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Messages from the conversation partner sit on the opposite side, untranslated. */
.saying-draft-partner-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.saying-partner { min-width: 0; margin-inline-end: clamp(0px, 12%, 96px); padding: 10px 14px 12px; border-radius: 16px 16px 16px 4px; background: var(--surface-subtle); border: 1px solid var(--border); }
.saying-partner .saying-entry-heading { align-items: center; margin-bottom: 4px; }
.saying-partner-label { flex: 1; min-width: 0; font-size: .78rem; font-weight: 600; letter-spacing: .02em; color: var(--muted); }
.saying-partner .saying-entry-actions .icon-button { width: 28px; height: 28px; }
.saying-partner-text { margin: 0; font-size: calc(1.1rem * var(--reader-font-scale, 1)); line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.saying-partner-text .inline-reader-text { white-space: pre-wrap; }
.saying-partner-row { display: flex; }
.saying-partner-button { font-size: .9rem; }

/* Suggested replies: choose one to insert it, or edit its meaning first. */
.saying-suggestions { display: grid; gap: 8px; }
.saying-suggestions h2 { font-size: .9rem; font-weight: 600; margin: 0; color: var(--text-secondary); }
.saying-suggestion-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.saying-suggestion { display: flex; align-items: center; gap: 6px; padding-inline-end: 8px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.saying-suggestion-choose { flex: 1; min-width: 0; display: grid; gap: 2px; justify-items: start; text-align: start; padding: 10px 14px; border: 0; border-radius: 14px; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.saying-suggestion-choose:disabled { cursor: default; opacity: .6; }
@media (hover: hover) and (pointer: fine) { .saying-suggestion-choose:hover, .saying-suggestion-choose:disabled:hover { background: transparent; color: var(--text); } }
.saying-reply-editor .button-row { justify-content: flex-end; }
.saying-suggestion-target { font-size: 1.1rem; line-height: 1.5; overflow-wrap: anywhere; }
.saying-suggestion-meaning { color: var(--muted); font-size: .85rem; line-height: 1.4; overflow-wrap: anywhere; }
.saying-suggestion .icon-button { flex: none; width: 34px; height: 34px; }
.saying-suggestions-loading { display: grid; gap: 8px; }
.saying-suggestion-skeleton { display: block; height: 58px; border-radius: 14px; background: linear-gradient(90deg, var(--surface-subtle), var(--surface-hover), var(--surface-subtle)); background-size: 200% 100%; animation: saying-suggestion-shimmer 1.4s ease-in-out infinite; }
@keyframes saying-suggestion-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .saying-suggestion-skeleton { animation: none; } }
.saying-suggestions-error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.saying-suggestions-error .error { margin: 0; }
@media (hover: hover) and (pointer: fine) { .saying-suggestion:has(.saying-suggestion-choose:not(:disabled)):hover { background: var(--surface-hover); } }

/* Translation rows retain source word controls and Markdown source offsets. */
.reader-sentence-translation { display: block; margin: .35em 0 .6em; font-size: min(1rem, calc(1rem * var(--reader-font-scale, 1))); line-height: 1.65; font-weight: 400; font-style: normal; letter-spacing: normal; color: color-mix(in srgb, var(--text) var(--reader-translation-visibility, 55%), transparent); white-space: pre-wrap; }
/* The translation block already ends the source line. Do not add another blank line. */
.reader-markdown .reader-sentence-translation + br { display: none; }
.reader-translation-waiting { color: var(--muted); font-size: .85em; }
.reader-sentence-translation-error { color: var(--danger); font-size: .85em; }

/* Center XP awards above the activity, with two waves after the entrance pulse. */
/* Keep reward notices out of the viewport hit-testing/compositing surface.
   Only the small toast itself owns a box and accepts pointer input. */
.xp-celebration-host { display: contents; pointer-events: none; }
.xp-celebration-host .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
button.xp-celebration { position: fixed; inset: 0; z-index: 90; width: max-content; height: max-content; margin: auto; display: grid; justify-items: center; gap: 2px; min-width: 128px; max-width: calc(100vw - 48px); padding: 10px 14px; pointer-events: auto; border: 1px solid var(--xp); border-radius: 18px; background: var(--xp-soft); color: var(--xp); box-shadow: 0 4px 24px #0005; text-align: center; animation: xp-reward-arrive 600ms ease-out both; }
@media (hover: hover) and (pointer: fine) { button.xp-celebration:hover { color: var(--xp); background: color-mix(in srgb, var(--xp) 8%, var(--xp-soft)); } }
.xp-celebration::before, .xp-celebration::after { content: ""; position: absolute; inset: -1px; border: 2px solid var(--xp); border-radius: inherit; pointer-events: none; opacity: 0; animation: xp-reward-ripple 700ms ease-out 240ms forwards; }
.xp-celebration::after { animation-delay: 390ms; }
.xp-celebration strong { font-size: 1.4rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
button.xp-celebration:where([data-leaving="true"]) { animation: xp-reward-depart 200ms ease-in both; opacity: 0; pointer-events: none; }
.xp-celebration-emblem { position: relative; display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 0; isolation: isolate; }
.xp-celebration-ring-face { position: absolute; inset: 0; display: grid; place-items: center; }
.xp-celebration-ring { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke-width: 5; }
.xp-celebration-track { stroke: color-mix(in srgb, var(--xp) 22%, var(--xp-soft)); }
.xp-celebration-filled { stroke: var(--xp); }
.xp-celebration-gain { stroke: color-mix(in srgb, var(--xp) 50%, #f6c4ff); animation: xp-ring-gain 650ms cubic-bezier(.2,.65,.25,1) both; }
.xp-celebration-ring-mark { display: grid; place-items: center; }
.xp-celebration[data-streak-flame="true"] .xp-celebration-ring-face { animation: xp-ring-transform 540ms ease-out both; }
.xp-celebration[data-streak-flame="true"] .xp-celebration-emblem::before,
.xp-celebration[data-streak-flame="true"] .xp-celebration-emblem::after { content: ""; position: absolute; z-index: -1; inset: 5px; border: 2px solid #ffae48; border-radius: 50%; animation: xp-streak-ripple 1100ms ease-out both; }
.xp-celebration[data-streak-flame="true"] .xp-celebration-emblem::after { animation-delay: 180ms; border-color: var(--xp); }
.xp-celebration-fire { z-index: 1; font-size: 2rem; line-height: 1; filter: drop-shadow(0 0 13px #f8834266); animation: xp-flame-rise 760ms cubic-bezier(.19,1,.38,1) both; }
.xp-celebration-streak { display: inline-flex; align-items: center; gap: 4px; margin-top: 3px; padding: 3px 7px; border-radius: 999px; color: var(--warning-ink); background: var(--warning-soft); font-size: .78rem; font-weight: 700; }
.xp-celebration-roll { display: inline-grid; overflow: hidden; font-size: 1rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.xp-celebration-roll > span { grid-area: 1 / 1; }
.xp-celebration-previous { animation: xp-streak-roll-out 460ms ease-in-out 420ms both; }
.xp-celebration-current { animation: xp-streak-roll-in 460ms ease-in-out 420ms both; }
.xp-celebration-label { font-size: .72rem; line-height: 1.2; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
/* Review rewards stay out of the card's center; goal celebrations keep the full layout. */
button.xp-celebration[data-compact="true"] { position: fixed; inset: auto; margin: 0; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); grid-template-columns: 34px minmax(0, 1fr); column-gap: 7px; row-gap: 1px; justify-items: start; min-width: 0; max-width: min(300px, calc(100vw - 24px)); padding: 7px 10px; border-radius: 12px; text-align: start; transform-origin: top right; }
button.xp-celebration[data-compact="true"]:not([data-leaving="true"]) { animation-name: xp-compact-arrive; animation-duration: 350ms; }
.xp-celebration[data-compact="true"] .xp-celebration-emblem { grid-column: 1; grid-row: 1 / 3; align-self: center; width: 34px; height: 34px; margin: 0; }
.xp-celebration[data-compact="true"] .xp-celebration-ring-mark svg { width: 18px; height: 18px; }
.xp-celebration[data-compact="true"] > strong { grid-column: 2; font-size: 1rem; }
.xp-celebration[data-compact="true"] .xp-celebration-label { grid-column: 2; font-size: .62rem; letter-spacing: .04em; overflow-wrap: anywhere; }
@keyframes xp-compact-arrive { from { opacity: 0; transform: translateY(-6px) scale(.92); } to { opacity: 1; transform: none; } }
.content-activity-bonus { width: fit-content; }
.xp-daily-meter { --xp-fill: var(--xp); display: grid; gap: 8px; min-width: 0; }
.xp-daily-label { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; font-size: .75rem; font-weight: 450; }
.xp-daily-label > span { color: var(--muted); }
.xp-daily-label strong { color: var(--xp); font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.xp-daily-track { height: 4px; border-radius: 4px; overflow: hidden; background: var(--border); }
.xp-daily-track > span { display: block; height: 100%; border-radius: inherit; background: var(--xp-fill); }
.xp-session-total, .xp-earned-badge { display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: 0 0 auto; width: fit-content; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--xp); border: 1px solid color-mix(in srgb, var(--xp) 25%, var(--border)); background: var(--xp-soft); font-weight: 600; border-radius: 999px; }
@media (hover: hover) and (pointer: fine) { .xp-session-total:hover, .xp-earned-badge:hover { color: var(--xp); border-color: var(--xp); background: var(--xp-soft); } }
.xp-session-total { padding: 5px 9px; font-size: .75rem; }
.flashcard-stage:has(.xp-session-total), .study-session:has(.xp-session-total) { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.study-topbar:has(.xp-session-total) .study-source > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xp-earned-badge { padding: 5px 10px; font-size: .8rem; }
.xp-session-total svg, .xp-earned-badge svg { width: 15px; height: 15px; color: currentColor; }
.xp-details-popup { width: min(460px, calc(100vw - 32px)); }
.xp-details-total { display: grid; gap: 8px; margin: 4px 0 28px; }
.xp-details-total > span, .xp-details-total small { color: var(--muted); font-size: .85rem; }
.xp-details-total > strong { color: var(--xp); font-size: 3.5rem; line-height: 1.1; letter-spacing: -.04em; font-weight: 600; font-variant-numeric: tabular-nums; }
.xp-details-total strong span { font-size: 1.1rem; color: var(--muted); font-weight: 450; letter-spacing: 0; }
.xp-details-popup .xp-daily-track { height: 6px; }
.xp-details-remaining { margin: 10px 0 24px; color: var(--muted); font-size: .8rem; }
.xp-details-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 16px; border-top: 1px solid var(--border); padding-top: 24px; margin: 0; }
.xp-details-stats[data-session="false"] > div:first-child { grid-column: 1 / -1; }
.xp-details-stats dt { color: var(--muted); font-size: .75rem; margin-bottom: 6px; }
.xp-details-stats dd { color: var(--xp); margin: 0; font-weight: 600; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.xp-details-timezone { margin: 24px 0; color: var(--muted); font-size: .7rem; }
.xp-details-actions { display: flex; justify-content: flex-end; }
@keyframes xp-reward-arrive { 0% { opacity: 0; transform: translateY(8px) scale(.84); } 35% { opacity: 1; transform: none; } 62% { opacity: 1; transform: scale(1.07); } 100% { opacity: 1; transform: none; } }
@keyframes xp-reward-depart { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.86); } }
@keyframes xp-reward-ripple { from { opacity: .45; transform: scale(1); } to { opacity: 0; transform: scale(1.25, 1.55); } }
@keyframes xp-ring-gain { from { stroke-dasharray: 0 100; } to { stroke-dasharray: var(--xp-ring-gain) 100; } }
@keyframes xp-ring-transform { 0% { opacity: 1; transform: none; } 40% { opacity: 1; transform: scale(1.18); } 100% { opacity: 0; transform: scale(.72); } }
@keyframes xp-streak-ripple { from { opacity: .85; transform: scale(1); } to { opacity: 0; transform: scale(3.1); } }
@keyframes xp-flame-rise { 0% { opacity: 0; transform: translateY(8px) scale(.25); } 28% { opacity: 0; } 65% { opacity: 1; transform: translateY(-3px) scale(1.2); } 100% { opacity: 1; transform: none; } }
@keyframes xp-streak-roll-out { to { opacity: 0; transform: translateY(-105%); } }
@keyframes xp-streak-roll-in { from { opacity: 0; transform: translateY(105%); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) {
  .xp-session-total { padding: 4px 7px; font-size: .7rem; }
}
@media (prefers-reduced-motion: reduce) {
  button.xp-celebration[data-compact="true"]:not([data-leaving="true"]), button.xp-celebration, .xp-celebration::before, .xp-celebration::after, .xp-celebration :is(.xp-celebration-gain, .xp-celebration-fire, .xp-celebration-previous, .xp-celebration-current),
  .xp-celebration[data-streak-flame="true"] .xp-celebration-ring-face,
  .xp-celebration[data-streak-flame="true"] .xp-celebration-emblem::before,
  .xp-celebration[data-streak-flame="true"] .xp-celebration-emblem::after { animation: none; transition: none; }
  .xp-celebration[data-streak-flame="true"] .xp-celebration-ring-face, .xp-celebration-previous { visibility: hidden; }
}

.reader-preparation-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.writing-ink-tools { flex-wrap: wrap; align-items: center; }
.writing-ink-tools .writing-hint-button { width: 36px; height: 36px; padding: 7px; }
.writing-hint-button[aria-pressed="true"] { color: var(--warning-ink); background: var(--warning-soft); box-shadow: inset 0 0 0 1px var(--warning); }

/* Dictionary composition shares the practice canvas and candidate picker. */
.dictionary-writing { padding: clamp(1rem, 3vw, 1.6rem); }
.dictionary-writing > p { margin: 0 0 16px; }
.dictionary-writing .writing-workspace { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 24px; align-items: center; }
.dictionary-writing .writing-canvas-wrap { width: 100%; margin-bottom: 0; }
@media (max-width: 620px) {
    .dictionary-writing .writing-workspace { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .dictionary-writing .writing-canvas-wrap { max-width: 240px; }
}

.reader-library-heading, .reader-title-actions { display: inline-flex; align-items: center; gap: 10px; }
.reader-title-actions { flex-shrink: 0; }
.reader-title-translation { flex: 0 0 100%; color: color-mix(in srgb, var(--text) var(--reader-translation-visibility, 55%), transparent); font-size: 1.05rem; line-height: 1.5; overflow-wrap: anywhere; }
.document-title-translation { color: color-mix(in srgb, var(--text) var(--reader-translation-visibility, 55%), transparent); font-size: .92rem; line-height: 1.4; overflow-wrap: anywhere; }

.reader-sentence-translation .translation-block { display: block; }
.reader-sentence-translation .translation-block + .translation-block { margin-top: .5em; }
.reader-sentence-translation .translation-heading { display: block; font-weight: 650; font-size: 1.1em; }
.reader-sentence-translation .translation-item { display: list-item; margin-inline-start: 1.3em; }
.reader-sentence-translation .translation-quote { display: block; border-inline-start: 3px solid var(--border); padding-inline-start: .8em; }
.reader-sentence-translation .translation-code { display: block; white-space: pre-wrap; }
.reader-sentence-translation .translation-rule { display: block; border-top: 1px solid var(--border); margin: .7em 0; }

.guided-dictation-preview { grid-column: 1; grid-row: 1 / span 2; min-height: 76px; padding: 12px 14px; border-radius: 12px; background: var(--surface-subtle); }
.guided-dictation-preview strong { display: flex; align-items: center; gap: 8px; }
.guided-dictation-preview p { margin: 8px 0 0; white-space: pre-wrap; }
.guided-mic-button[data-state="recording"] { background: var(--danger); color: white; }

.guided-microphone .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.story-image-retry { background: var(--surface); box-shadow: var(--shadow-sm); }

.reader-sentence-translation .translation-ordered-list > .translation-item { display: block; counter-increment: translation-item; }
.reader-sentence-translation .translation-ordered-list > .translation-item::before { content: counter(translation-item) ". "; }
.reader-sentence-translation .translation-cell { display: inline-block; margin-inline-end: 1em; }

.reader-original-input dl { display: grid; gap: 8px; margin: 0; }
.reader-original-input dt { margin-top: 12px; font-size: .8rem; font-weight: 650; color: var(--text-secondary); }
.reader-original-input dt:first-child { margin-top: 0; }
.reader-original-input dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Personalized setup and first lesson. */
.interest-editor { display: grid; gap: 12px; margin: 12px 0; }
.interest-editor > .interest-continue-actions { margin-top:24px; }
.interest-options { display: flex; flex-wrap: wrap; gap: 8px; }
.interest-options button { display: inline-flex; align-items: center; gap: 6px; }
.interest-options button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent); }
.interest-custom-recommendation {margin:12px 0 0;color:#7550ad;color:light-dark(#7550ad,#d8c7ff);font-size:.9rem;line-height:1.55}
.interest-add-topic,button.interest-add-topic {border:0;border-radius:10px;box-shadow:inset 0 0 0 1px var(--border-strong),var(--shadow-sm);background:#d8c7ff;color:#352052;position:relative;justify-self:stretch;display:inline-flex;align-items:center;justify-content:center;gap:9px;width:100%;min-width:0;max-width:100%;min-height:64px;margin-top:10px;padding:18px 24px;font-size:1rem;white-space:normal;overflow-wrap:anywhere;text-align:center}
.interest-custom-recommendation + .interest-add-topic {margin-top:0}
@media (hover: hover) and (pointer: fine) { button.interest-add-topic:hover {background:#e4d8ff;color:#352052} }
.interest-topic-composer {padding:8px 12px 8px 24px;gap:12px}
.interest-topic-composer > input {flex:1;min-width:0;width:100%;padding:8px 0;border:0;background:transparent;color:#352052;font-size:1.5rem;line-height:1.3;box-shadow:none;outline:none}
.interest-topic-composer > input::placeholder {color:#594371;opacity:1}
.interest-topic-composer > .interest-topic-send {display:grid;place-items:center;flex:none;width:40px;height:40px;padding:0;border-radius:50%;background:#352052;color:#fff}
@media (hover: hover) and (pointer: fine) { .interest-topic-composer > .interest-topic-send:hover {background:#4d316d;color:#fff} }
.custom-interest-chip { display: inline-flex; align-items: center; gap: 4px; min-width: 0; max-width: 100%; padding: 3px 5px 3px 12px; border: 1px solid var(--accent); border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: .9rem; }
.custom-interest-title { min-width: 0; overflow-wrap: anywhere; }
.custom-interest-chip > button.icon-button { flex: none; width: 28px; height: 28px; padding: 4px; color: inherit; }
.interest-topic-editor { display: grid; gap: 12px; min-width: 0; }
.interest-topic-editor input { width: 100%; min-width: 0; }
.interest-topic-editor > button { justify-self: end; }
.interest-topic-editor > small {overflow-wrap:anywhere}
.interest-topic-icon-controls {display:flex;align-items:center;flex-wrap:wrap;gap:8px}
.interest-topic-icon {display:grid;place-items:center;flex:none;width:44px;height:44px;border:1px solid var(--border);border-radius:12px;font-size:1.6rem;color:var(--muted)}
.interest-topic-icon-controls>.secondary {display:inline-flex;align-items:center;gap:6px;padding:8px 12px;font-size:.85rem}
.interest-topic-editor>button .word-illustration-spinner {width:16px;height:16px;margin-inline-end:6px}
.experience-picker { display: grid; grid-template-columns: repeat(var(--experience-columns, 3), minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 10px; margin: 16px 0; }
.experience-choice-buttons {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:16px 0;}
.experience-choice-buttons button {position:relative;width:100%;height:100%;min-width:0;min-height:76px;justify-self:stretch;align-self:stretch;justify-content:flex-start;padding:16px 44px 16px 16px;text-align:start;white-space:normal;overflow-wrap:anywhere;}
.experience-choice-buttons .language-check {position:absolute;top:50%;inset-inline-end:16px;transform:translateY(-50%);}
.setup-experience-level-help {margin:20px 0 0;font-size:.9rem;}
.experience-picker button { width: 100%; min-width: 0; min-height: 112px; height: 100%; justify-self: stretch; align-self: stretch; display: flex; flex-direction: column; align-items: flex-start; text-align: start; justify-content: flex-start; gap: 6px; padding: 14px; white-space: normal; overflow-wrap: anywhere; }
.experience-picker button small { font-weight: 400; line-height: 1.45; color: var(--text-secondary); }
.experience-picker button[aria-checked="true"], .experience-choice-buttons button[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.profile-experience { grid-column: 1 / -1; }
@media (max-width: 600px) { .experience-picker { grid-template-columns: 1fr; } .experience-picker.setup-levels {grid-template-columns:repeat(2,minmax(0,1fr));} }

/* Core language skill practice. */
.skills-page { max-width: 1120px; margin: 0 auto; padding: clamp(16px, 4vw, 48px); }
.skills-intro { max-width: 720px; margin-bottom: 32px; }
.skills-intro h1 { font-size: clamp(2.3rem, 5vw, 3.7rem); letter-spacing: -.05em; margin: 8px 0 14px; }
.skills-intro p { font-size: 1.06rem; line-height: 1.7; color: var(--text-secondary); }
.skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 22px; }
.skills-grid:has([data-skill="tones"]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
[data-skill="tone-changes"] .skill-card-art { color: #a26f39; background: color-mix(in srgb, #d9aa6a 15%, var(--surface)); }
button.skill-launch-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 26px; text-align: start; white-space: normal; color: var(--text); background: var(--surface); box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
@media (hover: hover) and (pointer: fine) { button.skill-launch-card:hover { transform: translateY(-4px); box-shadow: 0 14px 32px rgb(0 0 0 / .1); } }
.skill-card-art { position: relative; isolation: isolate; display: flex; align-items: center; justify-content: center; gap: 30px; height: 170px; width: 100%; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); overflow: hidden; }
[data-skill="stroke-order"] .skill-card-art { color: #9b6a2c; background: color-mix(in srgb, #e7b75a 16%, var(--surface)); }
[data-skill="pronunciation"] .skill-card-art { color: #8c6ab1; background: color-mix(in srgb, #a992d3 16%, var(--surface)); }
[data-skill="tones"] .skill-card-art { color: #457aa7; background: color-mix(in srgb, #72a4cc 14%, var(--surface)); }
.skill-orbit { position: absolute; z-index: -1; border: 1px solid currentColor; opacity: .12; width: 220px; height: 220px; border-radius: 50%; right: -40px; top: 20px; box-shadow: 0 0 0 30px currentColor; }
.skill-sound-bars { display: flex; gap: 5px; align-items: center; }
.skill-sound-bars i { display: block; width: 5px; border-radius: 5px; background: currentColor; opacity: .5; }
.skill-art-strokes { font-size: 2rem; opacity: .65; }
.skill-card-copy { display: flex; flex-direction: column; flex: 1; padding: 26px; gap: 14px; }
.skill-card-copy h2 { font-size: 1.4rem; line-height: 1.2; letter-spacing: -.025em; }
.skill-card-copy p { font-weight: 400; font-size: .95rem; color: var(--text-secondary); line-height: 1.65; }
.skill-launch { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; font-size: .9rem; }
.skills-practice-area { grid-row: 2; width: min(760px, 100%); justify-self: center; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 18px; container-type: inline-size; }
.skills-round { display: contents; }
.skills-difficulty-area { grid-row: 2; width: min(680px, 100%); justify-self: center; align-self: center; min-height: 0; max-height: 100%; display: grid; }
.skills-difficulty-picker { display: grid; gap: 24px; }
.skills-difficulty-picker h2 { font-size: clamp(1.4rem, 4vw, 2rem); letter-spacing: -.025em; }
.skills-difficulty-options { display: grid; grid-auto-rows: 1fr; gap: 12px; }
button.skills-difficulty-option { display: grid; width: 100%; min-width: 0; height: 100%; grid-template-columns: 34px minmax(0, 1fr) 20px; gap: 18px; align-items: center; padding: 20px; text-align: start; white-space: normal; border-radius: 18px; }
.skills-difficulty-option:focus-visible { background: var(--accent-soft); border-color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .skills-difficulty-option:hover { background: var(--accent-soft); border-color: var(--accent); } }
.skills-difficulty-option strong { display: block; font-size: 1.1rem; margin-bottom: 5px; }
.skills-difficulty-option p { font-size: .9rem; font-weight: 400; line-height: 1.5; color: var(--text-secondary); margin: 0; }
.skills-level-bars { height: 30px; display: flex; align-items: end; gap: 4px; }
.skills-level-bars i { width: 7px; border-radius: 3px; background: var(--border); }
.skills-level-bars i[data-active="true"] { background: var(--accent); }
button.skills-current-level { display: inline-flex; gap: 6px; align-items: center; padding: 8px 12px; border-radius: 20px; font-size: .8rem; }
.skills-progress { display: flex; align-items: center; gap: 16px; color: #fff; font-size: .78rem; font-weight: 650; letter-spacing: .1em; padding: 2px 8px; }
.skills-segments { flex: 1; display: flex; gap: 7px; }
.skills-segments > span { flex: 1; height: 9px; border-radius: 20px; background: #ffffff38; }
.skills-segments > span[data-current="true"] { outline: 2px solid #fff; outline-offset: 3px; }
.skills-segments > span:not([data-score="0"]) { background: hsl(var(--level-hue) 65% 72%); }
.skills-exercise-card { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 24px; }
.skills-exercise-card > .muted { max-width: 440px; font-size: .9rem; line-height: 1.6; }
.skills-listen-cue { display: flex; flex-direction: column; align-items: center; gap: 25px; color: var(--accent); }
.skills-listen-cue .speech-action { min-height: 56px; }
.skills-spoken-words { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px 24px; font-size: clamp(1.9rem, 6cqw, 3rem); line-height: 1.5; }
.skills-spoken-words > span { border-bottom: 2px solid var(--border); padding-bottom: 6px; }
.skills-spoken-words small { display: block; color: var(--text-secondary); font-size: .9rem; margin-top: 6px; }
.skills-reference { display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; padding-top: 18px; border-top: 1px solid var(--border); width: 100%; }
.skills-reference strong { font-size: 1.4rem; }.skills-reference p,.skills-reference small { color: var(--text-secondary); font-size: .85rem; margin: 3px 0; }
.skills-answer-dock { max-height: min(43dvh, 340px); }
.skills-answer-dock input { margin: 8px 0 14px; width: 100%; }
.skills-actions,.skills-summary-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.skills-actions .word-illustration-spinner { width: 20px; height: 20px; }
.skills-actions > p { font-size: .85rem; line-height: 1.5; }
.skills-answer-dock audio { display: block; width: 100%; max-height: 42px; margin: 10px 0; }
.skills-answer-dock .reader-flashcard-toolbar { margin: 0; }
.skills-answer-dock .reader-flashcard-microphone small:empty { display: none; }
.reader-flashcard-microphone .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* Submitted listening syllables stay visible alongside the feedback. */
.skills-submitted-answer { margin-bottom: 16px; }
.skills-answer-playback { display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-block:8px 12px; }
.skills-answer-playback > button { display:inline-flex;align-items:center;gap:8px; }
.skills-answer-playback audio { height:32px;max-width:100%; }
.skills-answer-playback audio:not([src]),.skills-answer-playback small:empty { display:none; }
.skills-answer-playback small { flex-basis:100%;color:var(--muted); }

.skills-submitted-label { margin: 0 0 8px; color: var(--text-secondary); font-size: .8rem; }
.skills-submitted-syllables { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.skills-submitted-syllable { display: grid; align-content: start; gap: 4px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.skills-submitted-sounds { display: flex; align-items: baseline; gap: 6px; font-size: 1.05rem; font-weight: 600; }
.skills-submitted-tone { font-size: .7rem; }
.skills-submitted-verdict { font-size: .65rem; font-weight: 500; }
.skills-submitted-syllable[data-state="correct"] { color: var(--success); border-color: var(--success); background: var(--success-soft); }
.skills-submitted-syllable[data-state="partial"] { color: var(--warning-ink); border-color: var(--warning); background: var(--warning-soft); }
.skills-submitted-syllable[data-state="incorrect"] { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.skills-submitted-tone[data-correct="false"] { color: var(--danger); }
.skills-submitted-tone[data-correct="true"] { color: var(--success); }
.skills-submitted-text { margin: 0; white-space: pre-wrap; }
.skills-feedback { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 10px 16px; margin-bottom: 16px; font-size: .95rem; line-height: 1.6; }
.skills-feedback .muted { grid-column: 2; font-size: .8rem; }
.skills-score { display: inline-flex; align-items: baseline; gap: 5px; padding: 9px 12px; border-radius: 8px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.skills-score strong { font-size: 1.5rem; line-height: 1.2; }
.skills-score small { font-size: .75rem; font-weight: 500; opacity: .7; }
.skills-reward-score { display: grid; justify-items: center; gap: 8px; }
.skills-session-rewards { display: flex; align-items: center; gap: 6px; letter-spacing: normal; }
.skills-session-rewards:empty { display: none; }
.skills-session-rewards .word-illustration-spinner { width: 16px; height: 16px; }
.skills-session-rewards .xp-session-total { white-space: nowrap; }
button.skills-xp-retry { padding: 5px 8px; font-size: .7rem; display: inline-flex; align-items: center; gap: 4px; }
.skills-summary-score { display: grid; gap: 8px; justify-items: center; }
.skills-summary { text-align: center; display: grid; align-content: center; justify-items: center; gap: 20px; }
.skills-summary h2 { font-size: 2rem; letter-spacing: -.03em; }.skills-summary p { color: var(--text-secondary); }
.skills-summary-icon { display: grid; place-items: center; width: 80px; height: 80px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.skills-load-error { grid-row: 2; place-self: center; max-width: 560px; }
.skills-tone-card { gap: 12px; }
.skills-tone-card h2 { font-size: 1.35rem; }
.skills-tone-note { max-width: 440px; font-size: .8rem; color: var(--text-secondary); }
.skills-tone-syllables { display: grid; gap: 20px; width: 100%; margin-top: 8px; }
.skills-tone-syllable { min-width: 0; padding: 0; border: 0; text-align: start; }
.skills-tone-syllable legend { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.skills-tone-syllable legend strong { font-size: 1.7rem; }
.skills-tone-index { color: var(--muted); font-size: .8rem; }
.skills-tone-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; }
.skills-tone-choice { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px 5px; min-height: 104px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); text-align: center; cursor: pointer; }
.skills-tone-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.skills-tone-choice strong { font-size: .9rem; }
.skills-tone-choice small { font-size: .68rem; line-height: 1.3; color: var(--text-secondary); }
.skills-tone-choice[data-selected="true"] { background: var(--accent-soft); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.skills-tone-choice[data-correct="true"] { border-color: #278254; box-shadow: inset 0 0 0 1px #278254; background: color-mix(in srgb, #278254 12%, var(--surface)); }
.skills-tone-choice[data-incorrect="true"] { border-color: #b84236; box-shadow: inset 0 0 0 1px #b84236; background: color-mix(in srgb, #b84236 10%, var(--surface)); }
.skills-tone-syllable:disabled .skills-tone-choice { cursor: default; }
.skills-tone-syllable-feedback { display: flex; align-items: center; gap: 6px; margin-top: 9px; font-size: .85rem; }
.skill-stroke-exercise { width: 100%; display: grid; justify-items: center; gap: 12px; }
.skill-stroke-exercise canvas { display: block; width: min(100%, 330px, 42dvh); aspect-ratio: 1; height: auto; touch-action: none; border: 1px solid var(--border); border-radius: 24px; background: var(--surface-subtle); }
.skill-stroke-exercise > p { min-height: 2.6em; font-size: .85rem; line-height: 1.3; }
.skill-stroke-tools { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.skill-stroke-tools button { display: inline-flex; align-items: center; gap: 5px; padding: 8px 12px; font-size: .8rem; }
.skill-stroke-tools [hidden] { display: none; }
.skill-stroke-tools [aria-pressed="true"] { background: #ffe2a2; color: #6d4913; }
.skill-stroke-exercise > small { font-size: .72rem; color: var(--muted); }
.skill-stroke-exercise[data-complete="true"] .skill-stroke-tools, .skill-stroke-exercise[data-complete="true"] > small { display: none; }
.skill-stroke-exercise[data-demonstrating="true"] .skill-stroke-tools { display: flex; }
.skill-stroke-exercise[data-demonstrating="true"] .skill-stroke-tools > :not([data-stroke="demo"]) { display: none; }
.skills-rule-guide { display: grid; gap: 22px; line-height: 1.65; }
.skills-rule-guide h3 { margin-bottom: 6px; font-size: 1rem; }
.skills-rule-guide p { color: var(--text-secondary); }
.skills-rule-guide > a { font-size: .8rem; }
.skills-tone-change-card { display: grid; align-content: center; justify-items: center; gap: 28px; width: min(100%, 560px); margin: auto; text-align: center; }
.skills-tone-change-card h2 { font-size: 1.4rem; }
.skills-change-prompt { display: grid; gap: 10px; }
.skills-change-prompt p { margin: 0; font-size: .9rem; line-height: 1.6; }
.skills-change-prompt small { font-size: .75rem; }
.skills-change-segment { display: grid; justify-items: center; gap: 20px; width: 100%; min-width: 0; }
.skills-change-row { display: grid; justify-items: center; gap: 8px; width: 100%; }
.skills-change-segment header strong { font-size: 2rem; }
.skills-change-segment header p { font-size: .8rem; color: var(--text-secondary); margin-top: 4px; }
.skills-change-label { font-size: .72rem; font-weight: 650; color: var(--muted); margin: 0; }
.skills-change-syllables { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; align-items: center; }
.skills-change-syllables > span { padding: 10px 14px; border-radius: 12px; background: var(--surface-subtle); font-size: 1.1rem; }
.skills-change-syllables sup { margin-left: 3px; font-weight: 700; }
select.skills-change-select { width: auto; max-width: 100%; min-height: 48px; font-size: .9rem; padding: 12px 30px 12px 12px; border-radius: 12px; }
select.skills-change-select:disabled { opacity: 1; color: var(--text); }
select.skills-change-select[data-result="correct"], .skills-change-solution > span { border-color: #278254; background: color-mix(in srgb, #278254 12%, var(--surface)); }
select.skills-change-select[data-result="incorrect"] { border-color: #b84236; background: color-mix(in srgb, #b84236 10%, var(--surface)); }
.skills-change-explanation { margin: 0; line-height: 1.65; font-size: .88rem; text-align: start; }
@media (max-width: 520px) {
    button.skills-difficulty-option { padding: 14px; gap: 12px; }
    .skills-difficulty-picker { gap: 18px; }
    .skills-page { padding: 20px 14px; }.skills-grid { gap: 18px; }.skill-card-art { height: 130px; }
    .skills-grid:has([data-skill="tones"]) { grid-template-columns: 1fr; }
    .skills-practice-area { gap: 12px; }.skills-exercise-card { gap: 18px; }.skills-feedback { gap: 8px; font-size: .85rem; }
    .skills-stage .study-card-body { padding: 20px; }.skills-stage .study-dock { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { button.skill-launch-card { transition: none; } @media (hover: hover) and (pointer: fine) { button.skill-launch-card:hover { transform: none; } } }

/* Pronunciation is composed in syllables, independently of the hidden answer. */
.pronunciation-composer { min-width: 0; display: grid; gap: 9px; }
.pronunciation-system { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; color: var(--text-secondary); font-size: .78rem; }
.pronunciation-system > span { font-weight: 650; }
.pronunciation-system small { font-size: .7rem; }
/* Keep the composer's own order instead of the outer answer/microphone grid's first row. */
.study-dock .pronunciation-composer input { grid-column:auto; grid-row:auto; width: 100%; min-height: 48px; margin: 0; font-size: 1.15rem; }
.pronunciation-sequence { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; max-height: 100px; overflow-y: auto; }
.pronunciation-chip { display: inline-flex; align-items: stretch; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; }
.pronunciation-chip[data-editing="true"] { border-color: var(--accent); background: var(--accent-soft); }
.study-dock .pronunciation-chip button { padding: 7px 9px; min-height: 36px; font-size: 1rem; border: 0; border-radius: 12px; box-shadow: none; }
.study-dock .pronunciation-chip .pronunciation-remove { padding: 7px; color: var(--text-secondary); }
.pronunciation-chip small, .pronunciation-suggestions button small { align-self: start; font-size: .6rem; color: var(--text-secondary); }
.pronunciation-suggestions { min-height: 86px; display: flex; flex-wrap: wrap; align-content: start; align-items: center; gap: 6px; }
.study-dock .pronunciation-suggestions button { min-height: 38px; padding: 7px 13px; border-radius: 10px; box-shadow: none; font-size: 1rem; }
.pronunciation-suggestions button[aria-selected="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.pronunciation-entry-help { color: var(--muted); font-size: .76rem; line-height: 1.5; padding: 8px 0; }
.pronunciation-tone-step { min-width: 0; outline: none; display: grid; gap: 8px; }
.pronunciation-tone-heading { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.pronunciation-tone-heading > span { color: var(--text-secondary); font-size: .8rem; }
.pronunciation-tone-heading > strong { font-size: 1.15rem; }
.study-dock .pronunciation-tone-heading button { padding: 7px 4px; font-size: .8rem; }
.pronunciation-tones { display: grid; grid-template-columns: repeat(auto-fit, minmax(58px, 1fr)); gap: 6px; }
.study-dock button.pronunciation-tone { flex-direction: column; gap: 3px; padding: 8px 4px; border-radius: 12px; min-height: 80px; box-shadow: none; }
.pronunciation-tone strong { font-size: 1.12rem; font-weight: 650; }
.pronunciation-tone small { font-size: .62rem; font-weight: 400; color: var(--text-secondary); }
.pronunciation-tone kbd { color: var(--text-secondary); font: inherit; font-size: .65rem; }
.flashcard-answer-editor[data-recording="true"] .pronunciation-composer { visibility: hidden; }
.skills-answer-dock:has(.pronunciation-composer) { max-height: min(52dvh, 460px); }
.skills-answer-dock .pronunciation-composer { margin-bottom: 12px; }
.skills-listen-cue .speech-control { flex-wrap: wrap; justify-content: center; }
.skills-listen-cue .speech-button { flex-shrink: 0; }
.skills-listen-cue .speech-error { flex-basis: 100%; }

/* Daily goals share tile styling across setup and Progress. */
.study-goal-choices { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; }
button.study-goal-choice { display:flex; flex-direction:column; align-items:stretch; text-align:start; gap:12px; padding:18px; border:1px solid var(--border); border-radius:18px; min-width:0; }
button.study-goal-choice[aria-pressed="true"], button.study-goal-custom[aria-pressed="true"] { border-color:var(--xp); background:var(--xp-soft); color:var(--xp); box-shadow:inset 0 0 0 1px var(--xp); }
.study-goal-choice-heading { display:flex; align-items:center; justify-content:space-between; gap:5px; min-height:24px; }
.study-goal-choice-heading strong { font-size:.95rem; }
.study-goal-xp { font-size:1.65rem; font-weight:700; font-variant-numeric:tabular-nums; }
.study-goal-xp span { font-size:.75rem; font-weight:500; }
.study-goal-choice small { color:var(--muted); font-size:.78rem; font-weight:400; }
.profile-study-goal { display:grid; gap:14px; padding-top:24px; border-top:1px solid var(--border); }
.profile-study-goal h2, .profile-study-goal p { margin:0; }
.profile-study-goal label { max-width:240px; }
.study-goal-custom { justify-self:start; }
a.home-daily-goal { position:relative; z-index:2; display:flex; align-items:center; gap:22px; margin:-52px 0 30px; padding:24px 26px; min-height:140px; border-radius:24px; text-decoration:none; color:var(--text); transition:border-color .15s,transform .16s var(--ease); }
@media (hover: hover) and (pointer: fine) { a.home-daily-goal:hover { border-color:var(--border-strong); transform:translateY(-1px); } }
.home-daily-goal .daily-goal-ring { width:104px; height:104px; flex-basis:104px; }
.home-daily-goal .daily-goal-ring circle { stroke-width:8; }
.home-daily-goal .daily-goal-ring > span { font-size:1.35rem; }
.home-daily-goal .daily-goal-copy h2 { font-size:1.45rem; letter-spacing:-.02em; }
.home-daily-goal .daily-goal-copy p { font-size:.95rem; }
.home-daily-goal .daily-goal-history { gap:5px; padding-left:26px; }
.daily-goal-streak { display:flex; align-items:center; gap:8px; }
.daily-goal-streak .shell-icon { color:var(--coral); }
.home-daily-goal .daily-goal-streak .shell-icon { color:#e8632f; }
.daily-goal-ring { position:relative; width:88px; height:88px; flex:0 0 88px; color:var(--xp); }
.daily-goal-ring > svg { width:100%; height:100%; transform:rotate(-90deg); }
.daily-goal-ring circle { fill:none; stroke-width:7; }
.daily-goal-track { stroke:var(--border); }
.daily-goal-fill { stroke:var(--xp); stroke-linecap:round; }
.daily-goal-ring > span { position:absolute; inset:0; display:flex; justify-content:center; align-items:center; font-weight:750; font-size:1.1rem; }
.daily-goal-copy { flex:1; min-width:0; }
.daily-goal-copy h2 { font-size:1.2rem; margin:5px 0 8px; }
.daily-goal-copy p { margin:0; font-size:.85rem; line-height:1.6; }
.daily-goal-copy p strong { color:var(--xp); white-space:nowrap; }
.daily-goal-copy p span::before { content:" · "; }
.daily-goal-copy p span, .daily-goal-history small { color:var(--muted); }
.daily-goal-history { display:grid; gap:6px; font-size:.85rem; border-left:1px solid var(--border); padding-left:22px; }
.daily-goal-history strong { font-size:1.15rem; }
.daily-goal-open { display:flex; align-items:center; gap:8px; font-size:.8rem; font-weight:650; white-space:nowrap; }
@media (max-width:1050px) { a.home-daily-goal { flex-wrap:wrap; } .daily-goal-open { margin-left:auto; } }
@media (max-width:650px) {
  .study-goal-choices { grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
  button.study-goal-choice { padding:14px; gap:8px; }
  /* Two compact rows: ring + goal, then history + the progress link. */
  a.home-daily-goal { display:grid; grid-template-columns:64px minmax(0,1fr) auto; gap:12px; padding:16px; margin-top:-40px; min-height:0; }
  .home-daily-goal .daily-goal-ring { grid-column:1; grid-row:1; width:64px; height:64px; flex-basis:64px; }
  .home-daily-goal .daily-goal-ring > span { font-size:1rem; }
  .home-daily-goal .daily-goal-copy { grid-column:2/-1; grid-row:1; }
  .home-daily-goal:not(:has(.daily-goal-ring)) .daily-goal-copy { grid-column:1/-1; }
  .home-daily-goal .daily-goal-copy h2 { margin:0 0 4px; font-size:1.1rem; }
  .home-daily-goal .daily-goal-copy p { font-size:.8rem; line-height:1.45; }
  .home-daily-goal .daily-goal-history { grid-column:1/3; grid-row:2; min-width:0; padding:0; gap:3px; font-size:.75rem; }
  .home-daily-goal .daily-goal-streak { gap:5px; flex-wrap:wrap; }
  .home-daily-goal .daily-goal-history strong { font-size:.95rem; }
  .home-daily-goal .daily-goal-open { grid-column:3; grid-row:2; align-self:center; justify-self:end; margin:0; padding:0; gap:6px; font-size:.75rem; line-height:1.25; }
  .home-daily-goal .daily-goal-open > svg { flex:none; }
  .daily-goal-ring { width:70px; height:70px; flex-basis:70px; }
  .daily-goal-copy { flex-basis:calc(100% - 86px); }
  .daily-goal-copy p span { display:block; }
  .daily-goal-copy p span::before { content:none; }
  .daily-goal-history { border-left:0; padding:0; }
  .daily-goal-open { white-space:normal; }
}

/* Bundled language reference: readable lessons, persistent self-assessment. */
.textbook-page { max-width: 1120px; margin: 0 auto; }
.textbook-intro { margin-bottom: 1.8rem; }
.textbook-intro h1 { margin: .4rem 0; }
.textbook-intro > p { max-width: 75ch; }
.textbook-levels { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.textbook-levels button[aria-pressed="true"], .pinyin-soundboard .pronunciation-tone[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.textbook-filters { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; }
.textbook-filters input[type="search"] { flex: 1 1 260px; min-width: 0; }
.textbook-filters label { display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.textbook-filters input[type="checkbox"] { width: auto; }
.textbook-level-group { margin-top: 2rem; }
.textbook-level-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 1rem; }
.textbook-level-heading h2 { display: flex; align-items: baseline; gap: 10px; margin: 0; }
.textbook-level-code { color: var(--muted); font-size: .8em; font-weight: 500; }
.textbook-level-familiarity { display: inline-flex; align-items: center; gap: 9px; font-size: .78rem; color: var(--muted); }
.textbook-familiarity { color: light-dark(hsl(var(--level-hue) 55% 36%), hsl(var(--level-hue) 60% 65%)); font-weight: 750; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.textbook-translation-notice { display: flex; align-items: center; gap: 8px; font-size: .85rem; }
.textbook-translation-notice button { padding: 4px 8px; }
.textbook-translation-loading { width: 100%; box-sizing: border-box; min-height: 64px; padding: 16px 20px; margin: 1rem 0; gap: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text-secondary); line-height: 1.5; }
.textbook-translation-loading .word-illustration-spinner { flex: none; width: 22px; height: 22px; }
button.pronunciation-guide-tile { display: flex; align-items: center; gap: 18px; position: relative; isolation: isolate; overflow: hidden; width: 100%; min-height: 128px; padding: 24px; margin: 1.75rem 0; border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border)); border-radius: 18px; background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); color: var(--text); box-shadow: none; text-align: start; }
@media (hover: hover) and (pointer: fine) { button.pronunciation-guide-tile:hover { border-color: var(--accent); background: var(--accent-soft); } }
.pronunciation-guide-symbol { display: grid; place-items: center; flex: none; width: 54px; height: 54px; color: var(--accent-ink); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.pronunciation-guide-copy { display: grid; gap: 8px; }
.pronunciation-guide-copy strong { font-size: 1.2rem; font-weight: 650; }
.pronunciation-guide-copy small { font-size: .85rem; font-weight: 400; line-height: 1.5; color: var(--text-secondary); }
.pronunciation-guide-art { flex: none; width: 200px; height: 80px; margin-inline-start: auto; color: var(--accent); opacity: .5; }
.pronunciation-guide-tile > .shell-icon { flex: none; margin-inline-start: auto; color: var(--accent-ink); }
@media (max-width: 700px) { button.pronunciation-guide-tile { padding: 20px; gap: 14px; } .pronunciation-guide-art { position: absolute; inset-inline-end: 25px; width: 150px; opacity: .12; z-index: -1; } .pronunciation-guide-copy small { max-width: 30ch; } }
.textbook-chapter-list { display: grid; grid-template-columns: minmax(0,1fr); gap: .75rem; }
.textbook-card { display: grid; grid-template-columns: minmax(0,1fr) 6.5rem; align-items: center; gap: 1.5rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: 16px; color: inherit; background: var(--surface); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .textbook-card:hover { border-color: var(--accent); } }
.textbook-card-copy { display: grid; gap: .4rem; min-width: 0; overflow-wrap: anywhere; }
.textbook-card h3 { margin: 0; font-size: 1.08rem; line-height: 1.4; }
.textbook-card p { margin: 0; line-height: 1.5; color: var(--text-secondary); }
.textbook-card-state { display: flex; align-self: stretch; justify-content: center; align-items: center; padding-inline-start: 1.25rem; border-inline-start: 1px solid var(--border); text-align: center; overflow-wrap: anywhere; font-size: .85rem; }
@media (max-width: 600px) { .textbook-card { grid-template-columns: minmax(0,1fr) 5rem; gap: 1rem; padding: 1rem; } .textbook-card-state { padding-inline-start: .75rem; } }
.textbook-article { max-width: 76ch; margin: 0 auto; line-height: 1.75; overflow-wrap: anywhere; }
.textbook-article h1 { font-size: clamp(1.5rem,3vw,2.1rem); line-height: 1.25; margin-top: .6rem; }
.textbook-article h2 { font-size: 1.2rem; margin-top: 1.75rem; line-height: 1.4; }
.textbook-article ul, .textbook-article ol { padding-left: 1.5rem; }
.textbook-article li { margin: .5rem 0; }
.textbook-inline-link { display: inline; padding: 0 .15em; border: 0; border-radius: 3px; background: transparent; color: var(--accent); text-decoration: underline; text-underline-offset: .18em; font: inherit; cursor: pointer; }
.textbook-table { max-width: 100%; overflow-x: auto; }
.textbook-table table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.textbook-table td { padding: .65rem; border: 1px solid var(--border); vertical-align: top; }
.textbook-table thead { font-weight: 700; background: var(--surface); }
.textbook-progress { display: flex; align-items: flex-start; flex-wrap: wrap; justify-content: space-between; gap: 1.5rem; border-top: 1px solid var(--border); padding-top: 1.5rem; margin-top: 2rem; }
.textbook-rating { display: grid; gap: .65rem; }
.textbook-rating .word-progress-levels { display: flex; gap: .35rem; }
.textbook-rating .word-progress-level { width: 2.7rem; height: 2.7rem; }
.pronunciation-info { font-size: .85rem; justify-self: end; margin-bottom: .4rem; }
.pronunciation-guide > .textbook-levels { position: relative; padding-bottom: .75rem; border-bottom: 1px solid var(--border); }
.pinyin-soundboard .pronunciation-tones { margin: 1rem 0; }
.pinyin-soundboard button.pronunciation-tone { width: 100%; flex-direction: column; justify-content: center; gap: 4px; min-height: 64px; padding: 10px 6px; }
.pinyin-soundboard .pronunciation-tone strong { white-space: nowrap; }
.soundboard-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(74px,1fr)); gap: .5rem; margin: 1rem 0; }
.soundboard-syllable { display: flex; flex-direction: column; gap: .2rem; padding: .75rem .35rem; min-height: 4.1rem; }
.soundboard-syllable strong { font-size: 1.15rem; }
.soundboard-syllable small { font-size: .75rem; opacity: .7; }
.soundboard-player { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 1rem 0; padding: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.soundboard-player audio { max-width: 100%; width: 280px; }
.soundboard-player p { flex: 1; min-width: 150px; margin: 0; font-size: .9rem; }
.pinyin-soundboard details { border-top: 1px solid var(--border); padding-top: 1rem; font-size: .9rem; }
@media (max-width: 560px) { .textbook-progress { flex-direction: column; } .textbook-filters { align-items: stretch; } .pinyin-soundboard .pronunciation-tones { grid-template-columns: repeat(3,1fr); } }
.pronunciation-guide > .textbook-levels > button { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; text-align: start; }
.guide-section-status { font-size: .72rem; opacity: .8; }
.guide-section-status .textbook-familiarity { margin-inline-start: 8px; font-size: .85rem; }
.guide-rating { color: hsl(var(--level-hue) 55% 36%); }
/* Core skill estimates use a shared 0–100 axis and identifiable line patterns. */
.skill-history-period, .skill-inspect-date { display:grid; gap:6px; font-size:.8rem; color:var(--muted); }
.skill-history-period select, .skill-inspect-date select { padding:8px 38px 8px 10px; font-size:.85rem; }
.skill-history-legend { display:grid; grid-template-columns:repeat(auto-fit,minmax(140px,1fr)); gap:10px; margin-bottom:22px; }
button.skill-history-key { display:grid; width:100%; justify-items:start; gap:9px; min-width:0; padding:13px; background:var(--surface); color:var(--text); border:1px solid var(--border); border-top:3px solid var(--skill-color); border-radius:12px; text-align:left; box-shadow:none; }
button.skill-history-key[aria-pressed="false"] { opacity:.5; background:var(--surface-subtle); }
.skill-key-name { display:flex; align-items:center; gap:7px; font-size:.83rem; font-weight:650; }
.skill-key-name svg { width:26px; height:10px; flex-shrink:0; }
.skill-key-name line { stroke:var(--skill-color); stroke-width:3; stroke-dasharray:var(--skill-dash); }
.skill-history-key small { font-size:.7rem; color:var(--muted); font-weight:400; }
.skill-rating-number { display:inline-flex; align-items:baseline; gap:2px; font-size:1.15rem; font-weight:750; font-variant-numeric:tabular-nums; color:hsl(var(--level-hue),48%,38%); background:color-mix(in srgb,hsl(var(--level-hue),55%,48%) 13%,var(--surface)); padding:5px 8px; border-radius:9px; }
.skill-rating-number small { font-size:.7rem; font-weight:500; color:var(--muted); }
.skill-history-chart .skill-history-line { fill:none; stroke:var(--skill-color); stroke-width:2.5; stroke-linejoin:round; stroke-dasharray:var(--skill-dash); }
.skill-history-chart .skill-history-dot { fill:var(--skill-color); stroke:var(--surface); stroke-width:1.5; }
.skill-history-chart > svg { height:255px; }
.skill-history-chart > svg:focus-visible {   border-radius:6px; }
.skill-inspect-date { display:flex; align-items:center; justify-content:flex-end; gap:10px; margin:8px 0 14px; }
.skill-inspect-date select { width:auto; min-width:145px; }
.skill-history-readout { display:grid; grid-template-columns:repeat(auto-fit,minmax(145px,1fr)); gap:12px; min-height:105px; }
.skill-history-readout > div { display:flex; flex-wrap:wrap; align-content:flex-start; align-items:baseline; gap:8px; padding-left:10px; border-left:2px solid var(--skill-color); }
.skill-history-readout strong { flex-basis:100%; font-size:.8rem; }
.skill-history-readout small { color:var(--muted); font-size:.72rem; }
.skill-grade-breakdown { border-top:1px solid var(--border); margin-top:20px; padding-top:16px; font-size:.85rem; }
.skill-grade-breakdown summary { cursor:pointer; font-weight:650; }
.skill-grade-table-wrap { overflow-x:auto; }
.skill-grade-table-wrap table { width:100%; font-size:.8rem; }
.skill-grade-table-wrap caption { text-align:left; color:var(--muted); padding:14px 0; font-size:.75rem; }
.skill-grade-table-wrap th, .skill-grade-table-wrap td { padding:10px 8px; text-align:left; border-bottom:1px solid var(--border); }
.skill-grade-table-wrap small { display:block; color:var(--muted); margin-top:5px; }
.skill-history-empty { display:grid; justify-items:center; padding:30px 20px; color:var(--muted); text-align:center; }
.skill-history-empty p { max-width:440px; line-height:1.7; }
@media(max-width:600px) {
 .skill-history-legend { gap:8px; }
 button.skill-history-key { padding:10px; }
 .skill-key-name { font-size:.78rem; }
 .skill-history-period { width:100%; }
 .skill-history-readout { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

.skill-history-cursor { stroke:var(--border-strong); stroke-width:1; }

.profile-quick-row { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.profile-quick-row:has(.profile-quick.active) { background: var(--accent-soft); }
.profile-quick-row .profile-quick { flex: 1; min-width: 0; }
.profile-quick-edit { flex: none; margin-right: 4px; width: 44px; height: 44px; }
.language-profile-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.language-profile-heading > div { flex: 1; min-width: 0; }
.language-profile-heading strong { font-size: 1.2rem; }
.language-profile-heading p { margin: 4px 0 0; font-size: .9rem; }
.language-profile-options { border-top: 1px solid var(--border); margin-top: 24px; padding-top: 20px; }
.language-profile-options h3 { margin-top: 0; }
.language-profile-save-status { min-height: 1.5em; font-size: .85rem; margin: 16px 0; }
.language-profile-delete { display: grid; justify-items: start; gap: 8px; border-top: 1px solid var(--border); padding-top: 20px; margin-top: 20px; }
.language-delete-warning { display: flex; align-items: flex-start; gap: 18px; margin: 8px 0 28px; }
.language-delete-warning h3 { margin: 0 0 12px; }
.language-delete-warning p { margin: 0; line-height: 1.6; }
.language-delete-icon { display: grid; place-items: center; flex: none; width: 58px; height: 58px; border-radius: 16px; color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.language-delete-entry { display: grid; gap: 12px; }
.language-delete-name { width: fit-content; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 1.25rem; user-select: text; }
.language-delete-entry input { width: 100%; }
.language-delete-actions { justify-content: flex-end; margin-top: 28px; flex-wrap: wrap; }
@media (max-width: 540px) {
  .language-delete-warning { gap: 12px; }
  .language-delete-icon { width: 42px; height: 42px; border-radius: 12px; }
}

button.progress-today { position:relative; width:100%; align-items:stretch; padding-block-end:32px; text-align:start; background:var(--surface); color:var(--text); font-weight:inherit; }
@media (hover: hover) and (pointer: fine) {
  button.progress-today:hover { background:var(--surface-hover); border-color:var(--border-strong); }
  .progress-today:hover .progress-today-edit { color:var(--text); }
}
.progress-today .progress-today-edit { position:absolute; inset-block-end:12px; inset-inline-end:14px; display:grid; place-items:center; color:var(--muted); }
.progress-today:focus-visible .progress-today-edit { color:var(--text); }
.progress-total-xp > strong, .progress-day-detail > strong { color: var(--xp); }
.progress-today-value { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; }
.progress-today-value > strong { font-size:clamp(2rem,4vw,2.8rem); line-height:1.15; color:var(--xp); font-variant-numeric:tabular-nums; letter-spacing:-.04em; }
.progress-today .daily-goal-ring { width:62px; height:62px; flex-basis:62px; }
.progress-today .daily-goal-ring > span { font-size:.8rem; }
.daily-goal-fill { transition:stroke-dasharray .3s ease; }

/* Daily quests */
.home-quests { display: grid; gap: 12px; margin-bottom: 28px; }
.home-quests-heading { gap: 12px 20px; flex-wrap: wrap; margin-bottom: 0; }
.home-quests-heading h2 { margin: 0; font-size: 1.05rem; }
.quest-timer { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: .74rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.quest-timer svg { color: var(--muted); }
.quest-timer[data-expired="true"] { color: var(--accent-ink); border-color: var(--border-strong); }
.quest-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; container: daily-quests / inline-size; }
.quest-card { --tone: var(--accent); --tone-soft: var(--accent-soft); position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; min-width: 0; min-height: 88px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); font: inherit; text-align: start; box-shadow: none; cursor: default; }
.quest-card.tone-jade { --tone: var(--success); --tone-soft: color-mix(in srgb, var(--success) 14%, var(--surface)); }
.quest-card.tone-marigold { --tone: var(--marigold); --tone-soft: var(--marigold-soft); }
.quest-card.tone-coral { --tone: var(--coral); --tone-soft: var(--coral-soft); }
.quest-card.tone-sky { --tone: var(--sky); --tone-soft: var(--sky-soft); }
.quest-icon { display: grid; place-items: center; width: 50px; height: 50px; flex: none; border-radius: 15px; background: var(--tone-soft); color: var(--tone); }
.quest-icon .shell-icon { width: 24px; height: 24px; }
.quest-card[data-complete="true"] { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: color-mix(in srgb, var(--success) 6%, var(--surface)); }
.quest-card[data-complete="true"] .quest-icon { background: var(--success); color: #fff; }
.quest-copy { display: grid; gap: 3px; min-width: 0; }
.quest-copy strong { overflow: hidden; font-size: .95rem; text-overflow: ellipsis; white-space: nowrap; }
.quest-copy small { overflow: hidden; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.quest-meter { display: block; height: 4px; margin-top: 3px; border-radius: 4px; overflow: hidden; background: var(--border); }
.quest-meter > span { display: block; height: 100%; border-radius: inherit; background: var(--tone); transition: width .35s ease; }
.quest-card[data-complete="true"] .quest-meter > span { background: var(--success); }
.quest-status { display: grid; gap: 4px; justify-items: end; flex: none; }
.quest-progress { color: var(--text-secondary); font-size: .78rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.quest-bonus { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; background: var(--xp-soft); color: var(--xp); font-size: .72rem; font-weight: 700; white-space: nowrap; }
.quest-card[data-complete="true"] .quest-bonus { background: color-mix(in srgb, var(--xp) 16%, var(--surface)); color: var(--xp); }
@container daily-quests (max-width: 700px) {
  .quest-card { grid-template-columns: 28px minmax(0,1fr); gap: 8px; min-height: 0; padding: 12px; align-items: start; }
  .quest-card .quest-icon { grid-column: 1; grid-row: 1; width: 28px; height: 28px; border-radius: 9px; }
  .quest-copy { grid-column: 1 / -1; grid-row: 1; gap: 6px; }
  .quest-copy strong { display: flex; align-items: center; min-height: 28px; padding-inline-start: 36px; font-size: .85rem; white-space: normal; overflow-wrap: anywhere; }
  .quest-copy small { font-size: .72rem; line-height: 1.35; white-space: normal; }
  .quest-status { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 4px; }
  .quest-bonus { padding: 3px 6px; font-size: .68rem; }
}
.quest-loading { display: grid; justify-items: center; gap: 10px; min-height: 150px; padding: 22px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--text-secondary); text-align: center; align-content: center; }
.quest-loading strong { font-size: .95rem; }
.quest-loading .muted { font-size: .82rem; }
@media (max-width: 600px) {
  .home-quests { margin-bottom: 18px; }
}
@media (prefers-reduced-motion: reduce) { .quest-meter > span { transition: none; } }
.study-goal-language { display:flex; align-items:center; gap:10px; margin:0 0 16px; }
.study-goal-language > span { font-size:1.5rem; }
@media (max-width:700px) {
  .progress-summary { grid-template-columns:1fr; }
  .progress-today-value > strong { font-size:1.7rem; }
}
@media (prefers-reduced-motion:reduce) { .daily-goal-fill { transition:none; } }

/* Vocabulary collections and the permanent word database. */
.vocabulary-collections { display: grid; gap: 12px; }
.vocabulary-collections .vocabulary-collection-row { margin-top: 0; }
.vocabulary-collection-row { position: relative; isolation: isolate; display: flex; align-items: center; gap: 16px; padding: 18px 22px; transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .16s var(--ease); }
.vocabulary-collection-open { display: flex; align-items: center; gap: 20px; flex: 1; min-width: 0; color: inherit; text-decoration: none; }
/* Extend the native link across the tile while keeping practice a separate action. */
.vocabulary-collection-open::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-lg); }
.vocabulary-collection-row:has(.vocabulary-collection-open:focus-visible), .lists-view-all:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.vocabulary-collection-open:focus-visible { outline: none; }
@media (hover: hover) and (pointer: fine) {
    :where(:root:not([data-touch-input])) .vocabulary-collection-row:hover { background-color: var(--surface-hover); border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
}
@media (prefers-reduced-motion: reduce) {
    .vocabulary-collection-row { transition: none; }
    @media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .vocabulary-collection-row:hover { transform:none; } }
}
.vocabulary-collection-open > svg { margin-left: auto; }
.vocabulary-collection-progress { flex: none; padding: .35em .55em; border-radius: 8px; font-size: .875rem; font-weight: 600; font-variant-numeric: tabular-nums; background: hsl(var(--progress-hue) 75% 48% / .16); border: 1px solid hsl(var(--progress-hue) 70% 45% / .22); }
.vocabulary-collection-copy { flex: 1; min-width: 0; }
.vocabulary-collection-copy h2, .vocabulary-collection-open h2 { margin: 0; font-size: 1.15rem; overflow-wrap: anywhere; }
.vocabulary-collection-copy p, .vocabulary-collection-open p { margin: 5px 0 12px; font-size: .875rem; }
.vocabulary-list-art { display: grid; place-items: center; flex: 0 0 64px; width: 64px; height: 64px; border-radius: 18px; background: var(--surface-subtle); overflow: hidden; font-size: 30px; }
.vocabulary-list-art img { width: 100%; height: 100%; object-fit: cover; }
.vocabulary-study-icon { position: relative; z-index: 1; flex-shrink: 0; }
.vocabulary-create-trigger { margin-top: 20px; }
.vocabulary-create-actions { flex-wrap: wrap; justify-content: flex-start; }
.vocabulary-create-actions + .database-row { margin-top: 12px; }
.vocabulary-create-actions .vocabulary-create-trigger { margin-top: 20px; }
.generated-list-title { margin: 6px 0 14px; }
.generated-list-title input { font-weight: 600; }
.structure-suggestions { display: grid; max-height: 55dvh; margin: 12px 0 20px; overflow-y: auto; }
.structure-suggestion-row { display: flex; align-items: flex-start; gap: 14px; padding: 16px 4px; border-bottom: 1px solid var(--border); }
.structure-suggestion-row > input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--accent); }
.structure-suggestion-copy { display: grid; gap: 10px; flex: 1; min-width: 0; }
.structure-suggestion-copy p { margin: 0; font-size: .84rem; }
.vocabulary-detail-heading { display: flex; align-items: center; gap: 16px; }
.vocabulary-detail-heading h2 { margin: 0; overflow-wrap: anywhere; }
.vocabulary-list-header { display: grid; gap: 20px; }
.vocabulary-list-header .vocabulary-progress-summary { margin: 0; padding: 20px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.vocabulary-list-header .reader-learning-heading { align-items: center; gap: 12px; flex-wrap: wrap; }
.vocabulary-list-header .reader-learning-heading strong { margin-left: auto; }
.vocabulary-database-search { margin: 24px 0; }
.vocabulary-suggestion-controls { display: flex; align-items: center; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.vocabulary-suggestions { display: grid; max-height: 50dvh; overflow-y: auto; }
.vocabulary-suggestion-row { display: flex; flex-direction: row; align-items: center; gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.vocabulary-suggestion-row input { width: 20px; height: 20px; flex-shrink: 0; }
.vocabulary-suggestion-row p { margin: 4px 0 0; font-size: .9rem; }
.vocabulary-suggestion-footer { display: flex; align-items: center; gap: 12px; padding-top: 20px; }
.vocabulary-suggestion-loading { display: flex; align-items: center; gap: 12px; padding: 24px 0; }
@media (max-width: 600px) {
    .vocabulary-collection-row { padding: 16px; gap: 8px; }
    .vocabulary-collection-open { gap: 12px; }
    .vocabulary-list-art { flex-basis: 48px; width: 48px; height: 48px; border-radius: 14px; font-size: 26px; }
}

/* Word suggestions keep fields, streamed results and actions in separate rows. */
.vocabulary-suggestion-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 180px); gap: 20px; margin-top: 24px; }
.vocabulary-suggestion-form label { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.vocabulary-suggestion-form .vocabulary-suggestion-footer { grid-column: 1 / -1; padding-top: 0; }
.vocabulary-suggestion-footer { justify-content: flex-end; flex-wrap: wrap; gap: 16px; margin-top: 8px; }
.vocabulary-add-status { display: inline-flex; align-items: center; gap: 10px; margin-right: auto; }
.vocabulary-suggestion-loading { min-height: 64px; padding: 18px 0; }
.vocabulary-suggestion-loading > .muted { margin-left: auto; white-space: nowrap; }
.vocabulary-suggestion-row > div { flex: 1; min-width: 0; }
.vocabulary-suggestion-controls { padding-top: 12px; border-top: 1px solid var(--border); }
.vocabulary-view-options { display: flex; flex-wrap: wrap; gap: 8px; margin: 24px 0 16px; }
.vocabulary-view-options [aria-pressed="true"] { background: var(--surface-subtle); box-shadow: inset 0 0 0 1px currentColor; }
.vocabulary-compact-list { padding: 0 18px; }
.vocabulary-compact-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.vocabulary-compact-row + .vocabulary-compact-row { border-top: 1px solid var(--border); }
/* Phrases and sentence structures list their entries like vocabulary words. */
.phrase-search { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 12px; }
.phrase-search .search-field { flex: 1 1 260px; margin: 0; }
.phrase-search .option-row { margin: 0; white-space: nowrap; }
.phrase-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 0; }
.phrase-row + .phrase-row, .structure-rows .structure-card + .structure-card { border-top: 1px solid var(--border); }
.structure-rows .structure-card { padding: 20px 0; }
.structure-rows .structure-card:last-child { padding-bottom: 4px; }
.vocabulary-compact-link { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(80px, 1fr) minmax(80px, 1fr) minmax(100px, 2fr); gap: 12px; align-items: baseline; color: inherit; text-decoration: none; }
.vocabulary-compact-link > * { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .vocabulary-suggestion-form { grid-template-columns: 1fr; gap: 18px; }
  .vocabulary-compact-link { grid-template-columns: 1fr; gap: 3px; }
  .vocabulary-compact-link .muted { font-size: .85rem; }
  .vocabulary-compact-meaning { font-size: .9rem; }
}

.vocabulary-import-actions { margin-bottom: 1rem; flex-wrap: wrap; }
.standard-vocabulary-lists { display: grid; gap: 10px; }
button.standard-vocabulary-list { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 64px; padding: 16px; text-align: start; white-space: normal; }
.standard-vocabulary-list > span { display: grid; gap: 4px; }
.standard-vocabulary-list svg { flex: none; }
.standard-vocabulary-heading { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.standard-vocabulary-heading h2 { margin: 0; font-size: 1.1rem; }

.standard-vocabulary-words { max-height: min(45vh, 30rem); overflow-y: auto; overscroll-behavior: contain; }
.standard-list-source { margin: .75rem 0; overflow-wrap: anywhere; }
.standard-list-source p { margin: .5rem 0; }
.standard-list-license { white-space: pre-wrap; font-size: .75rem; color: var(--muted); }

/* A list has one compact word view, with editing in its own dialog. */
.vocabulary-title { display: flex; align-items: center; gap: 16px; }
.vocabulary-title h1 { margin: 0; overflow-wrap: anywhere; min-width: 0; }
.vocabulary-title > .icon-button { flex-shrink: 0; }
.list-title-button { display:inline; padding:0; background:transparent; color:inherit; font:inherit; text-align:inherit; overflow-wrap:anywhere; }
.list-title-button:is(:active) { background:transparent; color:inherit; transform:none; }
@media (hover: hover) and (pointer: fine) { .list-title-button:is(:hover,:active) { background:transparent; color:inherit; transform:none; } }
@media (hover: hover) and (pointer: fine) { .list-title-button:hover { text-decoration:underline; text-decoration-thickness:1px; text-underline-offset:4px; } }
.vocabulary-progress-summary.surface { display: grid; gap: 6px; margin: 0; padding: 12px 18px; }
.vocabulary-progress-summary .topic-familiarity-track { margin:0; }
.vocabulary-list-actions { margin-block:18px; }
.vocabulary-list-actions .vocabulary-practice-button { margin-inline-start:auto; min-height:44px; min-width:140px; padding:10px 20px; font-size:1rem; }
.vocabulary-progress-summary .reader-learning-heading { margin: 0; }
.vocabulary-progress-summary h2 { font-size: 1.05rem; margin: 0; }
.vocabulary-practice-button { min-height: 52px; min-width: 180px; font-size: 1.05rem; padding: 14px 28px; }
.vocabulary-between-cards { display: flex; justify-content: flex-end; margin: 22px 0; }
.vocabulary-words-card .vocabulary-database-search { margin: 0 0 12px; }
.vocabulary-list-filling { margin: 0 0 12px; padding: 12px 14px; }
.vocabulary-list-filling p { margin: 0; }
.vocabulary-list-filling .muted { margin-top: 6px; font-size: .9em; }
.vocabulary-list-filling progress { display: block; width: 100%; height: 6px; margin-top: 8px; accent-color: var(--accent); }
.vocabulary-words-card .vocabulary-compact-list { padding: 0; }
.vocabulary-word-progress { flex: 0 0 44px; min-width: 0; }
.vocabulary-word-progress > button.word-progress-chip { width: 100%; min-height: 36px; font-size: 1rem; }
.vocabulary-word-progress > button.word-progress-chip.unrated { background: transparent; color: var(--muted); font-weight: 600; }
.vocabulary-word-progress > button.word-progress-chip:focus-visible { border-color: var(--border-strong); }
@media (hover: hover) and (pointer: fine) { .vocabulary-word-progress > button.word-progress-chip:hover:not(:disabled) { border-color: var(--border-strong); } }
.vocabulary-list-settings { display: grid; gap: 20px; margin: 0; }
.vocabulary-list-settings > label { max-width: none; margin: 0; }
.vocabulary-list-settings .vocabulary-actions { margin: 0; justify-content: flex-end; }
@media (max-width: 600px) {
  .vocabulary-title { gap: 12px; }
  .vocabulary-title .vocabulary-list-art { width: 44px; height: 44px; }
  .vocabulary-compact-row { gap: 8px; }
  .vocabulary-word-progress { flex-basis: 40px; }
  .vocabulary-compact-link .muted:empty { display: none; }
}

.reader-photo { display: grid; gap: 24px; }
.reader-photo fieldset { margin: 0; }
.photo-upload { position: relative; overflow: hidden; min-height: 44px; }
.reader-photo .button-row button { min-height: 44px; }
.photo-upload input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.photo-preview, .photo-camera video { display: block; width: 100%; max-height: 380px; object-fit: contain; border-radius: 12px; background: var(--surface-subtle); }
.photo-camera[hidden] { display: none; }
.photo-camera .form-actions { margin-top: 16px; }
.photo-modes { display: grid; gap: 14px; }
.photo-mode { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--border); border-radius: 12px; }
.photo-mode:has(input:checked) { border-color: var(--text); background: var(--surface-subtle); }
.photo-mode input { width: auto; margin: 0; }
.photo-mode span { display: grid; gap: 4px; }
.photo-mode small { color: var(--muted); font-weight: 400; }
.photo-review { border-top: 1px solid var(--border); padding-top: 24px; }
.photo-review h2, .photo-review p { margin: 0; }

.reader-source { display: grid; gap: 6px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); font-size: .875rem; color: var(--muted); }
.reader-source a { overflow-wrap: anywhere; text-underline-offset: 3px; }

/* Audio coach library. */
.coach-setup { max-width: 820px; }
.coach-setup form { display: grid; gap: 16px; }
.coach-visual { display:flex; align-items:center; gap:7px; height:72px; color:var(--accent); }
.coach-visual span { width:4px; height:24px; border-radius:4px; background:currentColor; opacity:.5; }
.coach-visual span:nth-child(3),.coach-visual span:nth-child(5) {height:46px;opacity:.8;}
.coach-library,.coach-history {display:grid;gap:16px;}
.coach-library {margin-top:32px;}
.coach-session-link {display:flex;align-items:center;gap:20px;text-decoration:none;color:inherit;}
.coach-session-link strong {flex:1;}
.coach-session-text {flex:1;display:grid;gap:4px;min-width:0;}
.coach-session-text span {font-size:.85rem;}
.coach-session-link .tag {margin:0;}
.tag.coach-done {background:var(--surface-subtle);color:var(--text-secondary);}
.coach-tip {display:flex;gap:10px;align-items:flex-start;margin:0;}
.coach-back {display:inline-flex;align-items:center;gap:6px;width:fit-content;margin-bottom:12px;color:var(--text-secondary);text-decoration:none;font-size:.9rem;}
@media (hover: hover) and (pointer: fine) { .coach-back:hover {color:var(--text);} }
.coach-tip svg {flex-shrink:0;margin-top:3px;}
/* Role-play reuses the live controller's start button and caption. */
.coach-start {min-height:52px;padding:14px 24px;}
.coach-live-caption {min-height:3.3em;max-height:12em;overflow:auto;font-size:1.2rem;line-height:1.65;white-space:pre-wrap;margin:24px 0 0;}

/* Audio coach session: a full-screen, hands-free stage. Status sits top-center,
   the coach in the middle, and large controls bottom-center for a quick glance
   and an easy tap while moving. */
.reader-popup.coach-stage {position:fixed;inset:0;width:100%;max-width:none;height:100dvh;max-height:none;margin:0;border:0;border-radius:0;background:var(--bg);box-shadow:none;}
.coach-stage > .reader-popup-heading {position:absolute;z-index:2;top:0;left:0;right:0;justify-content:center;padding:max(18px,env(safe-area-inset-top)) 76px 0;border:0;background:none;pointer-events:none;}
.coach-stage > .reader-popup-heading h2 {max-width:100%;overflow:hidden;color:var(--text-secondary);font-size:.95rem;font-weight:600;text-align:center;text-overflow:ellipsis;white-space:nowrap;}
.coach-stage > .reader-popup-heading .icon-button {position:absolute;top:max(8px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));width:52px;height:52px;border-radius:50%;pointer-events:auto;}
.coach-stage > .reader-popup-body {position:absolute;inset:0;padding:0;overflow:hidden;}
.coach-stage-live {position:absolute;inset:0;display:grid;grid-template-rows:auto minmax(0,1fr) auto;gap:16px;padding:calc(max(18px,env(safe-area-inset-top)) + 40px) max(16px,env(safe-area-inset-right)) max(20px,env(safe-area-inset-bottom)) max(16px,env(safe-area-inset-left));}
.coach-stage-top {display:grid;justify-items:center;gap:8px;text-align:center;}
.coach-stage-status {display:inline-flex;align-items:center;gap:10px;min-height:40px;margin:0;padding:8px 18px;border:1px solid var(--border);border-radius:999px;background:var(--surface);font-size:1rem;font-weight:600;}
.coach-stage-status [role="status"]:empty::before {content:"\00a0";}
.coach-stage-dot {width:10px;height:10px;flex:none;border-radius:50%;background:var(--muted);}
[data-live="true"] .coach-stage-dot {background:var(--accent);box-shadow:0 0 0 4px var(--accent-soft);}
.coach-stage-progress {margin:0;color:var(--muted);font-size:.85rem;}
.coach-stage-error {display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:12px;color:var(--danger);}
.coach-stage-error p {margin:0;}
.coach-stage-center {display:grid;grid-template-rows:minmax(140px,30dvh) minmax(0,1fr) auto;justify-items:center;gap:16px;width:100%;max-width:680px;min-height:0;margin:0 auto;text-align:center;}
.coach-stage-visual {display:grid;width:100%;place-items:center;}
.coach-stage-words {display:flex;flex-direction:column;align-items:center;gap:16px;width:100%;min-height:0;overflow-y:auto;overscroll-behavior:contain;}
.coach-stage-foot {max-width:100%;min-width:0;display:grid;min-height:48px;justify-items:center;align-content:end;gap:12px;}
.coach-stage-hint {max-width:420px;margin:0;color:var(--text-secondary);line-height:1.6;}
.coach-stage-caption {max-width:640px;max-height:30dvh;margin:0;overflow-y:auto;font-size:clamp(1.25rem,3.6vw,1.75rem);font-weight:500;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere;}
.coach-stage-caption:empty {display:none;}
.coach-stage-actions {display:flex;flex-wrap:wrap;justify-content:center;gap:12px;}
.coach-stage-actions > :is(button,.button-link) {min-height:48px;display:inline-flex;align-items:center;gap:8px;}
.coach-stage .coach-now {display:grid;gap:10px;width:100%;}
.coach-line {display:flex;align-items:center;justify-content:center;gap:14px;}
.coach-line p {margin:0;font-size:1.05rem;line-height:1.6;color:var(--text-secondary);}
.coach-line.target p {color:var(--text);font-size:clamp(1.3rem,3.6vw,1.7rem);font-weight:600;}
.coach-reveal {max-width:100%;max-height:24dvh;overflow:auto;overflow-wrap:anywhere;display:grid;justify-items:center;gap:6px;padding:16px 22px;border:1px solid var(--border);border-radius:18px;background:var(--surface);}
.coach-reveal strong {font-size:1.5rem;}
.coach-reveal button,.coach-reveal-toggle {display:inline-flex;align-items:center;gap:8px;min-height:44px;margin-top:6px;}
.coach-stage .coach-confirm {display:grid;justify-items:center;gap:12px;padding:16px 22px;border:1px solid var(--accent);border-radius:18px;background:var(--surface);}
.coach-stage .coach-confirm p {margin:0;font-size:1.1rem;}

/* Speaking Coach artwork stays behind the live stage; content has comic-style scrims. */
.reader-popup.coach-stage {--text:#f5f5f6;--text-secondary:#dedee3;--muted:#c1c3cb;--border:rgba(255,255,255,.22);--border-strong:rgba(255,255,255,.4);--surface:rgba(28,29,33,.7);--accent:#eeeef2;--accent-ink:#eeeef2;--accent-text:#202126;--accent-soft:rgba(255,255,255,.12);background:#15161a;color:var(--text);isolation:isolate}
.coach-background-ambient {position:absolute;inset:0;pointer-events:none;background:radial-gradient(ellipse at 20% 20%,#35494d,transparent 65%),radial-gradient(ellipse at 85% 80%,#4b3b50,transparent 65%),#181b22}
.coach-stage-live {z-index:1}
.coach-stage>.reader-popup-heading {z-index:3;padding-top:max(12px,env(safe-area-inset-top))}
.coach-stage .coach-glass,.coach-stage>.reader-popup-heading :is(h2,.icon-button) {
  border:1px solid var(--border);border-radius:20px;background:rgba(22,23,27,.68);color:var(--text);
  backdrop-filter:blur(10px) saturate(.9);-webkit-backdrop-filter:blur(10px) saturate(.9);box-shadow:0 8px 32px rgba(0,0,0,.12);
}
.coach-stage>.reader-popup-heading h2 {margin:0;padding:10px 18px}
.coach-stage>.reader-popup-heading .icon-button {border-radius:50%}
.coach-stage .coach-stage-status {border-radius:999px}
.coach-stage .coach-stage-progress {padding:6px 14px}
.coach-stage .coach-stage-error,.coach-stage .coach-stage-hint {padding:10px 16px}
.coach-stage .coach-stage-caption,.coach-stage .coach-now {padding:16px 22px}
.coach-stage .coach-starting {padding:20px 24px}
.coach-stage .coach-starting .coach-stage-hint {padding:0;background:none;border:0;box-shadow:none;backdrop-filter:none;-webkit-backdrop-filter:none}
.coach-stage .coach-stage-controls {width:auto;max-width:100%;padding:12px 16px}
.coach-stage .coach-stage-actions {padding:8px}
.coach-stage .loading-row.coach-glass {padding:10px 16px}
.coach-stage .coach-round-label {color:var(--text)}
/* Nested forms need a solid surface above the translucent stage panels. */
.coach-stage :is(.anchored-popover,.reader-word-bubble) {--surface:#232429;}
.coach-stage .coach-reveal-toggle {background:rgba(22,23,27,.8);color:var(--text);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}
.coach-background-retry {position:absolute;z-index:2;left:max(12px,env(safe-area-inset-left));bottom:max(12px,env(safe-area-inset-bottom))}
.coach-background-error {position:absolute;z-index:2;left:max(12px,env(safe-area-inset-left));bottom:calc(max(12px,env(safe-area-inset-bottom)) + 48px);max-width:220px;font-size:.75rem}
@media(max-width:600px) {
  .coach-stage .coach-stage-controls {padding:10px 6px}
  .coach-stage .coach-stage-caption,.coach-stage .coach-now {padding:12px 16px}
  .coach-stage .coach-starting {padding:16px}
}
@media(prefers-reduced-transparency:reduce) {
  .coach-stage .coach-glass,.coach-stage>.reader-popup-heading :is(h2,.icon-button),.coach-stage .coach-reveal-toggle {background:#232429;backdrop-filter:none;-webkit-backdrop-filter:none}
}

/* The orb mirrors the live state set by the controller on the stage root. */
.coach-orb {position:relative;display:grid;flex:none;place-items:center;width:clamp(96px,22vmin,176px);aspect-ratio:1;border-radius:50%;background:radial-gradient(circle at 35% 30%,color-mix(in srgb,var(--accent) 55%,white),var(--accent) 60%,color-mix(in srgb,var(--accent) 70%,black));color:var(--accent-text);opacity:.5;transition:opacity .3s ease,transform .3s ease;}
.coach-orb::after {content:"";position:absolute;inset:-14px;border:2px solid var(--accent);border-radius:50%;opacity:0;}
[data-live="true"] .coach-orb,.coach-orb.done {opacity:.9;}
[data-state="connecting"] .coach-orb,.coach-stage-live.starting .coach-orb {animation:coach-breathe 1.6s ease-in-out infinite;}
[data-state="ready"] .coach-orb::after {animation:coach-ring 2.2s ease-out infinite;}
[data-state="hearing"] .coach-orb {opacity:1;transform:scale(1.06);}
[data-state="hearing"] .coach-orb::after {animation:coach-ring 1s ease-out infinite;}
[data-state="thinking"] .coach-orb {animation:coach-breathe 1s ease-in-out infinite;}
[data-state="speaking"] .coach-orb {opacity:1;animation:coach-speak .45s ease-in-out infinite alternate;}
@keyframes coach-breathe {50% {opacity:.4;transform:scale(.92);}}
@keyframes coach-ring {from {opacity:.6;transform:scale(.9);} to {opacity:0;transform:scale(1.25);}}
@keyframes coach-speak {to {transform:scale(1.08);}}
@keyframes coach-spin {to {transform:rotate(360deg);}}

/* Startup steps: planning, microphone, then the live connection. */
/* Preparation contains the whole checklist, rather than the live stage's
   fixed orb/caption rows. Keep every message in flow and scroll short screens. */
.coach-stage-center.coach-stage-preparing {grid-template-rows:none;grid-auto-rows:max-content;align-content:start;align-content:safe center;overflow-y:auto;overscroll-behavior:contain;padding-block:16px;}
.coach-stage-preparing > .coach-starting {min-width:0;max-width:100%;}

.coach-starting {display:grid;justify-items:center;gap:22px;}
.coach-starting h2 {margin:0;font-size:clamp(1.3rem,4vw,1.7rem);}
.coach-steps {display:grid;gap:14px;min-width:min(300px,100%);margin:0;padding:0;list-style:none;text-align:start;}
.coach-steps li {display:flex;align-items:center;gap:12px;color:var(--muted);font-size:1.05rem;}
.coach-steps li:is(.active,.done) {color:var(--text);}
.coach-steps li.failed {color:var(--danger);}
.coach-step-mark {display:grid;flex:none;place-items:center;width:28px;height:28px;border:2px solid var(--border);border-radius:50%;}
.coach-steps .done .coach-step-mark {border-color:var(--accent);background:var(--accent);color:var(--accent-text);}
.coach-steps .active .coach-step-mark {border-color:var(--accent);}
.coach-steps .failed .coach-step-mark {border-color:var(--danger);}
.coach-step-spinner {width:14px;height:14px;border:2px solid var(--accent);border-right-color:transparent;border-radius:50%;animation:coach-spin .8s linear infinite;}

/* Bottom controls: large round targets with labels, the microphone in the middle. */
.coach-stage-bottom {display:grid;justify-items:center;gap:18px;}
.coach-stage-controls {display:flex;align-items:flex-start;justify-content:center;gap:clamp(4px,2vw,24px);width:100%;}
.coach-stage-controls[hidden] {display:none;}
button.coach-round,button.coach-mic {display:grid;justify-items:center;gap:8px;min-width:64px;min-height:0;padding:0;border:0;background:none;box-shadow:none;color:var(--text);}
@media (hover: hover) and (pointer: fine) { button.coach-round:hover:not(:disabled),button.coach-mic:hover:not(:disabled) {background:none;} }
.coach-round-icon {display:grid;place-items:center;width:64px;height:64px;border:1px solid var(--border);border-radius:50%;background:var(--surface);transition:border-color .15s ease,transform .15s ease;}
@media (hover: hover) and (pointer: fine) { button.coach-round:hover:not(:disabled) .coach-round-icon {border-color:var(--accent);} }
:is(button.coach-round,button.coach-mic):active:not(:disabled) .coach-round-icon {transform:scale(.94);}
:is(button.coach-round,button.coach-mic):focus-visible {outline:none;}
button.coach-round:disabled {opacity:.45;}
.coach-round-label {max-width:84px;color:var(--text-secondary);font-size:.85rem;font-weight:600;line-height:1.2;text-align:center;}
.coach-stage-controls > button.coach-round {margin-top:12px;}
.coach-mic .coach-round-icon {width:88px;height:88px;border:3px solid var(--accent);background:var(--accent);color:var(--accent-text);}
[data-live="true"] .coach-mic .coach-round-icon {background:var(--surface);color:var(--accent-ink);}
.coach-mic .coach-round-label {max-width:96px;color:var(--text);}
.coach-stage-live.starting .coach-stage-controls > button.coach-round {opacity:.35;pointer-events:none;}
@media (prefers-reduced-motion: reduce) {.coach-orb,.coach-orb::after,.coach-step-spinner {animation:none !important;}}

/* Session preferences: two switches, before a session and inside the details panel. */
.coach-preferences {display:grid;width:100%;text-align:start;}
.coach-preferences .switch-row {margin:0;padding:12px 0;}
.coach-preferences .switch-copy small {display:block;color:var(--text-secondary);line-height:1.45;}

/* Session details panel: typing, phrases, and the transcript. */
.reader-popup.coach-details {width:min(620px,calc(100vw - 24px));}
.coach-details > .reader-popup-body {display:grid;gap:28px;}
.coach-type,.coach-review,.coach-save-to,.coach-lookup {display:grid;gap:10px;}
.coach-review h3,.coach-history h3 {margin:0;}
.coach-inline-field {display:flex;gap:10px;}
.coach-inline-field input {flex:1;min-width:0;}
.coach-inline-field button {display:inline-flex;align-items:center;gap:8px;flex-shrink:0;}
.coach-phrase {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;padding:16px 0;border-top:1px solid var(--border);}
.coach-phrase > .coach-phrase-copy {display:grid;gap:4px;min-width:0;overflow-wrap:anywhere;}
/* Phrase actions must not place buttons inside nested word bubbles or pickers. */
.coach-phrase > button,.coach-phrase > .coach-phrase-saved {grid-column:2;grid-row:1;align-self:center;}
.coach-lookup {padding-top:16px;border-top:1px solid var(--border);}
.coach-exchange p {white-space:pre-wrap;line-height:1.65;}
.coach-exchange.learner {border-color:color-mix(in srgb,var(--accent) 30%,var(--border));}
.coach-earlier summary {cursor:pointer;color:var(--text-secondary);}
.coach-earlier[open] {display:grid;gap:16px;}
.coach-details-end {display:flex;justify-content:flex-end;padding-top:18px;border-top:1px solid var(--border);}
.coach-details-end button {display:inline-flex;align-items:center;gap:8px;}
.coach-phrase-review {gap:12px}
.coach-save-help {margin:0;color:var(--muted);font-size:.9rem;line-height:1.5}
.coach-phrase-tools {display:grid;gap:12px;padding:14px;border:1px solid var(--border);border-radius:16px;background:rgba(22,23,27,.85)}
.coach-phrase-destination {display:grid;gap:6px}
.coach-phrase-list-row,.coach-new-list {display:flex;gap:8px;align-items:center}
.coach-phrase-list-row>select,.coach-new-list>input {flex:1;min-width:0}
.coach-phrase-list-row>button,.coach-new-list>button {flex:none;white-space:nowrap}
.coach-phrase-bulk {display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.coach-save-notice {margin:0;color:#9be2b1;font-size:.85rem}
.coach-phrase-saved {display:inline-flex;align-items:center;gap:5px;color:#9be2b1;font-size:.85rem;font-weight:600}
.coach-phrase-tools .error {margin:0}
.coach-history>summary {cursor:pointer;font-weight:650;color:var(--muted)}
.coach-history[open] {display:grid;gap:14px}
@media(max-width:380px){.coach-phrase-list-row,.coach-new-list {flex-wrap:wrap}.coach-phrase-list-row>select,.coach-new-list>input {flex-basis:100%}}

@media(max-width:600px){.coach-session-link{gap:12px}.coach-round-icon{width:56px;height:56px}.coach-mic .coach-round-icon{width:76px;height:76px}.coach-stage-controls>button.coach-round{margin-top:10px}button.coach-round,button.coach-mic{min-width:0;flex:0 1 56px}.coach-stage-controls>button.coach-mic{flex-basis:76px}.coach-round-label{max-width:100%;overflow-wrap:anywhere;font-size:.78rem}}

@media(max-width:360px){.coach-round-icon{width:48px;height:48px}.coach-mic .coach-round-icon{width:64px;height:64px}.coach-stage-controls>button.coach-round{margin-top:8px}.coach-stage-controls>button.coach-mic{flex-basis:64px}}

/* Short screens keep the new scrims clear of one another. */
@media(max-height:600px) {
  .coach-stage-live {gap:8px;padding-top:54px;padding-bottom:max(8px,env(safe-area-inset-bottom))}
  .coach-stage-top {display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:6px}
  .coach-stage .coach-stage-status {min-height:32px;padding:6px 12px;font-size:.85rem}
  .coach-stage .coach-stage-progress {font-size:.75rem}
  .coach-stage .coach-stage-error {flex-basis:100%}
  .coach-stage-center:not(.coach-stage-preparing) {grid-template-rows:minmax(64px,14dvh) minmax(0,1fr) auto;gap:8px}
  .coach-stage-visual .coach-orb {width:64px}
  .coach-stage .coach-stage-caption {font-size:1rem;max-height:100%;padding:10px 12px}
  .coach-stage .coach-reveal {padding:10px 16px;gap:3px;max-height:22dvh;font-size:.85rem}
  .coach-stage .coach-reveal strong {font-size:1.2rem}
  .coach-stage .coach-stage-controls {padding:6px 10px;gap:8px}
  .coach-stage .coach-round-icon {width:40px;height:40px}
  .coach-stage .coach-mic .coach-round-icon {width:52px;height:52px}
  .coach-stage .coach-round-label {font-size:.7rem;max-width:64px}
  .coach-stage .coach-stage-controls>button.coach-round {margin-top:6px}
}
@media(max-height:600px) and (min-width:600px) {
  .coach-stage-center:not(.coach-stage-preparing) {max-width:960px;grid-template-columns:100px minmax(0,1fr) minmax(130px,200px);grid-template-rows:minmax(0,1fr);gap:16px;align-items:center}
  .coach-stage-visual {grid-column:1;grid-row:1}
  .coach-stage-words {grid-column:2;grid-row:1;max-height:100%}
  .coach-stage-foot {grid-column:3;grid-row:1;max-height:100%;align-content:center;overflow:auto}
  .coach-stage .coach-reveal {max-height:100%}
  .coach-stage-words .coach-starting {max-height:100%;overflow:auto;padding:12px}
}

/* Role-play: one room, one partner, a small set of practical outcomes. */
.roleplay-invitation,.roleplay-library-row,.roleplay-library-link{display:flex;align-items:center;gap:24px}
.roleplay-invitation{padding:32px}.roleplay-invitation>div:nth-child(2){flex:1}.roleplay-invitation h2{margin:0 0 10px}.roleplay-invitation p{margin:0;color:var(--muted)}
.roleplay-mark{display:grid;place-items:center;width:80px;height:80px;flex-shrink:0;border-radius:24px;background:var(--bg);color:var(--accent)}
.roleplay-library{display:grid;gap:14px;margin-top:28px}.roleplay-library-row{padding:20px 24px}.roleplay-library-link{flex:1;flex-wrap:wrap;min-width:0;color:inherit;text-decoration:none}.roleplay-library-link strong{flex:1}.roleplay-library-link span{font-size:.85rem}
.roleplay-task-panel{display:grid;gap:16px}
.roleplay-task{padding:24px}.roleplay-task-heading{display:flex;gap:12px;align-items:center;flex-wrap:wrap}.roleplay-task-heading h3{flex:1;margin:0;font-size:1.05rem}.roleplay-task-heading .tag{font-size:.7rem}.roleplay-step{width:28px;height:28px;display:grid;place-items:center;border:1px solid var(--border);border-radius:50%;font-size:.8rem;flex-shrink:0}.roleplay-task>p{line-height:1.65;color:var(--muted);margin:16px 0 0}.roleplay-task form{margin-top:20px}.roleplay-task .form-actions{margin-top:16px}.roleplay-task.complete .roleplay-step{color:var(--accent);border-color:var(--accent)}.roleplay-task.available{border-color:color-mix(in srgb,var(--accent) 55%,var(--border))}
.roleplay-choices{display:grid;gap:10px;border:0;padding:0;margin:0}.roleplay-option{display:flex;align-items:center;gap:12px;border:1px solid var(--border);border-radius:12px;padding:14px;cursor:pointer}.roleplay-option.selected{border-color:var(--accent);background:color-mix(in srgb,var(--accent) 7%,var(--surface))}.roleplay-option input{width:auto;flex-shrink:0;margin:0}.roleplay-task textarea,.roleplay-task input:not([type=radio]){width:100%}
.roleplay-result{border-top:1px solid var(--border);padding-top:16px;margin-top:20px;font-size:.9rem;line-height:1.65}.roleplay-result p{margin:0 0 8px}.roleplay-submitted{overflow-wrap:anywhere}.roleplay-result.correct{border-top-color:var(--accent)}.roleplay-result.retry{border-top-color:#9a9a9a}
.roleplay-transcript{margin-top:32px}.roleplay-line{display:grid;grid-template-columns:110px 1fr;gap:16px;padding:20px 0;border-top:1px solid var(--border)}.roleplay-line strong{font-size:.85rem;color:var(--muted)}.roleplay-line p{margin:0;line-height:1.8;white-space:pre-wrap}.roleplay-line small{grid-column:2}.roleplay-line.learner p{color:var(--accent)}.roleplay-archive{margin-top:28px}.roleplay-archive-link{display:block;padding:12px 0;color:inherit}
.roleplay-library-heading{margin:8px 0 2px;font-size:1.15rem}
.roleplay-library-text{flex:1;display:grid;gap:4px;min-width:0}.roleplay-library-text span{font-size:.85rem}
.roleplay-library-link .tag{margin:0}.tag.roleplay-done{background:var(--surface-subtle);color:var(--text-secondary)}
.roleplay-panel-hint{margin:8px 0 4px}
.roleplay-panel .roleplay-task.locked{opacity:.7}
.roleplay-panel .roleplay-empty{color:var(--muted)}
.roleplay-type{display:flex;gap:10px;margin-top:14px}
.roleplay-type input{flex:1;min-width:0;color:var(--text);background:rgba(0,0,0,.38);border-color:var(--border-strong)}
.roleplay-stage .roleplay-type button{background:#f2f2f2;color:#111111;border-color:#f2f2f2;flex-shrink:0}
.roleplay-stage .roleplay-type button:disabled{opacity:.5}
.roleplay-stage .roleplay-type-toggle{margin-inline-start:auto;width:40px;height:40px;min-width:40px;padding:8px}
/* Preparation uses an abstract, slowly drifting field, never a placeholder room. */
.roleplay-imagination{position:absolute;inset:0;overflow:hidden;pointer-events:none;background:radial-gradient(ellipse at 50% 40%,#252629,#111214 75%)}
.roleplay-imagination span{position:absolute;width:85vmax;height:65vmax;left:-25%;top:-35%;border-radius:50%;background:radial-gradient(ellipse,rgba(225,226,233,.11),transparent 65%);filter:var(--app-blur-filter, blur(35px));animation:roleplay-imagine 38s ease-in-out infinite alternate}
.roleplay-imagination span:nth-child(2){left:40%;top:20%;opacity:.6;animation-duration:49s;animation-delay:-17s}
.roleplay-imagination span:nth-child(3){left:15%;top:50%;width:55vmax;height:45vmax;opacity:.4;animation-duration:31s;animation-delay:-9s}
@keyframes roleplay-imagine{to{transform:translate(15%,18%) rotate(25deg) scale(1.12)}}
.roleplay-loading-frame{position:absolute;inset:0;display:grid;place-items:center;pointer-events:none}
.roleplay-loading-card{position:relative;width:min(440px,calc(100% - 32px));border-radius:24px;max-height:calc(100dvh - 170px);pointer-events:auto;isolation:isolate}
.roleplay-loading-scrim{position:absolute;inset:0;border-radius:inherit;pointer-events:none;z-index:0}
.roleplay-loading-content{position:relative;z-index:1;display:grid;justify-items:center;gap:14px;padding:32px 28px;border-radius:inherit;text-align:center;max-height:inherit;overflow:auto;overscroll-behavior:contain}
.roleplay-loading-card h2{margin:0;font-size:1.4rem}
.roleplay-loading-mark{position:relative;display:grid;place-items:center;width:72px;height:72px;border-radius:50%;background:#f2f2f2;color:#111111}
.roleplay-loading-mark::after{content:"";position:absolute;inset:-8px;border:2px solid #f2f2f2;border-radius:50%;animation:roleplay-loading-ring 1.8s ease-out infinite}
@keyframes roleplay-loading-ring{from{opacity:.7;transform:scale(.85)}to{opacity:0;transform:scale(1.3)}}
.roleplay-loading-tags{display:flex;flex-wrap:wrap;justify-content:center;gap:8px}
.roleplay-loading-tags .tag{margin:0;background:rgba(255,255,255,.12);color:var(--text)}
.roleplay-loading-bar{width:100%;height:8px;margin-top:8px;overflow:hidden;border-radius:999px;background:rgba(255,255,255,.14)}
.roleplay-loading-bar span{display:block;height:100%;border-radius:inherit;background:#f2f2f2;transition:width .4s ease}
.roleplay-loading-message{min-height:1.5em;margin:0;font-size:.95rem;animation:fade-in .4s ease}
.roleplay-loading-note{margin:0;color:var(--muted);font-size:.8rem}
.roleplay-loading-progress{width:100%;text-align:start}
.roleplay-loading-progress .comic-loading-steps{gap:12px}
.roleplay-loading-progress .comic-loading-steps li{gap:10px;font-size:.9rem}
.roleplay-loading-progress .comic-loading-steps li>span:nth-child(2){flex:1}
.roleplay-loading-progress .comic-loading-steps li small{font-size:.72rem;flex:none;font-weight:450;color:var(--muted)}
.roleplay-loading-progress .comic-loading-steps li.failed{color:var(--danger)}
.roleplay-loading-progress .comic-loading-steps li.failed .comic-loading-marker{border-color:var(--danger);color:var(--danger)}
.roleplay-loading-progress .comic-loading-detail{margin:10px 0 18px}
.roleplay-loading-steps{display:grid;width:100%;gap:12px;margin:4px 0 0;padding:0;list-style:none;text-align:start}
.roleplay-loading-steps li{display:flex;align-items:center;gap:10px;color:var(--muted);font-size:.9rem}
.roleplay-loading-steps li.done{color:var(--text)}
.roleplay-loading-steps li>span:nth-child(2){flex:1}
.roleplay-loading-steps li small{font-size:.72rem;flex:none}
.roleplay-loading-steps li.failed{color:var(--danger)}
.roleplay-loading-steps li.failed .roleplay-loading-step{border-color:var(--danger)}
.roleplay-library-spinner{display:inline-block;width:12px;height:12px;margin-inline-end:6px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:coach-spin .9s linear infinite}
.roleplay-loading-step{display:grid;place-items:center;width:20px;height:20px;flex:none;border:2px solid rgba(255,255,255,.3);border-radius:50%}
.roleplay-loading-steps li.done .roleplay-loading-step{border-color:#f2f2f2;background:#f2f2f2;color:#111111}
.roleplay-loading-steps li.active .roleplay-loading-step{border-color:#f2f2f2;border-right-color:transparent;animation:coach-spin .8s linear infinite}
.roleplay-loading .error{margin:0;color:var(--danger)}
.roleplay-loading-actions{display:flex;flex-wrap:wrap;justify-content:center;gap:12px}
.roleplay-loading-actions button{min-height:44px;padding:10px 20px;border-radius:12px}
.roleplay-loading-actions button:not(.secondary){background:#f2f2f2;color:#111111;border-color:#f2f2f2}
@media (prefers-reduced-motion:reduce){.roleplay-loading-mark::after,.roleplay-imagination span,.roleplay-loading-step,.roleplay-library-spinner{animation:none!important}.roleplay-loading-bar span{transition:none}}
/* The helper: a separate, warm-toned voice in the learner's language; the partner waits, dimmed. */
.roleplay-figure{transition:filter .4s ease}
@media(max-width:700px){.roleplay-control-row{flex-wrap:wrap}}
@media(max-width:850px){.roleplay-invitation{flex-wrap:wrap;padding:24px}.roleplay-invitation .button-link{width:100%;justify-content:center}.roleplay-mark{width:56px;height:56px}.roleplay-task{padding:20px}.roleplay-line{grid-template-columns:1fr;gap:8px}.roleplay-line small{grid-column:1}}

/* Immersive role-play: one scene, centered conversation, quiet edge controls. */
.roleplay-stage,.roleplay-panel{--text:#f5f5f5;--muted:#bdbdbd;--border:rgba(255,255,255,.2);--border-strong:rgba(255,255,255,.4);--surface:rgba(28,28,28,.78);--bg:#1e1e1e;--accent:#e8e8e8;--danger:#ffc4b9;color:var(--text)}
:is(.roleplay-stage,.roleplay-panel) .reader-word-bubble {--surface:#1c1c1c;}
.reader-popup.roleplay-stage{position:fixed;inset:0;width:100%;max-width:none;height:100dvh;max-height:none;margin:0;border:0;border-radius:0;background:#161616;isolation:isolate}
.roleplay-stage>.reader-popup-body{position:absolute;z-index:0;inset:0;padding:0;overflow:hidden;isolation:isolate}
.roleplay-environment,.roleplay-environment img,.roleplay-scene-shade{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.roleplay-environment img{object-fit:cover;object-position:center}
/* The partner shares the room's frame (preserveAspectRatio slice matches object-fit cover). */
.roleplay-scene-art,.roleplay-scene-art>svg{position:absolute;inset:0;width:100%;height:100%}
.roleplay-figure{filter:saturate(.85) brightness(.9)}
/* A drawn partner breathes and moves while talking; items fade in when shown. */
.roleplay-partner-art{transform-box:fill-box;transform-origin:50% 100%;animation:roleplay-breathe 5s ease-in-out infinite;transition:filter .4s ease}
.roleplay-stage:has([data-state="speaking"]) .roleplay-partner-art{animation:roleplay-speak .45s ease-in-out infinite alternate}
@keyframes roleplay-speak{to{transform:translateY(-3px) scale(1.012)}}
.roleplay-item{opacity:0;transform:translateY(14px);transform-box:fill-box;transition:opacity .5s ease,transform .5s ease}
.roleplay-figure-body{animation:roleplay-breathe 5s ease-in-out infinite;transform-box:fill-box}
.roleplay-figure-head{transform-box:fill-box;transform-origin:50% 100%;transition:transform .5s ease}
.roleplay-figure-eyes{transform-box:fill-box;transform-origin:center;animation:roleplay-blink 5.5s infinite}
.roleplay-figure-mouth{transform-box:fill-box;transform-origin:center}
.roleplay-stage:has([data-state="speaking"]) .roleplay-figure-mouth{animation:roleplay-talk .32s ease-in-out infinite alternate}
.roleplay-stage:has([data-state="hearing"]) .roleplay-figure-head{transform:rotate(-4deg)}
@keyframes roleplay-breathe{50%{transform:translateY(-2px)}}
@keyframes roleplay-blink{0%,95%,100%{transform:scaleY(1)}97%{transform:scaleY(.1)}}
@keyframes roleplay-talk{from{transform:scale(1,1)}to{transform:scale(.8,3)}}
@media (prefers-reduced-motion:reduce){.roleplay-figure-body,.roleplay-figure-eyes,.roleplay-figure-mouth,.roleplay-partner-art{animation:none!important}.roleplay-item{transition:none}}
.roleplay-scene-shade{background:linear-gradient(180deg,rgba(0,0,0,.48),transparent 32%,rgba(0,0,0,.12) 58%,rgba(0,0,0,.75))}
.roleplay-glass,.roleplay-stage>.reader-popup-heading,.reader-popup.roleplay-panel{border:1px solid var(--border);background:rgba(18,18,18,.74);backdrop-filter:blur(22px) saturate(1.15);-webkit-backdrop-filter:blur(22px) saturate(1.15);box-shadow:0 12px 40px rgba(0,0,0,.18);border-radius:18px;color:var(--text)}
.roleplay-stage>.reader-popup-heading{position:absolute;z-index:2;top:max(22px,env(safe-area-inset-top));left:max(22px,env(safe-area-inset-left));width:clamp(180px,22vw,300px);padding:10px 12px 10px 18px;gap:12px}
.roleplay-stage>.reader-popup-heading h2{font-size:.85rem;line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.roleplay-stage button,.roleplay-stage .button-link,.roleplay-panel button{color:var(--text);border-color:var(--border);box-shadow:none}
@media (hover: hover) and (pointer: fine) { .roleplay-stage button:hover:not(:disabled),.roleplay-panel button:hover:not(:disabled){background:rgba(255,255,255,.17)} }
.roleplay-stage .icon-button{width:44px;height:44px;min-width:44px;display:grid;place-items:center;padding:10px}
.roleplay-stage>.reader-popup-heading .icon-button{background:transparent;border:0}
button.roleplay-goal{position:absolute;top:max(22px,env(safe-area-inset-top));left:50%;transform:translateX(-50%);width:min(490px,42vw);display:grid;grid-template-columns:1fr auto;gap:6px 20px;text-align:start;padding:16px 22px;white-space:normal}
.roleplay-goal .eyebrow{grid-column:1;font-size:.65rem;letter-spacing:.13em;color:#d6d6d6;margin:0}
.roleplay-goal strong{grid-column:1;font-size:.95rem;line-height:1.45;font-weight:600;max-height:4.4em;overflow:auto}
.roleplay-goal-progress{grid-column:2;grid-row:1/3;align-self:center;display:flex;align-items:center;gap:8px;font-size:.75rem;color:#d6d6d6;max-width:110px}
.roleplay-edge-tools{position:absolute;top:max(22px,env(safe-area-inset-top));right:max(22px,env(safe-area-inset-right));display:flex;gap:8px}
.roleplay-edge-tools button{position:relative}
.roleplay-location{position:absolute;left:max(22px,env(safe-area-inset-left));bottom:max(22px,env(safe-area-inset-bottom));display:flex;align-items:center;gap:10px;max-width:min(260px,20vw);padding:12px 16px;font-size:.75rem;line-height:1.5}
.roleplay-location svg{flex-shrink:0}.roleplay-location span{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.roleplay-dock{position:absolute;bottom:max(24px,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:min(680px,calc(100% - 48px));display:grid;gap:12px;justify-items:center;max-height:calc(100% - 170px);overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:4px}
.roleplay-partner{display:flex;align-items:center;gap:12px;padding:12px 20px;border-radius:40px;max-width:100%}
.roleplay-partner>div{display:grid;gap:2px;text-align:center}.roleplay-partner strong{font-size:1rem}.roleplay-partner span:not(.roleplay-presence){font-size:.75rem;color:var(--muted)}
.roleplay-presence{width:8px;height:8px;flex-shrink:0;border-radius:50%;background:#8a8a8a}.roleplay-presence.live{background:#ffffff;box-shadow:0 0 0 5px #ffffff26}
.roleplay-live-controls{width:100%;padding:18px 22px}.roleplay-live-controls.finished{display:none}
.roleplay-live-controls .coach-live-caption{font-size:1.1rem;line-height:1.6;text-align:center;max-height:24dvh;overflow-y:auto;margin:0 0 18px;padding:0 6px 18px;border-bottom:1px solid var(--border);white-space:pre-wrap;overflow-wrap:anywhere}
.roleplay-live-controls .coach-live-caption:empty{display:none}
.roleplay-control-row{display:flex;align-items:center;justify-content:space-between;gap:16px}.roleplay-audio-state{display:flex;align-items:center;gap:10px;min-width:0}.roleplay-audio-state svg{flex-shrink:0;color:var(--muted)}
.roleplay-audio-state p{font-size:.75rem;line-height:1.5;margin:0;overflow-wrap:anywhere}
.roleplay-stage .coach-start,.roleplay-stage .button-link{background:#f2f2f2;color:#111111;border:1px solid #f2f2f2;padding:12px 20px;border-radius:12px;font-size:.85rem;flex-shrink:0}
@media (hover: hover) and (pointer: fine) { .roleplay-stage .coach-start:hover:not(:disabled),.roleplay-stage .button-link:hover{background:#ffffff} }
.roleplay-live-controls[data-live=true] .coach-start{color:var(--text);background:rgba(255,255,255,.08);border-color:var(--border)}
.roleplay-finished{width:100%;padding:22px;display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:16px}.roleplay-finished>strong{flex:1}.roleplay-finished>svg{color:var(--accent)}
.reader-popup.roleplay-panel{width:min(560px,calc(100vw - 32px));max-height:calc(100dvh - 48px);margin:auto max(24px,env(safe-area-inset-right)) auto auto;background:rgba(20,20,20,.9)}
.roleplay-panel::backdrop{background:rgba(0,0,0,.3)}
.roleplay-panel>.reader-popup-body{padding:24px}.roleplay-panel p{line-height:1.65}.roleplay-panel-objective{font-size:1.15rem;margin:0}
.roleplay-panel .surface{background:rgba(255,255,255,.05);box-shadow:none;border-color:var(--border)}
.roleplay-panel .roleplay-task.available{border-color:#d9d9d9}.roleplay-panel :is(input:not([type=radio]),textarea){color:var(--text);background:rgba(0,0,0,.38);border-color:var(--border-strong)}
.roleplay-panel .roleplay-option.selected{background:rgba(255,255,255,.12)}.roleplay-panel .tag{background:rgba(255,255,255,.1);color:var(--muted)}
.roleplay-panel .level-picker{--accent-soft:rgba(255,255,255,.14);--accent-text:#171717}
.roleplay-panel .roleplay-line{grid-template-columns:1fr;gap:6px}.roleplay-panel .roleplay-line small{grid-column:1}
@media(max-width:1000px){.roleplay-location{display:none}.roleplay-stage>.reader-popup-heading{width:190px}.roleplay-edge-tools{flex-direction:column}button.roleplay-goal{width:min(450px,calc(100% - 520px));left:calc(50% + 55px)}.roleplay-goal-progress{grid-row:auto;grid-column:1}.roleplay-goal{gap:4px!important}}
@media(max-width:700px){.roleplay-stage>.reader-popup-heading{top:max(12px,env(safe-area-inset-top));left:max(12px,env(safe-area-inset-left));width:calc(100% - 184px);padding:7px 10px 7px 14px}.roleplay-edge-tools{top:max(19px,env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));flex-direction:row;gap:6px}.roleplay-stage .icon-button{width:40px;height:40px;min-width:40px;padding:8px}button.roleplay-goal{top:calc(max(12px,env(safe-area-inset-top)) + 76px);left:50%;width:calc(100% - 24px);padding:12px 16px;grid-template-columns:1fr auto}.roleplay-goal strong{font-size:.85rem;max-height:2.9em}.roleplay-goal-progress{grid-column:2;grid-row:1/3}.roleplay-dock{width:calc(100% - 24px);bottom:max(12px,env(safe-area-inset-bottom));max-height:calc(100% - 208px);gap:8px}.roleplay-partner{padding:10px 16px}.roleplay-live-controls{padding:14px}.roleplay-control-row{flex-wrap:wrap;justify-content:center;gap:12px}.roleplay-audio-state{justify-content:center;flex:1 1 100%;text-align:center}.roleplay-stage .coach-start{width:100%}.roleplay-live-controls .coach-live-caption{font-size:1rem;max-height:20dvh;margin-bottom:14px;padding-bottom:14px}.reader-popup.roleplay-panel{margin:auto;width:calc(100vw - 24px);max-height:calc(100dvh - 24px)}.roleplay-panel>.reader-popup-body{padding:18px}.roleplay-environment img{object-position:57% center}}
@media(max-height:540px) and (min-width:701px){.roleplay-dock{bottom:12px;max-height:calc(100% - 120px);gap:6px}.roleplay-partner{padding:8px 16px}.roleplay-live-controls{padding:12px 18px}.roleplay-live-controls .coach-live-caption{max-height:15dvh;margin-bottom:10px;padding-bottom:10px}}

/* Assistant: a quiet, full-height conversation with native learning cards. */
.app-shell:has(.assistant-screen:not(.embedded)) { height: 100dvh; min-height: 0; grid-template-rows: minmax(0, 1fr); overflow: hidden; padding-bottom: 0; }
.workspace:has(.assistant-screen:not(.embedded)) { width: 100%; max-width: none; min-height: 0; overflow: hidden; padding: 0; }
.assistant-screen { height: var(--chat-height, calc(100dvh - var(--header-height, 60px))); min-height: 0; display: flex; flex-direction: column; position: relative; container: assistant / inline-size; }
/* Frost the full-screen chat without filtering its contents. A separate layer
   preserves viewport positioning for word popovers inside learning cards. */
.assistant-screen:not(.embedded) { --assistant-glass-opacity: 100%; --assistant-glass-filter: none; }
@supports ((backdrop-filter: blur(18px)) or (-webkit-backdrop-filter: blur(18px))) {
    .assistant-screen:not(.embedded) { --assistant-glass-opacity: calc(var(--home-glass-opacity) + 6%); --assistant-glass-filter: saturate(1.15) blur(18px); }
}
.assistant-screen:not(.embedded) :is(.assistant-heading, .assistant-welcome, .assistant-user-text, .is-assistant > .assistant-message-content, .assistant-message-avatar, .assistant-composer, .assistant-editing, .assistant-connection, .assistant-send-error, .assistant-dictation-status) { position: relative; isolation: isolate; background: transparent; }
.assistant-screen:not(.embedded) :is(.assistant-heading, .assistant-welcome, .assistant-user-text, .is-assistant > .assistant-message-content, .assistant-message-avatar, .assistant-composer, .assistant-editing, .assistant-connection, .assistant-send-error, .assistant-dictation-status)::before { content: ""; position: absolute; z-index: -1; inset: 0; border-radius: inherit; pointer-events: none; background: var(--surface); background: color-mix(in srgb, var(--surface) var(--assistant-glass-opacity), transparent); -webkit-backdrop-filter: var(--assistant-glass-filter); backdrop-filter: var(--assistant-glass-filter); }
.assistant-screen:not(.embedded) .assistant-welcome { margin-block: 8px 24px; padding: clamp(20px, 4vw, 32px); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow-sm); }
.assistant-screen:not(.embedded) .is-assistant > .assistant-message-content { padding: 18px 20px; border: 1px solid var(--border); border-radius: 4px 22px 22px; box-shadow: var(--shadow-sm); }
.assistant-screen:not(.embedded) :is(.assistant-editing, .assistant-connection, .assistant-send-error, .assistant-dictation-status) { margin-bottom: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; }
@media (prefers-reduced-transparency: reduce) {
    .assistant-screen:not(.embedded) { --assistant-glass-opacity: 100%; --assistant-glass-filter: none; }
}
.assistant-heading { display: flex; justify-content: space-between; align-items: center; flex: none; gap: 18px; padding: 20px clamp(18px, 4vw, 48px) 16px; border-bottom: 1px solid var(--border); }
.assistant-screen:not(.embedded) .assistant-heading { min-height:49px; padding-block:2px; gap:8px; }
.assistant-heading-copy { min-width: 0; flex: 1; }
.assistant-heading-label { margin: 0; font-size: .72rem; font-weight: 600; color: var(--muted); }
.assistant-history-toggle { flex: none; }
.assistant-history-toggle[aria-expanded="true"] { background: var(--surface-subtle); color: var(--text); }
.assistant-body { display: flex; flex: 1; min-height: 0; position: relative; isolation: isolate; }
.assistant-conversation-pane { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.assistant-history-panel { position:relative;isolation:isolate;flex:0 0 0;width:0;min-width:0;overflow:hidden;overscroll-behavior:contain;padding:16px 0;background:var(--surface);border-inline-end:0 solid var(--border);opacity:0;visibility:hidden;pointer-events:none;transition:flex-basis .22s var(--ease),width .22s var(--ease),padding .22s var(--ease),opacity .16s ease,visibility 0s .22s; }
.assistant-history-panel[data-open="true"] {flex-basis:280px;width:280px;padding-inline:16px;border-inline-end-width:1px;overflow-y:auto;opacity:1;visibility:visible;pointer-events:auto;transition-delay:0s;}
.assistant-history-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.assistant-history-heading h2 { margin: 0; font-size: .9rem; }
button.assistant-history-backdrop { display: none; }
@container assistant (max-width: 900px) {
    .assistant-history-panel { position:absolute;inset-block:0;inset-inline-start:0;flex:none;width:min(300px,calc(100% - 48px));padding:16px;border-inline-end-width:1px;z-index:2;box-shadow:8px 0 24px #0002;transform:translateX(-100%);transition:transform .22s var(--ease),opacity .16s ease,visibility 0s .22s; }
    .assistant-history-panel:dir(rtl) {transform:translateX(100%);}
    .assistant-history-panel[data-open="true"] {width:min(300px,calc(100% - 48px));transform:translateX(0);transition-delay:0s;}
    button.assistant-history-backdrop { display: block; position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 0; background: #0005; z-index: 1; cursor: default;opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease,visibility 0s .22s; }
    button.assistant-history-backdrop[data-open="true"] {opacity:1;visibility:visible;pointer-events:auto;transition-delay:0s;}
    button.assistant-history-backdrop:active { transform: none; }
}
@media(prefers-reduced-motion:reduce) {.assistant-history-panel,button.assistant-history-backdrop {transition:none;}}
.assistant-heading h1 { font-size: 1.1rem; margin: 3px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: min(50vw, 600px); }
.assistant-heading-actions { display: flex; align-items: center; gap: 8px; flex: none; }
/* "Ask about this": a compact chat in a popup, opened from anywhere in the app. */
.ask-about { flex: none; }
.ask-about.secondary { display: inline-flex; align-items: center; gap: 8px; }
.ask-about-popup > .reader-popup-body { display: flex; flex-direction: column; height: min(72dvh, 680px); padding: 0; overflow: clip; }
.assistant-screen.embedded { flex: 1; height: auto; }
.assistant-screen.embedded .assistant-thread { padding: 18px 20px 24px; }
.assistant-screen.embedded .assistant-welcome { padding: 0 0 12px; }
.assistant-embedded-actions { display: flex; justify-content: flex-end; flex: none; padding: 8px 16px 0; }
.assistant-embedded-actions .ghost { min-height: 32px; padding: 4px 10px; font-size: .82rem; }
.assistant-ask-welcome > p { margin: 14px 0; }
.assistant-context { display: grid; gap: 8px; max-width: 100%; margin: 0 0 10px; padding: 14px 16px; border: 1px solid var(--border); border-inline-start: 3px solid var(--accent); border-radius: 14px; background: var(--surface-subtle); text-align: start; }
.assistant-message.is-user .assistant-context { margin-inline-start: auto; }
.assistant-context p { margin: 0; overflow-wrap: anywhere; }
.assistant-context-label { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: .72rem; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; }
.assistant-context-title { font-size: .95rem; }
.assistant-context-text { font-size: 1.08rem; line-height: 1.6; }
.assistant-context-word { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font-size: 1.15rem; }
.assistant-context-note { font-size: .82rem; }
.assistant-context-prompt { font-weight: 600; }
.assistant-context-answer { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: .9rem; overflow-wrap: anywhere; }
.assistant-context-answer > .muted:first-child { flex: none; font-size: .75rem; font-weight: 600; }
.assistant-context .structure-pattern { margin-top: 2px; }
.textbook-section-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.textbook-section-meta .ask-about { margin-inline-start: auto; }
.dictionary-meaning-actions, .structure-example-actions { align-items: center; margin: 8px 0 0; }
.assistant-new { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; padding: 8px 12px; font-size: .8rem; }
/* Keep positioned message content, including screen-reader labels, inside the history. */
.assistant-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.assistant-thread { width: min(800px, 100%); margin: 0 auto; padding: 24px 26px 36px; }
.assistant-welcome { padding: clamp(12px, 5vh, 64px) 0 24px; }
.assistant-brand { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 16%, var(--border)); margin-bottom: 24px; }
.assistant-welcome h2 { font-size: clamp(1.55rem, 3vw, 2rem); line-height: 1.25; letter-spacing: -.025em; margin: 0 0 14px; }
.assistant-welcome > p { line-height: 1.65; max-width: 560px; }
.assistant-starters { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin: 30px 0 24px; }
button.assistant-starter { display: flex; align-items: center; text-align: start; gap: 12px; padding: 18px; min-height: 78px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: none; font-size: .86rem; font-weight: 600; }
.assistant-starter > svg:first-child { color: var(--text-secondary); flex: none; }
.assistant-starter > svg:last-child { margin-inline-start: auto; opacity: .5; flex: none; }
@media (hover: hover) and (pointer: fine) { button.assistant-starter:hover { border-color: var(--text-secondary); background: var(--surface-subtle); transform: translateY(-1px); } }
.assistant-message { display: flex; gap: 14px; margin: 0 0 30px; }
.assistant-message-avatar { width: 30px; height: 30px; display: grid; place-items: center; flex: none; border: 1px solid var(--border); border-radius: 10px; color: var(--text-secondary); margin-top: 5px; }
.assistant-message-content { flex: 1; min-width: 0; }
.assistant-message.is-user { justify-content: flex-end; margin-top: 12px; }
.assistant-message.is-user .assistant-message-content { max-width: 86%; flex: initial; }
.assistant-user-text { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 20px 20px 4px 20px; padding: 14px 20px; line-height: 1.7; }
.assistant-markdown { line-height: 1.8; font-size: .94rem; overflow-wrap: anywhere; }
.assistant-markdown > :first-child { margin-top: 0; }
.assistant-markdown > :last-child { margin-bottom: 0; }
.assistant-markdown p { margin: 0 0 14px; }
.assistant-markdown h1,.assistant-markdown h2,.assistant-markdown h3 { font-size: 1.1rem; margin: 20px 0 10px; }
.assistant-markdown ul,.assistant-markdown ol { padding-inline-start: 24px; margin: 12px 0; }
.assistant-markdown li { margin: 5px 0; }
.assistant-markdown pre { padding: 16px; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; white-space: pre; }
.assistant-markdown code { font-size: .85em; background: var(--surface-subtle); border-radius: 4px; padding: 2px 4px; }
.assistant-markdown pre code { padding: 0; background: none; }
.assistant-markdown blockquote { margin-inline: 0; padding-inline-start: 16px; border-inline-start: 3px solid var(--border); color: var(--text-secondary); }
.assistant-message-actions { display: flex; align-items: center; gap: 4px; margin-top: 8px; }
.assistant-message-actions .icon-button { width: 30px; min-width: 30px; height: 30px; border: 0; background: transparent; color: var(--text-secondary); }
.assistant-message.is-user .assistant-message-actions { justify-content: flex-end; }
.assistant-activity { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: .78rem; margin: 12px 0; }
.assistant-composer-area { position: relative; flex: none; width: min(800px, 100%); align-self: center; padding: 0 26px max(12px, env(safe-area-inset-bottom)); }
.assistant-composer { border: 1px solid var(--border); border-radius: 22px; background: var(--surface); padding: 10px 12px; box-shadow: 0 5px 24px #00000008; }
.assistant-composer:focus-within { border-color: color-mix(in srgb,var(--text-secondary) 60%,var(--border)); }
.assistant-composer textarea { display: block; width: 100%; min-height: 48px; max-height: 180px; height: 48px; padding: 10px 8px; resize: none; margin: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; font: inherit; line-height: 1.6; }
.assistant-composer textarea:focus { outline: none; box-shadow: none; }
.assistant-composer-toolbar { display: flex; gap: 8px; align-items: center; min-height: 40px; }
.assistant-composer-status { flex: 1; font-size: .66rem; color: var(--text-secondary); padding-inline-start: 6px; }
.assistant-composer .reader-flashcard-microphone { margin: 0; padding: 0; border: 0; background: transparent; flex: none; }
.assistant-composer .reader-flashcard-toolbar { margin: 0; gap: 0; }
.assistant-composer .reader-flashcard-toolbar meter { display: none; }
.assistant-composer .flashcard-mic-button { min-width: 38px; width: 38px; height: 38px; border: 0; background: transparent; box-shadow: none; }
.assistant-composer .flashcard-mic-button[aria-pressed="true"] { background: var(--surface-subtle); color: var(--danger); }
.assistant-composer .reader-flashcard-toolbar .ghost { padding: 6px 8px; min-height: 32px; font-size: .7rem; }
.assistant-composer:has(.reader-flashcard-microphone[data-state="hold"]) .assistant-composer-status { font-size: 0; }
button.assistant-send { display: grid; place-items: center; flex: none; width: 38px; height: 38px; min-width: 38px; padding: 0; border-radius: 50%; }
button.assistant-jump { position: absolute; top: -52px; inset-inline-start: calc(50% - 19px); width: 38px; min-width: 38px; height: 38px; padding: 0; display: grid; place-items: center; border-radius: 50%; box-shadow: 0 3px 15px #0002; }
button.assistant-jump[hidden] { display: none; }
.assistant-editing,.assistant-connection,.assistant-send-error,.assistant-dictation-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .75rem; padding: 10px 4px; }
.assistant-send-error { color: var(--danger); }
.assistant-dictation-status { color: var(--text-secondary); }
.assistant-editing .ghost,.assistant-connection .ghost,.assistant-send-error .ghost { flex: none; font-size: .75rem; padding: 6px; }
.assistant-loading { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 80px 20px; color: var(--text-secondary); }
button.assistant-open-card { display: flex; width: 100%; align-items: center; text-align: start; gap: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 16px; margin: 16px 0 4px; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .assistant-open-card:hover { background: var(--surface-subtle); border-color: var(--text-secondary); } }
.assistant-card-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-subtle); display: grid; place-items: center; flex: none; }
.assistant-open-card > span:nth-child(2) { flex: 1; min-width: 0; }
.assistant-open-card strong { display: block; font-size: .87rem; line-height: 1.5; }
.assistant-open-card small { display: block; font-size: .74rem; line-height: 1.6; font-weight: 400; margin-top: 3px; }
.assistant-open-card > svg { flex: none; }
.assistant-target-text { margin: 16px 0; padding: 16px 18px 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.assistant-target-text-context { margin: 0 0 10px; color: var(--text-secondary); font-size: .8rem; line-height: 1.6; overflow-wrap: anywhere; }
.assistant-target-text-content { font-size: 1.08rem; line-height: 2; overflow-wrap: anywhere; white-space: pre-wrap; }
.assistant-target-text-actions { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.assistant-target-text-actions .speech-control { font-size: .78rem; }
.assistant-proposal { margin: 20px 0 12px; padding: 20px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); }
.assistant-proposal[data-status="pending"] { border-color: color-mix(in srgb,var(--accent) 35%,var(--border)); }
.assistant-proposal[data-status="declined"] { opacity: .65; }
.assistant-proposal-badge { display: inline-flex; align-items: center; gap: 7px; font-size: .68rem; font-weight: 600; color: var(--text-secondary); }
.assistant-proposal[data-status="accepted"] .assistant-proposal-badge { color: var(--accent); }
.assistant-proposal h3 { margin: 10px 0 16px; font-size: 1rem; line-height: 1.5; }
.assistant-proposal p { line-height: 1.7; font-size: .85rem; }
.assistant-proposal .assistant-proposal-note { font-size: .72rem; color: var(--text-secondary); }
.assistant-proposal-space { display: flex; align-items: center; gap: 7px; margin: 10px 0 0; font-size: .72rem; color: var(--text-secondary); }
.assistant-proposal-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 18px; }
.assistant-proposal-actions > small { flex: 1; min-width: 120px; font-size: .67rem; }
.assistant-proposal-actions > button { padding: 9px 14px; min-height: 38px; font-size: .8rem; }
.assistant-list-preview { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface-subtle); border-radius: 10px; }
.assistant-list-preview > span { font-size: 1.7rem; }
.assistant-goal-preview > strong { font-size: 2rem; font-variant-numeric: tabular-nums; color: var(--accent); }
.assistant-passage-preview summary { cursor: pointer; font-size: .8rem; color: var(--text-secondary); padding-bottom: 12px; }
.assistant-passage-preview > div { max-height: 320px; overflow-y: auto; white-space: pre-wrap; font-size: .92rem; line-height: 1.9; padding: 14px 16px; border-radius: 10px; background: var(--surface-subtle); }
.assistant-word-selection { display: flex; align-items: center; gap: 4px; font-size: .7rem; margin-bottom: 10px; }
.assistant-word-selection > span { flex: 1; color: var(--text-secondary); }
.assistant-word-selection > button { padding: 5px 7px; font-size: .7rem; }
.assistant-proposed-words { max-height: 350px; overflow-y: auto; }
:is(label, div).assistant-proposed-word { display: flex; align-items: center; gap: 12px; margin: 0; padding: 12px 0; border-bottom: 1px solid var(--border); font-weight: 400; }
.assistant-proposed-word:last-child { border-bottom: 0; }
.assistant-proposed-word input { width: 17px; height: 17px; margin: 0; padding: 0; flex: none; accent-color: var(--accent); }
.assistant-proposed-word span { flex: 1; min-width: 0; font-size: .8rem; }
.assistant-proposed-word strong { display: block; font-size: .95rem; }
.assistant-proposed-word small { display: block; font-size: .7rem; margin-top: 4px; }
.assistant-history { display: grid; gap: 8px; }
button.assistant-history-item { display: flex; width: 100%; min-width: 0; text-align: start; align-items: center; gap: 10px; color: var(--text); background: transparent; border: 1px solid var(--border); box-shadow: none; padding: 12px; border-radius: 10px; }
.assistant-history-item > svg { flex: none; }
.assistant-history-item > strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
button.assistant-history-item[aria-current="page"] { background: var(--surface-subtle); }
#assistant-settings form .form-actions { margin-block-start: 16px; }
.assistant-archived-message { padding: 20px 0; border-top: 1px solid var(--border); }
.assistant-archived-message > strong { display: block; margin-bottom: 12px; font-size: .8rem; color: var(--text-secondary); }
button.assistant-archive-link { font-size: .72rem; color: var(--text-secondary); }
@media (max-width: 760px) {
    .app-shell > .workspace:has(.assistant-screen:not(.embedded)) { padding: 0; }
    .assistant-screen { min-height: 0; }
    .assistant-heading { padding: 12px 16px; gap: 8px; }
    .assistant-heading h1 { max-width: 100%; font-size: 1rem; }
    .assistant-heading-actions { gap: 3px; }
    .assistant-new { min-width: 36px; padding: 8px; }
    .assistant-new > span { display: none; }
    .assistant-thread { padding: 24px 16px; }
    .assistant-welcome { padding-top: 20px; }
    .assistant-brand { width: 52px; height: 52px; margin-bottom: 20px; }
    .assistant-starters { gap: 8px; margin-top: 24px; }
    button.assistant-starter { padding: 14px 12px; gap: 8px; font-size: .75rem; min-height: 80px; }
    .assistant-starter > svg:last-child { display: none; }
    .assistant-message { gap: 8px; }
    .assistant-message-avatar { width: 24px; height: 24px; }
    .assistant-screen:not(.embedded) .assistant-welcome { padding: 20px 16px; border-radius: 20px; }
    .assistant-screen:not(.embedded) .is-assistant > .assistant-message-content { padding: 14px; border-radius: 4px 18px 18px; }
    .assistant-message.is-user .assistant-message-content { max-width: 94%; }
    .assistant-composer-area { padding-inline: 10px; }
    .assistant-composer-status { font-size: .6rem; }
    .assistant-proposal { padding: 14px; }
    .assistant-word-selection { flex-wrap: wrap; }
    .assistant-proposal-actions > small { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
    @media (hover: hover) and (pointer: fine) { button.assistant-starter:hover { transform: none; } }
}

/* Shared XP activity colors: identical in chart segments, legend and receipts. */
.xp-history-chart, .xp-log-card { --xp-flashcards: #428ec9; --xp-reading: var(--xp); --xp-skills: #aa78ca; --xp-quests: #d6a23a; }
[data-activity="flashcards"] { --xp-activity-color: var(--xp-flashcards); }
[data-activity="guided_reading"] { --xp-activity-color: var(--xp-reading); }
[data-activity="skills"] { --xp-activity-color: var(--xp-skills); }
[data-activity="quests"] { --xp-activity-color: var(--xp-quests); }
[data-activity="character_practice"] { --xp-activity-color: #3b9e7a; }
[data-activity="comprehension"] { --xp-activity-color: #cf718c; }
[data-activity="audio_coaching"] { --xp-activity-color: #d19a43; }
[data-activity="podcasts"] { --xp-activity-color: #4c9eae; }
[data-activity="other"] { --xp-activity-color: var(--muted); }
.xp-activity-segment { fill: var(--xp-activity-color); }
.xp-activity-swatch { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 3px; background: var(--xp-activity-color); }
.xp-chart-cursor { fill: var(--text); opacity: .06; }
.xp-chart-total { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 20px; font-size: .8rem; }
.xp-chart-total strong { color: var(--xp); font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.xp-chart-readout { justify-content: space-between; border-top: 1px solid var(--border); }
.xp-chart-legend { justify-content: flex-start; gap: 12px 24px; margin-top: 8px; }
.xp-chart-legend strong { margin-left: 4px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.xp-chart-loading { min-height: 360px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.xp-log-scroll { max-height: 510px; overflow: auto; }
.xp-log-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.xp-log-table caption.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.xp-log-table th { position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--muted); text-align: start; padding: 10px 12px; font-size: .72rem; font-weight: 600; }
.xp-log-table td { border-top: 1px solid var(--border); padding: 13px 12px; vertical-align: middle; }
.xp-log-table th:first-child, .xp-log-table td:first-child { padding-inline-start: 0; }
.xp-log-table th:last-child, .xp-log-table td:last-child { text-align: end; padding-inline-end: 0; }
.xp-log-table time { display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.xp-log-table time small { color: var(--muted); font-size: .72rem; }
.xp-log-activity { display: inline-flex; align-items: center; gap: 8px; }
.xp-log-amount { color: var(--xp); font-size: 1rem; font-variant-numeric: tabular-nums; }
.xp-log-footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; }
.xp-log-footer small { font-size: .75rem; }
@media (max-width: 600px) {
  .xp-log-table td { padding: 12px 8px; }
  .xp-log-table { font-size: .78rem; }
  .xp-chart-readout strong { font-size: .74rem; }
  .xp-chart-legend { font-size: .72rem; gap: 10px 14px; }
}
.xp-chart-loading .word-illustration-spinner { width: 20px; height: 20px; }
.xp-log-footer .word-illustration-spinner { width: 14px; height: 14px; }

/* Phrases: sentence collections and a focused recall practice surface. */
.phrases-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.phrases-heading h1 { margin-bottom: 8px; }
.phrases-heading p { margin: 0; font-size: .9rem; }
.phrases-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin: 28px 0; }
.phrases-toolbar > button,.phrases-toolbar > a { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; font-size: .85rem; }
.phrases-toolbar > a { margin-inline-start: auto; }
.phrase-list-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin: 20px 0 30px; }
a.phrase-list-card { display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 6px 10px; padding: 22px; text-decoration: none; color: var(--text); transition: border-color .15s; }
.phrase-list-card > svg { grid-row: span 2; color: var(--accent); margin-top: 3px; }
.phrase-list-card strong { overflow-wrap: anywhere; font-size: .95rem; }
.phrase-list-card small { font-size: .76rem; }
@media (hover: hover) and (pointer: fine) { a.phrase-list-card:hover { border-color: var(--accent); } }
.phrase-list-create { padding: 18px 20px; display: flex; flex-direction: column; gap: 8px; }
.phrase-list-create label { margin: 0; font-size: .75rem; }
.phrase-list-create input { margin-top: 6px; padding: 8px 10px; }
.phrase-list-create button { min-height: 32px; padding: 6px 12px; align-self: flex-start; font-size: .75rem; }
.phrase-filters { display: flex; align-items: center; gap: 20px; margin: 24px 0 18px; }
.phrase-filters > input { flex: 1; min-width: 0; margin: 0; }
.phrase-filters > label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .8rem; font-weight: 400; white-space: nowrap; }
.phrase-filters input[type="checkbox"],.phrase-practice-status input[type="checkbox"],.phrase-suggestion-row > input { width: 17px; height: 17px; margin: 0; padding: 0; flex: none; accent-color: var(--accent); }
.phrase-entries { display: grid; gap: 14px; }
.phrase-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding: 24px; }
.phrase-card-copy { flex: 1; min-width: 0; }
:is(.phrase-card, .phrase-row) p { margin: 0 0 8px; overflow-wrap: anywhere; }
:is(.phrase-card, .phrase-row) p.muted { font-size: .8rem; }
.phrase-search input[type="checkbox"] { width: 17px; height: 17px; margin: 0; padding: 0; flex: none; accent-color: var(--accent); }
.phrase-sentence { font-size: 1.12rem; line-height: 1.8; letter-spacing: .005em; overflow-wrap: anywhere; }
.phrase-reading { font-size: .85rem; line-height: 1.7; }
.phrase-card-actions { display: flex; align-items: center; gap: 6px; flex: none; padding-top: 3px; }
.phrase-card-actions .speech-control { font-size: .78rem; }
.phrase-region-tags,.phrase-membership-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.phrase-region-tags .tag { font-size: .68rem; white-space: normal; text-align: start; }
.phrase-membership-tags { margin-top: 10px; }
.phrase-membership-tags .tag { font-size: .65rem; background: var(--surface-subtle); color: var(--text-secondary); }
.phrase-back,.phrase-source { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: .8rem; }
.phrase-source { margin-top: 8px; font-size: .72rem; }
.phrase-empty { padding: clamp(28px,5vw,56px); text-align: center; }
.phrase-empty > svg { color: var(--accent); margin-bottom: 16px; }
.phrase-empty h2 { font-size: 1.3rem; margin: 0 0 12px; }
.phrase-empty p { line-height: 1.8; font-size: .9rem; max-width: 480px; margin: 0 auto 20px; }
.phrase-empty > button,.phrase-empty > a { margin: 6px; }
.phrase-editor { display: grid; gap: 16px; }
.phrase-editor > label { margin: 0; font-size: .85rem; }
.phrase-editor textarea,.phrase-editor input { margin: 6px 0 0; }
.phrase-editor textarea { resize: vertical; }
.phrase-editor fieldset { min-width: 0; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.phrase-editor legend { padding-inline: 6px; font-size: .85rem; font-weight: 600; }
.phrase-editor fieldset > p { font-size: .8rem; }
.phrase-editor input[type="checkbox"] { margin: 0; }
.phrase-new-list { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.phrase-new-list input { min-width: 0; flex: 1; margin: 0; }
.phrase-new-list button { font-size: .75rem; padding: 8px 12px; flex: none; }
.phrase-region-editor { padding: 14px 0; border-block: 1px solid var(--border); }
.phrase-region-editor summary { cursor: pointer; font-size: .85rem; font-weight: 600; }
.phrase-region-editor > p { font-size: .78rem; line-height: 1.7; }
.phrase-region-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin: 10px 0; font-weight: 400; font-size: .8rem; }
.phrase-region-row select { width: 150px; margin: 0; padding: 8px; font-size: .8rem; }
.phrase-editor-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
button.phrase-starter-choice { display: flex; align-items: flex-start; flex-direction: column; gap: 6px; padding: 20px; text-align: start; white-space: normal; color: var(--text); }
.phrase-starter-choice[aria-pressed="true"] { border-color: var(--accent); background: color-mix(in srgb,var(--accent) 8%,var(--surface)); }
.phrase-starter-choice strong { font-size: .95rem; }
.phrase-starter-choice small { color: var(--accent); font-size: .72rem; }
.phrase-starter-choice span { font-size: .78rem; font-weight: 400; line-height: 1.6; color: var(--text-secondary); }
.phrase-starter-preview { max-height: 44dvh; overflow: auto; border-block: 1px solid var(--border); margin-bottom: 20px; padding-inline-end: 12px; }
.phrase-starter-preview > div { padding: 16px 0; border-bottom: 1px solid var(--border); }
.phrase-starter-preview p { margin: 0 0 6px; }
.phrase-starter-preview p:not(.phrase-sentence) { font-size: .85rem; }
.phrase-suggestion-form { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: end; gap: 14px; margin: 24px 0; }
.phrase-suggestion-form label { margin: 0; font-size: .8rem; }
.phrase-suggestion-form input,.phrase-suggestion-form select { margin-bottom: 0; }
.phrase-suggestion-form > button { justify-self: end; }
.phrase-suggestions { margin: 16px 0 24px; }
label.phrase-suggestion-row { display: flex; align-items: flex-start; gap: 14px; padding: 18px 0; border-top: 1px solid var(--border); font-weight: 400; margin: 0; }
.phrase-suggestion-row > input { margin-top: 10px; }
.phrase-suggestion-row > div { flex: 1; min-width: 0; }
.phrase-suggestion-row p { margin: 0 0 6px; }
.phrase-suggestion-row p:not(.phrase-sentence) { font-size: .84rem; }
.phrase-practice { max-width: 760px; margin-inline: auto; }
.phrase-practice > .page-header { margin-top: 24px; }
.phrase-practice-status { display: flex; justify-content: space-between; gap: 16px; font-size: .8rem; color: var(--text-secondary); }
.phrase-practice-status label { display: flex; gap: 8px; align-items: center; font-size: .8rem; font-weight: 400; margin: 0; }
.phrase-practice > progress { width: 100%; height: 5px; accent-color: var(--accent); margin: 16px 0 28px; }
.phrase-practice-card { text-align: center; padding: clamp(24px,5vw,48px); }
.phrase-practice-card > .eyebrow { color: var(--text-secondary); font-size: .7rem; margin: 0 0 24px; }
.phrase-prompt { font-size: clamp(1.3rem,3vw,1.8rem); line-height: 1.8; margin: 24px 0 36px; overflow-wrap: anywhere; }
.phrase-practice-card > .phrase-sentence { margin-bottom: 24px; font-size: 1.4rem; line-height: 2; }
.phrase-practice-card .phrase-region-tags { justify-content: center; margin-bottom: 20px; }
.phrase-practice-card > .speech-control { margin: 8px 0 20px; }
.phrase-practice-card > p.muted { margin-top: 28px; font-size: .85rem; }
.phrase-ratings { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-top: 18px; }
.phrase-ratings button { min-height: 48px; padding: 10px; }
@media (max-width: 900px) { .phrase-list-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 600px) {
    .phrases-toolbar { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
    .phrases-toolbar > button,.phrases-toolbar > a { margin: 0; width: 100%; padding: 10px 8px; font-size: .75rem; }
    .phrase-list-grid { grid-template-columns: minmax(0,1fr); }
    .phrase-filters { align-items: stretch; flex-direction: column; gap: 12px; }
    .phrase-card { flex-direction: column; padding: 20px; gap: 12px; }
    .phrase-card-actions { align-self: flex-end; padding: 0; }
    .phrase-region-row { gap: 8px; }
    .phrase-region-row select { width: 140px; }
    .phrase-ratings { gap: 6px; }
    .phrase-ratings button { font-size: .78rem; padding-inline: 4px; }
}

@media(max-height:650px){.roleplay-loading-frame{align-items:start;padding-top:110px}.roleplay-loading-card{max-height:calc(100dvh - 130px)}.roleplay-loading-content{padding:24px}.roleplay-loading-mark{width:48px;height:48px}}

/* Saved helper notes stay at the scene edges; compact screens open the same notes in a panel. */
.roleplay-study-card{position:absolute;top:150px;width:clamp(190px,19vw,260px);max-height:calc(100% - 270px);overflow:auto;padding:18px;overscroll-behavior:contain}
.roleplay-study-card[data-kind="key_words"]{left:max(22px,env(safe-area-inset-left))}
.roleplay-study-card[data-kind="useful_phrases"]{right:max(22px,env(safe-area-inset-right))}
.roleplay-study-card h3{font-size:.9rem;margin:0 0 12px}
.roleplay-help-entries{display:grid;gap:14px;margin:0;padding:0;list-style:none}
.roleplay-help-entries li{display:grid;gap:3px;overflow-wrap:anywhere}
.roleplay-help-entries strong{font-size:1.05rem;font-weight:650}
.roleplay-help-entries small{color:var(--muted);font-size:.85rem;line-height:1.4}
.roleplay-help-entries li>span{font-size:.85rem;line-height:1.5}
.roleplay-help-review+.roleplay-help-review{margin-top:24px;padding-top:20px;border-top:1px solid var(--border)}
.roleplay-partner>div{flex:1;min-width:0}
.roleplay-stage .roleplay-level-button{margin-inline-start:auto;padding:8px 10px;min-height:40px;display:flex;align-items:center;gap:8px;font-size:.8rem}
@media(max-width:700px){.roleplay-stage>.reader-popup-heading{width:calc(100% - 232px)}}

/* Role-play chrome stays anchored; captions never participate in dock layout.
   Each scrim filters the scene directly (no opaque parent surface). */
.roleplay-glass,.reader-popup.roleplay-panel,.roleplay-stage>.reader-popup-heading {
  background:rgba(18,18,18,.58);
  backdrop-filter:blur(32px) saturate(.85);
  -webkit-backdrop-filter:blur(32px) saturate(.85);
}
.roleplay-stage>.reader-popup-heading {
  top:max(16px,env(safe-area-inset-top));right:max(16px,env(safe-area-inset-right));left:auto;
  width:auto;padding:6px;gap:0;border-radius:16px;
}
.roleplay-stage>.reader-popup-heading h2 {display:none}
.roleplay-edge-tools {
  top:max(16px,env(safe-area-inset-top));left:max(16px,env(safe-area-inset-left));right:auto;
  flex-direction:row;gap:4px;padding:6px;border-radius:16px;
}
.roleplay-edge-tools .icon-button {background:transparent;border:0}
button.roleplay-goal {left:50%;width:min(490px,calc(100% - 450px));gap:6px 20px}
.roleplay-goal-progress {grid-column:2;grid-row:1/3}
.roleplay-dock {overflow:visible;max-height:none}
.roleplay-caption {
  position:absolute;bottom:calc(100% + 12px);left:4px;width:calc(100% - 8px);
  padding:16px 20px;display:grid;gap:10px;
}
.roleplay-caption:has(.coach-live-caption:empty):not(:has(button)) {display:none}
.roleplay-caption .coach-live-caption {
  min-height:0;margin:0;font-size:1.1rem;line-height:1.55;text-align:center;white-space:pre-wrap;
  overflow-wrap:anywhere;max-height:min(22dvh,180px);overflow-y:auto;overscroll-behavior:contain;
}
.roleplay-caption .coach-live-caption:empty {display:none}
.roleplay-objective-support {
  position:absolute;z-index:4;top:155px;width:clamp(210px,22vw,300px);
  display:grid;gap:10px;pointer-events:none;
}
.roleplay-objective-support[data-kind="key_words"] {left:max(22px,env(safe-area-inset-left));justify-items:start}
.roleplay-objective-support[data-kind="useful_phrases"] {right:max(22px,env(safe-area-inset-right));justify-items:end}
.roleplay-objective-support>* {pointer-events:auto}
.roleplay-stage .roleplay-support-toggle {display:flex;gap:10px;align-items:center;min-height:48px;padding:12px 16px;font-size:.85rem}
.roleplay-support-panel {width:100%;padding:18px;max-height:calc(100dvh - 300px);overflow:auto;overscroll-behavior:contain}
.roleplay-support-panel>header {display:flex;align-items:center;gap:8px;margin-bottom:14px}
.roleplay-support-panel h3 {flex:1;margin:0;font-size:.85rem;line-height:1.4;color:var(--muted)}
.roleplay-stage .roleplay-study-button {display:flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:44px;margin-top:20px;background:#f2f2f2;color:#111;border-radius:12px}
.roleplay-help-entries .inline-reader {font-size:inherit}
/* Pending words stay readable on scene scrims, with only a slight dimming. */
:is(.roleplay-stage,.roleplay-panel) .reader-unprocessed {color:var(--text);opacity:.8}
@media(max-width:1000px) {
  button.roleplay-goal {top:90px;width:min(490px,calc(100% - 32px))}
  .roleplay-objective-support {top:210px;width:min(300px,calc(100vw - 32px))}
  .roleplay-objective-support[data-kind="key_words"] {left:16px}
  .roleplay-objective-support[data-kind="useful_phrases"] {right:16px}
  .roleplay-support-panel {max-height:calc(100dvh - 370px);min-height:120px}
  .roleplay-objective-support:has(.roleplay-support-panel) {z-index:5}
}
@media(max-width:700px) {
  .roleplay-stage>.reader-popup-heading {left:auto;right:max(12px,env(safe-area-inset-right));width:auto;padding:6px;top:max(12px,env(safe-area-inset-top))}
  .roleplay-edge-tools {left:max(12px,env(safe-area-inset-left));top:max(12px,env(safe-area-inset-top));right:auto}
  .roleplay-caption {padding:12px;bottom:calc(100% + 8px)}
  .roleplay-caption .coach-live-caption {font-size:1rem;max-height:16dvh}
  .roleplay-support-toggle {max-width:calc(50vw - 24px)}
}
@media(max-height:540px) and (min-width:701px) {
  button.roleplay-goal {top:16px;width:min(420px,calc(100% - 450px))}
  .roleplay-objective-support {top:110px;width:210px}
  .roleplay-support-panel {max-height:calc(100dvh - 190px);min-height:90px}
  .roleplay-caption .coach-live-caption {max-height:12dvh}
  .roleplay-caption {padding:10px 14px;gap:4px}
}

@media(max-height:600px) and (max-width:700px) {
  button.roleplay-goal {top:76px;padding:8px 12px}
  .roleplay-goal strong {font-size:.8rem;line-height:1.3;max-height:2.6em}
  .roleplay-dock {gap:6px}
  .roleplay-partner {padding:6px 12px}
  .roleplay-stage .roleplay-level-button {min-height:32px;padding:4px 8px}
  .roleplay-live-controls {padding:8px 12px}
  .roleplay-control-row {flex-wrap:nowrap;gap:8px;justify-content:space-between}
  .roleplay-audio-state {flex:0 1 auto;text-align:start}
  .roleplay-audio-state>svg {display:none}
  .roleplay-stage .coach-start {width:auto;min-height:40px;padding:8px 12px}
  .roleplay-caption {padding:8px 12px;gap:2px}
  .roleplay-caption .coach-live-caption {font-size:.9rem;max-height:42px;line-height:1.4}
  .roleplay-objective-support {top:156px}
  .roleplay-stage .roleplay-support-toggle {padding:8px 12px;min-height:40px;font-size:.75rem}
  .roleplay-support-panel {max-height:calc(100dvh - 210px);min-height:90px;padding:12px}
}

@media(max-height:400px) and (max-width:700px) {
  .roleplay-partner>div>span {display:none}
  button.roleplay-goal {top:74px;padding:8px 12px}
  .roleplay-goal .eyebrow {display:none}
  .roleplay-goal strong {max-height:1.3em;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}
  .roleplay-goal-progress {grid-row:1}
  .roleplay-caption {left:50%;transform:translateX(-50%);width:max(170px,calc(100% - 280px));padding:8px 10px;gap:0}
  .roleplay-caption .coach-live-caption {max-height:36px;font-size:.8rem}
  .roleplay-objective-support {top:144px}
}

/* Stable role-play input dock: persistent typing, independent mic and transport. */
.roleplay-partner-controls {display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:12px;width:100%;min-width:0}
.roleplay-partner-controls>.roleplay-partner {grid-column:2;min-width:0}
.roleplay-stage .roleplay-display-toggles {grid-column:1;grid-row:1;justify-self:start;margin:0;gap:4px;padding:6px;border-radius:20px;--accent-ink:#f5f5f5;--accent-soft:rgba(255,255,255,.16)}
.roleplay-stage .roleplay-display-toggles>.icon-button {width:44px;height:44px;min-width:44px;padding:10px;border-radius:16px;color:var(--text)}
.roleplay-stage .roleplay-display-toggles>.icon-button[aria-pressed=true] {background:rgba(255,255,255,.16);box-shadow:inset 0 0 0 1px rgba(255,255,255,.22)}
.roleplay-stage :is(.roleplay-partner-controls,.roleplay-caption,.coach-live-caption)[hidden] {display:none}
.roleplay-live-controls .roleplay-control-row {display:flex;flex-wrap:nowrap;justify-content:center;gap:18px}
.roleplay-stage .roleplay-play {display:grid;place-items:center;width:68px;height:68px;min-width:68px;min-height:68px;padding:18px;border-radius:50%;background:#f2f2f2;color:#111}
.roleplay-stage .roleplay-play>span {grid-area:1/1;display:flex}
.roleplay-stage .roleplay-play .sr-only {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;padding:0;margin:-1px}
.roleplay-stage .roleplay-play .roleplay-stop-icon {display:none}
.roleplay-voice-pulse {width:44px;height:44px;flex:0 0 44px;display:grid;place-items:center}
.roleplay-voice-pulse::after {content:"";width:16px;height:16px;border-radius:50%;background:#b9e1cf;opacity:0;transform:scale(.75)}
.roleplay-live-controls[data-live=true] .roleplay-voice-pulse::after {opacity:1;animation:roleplay-voice-pulse 1.8s ease-in-out infinite}
@keyframes roleplay-voice-pulse {50% {transform:scale(1.15);box-shadow:0 0 0 8px rgba(185,225,207,.12)}}
.roleplay-stage .roleplay-mute {position:relative;width:44px;height:44px;min-width:44px;border-radius:50%;padding:11px}
.roleplay-mute-slash {display:none;position:absolute;width:24px;height:2px;background:currentColor;transform:rotate(-45deg);border-radius:2px}
.roleplay-mute[aria-pressed=true] .roleplay-mute-slash {display:block}
.roleplay-mute[aria-pressed=true] {background:rgba(255,255,255,.18)}
.roleplay-caption {display:grid;grid-template-columns:44px minmax(0,1fr);align-items:center;gap:12px}
.roleplay-caption .coach-live-caption {grid-area:1/2}
.roleplay-caption-study {grid-area:1/2;min-width:0;max-height:min(30dvh,240px);overflow:auto;overscroll-behavior:contain;font-size:1.1rem;line-height:1.55;text-align:center}
.roleplay-caption-study .reader-sentence-translation {margin:.4em 0 0;color:var(--muted)}
.roleplay-caption-study .inline-reader-text {white-space:pre-wrap}
.roleplay-connection-error:not([hidden]) {color:#ffb5ae;margin:0 0 12px;font-size:.85rem}
@media(prefers-reduced-motion:reduce){.roleplay-live-controls[data-live=true] .roleplay-voice-pulse::after{animation:none;transform:none}}
@media(max-width:700px){
  .roleplay-partner-controls {grid-template-columns:1fr 1fr;gap:8px}
  .roleplay-partner-controls>.roleplay-partner {grid-area:1/1/2/3;justify-self:center;max-width:100%;padding:8px 12px}
  .roleplay-partner-controls>.roleplay-display-toggles {grid-area:2/1}
  .roleplay-partner strong {overflow-wrap:anywhere}
  .roleplay-caption {padding:10px;gap:8px}
  .roleplay-type {gap:8px}
  .roleplay-stage .roleplay-type button {padding:10px 14px}
  .roleplay-type input {padding:10px 12px}
}
@media(max-height:600px){
  .roleplay-stage .roleplay-play {width:52px;height:52px;min-width:52px;min-height:52px;padding:12px}
  .roleplay-type {margin-top:8px}
  .roleplay-caption {left:4px;transform:none;width:calc(100% - 8px)}
}

/* Sound radiates behind the character only during partner audio playback. */
.roleplay-sound-waves {opacity:0;pointer-events:none;transition:opacity .25s ease}
.roleplay-sound-waves ellipse {fill:none;stroke:#d3e7df;stroke-width:1.5;vector-effect:non-scaling-stroke;transform-box:fill-box;transform-origin:center;opacity:0}
.roleplay-stage:has(.roleplay-live-controls[data-state="speaking"]) .roleplay-sound-waves {opacity:1}
.roleplay-stage:has(.roleplay-live-controls[data-state="speaking"]) .roleplay-sound-waves ellipse {animation:roleplay-sound-ripple 2.8s ease-out infinite;animation-delay:var(--wave-delay,0s)}
.roleplay-stage .roleplay-sound-waves ellipse:nth-child(2) {--wave-delay:-.93s}
.roleplay-stage .roleplay-sound-waves ellipse:nth-child(3) {--wave-delay:-1.86s}
@keyframes roleplay-sound-ripple {0% {transform:scale(.85);opacity:0} 18% {opacity:.24} 100% {transform:scale(2.7);opacity:0}}
@media(prefers-reduced-motion:reduce){.roleplay-sound-waves{display:none;transition:none}.roleplay-stage .roleplay-sound-waves ellipse{animation:none!important}}

/* The transcript itself is one accessible inspect action with a lighter scrim. */
.roleplay-stage .roleplay-caption {background:rgba(18,18,18,.32);border:0;box-shadow:none;color:var(--text);font-weight:400;text-transform:none;opacity:1}
@media (hover: hover) and (pointer: fine) { .roleplay-stage .roleplay-caption:hover:not(:disabled) {background:rgba(18,18,18,.42)} }
.roleplay-stage .roleplay-caption:has(.coach-live-caption:empty) {display:none}

/* Dictionary paradigms: grammar belongs to the headers, forms to the cells. */
.form-tables { display: grid; gap: 20px; min-width: 0; }
.form-table-scroll { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.form-table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: start; font-size: .94rem; }
.form-table caption { padding: 16px 18px; text-align: start; background: var(--surface); }
.form-table caption strong { display: block; font-size: 1rem; color: var(--text); }
.form-table caption span { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; }
.form-table th, .form-table td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: middle; text-align: start; }
.form-table thead th { background: var(--surface-subtle); color: var(--text-secondary); font-size: .78rem; font-weight: 650; }
.form-table tbody th { width: 1%; min-width: 100px; background: var(--surface-hover); color: var(--text-secondary); font-size: .84rem; font-weight: 550; }
.form-table th + th, .form-table td { border-inline-start: 1px solid var(--border); }
.form-table tr > th:first-child { position: sticky; inset-inline-start: 0; z-index: 1; }
.form-cell { display: flex; flex-direction: column; gap: 8px; min-width: 115px; }
.form-control { display: flex; align-items: center; gap: 5px; }
button.form-word { display: flex; flex-direction: column; align-items: start; gap: 2px; padding: 7px 9px; border-radius: 8px; background: transparent; color: var(--text); text-align: start; white-space: normal; box-shadow: none; }
button.form-word[aria-expanded="true"] { background: var(--surface-subtle); }
@media (hover: hover) and (pointer: fine) { button.form-word:hover { background: var(--surface-subtle); } }
button.form-word strong { font-weight: 600; }
.form-control .speech-button { width: 30px; height: 30px; min-width: 30px; padding: 6px; }
.form-control .speech-button svg { width: 16px; height: 16px; }
.form-cell-empty { padding: 7px 9px; color: var(--muted); }
.form-example-popup { max-width: 600px; }
.form-example-text { font-size: 1.2rem; line-height: 1.8; }
.form-example-text > .spoken-text { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .5rem; }
.form-example-text > .spoken-text > .speech-control { order: -1; }
@media (max-width: 600px) {
  .form-table th, .form-table td { padding: 9px 10px; }
  .form-table tbody th { min-width: 65px; font-size: .78rem; }
  .form-table caption { padding: 14px; }
  .form-cell { min-width: 80px; }
  .form-control { flex-direction: column-reverse; align-items: flex-start; gap: 2px; }
  button.form-word { padding: 5px 3px; font-size: .88rem; }
  .form-control .speech-button { margin: 0; }
}

/* Error details keep the normal message small while exposing full diagnostics on demand. */
.error-message { display: inline-flex; align-items: baseline; gap: .35rem; max-width: 100%; }
.icon-button.error-details-button { width: 24px; min-width: 24px; height: 24px; flex: 0 0 auto; color: var(--danger, #c13d3d); padding: .2rem; align-self: center; }
.error-details-popup { max-width: min(46rem, calc(100vw - 2rem)); }
.error-details-id { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .8rem 0; }
.error-details-id code { font-size: 1rem; overflow-wrap: anywhere; user-select: all; }
.error-details-actions {display:flex;justify-content:flex-end;margin-bottom:.75rem;}
.error-details-data { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 60vh; overflow: auto; font-size: .8rem; line-height: 1.5; user-select: text; }
.unhandled-client-error { position: fixed; bottom: 1rem; right: 1rem; z-index: 10000; max-width: min(28rem, 90vw); background: var(--surface, white); color: var(--danger, #c13d3d); border: 1px solid currentColor; border-radius: .5rem; padding: .7rem; }

/* Sentence structures: patterns, a small slot editor, and word-pool practice. */
.structure-card { padding: 22px; }
.structure-open h2 { margin: 0 0 16px; font-size: 1.05rem; }
.structure-title { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; box-shadow: none; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .structure-title:hover { background: transparent; color: var(--accent); } }
.structure-open p { font-size: .8rem; line-height: 1.7; margin: 14px 0 0; }
.structure-pattern { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 8px; }
.structure-pattern + p { margin-top: 14px; }
/* Punctuation sits between the slot boxes, level with their text. */
.structure-punctuation { align-self: flex-start; margin-inline: -5px -3px; padding-top: 7px; color: var(--text); font-size: 1.1rem; font-weight: 700; line-height: 1.35; }
.structure-punctuation.before { margin-inline: -3px -5px; }
.structure-answer .structure-punctuation { padding-top: 16px; font-size: 1.25rem; }
.structure-pattern-translation { color: var(--text-secondary); font-size: .9rem !important; font-style: italic; }
.structure-slot { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; max-width: 100%; }
.structure-slot-box { min-height: 0; max-width: 100%; padding: 7px 14px; border: 1.5px dashed color-mix(in srgb, var(--role) 60%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--role) 10%, var(--surface)); color: var(--text); font-size: 1rem; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; box-shadow: none; cursor: help; transition: background .15s var(--ease), border-color .15s var(--ease); }
.structure-slot-box.fixed { border-style: solid; background: color-mix(in srgb, var(--role) 20%, var(--surface)); }
.structure-slot.open .structure-slot-box { color: var(--text); border-color: var(--role); background: color-mix(in srgb, var(--role) 26%, var(--surface)); }
@media (hover: hover) and (pointer: fine) { .structure-slot-box:hover { color: var(--text); border-color: var(--role); background: color-mix(in srgb, var(--role) 26%, var(--surface)); } }
.structure-slot-filter { display: block; max-width: 22ch; overflow: hidden; color: var(--text-secondary); font-weight: 500; font-style: italic; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.structure-slot-term { min-height: 1.2em; max-width: 100%; color: color-mix(in srgb, var(--role, var(--text-secondary)) 72%, var(--text)); font-size: .72rem; font-weight: 600; line-height: 1.2; text-align: center; overflow-wrap: anywhere; }
.structure-slot-details { position: absolute; z-index: 20; top: calc(100% + 6px); inset-inline-start: 0; display: none; width: max-content; max-width: min(300px, calc(100vw - 48px)); padding: 12px 14px; border: 1px solid var(--border); border-top: 3px solid var(--role); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-raised); color: var(--text); font-size: .8rem; line-height: 1.5; text-align: start; animation: popover-in .14s var(--ease) both; }
.structure-slot.open .structure-slot-details, .structure-slot-box:focus-visible + .structure-slot-term + .structure-slot-details { display: grid; gap: 6px; }
@media (hover: hover) and (pointer: fine) { .structure-slot:hover .structure-slot-details { display: grid; gap: 6px; } }
.structure-slot-details strong { display: flex; align-items: center; gap: 7px; font-size: .82rem; }
.structure-slot-details .guided-swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--role); }
.structure-slot-details p { display: grid; gap: 1px; margin: 0 !important; font-size: .8rem !important; line-height: 1.45 !important; overflow-wrap: anywhere; }
.structure-slot-details p .muted { font-size: .7rem; }
.structure-slot-gloss { display: grid; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border); font-size: .85rem; }
.structure-slot-gloss-word { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 1.15rem; font-weight: 700; }
.structure-slot-gloss-word small { color: var(--text-secondary); font-size: .85rem; font-weight: 500; }
.structure-sentence-part { border-bottom: 3px solid color-mix(in srgb, var(--role) 70%, transparent); padding-bottom: 1px; }
.structure-card-footer { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 18px; }
.structure-card-footer .button-row { margin: 0; flex: none; }
.structure-card-footer .secondary { min-height: 36px; padding: 7px 12px; font-size: .8rem; }
.structure-slot-editor { display: grid; gap: 12px; }
.structure-slot-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.structure-slot-row > .tag { margin-top: 28px; }
.structure-slot-row label { margin: 0; font-size: .75rem; }
.structure-slot-row select { min-width: 135px; }
.structure-slot-value { flex: 1; min-width: 0; }
.structure-slot-details-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) repeat(2, minmax(90px, 110px)); gap: 10px; margin-top: 10px; }
@media (max-width: 640px) { .structure-slot-details-row { grid-template-columns: 1fr 1fr; } }
.structure-slot-actions { display: flex; flex-direction: column; gap: 2px; }
.structure-slot-actions button { min-height: 28px; padding: 2px 10px; }
.structure-examples { display: grid; gap: 16px; margin-top: 24px; }
.structure-examples article { padding: 20px; }
.structure-examples p { margin: 0 0 12px; }
.structure-practice-stage .study-topbar { width: min(900px, 100%); }
.structure-practice-scene { grid-row: 2; width: min(900px, 100%); min-width: 0; min-height: 0; justify-self: center; display: grid; container-type: inline-size; }
.structure-practice-scene > div { display: contents; }
.structure-practice-stage .study-card { max-height: none; }
.structure-practice-stage .study-card .study-card-body { display: block; min-height: 0; }
.structure-practice { min-width: 0; }
.structure-practice-setup { display: grid; gap: 20px; }
.structure-practice-setup h2,.structure-practice-setup p,.structure-practice-setup label { margin: 0; }
.structure-selection { border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; display: grid; gap: 10px; max-height: 350px; overflow-y: auto; }
.structure-selection legend { font-size: .85rem; padding-inline: 6px; }
.structure-practice-progress { display: flex; align-items: center; gap: 18px; margin: 0 0 14px; font-size: .8rem; color: var(--text-secondary); }
.structure-practice-progress progress { flex: 1; height: 6px; accent-color: var(--accent); }
.structure-exercise { text-align: center; }
.structure-exercise h2 { font-size: .9rem; color: var(--text-secondary); font-weight: 500; }
.structure-translation { font-size: clamp(1.25rem,3vw,1.7rem); line-height: 1.6; margin: 28px 0; }
.structure-instructions { font-size: .78rem; line-height: 1.7; }
.structure-answer { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 14px 10px; margin: 30px 0 22px; }
.structure-answer-cell { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 100%; }
.structure-answer-cell.colored .structure-answer-slot { border-color: color-mix(in srgb, var(--role) 60%, transparent); background: color-mix(in srgb, var(--role) 9%, var(--surface)); }
.structure-answer-cell.colored .structure-answer-slot.prefilled { border-style: solid; background: color-mix(in srgb, var(--role) 18%, var(--surface)); }
.structure-answer-cell .structure-slot-term { font-size: .75rem; }
.structure-answer-slot { display: inline-flex; align-items: center; justify-content: center; min-width: 80px; min-height: 62px; max-width: 100%; padding: 12px 16px; border: 2px dashed var(--border); border-radius: 12px; background: var(--surface-subtle); color: var(--text); font-size: 1.05rem; overflow-wrap: anywhere; }
.structure-answer-slot .muted { font-size: .8rem; }
.structure-answer-slot.prefilled { border-style: solid; border-color: transparent; font-weight: 600; }
.structure-answer-cell .structure-answer-slot.incorrect { border-color: var(--danger, #bd4949); }
.structure-answer-slot:disabled { opacity: 1; }
.structure-word-pool { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 82px; padding: 20px 10px; border-top: 1px solid var(--border); }
.structure-word { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; min-height: 44px; padding: 10px 16px; font-size: 1rem; cursor: grab; box-shadow: 0 3px 0 var(--border); overflow-wrap: anywhere; max-width: 100%; }
/* Explicit token colors prevent the generic button hover from hiding its text. */
.structure-word:is(:active,[aria-pressed="true"]) { background: var(--surface-hover); color: var(--text); border-color: var(--text-secondary); }
@media (hover: hover) and (pointer: fine) { .structure-word:is(:hover,:active,[aria-pressed="true"]) { background: var(--surface-hover); color: var(--text); border-color: var(--text-secondary); } }
.structure-word[aria-pressed="true"] { box-shadow: inset 0 -3px var(--text-secondary); }
.structure-exercise :is(.structure-word,.structure-answer-slot) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.structure-word { touch-action: none; }
.structure-word[data-dragging="true"] { opacity: .4; }
.structure-answer-slot:is(:active) { color: var(--text); background: var(--surface-hover); }
@media (hover: hover) and (pointer: fine) { .structure-answer-slot:is(:hover,:active) { color: var(--text); background: var(--surface-hover); } }
.structure-answer-slot[data-drop-target="true"] { border-style: solid; border-color: var(--text); box-shadow: inset 0 0 0 2px var(--text); }
.structure-practice-stage .study-card-scroll:focus { outline: none; }
.structure-exercise[data-input="pointer"] button:focus { outline: none; }
.structure-drag-preview { position: fixed; z-index: 10; pointer-events: none; transform: translate(-50%, -120%); border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); max-width: 80vw; overflow-wrap: anywhere; }
.structure-exercise .button-row { justify-content: center; }
.structure-revealed { padding: 18px; background: var(--surface-subtle); border-radius: 12px; margin: 16px 0; }
@media (max-width: 600px) {
  .structure-slot-row { flex-wrap: wrap; }
  .structure-slot-value { flex-basis: 100%; order: 3; }
  .structure-slot-actions { flex-direction: row; margin-inline-start: auto; }
  .structure-card-footer { flex-wrap: wrap; }
  .structure-answer-slot { min-width: 65px; padding: 10px; }
  .phrase-filters { flex-wrap: wrap; }
  .phrase-filters > input { min-width: 160px; }
}

/* Vocabulary folder navigation and list actions. */
.vocabulary-folder-parent { display: inline-block; margin-bottom: 12px; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .vocabulary-folder-parent:hover { text-decoration: underline; } }
.vocabulary-list-management { margin: 16px 0; }
.vocabulary-folder-delete-actions, .vocabulary-list-management { flex-wrap: wrap; }

/* Interface direction and lesson direction are independent. Logical insets keep
   menus and the sidebar anchored to the reader's start edge. */
[dir="rtl"] .sidebar-toggle svg,
[dir="rtl"] .page-history-back svg { transform: scaleX(-1); }
@media (max-width: 760px) {
  [dir="rtl"] .sidebar { transform: translateX(104%); }
  [dir="rtl"] .sidebar-expanded .sidebar { transform: none; }
}

/* Word flash cards: four learning dimensions. */
.flashcard-modes { display: grid; gap: 10px; border: 0; padding: 0; margin: 0; min-width: 0; }
.flashcard-mode-option { align-items: flex-start; gap: 10px; }
.flashcard-mode-option span { display: grid; gap: 2px; }
.flashcard-mode-option small { font-size: .78rem; line-height: 1.45; }
.flashcard-secondary-field { grid-column: 1 / -1; display: grid; gap: 6px; min-width: 0; }
.flashcard-secondary-field input { width: 100%; margin: 0; }
.flashcard-field-label { font-size: .75rem; font-weight: 650; color: var(--text-secondary); letter-spacing: .03em; text-transform: uppercase; }
.flashcard-answer-editor .flashcard-field-label { display: block; margin-bottom: 6px; }
.flashcard-speaking { display: grid; justify-items: center; gap: 12px; padding: 6px 0; }
.flashcard-speaking .reader-flashcard-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.flashcard-speaking .reader-flashcard-toolbar > button:first-child:not(.voice-record-button) { min-width: 180px; min-height: 52px; font-size: 1rem; }
.flashcard-recording-ready { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--success); }
.flashcard-cannot-speak { grid-column: 1 / -1; justify-self: center; font-size: .85rem; }
.flashcard-secondary-answer { display: flex; flex-wrap: wrap; gap: 6px; }
.study-scene:has(.study-answer-dock[data-answer-step]) { grid-template-rows: minmax(0, 1fr) auto; }
.study-answer-dock[data-answer-step] { max-height: min(360px, calc(var(--study-height) * .6)); padding: 14px 18px; gap: 8px; }
.study-answer-dock[data-answer-step] .flashcard-task { gap: 6px; }
.study-answer-dock[data-answer-step] .flashcard-task-title { flex: 1; font-size: .95rem; }
.flashcard-answer-step { flex: none; color: var(--text-secondary); font-size: .75rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.study-dock .flashcard-answer-back { flex: 0 0 32px; width: 32px; height: 32px; padding: 6px; }
.pronunciation-system .pronunciation-info { margin: 0; padding: 2px 4px; font-size: .75rem; }
.study-answer-dock .pronunciation-suggestions { min-height: 0; }
.study-answer-dock .pronunciation-suggestions:empty { display: none; }
.study-answer-dock[data-answer-step] .pronunciation-tone-heading { min-height: 36px; }
.study-answer-dock[data-answer-step] button.pronunciation-tone { min-height: 64px; padding: 5px 3px; gap: 2px; }

/* Characters: library rows, editor and the stroke flash card. */
.character-rows { display: grid; }
.character-row { display: flex; align-items: center; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.character-row:last-child { border-bottom: 0; }
.character-glyph { flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; background: var(--surface-subtle); border: 1px solid var(--border); font-size: 2.1rem; line-height: 1; }
.character-row[data-practicable="false"] .character-glyph { opacity: .6; }
.character-row-copy { flex: 1; min-width: 0; display: grid; gap: 3px; }
.character-row-copy p { margin: 0; overflow-wrap: anywhere; }
.character-reading { font-weight: 650; color: var(--accent-ink); }
.character-no-strokes { font-size: .78rem; }
.character-row-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.character-level-chip { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; padding: 4px 9px; border-radius: 20px; font-size: .8rem; font-weight: 650; font-variant-numeric: tabular-nums; background: hsl(var(--level-hue) 72% 48% / .18); border: 1px solid hsl(var(--level-hue) 72% 48% / .55); color: var(--text); }
.character-level-chip.unrated { background: color-mix(in srgb, var(--muted) 15%, transparent); border-color: var(--border); color: var(--text-secondary); font-weight: 500; }
.character-editor-glyph { font-size: 1.6rem; max-width: 120px; text-align: center; }
.character-suggestion-row { align-items: center; }
.character-suggestion-row .character-glyph { width: 52px; height: 52px; font-size: 1.7rem; }
.character-card { display: grid; justify-items: center; gap: 14px; text-align: center; }
.character-card-pronunciation { display: flex; align-items: center; justify-content: center; gap: 12px; }
.character-card-reading { font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 650; letter-spacing: .02em; margin: 0; }
.character-card-meaning { font-size: 1.15rem; margin: 0; }
.character-card-help { font-size: .8rem; }
.character-session-count { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; font-weight: 650; }
.study-scene:has(.character-dock) { grid-template-rows: minmax(0, 1fr) minmax(0, min(62%, 560px)); }
.character-dock { padding: 12px 16px; gap: 8px; overflow: auto; }
.character-stroke-exercise { gap: 8px; }
.character-stroke-exercise canvas { width: min(100%, 300px, 38dvh); }
.character-stroke-exercise > p { min-height: 2.2em; margin: 0; }
.character-stroke-exercise[data-complete="true"] .skill-stroke-tools, .character-stroke-exercise[data-complete="true"] > small { display: none; }
.character-stroke-exercise[data-demonstrating="true"] .skill-stroke-tools { display: none; }
.character-result-glyph { font-size: clamp(2.6rem, 9vw, 4rem); line-height: 1.1; margin: 0; }
.character-result { display: grid; gap: 14px; }
.character-result-progress { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text-secondary); }

/* Home activity sections share the full dashboard width. */
.home-sections { display: grid; gap: 32px; min-width: 0; }
.home-feature-section { min-width: 0; container: discovery-layout / inline-size; }
.home-dashboard :is(.home-feature-section,.home-quests) > .section-heading {
  position:sticky;top:var(--header-height);z-index:12;align-self:start;
  margin-inline:-12px;padding:2px 12px;border-radius:0 0 14px 14px;
  background:color-mix(in srgb,var(--bg) 94%,transparent);
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
}
/* The heading backdrop only appears while the heading is pinned under the app
   header; home/sticky_headings.js tracks their position and the language dock. */
.home-dashboard :is(.home-feature-section,.home-quests) > .section-heading {
  background:transparent;backdrop-filter:none;-webkit-backdrop-filter:none;
  transition:background-color .18s ease,backdrop-filter .18s ease,-webkit-backdrop-filter .18s ease;
}
.home-dashboard :is(.home-feature-section,.home-quests) > .section-heading[data-stuck="true"] {
  background:color-mix(in srgb,var(--bg) 94%,transparent);
  backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
}
/* Keep the linked heading's 44px touch target, without extra phone padding. */
@media(max-width:760px) {
  .home-dashboard :is(.home-feature-section,.home-quests) > .section-heading { padding-block:0; }
}
.home-feature-section > .section-heading h2 { margin: 0; font-size: 1.15rem; }
.home-feature-section > .section-heading h2:has(.home-section-link) {width:100%}
.home-content-grid { --discovery-card-height: 30rem; container: content-tiles / inline-size; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 16px; }
button.home-create-card {white-space:normal}
.home-section-link {display:flex;align-items:center;gap:12px;width:100%;min-height:44px;padding:4px 0;color:inherit;text-decoration:none;border-radius:6px;transition:color .15s ease}
@media (hover: hover) and (pointer: fine) { .home-section-link:hover {color:var(--accent);text-decoration:none} }
.home-section-icon {display:grid;place-items:center;flex:none;width:34px;height:34px;border-radius:11px;background:var(--surface-subtle);color:var(--text-secondary)}
.home-section-title {flex:1;min-width:0;overflow-wrap:anywhere}
.home-section-action {display:flex;align-items:center;gap:8px;flex:none;margin-inline-start:auto}
.home-section-view-all {font-size:.85rem;font-weight:500;opacity:0;transform:translateX(-4px);transition:opacity .15s ease,transform .15s ease}
.home-section-link:is(:focus-visible) .home-section-view-all {opacity:1;transform:translateX(0)}
@media (hover: hover) and (pointer: fine) { .home-section-link:is(:hover,:focus-visible) .home-section-view-all {opacity:1;transform:translateX(0)} }
@media(prefers-reduced-motion:reduce){.home-section-link,.home-section-view-all {transition:none}.home-section-view-all {transform:none}}
/* Fixed outer heights prevent images, generated copy and button defaults from
   contributing different intrinsic sizes to the same discovery row. */
:is(.home-content-grid, .library-create-grid) > :is(.home-content-card, .home-suggestion, .home-create-column) { height: var(--discovery-card-height); min-height: 0; }
/* Home action tiles split their column or row equally. */
.home-create-column { display: grid; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 16px; min-width: 0; min-height: 0; }
.home-create-column > .home-create-card { height: auto; }
/* Create tiles sit on quiet, checked-in artwork: faded solid shapes in the flag's first colour. */
.home-create-card { --tint: var(--flag-1, var(--accent)); position: relative; justify-items: center; align-content: center; color: var(--text); background: color-mix(in srgb, var(--tint) 4%, var(--surface)); }
@media (hover: hover) and (pointer: fine) { .home-create-card:hover { background: color-mix(in srgb, var(--tint) 7%, var(--surface)); border-color: color-mix(in srgb, var(--tint) 24%, var(--border)); } }
.home-create-art { position: absolute; inset: 0; display: block; color: var(--tint); opacity: .38; pointer-events: none; }
.home-create-art > svg { display: block; width: 100%; height: 100%; }
.coach-create-popup .coach-setup {padding:0;border:0;box-shadow:none;background:none}

.home-content-card { display: grid; align-items: stretch; align-content: start; gap: 0; width: 100%; min-width: 0; height: 100%; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); text-decoration: none; text-align: start; font: inherit; box-shadow: var(--shadow-sm); transition: border-color .15s ease, background-color .15s ease, box-shadow .18s ease, transform .18s var(--ease); }
@media (hover: hover) and (pointer: fine) { .home-content-card:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-2px); } }
.home-content-copy { display: grid; gap: 10px; min-width: 0; padding: 20px; }
.home-content-copy > strong { font-size: 1.1rem; line-height: 1.35; overflow-wrap: anywhere; }
.home-content-copy > .muted { font-size: .9rem; line-height: 1.5; }
/* Both content cards reserve the same text area and crop art to the remaining space. */
.home-recent-card { grid-template-rows: minmax(0, 1fr) var(--tile-caption-height, 14rem); }
.home-recent-card > .home-content-copy, .home-suggestion-card > .home-content-copy { min-height: 0; align-content: start; overflow: hidden; }
.home-recent-card .home-card-eyebrow { min-height: 28px; }
.home-recent-card > .home-content-copy { padding: 16px 20px; gap: 6px; }
:is(.home-recent-card, .home-suggestion-card, .home-create-card) .home-content-copy > :is(strong, .muted) { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
:is(.home-recent-card, .home-suggestion-card, .home-create-card) .home-content-copy > strong { -webkit-line-clamp: 2; }
:is(.home-recent-card, .home-suggestion-card, .home-create-card) .home-content-copy > .muted { -webkit-line-clamp: 3; }
/* The same width that stacks discovery cards also compacts their creation tile. */
@container content-tiles (max-width: 555px) {
  :is(.home-content-grid, .library-create-grid) > :is(.home-create-column, .home-create-card) { height: 11rem; }
  .home-create-card { align-content: center; height: auto; }
  /* Stacked: the creation tile and View all share one equally divided row. */
  .home-create-column { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); min-height: 0; }
  .home-create-column > .home-create-card { min-height: 0; }
}
/* Action labels and arrows stay on one row; optional copy uses the tile's
   actual width and height, including stacked and library layouts. */
.home-content-card:is(.home-create-card, .home-view-all-tile) { container: home-action / size; display: grid; grid-template-rows: minmax(0, 1fr); align-content: stretch; min-height: 0; padding: 0; }
.home-create-column > .home-view-all-tile { height: auto; }
.home-action-copy { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: center; align-items: center; gap: 10px 14px; width: 100%; min-width: 0; padding: 24px; text-align: start; }
.home-action-copy > strong { font-size: 1.1rem; line-height: 1.35; overflow-wrap: anywhere; }
.home-action-copy > .shell-icon { grid-column: 2; grid-row: 1; color: var(--muted); transition: transform .15s var(--ease); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .home-content-card:is(.home-create-card, .home-view-all-tile):hover .home-action-copy > .shell-icon { transform: translateX(2px); } }
.home-action-count { grid-column: 1; grid-row: 2; color: var(--muted); font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.home-action-copy > .muted { display: none; grid-column: 1; grid-row: 2; min-width: 0; font-size: .9rem; line-height: 1.5; overflow: hidden; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
@container home-action (min-width: 18rem) and (min-height: 12rem) {
  .home-action-copy > .muted { display: -webkit-box; }
}
@container home-action (min-width: 20rem) and (min-height: 10rem) {
  .home-action-copy > .muted { display: -webkit-box; }
}
@container home-action (max-width: 16rem) {
  .home-action-copy { padding: 16px; column-gap: 8px; }
  .home-action-copy > strong { font-size: 1rem; }
}
.home-card-eyebrow { display: inline-flex; align-items: center; gap: 6px; justify-self: start; font-size: .72rem; font-weight: 650; color: var(--text-secondary); }
.home-suggestion .home-card-eyebrow { padding: 5px 11px; border-radius: 999px; background: var(--home-tint-soft, var(--surface-subtle)); color: var(--home-tint-ink, var(--text-secondary)); }
.home-content-busy { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; gap:8px; background:#0009; color:#fff; font-size:.88rem; font-weight:650; }
.home-content-busy .word-illustration-spinner { width:18px; height:18px; }
.home-content-action { display: flex; align-items: center; gap: 8px; padding-top: 8px; color: var(--text); font-size: .88rem; font-weight: 650; }
.home-content-action .word-illustration-spinner { width: 18px; height: 18px; }
.home-suggestion { position: relative; min-width: 0; }
.home-suggestion-feedback { position: absolute; inset: auto 12px 12px; z-index: 3; display: grid; gap: 8px; max-height: 50%; overflow: auto; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.home-suggestion-feedback > * { margin: 0; }
/* The badge row shares the card's grid, keeping its menu outside the card's
   button and frosted/clipped surface so its dropdown can open over nearby tiles. */
.home-suggestion-tile {position:relative;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) 44px calc(var(--tile-caption-height, 14rem) - 44px);min-width:0;min-height:0;height:100%}
.home-suggestion-card {grid-area:1 / 1 / 4 / 2;grid-template-rows:subgrid}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .home-suggestion-card:hover {transform:none} }
.home-suggestion-card .home-suggestion-image {grid-row:1}
.home-suggestion-card .home-content-copy {grid-row:3;padding-top:6px}
.home-suggestion-heading {position:relative;grid-area:2 / 1 / 3 / 2;display:flex;align-items:center;gap:8px;min-width:0;margin:16px 20px 0;z-index:2;pointer-events:none}
.home-suggestion-heading .home-card-eyebrow {min-width:0;white-space:normal}
.home-suggestion-heading .home-card-eyebrow>.shell-icon {flex:none}
.home-suggestion-menu {position:static;flex:none;pointer-events:auto}
.home-suggestion-tile:has(.home-suggestion-menu.is-open) {z-index:40}
.home-suggestion-menu>.home-suggestion-popover {inset-inline-start:0;inset-inline-end:auto;width:min(250px,100%)}
/* The visible 28px control matches the badge, inside a 44px tap target. */
button.home-suggestion-refresh {position:relative;width:44px;min-width:44px;height:44px;margin:-8px;padding:0;background:transparent;border:0;box-shadow:none;color:var(--text)}
button.home-suggestion-refresh::before {content:"";position:absolute;inset:8px;background:color-mix(in srgb, var(--surface) 78%, transparent);-webkit-backdrop-filter:blur(8px);backdrop-filter:blur(8px);border:1px solid color-mix(in srgb, var(--border) 60%, transparent);border-radius:9px;box-shadow:0 2px 8px #0002;pointer-events:none}
button.home-suggestion-refresh > .shell-icon {position:relative;width:18px;height:18px}
@media (hover: hover) and (pointer: fine) { button.home-suggestion-refresh:hover:not(:disabled) {background:transparent;color:var(--text)} }
@media (hover: hover) and (pointer: fine) { button.home-suggestion-refresh:hover:not(:disabled)::before {background:var(--surface-hover);border-color:var(--border-strong)} }
.home-recent-card > .home-recent-art, .home-suggestion-card > .home-suggestion-image { height: 100%; min-height: 0; aspect-ratio: auto; }
.home-suggestion-image, .home-recent-art { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9; background: var(--surface-subtle); color: var(--text-secondary); overflow: hidden; }
.home-suggestion-image img, .home-recent-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.home-recent-art .book-cover { transform: rotate(-5deg); }
.home-thumbnail-action { position: absolute; top: 12px; right: 46px; left: 12px; min-height: 26px; z-index: 2; display: flex; align-items: center; justify-content: flex-end; color: #fff; font-size: 1rem; font-weight: 700; line-height: 1.2; text-align: right; text-shadow: 0 2px 8px #000b, 0 0 24px #000e; pointer-events: none; opacity: 1; }

.home-content-pending { align-content: center; justify-items: center; gap: 14px; min-height: 260px; padding: 24px; color: var(--text-secondary); }
.home-image-retry { margin-top: 8px; }
/* Palette tokens mirror both explicit themes and Automatic's OS appearance. */
:root, .theme-light, .theme-calm, .theme-system { --tile-info-opacity: 60%; --tile-info-alpha: .6; --tile-theme-rgb: 255, 255, 255; --tile-theme-ink: #111; --tile-theme-secondary: #111d; --tile-theme-detail-rgb: 0, 0, 0; --tile-theme-shadow: none; }
:root[data-theme="dark"], :root[data-theme="tokyo-night"], .theme-dark, .theme-tokyo-night { --tile-info-opacity: 80%; --tile-info-alpha: .8; --tile-theme-rgb: 16, 21, 29; --tile-theme-ink: #fff; --tile-theme-secondary: #ffffffe0; --tile-theme-detail-rgb: 255, 255, 255; --tile-theme-shadow: 0 1px 3px #0008; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"], .theme-system { --tile-info-opacity: 80%; --tile-info-alpha: .8; --tile-theme-rgb: 16, 21, 29; --tile-theme-ink: #fff; --tile-theme-secondary: #ffffffe0; --tile-theme-detail-rgb: 255, 255, 255; --tile-theme-shadow: 0 1px 3px #0008; }
}
[data-content-style="image"] { --tile-scrim-rgb: 16, 21, 29; --tile-ink: #fff; --tile-secondary: #ffffffe0; --tile-detail-rgb: 255, 255, 255; --tile-title-shadow: 0 1px 3px #0008; }
[data-content-style="image"][data-scrim-theme="adaptive"] { --tile-scrim-rgb: var(--tile-theme-rgb); --tile-ink: var(--tile-theme-ink); --tile-secondary: var(--tile-theme-secondary); --tile-detail-rgb: var(--tile-theme-detail-rgb); --tile-title-shadow: var(--tile-theme-shadow); }
/* Artwork fills the card; its caption has a sharp, theme-matched frosted scrim. */
[data-content-style="image"] > :is(.home-content-grid, .library-create-grid) { --discovery-card-height: 20.5rem; }
[data-content-style="image"] :is(.home-recent-card, .home-suggestion-card) { position: relative; color: var(--tile-ink); background: #253139; }
[data-content-style="image"] .home-recent-card { grid-template-rows: minmax(0, 1fr) var(--tile-caption-height, 6.5rem); }
[data-content-style="image"] :is(.home-recent-card > .home-recent-art, .home-suggestion-card > .home-suggestion-image) { position: absolute; inset: 0; height: 100%; background: #253139; }
[data-content-style="image"] .home-recent-card > .home-content-copy { position: relative; z-index: 1; grid-row: 2; grid-template-rows: 28px auto; padding: 8px 16px 12px; gap: 4px; }
[data-content-style="image"] .home-recent-card .home-card-eyebrow { min-height: 28px; color: var(--tile-secondary); }
[data-content-style="image"] .home-content-copy > .home-content-description { color:var(--tile-secondary); -webkit-line-clamp:2; }
[data-content-style="image"] :is(.home-recent-card, .home-suggestion-card) .home-content-copy > strong { text-shadow: var(--tile-title-shadow); }
[data-content-style="image"] .home-suggestion-tile { grid-template-rows: minmax(0, 1fr) 36px calc(var(--tile-caption-height, 6.5rem) - 36px); }
/* Fade both the tint and backdrop blur so neither leaves a hard upper edge. */
[data-content-style="image"] :is(.home-recent-card, .home-suggestion-card)::after { content: ""; position: absolute; inset: auto 0 0; height: calc(var(--tile-caption-height, 6.5rem) + 5rem); background: linear-gradient(to top, rgba(var(--tile-scrim-rgb), var(--tile-info-alpha, .42)), rgba(var(--tile-scrim-rgb), calc(var(--tile-info-alpha, .42) * .667)) 60%, transparent); -webkit-backdrop-filter: blur(calc(var(--tile-info-alpha, .42) * 14px)); backdrop-filter: blur(calc(var(--tile-info-alpha, .42) * 14px)); -webkit-mask-image: linear-gradient(to bottom, transparent, #000 55%); mask-image: linear-gradient(to bottom, transparent, #000 55%); pointer-events: none; }
[data-content-style="image"] .home-suggestion-card > .home-content-copy { position: relative; z-index: 1; padding: 4px 16px 12px; gap: 4px; }
[data-content-style="image"] .home-suggestion-heading { margin: 8px 16px 0; }
[data-content-style="image"] .home-suggestion-heading .home-card-eyebrow { color: var(--tile-ink); background: rgba(var(--tile-detail-rgb), .14); }
[data-content-style="image"] button.home-suggestion-refresh { color: var(--tile-ink); }
[data-content-style="image"] button.home-suggestion-refresh::before { background: rgba(var(--tile-detail-rgb), .12); border-color: rgba(var(--tile-detail-rgb), .25); }
@media (hover: hover) and (pointer: fine) { [data-content-style="image"] button.home-suggestion-refresh:hover:not(:disabled) { color: var(--tile-ink); } }
@media (hover: hover) and (pointer: fine) { [data-content-style="image"] button.home-suggestion-refresh:hover:not(:disabled)::before { background: rgba(var(--tile-detail-rgb), .22); } }
[data-content-style="image"] :is(.home-recent-card, .home-suggestion-card) .home-thumbnail-type { top: 12px; bottom: auto; }
[data-content-style="image"][data-scrim-edge="sharp"] :is(.home-recent-card, .home-suggestion-card)::after { height: var(--tile-caption-height, 6.5rem); background: rgba(var(--tile-scrim-rgb), var(--tile-info-alpha, .42)); -webkit-mask-image: none; mask-image: none; }
.home-stuff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.home-quick-link { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; min-width: 0; min-height: 88px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); color: var(--text); background: var(--surface); text-decoration: none; transition: border-color .15s ease, background-color .15s ease; }
@media (hover: hover) and (pointer: fine) { .home-quick-link:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-hover); } }
.home-quick-link strong { overflow-wrap: anywhere; }
.home-quick-link > span { display: grid; gap: 4px; }
.home-quick-link small { color: var(--muted); font-size: .75rem; }
.home-skills { display: grid; gap: 16px; min-width: 0; }
.home-skills > button.pronunciation-guide-tile { margin: 0; }
.home-skills-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
button.home-skill-tile { display: grid; grid-template-columns: 44px minmax(0, 1fr) 18px; align-items: center; gap: 12px; width: 100%; min-width: 0; min-height: 80px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); text-align: start; white-space: normal; box-shadow: none; transition: border-color .15s ease, background-color .15s ease; }
button.home-skill-tile:focus-visible { border-color: var(--border-strong); background: var(--surface-hover); color: var(--text); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button.home-skill-tile:hover { border-color: var(--border-strong); background: var(--surface-hover); color: var(--text); } }
.home-skill-tile .skill-card-art { width: 44px; height: 44px; border-radius: 12px; }
.home-skill-tile strong { font-size: 1rem; overflow-wrap: anywhere; }
.home-skill-tile > .shell-icon { color: var(--muted); }
@media (max-width:600px) {
  .home-sections { gap: 26px; }
  .home-quick-link { padding: 16px 12px; gap: 8px; }
  .home-quick-link > svg:last-child { display: none; }
}

/* The Home title and sidebar share the same language switcher. */
button.home-language-trigger { position: relative; z-index: 31; display: inline-flex; align-items: center; gap: 16px; width: max-content; max-width: calc(100% + 24px); margin: -8px -12px; padding: 8px 20px 8px 12px; border: 1px solid transparent; border-radius: 14px; background: transparent; color: var(--text); font: inherit; text-align: start; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { button.home-language-trigger:hover { border-color: var(--border-strong); background: var(--surface-hover); color: var(--text); } }
button.home-language-trigger:active { transform: none; }
.home-language-trigger > .shell-icon { flex: none; color: var(--muted); }
.home-language-trigger > span:not(.home-flag) { min-width:0; overflow-wrap:anywhere; }
.home-language-menu .profile-menu-popover { max-height: min(600px, calc(100dvh - 160px)); }
@media (max-width:600px) { button.home-language-trigger { gap: 12px; } }

/* Previous activity suggestions and their thumbnails. */
.home-history-loading { display: grid; place-items: center; min-height: 120px; }
.home-history-art { position: relative; display: grid; place-items: center; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 14px; background: var(--surface-subtle); color: var(--text-secondary); }
.home-history-art > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.home-suggestion-history-list { display: grid; gap: 12px; }
.home-suggestion-history-item { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.home-suggestion-menu > .profile-menu-popover { inset-inline-end: 0; inset-inline-start: auto; width: 250px; }
.home-suggestion-history-item .home-history-art { aspect-ratio: 16 / 9; border-radius: 10px; }
.home-suggestion-history-copy { display: grid; gap: 4px; min-width: 0; }
.home-suggestion-history-copy strong { font-size: 1rem; overflow-wrap: anywhere; }
.home-suggestion-history-copy > .muted { font-size: .88rem; line-height: 1.45; }
.home-suggestion-history-copy > button { justify-self: start; margin-top: 6px; }
@media (max-width: 600px) { .home-suggestion-history-item { grid-template-columns: minmax(0, 1fr); } }

/* Home tools keep entry fields and recent sessions together. */
.home-tools-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.home-tool-card { display: flex; flex-direction: column; gap: 18px; min-width: 0; padding: 24px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); color: var(--text); }
.home-tool-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.home-tool-heading h3 { margin: 0; font-size: 1.1rem; }
.home-tool-heading .text-link { flex: none; }
.home-tool-heading button.text-link { width: auto; padding: 0; background: transparent; color: var(--text-secondary); border: 0; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { .home-tool-heading button.text-link:hover { background: transparent; color: var(--text); text-decoration: underline; } }
.home-tool-form, .home-tool-form .search-field { min-width: 0; width: 100%; margin: 0; }
.home-tool-form .search-field input { min-width: 0; width: 0; flex: 1; }
.home-tool-form .search-field button { flex: none; display: inline-flex; align-items: center; gap: 8px; }
.home-tool-new { display: inline-flex; align-items: center; gap: 8px; }
.home-tool-card > p { margin: 0; }
.home-tool-recent { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: auto; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none; transition: background .15s, border-color .15s; }
.home-tool-recent > span { display: grid; gap: 5px; min-width: 0; }
.home-tool-recent small { color: var(--text-secondary); }
.home-tool-recent strong { overflow-wrap: anywhere; }
.home-tool-recent > svg { flex: none; }
.home-tool-recent:focus-visible { background: var(--surface-subtle); border-color: var(--text-secondary); color: var(--text); }
@media (hover: hover) and (pointer: fine) { .home-tool-recent:hover { background: var(--surface-subtle); border-color: var(--text-secondary); color: var(--text); } }

.vocabulary-browse-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px; margin-bottom: 16px; }
.vocabulary-browse-controls > label { display: grid; gap: 6px; margin: 0; color: var(--text-secondary); font-size: .8rem; font-weight: 600; }
.vocabulary-browse-controls select { min-width: 180px; max-width: 100%; margin: 0; color: var(--text); }
.vocabulary-word-type { display: block; margin-top: 4px; color: var(--muted); font-size: .72rem; font-weight: 400; }
@media (max-width: 600px) { .vocabulary-browse-controls > label { flex: 1 1 180px; min-width: 0; } .vocabulary-browse-controls select { width: 100%; min-width: 0; } }

/* Home-first navigation; the optional menu reserves space only when enabled. */
.header-language-menu { flex: none; }
/* Light surfaces need less tint for the same visible glass effect.
   Every Home tile shares the daily-goal glass surface. Scope this to Home:
   discovery cards, quests and pronunciation tiles are also used elsewhere. */
.home-dashboard { --home-tile-opacity: 100%; --home-tile-filter: none; }
@supports ((backdrop-filter: blur(14px)) or (-webkit-backdrop-filter: blur(14px))) {
  .home-dashboard { --home-tile-opacity: var(--home-glass-opacity); --home-tile-filter: blur(14px); }
}
.home-dashboard :is(a.home-daily-goal, .quest-card, .home-content-card, .activity-tile, .home-quick-link, button.home-skill-tile, button.pronunciation-guide-tile, .home-tool-card) {
  background: var(--home-tile-surface, var(--surface));
  background: color-mix(in srgb, var(--home-tile-surface, var(--surface)) var(--home-tile-opacity), transparent);
  -webkit-backdrop-filter: var(--home-tile-filter);
  backdrop-filter: var(--home-tile-filter);
}
.home-dashboard :is(.home-content-card, .activity-tile, .home-quick-link, .home-skill-tile):is(:focus-visible) {
  --home-tile-surface: var(--surface-hover);
}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .home-dashboard :is(.home-content-card, .activity-tile, .home-quick-link, .home-skill-tile):is(:hover, :focus-visible) {
  --home-tile-surface: var(--surface-hover);
} }
.home-dashboard .quest-card[data-complete="true"] {
  --home-tile-surface: color-mix(in srgb, var(--success) 6%, var(--surface));
}
.home-dashboard .pronunciation-guide-tile {
  --home-tile-surface: color-mix(in srgb, var(--accent-soft) 60%, var(--surface));
}
.home-dashboard .pronunciation-guide-tile:is(:focus-visible) {
  --home-tile-surface: var(--accent-soft);
}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .home-dashboard .pronunciation-guide-tile:is(:hover, :focus-visible) {
  --home-tile-surface: var(--accent-soft);
} }
@media (prefers-reduced-transparency: reduce) {
  .home-dashboard { --home-tile-opacity: 100%; --home-tile-filter: none; }
}

/* Header and account triggers share the same anchored theme picker. */
.header-theme-menu { flex: none; }
.theme-menu-options { display: grid; gap: 6px; }
.theme-menu-item { gap: 12px; border: 1px solid var(--preview-border); border-radius: 12px; background: var(--preview-bg); color: var(--preview-text, var(--text)); transition: border-color .12s ease, box-shadow .12s ease; }
@media (hover: hover) and (pointer: fine) { .theme-menu-item:hover { background: var(--preview-bg); color: var(--preview-text, var(--text)); border-color: var(--preview-accent); } }
.theme-menu-item[aria-checked="true"] { border-color: var(--preview-accent); box-shadow: inset 0 0 0 1px var(--preview-accent); }
.theme-menu-item.theme-preview-system { background: linear-gradient(100deg, #f5f5f5 80%, #121212 80%); border-color: #c9c9c9; --preview-text: #202020; --preview-muted: #707070; }
.theme-menu-item.theme-preview-system > .shell-icon { color: #d6d6d6; }
.theme-menu-copy { display: grid; flex: 1; gap: 1px; min-width: 0; }
.theme-menu-copy small { color: var(--preview-muted, var(--muted)); font-size: .76rem; font-weight: 450; }
.theme-menu-item > .shell-icon:last-child { color: var(--preview-accent); }
.theme-swatch, button.theme-swatch { position: relative; display: inline-block; flex: none; width: 22px; min-width: 22px; height: 22px; padding: 0; border: 1px solid rgba(128, 128, 128, .45); border-radius: 50%; background: var(--preview-bg); box-shadow: none; overflow: hidden; }
.theme-swatch::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--preview-accent); }
button.theme-swatch { cursor: pointer; transition: transform .12s var(--ease), box-shadow .12s ease; }
@media (hover: hover) and (pointer: fine) { button.theme-swatch:hover { background: var(--preview-bg); transform: scale(1.1); } }
button.theme-swatch[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.menu-theme-row { display: flex; align-items: center; gap: 11px; min-height: 42px; margin: 0 0 4px; padding: 6px 10px; color: var(--text); font-size: .92rem; font-weight: 550; }
.menu-theme-row > .shell-icon { color: var(--muted); }
.menu-theme-row > .menu-theme-label { flex: 1; min-width: 0; }
@media (max-width: 900px) { .header-theme-menu { display: none; } }
.header-language-menu > .profile-menu-popover { position: fixed; top: calc(var(--header-height) + 8px); inset-inline-start: auto; inset-inline-end: max(16px, env(safe-area-inset-right)); max-height: min(720px, calc(100dvh - var(--header-height) - 16px)); }
.app-header .header-language-trigger .learning-profile-flag { width: 34px; height: 34px; border-radius: 10px; }
@media (max-width: 380px) {
    .app-header { gap: 3px; }
    .app-header .header-home { width: 30px; }
    .app-shell .app-header button.sidebar-toggle, .app-shell .app-header button.header-language-trigger { width: 34px; min-width: 34px; }
}

.roleplay-caption[hidden] {display:none}

.roleplay-stage :is(.roleplay-speed,.roleplay-repeat) {display:flex;flex-direction:column;align-items:center;gap:4px;min-width:68px;padding:0;background:transparent;color:var(--text);border:0;box-shadow:none}
.roleplay-stage :is(.roleplay-speed,.roleplay-repeat) .coach-round-icon {display:grid;place-items:center;width:44px;height:44px;border:1px solid var(--border);border-radius:50%;background:rgba(255,255,255,.06)}
@media (hover: hover) and (pointer: fine) { .roleplay-stage :is(.roleplay-speed,.roleplay-repeat):hover:not(:disabled) .coach-round-icon {background:rgba(255,255,255,.14)} }
.roleplay-stage :is(.roleplay-speed,.roleplay-repeat) .coach-round-label {font-size:.75rem;line-height:1.2}

/* Comic pages fill the viewport; study controls sit in readable dark scrims. */
.flashcard-stage.comic-stage, .flashcard-stage.comic-stage[open] {background:#101114;display:block;padding:0;--surface:#202226;--surface-alt:#2b2d32;--text:#f5f5f6;--muted:#c1c3cb;--border:#53565f;color:var(--text)}
.comic-stage {--comic-footer-height:78px;-webkit-user-select:none;user-select:none}
.comic-stage :is(.comic-controls,.comic-interstitial,.word-info-bubble,.anchored-popover,.reader-subword-popup,.reader-popup,input,textarea,[contenteditable]) {-webkit-user-select:text;user-select:text}
.comic-background {position:absolute;inset:0;overflow:hidden;background:#000}
.comic-background,.comic-background img {-webkit-user-select:none;user-select:none;-webkit-user-drag:none;-webkit-touch-callout:none}
.comic-stage[data-comic-letterboxed="true"] .comic-background::before {content:"";position:absolute;inset:-72px;background-image:var(--comic-scene-url);background-size:var(--comic-scene-fill-width) var(--comic-scene-fill-height);background-position:center;background-repeat:no-repeat;filter:var(--app-blur-filter, blur(48px) brightness(.7));pointer-events:none}
.comic-background>img,.comic-page-layer>img {position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:100%;height:100%;max-width:none;object-fit:contain;object-position:center;display:block}
.comic-page-stage,.comic-page-layer,.comic-page-placeholder,.comic-page-preloads {position:absolute;inset:0;pointer-events:none}
.comic-page-layer {isolation:isolate;transform-origin:center center}
.comic-page-layer::before {content:"";position:absolute;z-index:-1;inset:-72px;background-image:var(--comic-page-url);background-size:cover;background-position:center;filter:var(--app-blur-filter, blur(48px) brightness(.7))}
.comic-page-stack[data-page-ready=true]>.comic-page-placeholder {display:none}
.comic-page-preloads>img {position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
.comic-page-error {position:absolute;z-index:1;left:50%;top:50%;transform:translate(-50%,-50%);max-width:calc(100% - 32px);padding:12px 16px;border-radius:16px;background:rgba(12,13,17,.8);color:#fff;pointer-events:auto}
/* Physical left/right edge cues sit above the artwork and below all reader UI. */
.comic-edge-navigation {position:absolute;inset:0;z-index:1;pointer-events:none;overflow:hidden}
.comic-edge {position:absolute;top:0;bottom:0;width:25%;color:#fff}
.comic-edge[data-direction="previous"] {left:0}
.comic-edge[data-direction="next"] {right:0}
.comic-edge-preview,.comic-edge-feedback {position:absolute;inset:0;display:flex;align-items:center;justify-content:center;opacity:0}
.comic-edge[data-direction="previous"]>:is(.comic-edge-preview,.comic-edge-feedback) {justify-content:flex-start;padding-left:clamp(12px,6vw,96px)}
.comic-edge[data-direction="next"]>:is(.comic-edge-preview,.comic-edge-feedback) {justify-content:flex-end;padding-right:clamp(12px,6vw,96px)}
.comic-edge-preview {transition:opacity .16s ease}
.comic-edge-preview>.comic-edge-arrow {opacity:.85}
.comic-edge-arrow {display:flex;align-items:center;justify-content:center;flex:none;padding:12px;border-radius:50%;background:rgb(0 0 0 / .45)}
.comic-edge-arrow>svg {width:clamp(32px,4vw,56px);height:clamp(32px,4vw,56px)}
.comic-edge[data-direction="previous"] .comic-edge-arrow>svg {transform:rotate(180deg)}
.comic-edge-navigation[data-hover="previous"] .comic-edge[data-direction="previous"]:not([data-pulsing])>.comic-edge-preview,
.comic-edge-navigation[data-hover="next"] .comic-edge[data-direction="next"]:not([data-pulsing])>.comic-edge-preview {opacity:1}
.comic-stage[data-edge-hover] {cursor:pointer}
@media(prefers-reduced-motion:reduce) {.comic-edge-preview {transition:none}}
/* Keep header menus above the segmented reading progress bar. */
.comic-topbar {position:absolute;z-index:4;inset:0 0 auto;display:flex;align-items:flex-start;justify-content:space-between;gap:20px;padding:max(16px,env(safe-area-inset-top)) max(24px,env(safe-area-inset-right)) 0 max(24px,env(safe-area-inset-left));pointer-events:none;color:#fff}
.comic-topbar>strong {position:relative;min-width:0;font-size:1.05rem;line-height:1.4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:12px 18px;max-width:calc(100% - 68px);border-radius:16px;pointer-events:auto}
.comic-topbar-actions {display:flex;gap:10px;flex-shrink:0;margin-inline-start:auto;pointer-events:none}
.comic-topbar .icon-button {position:relative;flex-shrink:0;width:48px;height:48px;border-radius:50%;pointer-events:auto}
.comic-topbar>strong,.comic-topbar .icon-button,.comic-control-scrim {background:rgba(12,13,17,.64);border:1px solid rgba(255,255,255,.18);box-shadow:0 4px 24px #0003;backdrop-filter:blur(8px) saturate(120%);-webkit-backdrop-filter:blur(8px) saturate(120%)}
.comic-controls {position:absolute;z-index:2;bottom:var(--comic-footer-height);left:max(20px,env(safe-area-inset-left),calc((100vw - 1120px)/2));right:max(20px,env(safe-area-inset-right),calc((100vw - 1120px)/2));padding:0;max-height:calc(var(--study-height,100dvh) - var(--comic-footer-height) - max(100px, calc(env(safe-area-inset-top) + 76px)));overflow:hidden;background:rgba(12,13,17,.68);border:1px solid rgba(255,255,255,.18);border-radius:22px;box-shadow:0 12px 48px #0004;backdrop-filter:blur(8px) saturate(120%);-webkit-backdrop-filter:blur(8px) saturate(120%);scrollbar-width:thin}
/* Clip a correctly aligned, blurred copy of the page beneath each scrim.
   This does not depend on backdrop-filter support or blur foreground content. */
.comic-controls-content {padding:clamp(8px,2dvh,18px) 28px;max-height:inherit;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin}
.comic-topbar>strong,.comic-topbar .icon-button,.comic-control-scrim,.comic-controls {isolation:isolate}
.comic-scrim-backdrop {display:none;position:absolute;z-index:-1;inset:0;overflow:hidden;border-radius:inherit;pointer-events:none;background:#000}
.comic-stage[data-comic-art-ready="true"] .comic-scrim-backdrop {display:block}
.comic-scrim-backdrop::before {content:"";position:absolute;inset:-48px;background-image:var(--comic-scene-url);background-repeat:no-repeat;background-size:var(--comic-scene-width) var(--comic-scene-height);background-position:calc(var(--comic-scene-left) - var(--comic-scrim-x) + 48px) calc(var(--comic-scene-top) - var(--comic-scrim-y) + 48px);filter:var(--app-blur-filter, blur(8px) saturate(1.2))}
.comic-scrim-fill {display:none;position:absolute;z-index:-1;inset:-108px;background-image:var(--comic-scene-url);background-size:var(--comic-scene-fill-width) var(--comic-scene-fill-height);background-position:calc(var(--comic-scene-fill-left) - var(--comic-scrim-x) + 108px) calc(var(--comic-scene-fill-top) - var(--comic-scrim-y) + 108px);background-repeat:no-repeat;filter:var(--app-blur-filter, blur(50px) brightness(.7))}
.comic-stage[data-comic-letterboxed="true"] .comic-scrim-fill {display:block}
.comic-scrim-backdrop::after {content:"";position:absolute;inset:0;background:var(--comic-scrim-tint,rgba(12,13,17,.64))}
.comic-controls {--comic-scrim-tint:rgba(12,13,17,.68)}
.comic-stage[data-comic-art-ready="true"] :is(.comic-topbar>strong,.comic-topbar .icon-button,.comic-control-scrim,.comic-controls) {background:transparent;backdrop-filter:none;-webkit-backdrop-filter:none}
@media (hover: hover) and (pointer: fine) { .comic-topbar .icon-button:hover {--comic-scrim-tint:rgba(12,13,17,.8)} }
.comic-stage .icon-button {color:var(--text)}
@media (hover: hover) and (pointer: fine) { .comic-stage .icon-button:hover:not(:disabled) {background:rgba(255,255,255,.14);color:#fff} }
@media (hover: hover) and (pointer: fine) { .comic-stage .comic-topbar .icon-button:hover:not(:disabled) {background:rgba(12,13,17,.8)} }
.comic-control-scrim .icon-button[aria-pressed="true"] {background:rgba(255,255,255,.16);box-shadow:inset 0 0 0 1px rgba(255,255,255,.22)}
.comic-sentence-row {display:flex;align-items:flex-start;gap:24px}
.comic-sentence-content {flex:1;min-width:0}
.comic-speaker {flex:0 0 80px;width:80px;margin:12px 0 0;text-align:center}
.comic-portrait {width:80px;height:80px;border-radius:20px;overflow:hidden;display:grid;place-items:center;background:rgba(255,255,255,.09);border:1px solid rgba(255,255,255,.2)}
.comic-portrait img {width:100%;height:100%;object-fit:cover;display:block}
.comic-speaker figcaption {font-size:.8rem;font-weight:650;line-height:1.35;margin-top:8px;overflow-wrap:anywhere;color:#fff}
.comic-narration {font-size:.75rem;color:var(--muted)}
.comic-control-scrim {position:relative;display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:6px;border-radius:20px;pointer-events:auto;width:max-content;max-width:100%}
.comic-action-controls .speech-button {width:44px;height:44px;border-radius:16px;background:transparent;color:#fff}
@media (hover: hover) and (pointer: fine) { .comic-action-controls .speech-button:hover {background:rgba(255,255,255,.14)} }
.comic-control-scrim>.icon-button {width:44px;height:44px;border-radius:16px;flex-shrink:0}
.comic-display-menu {justify-self:start}
.comic-action-controls {justify-self:center}
.comic-footer {position:absolute;z-index:2;inset:auto 0 0;display:grid;grid-template-columns:minmax(max-content,1fr) auto minmax(max-content,1fr);align-items:center;gap:clamp(6px,1.5dvh,12px);padding:0 max(24px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));pointer-events:none}
.comic-controls .guided-sentence-card {background:none;border:0;border-radius:0;box-shadow:none;padding:clamp(2px,.8dvh,8px) 0;max-height:none;overflow:visible;animation:none;-webkit-mask-image:none;mask-image:none}
.comic-controls .guided-sentence-meta>span {display:none}
.comic-controls .guided-sentence-meta {justify-content:flex-end}
.comic-controls .guided-sentence {color:#fff;font-size:clamp(1.35rem,2.6vw,2.2rem)}
.comic-translation {font-size:1rem;color:#eef0f5;margin:clamp(4px,1dvh,10px) 0}
.comic-navigation {justify-self:end;padding:6px;gap:0}
.comic-navigation .icon-button.comic-step-target {width:88px;min-width:88px;height:44px}
.comic-sentence-count {min-width:64px;text-align:center;font-size:.85rem;font-variant-numeric:tabular-nums;color:var(--muted);white-space:nowrap}
.comic-controls .secondary {background:rgba(255,255,255,.08);color:#fff;border-color:rgba(255,255,255,.22)}
@media (hover: hover) and (pointer: fine) { .comic-controls .secondary:hover:not(:disabled) {background:rgba(255,255,255,.16);border-color:rgba(255,255,255,.4)} }
.comic-empty {position:absolute;inset:80px 20px 50%;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:16px;text-align:center;color:#ddd}
.comic-stage .guided-scene-message {position:absolute;inset:80px 20px 20px;width:auto}
.comic-stage .guided-error {position:absolute;z-index:5;inset:auto auto max(18px,env(safe-area-inset-bottom)) 50%;width:min(600px,calc(100% - 40px));margin:0;background:#342226;color:#fff}
.comic-stage .guided-error > :is(.error-message,.offline-notice) {flex:1;min-width:0;overflow-wrap:anywhere}
@media(max-width:640px) {
    .comic-controls {left:max(10px,env(safe-area-inset-left));right:max(10px,env(safe-area-inset-right));border-radius:18px}
    .comic-controls-content {padding:clamp(6px,1.2dvh,12px) 14px}
    .comic-topbar{padding-left:max(16px,env(safe-area-inset-left));padding-right:max(16px,env(safe-area-inset-right))}
    .comic-sentence-row{gap:12px}
    .comic-speaker{flex-basis:52px;width:52px;margin-top:4px}
    .comic-portrait{width:52px;height:52px;border-radius:14px}
    .comic-speaker figcaption{font-size:.7rem;margin-top:4px}
    .comic-footer{gap:6px;padding-left:max(10px,env(safe-area-inset-left));padding-right:max(10px,env(safe-area-inset-right))}
}
@media(max-height:600px), (max-width:380px) {
    .comic-control-scrim {gap:4px;padding:4px;border-radius:16px}
    .comic-footer .comic-control-scrim>.icon-button,.comic-footer .comic-action-controls .speech-button {width:36px;min-width:36px;height:36px;border-radius:14px}
    .comic-controls-content {padding-block:6px}
    .comic-controls .guided-sentence-card {padding-block:2px}
    .comic-translation {margin-block:4px}
    .comic-footer {gap:4px;padding-bottom:max(4px,env(safe-area-inset-bottom))}
}
.comic-footer[data-layout="stacked"] {grid-template-columns:auto minmax(0,1fr)}
.comic-footer[data-layout="stacked"] .comic-display-menu {grid-column:1;grid-row:1}
.comic-footer[data-layout="stacked"] .comic-action-controls {grid-column:2;grid-row:1;justify-self:center}
.comic-footer[data-layout="stacked"] .comic-navigation {grid-column:1/-1;grid-row:2;justify-self:end}

/* Durable comic generation stages, with indeterminate planning and measured work. */
.comic-loading {width:min(100%,520px);text-align:left;margin:0 auto;color:var(--text)}
.comic-loading-heading {display:flex;align-items:baseline;justify-content:space-between;gap:16px;flex-wrap:wrap;margin-bottom:14px}
.comic-loading-heading strong {font-size:1.2rem}
.comic-loading-heading>span {font-size:.8rem;color:var(--muted);white-space:nowrap}
.comic-loading-bar {display:block;width:100%;height:8px;border:0;border-radius:999px;overflow:hidden;appearance:none;background:#34363d;accent-color:#d5d8e0}
.comic-loading-bar::-webkit-progress-bar {background:#34363d;border-radius:999px}
.comic-loading-bar::-webkit-progress-value {background:#d5d8e0;border-radius:999px;transition:width .35s ease}
.comic-loading-bar::-moz-progress-bar {background:#d5d8e0;border-radius:999px}
.comic-loading-bar:indeterminate {background:linear-gradient(90deg,#34363d 25%,#8f939e 50%,#34363d 75%);background-size:200% 100%;animation:comic-loading-sweep 1.8s linear infinite}
.comic-loading-bar:indeterminate::-webkit-progress-bar {background:transparent}
.comic-loading-detail {font-size:.85rem;color:var(--muted);line-height:1.6;margin:12px 0 22px}
.comic-loading-steps {list-style:none;padding:0;margin:0;display:grid;gap:18px}
.comic-loading-steps li {display:flex;align-items:center;gap:12px;font-size:.95rem;color:var(--muted)}
.comic-loading-steps li.active {color:var(--text);font-weight:600}
.comic-loading-steps li.pending {opacity:.6}
.comic-loading-marker {width:28px;height:28px;display:grid;place-items:center;flex-shrink:0;border:1px solid var(--border);border-radius:50%;font-size:.75rem}
.comic-loading-note {margin:26px 0 0;font-size:.8rem;line-height:1.6;color:var(--muted)}
.comic-preparing {overflow:auto;padding:24px 0;gap:16px;justify-content:flex-start}
.comic-preparing>.comic-preparation-card {display:flex;flex-direction:column;align-items:center;gap:16px;flex-shrink:0;margin-block:auto;width:min(100%,568px);padding:24px;border:1px solid rgba(255,255,255,.2);border-radius:22px;background:rgba(16,17,20,.82);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px)}
.comic-preparation-message {max-width:100%;overflow-wrap:anywhere}
.comic-preparation-recovery {display:grid;justify-items:center;gap:16px;margin-top:24px;text-align:center}
.comic-preparation-recovery p {margin:0;overflow-wrap:anywhere}
.comic-preparation-card>.reader-illustration-controls {margin-top:24px}
.comic-loading.compact {width:100%;margin:0 0 18px}
.comic-loading.compact .comic-loading-heading {margin-bottom:8px}
.comic-loading.compact .comic-loading-heading strong {font-size:.85rem}
.comic-loading.compact .comic-loading-detail {margin:8px 0 0;font-size:.75rem}
@keyframes comic-loading-sweep {to {background-position:-200% 0}}
@media(prefers-reduced-motion:reduce) {.comic-loading-bar:indeterminate {animation:none}.comic-loading-bar::-webkit-progress-value {transition:none}}

/* A supplied cover replaces ambient preparation art once decoded successfully. */
.loading-cover-backdrop {position:absolute;inset:0;overflow:hidden;pointer-events:none;isolation:isolate}
.loading-cover-backdrop>img {position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:center;opacity:0;transition:opacity .35s ease}
.loading-cover-backdrop[data-ready="true"]>img {opacity:1}
.loading-cover-backdrop[data-ready="true"]::after {content:"";position:absolute;inset:0;background:linear-gradient(180deg,rgba(0,0,0,.35),rgba(0,0,0,.2) 45%,rgba(0,0,0,.5))}
.comic-stage:has(.loading-cover-backdrop[data-ready="true"]) .comic-preparing>.comic-preparation-card {
  padding:24px;border:1px solid rgba(255,255,255,.2);border-radius:22px;
  background:rgba(16,17,20,.82);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);
}
@media(prefers-reduced-motion:reduce) {.loading-cover-backdrop>img {transition:none}}
@media(prefers-reduced-transparency:reduce) {.comic-stage:has(.loading-cover-backdrop) .comic-preparing>.comic-preparation-card {background:#202226;backdrop-filter:none;-webkit-backdrop-filter:none}}

/* Quiet ambient comic pages behind preparation, without competing with the text. */
.comic-loading-backdrop {position:absolute;inset:0;overflow:hidden;pointer-events:none;isolation:isolate;background:radial-gradient(ellipse at 15% 30%,#1b2331 0,transparent 60%),radial-gradient(ellipse at 90% 85%,#251e30 0,transparent 55%),#101114}
.comic-loading-backdrop::after {content:"";position:absolute;inset:0;background:radial-gradient(circle,#b5b9cc 1px,transparent 1.5px);background-size:9px 9px;opacity:.035;mask-image:linear-gradient(135deg,#000,transparent 60%)}
.comic-loading-light {position:absolute;inset:-25%;background:radial-gradient(ellipse at 25% 25%,rgba(124,153,210,.09),transparent 42%),radial-gradient(ellipse at 75% 75%,rgba(174,136,190,.07),transparent 40%);animation:comic-light-drift 22s ease-in-out infinite alternate;will-change:transform}
.comic-loading-page {position:absolute;display:grid;grid-template-columns:1fr 1fr;grid-template-rows:1fr 1.3fr;gap:12px;width:clamp(150px,22vw,310px);aspect-ratio:3/4;padding:14px;border:1px solid rgba(184,197,220,.12);border-radius:9px;opacity:.5;animation:comic-page-drift 18s ease-in-out infinite alternate;will-change:transform}
.comic-loading-page>span {border:1px solid rgba(184,197,220,.1);border-radius:3px;background:linear-gradient(140deg,rgba(184,197,220,.025),transparent)}
.comic-loading-page>span:last-child {grid-column:1/-1}
.comic-loading-page.page-one {left:-5%;top:14%;--page-angle:-16deg;animation-delay:-6s}
.comic-loading-page.page-two {right:-4%;top:12%;--page-angle:14deg;animation-duration:23s;animation-delay:-12s}
.comic-loading-page.page-three {right:17%;bottom:-30%;--page-angle:-8deg;animation-duration:26s;animation-delay:-17s;opacity:.3}
.comic-stage .comic-preparing {z-index:1}
@keyframes comic-light-drift {from {transform:translate3d(-2%,-1%,0) scale(1)} to {transform:translate3d(3%,3%,0) scale(1.06)}}
@keyframes comic-page-drift {from {transform:translate3d(0,0,0) rotate(var(--page-angle))} to {transform:translate3d(10px,-24px,0) rotate(calc(var(--page-angle) + 3deg))}}
@media(max-width:600px) {.comic-loading-page {opacity:.3}.comic-loading-page.page-one {left:-20%}.comic-loading-page.page-two {right:-20%}.comic-loading-page.page-three {bottom:-18%;right:2%}}
@media(prefers-reduced-motion:reduce) {.comic-loading-light,.comic-loading-page {animation:none;will-change:auto}.comic-loading-page {transform:rotate(var(--page-angle))}}

/* Character composition and local word lookup never require generated definitions. */
button.character-info-button { color:var(--text); background:var(--surface-subtle); }
@media (hover: hover) and (pointer: fine) { button.character-info-button:hover { color:var(--text); background:var(--accent-soft); } }
.character-info-heading { display:flex; align-items:center; gap:20px; }
.character-info-heading p { margin:4px 0 10px; }
.character-info-glyph { font-size:3.5rem; font-weight:500; }
.reader-definition-content:has(.character-info-content) { padding-block-start:0; }
.reader-definition-content .character-info-content { padding-block-start:18px; }
@media(max-width:600px) { .reader-definition-content .character-info-content { padding-block-start:10px; } }
.character-info-words > h3 { margin:0 0 4px; }
.character-word-filters { display:flex; position:sticky; top:0; z-index:2; background:var(--bg); border-bottom:1px solid var(--border); }
.workspace .character-word-filters { top:calc(var(--header-height) + var(--screen-header-offset, 0px)); }
.reader-definition-content .character-word-filters, .reader-popup-body .character-word-filters { top:0; }
.character-word-filters button { justify-content:center; padding:10px clamp(6px, 2vw, 16px); gap:6px; min-height:44px; border-radius:0; border-bottom:3px solid transparent; background:transparent; color:var(--muted); font-size:.85rem; }
.character-word-filters button[aria-pressed="true"] { border-bottom-color:var(--accent); color:var(--accent-ink); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .character-word-filters button:hover { background:var(--surface-subtle); color:var(--text); } }
.character-word-results { list-style:none; margin:0; padding:0; }
.character-word-result { display:flex; align-items:center; gap:12px; padding:14px 0; border-bottom:1px solid var(--border); }
.character-word-result > .character-word-definition { flex:1; min-width:0; }
.character-word-result strong { font-size:1.15rem; margin-inline-end:12px; }
.character-word-result p { margin:5px 0 0; overflow-wrap:anywhere; }
.character-word-result .vocabulary-save { flex:none; }
.character-word-rank { min-width:1.5em; font-variant-numeric:tabular-nums; }
.character-word-suggestions > button:last-child { margin-top:12px; }
.character-word-suggestions > p { font-size:.85rem; }

.character-stroke-details { display:grid; justify-items:center; gap:12px; margin:20px 0; }
.character-stroke-preview .skill-stroke-tools { align-items:center; }
.assistant-character-strokes { min-width:0; margin-block:12px; padding:16px; border:1px solid var(--border); border-radius:18px; background:var(--surface); }
.assistant-character-strokes > h3 { display:flex; align-items:center; gap:8px; margin:0 0 14px; font-size:1rem; }
.assistant-stroke-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,160px),1fr)); gap:20px; }
.assistant-stroke-character { min-width:0; display:flex; flex-direction:column; align-items:center; gap:10px; }
.assistant-stroke-character > header { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:10px; }
.assistant-stroke-character > header strong { font-family:var(--font-reading); font-size:1.5rem; }
.assistant-stroke-character > header span, .assistant-stroke-source { font-size:.8rem; }
.assistant-stroke-source { text-align:center; overflow-wrap:anywhere; }
.assistant-stroke-character .skill-stroke-tools { display:flex; flex-wrap:wrap; justify-content:center; gap:6px; }
.assistant-stroke-character .skill-stroke-tools button { padding:6px 8px; font-size:.8rem; }
.assistant-stroke-unavailable { margin:0; }
.character-stroke-preview { display:grid; justify-items:center; gap:8px; width:100%; }
.character-stroke-preview > svg { display:block; width:min(100%, 280px, 38dvh); aspect-ratio:1; border:1px solid var(--border); border-radius:24px; background:var(--surface-subtle); }
.character-stroke-grid { fill:none; stroke:var(--text); opacity:.12; stroke-width:3; stroke-dasharray:12 24; }
.character-stroke-art { fill:var(--text); animation:character-stroke-fill 750ms step-end var(--stroke-delay) both; }
.character-stroke-art[data-centerline="true"], .character-stroke-guides path { fill:none; stroke:var(--text); stroke-width:21; stroke-linecap:round; stroke-linejoin:round; }
.character-stroke-guides { opacity:.5; animation:character-stroke-hide 750ms step-end var(--stroke-delay) both; }
.character-stroke-guides .character-stroke-trace { stroke:#b77a14; stroke-dasharray:1; animation:character-stroke-draw 750ms linear var(--stroke-delay) both; }
.character-stroke-preview[data-paused="true"] :is(.character-stroke-art,.character-stroke-guides,.character-stroke-trace) { animation-play-state:paused; }
@keyframes character-stroke-fill { from { opacity:.25; } to { opacity:1; } }
@keyframes character-stroke-hide { from { visibility:visible; } to { visibility:hidden; } }
@keyframes character-stroke-draw { from { stroke-dashoffset:1; opacity:0; } 1% { opacity:1; } to { stroke-dashoffset:0; opacity:1; } }
@media(prefers-reduced-motion:reduce) { .character-stroke-preview .character-stroke-art { animation:none; } .character-stroke-guides, .character-stroke-pause { display:none; } }

.request-trace-button { display: inline-flex; align-items: center; gap: .4rem; margin-block: .4rem; }
.request-trace-popup .reader-popup-body {display:grid;align-content:start;background:var(--surface-subtle);gap:20px;}
.request-trace-category {display:grid;gap:18px;min-width:0;padding:20px;border:1px solid var(--border);border-radius:16px;background:var(--surface);}
.request-trace-category > h2 {margin:0;font-size:1.15rem;}
.request-trace-field {min-width:0;}
.request-trace-field > header {display:flex;align-items:center;justify-content:flex-start;gap:8px;}
.request-trace-extra > summary {cursor:pointer;font-size:.88rem;font-weight:650;color:var(--text-secondary);}
.request-trace-extra > summary .copy-text-button {vertical-align:middle;margin-inline-start:8px;}
.request-trace-field h3 {margin:0;font-size:.88rem;font-weight:650;color:var(--text-secondary);}
.request-trace-category .copy-text-button {width:28px;height:28px;min-height:28px;padding:5px;border:0;background:transparent;box-shadow:none;}
.request-trace-category pre {margin:6px 0 0;max-height:22rem;overflow:auto;white-space:pre-wrap;overflow-wrap:anywhere;padding:14px 16px;border:1px solid var(--border);border-radius:10px;background:var(--surface-subtle);font-size:.8rem;line-height:1.55;user-select:text;}
.request-trace-category .request-trace-prose {font-family:inherit;font-size:.9rem;}
.request-trace-raw {min-width:0;padding-top:12px;border-top:1px solid var(--border);}
.request-trace-raw > summary {cursor:pointer;font-size:.85rem;font-weight:600;color:var(--muted);}
.request-trace-raw > summary > span {margin-inline-end:6px;}
.request-trace-raw > summary > code {font-size:.75rem;margin-inline-end:8px;}
.request-trace-raw > summary .copy-text-button {vertical-align:middle;margin-inline-start:4px;}
@media(max-width:480px) {.request-trace-category {padding:14px;gap:14px;}.request-trace-category pre {padding:10px 12px;}}

/* Inline with the last translated character, including when the line wraps. */
.comic-translation { white-space: pre-wrap; }
.comic-translation-throbber { display: inline-block; width: .8em; height: .8em; margin-inline-start: .4em; vertical-align: -.05em; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: word-image-spin .8s linear infinite; }
@media (prefers-reduced-motion: reduce) { .comic-translation-throbber { animation: none; } }

.reader-word-keyword-image {display:block;text-align:center;pointer-events:none;user-select:none;}
.reader-word:has(.reader-word-keyword-image) {display:inline-grid;grid-template-columns:minmax(0,max-content);justify-items:center;vertical-align:baseline;}
.reader-image-hints-toggle {position:relative;}
.reader-image-hints-toggle[data-pending="true"] > svg {animation:speech-pulse 1s ease-in-out infinite;}
.reader-image-hints-error {position:absolute;right:2px;top:0;font-size:.75rem;}
@media(prefers-reduced-motion:reduce){.reader-image-hints-toggle[data-pending="true"] > svg {animation:none;opacity:.6;}}

.reader-cover-picker { margin-block: 1rem; }
.reader-cover-preview { display: block; width: min(100%, 240px); max-height: 160px; object-fit: cover; border-radius: 12px; }

/* Per-language daily goals share the header's compact ring. */
.compact-daily-goal {display:inline-flex;align-items:center;gap:7px;white-space:nowrap;font-variant-numeric:tabular-nums;font-size:inherit;font-weight:500;color:var(--text-secondary)}
.compact-daily-goal>svg {flex:none;color:var(--xp)}
.profile-quick .compact-daily-goal {font-size:.72rem;gap:5px}
.profile-quick .language-menu-choice {flex:1}
.profile-quick .language-menu-names strong {overflow-wrap:anywhere}
.profile-menu-popover:has(.compact-daily-goal) {width:min(430px,calc(100vw - 32px))}
.header-language-trigger,.home-language-trigger .home-flag {position:relative}
.profile-goal-notice {position:absolute;inset-inline-end:1px;top:1px;width:9px;height:9px;border-radius:50%;background:var(--xp);box-shadow:0 0 0 2px var(--surface);pointer-events:none}
.study-goal-choices[data-allow-break="true"] {grid-template-columns:repeat(5,minmax(0,1fr))}
@media(max-width:800px) {.study-goal-choices[data-allow-break="true"] {grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:380px) {.profile-quick {gap:7px;padding-inline:6px}.profile-quick .compact-daily-goal {font-size:.66rem;gap:3px}.profile-quick .language-menu-flag {font-size:1.1rem}.profile-quick .language-menu-choice {gap:7px}}

.profile-quick .header-xp-goal {display:inline}
.profile-goal-error {display:flex;align-items:center;gap:8px;padding:8px 10px;font-size:.75rem}
.study-goal-choices>button.study-goal-choice {width:100%}

/* The extra comic step keeps the final page visible behind a centered end card. */
.comic-topbar>strong {margin-inline-end:auto;min-width:0}
.comic-chapter-end {display:grid;justify-items:center;position:absolute;z-index:2;left:50%;top:50%;transform:translate(-50%,-50%);width:min(540px,calc(100% - 40px));max-height:calc(100dvh - 160px);overflow:auto;padding:32px;border-radius:22px;text-align:center;color:var(--text)}
.comic-chapter-end h2 {margin:0 0 24px;font-size:clamp(1.5rem,4vw,2rem);line-height:1.3}
.comic-chapter-end-actions {width:100%;display:flex;flex-wrap:wrap;justify-content:center;gap:12px}
.comic-chapter-end-actions>button {display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:44px;white-space:normal;border-radius:14px;padding:12px 18px}
.comic-chapter-end-actions>button:not(.secondary) {background:#f5f5f6;color:#202226;border-color:#f5f5f6}
.comic-chapter-end .secondary {color:var(--text);background:rgba(255,255,255,.09);border-color:var(--border)}
.comic-chapter-name {margin:16px 0 0;color:var(--muted);overflow-wrap:anywhere}
.comic-chapter-end-links {width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:12px;margin-top:20px}
.comic-chapter-end-links :is(button,a) {color:var(--muted);font-size:.85rem}
.comic-chapter-end-links>button {display:inline-flex;align-items:center;gap:6px;white-space:normal}
.comic-chapter-end .error {margin:16px 0;color:#ffc4b9}
@media(max-width:600px),(max-height:500px) {.comic-chapter-end {padding:22px}.comic-chapter-end h2 {margin-bottom:18px}.comic-chapter-end-links {margin-top:14px}}
@media(max-height:500px) {
  .comic-chapter-end {padding:18px}
  .comic-chapter-end h2 {font-size:1.5rem;margin-bottom:14px}
  .comic-chapter-end-actions>button {min-height:40px;padding:8px 14px}
  .comic-chapter-name {margin-top:12px;font-size:.85rem}
  .comic-chapter-end-links {margin-top:12px}
  .comic-chapter-end-links>button {min-height:32px;padding:6px 10px}
}

/* Reader creation: focused steps with a single-column choice list. */
.reader-story-wizard {display:grid;gap:20px;max-width:780px;margin-inline:auto}
.reader-wizard-steps {display:flex;flex-wrap:wrap;gap:12px 22px;list-style:none;padding:0;margin:0;color:var(--muted);font-size:.82rem}
.reader-wizard-steps li {display:flex;align-items:center;gap:7px}
.reader-wizard-steps li>span {display:grid;place-items:center;width:24px;height:24px;border-radius:50%;background:var(--surface-subtle)}
.reader-wizard-steps .current {color:var(--text);font-weight:700}
.reader-wizard-steps .current>span {background:var(--accent);color:var(--accent-text)}
.reader-wizard-heading {font-size:1.2rem;margin:0}
.reader-style-list,.reader-import-choices,.reader-synopsis-list {display:grid;gap:10px}
.reader-style-option {position:relative;display:flex;align-items:center;gap:14px;padding:14px 16px;border:1px solid var(--border);border-radius:14px;cursor:pointer;margin:0}
.reader-style-option>span {display:grid;gap:3px;flex:1;min-width:0}
.reader-style-option small {color:var(--muted);font-weight:400;line-height:1.4}
.reader-style-option input {position:absolute;inset:0;width:100%;height:100%;opacity:0;margin:0;cursor:inherit}
.reader-style-option:has(input:checked) {background:var(--accent-soft);border-color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}
.reader-import-choices {border-top:1px solid var(--border);padding-top:18px}
.reader-import-choices h3 {font-size:1rem;margin:0 0 4px}
.reader-import-choice {justify-content:flex-start;text-align:start;width:100%;padding:13px 16px}
.reader-import-choice>svg:last-child {margin-inline-start:auto}
.reader-visual-options[open],.reader-story-wizard .more-options[open] {display:grid;gap:16px}
.compose .reader-synopsis-topic {display:grid;gap:8px}
.reader-topic-input {display:grid;gap:10px}
.reader-topic-input input {min-width:0;width:100%}
.reader-topic-actions {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.reader-topic-actions>button {width:100%;min-width:0;min-height:44px;justify-content:center;text-align:center;white-space:normal;overflow-wrap:anywhere}
.reader-synopsis-option {width:100%;display:flex;gap:16px;align-items:center;justify-content:space-between;padding:18px;text-align:start;white-space:normal}
.reader-synopsis-option>span {display:grid;gap:7px;min-width:0}
.reader-synopsis-option>span>span {font-weight:400;color:var(--text-secondary);line-height:1.5}
.reader-synopsis-option>svg {flex:none}
.reader-wizard-actions {border-top:1px solid var(--border);padding-top:18px}
@media(max-width:500px) {.reader-style-option {padding:12px;gap:12px}}
.reader-synopsis-status {display:flex;align-items:center;gap:10px;min-height:48px;font-size:.9rem}
.reader-story-wizard .sr-only {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
.reader-wizard-actions {position:sticky;bottom:-24px;z-index:1;background:var(--surface);padding-block:16px 24px}
@media(max-width:600px) {.reader-wizard-actions {bottom:-16px;padding-bottom:16px}}

.home-thumbnail-type {position:absolute;right:12px;top:12px;display:grid;place-items:center;color:#fff;pointer-events:none;filter:drop-shadow(0 1px 2px #0009) drop-shadow(0 0 3px #0004)}
.home-content-type-name {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}

/* Libraries share Home's discovery cards, followed by compact cover-art rows. */
.library-create-grid {--discovery-card-height:30rem;container:content-tiles / inline-size;display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,270px),1fr));gap:16px;margin-bottom:30px;align-items:stretch}
.library-discovery {min-width:0;container:discovery-layout / inline-size}
/* Weight the creation column only when every discovery tile fits on one row. */
@container discovery-layout (min-width:556px) {
  :is(.home-content-grid,.library-create-grid):has(> :nth-child(2):last-child) {grid-template-columns:minmax(0,3fr) minmax(0,2fr);--create-art-aspect:32 / 27}
}
@container discovery-layout (min-width:842px) {
  :is(.home-content-grid,.library-create-grid):has(> :nth-child(3):last-child) {grid-template-columns:minmax(0,3fr) minmax(0,3fr) minmax(0,2fr);--create-art-aspect:32 / 27}
}
/* With two content cards on the first row, both actions fill the row below.
   A single content card keeps its existing stacked action column beside it. */
@container discovery-layout (min-width:556px) and (width < 842px) {
  .home-content-grid > .home-create-column:nth-child(3):last-child { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); height: 11rem; min-height: 0; }
}
.library-content-list {display:grid;gap:14px}
article.library-content-card {display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:stretch;min-width:0}
.library-content-open {display:grid;grid-template-columns:210px minmax(0,1fr);align-items:center;min-width:0;color:inherit;text-decoration:none}
.library-thumbnail {align-self:stretch;height:100%;min-height:128px;aspect-ratio:auto}
.library-thumbnail .book-cover {max-height:100px}
.library-content-copy {padding:20px;min-width:0;gap:9px}
.library-content-details {display:grid;justify-items:start;gap:9px;min-width:0;color:var(--text-secondary);font-size:.9rem}
.library-content-details .tag {margin:0}
.library-content-details .meter {width:100%}
.library-content-actions {display:flex;align-items:center;justify-content:center;padding:12px;min-width:0}
.library-content-actions .confirm-inline {flex-wrap:wrap;justify-content:flex-end}
.roleplay-archive .library-content-card {margin-top:12px}
@media(max-width:800px){.library-content-open {grid-template-columns:160px minmax(0,1fr)}.library-content-copy {padding:16px;gap:8px}}
@media(max-width:600px){.library-content-open {grid-template-columns:110px minmax(0,1fr)}.library-content-copy {padding:14px 12px}.library-content-copy>strong {font-size:1rem}.library-content-actions {padding:6px}.library-thumbnail {min-height:120px}.library-thumbnail .book-cover {transform:none;max-width:76px}.library-content-card:has(.confirm-inline) {grid-template-columns:minmax(0,1fr)}.library-content-actions:has(.confirm-inline) {justify-content:flex-end;border-top:1px solid var(--border);padding:10px}.library-content-actions .confirm-inline {justify-content:flex-start}}

/* Guided welcome uses the onboarding poster's gradient over full-bleed art. */
.comic-welcome-art {position:absolute;inset:0}
.comic-welcome-art .comic-background>img {object-fit:cover}
.comic-welcome-art .comic-empty {z-index:3}
.comic-welcome-art .loading-cover-backdrop[data-ready="true"]::after {content:none}
.comic-welcome-scrim {pointer-events:none;z-index:1}
.comic-welcome-scene {position:absolute;z-index:2;inset:0;display:flex;flex-direction:column;align-items:flex-start;overflow:auto;padding:calc(max(16px,env(safe-area-inset-top)) + 64px) max(clamp(16px,5vw,72px),env(safe-area-inset-right)) max(clamp(20px,5vh,64px),env(safe-area-inset-bottom)) max(clamp(16px,5vw,72px),env(safe-area-inset-left))}
.comic-welcome {display:grid;justify-items:start;gap:clamp(10px,2.4vh,22px);width:min(720px,100%);min-width:0;margin-block-start:auto;color:#fff;text-shadow:0 2px 12px rgb(0 0 0 / .6)}
.comic-welcome h2 {margin:0;color:inherit;font-size:clamp(1.6rem,4.6vw,3.35rem);line-height:1.17;text-wrap:balance}
.comic-welcome p {margin:0;line-height:1.5}
.comic-welcome-options {display:flex;min-width:0}
.comic-welcome-option {display:inline-flex;align-items:center;gap:10px;min-width:0}
.comic-welcome-option>span {font-size:.95rem;line-height:1.4;overflow-wrap:anywhere}
.comic-welcome-actions {display:flex;flex-wrap:wrap;gap:10px}
.comic-welcome-actions>button {min-height:44px;max-width:100%;white-space:normal}
.comic-welcome-actions>button:not(.secondary) {background:#f5f5f6;color:#202226;border-color:#f5f5f6}
.comic-welcome-title-row {display:grid;grid-template-columns:44px minmax(0,1fr);align-items:start;gap:12px;max-width:100%;text-align:start}
.comic-welcome-title-copy {display:grid;gap:8px;min-width:0;overflow-wrap:anywhere}
.comic-welcome-narration .speech-button {width:44px;height:44px;min-width:44px;padding:0;border-radius:50%}
.comic-welcome-narration .speech-button-icon {width:100%;height:100%}
@media(max-height:600px) {.comic-welcome-scrim {--poster-scrim-midpoint:32%}}
.comic-replay-keywords {display:inline-flex;align-items:center;gap:6px;padding:6px 10px;font-size:.85rem;justify-self:end}
/* Beside the narrator or speaker, at the heading row's end. */
.comic-sentence-heading .comic-replay-keywords {flex:none;margin:0;margin-inline-start:auto}
/* The two ways into a story (reading.rs): a tinted tile each, with the mode's
   illustration, its name and what it is like, and an arrow. The recommended one
   is outlined in its tint and wears the Recommended badge. */
.content-reading-actions {display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);grid-auto-rows:1fr;gap:12px}
.content-reading-action {display:grid;min-width:0}
.content-reading-guided {--mode:#3d8fe0}
.content-reading-full {--mode:#7b6fd0}
:is(button,a).content-reading-button {position:relative;display:grid;grid-template-columns:64px minmax(0,1fr) auto;align-items:center;gap:14px;width:100%;height:100%;min-height:96px;margin:0;padding:14px 16px 14px 12px;border:1px solid color-mix(in srgb,var(--mode) 22%,var(--border));border-radius:18px;background:linear-gradient(115deg,color-mix(in srgb,var(--mode) 13%,transparent),transparent 70%),var(--surface);box-shadow:0 1px 2px rgb(0 0 0 / .04),0 8px 22px -16px color-mix(in srgb,var(--mode) 55%,transparent);color:var(--text);font:inherit;font-weight:400;text-align:start;text-decoration:none;white-space:normal;cursor:pointer;transition:border-color .15s ease,box-shadow .15s ease,transform .15s ease}
.content-reading-button[data-recommended="true"] {border-color:color-mix(in srgb,var(--mode) 65%,var(--border));box-shadow:0 0 0 1px color-mix(in srgb,var(--mode) 45%,transparent),0 12px 28px -14px color-mix(in srgb,var(--mode) 70%,transparent);background:linear-gradient(115deg,color-mix(in srgb,var(--mode) 20%,transparent),transparent 75%),var(--surface)}
@media (hover:hover) and (pointer:fine) {:where(:root:not([data-touch-input])) :is(button,a).content-reading-button:not(:disabled):hover {border-color:color-mix(in srgb,var(--mode) 70%,var(--border));transform:translateY(-1px);box-shadow:0 1px 2px rgb(0 0 0 / .04),0 14px 30px -14px color-mix(in srgb,var(--mode) 70%,transparent)}}
:is(button,a).content-reading-button:active {transform:translateY(0)}
button.content-reading-button:disabled {opacity:.55;cursor:default}
.content-reading-art {display:grid;place-items:center;width:64px;height:64px;border-radius:16px;background:color-mix(in srgb,var(--mode) 10%,var(--surface));overflow:hidden}
.content-reading-art img {display:block;width:100%;height:100%;object-fit:contain;padding:4px;box-sizing:border-box}
.content-reading-copy {display:grid;justify-items:start;gap:3px;min-width:0}
.content-reading-labels {display:flex;align-items:center;flex-wrap:wrap;gap:4px 8px;min-width:0;}
.content-reading-title {font-size:1.05rem;font-weight:700;line-height:1.25;color:color-mix(in srgb,var(--mode) 30%,var(--text))}
.content-reading-help {display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;font-size:.82rem;line-height:1.35;color:var(--text-secondary)}
.content-reading-arrow {display:grid;place-items:center;width:34px;height:34px;border-radius:50%;background:color-mix(in srgb,var(--mode) 14%,var(--surface));color:color-mix(in srgb,var(--mode) 75%,var(--text));transition:background .15s ease,color .15s ease}
.content-reading-button[data-recommended="true"] .content-reading-arrow {background:var(--mode);color:#fff}
@media (max-width:760px) {.content-reading-actions {grid-template-columns:minmax(0,1fr)} :is(button,a).content-reading-button {min-height:84px}}
/* "Recommended", wherever the content page suggests the next step: the lavender
   pill (below) with a sparkle. */
.topic-recommended {display:inline-flex;align-items:center;gap:4px;width:max-content;line-height:1.25;white-space:nowrap}
.topic-recommended svg {flex:none}

/* Comic checkpoints keep the question, feedback, and answer in separate cards.
   Scroll the whole stack on short screens so no card can squeeze another away. */
.comic-interstitial {position:absolute;z-index:3;inset:96px max(16px,calc((100vw - 960px)/2)) max(16px,env(safe-area-inset-bottom));display:flex;flex-direction:column;align-items:center;gap:20px;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;pointer-events:auto;padding:2px}
.comic-question-panel,.comic-question-dock,.comic-question-feedback {flex:none;min-width:0;isolation:isolate;position:relative;color:var(--text);border-radius:22px;padding:24px;border:1px solid rgba(255,255,255,.18);box-shadow:0 10px 36px #0003}
.comic-question-panel {width:min(760px,100%);margin-block:auto;display:grid;justify-content:stretch;gap:14px;text-align:center}
.comic-question-panel h2 {font-size:.85rem;letter-spacing:.03em;color:var(--muted);margin:0}
.comic-question-heading {display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:start}
.comic-question-explanation {font-size:clamp(1.25rem,3vw,1.8rem);line-height:1.4;margin:0;overflow-wrap:anywhere}
.comic-question-target {font-size:clamp(1rem,2.5vw,1.35rem);line-height:1.5;margin:0;color:var(--text-secondary);overflow-wrap:anywhere}
.comic-question-response {flex:none;width:min(760px,100%);display:grid;gap:12px;margin-top:auto}
.comic-question-dock {width:100%;display:grid;justify-content:stretch;justify-items:stretch;gap:16px}
.comic-question-dock>form.guided-translation {width:100%;max-width:none;margin:0;justify-self:stretch;gap:12px}
.comic-question-dock .guided-answer-row {grid-template-columns:minmax(0,1fr) 44px}
.comic-question-dock .guided-answer-row textarea {width:100%;max-height:160px;grid-row:1 / span 2}
.comic-question-dock .guided-answer-row .recording-auto-button {grid-row:2}
.comic-question-dock textarea {min-height:72px;resize:vertical}
/* The mic button already indicates recording; the tiny level meter reads as a stray square. */
.comic-question-dock .guided-microphone meter {display:none}
.comic-question-actions {display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:10px;padding-top:4px}
.comic-question-actions .comic-question-back,.comic-question-actions .comic-question-skip {display:inline-flex;align-items:center;gap:6px;color:var(--text)}
.comic-question-actions .comic-question-back {margin-inline-end:auto}
.comic-question-feedback {width:100%;display:grid;gap:12px;justify-content:stretch;font-size:1rem;line-height:1.55;text-align:start;--grade-1:#ffaaa2;--grade-2:#ffc28a;--grade-3:#f5d66f;--grade-4:#8ce0aa;--grade-5:#85caff}
.comic-question-result {display:flex;align-items:center;flex-wrap:wrap;gap:12px 18px}
.comic-question-score {display:flex;align-items:baseline;gap:6px;color:var(--grade);font-variant-numeric:tabular-nums;line-height:1}
.comic-question-score strong {font-size:clamp(2.5rem,6vw,3.25rem);font-weight:800}
.comic-question-score>span {font-size:1.3rem;font-weight:650}
.comic-question-stars {display:flex;gap:3px;font-size:1.4rem;color:var(--grade)}
.comic-question-stars .unearned {color:rgba(255,255,255,.2)}
.comic-question-feedback p {margin:0;overflow-wrap:anywhere}
.comic-question-hint {color:var(--text-secondary);padding-top:12px;border-top:1px solid var(--border)}
.comic-question-xp {display:inline-flex;align-items:center;gap:7px;margin-inline-start:auto;padding:8px 12px;border-radius:999px;background:rgba(219,160,255,.12);color:#e3b5ff;font-size:1rem;font-weight:750;white-space:nowrap}
.comic-question-xp svg {width:20px;height:20px}
.comic-submitted-answer {display:grid;gap:8px;min-width:0}
.comic-answer-label {font-size:.78rem;font-weight:650;color:var(--muted)}
.comic-submitted-answer p {margin:0;font-size:1.15rem;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere}
.comic-answer-checking {display:flex;align-items:center;gap:10px;color:var(--text-secondary);font-size:.95rem}
.comic-answer-checking .word-illustration-spinner {flex:none;width:20px;height:20px}
.comic-question-dock .error {color:#ffc4b9;overflow-wrap:anywhere}
@media(max-width:600px),(max-height:600px){.comic-interstitial {inset:78px 10px max(10px,env(safe-area-inset-bottom));gap:14px}.comic-question-panel,.comic-question-dock,.comic-question-feedback {padding:16px;border-radius:18px}.comic-question-panel {gap:10px}.comic-question-dock {gap:12px}.comic-question-dock textarea {min-height:64px}.comic-question-dock .comic-question-actions button {padding:9px 12px}.comic-question-result {gap:10px}.comic-question-stars {font-size:1.15rem}.comic-question-xp {padding:6px 10px}}

/* Complete scene and matching mask always share the same crop and crossfade. */
.roleplay-raster-scene {position:absolute;inset:0;isolation:isolate}
.roleplay-pose {position:absolute;inset:0;opacity:0;transition:opacity 180ms ease;pointer-events:none;isolation:isolate;mix-blend-mode:plus-lighter}
.roleplay-pose[data-active="true"] {opacity:1}
.roleplay-pose img {position:absolute;inset:0;width:100%;height:100%;object-fit:cover;object-position:center}
.roleplay-character-mask {mix-blend-mode:plus-lighter;opacity:0}
.roleplay-stage:has(.roleplay-live-controls[data-state="speaking"]) .roleplay-character-mask {animation:roleplay-character-pulse 1100ms ease-in-out infinite}
@keyframes roleplay-character-pulse {0%,100% {opacity:0} 50% {opacity:.125}}
@media(prefers-reduced-motion:reduce){.roleplay-pose{transition:none}.roleplay-stage .roleplay-character-mask{animation:none!important}.roleplay-stage:has(.roleplay-live-controls[data-state="speaking"]) .roleplay-character-mask{opacity:.075}}

.roleplay-stage .roleplay-repeat {min-width:56px}
@media(max-width:700px){.roleplay-live-controls .roleplay-control-row{gap:8px}}

.coach-stage-center.coach-stage-checkpoint{grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr);align-items:center;overflow:auto}
.coach-stage-checkpoint>.coach-stage-visual,.coach-stage-checkpoint>.coach-stage-words,.coach-stage-checkpoint>.coach-stage-foot{display:none}
.coach-checkpoint-card{display:grid;justify-items:center;gap:16px;width:min(100%,480px);max-height:100%;overflow:auto;padding:30px;border-radius:24px}
.coach-checkpoint-card h2,.coach-checkpoint-card p{margin:0}
.coach-checkpoint-card>svg{width:40px;height:40px;color:var(--accent)}
.coach-checkpoint-bonus{color:var(--accent);font-size:1.2rem}
.coach-checkpoint-card small{color:var(--muted)}
@media(min-width:700px) and (max-height:520px){
  .coach-checkpoint-invitation{width:min(100%,640px);grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:8px 16px;padding:14px 20px}
  .coach-checkpoint-invitation>svg{display:none}
  .coach-checkpoint-invitation h2{grid-column:1;grid-row:1;font-size:1.2rem}
  .coach-checkpoint-invitation>p:first-of-type{grid-column:1;grid-row:2}
  .coach-checkpoint-invitation>.coach-checkpoint-bonus{grid-column:1;grid-row:3;align-self:center}
  .coach-checkpoint-invitation>p:last-of-type{grid-column:2;grid-row:1 / 3;align-self:center}
  .coach-checkpoint-invitation>.coach-stage-actions{grid-column:2;grid-row:3;padding:0;gap:8px}
  .coach-checkpoint-invitation>small{grid-column:1 / -1;grid-row:4}
}

/* Listening shares Speaking's hands-free stage and has a separate podcast flow. */
.listening-difficulties {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin:16px 0}
.listening-difficulties>button {display:grid;align-content:start;gap:8px;text-align:start;white-space:normal;padding:18px;border:1px solid var(--border);border-radius:16px}
.listening-difficulties>button.selected {border-color:var(--text);box-shadow:inset 0 0 0 1px var(--text);background:var(--surface-hover)}
.listening-difficulties>button>span {font-size:.9rem;font-weight:400;line-height:1.5;color:var(--text-secondary)}
.listening-topic-preview {padding:20px;border:1px solid var(--border);border-radius:16px;display:grid;gap:14px}
/* Podcast preparation card, shown before the player mounts. */
.listening-preparation-frame{position:absolute;inset:0;z-index:1;display:grid;place-items:center;overflow:auto;padding:100px 20px 30px}
.listening-preparation{width:min(580px,100%);padding:clamp(22px,5vw,40px);display:grid;gap:18px}
.listening-preparation :is(h2,p){margin:0}
.listening-loading-progress{padding:0;background:none;border:0;text-align:start}
.listening-loading-progress .comic-loading-steps{margin:14px 0 0}
/* Listening stage: the cover art is softened behind one focused player; the
   companion docks beside it on wide screens and slides up as a sheet on phones. */
.listening-stage .loading-cover-backdrop>img{transform:scale(1.12);filter:var(--app-blur-filter, blur(28px) saturate(1.15) brightness(.72))}
.listening-stage .loading-cover-backdrop[data-ready="true"]::after{background:linear-gradient(180deg,rgba(8,10,14,.5),rgba(8,10,14,.28) 40%,rgba(8,10,14,.62))}
.listening-stage-live{grid-template-rows:minmax(0,1fr);gap:0;padding:calc(max(12px,env(safe-area-inset-top)) + 66px) max(14px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left))}
.listening-workspace{display:grid;grid-template-columns:minmax(0,1fr);width:100%;max-width:620px;min-height:0;margin:0 auto}
.listening-stage :is(.listening-player,.listening-companion,.listening-preparation){background:rgba(18,22,28,.68);backdrop-filter:blur(26px) saturate(1.2);-webkit-backdrop-filter:blur(26px) saturate(1.2);border:1px solid rgba(255,255,255,.18);box-shadow:0 18px 60px #0004;border-radius:26px}
.listening-player{display:flex;flex-direction:column;gap:18px;min-height:0;padding:clamp(18px,3vw,28px);overflow:auto;overscroll-behavior:contain}
.listening-player :is(h2,h3,p){margin:0}
.listening-player h2{font-size:clamp(1.25rem,2.6vw,1.7rem);line-height:1.2;text-wrap:balance}
.listening-player h3{font-size:clamp(1.15rem,2.4vw,1.4rem);line-height:1.4}
.listening-player small{font-size:.74rem;letter-spacing:.08em;text-transform:uppercase;color:var(--text-secondary)}
.listening-episode-heading{display:flex;align-items:center;gap:16px}
.listening-episode-copy{display:grid;gap:6px;min-width:0}
.listening-cover{width:72px;aspect-ratio:1;flex-shrink:0;display:grid;place-items:center;overflow:hidden;border-radius:16px;background:linear-gradient(140deg,#598089,#35304d);box-shadow:0 8px 30px #0004}
.listening-cover img{width:100%;height:100%;object-fit:cover}
.listening-progress-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:12px;font-size:.8rem;color:var(--text-secondary)}
.listening-episode-progress{width:100%;height:4px;margin:0;accent-color:#c8e9dd}
.listening-hero{display:grid;flex:1 1 auto;align-content:center;gap:14px;min-height:96px}
.listening-caption{font-size:clamp(1.2rem,2.4vw,1.55rem);font-weight:500;line-height:1.6;overflow-wrap:anywhere}
.listening-status{display:flex;align-items:center;gap:8px;font-size:.85rem;color:var(--text-secondary)}
.listening-status-dot{width:8px;height:8px;flex:none;border-radius:50%;background:currentColor;opacity:.7}
[data-state="speaking"] .listening-status-dot{background:#c8e9dd;opacity:1;animation:coach-breathe 1.2s ease-in-out infinite}
[data-state="thinking"] .listening-status-dot{animation:coach-breathe .9s ease-in-out infinite}
.listening-note{font-size:.85rem;line-height:1.5;color:var(--text-secondary)}
.listening-welcome{gap:16px}
.listening-welcome>p:first-child{font-size:1.05rem;line-height:1.6}
.listening-welcome .switch-row{margin:0;padding:12px 0;border-top:1px solid var(--border);border-bottom:1px solid var(--border)}
.listening-welcome .switch-copy small{display:block;margin-top:2px;font-size:.85rem;font-weight:400;letter-spacing:0;line-height:1.5;text-transform:none;color:var(--text-secondary)}
.listening-start{width:100%;justify-content:center;gap:10px;min-height:54px;font-size:1.05rem}
.listening-answer{display:flex;align-items:center;gap:8px;padding:6px;border:1px solid var(--border);border-radius:16px;background:#0006}
.listening-answer input{flex:1;min-width:0;border:0;background:transparent;box-shadow:none;color:inherit}
.listening-score{display:flex;align-items:baseline;gap:14px;color:#ffc369}
.listening-score.good{color:#8fe0ac}
.listening-score>strong,.listening-earned{font-size:2rem;font-weight:750}
.listening-score>span,.listening-earned{color:#e6a5ef}
.listening-complete{justify-items:start}
.listening-transport{display:grid;grid-template-columns:minmax(0,1.6fr) minmax(0,1fr) minmax(0,1fr);gap:8px}
.listening-transport button{min-height:50px;justify-content:center;gap:8px;padding-inline:12px;white-space:nowrap}
.listening-speed{font-weight:500;opacity:.8}
.listening-footer{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
.listening-footer button{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:8px 14px;font-size:.85rem}
.listening-footer .listening-end{margin-inline-start:auto}
.listening-error,.listening-notice{display:grid;gap:8px;padding:12px 14px;border-radius:14px;font-size:.9rem;line-height:1.5}
.listening-error{background:#613a3a66}
.listening-notice{background:#ffffff10;color:var(--text-secondary)}
.listening-companion{display:flex;flex-direction:column;gap:14px;min-height:0;padding:18px;overflow:hidden}
.listening-panel-tabs{display:flex;flex-shrink:0;align-items:center;gap:8px}
.listening-panel-tabs>button:not(.icon-button){flex:1}
.listening-panel-tabs>.icon-button{display:none;color:var(--text)}
.listening-conversation,.listening-transcript{flex:1;min-height:80px;overflow:auto;overscroll-behavior:contain;line-height:1.65}
.listening-exchange{border-bottom:1px solid var(--border);padding-block:12px}
.listening-exchange p{margin:0 0 12px;white-space:pre-wrap}
.listening-exchange .listening-learner{padding:10px 14px;background:#ffffff10;border-radius:14px;margin-inline-start:24px}
.listening-transcript section{padding:14px;border:1px solid transparent;border-radius:16px;margin-bottom:10px}
.listening-transcript section.current{border-color:#ffffff30;background:#ffffff08}
.listening-transcript h3{font-size:.85rem;color:var(--text-secondary);margin:0 0 10px}
.listening-transcript .current-sentence{color:#dcfff3;background:#c8e9dd15;border-radius:6px}
.listening-transcript p{margin:10px 0}
.listening-quick-questions{display:flex;flex-wrap:wrap;gap:8px;flex-shrink:0}
.listening-quick-questions button{font-size:.78rem;min-height:36px;padding:8px 12px;white-space:normal}
.listening-type{display:flex;align-items:center;gap:6px;padding:6px;border:1px solid var(--border);border-radius:16px;background:#0006;flex-shrink:0}
.listening-type input{min-width:0;flex:1;background:transparent;border:0;box-shadow:none;color:inherit}
.listening-type .icon-button{color:var(--text)}
.listening-sheet-scrim{display:none}
@media(min-width:980px){
 .listening-footer .listening-open{display:none}
 .listening-workspace{grid-template-columns:minmax(0,1.15fr) minmax(320px,.85fr);gap:20px;max-width:1120px}
}
@media(max-width:979px){
 .listening-sheet-scrim{display:block;position:fixed;inset:0;z-index:4;background:#0009;opacity:0;pointer-events:none;transition:opacity .25s ease}
 .listening-companion{position:fixed;z-index:5;inset:auto 0 0;background:rgba(18,22,28,.9);max-height:min(84dvh,calc(100dvh - 72px));padding-bottom:max(18px,env(safe-area-inset-bottom));border-bottom:0;border-radius:24px 24px 0 0;transform:translateY(105%);visibility:hidden;transition:transform .3s var(--ease),visibility 0s .3s}
 .listening-workspace[data-sheet="true"] .listening-companion{transform:none;visibility:visible;transition:transform .3s var(--ease)}
 .listening-workspace[data-sheet="true"] .listening-sheet-scrim{opacity:1;pointer-events:auto}
 .listening-panel-tabs>.icon-button{display:inline-grid}
}
@media(max-width:600px){
 .listening-stage-live{padding:calc(max(12px,env(safe-area-inset-top)) + 58px) max(10px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left))}
 .listening-player{padding:16px;gap:14px;border-radius:22px}
 .listening-cover{width:64px;border-radius:14px}
 .listening-transport{grid-template-columns:minmax(0,1.5fr) auto auto}
 .listening-transport button{padding-inline:10px}
 .listening-difficulties{grid-template-columns:1fr}
}
@media(prefers-reduced-motion:reduce){.listening-companion,.listening-sheet-scrim{transition:none}.listening-status-dot{animation:none !important}}
@media(prefers-reduced-transparency:reduce){.listening-stage :is(.listening-player,.listening-companion,.listening-preparation){background:#232b31;backdrop-filter:none;-webkit-backdrop-filter:none}}

@media (max-width: 760px) and (prefers-reduced-transparency: reduce) {
  .sidebar::before { background: var(--sidebar); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ---------- Channels and the feed ---------- */
.home-feed-sections { gap: 16px; }
/* Standard discovery grids add columns as their container grows. */
.feed-grid { --discovery-card-height: 30rem; container: content-tiles / inline-size; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@container discovery-layout (min-width: 620px) { .feed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container discovery-layout (min-width: 1360px) { .feed-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@container discovery-layout (min-width: 940px) { .activity-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.feed-grid :is(.home-recent-card, .home-suggestion, .feed-flashcards-card, .feed-preparing) { height: var(--discovery-card-height); min-height: 0; }
.feed-grid .home-suggestion-tile { height: 100%; }
.feed-card { display: grid; gap: 8px; min-width: 0; }
.feed-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; padding: 0 4px; }
.feed-card-actions { display: flex; align-items: center; gap: 6px; }
.feed-content { display: grid; gap: 8px; min-width: 0; }
.feed-eyebrow-activity { color: var(--muted); font-weight: 550; }
.feed-loading, .feed-preparing { min-height: 160px; }
.feed-empty { display: grid; justify-items: center; gap: 12px; }
.feed-empty .empty-state { padding: 16px; }
.feed-empty-action { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.feed-flashcards-card { position: relative; align-content: center; justify-items: center; background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.feed-flashcards-art { position: absolute; inset: 0; display: grid; place-items: center; color: var(--accent); opacity: .18; pointer-events: none; }
.feed-flashcards-card .shell-icon { flex: none; }
.channel-chip { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; min-height: 28px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: .78rem; font-weight: 650; text-decoration: none; transition: border-color .15s ease, background-color .15s ease, color .15s ease; }
@media (hover: hover) and (pointer: fine) { .channel-chip:hover { border-color: var(--border-strong); background: var(--surface-hover); color: var(--text); } }
.channel-chip-own { cursor: default; }
.channel-chip-icon { font-size: .95rem; line-height: 1; }
.channel-chip-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-chip-large { width: fit-content; font-size: .9rem; min-height: 44px; padding: 10px 14px; }
.channels-page, .channel-page { display: grid; gap: 24px; min-width: 0; }
.lists-page { display: grid; gap: 32px; min-width: 0; }
.lists-section { display: grid; gap: 16px; min-width: 0; }
.lists-section-heading { margin: 0; font-size: 1.35rem; }
.lists-view-all { color: inherit; text-decoration: none; justify-content: space-between; }
.lists-view-all .vocabulary-collection-copy { display: grid; gap: 4px; }
.lists-view-all small { font-size: .875rem; }
.lists-page .vocabulary-collection-copy p { margin-bottom: 0; }
.lists-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); max-width: 760px; }
.channels-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.channels-toolbar > button { display: inline-flex; align-items: center; gap: 8px; }
.channel-list { display: grid; gap: 12px; }
.channel-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 14px 8px 8px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.channel-row-muted { background: color-mix(in srgb, var(--surface) 72%, transparent); border-color: color-mix(in srgb, var(--border) 72%, transparent); }
.channel-row-muted .channel-row-open { opacity: .72; }
.channel-row-open { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; min-width: 0; padding: 8px; border-radius: 12px; color: inherit; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .channel-row-open:hover { background: var(--surface-hover); } }
.channel-row-icon { display: grid; place-items: center; flex: none; width: 46px; height: 46px; border-radius: 14px; background: var(--surface-subtle); color: var(--text-secondary); font-size: 1.5rem; line-height: 1; }
.channel-row-copy { display: grid; gap: 2px; min-width: 0; }
.channel-row-copy strong { overflow-wrap: anywhere; }
.channel-row-switch { margin: 0; }
.channel-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px 24px; }
.channel-header-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.channel-header-icon { display: grid; place-items: center; flex: none; width: 64px; height: 64px; border-radius: 20px; background: var(--surface-subtle); color: var(--text-secondary); font-size: 2rem; line-height: 1; }
.channel-header-copy { display: grid; gap: 4px; min-width: 0; }
.channel-header-copy h1 { margin: 0; overflow-wrap: anywhere; }
.channel-header-copy .home-hero-eyebrow { margin: 0; }
.channel-topic { margin: 0; max-width: 60ch; }
.channel-header-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.channel-header-actions > button { display: inline-flex; align-items: center; gap: 8px; }
.art-style-field { display: grid; gap: 7px; width: min(100%, 480px); min-width: 0; }
.art-style-label { color: var(--text-secondary); font-size: .82rem; font-weight: 650; }
.art-style-trigger { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 6px 10px; text-align: start; }
.art-style-trigger span { flex: 1; }
.art-style-trigger img,.art-style-option img,.topic-art-style-value img { display: block; flex: none; border-radius: 8px; object-fit: cover; }
.art-style-options { position: relative; margin-top: 4px; max-height: min(420px, 50dvh); overflow-y: auto; overscroll-behavior: contain; padding: 7px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 28px rgba(0,0,0,.16); }
.art-style-option { display: flex; align-items: center; gap: 14px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: transparent; color: var(--text); text-align: start; }
.art-style-option span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.art-style-option svg { flex: none; }
.art-style-option.selected { background: var(--surface-subtle); }
@media (hover: hover) and (pointer: fine) { .art-style-option:hover { background: var(--surface-subtle); } }
.channel-follow-switch { margin: 0; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.channel-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.channel-stat { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-secondary); font-size: .82rem; font-weight: 600; text-decoration: none; }
@media (hover: hover) and (pointer: fine) { .channel-stat:hover { border-color: var(--border-strong); color: var(--text); } }
.channel-filter-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.channel-filter { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 600; }
.channel-filter select { width: auto; min-width: 180px; }
.channel-filter-row .secondary, .channel-ideas-menu > button { display: inline-flex; align-items: center; gap: 6px; }
.channel-ideas-menu { position: relative; }
.channel-section .section-heading { margin-bottom: 12px; }
.channel-empty-note { margin: 0 0 12px; }
.channel-failure { display: grid; gap: 8px; margin-bottom: 12px; }
.channel-create-row { display: flex; flex-wrap: wrap; gap: 10px; }
.channel-create-row > button { display: inline-flex; align-items: center; gap: 8px; }
.channel-detach { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; }
.channel-editor { display: grid; gap: 14px; }
.channel-editor label { display: grid; gap: 6px; }
.channel-editor textarea { width: 100%; min-width: 0; resize: vertical; }
.channel-editor-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.channel-editor-delete { display: inline-flex; align-items: center; gap: 6px; margin-inline-end: auto; }
.channel-icon-input { width: 80px; text-align: center; font-size: 1.2rem; }
.channel-create-icon {display:flex;align-items:center;gap:16px;flex-wrap:wrap;}
.channel-create-icon-preview {display:grid;place-items:center;flex:none;width:80px;height:80px;border:1px solid var(--border);border-radius:16px;background:var(--surface-subtle);}
.channel-create-icon-preview>.word-illustration-spinner {width:28px;height:28px;}
.channel-create-icon-controls {display:grid;gap:8px;}
.channel-suggest-form {display:grid;gap:14px;}
.channel-suggest-form p {margin:0;}
.profile-interests-help { margin: -6px 0 8px; font-size: .88rem; }
@media (max-width: 600px) {
  .channel-row { grid-template-columns: minmax(0, 1fr); }
  .channel-header-icon { width: 52px; height: 52px; font-size: 1.6rem; }
}

/* Discovery before signup shares the same channel controls as the signed-in feed. */
.channel-follow-button{display:inline-flex;align-items:center;justify-content:center;gap:.45rem;border:1px solid var(--border-strong);border-radius:999px;background:var(--surface);color:var(--text);padding:.55rem .9rem;min-width:116px;white-space:nowrap;transition:background .15s,border-color .15s,transform .15s}
.channel-follow-button.following{background:var(--text);color:var(--bg);border-color:var(--text)}
@media (hover: hover) and (pointer: fine) { .channel-follow-button:hover:not(:disabled){background:var(--surface-hover);color:var(--text);border-color:var(--accent);transform:translateY(-1px)} }
@media (hover: hover) and (pointer: fine) { .channel-follow-button.following:hover:not(:disabled){background:var(--accent-hover);color:var(--accent-text);border-color:var(--accent-hover)} }
.channel-vector-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;font-size:1.5em}
.channel-vector-icon img{width:100%;height:100%;object-fit:contain}
.channel-row-description{display:block;color:var(--muted);font-size:.9rem;line-height:1.45;margin:.25rem 0 .4rem}
.setup-channel-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem;margin:1.5rem 0}
.setup-channel{position:relative;min-width:0;overflow-wrap:anywhere;display:flex;flex-direction:column;align-items:flex-start;gap:.6rem;border:1px solid var(--border);border-radius:20px;padding:1.25rem;background:var(--surface);transition:background .15s,border-color .15s,opacity .15s}
.setup-channel.selected{border-color:color-mix(in srgb,var(--accent) 50%,var(--border))}
.setup-channel h3,.setup-content-copy h3{margin:0;font-size:1.12rem;line-height:1.3}
.setup-channel p{margin:0 0 .5rem;color:var(--muted);line-height:1.55;font-size:.94rem;flex:1}
.setup-channel .channel-follow-button{margin-top:auto;font-weight:650}
.setup-channel .setup-channel-toggle{position:absolute;inset:0;z-index:1;display:block;width:100%;height:100%;margin:0;padding:0;border:0;border-radius:inherit;background:none;box-shadow:none;cursor:pointer;transform:none}
.setup-channel .setup-channel-toggle:is(:active,:focus-visible){background:none;box-shadow:none;outline:none;transform:none}
@media (hover: hover) and (pointer: fine) { .setup-channel .setup-channel-toggle:is(:hover,:active,:focus-visible){background:none;box-shadow:none;outline:none;transform:none} }
.setup-channel .setup-channel-toggle:disabled{cursor:default}
.setup-channel:has(>.setup-channel-toggle:disabled) .channel-follow-button{opacity:.55}
@media (hover: hover) and (pointer: fine) { .setup-channel:has(>.setup-channel-toggle:hover:not(:disabled)){background:var(--surface-hover);border-color:var(--accent)} }
.setup-channel .error-details-button{position:relative;z-index:2}
.setup-channel-icon-loading{display:grid;place-items:center;width:48px;height:48px;flex:none}
.setup-progress{display:flex;flex-wrap:wrap;gap:.75rem 1.5rem;list-style:none;padding:1rem 0;margin:0;color:var(--muted);font-size:.9rem}
.setup-progress li{display:flex;align-items:center;gap:.6rem}.setup-progress .done{color:var(--text)}
.setup-progress .word-illustration-spinner{width:16px;height:16px;flex-shrink:0}
.setup-step-actions{display:flex;align-items:center;justify-content:space-between;gap:1rem;margin-top:1.5rem}
.setup-step-actions .onboarding-continue{margin-top:0}
.setup-content-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem;margin:1.25rem 0}
.setup-content-card{display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--border);border-radius:18px;background:var(--surface)}
.setup-content-art{flex:none;aspect-ratio:4/3;display:grid;place-items:center;background:linear-gradient(135deg,color-mix(in srgb,var(--accent) 20%,var(--surface)),var(--surface));overflow:hidden}
.setup-content-art img{grid-area:1/1;width:100%;height:100%;object-fit:cover}
.setup-content-copy{flex:1;min-width:0;overflow-wrap:anywhere;padding:1rem;display:flex;flex-direction:column;gap:.5rem}
.setup-content-title-loading{display:flex;align-items:center;min-height:2.8em}
.setup-content-channel{margin-top:auto;display:flex;align-items:center;gap:.45rem;color:var(--muted);font-size:.8rem;line-height:1.35}
.setup-content-channel .channel-vector-icon{flex:none}
.setup-content-type{display:flex;align-items:center;gap:.35rem;color:var(--muted);font-size:.75rem}
.signup-preview{border-top:1px solid var(--border);margin-top:2rem;padding-top:1.5rem}
.signup-preview h2{font-size:1.45rem;margin:.5rem 0}.signup-preview .setup-content-grid{grid-template-columns:1fr}
.signup-preview .setup-content-card{display:grid;grid-template-columns:120px 1fr}.signup-preview .setup-content-art{aspect-ratio:auto;height:100%;min-height:130px}.signup-preview .setup-content-copy{min-width:0;overflow-wrap:anywhere;padding:.9rem}
.setup-retry{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:1rem;margin:1rem 0}
@media(max-width:650px){.setup-channel-grid,.setup-content-grid{grid-template-columns:1fr}.setup-step-actions{flex-wrap:wrap}.setup-step-actions .onboarding-continue{flex:1}.setup-content-card{display:grid;grid-template-columns:110px 1fr}.setup-content-art{aspect-ratio:auto;height:100%;min-height:150px}.setup-channel{padding:1rem}.channel-row-description{font-size:.82rem}}

.feed-idea .home-suggestion-card:disabled:not([aria-busy="true"]){opacity:1;cursor:default}

.page-history-back { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 32px; margin: 0 0 14px; padding: 4px 0; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: .86rem; font-weight: 550; text-align: start; box-shadow: none; }
@media (hover: hover) and (pointer: fine) {
    .page-history-back:hover { background: transparent; color: var(--text); }
    .page-history-back:hover .history-back-name small { color: var(--text); }
}
.page-history-back > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.account-subscription-plan { margin-inline-start: auto; color: var(--muted); font-size: .85rem; font-weight: 400; text-align: end; overflow-wrap: anywhere; }

/* Saved activity completion, anchored to the thumbnail like watch progress. */
.home-activity-progress { position:absolute;inset:auto 0 0;height:5px;z-index:4;background:rgba(0,0,0,.45);direction:ltr;pointer-events:none; }
.home-activity-progress > span { display:block;height:100%;background:var(--xp);box-shadow:0 0 1px rgba(0,0,0,.35); }

.feed-flashcards-art { position:relative; }

.feed-generate-channels {display:grid;justify-items:center;gap:12px;padding:32px 24px;margin:0 0 24px;text-align:center;}
.feed-generate-channels h3,.feed-generate-channels p {margin:0;}
.feed-generate-channels>button {display:flex;align-items:center;justify-content:center;gap:12px;min-height:60px;width:min(100%,420px);font-size:1.15rem;}
.channel-discovery-actions {display:flex;justify-content:flex-end;margin-top:24px;}
.channel-discovery-popup {max-width:1100px;}

.setup-discovery:has(> .channel-discovery-loading) {display:flex;flex-direction:column;min-height:min(600px,calc(100dvh - 220px));}
.channel-discovery-loading {display:grid;justify-items:center;gap:10px;margin-top:auto;padding:20px 8px 0;text-align:center;}
.channel-discovery-loading-label {display:flex;align-items:center;justify-content:center;gap:10px;color:var(--muted);font-size:.9rem;}
.channel-discovery-loading>strong {font-size:1rem;line-height:1.5;max-width:36rem;}
.channel-discovery-spinner {display:block;flex:none;width:20px;height:20px;border-width:2px;}
.channel-discovery-progress {position:relative;width:min(100%,420px);height:8px;overflow:hidden;border-radius:999px;background:var(--surface-subtle);}
.channel-discovery-progress-fill {display:block;height:100%;border-radius:inherit;background:var(--accent);transition:width .25s ease;}
.channel-discovery-progress-fill.indeterminate {width:35%;animation:channel-discovery-progress 1.4s ease-in-out infinite;}
.channel-discovery-save-spinner {display:inline-block;width:16px;height:16px;vertical-align:middle;margin-inline-end:8px;}
@keyframes channel-discovery-progress {from{transform:translateX(-110%)}to{transform:translateX(310%)}}
@media(prefers-reduced-motion:reduce){.channel-discovery-progress-fill{transition:none}.channel-discovery-progress-fill.indeterminate{animation:none;transform:translateX(90%)}}

.channel-more-footer {display:grid;justify-items:center;gap:12px;margin:24px 0;min-height:44px;}
.channel-more-footer>button,.channel-more-loading {display:inline-flex;align-items:center;justify-content:center;gap:10px;min-height:44px;}
.channel-more-loading {color:var(--muted);}
.channel-more-loading>.word-illustration-spinner {display:inline-block;flex:none;width:22px;height:22px;}
.channel-more-form {display:grid;gap:14px;max-width:360px;padding:4px;}
.channel-more-form label {display:grid;gap:8px;}
.channel-more-form p {margin:0;font-size:.88rem;line-height:1.5;}
.channel-more-form input {width:100%;}
.channel-more-footer>.error {justify-self:stretch;}

/* Generation sits above the caption in both standard and image tile layouts. */
.activity-preparation-capsule {
  position:absolute; z-index:3; inset-inline:12px; bottom:12px;
  display:grid; gap:7px; padding:11px 14px; border-radius:22px;
  background:rgba(25,25,25,.88); color:#fff; border:1px solid #ffffff40;
  box-shadow:0 3px 18px #0003; backdrop-filter:blur(16px);
  text-align:start; font-size:.83rem; line-height:1.35; font-weight:600;
}
.activity-preparation-heading {display:flex; align-items:center; gap:9px; min-width:0;}
.activity-preparation-heading>span:last-child {overflow-wrap:anywhere;}
.activity-preparation-capsule .word-illustration-spinner {display:inline-block; flex:none; width:17px; height:17px;}
.activity-preparation-capsule progress {display:block; width:100%; height:5px; border:0; border-radius:8px; overflow:hidden; accent-color:#fff;}
.activity-preparation-capsule progress::-webkit-progress-bar {background:#ffffff35;}
.activity-preparation-capsule progress::-webkit-progress-value {background:#fff; border-radius:8px;}
.activity-preparation-capsule.failed {border-color:#f5b5a580; color:#ffd0c3;}
/* Share the thumbnail's grid row, so caption height never needs to be guessed. */
.home-content-card > .activity-preparation-capsule {
  position:relative; grid-row:1; grid-column:1; align-self:end; justify-self:stretch;
  inset:auto; margin:0 12px 12px; pointer-events:none;
}
.home-content-card:has(.activity-preparation-capsule) {grid-template-columns:minmax(0,1fr);}
.home-content-card > :is(.home-suggestion-image,.home-recent-art) {grid-column:1;grid-row:1;}
.home-content-card > .home-content-copy {grid-column:1;}
.home-history-art {position:relative;}

/* Compact activity tiles are slightly wider than tall at every column width.
   Size the outer suggestion wrapper so its badge row and title stay in subgrid. */
[data-content-style="image"] :is(.home-content-grid,.library-create-grid) > :is(.home-content-card,.home-suggestion),
[data-content-style="image"] .feed-grid :is(.home-recent-card,.home-suggestion,.feed-flashcards-card,.feed-preparing) {
  height:auto; min-height:0; aspect-ratio:10 / 9;
}
[data-content-style="image"] :is(.home-content-grid,.library-create-grid) > .home-create-column {height:100%;align-self:stretch;}

.home-language-controls {display:flex;align-items:center;flex-wrap:wrap;gap:14px 24px;min-width:0;}
.home-language-controls>.home-language-menu {min-width:0;max-width:100%;}
.home-target-level {min-width:0;max-width:100%;}
.home-target-level-control {display:flex;align-items:center;gap:8px;}
.home-target-level-button {display:inline-flex;align-items:center;justify-content:space-between;gap:18px;min-width:90px;min-height:40px;padding:7px 12px;border-radius:12px;font-size:.9rem;}
.home-target-level .word-illustration-spinner {display:inline-block;width:16px;height:16px;flex:none;}
.home-target-level-error {display:flex;align-items:center;gap:8px;max-width:300px;margin-top:6px;font-size:.8rem;}

/* Choose content difficulty with enough context to make an informed choice. */
.target-level-popup .reader-popup-body {display:grid;gap:18px;}
.target-level-explanation {margin:0;color:var(--text-secondary);font-size:.9rem;line-height:1.6;}
.target-level-options {display:grid;gap:8px;}
button.target-level-option {display:flex;align-items:center;gap:14px;width:100%;padding:14px;text-align:start;white-space:normal;}
.target-level-code {display:grid;place-items:center;flex:0 0 auto;min-width:48px;padding-inline:6px;box-sizing:border-box;white-space:nowrap;min-height:42px;border-radius:10px;background:var(--surface-subtle);font-size:1rem;font-weight:700;}
.target-level-copy {display:grid;gap:4px;flex:1;min-width:0;}
.target-level-copy strong {font-size:.95rem;}
.target-level-copy small {color:var(--text-secondary);font-size:.82rem;font-weight:400;line-height:1.45;}
.target-level-selected {display:flex;flex:0 0 20px;}
button.target-level-option[aria-pressed="true"] {background:var(--accent-soft);color:var(--accent-ink);border-color:var(--accent);}
@media (hover: hover) and (pointer: fine) {  button.target-level-option[aria-pressed="true"]:hover {background:var(--accent-soft);color:var(--accent-ink);border-color:var(--accent);} }
button.target-level-option[aria-pressed="true"] .target-level-code {background:var(--surface);}
@media(max-width:480px) {.target-level-popup .reader-popup-body {padding:16px;}button.target-level-option {gap:10px;padding:12px;}}

/* Caption visibility and opacity are independent of whether it overlays artwork. */
[data-content-style="standard"] {--tile-caption-height:14rem;}
[data-content-style="image"] {--tile-caption-height:6.5rem;}
[data-content-style="standard"][data-tile-descriptions="false"] {--tile-caption-height:8rem;}
[data-content-style="image"][data-tile-descriptions="true"] {--tile-caption-height:10.5rem;}
[data-tile-descriptions="false"] .home-content-copy>.home-content-description {display:none;}
.home-dashboard [data-content-style] :is(.home-recent-card,.home-suggestion-card),
[data-content-style] :is(.home-recent-card,.home-suggestion-card) {background:transparent;backdrop-filter:none;-webkit-backdrop-filter:none;}
[data-content-style="standard"] :is(.home-recent-card,.home-suggestion-card) {position:relative;isolation:isolate;}
[data-content-style="standard"] :is(.home-recent-card,.home-suggestion-card)::after {
  content:"";position:absolute;inset:auto 0 0;height:var(--tile-caption-height);pointer-events:none;
  background:color-mix(in srgb,var(--surface) var(--tile-info-opacity,76%),transparent);
  backdrop-filter:blur(calc(var(--tile-info-alpha,.76) * 14px));-webkit-backdrop-filter:blur(calc(var(--tile-info-alpha,.76) * 14px));
}
[data-content-style="standard"] :is(.home-recent-card,.home-suggestion-card)>.home-content-copy {position:relative;z-index:1;}

/* An interactive podcast: one quiet player, persistent transcript, contextual controls. */
.podcast-stage{display:grid;place-items:stretch center}
.podcast-player{width:min(820px,100%);min-height:0;display:flex;flex-direction:column;gap:14px;padding:clamp(16px,3vw,28px);border-radius:28px;background:rgba(18,22,28,.78);border:1px solid #ffffff24;backdrop-filter:blur(28px);box-shadow:0 24px 70px #0003;overflow:hidden}
.podcast-heading{display:flex;align-items:center;gap:14px;flex-shrink:0}
.podcast-heading-copy{flex:1;min-width:0}
.podcast-heading h2{font-size:clamp(1.05rem,2.6vw,1.5rem);line-height:1.25;margin:0 0 4px;text-wrap:balance}
.podcast-cover{width:56px;aspect-ratio:1;object-fit:cover;border-radius:14px}
.podcast-heading .icon-button{flex:none;color:inherit}
.podcast-section-button{padding:4px 0;min-height:30px;display:flex;gap:6px;max-width:100%;font-size:.82rem;text-align:start;color:var(--text-secondary)}
.podcast-section-button span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.podcast-section-button svg{flex:none}
.podcast-modes{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));padding:4px;border-radius:16px;background:#0003;flex-shrink:0}
.podcast-modes button{border-radius:12px;min-height:38px;padding:8px;font-size:.85rem;white-space:normal}
.podcast-modes button[aria-pressed="true"]{background:#ffffff20;color:#fff;box-shadow:0 2px 8px #0002}
.podcast-transcript{flex:1;min-height:100px;overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:10px 6px 28px;line-height:1.75;overflow-wrap:anywhere;scroll-behavior:smooth}
.podcast-welcome{display:grid;align-content:center;justify-items:center;min-height:100%;text-align:center;gap:20px;padding:20px 4px}
.podcast-welcome p{margin:0;max-width:52ch}
.podcast-welcome>p:first-of-type{font-size:1.15rem}
.podcast-exchange:empty{display:none}
.podcast-line{padding:5px 12px;border-radius:12px;font-size:clamp(1rem,2vw,1.14rem);transition:background .2s,color .2s}
.podcast-line p{margin:0}
.podcast-line[data-active="true"]{background:#c8e9dd12;color:#dcfff3}
.podcast-line[data-target="true"]{font-weight:500}
.podcast-analyze{display:inline;padding:0;border:0;border-radius:4px;background:transparent;box-shadow:none;color:inherit;font:inherit;line-height:inherit;text-align:inherit;white-space:normal;min-height:0}
@media (hover: hover) and (pointer: fine) { .podcast-analyze:hover{background:transparent;text-decoration:underline;text-decoration-color:#ffffff50;text-underline-offset:5px} }
.podcast-listener{margin:18px 0 12px 15%;padding:10px 16px;border-radius:16px;background:#ffffff14;color:var(--text-secondary)}
.podcast-controls{display:flex;justify-content:center;align-items:center;gap:10px;flex-shrink:0}
.podcast-controls>button{min-height:40px;font-size:.85rem;padding:8px 14px;white-space:normal}
.podcast-controls>.podcast-play{border-radius:50%;width:52px;height:52px;padding:12px;flex:none}
.podcast-status{display:flex;align-items:center;justify-content:center;gap:8px;font-size:.8rem;color:var(--text-secondary);min-height:20px}
.podcast-review{display:flex;justify-content:center;flex-wrap:wrap;gap:10px}
.podcast-review button{display:flex;gap:8px;align-items:center;font-size:.9rem}
.podcast-input{margin-top:2px}
.podcast-input button[aria-pressed="true"]{background:#c8e9dd30;color:#dcfff3}
.podcast-input input{font-size:1rem}
.podcast-outline{padding-inline-start:24px;max-width:440px}
.podcast-outline li{padding:12px;border-radius:12px}
.podcast-outline li.current{background:var(--surface-hover)}
.podcast-outline p{font-size:.88rem;color:var(--text-secondary);line-height:1.5;margin:6px 0 0}
.podcast-options{display:grid;gap:8px;min-width:220px}
.podcast-options>button{text-align:start;justify-content:flex-start}
.podcast-options .switch-row{padding:10px 0;margin:0;font-size:.9rem}
.podcast-finished{text-align:center;color:#c8e9dd;padding:24px}
@media(max-width:600px){.podcast-player{gap:10px;padding:14px;border-radius:22px}.podcast-cover{width:44px}.podcast-heading{gap:10px}.podcast-controls{gap:6px}.podcast-controls>button{padding:8px 10px}.podcast-line{padding-inline:5px}.podcast-input{gap:2px}.podcast-input button{padding:8px}}
@media(prefers-reduced-motion:reduce){.podcast-transcript{scroll-behavior:auto}.podcast-line{transition:none}}

.listening-stage > .reader-popup-heading h2{visibility:hidden}
@media(max-height:540px){.podcast-player{overflow-y:auto}.podcast-transcript{flex:0 0 180px;min-height:180px}}

/* Topics: one coherent learning unit, with a clear ordered path through it. */
.topic-card{position:relative;isolation:isolate;display:flex;flex-direction:column;width:100%;height:auto;min-height:0;aspect-ratio:4/3;padding:0;overflow:hidden;color:var(--text);text-decoration:none;transition:border-color .15s,box-shadow .15s}
.topic-card.surface{margin:0}
/* Avoid a touch-and-hold link preview keeping artwork in a pressed state. */
:is(.topic-card, .topic-activity, .reading-heading-open, .content-reading-button, .home-content-card, .home-quick-link, .library-content-open, .vocabulary-collection-open, .activity-tile, .more-feature, .writer-card) { -webkit-touch-callout: none; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .topic-card:hover{border-color:var(--accent);box-shadow:0 4px 18px color-mix(in srgb,var(--text) 12%,transparent)} }
.topic-card-art{position:absolute;inset:0;background:color-mix(in srgb,var(--accent) 9%,var(--surface));overflow:hidden}
/* Fill the tile directly, avoiding intrinsic grid sizing of percentage-height images in Safari. */
.topic-card-art>img{position:absolute;inset:0;display:block;width:100%;height:100%;object-fit:cover;object-position:center}
.topic-cover-loading>img {width:100%;height:100%;object-fit:cover;border-radius:inherit;}
.topic-card-image{position:relative;z-index:2;flex:1;min-height:0}
.topic-card-suggested{position:absolute;inset-block-end:.75rem;inset-inline-end:1.1rem;max-width:calc(100% - 2.2rem);display:inline-flex;align-items:center;gap:.35rem;padding:.35rem .65rem;border:1px solid #d7c3f4;border-radius:999px;background:#e8ddff;color:#513a7b;box-shadow:0 1px 6px #0002;font-size:.75rem;font-weight:650;line-height:1.25;pointer-events:none}
.topic-card-suggested>.shell-icon{flex:none}
.topic-card-type{position:absolute;z-index:2;inset-block-start:1rem;inset-inline-end:1.1rem;max-width:calc(100% - 2.2rem);display:flex;align-items:center;justify-content:flex-end;gap:.4rem;color:#fff;font-size:.8rem;font-weight:650;text-align:end;text-shadow:0 1px 3px rgb(0 0 0 / .95),0 2px 8px rgb(0 0 0 / .8);pointer-events:none}
.topic-card-type>.shell-icon{flex:none;filter:drop-shadow(0 1px 3px rgb(0 0 0 / .95))}
.topic-card-copy{position:relative;z-index:1;box-sizing:border-box;flex:none;margin-top:auto;padding:.85rem 1.2rem;display:flex;flex-direction:column;background:color-mix(in srgb,var(--surface) var(--tile-info-opacity,76%),transparent);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);border-top:1px solid color-mix(in srgb,var(--text) 12%,transparent)}
/* Keep the composited title blur inside the tile's rounded bottom border. */
.topic-card-copy{border-end-start-radius:inherit;border-end-end-radius:inherit}
.topic-card-copy h3{margin:0;height:2.6em;font-size:1.1rem;line-height:1.3;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;overflow-wrap:anywhere}
.topic-loading {display:flex;align-items:center;gap:12px;padding:24px;font-size:1rem}
.topic-loading .word-illustration-spinner {display:block;flex:none}
.topic-header{display:flex;align-items:center;gap:2rem;margin:1.5rem 0;padding:clamp(1.2rem,3vw,2rem);border:1px solid var(--border);border-radius:24px;background:var(--surface);box-shadow:var(--shadow);color:var(--text)}.topic-heading{min-width:0;overflow-wrap:anywhere}.topic-heading h1{margin:.4rem 0}.topic-heading p{margin:.6rem 0 0;line-height:1.6;color:var(--text-secondary)}
@supports ((backdrop-filter:blur(20px)) or (-webkit-backdrop-filter:blur(20px))){.topic-header{background:color-mix(in srgb,var(--surface) var(--home-glass-opacity,82%),transparent);backdrop-filter:blur(20px) saturate(1.1);-webkit-backdrop-filter:blur(20px) saturate(1.1)}}
@media(prefers-reduced-transparency:reduce){.topic-header{background:var(--surface);backdrop-filter:none;-webkit-backdrop-filter:none}}
.topic-cover{width:12rem;height:12rem;object-fit:cover;border-radius:24px;flex:none}
.topic-introduction{padding:1.6rem}.topic-introduction ol{display:grid;gap:1rem;padding-inline-start:1.5rem;margin:1.5rem 0}.topic-introduction li svg{vertical-align:middle;margin-inline-end:.7rem}
.topic-review-bar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:1rem;margin:1.5rem 0}.topic-review-bar .channel-stats{margin:0}
.topic-activities{display:flex;flex-direction:column;gap:1rem}.topic-activity{display:grid;grid-template-columns:7rem minmax(0,1fr) auto;align-items:center;gap:1.5rem;width:100%;padding:1.1rem;text-align:start;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:18px;white-space:normal}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .topic-activity:hover:not(:disabled){color:var(--text);background:color-mix(in srgb,var(--accent) 6%,var(--surface));border-color:var(--accent)} }
/* Keep unavailable activities readable; the global button hover also matches disabled buttons. */
.topic-activity:disabled{opacity:1;color:var(--text-secondary);background:var(--surface);border-color:var(--border);cursor:default}
.topic-activity-icon{display:grid;place-items:center;width:7rem;height:7rem;border-radius:12px;background:var(--surface-subtle);color:var(--text-secondary)}.topic-activity-icon>svg{width:3.5rem;height:3.5rem}
.topic-activity-copy{display:flex;flex-direction:column;gap:.5rem;min-width:0;font-weight:400;line-height:1.5}.topic-activity-copy strong{font-size:1.1rem}.topic-activity-labels{display:flex;flex-wrap:wrap;gap:.6rem;align-items:center}.topic-activity-status{display:flex;align-items:center;gap:.4rem;font-size:.85rem}.topic-recommended{border-radius:999px;background:#d8c7ff;color:#352052;padding:.25rem .65rem;font-size:.75rem;font-weight:700}.topic-preparing{display:flex;align-items:center;gap:.65rem}
@media(max-width:600px){.topic-header{flex-direction:column;align-items:flex-start;gap:1rem}.topic-cover{width:5rem;height:5rem;border-radius:12px}.topic-activity{grid-template-columns:3.5rem minmax(0,1fr);gap:.8rem;padding:.8rem}.topic-activity-icon{width:3.5rem;height:3.5rem}.topic-activity>svg:last-child{display:none}.topic-activity-icon>svg{width:2rem;height:2rem}.topic-page .section-heading{flex-wrap:wrap;gap:1rem}.topic-more .form-actions{flex-wrap:wrap}}

/* Account setup uses the same continuous full-screen surface as language choice. */
.setup-journey { --surface:rgba(255,255,255,.06); --surface-subtle:rgba(255,255,255,.04); --surface-hover:rgba(255,255,255,.12); --border:rgba(255,255,255,.16); --border-strong:rgba(255,255,255,.32); }
/* Floating forms need opaque surfaces above the translucent setup cards. */
.setup-journey .anchored-popover { --surface:#1c1c1c; --surface-subtle:#242424; --surface-hover:#2b2b2b; }
.setup-journey > .reader-popup-body { overflow-y:auto; scrollbar-gutter:stable both-edges; }
.setup-journey > .reader-popup-body:has(.onboarding-shell[data-language-page="true"]) { overflow:hidden; scrollbar-gutter:stable both-edges; }
.setup-journey .entry-shell { background:none; min-height:0; width:min(1040px,100%); margin:0 auto; padding:90px 0 20px; color:var(--text); }
.setup-journey .onboarding-card { width:100%; overflow:visible; }
.setup-journey .onboarding-flow { display:block; }
.setup-journey :is(.onboarding-active-question,.onboarding-review-screen,.auth-card) { background:none; border:0; box-shadow:none; border-radius:0; padding:24px 0; margin:0; }
.setup-journey .onboarding-question h1,.setup-journey .onboarding-review-screen h1 { font-size:clamp(30px,4.6vw,48px); max-width:860px; }
.setup-journey .onboarding-question h1:focus { outline:none; }
.setup-journey .setup-page-back { display:inline-flex; align-items:center; gap:10px; color:var(--text-secondary); padding:8px 0; margin:0 0 14px; box-shadow:none; background:none; }
@media (hover: hover) and (pointer: fine) { .setup-journey .setup-page-back:hover { color:var(--text); } }
.setup-journey .setup-step-actions { justify-content:flex-end; }
.setup-journey .entry-return { width:min(600px,100%); margin:0 auto; }
.setup-journey .auth-card { width:100%; }
.setup-journey .onboarding-shell[data-language-page="true"] { flex:1 1 0; width:100%; height:auto; min-height:0; padding:0; overflow:hidden; }
.setup-journey .onboarding-shell[data-language-page="true"] :is(.onboarding-card,.onboarding-flow),
.setup-journey .add-profile-journey[data-language-page="true"] > div { display:flex; flex-direction:column; flex:1 1 0; height:auto; min-height:0; }
.setup-journey .onboarding-shell[data-language-page="true"] .onboarding-notice { display:none; }
.setup-journey .setup-language-back { position:absolute; top:24px; left:28px; z-index:3; max-width:calc(100% - 130px); }
@media(max-height:600px) {
  .language-journey-search { padding-top:80px; }
  .language-journey-search > label { font-size:18px; margin-bottom:8px; }
  .language-journey .language-journey-input { font-size:30px; padding-block:6px 10px; }
  .language-journey-results { margin-top:14px; }
}

.topic-cover-loading {display:grid;place-items:center;background:var(--surface-subtle);}

/* Activity rows use type icons; the topic identity card shows cover art. */
.topic-activity {position:relative;isolation:isolate;overflow:hidden;}
.topic-activity:disabled::after {content:"";position:absolute;inset:0;z-index:4;pointer-events:none;background:rgba(var(--tile-theme-rgb),.25);}
.topic-more {margin-top:16px;}
.topic-activities > .topic-more {margin-top:0;}
.topic-activities-divider {width:100%;border:0;border-top:1px solid var(--border-strong);margin:1rem 0;}
.topic-more .channel-more-form select {padding-inline-end:38px;}

/* Flashcard setup controls remain comfortably tappable on small screens. */
.flashcard-mode-toggles { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.flashcard-mode-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 18px; border-radius: 16px; }
.flashcard-mode-toggle[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.flashcard-word-count { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 46px; }
.flashcard-hands-free-note { margin: 0; color: var(--warning-ink, var(--muted)); font-size: .9rem; font-weight: 550; }
/* The hands-free stage reuses the Speaking Coach stage; these are its cards. */
.flashcard-audio-stage [data-state="hearing"]:not([data-voice]) .coach-orb { transform:scale(.76); }
.flashcard-audio-stage [data-voice="hearing"] .coach-orb { animation:none; opacity:1; transform:scale(calc(.68 + .1 * var(--level,0) + .045 * var(--pitch,.5))); transition:transform 90ms linear; }
.flashcard-audio-stage [data-voice="hearing"] .coach-orb::after { animation:none; }
@media (prefers-reduced-motion:reduce) { .flashcard-audio-stage [data-voice="hearing"] .coach-orb { transform:scale(.76); transition:none; } }
.flashcard-mute[aria-pressed="true"] .coach-round-icon { background:#aa3040; color:white; border-color:#ef8994; }
.flashcard-mute .coach-round-icon { position: relative; }
.flashcard-mute[aria-pressed="true"] .coach-round-icon::after { content: ""; position: absolute; width: 25px; height: 2px; background: currentColor; transform: rotate(45deg); box-shadow: 0 2px var(--surface); }
.flashcard-audio-stage .coach-stage-foot { gap: 10px; }
.flashcard-audio-card .eyebrow, .flashcard-audio-result .eyebrow { margin: 0; color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.flashcard-audio-result { grid-template-columns: auto auto; column-gap: 12px; justify-content: center; align-items: baseline; padding-block: 10px; }
.flashcard-audio-result > .eyebrow, .flashcard-audio-result > .flashcard-audio-score, .flashcard-audio-result > .muted { grid-column: 1 / -1; }
.flashcard-audio-result > strong:has(+ .muted) { grid-column:1 / -1; }
.flashcard-audio-result strong { font-size: 1.2rem; }
.flashcard-audio-score { font-weight:700; font-variant-numeric:tabular-nums; }
.mastery-step-header {display:grid;grid-template-columns:minmax(max-content,1fr) auto minmax(0,1fr);align-items:center;gap:8px;}
.mastery-step-header .mastery-back {justify-self:start;padding:8px 12px;}
.flashcard-self-grade-header {grid-template-columns:auto minmax(0,1fr);}
.mastery-step {text-align:center;font-size:.9rem;font-weight:600;margin:0;}
.mastery-known-meaning {text-align:center;margin:12px 0;color:var(--text-secondary);}
.study-answer-dock.mastery-answer-dock {display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);align-items:stretch;overflow:hidden;gap:12px;}
.mastery-answer-dock > .mastery-step-header {grid-template-columns:auto minmax(0,1fr);}
.mastery-answer-dock > .primary {justify-self:end;}
.mastery-summary {display:flex;align-items:center;flex-wrap:wrap;gap:12px;min-width:0;}
.mastery-grade {display:inline-flex;padding:10px 14px;border-radius:12px;font-size:1.1rem;font-weight:650;white-space:nowrap;background:hsl(var(--familiarity-hue) 72% 48% / .18);border:1px solid hsl(var(--familiarity-hue) 72% 48% / .5);color:var(--text);}
.mastery-mistakes {display:grid;gap:4px;font-size:.85rem;color:var(--text-secondary);}
.mastery-result-actions {display:flex;align-items:center;gap:12px;margin-left:auto;}
.mastery-answer-dock > .memory-identify {min-height:0;overflow:auto;overscroll-behavior:contain;}
.mastery-answer-dock .memory-identify-option {font-size:1rem;min-height:3rem;padding:10px 26px;}
.mastery-answer-dock .memory-identify-heading {font-size:.9rem;margin-bottom:12px;}
.mastery-answer-dock .memory-identify-feedback {margin-top:8px;}
/* Make written choices legible without spending the dock on empty space. */
.study-answer-dock:has(.memory-identify-options) {padding:clamp(8px,2vw,12px);gap:8px;}
.study-answer-dock .memory-identify-options {gap:8px;}
.study-answer-dock .memory-identify-option {min-height:3.25rem;padding:4px 26px;font-size:clamp(2rem,5vw,2.5rem);line-height:1.25;}
.study-answer-dock .memory-identify:has(> .memory-identify-options) > .memory-identify-feedback:empty {display:none;}

.flashcard-autoplay { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.study-dock .flashcard-begin { min-width: min(320px, 65vw); min-height: 62px; padding: 18px 36px; font-size: 1.1rem; }
.flashcard-selection-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.flashcard-word-selection { display: grid; gap: 8px; max-height: min(52vh, 440px); overflow-y: auto; text-align: start; }
.flashcard-word-selection .option-row { align-items: center; padding: 12px; margin: 0; min-height: 56px; }
.flashcard-word-selection .flashcard-session-word { min-width: 0; overflow-wrap: anywhere; }
.flashcard-visualize { margin: 16px auto; min-height: 44px; }
.study-scene:has(.study-card[data-kind="setup"]) { grid-template-rows: minmax(0, 1fr) auto; }
/* Keep setup controls steady while the deck is prepared. */
.study-card[data-kind="setup"] { animation: none; }
.study-scene:has(.flashcard-setup-welcome) > .study-dock { animation: none; }
.flashcard-setup-welcome .flashcard-word-count { width: min(100%, 240px); font-variant-numeric: tabular-nums; }
.flashcard-setup-status { display: grid; gap: 10px; flex: none; width: min(100%, 440px); font-size: .95rem; line-height: 1.65; }
.flashcard-setup-status p { margin: 0; }
.flashcard-setup-message { display: grid; align-items: center; }
.flashcard-setup-state { grid-area: 1 / 1; display: flex; align-items: center; justify-content: center; gap: 8px; }
.flashcard-setup-status [data-active="false"] { display: none; }
.flashcard-setup-status .study-ready { animation: none; }
.flashcard-setup-status .study-ready[data-active="true"] { animation: study-ready-out .4s ease 1s forwards; }
.flashcard-setup-progress { width: 100%; height: 6px; margin: 0; }
.flashcard-setup-help { color: var(--text-secondary); }

@media (max-width: 480px) {
    .study-card[data-kind="setup"] .study-welcome { gap: 12px; }
    .study-card[data-kind="setup"] .study-welcome-icon { width: 56px; height: 56px; border-radius: 18px; }
}

.word-progress-inline { grid-column: 1 / -1; justify-self: start; }
.word-progress-chip[hidden] { display:none!important; }
.word-learning-progress:has(.word-progress-picker:popover-open) .word-progress-inline,
.word-learning-progress:has(.word-progress-picker.open) .word-progress-inline { display: none; }

.topic-vocabulary-progress { display:grid; gap:12px; margin:0; padding:20px 24px; }
.topic-flashcards { text-decoration:none; }
.topic-vocabulary-progress .reader-learning-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topic-vocabulary-progress h2 { margin: 0; font-size: 1.05rem; }
.topic-vocabulary-progress .topic-familiarity-track { margin: 0; }

.topic-channel-origin { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topic-channel-origin > span { flex: none; color: var(--text-secondary); font-size: .85rem; }

.content-opening-reader { min-height: 100%; display: flex; flex-direction: column; align-items: stretch; justify-content: safe center; gap: 20px; width: min(540px, 100%); margin: auto; padding: 90px 24px 32px; overflow-y: auto; }
.content-opening-reader .reader-preparation { background: var(--surface); color: var(--text); }
.content-opening-reader > .error { padding: 20px; border-radius: 16px; }

.collection-copy-button { margin-bottom: 20px; }
.collection-copy-form { display: grid; gap: 16px; }

/* Topics are a reading with supporting learning activities. */
.topic-main-title {font-size:clamp(1.25rem,2.6vw,2rem);font-weight:750;line-height:1.25;}
.topic-completion {display:flex;align-items:center;gap:.75rem;width:100%;margin-top:.4rem;}
.topic-completion-track {display:block;flex:1;height:6px;overflow:hidden;background:var(--border);border-radius:99px;}
.topic-completion-track>span {display:block;height:100%;background:var(--accent);border-radius:inherit;}
.topic-completion>small {font-size:.8rem;color:var(--text-secondary);font-variant-numeric:tabular-nums;}
.topic-vocabulary-progress .reader-learning-heading h2 {font-size:.9rem;color:var(--text-secondary);font-weight:400;}

/* Keep word navigation within the study dialog's own interactive layer. */
.guided-selection-controls {z-index:90;}
.guided-stage:has(.guided-selection-controls) :is(.comic-footer,.guided-response,.guided-hint-actions) {visibility:hidden;pointer-events:none;}
.guided-sentence-card:focus-visible {border-radius:10px;}

.language-level{display:inline-flex;align-items:center;flex:none;align-self:flex-start;border:1px solid currentColor;border-radius:.35rem;padding:.1rem .4rem;font-size:.75rem;font-weight:650;line-height:1.3;vertical-align:middle;white-space:nowrap}
.topic-card-type .language-level{align-self:center;background:rgb(0 0 0 / .35)}

.topic-card-container{display:grid;gap:8px;min-width:0}
.topic-card-generating{background:#e8ddff;color:#513a7b}
.topic-card-ready{background:#e0f2e6;color:#24633f;border-color:#b9ddc5}
.topic-card-failed{background:#f8e3dc;color:#873e2b;border-color:#eac3b6}
.topic-card-generating-label{animation:topic-generation-pulse 1.6s ease-in-out infinite}
.topic-generation-ring{display:block;flex:none;transform:rotate(-90deg)}
.topic-generation-track{opacity:.25}
.topic-generation-value{stroke-linecap:round;transition:stroke-dashoffset .3s ease}
.topic-generation-ring.indeterminate{animation:topic-generation-spin 1s linear infinite}
@keyframes topic-generation-pulse{0%,100%{opacity:1}50%{opacity:.5}}
@keyframes topic-generation-spin{to{transform:rotate(270deg)}}
@media(prefers-reduced-motion:reduce){.topic-card-generating-label,.topic-generation-ring.indeterminate{animation:none}.topic-generation-value{transition:none}}

/* Compact topic identity, followed by channel/date and actionable activity rows. */
.topic-page {gap:clamp(10px,1.5vw,16px);}
.topic-page .topic-header {display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:clamp(12px,2vw,24px);margin:0;padding:clamp(12px,2vw,22px);border-radius:18px;}
.topic-header-leading {display:grid;justify-items:center;gap:8px;min-width:0;}
.topic-header-leading .topic-cover {display:grid;width:clamp(52px,8vw,88px);height:clamp(52px,8vw,88px);border-radius:12px;overflow:hidden;}
.topic-header-leading .topic-activity-labels {justify-content:center;gap:6px;}
.topic-header-leading .home-hero-eyebrow {margin:0;font-size:.65rem;}
.topic-page .topic-main-title {margin:0;min-width:0;overflow-wrap:anywhere;}
.topic-channel-origin {justify-content:space-between;gap:8px;margin:0;flex-wrap:wrap;}
.topic-channel-source {display:flex;align-items:center;gap:8px;min-width:0;flex:1;}
.topic-channel-source>span {flex:none;color:var(--text-secondary);font-size:.75rem;}
.topic-channel-source .channel-chip {min-width:0;max-width:100%;font-size:.8rem;padding:6px 10px;}
.topic-channel-source .channel-chip-title {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.topic-age {flex:none;color:var(--text);font-size:.75rem;font-weight:550;white-space:nowrap;margin-inline-start:auto;text-shadow:0 1px 2px var(--bg),0 0 5px var(--bg);}
.topic-page .topic-review-bar {margin:2px 0 8px;gap:10px;}
.topic-page .home-feature-section>.section-heading {margin-bottom:10px;}
.topic-page .topic-activities {gap:12px;}
.topic-page .topic-full-reading {margin-top:12px;}
.topic-page .topic-activity {grid-template-columns:clamp(48px,6vw,72px) minmax(0,1fr) auto;gap:clamp(10px,1.5vw,18px);padding:clamp(12px,1.5vw,18px);}
.topic-page .content-reading-button {grid-template-columns:clamp(48px,6vw,72px) minmax(0,1fr) auto;gap:clamp(10px,1.5vw,18px);padding:clamp(12px,1.5vw,18px);min-height:calc(clamp(48px,6vw,72px) + clamp(24px,3vw,36px) + 2px);}
.topic-page .content-reading-art {width:clamp(48px,6vw,72px);height:clamp(48px,6vw,72px);}
@media (min-width:761px) and (max-width:1000px) {.content-reading-help {-webkit-line-clamp:1;}}
.topic-page .topic-activity-icon {width:clamp(48px,6vw,72px);height:clamp(48px,6vw,72px);}
.topic-page .topic-activity-icon>svg {width:clamp(28px,3vw,38px);height:clamp(28px,3vw,38px);}
.topic-page .topic-activity-copy {gap:6px;}
.topic-page .topic-activity-labels {gap:6px;}
.topic-page .topic-activity-copy strong {font-size:1rem;line-height:1.35;}
.topic-page .topic-activity-copy>.muted {font-size:.85rem;}
.topic-page .topic-completion {margin-top:2px;}
.topic-page .topic-more {margin-top:0;}
.screen-docked-meta {display:flex;align-items:center;gap:6px;flex:none;}
.screen-docked-meta .topic-cover {position:relative;display:grid;width:36px;height:36px;border-radius:8px;overflow:hidden;}
.screen-docked-meta .vocabulary-list-art {flex-basis:32px;width:32px;height:32px;border-radius:8px;font-size:1.1rem;}
.screen-docked-meta .vocabulary-list-art .shell-icon {width:18px;height:18px;}
.screen-docked-meta .topic-activity-labels {display:grid;gap:2px;}
.screen-docked-meta .home-hero-eyebrow {margin:0;font-size:.55rem;}
.screen-docked-meta .language-level {font-size:.6rem;padding:1px 4px;justify-self:start;}
.screen-docked-header[data-topic="true"] .screen-docked-back {justify-content:center;}
.screen-docked-header[data-topic="true"] .screen-docked-back>span {display:none;}
.screen-docked-header[data-topic="true"] .screen-docked-inner {gap:10px;}
@media(max-width:600px),(max-height:650px) {
    .workspace:has(.topic-page) {padding-top:14px;}
    .topic-page .topic-header {padding:12px;gap:12px;margin-bottom:0;}
    .topic-page .topic-review-bar {margin:0 0 4px;}
    .topic-page .topic-activities {gap:10px;}
    .topic-page .topic-full-reading {margin-top:10px;}
    .topic-page .topic-activity {grid-template-columns:48px minmax(0,1fr);padding:12px;gap:10px;}
    .topic-page .content-reading-button {grid-template-columns:48px minmax(0,1fr);padding:12px;gap:10px;}
    .topic-page .content-reading-arrow {display:none;}
    .topic-page .topic-activity>svg:last-child {display:none;}
    .topic-page .topic-activity-icon {width:48px;height:48px;}
    .topic-page .topic-activity-status {font-size:.78rem;}
    .topic-page .topic-activity-copy>.muted {font-size:.8rem;}
}

.guided-sentence-card[data-selected="true"] {outline:2px solid var(--accent);outline-offset:4px;border-radius:10px;}
/* Every connection/cache notice stays above the header, including online notices. */
.offline-banners { position: sticky; top: 0; z-index: 10000; }
.offline-banner { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: max(.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left)); background: #f6e8bd; color: #4c4026; font-size: .875rem; line-height: 1.45; }
.offline-banner-copy { min-width: 0; }
button.offline-banner-refresh { display: inline-flex; align-items: center; justify-content: center; flex: none; width: calc(44px * 2 / 3); height: calc(44px * 2 / 3); min-height: calc(44px * 2 / 3); padding: 0; border: 1px solid #4c4026; border-radius: 50%; background: #4c4026; color: #fff; box-shadow: none; }
button.offline-banner-refresh svg { width: calc(20px * 2 / 3); height: calc(20px * 2 / 3); }
@media (hover: hover) and (pointer: fine) { button.offline-banner-refresh:hover { background: #302819; border-color: #302819; color: #fff; } }
.offline-storage-notice { display: flex; align-items: center; justify-content: center; gap: .75rem; line-height: 1.45; padding: .5rem 1rem; background: #f6e8bd; color: #4c4026; font-size: .8rem; text-align: center; }
.offline-storage-notice > span { min-width: 0; }
button.offline-storage-dismiss { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 30px; height: 30px; min-height: 30px; padding: 0; border: none; border-radius: 50%; background: transparent; color: inherit; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { button.offline-storage-dismiss:hover { background: #4c40261a; } }
.offline-storage-settings-warning { justify-content: flex-start; text-align: start; border-radius: 12px; padding: .85rem 1rem; margin-block: .75rem; }
.offline-notice { color: var(--muted, #777); font-weight: normal; }
.speech-button[data-offline-notice="true"] { color: var(--muted, #777); border-color: var(--border, #ddd); }
.offline-cache-total { display: flex; justify-content: space-between; gap: 1rem; padding-block: 1rem; }
.offline-cache-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.offline-cache-table th, .offline-cache-table td { padding: .6rem .25rem; text-align: start; border-bottom: 1px solid var(--border, #ddd); }
.offline-cache-table th:first-child { font-weight: 500; }
.offline-cache-table td, .offline-cache-table th:not(:first-child) { text-align: end; font-variant-numeric: tabular-nums; }
.offline-cache-version-count { display: block; margin-top: .2rem; font-size: .8em; font-weight: 400; }
.offline-cache-table .offline-cache-detail th { padding-inline-start: 1.25rem; }
.offline-cache-table tr:not(.offline-cache-version-note) > td:last-child { white-space: nowrap; }
.offline-cache-detail { font-size: .9em; }
.offline-cache-table .offline-cache-version-note td { text-align: start; font-size: .9em; color: var(--muted); }
.error:has(.offline-notice) { color: var(--muted, #777); background: transparent; border-color: transparent; }
[data-offline] [data-online-required] { opacity: .65; }

/* Measure the full notice stack so online storage/update messages cannot sit
   behind the header and tint its backdrop blur. */
html:has(.offline-banners) .app-shell { --header-height: calc(60px + env(safe-area-inset-top) + var(--offline-banner-height, 0px)); padding-top: calc(var(--header-height) - var(--offline-banner-height, 0px)); min-height: calc(100dvh - var(--offline-banner-height, 0px)); }
html:has(.offline-banners) .app-header { top: var(--offline-banner-height, 0px); height: calc(var(--header-height) - var(--offline-banner-height, 0px)); }
html:has(.offline-banners) dialog.reader-popup[open] { margin-top: calc(var(--offline-banner-height, 0px) + 12px); max-height: calc(100dvh - var(--offline-banner-height, 0px) - 24px); }

/* Full-bleed topic identity and a shared entry point for the recommended activity. */
.topic-page .topic-header {position:relative;grid-template-columns:clamp(112px,22vw,200px) minmax(0,1fr);align-items:stretch;gap:0;padding:0;overflow:hidden;min-height:160px;}
.topic-page .topic-header-leading {display:block;position:relative;min-height:0;width:100%;}
.topic-page .topic-header-leading .topic-cover {position:absolute;inset:0;width:100%;height:100%;border-radius:0;}
.topic-header-leading .topic-cover img {width:100%;height:100%;object-fit:cover;}
.topic-primary-copy {display:flex;flex-direction:column;justify-content:center;gap:10px;min-width:0;padding:clamp(16px,2vw,28px);}
.topic-page .topic-primary-copy .topic-activity-labels {gap:8px;}
.topic-primary-copy .home-hero-eyebrow {margin:0;font-size:.7rem;}
.topic-primary-next {display:flex;align-items:center;flex-wrap:wrap;gap:6px 10px;font-size:.85rem;line-height:1.45;}
.topic-primary-next svg {flex:none;}
.topic-primary-recommendation {color:var(--text-secondary);font-size:.75rem;}
.topic-channel-origin>.topic-age {display:inline-flex;align-items:center;min-height:30px;padding:4px 10px;border:1px solid var(--border);border-radius:999px;background:var(--surface);color:var(--text);line-height:1.4;}
.topic-page .topic-review-bar {display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;}
.topic-actions {margin-inline-start:auto;}
.topic-options-menu {width:min(380px,calc(100vw - 24px));}
.topic-options-menu .topic-art-style {margin:4px 0 16px;}
.topic-art-style-value {display:flex;align-items:center;gap:10px;margin:0;font-weight:600;overflow-wrap:anywhere;}
.topic-art-style-value svg {flex:none;}
.topic-options-actions {display:grid;gap:6px;border-top:1px solid var(--border);padding-top:10px;}
.topic-options-menu .topic-options-actions > button {display:flex;align-items:center;gap:8px;width:100%;justify-content:flex-start;text-align:start;}
.topic-options-actions > button:not(:has(> .shell-icon))::before {content:"";flex:0 0 18px;}
.art-style-popover .art-style-options {margin:0;padding:0;border:0;box-shadow:none;max-height:none;overflow:visible;}
@media(max-width:600px),(max-height:650px) {
    .topic-page .topic-header {padding:0;gap:0;min-height:144px;grid-template-columns:clamp(96px,28vw,140px) minmax(0,1fr);}
    .topic-primary-copy {padding:14px;gap:8px;}
    .topic-primary-copy .topic-main-title {font-size:1.15rem;}
    .topic-primary-next {font-size:.78rem;}
}
.topic-primary-next-title {color:var(--text-secondary);font-size:.82rem;line-height:1.4;}

/* Reading levels remain distinct over illustrated document headers. */
:root, .theme-light, .theme-calm, .theme-system {
  --reading-level-ink: #173e87;
  --reading-level-fill: #edf4ff;
  --reading-level-edge: #2563eb;
}
:root[data-theme="dark"], :root[data-theme="tokyo-night"], .theme-dark, .theme-tokyo-night, .comic-stage {
  --reading-level-ink: #c7e3ff;
  --reading-level-fill: #142c4c;
  --reading-level-edge: #60a5fa;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"], .theme-system {
    --reading-level-ink: #c7e3ff;
    --reading-level-fill: #142c4c;
    --reading-level-edge: #60a5fa;
  }
}
button.reader-reading-level { justify-content: center; min-width: 38px; min-height: 38px; padding: 0; background: transparent; color: inherit; }
.reader-reading-level .language-level { align-self: center; }
.reader-title .reader-reading-level .language-level { color: var(--reading-level-ink); background: var(--reading-level-fill); border-color: var(--reading-level-edge); }
.reading-level-popover { width: min(240px, calc(100vw - 24px)); }
.reading-level-popover p { margin: 0; }
.reader-import-level {display:grid;gap:12px;}
.reader-import-level>label:not(.switch-row) {max-width:360px;}

/* Reserve the actual caption row so artwork stays centered above it, including
   with larger fonts and localized titles. The default still fills the tile. */
[data-topic-image-through-title="false"] > .topic-card {display:grid;grid-template-rows:minmax(0,1fr) auto;}
[data-topic-image-through-title="false"] > .topic-card > .topic-card-art {position:relative;inset:auto;grid-area:1/1;min-width:0;min-height:0;}
[data-topic-image-through-title="false"] > .topic-card > .topic-card-image {grid-area:1/1;}
[data-topic-image-through-title="false"] > .topic-card > .topic-card-copy {grid-area:2/1;margin-top:0;}

/* Add Home metrics according to the tile's available width, including when a
   sidebar is open. Keep the compact goal and streak together on small screens. */
.home-daily-goal-container {container:home-goal / inline-size;margin:-52px 0 16px;}
a.home-daily-goal {display:grid;grid-template-columns:64px minmax(0,1fr) auto;gap:16px 12px;margin:0;padding:18px;min-height:0;}
.home-daily-goal .daily-goal-ring {grid-area:1/1;width:64px;height:64px;flex-basis:64px;}
.home-daily-goal .daily-goal-ring > span {font-size:1rem;}
.home-daily-goal .daily-goal-copy {grid-column:2/-1;grid-row:1;}
.home-daily-goal .daily-goal-copy h2 {margin:0 0 4px;font-size:1.15rem;}
.home-daily-goal .daily-goal-copy p {font-size:.85rem;}
.home-daily-goal .daily-goal-history {grid-column:1/3;grid-row:2;display:flex;align-items:center;gap:12px;padding:0;border:0;min-width:0;}
.home-daily-goal .daily-goal-streak {display:grid;grid-template-columns:auto minmax(0,1fr);align-items:baseline;gap:2px 7px;min-width:0;}
.home-daily-goal .daily-goal-streak strong {font-size:1.5rem;font-weight:750;line-height:1.15;letter-spacing:-.03em;font-variant-numeric:tabular-nums;}
.home-daily-goal .daily-goal-streak > span {font-size:.75rem;line-height:1.35;color:var(--text-secondary);}
.home-daily-goal .daily-goal-total-compact {grid-column:1/-1;font-size:.72rem;}
.home-daily-goal .daily-goal-open {grid-column:3;grid-row:2;align-self:center;justify-self:end;margin:0;}
.home-daily-goal .daily-goal-extra {display:none;min-width:0;border-inline-start:1px solid var(--border);padding-inline-start:24px;}
.home-daily-goal .daily-goal-extra strong {font-size:2rem;line-height:1.1;font-weight:750;letter-spacing:-.04em;font-variant-numeric:tabular-nums;overflow-wrap:anywhere;}
.home-daily-goal .daily-goal-extra > span {color:var(--text-secondary);font-size:.8rem;line-height:1.4;}
.home-daily-goal .daily-goal-total-xp strong {color:var(--xp);}
.home-daily-goal:not(:has(.daily-goal-ring)) .daily-goal-copy {grid-column:1/-1;}
.goal-streak-icon {display:inline-grid;place-items:center;flex:none;width:44px;height:44px;border-radius:15px;color:#df6029;background:color-mix(in srgb,#e8632f 10%,transparent);border:1px solid color-mix(in srgb,#e8632f 20%,transparent);}
.goal-streak-icon[data-active="true"] {color:#ed782d;background:radial-gradient(circle at 30% 20%,#ffcc6529,transparent 75%),color-mix(in srgb,#e8632f 13%,transparent);box-shadow:0 4px 18px #e8632f18,inset 0 1px 0 #ffc36824;}
.goal-streak-icon[data-active="true"] .shell-icon {filter:drop-shadow(0 2px 6px #e8632f38);}
.progress-streak-value {display:flex;align-items:center;flex-wrap:wrap;gap:14px;}
.progress-streak-value > strong {font-size:clamp(2rem,4vw,2.8rem);line-height:1.15;font-variant-numeric:tabular-nums;letter-spacing:-.04em;}
.progress-streak-value > strong > span {font-size:.95rem;font-weight:500;color:var(--muted);letter-spacing:normal;}
.progress-streak-value .goal-streak-icon {width:52px;height:52px;border-radius:18px;}
@media(max-width:650px) {.home-daily-goal-container {margin-top:-40px;}}
@container home-goal (min-width:700px) {
    a.home-daily-goal {grid-template-columns:88px minmax(0,1.2fr) minmax(0,1fr) auto;gap:22px;padding:24px 26px;min-height:140px;}
    .home-daily-goal .daily-goal-ring {width:88px;height:88px;}
    .home-daily-goal .daily-goal-ring > span {font-size:1.2rem;}
    .home-daily-goal .daily-goal-copy {grid-area:1/2;}
    .home-daily-goal .daily-goal-copy h2 {font-size:1.3rem;}
    .home-daily-goal .daily-goal-copy p {font-size:.95rem;}
    .home-daily-goal .daily-goal-history {grid-area:1/3;border-inline-start:1px solid var(--border);padding-inline-start:22px;gap:12px;}
    .home-daily-goal .daily-goal-streak {grid-template-columns:minmax(0,1fr);gap:4px;}
    .home-daily-goal .daily-goal-streak strong {font-size:2rem;}
    .home-daily-goal .daily-goal-open {grid-area:1/4;}
    .home-daily-goal:not(:has(.daily-goal-ring)) .daily-goal-copy {grid-column:1/-2;}
}
@container home-goal (min-width:820px) {
    a.home-daily-goal {grid-template-columns:88px minmax(0,1.2fr) minmax(0,1.1fr) minmax(0,1fr) auto;}
    .home-daily-goal .daily-goal-total-xp {display:grid;gap:7px;grid-area:1/4;}
    .home-daily-goal .daily-goal-total-compact {display:none;}
    .home-daily-goal .daily-goal-open {grid-area:1/5;}
}
@container home-goal (min-width:1100px) {
    a.home-daily-goal {grid-template-columns:88px minmax(0,1.3fr) minmax(0,1.1fr) minmax(0,1fr) minmax(0,1fr) auto;gap:26px;}
    .home-daily-goal .daily-goal-vocab {display:grid;gap:7px;grid-area:1/5;}
    .home-daily-goal .daily-goal-open {grid-area:1/6;}
}
.home-daily-goal .daily-goal-copy p strong {white-space:normal;overflow-wrap:anywhere;}

/* Custom Content is a stack of activity rows, with recent items before a pair of actions. */
.own-content-library {display:grid;gap:32px;}
.own-content-section {container:own-content / inline-size;min-width:0;}
.own-content-section .section-heading h2 {display:flex;align-items:center;gap:10px;}
.own-content-row {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:stretch;gap:14px;}
.own-content-recent {min-width:0;}
.own-content-recent:nth-child(n+2) {display:none;}
.own-content-recent > .feed-content {height:100%;}
.own-content-recent .feed-content-card {width:100%;height:auto;min-height:100%;aspect-ratio:10/9;}
.own-content-actions {grid-column:-2/-1;display:grid;grid-template-rows:repeat(2,minmax(0,1fr));gap:12px;min-width:0;min-height:144px;}
.own-content-actions > .own-content-action {display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;min-height:66px;padding:18px;text-align:start;text-decoration:none;white-space:normal;color:var(--text);background:var(--surface);border:1px solid var(--border);border-radius:18px;box-shadow:var(--shadow-sm);}
@media (hover: hover) and (pointer: fine) { .own-content-actions > .own-content-action:hover:not(:disabled) {background:var(--surface-hover);border-color:var(--accent);} }
.own-content-action > span {display:grid;gap:6px;min-width:0;}
.own-content-action strong {font-size:1rem;overflow-wrap:anywhere;}
.own-content-action small {font-weight:400;font-size:.8rem;line-height:1.4;color:var(--text-secondary);}
.own-content-action > .shell-icon {flex:none;}
.own-content-row[data-empty="true"] {display:block;}
.own-content-row[data-empty="true"] .own-content-actions {grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:1fr;min-height:88px;}
.own-content-all {container:discovery-layout / inline-size;}
@container own-content (min-width:780px) {
    .own-content-row {grid-template-columns:repeat(3,minmax(0,1fr));}
    .own-content-recent:nth-child(2) {display:block;}
}
@container own-content (min-width:1200px) {
    .own-content-row {grid-template-columns:repeat(4,minmax(0,1fr));}
    .own-content-recent:nth-child(3) {display:block;}
}

/* Recorded credit charges, by activity and generation type. */
.credit-usage-controls { display: flex; flex-wrap: wrap; gap: 1rem; margin-block: .75rem; }
.credit-usage-controls label { display: grid; gap: .4rem; font-size: .85rem; color: var(--muted); }
.credit-usage-controls select { min-width: 150px; }
.credit-usage-chart { margin-top: 1.25rem; }
.credit-usage-total { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.credit-usage-total strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.credit-usage-total span { color: var(--muted); font-size: .85rem; }
.credit-usage-cursor { fill: var(--text); opacity: .06; }
.credit-usage-legend, .credit-usage-day { display: flex; flex-wrap: wrap; gap: .65rem 1.2rem; font-size: .8rem; }
.credit-usage-legend { margin-top: .75rem; }
.credit-usage-legend > span, .credit-usage-day > span { display: inline-flex; align-items: center; gap: .35rem; }
.credit-usage-swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; flex-shrink: 0; }
.credit-usage-day { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.credit-usage-day > strong { flex-basis: 100%; }
@media (max-width: 480px) {
  .credit-usage-controls label { flex: 1; min-width: 0; }
  .credit-usage-controls select { min-width: 0; width: 100%; }
  .credit-usage-over-time .token-budget-heading { align-items: start; }
}

/* Content management controls stay outside each tile's navigation target. */
.managed-tile { position: relative; min-width: 0; }
.managed-tile > .home-content-card, .managed-tile > .topic-card { width: 100%; }
.tile-management { position: absolute; inset-inline-end: 10px; bottom: 10px; z-index: 3; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s ease; }
.managed-tile:has(:focus-visible) > .tile-management, :root[data-touch-input] .tile-management, .tile-management[data-open="true"] { opacity: 1; visibility: visible; pointer-events: auto; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .managed-tile:hover > .tile-management { opacity: 1; visibility: visible; pointer-events: auto; } }
button.tile-management-trigger { width: 36px; height: 36px; min-height: 36px; padding: 7px; border: 1px solid transparent; color: var(--text); background: transparent; box-shadow: none; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button.tile-management-trigger:hover { border-color:var(--border); background:var(--surface-hover); } }
.managed-tile .home-content-copy, .managed-tile .topic-card-copy { padding-inline-end: 56px; }
.tile-management-menu { min-width: 180px; }
.recent-activity-tile { position:relative; min-width:0; --recent-menu-space:52px; }
.recent-activity-tile[data-pinned="true"] { --recent-menu-space:76px; }
.recent-activity-tile > .tile-management {
  display:flex; align-items:center; gap:4px; inset-inline:auto; right:8px; bottom:8px;
  opacity:1; visibility:visible; pointer-events:auto;
}
.recent-activity-pin { display:inline-flex; color:var(--text-secondary); }
.content-management-controls { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; margin: 24px 0 18px; }
.content-management-controls label { display: grid; gap: 8px; margin: 0; }
.content-management-controls label:first-child { flex: 1; min-width: min(240px, 100%); }
.content-management-controls input, .content-management-controls select { width: 100%; }
.content-management-grid { margin-top: 18px; }
@media (hover: none) { .tile-management { opacity: 1; visibility: visible; pointer-events: auto; } }
@media (max-width: 600px) { .content-management-controls label { flex: 1; min-width: min(240px, 100%); } }

/* Mount a blank comic shell immediately, even before showModal reaches the bridge. */
.flashcard-stage.comic-stage { z-index: 1000; }
.comic-opening-status { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 1rem; font-weight: 600; }
.comic-preparing > .comic-preparation-card:has(.comic-opening-status) { max-width: 400px; }

/* Comic information is tucked into the toolbar; welcome keeps one preference. */
.comic-opening-topbar {justify-content:flex-end;}
.comic-welcome .comic-title-translation {color:rgb(255 255 255 / .82);font-size:clamp(1rem,2.2vw,1.25rem);line-height:1.4;}
.comic-autoplay-toggle {width:100%;padding:6px;border:1px solid transparent;border-radius:16px;background:transparent;color:var(--text);text-align:start;white-space:normal;font-weight:500;}
@media (hover: hover) and (pointer: fine) { .comic-autoplay-toggle:hover {background:rgba(255,255,255,.08);} }
.comic-autoplay-icon {display:grid;place-items:center;width:44px;height:44px;border-radius:16px;background:rgba(255,255,255,.08);border:1px solid var(--border);}
.comic-autoplay-toggle[aria-pressed="true"] .comic-autoplay-icon {background:rgba(255,255,255,.2);border-color:rgba(255,255,255,.45);}
.comic-info-menu {z-index:20;pointer-events:auto;width:min(420px,calc(100vw - 24px));}
.comic-info-menu .anchored-popover-heading {align-items:flex-start;}
.comic-info-menu .anchored-popover-heading h2 {font-size:1.15rem;line-height:1.4;}
.comic-info-menu .comic-title-translation {margin:0;color:var(--text-secondary);line-height:1.5;}
.comic-menu-progress {display:grid;gap:12px;min-width:0;padding-block:8px;}
.comic-menu-review {display:flex;align-items:center;justify-content:center;gap:8px;width:100%;}
.comic-info-retry {display:grid;gap:8px;}

.comic-menu-progress .reader-learning-heading {justify-content:space-between;}

/* Keep audio available while the secondary actions fold into a measured overflow menu. */
.comic-action-controls.comic-control-scrim,.comic-inline-actions,.comic-action-options {gap:0}
.comic-audio-control,.comic-inline-actions,.comic-action-options {display:flex;align-items:center;width:max-content;flex-shrink:0}
.comic-inline-actions>.icon-button,.comic-action-options>.icon-button {width:44px;min-width:44px;height:44px;border-radius:16px;margin:0}
#comic-actions-popover {width:max-content;min-width:180px;background:#202226;color:var(--text);border-color:#53565f;pointer-events:auto}
@media(max-width:640px), (max-height:600px) {
    .comic-display-menu>.icon-button,.comic-action-controls .speech-button,.comic-action-controls>.icon-button,.comic-inline-actions>.icon-button {width:36px;min-width:36px;height:36px}
    .comic-navigation .icon-button.comic-step-target {width:72px;min-width:72px;height:36px}
}

.comic-audio-control .speech-error {max-width:180px}

/* Passive, centered feedback above readers and their full-screen dialogs. */
.toggle-feedback {position:fixed;inset:auto auto max(24px,env(safe-area-inset-bottom)) 50%;transform:translateX(-50%);margin:0;z-index:2147483647;display:flex;align-items:center;justify-content:center;gap:12px;width:max-content;max-width:calc(100vw - 32px);box-sizing:border-box;padding:16px 24px;border:1px solid rgba(255,255,255,.2);border-radius:999px;background:rgba(20,22,27,.86);color:#fff;box-shadow:0 8px 36px #0005;backdrop-filter:blur(16px) saturate(120%);-webkit-backdrop-filter:blur(16px) saturate(120%);font-size:1rem;font-weight:600;line-height:1.4;text-align:center;pointer-events:none;user-select:none;opacity:0}
.toggle-feedback[data-visible="true"] {opacity:1;animation:toggle-feedback-in .16s ease-out}
.toggle-feedback::backdrop {background:transparent;pointer-events:none}
.toggle-feedback>svg {width:28px;height:28px;flex:none}
.toggle-feedback>span {min-width:0;overflow-wrap:anywhere}
@keyframes toggle-feedback-in {from {opacity:0} to {opacity:1}}
@media(prefers-reduced-motion:reduce) {.toggle-feedback[data-visible="true"] {animation:none}}

/* Preparation reserves normal-flow space for the title above its centered status. */
.reader-popup.input-preparation {position:fixed;inset:0;width:100%;max-width:none;height:100dvh;max-height:none;margin:0;border:0;border-radius:0;background:var(--bg);box-shadow:none;}
.input-preparation > .reader-popup-heading {align-items:flex-start;gap:20px;padding:max(18px,env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) 18px max(20px,env(safe-area-inset-left));}
.input-preparation > .reader-popup-heading h2 {min-width:0;max-width:64ch;font-size:clamp(1rem,2vw,1.25rem);line-height:1.5;overflow-wrap:anywhere;}
.input-preparation > .reader-popup-heading .icon-button {width:44px;height:44px;}
.input-preparation > .reader-popup-body {display:flex;flex:1;padding:clamp(20px,5vw,64px) max(20px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left));}
.input-preparation-status {display:flex;flex-direction:column;align-items:center;gap:20px;width:min(100%,540px);margin:auto;padding:clamp(24px,5vw,48px);border:1px solid var(--border);border-radius:24px;background:var(--surface);text-align:center;overflow-wrap:anywhere;}
.input-preparation-label {color:var(--muted);font-size:.8rem;}
.input-preparation-status > .word-illustration-spinner {display:block;flex:none;width:44px;height:44px;border-width:3px;}
.input-preparation-status h3 {margin:0;font-size:clamp(1.2rem,3vw,1.6rem);line-height:1.4;}
.input-preparation-status p {margin:0;max-width:38ch;color:var(--text-secondary);line-height:1.6;}

/* Comprehensible input uses the page theme, with themed glass around
   lesson controls and isolated cutout images. */
.input-setup {display:grid;gap:22px;}
.input-source-options {display:grid;gap:12px;}
.input-source-options .reader-synopsis-option {justify-content:flex-start;}
.input-source-options .reader-synopsis-option>span {flex:1;}
.input-source-options small {color:var(--muted);font-weight:400;line-height:1.5;}
.input-list-options,.input-word-options {max-height:320px;overflow-y:auto;overscroll-behavior:contain;}
.input-list-options {display:grid;gap:8px;padding:4px;}
.input-setup label {display:grid;gap:8px;}
.input-experience {--input-glass-opacity:100%;--input-glass-filter:none;--input-space:clamp(6px,min(1.6vw,1.8dvh),18px);--input-inset:clamp(8px,min(2.5vw,2.6dvh),24px);isolation:isolate;position:fixed;inset:0;z-index:100;background:var(--bg);color:var(--text);overflow:hidden;padding:env(safe-area-inset-top) max(var(--input-inset),env(safe-area-inset-right)) max(var(--input-space),env(safe-area-inset-bottom)) max(var(--input-inset),env(safe-area-inset-left));display:flex;flex-direction:column;}
.input-header {display:flex;align-items:center;justify-content:space-between;gap:var(--input-space);padding:var(--input-space) var(--input-inset);max-width:1200px;width:100%;margin:var(--input-space) auto;flex-shrink:0;}
.input-heading {text-align:center;min-width:0;}.input-heading small {color:var(--muted);}.input-heading h1 {overflow-wrap:anywhere;font-size:clamp(1rem,2vw,1.4rem);margin:4px 0;}
.input-progress {flex-shrink:0;display:flex;align-items:center;gap:12px;max-width:720px;width:100%;margin:0 auto;color:var(--muted);font-size:.8rem;}.input-progress progress {min-width:0;flex:1;height:5px;accent-color:var(--accent);}
.input-reward-anchor {position:relative;flex:none;height:0;}
.input-reward-anchor button.xp-celebration[data-compact="true"] {position:absolute;top:var(--input-space);right:0;}
.input-step-region {flex:1;min-height:0;display:flex;flex-direction:column;padding-top:var(--input-space);}
.input-step {flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;gap:var(--input-space);max-width:1100px;width:100%;margin:0 auto;}
/* The content gets the remaining viewport; controls and navigation reserve their own space. */
.input-content {flex:1;min-height:0;width:100%;display:flex;flex-direction:column;align-items:center;justify-content:safe center;gap:var(--input-space);overflow:auto;overscroll-behavior:contain;}
.input-content > :not(.input-stage):not(.input-starting-scene) {flex-shrink:0;}
.input-controls .input-answer {gap:var(--input-space);}
.input-controls {flex:0 1 auto;min-height:0;max-height:60dvh;width:100%;display:flex;flex-direction:column;align-items:center;gap:var(--input-space);}
.input-controls > .input-response {flex:0 1 auto;min-height:0;max-height:35dvh;overflow:auto;overscroll-behavior:contain;}
.input-navigation {display:flex;align-items:center;justify-content:space-between;gap:var(--input-space);width:100%;min-height:46px;flex:none;}
.input-navigation > .input-screen-next {margin-inline-start:auto;}
.input-review-badge {align-self:center;display:inline-flex;align-items:center;justify-content:center;padding:5px 14px;border-radius:999px;background:#d8c7ff;color:#382651;font-size:.8rem;font-weight:650;line-height:1.4;}
.input-stage {position:relative;display:flex;align-items:stretch;justify-content:center;gap:var(--input-space);width:100%;flex:0 1 42dvh;min-height:64px;max-height:520px;}
.input-picture {position:relative;display:flex;align-items:center;justify-content:center;flex:1;min-width:0;min-height:0;border:2px solid transparent;border-radius:24px;background:transparent;padding:var(--input-space);box-shadow:none;}
.input-picture:disabled {opacity:1;cursor:default;}.input-picture img {width:100%;height:100%;min-height:0;object-fit:contain;}.input-picture[data-selected=true] {border-color:var(--accent);}@media (hover: hover) and (pointer: fine) { .input-stage[data-choices=true] .input-picture:hover:not(:disabled) {border-color:var(--accent);} }
.input-picture-number {position:absolute;bottom:10px;left:14px;font-size:.8rem;color:var(--muted);}.input-stage-loading {position:absolute;inset:0;display:flex;flex-direction:column;gap:16px;align-items:center;justify-content:center;background:var(--bg);border-radius:24px;}
.input-caption {width:100%;text-align:center;}.input-target {display:flex;align-items:center;justify-content:center;gap:12px;flex-wrap:wrap;font-size:clamp(1.4rem,3vw,2.2rem);line-height:1.8;}.input-target .reader-word-help {text-align:start;}.input-instruction {display:flex;align-items:center;justify-content:center;gap:12px;font-size:1.1rem;}.input-instruction p {margin:8px 0;}
.input-answer {width:min(100%,620px);display:grid;gap:12px;}.input-answer textarea {width:100%;}.input-answer audio {width:100%;}.input-feedback {width:min(100%,700px);text-align:center;padding:20px;border:1px solid var(--border);border-radius:20px;}.input-feedback[data-correct=true] {border-color:var(--accent);}.input-feedback button {margin-top:16px;}.input-next {display:flex;align-items:center;gap:12px;}.input-complete,.input-loading {margin:auto;display:flex;flex-direction:column;align-items:center;text-align:center;gap:16px;padding:40px 20px;}
@media(max-width:650px) {.input-stage[data-choices=true] {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-auto-rows:minmax(0,1fr);}}

.input-answer .reader-flashcard-toolbar {display:grid;grid-template-rows:auto;justify-content:center;gap:12px;}
.input-answer .reader-flashcard-toolbar button {grid-row:1;}
.input-step .reader-flashcard-toolbar > button:first-child:not(.voice-record-button) {min-width:11rem;}
.input-practice-celebration {display:flex;align-items:center;justify-content:center;gap:10px;font-size:1.1rem;animation:input-practice-pop .45s ease-out;}
.input-practice-celebration svg {padding:6px;width:40px;height:40px;border-radius:50%;background:light-dark(#24734518,#90dfaf18);box-shadow:0 0 0 6px light-dark(#24734508,#90dfaf08);}
@keyframes input-practice-pop {0% {transform:scale(.85);opacity:0;} 65% {transform:scale(1.06);} 100% {transform:scale(1);opacity:1;}}
@media(prefers-reduced-motion:reduce) {.input-practice-celebration {animation:none;}}


.input-recording {width:min(100%,620px);display:grid;gap:8px;text-align:center;}
.input-recording audio {width:100%;}

/* Match the Home page's palette and transparency, with solid fallbacks. */
@supports ((backdrop-filter:blur(18px)) or (-webkit-backdrop-filter:blur(18px))) {
  .input-experience {--input-glass-opacity:var(--home-glass-opacity,82%);--input-glass-filter:blur(18px) saturate(1.1);}
}
.input-experience :is(.input-header,.input-progress,.input-picture,.input-teaching-card,.input-listening-caption,.input-response,.input-complete,.input-loading,.input-stage-loading):not(:where(.input-teaching-card .input-picture)) {
  background:var(--surface);
  background:color-mix(in srgb,var(--surface) var(--input-glass-opacity),transparent);
  border:1px solid color-mix(in srgb,var(--border) 80%,transparent);
  border-radius:24px;
  box-shadow:0 8px 28px #0000000c;
  -webkit-backdrop-filter:var(--input-glass-filter);
  backdrop-filter:var(--input-glass-filter);
}
.input-progress {padding:10px 18px;}
.input-response {display:flex;flex-direction:column;align-items:center;gap:var(--input-space);width:min(100%,760px);padding:var(--input-space) var(--input-inset);text-align:center;}
.input-listening-caption {width:fit-content;max-width:100%;padding:var(--input-space) var(--input-inset);}
.input-experience .input-picture {border-width:2px;}
.input-picture[data-selected=true] {border-color:var(--accent);}
@media (hover: hover) and (pointer: fine) { .input-stage[data-choices=true] .input-picture:hover:not(:disabled) {border-color:var(--accent);} }
.input-feedback {padding:0;border:0;}
.input-stage[aria-busy=true] .input-picture {visibility:hidden;}
.input-stage-loading {padding:24px;text-align:center;}
.input-complete,.input-loading {width:min(100%,700px);min-height:0;max-height:100%;overflow:auto;flex-shrink:1;}
.input-complete-navigation {margin-top:var(--input-space);}
@media(prefers-reduced-transparency:reduce) {
  .input-experience {--input-glass-opacity:100%;--input-glass-filter:none;}
}
@media(max-width:650px) {
  .input-header {border-radius:20px;}
  .input-instruction {font-size:1rem;}
  .input-experience .input-picture {border-radius:18px;}
}

.input-stage[aria-busy=true] {flex-basis:42dvh;}
.input-stage-loading {padding:20px;overflow:auto;}
.input-loading-title {margin:0;text-align:center;font-size:1rem;}
.input-loading-progress {width:min(100%,360px);display:grid;gap:10px;font-size:.85rem;}
.input-loading-row {display:grid;grid-template-columns:1fr auto;gap:5px 12px;}
.input-loading-row progress {grid-column:1 / -1;width:100%;height:5px;accent-color:var(--accent);}

.input-response {position:relative;}
.input-mode-toggle {position:absolute;top:12px;right:12px;margin:0;}
.input-response:has(.input-mode-toggle) .input-caption {padding-inline:36px;}
.input-answer textarea[hidden] {display:none;}
.input-feedback-summary {display:flex;align-items:center;justify-content:center;gap:10px;}
.input-feedback .input-feedback-summary button {margin:0;}
.input-feedback-popover {max-width:min(420px,calc(100vw - 28px));max-height:60dvh;overflow:auto;line-height:1.6;}
.input-feedback-summary[data-outcome="success"] {color:light-dark(#247345,#90dfaf);}
.input-feedback-summary[data-outcome="partial"] {color:light-dark(#936800,#f5cd62);}
.input-feedback-summary[data-outcome="retry"] {color:light-dark(#b72e37,#ff8b94);}

.app-update-toast {inset:auto auto max(24px,env(safe-area-inset-bottom)) 50%;transform:translateX(-50%);}

.input-playback-settings {display:grid;gap:16px;margin-bottom:24px;}
.input-playback-settings label {display:flex;align-items:center;gap:10px;}

/* Keep Home's language controls available as the hero scrolls away. */
.home-language-slot { min-width: 0; }
.home-language-controls { transition: background-color .2s ease, box-shadow .2s ease; }
.home-language-controls h1 { transition: font-size .2s ease, gap .2s ease; }
.home-dashboard[data-language-stuck="true"] > .home-hero { z-index: 40; }
.home-language-controls[data-stuck="true"] {
  position: fixed; top: var(--header-height); inset-inline: var(--content-inset-start, 0px) 0;
  box-sizing: border-box; z-index: 40;
  min-height: 48px; padding: 4px 12px; gap: 8px 16px;
  border-radius: 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 1px 0 var(--border);
}
.home-language-controls[data-stuck="true"] h1 { font-size: 1.15rem; gap: 8px; }
.home-language-controls[data-stuck="true"] .home-language-menu { flex: 1; }
.home-language-controls[data-stuck="true"] .home-language-trigger { gap: 8px; margin: 0; padding: 4px; max-width: 100%; min-height: 40px; }
.home-language-controls[data-stuck="true"] .home-language-trigger > .shell-icon { width: 18px; height: 18px; }
.home-language-controls[data-stuck="true"] .home-target-level-button { min-width: 64px; min-height: 36px; padding: 4px 10px; }
.home-dashboard :is(.home-feature-section,.home-quests) > .section-heading {
  top: calc(var(--header-height) + var(--home-dock-height, 0px));
}
.home-dashboard .section-heading :is(h2,.home-section-icon) { transition: font-size .2s ease, width .2s ease, height .2s ease; }
.home-dashboard .section-heading[data-stuck="true"] h2 { font-size: 1rem; }
.home-dashboard .section-heading[data-stuck="true"] .home-section-icon { width: 28px; height: 28px; }
@media(prefers-reduced-motion:reduce) {
  .home-language-controls, .home-language-controls h1,
  .home-dashboard .section-heading, .home-dashboard .section-heading :is(h2,.home-section-icon) { transition: none; }
}

/* Compact language and level controls when the hero scrolls away. */
.home-target-level-display { display: none; }
.home-language-controls[data-stuck="true"] { flex-wrap: nowrap; gap: 8px 16px; }
.home-language-controls[data-stuck="true"] > :not(.home-language-menu,.home-target-level) { display: none; }
.home-language-controls[data-stuck="true"] .home-target-level-control { display: none; }
.home-language-controls[data-stuck="true"] .home-target-level-display {
  display: inline-flex; align-items: center; justify-content: center; min-height: 30px;
  padding: 2px 9px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-secondary); font-size: .85rem; font-weight: 600; line-height: 1.2;
}
.home-language-controls[data-stuck="true"] > .home-target-level { flex: none; }
.home-language-controls[data-stuck="true"] .home-language-trigger { white-space: nowrap; }
.home-language-controls[data-stuck="true"] .home-language-trigger > span:not(.home-flag) {
  display: inline-block; max-width: 40rem; white-space: nowrap; overflow: hidden;
  transition: max-width .22s ease, opacity .18s ease;
}
.home-language-controls[data-flag-only="true"] .home-language-trigger > span:not(.home-flag) { max-width: 0; opacity: 0; }
.home-language-controls[data-flag-only="true"] .home-language-trigger { gap: 0; }
.home-language-controls[data-flag-only="true"] .home-language-trigger > .shell-icon { width: 0; opacity: 0; }
.home-language-controls[data-stuck="true"] .home-language-trigger > .shell-icon { transition: width .22s ease, opacity .18s ease; }
@media(prefers-reduced-motion:reduce) {
  .home-language-controls[data-stuck="true"] :is(.home-language-trigger > span,.home-language-trigger > .shell-icon) { transition: none; }
}

/* Analysis advances over the existing text without adding width or line boxes. */
.reader-pending-character { border-radius: .12em; animation: reader-character-pulse 1.4s ease-in-out infinite; }
@keyframes reader-character-pulse {
  0%, 100% { background-color: color-mix(in srgb, var(--accent) 12%, transparent); }
  50% { background-color: color-mix(in srgb, var(--accent) 35%, transparent); }
}
@media(prefers-reduced-motion:reduce) {
  .reader-pending-character { animation: none; background-color: color-mix(in srgb, var(--accent) 22%, transparent); }
}

/* Keep sentence actions exposed; navigation gives up surplus width first. */
.comic-footer { grid-template-columns: auto minmax(max-content,1fr) auto; }
.comic-navigation { --comic-nav-ideal: 88; --comic-nav-min: 44; }
.comic-navigation .icon-button.comic-step-target { width: var(--comic-arrow-width,88px); min-width: var(--comic-arrow-width,88px); }
@media(max-width:640px) {
  .comic-navigation { --comic-nav-ideal: 72; --comic-nav-min: 36; }
  .comic-navigation .icon-button.comic-step-target { width: var(--comic-arrow-width,72px); min-width: var(--comic-arrow-width,72px); }
}

/* Interest topics share account identity while follows belong to the active language. */
.tile-management-menu .menu-item { display:flex; align-items:center; text-decoration:none; }

/* Keep the feed timing readable over artwork in every theme. */
.feed-next-suggestion {color:var(--text);font-weight:550;text-shadow:0 1px 2px var(--bg),0 0 5px var(--bg);}

.art-style-preferences { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,260px),1fr)); gap: 8px; max-height: none; overflow: visible; overscroll-behavior: auto; box-shadow: none; }
.art-style-preferences img { width: 64px; height: 64px; }
.art-style-preferences .art-style-option { border: 1px solid var(--border); opacity: 1; }
.art-style-preferences .art-style-option.selected { border-color: var(--accent); }
/* A selected style can be locked because at least one must remain enabled.
   Dim excluded styles, independently of this temporary/last-style input lock. */
.art-style-preferences .art-style-option[aria-checked="false"] { color: var(--text-secondary); }
.art-style-preferences .art-style-option[aria-checked="false"] img { opacity: .55; filter: grayscale(.75); }

.app-version-gate { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; border: 0; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); background: var(--bg, #111); color: var(--text); overflow-y: auto; }
.app-version-gate:not([open]) { display: none; }
.app-version-gate.study-obscured { filter: none; }
/* Calm, theme-colored update progress. */
.version-loading {width:min(100%,360px);display:flex;flex-direction:column;align-items:center;text-align:center;padding-block:24px;}
.version-loading-brand .wordmark {width:166px;color:var(--text);}
.version-loading-art {display:grid;place-items:center;width:128px;height:128px;margin:36px 0 32px;color:var(--accent,var(--text));}
.version-loading-throbber {width:56px;height:56px;animation:version-loading-spin 1s linear infinite;}
.version-loading-status {display:grid;gap:14px;width:100%;}
.version-loading-status h1 {font-size:1.15rem;line-height:1.45;font-weight:600;margin:0;color:var(--text);text-wrap:balance;}
.version-download-meter {height:7px;border-radius:99px;overflow:hidden;background:var(--border);margin-top:9px;}
.version-download-fill {display:block;position:relative;height:100%;width:var(--download-progress);border-radius:inherit;background:var(--accent,var(--text));transition:width .6s ease;overflow:hidden;}
.version-download-meter[data-determinate="false"] .version-download-fill {animation:version-download-sweep 2s ease-in-out infinite;}
.version-download-detail {display:flex;align-items:center;justify-content:space-between;gap:16px;font-size:.82rem;color:var(--text-secondary);font-variant-numeric:tabular-nums;min-height:20px;}
.version-download-detail:has(> :only-child) {justify-content:center;}
.version-download-percent {font-weight:600;color:var(--text);}
.version-loading button.version-continue-offline {margin-top:64px;min-height:44px;padding:10px 16px;background:none;border:0;border-radius:6px;box-shadow:none;color:var(--muted);font-size:.85rem;font-weight:400;}
@media (hover: hover) and (pointer: fine) { .version-loading button.version-continue-offline:hover {background:none;color:var(--text);text-decoration:underline;text-underline-offset:4px;transform:none;box-shadow:none;} }
/* Keep recovery reachable below the centered status, including phone safe areas. */
.app-version-gate {padding-bottom:max(108px,calc(92px + env(safe-area-inset-bottom)));}
.version-loading-footer {position:fixed;bottom:max(16px,env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);width:max-content;max-width:calc(100% - 48px);display:flex;flex-direction:column;align-items:center;}
.version-loading button.version-clear-cache {max-width:100%;min-height:44px;padding:10px 16px;background:none;border:0;box-shadow:none;color:var(--muted);font-size:.85rem;font-weight:400;}
@media (hover: hover) and (pointer: fine) { .version-loading button.version-clear-cache:hover {background:none;color:var(--text);text-decoration:underline;text-underline-offset:4px;transform:none;box-shadow:none;} }
.version-loading[data-phase="error"] .version-loading-art *,.version-loading[data-phase="error"] .version-download-fill {animation-play-state:paused;}
.version-loading[data-phase="error"] .version-download-meter {opacity:.45;}
@keyframes version-loading-spin {to {transform:rotate(360deg);}}
@keyframes version-download-sweep {0%,100% {transform:translateX(-5%);}50% {transform:translateX(195%);}}
@media (max-height:620px) {.version-loading-art {margin-block:20px;height:100px;}.version-loading button.version-continue-offline {margin-top:32px;}}
@media (prefers-reduced-motion:reduce) {.version-loading-art *,.version-download-fill {animation:none;transition:none;}}

/* Active click-to-record buttons breathe while waiting and spring with the voice. */
button.mic-listening {display:inline-flex;align-items:center;justify-content:center;gap:12px;}
button.mic-listening::before {content:"";flex:none;width:14px;height:14px;border-radius:50%;background:currentColor;box-shadow:0 0 0 5px color-mix(in srgb,currentColor 10%,transparent);animation:mic-listening-pulse 1.6s ease-in-out infinite;}
button.mic-listening[data-speaking="true"]::before {animation:mic-listening-bounce .36s cubic-bezier(.22,.68,.28,1.4) infinite alternate;}
@keyframes mic-listening-pulse {0%,100% {transform:scale(.8);opacity:.5;}50% {transform:scale(1);opacity:.95;}}
@keyframes mic-listening-bounce {0% {transform:translateY(2px) scaleX(calc(1 + var(--mic-energy,0) * .28)) scaleY(.8);border-radius:48% 52% 44% 56%;}100% {transform:translateY(calc(-2px - var(--mic-energy,0) * 4px)) scaleX(.9) scaleY(calc(1.05 + var(--mic-energy,0) * .45));border-radius:44% 56% 54% 46%;}}
@media(prefers-reduced-motion:reduce) {button.mic-listening::before,button.mic-listening[data-speaking="true"]::before {animation:none;transform:none;}button.mic-listening[data-speaking="true"]::before {box-shadow:0 0 0 5px color-mix(in srgb,currentColor 24%,transparent);}}

.input-progress.input-trail {position:relative;display:grid;max-width:960px;min-height:44px;}
.input-trail-toggle {position:absolute;inset:0;z-index:1;width:100%;height:100%;min-height:0;padding:0;border:0;border-radius:inherit;background:transparent;box-shadow:none;cursor:pointer;}
@media (hover: hover) and (pointer: fine) { .input-trail-toggle:hover {background:color-mix(in srgb,var(--text) 4%,transparent);} }
.input-trail-toggle:active {transform:none;}
.input-trail-popover .input-trail-legend {flex-direction:column;align-items:flex-start;gap:12px;font-size:.85rem;}
.input-trail-popover .input-trail-legend span::before {width:9px;height:9px;}
/* Shared reading trails: completion, readiness and current position are independent. */
.input-progress.input-trail,.guided-step-trail {color:#fff;background:rgba(14,16,20,.68);border:1px solid #ffffff1f;border-radius:14px;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);}
.input-progress.input-trail {padding:10px 14px;}
.guided-step-trail {position:absolute;z-index:3;top:calc(max(16px,env(safe-area-inset-top)) + 60px);left:50%;transform:translateX(-50%);width:calc(100% - 48px);max-width:960px;padding:10px 12px;pointer-events:auto;}
.guided-step-trail .input-trail-toggle {border-radius:14px;}
.step-trail-track {display:flex;align-items:center;gap:3px;min-width:0;overflow-x:auto;padding:4px;scrollbar-width:none;}
.step-trail-track::-webkit-scrollbar {display:none;}
.step-trail-segment {position:relative;flex:1 0 5px;min-width:5px;height:8px;border-radius:999px;background:var(--trail-color,#ffffff26);transition:background-color .25s ease;}
:is(.step-trail-segment,.input-trail-legend span)[data-state="complete"] {--trail-color:#69c68e;}
:is(.step-trail-segment,.input-trail-legend span)[data-state="started"] {--trail-color:#e4b955;}
:is(.step-trail-segment,.input-trail-legend span)[data-state="loaded"],:is(.step-trail-segment,.input-trail-legend span)[data-state="not_started"] {--trail-color:#ffffff61;}
:is(.step-trail-segment,.input-trail-legend span)[data-state="loading"] {--trail-color:#ffffff38;}
:is(.step-trail-segment,.input-trail-legend span)[data-state="unloaded"],.input-trail-legend span[data-state="failed"] {--trail-color:#ffffff26;}
.input-trail .step-trail-segment[data-bonus-xp="true"] {--trail-color:var(--xp);}
.step-trail-segment[aria-current="step"] {outline:1.5px solid #fff;outline-offset:1px;}
.step-trail-segment[data-loading="true"]::after {content:"";position:absolute;inset:0;border-radius:inherit;background:#ddd;animation:step-trail-loading 1.4s ease-in-out infinite;}
@keyframes step-trail-loading {0%,100% {opacity:.08;}50% {opacity:.55;}}
.step-trail-segment[data-failed="true"]::before {content:"";position:absolute;right:0;top:-2px;width:4px;height:4px;border-radius:50%;background:#f48c80;}
.step-trail-segment:is([data-photo="true"],[data-step="conclusion"]) {flex:0 0 3px;min-width:3px;height:10px;margin-inline:3px;outline:none;}
.step-trail-segment:is([data-photo="true"],[data-step="conclusion"])[aria-current="step"] {outline:1.5px solid #fff;outline-offset:2px;}
.step-trail-segment:is([data-photo="true"],[data-step="conclusion"])[data-bonus-xp="true"] { background:var(--xp);outline-color:var(--xp); }
.step-trail-segment[data-question="true"] {display:grid;place-items:center;flex:0 0 16px;min-width:16px;height:16px;margin-inline:2px;border-radius:4px;background:transparent;color:#ffffffbf;}
.step-trail-segment[data-question="true"][data-bonus-xp="true"] {color:var(--xp);}
.step-trail-segment[data-question="true"] svg {display:block;}
.input-trail-legend .step-trail-question-legend::before {content:none;}
.input-trail-legend {display:flex;justify-content:center;gap:8px 16px;flex-wrap:wrap;font-size:.68rem;color:inherit;}
.input-trail-legend span {display:inline-flex;align-items:center;gap:8px;}
.input-trail-legend span::before {content:"";width:18px;height:8px;border-radius:999px;background:var(--trail-color,#ffffff26);}
.input-trail-legend span[data-state="current"]::before {outline:2px solid #fff;outline-offset:2px;}
.input-trail-legend span[data-state="loading"]::before {animation:step-trail-loading 1.4s ease-in-out infinite;}
.input-trail-legend span[data-state="failed"]::before {box-shadow:inset -4px 0 #f48c80;}
.input-trail-legend .step-trail-page-legend::before {width:3px;height:10px;border-radius:2px;outline:1px solid #ffffffa6;outline-offset:1px;background:#ffffff61;margin-inline:8px;}
.input-trail-popover {background:#202226;color:#fff;color-scheme:dark;}
.input-trail-popover .input-trail-legend span::before {width:18px;height:8px;}
.input-trail-popover .input-trail-legend .step-trail-page-legend::before {width:3px;height:10px;}
@media(max-width:600px) {.guided-step-trail {width:calc(100% - 32px);}}
@media(prefers-reduced-motion:reduce) {.step-trail-segment,.step-trail-segment[data-loading="true"]::after,.input-trail-legend span[data-state="loading"]::before {transition:none;animation:none;}.step-trail-segment[data-loading="true"]::after {opacity:.28;}}

/* First picks keep three generous slots throughout both setup journeys. */
.setup-journey .entry-shell:has(.first-picks) {width:min(1240px,100%);min-width:0;flex-shrink:0;}
/* StateScope emits a flex item: constrain it before the carousel computes its tracks. */
.add-profile-journey > div {width:100%;min-width:0;}
.first-picks {width:100%;min-width:0;container-type:inline-size;}
.first-picks .first-picks-grid {display:grid;grid-template-columns:repeat(3,minmax(min(300px,calc(100% - 4px)),1fr));grid-auto-flow:column;gap:20px;width:100%;min-width:0;overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x proximity;scroll-padding-inline:2px;scrollbar-width:thin;scrollbar-color:var(--border-strong) transparent;padding:4px 2px 14px;margin:20px 0;align-items:start;}
/* Use the page gutters for the fade so a card at either end stays fully visible. */
@container (max-width: 943px) {
  .first-picks .first-picks-grid {
    --edge-fade: 18px;
    width:calc(100% + 2 * var(--edge-fade));
    box-sizing:border-box;
    margin-inline:calc(-1 * var(--edge-fade));
    padding-inline:calc(var(--edge-fade) + 4px);
    scroll-padding-inline:calc(var(--edge-fade) + 4px);
    -webkit-mask-image:linear-gradient(to right,transparent,#000 var(--edge-fade),#000 calc(100% - var(--edge-fade)),transparent);
    mask-image:linear-gradient(to right,transparent,#000 var(--edge-fade),#000 calc(100% - var(--edge-fade)),transparent);
  }
}
.first-picks-grid > * {min-width:0;scroll-snap-align:start;}
.first-picks-grid .topic-card {aspect-ratio:auto;min-height:380px;}
.first-picks-grid .topic-card-image,.first-picks-grid .topic-card-art {min-height:240px;}
.first-picks-grid .topic-card-type {flex-wrap:wrap;}
.first-picks-grid .feed-card-footer {flex-wrap:wrap;}
.first-picks .setup-content-card {display:flex;flex-direction:column;min-height:380px;}
.first-picks .setup-content-art {position:relative;aspect-ratio:auto;height:240px;min-height:240px;}
.first-picks .setup-content-copy {min-height:140px;padding:20px;}
.first-picks .setup-content-copy h3 {margin:0;line-height:1.35;overflow-wrap:anywhere;}
.first-pick-placeholder {min-height:380px;border:1px solid var(--border);border-radius:20px;overflow:hidden;background:var(--surface);}
.first-pick-placeholder-art {height:240px;background:var(--surface-subtle);}
.first-pick-placeholder-copy {display:grid;gap:14px;padding:24px;}
.first-pick-placeholder-copy span {height:14px;border-radius:5px;background:var(--border);}
.first-pick-placeholder-copy span:last-child {width:60%;}
.first-pick-placeholder {position:relative;isolation:isolate;}
.first-pick-placeholder::after {content:"";position:absolute;inset:0;pointer-events:none;background:linear-gradient(100deg,transparent 25%,rgb(255 255 255 / .12) 50%,transparent 75%) 0 0 / 200% 100%;animation:shimmer 1.6s linear infinite;}
.first-picks > .setup-step-actions {margin-top:20px;}
@media(prefers-reduced-motion:reduce) {.first-pick-placeholder::after {animation:none;}}

/* Align the full language selector with the measured page content column. */
.header-actions { display: flex; flex: none; align-items: center; gap: 12px; margin-inline-start: auto; }
.header-language-trigger .learning-profile-flag { position: relative; }
.header-language-name { font-size: 1.05rem; font-weight: 650; }
.header-language-name, .header-language-trigger > .shell-icon {
  position: absolute; visibility: hidden; width: max-content; white-space: nowrap;
}
.app-header[data-home="true"] .header-language-menu { position: absolute; visibility: hidden; pointer-events: none; }
.app-header[data-language-room="true"] .header-language-menu {
  position: absolute; left: var(--header-language-left); top: calc(var(--header-language-top) - 20px);
}
.app-header[data-language-room="true"] .header-language-trigger {
  display: inline-flex; align-items: center; gap: 8px; width: max-content; min-width: 0;
  padding: 4px 8px; font-size: 1.05rem; font-weight: 650; color: var(--text); transform-origin: left center;
}
.app-header[data-language-room="true"] .header-language-trigger .learning-profile-flag { width: 28px; height: 28px; font-size: 1.35rem; }
.app-header[data-language-room="true"] .header-language-name,
.app-header[data-language-room="true"] .header-language-trigger > .shell-icon { position: static; visibility: inherit; }
.app-header[data-language-room="true"] .header-language-trigger > .shell-icon { color: var(--muted); flex: none; }
.app-header[data-language-room="true"] .header-language-menu > .profile-menu-popover {
  inset-inline-start: var(--header-language-left); inset-inline-end: auto;
}
.app-header[data-home="true"][data-language-docked="true"] .header-language-menu { visibility: visible; pointer-events: auto; }
.home-dashboard[data-language-in-header="true"] .home-language-controls {
  min-height: 0; padding: 0; gap: 0; background: none; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none;
}
.home-dashboard[data-language-in-header="true"] .home-language-controls > .home-language-menu {
  position: absolute; visibility: hidden; pointer-events: none;
}
.home-dashboard[data-language-in-header="true"] .home-language-controls > .home-target-level { display: none; }
@media(max-width:760px) { .header-actions { gap: 6px; } }
@media(max-width:380px) { .header-actions { gap: 3px; } }

/* Question prompts sit between the picture and response surfaces. */
.input-step > .input-question {width:min(100%,960px);padding:0 12px;font-size:clamp(1.25rem,2.2vw,1.6rem);font-weight:700;line-height:1.4;text-align:center;}
.input-question p {margin:0;min-width:0;overflow-wrap:anywhere;}
.input-question .speech-control {flex:none;}

/* Prepared vocabulary introductions precede sentence playback in casual previews. */
.preview-preparation {display:flex;align-items:center;flex-wrap:wrap;gap:8px;font-size:.9rem;line-height:1.45;color:var(--text)}
.preview-preparation small {opacity:.8;font-variant-numeric:tabular-nums}
.comic-keyword-preview {animation:preview-panel-in 280ms ease-out both}
.comic-keyword-preview.is-leaving {animation:preview-panel-out 280ms ease-in both;pointer-events:none}
.comic-keyword-content {position:relative;padding:24px 28px 28px;max-height:inherit;overflow-x:hidden;overflow-y:auto;overscroll-behavior:contain}
.comic-keyword-content h2 {margin:0 0 20px;font-size:1.05rem;font-weight:650;letter-spacing:.015em}
.comic-keyword-content hr {display:none}
.comic-keyword-grid {display:grid;grid-template-columns:repeat(var(--keyword-count),minmax(0,1fr));gap:24px;align-items:start}
.comic-keyword {display:grid;justify-items:center;align-content:start;gap:8px;min-width:0;text-align:center;animation:preview-word-in 360ms ease-out both}
.comic-keyword img {display:block;width:100%;height:clamp(100px,20vh,190px);object-fit:contain;user-select:none;-webkit-user-drag:none}
.comic-keyword strong {font-size:clamp(1.5rem,3vw,2.3rem);font-weight:700;line-height:1.2;overflow-wrap:anywhere}
.comic-keyword-phonetic {font-size:clamp(1rem,1.8vw,1.3rem);line-height:1.4;opacity:.85;overflow-wrap:anywhere}
.comic-keyword .speech-control {margin-top:4px}
.comic-preview-sentence {animation:preview-panel-in 320ms ease-out both}
@keyframes preview-panel-in {from {opacity:0;transform:translateY(18px) scale(.985)} to {opacity:1;transform:none}}
@keyframes preview-panel-out {to {opacity:0;transform:translateY(-18px) scale(.985)}}
@keyframes preview-word-in {from {opacity:0;transform:translateY(10px) scale(.94)} to {opacity:1;transform:none}}
@media(max-width:600px){.comic-keyword-content {padding:18px 14px 20px}.comic-keyword-grid {gap:10px}.comic-keyword-content h2 {margin-bottom:12px}.comic-keyword strong {font-size:clamp(1.2rem,5vw,1.65rem)}.comic-keyword img {height:clamp(82px,16vh,145px)}}
@media(prefers-reduced-motion:reduce){.comic-keyword-preview,.comic-keyword-preview.is-leaving,.comic-keyword,.comic-preview-sentence {animation:none}}
@media(max-height:500px){.comic-keyword-content {padding:12px 16px}.comic-keyword-content h2 {margin-bottom:8px}.comic-keyword-grid {gap:16px}.comic-keyword {gap:3px}.comic-keyword img {height:60px}.comic-keyword strong {font-size:1.3rem}.comic-keyword-phonetic {font-size:.9rem}.comic-keyword .speech-button {width:32px;height:32px}}

.section-heading.topic-learning-heading { margin-top: 28px; }

.assistant-user-message-copy { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.assistant-user-message-copy[data-expanded="true"] { display: block; overflow: visible; }
button.assistant-user-message-expand { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 2px 0; min-height: 30px; font-size: .8rem; color: var(--text-secondary); text-decoration: none; white-space: normal; }

.assistant-list-preview { flex-wrap: wrap; }
.assistant-list-preview > small { margin-inline-start: auto; font-size: .85rem; white-space: nowrap; }

.assistant-user-message-chevron { display: inline-flex; transition: transform .15s ease; }
.assistant-user-message-chevron[data-expanded="true"] { transform: rotate(180deg); }

.character-row-actions .character-progress-inline { margin: 0; padding: 0; border: 0; }

.preview-preparation.error { color: var(--coral-ink, #c44b42); }
.comic-welcome .preview-preparation.error { color: #ffc4b9; }

button.reader-sentence-speaker { display:inline-flex; vertical-align:middle; margin:0 .5em .2em 0; padding:0; width:44px; height:44px; min-height:44px; border:0; border-radius:50%; background:transparent; color:var(--text); }
@media (hover: hover) and (pointer: fine) { button.reader-sentence-speaker:hover:not(:disabled) { background:transparent; box-shadow:0 0 0 2px var(--border); } }
.reader-sentence-speaker img,.reader-speaker-initial {width:44px;height:44px;border-radius:50%;object-fit:cover;flex:none;}
.reader-speaker-initial {display:inline-grid;place-items:center;background:var(--accent-soft);color:var(--accent-ink);}
.reader-character-profile { width:min(300px,calc(100vw - 32px)); }
.reader-character-profile figure { margin:0; text-align:center; }
.reader-character-profile-portrait {display:block;width:100%;aspect-ratio:1;object-fit:cover;border-radius:16px;}
.reader-character-profile figcaption {display:grid;gap:4px;margin-top:12px;text-align:center;}
.reader-character-name-reading {color:var(--text-secondary);font-size:.9rem;}

/* Standalone Custom Content reader learning and practice controls. */
/* Preview only this document's passage, without changing its display preference. */
.reader-view:has(> .reader-flashcard-panel > .reader-learning-progress:focus-visible) > .reading-page > .progressive-reading { --reader-progress-fill: 45%; --reader-progress-line: 0%; }
@media (hover: hover) and (pointer: fine) {
    .reader-view:has(> .reader-flashcard-panel > .reader-learning-progress:hover) > .reading-page > .progressive-reading { --reader-progress-fill: 45%; --reader-progress-line: 0%; }
}
.reader-practice-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.reader-practice-panel > .reader-practice-launch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.reader-practice-panel > .reader-practice-launch > :is(button, .button-link) { width: 100%; justify-content: flex-start; text-align: start; }
.reader-view > .reader-practice-panel { margin-top: 22px; }
.reader-view > .reader-practice-panel > .reader-practice-launch > :first-child { grid-column: 1 / -1; }
@media (max-width: 600px) { .reader-practice-panel > .reader-practice-launch { grid-template-columns: 1fr; } }
.reader-flashcard-panel { display: grid; gap: 12px; margin: 14px 0 0; }
.reader-practice-panel, button.reader-learning-progress { padding: 14px 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
button.reader-learning-progress { display: block; width: 100%; color: var(--text); text-align: start; }
@media (hover: hover) and (pointer: fine) { button.reader-learning-progress:hover { background: var(--surface-hover); border-color: var(--border-strong); } }
.reader-practice-panel > p { margin: 10px 0 0; font-size: .86rem; }
.flashcard-progress-matrix { min-width: 0; margin-top: 18px; }
.flashcard-matrix-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.flashcard-progress-matrix p, .flashcard-matrix-pagination { font-size: .8rem; }
.flashcard-progress-matrix > p { margin-top: 12px; }
.flashcard-matrix-controls { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(130px, .65fr) minmax(160px, .8fr); gap: 8px; margin-bottom: 12px; }
.flashcard-matrix-controls input, .flashcard-matrix-controls select { min-width: 0; width: 100%; margin: 0; font-size: .8rem; }
@media (max-width: 700px) {
  .flashcard-matrix-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flashcard-matrix-search { grid-column: 1 / -1; }
}
.flashcard-matrix-scroll { max-width: 100%; max-height: min(65vh, 600px); overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.flashcard-matrix-table { width: 100%; min-width: 840px; border-collapse: separate; border-spacing: 0; font-size: .85rem; }
.flashcard-matrix-table .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.flashcard-matrix-table th, .flashcard-matrix-table td { padding: 12px; border-bottom: 1px solid var(--border); border-inline-end: 1px solid var(--border); }
.flashcard-matrix-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-subtle); font-size: .75rem; text-align: center; }
button.flashcard-matrix-sort { display: flex; justify-content: center; gap: 6px; width: 100%; padding: 2px 0; background: transparent; color: var(--text-secondary); font-size: inherit; }
.flashcard-matrix-table thead th:first-child .flashcard-matrix-sort { justify-content: flex-start; }
.flashcard-matrix-table th[aria-sort]:not([aria-sort="none"]) button { color: var(--text); }
@media (hover: hover) and (pointer: fine) { button.flashcard-matrix-sort:hover { color: var(--text); } }
.flashcard-matrix-table tr > :first-child { position: sticky; inset-inline-start: 0; z-index: 1; min-width: 180px; max-width: 260px; background: var(--surface); text-align: start; }
.flashcard-matrix-table thead th:first-child { z-index: 3; background: var(--surface-subtle); }
.flashcard-matrix-table tbody th { font-weight: 400; overflow-wrap: anywhere; }
.flashcard-matrix-meaning { display: block; color: var(--text-secondary); font-size: .75rem; margin-top: 4px; line-height: 1.4; }
.flashcard-matrix-table td { min-width: 100px; padding: 0; text-align: center; font-variant-numeric: tabular-nums; }
.flashcard-matrix-table td.flashcard-matrix-readonly { padding: 12px; }
button.flashcard-matrix-score { display: flex; flex-direction: column; justify-content: center; gap: 0; width: 100%; min-height: 70px; padding: 12px; border-radius: 0; background:hsl(var(--level-hue) 78% 48% / var(--retention-opacity,.15)); color:light-dark(var(--learning-ink-light,var(--text)),var(--learning-ink-dark,var(--text))); }
button.flashcard-matrix-score[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
@media (hover: hover) and (pointer: fine) { button.flashcard-matrix-score:hover:not(:disabled) { box-shadow: inset 0 0 0 2px var(--accent); } }
button.flashcard-matrix-score[aria-disabled="true"] { opacity: 1; cursor: progress; }
button.flashcard-matrix-score small { font-weight:400; color:inherit; }
button.flashcard-matrix-score[data-rated="false"] {background:var(--surface-subtle);color:var(--muted);}
.flashcard-matrix-table td strong { display: block; font-size: 1rem; }
.flashcard-matrix-table td small { display: block; margin-top: 4px; font-size: .7rem; }
.flashcard-matrix-table tr > :last-child { border-inline-end: 0; }
.flashcard-matrix-table tbody tr:last-child > * { border-bottom: 0; }
.flashcard-matrix-pagination { margin-top: 14px; justify-content: flex-start; }
.flashcard-matrix-pagination p { flex: 1; min-width: 160px; }
.flashcard-matrix-pagination button { padding: 8px 12px; font-size: .8rem; }
.flashcard-matrix-empty { padding: 18px 0; color: var(--text-secondary); }
/* The completed badge shared by guided reading and comprehensible input. */
.content-step-completed { display:inline-flex; align-items:center; align-self:flex-start; gap:8px; border:1px solid color-mix(in srgb,var(--step-color) 35%,var(--border)); border-radius:99px; padding:4px 10px 4px 5px; background:color-mix(in srgb,var(--step-color) 9%,transparent); color:var(--step-ink); font-size:.85rem; font-weight:550; }
.content-step-completed svg { border-radius:50%; background:var(--step-color); color:#14342a; padding:3px; box-sizing:content-box; }

/* Vocabulary pages keep only the viewport mounted; fixed row geometry makes
   scrollbar jumps independent of library size. Full text remains on the word page. */
.vocabulary-window { --vocabulary-row-height:112px; position: relative; }
.vocabulary-window-content { position: relative; }
.vocabulary-window .vocabulary-window-row { position: absolute; left: 0; right: 0; height: var(--vocabulary-row-height); box-sizing: border-box; border-bottom: 1px solid var(--border); border-top: 0; }
.vocabulary-window .vocabulary-compact-link > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vocabulary-window .vocabulary-word-type { display: block; overflow: hidden; text-overflow: ellipsis; }
.vocabulary-window .vocabulary-word-progress { flex: 0 0 auto; max-width: 80px; }
.vocabulary-window .vocabulary-word-progress > button.word-progress-chip { width: auto; max-width: 80px; overflow: hidden; text-overflow: ellipsis; font-size: .75rem; }
button.vocabulary-compact-link {padding:0;border:0;border-radius:6px;background:transparent;box-shadow:none;text-align:start;font:inherit;}
@media (hover: hover) and (pointer: fine) { button.vocabulary-compact-link:hover {background:var(--surface-hover);color:inherit;} }
.vocabulary-row-metrics {display:flex;align-items:center;gap:8px;flex:none;}
.vocabulary-row-metrics .word-importance-button {white-space:nowrap;}
@media(max-width:760px) {
 .vocabulary-window {--vocabulary-row-height:160px;}
 .vocabulary-window .vocabulary-window-row {display:grid;grid-template-columns:32px minmax(0,1fr);gap:2px 8px;padding:6px 0;align-content:center;}
 .vocabulary-window-row > .speech-control {grid-column:1;grid-row:1 / span 2;align-self:start;}
 .vocabulary-window-row > .speech-control .speech-button {width:32px;height:32px;min-width:32px;padding:6px;}
 .vocabulary-window-row > .vocabulary-compact-link {grid-column:2;grid-row:1;grid-template-columns:1fr;gap:0;font-size:.9rem;line-height:1.15;}
 .vocabulary-window-row > .vocabulary-row-metrics {grid-column:2;grid-row:2;gap:5px;min-width:0;}
 .vocabulary-row-metrics :is(.word-importance-button,.word-history-button,.word-list-button,.word-progress-chip) {height:30px;min-height:30px;min-width:30px;padding:4px 6px;}
 .vocabulary-row-metrics :is(.word-history-button,.word-list-button) {width:30px;}
}
.vocabulary-result-count { margin: 12px 0; }
.vocabulary-page-error { padding: 12px 0; }

/* The word caption reserves its space inside the illustration card before revealing. */
.input-teaching-card {width:min(100%,800px);flex:none;flex-direction:column;min-height:0;max-height:none;padding:var(--input-inset);gap:clamp(10px,2dvh,20px);}
.input-teaching-images {display:flex;gap:var(--input-space);}
.input-teaching-card .input-picture {border:0;padding:0;}
.input-teaching-card .input-picture > img {height:auto;max-height:min(42dvh,520px);}
.input-step[data-introduction]:not([data-reviewing="true"]) .input-stage[aria-busy="false"] .input-picture img { animation:input-image-arrive 360ms cubic-bezier(.2,.8,.25,1) both; }
.input-teaching-caption {padding-block:var(--input-space);animation:input-panel-arrive 300ms ease-out both;}
.input-teaching-meaning { margin:8px 0 0; color:var(--text-secondary); overflow-wrap:anywhere; }
@keyframes input-image-arrive { from { opacity:0; transform:translateY(10px) scale(.94); } 70% { opacity:1; transform:translateY(-2px) scale(1.015); } to { opacity:1; transform:none; } }
@keyframes input-panel-arrive { from { opacity:0; transform:translateY(min(12px,var(--input-space))); } to { opacity:1; transform:none; } }
@media(prefers-reduced-motion:reduce) {
 .input-step[data-introduction]:not([data-reviewing="true"]) .input-stage[aria-busy="false"] .input-picture img,.input-teaching-caption { animation:none; }
}

/* Retained visits keep their state in Rust, without hidden interactive controls. */
.input-step-cache:empty { display:none; }
.input-experience .input-screen-previous,.input-experience .input-screen-next { display:inline-flex; align-items:center; justify-content:center; gap:10px; min-height:46px; margin:0; box-shadow:var(--shadow-sm); }
.input-experience .input-screen-previous { background:color-mix(in srgb,var(--surface) 94%,transparent); border:1px solid var(--border); color:var(--text-secondary); }
.input-experience .input-screen-previous:disabled { opacity:.4; }
.input-step[data-reviewing="true"] :is(.input-picture img,.input-teaching-caption,.input-response) { animation:none; }

/* Picture hints stay beneath their word without intercepting word selection. */
.reader-preview-word-image { display: flex; align-items: center; justify-content: center; height: 1.8em; pointer-events: none; user-select: none; }
.reader-preview-word-image img { width: 1.8em; height: 1.8em; object-fit: contain; }

/* Keep the preview heading in its own compact scrim above the image panel. */
.comic-controls.comic-keyword-preview {display:flex;flex-direction:column;gap:10px;overflow:visible;background:transparent;border:0;box-shadow:none;backdrop-filter:none;-webkit-backdrop-filter:none}
.comic-keyword-heading {display:flex;align-items:center;gap:20px;max-width:100%;position:relative;align-self:flex-start;flex:none;margin:0;padding:10px 16px;font-size:.9rem;font-weight:650;line-height:1.3;letter-spacing:.015em;border:1px solid rgba(255,255,255,.18);border-radius:14px;background:rgba(12,13,17,.68);box-shadow:0 6px 20px #0003;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px)}
.comic-keyword-panel {position:relative;min-height:0;width:100%;padding:0;display:flex;flex-direction:column;align-items:stretch;border:1px solid rgba(255,255,255,.18);border-radius:22px;background:rgba(12,13,17,.68);box-shadow:0 12px 48px #0004;overflow:hidden;backdrop-filter:blur(8px) saturate(120%);-webkit-backdrop-filter:blur(8px) saturate(120%)}
@media(max-width:600px){.comic-keyword-heading {padding:8px 12px;font-size:.85rem}.comic-keyword-panel {border-radius:18px}}
.feed-generation-topics { display:grid; gap:10px; max-height:250px; overflow:auto; padding:6px; }
.feed-generation-form { display:grid; gap:16px; }
.feed-generation-form fieldset { margin:0; }
.feed-generation-topics label.checkbox-row { display:flex; align-items:center; gap:10px; margin:0; }
.feed-generation-topics input[type="checkbox"] { width:20px; height:20px; margin:0; flex:none; }

/* Supporting activities use compact illustrations and quiet individual accents.
   Their icon-sized art frames preserve the existing row height. */
.topic-activity-row[data-support-activity] { --support-color:#e3bd71; --support-ink:light-dark(#85611e,#e4c077); }
.topic-activity-row[data-support-activity="coach"] { --support-color:#e5a47b; --support-ink:light-dark(#945336,#e9ad86); }
.topic-activity-row[data-support-activity="podcast"] { --support-color:#b3a0df; --support-ink:light-dark(#705998,#c3b2ed); }
.topic-activity-row[data-support-activity="reading"] { --support-color:#94bdd9; --support-ink:light-dark(#396b87,#a1cce5); }
.topic-activity-row[data-support-activity="read-aloud"] { --support-color:#d3a0b9; --support-ink:light-dark(#964e73,#dfb1c8); }
.topic-activity-row[data-support-activity="translate"] { --support-color:#8fc9bc; --support-ink:light-dark(#306e66,#a0d8cb); }
.topic-activity-row[data-support-activity="roleplay"] { --support-color:#d9af95; --support-ink:light-dark(#916047,#e1baa3); }
.topic-activity-row:is([data-support-activity="pictures"],[data-support-activity="describe"]) { --support-color:#b4a0e8; --support-ink:light-dark(#6955a2,#c3b1ec); }
.topic-page [data-support-activity] .topic-activity { grid-template-columns:clamp(84px,10vw,128px) minmax(0,1fr) 34px; border-color:color-mix(in srgb,var(--support-color) 16%,var(--border)); background:linear-gradient(105deg,color-mix(in srgb,var(--support-color) 9%,transparent),transparent 42%),var(--surface); }
@supports ((backdrop-filter:blur(18px)) or (-webkit-backdrop-filter:blur(18px))) {
 .topic-page [data-support-activity] .topic-activity { background:linear-gradient(105deg,color-mix(in srgb,var(--support-color) 9%,transparent),transparent 42%),color-mix(in srgb,var(--surface) 94%,transparent); backdrop-filter:blur(18px); -webkit-backdrop-filter:blur(18px); }
}
.topic-page [data-support-activity] .topic-activity-icon { position:relative; width:100%; height:clamp(48px,6vw,72px); border-radius:0; background:none; overflow:visible; }
.topic-page [data-support-activity] .topic-activity-icon>img { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:calc(100% + 20px); height:calc(100% + 28px); max-width:none; object-fit:contain; pointer-events:none; }
.support-activity-action { display:grid; place-items:center; flex:none; width:34px; height:34px; border:1px solid color-mix(in srgb,var(--support-color) 35%,var(--border)); border-radius:50%; color:var(--support-ink); background:color-mix(in srgb,var(--support-color) 6%,transparent); }
.topic-page [data-support-activity] .topic-completion-track { background:color-mix(in srgb,var(--support-color) 7%,var(--border)); }
.topic-page [data-support-activity] .topic-completion-track>span { background:var(--support-color); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .topic-page [data-support-activity] .topic-activity:hover:not(:disabled) { border-color:color-mix(in srgb,var(--support-color) 55%,var(--border)); background-color:var(--surface-hover); box-shadow:var(--shadow); } }
.topic-page [data-support-activity] .topic-activity:disabled { border-color:var(--border); color:var(--text-secondary); }
@media(max-width:600px),(max-height:650px) {
 .topic-page [data-support-activity] .topic-activity { grid-template-columns:48px minmax(0,1fr); }
 .topic-page [data-support-activity] .topic-activity-icon { height:48px; }
 .support-activity-action { display:none; }
 .topic-page [data-support-activity] .topic-activity-icon>img { width:76px; height:66px; }
}
@media(prefers-reduced-transparency:reduce) {
 .topic-page [data-support-activity] .topic-activity { background-color:var(--surface); backdrop-filter:none; -webkit-backdrop-filter:none; }
}

/* Prefer touch wording whenever a touch-like pointing device is available,
   including touch laptops. The query also responds to input-device changes. */
.feed-generation-tap-hint { display:none; }
@media (any-pointer:coarse) {
 .feed-generation-click-hint { display:none; }
 .feed-generation-tap-hint { display:inline; }
}

/* Class notes: a quiet, readable board for shared lessons. */
.class-notes-library { max-width: 1000px; margin: 0 auto; }
.class-notes-create { display:flex; gap:12px; margin-top:28px; }
.class-notes-create input { flex:1; min-width:0; }
.class-notes-session-list { display:grid; gap:12px; margin-top:30px; }
.class-notes-session-card { display:flex; align-items:center; gap:18px; width:100%; padding:22px; text-align:start; color:var(--text); }
.class-notes-session-card > span { display:grid; gap:6px; flex:1; }
.class-notes-session-card strong { font-size:20px; }
.class-notes-session-card small { color:var(--muted); font-weight:400; }
.class-notes-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; color:var(--muted); padding:80px 24px; gap:12px; }
.class-notes-empty h2 { color:var(--text); font-size:26px; margin:8px 0 0; }
.class-notes-empty p { max-width:480px; margin:0; }
dialog.reader-popup.class-notes-fullscreen:focus { outline:none; }
dialog.reader-popup.class-notes-fullscreen { width:100vw; max-width:100vw; height:100dvh; max-height:100dvh; inset:0; margin:0; border:0; border-radius:0; padding:0; background:var(--bg); box-shadow:none; }
.class-notes-fullscreen > .reader-popup-heading { display:none; }
.class-notes-fullscreen > .reader-popup-body { height:100%; max-height:none; overflow:hidden; padding:0; }
.class-notes-board { display:flex; flex-direction:column; height:100%; padding:0 32px; color:var(--text); }
.class-notes-toolbar { display:flex; justify-content:space-between; align-items:center; gap:20px; padding:24px 0 20px; border-bottom:1px solid var(--border); }
.class-notes-heading { min-width:0; }
.class-notes-heading .eyebrow { font-size:11px; letter-spacing:.16em; color:var(--muted); }
.class-notes-heading > div { display:flex; align-items:center; gap:10px; }
.class-notes-heading h1 { font-size:25px; line-height:1.35; margin:5px 0 0; overflow-wrap:anywhere; }
.class-notes-title-button { padding:0; border:0; background:none; color:inherit; font:inherit; text-align:start; cursor:pointer; overflow-wrap:anywhere; }
.class-notes-title-button:is(:active) { background:var(--surface-subtle); color:var(--text); }
@media (hover: hover) and (pointer: fine) { .class-notes-title-button:is(:hover,:active) { background:var(--surface-subtle); color:var(--text); } }
@media (hover: hover) and (pointer: fine) { .class-notes-title-button:hover { text-decoration:underline; text-decoration-thickness:1px; text-underline-offset:4px; } }
.class-notes-tools { display:flex; flex:none; gap:12px; align-items:center; }
.class-notes-tools .icon-button { width:44px; min-width:44px; height:44px; padding:6px; }
.class-notes-close { margin-left:0; }
.class-notes-selection-toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:8px 14px; padding:12px 0; border-bottom:1px solid var(--border); flex-shrink:0; }
.class-notes-selection-toolbar > strong { white-space:nowrap; }
.class-notes-selection-toolbar > .muted { font-size:13px; white-space:nowrap; }
.class-notes-selection-actions { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:8px; margin-inline-start:auto; }
.class-notes-selection-actions button:not(.icon-button) { min-height:36px; padding:7px 11px; font-size:13px; }
.class-notes-selection-delete { color:var(--danger); }
.class-notes-column-headings { display:grid; gap:22px; padding:20px 6px 6px; font-size:10px; letter-spacing:.12em; color:var(--muted); overflow:hidden; flex-shrink:0; }
/* Always own vertical gestures, even for short lists. Contain prevents scroll
   chaining while preserving native rubber banding (unlike overscroll: none). */
.class-notes-rows { flex:1; overflow-x:hidden; overflow-y:scroll; min-width:0; min-height:0; padding:6px 0 12px; overscroll-behavior-y:contain; touch-action:pan-y pinch-zoom; }
.class-note-row { display:grid; align-items:center; column-gap:22px; padding:10px 6px; border-bottom:1px solid var(--border); min-width:650px; }
.class-note-row[data-pending="true"] { background:color-mix(in srgb,var(--accent) 3%,transparent); }
.class-note-target,.class-note-translation { min-width:0; overflow-wrap:anywhere; }
.class-note-text { font-size:var(--note-target-size); line-height:1.35; font-weight:550; }
.class-note-text .reader-word,.class-note-text .inline-reader { font-size:inherit; }
.class-note-text .reader-word-reading { font-size:var(--note-reading-size); }
.class-note-translation { font-size:var(--note-translation-size); line-height:1.35; }
.class-note-base { display:block; color:var(--muted); font-size:16px; margin-top:2px; }

.class-note-listen .speech-button { width:44px; height:44px; }
.class-note-image { width:var(--note-image-size); display:grid; align-items:center; }
.class-note-image .word-illustration { width:100%; max-width:100%; margin:0; padding:0; border:0; background:transparent; }
.class-note-image .word-illustration-placeholder { min-height:var(--note-image-size); padding:8px; font-size:11px; }
.class-note-image img { width:var(--note-image-size); height:var(--note-image-size); object-fit:contain; }
.class-note-image .image-controls { opacity:0; }
.class-note-image:focus-within .word-image-controls { opacity:1; }
@media (hover: hover) and (pointer: fine) { .class-note-image:hover .word-image-controls { opacity:1; } }
.class-note-spinner { display:block; width:22px; height:22px; border:2px solid var(--border); border-top-color:var(--accent); border-radius:50%; animation:class-note-spin 1s linear infinite; }
@keyframes class-note-spin { to { transform:rotate(360deg); } }
.class-notes-menu { position:relative; }
.class-notes-menu summary { list-style:none; cursor:pointer; }
.class-notes-menu summary::-webkit-details-marker { display:none; }
.class-notes-menu-items { position:absolute; right:0; top:calc(100% + 6px); min-width:220px; padding:6px; border:1px solid var(--border); border-radius:12px; background:var(--surface); box-shadow:0 12px 36px #0002; z-index:20; }
.class-notes-menu-items :is(button,a.class-notes-export-download) { display:flex; align-items:center; justify-content:flex-start; gap:10px; width:100%; padding:12px; border:0; border-radius:8px; background:transparent; color:var(--text); font:inherit; font-weight:650; line-height:1.4; text-align:start; text-decoration:none; }
@media (hover: hover) and (pointer: fine) { .class-notes-menu-items :is(button,a.class-notes-export-download):hover { background:var(--surface-subtle); } }
.class-notes-menu-divider { border:0; border-top:1px solid var(--border); margin:6px 0; }
.class-notes-sortable { position:relative; padding-inline-start:28px; }
.class-notes-sortable.is-selected > .class-note-row { background:color-mix(in srgb,var(--accent) 10%,transparent); }
.class-notes-sortable.is-selected > .class-note-section { outline:2px solid var(--accent); outline-offset:-2px; }
.class-note-select { position:absolute; inset-inline-start:0; top:50%; transform:translateY(-50%); width:22px; height:22px; margin:0; accent-color:var(--accent); cursor:pointer; }
.class-note-move { position:absolute; inset-inline-start:0; top:50%; transform:translateY(-50%); width:24px; padding:6px 0; background:transparent; color:var(--muted); border:0; font-size:22px; line-height:1; cursor:grab; touch-action:none; user-select:none; }
.class-note-move:active { cursor:grabbing; transform:translateY(-50%); }
.class-notes-sortable.is-dragging { opacity:.45; }
.class-notes-sortable.drop-before::before,.class-notes-sortable.drop-after::after { content:""; position:absolute; inset-inline:0; height:3px; border-radius:2px; background:var(--accent); pointer-events:none; z-index:5; }
.class-notes-sortable.drop-before::before { top:0; }
.class-notes-sortable.drop-after::after { bottom:0; }
.class-notes-order-status { margin:0; font-size:12px; color:var(--muted); }
.class-note-section { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; margin:8px 0 4px; padding:14px 18px; border-inline-start:4px solid var(--accent); border-radius:8px; background:var(--surface-subtle); }
.class-note-section-titles { min-width:0; overflow-wrap:anywhere; }
.class-note-section .eyebrow { font-size:11px; letter-spacing:.14em; color:var(--muted); }
.class-note-section h2 { font-size:var(--note-target-size); margin:4px 0; line-height:1.3; }
.class-note-section p { font-size:var(--note-translation-size); color:var(--muted); margin:0; line-height:1.35; }
.class-note-section-editor { display:grid; gap:18px; }
.class-note-section-actions { display:flex; justify-content:flex-end; }
.class-note-section-editor label { display:grid; gap:8px; }
.class-note-section-editor .class-note-translate-option { display:inline-flex; align-items:center; justify-self:start; gap:10px; min-height:32px; cursor:pointer; }
dialog.reader-popup#class-note-section-editor:focus { outline:none; }
dialog.reader-popup#class-note-section-editor { -webkit-user-select:none; user-select:none; }
dialog.reader-popup#class-note-section-editor input { -webkit-user-select:text; user-select:text; }
.class-notes-column-headings { margin-inline-start:28px; }
.class-notes-sharing { display:grid; gap:18px; }
.class-notes-sharing p { margin:0; }
.class-notes-sharing label { display:grid; gap:8px; }
.class-notes-sharing input { width:100%; min-width:0; }
.class-notes-share-actions { display:flex; align-items:center; flex-wrap:wrap; gap:18px; }
.class-notes-share-actions .copy-text-button { display:inline-flex; align-items:center; gap:8px; }
.class-notes-rename-form { display:grid; gap:20px; }
.class-notes-rename-form label { display:grid; gap:8px; }
.class-notes-add-words-form { display:grid; gap:16px; }
.class-notes-add-words-form p { margin:0; }
.class-notes-add-words-form label { display:grid; gap:8px; }
.class-notes-add-words-form :is(input,select) { width:100%; min-width:0; }
.class-notes-composer { display:grid; grid-template-columns:1fr auto; gap:16px; padding:10px 0 max(10px,env(safe-area-inset-bottom)); background:var(--bg); }
.class-notes-composer input { font-size:24px; min-height:66px; min-width:0; padding:16px 20px; border-radius:14px; }
.class-notes-composer button { border-radius:14px; padding:16px 24px; font-size:17px; display:flex; align-items:center; gap:8px; }
.class-notes-settings,.class-note-editor { display:grid; gap:18px; }
.class-notes-settings label,.class-note-editor label { display:grid; gap:8px; }
.class-notes-setting-toggles { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.class-notes-setting-toggle { display:flex; justify-content:flex-start; gap:9px; width:100%; min-height:46px; padding:10px 14px; text-align:start; border:1px solid var(--border-strong); border-radius:10px; background:transparent; color:var(--text); font-weight:600; }
@media (hover: hover) and (pointer: fine) { .class-notes-setting-toggle:hover { background:var(--surface-subtle); } }
.class-notes-setting-toggle[data-selected="true"] { border-color:var(--accent); background:var(--accent); color:var(--accent-text); }
@media (hover: hover) and (pointer: fine) { .class-notes-setting-toggle[data-selected="true"]:hover { background:var(--accent-hover); } }
.class-notes-setting-toggle svg { flex:none; }
.class-notes-setting-slider { display:grid; gap:8px; }
.class-notes-setting-slider-label { display:flex; justify-content:space-between; gap:16px; font-weight:600; }
.class-notes-setting-slider-label output { color:var(--muted); font-variant-numeric:tabular-nums; white-space:nowrap; }
.class-notes-setting-slider input[type="range"] { width:100%; margin:0; }
@media(max-width:600px) { .class-notes-setting-toggles { grid-template-columns:1fr; } }
.class-note-edit-field { display:grid; gap:8px; }
.class-note-edit-field > button { justify-self:end; }
.class-note-editor textarea { width:100%; }
.class-notes-import { display:grid; gap:18px; }
.class-notes-import-items { max-height:45vh; overflow:auto; border-block:1px solid var(--border); }
.class-notes-import-item { display:flex; align-items:center; gap:16px; padding:16px 4px; border-bottom:1px solid var(--border); }
.class-notes-import-item input { width:20px; height:20px; flex:none; }
.class-notes-import-item span { display:grid; gap:5px; min-width:0; overflow-wrap:anywhere; }
.class-notes-import-item strong { font-size:20px; }
.class-notes-import-item small { color:var(--muted); }
.class-note-pattern-link { background:none; border:0; padding:0; color:var(--text); text-align:start; font-size:var(--note-target-size); }
.class-note-kind { display:block; font-size:11px; letter-spacing:.14em; color:var(--muted); margin-bottom:3px; }
.class-note-pattern-preview { display:flex; flex-wrap:wrap; gap:6px; margin-top:6px; }
.class-note-pattern-preview span { border-bottom:2px solid currentColor; font-size:16px; padding:2px 4px; }
@media(max-width:760px) { .class-notes-board { padding:0 16px; } .class-notes-toolbar { padding-top:16px; gap:8px; } .class-notes-heading h1 { font-size:20px; } .class-notes-tools { gap:8px; } .class-notes-close { margin-left:0; } .class-notes-composer input { font-size:20px; } .class-notes-composer button { font-size:0; padding:12px; } .class-note-row { gap:16px; } }
@media(prefers-reduced-motion:reduce) { .class-note-spinner { animation:none; } }

.class-note-word-help { display:inline; background:none; border:0; padding:0; color:inherit; font:inherit; line-height:inherit; text-align:inherit; }
.class-note-word-help:is(:focus-visible), .class-note-pattern-link:is(:focus-visible) { background:transparent; color:inherit; text-decoration:underline; text-decoration-thickness:1px; text-underline-offset:6px; }
@media (hover: hover) and (pointer: fine) { .class-note-word-help:is(:hover,:focus-visible), .class-note-pattern-link:is(:hover,:focus-visible) { background:transparent; color:inherit; text-decoration:underline; text-decoration-thickness:1px; text-underline-offset:6px; } }

.class-note-image .story-image-ai,.class-note-image .story-image-toolbar { opacity:0; }
.class-note-image:focus-within .story-image-ai,.class-note-image:focus-within .story-image-toolbar { opacity:1; }
@media (hover: hover) and (pointer: fine) { .class-note-image:hover .story-image-ai,.class-note-image:hover .story-image-toolbar { opacity:1; } }
.reported-word-image {position:relative;display:block;max-width:100%;}
.word-image-delivery-status {display:grid;place-items:center;width:100%;min-height:28px;aspect-ratio:1;color:var(--muted);}
.reported-word-image > img {display:block;width:100%;height:auto;object-fit:contain;}
.reported-word-image .word-image-report {position:absolute;right:0;bottom:0;display:grid;place-items:center;width:28px;height:28px;min-width:0;min-height:0;padding:7px;border:0;border-radius:6px;background:transparent;color:#fff;box-shadow:none;cursor:pointer;opacity:.66;}
@media (hover: hover) and (pointer: fine) {
  .reported-word-image .word-image-report {opacity:0;}
  .reported-word-image:hover .word-image-report,.reported-word-image:focus-within .word-image-report {opacity:1;}
}
.reported-word-image .word-image-report:active {opacity:1;}
.reported-word-image .word-image-report svg {filter:drop-shadow(0 1px 2px rgb(0 0 0 / .65));}
@media (hover: hover) and (pointer: fine) { .reported-word-image .word-image-report:hover {background:rgb(0 0 0 / .3);} }
.reported-word-image.word-image-hidden {display:grid;place-items:center;aspect-ratio:1;width:100%;}
.word-image-unhide {display:grid;place-items:center;padding:8px;background:transparent;color:var(--muted);border:0;box-shadow:none;cursor:pointer;}
@media (hover: hover) and (pointer: fine) { .word-image-unhide:hover {background:var(--surface-subtle);color:var(--text);} }
.word-image-confirmation {display:contents;}
.word-image-confirmation-actions {display:flex;justify-content:flex-end;gap:12px;margin-top:24px;}
.word-illustration > .reported-word-image > img {aspect-ratio:1;}
.comic-keyword > .reported-word-image {width:100%;min-height:0;}

/* Keep preview illustrations bounded after the shared reportable-image wrapper.
   Miniatures follow the text size; introduction cards follow the viewport. */
.reader-preview-word-image > .reported-word-image.miniature,
.reader-preview-word-image > .reported-word-image.miniature > img {
  width:1.8em;height:1.8em;min-width:0;max-width:1.8em;max-height:1.8em;aspect-ratio:1;
}
.comic-controls.comic-keyword-preview {
  --keyword-image-size:clamp(64px,min(19vw,24dvh),220px);
  --keyword-label-size:clamp(1.1rem,min(2.6vw,4.5dvh),2.3rem);
  --keyword-reading-size:clamp(.8rem,min(1.5vw,2.8dvh),1.2rem);
}
.comic-keyword-preview .comic-keyword-content {padding:clamp(12px,2dvh,24px) clamp(12px,2vw,28px);}
.comic-keyword-preview .comic-keyword-grid {gap:clamp(8px,2vw,24px);}
.comic-keyword-preview .comic-keyword {gap:clamp(4px,1dvh,8px);}
.comic-keyword-preview .comic-keyword > .reported-word-image {
  width:100%;height:var(--keyword-image-size);max-height:var(--keyword-image-size);aspect-ratio:auto;
}
.comic-keyword-preview .comic-keyword > .reported-word-image > img {
  width:100%;height:100%;max-height:100%;object-fit:contain;
}
.comic-keyword-preview .comic-keyword strong {font-size:var(--keyword-label-size);}
.comic-keyword-preview .comic-keyword-phonetic {font-size:var(--keyword-reading-size);}
.comic-keyword-preview .comic-keyword .speech-button {
  width:clamp(32px,5dvh,44px);height:clamp(32px,5dvh,44px);min-height:0;min-width:0;
}

.comic-navigation .comic-preview-playback {flex:none;width:44px;min-width:44px;height:44px;padding:10px;}

/* A story visit waits only for its own decoded artwork and prepared audio. */
.comic-step-loading {position:absolute;inset:50% auto auto 50%;transform:translate(-50%,-50%);z-index:6;display:flex;flex-direction:column;align-items:center;gap:16px;width:max-content;max-width:calc(100% - 48px);padding:24px 28px;border-radius:20px;background:rgba(16,17,20,.88);color:#fff;text-align:center;pointer-events:auto}
.comic-step-loading p {margin:0}
.comic-step-download-progress { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: .85rem; }
.comic-step-download-progress progress { flex: 1; min-width: 0; height: 6px; accent-color: currentColor; }
.comic-step-download-progress span { white-space: nowrap; font-variant-numeric: tabular-nums; }
.comic-step-spinner {width:36px;height:36px;border:3px solid rgba(255,255,255,.24);border-top-color:var(--marigold);border-radius:50%;animation:comic-step-spin .8s linear infinite}
@keyframes comic-step-spin {to {transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce) {.comic-step-spinner {animation-duration:2s}}
.comic-step-loading-back {position:absolute;bottom:max(24px,var(--safe-area-bottom,0px));left:50%;transform:translateX(-50%);z-index:6}

/* Character recognition shares the pronunciation composer with word cards. */
.character-familiarity-badge {font-weight:600;font-variant-numeric:tabular-nums;}
.study-scene:has(.character-recognition-dock) { grid-template-rows: minmax(90px, 1fr) auto; }
.character-recognition-dock { max-height: calc(var(--study-height) * .72); overflow: auto; padding: 16px 20px; gap: 10px; }
.character-recognition-dock > label { display: grid; gap: 6px; }
.character-recognition-dock > .switch-row { display: flex; align-items: center; gap: 10px; }
.character-recognition-dock .switch-row input { flex: 0 0 40px; }
/* All library practice uses the same bounded study stage as vocabulary. */
.study-scene:has(.phrase-answer-dock) { grid-template-rows: minmax(100px, 1fr) auto; }
.phrase-answer-dock { max-height: calc(var(--study-height) * .6); overflow: auto; padding: 18px 20px; }
.phrase-answer-dock textarea { min-height: 88px; resize: vertical; }
.phrase-answer-dock .switch-row { margin: 0; padding: 4px 0; }
.structure-practice .flashcard-familiarity { margin-top: 24px; }
.phrase-session .study-welcome .phrase-sentence { font-size: clamp(1.5rem, 4vw, 2rem); line-height: 1.55; color: var(--text); }

/* Compact notes: one shared relative scale, stacked until laptop widths. */
.class-notes-toolbar { padding:14px 0 12px; }
.class-notes-rows { padding-top:0; }
.class-note-row { min-width:0; grid-template-columns:var(--note-image-size) minmax(0,1fr) 32px; gap:2px 10px; padding:8px 0; align-items:start; }
.class-note-row[data-images="false"] { grid-template-columns:minmax(0,1fr) 32px; }
.class-note-image { grid-column:1; grid-row:1; align-self:center; }
.class-note-content { grid-column:2; grid-row:1; min-width:0; align-self:center; }
.class-note-row[data-images="false"] .class-note-content { grid-column:1; }
.class-note-target { grid-column:2; grid-row:1; display:flex; align-items:flex-start; gap:6px; }
.class-note-target-copy { min-width:0; flex:1; }
.class-note-listen { flex:none; }
.class-note-listen .speech-button { width:32px; height:32px; min-height:32px; padding:6px; }
.class-note-text { line-height:1.2; }
.class-note-text .reader-word { margin:0; padding-block:0; row-gap:1px; line-height:1.2; }
.class-note-text .reader-word-reading { line-height:1.2; margin:0; padding:0; }
.class-note-translation { grid-column:2; grid-row:2; margin-top:2px; padding-inline-start:38px; line-height:1.2; }
.class-note-actions { grid-column:3; grid-row:1; }
.class-note-actions > .icon-button { width:32px; min-width:32px; height:32px; padding:4px; }
.class-note-row[data-images="false"] :is(.class-note-target,.class-note-translation) { grid-column:1; }
.class-note-row[data-images="false"] .class-note-actions { grid-column:2; }
.class-note-section { padding:12px; margin-top:12px; }
.class-notes-composer { gap:8px; }
.class-notes-composer input { font-size:16px; min-height:46px; padding:10px 12px; }
.class-notes-composer button { padding:10px 14px; }
.class-notes-size-range { display:flex; justify-content:space-between; color:var(--muted); font-size:12px; font-weight:400; }
@media(min-width:1100px) {
 .class-note-content { display:contents; }
 .class-note-row { grid-template-columns:var(--note-image-size) minmax(0,1.3fr) minmax(0,1fr) 32px; column-gap:18px; align-items:center; }
 .class-note-translation { grid-column:3; grid-row:1; padding:0; }
 .class-note-actions { grid-column:4; }
 .class-note-image,.class-note-actions { grid-row:1; }
 .class-note-row[data-images="false"] { grid-template-columns:minmax(0,1.3fr) minmax(0,1fr) 32px; }
 .class-note-row[data-images="false"] .class-note-translation { grid-column:2; }
 .class-note-row[data-images="false"] .class-note-actions { grid-column:3; }
 .class-note-row:not(:has(.class-note-translation)) { grid-template-columns:var(--note-image-size) minmax(0,1fr) 32px; }
 .class-note-row:not(:has(.class-note-translation)) .class-note-actions { grid-column:3; }
 .class-note-row[data-images="false"]:not(:has(.class-note-translation)) { grid-template-columns:minmax(0,1fr) 32px; }
 .class-note-row[data-images="false"]:not(:has(.class-note-translation)) .class-note-actions { grid-column:2; }
}
@media(max-width:600px) {
 .class-notes-board { padding:0 12px; }
 .class-notes-heading > div { gap:2px; }
 .class-notes-tools { gap:8px; }
 .class-notes-sortable { padding-inline-start:22px; }
}

.class-note-reading { font-size:var(--note-reading-size); color:var(--muted); line-height:1.2; margin:2px 0 0; }

.class-notes-import-lists { display:grid; gap:8px; }
.class-notes-import-list { display:flex; align-items:center; gap:12px; width:100%; padding:12px; border:1px solid var(--border); border-radius:12px; background:var(--surface); color:var(--text); text-align:start; }
@media (hover: hover) and (pointer: fine) { .class-notes-import-list:hover:not(:disabled) { background:var(--surface-hover); } }
.class-notes-import-list > span:nth-child(2) { display:grid; gap:4px; flex:1; min-width:0; }
.class-notes-import-list strong { overflow-wrap:anywhere; }
.class-notes-import-list small { font-weight:400; color:var(--muted); }
.class-notes-import-list > svg { flex:none; }
.class-notes-import-heading { display:flex; align-items:center; gap:12px; }
.class-notes-import-heading button { display:inline-flex; align-items:center; gap:5px; }

/* Notes are routed pages; loading belongs to the same board as loaded content. */
/* The notes board shares the normal app header/sidebar and owns its list scrolling. */
.app-shell:has(.class-notes-page) {height:calc(100dvh - var(--offline-banner-height,0px));min-height:0;grid-template-rows:minmax(0,1fr);overflow:hidden;}
.workspace:has(.class-notes-page) {width:100%;max-width:none;min-height:0;overflow:hidden;padding:0 max(20px,env(safe-area-inset-right)) 20px max(20px,env(safe-area-inset-left));}
/* StateScope adds a wrapper between the workspace and the routed note. */
.workspace > div:has(> .class-notes-page) {height:100%;min-height:0;}
.class-notes-page {display:flex;flex-direction:column;min-width:0;height:100%;min-height:0;color:var(--text);}
.class-notes-page .class-notes-navigation {min-height:49px; gap:8px; flex:none; flex-wrap:nowrap; padding:2px 0; margin-bottom:8px;}
:is(.class-notes-navigation,.assistant-heading) > .page-history-back {display:grid;place-items:center;flex:none;width:44px;min-width:44px;height:44px;margin:0;padding:0;}
:is(.class-notes-navigation,.assistant-heading) > .page-history-back > span {display:none;}
.class-notes-navigation .class-notes-heading {flex:1 1 0;}
.class-notes-navigation .screen-supertitle {margin-bottom:1px;font-size:.7rem;}
.class-notes-navigation h1 {margin:0;font-size:1.05rem;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.class-notes-navigation .class-notes-title-button {display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.class-notes-navigation .class-notes-tools {flex-wrap:nowrap;}
@media(max-width:600px) {
 .class-notes-navigation .class-notes-tools {gap:2px;}
 .class-notes-navigation .class-notes-tools .icon-button {width:34px;min-width:34px;height:34px;}
}
.class-notes-page > .class-notes-board {flex:1;min-height:0;height:auto;padding:0;}
.notes-loading { display:grid; gap:1px; overflow:hidden; }
.notes-loading-row { height:76px; border-bottom:1px solid var(--border); background:linear-gradient(90deg,var(--surface-subtle) 52px,transparent 52px) no-repeat 0 12px / 52px 52px; opacity:.55; }
.class-notes-session-list { gap:8px; margin-top:20px; }
.class-notes-session-list > .class-notes-session-card { margin:0; padding:16px; gap:12px; background:var(--surface); color:var(--text); -webkit-user-select:none; user-select:none; }

.class-notes-session-list > .class-notes-session-card:active:not(:disabled) { background:var(--surface-hover); color:var(--text); }
@media (hover: hover) and (pointer: fine) { .class-notes-session-list > .class-notes-session-card:hover:not(:disabled) { background:var(--surface-hover); color:var(--text); } }
@media(max-width:600px) { .class-notes-create { gap:8px; } .class-notes-create button { padding-inline:12px; white-space:nowrap; } .class-notes-create input { width:0; } }

.class-notes-menu-items button.class-notes-delete-note { color:var(--danger); }

.class-note-image-placeholder { display:block; width:var(--note-image-size); height:var(--note-image-size); }

.class-note-image:has(.word-illustration) { min-height:var(--note-image-size); }

.content-preparation-summary { margin:12px 0; }
.content-preparation-summary > button { display:inline-flex; align-items:center; gap:8px; }
.content-preparation-assets { list-style:none; margin:12px 0; padding:0; }
.content-preparation-assets li { display:grid; gap:4px; padding:10px 0; border-bottom:1px solid var(--border); }
.content-preparation-assets li > span { color:var(--muted); }

/* Keep the recommended activity prominent; other steps remain fully actionable. */
/* Without an action pill, give the text the remaining desktop width. */
@media (max-width:760px) {
 .topic-page [data-primary-step] .topic-activity,
}

/* Opening must remain escapable before any reader toolbar or artwork is ready. */
.comic-stage > button.reader-opening-close {
 position:fixed; z-index:10; top:max(16px,env(safe-area-inset-top)); right:max(16px,env(safe-area-inset-right));
 display:grid; place-items:center; width:48px; height:48px; min-height:48px; padding:0;
 border:1px solid rgba(255,255,255,.4); border-radius:50%; background:rgba(12,13,17,.85); color:#fff;
 pointer-events:auto; box-shadow:0 4px 16px #0005;
}
@media (hover: hover) and (pointer: fine) { .comic-stage > button.reader-opening-close:hover:not(:disabled) { background:#202226; color:#fff; } }

.reader-preparation-steps li[data-state="running"] .reader-preparation-circle[data-determinate="true"]::after {
 inset:-1.5px; border:0; animation:none;
 background:conic-gradient(var(--accent) var(--step-progress),var(--border-strong) 0);
 -webkit-mask:radial-gradient(farthest-side,transparent calc(100% - 2px),#000 0);
 mask:radial-gradient(farthest-side,transparent calc(100% - 2px),#000 0);
}

.topic-vocabulary-progress { padding:0; }
.topic-familiarity-title {display:flex;align-items:baseline;flex-wrap:wrap;gap:4px 10px;min-width:0;}
.topic-familiarity-count {font-size:.78rem;font-weight:400;color:var(--text-muted);white-space:nowrap;}
.topic-character-study {margin-top:24px;}

.topic-vocabulary-open { display:grid; gap:10px; width:100%; padding:14px 16px; text-decoration:none; border:0; border-radius:inherit; background:transparent; color:var(--text); text-align:start; }
@media (hover: hover) and (pointer: fine) { .topic-vocabulary-open:hover:not(:disabled) { background:var(--surface-subtle); color:var(--text); } }
.topic-vocabulary-label { font-size:.9rem; font-weight:600; color:var(--text-secondary); }
.topic-familiarity-chart {position:relative;border-radius:inherit;}
.topic-familiarity-chart[data-checkpoints="true"] button.topic-vocabulary-open {padding-bottom:34px;}
.topic-familiarity-chart[data-staggered="true"] button.topic-vocabulary-open {padding-bottom:54px;}
.topic-familiarity-track {display:block;min-width:0;margin-top:6px;position:relative;direction:ltr;}
.topic-familiarity-initial,.topic-familiarity-current,.topic-familiarity-checkpoint-bar {position:absolute;height:20px;top:-4px;translate:-50% 0;border-radius:999px;pointer-events:none;}
.topic-familiarity-initial {width:4px;background:rgb(255 255 255 / .3);}
.topic-familiarity-current {height:calc(100% + 8px);width:4px;background:white;box-shadow:0 0 0 1px #24212c66;z-index:3;}
.topic-familiarity-checkpoints {position:absolute;inset-inline:16px;bottom:34px;height:12px;direction:ltr;pointer-events:none;}
.topic-familiarity-chart[data-staggered="true"] .topic-familiarity-checkpoints {bottom:54px;}
.topic-familiarity-checkpoint {position:absolute;top:0;pointer-events:auto;z-index:2;}
.topic-familiarity-checkpoint:is(:focus-within,[data-open="true"]) {z-index:4;}
@media (hover: hover) and (pointer: fine) { .topic-familiarity-checkpoint:is(:hover,:focus-within,[data-open="true"]) {z-index:4;} }
.topic-familiarity-checkpoint-bar {width:8px;background:var(--xp);box-shadow:0 0 0 1px var(--surface);}
button.topic-familiarity-checkpoint-button {position:absolute;left:0;top:-4px;translate:-50% 0;width:10px;min-height:20px;height:20px;padding:0;border:0;border-radius:4px;background:transparent;color:var(--xp);}
.topic-familiarity-checkpoint-label {position:absolute;top:21px;left:50%;translate:-50% 0;padding:3px;white-space:nowrap;font-size:.7rem;font-weight:750;line-height:1;}
.topic-familiarity-checkpoint[data-lower="true"] .topic-familiarity-checkpoint-label {top:41px;}
@media (hover: hover) and (pointer: fine) { button.topic-familiarity-checkpoint-button:hover {background:transparent;color:var(--xp);} }
.topic-familiarity-checkpoint-popover {display:none;position:absolute;right:-10px;top:38px;width:max-content;max-width:min(230px,70vw);padding:8px 12px;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--text);box-shadow:var(--shadow-sm);font-size:.78rem;pointer-events:none;}
.topic-familiarity-checkpoint[data-lower="true"] .topic-familiarity-checkpoint-popover {top:58px;}
.topic-familiarity-checkpoint:is(:focus-within,[data-open="true"]) .topic-familiarity-checkpoint-popover {display:block;}
@media (hover: hover) and (pointer: fine) { .topic-familiarity-checkpoint:is(:hover,:focus-within,[data-open="true"]) .topic-familiarity-checkpoint-popover {display:block;} }
.topic-familiarity-chart[data-claimable="true"] {box-shadow:inset 0 0 0 2px var(--xp);}
.topic-familiarity-claim {margin-inline-start:auto;animation:topic-familiarity-pulse 1.6s ease-in-out infinite;}
.topic-familiarity-error {margin:0 24px 14px;}
@keyframes topic-familiarity-pulse {50% {transform:scale(1.06);box-shadow:0 0 0 4px var(--xp-soft);}}
@media(prefers-reduced-motion:reduce) {.topic-familiarity-claim {animation:none;}}
.vocabulary-familiarity-popup { height:min(760px,calc(100dvh - 32px)); }
.vocabulary-familiarity-popup > .reader-popup-body { padding:0; }

/* Preview keeps the same display menu and navigation during words and sentences. */
.comic-footer[data-preview="true"] .comic-inline-actions { display:none; }
.comic-footer[data-preview="true"] .comic-audio-control { width:44px; min-height:44px; }
@media(max-width:640px), (max-height:600px) {
 .comic-footer[data-preview="true"] .comic-audio-control { width:36px; min-height:36px; }
}

/* Never expose native broken-image placeholders while cover artwork loads. */
.topic-card-art>img[data-art-state],.topic-cover-loading>img[data-art-state] {opacity:0;}
.topic-card-art>img[data-art-state="ready"],.topic-cover-loading>img[data-art-state="ready"] {opacity:1;}

/* Read-only keyword artwork hints share one visibility toggle. */
.reader-word-keyword-image img { display:block; width:2.8em; height:2.8em; max-width:96px; max-height:96px; object-fit:contain; }

.word-info-bubble .reader-definition-expand {width:auto;min-height:34px;padding:5px 12px;font-weight:600;}
.word-commonness:is(button) {width:fit-content;padding:6px;border:0;background:transparent;cursor:pointer;border-radius:8px;}
.word-info-bubble .reader-word-image .word-illustration {width:min(100%,120px);transition:width .25s ease;margin-block:12px;}
.word-info-bubble .reader-word-image[data-large="true"] .word-illustration {width:min(100%,var(--word-image-large,240px));}
@media(prefers-reduced-motion:reduce){.word-info-bubble .reader-word-image .word-illustration{transition:none}}

@media (hover: hover) and (pointer: fine) { .word-commonness:is(button):hover {background:var(--surface-subtle);color:var(--text);} }

.reader-word-help-actions .reader-definition-expand {gap:8px;height:auto;min-height:36px;}

/* The content identity expands in place; activities below are the entry points. */
.topic-primary-copy {background:var(--surface);}
.topic-primary-copy .topic-channel-origin {position:relative;z-index:3;justify-content:flex-start;gap:6px 10px;margin-top:4px;pointer-events:none;}
.topic-primary-copy .topic-channel-origin a {pointer-events:auto;}
.topic-primary-copy .topic-age {border:0;border-radius:0;background:none;padding:0;min-height:0;margin:0;color:var(--text-secondary);text-shadow:none;font-weight:400;white-space:normal;}
.content-preparation-summary > .content-preparation-trigger {background:transparent;color:var(--text-secondary);border:0;box-shadow:none;padding:8px 0;font-weight:500;}
@media (hover: hover) and (pointer: fine) { .content-preparation-summary > .content-preparation-trigger:hover {background:transparent;color:var(--text);box-shadow:none;} }
.content-preparation-trigger .word-illustration-spinner {flex:none;width:18px;height:18px;}

.billing-scheduled-change {padding:12px 14px;border-radius:12px;background:var(--surface-subtle);font-weight:600;line-height:1.5;}

/* Preparation is one shared gate for the complete activity journey. */
.channel-stats[data-preparing="true"] {opacity:.4;filter:grayscale(1);}
.home-feature-section[data-preparing="true"] .topic-activity {opacity:.43;filter:grayscale(1);cursor:default;position:relative;overflow:hidden;}
.home-feature-section[data-preparing="true"] .topic-activity::after {content:"";position:absolute;inset:0;pointer-events:none;background:linear-gradient(110deg,transparent 30%,#ffffff55 50%,transparent 70%);transform:translateX(-100%);animation:content-creation-sheen 2.8s ease-in-out infinite;}
.content-preparation-summary {display:grid;grid-template-rows:1fr;opacity:1;transition:grid-template-rows .55s ease,opacity .4s ease,margin .55s ease;}
.content-preparation-summary[data-dismissed="true"] {grid-template-rows:0fr;opacity:0;margin:0;pointer-events:none;visibility:hidden;transition:grid-template-rows .55s ease,opacity .4s ease,margin .55s ease,visibility 0s .55s;}
.content-preparation-card {overflow:hidden;min-height:0;border-radius:20px;background:linear-gradient(115deg,#2677df20,#60baff13);color:var(--text);box-shadow:inset 0 0 0 1px #5098e63b;transition:background .5s ease;}
.content-preparation-heading>.content-preparation-trigger {display:flex;align-items:center;gap:12px;width:100%;border:0;background:transparent!important;color:inherit!important;box-shadow:none;padding:20px 22px 14px;text-align:left;}
.content-preparation-trigger strong {font-size:1.05rem;font-weight:650;}
.content-preparation-percent {margin-left:auto;font-size:.85rem;font-variant-numeric:tabular-nums;opacity:.65;}
.content-preparation-trigger .word-illustration-spinner {width:20px;height:20px;flex:none;color:#438ce8;}
.content-creation-track {height:7px;margin:0 22px 22px;border-radius:99px;background:#528bd526;overflow:hidden;}
.content-creation-track>span {display:block;height:100%;min-width:2px;border-radius:inherit;background:linear-gradient(90deg,#377ae0,#5bbdf3);position:relative;overflow:hidden;transition:width .8s ease,background .5s ease;}
.content-creation-track>span::after {content:"";position:absolute;inset:0;background:linear-gradient(100deg,transparent,#ffffff88,transparent);animation:content-creation-sheen 1.8s ease-in-out infinite;}
.content-preparation-summary[data-complete="true"] .content-preparation-card {background:#30a96519;color:#238a52;}
.content-preparation-summary[data-complete="true"] .content-creation-track>span {background:#35ae70;}
.content-preparation-summary[data-complete="true"] .content-preparation-trigger>svg {animation:content-complete-pop .4s ease-out;}
@keyframes content-creation-sheen {from {transform:translateX(-100%);}to {transform:translateX(100%);}}
@keyframes content-complete-pop {from {transform:scale(.5);opacity:0;}to {transform:scale(1);opacity:1;}}
@media(prefers-reduced-motion:reduce) {.content-preparation-summary,.content-creation-track>span {transition:none!important;}.content-creation-track>span::after,.home-feature-section[data-preparing="true"] .topic-activity::after,.content-preparation-summary[data-complete="true"] svg {animation:none!important;}}

.home-feature-section > .topic-vocabulary-progress {margin-top:24px;}
/* The highlight leaves the clipped track before wrapping back to its start. */
.content-creation-track>span::after {width:50%;inset:0 auto 0 0;animation:content-progress-sheen 2s linear infinite;}
@keyframes content-progress-sheen {from {transform:translateX(-110%);}to {transform:translateX(220%);}}

.topic-navigation-row {display:flex;align-items:center;justify-content:space-between;gap:16px;min-height:44px;margin-bottom:14px;}
.topic-navigation-row>.page-history-back {margin:0;}
.icon-button.topic-actions-trigger {background:var(--surface);color:var(--text);opacity:1;border:1px solid var(--border);box-shadow:none;width:38px;height:38px;}
button[aria-expanded="true"]:has(> .more-icon),
details[open] > summary:has(> .more-icon) {
  background:var(--accent); color:var(--accent-text); border-color:var(--accent);
}
.topic-page .topic-review-bar {grid-template-columns:minmax(0,1fr);}

/* Anchor artwork to its own viewport; intrinsic grid image sizing in Safari
   must not make the image box extend into the title/metadata area. */
.topic-header-leading .topic-cover>img {position:absolute;inset:0;display:block;width:100%;height:100%;min-width:0;min-height:0;object-position:center;}

.preview-download-progress {display:grid;gap:6px;margin-block:12px;font-size:.85rem;color:var(--text-muted);}
.preview-download-row {display:flex;align-items:center;gap:8px;}
.preview-download-row .comic-step-spinner {width:14px;height:14px;border-width:2px;flex:none;}
.preview-download-row small {margin-left:auto;font-variant-numeric:tabular-nums;}
.speech-loading-dot {width:1rem;height:1rem;box-sizing:border-box;border:2px solid currentColor;border-right-color:transparent;background:transparent;animation:comic-step-spin .8s linear infinite;}
.speech-button[data-state="loading"] .speech-pause {display:none;}

/* Three independent examples share one meaning; collapse preserves image size. */
.meaning-images {display:flex;justify-content:center;align-items:center;gap:12px;width:100%;min-width:0;}
.meaning-images .meaning-image {display:block;flex:0 1 33.333%;min-width:0;max-width:240px;padding:0;border:0;background:transparent;box-shadow:none;overflow:hidden;}
.meaning-images .meaning-image img {display:block;width:100%;height:clamp(90px,20dvh,190px);object-fit:contain;}
.meaning-image:active {background:transparent;color:inherit;}
@media (hover: hover) and (pointer: fine) { .meaning-image:hover {background:transparent;color:inherit;} }
.input-picture:has(.meaning-images) {width:100%;}
@media(max-width:600px){.meaning-images {gap:6px;}.meaning-images .meaning-image img {height:clamp(80px,16dvh,145px);}}
@media(prefers-reduced-motion:reduce){.meaning-images .meaning-image {transition:none;}}

.preview-preload-trigger {display:inline-flex;align-items:center;gap:9px;margin-block:12px;padding:4px 0;border:0;background:transparent;color:inherit;font:inherit;font-size:.85rem;box-shadow:none;}
.preview-preload-trigger:active {background:transparent;color:inherit;opacity:.85;}
@media (hover: hover) and (pointer: fine) { .preview-preload-trigger:hover {background:transparent;color:inherit;opacity:.85;} }
.preview-preload-ring {width:24px;height:24px;flex:none;}
.preview-preload-ring svg {display:block;width:100%;height:100%;}
.preview-preload-track {stroke:currentColor;opacity:.2;}
.preview-preload-fill {stroke:currentColor;stroke-linecap:round;transition:stroke-dasharray .3s ease;}
@media(prefers-reduced-motion:reduce) {.preview-preload-fill {transition:none;}}

.keyword-sequence-progress {display:flex;align-items:center;min-width:0;}
.keyword-sequence-progress .step-trail-track {justify-content:center;width:auto;gap:5px;padding:6px;}
.comic-navigation {--comic-nav-ideal:112;}
@media(max-width:600px) {.comic-navigation {--comic-nav-ideal:96;}}

.landing-legal-links {display:flex;justify-content:center;flex-wrap:wrap;gap:24px;padding:24px 16px 100px;font-size:.85rem;}
.landing-legal-links a {color:var(--text-secondary);text-underline-offset:3px;}

.auth-legal-agreement { display:flex; align-items:flex-start; gap:10px; margin:20px 0; font-weight:400; line-height:1.6; cursor:pointer; }
.auth-legal-agreement input[type="checkbox"] { margin-top:3px; cursor:pointer; }
.auth-legal-agreement a { color:var(--text); text-decoration:underline; text-underline-offset:3px; }

.definition-version-bar {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:6px 12px;padding:6px 10px;margin-top:16px;border-radius:12px;font-size:.85rem;}
.definition-version-navigation, .definition-votes {display:flex;align-items:center;gap:4px;flex-wrap:nowrap;}
.definition-votes {margin-inline-start:auto;}
.definition-version-bar button {min-width:30px;min-height:30px;padding:4px;font-size:1.1rem;}
.definition-version-bar button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.definition-version-label, .definition-vote-count { font-variant-numeric: tabular-nums; }
.definition-vote-count { min-width: 2ch; text-align: center; font-weight: 700; }
.definition-info-button {margin-inline-start:6px;}
.definition-info {max-width:min(360px,calc(100vw - 24px));}
.definition-info > p {margin:10px 0 0;line-height:1.5;}
.definition-version-bar + .definition-controls {margin-top:8px;}
.definition-regenerate-form {display:grid;gap:16px;}
.definition-regenerate-form > p {margin:0;font-size:.85rem;line-height:1.5;}
.definition-regenerate-form .button-row {justify-content:flex-end;}

.app-build-commit { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.settings-legal-links { position: relative; display: flex; justify-content: center; flex-wrap: wrap; gap: 12px 24px; padding: 12px; font-size: .85rem; }
.settings-legal-links:has(> .app-build-commit) { padding-inline: 85px; }
.settings-legal-links > .app-build-commit { position: absolute; inset-inline-start: 12px; bottom: 12px; }
@media (max-width: 480px) {
    .settings-legal-links:has(> .app-build-commit) { padding-inline: 12px; }
    .settings-legal-links > .app-build-commit { position: static; flex-basis: 100%; order: 1; }
}
.settings-legal-links a { color: var(--text-secondary); text-underline-offset: 3px; }

button:is([data-recording-mode="hold"],[data-recording-mode="toggle"]) { touch-action: none; user-select: none; -webkit-user-select: none; }
.recording-auto-button { flex-shrink: 0; min-width: 40px; min-height: 40px; vertical-align: middle; }
.recording-auto-button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.recording-auto-button svg { pointer-events: none; }
.recording-mode-setting { display: grid; gap: 8px; margin-bottom: 16px; }
.coach-stage-controls > .recording-auto-button { align-self: center; }

.flashcard-answer-input:has(.recording-auto-button) { grid-template-columns: minmax(0, 1fr) 44px 40px; }
.study-dock .flashcard-answer-input .recording-auto-button { grid-column: 3; grid-row: 1; }
.roleplay-play[data-recording-mode] .roleplay-play-icon { display: inline-flex; }
.roleplay-play[data-recording-mode] .roleplay-stop-icon { display: none; }
.roleplay-play[data-recording-mode][aria-pressed="true"] .roleplay-play-icon { display: none; }
.roleplay-play[data-recording-mode][aria-pressed="true"] .roleplay-stop-icon { display: inline-flex; }

/* Articles remain readable while the lexical headword carries the emphasis. */
.headword-article { opacity: .65; font-weight: inherit; }

/* Model-ranked wording variants arrive independently beneath one source request. */
.saying-written-forms-heading {margin:0 0 12px;color:var(--text-secondary);font-size:.9rem;font-weight:600;}
.saying-variants {display:grid;gap:20px;margin:0;padding:0;list-style:none;counter-reset:wording-variant;}
.saying-variant {min-width:0;counter-increment:wording-variant;}
.saying-variants[data-multiple="true"] > .saying-variant {position:relative;padding-inline-start:30px;}
.saying-variants[data-multiple="true"] > .saying-variant::before {content:counter(wording-variant);position:absolute;inset-inline-start:0;top:4px;color:var(--text-secondary);font-size:.85rem;font-variant-numeric:tabular-nums;}
.saying-variant + .saying-variant {border-top:1px solid var(--border);padding-top:20px;}
.saying-variants[data-multiple="true"] > .saying-variant + .saying-variant::before {top:24px;}
.saying-variant-meaning {margin:10px 0 0;font-size:.95rem;line-height:1.5;}
.saying-variant-note {margin:8px 0 0;font-size:.85rem;line-height:1.5;}

/* Scene changes keep the reference scene visible while choosing its outcome. */
.input-starting-scene { flex:0 1 18dvh;min-height:28px;max-height:210px;display:flex;flex-direction:column;text-align:center;margin:0 auto; }
.input-starting-scene h3 { flex:none;font-size:.9rem;color:var(--muted);margin:0 0 4px; }
.input-starting-scene img { display:block;flex:1;min-height:0;width:100%;max-width:320px;height:100%;object-fit:contain;margin:auto; }

.input-stage[hidden] { display:none; }
.input-step[data-scene-change=true] .input-stage[data-choices=true] { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); }

.credit-usage-scope { display:flex; gap:8px; flex-wrap:wrap; margin-block:12px; }
.credit-usage-scope button[aria-pressed=true] { background:var(--text); color:var(--bg); }
.shared-usage-badge { color:var(--muted); font-size:.85rem; }

.topic-actions { display:flex; align-items:center; gap:8px; }
.reader-title-meta { display: flex; align-items: center; gap: 8px; }

.saying-session-header {display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;max-width:none;margin-bottom:8px}
.saying-session-title {display:flex;align-items:center;gap:10px;min-width:0}
.saying-session-title h1 {margin:0;min-width:0;overflow-wrap:anywhere}
.saying-session-title>.icon-button {flex-shrink:0}
.saying-session-header .reader-document-actions {position:static;container-type:normal;padding:0;border:0;background:transparent;margin:0 0 0 auto;min-width:0;flex:none}

.first-pick-choice,.first-pick-ghost {text-align:start;color:var(--text);padding:0;white-space:normal;justify-content:flex-start;align-items:stretch}
.first-pick-choice:focus-visible {border-color:var(--accent);}
@media (hover: hover) and (pointer: fine) { .first-pick-choice:not(:disabled):hover {border-color:var(--accent);outline:2px solid var(--accent);outline-offset:1px} }
.signup-first-pick {padding-bottom:1.5rem}
.signup-first-pick h2 {font-size:clamp(1.1rem,3vw,1.45rem);margin:0 0 .8rem}
.signup-first-pick .setup-content-card {display:grid;grid-template-columns:auto 1fr}
.signup-first-pick .setup-content-card > img {width:clamp(85px,23vw,140px);height:100%;object-fit:cover}
.signup-first-pick .setup-content-card > img[hidden]+.setup-content-copy,.signup-first-pick .setup-content-copy:only-child {grid-column:1/-1}
.signup-language {display:flex;align-items:center;gap:.6rem;color:var(--muted);margin:1rem 0}
.signup-language span {font-size:1.55rem}
@media(prefers-reduced-motion:no-preference){
.first-pick-signup,.signup-first-pick {animation:first-pick-arrive .45s ease both}
.signup-language {animation:first-pick-arrive .4s .28s ease both}
@keyframes first-pick-arrive {from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
}
.upcoming-feed-card {display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--border);border-radius:18px;background:var(--surface)}
.upcoming-idea {width:100%;flex:1;display:flex;flex-direction:column;align-items:stretch;text-align:start;gap:.5rem;background:transparent;color:var(--text);border:0;border-radius:0;padding:0 0 1rem}
.upcoming-idea img {width:100%;aspect-ratio:16/9;object-fit:cover}
.upcoming-idea strong,.upcoming-idea small {padding-inline:1rem}
.upcoming-idea small,.signup-language {color:var(--muted)}
.upcoming-manager {display:grid;gap:.85rem}
.upcoming-manager h3,.cycle-idea-row p {margin:.25rem 0}
.upcoming-manager > button {justify-self:stretch;width:100%;}
.story-interview-result-actions {display:grid;gap:.75rem;width:100%;}
.story-interview-result-actions > :is(button,.button-link) {width:100%;}
.cycle-idea-row {display:flex;gap:.8rem;align-items:center;padding:.75rem;border:1px solid var(--border);border-radius:14px}
.cycle-idea-row img {width:4.5rem;height:4.5rem;border-radius:.5rem;object-fit:cover}

.first-picks .first-pick-choice {width:100%;min-width:0;box-sizing:border-box}

.first-picks button.first-pick-choice:focus-visible {background:var(--surface);color:var(--text)}
@media (hover: hover) and (pointer: fine) { .first-picks button.first-pick-choice:not(:disabled):hover {background:var(--surface);color:var(--text)} }
.upcoming-cover {position:relative;width:100%;aspect-ratio:16/9;background:linear-gradient(100deg,var(--surface-subtle) 30%,var(--surface-hover) 50%,var(--surface-subtle) 70%) 0 0 / 200% 100%;animation:shimmer 1.6s linear infinite}
.upcoming-cover img {position:absolute;inset:0;height:100%;object-fit:cover}
@media (prefers-reduced-motion:reduce){.upcoming-cover {animation:none}}
.upcoming-tile {position:relative}
button.upcoming-topic-card {text-align:start;gap:0;align-items:stretch;white-space:normal;border:2px solid #b4a0e8}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button.upcoming-topic-card:hover {border-color:#b4a0e8} }
.upcoming-art {background:linear-gradient(100deg,var(--surface-subtle) 30%,var(--surface-hover) 50%,var(--surface-subtle) 70%) 0 0 / 200% 100%;animation:shimmer 1.6s linear infinite}
@media (prefers-reduced-motion:reduce){.upcoming-art {animation:none}}
@media (hover: hover) and (pointer: fine) { .upcoming-idea:hover {background:var(--surface-hover);color:var(--text)} }
.upcoming-tile .upcoming-manage {position:absolute;z-index:3;top:.65rem;right:.65rem;background:var(--surface);color:var(--text)}
.upcoming-badge {flex-direction:column;align-items:flex-start;gap:1px;border-radius:.85rem;line-height:1.3}
.upcoming-countdown {font-size:.75rem;font-weight:500}

.activity-fullscreen[hidden], .activity-fullscreen .fullscreen-exit,
.activity-fullscreen[aria-pressed=true] .fullscreen-enter {display:none}
.activity-fullscreen[aria-pressed=true] .fullscreen-exit {display:inline}
.coach-stage > .reader-popup-heading .activity-fullscreen {right:calc(max(12px,env(safe-area-inset-right)) + 58px)}
.input-header .activity-fullscreen {margin-inline-start:auto}
.upcoming-manager .cycle-restore {position:relative;width:100%;padding:0;border:0;background:transparent;color:inherit;text-align:start}
.cycle-restore:focus-visible .cycle-idea-row {background:var(--surface-alt);border-color:var(--border-strong)}
@media (hover: hover) and (pointer: fine) { .cycle-restore:hover .cycle-idea-row {background:var(--surface-alt);border-color:var(--border-strong)} }
.cycle-idea-description {display:block;margin:.25rem 0;font-weight:normal}
.cycle-idea-row img {flex-shrink:0}
.cycle-art-placeholder {display:grid;place-items:center;width:4.5rem;height:4.5rem;flex-shrink:0;border-radius:.5rem;background:var(--surface-alt);color:var(--muted)}

.cycle-restore .cycle-idea-row {padding-inline-end:2.5rem}
.cycle-restore > svg {position:absolute;inset-inline-end:.8rem;top:50%;transform:translateY(-50%);color:var(--muted)}

/* Let the orb communicate readiness while retaining the status announcement. */
:is(#coach-stage,#flashcard-audio-stage) [data-ready-cue="true"] .coach-stage-status,
:is(#coach-stage,#flashcard-audio-stage) .coach-stage-status:has([role="status"]:empty) {
  position:absolute;width:1px;height:1px;min-height:0;padding:0;margin:-1px;border:0;overflow:hidden;clip-path:inset(50%);
}
:is(#coach-stage,#flashcard-audio-stage) [data-ready-cue="true"] .coach-orb {opacity:.78;box-shadow:0 0 0 2px var(--border-strong),0 0 20px var(--accent-soft)}
:is(#coach-stage,#flashcard-audio-stage) .coach-stage-words > * {flex-shrink:0}

@media (max-width:700px) {
  :is(#coach-stage,#flashcard-audio-stage) > .reader-popup-heading {gap:4px;justify-content:flex-end;padding:max(6px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 0 max(12px,env(safe-area-inset-left))}
  :is(#coach-stage,#flashcard-audio-stage) > .reader-popup-heading h2 {min-width:0;margin-inline-end:auto;padding:5px 10px;white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.2}
  :is(#coach-stage,#flashcard-audio-stage) > .reader-popup-heading .icon-button {position:static;flex:none;width:42px;height:42px}
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-live {min-width:0;gap:8px;padding:calc(max(6px,env(safe-area-inset-top)) + 50px) max(12px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-controls {display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);align-items:start;width:min(100%,540px);gap:3px;padding:8px 4px}
  /* The shared recorder adds a compact auto-record toggle beside the mic. */
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-controls > :is(.coach-round,.coach-mic) {min-width:0;width:100%;justify-self:stretch}
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-controls .coach-round-icon {width:min(44px,100%);height:auto;aspect-ratio:1}
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-controls .coach-mic .coach-round-icon {width:min(54px,100%)}
  :is(#coach-stage,#flashcard-audio-stage) .coach-round-label {min-width:0;max-width:100%;overflow-wrap:anywhere}
}

/* Fit the words and phrase first; the orb takes only the remaining space.
   Short landscape screens use the existing side-by-side layout. */
@media (max-width:599px), (min-height:601px) {
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-center:not(.coach-stage-checkpoint,.coach-stage-preparing) {
    display:flex;flex-direction:column;align-items:center;gap:8px;min-width:0;overflow:auto;overscroll-behavior:contain;
  }
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-visual {flex:1 0 auto;padding-block:6px}
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-visual .coach-orb {width:clamp(48px,min(18vmin,10dvh),128px)}
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-words {flex:none;overflow:visible;gap:8px}
  :is(#coach-stage,#flashcard-audio-stage) :is(.coach-stage-caption,.coach-reveal) {max-height:none;overflow:visible}
  :is(#coach-stage,#flashcard-audio-stage) .coach-stage-foot {flex:none;max-height:none;min-height:0;overflow:visible}
}

/* Role-play conversation: one bubble per turn above the controls, fading out
   towards the partner, then speed · play/pause · repeat, then the input bar. */
.roleplay-transcript {
  position:absolute;bottom:calc(100% + 12px);left:0;width:100%;
  max-height:min(46dvh,440px);overflow-y:auto;overscroll-behavior:contain;touch-action:pan-y;
  display:flex;flex-direction:column;gap:10px;padding:4px 4px 2px;scrollbar-width:none;
  -webkit-mask-image:linear-gradient(to bottom,transparent,#000 42%);mask-image:linear-gradient(to bottom,transparent,#000 42%);
}
.roleplay-transcript::-webkit-scrollbar {display:none}
.roleplay-stage .roleplay-transcript[hidden],.roleplay-turn[hidden],.roleplay-turn.live:has(.coach-live-caption:empty) {display:none}
.roleplay-turn {
  flex:0 0 auto;max-width:min(86%,560px);padding:11px 16px;border-radius:20px;font-size:1.05rem;line-height:1.5;
  white-space:pre-wrap;overflow-wrap:anywhere;text-align:start;
}
.roleplay-turn p {margin:0}
.roleplay-turn.partner {align-self:flex-start;background:rgba(18,18,18,.66);color:#f5f5f5;border:1px solid rgba(255,255,255,.12);border-bottom-left-radius:6px}
.roleplay-turn.learner {align-self:flex-end;background:rgba(56,118,92,.82);color:#f2fbf6;border:1px solid rgba(185,225,207,.28);border-bottom-right-radius:6px}
.roleplay-turn.partner[role=button] {cursor:pointer;transition:background .15s ease,box-shadow .15s ease,transform .1s ease}
@media (hover: hover) and (pointer: fine) { .roleplay-turn.partner[role=button]:hover {background:rgba(34,34,34,.78);box-shadow:inset 0 0 0 1px rgba(255,255,255,.3)} }
.roleplay-turn.partner[role=button]:active {transform:scale(.985)}
.roleplay-turn[data-analyzed=true] {box-shadow:inset 0 0 0 1px rgba(255,255,255,.26)}
.roleplay-turn[data-analyzed=true] .reader-sentence-translation {margin:.4em 0 0;color:rgba(245,245,245,.72)}
.roleplay-turn[data-interrupted=true] {border-style:dashed;border-color:rgba(255,255,255,.4)}
.roleplay-turn[data-interrupted=true]>p {opacity:.78}
.roleplay-turn-cut {display:flex;align-items:center;gap:6px;margin-top:6px;font-size:.78rem;color:rgba(245,245,245,.7)}
.roleplay-turn-cut::before {content:"";width:12px;height:2px;border-radius:2px;background:currentColor}
.roleplay-turn.pending {padding:12px 18px}
.roleplay-live-controls .roleplay-control-row {display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:16px}
.roleplay-control-side {display:flex;align-items:center;gap:10px;min-width:0}
.roleplay-control-side.start {justify-content:flex-end}
.roleplay-control-side.end {justify-content:flex-start}
.roleplay-stage .roleplay-live-controls .roleplay-call {display:grid;place-items:center;width:72px;height:72px;min-width:72px;min-height:72px;padding:0;border:0;border-radius:50%;background:#f2f2f2;color:#111}
.roleplay-stage .roleplay-call:disabled {opacity:.45}
.roleplay-live-controls:has(.roleplay-control-row) {padding:14px 18px}
/* The toggle sits left; an equal empty column on the right keeps the microphone
   centred, with automatic recording to its left and mute to its right. */
.roleplay-input-dock {width:100%;display:grid;grid-template-columns:44px minmax(0,1fr) 44px;align-items:center;gap:12px;padding:12px 16px}
.roleplay-stage .roleplay-input-dock[hidden],.roleplay-input-dock [hidden] {display:none!important}
.roleplay-input-toggle {grid-column:1}
.roleplay-voice-input {grid-column:2;display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:14px;min-width:0}
/* Fixed columns: the voice controller adds the automatic recording button after
   the microphone once it binds, which must not move the microphone. */
.roleplay-voice-input .recording-auto-button {grid-area:1/1;justify-self:end}
.roleplay-voice-input .roleplay-play {grid-area:1/2;justify-self:center}
.roleplay-voice-input .roleplay-mute {grid-area:1/3;justify-self:start}
.roleplay-input-dock .roleplay-type {grid-column:2/4;min-width:0;margin:0}
.roleplay-stage .roleplay-input-toggle {width:44px;height:44px;min-width:44px;padding:10px;border-radius:50%;color:var(--text);background:rgba(255,255,255,.08)}
@media(max-width:700px){
  .roleplay-transcript {max-height:min(40dvh,360px)}
  .roleplay-turn {font-size:1rem;padding:10px 14px}
  .roleplay-stage .roleplay-live-controls .roleplay-call {width:60px;height:60px;min-width:60px;min-height:60px}
  .roleplay-input-dock {padding:10px 12px;gap:10px}
}
@media(prefers-reduced-motion:reduce){.roleplay-turn.partner[role=button]{transition:none}.roleplay-turn.partner[role=button]:active{transform:none}}
@media(prefers-reduced-transparency:reduce){.roleplay-turn.partner{background:#1c1c1c}.roleplay-turn.learner{background:#2f6650}}

/* 3D scene assets: the loading overview and the room's asset browser. */
.stage3d-assets{display:grid;gap:14px;width:100%;text-align:start}
.stage3d-asset-group h3{margin:0 0 6px;font-size:.72rem;font-weight:650;letter-spacing:.04em;text-transform:uppercase;color:var(--muted)}
.stage3d-asset-group ul{display:grid;gap:4px;margin:0;padding:0;list-style:none}
.stage3d-asset{display:grid;gap:3px;padding:7px 10px;border-radius:10px;background:rgba(255,255,255,.06)}
.stage3d-asset-line{display:flex;align-items:center;gap:10px;min-width:0}
.stage3d-asset-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:.88rem}
.stage3d-asset-status{display:inline-flex;align-items:center;gap:6px;flex:none;font-size:.72rem;color:var(--muted)}
.stage3d-asset[data-status=done] .stage3d-asset-status{color:var(--text)}
.stage3d-asset[data-status=failed] .stage3d-asset-status{color:var(--danger)}
.stage3d-asset[data-status=pending]{opacity:.7}
.stage3d-assets.detailed .stage3d-asset{gap:4px;padding:10px 12px}
.stage3d-assets.detailed .stage3d-asset-name{white-space:normal;font-weight:600}
.stage3d-asset p{margin:0;font-size:.8rem;color:var(--muted);overflow-wrap:anywhere}
.stage3d-asset-facts{display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px}
.stage3d-asset-swatches{display:inline-flex;gap:3px}
.stage3d-asset-swatches i{width:12px;height:12px;border-radius:50%;box-shadow:inset 0 0 0 1px rgba(255,255,255,.25)}
.stage3d-asset-cost{font-variant-numeric:tabular-nums}
.stage3d-asset-credit a{color:inherit;text-decoration:underline;text-underline-offset:2px}
.stage3d-assets-note{margin:0;font-size:.78rem}
.roleplay-loading-progress .stage3d-assets{margin-top:6px;max-height:min(34dvh,280px);overflow:auto;overscroll-behavior:contain}

/* Record button: green to start, glowing red while recording, with a glow and
   rings that follow the learner's voice (--level loudness, --pitch tone), and
   yellow while automatic recording listens for speech. The rings are outlines
   that grow by offset: outlines never add scroll height, so the pulses cannot
   make the dock around the button scrollable. */
:is(.roleplay-stage .roleplay-play,.voice-record-button){--level:0;--pitch:.5;--glow:hsl(calc(350deg + var(--pitch) * 28deg) 92% 60%);position:relative;overflow:visible;background:#2e9d5c;color:#fff;transition:background .2s ease,color .2s ease,box-shadow .1s linear}
@media (hover: hover) and (pointer: fine) { :is(.roleplay-stage .roleplay-play,.voice-record-button):not(:disabled,[aria-busy=true],[aria-pressed=true]):hover{background:#36ad68} }
:is(.roleplay-stage .roleplay-play,.voice-record-button)[data-recording-mode][aria-pressed] .roleplay-stop-icon{display:none}
:is(.roleplay-stage .roleplay-play,.voice-record-button)[data-recording-mode][aria-pressed=true]:not([aria-busy=true]) .roleplay-play-icon{display:flex;transform:scale(calc(1 + var(--level) * .22));transition:transform .08s linear}
:is(.roleplay-stage .roleplay-play,.voice-record-button)[aria-pressed=true]:not([aria-busy=true]){background:#e5383b;color:#fff;box-shadow:0 0 calc(14px + var(--level) * 34px) calc(2px + var(--level) * 12px) color-mix(in srgb,var(--glow) 70%,transparent)}
@media (hover: hover) and (pointer: fine) { :is(.roleplay-stage .roleplay-play,.voice-record-button)[aria-pressed=true]:not([aria-busy=true]):not(:disabled):hover{background:#ee4a4d} }
:is(.roleplay-stage .roleplay-play,.voice-record-button)::before,:is(.roleplay-stage .roleplay-play,.voice-record-button)::after{content:"";position:absolute;inset:-2px;border-radius:50%;outline:2px solid var(--glow);outline-offset:0;pointer-events:none;opacity:0}
:is(.roleplay-stage .roleplay-play,.voice-record-button)[aria-pressed=true]:not([aria-busy=true])::before{opacity:calc(.35 + var(--level) * .65);outline-offset:calc(1px + var(--level) * 16px);transition:outline-offset .08s linear,opacity .08s linear}
:is(.roleplay-stage .roleplay-play,.voice-record-button)[aria-pressed=true]:not([aria-busy=true])::after{animation:roleplay-record-ripple 1.5s ease-out infinite}
:is(.roleplay-stage .roleplay-play,.voice-record-button)[aria-pressed=true]:not([aria-busy=true])[data-recording-auto=true]:not([data-voice=hearing]){--glow:#f2c230;background:#f2c230;color:#2a2100;box-shadow:0 0 14px 2px rgba(242,194,48,.35)}
:is(.roleplay-stage .roleplay-play,.voice-record-button)[aria-pressed=true]:not([aria-busy=true])[data-recording-auto=true]:not([data-voice=hearing])::before{opacity:.45;outline-offset:calc(1px + var(--level) * 7px)}
:is(.roleplay-stage .roleplay-play,.voice-record-button)[aria-pressed=true]:not([aria-busy=true])[data-recording-auto=true]:not([data-voice=hearing])::after{animation-duration:2.4s}
@keyframes roleplay-record-ripple{from{opacity:.55;outline-offset:0}to{opacity:0;outline-offset:26px}}
@media(prefers-reduced-motion:reduce){:is(.roleplay-stage .roleplay-play,.voice-record-button)::after{animation:none!important}}

/* The objective tile sits at the top centre, below the partner. */
.roleplay-stage .roleplay-partner-controls>button.roleplay-goal{grid-column:1/-1;grid-row:2;position:relative;inset:auto;top:auto;left:auto;transform:none;justify-self:center;width:min(560px,100%);margin:0}
@media(max-width:700px){.roleplay-stage .roleplay-partner-controls>button.roleplay-goal{grid-row:3;padding:10px 14px}}

/* Welcome: one card over the scene. The room's controls stay mounted, so the
   live call can bind to them, but appear only once the conversation starts. */
.roleplay-stage.welcoming :is(.roleplay-partner-controls,.roleplay-edge-tools,.roleplay-location,.roleplay-objective-support,.roleplay-dock){display:none}
.roleplay-welcome{position:absolute;z-index:4;top:50%;left:50%;transform:translate(-50%,-50%);width:min(520px,calc(100% - 32px));max-height:calc(100% - 32px);overflow:auto;overscroll-behavior:contain;display:grid;justify-items:center;gap:12px;padding:28px 24px 24px;border-radius:24px;text-align:center}
.roleplay-welcome .eyebrow{color:#d6d6d6;letter-spacing:.1em}
.roleplay-welcome h2{margin:0;font-size:1.6rem;line-height:1.25;overflow-wrap:anywhere}
.roleplay-welcome-setting{margin:0;color:var(--muted)}
.roleplay-welcome-objective{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;width:100%;margin-top:6px;padding:14px 16px;border:1px solid var(--border);border-radius:16px;background:rgba(255,255,255,.06);color:var(--text);text-align:start;white-space:normal}
@media (hover: hover) and (pointer: fine) { .roleplay-welcome-objective:hover{background:rgba(255,255,255,.12)} }
.roleplay-welcome-objective .eyebrow{font-size:.65rem;letter-spacing:.13em}
.roleplay-welcome-objective strong{font-size:.95rem;line-height:1.45;font-weight:600}
.roleplay-welcome-objective .roleplay-goal-copy{grid-column:2}
.roleplay-welcome-objective .roleplay-goal-progress{grid-column:3;grid-row:1;display:flex;align-items:center;gap:8px;font-size:.75rem;color:#d6d6d6}
.roleplay-welcome-study{display:flex;flex-wrap:wrap;justify-content:center;gap:10px;width:100%}
.roleplay-stage .roleplay-welcome-study button{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:8px 18px;border:1px solid var(--border-strong);border-radius:999px;background:rgba(255,255,255,.08);color:var(--text)}
@media (hover: hover) and (pointer: fine) { .roleplay-stage .roleplay-welcome-study button:hover:not(:disabled){background:rgba(255,255,255,.16)} }
.roleplay-stage .roleplay-welcome-study button:disabled{opacity:.45}
.roleplay-stage .roleplay-welcome-start{display:inline-flex;align-items:center;justify-content:center;gap:10px;min-height:52px;margin-top:10px;padding:12px 30px;border:0;border-radius:999px;background:#f2f2f2;color:#111;font-size:1.05rem;font-weight:650}
@media (hover: hover) and (pointer: fine) { .roleplay-stage .roleplay-welcome-start:hover{background:#fff} }
@media(max-width:700px){.roleplay-welcome{padding:22px 16px 18px}.roleplay-welcome h2{font-size:1.3rem}}
/* A fixed-height list with a leading spacer: a few turns sit at the bottom,
   and any turn can be scrolled down out of the faded top, even before the
   conversation fills the list. */
.roleplay-transcript{height:min(46dvh,440px);max-height:none}
.roleplay-transcript::before{content:"";flex:1 0 40%}
@media(max-width:700px){.roleplay-transcript{height:min(40dvh,360px)}}
.roleplay-transcript[data-dragging=true]{cursor:grabbing;user-select:none;-webkit-user-select:none}

.comic-keyword-heading > h2 {margin:0;font:inherit;flex:none;}
.comic-keyword-label-row {display:flex;align-items:center;justify-content:center;gap:16px;max-width:100%;direction:ltr;}
.comic-keyword-label {display:grid;gap:8px;min-width:0;text-align:center;}
.comic-keyword-label-row .comic-keyword-audio {flex:none;}
.comic-keyword-label-row .speech-control {margin:0;}

.comic-controls.comic-keyword-preview {left:0;right:0;margin-inline:auto;width:max-content;max-width:calc(100% - 40px);}
.comic-keyword-preview .comic-keyword-panel {width:max-content;max-width:100%;}
.comic-keyword-preview .comic-keyword-content {max-width:100%;padding-inline:16px;}
.comic-keyword-preview .meaning-images {width:max-content;max-width:100%;}
.comic-keyword-preview .meaning-image {flex:0 1 var(--keyword-image-size);width:var(--keyword-image-size);}
@media(max-width:600px) {
    .comic-controls.comic-keyword-preview {max-width:calc(100% - 20px);}
    .comic-keyword-preview .comic-keyword-content {padding-inline:12px;}
}

.comic-next-sentence.comic-next-hint svg {animation:comic-next-hint 2.4s ease-in-out infinite;}
@keyframes comic-next-hint {0%,100% {transform:scale(1);opacity:.8}50% {transform:scale(1.13);opacity:1}}
@media(prefers-reduced-motion:reduce) {.comic-next-sentence.comic-next-hint svg {animation:none;opacity:1;}}

.class-notes-section-group {border:1px solid var(--border);border-radius:14px;margin:8px 0 18px;overflow:clip;}
.class-notes-section-group[data-active="true"] {border-color:var(--accent);box-shadow:0 0 0 1px var(--accent);}
.class-notes-section-header {display:flex;align-items:center;gap:4px;background:var(--surface-subtle);padding:6px;cursor:pointer;}
.class-notes-section-header > .class-note-section {flex:1;min-width:0;margin:0;border:0;padding:6px;align-items:center;background:transparent;}
.class-notes-section-header .class-note-section-titles {flex:1;}
.class-notes-section-header h2 {font-size:1.2rem;margin:0;}
.class-notes-section-header p {font-size:.95rem;}
.class-notes-section-entries {padding:0 8px;min-height:12px;}
.class-note-section-select {padding:4px 0;background:transparent;color:inherit;font:inherit;border:0;box-shadow:none;text-align:start;min-height:0;}
@media (hover: hover) and (pointer: fine) { .class-note-section-select:hover {background:transparent;color:var(--accent);} }
.class-notes-section-group {position:relative;overflow:visible;}
.class-notes-section-header {border-radius:13px;}
.class-notes-section-header > .class-note-move,.class-notes-section-header > .class-note-move:active {position:static;transform:none;flex:0 0 24px;}
.class-notes-section-group.is-dragging {opacity:.45;}
.class-notes-section-group.drop-before::before,.class-notes-section-group.drop-after::after {content:"";position:absolute;inset-inline:0;height:3px;background:var(--accent);pointer-events:none;z-index:5;}
.class-notes-section-group.drop-before::before {top:0;}
.class-notes-section-group.drop-after::after {bottom:0;}

.guided-step-trail,.input-progress.input-trail {padding-block:1px;min-height:0;}
:is(.guided-step-trail,.input-progress.input-trail) .step-trail-track {padding-block:3px;}
.comic-photo-page-label {position:absolute;z-index:2;inset-inline:0;bottom:calc(var(--comic-footer-height) + 8px);width:max-content;margin-inline:auto;padding:5px 12px;border:1px solid #ffffff40;border-radius:999px;background:#14161bd9;color:#fff;font-size:.8rem;font-weight:600;pointer-events:none;}
.comic-controls[data-sentence-index] {width:max-content;max-width:min(1120px,calc(100% - 40px));left:0;right:0;margin-inline:auto;}
.comic-controls.comic-keyword-preview {scale:var(--comic-panel-scale,1);transform-origin:bottom center;}
.comic-stage[data-panel-docked="true"] .comic-action-controls {justify-self:start;}
.comic-stage[data-panel-docked="true"] :is(.comic-keyword-preview,.comic-controls[data-sentence-index]) {
    left:var(--comic-panel-center);right:auto;margin-inline:0;translate:-50% 0;bottom:var(--comic-panel-bottom);
}

.class-note-section-select-checkbox { flex:none; width:22px; height:22px; margin:0 4px 0 0; accent-color:var(--accent); cursor:pointer; }
.class-notes-move-menu { width:min(320px,calc(100vw - 24px)); }
.class-notes-move-destinations { display:grid; gap:4px; max-height:300px; overflow-y:auto; }
.class-notes-move-destinations > button { width:100%; justify-content:flex-start; text-align:start; overflow-wrap:anywhere; }

.class-notes-history {display:flex;align-items:center;gap:4px;}
@media(max-width:600px){.class-notes-toolbar{flex-wrap:wrap;}.class-notes-heading{flex-basis:100%;}.class-notes-tools{margin-inline-start:auto;gap:4px;max-width:100%;flex-wrap:wrap;justify-content:flex-end;}.class-notes-history .icon-button{width:34px;min-width:34px;}}
.flashcard-answer-choices {display:grid;grid-template-columns:minmax(0,1fr) minmax(0,2fr);gap:12px;width:100%;}
.flashcard-answer-choices:has(> .flashcard-quiz-answer):has(> .flashcard-manual-answer) {grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,2fr);}
.flashcard-answer-choices > .flashcard-reveal-answer:first-child {grid-column:1 / -1;}
.flashcard-answer-choices > :is(.flashcard-quiz-answer,.flashcard-manual-answer) {width:100%;min-width:0;padding-inline:8px;font-size:1.1rem;}
.flashcard-answer-choices > .flashcard-reveal-answer {min-width:0;width:auto;padding-inline:8px;}
.flashcard-reveal-answer {width:100%;min-height:96px;font-size:1.3rem;}
.flashcard-key-hint {padding:3px 7px;border:1px solid currentColor;border-radius:5px;font:inherit;font-size:.65em;font-weight:500;opacity:.65;}
@media (hover:none) {.flashcard-key-hint {display:none;}}
/* A single centered content region prevents the listening button from becoming
   an arbitrary row in the card's full-height grid. */
.study-card[data-kind="self-grading"] .study-card-scroll {display:flex;flex-direction:column;}
.study-card[data-kind="self-grading"] .study-card-body {flex:1;display:flex;flex-direction:column;gap:24px;}
.flashcard-self-content {flex:1;display:flex;flex-direction:column;justify-content:center;align-items:center;text-align:center;gap:20px;}
.flashcard-self-listening {display:grid;justify-items:center;gap:20px;width:100%;}
.flashcard-self-answer {text-align:center;display:grid;justify-items:center;gap:16px;width:100%;}
.flashcard-meaning-images {width:min(100%,600px);margin-inline:auto;}
.study-card .flashcard-meaning-images .word-illustration {width:100%;margin:0;}
.study-card .flashcard-meaning-images .meaning-images[data-interactive="true"] {min-height:0;}
.study-card .flashcard-definition,.study-card .flashcard-meaning-images {width:100%;}
.study-card .flashcard-meaning-images .meaning-images[data-interactive="true"] .meaning-image img {max-height:none;}
/* A 2:1:1 split makes the expanded image 50% wider than its equal-third size. */
.study-card .flashcard-meaning-images .meaning-images[data-interactive="true"][data-expanded="true"] .meaning-image[data-expanded="true"] {flex-grow:2;}
.study-card .flashcard-meaning-images .triplet-loading :is(.meaning-image,.reported-word-image) {max-height:none;}
.flashcard-self-word {display:flex;align-items:center;justify-content:center;gap:16px;}
.flashcard-self-word h2,.flashcard-self-word p,.flashcard-self-answer > p {margin:0;}
.flashcard-self-word .speech-button {flex:none;margin:0;}
.flashcard-self-pronunciation {font-size:1.3rem;}
.flashcard-revealed-progress {display:flex;align-items:center;justify-content:center;gap:12px;margin-top:auto;padding-top:20px;}
.flashcard-revealed-progress > span {font-size:.85rem;color:var(--muted);}
.flashcard-pronunciation-reveal {text-decoration:none;display:inline-flex;align-items:center;justify-content:center;gap:8px;}
.flashcard-self-ratings {display:flex;gap:10px;flex-wrap:wrap;}
.flashcard-self-ratings > button {flex:1;min-height:56px;font-size:1.2rem;}
.flashcard-rate-setting input[type="range"] {width:100%;}

/* Regional preference, shared by word help, definitions and How to say. */
.regional-usage { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; margin-block: .4rem; font-size: .85rem; }
.regional-usage-flags { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; list-style: none; margin: 0; padding: 0; }
.regional-usage-flags li { display: inline-flex; }
.regional-usage-flag { font-size: 1.35rem; line-height: 1.3; }
.saying-variant-situation { font-size: .9rem; margin-block: .4rem; }

.notes-text-import-form { display:grid; gap:18px; }
.notes-text-import-form > p { margin:0; }

/* Keep localized copy combinations readable while fitting narrow note screens. */
.class-note-actions .class-notes-menu-items { width:max-content; min-width:min(220px,calc(100vw - 96px)); max-width:min(520px,calc(100vw - 96px)); }

/* Contextual pronunciation changes keep the spoken guide legible in both themes. */
.pronunciation-change { background:rgba(230,183,42,.20); color:inherit; border-radius:3px; padding:0 .08em; cursor:pointer; box-decoration-break:clone; -webkit-box-decoration-break:clone; }
@media (hover: hover) and (pointer: fine) { .pronunciation-change:hover { background:rgba(230,183,42,.34); } }
.pronunciation-change-popover { width:360px; font-size:1rem; font-weight:400; line-height:1.5; color:var(--text); }
.pronunciation-comparison { display:flex; flex-wrap:wrap; gap:12px 24px; }
.pronunciation-comparison p { margin:0; display:grid; gap:4px; }
.pronunciation-comparison strong { font-size:.8rem; color:var(--muted); }
.pronunciation-comparison bdi { font-size:1.15rem; }
.pronunciation-explaining { display:flex; gap:8px; align-items:center; color:var(--muted); }
.pronunciation-explaining .comic-step-spinner { flex:none; width:16px; height:16px; }
.pronunciation-change-popover .anchored-popover-heading h2 { font-size:1rem; line-height:1.35; }

.transcript-repeat {display:inline-flex;align-items:center;gap:8px;vertical-align:middle}
.transcript-repeat svg {flex:none}

.roleplay-bulk-reading,.roleplay-bulk-translation {margin-top:.45em!important;font-size:.85em;line-height:1.5;opacity:.78;white-space:pre-wrap}
.roleplay-analysis-spinner,.roleplay-assistance-spinner {display:inline-block;width:14px;height:14px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:comic-step-spin .8s linear infinite;vertical-align:middle}
.roleplay-analysis-spinner {margin-inline-end:8px}.roleplay-assistance-spinner {margin-inline-start:8px;width:10px;height:10px}
.roleplay-turn.learner[role=button] {cursor:pointer}
@media(prefers-reduced-motion:reduce){.roleplay-analysis-spinner,.roleplay-assistance-spinner{animation:none}}

.reader-character-aligned {display:inline-flex;align-items:flex-start;gap:.12em}.reader-character-pair {display:inline-flex;flex-direction:column;align-items:center}.reader-character-pair .reader-word-reading {white-space:nowrap}
.roleplay-turn .reader-word {background:transparent;color:inherit;box-shadow:none}
.roleplay-turn .reader-word:is(:focus-visible,[aria-expanded="true"]) {background:rgba(255,255,255,.12);color:inherit}
@media (hover: hover) and (pointer: fine) { .roleplay-turn .reader-word:hover {background:color-mix(in srgb,var(--text) 12%,transparent);color:inherit} }
.roleplay-turn .reader-word-reading {color:rgba(245,245,245,.75)}
.objective-ci {position:absolute;inset:0;z-index:8;overflow:auto;background:var(--bg)}
.objective-navigation {display:flex;justify-content:center;gap:8px;flex-wrap:wrap}
.roleplay-welcome .secondary {max-width:100%;white-space:normal}
.objective-percent {font-size:.78em;border-radius:999px;padding:.15em .6em;background:#8883}
.objective-medal {width:72px;height:72px;display:grid;place-items:center;border-radius:50%;background:#a5efc8;color:#164630;font-size:36px;animation:objective-award .6s ease-out both}
@keyframes objective-award {from{transform:scale(.45) rotate(-12deg);opacity:.2}70%{transform:scale(1.12)}to{transform:scale(1);opacity:1}}
@media(prefers-reduced-motion:reduce){.objective-medal{animation:none}}
.roleplay-stage:has(.objective-ci) > .reader-popup-heading {display:none}
.roleplay-stage .roleplay-welcome .secondary {min-height:44px;padding:10px 18px;color:var(--text);background:rgba(255,255,255,.09);border:1px solid var(--border);border-radius:999px}
@media (hover: hover) and (pointer: fine) { .roleplay-stage .roleplay-welcome .roleplay-welcome-start:hover:not(:disabled) {background:#fff;color:#111} }
.comic-completed-celebration {--step-color:#92f4d5;--step-ink:#92f4d5;margin-bottom:24px;animation:comic-complete-arrival .65s cubic-bezier(.2,.8,.25,1.2) both}
.comic-completed-celebration .content-step-completed {font-size:1rem}
@keyframes comic-complete-arrival {from{opacity:0;transform:translateY(18px) scale(.65)}65%{opacity:1;transform:translateY(-3px) scale(1.08)}to{opacity:1;transform:translateY(0) scale(1)}}
@media(prefers-reduced-motion:reduce){.comic-completed-celebration{animation:none}}
.input-experience .input-loading-next {background:transparent;color:var(--text);border:1px solid var(--border-strong);box-shadow:none}
@media (hover: hover) and (pointer: fine) { .input-experience .input-loading-next:hover:not(:disabled) {background:var(--accent-soft)} }

.reader-flashcard-toolbar .voice-record-button {display:inline-grid;place-items:center;width:68px;height:68px;min-width:68px;min-height:68px;border-radius:50%;padding:18px;border:0;touch-action:none;user-select:none}
.voice-record-button .voice-record-icon {display:flex;transform:scale(calc(1 + var(--level) * .22));transition:transform .08s linear}
.voice-record-spinner {display:none}
.voice-record-button:is([data-state="permission"],[data-state="busy"]) {background:#606060;color:#fff;box-shadow:none}
.voice-record-button:is([data-state="permission"],[data-state="busy"])::before,.voice-record-button:is([data-state="permission"],[data-state="busy"])::after {display:none}
.voice-record-button:is([data-state="permission"],[data-state="busy"]) .voice-record-icon {display:none}
.voice-record-button:is([data-state="permission"],[data-state="busy"]) .voice-record-spinner {display:block;width:26px;height:26px;border:3px solid #ffffff40;border-top-color:#fff;border-radius:50%;animation:voice-record-wait .8s linear infinite}
@keyframes voice-record-wait {to{transform:rotate(360deg)}}
@media(prefers-reduced-motion:reduce){.voice-record-spinner{animation:none!important}}

.reader-flashcard-microphone[hidden] {display:none!important}
.comic-sentence-heading {display:flex;align-items:center;gap:12px;margin-bottom:10px;min-height:36px}
.comic-sentence-heading .comic-speaker {display:flex;align-items:center;gap:8px;flex:0 1 auto;width:auto;margin:0;text-align:start}
.comic-sentence-heading .comic-speaker figcaption {margin:0}
.comic-sentence-heading .comic-portrait {width:36px;height:36px;flex:none}
.comic-sentence-heading .speech-button {width:36px;height:36px;min-width:36px}
.comic-footer[data-preview="true"] .comic-action-controls {display:none}
.comic-keyword-actions {display:flex;align-items:center;gap:8px;flex:none}
@media(max-width:600px){.comic-keyword-label-row{gap:10px}.comic-keyword-actions{gap:4px}}
.comic-keyword-meaning {margin:14px 0 0;text-align:center;font-size:1rem;color:var(--muted)}
@media(max-width:400px){.comic-keyword-label-row{gap:8px}.comic-keyword-actions{gap:2px}.comic-keyword-actions .icon-button{width:32px;min-width:32px;padding:6px}}
@media(max-width:600px) and (orientation:portrait) {
  .comic-controls.comic-keyword-preview {width:calc(100% - 24px);max-width:calc(100% - 24px)}
  .comic-keyword-preview :is(.comic-keyword-panel,.comic-keyword-content,.comic-keyword-grid,.comic-keyword) {width:100%;box-sizing:border-box}
  .comic-keyword-preview .meaning-images {width:100%}
  .comic-keyword-preview .meaning-image {flex:1 1 0;width:auto;max-width:none}
  .comic-keyword-preview .meaning-image img {width:100%;height:auto;aspect-ratio:1;object-fit:contain}
}

/* Equal side tracks keep recording centred when optional controls appear. */
.input-answer .reader-flashcard-toolbar {width:100%;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);}
.input-answer .reader-flashcard-toolbar .voice-record-button {grid-column:2;grid-row:1;justify-self:center;}
.input-answer .reader-flashcard-toolbar .recording-auto-button {grid-column:3;grid-row:1;justify-self:start;}

.input-screen-previous[hidden] {display:none!important;}

/* Symmetric side tracks centre the text independently of its audio button. */
.flashcard-self-word,.flashcard-context-row {display:grid;grid-template-columns:48px minmax(0,auto) 48px;align-items:center;justify-content:center;gap:16px;max-width:100%;}
.flashcard-self-word>.speech-control,.flashcard-context-row>.speech-control {grid-column:1;justify-self:center;}
.flashcard-self-word>div,.flashcard-context-row>.flashcard-context {grid-column:2;min-width:0;}
.flashcard-self-word h2,.flashcard-front-word {font-size:clamp(2rem,5vw,3rem);line-height:1.3;margin:0;}
.flashcard-front-word {text-align:center;}
.flashcard-context-row .flashcard-context {margin:0;padding:12px 0;}
.flashcard-context-row .speech-button {margin:0;}
.flashcard-context-row.flashcard-context-audio-labeled {display:flex;flex-direction:column;align-items:center;justify-content:center;width:100%;}
.flashcard-context-audio-labeled > .speech-control {max-width:100%;}
.flashcard-context-audio-labeled .speech-button-labeled {width:auto;max-width:100%;height:auto;min-height:44px;gap:8px;}
.flashcard-context-audio-labeled .speech-button-label {display:inline;}
@media(max-width:480px) {.flashcard-self-word,.flashcard-context-row {grid-template-columns:40px minmax(0,1fr) 40px;gap:8px;width:100%;}}

.study-card .flashcard-back-heading {display:grid;grid-template-columns:48px minmax(0,auto) 48px;align-items:center;justify-content:center;gap:16px;width:100%;padding-right:0;}
.study-card .flashcard-back-heading>div {grid-column:2;text-align:center;}

.word-progress-picker-heading {display:flex;align-items:center;justify-content:space-between;gap:12px;padding-bottom:8px;}
.word-progress-picker-heading .icon-button {width:32px;height:32px;min-width:32px;min-height:32px;padding:6px;}
.word-memory-details {display:grid;gap:16px;}
.word-memory-details>p {margin:0;color:var(--muted);}
.word-memory-details summary {cursor:pointer;font-weight:600;}
.word-memory-details details>.word-memory-dimension {margin-top:16px;}
.word-memory-dimension {border:1px solid var(--border);border-radius:14px;padding:16px;}
.word-memory-dimension h3 {margin:0 0 12px;}
.word-memory-dimension dl {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px 16px;margin:0;font-size:.9rem;}
.word-memory-dimension dd {margin:0;font-variant-numeric:tabular-nums;text-align:end;}
/* Keep delayed introductions in flow; invisible panels cannot receive input. */
.input-step [data-pending="true"] {visibility:hidden;pointer-events:none;animation:none;}
.input-speech-placeholder {display:inline-block;width:2rem;height:2rem;margin-inline:.25rem;flex-shrink:0;}
.input-picture > .meaning-images {width:100%;height:100%;min-height:0;}
.input-picture:has(> .grammar-tag) {flex-direction:column;gap:var(--input-space);}
.input-picture:has(> .grammar-tag) > .meaning-images {height:auto;}
:is(.input-picture,.comic-keyword) > .grammar-tag {margin:0;}

/* A prepared opening window unlocks preview while the rest keeps generating. */
.home-feature-section[data-preparing="true"] [data-preview-available="true"] .topic-activity {opacity:1;filter:none;cursor:pointer;}
.home-feature-section[data-preparing="true"] [data-preview-available="true"] .topic-activity::after {display:none;}

.content-preparation-group h3 {font-size:1rem;margin:20px 0 8px;}
.content-preparation-row-progress {width:100%;height:5px;accent-color:var(--accent);}

/* Card backs expose compact controls; calculations live in the retention popup. */
.flashcard-revealed-progress {flex-wrap:wrap;gap:8px;}
.flashcard-character-headword .reader-character-word { justify-content: center; }
.study-card .flashcard-character-headword :is(button.reader-subword-button.reader-title-character, .reader-title-literal) { font-size: clamp(1.75rem, 5vw, 2.65rem); }
.flashcard-definition { display: grid; justify-items: center; gap: 8px; text-align: center; }
.flashcard-definition > p { margin: 0; }
.flashcard-word-metadata { display: flex; align-items: center; justify-content: center; gap: 10px; }
.flashcard-revealed-progress > .word-history-button,
.flashcard-revealed-progress > .ask-about,
.flashcard-context-row .flashcard-example-translate { box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-sm); color: var(--text); }
.flashcard-context-row .flashcard-example-translate[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.flashcard-introduction > .flashcard-revealed-progress { margin: 0; padding: 0; }
.flashcard-revealed-progress > button.word-progress-chip,
.flashcard-retention-chip {min-width:44px;min-height:44px;border-radius:10px;font-size:1rem;font-weight:750;font-variant-numeric:tabular-nums;}
.flashcard-revealed-progress > button:is(.word-importance-button, .word-history-button, .word-progress-chip, .ask-about) {height:38px;min-height:38px;padding-block:0;}
button.flashcard-retention-chip {display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:0 10px;background:var(--surface-subtle);color:var(--text);border:1px solid transparent;}
button.flashcard-retention-chip:focus-visible {border-color:var(--text-secondary);}
@media (hover: hover) and (pointer: fine) { button.flashcard-retention-chip:hover {border-color:var(--text-secondary);} }
.word-bubble-progress-row > button.flashcard-retention-chip {min-height:32px;border-radius:8px;font-size:.9rem;}
.word-memory-formula {font-size:.8rem;color:var(--muted);overflow-wrap:anywhere;}
.flashcard-memory-score-row {display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:8px;font-variant-numeric:tabular-nums;}
.flashcard-memory-score-row > span:first-child {color:var(--muted);margin-right:4px;font-size:.9rem;}
.flashcard-memory-before {color:var(--muted);}
.flashcard-memory-interval {display:block;text-align:center;color:var(--muted);font-size:.78rem;}
.flashcard-memory-change {display:grid;gap:10px;padding:12px 0;}
.flashcard-memory-change[data-compact="true"] {gap:6px;padding:0;font-size:.85rem;}
.flashcard-memory-change[data-compact="true"] > .flashcard-memory-score-row {justify-content:flex-start;}
.flashcard-memory-change .flashcard-change-info {width:30px;height:30px;min-height:30px;padding:4px;}
.flashcard-change-details .flashcard-memory-score-row {justify-content:flex-start;}
.flashcard-change-details .flashcard-memory-interval,.flashcard-change-details .flashcard-memory-skills summary {text-align:start;}


.flashcard-memory-skills {font-size:.85rem;}
.flashcard-memory-skills summary {cursor:pointer;text-align:center;color:var(--muted);}
.flashcard-memory-skill {display:grid;gap:4px;padding:10px 0;border-bottom:1px solid var(--border);font-variant-numeric:tabular-nums;}
@media(max-width:480px) {.flashcard-revealed-progress {padding-top:10px;gap:6px;}.flashcard-memory-score-row {gap:6px;}}

.study-menu > summary.flashcard-progress-trigger {padding:0;background:transparent;color:var(--text);}
.flashcard-progress-badge {display:flex;align-items:center;justify-content:center;gap:7px;padding:8px;border-radius:11px;background:hsl(var(--progress-hue) 75% 48% / .16);border:1px solid hsl(var(--progress-hue) 70% 45% / .22);transform-origin:center;}
.study-menu[open] > .flashcard-progress-trigger .flashcard-progress-badge {border-color:hsl(var(--progress-hue) 70% 45% / .5);}
@media (hover: hover) and (pointer: fine) { .flashcard-progress-trigger:hover .flashcard-progress-badge {border-color:hsl(var(--progress-hue) 70% 45% / .5);} }
.flashcard-progress-badge[data-answered="true"] {animation:flashcard-progress-pulse .48s ease-out both;}
@keyframes flashcard-progress-pulse {0%,100% {transform:translateY(0) scale(1);}38% {transform:translateY(-2px) scale(1.06);}70% {transform:translateY(0) scale(.99);}}
@media(prefers-reduced-motion:reduce) {.flashcard-progress-badge[data-answered="true"] {animation:none;}}

.flashcard-known-duration-options {display:grid;gap:10px;}
.flashcard-known-duration-options button {width:100%;min-height:48px;}
.flashcard-known-duration-options .flashcard-key-hint {margin-inline-start:12px;}

/* Picture-choice feedback stays on the question while other choices remain usable. */
.input-picture-verdict {
  position: absolute;
  right: 5%;
  bottom: 5%;
  width: 25%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: #f2aaaa;
  pointer-events: none;
  animation: input-choice-bounce 360ms ease-out both;
}
.input-picture-verdict[data-correct="true"] { color: #6fcf97; }
.input-picture-verdict svg { width: 100%; height: 100%; stroke-width: 3; }
.input-picture:disabled:has(.input-picture-verdict) { opacity: 1; }
.input-choice-feedback { display: inline-block; animation: input-choice-bounce 360ms ease-out both; }
@keyframes input-choice-bounce {
  0% { opacity: 0; transform: scale(.55); }
  65% { opacity: 1; transform: scale(1.12); }
  100% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .input-picture-verdict, .input-choice-feedback { animation: none; }
}

.input-feedback[data-correct="true"] .input-choice-feedback { color: light-dark(#247345,#90dfaf); }
.input-feedback[data-correct="false"] .input-choice-feedback { color: light-dark(#b72e37,#ff8b94); }

/* Keep segment hover targets above the bar-wide legend button. */
.input-trail > .step-trail-track { position: relative; z-index: 2; pointer-events: none; }
.input-trail > .step-trail-track .step-trail-segment { pointer-events: auto; cursor: pointer; }
.input-trail .step-trail-segment[tabindex] { cursor: help; }
.input-step-loading-details {
  position: absolute;
  z-index: 10;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: min(340px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid #ffffff30;
  border-radius: 14px;
  background: #202226;
  color: #fff;
  box-shadow: 0 8px 28px #0004;
  font-size: .85rem;
  pointer-events: none;
}
.input-step-loading-details .preview-download-progress { margin-top: 12px; }

.input-progress.input-trail:has(.input-step-loading-details) { z-index: 5; }

:is(.reader-word-image, .vocabulary-entry-images) .word-illustration:has(.meaning-images[data-interactive="true"]) {
  width: 100%; max-width: 600px; background: transparent; overflow: visible;
}
.meaning-images[data-interactive="true"] { min-height: 120px; align-items: center; }
.meaning-images[data-interactive="true"] .meaning-image {
  flex: 1 1 0; max-width: none; cursor: zoom-in; border-radius: 12px;
  transition: flex-grow 280ms ease;
}
.meaning-images[data-interactive="true"][data-expanded="true"] .meaning-image[data-expanded="true"] { flex-grow: 4; cursor: zoom-out; }
.meaning-images[data-interactive="true"] .meaning-image img {
  width: 100%; height: auto; aspect-ratio: 1; max-height: min(240px, 30dvh); object-fit: contain;
}
.meaning-images[data-interactive="true"] .reported-word-image { display: block; width: 100%; }
@media(prefers-reduced-motion:reduce) { .meaning-images[data-interactive="true"] .meaning-image { transition: none; } }
.meaning-images[data-interactive="true"] .meaning-image img {
  max-height: min(140px, 18dvh); transition: max-height 280ms ease;
}
.meaning-images[data-interactive="true"] .meaning-image[data-expanded="true"] img { max-height: min(240px, 30dvh); }
@media(prefers-reduced-motion:reduce) { .meaning-images[data-interactive="true"] .meaning-image img { transition: none; } }

/* Main pages share Notes' content column. Activity canvases and Home keep their own layouts. */
.workspace:not(:has(.home-dashboard)) :is(.class-notes-library, .skills-page, .testing-page, .textbook-page, .how-to-say, .progress-page, .channels-page, .channel-page, .lists-page) {
  width: 100%;
  max-width: var(--page-column-width, 1000px);
  margin-inline: auto;
}
.workspace:not(:has(.home-dashboard)) .skills-page { padding: 0; }
.workspace:not(:has(.home-dashboard)) .skills-intro { max-width: none; margin-block: 0 28px; }
.workspace:not(:has(.home-dashboard)) .skills-intro p { max-width: 640px; }
.workspace:not(:has(.home-dashboard)) :is(.skills-intro, .textbook-intro, .progress-page-heading) h1 {
  font-size: var(--page-title-size); line-height: 1.2; letter-spacing: -.028em; margin: 0 0 10px;
}
/* Chat follows the same column and top gutter, while retaining its viewport-height composer. */
.app-shell > .workspace:has(> .assistant-screen:not(.embedded)) {
  width: min(1120px, 100%);
  padding: var(--workspace-top) max(var(--workspace-gutter), env(safe-area-inset-right)) 0 max(var(--workspace-gutter), env(safe-area-inset-left));
}
@media (max-width: 760px) {
  .app-shell > .workspace:has(> .assistant-screen:not(.embedded)) { --workspace-top: 22px; --workspace-gutter: 16px; }
}

.workspace:not(:has(.home-dashboard)) .progress-page-heading { padding: 0; }
.workspace > .assistant-screen:not(.embedded) {
  height: var(--chat-height, calc(100dvh - var(--header-height, 60px) - var(--workspace-top)));
}
.suggested-content-card { width:100%; text-align:start; }
.suggested-content-preview { display:grid; gap:18px; }
.suggested-content-preview h2,.suggested-content-preview p { margin:0; }
.suggested-content-cover { width:100%; max-height:280px; border-radius:16px; object-fit:cover; }

.word-importance-button {font-size:.8rem;padding:.4rem .6rem;white-space:nowrap;}
.word-importance-options {display:grid;gap:.5rem;min-width:220px;}
.word-importance-options button {display:flex;gap:.75rem;justify-content:flex-start;}
.word-importance-options button[aria-pressed="true"] {outline:2px solid var(--text);}
.word-importance-options button {width:100%;}

/* Dynamic encounter history keeps the word and its latest source together. */
.encountered-words:not(:empty) { margin-block: .5rem 1rem; }
.encountered-word { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding-block:1.15rem; }
.encountered-word + .encountered-word { border-top:1px solid color-mix(in srgb,currentColor 12%,transparent); }
.encountered-word-copy { min-width:0; }
.encountered-term { font-size:1.3rem; font-weight:650; text-decoration:none; }
.encountered-word-copy p { margin:.35rem 0 0; }
.encountered-word-source { display:flex; flex-direction:column; align-items:flex-end; gap:.5rem; max-width:45%; font-size:.85rem; }
.encounter-source-chip { display:inline-flex; align-items:center; gap:.4rem; border-radius:999px; padding:.35rem .7rem; background:color-mix(in srgb,currentColor 7%,transparent); text-decoration:none; max-width:100%; overflow-wrap:anywhere; }
@media(max-width:540px) { .encountered-word { align-items:flex-start; flex-direction:column; gap:.7rem; } .encountered-word-source { flex-direction:row; flex-wrap:wrap; align-items:center; max-width:100%; } }

/* Compact word metrics retain readable text beside their shared meaning icons. */
button.word-progress-chip, .word-importance-button {display:inline-flex;align-items:center;justify-content:center;gap:6px;}
.word-progress-chip > svg, .word-importance-button > svg {flex-shrink:0;}
.word-progress-picker-heading > strong {display:inline-flex;align-items:center;gap:8px;}
.word-importance-options {margin-top:8px;}

/* Failed preparation stays actionable without opening its detail popover. */
.content-preparation-summary[data-failed="true"] .content-preparation-card {background:color-mix(in srgb,var(--danger,#d04b42) 10%,var(--surface));box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--danger,#d04b42) 35%,transparent);}
.content-preparation-summary[data-failed="true"] .content-preparation-trigger>.shell-icon {color:var(--danger,#d04b42);flex:none;}
.content-preparation-summary[data-failed="true"] .content-creation-track>span {background:var(--danger,#d04b42);}
.content-preparation-summary[data-failed="true"] .content-creation-track>span::after {animation:none;display:none;}
.content-preparation-actions {display:flex;align-items:center;justify-content:space-between;gap:12px;padding:0 22px 18px;}
.content-preparation-paused {display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 20px;}
.content-preparation-paused > div {display:flex;align-items:center;gap:8px;}
.content-preparation-actions p {color:var(--text-secondary);display:grid;gap:4px;margin:0;font-size:.9rem;}
.content-preparation-retry {flex:none;}
@media(max-width:480px) {.content-preparation-actions {align-items:stretch;flex-direction:column;padding-inline:16px;}}

.flag-icon,
.flag-globe {
  display: inline-block;
  flex: none;
  width: 1.16em;
  height: .87em;
  vertical-align: -.06em;
}
.flag-icon {
  object-fit: contain;
  border-radius: .1em;
  filter: drop-shadow(0 -.5px 0 rgb(255 255 255 / 25%)) drop-shadow(0 1px 0 rgb(0 0 0 / 25%));
}
.flag-globe > .shell-icon {
  display: block;
  width: 100%;
  height: 100%;
}

/* Friends, profile links, and the header notification bell. */
.header-notifications { position: relative; flex: none; }
.header-notifications-trigger { position: relative; }
.notification-badge { position: absolute; top: 4px; inset-inline-end: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--accent); color: var(--accent-contrast, #fff); font-size: .62rem; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.notifications-popover { width: min(400px, calc(100vw - 24px)); }
.notifications-read-all { min-height: 32px; padding: 4px 10px; font-size: .8rem; }
.notification-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.notification-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; border-radius: 12px; background: transparent; color: var(--text); text-align: start; }
@media (hover: hover) and (pointer: fine) { .notification-item:hover { background: var(--surface-subtle); } }
.notification-item[data-unread="true"] { background: color-mix(in srgb, var(--accent) 7%, transparent); }
@media (hover: hover) and (pointer: fine) { .notification-item[data-unread="true"]:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); } }
.notification-copy { display: grid; flex: 1; gap: 2px; min-width: 0; font-weight: 550; overflow-wrap: anywhere; }
.notification-copy small { font-weight: 450; }
.notification-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.profile-link-card { display: grid; gap: 12px; }
.profile-link-card h2 { margin: 0; font-size: 1.1rem; }
.profile-link-card p { margin: 0; }
.profile-link-card label { display: grid; gap: 8px; }
.profile-link-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.profile-link-actions .button-link { display: inline-flex; align-items: center; gap: 8px; }
.friends-page, .person-page { display: grid; gap: 18px; max-width: 860px; }
.friends-page .surface + .surface, .person-page .surface + .surface { margin-top: 0; }
.friends-card h2 { margin: 0 0 14px; font-size: 1.1rem; }
.friend-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 14px; }
.friend-row[data-mutual="true"] { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: color-mix(in srgb, var(--accent) 4%, transparent); }
.friend-row-link { display: flex; flex: 1; align-items: center; gap: 14px; min-width: 0; color: var(--text); text-decoration: none; border-radius: 10px; }
@media (hover: hover) and (pointer: fine) { .friend-row-link:hover strong { text-decoration: underline; } }
.friend-row-copy { display: grid; gap: 4px; min-width: 0; }
.friend-row-copy strong { overflow-wrap: anywhere; }
.friend-pending { color: var(--muted); font-size: .82rem; }
.friend-progress-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--text-secondary); font-size: .82rem; font-variant-numeric: tabular-nums; }
.friend-progress-streak { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.friend-progress-streak[data-active="true"] { color: var(--xp); }
.friend-progress-flags { display: inline-flex; gap: 4px; }
.friend-progress-flag { font-size: 1.05rem; line-height: 1; }
.friend-remove { flex: none; gap: 6px; min-height: 36px; padding: 6px 10px; font-size: .82rem; }
.person-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; }
.person-heading .avatar { flex-basis: 56px; width: 56px; height: 56px; font-size: 1.4rem; }
.person-heading-copy { display: grid; flex: 1; gap: 6px; min-width: 200px; }
.person-heading-copy h1 { margin: 0; font-size: 1.5rem; overflow-wrap: anywhere; }
.person-heading-copy p { margin: 0; }
.person-status { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: .9rem; }
.person-status[data-mutual="true"] { color: var(--xp); font-weight: 600; }
.person-actions { display: flex; flex: none; gap: 10px; }
.person-actions button { display: inline-flex; align-items: center; gap: 6px; }
.friend-progress-card .progress-section-heading { margin-bottom: 16px; }
.friend-progress-totals { margin-bottom: 18px; }
.friend-progress-totals .progress-stat { margin-top: 0; }
@media (max-width: 600px) {
  .friend-row { flex-wrap: wrap; }
  .friend-remove { margin-inline-start: auto; }
  .notification-badge { top: 2px; inset-inline-end: 2px; }
}

/* Referral invites and the quiet profile identifier. */
.referral-card { display: grid; gap: 12px; }
.referral-card h2 { margin: 0; font-size: 1.1rem; }
.referral-card p { margin: 0; }
.referral-allowance { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.referral-allowance button { display: inline-flex; align-items: center; gap: 6px; }
.referral-allowance-copy { color: var(--text-secondary); font-size: .9rem; font-variant-numeric: tabular-nums; }
.invite-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.invite-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-subtle); }
.invite-row[data-status="referral_withdrawn"] { opacity: .65; }
.invite-row[data-status="referral_used"] { border-color: color-mix(in srgb, var(--xp) 45%, var(--border)); }
.invite-row-main { display: grid; flex: 1; gap: 6px; min-width: 220px; }
.invite-code-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.invite-code { font-family: var(--font-mono, SFMono-Regular, Menlo, Consolas, monospace); font-size: .98rem; font-weight: 700; letter-spacing: .06em; }
.invite-code-line .tag { margin: 0; }
.invite-row[data-status="referral_used"] .invite-status { background: color-mix(in srgb, var(--xp) 18%, transparent); color: var(--xp); }
.invite-row[data-status="referral_withdrawn"] .invite-status { background: var(--surface); color: var(--muted); }
.invite-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .85rem; }
.invite-used-by { color: var(--text); font-weight: 600; }
.invite-bonus { color: var(--xp); font-weight: 600; }
.invite-row-actions { display: flex; flex: none; gap: 8px; }
.invite-row-actions button { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 12px; font-size: .85rem; }
.invite-email-form { display: grid; gap: 12px; }
.invite-email-form p { margin: 0; }
.invite-email-form .form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.profile-id-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin: 0; padding: 4px 12px 8px; font-size: .74rem; }
.profile-id-row .profile-id-value { font-family: var(--font-mono, SFMono-Regular, Menlo, Consolas, monospace); font-size: .72rem; color: var(--muted); user-select: all; }
.profile-id-row .copy-text-button { width: 26px; min-width: 26px; height: 26px; color: var(--muted); }
.profile-id-row .copy-text-button .shell-icon { width: 13px; height: 13px; }
.referral-reward { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--xp) 10%, transparent); color: var(--text); font-size: .88rem; line-height: 1.45; }
.referral-reward .shell-icon { flex: none; margin-top: 2px; color: var(--xp); }
.referral-reward + .referral-reward { margin-top: -4px; }
.invite-plan-bonus { color: var(--accent-ink, var(--text)); }
/* Collection details scroll with the workspace. Only their controls stick. */
.workspace:has([data-list-page="true"]) { padding-block-start: 0; }
.workspace:has([data-list-page="true"]) > .page-history-back { display: none; }
.study-list { min-width: 0; overflow-anchor: none; }
.study-list-toolbar {
  position: sticky;
  top: var(--header-height, 0px);
  z-index: 76;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  grid-template-areas: "back back back back" "title title title title"
    "summary summary summary summary" "actions actions practice practice" "filters filters filters filters";
  align-items: center;
  container-type: inline-size;
  padding: clamp(10px, 1.4vw, 18px) 0 10px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.study-list-toolbar[data-compact="true"] {
  background: var(--bg);
  grid-template-areas: "back title summary practice" "filters filters filters filters";
  padding-block: 4px;
  box-shadow: 0 8px 16px -14px var(--text);
}
.study-list-back { grid-area: back; min-width: 0; }
.study-list-title { grid-area: title; min-width: 0; }
.study-list-summary { grid-area: summary; min-width: 0; }
.study-list-practice { grid-area: practice; display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.study-list-toolbar[data-compact="true"] .study-list-practice { margin-top: 0; }
.list-history-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.study-list-practice .list-history-button { min-width: 44px; min-height: 44px; padding: 10px; }
.list-familiarity-graph-action { display: flex; flex: 1; justify-content: center; }
.study-list-actions { grid-area: actions; min-width: 0; padding-inline-end: 12px; }
.study-list-filters { grid-area: filters; min-width: 0; }
.study-list-toolbar > :empty { display: none; }
.study-list-back .page-history-back { margin: 0 0 6px; margin-inline-end: 10px; }
.study-list-title .page-header { margin: 0; }
.study-list-title h1 { margin: 0; }
.study-list-title .vocabulary-title { gap: 10px; }
.study-list-toolbar .vocabulary-practice-button {
  min-width: 0;
  min-height: 42px;
  padding: 8px 14px;
  font-size: .95rem;
  margin-inline-start: 0;
  white-space: nowrap;
}
.study-list-summary > .vocabulary-progress-summary.surface { margin-top: 10px; }
.study-list-summary .topic-vocabulary-open { padding: 4px 0; }
.study-list-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.study-list-actions > :is(.vocabulary-list-management, .vocabulary-import-actions) { display: contents; }
.study-list-actions > .vocabulary-folder-parent { flex-basis: 100%; margin: 0; }
.study-list-actions .collection-copy-button { margin: 0; }
.study-list-actions > p { flex-basis: 100%; margin: 0; }
.study-list-filters > :is(.search-field, .phrase-search, .study-list-vocabulary-filters) { margin: 10px 0 0; }
.study-list-vocabulary-filters { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.study-list-vocabulary-filters .vocabulary-database-search { margin: 0; min-width: 0; }
.study-list-vocabulary-filters .vocabulary-browse-controls { flex-wrap: nowrap; align-items: center; margin: 0; gap: 8px; }
.study-list-vocabulary-filters .vocabulary-browse-controls > label { position: relative; flex: 1 1 0; min-width: 0; }
.study-list-vocabulary-filters .vocabulary-icon-select > svg { position: absolute; inset-inline-start: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.study-list-vocabulary-filters .vocabulary-browse-controls select { width: 100%; min-width: 0; max-width: 100%; min-height: 44px; padding-inline-start: 32px; text-overflow: ellipsis; }
.study-list-vocabulary-filters .vocabulary-search-toggle { flex: none; width: 44px; min-width: 44px; height: 44px; padding: 0; }
.study-list-vocabulary-filters .vocabulary-search-toggle[aria-expanded="true"] { color: var(--accent-ink); background: var(--accent-soft); }
.study-list-rows { margin-top: 12px; }
.study-list-toolbar[data-compact="true"] .study-list-actions,
.study-list-toolbar[data-compact="true"] .study-list-back .page-history-back > span,
.study-list-toolbar[data-compact="true"] .study-list-title .lede,
.study-list-toolbar[data-compact="true"] .study-list-summary :is(h2, .reader-learning-track, .topic-familiarity-track) { display: none; }
.study-list-toolbar[data-compact="true"] .study-list-back .page-history-back { margin-block: 0; }
.study-list-toolbar[data-compact="true"] .study-list-title h1 {
  font-size: clamp(1rem, 2.3vw, 1.25rem);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.study-list-toolbar[data-compact="true"] .study-list-title .list-title-button {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.study-list-toolbar[data-compact="true"] .study-list-title .vocabulary-list-art {
  width: 30px; height: 30px; flex-basis: 30px; border-radius: 8px; font-size: 17px;
}
.study-list-toolbar[data-compact="true"] .study-list-title .vocabulary-list-art svg { width: 17px; height: 17px; }
.study-list-toolbar[data-compact="true"] .study-list-title .icon-button { display: none; }
.study-list-toolbar[data-compact="true"] .study-list-summary > .vocabulary-progress-summary.surface {
  margin: 0; margin-inline-start: 8px; padding: 5px 8px; border-radius: 8px; box-shadow: none; white-space: nowrap;
}
.study-list-toolbar[data-compact="true"] .study-list-summary .topic-vocabulary-open { padding: 0; }
.study-list-toolbar[data-compact="true"] .vocabulary-practice-button { min-height: 36px; padding: 6px 10px; }
.study-list-toolbar[data-compact="true"] .study-list-filters :is(.search-field, .phrase-search, .study-list-vocabulary-filters) { margin-top: 6px; }
.study-list-toolbar[data-compact="true"] .study-list-filters .search-field { padding-block: 2px; }
.study-list-toolbar[data-compact="true"] .study-list-filters .search-field input { min-height: 38px; }
.study-list-toolbar[data-compact="true"] .vocabulary-browse-controls label > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.vocabulary-familiarity-popup .study-list-toolbar { top: 0; background: var(--surface); padding-inline: clamp(12px, 2vw, 20px); }
.vocabulary-familiarity-popup .study-list-rows { margin: 0; padding-inline: clamp(12px, 2vw, 20px); }

@container (max-width: 570px) {
  .study-list-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .study-list-actions > button,
  .study-list-actions > :is(.vocabulary-list-management, .vocabulary-import-actions) > button {
    min-height: 40px; padding: 5px 8px; font-size: .8rem; white-space: normal;
  }
  .study-list-actions > :is(p, .vocabulary-folder-parent) { grid-column: 1 / -1; }
  .study-list-vocabulary-filters .vocabulary-browse-controls > label { flex: 1 1 0; min-width: 0; }
  .study-list-vocabulary-filters .vocabulary-browse-controls select { width: 100%; }
  .study-list-title h1 { font-size: clamp(1.15rem, 4vw, 1.65rem); }
}
@container (max-width: 360px) {
  .study-list-toolbar[data-compact="true"] .vocabulary-list-art { display: none; }
  .study-list-practice .vocabulary-practice-button svg { display: none; }
}
.study-list-summary .flashcard-learning-progress { margin: 0; }
.study-list-toolbar[data-compact="true"] .flashcard-learning-progress :is(summary > span, .flashcard-dimension-progress) { display: none; }
.study-list-toolbar[data-compact="true"] .flashcard-learning-progress summary { display: block; }
.study-list-toolbar[data-compact="true"] .flashcard-learning-progress summary::-webkit-details-marker { display: none; }

@media (max-width: 600px) {
  .study-list-rows.surface { padding-inline: 12px; }
}

.shared-content-page { width:min(100%,1120px); margin-inline:auto; padding:clamp(12px,3vw,28px); }
.shared-content-page .shared-theme-toggle { width:44px; height:44px; background:var(--surface); color:var(--text); border:1px solid var(--border); }
.shared-content-page a.topic-activity { text-decoration:none; color:var(--text); }
.shared-content-page [data-primary-step] .support-activity-action {
    display:grid;
    position:absolute;
    inset-inline-end:14px;
    inset-block-start:50%;
    transform:translateY(-50%);
}
.shared-content-account { margin-block:20px; }
.shared-content-collection { margin-block:12px; padding:clamp(14px,3vw,24px); }
.shared-content-collection ul { list-style:none; padding:0; margin:0; }
.shared-content-collection li {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr) minmax(0,2fr);
    gap:8px 16px;
    padding:12px 0;
    border-bottom:1px solid var(--border);
    overflow-wrap:anywhere;
}
@media (max-width:520px) {
    .shared-content-collection li { grid-template-columns:1fr; gap:4px; }
}
.custom-content-bundle-form,
.custom-content-bundle-form label { display:grid; gap:8px; }
.custom-content-bundle-form { gap:16px; }
.reader-popup-heading .popup-back { flex: none; margin-inline-end: 4px; }

.content-guidelines { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; margin:20px 0; }
.content-guidelines .guideline-option { width:100%; min-width:0; display:flex; flex-direction:column; align-items:stretch; gap:9px; text-align:left; padding:18px; border:2px solid var(--border); border-radius:16px; background:var(--surface); color:var(--text); min-height:116px; }
.content-guidelines .guideline-option.selected { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.guideline-title {display:flex; align-items:center; justify-content:space-between; gap:8px; font-weight:700;}
.guideline-option small {font-weight:400; line-height:1.45; color:var(--muted);}
.guideline-notices {font-size:.85rem; line-height:1.5; color:var(--muted);}
@media(max-width:500px) {.content-guidelines {grid-template-columns:1fr;} .content-guidelines .guideline-option {min-height:90px;}}

.trademark-notice {font-size:.78rem; line-height:1.5; color:var(--muted); margin:24px 0 8px;}
.comic-welcome .trademark-notice {color:inherit; opacity:.8;}

/* Each Content activity becomes usable independently as its inputs arrive. */
.home-feature-section[data-preparing="true"] .topic-activity-row:not([inert]) .topic-activity:not(:disabled) {opacity:1;filter:none;cursor:pointer;}
.home-feature-section[data-preparing="true"] .topic-activity-row:not([inert]) .topic-activity:not(:disabled)::after {display:none;}
.library-creation-row {display:flex;justify-content:flex-end;margin:1.5rem 0;}

.own-content-page {container:discovery-layout / inline-size;}

.flashcard-dimension-heading { display:flex; align-items:center; justify-content:center; gap:.45rem; }

.flashcard-setup-progress-controls {display:flex;align-items:center;justify-content:center;gap:10px;width:100%;}
.flashcard-setup-progress-controls .flashcard-word-count {width:auto;min-width:0;}
button.flashcard-progress-trigger {padding:0;min-width:0;border:0;background:transparent;color:var(--text);font-variant-numeric:tabular-nums;}
button.flashcard-progress-trigger[aria-expanded="true"] {background:transparent;color:var(--text);}
@media (hover: hover) and (pointer: fine) { button.flashcard-progress-trigger:hover {background:transparent;color:var(--text);} }
button.flashcard-progress-trigger[aria-expanded="true"] .flashcard-progress-badge {border-color:hsl(var(--progress-hue) 70% 45% / .5);}
.flashcard-dimension-row[data-enabled="false"] {opacity:.5;}
.flashcard-progress-popover {text-align:start;}
.flashcard-progress-popover .flashcard-learning-progress {margin:0;}

/* Word study setup */
.study-welcome.word-study-setup { min-height: 0; align-items: stretch; justify-content: flex-start; gap: 16px; text-align: start; }
.word-study-setup-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.word-study-setup-heading h2 { margin: 0; font-size: clamp(1.5rem, 3.5vw, 2rem); line-height: 1.2; letter-spacing: -.025em; }
.flashcard-activity-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.flashcard-activity-option {
    --choice-color: #ba8529; position: relative; display: grid; grid-template-rows: auto 1fr;
    justify-items: start; align-content: start; gap: 8px; min-width: 0; padding: 16px;
    border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface-subtle); color: var(--text); cursor: pointer;
}
.flashcard-activity-option[data-audio="true"] { --choice-color: #9275c7; }
.flashcard-activity-option:has(:checked) { border-color: var(--choice-color); box-shadow: inset 0 0 0 1px var(--choice-color); background: color-mix(in srgb, var(--choice-color) 12%, var(--surface)); }
.flashcard-activity-option:has(:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; }
.flashcard-activity-option:has(:disabled) { cursor: default; }
.flashcard-activity-option input { position: absolute; inset-block-start: 12px; inset-inline-end: 12px; accent-color: var(--choice-color); }
.flashcard-activity-option img { width: min(75%, 100px); height: 58px; object-fit: contain; }
.flashcard-activity-option strong { font-size: clamp(.92rem, 2vw, 1.06rem); line-height: 1.25; }
.flashcard-setup-skills { padding-block: 4px 16px; border-bottom: 1px solid var(--border); }
.flashcard-setup-skills h3 { margin: 0 0 9px; font-size: .9rem; color: var(--text-secondary); }
.flashcard-setup-skills .flashcard-mode-toggles { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%, 108px),1fr)); gap: 8px; }
.flashcard-setup-skills .flashcard-mode-toggle { justify-content: flex-start; width: 100%; min-height: 44px; padding: 8px; gap: 6px; border-radius: 10px; font-size: .86rem; }
.flashcard-skill-check { display: inline-flex; margin-inline-start: auto; }
.word-study-setup .flashcard-setup-progress-controls { flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.word-study-setup .flashcard-autoplay { margin: 0; padding: 7px 10px; min-height: 44px; font-size: .8rem; }
.flashcard-session .flashcard-setup-status { align-self: center; font-size: .86rem; text-align: center; }
.flashcard-setup-status:not(:has([data-active="true"])) { display: none; }
.flashcard-session .study-scene:has(.flashcard-activity-options) > .study-dock { width: 100%; border: 0; padding: 0; background: transparent; box-shadow: none; }
.flashcard-session .study-scene:has(.flashcard-activity-options) .flashcard-begin { width: 100%; min-width: 0; min-height: 50px; padding: 12px; }
@media (max-width: 480px) {
    .flashcard-activity-options { gap: 8px; }
    .flashcard-activity-option { padding: 12px; }
    .flashcard-activity-option img { height: 46px; }
    .flashcard-setup-skills .flashcard-mode-toggles { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

/* Signed-out profile links retain the identity behind the invitation. */
.reader-popup.profile-invite {width:min(480px,calc(100vw - 24px))}
.profile-invite > .reader-popup-heading {border-bottom:0;padding-bottom:8px}
.profile-invite > .reader-popup-heading h2 {position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}
.profile-invite-logo {display:flex;align-items:center;margin-inline-end:auto}
.profile-invite-logo .wordmark {width:130px;height:36px}
.profile-invite > .reader-popup-body {display:grid;gap:22px;padding-top:8px}
.profile-invite-intro {margin:0;font-size:1.15rem;line-height:1.5}
.profile-invite-summary {display:flex;align-items:center;gap:16px;padding:20px;min-width:0}
.profile-invite-summary strong {overflow-wrap:anywhere;font-size:1.2rem}
.profile-invite-summary .avatar {flex:none;width:52px;height:52px;font-size:1.4rem}
.profile-invite-message {margin:0;color:var(--muted);line-height:1.5}
.profile-invite-actions {display:grid;gap:10px}
.profile-invite-actions button {width:100%}

.profile-name-row {display:grid;gap:4px;margin-block:18px}
button.profile-name-edit {display:inline-flex;align-items:center;justify-self:start;gap:10px;background:transparent;border:0;box-shadow:none;padding:6px 8px;margin-inline-start:-8px;font-size:1.15rem;color:var(--text)}
button.profile-name-edit:active {background:color-mix(in srgb,currentColor 8%,transparent)}
@media (hover: hover) and (pointer: fine) { button.profile-name-edit:hover {background:color-mix(in srgb,currentColor 8%,transparent)} }
.profile-sign-out {margin-top:18px}
.change-name-actions {justify-content:flex-end;margin-top:24px;gap:10px}
button.vocabulary-points-button {display:inline;padding:0;border:0;border-radius:4px;min-height:0;background:transparent;box-shadow:none;color:inherit;font:inherit;line-height:inherit;text-align:inherit}
button.vocabulary-points-button:active {background:color-mix(in srgb,currentColor 8%,transparent);text-decoration:underline;text-underline-offset:3px}
@media (hover: hover) and (pointer: fine) { button.vocabulary-points-button:hover {background:color-mix(in srgb,currentColor 8%,transparent);text-decoration:underline;text-underline-offset:3px} }

/* Image placeholders share the artwork's bounds, including its clipped corners. */
/* Safari can defer an offscreen carousel image for the entire visit. Its
   placeholder should stay visible without asking the renderer for frames. */
.image-loading {position:absolute;inset:0;display:grid;place-items:center;overflow:hidden;border-radius:inherit;pointer-events:none;background:linear-gradient(105deg,transparent 25%,color-mix(in srgb,var(--text) 5%,transparent) 50%,transparent 75%),var(--surface-subtle);color:var(--text-secondary);}
.image-loading-ai {display:grid;place-items:center;opacity:.5;animation:image-generation-fade 2.8s ease-in-out 3;}
@keyframes image-generation-fade {0%,100% {opacity:.25;}50% {opacity:.5;}}
img[data-image-loading="true"] {opacity:0;animation:none;}
.reported-word-image:has(>.image-loading):not(:has(>img)) {aspect-ratio:1;}
.reported-word-image {border-radius:inherit;}
.word-illustration-placeholder:not(.word-illustration-error) {position:relative;min-height:0;padding:0;aspect-ratio:1;border-radius:inherit;}
.word-illustration-placeholder.passage-loading,.passage-illustration .reported-word-image:has(>.image-loading):not(:has(>img)) {aspect-ratio:3/2;}
.reader-story-image>.reported-word-image {aspect-ratio:3/2;}
.reader-story-image-placeholder[data-loading="true"] {position:relative;}
.guided-image-placeholder {position:relative;aspect-ratio:3/2;min-height:0;}
.guided-image>.reported-word-image {aspect-ratio:3/2;overflow:hidden;border-radius:14px;}
.guided-image>.reported-word-image>img {width:100%;height:100%;object-fit:contain;}
.setup-content-art,.topic-cover-loading {position:relative;overflow:hidden;}
.topic-card-art>.image-loading,.topic-cover-loading>.image-loading,.setup-content-art>.image-loading {z-index:1;}
:is(.topic-card-art,.topic-cover-loading):has(>img[data-art-state="ready"],>img[data-art-state="error"])>.image-loading {display:none;}
.meaning-images .meaning-image {position:relative;border-radius:12px;}
.meaning-images[data-interactive="true"] .reported-word-image:has(>.image-loading):not(:has(>img)) {aspect-ratio:1;max-height:min(140px,18dvh);}
@media(prefers-reduced-motion:reduce) {.image-loading-ai {animation:none;}}

:is(.reader-word-image, .vocabulary-entry-images) .word-illustration:has(.triplet-loading) {width:100%;max-width:600px;background:transparent;overflow:visible;}
.word-illustration-placeholder.triplet-loading {display:flex;flex-direction:row;aspect-ratio:auto;gap:12px;}
.triplet-loading .meaning-image {aspect-ratio:1;max-height:min(140px,18dvh);}
.triplet-loading .meaning-image > .reported-word-image {position:absolute;inset:0;height:100%;}
.passage-illustration>.reported-word-image {aspect-ratio:3/2;}

.comic-portrait {position:relative;}
.story-image-regenerate[data-regenerating="true"] .shell-icon {animation:image-generation-fade 2.8s ease-in-out infinite;opacity:.5;}
@media(max-width:600px) {.word-illustration-placeholder.triplet-loading {gap:6px;}}
@media(prefers-reduced-motion:reduce) {.story-image-regenerate[data-regenerating="true"] .shell-icon {animation:none;}}

.meaning-images:not([data-interactive="true"]) .reported-word-image:has(>.image-loading):not(:has(>img)) {height:clamp(90px,20dvh,190px);aspect-ratio:auto;}
@media(max-width:600px) {.meaning-images:not([data-interactive="true"]) .reported-word-image:has(>.image-loading):not(:has(>img)) {height:clamp(80px,16dvh,145px);}}
/* Keep session totals and skill headings visible while only vocabulary scrolls. */
.anchored-popover.flashcard-progress-popover { width: min(680px, calc(100vw - 24px)); overflow: hidden; }
.anchored-popover.flashcard-progress-popover:is(.open,:popover-open) { display: flex; flex-direction: column; }
.flashcard-progress-popover > .anchored-popover-heading { flex: none; }
.flashcard-progress-popover .anchored-popover-heading:has(.flashcard-progress-graph-action) h2 { flex: 0 1 auto; }
.flashcard-progress-graph-action { display: flex; flex: 1; justify-content: center; min-width: max-content; }
.flashcard-progress-graph-action .session-history-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button.flashcard-progress-more { width: 100%; margin-top: 8px; justify-content: center; }
.flashcard-session-progress, .flashcard-score-table { display: flex; flex-direction: column; min-height: 0; }
.flashcard-session-progress { flex: 1 1 auto; align-items: stretch; gap: 12px; margin: 0; overflow: hidden; }
.flashcard-score-table { flex: 1 1 auto; overflow: hidden; }
.flashcard-session-counts { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; flex: none; }
.flashcard-session-count { padding: 6px 10px; border-radius: 999px; background: var(--surface-hover); font-size: .8rem; font-weight: 600; }
.flashcard-score-fixed { flex: none; }
.flashcard-score-words { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-gutter: stable; flex: 1 1 auto; min-height: 0; }
.flashcard-score-row { display: grid; grid-template-columns: minmax(90px,2.5fr) repeat(5,minmax(0,1fr)); align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.flashcard-score-fixed { padding-right: 10px; }
.flashcard-score-head { padding-top: 0; border-bottom: 0; }
.flashcard-score-head > span { display: flex; justify-content: center; }
.flashcard-score-overall { padding-top: 4px; }
.flashcard-score-cell { display: grid; gap: 6px; text-align: center; font-size: .78rem; font-variant-numeric: tabular-nums; }
.flashcard-score-cell .reader-learning-track { height: 5px; }
.flashcard-score-table [data-enabled="false"] { opacity: .5; }
@media (max-width: 480px) {
    .anchored-popover.flashcard-progress-popover { padding: 12px; }
    .flashcard-score-row { grid-template-columns: minmax(76px,1.8fr) repeat(5,minmax(0,1fr)); gap: 4px; }
    .flashcard-score-cell { font-size: .65rem; }
    .flashcard-score-row .flashcard-session-word > strong { font-size: .95rem; }
    .flashcard-score-row .flashcard-session-word > span { font-size: .7rem; }
}

.comic-stage:has(.guided-step-trail) > .xp-celebration-host > button.xp-celebration {
  position:absolute;
  inset:calc(var(--guided-trail-bottom, calc(max(16px, env(safe-area-inset-top)) + 86px)) + 8px) 0 auto;
  margin:0 auto;
  transform-origin:top center;
}
/* A save failure is a surface, even when its message describes an offline connection. */
.study-status.flashcard-save-error, .study-status.error:has(.offline-notice) { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.study-status.flashcard-save-error { display: grid; gap: 12px; width: min(440px, calc(100% - 32px)); max-height: calc(var(--study-height, 100dvh) - 100px); overflow-y: auto; margin: 0; padding: 16px; font-size: .85rem; line-height: 1.5; box-shadow: var(--shadow-raised); overflow-wrap: anywhere; }
.flashcard-save-error > strong { font-size: .95rem; }
.flashcard-save-error > .flashcard-unsaved-count { margin: 0; }
.flashcard-save-error > .offline-notice { color: var(--text-secondary); }
.flashcard-save-actions { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
.flashcard-save-actions > button { flex: 1 1 auto; min-height: 42px; padding: 10px 14px; font-size: .8rem; }

/* Shared familiarity/session matrix: compact score chips and stacked word metadata. */
.flashcard-score-chip, button.flashcard-score-chip { display:inline-flex; align-items:center; justify-content:center; justify-self:center; min-width:0; width:100%; max-width:58px; min-height:32px; padding:6px 3px; border:0; border-radius:8px; background:hsl(var(--level-hue) 78% 48% / var(--retention-opacity,.15)); color:light-dark(var(--learning-ink-light,var(--text)),var(--learning-ink-dark,var(--text))); font-size:.85rem; font-weight:650; font-variant-numeric:tabular-nums; box-shadow:none; }
.flashcard-score-chip[data-rated="false"] { background:var(--surface-subtle); color:var(--text-secondary); }
@media (hover: hover) and (pointer: fine) { button.flashcard-score-chip:hover { box-shadow:inset 0 0 0 1px var(--text-secondary); } }
.flashcard-score-meaning { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.flashcard-score-reading { color:var(--text-secondary); }
.flashcard-progress-search { flex:none; min-width:0; width:100%; }
.vocabulary-familiarity-popup > .reader-popup-body { display:flex; flex-direction:column; min-height:0; overflow:hidden; padding:16px; gap:14px; }
.vocabulary-familiarity-popup .flashcard-session-progress { overflow:hidden; }
.vocabulary-familiarity-popup .flashcard-score-words { max-height:none; }
.familiarity-table-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex:none; }
.familiarity-table-toolbar > strong { min-width:0; overflow-wrap:anywhere; }
.familiarity-table-toolbar button { flex:none; }
@media(max-width:480px) {
    .flashcard-score-chip, button.flashcard-score-chip { font-size:.75rem; min-height:32px; }
    .vocabulary-familiarity-popup > .reader-popup-body { padding:12px; }
}

/* An immersive picture canvas with a bottom composer and saved observations. */
/* The describe dialog repaints theme colours for its dark stage. This wrapper
   captures the app theme first, so word bubbles inside keep the standard look. */
.describe-theme {display:contents;--page-text:var(--text);--page-text-secondary:var(--text-secondary);--page-muted:var(--muted);--page-surface:var(--surface);--page-surface-subtle:var(--surface-subtle);--page-border:var(--border);--page-border-strong:var(--border-strong);--page-accent:var(--accent);--page-accent-soft:var(--accent-soft);--page-accent-text:var(--accent-text);--page-highlight:var(--highlight);--page-xp:var(--xp);--page-xp-soft:var(--xp-soft);}
.describe-experience :is(.reader-word-bubble,.anchored-popover) {--text:var(--page-text);--text-secondary:var(--page-text-secondary);--muted:var(--page-muted);--surface:var(--page-surface);--surface-subtle:var(--page-surface-subtle);--border:var(--page-border);--border-strong:var(--page-border-strong);--accent:var(--page-accent);--accent-soft:var(--page-accent-soft);--accent-text:var(--page-accent-text);--highlight:var(--page-highlight);--xp:var(--page-xp);--xp-soft:var(--page-xp-soft);color:var(--text);backdrop-filter:none;-webkit-backdrop-filter:none;}
dialog.describe-experience {position:fixed;inset:0;margin:0;width:100%;max-width:none;height:100dvh;max-height:100dvh;border:0;border-radius:0;padding:0;display:flex;flex-direction:column;background:#16171b;color:#fff;overflow:auto;overscroll-behavior:contain;isolation:isolate;--text:#fff;--text-secondary:#c6c6cd;--muted:#c6c6cd;--surface:rgba(23,24,29,.86);--surface-subtle:rgba(255,255,255,.08);--border:rgba(255,255,255,.18);--border-strong:rgba(255,255,255,.35);--accent:#d6b0ff;--accent-soft:rgba(214,176,255,.18);--accent-text:#202127;--highlight:rgba(214,176,255,.2);--xp:#e69aef;--xp-soft:rgba(230,154,239,.16);}
.describe-experience::backdrop {background:#16171b;}
.describe-background {position:absolute;inset:0;z-index:-1;overflow:hidden;pointer-events:none;}
.describe-background img {width:100%;height:100%;object-fit:cover;filter:var(--app-blur-filter, blur(36px) brightness(.48));transform:scale(1.1);}
.describe-background::after {content:"";position:absolute;inset:0;background:linear-gradient(180deg,rgba(0,0,0,.15),transparent 40%,rgba(0,0,0,.45));}
.describe-eyebrow {font-size:.65rem;letter-spacing:.13em;text-transform:uppercase;font-weight:700;color:var(--muted);}
.describe-success {color:#54b68a;display:flex;gap:6px;align-items:center;}
.describe-header {display:flex;align-items:center;justify-content:space-between;gap:16px;width:100%;position:relative;z-index:2;margin:0 auto;padding:max(10px,env(safe-area-inset-top)) max(20px,env(safe-area-inset-right)) 8px max(24px,env(safe-area-inset-left));}
.describe-header>div:first-child {min-width:0;}
.describe-header h1 {font-size:1rem;margin:3px 0 0;line-height:1.35;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.describe-experience button:not(:is(.reader-word-bubble,.anchored-popover) *) {color:#fff;}
.describe-experience button:not(.secondary):not(.icon-button):not(.describe-history-item):not(.explanation-target-link):not(.describe-segment):not(.speech-button):not(.reader-word):not(.inline-reader-retry):not(:is(.reader-word-bubble,.anchored-popover) *) {background:#f6f4fa;color:#202127;}
.describe-header button,.describe-experience .secondary:not(:is(.reader-word-bubble,.anchored-popover) *) {background:rgba(20,21,25,.55);border:1px solid var(--border);box-shadow:none;backdrop-filter:blur(16px);}
.describe-header .icon-button {flex-shrink:0;}
.describe-trail {display:flex;gap:8px;margin:0 20px 8px;padding:4px 12px;border-radius:999px;background:rgba(20,21,25,.6);border:1px solid var(--border);}
.describe-segments {display:flex;align-items:center;gap:5px;flex:1;min-width:0;padding:0;}
.describe-page-marker {display:flex;align-items:center;color:#d6b0ff;margin-right:3px;}
/* One segment per question, tinted by the XP it has earned; tap to open it. */
.describe-segment {flex:1;min-width:0;height:17px;padding:6px 0;margin:0;border:0;border-radius:999px;background:transparent;box-shadow:none;cursor:pointer;}
.describe-segment::before {content:"";display:block;width:100%;height:5px;border-radius:999px;background:#d6b0ff;opacity:.4;transition:opacity .2s,height .2s,margin .2s;}
.describe-segment[data-answered="true"]::before {background:#e4b16c;opacity:.85;}
.describe-segment[data-xp="1"]::before,.describe-segment[data-xp="2"]::before {background:#8ce4b7;opacity:.7;}
.describe-segment[data-xp="3"]::before {background:#8ce4b7;opacity:1;}
.describe-segment[data-current="true"]::before {height:7px;margin-top:-1px;opacity:1;box-shadow:0 0 0 2px rgba(255,255,255,.55);}
.describe-page-marker[data-complete="true"] {color:#8ce4b7;}
/* The picture fills the stage and the question panel sits over its bottom. */
.describe-stage {flex:1;min-height:0;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;gap:8px;padding:0 20px max(14px,env(safe-area-inset-bottom));}
.describe-picture {grid-column:1;grid-row:1 / -1;position:relative;min-height:0;margin:0;overflow:hidden;}
/* Inset and centred, so the question card and answer panel cover less of it. */
.describe-picture img {position:absolute;inset:clamp(36px,12%,130px) 0;display:block;width:100%;height:calc(100% - 2 * clamp(36px,12%,130px));object-fit:contain;border-radius:14px;}
.describe-question-card {grid-column:1;grid-row:1;justify-self:center;align-self:start;position:relative;z-index:1;width:min(100%,760px);padding:8px 14px 9px 10px;background:rgba(20,21,25,.8);color:#fff;--accent:#fff;--accent-soft:rgba(255,255,255,.12);--highlight:rgba(255,255,255,.16);border:1px solid var(--border);border-radius:18px;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);box-shadow:0 10px 30px #0004;}
.describe-panel {position:relative;z-index:1;min-width:0;min-height:0;display:flex;flex-direction:column;background:rgba(20,21,25,.78);border:1px solid var(--border);border-radius:22px;backdrop-filter:blur(20px);-webkit-backdrop-filter:blur(20px);box-shadow:0 12px 40px #0004;}
.describe-panel-title {display:flex;align-items:center;gap:8px;margin:0;font-size:.85rem;font-weight:600;color:#dedee5;}
.describe-panel-body {flex:1 1 auto;min-height:0;display:flex;flex-direction:column;}
/* Keep focus rings and the microphone outline clear of the panel edge. */
.describe-panel-content {min-height:0;overflow:hidden;padding:3px;margin:-3px;display:flex;flex-direction:column;}
/* The question panel never shrinks below its content; on short screens the page scrolls. */
.describe-compose {grid-column:1;grid-row:3;align-self:end;width:min(100%,760px);min-height:auto;justify-self:center;padding:10px 14px 12px;}
.describe-compose .describe-panel-content {gap:8px;}
.describe-form {display:grid;gap:8px;margin:0;}
.describe-form label {font-size:.85rem;font-weight:600;color:#dedee5;}
.describe-form textarea {width:100%;min-width:0;min-height:48px;max-height:140px;font-size:16px;line-height:1.4;border-radius:14px;background:rgba(0,0,0,.28);border:1px solid rgba(255,255,255,.35);color:#fff;padding:10px 12px;resize:vertical;}
.describe-form textarea::placeholder {color:#b7b7c0;}
.describe-form textarea:disabled {opacity:.75;-webkit-text-fill-color:#fff;}
/* The mic matches the field's height; the automatic-mic toggle sits under it. */
.describe-answer-row .guided-mic-button {width:44px;height:44px;}
.describe-answer-row .guided-microphone meter {display:none;}
.describe-answer-row .recording-auto-button {grid-row:2;}
.describe-actions {display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;margin-top:2px;}
.describe-submit {display:inline-flex;align-items:center;gap:6px;}
.describe-feedback {font-size:.9rem;border-left:3px solid #e4b16c;padding-left:10px;margin:0;line-height:1.45;}
.describe-question-nav {display:flex;align-items:center;gap:2px;padding:2px;border-radius:999px;background:rgba(20,21,25,.55);border:1px solid var(--border);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);}
.describe-question-nav .icon-button {width:32px;height:32px;min-width:32px;min-height:32px;padding:0;display:grid;place-items:center;background:transparent;border:0;border-radius:50%;}
@media (hover: hover) and (pointer: fine) { .describe-question-nav .icon-button:not(:disabled):hover {background:rgba(255,255,255,.1);} }
.describe-question-nav .icon-button:disabled {opacity:.35;}
.describe-question-count {min-width:7.5em;text-align:center;font-size:.85rem;font-weight:600;color:#dedee5;font-variant-numeric:tabular-nums;}
.describe-question-line {display:flex;align-items:center;gap:8px;}
.describe-question-line .speech-button,.describe-question-audio {flex-shrink:0;}
.describe-question-text {flex:1;min-width:0;margin:0;font-size:1.2rem;font-weight:650;line-height:1.35;overflow-wrap:anywhere;}
.describe-question-translation {margin:2px 0 0;padding-inline-start:44px;font-size:.82rem;line-height:1.35;color:var(--muted);}
.describe-question-line .speech-button {margin:0;}
.describe-question-audio .speech-button:is(:focus-visible) {background:rgba(255,255,255,.2);color:#fff;}
@media (hover: hover) and (pointer: fine) { .describe-question-audio .speech-button:is(:hover,:focus-visible) {background:rgba(255,255,255,.2);color:#fff;} }
/* Analysis must not dim the question while its word support is streaming. */
.describe-question-text .reader-unprocessed:not(:is(.reader-word-bubble,.anchored-popover) *) {color:inherit;opacity:1;}

.describe-xp-note {font-size:.75rem;color:var(--muted);}
.describe-edit {display:inline-flex;align-items:center;gap:6px;}
.describe-actions .describe-complete-actions {margin:0;margin-inline-start:auto;}
.describe-scores {display:flex;flex-wrap:wrap;align-items:center;gap:6px 14px;}
.describe-score-overall {display:flex;align-items:baseline;gap:6px;}
.describe-score-overall strong {font-size:1.6rem;line-height:1;font-variant-numeric:tabular-nums;}
.describe-score-overall>span:not(.describe-xp-chip) {color:var(--muted);font-weight:600;}
.describe-xp-chip {align-self:center;margin-inline-start:8px;padding:3px 10px;border-radius:999px;border:1px solid color-mix(in srgb,var(--xp) 50%,transparent);background:var(--xp-soft);color:var(--xp);font-size:.8rem;font-weight:700;white-space:nowrap;}
/* Target-language words open the word bubble: accent links in feedback, quiet
   dotted underlines in the question and example answer. */
.describe-experience button.explanation-target-link:not(:is(.reader-word-bubble,.anchored-popover) *) {color:var(--accent);}
.describe-example {display:grid;gap:4px;}
.describe-example-text {margin:0;font-size:1.05rem;line-height:1.6;overflow-wrap:anywhere;}
.describe-score-list {display:flex;flex-wrap:wrap;gap:6px;margin:0;}
.describe-score {display:flex;align-items:baseline;gap:6px;padding:4px 10px;border-radius:999px;background:rgba(255,255,255,.07);font-size:.8rem;}
.describe-score dt {color:var(--muted);}
.describe-score dd {margin:0;font-weight:700;font-variant-numeric:tabular-nums;}
/* Scores share one red-yellow-green scale: 1-2, 3, 4-5 (averages: under 2.5, under 3.5, above). */
.describe-score[data-level="high"] dd,.describe-score-overall[data-level="high"] strong {color:#8ce4b7;}
.describe-score[data-level="mid"] dd,.describe-score-overall[data-level="mid"] strong {color:#f5d66f;}
.describe-score[data-level="low"] dd,.describe-score-overall[data-level="low"] strong {color:#ff9b8f;}
/* The graded answer: underlines are green (good), red (fix) or yellow (could be better). */
.describe-annotated {display:grid;gap:6px;}
.describe-answer-label {font-size:.75rem;font-weight:600;color:var(--muted);}
.describe-annotated-text {margin:0;padding:8px 12px;border-radius:14px;background:rgba(0,0,0,.28);border:1px solid rgba(255,255,255,.2);font-size:1.05rem;line-height:1.75;white-space:pre-wrap;overflow-wrap:anywhere;}
.describe-mark {--mark:#f5d66f;cursor:pointer;border-radius:4px;text-decoration:underline;text-decoration-color:var(--mark);text-decoration-thickness:2px;text-underline-offset:4px;transition:background .15s;}
.describe-mark[data-kind="good"] {--mark:#8ce4b7;}
.describe-mark[data-kind="error"] {--mark:#ff8a80;}
.describe-mark[aria-pressed="true"] {background:color-mix(in srgb,var(--mark) 24%,transparent);}
@media (hover: hover) and (pointer: fine) { .describe-mark:hover {background:color-mix(in srgb,var(--mark) 24%,transparent);} }
.describe-note {--mark:#f5d66f;padding:7px 12px;border-radius:12px;border-inline-start:3px solid var(--mark);background:rgba(255,255,255,.06);font-size:.88rem;line-height:1.45;animation:describe-note-in .2s ease both;}
.describe-note[data-kind="good"] {--mark:#8ce4b7;}
.describe-note[data-kind="error"] {--mark:#ff8a80;}
.describe-note strong {display:block;margin-bottom:2px;font-size:.75rem;color:var(--mark);}
.describe-note p {margin:0;}
@keyframes describe-note-in {from{opacity:0;transform:translateY(-3px)}to{opacity:1;transform:none}}
.describe-feedback[data-accepted="true"] {border-color:#8ce4b7;}
.describe-welcome {display:flex;flex-direction:column;align-items:center;text-align:center;gap:18px;max-width:520px;margin:8dvh auto;padding:28px;}
.describe-welcome h2 {font-size:1.9rem;line-height:1.2;margin:0;}
.describe-welcome p {line-height:1.6;margin:0;}
.describe-welcome-picture {position:absolute;inset:0;width:100%;height:100%;object-fit:contain;z-index:-1;pointer-events:none;}
.describe-welcome-overlay {background:rgba(20,21,25,.65);border:1px solid var(--border);border-radius:28px;backdrop-filter:blur(22px);box-shadow:0 18px 70px #0003;}
.describe-welcome-icon {display:grid;place-items:center;width:80px;height:80px;border-radius:24px;background:rgba(255,255,255,.08);}
.describe-welcome button {display:flex;align-items:center;justify-content:center;gap:12px;}
.describe-complete .describe-panel-content {display:grid;justify-items:center;text-align:center;gap:10px;}
.describe-complete .describe-panel-title {font-size:1.05rem;color:#fff;}
.describe-complete .describe-panel-title svg {color:#8ce4b7;}
.describe-complete p {font-size:.9rem;margin:0;}
.describe-complete-actions {display:flex;flex-wrap:wrap;justify-content:center;gap:10px;margin-top:6px;}
.describe-error {position:relative;z-index:3;max-width:100%;margin:8px 24px;padding:12px;border-radius:14px;background:#472632;color:#fff;}
@media(max-width:760px){
 .describe-header {flex-wrap:wrap;padding: max(10px,env(safe-area-inset-top)) 12px 8px;}
 .describe-question-nav {order:3;width:100%;justify-content:space-between;}
 .describe-trail {margin:0 12px 8px;}
 .describe-stage {grid-template-rows:auto minmax(140px,1fr) auto;gap:8px;padding:0 12px max(12px,env(safe-area-inset-bottom));}
 .describe-picture img {inset:0;height:100%;}
 .describe-picture {grid-row:2;border-radius:0;}
 .describe-compose {grid-row:3;align-self:start;width:100%;padding:10px 12px;}
 .describe-question-card {width:100%;}
 .describe-welcome {margin:4dvh 16px;padding:24px;max-width:none;}
 .describe-welcome h2 {font-size:1.6rem;}
}

/* One shared column grid; the heading reserves the same scrollbar gutter as rows. */
.flashcard-session-counts {display:flex;flex-wrap:nowrap;gap:6px;width:100%;}
.flashcard-session-count {flex:1 1 0;min-width:0;text-align:center;white-space:nowrap;padding:6px;font-size:clamp(.65rem,2.4vw,.8rem);}
.flashcard-score-fixed {padding-right:0;overflow-y:hidden;scrollbar-gutter:stable;}
.flashcard-score-head > span {position:relative;min-width:0;}
.flashcard-skill-heading {display:grid;place-items:center;background:transparent;color:var(--muted);box-shadow:none;border:0;border-radius:8px;padding:6px;min-width:0;}
@media (hover: hover) and (pointer: fine) { .flashcard-skill-heading:hover {background:var(--surface-hover);color:var(--text);} }
button.flashcard-word-details {display:flex;flex-direction:column;align-items:flex-start;gap:4px;width:100%;min-width:0;padding:4px 0;border:0;background:transparent;color:var(--text);box-shadow:none;text-align:start;border-radius:6px;}
@media (hover: hover) and (pointer: fine) { button.flashcard-word-details:hover {background:var(--surface-hover);} }
.flashcard-word-details strong {font-size:1rem;}
.flashcard-word-details span {font-size:.8rem;font-weight:400;}
.flashcard-word-info {width:min(560px,calc(100vw - 24px));max-height:75dvh;overflow:auto;}
.flashcard-skill-name {width:max-content;max-width:calc(100vw - 24px);}
.flashcard-overall-help {max-width:270px;margin:0;line-height:1.5;color:var(--text-secondary);}

.workspace:has([data-list-page="true"]) .page-history-back-outer {display:none;}
.vocabulary-action-menu {display:grid;gap:4px;width:min(340px,calc(100vw - 24px));}
.vocabulary-action-menu > button {width:100%;text-align:start;justify-content:flex-start;background:transparent;color:var(--text);box-shadow:none;}
@media (hover: hover) and (pointer: fine) { .vocabulary-action-menu > button:hover {background:var(--surface-hover);} }
.vocabulary-action-triggers {display:flex;align-items:center;gap:8px;margin-block:10px;}
.vocabulary-action-triggers button {margin:0;}
.describe-preparation-details {display:grid;gap:14px;width:100%;padding:20px;border:1px solid var(--border);border-radius:20px;background:var(--surface);}
.describe-preparation-row {display:flex;justify-content:space-between;align-items:center;gap:12px;text-align:start;font-size:.9rem;}
.describe-preparation-row strong {color:var(--muted);font-size:.8rem;white-space:nowrap;}
.describe-preparation-details progress {width:100%;height:7px;accent-color:#69c49c;}
button.flashcard-session-count {display:block;width:auto;color:var(--muted);box-shadow:none;font-weight:600;justify-content:center;}
@media (hover: hover) and (pointer: fine) { button.flashcard-session-count:hover {background:var(--surface-subtle);} }
button.flashcard-session-count[aria-pressed="true"] {outline:2px solid var(--text);outline-offset:-2px;color:var(--text);}
.flashcard-score-cell[data-filter-match="true"] > :is(.flashcard-score-chip,.word-rating-picker) {box-shadow:inset 0 0 0 2px white;border-radius:8px;}
.reader-info-popover:has(.word-info-bubble) > .anchored-popover-heading {display:none;}
.reader-info-popover .reader-word-bubble[data-contained="true"] {position:static;width:100%;max-height:none;margin:0;padding:0;border:0;box-shadow:none;overflow:visible;background:transparent;backdrop-filter:none;}
.flashcard-word-info.reader-info-popover {width:min(390px,calc(100vw - 24px));}

.describe-header-actions {display:flex;align-items:center;gap:8px;flex-shrink:0;}
.describe-history-toggle {display:flex;align-items:center;gap:8px;font-size:.85rem;}
.describe-preparation-preview {width:100%;max-height:240px;object-fit:contain;border-radius:18px;}
.describe-history {max-width:900px;margin:24px auto;padding:0 24px 32px;}
.describe-history h2 {margin-bottom:8px;}
.describe-history-list {display:grid;gap:12px;margin-top:24px;}
.describe-history-item {width:100%;min-width:0;display:grid;grid-template-columns:120px minmax(0,1fr) auto;gap:20px;align-items:center;padding:12px;text-align:start;background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:20px;box-shadow:var(--shadow-sm);}
.describe-history-item[aria-current="true"] {border-color:var(--accent);}
.describe-history-item img,.describe-history-placeholder {width:120px;height:80px;object-fit:cover;border-radius:12px;background:var(--surface-subtle);}
.describe-history-placeholder {display:grid;place-items:center;}
.describe-history-item>span:not(.describe-history-placeholder) {display:grid;gap:8px;}
.describe-history-item small {font-weight:400;color:var(--muted);}
@media(max-width:600px) {
 .describe-history-toggle span {display:none;}
 .describe-history {padding:0 16px 24px;}
 .describe-history-item {grid-template-columns:96px minmax(0,1fr) auto;gap:12px;}
 .describe-history-item img,.describe-history-placeholder {width:96px;height:72px;}
}

/* ----- Quick-start funnel (/onboard): one question per page, sliding left and right ----- */
.onboard { position:relative; display:flex; flex-direction:column; align-items:center; min-height:100dvh; padding:0 max(20px,env(safe-area-inset-right)) max(40px,env(safe-area-inset-bottom)) max(20px,env(safe-area-inset-left)); background:radial-gradient(120% 60% at 50% -10%, var(--bg-accent), transparent 60%), var(--bg); overflow-x:clip; }
.onboard.onboard-reading { padding:0; min-height:100dvh; }
/* The landing page and the rest of onboarding scroll without a visible page scroll bar;
   lists inside keep theirs. */
html:has(#onboard) { scrollbar-width:none; }
html:has(#onboard)::-webkit-scrollbar { display:none; }
/* The header is fixed to the top of the window; onboard/header.js reserves its
   height as --onboard-header and raises a background once anything is beneath it. */
.onboard-topbar { position:fixed; z-index:30; top:0; left:max(clamp(12px, 3vw + 4px, 20px), env(safe-area-inset-left)); right:max(clamp(12px, 3vw + 4px, 20px), env(safe-area-inset-right)); display:flex; align-items:center; justify-content:space-between; gap:clamp(8px, 1.5vw + 2px, 12px); max-width:1040px; margin:0 auto; padding:max(clamp(8px, 1.6vw + 4px, 18px), env(safe-area-inset-top)) 0 clamp(6px, .8vw + 3px, 10px); }
/* Nearly opaque and never blurred: a blur would be redone for every frame of the
   pictures moving beneath it, which made scrolling the landing page stutter. */
.onboard-topbar::before { content:""; position:absolute; z-index:-1; inset:0 auto; left:50%; width:100vw; translate:-50% 0; border-bottom:1px solid var(--border); background:color-mix(in srgb, var(--bg) 97%, transparent); opacity:0; pointer-events:none; transition:opacity .25s ease; }
.onboard[data-header-raised] .onboard-topbar::before { opacity:1; }
.onboard:not(.onboard-reading)::before { content:""; flex:none; height:var(--onboard-header, 72px); }
.onboard-topbar .entry-logo { flex:0 1 132px; min-width:56px; }
/* The hero carries the wordmark itself; the header shows it from the second page on. */
/* On the landing page the header's logo waits until the big one goes beneath it. */
.onboard-topbar .entry-logo { transition:opacity .25s ease, visibility .25s; }
.onboard[data-step="hero"]:not([data-header-logo]) .onboard-topbar .entry-logo { opacity:0; visibility:hidden; }
@media (prefers-reduced-motion: reduce) { .onboard-topbar::before, .onboard-topbar .entry-logo { transition:none; } }
.onboard-topbar .wordmark { width:100%; max-width:132px; }
.onboard-topbar-actions { display:flex; align-items:center; gap:clamp(6px, 1vw + 2px, 8px); flex:none; }
.onboard-topbar .onboard-sign-in { min-height:44px; white-space:nowrap; }
.onboard-sign-in-short { display:none; }
@media (max-width:800px) {
  .onboard-topbar-actions .entry-language-display { justify-content:center; width:44px; height:44px; padding:0; border-radius:50%; }
  .onboard-topbar-actions .entry-language-display>span, .onboard-topbar-actions .entry-language-display>svg:last-child { display:none; }
  .onboard-topbar .onboard-sign-in { font-size:.8rem; }
}
/* The header tightens with the window (above); on a phone, "I already have an account"
   becomes "Sign in". */
@media (max-width:600px) {
  .onboard-sign-in-long { display:none; }
  .onboard-sign-in-short { display:inline; }
  .onboard-topbar .onboard-sign-in { padding-inline:12px; }
}
.onboard-stage { position:relative; display:grid; width:100%; flex:1; }
.onboard-step { grid-area:1 / 1; display:flex; flex-direction:column; align-items:center; width:100%; min-width:0; }
.onboard-step[data-enter="forward"] { animation:onboard-step-in-forward .38s var(--ease) both; }
.onboard-step[data-enter="back"] { animation:onboard-step-in-back .38s var(--ease) both; }
.onboard-step[data-leave="forward"] { animation:onboard-step-out-forward .34s var(--ease) both; pointer-events:none; }
.onboard-step[data-leave="back"] { animation:onboard-step-out-back .34s var(--ease) both; pointer-events:none; }
@keyframes onboard-step-in-forward { from { opacity:0; transform:translate3d(56px,0,0); } to { opacity:1; transform:none; } }
@keyframes onboard-step-in-back { from { opacity:0; transform:translate3d(-56px,0,0); } to { opacity:1; transform:none; } }
@keyframes onboard-step-out-forward { from { opacity:1; transform:none; } to { opacity:0; transform:translate3d(-56px,0,0); } }
@keyframes onboard-step-out-back { from { opacity:1; transform:none; } to { opacity:0; transform:translate3d(56px,0,0); } }
[dir="rtl"] .onboard-step[data-enter="forward"] { animation-name:onboard-step-in-back; }
[dir="rtl"] .onboard-step[data-enter="back"] { animation-name:onboard-step-in-forward; }
[dir="rtl"] .onboard-step[data-leave="forward"] { animation-name:onboard-step-out-back; }
[dir="rtl"] .onboard-step[data-leave="back"] { animation-name:onboard-step-out-forward; }
@media (prefers-reduced-motion: reduce) { .onboard-step { animation:none !important; } .onboard-step[data-leave] { display:none; } }

/* Hero */
/* The landing page scrolls as laid out; onboard/hero_scroll.js flies the logo into
   the header and brings the tiles in. */
.onboard-landing { display:contents; }
.onboard-hero { position:relative; display:flex; flex-direction:column; align-items:center; gap:22px; width:min(760px,100%); padding:24px 0 22px; text-align:center; }
/* "Design your first story", the note under it and the legal links: under the
   demo, and again after the tiles. */
.onboard-start-set { display:grid; justify-items:center; gap:10px; width:100%; text-align:center; }
.onboard-start-set > .onboard-primary { max-width:360px; }
.onboard-start-set .landing-legal-links { padding:0 16px; gap:20px; }
/* "Learn more" and the tiles (hero_scroll.js). Without the script, or with
   reduced motion, the first start button, the heading, the tiles and the second
   start button simply follow each other. With it, the heading shares the first
   start button's place: at first it waits faintly below it (--learn-offset)
   while the tiles and the second start button are hidden; once the page has
   scrolled on, the start button fades, the heading brightens and rises into its
   place, the tiles come in below it and the second start button below them.
   Scrolling back reverses it. A tile reached with the keyboard shows at once. */
.onboard-features-stack { display:flex; flex-direction:column; align-items:center; gap:20px; width:100%; }
.onboard-features[data-reveal] .onboard-features-stack { display:grid; grid-template-columns:minmax(0,1fr); justify-items:center; row-gap:20px; }
.onboard-features[data-reveal] .onboard-features-stack > :is(.onboard-start-intro, h2, .onboard-features-about) { grid-area:1 / 1; }
/* Right under the demo's choices, not centred on the taller paragraph that
   shares its place, so a small window shows it without scrolling. */
.onboard-features[data-reveal] .onboard-features-stack > .onboard-start-intro { align-self:start; }
.onboard-features[data-reveal] .onboard-features-stack > h2 { position:relative; z-index:1; align-self:end; opacity:.6; transform:translateY(var(--learn-offset, 0px)); transition:opacity .4s ease, transform .6s cubic-bezier(.2,.8,.2,1); }
/* Arrived, the heading has done its job: it fades as it rises, and a paragraph
   about Compri takes its and the start button's place, just above the tiles. */
.onboard-features[data-arrived] .onboard-features-stack > h2 { opacity:0; transform:none; pointer-events:none; }
.onboard-features-about { display:grid; justify-items:center; gap:22px; width:min(620px,100%); }
/* The landing page's logo at its full size, with the same face as at the top. */
.onboard-about-face .wordmark { width:min(240px,60vw); height:auto; color:var(--text); }
.onboard-features-about > p { margin:0; color:var(--text); font-size:clamp(1rem,2.2vw,1.12rem); line-height:1.65; text-align:start; text-wrap:pretty; }
/* Weight rather than slant, which suits every script. */
.onboard-features-about em { font-style:normal; font-weight:650; }
.onboard-features[data-reveal] .onboard-features-stack > .onboard-features-about { align-self:end; opacity:0; transform:translateY(14px); pointer-events:none; transition:opacity .45s ease .1s, transform .6s cubic-bezier(.2,.8,.2,1) .05s; }
.onboard-features[data-arrived] .onboard-features-stack > .onboard-features-about { opacity:1; transform:none; pointer-events:auto; }
.onboard-features[data-reveal] :is(.onboard-start-intro, .onboard-features-end) { transition:opacity .4s ease, filter .3s ease; }
.onboard-features[data-arrived] .onboard-start-intro, .onboard-features[data-reveal]:not([data-arrived]) .onboard-features-end { opacity:0; pointer-events:none; }
.onboard-features[data-reveal]:not([data-arrived]) .onboard-feature-grid { pointer-events:none; }
/* Meanwhile the demo and its choices fade, and "Return to demo" waits faintly,
   an up arrow over its words, where the first start button was. */
.onboard-hero-demo { transition:opacity .4s ease, filter .3s ease; }
.onboard-landing[data-arrived] .onboard-hero-demo { opacity:0; pointer-events:none; }
.onboard-return-demo { display:none; }
/* The heading's size, its arrow pointing up; placed by hero_scroll.js. */
.onboard-features[data-reveal] .onboard-features-stack > button.onboard-return-demo { position:relative; z-index:1; display:inline-flex; flex-direction:column; align-items:center; gap:18px; grid-area:1 / 1; align-self:start; min-height:0; margin:0; padding:2px 16px 6px; border:0; border-radius:16px; background:transparent; box-shadow:none; color:var(--text); font:inherit; font-size:clamp(1.3rem,2.8vw,1.75rem); font-weight:500; letter-spacing:-.02em; opacity:0; pointer-events:none; transition:opacity .4s ease; }
.onboard-return-arrow { color:var(--text-secondary); }
.onboard-features[data-arrived] .onboard-features-stack > button.onboard-return-demo { opacity:.6; pointer-events:auto; }
.onboard-return-arrow { display:flex; transition:transform .2s ease; }
@media (hover: hover) and (pointer: fine) {
  .onboard-features[data-arrived] .onboard-features-stack > button.onboard-return-demo:hover { opacity:1; background:transparent; }
  .onboard-features[data-arrived] .onboard-features-stack > button.onboard-return-demo:hover .onboard-return-arrow { transform:translateY(-3px); }
}
.onboard-features[data-arrived] .onboard-features-stack > button.onboard-return-demo:focus-visible { opacity:1; }
.onboard-feature-grid > li { transition:opacity .45s ease-out, transform .6s cubic-bezier(.2,.9,.25,1.15); transition-delay:var(--onboard-tile-delay, 0ms); }
.onboard-features[data-reveal] .onboard-feature-grid > li:not([data-shown]):not(:has(:focus-visible)) { opacity:0; transform:translateY(22px) scale(.94); pointer-events:none; }
@media (prefers-reduced-motion: reduce) { .onboard-feature-grid > li, .onboard-features-stack > h2, .onboard-features-about, .onboard-start-intro, .onboard-features-end, .onboard-hero-demo, .onboard-return-demo { transition:none !important; } }
.onboard-hero-logo .wordmark { width:min(240px,60vw); }
/* A logo face (onboard/logo.js): clicking it sends a hello flying, and now and
   then, until it has been clicked, it wobbles slightly in a soft glow of a
   random colour (--beckon-hue) around the C, to show it can be clicked. */
.onboard-face { position:relative; isolation:isolate; cursor:pointer; -webkit-user-select:none; user-select:none; -webkit-tap-highlight-color:transparent; }
.onboard-face::before { content:""; position:absolute; z-index:-1; left:-11%; top:-22%; width:44%; height:144%; border-radius:50%; background:radial-gradient(closest-side, hsl(var(--beckon-hue, 210) 85% 60% / .42), hsl(var(--beckon-hue, 210) 85% 60% / .16) 55%, transparent); opacity:0; pointer-events:none; }
.onboard-face[data-beckon]::before { animation:onboard-face-glow 1.6s both; }
.onboard-face[data-beckon] > .wordmark { transform-origin:11% 50%; animation:onboard-face-wobble 1.6s both; }
@keyframes onboard-face-glow { 0% { opacity:0; transform:scale(.7); } 30% { opacity:1; transform:scale(1.05); } 70% { opacity:.7; transform:scale(1); } 100% { opacity:0; transform:scale(.95); } }
@keyframes onboard-face-wobble { 0%, 12% { transform:none; } 22% { transform:rotate(-3deg) scale(1.03); } 34% { transform:rotate(2.4deg) scale(1.02); } 46% { transform:rotate(-1.4deg); } 58% { transform:rotate(.7deg); } 70%, 100% { transform:none; } }
@media (prefers-reduced-motion: reduce) { .onboard-face[data-beckon] > .wordmark { animation:none; } }
.onboard-hello-layer { position:fixed; inset:0; z-index:60; overflow:hidden; pointer-events:none; }
.onboard-hello { position:absolute; left:0; top:0; font-size:clamp(1.35rem,3vw,1.9rem); font-weight:750; line-height:1.1; letter-spacing:-.01em; white-space:nowrap; text-shadow:0 2px 12px rgb(0 0 0 / .22); will-change:transform, opacity; }
.onboard-headline { margin:0; font-size:clamp(1.9rem,4.6vw,3.1rem); line-height:1.12; letter-spacing:-.03em; text-wrap:balance; }
.onboard-flags { --onboard-flag-fade:12%; width:100%; max-width:640px; overflow:hidden; -webkit-mask-image:linear-gradient(90deg,transparent,#000 var(--onboard-flag-fade),#000 calc(100% - var(--onboard-flag-fade)),transparent); mask-image:linear-gradient(90deg,transparent,#000 var(--onboard-flag-fade),#000 calc(100% - var(--onboard-flag-fade)),transparent); }
.onboard-flags-track { display:flex; align-items:center; gap:4px; width:max-content; animation:onboard-flags-drift 480s linear infinite; }
.onboard button.onboard-languages { position:relative; display:grid; justify-items:center; gap:10px; width:100%; max-width:680px; min-height:0; margin:0; padding:14px 0 12px; border:0; border-radius:28px; background:transparent; box-shadow:none; color:inherit; font:inherit; cursor:pointer; }
/* A soft glow behind the ribbon and the count, strongest in the middle and gone at the sides. */
.onboard button.onboard-languages::before { content:""; position:absolute; inset:0; border-radius:inherit; background:radial-gradient(55% 90% at 50% 50%, color-mix(in srgb, var(--text) 9%, transparent), transparent 100%); opacity:0; transition:opacity .25s ease; pointer-events:none; }
.onboard button.onboard-languages:focus-visible::before { opacity:1; }
@media (hover: hover) and (pointer: fine) { .onboard button.onboard-languages:hover::before { opacity:1; } }

.onboard button.onboard-languages .onboard-language-count { margin:0; }
.onboard-flag { display:inline-flex; flex:none; align-items:center; gap:8px; padding:6px 10px; color:var(--text-secondary); font-size:.92rem; font-weight:600; white-space:nowrap; }
.onboard-flag .flag-icon { width:26px; height:auto; border-radius:4px; box-shadow:0 1px 3px rgb(0 0 0 / .25); }
@keyframes onboard-flags-drift { from { transform:translate3d(0,0,0); } to { transform:translate3d(-50%,0,0); } }
@media (prefers-reduced-motion: reduce) { .onboard-flags-track { animation:none; } }
.onboard-language-count { color:var(--text-secondary); font-size:.9rem; }
:is(.onboard,.story-interview) button.onboard-primary { display:inline-flex; align-items:center; justify-content:center; gap:10px; width:100%; min-height:52px; padding:14px 28px; border:0; border-radius:999px; background:var(--accent); color:var(--accent-text); font-size:1.05rem; font-weight:650; box-shadow:0 12px 32px -14px rgb(0 0 0 / .5); }
@media (hover: hover) and (pointer: fine) { :is(.onboard,.story-interview) button.onboard-primary:hover:not(:disabled) { background:var(--accent-hover); } }
:is(.onboard,.story-interview) button.onboard-primary:disabled { opacity:.55; }
.onboard button.onboard-outline { display:inline-flex; align-items:center; justify-content:center; gap:10px; width:100%; min-height:52px; padding:14px 28px; border:1.5px solid var(--border-strong); border-radius:999px; background:transparent; color:var(--text); font-size:1.05rem; font-weight:650; box-shadow:none; }
@media (hover: hover) and (pointer: fine) { .onboard button.onboard-outline:hover:not(:disabled) { border-color:var(--accent); background:var(--accent-soft); color:var(--accent-ink); } }
.onboard-trial-note { max-width:440px; margin:2px 0 0; color:var(--text-secondary); font-size:.9rem; line-height:1.45; text-wrap:balance; }
.onboard-trial-emphasis { color:var(--text); font-weight:inherit; }
/* A short window keeps the start button in view. */
@media (max-height: 840px) { .onboard-hero { gap:16px; padding:12px 0 16px; } }
/* The landing page as plain HTML (client/index.html), for search engines, link
   previews and the moments before the app starts: the logo, headline and start
   button about where the app draws them, a placeholder where the demo goes, then
   the features as text. The app removes it once it can draw a page (main.rs). */
#compri-landing { position:fixed; inset:0; z-index:5; overflow-y:auto; overscroll-behavior:contain; background:radial-gradient(120% 60% at 50% -10%, var(--bg-accent), transparent 60%), var(--bg); color:var(--text); text-align:center; }
:root[data-landing="off"] #compri-landing { display:none; }
.static-landing { display:flex; flex-direction:column; align-items:center; gap:22px; width:min(760px,100%); margin:0 auto; padding:102px 20px 40px; }
.static-landing-mark { width:min(240px,60vw); }
.static-landing h1 { margin:0; font-size:clamp(1.9rem,4.6vw,3.1rem); font-weight:720; line-height:1.12; letter-spacing:-.03em; text-wrap:balance; }
/* The demo's story card, then its three rows of choices. */
.static-landing-demo { display:flex; flex-direction:column; align-items:center; gap:10px; width:100%; }
.static-landing-demo > * { flex:none; max-width:100%; border:1px solid var(--border); background:linear-gradient(100deg, var(--surface) 40%, var(--bg-accent) 50%, var(--surface) 60%) 0 0 / 250% 100%; animation:static-landing-wait 1.6s linear infinite; }
.static-landing-demo > div { width:560px; height:calc(min(560px, 100vw - 40px) * .648 + 58px); margin-bottom:5px; border-radius:18px; }
.static-landing-demo > span { height:32px; border-radius:999px; }
.static-landing-demo > span:nth-child(2) { width:476px; }
.static-landing-demo > span:nth-child(3) { width:390px; }
.static-landing-demo > span:nth-child(4) { width:334px; }
@keyframes static-landing-wait { to { background-position:-250% 0; } }
#compri-landing-start { justify-content:center; gap:10px; width:100%; max-width:360px; min-height:52px; margin-top:8px; padding:14px 28px; border-radius:999px; font-size:1.05rem; box-shadow:0 12px 32px -14px rgb(0 0 0 / .5); }
/* Pressed before the app is ready: the first step opens once it is. */
#compri-landing[data-start] #compri-landing-start { cursor:progress; opacity:.7; }
.static-landing-note { max-width:440px; margin:-10px 0 0; color:var(--text-secondary); font-size:.9rem; line-height:1.45; text-wrap:balance; }
.static-landing-note strong { color:var(--text); font-weight:inherit; }
.static-landing-legal { display:flex; justify-content:center; flex-wrap:wrap; gap:20px; margin-top:-12px; font-size:.85rem; }
.static-landing-legal a { color:var(--text-secondary); text-underline-offset:3px; }
.static-landing-more { display:flex; flex-direction:column; align-items:center; gap:18px; width:100%; margin-top:96px; }
.static-landing-more h2 { margin:0; font-size:1.35rem; }
.static-landing-more > p { max-width:620px; margin:0; color:var(--text-secondary); font-size:1.05rem; line-height:1.6; text-wrap:pretty; }
.static-landing-more > p strong { color:var(--text); font-weight:650; }
.static-landing-features { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; width:100%; margin:12px 0 0; padding:0; list-style:none; text-align:start; }
.static-landing-features li { padding:18px 20px; border:1px solid var(--border); border-radius:18px; background:var(--surface); }
.static-landing-features h3 { margin:0 0 6px; font-size:1.02rem; }
.static-landing-features p { margin:0; color:var(--text-secondary); font-size:.92rem; line-height:1.5; }
.static-landing-more > p.static-landing-count { margin-top:8px; font-size:.9rem; }
@media (max-height: 840px) { .static-landing { gap:16px; padding-top:90px; } }
@media (max-width: 600px) {
  .static-landing { padding-top:90px; }
  .static-landing-features { grid-template-columns:1fr; }
}
/* Where the rows name only the chosen language and interest. */
@media (max-width: 460px) {
  .static-landing-demo > span:nth-child(2) { width:292px; }
  .static-landing-demo > span:nth-child(3) { width:203px; }
  .static-landing-demo > span:nth-child(4) { width:338px; }
}
/* As the hero: less room above the logo in a short window, and a wider picture
   in a shorter one still. */
@media (max-width: 600px) and (max-height: 840px) { .static-landing { padding-top:78px; } }
@media (max-height: 760px) { .static-landing-demo > div { height:calc(min(560px, 100vw - 40px) * .586 + 58px); } }
@media (prefers-reduced-motion: reduce) { .static-landing-demo { animation:none; } }
/* The guided reading demo (demo.rs): a story picture sitting on a solid caption
   that holds the sentence, its words colored by part of speech. */
.onboard-hero-demo { display:grid; justify-items:center; gap:14px; width:100%; }
.onboard-hero-demo > .onboard-demo { width:min(560px,100%); }
.onboard-demo { position:relative; display:grid; overflow:hidden; border:1px solid var(--border); border-radius:22px; background:var(--surface); box-shadow:var(--shadow-raised); text-align:start; }
/* The caption being replaced, fading out over the new one (demo_card.js). */
.onboard-demo-ghosts { position:absolute; inset:0; pointer-events:none; }
.onboard-demo-ghosts > .onboard-demo-caption { position:absolute; left:0; right:0; }
/* Only the new caption's listen button shows; the two would sit at different heights. */
.onboard-demo-ghosts .onboard-demo-listen { visibility:hidden; }
.onboard-demo-art { position:relative; aspect-ratio:16 / 9; overflow:hidden; background:radial-gradient(90% 120% at 15% 10%, color-mix(in srgb, var(--accent) 26%, transparent), transparent 60%), radial-gradient(80% 100% at 90% 90%, color-mix(in srgb, #4aad85 24%, transparent), transparent 60%), var(--surface-subtle); }
.onboard-demo-art > img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; object-position:center 60%; animation:onboard-demo-art-in .6s ease both; }
/* The sheen sweeps across by moving, not by repainting, so it costs nothing while the page scrolls. */
.onboard-demo-art[data-preparing="true"]::after { content:""; position:absolute; inset:0 auto 0 -100%; width:100%; background:linear-gradient(105deg, transparent 20%, color-mix(in srgb, var(--text) 8%, transparent) 50%, transparent 80%); animation:onboard-demo-sweep 2.4s linear infinite; }
@keyframes onboard-demo-sweep { to { transform:translateX(200%); } }
@keyframes onboard-demo-art-in { from { opacity:0; } to { opacity:1; } }
/* Language, interest and level, below the card: one row of pills per choice. */
/* One row each, however wide the window. */
.onboard-demo-choices { display:flex; flex-direction:column; align-items:center; gap:8px; max-width:100%; }
.onboard-demo-choice-group { position:relative; isolation:isolate; display:inline-flex; gap:2px; max-width:100%; padding:3px; border:1px solid var(--border); border-radius:999px; background:color-mix(in srgb, var(--text) 4%, var(--surface)); }
.onboard button.onboard-demo-choice { display:inline-flex; align-items:center; gap:6px; min-width:0; min-height:0; margin:0; padding:5px 12px 5px 9px; overflow:hidden; border:0; border-radius:999px; background:transparent; box-shadow:none; color:var(--text-secondary); font-size:.8rem; font-weight:600; line-height:1.2; white-space:nowrap; cursor:pointer; transition:background .15s ease, color .15s ease; }
.onboard button.onboard-demo-choice > span { overflow:hidden; text-overflow:ellipsis; }
.onboard button.onboard-demo-choice .flag-icon { flex:none; width:18px; height:auto; border-radius:3px; }
.onboard-demo-icon { flex:none; width:16px; height:16px; }
.onboard button.onboard-demo-choice[aria-pressed="true"] { background:var(--text); color:var(--bg); }
.onboard button.onboard-demo-more { padding-inline:12px; }
/* One highlight per row glides to the chosen option (demo_choices.js); the
   chosen option's own background steps aside for it, and its text turns as the
   highlight arrives. */
.onboard-demo-choice-pill { position:absolute; top:3px; bottom:3px; left:0; z-index:-1; width:0; border-radius:999px; background:var(--text); pointer-events:none; }
.onboard-demo-choice-group:not([data-glide]) > .onboard-demo-choice-pill { display:none; }
.onboard-demo-choice-group[data-glide] > button.onboard-demo-choice[aria-pressed="true"] { background:transparent; }
.onboard-demo-choice-group[data-glide] > button.onboard-demo-choice { transition:background .15s ease, color .28s ease .06s; }
/* Narrow screens name only the chosen language and interest; names open and
   close by width, each to its own (--label-width, measured by demo_choices.js). */
@media (max-width: 460px) {
  :is(.onboard-demo-languages, .onboard-demo-interests) button.onboard-demo-choice > .onboard-demo-choice-label { max-width:var(--label-width, 8em); text-overflow:clip; }
  :is(.onboard-demo-languages, .onboard-demo-interests) .onboard-demo-choice[aria-pressed="false"] > .onboard-demo-choice-label { max-width:0; margin-inline-start:-6px; opacity:0; }
  :is(.onboard-demo-languages, .onboard-demo-interests) .onboard-demo-choice[aria-pressed="false"]:not(.onboard-demo-more) { padding-inline:10px; }
  .onboard-demo-choice-group[data-glide]:is(.onboard-demo-languages, .onboard-demo-interests) > button.onboard-demo-choice { transition:background .15s ease, color .28s ease .06s, padding .38s cubic-bezier(.2,.9,.25,1); }
  .onboard-demo-choice-group[data-glide]:is(.onboard-demo-languages, .onboard-demo-interests) .onboard-demo-choice-label { transition:max-width .38s cubic-bezier(.2,.9,.25,1), margin .38s cubic-bezier(.2,.9,.25,1), opacity .25s ease; }
}
@media (prefers-reduced-motion: reduce) { .onboard-demo-choice-group .onboard-demo-choice, .onboard-demo-choice-group .onboard-demo-choice-label { transition:none !important; } }
@media (hover: hover) and (pointer: fine) { .onboard button.onboard-demo-choice[aria-pressed="false"]:hover { background:color-mix(in srgb, var(--text) 9%, transparent); color:var(--text); } }
.onboard-demo-caption { display:grid; grid-template-columns:auto minmax(0,1fr); align-items:center; column-gap:14px; padding:14px 22px 16px 16px; background:var(--surface); }
/* A language without a voice has no listen button. */
.onboard-demo-caption[data-voiced="false"] { grid-template-columns:minmax(0,1fr); padding-inline-start:22px; }
/* The round listen buttons: a ring turns while the recording loads, and stop shows while it plays. */
.onboard button.onboard-demo-listen { position:relative; display:grid; place-items:center; flex:none; width:46px; height:46px; min-width:0; min-height:0; margin:0; padding:0; border:1px solid var(--border); border-radius:50%; background:color-mix(in srgb, var(--text) 6%, var(--surface)); box-shadow:none; color:var(--text); cursor:pointer; transition:background .15s ease, color .15s ease; }
.onboard button.onboard-demo-listen.onboard-demo-listen-small { width:34px; height:34px; }
.onboard-demo-listen > span { display:grid; place-items:center; grid-area:1 / 1; }
.onboard-demo-listen-stop, .onboard-demo-listen[data-state="playing"] .onboard-demo-listen-play { visibility:hidden; }
.onboard-demo-listen[data-state="playing"] .onboard-demo-listen-stop { visibility:visible; }
.onboard button.onboard-demo-listen[data-state="playing"] { background:var(--text); color:var(--bg); }
.onboard-demo-listen[data-state="loading"]::after { content:""; position:absolute; inset:-3px; border:2px solid transparent; border-top-color:var(--text); border-radius:50%; animation:onboard-demo-spin .8s linear infinite; }
.onboard button.onboard-demo-listen[data-state="error"] { color:var(--danger, #c0392b); }
@media (hover: hover) and (pointer: fine) { .onboard button.onboard-demo-listen:not([data-state="playing"]):hover { background:color-mix(in srgb, var(--text) 12%, var(--surface)); } }
@keyframes onboard-demo-spin { to { transform:rotate(1turn); } }
.onboard-demo-sentence { margin:0; color:var(--text); font-family:var(--font-reading); font-size:clamp(1.35rem,3.6vw,1.75rem); font-weight:600; line-height:1.35; }
.onboard-demo-sentence:lang(zh) { font-family:var(--font-sans); }
.onboard-demo-unit { display:inline-flex; align-items:flex-start; vertical-align:top; white-space:nowrap; }
.onboard-demo-sentence[data-readings="true"] .onboard-demo-unit { margin-bottom:.3em; }
:where(.onboard-demo-word) { --grammar-color:#84909e; }
.onboard button.onboard-demo-word { display:inline-flex; flex-direction:column; align-items:center; min-width:0; min-height:0; margin:0; padding:0 .06em; border:0; border-radius:8px; background:transparent; box-shadow:none; color:color-mix(in srgb, var(--grammar-color) 74%, var(--text)); font:inherit; line-height:inherit; cursor:pointer; transition:background .15s ease; }
.onboard button.onboard-demo-word[aria-expanded="true"] { background:color-mix(in srgb, var(--grammar-color) 18%, transparent); }
@media (hover: hover) and (pointer: fine) { .onboard button.onboard-demo-word:hover { background:color-mix(in srgb, var(--grammar-color) 14%, transparent); } }
.onboard-demo-face { display:flex; flex-direction:column; align-items:center; }
.onboard-demo-reading { margin-top:-.1em; color:var(--text-secondary); font-family:var(--font-sans); font-size:max(.75rem,.48em); font-weight:500; line-height:1.3; }
/* The tap hint (use_beckon in demo.rs): until the visitor taps a word, a fingertip
   drops onto one word at a time, presses it with a burst ring, and the word
   boings like jelly in a glow of its part-of-speech colour. Every part runs on one
   2.6s clock and moves only by transform and opacity, so it never repaints. */
.onboard button.onboard-demo-word[data-beckon="true"] { position:relative; isolation:isolate; }
.onboard-demo-word[data-beckon="true"] .onboard-demo-face { transform-origin:50% 85%; animation:onboard-demo-boing 2.6s both; }
.onboard-demo-word[data-beckon="true"]::before { content:""; position:absolute; z-index:-1; inset:-.36em -.6em; border-radius:999px; background:radial-gradient(closest-side, color-mix(in srgb, var(--grammar-color) 62%, transparent), color-mix(in srgb, var(--grammar-color) 34%, transparent) 50%, transparent); opacity:0; pointer-events:none; animation:onboard-demo-glow 2.6s both; }
/* A translucent fingertip on the word's lower right, so the word still reads through it. */
.onboard-demo-tap { position:absolute; z-index:1; left:72%; top:1.02em; width:.82em; height:.82em; margin:-.41em 0 0 -.41em; pointer-events:none; }
.onboard-demo-tap::before, .onboard-demo-tap::after { content:""; position:absolute; inset:0; box-sizing:border-box; border-radius:50%; opacity:0; }
.onboard-demo-tap::before { border:.11em solid color-mix(in srgb, var(--grammar-color) 75%, #fff); animation:onboard-demo-ring 2.6s ease-out both; }
.onboard-demo-tap::after { border:.1em solid color-mix(in srgb, var(--grammar-color) 80%, #fff); background:rgb(255 255 255 / .62); box-shadow:0 .1em .28em rgb(0 0 0 / .28); animation:onboard-demo-press 2.6s both; }
@keyframes onboard-demo-press {
  0% { opacity:0; transform:translateY(-.7em) scale(.3); }
  12% { opacity:1; transform:translateY(0) scale(1.14); animation-timing-function:ease-in-out; }
  18% { transform:scale(.95); }
  23% { transform:scale(1); animation-timing-function:ease-in; }
  29% { transform:scale(.7); animation-timing-function:cubic-bezier(.3,1.6,.6,1); }
  40% { transform:scale(1); }
  80% { opacity:1; transform:scale(1); animation-timing-function:ease-in; }
  86% { opacity:1; transform:scale(1.12); }
  100% { opacity:0; transform:scale(0); }
}
@keyframes onboard-demo-ring {
  0%, 28% { opacity:0; transform:scale(.7); }
  30% { opacity:.95; transform:scale(.8); }
  62%, 100% { opacity:0; transform:scale(2.7); }
}
@keyframes onboard-demo-glow {
  0%, 27% { opacity:0; transform:scale(.55); }
  36% { opacity:1; transform:scale(1.1); }
  50% { opacity:.9; transform:scale(1); }
  82% { opacity:.75; transform:scale(1); }
  100% { opacity:0; transform:scale(.9); }
}
@keyframes onboard-demo-boing {
  0%, 28% { transform:none; }
  31% { transform:scale(1.16, .82); }
  39% { transform:translateY(-.1em) scale(.9, 1.13) rotate(-5deg); }
  47% { transform:scale(1.07, .95) rotate(4deg); }
  55% { transform:scale(.97, 1.04) rotate(-2.5deg); }
  63% { transform:scale(1.02, .99) rotate(1deg); }
  70%, 100% { transform:none; }
}
@keyframes onboard-demo-fade { 0%, 100% { opacity:0; } 15%, 80% { opacity:1; } }
/* Frosted: the story shows through, blurred. */
.anchored-popover.onboard-demo-popover { width:min(400px, calc(100vw - 24px)); background:color-mix(in srgb, var(--surface) 68%, transparent); -webkit-backdrop-filter:blur(18px) saturate(1.5); backdrop-filter:blur(18px) saturate(1.5); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .anchored-popover.onboard-demo-popover { background:var(--surface); } }
/* The recording, part of speech and reading lead the close button's row. */
.onboard-demo-details { display:flex; flex-wrap:wrap; align-items:center; gap:10px; min-width:0; margin-inline-end:auto; }
.onboard-demo-details .grammar-tag { margin:0; }
.onboard-demo-detail-reading { color:var(--text-secondary); font-size:1.05rem; }
.onboard-demo-images { display:flex; gap:10px; }
.onboard-demo-images > .meaning-images { display:contents; }
.onboard-demo-images :is(.meaning-image, .onboard-demo-image-slot) { position:relative; flex:1 1 0; min-width:0; max-width:none; aspect-ratio:1; border-radius:12px; overflow:hidden; }
.onboard-demo-images .reported-word-image { width:100%; height:100%; }
.onboard-demo-images .meaning-images .meaning-image img { width:100%; height:100%; object-fit:contain; }
@media (max-height: 760px) { .onboard-demo-art { aspect-ratio:2 / 1; } }
@media (prefers-reduced-motion: reduce) {
  .onboard-demo-art > img, .onboard-demo-listen[data-state="loading"]::after, .onboard-demo-art[data-preparing="true"]::after { animation:none; }
  /* The hint still shows, only fading in and out in place. */
  .onboard-demo-word[data-beckon="true"] .onboard-demo-face { animation:none; }
  .onboard-demo-tap::before { display:none; }
  .onboard-demo-word[data-beckon="true"]::before, .onboard-demo-tap::after { animation-name:onboard-demo-fade; }
}

/* Learn more: one small tinted tile per feature, an icon and a name. A tile grows
   into a popup about its feature (onboard/features.js); --hue tints both. */
.onboard-features { position:relative; display:flex; flex-direction:column; align-items:center; gap:20px; width:min(760px,100%); padding:8px 0 60px; }
.onboard-features-stack > h2 { margin:0; font-size:clamp(1.3rem,2.8vw,1.75rem); font-weight:500; letter-spacing:-.02em; text-align:center; }
.onboard button.onboard-features-more { display:inline-flex; flex-direction:column; align-items:center; gap:18px; min-height:0; margin:0; padding:6px 16px 2px; border:0; border-radius:16px; background:transparent; box-shadow:none; color:inherit; font:inherit; letter-spacing:inherit; text-align:center; }
.onboard-features-arrow { display:flex; color:var(--text-secondary); transition:transform .2s ease, color .2s ease; }
@media (hover: hover) and (pointer: fine) {
  .onboard button.onboard-features-more:hover { background:transparent; }
  .onboard button.onboard-features-more:hover .onboard-features-arrow { color:var(--text); transform:translateY(3px); }
}
@media (prefers-reduced-motion: reduce) { .onboard-features-arrow { transition:none; } }
/* Two columns everywhere: guided reading spans both, then four rows of two. */
.onboard-feature-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; width:min(620px,100%); margin:0; padding:0; list-style:none; }
.onboard-feature-grid li { display:flex; min-width:0; }
/* Scrolled to from the heading, it stops below the fixed header. */
.onboard-feature-grid { scroll-margin-top:calc(var(--onboard-header, 72px) + 16px); }
.onboard-feature-grid li[data-wide="true"] { grid-column:1 / -1; }
.onboard-feature-tile, dialog.onboard-feature-popup { --tint:hsl(var(--hue) 62% 52%); --well:color-mix(in srgb, var(--tint) 12%, transparent); }
.onboard-feature-icon { display:flex; flex:none; color:color-mix(in srgb, var(--tint) 80%, var(--text)); }
.onboard button.onboard-feature-tile { display:flex; flex-direction:column; align-items:flex-start; justify-content:space-between; gap:18px; width:100%; min-height:118px; margin:0; padding:18px 16px 16px; border:1px solid color-mix(in srgb, var(--tint) 20%, transparent); border-radius:18px; background:color-mix(in srgb, var(--tint) 14%, var(--surface)); color:var(--text); font:inherit; text-align:start; box-shadow:none; transition:background-color .18s ease, transform .18s ease, box-shadow .18s ease; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .onboard button.onboard-feature-tile:hover { background:color-mix(in srgb, var(--tint) 21%, var(--surface)); transform:translateY(-2px); box-shadow:0 14px 30px -22px rgb(0 0 0 / .5); } }
/* While its popup is open, the tile is the popup. */
.onboard button.onboard-feature-tile[data-open="true"] { visibility:hidden; }
.onboard-feature-name { font-size:.95rem; font-weight:600; line-height:1.3; overflow-wrap:break-word; text-wrap:balance; }
@media (max-width: 600px) {
  .onboard-feature-grid { gap:10px; }
  .onboard button.onboard-feature-tile { min-height:104px; padding:14px; gap:12px; }
}
@media (prefers-reduced-motion: reduce) { .onboard button.onboard-feature-tile { transition:none; } }
.onboard-features-end { margin-top:12px; }
.onboard-features-end > .onboard-languages { margin-top:12px; }
/* The page blurs (popup.js) and comes back into focus gradually. */
.onboard-topbar, .onboard-hero, .onboard-features > :not(dialog) { transition:filter .3s ease; }

/* A feature's popup: the tile's look at full size, over a dark scrim. Its parts
   sit in wells of the same tint. */
dialog.onboard-feature-popup { width:min(560px, calc(100vw - 24px)); border-color:color-mix(in srgb, var(--tint) 24%, var(--border)); border-radius:24px; background:color-mix(in srgb, var(--tint) 9%, var(--surface)); }
dialog.onboard-feature-popup:not([data-grown]) { opacity:0; }
dialog.onboard-feature-popup::backdrop { background:rgb(6 8 12 / .62); animation:onboard-scrim-in .35s ease backwards; transition:opacity .3s ease; }
dialog.onboard-feature-popup[data-closing]::backdrop { opacity:0; }
@keyframes onboard-scrim-in { from { opacity:0; } }
.onboard-feature-popup .reader-popup-heading { justify-content:flex-start; gap:14px; padding:20px 16px 4px 22px; border-bottom:0; }
.onboard-feature-popup .reader-popup-heading h2 { flex:1; min-width:0; text-align:start; font-size:1.3rem; line-height:1.25; letter-spacing:-.01em; }
.onboard-feature-popup .reader-popup-body { padding:14px 24px 26px; }
@media (max-width: 480px) { .onboard-feature-popup .reader-popup-heading { padding:16px 12px 2px 18px; } .onboard-feature-popup .reader-popup-body { padding:12px 18px 22px; } }
.onboard-feature-body { display:grid; gap:20px; }
.onboard-feature-body figure, .onboard-feature-body p { margin:0; }
.onboard-feature-lead { font-size:1.06rem; line-height:1.55; }
.onboard-feature-glyph { display:flex; justify-content:center; flex:none; color:color-mix(in srgb, var(--tint) 80%, var(--text)); }
.onboard-feature-points { display:grid; gap:14px; margin:0; padding:0; list-style:none; }
.onboard-feature-points li { display:grid; grid-template-columns:auto minmax(0,1fr); gap:1px 12px; }
.onboard-feature-points .onboard-feature-glyph, .onboard-feature-tools .onboard-feature-glyph { grid-row:span 2; padding-top:2px; }
.onboard-feature-points strong, .onboard-feature-tools strong { font-weight:650; line-height:1.35; }
.onboard-feature-detail { color:var(--text-secondary); font-size:.92rem; line-height:1.45; }
.onboard-feature-tools { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin:0; padding:0; list-style:none; }
.onboard-feature-tools li { display:grid; grid-template-columns:auto minmax(0,1fr); align-content:start; gap:2px 10px; padding:14px; border-radius:16px; background:var(--well); }
@media (max-width: 480px) { .onboard-feature-tools { grid-template-columns:1fr; } }
.onboard-feature-chips { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.onboard-feature-label, .onboard-feature-body figcaption { color:var(--text-secondary); font-size:.85rem; line-height:1.45; }
.onboard-feature-label { margin-inline-end:2px; }
.onboard-feature-chip { display:inline-flex; align-items:center; gap:6px; padding:6px 11px; border-radius:999px; background:var(--well); font-size:.87rem; font-weight:600; }
.onboard-feature-chip .shell-icon { color:color-mix(in srgb, var(--tint) 72%, var(--text)); }
.onboard-feature-skills { display:grid; gap:10px; }
.onboard-feature-skill-row { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; }
.onboard-feature-skill { display:grid; justify-items:center; gap:8px; padding:14px 4px 12px; border-radius:14px; background:var(--well); font-size:.82rem; font-weight:600; text-align:center; overflow-wrap:break-word; }
/* On a phone, two by two with the icon beside the name, so longer names fit whole. */
@media (max-width: 480px) {
  .onboard-feature-skill-row { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .onboard-feature-skill { grid-auto-flow:column; justify-content:start; align-items:center; padding:10px 12px; text-align:start; }
}
/* A conversation in miniature: the question, then an answer with a practice list. */
.onboard-feature-chat { display:grid; gap:8px; padding:14px; border-radius:18px; background:var(--well); font-size:.9rem; line-height:1.45; }
.onboard-feature-question { justify-self:end; max-width:85%; padding:9px 13px; border-radius:16px 16px 4px 16px; background:var(--accent); color:var(--accent-text); }
[dir="rtl"] .onboard-feature-question { border-radius:16px 16px 16px 4px; }
.onboard-feature-answer { justify-self:start; display:grid; gap:10px; max-width:92%; padding:10px 12px 12px; border:1px solid var(--border); border-radius:16px 16px 16px 4px; background:var(--surface); }
[dir="rtl"] .onboard-feature-answer { border-radius:16px 16px 4px 16px; }
.onboard-feature-attachment { display:flex; align-items:center; gap:8px; padding:8px 10px; border-radius:12px; background:color-mix(in srgb, var(--tint) 12%, var(--surface)); font-weight:600; }
.onboard-feature-attachment > .shell-icon { margin-inline-start:auto; color:var(--muted); }
[dir="rtl"] .onboard-feature-attachment > .shell-icon { transform:scaleX(-1); }
/* A video with its subtitle line; one word is being saved. */
.onboard-feature-video { position:relative; display:grid; place-items:end center; aspect-ratio:16 / 7; padding:0 14px 16px; border-radius:18px; background:radial-gradient(90% 120% at 30% 10%, hsl(var(--hue) 35% 30%), #0c0e13 70%); color:#fff; overflow:hidden; }
.onboard-feature-play { position:absolute; inset:0; display:grid; place-items:center; opacity:.35; }
.onboard-feature-subtitle { position:relative; display:flex; flex-wrap:wrap; justify-content:center; align-items:center; gap:6px; max-width:100%; padding:8px 12px; border-radius:8px; background:rgb(0 0 0 / .55); }
.onboard-feature-word { position:relative; display:block; height:.55em; border-radius:4px; background:rgb(255 255 255 / .82); font-size:14px; }
.onboard-feature-word.saved { height:.8em; background:hsl(var(--hue) 90% 70%); box-shadow:0 0 0 3px hsl(var(--hue) 90% 70% / .3); }
.onboard-feature-save { position:absolute; bottom:calc(100% + 10px); left:50%; display:inline-flex; align-items:center; gap:4px; padding:5px 10px 5px 8px; border-radius:999px; background:#fff; color:#16171c; font-size:12px; font-weight:650; white-space:nowrap; transform:translateX(-50%); box-shadow:0 6px 18px rgb(0 0 0 / .35); }
/* Role-play goals, the first two done. */
.onboard-feature-tasks { display:grid; gap:10px; margin:0; padding:14px 16px; border-radius:18px; background:var(--well); list-style:none; font-size:.92rem; }
.onboard-feature-tasks li { display:flex; align-items:center; gap:10px; }
.onboard-feature-tasks li[data-done="true"] { color:var(--text-secondary); }
.onboard-feature-check { display:grid; place-items:center; flex:none; width:22px; height:22px; border:1.5px solid var(--border-strong); border-radius:50%; }
.onboard-feature-tasks li[data-done="true"] .onboard-feature-check { border-color:transparent; background:color-mix(in srgb, var(--tint) 75%, var(--text)); color:var(--surface); }
/* How much of each podcast mode is in the new language. */
.onboard-feature-modes { display:grid; gap:10px; }
.onboard-feature-mode-row { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
/* The name has the whole width; the bar and the share sit beneath it. */
.onboard-feature-mode { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:8px; padding:11px 12px; border-radius:14px; background:var(--well); font-size:.85rem; }
.onboard-feature-mode strong { grid-column:1 / -1; font-weight:650; overflow-wrap:break-word; }
.onboard-feature-share { height:6px; border-radius:3px; background:color-mix(in srgb, var(--tint) 18%, transparent); overflow:hidden; }
.onboard-feature-share span { display:block; height:100%; border-radius:inherit; background:color-mix(in srgb, var(--tint) 75%, var(--text)); }
.onboard-feature-percent { color:var(--text-secondary); font-size:.8rem; font-variant-numeric:tabular-nums; }
/* On a phone, one row per mode: name, bar, share. */
@media (max-width: 480px) {
  .onboard-feature-mode-row { grid-template-columns:max-content minmax(0,1fr) auto; gap:6px 0; }
  .onboard-feature-mode { grid-column:1 / -1; grid-template-columns:subgrid; gap:12px; padding:10px 12px; }
  .onboard-feature-mode strong { grid-column:auto; }
}
/* 木 stroke by stroke, on practice-paper guides; the newest stroke is tinted. */
.onboard-feature-strokes { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:8px; max-width:360px; }
.onboard-feature-strokes svg { display:block; width:100%; height:auto; border-radius:12px; background:var(--well); }
.onboard-feature-strokes .guide { stroke:color-mix(in srgb, var(--tint) 35%, transparent); stroke-width:1; stroke-dasharray:3 4; }
.onboard-feature-strokes .stroke { stroke:var(--text); stroke-width:7; }
.onboard-feature-strokes .stroke.new { stroke:color-mix(in srgb, var(--tint) 85%, var(--text)); }
.onboard-feature-strokes text { fill:var(--muted); font-size:15px; font-weight:650; }
/* CEFR levels, deepening from A1 to C2. */
.onboard-feature-levels { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:6px; }
.onboard-feature-levels span { padding:8px 0; border-radius:10px; background:color-mix(in srgb, var(--tint) calc(10% + 10% * var(--step)), transparent); font-size:.85rem; font-weight:650; text-align:center; }
@keyframes onboard-fade-up { from { opacity:0; transform:translateY(14px); } to { opacity:1; transform:none; } }

/* Questions */
.onboard-question { display:flex; flex-direction:column; align-items:stretch; width:min(560px,100%); padding:clamp(16px,5vh,56px) 0 40px; }
.onboard-question-wide { width:min(860px,100%); }
.onboard-back { align-self:flex-start; margin:0 0 18px -8px; color:var(--text-secondary); }
.onboard-question-title { margin:0 0 8px; font-size:clamp(1.6rem,3.6vw,2.4rem); line-height:1.15; letter-spacing:-.025em; text-wrap:balance; }
.onboard-question-help { margin:0 0 18px; color:var(--text-secondary); line-height:1.55; }
.onboard-question-body { display:flex; flex-direction:column; gap:14px; margin-top:18px; }
.onboard-actions { display:flex; justify-content:flex-end; gap:12px; margin-top:12px; }
.onboard-actions-split { justify-content:space-between; }
.onboard-question .setup-experience-picker { width:100%; --experience-columns:2; }
.onboard-question .experience-picker.setup-levels { grid-template-columns:repeat(2,minmax(0,1fr)); }
.experience-heading { display:flex; align-items:baseline; gap:10px; }
.experience-code { color:var(--text-secondary); font-weight:600; opacity:.7; }
.experience-heading strong { font-size:1.05rem; }
.onboard-varieties, .onboard-options { display:grid; gap:10px; }
.onboard button.onboard-choice { display:flex; align-items:center; gap:16px; width:100%; min-height:64px; padding:14px 18px; border:1px solid var(--border); border-radius:16px; background:var(--surface); color:var(--text); text-align:start; box-shadow:none; font-size:1.05rem; transition:border-color .18s, background .18s, transform .18s; }
@media (hover: hover) and (pointer: fine) { .onboard button.onboard-choice:hover:not(:disabled) { border-color:var(--accent); background:var(--surface-hover); transform:translateY(-1px); } }
.onboard button.onboard-choice[aria-pressed="true"] { border-color:var(--accent); background:var(--accent-soft); }
.onboard button.onboard-choice > span:first-child { flex:1; min-width:0; overflow-wrap:anywhere; }
.onboard button.onboard-choice > svg { flex:none; opacity:.55; }
.onboard-variety-flag { flex:none !important; display:inline-flex; }
.onboard-variety-flag .flag-icon { width:40px; height:auto; border-radius:4px; }
.onboard-variety-name { display:flex; flex:1; align-items:center; flex-wrap:wrap; gap:6px 12px; min-width:0; }
.onboard-variety-name strong { font-size:1.1rem; font-weight:600; }
/* The language the visitor chose for the landing demo, offered first, and "Something else…". */
.onboard-remembered-language .onboard-variety-name { flex-direction:column; align-items:flex-start; gap:2px; }
.onboard-remembered-language .onboard-variety-name small { color:var(--text-secondary); font-size:.9rem; }
.onboard-language-else .onboard-variety-flag { justify-content:center; width:40px; color:var(--text-secondary); }
.onboard-remembered-language, .onboard-language[data-offered="true"] { animation:onboard-fade-up .35s cubic-bezier(.2,.8,.2,1) both; }
@media (prefers-reduced-motion: reduce) { .onboard-remembered-language, .onboard-language[data-offered="true"] { animation:none; } }
/* The full language picker opened from the landing demo fades in over a dark,
   blurred page, and away once a language is picked (demo.rs). */
#onboard dialog.language-journey { animation:onboard-scrim-in .3s ease both; transition:opacity .28s ease; }
#onboard dialog.language-journey::backdrop { animation:onboard-scrim-in .3s ease backwards; transition:opacity .28s ease; }
#onboard dialog.language-journey[data-closing], #onboard dialog.language-journey[data-closing]::backdrop { opacity:0; }
@media (prefers-reduced-motion: reduce) { #onboard dialog.language-journey, #onboard dialog.language-journey::backdrop { animation:none; transition:none; } }
/* The language list follows the page theme here instead of the setup popup's dark styling. */
.onboard-language.language-journey { min-height:calc(100dvh - 120px); border-radius:0; background:transparent; color:var(--text); overflow:hidden; }
.onboard-language .language-journey-search > label { color:var(--text-secondary); }
.onboard-language.language-journey .language-journey-input { color:var(--text); border-bottom-color:var(--border-strong); }
.onboard-language.language-journey .language-journey-input:focus { border-color:var(--text); box-shadow:0 2px 0 color-mix(in srgb, var(--text) 20%, transparent); }
.onboard-language.language-journey .language-journey-input::placeholder { color:var(--muted); }
.onboard-language .language-journey-support-heading { color:var(--text); }
.onboard-language.language-journey .language-journey-tile { border-color:var(--border); background:var(--surface); color:var(--text); }
@media (hover: hover) and (pointer: fine) { .onboard-language.language-journey .language-journey-tile:hover { border-color:var(--accent); background:var(--surface-hover); } }
.onboard-language .language-journey-names small { color:var(--text-secondary); }
.onboard-language.language-journey .language-journey-back { color:var(--text-secondary); }
.onboard-language.language-journey .language-uncommon-label, .onboard-language.language-journey .language-support-notice { color:var(--muted); }
.onboard-language .language-journey-empty { color:var(--text-secondary); }
.onboard-language.language-journey .language-journey-suggest { background:var(--accent); color:var(--accent-text); border-color:var(--accent); }
.onboard-language.language-journey > .reader-popup-body { display:flex; flex-direction:column; flex:1 1 0; min-height:0; height:calc(100dvh - 120px); padding:0 28px max(32px,env(safe-area-inset-bottom)); }
.onboard-language .language-journey-search[data-browse="true"] { padding-top:24px; }
/* Landscape phones: without this the search controls fill the step and the list gets no height. */
@media(max-height:600px) {
  .onboard-language.language-journey { min-height:calc(100dvh - 52px); padding-top:0; }
  .onboard-language.language-journey > .reader-popup-body { height:calc(100dvh - 52px); padding-bottom:max(12px,env(safe-area-inset-bottom)); }
  .onboard-language .language-journey-search[data-browse="true"] { padding-top:0; }
}

/* Topic grid and the custom field that replaces it */
.onboard-topic-layers { position:relative; display:grid; }
.onboard-topic-layers > * { grid-area:1 / 1; }
.onboard-topic-presets { display:flex; flex-direction:column; gap:16px; transition:opacity .28s ease, transform .28s ease; }
.onboard-topic-layers[data-specific="true"] > .onboard-topic-presets { opacity:0; transform:scale(.98); pointer-events:none; }
.onboard-topic-custom { display:flex; flex-direction:column; justify-content:center; gap:18px; min-height:220px; animation:onboard-fade-up .32s var(--ease) both; }
.onboard-topic-custom input { width:100%; min-height:56px; padding:14px 18px; border-radius:14px; font-size:1.15rem; }
.onboard-topic-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
:is(.onboard,.story-interview) button.onboard-topic { display:flex; width:100%; flex-direction:column; align-items:center; justify-content:center; gap:10px; min-height:144px; padding:16px 10px; border:1px solid var(--border); border-radius:18px; background:var(--surface); color:var(--text); font-size:1rem; font-weight:600; box-shadow:none; transition:border-color .18s, background .18s, transform .18s; }
@media (hover: hover) and (pointer: fine) { :is(.onboard,.story-interview) button.onboard-topic:hover:not(:disabled) { border-color:var(--accent); background:var(--surface-hover); transform:translateY(-2px); } }
:is(.onboard,.story-interview) button.onboard-topic[aria-pressed="true"] { border-color:var(--accent); background:var(--accent-soft); }
.onboard-topic-icon { display:inline-grid; place-items:center; flex:none; width:84px; height:84px; background:transparent; }
.onboard-topic-illustration { display:block; width:100%; height:100%; object-fit:contain; filter:drop-shadow(0 3px 3px #0000000d); }
.onboard-specific { align-self:center; color:var(--text-secondary); }
@media (max-width:520px) { .onboard-topic-grid { gap:8px; } :is(.onboard,.story-interview) button.onboard-topic { min-height:96px; padding:14px 6px; font-size:.9rem; } .onboard-topic-icon { width:64px; height:64px; } }
.onboard-thinking { display:flex; align-items:center; gap:12px; min-height:120px; margin:0; color:var(--text-secondary); font-size:1.05rem; }
.onboard-error { display:grid; gap:12px; padding:16px; border:1px solid var(--danger-soft, var(--border)); border-radius:14px; background:var(--surface); }

/* Story choices reserve their row width while text and artwork are loading. */
.onboard-stories { display:grid; width:100%; min-width:0; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
.onboard button.onboard-story { display:flex; width:100%; min-width:0; flex-direction:column; align-items:stretch; min-height:360px; padding:0; border:1px solid var(--border); border-radius:20px; background:var(--surface); color:var(--text); text-align:start; overflow:hidden; box-shadow:none; transition:border-color .18s, transform .18s, box-shadow .18s; }
@media (hover: hover) and (pointer: fine) { .onboard button.onboard-story:hover:not(:disabled) { border-color:var(--accent); transform:translateY(-2px); box-shadow:var(--shadow); } }
.onboard button.onboard-story:disabled { cursor:default; opacity:1; }
.onboard button.onboard-story[data-ready="false"] { color:var(--text-secondary); }
.onboard-story-art { position:relative; flex:none; aspect-ratio:1; display:grid; place-items:center; background:linear-gradient(135deg,color-mix(in srgb,var(--accent) 18%,var(--surface)),var(--surface-subtle)); overflow:hidden; }
.onboard-story-art img { grid-area:1 / 1; width:100%; height:100%; object-fit:cover; animation:fade-in .5s ease both; }
.onboard-story-copy { display:flex; flex-direction:column; gap:8px; padding:16px 18px 20px; }
.onboard-story-copy h3 { margin:0; font-size:1.15rem; line-height:1.3; }
.onboard-story-copy p { margin:0; color:var(--text-secondary); line-height:1.5; font-size:.95rem; }
.onboard-story-title-loading { display:grid; gap:8px; }
.onboard-skeleton { display:block; height:12px; border-radius:6px; background:linear-gradient(100deg, color-mix(in srgb,var(--text) 8%,transparent) 30%, color-mix(in srgb,var(--text) 16%,transparent) 50%, color-mix(in srgb,var(--text) 8%,transparent) 70%) 0 0 / 200% 100%; animation:shimmer 1.5s linear infinite; }
.onboard-skeleton-title { height:18px; width:80%; }
.onboard-skeleton-short { width:55%; }
@media (max-width:760px) { .onboard-stories { grid-template-columns:1fr; } .onboard button.onboard-story { flex-direction:row; min-height:0; } .onboard-story-art { width:128px; aspect-ratio:auto; min-height:128px; } .onboard-story-copy { flex:1; min-width:0; justify-content:center; } }

/* Preparing: the chosen picture with a checklist, then a shimmering start button */
.onboard-preparing { background:#101114; position:relative; display:grid; width:100%; max-width:1040px; min-height:calc(100dvh - 120px); margin:0 auto; border-radius:var(--radius-xl); overflow:hidden; isolation:isolate; }
.onboard-preparing-art { position:absolute; inset:0; z-index:-1; }
.onboard-preparing-art img { width:100%; height:100%; object-fit:cover; filter:saturate(1.05); transform:scale(1.02); animation:onboard-ken-burns 40s ease-in-out infinite alternate; }
.onboard-preparing-art::after,.comic-welcome-scrim { content:""; position:absolute; inset:0; background:linear-gradient(180deg, rgb(10 11 14 / .25), rgb(10 11 14 / .72) var(--poster-scrim-midpoint,60%), rgb(10 11 14 / .9)); }
@keyframes onboard-ken-burns { from { transform:scale(1.02); } to { transform:scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .onboard-preparing-art img { animation:none; } }
/* The visitor's story being prepared: a spinner, the heading and how long it takes. */
.onboard-outline-status { display:grid; justify-items:center; gap:10px; margin-top:clamp(40px,14vh,140px); text-align:center; }
.onboard-outline-status .onboard-question-title { margin:10px 0 0; }
.onboard-outline-status .onboard-question-help { margin:0; }
.onboard-outline-spinner { width:44px; height:44px; border:3px solid color-mix(in srgb, var(--text) 14%, transparent); border-top-color:var(--accent); border-radius:50%; animation:onboard-demo-spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .onboard-outline-spinner { animation-duration:2.4s; } }
/* Back, over the poster's top corner. */
.onboard button.onboard-preparing-back { position:absolute; top:clamp(14px,3vw,24px); left:clamp(14px,3vw,28px); z-index:1; margin:0; padding:8px 14px 8px 10px; border-radius:999px; background:rgb(10 11 14 / .45); color:#fff; backdrop-filter:none; }
@media (hover: hover) and (pointer: fine) { .onboard button.onboard-preparing-back:hover { background:rgb(10 11 14 / .65); color:#fff; } }
.onboard-preparing-panel { align-self:end; display:grid; gap:14px; width:min(560px,100%); padding:clamp(24px,5vw,48px); color:#fff; }
.onboard-preparing-eyebrow { margin:0; color:rgb(255 255 255 / .72); font-size:.85rem; font-weight:650; letter-spacing:.08em; text-transform:uppercase; }
.onboard-preparing-panel h1 { color:inherit; margin:0; font-size:clamp(1.7rem,4vw,2.6rem); line-height:1.15; letter-spacing:-.025em; text-wrap:balance; }
.onboard-preparing-titles { display:grid; gap:8px; min-width:0; overflow-wrap:anywhere; }
.onboard-preparing-native { margin:0; color:rgb(255 255 255 / .68); font-size:clamp(1.05rem,2.4vw,1.35rem); line-height:1.4; font-weight:500; }
.onboard-preparing-help { margin:0; color:rgb(255 255 255 / .8); line-height:1.55; }
.onboard-prep-steps { display:grid; gap:10px; margin:6px 0 0; padding:0; list-style:none; }
.onboard-prep-steps li { display:flex; align-items:center; gap:12px; color:rgb(255 255 255 / .55); transition:color .3s ease; }
.onboard-prep-steps li[data-active="true"] { color:#fff; }
.onboard-prep-steps li[data-done="true"] { color:rgb(255 255 255 / .85); }
.onboard-prep-mark { display:inline-grid; place-items:center; flex:none; width:24px; height:24px; border:1.5px solid currentColor; border-radius:50%; }
.onboard-prep-steps li[data-done="true"] .onboard-prep-mark { background:var(--success, #2f9e73); border-color:transparent; color:#fff; }
.onboard-prep-steps .word-illustration-spinner { width:14px; height:14px; }
.onboard button.onboard-start-reading { position:relative; justify-self:start; width:auto; min-width:min(280px,100%); margin-top:8px; overflow:hidden; animation:onboard-fade-up .5s var(--ease) both; }
.onboard button.onboard-start-reading::after { content:""; position:absolute; inset:0; background:linear-gradient(110deg, transparent 35%, rgb(255 255 255 / .55) 50%, transparent 65%) 0 0 / 250% 100%; animation:onboard-shimmer 2.2s ease-in-out infinite; pointer-events:none; }
@keyframes onboard-shimmer { from { background-position:150% 0; } to { background-position:-150% 0; } }
@media (prefers-reduced-motion: reduce) { .onboard button.onboard-start-reading::after { animation:none; } }
@media (max-width:760px) { .onboard-preparing { min-height:calc(100dvh - 100px); border-radius:var(--radius-lg); } }

/* Account gate inside the preview reader */
.onboard-account-gate { gap:14px; }
.onboard-account-gate h2 { margin:0; font-size:clamp(1.4rem,3.4vw,2rem); line-height:1.2; }
.onboard-account-gate .onboard-account-help { margin:0; color:var(--text-secondary); }
.onboard-account-gate .auth-legal-agreement { justify-self:stretch; text-align:start; }
.onboard-account-gate .social-sign-in { width:100%; }
.onboard-account-gate .social-sign-in-buttons { margin:8px 0; }
.onboard-account-gate .auth-divider { display:none; }
.onboard button.onboard-email-button { display:flex; align-items:center; justify-content:center; gap:12px; width:100%; min-height:48px; border-radius:8px; font-size:1rem; font-weight:500; }
.onboard-email-form { display:grid; gap:14px; width:100%; text-align:start; }
.onboard-email-form form { display:grid; gap:14px; }
.onboard-email-form h3 { margin:0; }
.onboard-email-form label { display:grid; gap:6px; font-weight:600; }
.onboard-email-form input { width:100%; }

/* Funnel refinements: emoji answers, full-width specific button, vertical story tiles */
.onboard-choice-emoji { display:inline-grid; place-items:center; flex:none !important; width:36px; height:36px; border-radius:10px; background:var(--accent-soft); color:var(--accent-ink); font-size:1.25rem; line-height:1; }
.onboard button.onboard-choice-else { border-style:dashed; }
.onboard-actions-start { justify-content:flex-start; }
.onboard button.onboard-specific { margin-top:4px; }
.onboard-stories { grid-template-columns:1fr; gap:14px; }
.onboard button.onboard-story { flex-direction:row; align-items:stretch; min-height:0; }
.onboard-story-art { width:min(200px,36vw); aspect-ratio:1; min-height:160px; }
.onboard-story-copy { flex:1; min-width:0; justify-content:center; gap:8px; padding:18px 20px; }
.onboard-story-meta { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; color:var(--text-secondary); font-size:.82rem; }
.onboard-story-language { display:inline-flex; align-items:center; gap:6px; }
.onboard-story-language .flag-icon { width:22px; height:auto; border-radius:3px; }
.onboard-story-kind { display:inline-flex; align-items:center; gap:5px; }
.onboard-story-copy h3 { font-size:1.25rem; }
.onboard-story-native { margin:-4px 0 0 !important; color:var(--text-secondary); font-weight:500; opacity:.85; }
@media (max-width:760px) { .onboard-story-art { width:120px; min-height:120px; } .onboard-story-copy { padding:14px 16px; } }

/* Interview-based next-story selection. */
dialog#story-interview {width:min(760px,calc(100vw - 24px));}
.story-interview {display:grid;grid-template-columns:minmax(0,1fr);gap:18px;}
.story-interview h2 {font-size:1.4rem;margin:0;line-height:1.3;}
.story-interview h3 {font-size:.9rem;margin:4px 0 0;}
.story-interview p {margin:0;line-height:1.5;}
.story-space-icon .vocabulary-list-art {width:44px;height:44px;flex-basis:44px;border-radius:10px;font-size:30px;}
.story-interview .onboard-specific {margin-top:4px;}
.story-interview-history,.story-interview > .story-interview-change {width:100%;}
.story-interview-topic-form,.story-interview-step,.story-interview-step form {display:grid;gap:14px;}
.story-interview-topic-form {justify-content:stretch;min-height:0;}
.story-interview-topic-form input {width:100%;height:56px;font-size:16px;}
.story-interview-options,.story-interview-ideas {display:grid;gap:10px;}
.story-interview-options button {display:flex;align-items:center;gap:12px;width:100%;text-align:start;justify-content:flex-start;padding:14px;}
.story-interview .reading-preference-options button { display:flex; align-items:center; gap:14px; width:100%; min-height:64px; padding:14px 18px; border:1px solid var(--border); border-radius:16px; background:var(--surface); color:var(--text); text-align:start; box-shadow:none; }
@media (hover: hover) and (pointer: fine) { .story-interview .reading-preference-options button:hover { border-color:var(--accent); background:var(--surface-hover); } }
.story-interview .reading-preference-options button[aria-pressed="true"] { border-color:var(--accent); background:var(--accent-soft); }
.reading-preference-options button > span:nth-child(2) { flex:1; min-width:0; overflow-wrap:anywhere; }
.reading-preference-options button > svg { flex:none; opacity:.55; }
.story-interview-selected {display:grid;gap:12px;}
.story-interview-selected .topic-card-copy h3 {font-size:1.1rem;margin:0;}
.story-interview-availability {padding:14px;border-radius:12px;background:var(--surface-alt);}
.story-interview-loading {display:flex;align-items:center;gap:10px;}
.story-interview-loading > .word-illustration-spinner {flex:none;width:22px;height:22px;}
.story-interview-step-header,.story-interview-answer-actions {display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:16px;}
.story-interview .story-interview-back {margin:0;}
.story-interview-skeleton-layout {display:grid;gap:14px;}
.story-interview-skeleton-heading {display:grid;gap:8px;padding-block:5px;}
.story-interview-skeleton-heading > .onboard-skeleton {height:1.4rem;width:78%;}
.story-interview-skeleton-heading > .onboard-skeleton:last-child {display:none;width:46%;}
.story-interview-skeleton-option {display:flex;align-items:center;gap:12px;min-height:52px;padding:14px;border:1px solid var(--border);border-radius:10px;}
.story-interview-skeleton-icon {flex:none;width:24px;height:24px;border-radius:6px;}
.story-interview-skeleton-label {width:38%;max-width:260px;height:14px;}
.story-interview-skeleton-option:nth-child(even) .story-interview-skeleton-label {width:51%;max-width:340px;}
@media (max-width:520px) {.story-interview-skeleton-heading > .onboard-skeleton:last-child {display:block;}}
@media (prefers-reduced-motion:reduce) {.story-interview-skeleton .onboard-skeleton {animation:none;}}

.story-interview-custom-answer input {width:100%;min-width:0;font-size:16px;}
button.story-interview-idea {width:100%;padding:0;background:var(--surface);color:var(--text);text-align:start;box-shadow:none;}
.story-interview-idea .cycle-idea-row,.upcoming-manager .cycle-idea-row {width:100%;min-width:0;}
@media (hover: hover) and (pointer: fine) { .story-interview-idea:hover .cycle-idea-row {background:var(--surface-alt);border-color:var(--accent);} }

/* Word and pronunciation stay in one centered layout, with audio on the reading row. */
.flashcard-pronounced-headword { --headword-audio-size: 2rem; display: grid; grid-template-columns: var(--headword-audio-size) minmax(0, auto) var(--headword-audio-size); align-items: center; justify-content: center; column-gap: 12px; max-width: 100%; width: fit-content; margin-inline: auto; }
.flashcard-pronounced-headword > .speech-control { grid-column: 1; justify-self: center; min-height: var(--headword-audio-size); }
.flashcard-pronounced-headword[data-has-reading="true"] > .speech-control { align-self: end; }
.flashcard-pronounced-headword > .speech-control .speech-button { width: var(--headword-audio-size); height: var(--headword-audio-size); min-width: var(--headword-audio-size); margin: 0; }
.flashcard-pronounced-word { grid-column: 2; min-width: 0; text-align: center; }
.flashcard-pronounced-word > :is(h2, h3, p) { margin: 0; }
.flashcard-pronounced-word > .flashcard-character-headword .reader-character-title { display: inline-flex; flex-direction: column; align-items: center; }
.flashcard-pronounced-word > :is(.flashcard-character-headword, .flashcard-whole-headword) .reader-character-reading, .flashcard-pronounced-word > .flashcard-headword-reading, .flashcard-whole-word-grid > .flashcard-headword-reading { display: flex; align-items: center; justify-content: center; min-height: var(--headword-audio-size); color: var(--text-secondary); font-size: 1.05rem; line-height: 1.35; font-weight: 400; }
.flashcard-pronounced-word > .flashcard-character-headword .reader-character-cell { gap: 4px; }
.flashcard-headword-reading { overflow-wrap: anywhere; }
@media (max-width: 480px) { .flashcard-pronounced-headword { column-gap: 6px; } }

.feed-card-metadata {justify-content:flex-end;text-align:end;font-size:.75rem;color:var(--text-secondary);overflow-wrap:anywhere;}
.feed-card-metadata .topic-age {margin:0;color:inherit;font:inherit;text-shadow:none;white-space:normal;}

/* Keep the page fullscreen control available alongside compact header actions. */
.app-header .page-fullscreen {width:40px;min-width:40px;height:40px;padding:8px;border:0;background:transparent;box-shadow:none;color:var(--text-secondary);}
@media(max-width:600px) {
 .app-header .header-logo-home {gap:6px;min-height:40px;}
 .app-header .header-home {width:20px;}
 .app-header .header-daily-xp .compact-daily-goal > span {display:none;}
 .app-header .page-fullscreen {width:34px;min-width:34px;height:36px;padding:7px;}
}
/* Generation provenance remains visible without obstructing immersive activity controls. */
button.generation-settings-notice {pointer-events:auto;display:flex;align-items:center;justify-content:flex-start;gap:8px;max-width:100%;padding:10px 14px;border:1px solid #b4a0e8;border-radius:12px;background:var(--surface);color:var(--text);font-size:.9rem;font-weight:500;text-align:start;white-space:normal;box-shadow:none;}
@media (hover: hover) and (pointer: fine) { button.generation-settings-notice:hover {border-color:#b4a0e8;background:var(--surface-hover);color:var(--text);} }
.generation-settings-notice > svg {flex:none;color:#b4a0e8;}
button.generation-settings-notice[data-compact="true"] {width:auto;min-width:0;padding:8px 10px;font-size:.75rem;line-height:1.2;}
.generation-settings-comparison {display:grid;gap:12px;}
.generation-settings-comparison + .generation-settings-actions {margin:20px 0 0;padding-top:16px;border-top:1px solid var(--border);}
.generation-settings-columns,.generation-settings-row {display:grid;grid-template-columns:1fr 1fr 1fr;align-items:start;gap:12px;overflow-wrap:anywhere;}
.generation-settings-columns {color:var(--muted);font-size:.85rem;}
.generation-settings-row {padding-top:12px;border-top:1px solid var(--border);font-size:.9rem;}
@media(max-width:520px){.generation-settings-columns {grid-template-columns:1fr 1fr;}.generation-settings-columns > span {display:none;}.generation-settings-row {grid-template-columns:1fr 1fr;}.generation-settings-row > strong {grid-column:1/-1;}}

/* Connecting AI apps (MCP): consent page and the Settings section. */
.mcp-connect-points {list-style:none;padding:0;margin:0;display:grid;gap:10px;}
.mcp-connect-points li {display:flex;align-items:flex-start;gap:10px;line-height:1.45;}
.mcp-connect-points svg {flex-shrink:0;margin-top:2px;color:var(--accent);}
.mcp-connect-return {margin:0;font-size:.82rem;color:var(--muted);}
.mcp-settings-address {display:flex;align-items:center;gap:8px;margin:4px 0 12px;padding:8px 10px;border:1px solid var(--border);border-radius:12px;background:var(--surface-subtle);}
.mcp-settings-address code {flex:1;min-width:0;font-size:.9rem;overflow-wrap:anywhere;}
.mcp-connections {list-style:none;padding:0;margin:0;display:grid;gap:8px;}
.mcp-connections li {display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border:1px solid var(--border);border-radius:12px;}
.mcp-connections li > div {display:grid;gap:2px;min-width:0;}
.mcp-connections li > div strong {overflow-wrap:anywhere;}
.mcp-connect .mcp-connect-points {margin-top:16px;}
.mcp-connect .form-actions {margin-top:22px;}
.mcp-connect .mcp-connect-return {margin-top:12px;}
.flashcard-new-label { text-transform:none; }
.retention-editor { display:grid; gap:12px; margin:16px 0; }
.retention-editor-row { display:grid; grid-template-columns:minmax(0,1fr); gap:10px; }
.retention-editor-row input[type="range"] { width:100%; min-width:0; min-height:28px; padding:0; border:0; background:transparent; accent-color:var(--accent); }
.retention-editor-row button { width:100%; justify-content:center; }

.word-progress-retention {display:grid;gap:8px;border-top:1px solid var(--border);padding-top:10px;margin-top:4px;}
.word-progress-retention-heading {display:flex;align-items:center;justify-content:space-between;gap:14px;font-size:.78rem;}
.word-progress-retention-heading > span {display:inline-flex;align-items:center;gap:6px;}
.word-progress-retention .retention-editor-row {gap:8px;margin:0;}
.word-progress-retention .retention-editor-row button {padding:7px 9px;font-size:.78rem;}
.word-progress-current-value {font-variant-numeric:tabular-nums;}

/* Word memory history: the same decay model as the learning-value controls. */
.word-history-button {flex:none;width:32px;height:32px;padding:6px;}
.reader-popup:has(.word-history-chart) {width:min(960px,calc(100vw - 24px));}
.word-history-chart {min-width:0;display:grid;gap:12px;}
.word-history-chart h3,.word-history-chart p {margin:0;}
.word-history-legend {display:flex;flex-wrap:wrap;gap:8px;}
button.word-history-key {display:inline-flex;align-items:center;gap:7px;border:1px solid var(--border);border-radius:999px;padding:7px 10px;background:var(--surface);color:var(--text);font-size:.8rem;font-weight:500;box-shadow:none;}
.word-history-key[aria-pressed="false"] {opacity:.4;}
.word-history-key strong {font-variant-numeric:tabular-nums;min-width:2ch;}
.word-history-swatch {width:14px;height:3px;border-radius:2px;background:var(--history-line);}
.word-history-plot {width:100%;min-width:0;touch-action:pan-y pinch-zoom;cursor:grab;}
.word-history-plot[data-panning="true"] {cursor:grabbing;user-select:none;-webkit-user-select:none;}
.word-history-plot[data-panning="true"] :is(.word-history-hit,.word-history-dot) {pointer-events:none;}
.word-history-plot svg {display:block;width:100%;height:auto;overflow:hidden;}
.word-history-line {fill:none;stroke:var(--history-line);stroke-width:2;stroke-linejoin:round;stroke-linecap:round;}
.word-history-series.overall .word-history-line {stroke-width:2.8;}
.word-history-line.projection {stroke-dasharray:5 5;opacity:.75;}
.word-history-dot {fill:var(--history-line);stroke:var(--surface);stroke-width:.7;}
.word-history-future {fill:var(--accent);opacity:.035;}
.word-history-now {stroke:var(--muted);stroke-width:1;stroke-dasharray:3 4;}
.word-history-cursor {stroke:var(--muted);stroke-width:.7;opacity:.4;pointer-events:none;}
.word-history-selection {font-size:.75rem;color:var(--muted);font-variant-numeric:tabular-nums;}
.word-history-timeline {display:flex;align-items:center;gap:8px;}
.word-history-timeline input {flex:1;min-width:0;width:100%;}
.word-history-zoom-icon {display:flex;flex:none;color:var(--muted);}
.word-history-zoom-level {flex:none;font-size:.75rem;min-width:3ch;text-align:end;font-variant-numeric:tabular-nums;}
.word-history-timeline .word-history-reset {flex:none;width:30px;height:30px;min-height:30px;padding:5px;}
.word-history-timeline>button:not(.word-history-reset) {flex:none;font-size:.8rem;padding:6px 9px;}
.word-history-line,.word-history-now {pointer-events:none;}
.word-history-dot {cursor:crosshair;}
.word-progress-retention-heading .word-progress-retention-value {gap:6px;flex:none;}
button.retention-edit-toggle {width:26px;height:26px;min-width:26px;min-height:26px;padding:5px;}
button.retention-edit-toggle[aria-pressed="true"] {background:var(--text);color:var(--surface);border-color:var(--text);}
.flashcard-rate-settings {display:grid;gap:12px;}
.flashcard-rate-settings h3,.flashcard-rate-settings p {margin:0;}
.flashcard-rate-settings .muted {font-size:.82rem;line-height:1.5;}

/* Answer receipts keep their title/close control outside the scrolling list. */
.anchored-popover.flashcard-recent-answers {width:min(560px,calc(100vw - 24px));padding:0;overflow:hidden;}
.anchored-popover.flashcard-recent-answers:is(.open,:popover-open) {display:flex;flex-direction:column;gap:0;}
.flashcard-recent-answers > .anchored-popover-heading {flex:none;padding:16px;border-bottom:1px solid var(--border);}
.flashcard-history-counts {padding:12px 14px;border-bottom:1px solid var(--border);}
.flashcard-history-counts .flashcard-session-count {color:var(--muted);}
.flashcard-history-scroll {flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;display:grid;align-content:start;gap:12px;padding:14px;background:var(--surface-subtle);text-align:start;}
.flashcard-recent-answers .flashcard-history-row {min-width:0;margin:0;padding:16px;gap:10px;border:1px solid var(--border);border-radius:16px;background:var(--surface);text-align:start;}
.flashcard-history-headword {display:grid;gap:5px;}
.flashcard-history-word-line {display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 12px;min-width:0;}
.flashcard-history-word-line h3 {margin:0;font-size:1.2rem;}
.flashcard-history-reading {min-width:0;color:var(--muted);font-size:1rem;overflow-wrap:anywhere;}
.flashcard-history-definition {margin:0;font-size:1rem;}
.flashcard-history-dimension {display:inline-flex;align-items:center;gap:6px;font-weight:650;}
.flashcard-recent-answers .flashcard-memory-change {padding:4px 0;}
.flashcard-recent-answers .flashcard-memory-score-row {justify-content:flex-start;}
.flashcard-recent-answers .flashcard-memory-interval,.flashcard-recent-answers .flashcard-memory-skills summary {text-align:start;}
.flashcard-memory-value[data-after="true"] {font-weight:700;}
.flashcard-memory-value {display:inline-flex;align-items:center;padding:4px 7px;border-radius:7px;background:var(--surface-hover);color:var(--muted);font-weight:650;white-space:nowrap;}
.flashcard-memory-value[data-rated="true"] {background:hsl(var(--level-hue) 78% 48% / var(--retention-opacity,.15));color:light-dark(var(--learning-ink-light,var(--text)),var(--learning-ink-dark,var(--text)));}
@media(max-width:480px) {.flashcard-history-scroll {padding:10px;gap:10px;}.flashcard-recent-answers .flashcard-history-row {padding:12px;}.flashcard-recent-answers .flashcard-memory-score-row {font-size:.85rem;}}

/* Revealed answers use one word target; pronunciation keeps its column alignment. */
.flashcard-whole-word-grid {display:grid;grid-template-columns:repeat(var(--headword-columns,1),minmax(0,1fr));column-gap:5px;row-gap:4px;width:max-content;max-width:100%;}
button.flashcard-word-info-trigger {grid-column:1 / -1;min-width:0;min-height:0;padding:3px 0;border:0;border-radius:8px;background:transparent;box-shadow:none;color:var(--text);font-family:var(--font-reading);font-size:clamp(1.75rem,5vw,2.65rem);font-weight:650;line-height:1.2;overflow-wrap:anywhere;}
/* CJK cues and revealed words must use the same glyph face and size. The
   generic serif reading stack can select a visibly different form of 周. */
.study-card :is(.flashcard-front-word, button.flashcard-word-info-trigger):is(:lang(zh), :lang(yue), :lang(nan), :lang(hak), :lang(wuu), :lang(ja), :lang(ko)) {font-family:var(--font-sans);font-size:clamp(2rem,5vw,3rem);font-weight:650;line-height:1.3;}
button.flashcard-word-info-trigger[data-aligned="true"] {display:grid;grid-template-columns:subgrid;}
@media (hover: hover) and (pointer: fine) { button.flashcard-word-info-trigger:hover {background:transparent;color:var(--accent-ink);text-decoration:underline;text-underline-offset:.14em;} }
.flashcard-whole-word-grid > .flashcard-headword-reading {grid-column:1 / -1;}

/* Dedicated flashcard examples are never clipped or ellipsized. */
.flashcard-short-example { width: 100%; margin-top: 1rem; }
.flashcard-short-example .flashcard-context { white-space: normal; overflow: visible; text-overflow: clip; max-height: none; -webkit-line-clamp: unset; }
.flashcard-example-loading, .flashcard-example-failure, .flashcard-example-retry { font-size: .85rem; }
.flashcard-example-failure { display: grid; justify-items: center; gap: 4px; }
.flashcard-example-failure .error-message { align-items: center; text-align: start; }
.flashcard-example-failure .error-details-button { width: 44px; min-width: 44px; height: 44px; }

.flashcard-session:has(.flashcard-pull-navigation) {--pull-control-height:30px;grid-template-rows:56px var(--pull-control-height) minmax(0,1fr);gap:10px;}
.flashcard-session:has(.flashcard-pull-navigation) > .study-scene {grid-row:3;}
.character-session .study-card {max-height:none;align-self:stretch;}
/* Give the session one definite viewport track. The card and its answer
   controls share the remaining space below the header and pull navigation. */
.flashcard-stage[open]:has(> .flashcard-session:not(.character-session)) {
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}
.flashcard-stage > .flashcard-session:not(.character-session) { height: auto; }
.flashcard-session:not(.character-session) > .study-scene:not(:has(.study-writing-dock, .study-feedback-actions)) {
    grid-template-rows: minmax(0, 1fr) auto;
}
.flashcard-session:not(.character-session) > .study-scene:has(.word-study-setup) {
    grid-template-rows: minmax(0, max-content) auto;
    align-content: center;
    gap: 12px;
}
/* Keep the cue visible while longer quiz choices scroll within the dock. */
.flashcard-session:not(.character-session) > .study-scene {container-type:size;}
.flashcard-session .study-answer-dock:not(.study-writing-dock) {max-height:min(60cqh,460px);}
.flashcard-session .study-dock {animation:none;}
.flashcard-session .study-dock[data-resizing="true"] {overflow:hidden;}
.flashcard-session .study-dock[data-resizing="true"] > * {overflow:hidden;}
.study-dock .flashcard-answer-cancel {flex:none;padding:8px 12px;}
.study-dock .flashcard-task-title {flex:1;}
.study-dock .flashcard-hints {margin:8px 0;}
.flashcard-session:not(.character-session) > .study-scene:not(:has(.study-dock)) {
    grid-template-rows: minmax(0, 1fr);
}
.flashcard-session:not(.character-session) .study-card {
    height: auto;
    max-height: 100%;
    align-self: center;
    display: flex;
    flex-direction: column;
}
.flashcard-session:not(.character-session) .study-card-scroll { height: auto; min-height: 0; }
.flashcard-session:not(.character-session) .study-card:not(:has(.study-card-header)) .study-card-body { min-height: 0; }
.flashcard-session .study-answer-dock:has(.flashcard-self-ratings) {padding:10px 12px;gap:8px;}
.flashcard-session .study-answer-dock:has(.flashcard-self-ratings) > p {margin:0;}
.flashcard-session .flashcard-self-ratings {flex-wrap:nowrap;gap:8px;}
.flashcard-session .flashcard-self-ratings > button {min-width:0;padding-inline:4px;}
.flashcard-pull-navigation {position:relative;z-index:5;grid-row:2;display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;justify-self:center;width:min(660px,100%);gap:.65rem;color:var(--text-secondary);}
.flashcard-session:has(.study-menu[open]) > .study-topbar {z-index:6;}
.flashcard-pull-navigation > :first-child {justify-self:end;}
.flashcard-pull-navigation > :last-child {justify-self:start;}
.flashcard-pull-navigation .icon-button {width:52px;min-width:52px;height:var(--pull-control-height);min-height:var(--pull-control-height);padding:4px;border:1px solid var(--border);border-radius:10px;background:var(--surface);}
.flashcard-pull-navigation .flashcard-pull-skip {min-width:52px;height:var(--pull-control-height);min-height:var(--pull-control-height);padding:3px 10px;border:1px solid var(--border);border-radius:10px;background:var(--surface);font-size:.85rem;}
.flashcard-pull-position {display:inline-flex;align-items:center;justify-content:center;gap:6px;height:var(--pull-control-height);min-height:var(--pull-control-height);color:var(--text-secondary);font-size:.85rem;font-weight:500;font-variant-numeric:tabular-nums;min-width:6rem;text-align:center;background:var(--surface);border:1px solid var(--border);border-radius:999px;padding:.25rem .6rem;}
@media (hover: hover) and (pointer: fine) {button.flashcard-pull-position:hover {background:var(--surface-hover);color:var(--text);}}
.flashcard-pull-hash {opacity:.66;}
.flashcard-pull-saved-dock {display:flex;flex-direction:column;justify-content:center;align-items:stretch;gap:.8rem;padding:1rem 1.3rem;}
.flashcard-saved-grade {display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:.6rem;}
.flashcard-saved-grade p {font-size:.95rem;line-height:1.35;margin:0;overflow-wrap:anywhere;}
.flashcard-saved-grade-value {padding:.45rem .9rem;border-radius:12px;background:hsl(var(--familiarity-hue) 65% 48% / .2);border:1px solid hsl(var(--familiarity-hue) 65% 48% / .5);font-weight:700;font-size:1.25rem;}
@media(max-width:600px) {.flashcard-session:has(.flashcard-pull-navigation) {--pull-control-height:38px;gap:6px;}.flashcard-pull-position {font-size:.9rem;}.flashcard-pull-navigation .flashcard-pull-skip {font-size:.9rem;}}
@media(max-height:600px) {.flashcard-session:has(.flashcard-pull-navigation) {--pull-control-height:34px;grid-template-rows:44px var(--pull-control-height) minmax(0,1fr);gap:4px;}.flashcard-pull-saved-dock {padding:.5rem 1rem;gap:.4rem;}}

/* Keep literal images and intended meanings visibly separate in phrase lists. */
.phrase-meanings {display:grid;gap:10px;min-width:0;text-align:start;}
.phrase-meanings .phrase-meaning {display:grid;gap:2px;}
.phrase-meanings p {margin:0;}
.phrase-meanings small {font-size:.78rem;font-weight:600;}

.phrase-membership-copy {display:grid;gap:2px;}
.phrase-membership-copy small {font-size:.75rem;font-weight:450;color:var(--muted);}

/* Phrase cards share word-card chrome, grading controls and skill editors. */
.phrase-session .flashcard-mode-options {display:flex;flex-wrap:wrap;justify-content:center;gap:10px;}
.phrase-session .flashcard-mode-options [aria-pressed="true"], .phrase-familiarity-filters [aria-pressed="true"] {background:var(--surface-hover);border-color:var(--text);outline:1px solid var(--text);}
.phrase-session .flashcard-setup-switches {display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:20px;margin-top:20px;}
.phrase-session .phrase-sentence {font-size:clamp(1.5rem,4vw,2rem);line-height:1.55;}
.phrase-session .phrase-meanings {text-align:center;}
.phrase-interactive-text .inline-reader {display:inline;}
.phrase-learning-control {display:inline-flex;align-items:center;gap:6px;min-width:0;}
.phrase-saving-label {font-size:.8rem;color:var(--text-secondary);animation:phrase-saving-opacity 1.6s ease-in-out infinite;}
@keyframes phrase-saving-opacity {50% {opacity:.45;}}
.phrase-familiarity-filters {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin-bottom:14px;}
.phrase-familiarity-filters button {padding:8px 4px;font-size:.82rem;}
.phrase-familiarity-rows {display:grid;gap:16px;}
.phrase-familiarity-row {padding-bottom:16px;border-bottom:1px solid var(--border);}
.phrase-dimension-values {display:flex;flex-wrap:wrap;gap:8px;margin-top:12px;}
@media(prefers-reduced-motion:reduce) {.phrase-saving-label {animation:none;}}
.phrase-dimension-headings, .phrase-dimension-values {display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:8px;}
.phrase-dimension-headings {margin:0 0 10px;color:var(--text-secondary);text-align:center;}
.phrase-dimension-headings > span {display:grid;place-items:center;}
.phrase-dimension-values .phrase-learning-control, .phrase-dimension-values .flashcard-score-chip {width:100%;}

/* Shared word rows: pronunciation belongs to the headword; the gloss has room
   for inline grammar chips rather than a separate type/pronunciation column. */
.vocabulary-compact-link {grid-template-columns:minmax(100px,1fr) minmax(160px,2fr);align-items:center;gap:18px;}
.vocabulary-headword {display:grid;gap:3px;min-width:0;}
.vocabulary-headword strong, .vocabulary-pronunciation {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.vocabulary-pronunciation {display:block;font-size:.85rem;font-weight:400;}
.vocabulary-compact-meaning .grammar-tag {display:inline-block;vertical-align:baseline;margin-inline-end:.5em;font-size:.75rem;line-height:1.4;font-weight:600;white-space:nowrap;}
.vocabulary-window .vocabulary-compact-link > .vocabulary-compact-meaning {white-space:normal;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;line-height:1.3;}
.encountered-word {display:grid;grid-template-columns:36px minmax(0,1fr) auto;align-items:center;}
.encountered-word-controls {display:grid;justify-items:end;gap:8px;min-width:0;}
.encountered-word-source {flex-direction:row;align-items:center;flex-wrap:wrap;justify-content:flex-end;max-width:100%;font-size:.75rem;}
.encountered-word-source .encounter-source-chip {max-width:240px;}
@media(max-width:760px) {
 .vocabulary-window-row > .vocabulary-compact-link, .encountered-word > .vocabulary-compact-link {grid-template-columns:minmax(0,1fr);gap:2px;line-height:1.15;}
 .vocabulary-window .vocabulary-compact-link > .vocabulary-compact-meaning {-webkit-line-clamp:2;font-size:.85rem;line-height:1.15;}
 .encountered-word {grid-template-columns:32px minmax(0,1fr);gap:6px 8px;}
 .encountered-word > .speech-control {grid-column:1;grid-row:1 / span 2;align-self:start;}
 .encountered-word > .vocabulary-compact-link {grid-column:2;grid-row:1;}
 .encountered-word-controls {grid-column:2;grid-row:2;justify-items:start;}
 .encountered-word-source {justify-content:flex-start;}
}
/* Progress labels must reserve their actual width in encounter action groups. */
.encountered-word .vocabulary-word-progress {flex:0 0 auto;max-width:100px;}
.encountered-word .vocabulary-word-progress > button.word-progress-chip {width:auto;max-width:100px;overflow:hidden;text-overflow:ellipsis;}

/* Image generation details are enabled through Developer tools. */
.image-generation-details-layer {
  position: absolute;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  overflow: clip;
}
:is(body, .theme-root) > .image-generation-details-layer { position: fixed; }
.image-generation-details-local-host { position: relative; isolation: isolate; }
.image-generation-details-layer[data-local="true"] { z-index: 3; border-radius: inherit; }

.image-generation-details-button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 50%;
  background: rgb(0 0 0 / 76%);
  color: #fff;
  pointer-events: auto;
}
.image-generation-details-panel {
  max-height:calc(100dvh - 32px);
  overflow:auto;
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  padding: 10px 12px;
  background: var(--surface, #fff);
  color: var(--text, #202020);
  border: 1px solid var(--border, #ddd);
  border-radius: 10px;
  box-shadow: var(--shadow-raised, 0 4px 16px rgb(0 0 0 / 24%));
  font-size: .8rem;
  pointer-events: auto;
}
.image-generation-details-panel dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 12px;
  margin: 0;
}
.image-generation-details-panel dt { color: var(--text-secondary, #515151); }
.image-generation-details-panel dd { margin: 0; overflow-wrap: anywhere; }

.news-sources { margin-block: 12px; font-size: .875rem; }
.news-sources ul { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 4px 0 0; padding: 0; list-style: none; }
.news-sources a { color: inherit; overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: 3px; }
.onboard-stories .news-sources { margin-inline: 18px; }
.news-attribution { opacity: .82; }

.content-opening-overview {justify-self:start;font-size:.85rem;}
.onboard-preparing-panel .content-opening-overview {color:#fff;background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.3);}

/* Revealed examples use the reader's word bubbles after an explicit analysis tap. */
button.inline-reader-analyze {display:inline;margin:0;padding:0;border:0;border-radius:2px;background:transparent;color:inherit;font:inherit;font-weight:inherit;line-height:inherit;white-space:inherit;box-shadow:none;text-align:inherit;}
button.inline-reader-analyze:disabled {opacity:1;cursor:progress;}
@media (hover: hover) and (pointer: fine) {button.inline-reader-analyze:not(:disabled):hover {background:var(--surface-hover);color:inherit;}}
.flashcard-context-row > .flashcard-example-actions {grid-column:3;justify-self:center;align-self:center;display:flex;align-items:center;justify-content:center;flex:none;width:38px;}
.flashcard-context-row.flashcard-context-audio-labeled:has(> .flashcard-context) {display:grid;grid-template-columns:auto minmax(0,auto) 40px;gap:12px;}
.reading-heading {display:flex;align-items:center;gap:1rem;margin-block:1.25rem;}
.reading-heading-thumbnail {display:block;width:clamp(3.25rem,7vw,5rem);aspect-ratio:1;object-fit:cover;border-radius:12px;}
.screen-docked-meta .reading-heading-thumbnail {width:32px;border-radius:8px;}
.reading-heading h1 {margin:0;overflow-wrap:anywhere;}
.reading-heading-meta {display:flex;align-items:center;gap:.65rem;margin-top:.5rem;color:var(--muted);}
.reading-heading-meta .topic-age {margin:0;color:inherit;text-shadow:none;font-weight:400;}
.reading-heading-open {display:inline-grid;place-items:center;flex:none;width:38px;height:38px;padding:0;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--text);}
[dir="rtl"] .reading-heading-open svg {transform:scaleX(-1);}
/* Reading mode: the chosen mode is in colour and opaque, the others greyscale and faded. */
.reading-modes {display:grid;gap:8px;margin:6px 0 0;}
.reading-modes-label {margin:0;font-size:.78rem;font-weight:650;letter-spacing:.06em;text-transform:uppercase;color:var(--text-secondary);}
.reading-mode-options {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(6px,1vw,12px);}
button.reading-mode {--mode-color:#8df5d2;--mode-ink:light-dark(#176b59,#9aefd4);display:grid;grid-template-columns:clamp(64px,8vw,92px) minmax(0,1fr);align-items:center;justify-content:stretch;gap:clamp(8px,1.2vw,14px);width:100%;min-height:78px;padding:8px 14px 8px 8px;border:1px solid var(--border);border-radius:16px;background:var(--surface);color:var(--text);font-weight:inherit;text-align:start;white-space:normal;box-shadow:none;transition:border-color .18s ease,background-color .18s ease,box-shadow .18s ease;}
button.reading-mode[data-mode="guided"] {--mode-color:#85caff;--mode-ink:light-dark(#246598,#8ed0ff);}
button.reading-mode[data-mode="full"] {--mode-color:#b9a4ec;--mode-ink:light-dark(#62499c,#c9b8f2);}
.reading-mode-art {display:block;height:60px;overflow:hidden;border-radius:11px;background:color-mix(in srgb,var(--text) 5%,transparent);}
.reading-mode-art img {display:block;width:100%;height:100%;object-fit:cover;filter:grayscale(1);opacity:.45;transition:filter .2s ease,opacity .2s ease;}
.reading-mode-copy {display:grid;gap:4px;min-width:0;}
.reading-mode-title {font-size:1rem;font-weight:700;line-height:1.25;opacity:.5;transition:opacity .2s ease;overflow-wrap:anywhere;}
.reading-mode-meta {display:flex;flex-wrap:wrap;align-items:center;gap:4px 6px;min-height:1.25rem;font-size:.75rem;color:var(--text-secondary);opacity:.55;transition:opacity .2s ease;}
.reading-mode-meta:empty {display:none;}
.reading-mode-done {display:inline-flex;align-items:center;gap:3px;color:var(--success);font-weight:650;}
.reading-mode-progress {font-variant-numeric:tabular-nums;font-weight:650;}
button.reading-mode[data-selected="true"] {border-color:var(--mode-color);box-shadow:inset 0 0 0 1px var(--mode-color);background:linear-gradient(110deg,color-mix(in srgb,var(--mode-color) 16%,transparent),transparent 72%),var(--surface);}
.reading-mode[data-selected="true"] .reading-mode-art img {filter:none;opacity:1;}
.reading-mode[data-selected="true"] .reading-mode-title {opacity:1;color:var(--mode-ink);}
.reading-mode[data-selected="true"] .reading-mode-meta {opacity:1;}
@media (hover: hover) and (pointer: fine) {
    button.reading-mode:hover {background:var(--surface);color:var(--text);border-color:color-mix(in srgb,var(--mode-color) 60%,var(--border));}
    button.reading-mode[data-selected="true"]:hover {background:linear-gradient(110deg,color-mix(in srgb,var(--mode-color) 16%,transparent),transparent 72%),var(--surface);border-color:var(--mode-color);}
    .reading-mode:not([data-selected="true"]):hover .reading-mode-art img {opacity:.7;filter:grayscale(.6);}
    .reading-mode:not([data-selected="true"]):hover :is(.reading-mode-title,.reading-mode-meta) {opacity:.8;}
}
.reading-mode-help {margin:0;font-size:.85rem;line-height:1.45;color:var(--text-secondary);}
@media (max-width:640px) {
    button.reading-mode {grid-template-columns:minmax(0,1fr);justify-items:center;gap:6px;min-height:0;padding:8px 6px 10px;text-align:center;}
    .reading-mode-art {width:100%;max-width:104px;height:52px;}
    .reading-mode-title {font-size:.9rem;}
    .reading-mode-meta {justify-content:center;}
}
@media (prefers-reduced-motion:reduce) { button.reading-mode,.reading-mode-art img,.reading-mode-title,.reading-mode-meta {transition:none;} }
.topic-page > .topic-vocabulary-progress {margin-top:clamp(6px,1vw,10px);}
.topic-page .home-feature-section > .section-heading.topic-learning-heading:first-child {margin-top:8px;}

/* Unfinished activities appear only in developer tools mode. */
.developer-badge {display:inline-flex;align-items:center;padding:2px 7px;border:1px dashed color-mix(in srgb,var(--warning) 70%,transparent);border-radius:6px;background:var(--warning-soft);color:var(--warning-ink);font-size:.66rem;font-weight:750;letter-spacing:.08em;line-height:1.3;}

/* Full reading: comprehension questions between paragraphs. XP purple until
   every point is earned, then success green. */
.reader-question {--question-color:var(--xp);--question-soft:var(--xp-soft);display:block;margin:1.1em 0;border:1px solid color-mix(in srgb,var(--question-color) 38%,var(--border));border-radius:16px;background:linear-gradient(105deg,var(--question-soft),color-mix(in srgb,var(--question-soft) 35%,var(--surface)) 70%);color:var(--text);font-size:inherit;line-height:inherit;transition:border-color .25s ease,background .25s ease;}
.reader-question[data-state="complete"] {--question-color:var(--success);--question-soft:var(--success-soft);}
.reader-question[data-open="true"] {box-shadow:var(--shadow);}
button.reader-question-summary {display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;justify-content:stretch;gap:10px 12px;width:100%;padding:12px 14px;border:0;border-radius:15px;background:transparent;color:inherit;font-weight:inherit;text-align:start;white-space:normal;box-shadow:none;}
@media (hover: hover) and (pointer: fine) { button.reader-question-summary:hover {background:color-mix(in srgb,var(--question-color) 8%,transparent);} }
button.reader-question-summary:active {transform:none;}
.reader-question-mark {display:grid;place-items:center;width:34px;height:34px;border-radius:50%;background:var(--question-color);color:var(--surface);}
.reader-question-mark {justify-self:start;}
.reader-question-status {display:flex;align-items:center;justify-content:flex-end;gap:8px;min-width:0;flex-wrap:wrap;}
.reader-question-score {font-family:var(--font-sans);font-size:.85rem;font-weight:700;white-space:nowrap;}
.reader-question-score[data-level="high"] {color:var(--success);}
.reader-question-score[data-level="mid"] {color:var(--warning-ink);}
.reader-question-score[data-level="low"] {color:var(--danger);}
.reader-question-eyebrow {text-align:center;color:var(--question-color);font-size:.7rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;}
.reader-question-xp {padding:3px 10px;border:1px solid color-mix(in srgb,var(--question-color) 45%,transparent);border-radius:999px;background:color-mix(in srgb,var(--question-color) 12%,var(--surface));color:var(--question-color);font-size:.78rem;font-weight:700;white-space:nowrap;}
.reader-question-chevron {display:grid;place-items:center;color:var(--text-secondary);transition:transform .2s ease;}
.reader-question[data-open="true"] .reader-question-chevron {transform:rotate(180deg);}
.reader-question-body {display:grid;gap:12px;padding:4px 14px 14px;}
.reader-question-prompt {display:flex;align-items:flex-start;gap:8px;padding:10px 12px;border-radius:12px;background:color-mix(in srgb,var(--surface) 82%,transparent);}
.reader-question-prompt .speech-button {flex:none;margin:0;}
.reader-question-prompt-copy {display:grid;gap:2px;min-width:0;}
.reader-question-prompt-text {margin:0;font-size:inherit;font-weight:inherit;line-height:inherit;overflow-wrap:anywhere;}
.reader-question-prompt-text .reader-unprocessed:not(:is(.reader-word-bubble,.anchored-popover) *) {color:inherit;opacity:1;}
.reader-question .reader-question-translation {margin:0;}
.reader-question-form {display:grid;gap:8px;}
.reader-question-form > label {color:var(--text-secondary);font-size:.78rem;font-weight:650;}
.reader-question-form textarea {width:100%;background:var(--surface);font-family:var(--font-reading);font-size:inherit;line-height:inherit;}
.reader-question-actions {display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px;}
.reader-question-tip {margin-inline-end:auto;color:var(--text-secondary);font-size:.78rem;line-height:1.35;}
.reader-question-submitted {display:grid;gap:4px;}
.reader-question-submitted p {margin:0;padding:8px 12px;border:1px solid var(--border);border-radius:12px;background:var(--surface);overflow-wrap:anywhere;}
.reader-question-checking {display:flex;align-items:center;gap:8px;color:var(--text-secondary);font-size:.9rem;}
.reader-question-review {display:grid;gap:10px;}
.reader-question .error {margin:0;}
/* The tile's own labels use the interface font; question and answer text keep the reading font. */
.reader-question :is(.reader-question-eyebrow,.reader-question-xp,.reader-question-translation,.reader-question-form>label,.reader-question-tip,.reader-question-actions,.reader-question-checking,.describe-scores,.describe-feedback,.describe-answer-label,.describe-note,.error) {font-family:var(--font-sans);}
/* The writing feedback was drawn for the dark picture stage; use page colours here. */
.reader-question .describe-score {background:color-mix(in srgb,var(--text) 7%,transparent);}
.reader-question .describe-score dt,.reader-question .describe-score-overall>span:not(.describe-xp-chip),.reader-question .describe-answer-label {color:var(--text-secondary);}
.reader-question :is(.describe-score[data-level="high"] dd,.describe-score-overall[data-level="high"] strong) {color:var(--success);}
.reader-question :is(.describe-score[data-level="mid"] dd,.describe-score-overall[data-level="mid"] strong) {color:var(--warning-ink);}
.reader-question :is(.describe-score[data-level="low"] dd,.describe-score-overall[data-level="low"] strong) {color:var(--danger);}
.reader-question .describe-feedback {border-color:var(--warning);}
.reader-question .describe-feedback[data-accepted="true"] {border-color:var(--success);}
.reader-question .describe-annotated-text {font-size:inherit;line-height:inherit;border-color:var(--border);background:var(--surface);}
.reader-question .describe-mark,.reader-question .describe-note {--mark:var(--warning);}
.reader-question :is(.describe-mark,.describe-note)[data-kind="good"] {--mark:var(--success);}
.reader-question :is(.describe-mark,.describe-note)[data-kind="error"] {--mark:var(--danger);}
.reader-question .describe-note {background:color-mix(in srgb,var(--mark) 9%,var(--surface));}
.reader-question .describe-note strong {color:color-mix(in srgb,var(--mark) 80%,var(--text));}
@media (max-width:560px) {
    button.reader-question-summary {padding:10px 12px;}
    .reader-question-mark {width:28px;height:28px;}
    .reader-question-chevron {display:none;}
    .reader-question-body {padding-inline:10px;}
}
@media (prefers-reduced-motion:reduce) { .reader-question,.reader-question-chevron {transition:none;} }

/* Dictation beside text is a peer of Send, rather than a standalone voice activity. */
[data-text-voice="true"] { --composer-control-size: 44px; }
.assistant-composer[data-text-voice="true"] { --composer-control-size: 38px; }
[data-text-voice="true"] button:is(.voice-record-button, .guided-mic-button, .flashcard-mic-button, .assistant-send) {
    box-sizing: border-box; display: inline-grid; place-items: center; flex: none;
    width: var(--composer-control-size); height: var(--composer-control-size);
    min-width: var(--composer-control-size); min-height: var(--composer-control-size);
    padding: 0; border-radius: 50%;
}
[data-text-voice="true"] :is(.voice-record-button, .guided-mic-button, .flashcard-mic-button) {
    border: 1px solid var(--border-strong);
}
[data-text-voice="true"] :is(.voice-record-button, .guided-mic-button, .flashcard-mic-button):not([aria-pressed="true"],[aria-busy="true"],[data-state="recording"],[data-state="permission"],[data-state="busy"]) {
    background: transparent; color: var(--text); box-shadow: none;
}
[data-text-voice="true"] :is(.voice-record-button, .guided-mic-button, .flashcard-mic-button) svg { width: 20px; height: 20px; }
[data-text-voice="true"] button[type="submit"] { min-height: var(--composer-control-size); }
[data-text-voice="true"] .recording-auto-button { display: none; }
[data-text-voice="true"][data-has-text="true"] button[type="submit"] { background: #2878d0; border-color: #2878d0; color: #fff; }
@media (hover: hover) and (pointer: fine) {
    [data-text-voice="true"] :is(.voice-record-button, .guided-mic-button, .flashcard-mic-button):not(:disabled,[aria-pressed="true"],[aria-busy="true"],[data-state="recording"],[data-state="permission"],[data-state="busy"]):hover { background: var(--surface-hover); }
    [data-text-voice="true"][data-has-text="true"] button[type="submit"]:not(:disabled):hover { background: #2067b6; border-color: #2067b6; }
}

/* Checkpoint answers sit above the persistent reader navigation. */
.comic-interstitial {top:calc(var(--guided-trail-bottom, calc(max(16px, env(safe-area-inset-top)) + 86px)) + 12px);bottom:calc(var(--comic-footer-height,76px) + 16px)}
.comic-question-panel {margin-block:0}
.comic-question-dock {padding:16px;gap:10px}
.comic-question-dock>form.guided-translation {gap:8px}
.comic-question-actions>label {margin-inline-end:auto;color:var(--muted)}
@media(max-width:600px),(max-height:600px){
 .comic-interstitial {bottom:calc(var(--comic-footer-height,68px) + 10px);gap:12px}
 .comic-question-dock {padding:12px}
 .content-reading-actions {gap:8px}
}

.flashcard-draw-reasons { display: flex; gap: .25rem; }
button.ghost.flashcard-draw-reason { color: #c77816 !important; padding: .25rem; min-width: 28px; min-height: 28px; }

button.vocabulary-edit-icon { padding: 0; flex-shrink: 0; background: transparent; border: 0; }

.vocabulary-parts-of-speech { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.vocabulary-parts-of-speech .grammar-tag { margin-inline-end: 0; }
.vocabulary-window .vocabulary-compact-link > .vocabulary-compact-meaning { display: block; }
.vocabulary-short-definition { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }

/* Let the disclosure own the tile's padding so its whole surface is interactive. */
.vocabulary-progress-summary.surface:has(> .topic-vocabulary-open) { padding: 0; }
.vocabulary-progress-summary.surface > .topic-vocabulary-open { padding: 16px 18px; }
.study-list-toolbar[data-compact="true"] .study-list-summary > .vocabulary-progress-summary.surface:has(> .topic-vocabulary-open) { padding: 0; }
.study-list-toolbar[data-compact="true"] .vocabulary-progress-summary.surface > .topic-vocabulary-open { padding: 5px 8px; }

.list-familiarity-header-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.vocabulary-familiarity-popup > .reader-popup-heading { justify-content:flex-start; flex-wrap:wrap; }
.vocabulary-familiarity-popup > .reader-popup-heading h2 { flex:0 1 auto; }
.vocabulary-familiarity-popup > .reader-popup-heading > .icon-button { margin-inline-start:auto; }
.list-familiarity-header-actions .vocabulary-collection-progress { padding:10px 14px; border-radius:12px; }
@media (max-width:600px) {
 .list-familiarity-header-actions { order:3; flex-basis:100%; gap:8px; }
 .list-familiarity-header-actions button { padding:8px 10px; }
}
@media (max-width:600px) {
 .list-familiarity-header-actions .vocabulary-practice-button { min-width:0; }
 .list-familiarity-header-actions { gap:6px; }
 .list-familiarity-header-actions .vocabulary-collection-progress { padding:8px 10px; }
}

/* Control labels behave like native controls, including nested icon/text spans. */
:is(button, [role="button"], .button-link, summary, input[type="button"], input[type="submit"], input[type="reset"]),
:is(button, [role="button"], .button-link, summary) * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none;
}
/* Custom controls can contain editable fields; keep their text editable. */
:is(button, [role="button"], .button-link, summary) :is(input, textarea, [contenteditable="true"], [contenteditable="true"] *) {
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* Study shells must never become secondary scrolling surfaces on iOS.
   Only the card content and answer dock own vertical touch scrolling. */
.flashcard-stage:has(> .flashcard-session) { overflow: clip; }
.flashcard-session .study-card { overflow: clip; }
.flashcard-session :is(.study-card-scroll, .study-dock) { overscroll-behavior: none; }

/* Prerequisite-blocked skills remain visible, but are not eligible for a draw. */
.flashcard-score-cell[data-prerequisite-locked="true"] > .flashcard-score-chip {text-decoration:underline;text-decoration-color:#e49738;text-decoration-thickness:2px;text-underline-offset:5px;}

.flashcard-motion-speed {display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:8px;}
.flashcard-motion-speed input {grid-column:1 / -1;width:100%;margin:0;}
.flashcard-motion-speed output {font-variant-numeric:tabular-nums;color:var(--muted);font-size:.85rem;}
.flashcard-stage[data-flashcard-animations="false"]:has(.flashcard-session) *,
.flashcard-stage[data-flashcard-animations="false"]:has(.flashcard-session) *::before,
.flashcard-stage[data-flashcard-animations="false"]:has(.flashcard-session) *::after {animation:none !important;transition:none !important;}

.flashcard-session .study-card[data-kind="waiting-next"] {background:transparent;border:0;box-shadow:none;}
.flashcard-session .study-card[data-kind="waiting-next"]::before {display:none;}
.flashcard-next-status {display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;text-align:center;padding:1rem;}
.flashcard-next-status .flashcard-save-error {position:static;transform:none;}

.flashcard-next-status .spinner {display:block;width:2rem;height:2rem;border:3px solid currentColor;border-right-color:transparent;border-radius:50%;opacity:.65;animation:flashcard-next-spin 1s linear infinite;}
@keyframes flashcard-next-spin {to {transform:rotate(360deg);}}

/* Shared word-memory practice. Only the drawing surface captures gestures. */
.memory-helper-popup {width:min(36rem,calc(100vw - 1.5rem));}
.memory-helper-popup .reader-popup-body {padding:clamp(1rem,3vw,1.5rem);}
.memory-helper [hidden], .memory-write [hidden] {display:none !important;}
.memory-helper-tabs {display:flex;gap:.5rem;justify-content:center;margin-bottom:1.25rem;}
.memory-helper-tabs > button {flex:1;justify-content:center;max-width:14rem;}
.memory-helper-button {display:inline-flex;align-items:center;justify-content:center;gap:.4rem;}
.memory-helper-target {text-align:center;margin-bottom:1.25rem;}
.memory-helper-word-frame {position:relative;}
.memory-helper-target-word {display:flex;justify-content:center;flex-wrap:wrap;gap:.06em;font-size:clamp(2rem,7vw,3rem);line-height:1.4;}
.memory-helper-target-word > span {border-bottom:3px solid transparent;}
.memory-helper-target-word > [role="button"], .memory-write-word > [role="button"] {cursor:pointer;touch-action:manipulation;border-radius:.15em;}
@media (hover:hover) and (pointer:fine) {
 .memory-helper-target-word > [role="button"]:hover, .memory-write-word > [role="button"]:hover {background:color-mix(in srgb,currentColor 10%,transparent);}
}
.memory-helper-target-word > [role="button"]:active, .memory-write-word > [role="button"]:active {background:color-mix(in srgb,currentColor 16%,transparent);}
.memory-helper-word-mask {display:none;position:absolute;inset:0;align-items:center;justify-content:center;flex-wrap:wrap;gap:.45em;font-size:clamp(2rem,7vw,3rem);pointer-events:none;}
.memory-helper-word-mask > span {width:.18em;height:.18em;border-radius:50%;background:currentColor;opacity:.3;}
.memory-helper[data-mode="identify"] .memory-helper-target-word {opacity:0;pointer-events:none;user-select:none;-webkit-user-select:none;}
.memory-helper[data-mode="identify"] .memory-helper-word-mask {display:flex;}
.memory-helper[data-mode="write"] .memory-helper-target[data-stroke-word="true"] .memory-helper-target-word > span {opacity:.5;}
.memory-helper[data-mode="write"] .memory-current-character {border-bottom-color:currentColor;}
.memory-helper[data-mode="write"] .memory-character-complete {color:#36ac79;}
.memory-helper-meaning {margin-top:.35rem;line-height:1.4;color:var(--muted);}
.memory-write {display:flex;flex-direction:column;align-items:center;gap:.75rem;text-align:center;}
.memory-write-word {display:flex;justify-content:center;flex-wrap:wrap;gap:.22em;font-size:clamp(2rem,7vw,3rem);line-height:1.4;}
.memory-write-word > span {opacity:.5;border-bottom:3px solid transparent;min-width:.65em;transition:color .15s;}
.memory-write-word > .memory-current-character {border-bottom-color:currentColor;}
.memory-write-word > .memory-character-complete {color:#36ac79;opacity:1;}
.memory-write-instruction {margin:0;min-height:2.5em;font-size:.9rem;line-height:1.4;max-width:26rem;}
.memory-write-stage {position:relative;width:100%;display:flex;align-items:center;justify-content:center;min-height:8rem;}
.memory-write canvas {display:block;flex:none;width:min(100%,20rem);height:auto;aspect-ratio:1;touch-action:none;border:1px solid var(--border);border-radius:1rem;cursor:crosshair;}
.memory-type {position:relative;width:100%;min-height:5rem;border:1px solid var(--border);border-radius:1rem;font-size:clamp(1.5rem,6vw,2.75rem);font-family:monospace;line-height:1.5;text-align:start;overflow:hidden;}
.memory-type input, .memory-type-ghost, .memory-type-letters {font:inherit;letter-spacing:inherit;line-height:inherit;white-space:pre;padding:1rem;width:100%;box-sizing:border-box;text-align:inherit;}
.memory-type input {position:relative;display:block;margin:0;border:0;border-radius:inherit;background:transparent;color:transparent;caret-color:var(--text);-webkit-text-fill-color:transparent;box-shadow:none;}
.memory-type-ghost, .memory-type-letters {position:absolute;inset:0;pointer-events:none;}
.memory-type-ghost {opacity:.25;}
.memory-type-letters {color:var(--text);}
.memory-wrong-letter {color:#e26670;text-decoration:underline;text-decoration-thickness:2px;text-underline-offset:.15em;}
.memory-write-success .memory-type-letters {color:#36ac79;}
.memory-write-pulse {position:absolute;inset:0;pointer-events:none;border-radius:1rem;background:#36ac79;opacity:0;}
.memory-pulse-on {animation:memory-success-pulse .3s ease-out;}
@keyframes memory-success-pulse {0% {opacity:.3;transform:scale(.98);}100% {opacity:0;transform:scale(1.02);}}
.memory-write-feedback, .memory-identify-feedback {min-height:1.5em;font-size:.9rem;color:var(--muted);text-align:center;}
.memory-write-tools {display:flex;align-items:center;justify-content:center;gap:.75rem;}
.memory-write-ghost[aria-pressed="true"] > svg:last-child, .memory-write-ghost[aria-pressed="false"] > svg:first-child {display:none;}
.memory-stroke-source {max-width:28rem;font-size:.65rem;line-height:1.4;opacity:.75;}
.memory-helper-status {min-height:16rem;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1rem;text-align:center;}
.memory-helper-status .spinner {display:block;width:2rem;height:2rem;border:3px solid currentColor;border-right-color:transparent;border-radius:50%;opacity:.6;animation:flashcard-next-spin 1s linear infinite;}
.memory-identify-heading {display:flex;align-items:center;gap:1rem;margin-bottom:1rem;}
.memory-identify-heading p {margin:0;flex:1;line-height:1.4;color:var(--muted);}
.memory-identify-heading button {flex:none;}
.memory-identify-options {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;}
.memory-identify-option {position:relative;width:100%;min-width:0;box-sizing:border-box;min-height:5rem;display:flex;align-items:center;justify-content:center;gap:.5rem;padding:.75rem 2rem;font-size:clamp(1.4rem,5vw,2rem);transition:background-color .25s,color .25s,border-color .25s;}
.memory-identify-option > span:first-child {overflow-wrap:anywhere;}
.memory-identify-mark {position:absolute;right:.5rem;display:flex;align-items:center;}
button.memory-identify-option[data-result="wrong"] {background:color-mix(in srgb,#df5865 16%,var(--surface));border-color:#df5865;color:#df5865;opacity:.7;}
button.memory-identify-option[data-result="correct"] {background:color-mix(in srgb,#36ac79 20%,var(--surface));border-color:#36ac79;color:#36ac79;opacity:1;}
.memory-identify-feedback {margin-top:1rem;}
.memory-listen-options {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;}
.memory-listen-option {position:relative;min-width:0;border:1px solid var(--border);border-radius:1rem;padding:.3rem;transition:background-color .2s,border-color .2s;}
.memory-listen-option .speech-control, .memory-listen-option .speech-button {width:100%;}
.memory-listen-option .speech-button {height:3.7rem;background:transparent;color:inherit;justify-content:center;}
.memory-listen-option .speech-button-label {font-size:1.1rem;}
.memory-listen-option[data-selected="true"] {border-color:var(--text);background:color-mix(in srgb,var(--text) 8%,var(--surface));box-shadow:inset 0 0 0 1px currentColor;}
.memory-listen-option[data-result="correct"] {border-color:#36ac79;background:color-mix(in srgb,#36ac79 16%,var(--surface));color:#36ac79;}
.memory-listen-option[data-result="wrong"] {border-color:#df5865;background:color-mix(in srgb,#df5865 16%,var(--surface));color:#df5865;}
.memory-listen-result {position:absolute;right:.5rem;top:.45rem;pointer-events:none;display:flex;}
.memory-listen-check {width:100%;justify-content:center;margin-top:1rem;}
@media (prefers-reduced-motion:reduce) {.memory-pulse-on {animation:none;}.memory-identify-option {transition:none;}}

.flashcard-partial-reveals {display:flex;flex-wrap:wrap;justify-content:center;gap:12px;}

/* Device-local power saving: no live backdrop filtering or foreground blur.
   Keep modal scrims and pointer handling intact. Important also covers inline
   filters and top-layer dialog backdrops, including activity stylesheets. */
:root[data-disable-blur="true"] { --app-blur-filter: none; }
:root[data-disable-blur="true"] *,
:root[data-disable-blur="true"] *::before,
:root[data-disable-blur="true"] *::after,
:root[data-disable-blur="true"] *::backdrop {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}
:root[data-disable-blur="true"] .flashcard-stage::backdrop { background: rgb(8 12 18 / .9); }
/* Retain image dimming for readable controls when removing image blur. */
:root[data-disable-blur="true"] :is(.comic-background,.comic-page-layer)::before { filter: brightness(.7); }
:root[data-disable-blur="true"] .describe-background img { filter: brightness(.48); }
:root[data-disable-blur="true"] .listening-stage .loading-cover-backdrop>img { filter: saturate(1.15) brightness(.72); }
:root[data-disable-blur="true"] .comic-scrim-backdrop::before,
:root[data-disable-blur="true"] .comic-scrim-fill { background-image: none; }
.blur-power-setting { display: grid; gap: 8px; }
.blur-power-setting .switch-row { margin: 0; }

/* Dedicated practice routes replace the app shell rather than blurring it. */
.flashcard-stage.flashcard-screen { background: var(--bg); }
.flashcard-screen::backdrop { background: var(--bg); -webkit-backdrop-filter: none !important; backdrop-filter: none !important; animation: none; }
/* Foreground viewport repair must not replay the answer area's entrance. */
.flashcard-screen .study-dock { animation: none; }

.art-style-auto-preview {display:grid;place-items:center;width:105px;height:105px;background:var(--surface-subtle);color:var(--text-secondary);border-radius:12px;}

/* Writer: a quiet sheet with persistent version and feedback controls. */
.writer-library,.writer-page{width:100%;max-width:var(--page-column-width,1000px);margin:0 auto;padding:0}
.writer-library .page-header{display:flex;align-items:center;justify-content:space-between;gap:16px}
.writer-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:18px;margin-top:32px}
.writer-card{display:grid;grid-template-columns:auto minmax(0,1fr);align-content:center;gap:4px 12px;aspect-ratio:8/3;border:1px solid var(--border);border-radius:18px;padding:12px 16px;background:var(--surface);color:inherit;text-decoration:none}
.writer-card > .shell-icon{grid-row:span 2;align-self:center}
.writer-card h2{font-size:1.2rem;margin:0;overflow-wrap:anywhere}.writer-card span{opacity:.65;font-size:.85rem}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .writer-card:hover { border-color:var(--accent);transform:translateY(-2px) } }
.writer-empty{text-align:center;border:1px dashed var(--border);border-radius:20px;padding:70px 24px;margin-top:30px}.writer-empty .shell-icon{margin:auto}
.writer-paper{border:1px solid var(--border);border-radius:20px;background:var(--surface);margin-top:16px;padding:24px 36px;box-shadow:0 12px 40px #00000005}
.writer-toolbar,.writer-tools,.writer-mode,.writer-footer,.writer-sentence-heading{display:flex;align-items:center;justify-content:space-between;gap:12px}
.writer-toolbar{padding-bottom:22px;border-bottom:1px solid var(--border)}.writer-tools{justify-content:flex-end}
.writer-mode{gap:3px;border-radius:12px;padding:4px;background:var(--bg)}.writer-mode button{min-width:65px}.writer-mode button[aria-pressed=true],.writer-feedback-toggle[aria-pressed=true]{background:var(--surface);box-shadow:0 1px 5px #00000010;color:var(--accent)}
.writer-actions-popover{width:290px;max-width:calc(100vw - 24px);padding:6px}.writer-menu{display:flex;flex-direction:column}
.writer-menu button{display:block;width:100%;text-align:left;background:transparent;color:inherit;border:0;box-shadow:none;border-radius:8px;padding:12px;font-size:.9rem}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .writer-menu button:hover { background:var(--bg) } }
.writer-title-input,.writer-title{font-size:2rem!important;font-weight:650;line-height:1.3;margin:28px 0 20px!important;letter-spacing:-.035em;overflow-wrap:anywhere}
.writer-paper > .screen-supertitle {margin-top:22px;}
.writer-paper > :is(.writer-title,.writer-title-input) {margin-top:0!important;}
input.writer-title-input{border:0;background:transparent;padding:0;width:100%;box-shadow:none;border-radius:0}
textarea.writer-textarea{display:block;width:100%;min-height:430px;resize:vertical;border:0;box-shadow:none;background:transparent;padding:0;line-height:1.95;font-size:1.2rem;border-radius:0}
.writer-textarea:focus,.writer-title-input:focus{outline:2px solid var(--accent);outline-offset:6px}
.writer-reading{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.95;font-size:1.2rem;min-height:390px}
.writer-footer{border-top:1px solid var(--border);margin-top:24px;padding-top:20px;font-size:.8rem;flex-wrap:wrap}.writer-footer .button-row{margin:0}
.writer-history{display:grid;grid-template-columns:210px 1fr;gap:24px}.writer-version-list{display:flex;flex-direction:column;gap:8px;max-height:65vh;overflow:auto}
.writer-version{display:flex;flex-direction:column;gap:5px;align-items:flex-start!important;text-align:left}.writer-version span{font-size:.78rem;opacity:.7}.writer-version[aria-pressed=true]{background:var(--bg)}
.writer-version-preview p{white-space:pre-wrap;overflow-wrap:anywhere;max-height:50vh;overflow:auto;line-height:1.8}
.writer-analysis-loading{display:flex;align-items:center;gap:15px;padding:45px 0;line-height:1.6}
.writer-sentence{border:1px solid var(--border);border-radius:14px;margin:16px 0;padding:20px}.writer-sentence-heading>span{font-size:.75rem;opacity:.6;text-transform:uppercase;letter-spacing:.06em}
.writer-sentence-heading button{font-size:.8rem}.writer-sentence-text{line-height:1.9;font-size:1.25rem;overflow-wrap:anywhere}.writer-guidance{border-top:1px solid var(--border);padding-top:16px;line-height:1.7}
@media(max-width:600px){.writer-paper{padding:18px;border-radius:15px}.writer-toolbar{gap:5px}.writer-tools{gap:3px}.writer-mode button{min-width:48px;padding:8px}.writer-feedback-toggle{padding:8px}.writer-title-input,.writer-title{font-size:1.7rem!important}.writer-textarea{min-height:52vh!important}.writer-footer{gap:16px}.writer-footer .button-row{width:100%;justify-content:flex-end}.writer-history{grid-template-columns:1fr}.writer-version-list{max-height:22vh}.writer-sentence{padding:14px}.writer-library .page-header h1{font-size:1.8rem}}
.writer-version time{font-size:.72rem;opacity:.6}
.writer-sentence .describe-annotated-text{background:var(--surface);border-color:var(--border);font-size:1.2rem;padding:12px 0;border:0}
.writer-sentence :is(.describe-mark,.describe-note){--mark:var(--warning)}
.writer-sentence :is(.describe-mark,.describe-note)[data-kind=good]{--mark:var(--success)}
.writer-sentence :is(.describe-mark,.describe-note)[data-kind=error]{--mark:var(--danger)}
.writer-sentence .describe-note{background:color-mix(in srgb,var(--mark) 9%,var(--surface));padding:12px}
.writer-sentence .describe-note strong{color:color-mix(in srgb,var(--mark) 80%,var(--text))}
.writer-sentence .describe-answer-label{display:none}

.writing-reader{position:relative}.writing-reader-text{white-space:pre-wrap;overflow-wrap:anywhere}
.writer-sentence-text{margin:18px 0}.writer-sentence .writing-reader-text{white-space:normal}.writing-reader .describe-mark .reader-word-source{text-decoration:underline;text-decoration-color:var(--mark);text-decoration-thickness:3px;text-underline-offset:5px}
.writing-reader .describe-mark[data-selected=true]{background:color-mix(in srgb,var(--mark) 13%,transparent)}

/* Equal side tracks keep the category centered regardless of status width. */
.flashcard-heading-row {display:grid;grid-template-columns:minmax(0,1fr) max-content minmax(0,1fr);align-items:center;min-height:22px;width:100%;}
.flashcard-heading-row > .study-card-eyebrow {grid-column:2;grid-row:1;white-space:nowrap;}
.flashcard-heading-row > .flashcard-state-chip {grid-column:3;grid-row:1;justify-self:start;margin-inline-start:8px;}
.flashcard-state-chip {display:inline-flex;align-items:center;min-height:22px;padding:3px 7px;border-radius:7px;border:1px solid color-mix(in srgb,var(--state-color) 36%,transparent);background:color-mix(in srgb,var(--state-color) 16%,var(--surface));color:var(--state-color);font-size:.7rem;line-height:1.3;font-weight:650;letter-spacing:.02em;white-space:nowrap;}
.study-card-header:has(.flashcard-heading-row) .flashcard-card-list-action {top:56px;}
.flashcard-state-chip[data-state="new"] {--state-color:light-dark(#25679c,#8bcaff);}
.flashcard-state-chip[data-state="learning"] {--state-color:light-dark(#267344,#8bddac);}
.flashcard-state-chip[data-state="relearning"] {--state-color:light-dark(#7752a6,#c6adee);}
.flashcard-state-chip[data-state="reviewing"] {--state-color:light-dark(#606873,#b7bec7);}
@container (max-width:340px) {
    .flashcard-heading-row > .flashcard-state-chip {font-size:.65rem;padding-inline:5px;margin-inline-start:6px;}
}

/* Shared exact-headword alternatives stay compact beside the current gloss. */
.word-other-meanings { display: inline-flex; max-width: 100%; }
.other-meanings-chip.secondary { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .55rem; min-height: 0; border-radius: .6rem; font-size: .8rem; font-weight: 500; }
.other-meanings-popover { width: min(24rem, calc(100vw - 2rem)); }
.other-meanings-list { display: grid; gap: .4rem; max-height: min(26rem, 60dvh); overflow-y: auto; }
.other-meaning-option { width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: .2rem .65rem; padding: .65rem .75rem; text-align: start; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: .65rem; }
.other-meaning-option:focus-visible { background: var(--surface-hover); }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .other-meaning-option:hover { background:var(--surface-hover); } }
.other-meaning-gloss { grid-column: 1 / -1; font-weight: 400; overflow-wrap: anywhere; }
.other-meaning-type { font-size: .75rem; font-weight: 400; }
.reader-word-description > .word-other-meanings { margin-top: .4rem; }
.vocabulary-entry-gloss > .word-other-meanings { margin-bottom: .5rem; }
.character-word-definition { display:block; min-width:0; color:inherit; text-decoration:none; border-radius:6px; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .character-word-definition:hover strong { text-decoration:underline; } }

.dictionary-history { width: min(420px, calc(100vw - 24px)); }
.dictionary-history-entries { max-height: min(55dvh, 480px); overflow-y: auto; }
.dictionary-history-entry { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); }
.dictionary-history .dictionary-history-entry > .dictionary-history-query { flex: 1; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); justify-content: stretch; gap: 4px; text-align: start; padding: 12px 8px; }
.dictionary-history-query strong, .dictionary-history-query span { overflow-wrap: anywhere; white-space: normal; }
.dictionary-history-query span { font-size: .85rem; font-weight: 400; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.dictionary-history-entry:last-child { border-bottom: 0; }
.dictionary-history-entry > .icon-button { flex: none; }
.dictionary-history-footer { padding-top: 12px; border-top: 1px solid var(--border); }
.dictionary-history-footer button { width: 100%; }

/* A software keyboard resizes the notes list, rather than panning the app away. */
.app-shell[data-notes-keyboard="true"] { position:fixed; inset-inline:0; top:var(--notes-viewport-top); height:var(--notes-viewport-height); min-height:0; padding-top:var(--header-height); grid-template-rows:minmax(0,1fr); overflow:hidden; }
.app-shell[data-notes-keyboard="true"] > .app-header { top:calc(var(--notes-viewport-top) + var(--offline-banner-height,0px)); }
.app-shell[data-notes-keyboard="true"] > .sidebar { top:calc(var(--notes-viewport-top) + var(--header-height)); bottom:auto; height:calc(var(--notes-viewport-height) - var(--header-height)); }
.app-shell[data-notes-keyboard="true"] > .sidebar-scrim { top:calc(var(--notes-viewport-top) + var(--header-height)); bottom:auto; height:calc(var(--notes-viewport-height) - var(--header-height)); }
.app-shell[data-notes-keyboard="true"] > .workspace:has(.class-notes-page) { height:100%; min-height:0; padding:0 max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left)); }
.app-shell[data-notes-keyboard="true"] .class-notes-page { height:calc(var(--notes-viewport-height) - var(--header-height) - 8px); }
.class-notes-page :is(.class-notes-toolbar,.class-notes-composer) { flex-shrink:0; }
.app-shell[data-notes-keyboard="true"] .class-notes-composer { padding-block:8px; }
@media(max-width:600px) {
 .app-shell[data-notes-keyboard="true"] .class-notes-toolbar { flex-wrap:nowrap; padding-bottom:6px; }
 .app-shell[data-notes-keyboard="true"] .class-notes-heading { flex:1; min-width:0; }
 .app-shell[data-notes-keyboard="true"] .class-notes-title-button { display:block; width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
 .app-shell[data-notes-keyboard="true"] .class-notes-tools { flex-wrap:nowrap; gap:2px; }
 .app-shell[data-notes-keyboard="true"] .class-notes-tools .icon-button { width:34px; min-width:34px; height:34px; }
}

/* Discovery is a choice before the existing story interview. */
.story-discovery-choices { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin: 20px 0; }
.story-discovery-choices .onboard-choice { display: flex; align-items: center; gap: 18px; width: 100%; padding: 22px; text-align: start; }
.story-discovery-choices .onboard-choice > span:nth-child(2) { flex: 1; min-width: 0; }
.story-discovery-choices strong, .story-discovery-choices small { display: block; }
.story-discovery-choices small { margin-top: 6px; font-weight: 400; line-height: 1.5; }
.story-discovery-form { display: grid; gap: 8px; margin-top: 20px; }

.story-discovery-form input { min-width: 0; flex: 1; }
.story-discovery-note { font-size: .85rem; }
.story-discovery-results { display: grid; gap: 14px; }
.story-discovery-result { display: flex; gap: 18px; padding: 16px; border: 1px solid var(--border); border-radius: 16px; }
.story-discovery-media { flex: 0 0 144px; min-width: 0; }
.story-discovery-thumbnail { display: grid; place-items: center; color: var(--text-secondary); position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: var(--surface); }
.story-discovery-thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
.story-discovery-media .story-search-votes { justify-content: center; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; }
.story-search-metadata, .story-search-type { display: flex; align-items: center; gap: 8px; }
.story-search-metadata { margin-bottom: 12px; flex-wrap: wrap; }
.story-search-type { font-size: .8rem; color: var(--text-secondary); }
button.story-adaptation-trigger { padding: 0; min-height: 36px; margin: 0 0 12px; background: transparent; box-shadow: none; font-weight: 500; text-align: start; }
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button.story-adaptation-trigger:hover { color:var(--text); } }
.story-discovery-copy { min-width: 0; flex: 1; }
.story-discovery-copy h3 { margin: 4px 0 8px; }
.story-discovery-copy p { line-height: 1.5; margin: 0 0 14px; }
.story-discovery-empty { text-align: center; padding: 30px 10px; }
.story-discovery-remove { position: absolute; right: 12px; top: 12px; z-index: 2; font-size: .8rem; }
.discovered-story-reading progress { width: 100%; }
.discovered-story-cover { display: block; width: 100%; max-height: 240px; object-fit: cover; border-radius: 14px; margin-top: 16px; }
.discovered-story-page { font-size: 1.2rem; line-height: 1.9; padding: 12px 0; }
.discovered-story-words { margin-top: 24px; }
.discovered-story-words dl > div { padding: 10px 0; border-bottom: 1px solid var(--border); }
.discovered-story-words dt { font-weight: 700; }
.discovered-story-words dd { margin: 4px 0 0; }
@media (max-width: 480px) {
  .story-discovery-choices .onboard-choice { padding: 16px; gap: 12px; }
  .story-discovery-result { padding: 12px; gap: 12px; }
  .story-discovery-media { flex-basis: 88px; }
}

/* Videos keep public recommendations separate from a learner's private study data. */
.videos-screen {max-width:1200px;margin:0 auto;padding:24px;display:grid;gap:28px;}
.videos-heading {display:flex;justify-content:space-between;align-items:start;gap:28px;}
.videos-heading h1 {margin:0 0 8px;}
.videos-heading>div>p {max-width:540px;line-height:1.6;}
.video-extension-tile {display:flex;gap:14px;flex:0 1 370px;padding:20px;border-radius:20px;}
.video-extension-status {display:flex;align-items:center;gap:8px;margin-top:8px;}
.video-connection-chip {border:0;border-radius:999px;padding:5px 12px;background:#ffdf82;color:#513900;font-size:.82rem;font-weight:650;line-height:1.4;cursor:pointer;}
.video-extension-tile[data-connected="true"] .video-connection-chip {background:#bceccf;color:#174d30;}
.video-connection-chip:disabled {opacity:1;cursor:progress;}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .video-connection-chip:hover:not(:disabled) { box-shadow:inset 0 0 0 1px currentColor; } }
.video-extension-tile p {font-size:.85rem;line-height:1.5;margin:8px 0;}
.video-extension-icon {display:grid;place-items:center;flex:none;width:46px;height:46px;border-radius:14px;background:#e9dfff;color:#674c9b;}
.video-extension-tile[data-connected="true"] .video-extension-icon {background:#dff3e8;color:#276b49;}
.video-coming-soon {display:inline-flex;padding:5px 10px;border-radius:8px;background:var(--surface-subtle);font-size:.8rem;color:var(--muted);}
.videos-section {display:grid;gap:16px;min-width:0;}
.videos-section h2 {margin:0;font-size:1.25rem;}
.videos-grid {display:grid;grid-template-columns:repeat(auto-fill,minmax(min(260px,100%),1fr));gap:20px;}
.video-tile {overflow:hidden;display:flex;flex-direction:column;border-radius:20px;color:var(--text);text-decoration:none;min-width:0;padding:0;}
.videos-grid>.video-tile,.video-channel-grid>.video-channel {margin:0;}
.videos-section>.section-heading {margin-bottom:0;flex-wrap:wrap;}
.videos-section>.section-heading>.button-row {flex-wrap:wrap;}
.video-tile-art {position:relative;display:grid;place-items:center;aspect-ratio:16/9;background:var(--surface-subtle);color:var(--muted);overflow:hidden;}
.video-tile-art img {width:100%;height:100%;object-fit:cover;}
.video-site-label {position:absolute;bottom:10px;left:12px;background:rgb(0 0 0 / .7);color:white;border-radius:6px;padding:3px 7px;font-size:.75rem;}
.video-tile-copy {display:grid;gap:9px;padding:18px;}
.video-tile-copy h3 {margin:0;font-size:1.05rem;line-height:1.4;}
.video-tile-copy>.muted {font-size:.85rem;}
.video-subtitle-chip {justify-self:start;font-size:.75rem;background:var(--accent-soft);padding:5px 8px;border-radius:7px;}
.video-channel-grid {display:grid;grid-template-columns:repeat(auto-fill,minmax(min(300px,100%),1fr));gap:14px;}
.video-channel {display:flex;align-items:center;gap:12px;padding:18px;border-radius:16px;text-decoration:none;color:var(--text);min-width:0;}
.video-channel>img,.video-channel-placeholder {width:48px;height:48px;flex:none;object-fit:cover;border-radius:50%;background:var(--surface-subtle);display:grid;place-items:center;}
.video-channel>span:not(.video-channel-placeholder) {display:grid;gap:5px;min-width:0;flex:1;}
.video-channel small {color:var(--muted);}
.videos-empty {padding:30px;display:grid;justify-items:start;gap:12px;border-radius:18px;color:var(--text-secondary);line-height:1.65;}
.videos-empty p {margin:0;max-width:700px;}
.video-detail-header {display:grid;grid-template-columns:minmax(200px,360px) minmax(0,1fr);gap:28px;padding:24px;border-radius:22px;align-items:center;}
.video-detail-header:not(:has(.video-detail-art)) {grid-template-columns:1fr;}
.video-detail-art {width:100%;border-radius:12px;aspect-ratio:16/9;object-fit:cover;}
.video-detail-heading h1 {margin:0 0 12px;font-size:clamp(1.4rem,3vw,2rem);line-height:1.35;}
.video-detail-heading>.button-row {margin-top:20px;}
.video-subtitle-study {display:grid;gap:18px;padding:24px;border-radius:20px;}
.video-subtitle-lines {list-style:none;padding:0;margin:0;display:grid;}
.video-subtitle-lines>li {display:grid;grid-template-columns:55px minmax(0,1fr);gap:16px;padding:18px 0;border-bottom:1px solid var(--border);}
.video-cue-time {font-size:.8rem;color:var(--muted);font-variant-numeric:tabular-nums;}
.video-cue-text {margin:0;font-size:1.2rem;line-height:1.8;white-space:pre-wrap;}
.video-cue-translation {margin:8px 0 0;line-height:1.6;font-size:.9rem;}
/* A word of a subtitle line: its reading above it, and the reader's word help on a tap. */
button.video-subtitle-word {display:inline;width:auto;margin:0;padding:0 1px;border:0;border-radius:5px;background:transparent;box-shadow:none;color:inherit;font:inherit;font-weight:inherit;line-height:inherit;white-space:pre-wrap;text-align:inherit;touch-action:manipulation;transform:none;}
button.video-subtitle-word:is(:focus-visible,[aria-expanded="true"]) {background:var(--accent-soft);color:inherit;}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) button.video-subtitle-word:hover { background:var(--accent-soft);color:inherit; } }
.video-word-text {text-decoration:underline;text-decoration-color:var(--border-strong);text-underline-offset:5px;}
button.video-subtitle-word[aria-expanded="true"] .video-word-text {text-decoration-color:var(--accent);}
rt.video-word-reading {font-size:.55em;font-weight:400;color:var(--muted);text-decoration:none;user-select:none;}
.video-subtitle-lines[data-readings="true"] .video-cue-text {line-height:2.3;}
/* Which of the two views, and which track, is showing. */
.video-subtitle-study .button-row>button.secondary[aria-pressed="true"],.videos-section>.button-row>button.secondary[aria-pressed="true"] {color:var(--accent-ink);background:var(--accent-soft);box-shadow:inset 0 0 0 1px var(--accent);}
.video-study-toolbar {display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:12px;}
.video-study-display>button {padding:8px 12px;font-size:.85rem;}
.video-study-display>button[aria-pressed="true"] {color:var(--accent-ink);background:var(--accent-soft);}
.video-study-progress {margin:0;font-size:.85rem;line-height:1.5;}
.video-study-words {display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px;}
.video-vocabulary-word {display:grid;gap:5px;padding:14px;border:1px solid var(--border);border-radius:12px;color:var(--text);text-decoration:none;}
.video-vocabulary-word strong {font-size:1.2rem;}.video-vocabulary-word small,.video-vocabulary-word>span {color:var(--muted);}
.video-disclosures {border-top:1px solid var(--border);padding-top:20px;color:var(--muted);font-size:.8rem;line-height:1.6;}
.video-disclosures a {color:var(--text-secondary);}
@media(max-width:760px){.videos-screen{padding:18px 14px;gap:24px;}.videos-heading{flex-direction:column;gap:18px;}.video-extension-tile{flex:auto;width:100%;}.video-detail-header{grid-template-columns:1fr;padding:18px;gap:18px;}.video-subtitle-study{padding:16px;}.video-subtitle-lines>li{gap:10px;grid-template-columns:42px minmax(0,1fr);}}

/* Story preparation never blocks reaching the account. */
.onboard button.onboard-skip-story {align-self:flex-start; justify-self:start; margin:22px 0 0; padding:8px 0; background:transparent; border:0; box-shadow:none; color:var(--text-secondary); font-size:.88rem; font-weight:500;}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .onboard button.onboard-skip-story:hover:not(:disabled) { color:var(--text); text-decoration:underline; background:transparent; } }
.onboard-preparing-panel button.onboard-skip-story {color:rgba(255,255,255,.72); margin-top:4px;}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .onboard-preparing-panel button.onboard-skip-story:hover:not(:disabled) { color:#fff; } }
.extension-profile-setup {display:grid;gap:16px;min-width:0;margin:22px 0;padding:0;border:0;}
.extension-profile-setup label {display:grid;gap:6px;}
.extension-profile-setup .lede {margin:0;}

/* Story discovery and explicit creation. */
.story-price {display:inline-flex;margin-top:.6rem;padding:.2rem .55rem;border-radius:.5rem;background:color-mix(in srgb,#b894ea 20%,transparent);font-size:.9rem;font-weight:650;}
.story-search-filters {display:grid;gap:.65rem;margin:1rem 0 1.25rem;}
.story-search-filters select {max-width:14rem;}
.story-search-topics,.story-topic-labels {display:flex;flex-wrap:wrap;gap:.5rem;}
.story-search-topics button[aria-pressed="true"],.content-votes button[aria-pressed="true"] {background:color-mix(in srgb,#b894ea 25%,transparent);border-color:#b894ea;}
.story-topic-labels {margin:.5rem 0;font-size:.8rem;}
.content-votes {display:flex;align-items:center;gap:.4rem;margin:.65rem 0;}
.content-votes button {display:inline-flex;align-items:center;gap:.35rem;padding:.4rem .65rem;min-height:2.5rem;}
.feed-card>.content-votes {margin-left:.3rem;}

/* Reading the same content with another learning profile. */
.read-profile-picker {display:grid;gap:1rem}
.read-profile-picker p {margin:0}
.read-profile-picker button.secondary.read-profile-trigger {display:flex;align-items:center;justify-content:space-between;gap:1rem;text-align:start;width:100%}
.read-profile-menu .profile-quick {width:100%}
.profile-reading-text {border-top:1px solid var(--border);margin-top:1.5rem;padding-top:1rem}
.profile-reading-text p {font-size:1.25rem;line-height:1.8;white-space:pre-line}
.profile-reading-text img {display:block;max-width:100%;max-height:70vh;object-fit:contain;border-radius:1rem;margin:1.5rem auto}
.read-profile-dialog > .reader-popup-heading {gap:12px}
.read-profile-dialog > .reader-popup-heading > h2 {flex:1}

.generation-settings-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.generation-settings-actions .generation-settings-notice { margin: 0; }
.content-language-activities[data-language-blocked="true"] { opacity: .45; filter: grayscale(1); }

.topic-actions .content-votes {margin:0 8px 0 0;}
.content-votes-label {display:flex;align-items:center;gap:4px;white-space:nowrap;font-size:.85rem;color:var(--muted);}
.content-votes button.content-votes-info {padding:4px;min-height:28px;width:28px;height:28px;box-shadow:none;}
@media(max-width:600px){
    .topic-navigation-row {flex-wrap:wrap;}
    .topic-navigation-row .topic-actions {width:100%;justify-content:flex-end;}
    .topic-actions .content-votes {margin-inline-end:auto;}
}

#story-interview > .reader-popup-heading {justify-content:flex-start;}
#story-interview > .reader-popup-heading > .icon-button {margin-inline-start:auto;}
.story-visibility-badge {display:inline-flex;align-items:center;gap:5px;padding:3px 9px;border-radius:999px;font-size:.75rem;font-weight:600;line-height:1.4;color:var(--text-secondary);background:var(--surface-hover);border:1px solid var(--border);}
.story-public-warning {display:flex;align-items:flex-start;gap:8px;margin:0;color:var(--text-secondary);font-size:.9rem;line-height:1.5;}
.story-public-warning > svg {flex:none;margin-top:2px;color:#9b80d1;}

.story-title-translation-status {display:inline-flex;align-items:center;flex-wrap:wrap;gap:8px;color:var(--muted);font-size:.9rem;font-weight:500;}
.story-title-translation-status button {padding:2px 6px;}

.story-version-notice {display:flex;align-items:flex-start;gap:8px;font-size:.85rem;color:var(--text-secondary);}
.story-version-notice > svg {flex:none;margin-top:2px;color:#9b80d1;}

.story-discovery-form { display: grid; gap: 16px; }
.story-search-selected-topic, .story-search-votes, .story-search-votes > span { display: flex; align-items: center; gap: 8px; }
.story-search-votes { gap: 20px; color: var(--text-secondary); font-size: .9rem; }
.story-search-empty-actions { display: grid; gap: 12px; max-width: 420px; margin: 18px auto 0; }
.story-search-empty-actions > button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }

.story-search-instant { display: inline-flex; width: fit-content; margin-top: 6px; padding: 3px 9px; border-radius: 999px; background: #a891d726; color: var(--text-primary); font-size: .8rem; font-weight: 600; }

/* Forward actions stay at the end even when there is no Back/Skip sibling. */
.story-interview .form-actions > button[type="submit"],
.story-interview-answer-actions > button[type="submit"],
.story-flow-forward { margin-inline-start: auto; }

.content-preparation-heading {display:flex;align-items:center;gap:8px;padding-right:18px;}
.content-preparation-heading>.content-preparation-trigger {flex:1;min-width:0;}
button.generation-settings-notice[data-icon-only="true"] {flex:none;padding:8px;border:0;background:transparent;}
.generation-settings-progress-heading {display:flex;align-items:center;gap:8px;}

/* Practice and note tiles match stories in multi-column feeds. */
:is(.feed-flashcard-configuration, .feed-note-card) {
  min-width: 0;
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(12px, 2cqi, 24px);
  height: auto;
  min-height: 0;
  aspect-ratio: 4 / 3;
  box-sizing: border-box;
  padding: clamp(20px, 3cqi, 36px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface));
  color: var(--text);
  text-decoration: none;
  box-shadow: 0 2px 4px #0000000a;
}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) :is(.feed-flashcard-configuration, .feed-note-card):hover { border-color:var(--accent); } }
:is(.feed-flashcard-configuration, .feed-note-card):focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.feed-practice-kind { display:flex; align-items:center; gap:8px; color:var(--muted); font-weight:600; }
.feed-practice-source { display:flex; align-items:center; gap:16px; }
.feed-practice-source-icon { display:grid; place-items:center; flex:0 0 60px; width:60px; height:60px; border-radius:18px; background:color-mix(in srgb,var(--accent) 12%,var(--surface)); font-size:36px; }
.feed-practice-source h3 { min-width:0; flex:1; margin:0; font-size:clamp(20px,2.3cqi,28px); line-height:1.25; overflow:hidden; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; }
.feed-practice-progress { margin-top:auto; padding-right:42px; }
.feed-practice-progress > div { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:8px; font-size:0.9rem; }
.feed-practice-progress strong { font-size:1.25rem; }
.feed-practice-progress progress { display:block; width:100%; height:8px; border:0; border-radius:99px; overflow:hidden; accent-color:var(--accent); background:var(--border); }
.feed-practice-progress progress::-webkit-progress-bar { background:var(--border); }
.feed-practice-progress progress::-webkit-progress-value { background:var(--accent); border-radius:99px; }
.feed-practice-progress progress::-moz-progress-bar { background:var(--accent); border-radius:99px; }
.feed-practice-open { position:absolute; bottom:28px; right:24px; color:var(--accent); }
@container feed-practice (width < 400px) {
  :is(.feed-flashcard-configuration, .feed-note-card) { padding:14px; gap:8px; }
  .feed-practice-kind { font-size:0.8rem; }
  .feed-practice-source { gap:12px; }
  .feed-practice-source-icon { flex-basis:44px; width:44px; height:44px; font-size:30px; border-radius:12px; }
  .feed-practice-source h3 { font-size:20px; -webkit-line-clamp:2; }
  .feed-practice-progress > div { font-size:0.8rem; margin-bottom:6px; }
  .feed-practice-progress strong { font-size:1.1rem; }
  .feed-practice-open { bottom:18px; right:18px; }
}

.feed-practice-source-icon img { width:100%; height:100%; object-fit:cover; border-radius:inherit; }

.feed-practice-card { position:relative; container:feed-practice / inline-size; }

.feed-note-summary { margin-top:auto; padding-right:42px; color:var(--text-secondary); }

/* Size practice controls to their tile, including narrow tiles in wide layouts. */
@container feed-practice (width < 620px) {
  :is(.feed-flashcard-configuration, .feed-note-card) {
    aspect-ratio:8 / 3;
    display:grid;
    grid-template-columns:auto minmax(0,1fr);
    grid-template-rows:auto minmax(0,1fr) auto;
    gap:6px;
    padding:12px;
  }
  .feed-practice-kind {grid-row:1;grid-column:1;font-size:.7rem;gap:4px;padding-right:0;}
  .feed-practice-kind .shell-icon {width:16px;height:16px;}
  .feed-practice-source {grid-row:2;grid-column:1 / -1;gap:10px;min-height:0;}
  .feed-practice-source-icon {flex-basis:32px;width:32px;height:32px;font-size:24px;border-radius:10px;}
  .feed-practice-source-icon .shell-icon {width:26px;height:26px;}
  .feed-practice-source h3 {font-size:18px;line-height:1.15;-webkit-line-clamp:2;}
  .feed-practice-progress,.feed-note-summary {grid-row:3;grid-column:1 / -1;margin:0;padding-right:30px;}
  .feed-practice-progress > div {font-size:.7rem;line-height:1.2;margin-bottom:4px;}
  .feed-practice-progress strong {font-size:.9rem;}
  .feed-practice-progress progress {height:5px;}
  .feed-note-summary {font-size:.8rem;}
  .feed-practice-open {bottom:9px;right:10px;}
}
@container feed-practice (width < 285px) {
  :is(.feed-flashcard-configuration, .feed-note-card) {padding:8px;gap:3px;}
  .feed-practice-source-icon {flex-basis:28px;width:28px;height:28px;}
  .feed-practice-source h3 {font-size:16px;-webkit-line-clamp:1;}
}

/* Reading combines generated and custom material without topic grouping. */
.reading-library-page {row-gap:20px;}
.reading-library-page > .page-header {margin:0;}
.reading-library-actions {display:flex;flex-wrap:wrap;justify-content:flex-start;gap:12px;margin:0;}

/* Secondary features share one tab and remain full-width destinations. */
.more-screen {max-width:1100px;margin:0 auto;padding:clamp(20px,4vw,40px);display:grid;gap:28px;}
.more-screen .page-header {margin:0;}
.more-screen h1 {margin:0;}
.more-features {display:grid;gap:16px;}
.more-feature {display:flex;align-items:center;gap:22px;color:var(--text);text-decoration:none;padding:24px;transition:background-color .16s ease,border-color .16s ease,box-shadow .16s ease,transform .16s var(--ease);}
.more-features>.more-feature {margin:0;}
.more-feature-icon {display:grid;place-items:center;flex:none;width:68px;height:68px;border-radius:18px;background:var(--tone-soft);color:var(--tone);}
.more-feature-copy {flex:1;min-width:0;}
.more-feature h2 {margin:0 0 7px;font-size:1.2rem;}
.more-feature p {margin:0;color:var(--muted);line-height:1.5;}
.more-feature>.shell-icon {flex:none;color:var(--tone);}
.more-feature:focus-visible {outline:2px solid var(--accent);outline-offset:4px;}
@media(hover:hover) and (pointer:fine){:where(:root:not([data-touch-input])) .more-feature:hover{background:var(--surface-hover);border-color:var(--tone);box-shadow:var(--shadow);transform:translateY(-1px);}}
@media(max-width:600px){.more-screen{gap:20px;}.more-feature{padding:18px;gap:14px;}.more-feature-icon{width:50px;height:50px;border-radius:14px;}.more-feature h2{font-size:1.05rem;}.more-feature p{font-size:.875rem;}}
@media(prefers-reduced-motion:reduce){.more-feature{transition:none;} @media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .more-feature:hover { transform:none; } }}

/* Recall grades and the resulting skill adjustment. */
.flashcard-form-results {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem;width:100%;}
.study-dock .flashcard-form-result {display:flex;flex-direction:column;align-items:stretch;gap:.5rem;min-width:0;width:100%;padding:.75rem;border:1px solid var(--border);border-radius:1rem;background:var(--surface);color:var(--text);text-align:start;box-shadow:none;}
.flashcard-form-result strong {flex:1;min-width:0;font-size:.9rem;}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .study-dock .flashcard-form-result:hover { background:var(--surface-hover); } }
.flashcard-form-result-details {display:flex;flex-direction:column;gap:.75rem;}
.flashcard-form-result-details p {margin:0;}
.flashcard-form-values {display:flex;flex-direction:column;gap:.25rem;font-size:.9rem;}
.flashcard-form-rating {display:flex;flex-direction:column;gap:.5rem;margin-block:.8rem;}
.flashcard-form-rating .flashcard-self-rating[aria-pressed="true"] {outline:3px solid currentColor;outline-offset:-3px;}
.flashcard-form-input {width:100%;margin-block:1rem;}
.flashcard-form-input>input {width:100%;}
/* Tighten outer gutters, dock padding and tile gaps before stacking. */
.flashcard-stage:has(.flashcard-form-results) {padding-left:max(clamp(6px,2vw,16px),env(safe-area-inset-left));padding-right:max(clamp(6px,2vw,16px),env(safe-area-inset-right));}
.study-scene:has(.flashcard-form-results) {gap:clamp(8px,2vw,18px);}
.study-dock:has(.flashcard-form-results) {padding:clamp(8px,2.2vw,24px);gap:clamp(8px,1.6vw,18px);}
.flashcard-form-results {gap:clamp(5px,1.4vw,16px);}
.study-dock .flashcard-form-result {padding:clamp(6px,1.2vw,12px);}
.flashcard-form-rating>strong {display:flex;align-items:center;gap:.5rem;}
@media(max-width:700px){
 .flashcard-form-result-heading {flex-direction:column;gap:.3rem;}
 .flashcard-form-result strong {font-size:.8rem;}
 .flashcard-form-results .flashcard-result-familiarity {font-size:.8rem;padding:5px;gap:.2rem;flex-wrap:wrap;justify-content:center;}
 .flashcard-form-results .flashcard-result-familiarity .shell-icon {width:16px;height:16px;}
}
@media(max-width:359px){.flashcard-form-results {grid-template-columns:1fr;}.flashcard-form-result-heading {flex-direction:row;}}

.flashcard-form-result-heading {display:flex;align-items:center;gap:.5rem;}
.flashcard-result-title {display:inline-flex;align-items:center;gap:.3rem;}
.flashcard-result-title>.shell-icon {flex:none;}
.flashcard-form-result-changes {display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:.4rem;}
.flashcard-result-familiarity {gap:.4rem;align-self:center;font-size:.95rem;}
.flashcard-result-retention {display:inline-flex;flex-wrap:wrap;align-items:baseline;gap:.2rem .4rem;max-width:100%;font-variant-numeric:tabular-nums;}
.flashcard-result-retention[data-compact="true"] {justify-content:center;padding:4px 7px;border-radius:7px;background:var(--surface-hover);font-size:.8rem;line-height:1.4;}
.flashcard-result-retention-label {color:var(--text-secondary);}
.flashcard-result-retention-times {display:inline-flex;gap:.3rem;white-space:nowrap;}
.flashcard-result-retention-current {font-weight:650;}
.mastery-result-actions.flashcard-result-footer {display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);width:100%;margin-left:0;gap:.75rem;}
.flashcard-result-footer>:first-child {justify-self:start;}
.flashcard-result-footer>button.mastery-continue {justify-self:end;align-self:stretch;width:100%;max-width:12rem;min-width:0;padding:10px clamp(6px,2vw,28px);}
.flashcard-result-overall {display:flex;flex-direction:column;align-items:center;gap:.25rem;font-size:.75rem;}
@media(max-width:480px){.flashcard-result-footer>button {min-width:0;padding:10px;font-size:.85rem;}.mastery-result-actions.flashcard-result-footer{gap:.5rem;}}

.flashcard-result-delta {display:inline-flex;align-items:center;gap:.1rem;font-size:.75em;font-weight:500;opacity:.65;}
.flashcard-result-delta>.shell-icon {flex:none;}
@media(max-width:480px){.flashcard-result-footer>button{white-space:normal;padding:10px 6px;}.flashcard-result-footer .flashcard-result-familiarity{font-size:.85rem;gap:.25rem;}}

.study-dock .flashcard-overall-trigger {display:flex;flex-direction:column;gap:.3rem;padding:.5rem;border:1px solid var(--border);border-radius:1rem;background:var(--surface);color:var(--text);box-shadow:none;font-size:.75rem;}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .study-dock .flashcard-overall-trigger:hover { background:var(--surface-hover); } }
.flashcard-overall-equation {font-variant-numeric:tabular-nums;}
@media(max-width:480px){.study-dock .flashcard-overall-trigger{padding:.35rem;}}

@media(max-width:600px){
 .flashcard-answer-choices {gap:6px;}
 .flashcard-answer-choices > :is(.flashcard-quiz-answer,.flashcard-manual-answer,.flashcard-reveal-answer) {padding-inline:5px;font-size:.9rem;gap:5px;flex-wrap:wrap;justify-content:center;}
 .flashcard-answer-choices .shell-icon {flex-shrink:0;}
}

/* Overall is an average, visually separated from the four learning dimensions. */
.flashcard-score-fixed {scrollbar-width:thin;}
.flashcard-score-row {--flashcard-column-gap:8px;gap:var(--flashcard-column-gap);}
.flashcard-score-row > [data-dimension="Overall"] {position:relative;align-self:stretch;align-content:center;align-items:center;}
.flashcard-score-row > [data-dimension="Overall"]::before {content:"";position:absolute;inset-inline-start:calc(var(--flashcard-column-gap) / -2);top:-12px;bottom:-12px;width:1px;background:color-mix(in srgb,var(--border) 60%,transparent);pointer-events:none;}
.flashcard-score-head > [data-dimension="Overall"]::before {top:0;}
.flashcard-score-overall > [data-dimension="Overall"]::before {top:-4px;}
@media(max-width:480px){.flashcard-score-row {--flashcard-column-gap:4px;}}

.flashcard-form-results[data-count="1"] {grid-template-columns:minmax(0,1fr);}
.flashcard-form-results[data-count="1"] .flashcard-form-result-heading {flex-direction:row;}

@media (max-width:600px) {
    .flashcard-form-results[data-count="3"]:has([data-response-only="true"]) {
        grid-template-columns:repeat(2,minmax(0,1fr));
    }
    .flashcard-form-results [data-response-only="true"] .flashcard-form-result-heading {
        flex-flow:row wrap;
    }
    .flashcard-form-results:has([data-response-only="true"]) > .flashcard-form-result:last-of-type {
        grid-column:1 / -1;
        flex-flow:row wrap;
        align-items:center;
        justify-content:space-between;
    }
    .flashcard-form-results:has([data-response-only="true"]) > :last-of-type .flashcard-form-result-heading {
        flex-direction:row;
    }
}

/* Available triplets start visual; missing triplets keep the meaning readable. */
.flashcard-meaning-images {display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px;}
.flashcard-meaning-visual {position:relative;width:100%;min-width:0;}
.flashcard-meaning-visual .word-illustration {width:100%;margin:0;padding:0;border:0;background:transparent;}
.flashcard-meaning-explanation {flex-basis:100%;text-align:center;}
.flashcard-meaning-explanation p {margin:4px 0;}
.meaning-text-toggle {flex:none;}
.memory-meaning-options {display:flex;flex-direction:column;gap:10px;}
.memory-meaning-option {position:relative;border:1px solid var(--border);border-radius:18px;padding:8px 10px;background:var(--surface);min-width:0;}
.memory-meaning-option .flashcard-meaning-images {width:100%;display:grid;grid-template-columns:minmax(0,1fr) auto;gap:6px;}
.memory-meaning-option .flashcard-meaning-explanation {grid-column:1/-1;}
.memory-meaning-option .meaning-images {gap:6px;}
.memory-meaning-option .meaning-images .meaning-image img {height:clamp(54px,7dvh,80px);max-height:80px;}
.memory-meaning-option .triplet-loading .meaning-image {height:clamp(54px,7dvh,80px);}
.memory-meaning-option .meaning-image-select {position:absolute;inset:0;width:100%;height:100%;border:0;border-radius:10px;background:transparent;box-shadow:none;padding:0;cursor:pointer;}
.memory-meaning-option:has(.meaning-image-select:focus-visible) {border-color:var(--text);}
@media (hover: hover) and (pointer: fine) { :where(:root:not([data-touch-input])) .memory-meaning-option:has(.meaning-image-select:hover:not(:disabled)) { border-color:var(--text); } }
.memory-meaning-option:has(.meaning-image-select:focus-visible) {outline:2px solid var(--text);outline-offset:2px;}
.memory-meaning-option[data-result="correct"] {border-color:#6bbf59;background:color-mix(in srgb,#6bbf59 12%,var(--surface));}
.memory-meaning-option[data-result="wrong"] {border-color:#df7777;background:color-mix(in srgb,#df7777 10%,var(--surface));}
.memory-meaning-option .memory-identify-mark {position:absolute;top:4px;left:6px;pointer-events:none;}
.memory-meaning-option .word-illustration-error {position:relative;z-index:1;}
@media(max-width:600px) {.memory-meaning-options {gap:6px;}.memory-meaning-option {padding:6px;border-radius:12px;}}

.memory-meaning-option .meaning-text-select {width:100%;border:0;background:transparent;color:var(--text);box-shadow:none;padding:8px;font-size:1rem;text-align:center;}

/* Sequential recall keeps the upcoming output hidden until its grading step. */
.flashcard-answer-choices > .flashcard-reveal-answer {flex-direction:column;gap:5px;}
.flashcard-self-grade-label {display:flex;align-items:center;justify-content:center;gap:8px;}
.flashcard-self-grade-subtitle {font-size:.72em;font-weight:400;opacity:.65;}
.flashcard-self-grade-question {display:flex;align-items:center;justify-content:center;gap:8px;}
.flashcard-self-grade-question .shell-icon {flex-shrink:0;}
.flashcard-self-grade-footer {display:flex;align-items:center;min-height:32px;}
.flashcard-self-grade-footer small {font-size:.85rem;}
.flashcard-self-grade-back {font-size:.85rem;padding:6px 10px;min-height:32px;}

.flashcard-self-grade-name {white-space:nowrap;}
.flashcard-self-grade-skip {margin-left:auto;}
@media(max-width:600px) {.flashcard-self-grade-label .flashcard-key-hint {display:none;}}

/* Reserve a separate top row so activity labels never collide with list controls. */
.vocabulary-collection-row[data-has-activity="true"] { padding-top: 38px; }
.vocabulary-collection-activity { position: absolute; top: 10px; right: 18px; font-size: .75rem; line-height: 1.3; pointer-events: none; }
.vocabulary-collection-activity .topic-age { color: inherit; font: inherit; margin: 0; text-shadow: none; }
.vocabulary-import-actions > .vocabulary-create-trigger { margin-top: 0; }
@media (max-width: 600px) {
    .vocabulary-collection-row[data-has-activity="true"] { padding-top: 34px; }
    .vocabulary-collection-activity { right: 16px; font-size: .7rem; }
}

.memory-listen-option {flex-direction:column;}
.memory-listen-transcription {padding:.25rem .5rem;color:var(--text-secondary);font-size:.9rem;}

/* Topics: learning spaces that hold activities. Most tiles reuse the story card. */
:is(.tspace-topics-page,.tspace-topic-page,.tspace-activity-page) {container:discovery-layout / inline-size;gap:clamp(14px,1.8vw,20px);align-content:start;}
:is(.tspace-topics-page,.tspace-topic-page,.tspace-activity-page) .surface + .surface {margin-top:0;}
.tspace-directory-header {display:flex;align-items:center;justify-content:space-between;gap:12px;}
.tspace-directory-title {display:flex;align-items:center;gap:4px;min-width:0;}
.tspace-directory-title h1 {margin:0;overflow-wrap:anywhere;}
button.tspace-directory-info {flex:none;width:44px;height:44px;border-radius:50%;}
.tspace-directory-create {flex:none;min-height:44px;max-width:52%;text-align:start;}
.tspace-directory-create svg {flex:none;}
.tspace-grid .topic-card-container {min-width:0;}
.tspace-empty {display:grid;justify-items:start;gap:8px;}
.tspace-empty h2 {margin:0;font-size:1.15rem;}
.tspace-empty p {margin:0;}
.tspace-tile-art {display:grid;}
.tspace-tile-glyph {place-self:start;display:grid;place-items:center;margin:clamp(14px,4cqi,22px);color:color-mix(in srgb,var(--accent) 55%,var(--text-secondary));font-size:clamp(40px,12cqi,64px);line-height:1;}
.tspace-space-art {display:grid;place-items:center;color:var(--text-secondary);font-size:clamp(40px,12cqi,64px);line-height:1;}
.tspace-space-art > .shell-icon {width:1em;height:1em;}
.tspace-tile-glyph .shell-icon {width:clamp(40px,12cqi,64px);height:clamp(40px,12cqi,64px);}
.tspace-tile {container-type:inline-size;}
.tspace-tile .topic-card-copy {gap:4px;}
.tspace-tile .topic-card-copy h3 {margin:0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
.tspace-tile-meta {color:var(--text-secondary);font-size:.82rem;}
.tspace-tile-track .topic-familiarity-track {margin-top:2px;}
.tspace-tile-track .reader-learning-track {height:6px;}
.tspace-tile-completion {margin-top:2px;}
.tspace-tile .topic-card-suggested .word-illustration-spinner {width:14px;height:14px;}

/* Compact cards size an otherwise compact row. Stretch them to the shared
   grid row when a taller card is present, keeping the activity footer below. */
.feed-grid > :has(.tspace-compact-activity,.feed-note-card) {align-self:stretch;}
.feed-grid > .recent-activity-tile:has(.tspace-compact-activity,.feed-note-card),
.managed-tile:has(> .tspace-compact-activity) {display:grid;}
.feed-grid :is(.tspace-compact-activity,.feed-note-card) {align-self:stretch;aspect-ratio:8/3;}

.managed-tile > .tspace-compact-activity {
  display:grid;grid-template-columns:clamp(58px,22%,104px) minmax(0,1fr);
  grid-template-rows:1fr auto auto 1fr;min-height:96px;
}
.managed-tile > .tspace-compact-activity > .topic-card-art {position:relative;inset:auto;grid-area:1/1/-1/2;}
.tspace-compact-activity .tspace-tile-glyph {place-self:center;margin:0;}
.tspace-compact-activity .tspace-tile-glyph .shell-icon {width:clamp(28px,10cqi,42px);height:clamp(28px,10cqi,42px);}
.managed-tile > .tspace-compact-activity > .topic-card-image {
  grid-area:2/2;display:flex;align-items:center;gap:4px 8px;flex-wrap:wrap;padding:8px 12px 0;
}
.tspace-compact-activity :is(.topic-card-type,.topic-card-suggested) {
  position:static;max-width:100%;text-align:start;justify-content:start;
}
.tspace-compact-activity .topic-card-type {color:var(--text-secondary);text-shadow:none;}
.tspace-compact-activity .topic-card-type .language-level {background:none;}
.tspace-compact-activity .topic-card-type > .shell-icon {display:none;}
.managed-tile > .tspace-compact-activity > .topic-card-copy {
  grid-area:3/2;margin:0;padding:4px 12px 8px;border:0;background:none;backdrop-filter:none;
}
.tspace-compact-activity .topic-card-copy h3 {height:auto;}
.feed-grid .feed-note-card {gap:6px;padding:10px 12px;min-height:96px;}
.feed-grid .feed-note-card .feed-practice-source-icon {flex-basis:32px;width:32px;height:32px;font-size:26px;border-radius:10px;}
.feed-grid .feed-note-card .feed-practice-source-icon .shell-icon {width:26px;height:26px;}
.feed-grid .feed-note-card .feed-note-summary {margin:0;font-size:.8rem;}

.recent-grid, .reader-library .library-content-list { grid-template-columns:minmax(0, 1fr); gap:var(--recent-grid-gap); }
.recent-grid-cell { display:contents; }
.recent-grid-cell[data-half-height="true"] :is(.topic-card, .feed-content-card, .feed-note-card, .feed-flashcard-configuration) {
  aspect-ratio:8/3;
}
@container discovery-layout (min-width:46rem) {
  .recent-grid, .reader-library .library-content-list { grid-template-columns:repeat(2, minmax(0, 1fr)); }
  .recent-grid {
    grid-auto-rows:1fr;
  }
  .recent-grid-cell {
    display:block;
    min-width:0;
    container-type:inline-size;
    grid-area:var(--recent-grid-area);
    --recent-half-height:max(7rem, calc((75cqi - var(--recent-grid-gap)) / 2));
    --recent-card-height:calc(2 * var(--recent-half-height) + var(--recent-grid-gap));
  }
  .recent-grid-cell[data-half-height="true"] { --recent-card-height:var(--recent-half-height); }
  .recent-grid .recent-grid-cell :is(.topic-card, .feed-content-card, .feed-note-card, .feed-flashcard-configuration) {
    height:var(--recent-card-height);
    min-height:0;
    aspect-ratio:auto;
  }
}

.tspace-topic-header {display:grid;gap:8px;min-width:0;}
.tspace-add-content {width:100%;justify-content:center;margin-block-start:24px;}
@media (max-width:640px) {
  .tspace-topic-heading .tspace-add {display:none;}
}
.tspace-topic-heading {display:flex;align-items:center;justify-content:space-between;gap:12px;min-width:0;}
.tspace-topic-title {display:flex;align-items:center;gap:.5em;min-width:0;margin:0;font-size:clamp(1.5rem,3.2vw,2.2rem);line-height:1.2;overflow-wrap:anywhere;}
.tspace-topic-identity {display:flex;align-items:center;gap:12px;min-width:0;}
.tspace-edit-icon .vocabulary-list-art {width:48px;height:48px;border-radius:12px;font-size:26px;}
.tspace-icon-fields {display:grid;grid-template-columns:64px minmax(0,1fr);align-items:end;gap:12px;}
.tspace-icon-fields label {display:grid;gap:6px;}
.tspace-icon-actions {margin:0;}
.tspace-topic-description {margin:0;white-space:pre-line;}

/* The bar is a button that carries its own padding; the flashcards link sits beside it. */
.tspace-vocabulary {display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:0 4px;padding-inline-end:16px;}
.tspace-vocabulary .topic-vocabulary-open {margin:0;font:inherit;cursor:pointer;}
.tspace-vocabulary-empty {grid-template-columns:minmax(0,1fr);gap:4px;padding:16px 20px;}
.tspace-vocabulary-empty p {margin:0;}
.tspace-flashcards {white-space:nowrap;}
@container discovery-layout (width < 620px) {
  .tspace-vocabulary:not(.tspace-vocabulary-empty) {grid-template-columns:minmax(0,1fr);padding:0 0 14px;}
  .tspace-flashcards {justify-self:stretch;width:auto;margin-inline:16px;}
}

.tspace-form {display:grid;gap:10px;min-width:0;}
.tspace-form label {font-weight:650;}
.tspace-form :is(input,textarea) {width:100%;box-sizing:border-box;}
.tspace-form p {margin:0;}
.tspace-add-grid {display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,250px),1fr));gap:10px;}
button.tspace-add-option {display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:12px;width:100%;height:100%;min-height:76px;padding:12px 14px;border-radius:16px;text-align:start;white-space:normal;font-weight:400;}
.tspace-add-icon {display:grid;place-items:center;width:44px;height:44px;border-radius:12px;background:color-mix(in srgb,var(--accent) 12%,var(--surface));color:var(--accent);}
.tspace-add-copy {display:grid;gap:2px;min-width:0;}
.tspace-add-copy strong {font-size:1rem;}
.tspace-add-copy small {color:var(--text-secondary);line-height:1.35;}
.tspace-add-more {margin:18px 0 8px;font-size:.85rem;font-weight:650;color:var(--text-secondary);text-transform:uppercase;letter-spacing:.06em;}
.tspace-add-back {margin-bottom:8px;}
.tspace-add-readings {display:grid;gap:8px;}
.tspace-document-create {margin-top:16px;}
button.tspace-add-reading {display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:10px;width:100%;text-align:start;white-space:normal;}
button.space-delete-option {width:100%;min-height:48px;justify-content:space-between;text-align:start;white-space:normal;}
button.space-delete-option > span {overflow-wrap:anywhere;}
button.space-delete-option > .shell-icon {flex:none;}
.space-delete-title,.space-delete-items li {display:flex;align-items:center;gap:10px;overflow-wrap:anywhere;}
.space-delete-items {display:grid;gap:8px;list-style:none;padding-inline-start:0;}
:is(.space-delete-title,.space-delete-items li) > .shell-icon {flex:none;color:var(--text-secondary);}

.tspace-suggestion-list {display:grid;gap:10px;}
.tspace-suggestion {display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:14px;padding:12px 16px;}
.tspace-suggestion-art {display:grid;place-items:center;width:72px;height:72px;border-radius:12px;overflow:hidden;background:color-mix(in srgb,var(--accent) 9%,var(--surface));color:var(--text-secondary);}
.tspace-suggestion-art img {width:100%;height:100%;object-fit:cover;}
.tspace-suggestion-copy {display:grid;gap:3px;min-width:0;}
.tspace-suggestion-copy small {display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
.tspace-suggestion-labels {display:flex;flex-wrap:wrap;align-items:center;gap:8px;color:var(--text-secondary);font-size:.85rem;}
@container discovery-layout (width < 520px) {
  .tspace-suggestion {grid-template-columns:auto minmax(0,1fr);}
  .tspace-suggestion > button {grid-column:1 / -1;width:100%;}
}

.tspace-activity-page .topic-header {position:relative;}
.tspace-activity-cover {display:grid;place-items:center;background:color-mix(in srgb,var(--accent) 9%,var(--surface));color:color-mix(in srgb,var(--accent) 55%,var(--text-secondary));}
.tspace-activity-cover img {width:100%;height:100%;object-fit:cover;}
.tspace-activity-cover > .shell-icon {width:min(44%,48px);height:min(44%,48px);}
.tspace-activity-menu {position:absolute;inset-block-start:10px;inset-inline-end:10px;}
.tspace-entries .content-reading-actions {grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));}
.tspace-entry-button {--mode:var(--accent);}
.tspace-entry-button .topic-activity-icon {border-radius:16px;background:color-mix(in srgb,var(--mode) 10%,var(--surface));overflow:hidden;}
.tspace-entry-button .topic-activity-icon img {display:block;width:100%;height:100%;object-fit:contain;}
.tspace-entry-icon {color:var(--accent);}
.topic-page a.tspace-entry-illustrated {
  --entry-backdrop:#101114;
  isolation:isolate;
  overflow:hidden;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:end;
  min-block-size:clamp(240px,42cqi,320px);
  padding:clamp(16px,3cqi,28px);
  background:var(--entry-backdrop);
}
.tspace-entry-cover {position:absolute;inset:0;z-index:-1;pointer-events:none;}
.tspace-entry-cover img {display:block;width:100%;height:100%;object-fit:cover;object-position:center 44%;}
.tspace-entry-cover::after {
  content:"";
  position:absolute;
  inset:0;
  background:linear-gradient(to top,var(--entry-backdrop),rgb(16 17 20 / .78) 27%,transparent 76%);
}
.tspace-entry-illustrated .content-reading-title {font-size:clamp(1.15rem,2.5cqi,1.55rem);color:#fff;}
.tspace-entry-illustrated .content-reading-help {display:block;color:#e2e4ea;}
.topic-page .tspace-entry-illustrated .content-reading-arrow {display:grid;background:rgb(16 17 20 / .68);border:1px solid rgb(255 255 255 / .45);color:#fff;}
@container discovery-layout (width >= 620px) {
  .tspace-entry-cover {inset-inline-start:27%;}
  .tspace-entry-cover::after {
    background:linear-gradient(var(--entry-fade-direction,to right),var(--entry-backdrop),rgb(16 17 20 / .58) 23%,transparent 62%),
      linear-gradient(to top,rgb(16 17 20 / .74),transparent 54%);
  }
  .tspace-entry-cover:dir(rtl) {--entry-fade-direction:to left;}
  .tspace-entry-illustrated .content-reading-copy {max-inline-size:36ch;}
}
.tspace-build-words {display:grid;justify-items:start;gap:8px;}

/* The story's four ways to read it, as large tiles. */
.content-reading-actions.tspace-reading-tiles {grid-template-columns:repeat(2,minmax(0,1fr));}
@media (max-width:760px) {.content-reading-actions.tspace-reading-tiles {grid-template-columns:minmax(0,1fr);}}
/* The flashcards tile sits under the familiarity bar, and the groups of things
   made from a story keep the tile gap between them. */
.topic-page .content-flashcards,.topic-page .topic-activities:not(:empty) ~ .topic-challenge-activities {margin-top:12px;}
@media(max-width:600px),(max-height:650px) {
    .topic-page .content-flashcards,.topic-page .topic-activities:not(:empty) ~ .topic-challenge-activities {margin-top:10px;}
}
.content-reading-read-aloud {--mode:#2f9e6e}
.content-reading-translate {--mode:#d9822b}
/* Without cover art, the kind label and its icon use a glow opposite the theme's text color. */
.tspace-tile:not(.tspace-compact-activity):not(:has(.tspace-tile-art > img)) .topic-card-type {
  --topic-kind-glow:light-dark(rgb(255 255 255 / .95),rgb(0 0 0 / .8));
  color:var(--text-secondary);
  text-shadow:0 0 4px var(--topic-kind-glow);
}
.tspace-tile:not(.tspace-compact-activity):not(:has(.tspace-tile-art > img)) .topic-card-type > .shell-icon {filter:drop-shadow(0 0 3px var(--topic-kind-glow));}
.tspace-tile:not(.tspace-compact-activity):not(:has(.tspace-tile-art > img)) .topic-card-type .language-level {background:none;}

/* Topic membership belongs on the native document/list screen. */
.parent-chips { display:flex; flex-wrap:wrap; align-items:center; gap:6px; min-width:0; }
.parent-chips .shell-icon { flex:none; }
:is(.reader-view,.study-list-title,.writer-paper,.assistant-heading-copy,.podcast-heading-copy,.describe-header > div:first-child) > .parent-chips { margin-block-end:8px; }
.saying-session-header > .parent-chips { flex-basis:100%; }
.roleplay-stage > .reader-popup-heading > .parent-chips { max-inline-size:min(15rem, calc(100vw - 224px)); margin-inline:4px; }
.coach-stage > .reader-popup-heading:has(> .parent-chips) { flex-wrap:wrap; gap:6px; }
.coach-stage > .reader-popup-heading > .parent-chips { flex-basis:100%; justify-content:center; pointer-events:auto; }
.coach-stage:has(> .reader-popup-heading > .parent-chips) .coach-stage-live { padding-block-start:calc(max(18px,env(safe-area-inset-top)) + 76px); }

.native-activity-context { display:flex; flex-direction:column; gap:12px; min-width:0; }
.native-activity-context:empty { display:none; }
.native-activity-context > button { align-self:flex-start; }

.class-notes-rows > .native-activity-context { margin-bottom:16px; }

/* A story image's description: an info button on the image, and the text over its lower edge. */
.story-scene-info {position:absolute;z-index:3;inset:10px 10px auto auto;display:grid;justify-items:end;gap:8px;max-width:calc(100% - 20px);pointer-events:none;}
[dir="rtl"] .story-scene-info {inset:10px auto auto 10px;justify-items:start;}
.story-scene-info > * {pointer-events:auto;}
button.story-scene-info-button {width:36px;height:36px;border:1px solid #ffffff40;border-radius:999px;background:#14161bb3;color:#fff;box-shadow:none;opacity:.85;}
button.story-scene-info-button[aria-expanded="true"] {background:#14161b;opacity:1;}
.story-scene-info-text {margin:0;padding:10px 14px;max-width:min(100%,560px);max-height:40vh;overflow:auto;border:1px solid #ffffff40;border-radius:14px;background:#14161be6;color:#fff;font:.9rem/1.5 var(--font-sans);text-align:start;}
/* The guided page capsule anchors the caption above both the label and the footer. */
.comic-photo-page-label:has(.story-scene-info) {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-block: 1px;
    padding-inline-end: 2px;
}
.comic-photo-page-label .story-scene-info { position: static; display: flex; max-width: none; }
.comic-photo-page-label .story-scene-info-button { border-color: transparent; background: transparent; }
.comic-photo-page-label .story-scene-info-button:is(:active, :focus-visible, [aria-expanded="true"]) {
    background: #ffffff24;
    opacity: 1;
}
@media (hover: hover) and (pointer: fine) {
    .comic-photo-page-label .story-scene-info-button:hover { background: #ffffff24; opacity: 1; }
}
.comic-photo-page-label .story-scene-info-text {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(560px, calc(100vw - 32px));
    overflow-wrap: anywhere;
}

/* Character study is shared by vocabulary familiarity popups. */
.content-study-section { display: grid; gap: 1rem; }
.topic-page .content-study-section > :is(h2, .topic-vocabulary-progress, .content-flashcards) { margin: 0; }
.vocabulary-characters-action { display: flex; justify-content: flex-end; margin-bottom: .75rem; }
.vocabulary-character-progress { display: grid; gap: .8rem; margin-bottom: 1rem; }
.vocabulary-character-progress .reader-learning-heading { display: flex; justify-content: space-between; gap: .75rem; }
.vocabulary-character-study { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.vocabulary-character-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(7rem,1fr)); gap: .65rem; }
.vocabulary-character-item { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .75rem; border: 1px solid var(--border); border-radius: .8rem; }
.vocabulary-character-item .reader-subword-button { font-size: 2rem; }

.space-destinations {display:grid;gap:.55rem}
button.space-destination {display:flex;align-items:center;gap:.8rem;text-align:start;width:100%;padding:.85rem 1rem;background:var(--surface);color:var(--text);border:1px solid var(--border);border-radius:12px}
.space-destination span {display:grid;gap:.2rem;min-width:0;overflow-wrap:anywhere}
.space-destination small {color:var(--muted)}
button.space-remove {margin-top:.4rem;background:transparent}

.video-track-summary {padding: 16px 20px;}
.video-track-summary .section-heading {margin: 0;}
.video-line-counts {display:flex;gap:clamp(16px,5vw,60px);flex-wrap:wrap;margin:8px 0;}
.video-line-counts dt {color:var(--muted);font-size:.85rem;}
.video-line-counts dd {margin:4px 0 0;font-size:1.25rem;font-weight:600;}

.video-vocabulary-grid {display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,220px),1fr));gap:12px;}

.history-back-name {display:grid;min-width:0;text-align:start;line-height:1.2;}
.history-back-name small {font-size:.72em;color:var(--text-secondary);opacity:.8;transition:color .15s ease;}
.history-back-name > span {overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:min(56vw,28rem);}
.activity-screen-heading {display:flex;align-items:center;gap:12px;}
.activity-screen-heading h1 {margin:0;overflow-wrap:anywhere;}
.activity-screen-heading .screen-title-group:has(.activity-screen-level) {display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:4px 8px;}
.activity-screen-heading .screen-title-group:has(.activity-screen-level) h1 {grid-column:1 / -1;}
.activity-screen-heading .screen-title-group:has(.activity-screen-level) .screen-supertitle {margin:0;}
.activity-screen-level {grid-row:1;grid-column:2;justify-self:start;display:flex;}
.ask-about-popup > .reader-popup-heading h2 {flex:1;min-width:0;}

/* Measure the new step independently while the native dialog moves to its size. */
.reader-popup:has(> .popup-size-content) { transition: width .25s ease, height .25s ease; }
.popup-size-content { display:flex; flex-direction:column; flex:none; width:min(638px,calc(100vw - 26px - env(safe-area-inset-left) - env(safe-area-inset-right))); max-height:calc(100dvh - 26px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
[data-wide="true"] > .popup-size-content { width:min(998px,calc(100vw - 26px - env(safe-area-inset-left) - env(safe-area-inset-right))); }
.tspace-add-popup .form-actions, .tspace-add-popup .reader-wizard-actions { justify-content:space-between; }
.tspace-add-popup .story-interview > button.ghost { justify-self:start; }
@media (prefers-reduced-motion:reduce) { .reader-popup:has(> .popup-size-content) { transition:none; } }

/* The Reading library uses cover-first cards, sized against its available pane. */
.reader-library {container: discovery-layout / inline-size;}
.reader-library .library-content-card {aspect-ratio:4/3;height:auto;grid-template: minmax(0,1fr) / minmax(0,1fr);}
.reader-library .library-content-open {grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr) auto;}
.reader-library .library-thumbnail {height:auto;min-height:0;}
.reader-library .library-content-copy {padding:14px 16px 16px;}

/* A Space in the directory has a thumbnail alongside its name and word counts. */
.tspace-topics-page .tspace-grid {grid-template-columns:minmax(0,1fr);}
.tspace-topics-page .managed-tile > .tspace-topic-tile {
  display:grid;grid-template-columns:clamp(92px,26%,160px) minmax(0,1fr);
  grid-template-rows:auto;aspect-ratio:auto;height:auto;min-height:120px;
}
.tspace-topics-page .managed-tile > .tspace-topic-tile > .topic-card-art {position:relative;inset:auto;grid-area:1/1;}
.tspace-topics-page .tspace-topic-tile .topic-card-image {display:none;}
.tspace-topics-page .managed-tile > .tspace-topic-tile > .topic-card-copy {
  grid-area:1/2;justify-content:center;margin:0;padding:12px 16px;border:0;
}
.tspace-topics-page .topic-card-copy h3 {height:auto;}
.tspace-topics-page .topic-card-copy > .feed-card-metadata {padding:0;margin-block-start:4px;}
.tspace-topics-page .tspace-tile-glyph {place-self:center;margin:0;}

/* Home and Space categories scroll independently within the content column. */
.activity-rows { display:grid; min-width:0; gap:12px; }
.activity-row-section { min-width:0; }
.feed-section .activity-row-section:not(:has(.recent-activity-tile)) { display:none; }
.activity-row-heading { display:flex; align-items:center; min-height:32px; gap:12px; margin-bottom:6px; }
.activity-row-heading h2 { margin:0; margin-inline-end:auto; color:var(--text-secondary); font-size:.95rem; font-weight:600; }
.activity-row-controls { display:flex; gap:4px; }
.activity-row-controls[hidden] { display:none; }
.activity-row-controls button { width:32px; height:32px; min-height:32px; border-radius:50%; background:var(--surface); }
.activity-row-controls button:disabled { opacity:.35; }
.activity-row-controls:dir(rtl) svg { transform:scaleX(-1); }
@media (any-pointer:coarse) {
  .activity-row-controls { display:none; }
  .activity-row-heading { min-height:24px; }
}
@media (prefers-reduced-motion:no-preference) { .activity-row { scroll-behavior:smooth; } }
.activity-row {
  --row-tile-size:min(calc((100cqi - 6px) * .82), var(--activity-tile-width, 20rem));
  --row-fade-width:calc(var(--row-tile-size) / 3);
  --row-bleed:min(var(--activity-row-gutter, 0px), var(--row-fade-width));
  /* Matching margins and padding expose overflow in the gutters while keeping tiles aligned with the heading. */
  margin-inline:calc(0px - var(--row-bleed));
  padding:4px calc(3px + var(--row-bleed));
  display:grid; grid-auto-flow:column; grid-auto-columns:var(--row-tile-size); gap:14px;
  align-items:start; overflow-x:auto; overscroll-behavior-x:contain;
  scroll-snap-type:x proximity; scrollbar-width:none; scroll-padding-inline:calc(3px + var(--row-bleed));
}
/* Fully expose each end tile when the learner reaches it. */
.activity-row[data-can-scroll-start="true"] { --fade-start:var(--row-bleed); }
.activity-row[data-can-scroll-end="true"] { --fade-end:var(--row-bleed); }
.activity-row:dir(rtl) { --fade-direction:to left; }
.activity-row:is([data-can-scroll-start="true"], [data-can-scroll-end="true"]) {
  /* In a narrow gutter, the transparent end of the fade falls beyond the screen. */
  mask-image:linear-gradient(var(--fade-direction, to right),
    transparent calc(var(--fade-start, 0px) - var(--row-fade-width)), black var(--fade-start, 0px),
    black calc(100% - var(--fade-end, 0px)), transparent calc(100% - var(--fade-end, 0px) + var(--row-fade-width)));
}
.activity-row::-webkit-scrollbar { display:none; }
/* Newer items can arrive first or last. Snap once the initial row order is known. */
.feed-section[aria-busy="true"] .activity-row { scroll-snap-type:none; overflow-anchor:none; }
.activity-row:focus { outline:none; }
.activity-row > * { scroll-snap-align:start; container-type:inline-size; min-width:0; }
.activity-row :is(.topic-card, .feed-content-card) { width:100%; height:auto; min-height:0; aspect-ratio:4/3; }
:is(.activity-row-section[data-compact="true"], .activity-row > [data-compact-row="true"]) :is(.topic-card, .feed-content-card, .feed-note-card, .feed-flashcard-configuration) {
  width:100%; height:auto; min-height:0; aspect-ratio:8/3;
}

@container discovery-layout (min-width:40rem) {
  .activity-row { --activity-tile-width:clamp(20rem, 8rem + 20vw, var(--activity-tile-max-width)); }
}
.activity-row :is(.topic-card-copy h3, .feed-practice-source h3, .home-content-copy > strong) {
  font-size:clamp(.875rem, .35rem + 3cqi, 1.125rem);
}
.activity-row-section[data-compact="false"] .topic-card-copy { padding-inline:clamp(.75rem, 5cqi, 1.2rem); }
@container (max-width:20rem) {
  .activity-row-section[data-compact="false"] .topic-card-copy h3 { height:auto; min-height:2.6em; -webkit-line-clamp:3; }
}

/* Date headings start a new group in both Home layouts. */
.feed-section .activity-row-heading { justify-content:space-between; min-height:0; gap:8px; margin-bottom:4px; }
.feed-section .activity-row-heading:dir(rtl) { flex-direction:row-reverse; }
.feed-section .activity-row-heading h2 { margin:0; font-size:.8rem; line-height:1.35; font-weight:500; color:var(--muted); }
.feed-section .recent-activity-tile :is(.topic-card-copy, .home-content-copy, .feed-practice-progress, .feed-note-summary, .setup-content-copy) {
  padding-right:var(--recent-menu-space);
}
.recent-activity-tile .feed-chat-card .feed-practice-source { padding-right:var(--recent-menu-space); }
.recent-activity-tile .feed-practice-open { display:none; }

.flashcard-activity-options { grid-template-columns:repeat(3,minmax(0,1fr)); }
.word-phrases-option { --choice-color:#468971; }
.word-phrases-paper {
    align-self:center; width:100%; min-height:0; max-height:100%; overflow:auto; padding:clamp(18px,4vw,36px);
    border:1px solid var(--border); border-radius:20px; background:var(--surface); box-shadow:var(--shadow-sm);
}
.word-phrases-paper header { display:flex; align-items:center; justify-content:space-between; gap:16px; color:var(--text-secondary); font-size:.85rem; font-weight:600; }
.word-phrases-paper progress { width:clamp(60px,28%,140px); height:5px; accent-color:#468971; }
.word-phrases-sentence { margin:clamp(32px,8vh,80px) 0; font-size:clamp(1.6rem,5vw,2.55rem); line-height:1.85; text-align:center; overflow-wrap:anywhere; white-space:pre-wrap; text-wrap:balance; }
.word-phrases-unit { display:inline-block; max-width:100%; }
.word-phrases-pending { display:grid; justify-items:center; gap:12px; padding:clamp(24px,6vh,60px) 0; }
.word-phrases-pending .word-phrases-sentence { margin:0 0 12px; }
button.word-phrases-token {
    display:inline; min-height:0; padding:.04em 0; border:0; border-radius:5px; background:transparent; box-shadow:none;
    font:inherit; line-height:inherit; color:inherit; white-space:normal; overflow-wrap:anywhere; cursor:pointer;
    text-decoration:underline; text-decoration-thickness:1px; text-underline-offset:.19em; text-decoration-color:var(--border-strong);
}
button.word-phrases-token[aria-pressed="true"] { background:color-mix(in srgb,#468971 20%,var(--surface)); color:var(--text); text-decoration-color:#468971; text-decoration-thickness:2px; }
.word-phrases-dock.study-dock { display:grid; gap:12px; width:100%; min-height:0; padding:clamp(12px,3vw,22px); max-height:57cqh; overflow:auto; }
.word-phrases-wordbar,.word-phrases-familiarity,.word-phrases-selection,.word-phrases-stepper { display:flex; align-items:center; gap:8px; }
.word-phrases-wordbar,.word-phrases-familiarity { justify-content:space-between; }
.word-phrases-selection { justify-content:center; min-width:0; }
.word-phrases-selection strong { font-size:clamp(1.25rem,3vw,1.65rem); overflow-wrap:anywhere; }
.word-phrases-selection .icon-button { color:var(--text-secondary); flex:none; }
.word-phrases-familiarity { border-top:1px solid var(--border); padding-top:10px; font-size:.9rem; color:var(--text-secondary); }
.word-phrases-stepper output { min-width:4.3em; text-align:center; color:var(--text); font-variant-numeric:tabular-nums; }
.word-phrases-dock .icon-button { min-width:42px; min-height:42px; }
.word-phrases-continue { width:100%; min-height:44px; }
.word-phrases-book { width:90px; height:74px; object-fit:contain; }
@media (max-height:540px) {
    .word-phrases-dock.study-dock { gap:5px; padding:8px; }
    .word-phrases-sentence { margin:8px 0; font-size:1.5rem; }
}
@media (max-width:400px) {
    .flashcard-activity-option { padding:10px 8px; }
    .flashcard-activity-option strong { font-size:.85rem; overflow-wrap:anywhere; }
}

.first-reading-picker,.first-reading-copy,.first-reading-account,.first-reading-trial {display:grid;min-width:0}
.first-reading-picker {gap:16px}
.first-reading-context,.first-reading-message,.first-reading-synopsis {margin:0;color:var(--text-secondary)}
.first-reading-context {font-size:.94rem}
.first-reading-search {display:flex;align-items:center;gap:10px;padding:0 14px;background:var(--surface);color:var(--text-secondary);border:1px solid var(--border);border-radius:12px}
.first-reading-search:focus-within {outline:2px solid var(--accent);outline-offset:2px}
.first-reading-search input {background:transparent;border:0;box-shadow:none;outline:0;min-width:0;flex:1;padding:13px 0;color:var(--text);font:inherit}
.first-reading-results {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:0;padding:0;list-style:none}
.onboard button.first-reading-tile,.onboard button.first-reading-custom {display:flex;align-items:center;gap:14px;text-align:start;white-space:normal;width:100%;height:100%;border:1px solid var(--border);color:var(--text);background:var(--surface);border-radius:14px}
.onboard button.first-reading-tile {padding:10px}
.first-reading-art {width:84px;aspect-ratio:1;flex:none;display:grid;place-items:center;border-radius:9px;overflow:hidden;background:var(--surface-subtle);color:var(--text-secondary)}
.first-reading-art img {width:100%;height:100%;object-fit:cover}
.first-reading-copy {gap:4px;align-content:center}
.first-reading-copy strong {font-size:1.02rem;line-height:1.25;overflow-wrap:anywhere}
.first-reading-level {color:var(--text-secondary);font-size:.7rem;font-weight:650;letter-spacing:.04em}
.first-reading-synopsis {font-weight:400;font-size:.86rem;line-height:1.35;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.onboard button.first-reading-custom {padding:16px;background:color-mix(in srgb,var(--accent) 7%,var(--surface));border-color:color-mix(in srgb,var(--accent) 35%,var(--border))}
.first-reading-custom-icon {display:grid;place-items:center;width:44px;height:44px;border-radius:12px;background:color-mix(in srgb,var(--accent) 15%,transparent);color:var(--text)}
.first-reading-custom>.first-reading-copy {flex:1}
.first-reading-picker button.onboard-skip-story {margin-top:0}
.first-reading-account,.first-reading-trial {gap:16px}
.first-reading-trial p {margin:0;color:var(--text-secondary)}
@media(max-width:680px) {
  .first-reading-results {grid-template-columns:1fr}
  .first-reading-art {width:65px}
  .first-reading-picker {gap:12px}
}

.first-reading-plan { display: flex; width: 100%; align-items: center; gap: .75rem; padding: 1rem; border: 1px solid var(--border); border-radius: .85rem; background: var(--surface); color: inherit; text-align: start; }
.first-reading-plan-name { flex: 1; display: grid; gap: .2rem; }
.first-reading-plan-name strong { color: var(--text); }
.first-reading-plan-name small { font-weight: 400; }
.first-reading-trial .billing-intervals { margin-top: 0; }
.first-reading-plan span { color: var(--muted); }
.first-reading-plan:hover:enabled, .first-reading-plan:focus-visible { border-color: currentColor; }
