/* ==========================================================================
   Context English — Consolidated Design System & Styles (P2)
   Preserves 100% of motion choreography, tokens, breakpoints & hooks.
   ========================================================================== */

/* ---------- 1. Design Tokens (:root = dark, html[data-theme="light"] = light) ---------- */
:root {
  color-scheme: dark;
  --bg: #141518;
  --surface-0: #1E2024;
  --surface-1: #1A1C20;
  --surface-2: #26292E;
  --capsule-surface: var(--surface-0);
  --header-surface: var(--capsule-surface);
  --band: #191B1F;
  --tone-a: #17191C;
  --tone-b: #1A1C20;
  --sentence-bg: var(--tone-b);
  --ink-1: #ECEAE6;
  --ink-2: #A3A7AE;
  --ink-3: #8A8F98;
  --accent: #9DAAC6;
  --vocab: #9BB0D4;
  --vocab-stroke: #A08C69;
  --danger: #D88A82;
  --success: #93B39A;
  --scrim: rgba(0, 0, 0, .5);

  --accent-a12: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-a15: color-mix(in srgb, var(--accent) 15%, transparent);
  --accent-a20: color-mix(in srgb, var(--accent) 20%, transparent);
  --accent-a30: color-mix(in srgb, var(--accent) 30%, transparent);
  --ink-a20: color-mix(in srgb, var(--ink-1) 20%, transparent);
  --danger-a10: color-mix(in srgb, var(--danger) 10%, transparent);

  --btn-primary-bg: #ECEAE6;
  --btn-primary-ink: #141518;
  --btn-primary-hover: color-mix(in srgb, var(--btn-primary-bg) 94%, black);
  --scene-bg: #1C1E22;
  --scene-bg-2: #23262B;
  --scene-ink: #ECEAE6;
  --scene-muted: #A3A7AE;
  --scene-btn-bg: #ECEAE6;
  --scene-btn-ink: #141518;
  --scene-btn-2-bg: rgba(255, 255, 255, .07);
  --scene-btn-2-ink: #ECEAE6;

  /* Semantic aliases */
  --text: var(--ink-1);
  --muted: var(--ink-2);
  --faint: var(--ink-3);
  --surface: var(--surface-1);

  /* Typography: 2 families (Inter/system UI sans + Newsreader/Noto Serif SC prose) */
  --font-ui: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "HarmonyOS Sans SC", "Noto Sans SC", system-ui, sans-serif;
  --font-serif-en: "Newsreader", Georgia, serif;
  --font-serif-cn: "Noto Serif SC", "Source Han Serif SC", serif;
  --display: var(--font-serif-en);
  --serif-en: var(--font-serif-en);
  --serif-cn: var(--font-serif-cn);
  --sans: var(--font-ui);

  /* Disciplined type scale: 3 body/UI steps (13/15/18) + heading steps */
  --fs-12: 12px; --lh-12: 1.4;
  --fs-13: 13px; --lh-13: 1.45;
  --fs-14: 14px; --lh-14: 1.5;
  --fs-15: 15px; --lh-15: 1.55;
  --fs-17: 17px; --lh-17: 1.45;
  --fs-20: 20px; --lh-20: 1.35;
  --fs-24: 24px; --lh-24: 1.3;
  --fs-32: 32px; --lh-32: 1.2;
  --fs-44: 44px; --lh-44: 1.1;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 48px;

  --r-check: 6px;
  --r-inner: 8px;
  --r-10: 10px;
  --r-12: 12px;
  --r-field: 14px;
  --r-row: 14px;
  --r-entry: 16px;
  --r-popover: 16px;
  --r-dialog: 20px;
  --r-sheet: 24px;
  --r-pill: 999px;

  --shadow-rest: 0 1px 2px rgba(0, 0, 0, .15);
  --shadow-float: 0 1px 2px rgba(20, 22, 26, .18), 0 8px 24px rgba(20, 22, 26, .30);
  --shadow-overlay: 0 2px 8px rgba(20, 22, 26, .18), 0 24px 64px rgba(20, 22, 26, .48);
  --shadow-knob: 0 1px 2px rgba(20, 22, 26, .25);
  --ring: 0 0 0 3px var(--accent-a30);
  --ring-danger: 0 0 0 1px var(--danger-a10);

  --header-h: 72px;
  --wave-edge-blur: 0px;

  --reading-adjustment: 0px;

  /* Motion tokens */
  --dur-1: 160ms;
  --dur-2: 240ms;
  --dur-3: 320ms;
  --dur-4: 380ms;
  --dur-pop: 160ms;
  --dur-arrive: 600ms;
  --dur-pulse: 1.2s;
  --dur-drift: 42s;
  --dur-knob: 450ms;
  --delay-arrive: 80ms;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #FFFFFF;
  --surface-0: #FFFFFF;
  --surface-1: #F8F9FA;
  --surface-2: #F0F2F5;
  --band: #FAFBFD;
  --tone-a: #FFFFFF;
  --tone-b: #F8F9FB;
  --ink-1: #1F2430;
  --ink-2: #5E6470;
  --ink-3: #676C75;
  --accent: #4E5D7A;
  --vocab: #3B5580;
  --vocab-stroke: #8E9CB2;
  --danger: #B4534A;
  --success: #5E7D63;
  --scrim: rgba(24, 26, 31, .32);

  --btn-primary-bg: #1F2430;
  --btn-primary-ink: #FFFFFF;
  --scene-bg: #F8F9FB;
  --scene-bg-2: #F2F4F7;
  --scene-ink: #1F2430;
  --scene-muted: #5E6470;
  --scene-btn-bg: #1F2430;
  --scene-btn-ink: #FFFFFF;
  --scene-btn-2-bg: rgba(255, 255, 255, .88);
  --scene-btn-2-ink: #1F2430;

  --shadow-rest: 0 1px 2px rgba(20, 22, 26, .05);
  --shadow-float: 0 1px 2px rgba(20, 22, 26, .06), 0 8px 24px rgba(20, 22, 26, .10);
  --shadow-overlay: 0 2px 8px rgba(20, 22, 26, .06), 0 24px 64px rgba(20, 22, 26, .16);
  --shadow-knob: 0 1px 2px rgba(20, 22, 26, .18);
}

html[data-reading-size="small"] { --reading-adjustment: -2px; }
html[data-reading-size="large"] { --reading-adjustment: 2px; }
@media (max-width: 1023px) { :root { --header-h: 60px; } }

/* ---------- 2. Base, Focus & Theme Transitions ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); overflow-x: clip; scrollbar-gutter: stable; }
html.ce-modal-lock { overflow: hidden; }
html.ce-modal-lock body { padding-right: var(--sbw, 0px); }
html.ce-modal-lock .home-texture::before { animation-play-state: paused; }
body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink-1);
  font-family: var(--font-serif-en);
  font-size: 18px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
}
html.theme-init body { transition: none !important; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { font: inherit; }

/* Circular View Transition theme reveal */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.theme-switching *:not(.theme-knob), html.theme-switching *::before, html.theme-switching *::after { transition: none !important; }

/* Keyboard-only focus rings */
:focus-visible { outline: none; box-shadow: var(--ring); }
:where(a, summary):focus-visible { border-radius: var(--r-inner); }
.vocab:focus-visible { border-radius: var(--r-pill); }
html[data-input="pointer"] :focus-visible { box-shadow: none; }
html[data-input="pointer"] .vocab:focus-visible { border-radius: var(--r-pill); box-shadow: none; }
.ov-title:focus, .ov-heading:focus, .library-heading:focus, .mobile-toc-head h2:focus, .mode-heading:focus, .account-content h2:focus, #assistant-title:focus { outline: none; box-shadow: none; }
.ov-title:focus-visible, .ov-heading:focus-visible, .library-heading:focus-visible, .mobile-toc-head h2:focus-visible, .mode-heading:focus-visible, .account-content h2:focus-visible, #assistant-title:focus-visible { outline: none; box-shadow: var(--ring); }
html[data-input="pointer"] :is(.ov-title, .ov-heading, .library-heading, .mobile-toc-head h2, .mode-heading, .account-content h2, #assistant-title):focus-visible { box-shadow: none; }

/* Reading progress bar */
.reading-progress { position: fixed; z-index: 50; top: 0; left: 0; width: 100%; height: 2px; }
.reading-progress span { display: block; width: 100%; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left center; }

/* Frame & full-bleed helper */
.site-frame { width: min(100% - 48px, 1260px); margin: 0 auto; }
.full-band { width: 100vw; margin-inline: calc(50% - 50vw); background: var(--band); }

/* ---------- 3. Floating Capsule Header (with split reading-context morph) ---------- */
.site-header {
  position: sticky;
  z-index: 40;
  top: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  min-height: var(--header-h);
  width: 100vw;
  margin-inline: calc(50% - 50vw);
  padding-inline: max(32px, env(safe-area-inset-left)) max(32px, env(safe-area-inset-right));
  background: var(--bg);
}
.site-name {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 10px;
  text-align: center;
  text-decoration: none;
  color: var(--ink-1);
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.015em;
  line-height: 1.1;
  text-transform: uppercase;
  white-space: nowrap;
}
.mark { display: block; flex: none; width: 1.1em; height: 1.1em; }
.site-header .library-open svg, .settings-open svg, .account-open svg {
  display: block; flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.header-end { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.site-frame > .site-header.capsule-header {
  --header-tools: 88px;
  --header-height: 60px;
  position: sticky;
  top: calc(12px + env(safe-area-inset-top));
  width: min(1100px, calc(var(--header-viewport, 100vw) - 24px));
  min-height: 60px;
  height: 60px;
  margin: 12px calc((100% - min(1100px, var(--header-viewport, 100vw) - 24px)) / 2) 24px;
  padding: 0;
  display: block;
  background: transparent !important;
}
.site-frame > .site-header.capsule-header::before {
  content: "";
  position: fixed;
  z-index: -1;
  top: 0;
  left: 0;
  right: 0;
  height: calc(82px + env(safe-area-inset-top));
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 90%, transparent) 58%, transparent 100%);
  transition: opacity var(--dur-2) var(--ease-out);
}
.site-frame > .site-header.capsule-header.scrolled::before,
.site-frame > .site-header.capsule-header.is-reading::before { opacity: 1; }
.capsule-header::after { display: none; }

.header-pill {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  width: 100%;
  height: var(--header-height);
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--header-surface) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 6px 22px #0002;
  transition: width var(--dur-3) var(--ease-out), height var(--dur-3) var(--ease-out);
}
.site-frame > .capsule-header .library-open { width: 40px; min-width: 40px; height: 44px; }
.header-identity { position: relative; display: grid; place-items: center; flex: 1; min-width: 0; height: 100%; margin-right: var(--header-tools); }
.site-frame > .capsule-header .site-name { position: static; font-size: 15px; gap: 6px; letter-spacing: -.4px; transition: opacity 180ms var(--ease-out), transform 280ms var(--ease-out); }
.site-frame > .capsule-header .header-end { position: absolute; z-index: 2; top: 0; right: 8px; height: var(--header-height); gap: 0; padding: 0; display: flex; border-radius: var(--r-pill); transition: height var(--dur-3) var(--ease-out); }
.site-frame > .capsule-header .header-end > .btn-icon { margin: 0; padding: 0; width: 40px; min-width: 40px; height: 44px; }
.capsule-header .account-label { display: none; }
.capsule-header [aria-expanded="true"] { color: var(--accent); }

.header-reading-context {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 0; padding-left: 6px; min-width: 0;
  opacity: 0; visibility: hidden; transform: translateY(8px); color: var(--ink-1); text-decoration: none; font-family: var(--font-ui);
  transition: opacity 220ms var(--ease-out), transform 280ms var(--ease-out);
}
.header-act { font-size: var(--fs-12); line-height: 1.4; color: var(--ink-2); }
.header-part { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: var(--fs-13); line-height: 1.45; }

.site-frame > .capsule-header.is-reading { --header-height: 52px; }
.capsule-header.is-reading .header-pill { width: calc(100% - var(--header-tools) - 8px); }
.capsule-header.is-reading .header-identity { margin-right: 0; }
.capsule-header.is-reading .site-name { opacity: 0; visibility: hidden; transform: translateY(-8px); }
.capsule-header.is-reading .header-reading-context { opacity: 1; visibility: visible; transform: none; }
.site-frame > .capsule-header.is-reading .header-end {
  right: 0; padding: 4px;
  background: color-mix(in srgb, var(--header-surface) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 6px 22px #0002;
}

@media (min-width: 1024px) {
  .site-frame > .site-header.capsule-header { width: min(1100px, calc(var(--header-viewport, 100vw) - 64px)); margin-inline: calc((100% - min(1100px, var(--header-viewport, 100vw) - 64px)) / 2); }
  .site-frame > .capsule-header .site-name { font-size: 24px; }
  .header-part { font-size: var(--fs-15); }
  .article-frame > .site-header.capsule-header { --header-tools: 132px; --resting-inset: max(0px, calc((100% - 1100px) / 2)); width: 100%; margin-inline: 0; }
  .article-frame > .capsule-header .header-pill { width: min(100%, 1100px); margin-inline-start: var(--resting-inset); transition: width var(--dur-3) var(--ease-out), height var(--dur-3) var(--ease-out), margin-inline-start var(--dur-3) var(--ease-out); }
  .article-frame > .capsule-header .header-end { right: calc(8px + var(--resting-inset)); transition: height var(--dur-3) var(--ease-out), right var(--dur-3) var(--ease-out); }
  .article-frame > .capsule-header.is-reading { pointer-events: none; }
  .article-frame > .capsule-header.is-reading .header-pill { width: clamp(150px, calc((100% - 760px) / 2), 300px); margin-inline-start: 0; pointer-events: auto; }
  .article-frame > .capsule-header.is-reading .header-end { right: 0; pointer-events: auto; }
}
@media (max-width: 1023px) { .article-frame .site-header .theme-btn { display: none; } }
@media (max-width: 359px) { .site-frame > .capsule-header .site-name { font-size: var(--fs-13); gap: 4px; } }

/* ---------- 4. Buttons, Theme Toggle, Switches & Segmented Controls ---------- */
.btn, .reading-link {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill);
  font-family: var(--font-ui); font-size: var(--fs-15); font-weight: 560; line-height: 1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.btn svg, .reading-link .i { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn:active, .reading-link:active { transform: scale(.97); }
.btn[disabled], .btn:disabled { opacity: .5; cursor: default; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: var(--fs-13); }
.btn-lg { min-height: 48px; padding: 0 24px; font-size: var(--fs-15); }
.btn-primary, .reading-link { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }
.btn-primary:hover, .reading-link:hover { background: var(--btn-primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--ink-1); }
.btn-secondary:hover { background: color-mix(in srgb, var(--surface-2) 82%, var(--ink-1) 6%); }
.btn-text { min-height: 36px; padding: 0 12px; background: transparent; color: var(--ink-2); font-size: var(--fs-13); }
.btn-text:hover { background: var(--surface-1); color: var(--ink-1); }
.btn-block { display: flex; width: 100%; }

.icon-button, .btn-icon {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-1); cursor: pointer;
  transition: background-color 120ms var(--ease-out), color 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.btn-icon:hover, .icon-button:hover { background: var(--surface-1); }
.btn-icon:active, .library-open:active, .settings-open:active, .reader-tools button:active, .ov-close:active, .chat-close:active, .chat-new:active { transform: scale(.97); }

/* Header theme button & hover tooltip */
.theme-btn { position: relative; color: var(--ink-1); }
.theme-icon { display: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
html[data-theme-mode="system"] .theme-icon-system,
html[data-theme-mode="light"] .theme-icon-sun,
html[data-theme-mode="dark"] .theme-icon-moon,
html:not([data-theme-mode])[data-theme="light"] .theme-icon-sun,
html:not([data-theme-mode])[data-theme="dark"] .theme-icon-moon { display: block; }
.theme-btn::after {
  content: attr(data-tooltip); position: absolute; top: calc(100% + 8px); right: 0;
  padding: 6px 10px; border-radius: var(--r-pill); background: var(--ink-1); color: var(--bg);
  font: 560 var(--fs-12)/1 var(--font-ui); white-space: nowrap; opacity: 0; transform: translateY(-2px); pointer-events: none;
  transition: opacity 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.theme-btn:is(:hover, :focus-visible):not([aria-expanded="true"])::after { opacity: 1; transform: none; transition-delay: 300ms; }

/* Segmented controls & switches */
.font-size-control, .context-segments, .archive-order {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px; border: 0; border-radius: var(--r-pill); background: var(--surface-1); font-family: var(--font-ui);
}
.context-segments { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 4px; }
.font-size-control button, .mode-options .context-button, .archive-order button {
  position: relative; min-width: 34px; min-height: 32px; height: 32px; padding: 0 12px; border: 0; border-radius: var(--r-pill);
  background: transparent; color: var(--ink-2); font: 560 var(--fs-13)/1 var(--font-ui); cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-sheet), color var(--dur-2) var(--ease-sheet);
}
.font-size-control button:hover, .archive-order button:hover { color: var(--ink-1); }
.font-size-control button[aria-pressed="true"], .mode-options .context-button[aria-pressed="true"], .archive-order button[aria-pressed="true"] {
  background: var(--surface-0); color: var(--ink-1); box-shadow: var(--shadow-rest);
}
html:not([data-theme="light"]) .archive-order button[aria-pressed="true"] { background: var(--surface-2); }

.theme-toggle { position: relative; flex: none; width: 44px; height: 26px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); padding: 3px; cursor: pointer; transition: background-color var(--dur-2) var(--ease-sheet); }
.theme-toggle[aria-pressed="true"], html[data-theme="dark"] .theme-toggle { background: var(--accent); }
.theme-knob { display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-knob); transform: translateX(18px); transition: transform var(--dur-knob) var(--ease-sheet); }
html[data-theme="light"] .theme-knob { transform: translateX(0); }

.option-switch { display: flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; padding: 0; border-radius: var(--r-pill); background: transparent; border: 0; cursor: pointer; }
.switch-track { position: relative; display: block; width: 38px; height: 22px; border-radius: var(--r-pill); background: var(--surface-2); transition: background-color var(--dur-2) var(--ease-sheet); }
.switch-track::before { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-knob); transition: transform var(--dur-2) var(--ease-sheet); }
.option-switch[aria-checked="true"] .switch-track { background: var(--accent); }
.option-switch[aria-checked="true"] .switch-track::before { transform: translateX(16px); }
@media (hover: hover) { .option-switch:hover .switch-track { filter: brightness(.96); } }
.settings-rows .option-switch { margin-block: -9px; }
.settings-rows .switch-track { width: 44px; height: 26px; }
.settings-rows .switch-track::before { width: 20px; height: 20px; transition-duration: var(--dur-knob); }
.settings-rows .option-switch[aria-checked="true"] .switch-track::before { transform: translateX(18px); }

/* Extended touch hit areas */
.theme-toggle::after { content: ""; position: absolute; inset: -9px 0; border-radius: inherit; }
.font-size-control button::after { content: ""; position: absolute; inset: -7px 0; border-radius: inherit; }
.font-size-control button:first-child::after { left: -10px; }
.font-size-control button:last-child::after { right: -10px; }
.mode-options .context-button::after { content: ""; position: absolute; inset: -6px 0; border-radius: inherit; }
.mode-options #reset-recall { position: relative; }
.mode-options #reset-recall::after { content: ""; position: absolute; inset: -2px 0; border-radius: inherit; }

/* ---------- 5. Overlays: Dialog, Sheet, Drawer, Popover (reversed-close keyframes) ---------- */
dialog.ov-dialog, dialog.ov-sheet, dialog.ov-drawer, .ov-popover {
  margin: 0; padding: 0; border: 0; color: var(--ink-1); background: var(--surface-0);
  font-family: var(--font-ui); overflow: hidden; box-shadow: var(--shadow-overlay);
}
dialog.ov-dialog::backdrop, dialog.ov-sheet::backdrop, dialog.ov-drawer::backdrop {
  background: var(--scrim); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: veil-in 240ms var(--ease-sheet) both;
}
dialog.ov-dialog.closing::backdrop, dialog.ov-sheet.closing::backdrop, dialog.ov-drawer.closing::backdrop {
  animation: veil-out 190ms var(--ease-out) reverse both;
}
.ov-close {
  position: relative; z-index: 2; display: grid; place-items: center; width: 36px; height: 36px; padding: 0;
  border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1); cursor: pointer;
  transition: background-color 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.ov-close::before { content: ""; position: absolute; inset: -4px; border-radius: var(--r-pill); }
.ov-close:hover { background: color-mix(in srgb, var(--surface-2) 82%, var(--ink-1)); }
.ov-close svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }

dialog.ov-dialog {
  inset: 0; width: min(440px, 100vw - 32px); max-width: none; max-height: calc(100dvh - 32px);
  margin: auto; padding: var(--sp-6); border-radius: var(--r-dialog);
  animation: dlg-in 240ms var(--ease-sheet) both;
}
dialog.ov-dialog.closing { animation: dlg-out 180ms cubic-bezier(.55, 0, .8, 1) reverse both; }

dialog.ov-sheet {
  inset: auto 0 0; width: auto; max-width: none; max-height: min(86dvh, 640px);
  margin: 0; padding: var(--sp-3) var(--sp-5) calc(var(--sp-6) + env(safe-area-inset-bottom));
  border-top-left-radius: var(--r-sheet); border-top-right-radius: var(--r-sheet);
  animation: sheet-in 280ms var(--ease-sheet) both;
}
dialog.ov-sheet.closing { animation: sheet-out 220ms cubic-bezier(.55, 0, .8, 1) reverse both; }
dialog.ov-sheet::backdrop { backdrop-filter: none; -webkit-backdrop-filter: none; animation-duration: 260ms; }
dialog.ov-sheet.closing::backdrop { animation-duration: 220ms; }
.ov-handle { width: 36px; height: 4px; margin: 0 auto var(--sp-3); border-radius: var(--r-pill); background: var(--ink-a20); }

dialog.ov-drawer {
  inset: 12px; max-width: none; max-height: none; margin: 0; border-radius: var(--r-sheet);
  animation: drawer-in 250ms var(--ease-out) both;
}
dialog.ov-drawer[open] { will-change: transform; }
dialog.ov-drawer::backdrop {
  backdrop-filter: none; -webkit-backdrop-filter: none;
  animation: veil-in 240ms var(--ease-out) both;
}
dialog.ov-drawer.closing { animation: drawer-out 200ms cubic-bezier(.55, 0, .8, 1) reverse both; }
dialog.ov-drawer.closing::backdrop { animation: veil-out 190ms var(--ease-out) reverse both; }
dialog.ov-drawer.from-left { right: auto; width: min(348px, calc(100% - 64px)); }
dialog.ov-drawer.from-right { left: auto; width: min(380px, calc(100% - 48px)); animation-name: drawer-right-in; }
dialog.ov-drawer.from-right.closing { animation-name: drawer-right-out; }

.ov-popover {
  border-radius: var(--r-popover); padding: 14px 16px; max-width: 320px; box-shadow: var(--shadow-float);
  transform-origin: 50% 100%; animation: pop-in var(--dur-pop) var(--ease-sheet) both;
}
.ov-popover.opens-below { transform-origin: 50% 0; }
.ov-popover.closing { animation: pop-out 130ms var(--ease-sheet) reverse both; }

@keyframes dlg-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes dlg-out { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes sheet-in { from { transform: translate3d(0, 100%, 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes sheet-out { from { transform: translate3d(0, 100%, 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes drawer-in { from { transform: translate3d(-100%, 0, 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes drawer-out { from { transform: translate3d(-100%, 0, 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes drawer-right-in { from { transform: translate3d(100%, 0, 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes drawer-right-out { from { transform: translate3d(100%, 0, 0); } to { transform: translate3d(0, 0, 0); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(var(--pop-offset, 4px)) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes pop-out { from { opacity: 0; transform: translateY(var(--pop-offset, 4px)) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes veil-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes veil-out { from { opacity: 0; } to { opacity: 1; } }
@keyframes settings-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ai-desk-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

@media (min-width: 1024px) {
  .assistant-panel:not(.closing) { animation: ai-desk-in 200ms var(--ease-out) both; }
  .assistant-panel.closing { animation: ai-desk-in 160ms var(--ease-out) reverse both; }
}

/* Settings anchored popover */
.settings-dialog {
  position: fixed; z-index: 90; inset: auto; width: min(304px, calc(100vw - 64px)); max-height: calc(100dvh - 120px);
  margin: 0; padding: 16px 6px 16px 16px; border: 0; border-radius: var(--r-popover);
  background: var(--surface-0); color: var(--ink-1); box-shadow: var(--shadow-float);
  font-family: var(--font-ui); overflow: hidden; transform-origin: 100% 0;
  animation: settings-in var(--dur-pop) var(--ease-out) both;
}
.settings-dialog::backdrop { background: transparent; backdrop-filter: none; -webkit-backdrop-filter: none; animation: none; }
.settings-dialog.closing { animation: settings-in var(--dur-1) var(--ease-out) reverse both; }
.settings-sheet { max-height: calc(100dvh - 120px); overflow-y: auto; overscroll-behavior: contain; padding-right: 10px; }
.settings-sheet .ov-handle { display: none; }
.settings-rows { padding-top: 4px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 0; }
.setting-label { color: var(--ink-2); font-family: var(--font-ui); font-size: var(--fs-13); }

/* Library drawer */
dialog.ov-drawer.library-dialog { max-height: calc(100dvh - 24px); padding: 0; contain: layout style paint; }
.library-dialog[open] { display: flex; flex-direction: column; }
.library-shell { display: flex; flex: 1; min-height: 0; flex-direction: column; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.library-head { display: flex; flex-shrink: 0; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 14px 8px 22px; }
.library-heading { margin: 0; font: 600 var(--fs-17)/var(--lh-17) var(--font-ui); text-align: left; }
.library-panels { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 14px 20px; }
.library-articles { display: flex; flex-direction: column; }
.library-item { display: grid; grid-template-columns: 60px minmax(0, 1fr); gap: 10px; padding: 14px 12px; border-radius: var(--r-12); text-decoration: none; transition: background-color var(--dur-1) var(--ease-out); -webkit-touch-callout: none; }
.library-item.is-current { background: var(--accent-a12); }
.library-item.is-current .library-title strong { font-weight: 600; }
.library-item.is-current .library-number,
.library-item.is-current .library-collection-icon { color: var(--accent); }
@media (hover: hover) and (pointer: fine) {
  .library-item:hover { background: var(--surface-1); }
  .library-item.is-current:hover { background: var(--accent-a15); }
}
.library-number { padding-top: 2px; color: var(--ink-2); font: 600 var(--fs-13)/1.5 var(--font-ui); font-variant-numeric: tabular-nums; letter-spacing: .04em; white-space: nowrap; }
.library-title { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.library-title strong { font-family: var(--font-ui); font-size: var(--fs-15); font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.library-title em { color: var(--ink-2); font-family: var(--font-ui); font-size: var(--fs-13); font-style: normal; line-height: var(--lh-13); overflow-wrap: anywhere; }
.library-vocabulary, .library-sentences { grid-template-columns: 22px minmax(0, 1fr); align-items: start; gap: 12px; padding: 13px 12px; }
.library-vocabulary { margin-bottom: 12px; }
.library-sentences { margin-top: 12px; }
.library-vocabulary .library-title strong, .library-sentences .library-title strong { font-weight: 600; }
.library-collection-icon { display: grid; place-items: center; width: 22px; height: 22px; margin-top: 1px; color: var(--ink-2); transition: color var(--dur-1) var(--ease-out); }
.library-collection-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Drag-to-dismiss drawers & sheets */
@media (max-width: 1199px) { .library-dialog { touch-action: pan-y pinch-zoom; } }
@media (max-width: 1023px) { .assistant-panel, .mobile-toc-dialog, .mobile-mode-dialog { touch-action: pan-y pinch-zoom; } }
.library-dialog.is-dragging, .assistant-panel.is-dragging, .mobile-toc-dialog.is-dragging, .mobile-mode-dialog.is-dragging { will-change: translate; -webkit-user-select: none; user-select: none; }

/* Word lookup popover */
.word-popover {
  position: fixed; inset: auto; z-index: 100; display: none; flex-direction: column; gap: var(--sp-2);
  width: max-content; min-width: min(168px, calc(100vw - 24px)); max-width: min(320px, calc(100vw - 24px)); max-height: min(280px, 45dvh);
  overflow-y: auto; overscroll-behavior: auto; line-height: 1.45; overflow-wrap: anywhere;
}
.word-popover[open] { display: flex; animation: word-card-in 110ms var(--ease-out) both; }
.word-popover.closing { animation: word-card-out 85ms var(--ease-out) both; }
.word-popover [hidden] { display: none; }
.popover-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; }
.popover-term { font-family: var(--font-ui); font-size: var(--fs-17); font-weight: 650; line-height: 1.3; }
.popover-pronunciation { font-family: var(--font-ui); font-size: var(--fs-13); color: var(--ink-2); }
.popover-definition { display: block; font-family: var(--font-ui); font-size: var(--fs-15); line-height: 1.5; }
.popover-actions { display: inline-flex; align-items: center; gap: 8px; }
.popover-speak, .popover-fav {
  position: relative; align-self: flex-start; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1);
  font: 560 var(--fs-13)/1 var(--font-ui); cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform 100ms var(--ease-out);
}
.popover-speak::before, .popover-fav::before { content: ""; position: absolute; inset: -6px; border-radius: var(--r-pill); }
.popover-speak svg { width: 14px; height: 14px; fill: currentColor; stroke: none; flex: none; }
.popover-fav svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; display: inline-block; transform-origin: center; }
.popover-speak:hover, .popover-fav:hover { background: color-mix(in srgb, var(--surface-2) 82%, var(--ink-1)); }
.popover-speak:active, .popover-fav:active { transform: scale(.96); }
.popover-speak:disabled { opacity: .5; cursor: default; }
.popover-fav.is-favorited { background: var(--btn-primary-bg); color: var(--btn-primary-ink); }
.popover-fav.is-favorited svg { fill: currentColor; stroke: none; }
.popover-fav.is-favorited:hover { background: var(--btn-primary-hover); }
.popover-fav svg.anim-pop { animation: fav-icon-pop 200ms var(--ease-out); }
.popover-audio-error { color: var(--ink-2); font-size: var(--fs-12); }
.popover-close { display: none; }
.popover-pronunciation-toggle { align-self: flex-start; min-height: 28px; padding: 2px 0; border: 0; background: none; color: var(--ink-2); font: var(--fs-13) var(--font-ui); cursor: pointer; }
@keyframes fav-icon-pop { 0% { transform: scale(1); } 50% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes word-card-in { from { opacity: 0; transform: translateY(var(--word-enter-offset, -4px)) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes word-card-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(var(--word-enter-offset, -4px)) scale(.985); } }

/* ---------- 6. Homepage: Paper Drift, Hero Band, 25-Act Grid & Endzone ---------- */
.home-frame { position: relative; z-index: 1; }
.home-main { max-width: 1120px; margin: 0 auto; }
.home-texture {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  mask-image: linear-gradient(90deg, #000, rgba(0, 0, 0, .25) 28%, rgba(0, 0, 0, .25) 72%, #000);
}
.home-texture::before {
  content: ""; position: absolute; inset: -18px; background: var(--ink-1); opacity: .065;
  mask-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22640%22%20height%3D%22540%22%20viewBox%3D%220%200%20640%20540%22%3E%3Cpath%20d%3D%22M-40%2018%20C110%20-12%20200%2050%20330%2026%20S520%20-10%20680%2020%20M-40%2078%20C110%2048%20200%20110%20330%2086%20S520%2050%20680%2080%20M-40%20138%20C110%20108%20200%20170%20330%20146%20S520%20110%20680%20140%20M-40%20198%20C110%20168%20200%20230%20330%20206%20S520%20170%20680%20200%20M-40%20258%20C110%20228%20200%20290%20330%20266%20S520%20230%20680%20260%20M-40%20318%20C110%20288%20200%20350%20330%20326%20S520%20290%20680%20320%20M-40%20378%20C110%20348%20200%20410%20330%20386%20S520%20350%20680%20380%20M-40%20438%20C110%20408%20200%20470%20330%20446%20S520%20410%20680%20440%20M-40%20498%20C110%20468%20200%20530%20330%20506%20S520%20470%20680%20500%22%20fill%3D%22none%22%20stroke%3D%22black%22%20stroke-width%3D%22.8%22%2F%3E%3C%2Fsvg%3E");
  mask-size: 640px 540px; mask-repeat: repeat;
  animation: home-paper-drift var(--dur-drift) var(--ease-out) infinite alternate;
}
.home-texture.is-paused::before { animation-play-state: paused; }
.home-frame .featured-copy, .home-frame .featured-art { animation: home-arrive var(--dur-arrive) var(--ease-out) both; }
.home-frame .featured-art { animation-delay: var(--delay-arrive); }
@keyframes home-paper-drift { from { transform: translate3d(-6px, -4px, 0); } to { transform: translate3d(6px, 4px, 0); } }
@keyframes home-arrive { from { opacity: .6; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 700px) { .home-texture::before { animation: none; } }

.home-frame .hero-band.full-band {
  --wave-h: clamp(48px, 7vw, 104px);
  position: relative; overflow: visible; padding: 56px 0 calc(40px + var(--wave-h));
  background: linear-gradient(180deg, var(--tone-a) 0, var(--tone-b) calc(100% - var(--wave-h) + 2px), transparent calc(100% - var(--wave-h) + 2px));
}
.home-frame .hero-band::before {
  content: ""; position: absolute; inset: 0 0 var(--wave-h); pointer-events: none;
  background: radial-gradient(60% 70% at 78% 40%, color-mix(in srgb, var(--accent) 7%, transparent), transparent 70%);
}
.home-frame .hero-inner {
  position: relative; z-index: 1; display: grid; grid-template-columns: 7fr 5fr;
  grid-template-areas: "copy art" "cta art"; column-gap: 48px; align-items: center;
  width: min(100% - 96px, 1120px); margin-inline: auto;
}
.home-frame .featured-copy { grid-area: copy; align-self: end; margin: 0; padding: 0; }
.home-frame .featured-copy h1 { margin: 0 0 18px; font: 600 clamp(44px, 5.2vw, 76px)/1 var(--font-serif-en); letter-spacing: -.022em; text-wrap: balance; }
.home-frame .featured-copy h1 a { text-decoration: none; }
.home-frame .featured-copy h1 a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 5px; }
.home-frame .featured-chinese { margin: 0; font: 400 22px/1.5 var(--font-serif-cn); letter-spacing: .02em; color: var(--ink-2); }
.home-frame .featured-meta { margin: 12px 0 0; font: 560 var(--fs-13)/1.5 var(--font-ui); letter-spacing: .04em; color: var(--accent); }
.home-frame .hero-cta { grid-area: cta; align-self: start; justify-self: start; margin-top: 32px; height: 48px; padding: 0 24px 0 22px; font-size: var(--fs-15); }
.home-frame .hero-cta .arr { display: inline-flex; transition: transform var(--dur-2) var(--ease-out); }
.home-frame .hero-cta:hover .arr { transform: translateX(3px); }
.home-frame .featured-art { grid-area: art; justify-self: end; align-self: center; width: 100%; max-width: 480px; margin: 0; color: var(--ink-2); }
.editorial-art { display: block; width: 100%; height: auto; }
.home-frame .hero-band .hero-wave { position: absolute; left: 0; bottom: -1px; width: 100%; height: var(--wave-h); fill: none; overflow: visible; z-index: 0; pointer-events: none; }
.home-frame .hero-band .hero-wave .soft { filter: blur(7px); opacity: .75; }
.home-frame .hero-band .hero-wave .edge { filter: blur(var(--wave-edge-blur)); }

/* Homepage archive grid */
.home-frame .archive-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 16px; padding: 56px 0 36px; }
.archive-heading-main { display: flex; align-items: baseline; gap: 14px; }
.home-frame .archive-heading h2 { margin: 0; font: 650 var(--fs-24)/var(--lh-24) var(--font-ui); letter-spacing: -.01em; }
.article-meta { color: var(--ink-2); font: 400 var(--fs-13)/1.5 var(--font-ui); font-variant-numeric: tabular-nums; }
.home-frame .article-index { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 56px; padding-bottom: 16px; }
.home-frame .article-row {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) 24px; gap: 0 16px; align-items: baseline;
  padding: 18px 16px 18px 12px; margin: 0 -16px 4px -12px; border-radius: var(--r-entry); text-decoration: none;
  transition: background-color var(--dur-1) var(--ease-out), opacity var(--dur-pop) var(--ease-out);
}
.article-row[hidden] { display: none; }
.article-row:hover, .article-row:focus-visible { background: var(--surface-1); }
.article-row.is-last-read { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.article-row.is-last-read:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.home-frame .article-number { padding: 0; font: 560 var(--fs-13)/1.5 var(--font-ui); font-variant-numeric: tabular-nums; letter-spacing: .02em; color: var(--accent); white-space: nowrap; }
.home-frame .article-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin-right: -12px; }
.home-frame .article-title strong { font: 500 24px/1.25 var(--font-serif-en); letter-spacing: -.008em; text-wrap: pretty; overflow-wrap: anywhere; transition: transform var(--dur-1) var(--ease-out); }
@media (hover: hover) { .article-row:hover .article-title strong { transform: translateX(4px); } }
.article-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.article-topic { font: 400 var(--fs-14)/1.5 var(--font-ui); font-style: normal; color: var(--ink-2); }
.article-new { color: var(--success); font-weight: 560; }
.article-progress-tag { color: var(--accent); font: 560 var(--fs-13)/1.5 var(--font-ui); }
.home-frame .article-row::after {
  content: ""; align-self: center; width: 18px; height: 18px; background: var(--ink-3); opacity: .6;
  transition: opacity var(--dur-1), transform var(--dur-2) var(--ease-out);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") center / contain no-repeat;
}
.home-frame .article-row:hover::after, .home-frame .article-row:focus-visible::after { opacity: 1; transform: translateX(2px); }

/* Homepage closing endzone & colophon */
.endzone {
  margin-top: clamp(48px, 7vw, 96px); padding: 48px 0 calc(36px + env(safe-area-inset-bottom));
  border-top: 1px solid color-mix(in srgb, var(--ink-2) 22%, transparent);
  text-align: center; color: var(--ink-2); font: 400 14px/1.6 var(--font-ui);
}
.colophon .site-name { display: inline-flex; justify-self: center; gap: 8px; font-size: 21px; color: var(--ink-1); }
.colophon p { margin: 5px 0 0; font: 400 14px/1.6 var(--font-serif-cn); letter-spacing: .08em; }
.endzone-nav { display: grid; gap: 8px; margin: 26px auto; }
.endzone-nav div { display: flex; align-items: baseline; flex-wrap: wrap; justify-content: center; gap: 2px 17px; }
.endzone-nav strong { font-weight: 600; color: var(--ink-1); }
.endzone-nav a { padding-block: 4px; color: inherit; text-decoration: none; }
.endzone-nav a:hover { color: var(--ink-1); text-decoration: underline; }
.endzone small { font-size: 12px; }
@media (max-width: 600px) {
  .endzone-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 340px; }
  .endzone-nav div { flex-direction: column; align-items: center; justify-content: flex-start; }
  .endzone-nav strong { margin-bottom: 5px; }
}

/* 404 inside home shell */
.not-found { display: none; }
html[data-not-found] .home-frame { min-height: 100dvh; display: flex; flex-direction: column; }
html[data-not-found] .home-main { flex: 1 0 auto; display: flex; align-items: center; justify-content: center; }
html[data-not-found] .home-main > :not(.not-found) { display: none; }
html[data-not-found] .not-found { display: block; width: min(100%, 560px); margin: 0 auto; padding: 96px 0 120px; text-align: center; font-family: var(--font-ui); }
.nf-code { margin: 0 0 8px; font: 500 clamp(88px, 12vw, 120px)/1 var(--font-serif-en); letter-spacing: -.03em; color: var(--ink-3); font-variant-numeric: lining-nums; }
.nf-code em { font-style: italic; color: var(--vocab); }
.not-found h1 { margin: 0; font: 650 var(--fs-32)/var(--lh-32) var(--font-ui); letter-spacing: -.01em; }
.not-found p:not(.nf-code) { margin: 12px 0 28px; color: var(--ink-2); font: 400 var(--fs-15)/1.7 var(--font-ui); }
.not-found-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
html[data-not-found] .endzone { margin-top: 0; padding: 28px 0; border: 0; }
html[data-not-found] .endzone :is(.endzone-nav, small, p) { display: none; }

/* ---------- 7. Article Reader: 3-Column Rails, Modes, Vocab, Usage Band, Next Scene & Dock ---------- */
.article-layout { position: relative; width: 100%; margin: 0 auto; }
.article { width: min(100%, 700px); margin: 36px auto 0; }
.article-hero { margin-bottom: 28px; text-align: center; }
.article-act { margin: 0 0 20px; color: var(--ink-2); font: 600 var(--fs-13)/1.5 var(--font-ui); letter-spacing: .08em; }
.article-hero h1 { margin: 0; font: 700 clamp(36px, 4.5vw, 62px)/1.1 var(--font-serif-en); letter-spacing: -.015em; }
.article-cn-title { margin: 1.2rem 0 0; font-family: var(--font-serif-cn); color: var(--ink-2); font-size: var(--fs-20); }

.article-vocabulary-link {
  display: inline-flex; align-items: center; min-height: 44px; margin-top: 14px; padding: 0 15px;
  border-radius: var(--r-pill); background: var(--surface-1); color: var(--ink-1);
  font: 550 var(--fs-14)/1.4 var(--font-ui); text-decoration: none;
}
.article-vocabulary-link:hover { background: var(--surface-2); }
.article-vocabulary-end { display: flex; justify-content: center; }
.article-vocabulary-end .article-vocabulary-link { margin-top: 0; }
.vocabulary-sibling {
  display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2);
  font: 550 var(--fs-14)/1.4 var(--font-ui); text-decoration: underline; text-underline-offset: .25em;
}
.vocabulary-sibling:hover { color: var(--ink-1); }

.part-section { position: relative; z-index: 0; scroll-margin-top: 92px; }
.section-rule { padding-top: 24px; margin-bottom: 24px; }
.article-content h2 { margin: 0 0 28px; font: 500 clamp(24px, 3vw, 36px)/1.3 var(--font-serif-en); letter-spacing: -.01em; }
.article-content p { margin: 0 0 1.4rem; }
.mode-panel[hidden], .mode-controls [hidden] { display: none !important; }
.mode-panel.weave-story { color: var(--ink-1); font: calc(1.05rem + var(--reading-adjustment))/2 var(--font-serif-cn); }
.weave-story .vocab { font-family: var(--font-serif-en); font-weight: 600; margin-inline: .12em; }
.article-content .english, .mode-panel.recall-story:not(.weave-story) { color: var(--ink-1); font-family: var(--font-serif-en); font-size: calc(1.22rem + var(--reading-adjustment)); line-height: 1.72; }
.translation { margin-top: -.85rem !important; margin-bottom: 2.1rem !important; color: var(--ink-2); font-family: var(--font-serif-cn); font-size: calc(.94rem + var(--reading-adjustment)); line-height: 1.9; }
body.english-only .translation { display: none; }

/* Recall blanks */
.recall-blank {
  display: inline; max-width: 100%; overflow-wrap: anywhere; text-align: left; font: inherit; cursor: pointer;
  color: var(--ink-1); background: var(--surface-1); border: 0; border-bottom: 1px dashed var(--ink-3);
  border-radius: var(--r-inner); padding: 0 7px;
}
.recall-blank.is-known { border-bottom-style: solid; }
.recall-blank.is-weak { outline: 1px dashed var(--ink-2); }
.recall-blank.is-revealed { background: transparent; border-bottom-style: dotted; }
.recall-blank:focus-visible { box-shadow: var(--ring); }

/* Color-accented vocab words (no underline clutter; wraps cleanly inline) */
.vocab {
  display: inline; padding: 1px 3px; margin: -1px -3px; border: 0; border-radius: 5px;
  background-color: transparent; color: var(--vocab); cursor: pointer;
  font-family: inherit; font-size: inherit; line-height: inherit; text-decoration: none;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  transition: color 90ms var(--ease-out), background-color 90ms var(--ease-out);
}
.article-content .english .vocab { font-weight: 500; }
.vocab.is-word-active { border-radius: 6px; background-color: var(--accent-a12); }
.vocab.is-audio-error { color: var(--danger); }
@media (hover: hover) { .vocab:hover { background-color: var(--accent-a12); border-radius: 6px; } }
.jump-sentence-mark {
  padding-block: 2px;
  border-radius: 4px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  animation: jump-sentence-fade 2400ms var(--ease-out) forwards;
}
.vocab.is-jump-sentence {
  border-radius: 4px;
  animation: jump-sentence-fade 2400ms var(--ease-out) forwards;
}
.vocab.is-jump-highlight { border-radius: var(--r-pill); animation: jump-highlight-fade 2400ms var(--ease-out) forwards; }
@keyframes jump-sentence-fade { 0% { background-color: transparent; } 10%, 42% { background-color: var(--accent-a15); } 100% { background-color: transparent; } }
@keyframes jump-highlight-fade { 0% { background-color: transparent; } 10%, 42% { background-color: var(--accent-a30); } 100% { background-color: transparent; } }

/* Collocations / usage box (neutral surface + WCAG AA accent heading) */
.usage-band { position: relative; margin: 52px 0 68px; padding: 26px 28px 28px; border-radius: 22px; background: var(--surface-1); }
.usage-band .ub-wave { display: none; }
.article-content .usage-band h3 { margin: 0 0 14px; font: 600 var(--fs-13)/1.5 var(--font-ui); letter-spacing: .08em; color: var(--accent); }
.usage-band .collocations { margin: 0; padding: 0; list-style: none; font: calc(var(--fs-15) + var(--reading-adjustment))/1.75 var(--font-ui); color: var(--ink-2); }
.usage-band .collocations li { margin: 16px 0 0; text-wrap: pretty; }
.usage-band .collocations li:first-child { margin-top: 0; }
.usage-band .collocations li.guidance { margin-top: 4px; font: inherit; }
.usage-band .collocations strong { font: 600 calc(18px + var(--reading-adjustment))/1.5 var(--font-serif-en); color: var(--ink-1); }
.usage-band .collocations em { font-style: normal; }

/* Desktop sticky side rails */
.desktop-modes, .desktop-toc { display: none; }
.mode-controls { font-family: var(--font-ui); }
.mode-heading, .desktop-toc p { margin: 0 0 10px; color: var(--ink-2); font: 600 var(--fs-13)/1.5 var(--font-ui); letter-spacing: .06em; }
.mode-list { display: grid; gap: 5px; }
.mode-list button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 10px 12px;
  border: 0; border-radius: var(--r-12); color: var(--ink-2); background: transparent;
  font: 400 var(--fs-13)/1.5 var(--font-ui); text-align: left; cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.mode-list button:hover { background: var(--surface-1); color: var(--ink-1); }
.mode-list button[aria-pressed="true"] { background: var(--accent-a12); color: var(--ink-1); font-weight: 560; }
.mode-list svg, .mode-letter { flex: none; width: 18px; height: 18px; }
.mode-list svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.mode-letter { font: 600 var(--fs-15)/18px var(--font-ui); }
.mode-options { font: var(--fs-13)/1.6 var(--font-ui); color: var(--ink-2); }
.mode-options:has(> :not([hidden])) { margin-top: 18px; }
.mode-options #recall-options { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
.mode-options .context-option { display: grid; gap: 10px; padding-bottom: 6px; }
.mode-options .option-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.mode-options #reset-recall { min-height: 40px; margin-top: 6px; padding: 5px 12px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1); font: 560 var(--fs-13)/1.4 var(--font-ui); cursor: pointer; }
.mode-options #reset-recall:hover { background: color-mix(in srgb, var(--surface-2) 82%, var(--ink-1) 6%); }
.mode-controls button:focus { outline: none; }
.mode-controls button:focus-visible { box-shadow: var(--ring); }
html[data-input="pointer"] .mode-controls button:focus-visible { box-shadow: none; }
.desktop-modes .mode-controls .ov-close { display: none; }

@media (min-width: 1024px) {
  .article-frame { width: min(100% - 64px, 1440px); }
  .article-layout { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(0, 700px) minmax(160px, 1fr); column-gap: clamp(24px, 2.5vw, 84px); }
  .desktop-modes { display: block; grid-column: 1; grid-row: 1; align-self: start; position: sticky; top: 104px; width: min(100%, 176px); max-height: calc(100dvh - 128px); overflow-y: auto; }
  .article { grid-column: 2; grid-row: 1; width: 100%; margin: 36px 0 0; }
  .desktop-toc { display: block; grid-column: 3; grid-row: 1; justify-self: end; align-self: start; position: sticky; top: 104px; width: min(100%, 232px); max-height: calc(100dvh - 128px); overflow-y: auto; }
  .desktop-toc p { padding: 0 12px; }
  .desktop-toc a {
    display: grid; grid-template-columns: 24px minmax(0, 1fr); column-gap: 6px; align-items: baseline;
    padding: 8px 12px; margin: 2px 0; border-radius: var(--r-12); color: var(--ink-2); text-decoration: none;
    font: 400 var(--fs-13)/1.45 var(--font-ui); transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
  }
  .desktop-toc a:hover { color: var(--ink-1); background: var(--surface-1); }
  .desktop-toc a span:first-child { color: var(--ink-3); font: 600 var(--fs-12)/1.45 var(--font-ui); font-variant-numeric: tabular-nums; padding-top: 2px; }
  .desktop-toc a .toc-label { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; font-family: var(--font-ui); font-size: var(--fs-13); line-height: 1.45; }
  .desktop-toc a.is-active { color: var(--ink-1); background: var(--accent-a12); }
  .desktop-toc a.is-active span:first-child { color: var(--accent); font-weight: 650; }
}
@media (min-width: 1200px) {
  .article-layout { grid-template-columns: minmax(156px, 1fr) minmax(0, 700px) minmax(200px, 1fr); column-gap: clamp(40px, 5vw, 84px); }
}

/* Mobile reader dock & bottom sheets */
.reader-tools {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex; align-items: center; flex-wrap: nowrap; gap: 2px; height: 52px; padding: 6px; border-radius: var(--r-pill);
  background: var(--capsule-surface); box-shadow: var(--shadow-float); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  font-family: var(--font-ui); transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-2) var(--ease-out);
}
.reader-tools.is-hidden { transform: translateX(-50%) translateY(calc(100% + 16px + env(safe-area-inset-bottom))); pointer-events: none; }
.mobile-toc-open, .mobile-mode-open {
  display: flex; align-items: center; gap: 7px; flex: none; height: 40px; padding: 0 13px; color: var(--ink-1);
  border: 0; border-radius: var(--r-pill); background: transparent; cursor: pointer; font: 560 var(--fs-13)/1 var(--font-ui); white-space: nowrap;
  transition: background-color 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.mobile-toc-open[aria-expanded="true"], .mobile-mode-open[aria-expanded="true"] { background: var(--accent-a15); }
@media (hover: hover) { .mobile-toc-open:hover, .mobile-mode-open:hover { background: var(--surface-1); } }
.mobile-mode-open svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tool-chevron { color: var(--ink-2); font-size: var(--fs-13); padding-left: 1px; }
.mobile-toc-icon { display: grid; gap: 3px; width: 13px; flex: none; }
.mobile-toc-icon i { display: block; height: 1px; border-radius: var(--r-pill); background: currentColor; }
.mobile-toc-icon i:nth-child(2) { width: 9px; }
.mobile-toc-progress { display: flex; align-items: baseline; gap: 3px; font-variant-numeric: tabular-nums; }
.mobile-toc-progress strong { font-size: var(--fs-12); font-weight: 650; }
.mobile-toc-progress span { color: var(--ink-2); font-size: var(--fs-12); }

.mobile-toc-dialog, .mobile-mode-dialog { left: 0; }
.mobile-toc-sheet, .mobile-mode-sheet { overflow-y: auto; max-height: inherit; overscroll-behavior: contain; padding: 0 20px 20px; }
.mobile-toc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 8px 0; margin: 0 0 4px; }
.mobile-toc-head h2, .mobile-mode-dialog .mode-heading { margin: 0; font: 600 var(--fs-15)/1.5 var(--font-ui); color: var(--ink-1); letter-spacing: 0; }
.mobile-toc-list { display: flex; flex-direction: column; padding-top: var(--sp-1); }
.mobile-toc-list a { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 15px 10px; border-radius: var(--r-12); color: var(--ink-2); text-decoration: none; font-size: var(--fs-15); line-height: 1.35; }
.mobile-toc-list a span { color: var(--ink-3); font-size: var(--fs-12); font-variant-numeric: tabular-nums; }
.mobile-toc-list a.is-active { color: var(--ink-1); background: var(--accent-a12); }

/* Mobile end-of-article outline */
.article-outline { display: flex; flex-direction: column; gap: 8px; margin: 40px 0 0; }
.article-outline p { margin: 0 0 6px; color: var(--ink-1); font: 650 var(--fs-15)/1.5 var(--font-ui); }
.article-outline a { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 48px; padding: 8px 14px; border-radius: var(--r-field); background: var(--surface-1); color: var(--ink-1); text-decoration: none; font: 500 var(--fs-15)/1.4 var(--font-ui); transition: background-color var(--dur-1) var(--ease-out); }
.article-outline a span:first-child { color: var(--accent); font: 650 var(--fs-13)/1.35 var(--font-ui); font-variant-numeric: tabular-nums; }
@media (min-width: 1024px) { .reader-tools, .article-outline { display: none; } }

/* Next scene closing band */
.next-scene {
  --scene-wave: 56px; position: relative; z-index: 0; width: 100vw; margin-inline: calc(50% - 50vw);
  margin-top: calc(5rem + var(--scene-wave)); margin-bottom: clamp(40px, 5vw, 80px);
  background: linear-gradient(180deg, var(--scene-bg), var(--scene-bg-2)); color: var(--scene-ink); font-family: var(--font-ui);
}
.next-scene::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: calc(100% - 1px); height: var(--scene-wave); z-index: -1; pointer-events: none; filter: blur(.5px);
  background: var(--scene-bg);
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='56' preserveAspectRatio='none'%3E%3Cpath d='M0 56V24C120 24 200 4 330 4C470 4 600 34 800 34V56Z' fill='black'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='800' height='56' preserveAspectRatio='none'%3E%3Cpath d='M0 56V24C120 24 200 4 330 4C470 4 600 34 800 34V56Z' fill='black'/%3E%3C/svg%3E");
  mask-size: 100% 100%; mask-repeat: no-repeat; -webkit-mask-size: 100% 100%; -webkit-mask-repeat: no-repeat;
}
.next-scene .scene-wave { position: absolute; z-index: 0; left: 0; top: calc(100% - 1px); width: 100%; height: clamp(40px, 5vw, 80px); pointer-events: none; display: block; }
.next-scene .scene-wave .soft { display: none; }
.next-scene .scene-wave .edge { fill: var(--scene-bg-2) !important; }
.next-scene-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 24px; width: min(100% - 96px, 700px); margin-inline: auto; padding: 44px 0; }
.next-scene-copy { display: flex; flex-direction: column; gap: 8px; margin: 0; min-width: 0; }
.next-scene-title { display: flex; flex-direction: column; gap: 8px; min-width: 0; color: inherit; text-decoration: none; }
.next-scene-act { color: var(--scene-muted); font: 600 var(--fs-13)/1.5 var(--font-ui); letter-spacing: .08em; }
.next-scene-copy strong { font: 650 var(--fs-20)/1.35 var(--font-ui); letter-spacing: -.01em; }
.next-scene-title strong { font: 400 clamp(26px, 3vw, 36px)/1.15 var(--font-serif-en); letter-spacing: -.01em; overflow-wrap: anywhere; }
.next-scene-title em { color: var(--scene-muted); font: 400 var(--fs-15)/1.5 var(--font-serif-cn); font-style: normal; }
.next-scene-title:hover strong { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }
.next-scene-actions { display: flex; flex: none; align-items: center; gap: 12px; }
.next-scene .next-scene-back { background: var(--scene-btn-2-bg); color: var(--ink-1); }
.next-scene .next-scene-back:hover { background: color-mix(in srgb, var(--scene-btn-2-bg) 90%, var(--scene-ink)); }
.next-scene .next-scene-btn { background: var(--scene-btn-bg); color: var(--scene-btn-ink); }
.next-scene .next-scene-btn:hover { background: color-mix(in srgb, var(--scene-btn-bg) 88%, var(--scene-ink)); }
.next-scene-actions .arr { display: inline-flex; transition: transform var(--dur-2) var(--ease-out); }
.next-scene-actions .btn:hover .arr { transform: translateX(3px); }

/* Simple page footer */
.page-foot { display: flex; justify-content: center; align-items: center; background: transparent; padding: 56px 24px calc(32px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.page-foot .site-name { font-size: var(--fs-20); gap: 8px; color: var(--ink-1); justify-self: auto; }

/* ---------- 8. Secondary Pages: Sentences & Favorites ---------- */
.sentences-page { width: min(100%, 860px); margin: 5vh auto 0; }
.sentences-hero { width: 100%; margin-bottom: 32px; text-align: left; }
.sentences-title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; }
.sentences-hero h1 { margin: 0; color: var(--ink-1); font: 700 var(--fs-44)/var(--lh-44) var(--font-serif-en); letter-spacing: -.02em; }
.sentences-hero .sentence-count { margin: 0; color: var(--ink-2); font: 560 var(--fs-15)/1.5 var(--font-ui); font-variant-numeric: tabular-nums; }
.sentences-hero .article-cn-title { margin: 8px 0 0; font: 400 var(--fs-17)/1.5 var(--font-ui); color: var(--ink-2); }
.sentence-search { position: relative; margin-bottom: 24px; font: 560 var(--fs-13)/1.6 var(--font-ui); color: var(--ink-2); }
.sentence-search label { display: block; margin-bottom: 8px; }
.sentence-search input::-webkit-search-cancel-button { appearance: none; }
.sentence-search input { display: block; width: 100%; height: 48px; padding: 0 52px 0 16px; border: 0; border-radius: var(--r-field); background: var(--surface-1); color: var(--ink-1); font: 16px/1.5 var(--font-ui); transition: background-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out); }
.sentence-search input:focus { outline: none; background: var(--surface-0); box-shadow: var(--shadow-float), var(--ring); }
.sentence-search input::placeholder { color: var(--ink-2); opacity: 1; }
.search-clear { position: absolute; top: 34px; right: 14px; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out); }
.search-clear svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; }
.search-clear:hover { color: var(--ink-1); background: color-mix(in srgb, var(--surface-2) 82%, var(--ink-1)); }
.search-clear:active { transform: scale(.92); }
.sentence-empty { margin: 24px 0; color: var(--ink-2); font: var(--fs-15)/1.7 var(--font-ui); }
.sentence-entry[hidden], .sentence-empty[hidden] { display: none; }
.sentences-list { display: flex; flex-direction: column; gap: 28px; }
.sentence-entry { display: block; padding: 12px 0; scroll-margin-top: 90px; }
.sentence-number { display: block; margin: 0 0 6px; color: var(--ink-3); font: 500 var(--fs-12)/1.4 var(--font-ui); font-variant-numeric: tabular-nums; }
.sentence-copy h2 { margin: 0 0 .8rem; font-family: var(--font-serif-en); font-size: var(--fs-24); line-height: 1.25; font-weight: 600; }
.sentence-english { margin: 0 0 .6rem; font-size: calc(1.22rem + var(--reading-adjustment)); line-height: 1.65; }
.sentence-chinese { margin: 0; color: var(--ink-2); font-family: var(--font-serif-cn); font-size: calc(.94rem + var(--reading-adjustment)); line-height: 1.85; }
.sentence-note { margin: 1.1rem 0 0; padding: 14px 16px; border-radius: var(--r-field); background: var(--surface-1); color: var(--ink-2); font-family: var(--font-ui); font-size: var(--fs-13); line-height: 1.75; }

/* Favorites */
.site-frame:has(> .favorites-page) { min-height: 100dvh; display: flex; flex-direction: column; }
.favorites-page { flex: 1 0 auto; width: min(100%, 860px); margin: 40px auto 48px; }
.favorites-hero { width: 100%; margin-bottom: 32px; }
.favorites-title-row { display: flex; flex-direction: column; gap: 6px; }
.favorites-hero h1 { margin: 0; color: var(--ink-1); font: 650 var(--fs-32)/var(--lh-32) var(--font-ui); letter-spacing: -.01em; }
.favorites-count { margin: 0; color: var(--ink-2); font: 400 var(--fs-13)/1.5 var(--font-ui); font-variant-numeric: tabular-nums; }
.favorites-list { display: flex; flex-direction: column; gap: 8px; }
.fav-item-wrapper { display: grid; grid-template-rows: 1fr; min-height: 0; transition: grid-template-rows 240ms var(--ease-sheet), margin-bottom 240ms var(--ease-sheet); }
.fav-item-wrapper.is-collapsing { grid-template-rows: 0fr !important; margin-bottom: -8px !important; pointer-events: none; }
.fav-row { min-height: 0; overflow: hidden; position: relative; background: transparent; border: 0; border-radius: var(--r-entry); padding: 12px 16px; margin-inline: -16px; cursor: pointer; user-select: none; transition: background-color 150ms var(--ease-out), opacity 180ms var(--ease-out); }
.fav-row.is-fading { opacity: 0 !important; }
@media (hover: hover) and (pointer: fine) { .fav-row:hover { background-color: var(--surface-1); } }
.fav-row:focus:not(:focus-visible) { outline: none; }
.fav-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fav-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.fav-main-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.fav-line-1 { display: flex; align-items: center; flex-wrap: wrap; column-gap: 8px; row-gap: 4px; }
.fav-term { font: 650 calc(var(--fs-20) + var(--reading-adjustment))/1.3 var(--font-ui); color: var(--ink-1); letter-spacing: -.01em; overflow-wrap: anywhere; }
.fav-phonetic { font: 400 var(--fs-14)/1.4 var(--font-ui); color: var(--ink-3); }
.fav-speaker-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 44px; align-self: stretch; margin: 0 -10px 0 -4px; padding: 0; border: 0; background: transparent; color: var(--ink-3); cursor: pointer; border-radius: var(--r-pill); transition: color 150ms var(--ease-out); }
.fav-speaker-btn svg { width: 16px; height: 16px; fill: currentColor; transition: transform 120ms var(--ease-out); }
.fav-speaker-btn:hover, .fav-speaker-btn.is-playing { color: var(--ink-1); }
.fav-speaker-btn:active svg { transform: scale(.92); }
.fav-definition { margin: 4px 0 0; font: 400 calc(var(--fs-15) + var(--reading-adjustment))/1.6 var(--font-ui); color: var(--ink-2); }
.fav-expand-indicator { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: -4px -8px 0 0; color: var(--ink-3); flex: none; transition: color 150ms var(--ease-out); }
.fav-row:hover .fav-expand-indicator { color: var(--ink-1); }
.fav-expand-arrow { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--dur-2) var(--ease-sheet); }
.fav-row[aria-expanded="true"] .fav-expand-arrow { transform: rotate(180deg); }
.fav-expand-accordion { display: grid; grid-template-rows: 0fr; opacity: 0; overflow: hidden; visibility: hidden; transition: grid-template-rows var(--dur-2) var(--ease-sheet), opacity var(--dur-2) var(--ease-sheet), visibility var(--dur-2) step-end; }
.fav-row[aria-expanded="true"] .fav-expand-accordion { grid-template-rows: 1fr; opacity: 1; visibility: visible; transition: grid-template-rows var(--dur-2) var(--ease-sheet), opacity var(--dur-2) var(--ease-sheet), visibility 0s; }
.fav-expand-content { overflow: hidden; min-height: 0; }
.fav-sentence-p { margin: 12px 0 0; font: 400 var(--fs-17)/1.65 var(--font-serif-en); color: var(--ink-1); }
.fav-sentence-word { font-weight: 700; text-decoration: underline wavy var(--vocab) 1.5px; text-underline-offset: 6px; text-decoration-skip-ink: none; }
.fav-title-note { margin: 12px 0 0; font: 400 var(--fs-14)/1.5 var(--font-ui); color: var(--ink-2); }
.fav-action-bar { margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fav-source-capsule { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1); font: 560 var(--fs-13)/1 var(--font-ui); text-decoration: none; cursor: pointer; transition: background-color var(--dur-1) var(--ease-out), transform 100ms var(--ease-out); }
.fav-source-capsule:hover { background: color-mix(in srgb, var(--surface-2) 84%, var(--ink-1) 16%); }
.fav-source-capsule:active { transform: scale(.97); }
.fav-source-capsule .fav-book-icon { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.fav-source-capsule .fav-arrow-icon { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.fav-remove-action { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font: 560 var(--fs-13)/1 var(--font-ui); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform 100ms var(--ease-out); }
.fav-remove-action::before { content: ""; position: absolute; inset: -5px -4px; border-radius: var(--r-pill); }
@media (hover: hover) and (pointer: fine) { .fav-remove-action:hover { background: var(--surface-2); color: var(--ink-1); } }
.fav-remove-action:active { transform: scale(.97); }
.fav-remove-action svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.fav-back-section { margin-top: 48px; }
.fav-back-section[hidden], .favorites-empty[hidden] { display: none; }
.fav-back-btn { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1); font: 560 var(--fs-15)/1 var(--font-ui); text-decoration: none; transition: background-color var(--dur-1) var(--ease-out), transform 100ms var(--ease-out); }
.fav-back-btn:hover { background: color-mix(in srgb, var(--surface-2) 82%, var(--ink-1) 18%); }
.fav-back-btn:active { transform: scale(.96); }
.fav-back-btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.favorites-empty { display: flex; flex-direction: column; align-items: flex-start; padding: 48px 0; text-align: left; }
.fav-empty-title { margin: 0; font: 600 var(--fs-17)/1.4 var(--font-ui); color: var(--ink-1); }
.fav-empty-desc { margin: 8px 0 20px; font: 400 var(--fs-15)/1.7 var(--font-ui); color: var(--ink-2); }
.fav-empty-action { display: inline-flex; align-items: center; justify-content: center; height: 44px; padding: 0 24px; border: 0; border-radius: var(--r-pill); background: var(--btn-primary-bg); color: var(--btn-primary-ink); font: 560 var(--fs-15)/1 var(--font-ui); text-decoration: none; transition: background-color var(--dur-1) var(--ease-out), transform 100ms var(--ease-out); }
.fav-empty-action:hover { background: var(--btn-primary-hover); }
.fav-empty-action:active { transform: scale(.96); }

/* Undo toast */
.fav-toast-container { position: fixed; z-index: 100; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(100px); opacity: 0; pointer-events: none; transition: transform var(--dur-2) var(--ease-sheet), opacity var(--dur-2) var(--ease-sheet); }
.fav-toast-container.is-shown { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.fav-toast { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 14px 10px 20px; background: var(--surface-0); color: var(--ink-1); border: 0; border-radius: var(--r-pill); box-shadow: var(--shadow-overlay); font-family: var(--font-ui); min-width: 280px; }
.fav-toast-msg { font-size: var(--fs-14); font-weight: 500; color: var(--ink-1); margin: 0; white-space: nowrap; }
.fav-toast-undo-btn { display: inline-flex; align-items: center; justify-content: center; height: 32px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-1); font: 600 var(--fs-13)/1 var(--font-ui); cursor: pointer; transition: background-color var(--dur-1) var(--ease-out), transform 100ms var(--ease-out); }
.fav-toast-undo-btn:hover { background: color-mix(in srgb, var(--surface-2) 80%, var(--ink-1) 20%); }
.fav-toast-undo-btn:active { transform: scale(.95); }

/* ---------- 9. Responsive Breakpoints ---------- */
@media (max-width: 1023px) {
  .home-frame .hero-band.full-band { padding: 28px 0 calc(8px + var(--wave-h)); }
  .home-frame .hero-inner { grid-template-columns: 1fr; grid-template-areas: "art" "copy" "cta"; row-gap: 0; width: calc(100% - 40px); }
  .home-frame .featured-art { max-width: 300px; justify-self: end; margin: -4px 0 20px; }
  .home-frame .featured-copy h1 { font-size: clamp(38px, 11vw, 48px); margin: 0 0 12px; }
  .home-frame .featured-chinese { font-size: 18px; }
  .home-frame .hero-cta { margin-top: 24px; }
  .home-frame .archive-heading { padding: 40px 0 20px; }
  .home-frame .article-row { grid-template-columns: minmax(0, 1fr) 20px; padding: 14px 12px; margin: 0 -12px 4px; }
  .home-frame .article-number { grid-column: 1 / -1; padding-bottom: 4px; }
  .home-frame .article-title strong { font-size: 22px; }
  .home-frame .article-row::after { grid-column: 2; grid-row: 2; }
  .page-foot { padding: 40px 20px calc(32px + env(safe-area-inset-bottom)); }
  .page-foot .site-name { font-size: 18px; gap: 7px; }
  .favorites-page { margin: 24px auto 36px; }
  .favorites-hero { margin-bottom: 24px; }
  .favorites-list { gap: 4px; }
  .fav-item-wrapper.is-collapsing { margin-bottom: -4px !important; }
  .fav-source-capsule { height: 40px; padding: 0 16px; }
  .fav-toast-container { left: 16px; right: 16px; bottom: 20px; width: auto; max-width: 500px; margin: 0 auto; transform: translateY(100px); }
  .fav-toast-container.is-shown { transform: translateY(0); }
  .fav-toast { min-width: 0; width: 100%; }
}
@media (max-width: 959px) {
  .home-frame .article-index { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
@media (max-width: 760px) {
  .usage-band { margin: 44px 0 56px; padding: 22px 20px 24px; border-radius: 18px; }
  .usage-band .collocations strong { font-size: calc(var(--fs-17) + var(--reading-adjustment)); }
}
@media (max-width: 700px) {
  .article { margin-top: 24px; }
  .article-hero h1 { font-size: 36px; }
  .article-cn-title { font-size: 18px; }
  .article-content .part-section { scroll-margin-top: 80px; }
  .article-content h2 { font-size: var(--fs-24); }
  .next-scene { --scene-wave: 40px; }
  .next-scene-inner { width: calc(100% - 48px); padding: 32px 0 36px; }
  .next-scene-title strong { font-size: 28px; }
  .next-scene-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; width: 100%; }
  .next-scene .next-scene-actions .btn { height: 48px; min-height: 48px; padding-inline: 14px; gap: 6px; min-width: 0; justify-content: center; }
  .not-found h1 { font-size: 26px; }
}
@media (max-width: 359.98px) {
  .next-scene .next-scene-actions { grid-template-columns: 1fr; }
}

/* ---------- 10. Reduced Motion & Internal Scrollbar Hiding ---------- */
@media (prefers-reduced-motion: reduce) {
  .home-texture::before, .home-frame .featured-copy, .home-frame .featured-art, .popover-fav svg.anim-pop { animation: none; }
  .site-frame > .site-header.capsule-header::before, .site-frame > .capsule-header, .header-pill, .capsule-header .header-end, .capsule-header .site-name, .header-reading-context,
  .article-row, .fav-item-wrapper, .fav-row, .fav-expand-arrow, .fav-expand-accordion, .fav-toast-container { transition: none !important; }
  .btn-icon:active, .library-open:active, .settings-open:active, .reader-tools button:active, .ov-close:active, .chat-close:active, .chat-new:active, .popover-fav { transform: none !important; }
  .assistant-panel, .assistant-panel.closing, dialog.ov-dialog, dialog.ov-dialog.closing, .settings-dialog, .settings-dialog.closing, .reader-tools {
    animation-name: veil-in !important; animation-duration: 120ms !important; transition-duration: 120ms !important;
  }
  .assistant-panel.closing, dialog.ov-dialog.closing, .settings-dialog.closing { animation-direction: reverse !important; }
  .jump-sentence-mark, .vocab.is-jump-sentence { animation: jump-sentence-fade 2400ms linear forwards; }
  .vocab.is-jump-highlight { animation: jump-highlight-fade 2400ms linear forwards; }
}

.library-panels, .settings-sheet, .mobile-toc-sheet, .mobile-mode-sheet, .word-popover, .desktop-modes, .desktop-toc { scrollbar-width: none; }
.library-panels::-webkit-scrollbar, .settings-sheet::-webkit-scrollbar, .mobile-toc-sheet::-webkit-scrollbar, .mobile-mode-sheet::-webkit-scrollbar, .word-popover::-webkit-scrollbar, .desktop-modes::-webkit-scrollbar, .desktop-toc::-webkit-scrollbar { display: none; }
