/* ==========================================================================
   语阅 Yuyue — Official Website
   Faithful to the original site's quiet paper-and-ink soul (720px core column,
   #F8F5F0 warm paper, #2A2B2E ink, #FBE7A0 highlighter yellow, #2B4C7E 阅 rule),
   elevated with tactile, bookish interactions.
   ========================================================================== */

:root {
  color-scheme: light dark;

  --bg: #F8F5F0;
  --bg-soft: #F1EDE5;
  --card: #FFFFFF;
  --inset: #EFEEEB;
  --line: #E7E5E1;
  --line-strong: #D4D0C8;

  --t1: #2A2B2E;
  --t2: #6E6B68;
  --t3: #8A8682;

  /* Authentic Yuyue reading accents */
  --hl: #FBE7A0;
  --hl-ink: #2A2B2E;
  --hl-r: #EF7F71;
  --hl-b: #C4E3F4;
  --ink-rule: #2B4C7E;

  /* App icon tile */
  --tile: #FBFAF7;
  --tile-ink: #1C1D20;

  /* Translucent glass (floating capsule & popovers) */
  --glass: rgba(251, 250, 247, 0.84);
  --glass-line: rgba(80, 65, 45, 0.14);
  --scrim: rgba(24, 20, 16, 0.56);

  /* Typography — exact original hierarchy */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --font-serif-zh: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --font-kai: "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", serif;
  --font-serif-en: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Motion tokens */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.22, 1.12, 0.36, 1);

  --col: 720px;
  --col-wide: 920px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1613;
    --bg-soft: #221E1A;
    --card: #1B1C1E;
    --inset: #252629;
    --line: #2C2D30;
    --line-strong: #3F4044;

    --t1: #EDEDEE;
    --t2: #9A9895;
    --t3: #777572;

    --hl: rgba(251, 231, 160, 0.30);
    --hl-ink: #EDEDEE;
    --hl-r: #E57A6E;
    --hl-b: rgba(196, 227, 244, 0.28);
    --ink-rule: #8FA8C8;

    --glass: rgba(30, 31, 34, 0.84);
    --glass-line: rgba(255, 255, 255, 0.10);
    --scrim: rgba(0, 0, 0, 0.78);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1A1613;
  --bg-soft: #221E1A;
  --card: #1B1C1E;
  --inset: #252629;
  --line: #2C2D30;
  --line-strong: #3F4044;

  --t1: #EDEDEE;
  --t2: #9A9895;
  --t3: #777572;

  --hl: rgba(251, 231, 160, 0.30);
  --hl-ink: #EDEDEE;
  --hl-r: #E57A6E;
  --hl-b: rgba(196, 227, 244, 0.28);
  --ink-rule: #8FA8C8;

  --glass: rgba(30, 31, 34, 0.84);
  --glass-line: rgba(255, 255, 255, 0.10);
  --scrim: rgba(0, 0, 0, 0.78);
}

:root[data-theme="light"] { color-scheme: light; }

/* ==========================================================================
   Base & Mobile-Native Baseline
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--t1);
  font: 17px/1.7 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 240ms ease, color 240ms ease;
}

/* Zero-flicker bilingual rules */
html[data-lang="zh"] .i18n-en { display: none !important; }
html[data-lang="en"] .i18n-zh { display: none !important; }

main { transition: opacity 150ms var(--ease-out); }
main.lang-switching { opacity: 0.72; }

a, button, [role="button"], [role="tab"], summary { touch-action: manipulation; }
button, [role="button"], [role="tab"], summary {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
  transition: color 140ms ease, text-decoration-color 140ms ease;
}
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration-color: currentColor; }
}

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

:focus-visible {
  outline: 2px solid var(--t1);
  outline-offset: 3px;
  border-radius: 5px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--inset);
  color: var(--t1);
  padding: 1px 6px;
  border-radius: 5px;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 200;
  background: var(--t1);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 16px; }

/* The intimate 720px original column + selective 920px media breakout */
.col {
  max-width: var(--col);
  margin: 0 auto;
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
}

.col-wide {
  max-width: var(--col-wide);
  margin: 0 auto;
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
}

.muted { color: var(--t2); }
.subtle { color: var(--t3); }

/* ==========================================================================
   Opening Top Strip (No Heavy Navbar — Pure Paper + 阅 Tile)
   ========================================================================== */

.top-strip {
  padding-top: calc(48px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.mark-link {
  display: inline-block;
  text-decoration: none;
  border-radius: 15px;
  perspective: 320px;
}

/* Signature 阅 tile — exact original 56x56 box with physical tactile hover */
.mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--tile);
  color: var(--tile-ink);
  display: grid;
  place-items: center;
  position: relative;
  flex-shrink: 0;
  font: 700 28px/1 var(--font-serif-zh);
  box-shadow: 0 0 0 0.5px rgba(30, 28, 24, 0.08), 0 6px 16px rgba(30, 28, 24, 0.14);
  transition: transform 240ms var(--ease-out), box-shadow 240ms var(--ease-out);
}
.mark::after {
  content: "";
  position: absolute;
  left: 17px;
  right: 17px;
  bottom: 11px;
  height: 2px;
  border-radius: 2px;
  background: #2B4C7E;
  transition: transform 240ms var(--ease-out);
}

.mark-link:active .mark { transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) {
  .mark-link:hover .mark {
    transform: translateY(-2px) rotate(-1.5deg);
    box-shadow: 0 0 0 0.5px rgba(30, 28, 24, 0.10), 0 10px 24px rgba(30, 28, 24, 0.18);
  }
  .mark-link:hover .mark::after { transform: scaleX(1.12); }
}

.mark-sm {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  font-size: 14.5px;
  box-shadow: 0 0 0 0.5px rgba(30, 28, 24, 0.08), 0 2px 6px rgba(30, 28, 24, 0.10);
}
.mark-sm::after { left: 8px; right: 8px; bottom: 4.5px; height: 1.5px; }

.top-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-right: 10px;
  font-size: 14px;
  color: var(--t2);
}
.top-nav::after {
  content: "";
  width: 1px;
  height: 13px;
  background: var(--line-strong);
  opacity: 0.75;
  margin-left: 2px;
}

.top-nav a {
  text-decoration: none;
  color: var(--t2);
  padding: 2px 0;
  transition: color 140ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .top-nav a:hover { color: var(--t1); }
}
.top-nav a[aria-current="page"] {
  color: var(--t1);
  font-weight: 600;
  background: linear-gradient(transparent 62%, var(--hl) 62%);
}

/* Minimal globe + target-language ghost button (paired with .theme-btn) */
.lang-toggle {
  height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 140ms ease, background-color 140ms ease, transform 120ms var(--ease-out);
}
.lang-toggle:active { transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) {
  .lang-toggle:hover { color: var(--t1); background: var(--inset); }
}
.lang-toggle svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.theme-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  color: var(--t2);
  transition: color 140ms ease, background-color 140ms ease, transform 120ms var(--ease-out);
}
.theme-btn:active { transform: scale(0.92); }
@media (hover: hover) and (pointer: fine) {
  .theme-btn:hover { color: var(--t1); background: var(--inset); }
}
.theme-btn svg { width: 15.5px; height: 15.5px; }
.icon-sun { display: none; }
.icon-moon { display: block; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

.menu-btn {
  display: none;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  place-items: center;
  color: var(--t1);
}
.menu-btn .icon-close { display: none; }
.menu-btn[aria-expanded="true"] .icon-menu { display: none; }
.menu-btn[aria-expanded="true"] .icon-close { display: block; }

@media (max-width: 680px) {
  .top-strip { padding-top: calc(28px + env(safe-area-inset-top, 0px)); }
  .top-nav { display: none; }
  .menu-btn { display: grid; }
  .top-right { gap: 8px; }
}

/* Floating Yuyue Glass Capsule (only appears once scrolled past Hero!) */
.float-nav {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 60;
  width: max-content;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 0.5px solid var(--glass-line);
  box-shadow: 0 8px 28px rgba(30, 26, 22, 0.10), 0 1px 3px rgba(30, 26, 22, 0.06);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px) scale(0.97);
  transition: opacity 200ms var(--ease-out), transform 240ms var(--ease-out);
  max-width: calc(100vw - 24px);
}

.float-nav.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0) scale(1);
}

@media (prefers-reduced-transparency: reduce) {
  .float-nav { background: var(--card); backdrop-filter: none; -webkit-backdrop-filter: none; }
}

.float-links {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 13.5px;
}
.float-links a {
  text-decoration: none;
  color: var(--t2);
  white-space: nowrap;
  transition: color 140ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .float-links a:hover { color: var(--t1); }
}

.float-sep { width: 1px; height: 13px; background: var(--line-strong); }

.float-nav .lang-toggle {
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
}

@media (max-width: 680px) {
  .float-links, .float-sep { display: none; }
  .float-nav { gap: 10px; }
}

/* Mobile Drawer Sheet */
.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 75;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease-out);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 16px;
}
.mobile-drawer.is-open { opacity: 1; pointer-events: auto; }

.mobile-sheet {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
  transform: translateY(-8px) scale(0.97);
  transition: transform 220ms var(--ease-drawer);
}
.mobile-drawer.is-open .mobile-sheet { transform: translateY(0) scale(1); }

.mobile-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 0.5px solid var(--line);
  margin-bottom: 6px;
}

.mobile-nav-list { display: grid; }
.mobile-nav-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 2px;
  font-size: 16px;
  font-weight: 550;
  text-decoration: none;
  color: var(--t1);
  border-bottom: 0.5px solid var(--line);
}
.mobile-nav-list a:last-child { border-bottom: none; }

/* ==========================================================================
   Hero — Pure Original Silhouette + Living Book Page
   ========================================================================== */

.hero {
  padding-top: 28px;
  padding-bottom: 24px;
}

.hero h1 {
  margin: 0 0 16px;
  font-size: clamp(2.25rem, 6.4vw, 3.55rem);
  line-height: 1.09;
  font-weight: 750;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
html[data-lang="zh"] .hero h1 {
  letter-spacing: -0.02em;
  line-height: 1.18;
}

.sub {
  font-size: 19px;
  color: var(--t2);
  max-width: 60ch;
  margin: 0 0 22px;
  line-height: 1.66;
  text-wrap: pretty;
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  margin-bottom: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 120ms var(--ease-out), opacity 140ms ease, border-color 140ms ease, background-color 140ms ease;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--t1);
  color: var(--bg);
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { opacity: 0.86; }
}

.btn-ghost {
  background: var(--card);
  color: var(--t1);
  border: 0.5px solid var(--line-strong);
}
@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover { border-color: var(--t1); }
}

.hero-inline-meta {
  font-size: 13.5px;
  color: var(--t3);
}

/* ==========================================================================
   INTERACTION #1 — The Living Book Page (Heir to Original <figure class="page">)
   ========================================================================== */

.page {
  --p-bg: var(--card);
  --p-ink: var(--t1);
  --p-ink2: var(--t2);
  --p-line: var(--line);
  --p-hl: var(--hl);
  --p-hl-ink: var(--hl-ink);
  --p-rule: var(--ink-rule);
  --p-wave: var(--hl-r);
  --p-dash: #2B4C7E;
  --p-size: 18px;
  --p-font-zh: var(--font-serif-zh);
  --p-font-en: var(--font-serif-en);

  margin: 34px 0 10px;
  background: var(--p-bg);
  color: var(--p-ink);
  border: 0.5px solid var(--p-line);
  border-radius: 18px;
  position: relative;
  transition: background-color 260ms ease, color 260ms ease, border-color 260ms ease;
}

/* Authentic 6 Papers from design/tokens.json */
.page[data-paper="plain"] {
  --p-bg: #FFFFFF; --p-ink: #2A2B2E; --p-ink2: #777571; --p-line: #E7E5E1;
  --p-hl: #FBE7A0; --p-hl-ink: #2A2B2E; --p-rule: #2B4C7E; --p-dash: #2B4C7E;
}
.page[data-paper="kami"] {
  --p-bg: #F5F4ED; --p-ink: #26251F; --p-ink2: #716E62; --p-line: #E2DFD3;
  --p-hl: #EFE3B8; --p-hl-ink: #26251F; --p-rule: #1B365D; --p-dash: #1B365D;
}
.page[data-paper="sage"] {
  --p-bg: #E6E7DC; --p-ink: #2A2C24; --p-ink2: #63665A; --p-line: #D3D5C6;
  --p-hl: #F3E3A4; --p-hl-ink: #2A2C24; --p-rule: #2B4C7E; --p-dash: #2B4C7E;
}
.page[data-paper="eink"] {
  --p-bg: #E9E8E3; --p-ink: #141414; --p-ink2: #555555; --p-line: #C9C8C2;
  --p-hl: rgba(20, 20, 20, 0.12); --p-hl-ink: #141414; --p-rule: #141414; --p-dash: #141414;
  background-image: radial-gradient(rgba(20, 20, 20, 0.045) 0.6px, transparent 0.6px);
  background-size: 4px 4px;
}
.page[data-paper="kaminight"] {
  --p-bg: #1B1A17; --p-ink: #E3DED0; --p-ink2: #8C8779; --p-line: #2E2C27;
  --p-hl: rgba(233, 210, 140, 0.24); --p-hl-ink: #ECE7DA; --p-rule: #8FA8C8; --p-dash: #8FA8C8;
}
.page[data-paper="dark"] {
  --p-bg: #121314; --p-ink: #D6D6D8; --p-ink2: #7E7E83; --p-line: #26272A;
  --p-hl: rgba(251, 231, 160, 0.26); --p-hl-ink: #EDEDEE; --p-rule: #8FA8C8; --p-dash: #8FA8C8;
}

.page[data-font="kai"] { --p-font-zh: var(--font-kai); }
.page[data-font="sans"] { --p-font-zh: var(--font-sans); --p-font-en: var(--font-sans); }

.page-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 14px;
  padding: 13px 24px 11px;
  border-bottom: 0.5px solid var(--p-line);
  font: 13px/1.4 var(--font-sans);
  color: var(--p-ink2);
}

.page-books {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.book-switch {
  color: var(--p-ink2);
  font-weight: 500;
  padding-bottom: 2px;
  border-bottom: 1.5px solid transparent;
  transition: color 140ms ease, border-color 140ms ease;
}
.book-switch[aria-selected="true"] {
  color: var(--p-ink);
  font-weight: 650;
  border-bottom-color: var(--p-rule);
}

.page-top-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mini-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  border: 0.5px solid var(--p-line);
  color: var(--p-ink2);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease, transform 120ms var(--ease-out);
}
.mini-pill:active { transform: scale(0.95); }
.mini-pill[aria-pressed="true"] {
  color: var(--p-ink);
  border-color: var(--p-ink);
  background: color-mix(in srgb, var(--p-ink) 7%, transparent);
}
.mini-pill[hidden] { display: none; }

.vocab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--p-hl);
  color: var(--p-hl-ink);
  font-size: 11px;
  font-weight: 700;
  transition: transform 200ms var(--ease-spring);
}
.vocab-badge.pop { transform: scale(1.28); }

.page-prose-area {
  padding: 24px 26px 20px;
  position: relative;
}

.page-pane[data-book="zh"] {
  font: var(--p-size)/1.95 var(--p-font-zh);
}
.page-pane[data-book="en"] {
  font: var(--p-size)/1.88 var(--p-font-en);
}

.page-pane p { margin: 0 0 12px; max-width: none; }
.page-pane p:last-child { margin-bottom: 0; }
.page-pane[data-book="zh"] p { text-indent: 2em; text-align: justify; }

/* The signature read-aloud highlighter sweep (exact spirit of original @keyframes read!) */
.sent {
  cursor: pointer;
  border-radius: 3px;
  padding: 1px 4px;
  margin: 0 -4px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 0% 100%;
  background-image: linear-gradient(var(--p-hl), var(--p-hl));
  transition: background-size 220ms var(--ease-out), color 160ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .sent:hover:not(.is-active):not(.is-active-instant) {
    text-decoration: underline;
    text-decoration-color: var(--p-line);
    text-underline-offset: 4px;
  }
}

.sent.is-active {
  color: var(--p-hl-ink);
  background-size: 100% 100%;
  transition: background-size 2.6s cubic-bezier(0.2, 0.7, 0.25, 1);
}

.sent.is-active-instant {
  color: var(--p-hl-ink);
  background-size: 100% 100%;
  transition: background-size 240ms var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  .sent.is-active { transition: none; }
}

/* User-applied live highlights */
.user-hl-y {
  background: var(--p-hl);
  color: var(--p-hl-ink);
  border-radius: 3px;
  padding: 1px 2px;
}
.user-hl-w {
  text-decoration: underline wavy var(--p-wave);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.user-hl-b {
  text-decoration: underline dashed var(--p-dash);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}

/* User-added live thought card right inside the book page */
.live-thought {
  margin-top: 12px;
  padding: 10px 13px;
  border-left: 2px solid var(--p-rule);
  background: color-mix(in srgb, var(--p-ink) 4%, transparent);
  border-radius: 0 10px 10px 0;
  font: 13.5px/1.55 var(--font-sans);
  color: var(--p-ink2);
  text-indent: 0 !important;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  animation: fadeRise 220ms var(--ease-out);
}
.live-thought b { color: var(--p-ink); display: block; font-size: 12px; margin-bottom: 2px; }
.live-thought .thought-quote { display: block; font-size: 12.5px; opacity: 0.72; margin-bottom: 3px; }
.live-thought button { font-size: 14px; color: var(--p-ink2); opacity: 0.7; padding: 0 4px; }

.thought-composer {
  margin-top: 12px;
  padding: 12px 14px;
  border: 0.5px solid var(--p-line);
  border-left: 2px solid var(--p-rule);
  background: color-mix(in srgb, var(--p-ink) 3.5%, transparent);
  border-radius: 0 12px 12px 0;
  font-family: var(--font-sans);
  animation: fadeRise 180ms var(--ease-out);
}
.thought-composer-quote {
  font-size: 12.5px;
  color: var(--p-ink2);
  margin-bottom: 8px;
}
.thought-composer-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.thought-composer input {
  flex: 1;
  min-width: 0;
  font: 16px/1.4 var(--font-sans);
  color: var(--p-ink);
  background: var(--p-bg);
  border: 0.5px solid var(--p-line);
  border-radius: 8px;
  padding: 6px 10px;
}
.thought-composer input:focus {
  outline: none;
  border-color: var(--p-rule);
}
.thought-composer .bar-btn { height: 34px; padding: 0 12px; }

.moments-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 32px;
}
.moment-item {
  padding-top: 16px;
  border-top: 0.5px solid var(--line);
}
.moment-time {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t3);
  margin-bottom: 6px;
}
.moment-item h3 {
  font-size: 18px;
  line-height: 1.35;
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.moment-item p {
  font-size: 15px;
  color: var(--t2);
  margin: 0;
  line-height: 1.68;
}
@media (max-width: 580px) {
  .moments-grid { grid-template-columns: 1fr; gap: 20px; }
}

@keyframes fadeRise {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Interlinear ruby word glosses */
.word-gloss {
  cursor: pointer;
  border-bottom: 1px dotted var(--p-ink2);
  border-radius: 2px;
  transition: background-color 140ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .word-gloss:hover { background-color: var(--p-hl); }
}
.word-gloss.is-selected { background-color: var(--p-hl); color: var(--p-hl-ink); }
.word-gloss ruby { ruby-position: over; }
.word-gloss rt {
  font-family: var(--font-sans);
  font-size: 10.5px;
  color: var(--p-ink2);
  transition: opacity 160ms ease;
}
.page.glosses-off .word-gloss rt { opacity: 0; font-size: 0; }

/* Floating Selection Highlighter Toolbar (origin-aware) */
.sel-bar {
  position: absolute;
  z-index: 35;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--t1);
  color: var(--bg);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
  font: 12.5px/1 var(--font-sans);
  transform-origin: bottom center;
  opacity: 0;
  transform: translate(-50%, 4px) scale(0.94);
  pointer-events: none;
  transition: opacity 150ms var(--ease-out), transform 170ms var(--ease-out);
}
.sel-bar.is-open {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}

.sel-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  transition: transform 120ms var(--ease-out);
}
.sel-dot:active { transform: scale(0.88); }
.sel-dot[data-hl="y"] { background: #FBE7A0; }
.sel-dot[data-hl="w"] { background: #EF7F71; }
.sel-dot[data-hl="b"] { background: #C4E3F4; }
.sel-note-btn {
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--bg);
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 10px;
}

/* Dictionary Popover */
.dict-popover {
  position: absolute;
  z-index: 36;
  width: min(296px, calc(100% - 28px));
  background: var(--card);
  color: var(--t1);
  border: 0.5px solid var(--line-strong);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 12px 30px rgba(30, 26, 22, 0.16);
  font-family: var(--font-sans);
  transform-origin: top center;
  opacity: 0;
  transform: translateY(-4px) scale(0.96);
  pointer-events: none;
  transition: opacity 150ms var(--ease-out), transform 170ms var(--ease-out);
}
.dict-popover.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.dict-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 5px; }
.dict-word { font-size: 16.5px; font-weight: 700; }
.dict-ipa { font-family: var(--font-mono); font-size: 12px; color: var(--t3); }
.dict-def { font-size: 13.5px; line-height: 1.55; color: var(--t2); margin: 0 0 12px; }
.dict-foot { display: flex; align-items: center; justify-content: space-between; }
.dict-save-btn {
  font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 7px;
  border: 0.5px solid var(--line-strong); color: var(--t1);
  transition: background-color 140ms ease, color 140ms ease, transform 120ms var(--ease-out);
}
.dict-save-btn:active { transform: scale(0.95); }
.dict-save-btn.is-saved { background: var(--hl); color: var(--hl-ink); border-color: transparent; }
.dict-close-btn { font-size: 12.5px; color: var(--t3); padding: 4px 6px; }

/* Inline Aa Typesetting Drawer (modeled directly on 11-mobile-typeset.png!) */
.typeset-drawer {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 260ms var(--ease-drawer);
}
.typeset-drawer.is-open { grid-template-rows: 1fr; }
.typeset-inner { overflow: hidden; }
.typeset-content {
  padding: 16px 24px 18px;
  border-top: 0.5px solid var(--p-line);
  font-family: var(--font-sans);
  display: grid;
  gap: 14px;
}

.paper-tiles {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.paper-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--p-ink2);
  transition: transform 120ms var(--ease-out);
}
.paper-tile:active { transform: scale(0.94); }

.paper-swatch {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font: 600 14px/1 var(--font-serif-zh);
  border: 1.5px solid rgba(128, 128, 128, 0.22);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.paper-tile[aria-pressed="true"] .paper-swatch {
  border-color: var(--p-rule);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--p-rule) 22%, transparent);
}
.paper-tile[aria-pressed="true"] { color: var(--p-ink); font-weight: 600; }

.paper-tile[data-set-paper="plain"] .paper-swatch { background: #FFFFFF; color: #2A2B2E; }
.paper-tile[data-set-paper="kami"] .paper-swatch { background: #F5F4ED; color: #26251F; }
.paper-tile[data-set-paper="sage"] .paper-swatch { background: #E6E7DC; color: #2A2C24; }
.paper-tile[data-set-paper="eink"] .paper-swatch { background: #E9E8E3; color: #141414; }
.paper-tile[data-set-paper="kaminight"] .paper-swatch { background: #1B1A17; color: #E3DED0; }
.paper-tile[data-set-paper="dark"] .paper-swatch { background: #121314; color: #D6D6D8; }

.typeset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
}

.font-pills {
  display: inline-flex;
  gap: 6px;
}
.font-pill {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  border: 0.5px solid var(--p-line);
  color: var(--p-ink2);
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease, transform 120ms var(--ease-out);
}
.font-pill:active { transform: scale(0.95); }
.font-pill[aria-pressed="true"] {
  border-color: var(--p-ink);
  color: var(--p-ink);
  font-weight: 600;
  background: color-mix(in srgb, var(--p-ink) 6%, transparent);
}

.size-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 170px;
  max-width: 240px;
  font-size: 13px;
  color: var(--p-ink2);
}
.size-control input[type="range"] {
  flex: 1;
  accent-color: var(--p-rule);
  cursor: pointer;
}

@media (max-width: 520px) {
  .paper-tiles { grid-template-columns: repeat(3, 1fr); }
}

/* Quiet bottom reading bar — direct evolution of original .page .bar */
.page-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  padding: 12px 24px 14px;
  border-top: 0.5px solid var(--p-line);
  font: 13px/1.4 var(--font-sans);
  color: var(--p-ink2);
  position: relative;
}

.page-bar-track {
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 2px;
  overflow: hidden;
}
.page-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--p-rule);
  transform-origin: left center;
  transform: scaleX(0.5);
  transition: transform 280ms var(--ease-out);
}

.ink-wave-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ink-wave-svg {
  width: 54px;
  height: 16px;
  overflow: visible;
  display: block;
}

.ink-wave-path {
  fill: none;
  stroke: var(--p-rule);
  stroke-width: 1.6;
  stroke-linecap: round;
  transition: opacity 200ms ease;
}

.bar-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bar-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--p-ink);
  border: 0.5px solid var(--p-line);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: border-color 140ms ease, background-color 140ms ease, transform 120ms var(--ease-out);
}
.bar-btn:active { transform: scale(0.95); }
@media (hover: hover) and (pointer: fine) {
  .bar-btn:hover { border-color: var(--p-ink2); }
}
.bar-btn-play {
  background: var(--p-ink);
  color: var(--p-bg);
  border-color: var(--p-ink);
}

.page-tip {
  margin: 0;
  font-size: 13px;
  color: var(--t3);
}

/* ==========================================================================
   Section Rhythm
   ========================================================================== */

.chapter {
  margin-top: 64px;
  padding-top: 48px;
  border-top: 0.5px solid var(--line);
}

.chapter-title {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 3.6vw, 2.15rem);
  line-height: 1.18;
  font-weight: 720;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.chapter-sub {
  margin: 0 0 28px;
  font-size: 16.5px;
  color: var(--t2);
  max-width: 58ch;
  line-height: 1.65;
}

/* ==========================================================================
   INTERACTION #3 — Live Highlight → Export & 3D Flippable Anki Card Studio
   ========================================================================== */

.export-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  border-bottom: 0.5px solid var(--line);
  margin-bottom: 22px;
}

.export-tab {
  padding: 9px 0;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--t2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 140ms ease, border-color 160ms ease;
}
@media (hover: hover) and (pointer: fine) {
  .export-tab:hover { color: var(--t1); }
}
.export-tab[aria-selected="true"] {
  color: var(--t1);
  font-weight: 650;
  border-bottom-color: var(--t1);
}

.export-stage {
  min-height: 256px;
}

.export-pane {
  animation: fadeRise 220ms var(--ease-out);
}
.export-pane[hidden] { display: none; }

/* 3D Light-Tilting Literary Quote Card */
.quote-tilt-wrap {
  perspective: 900px;
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
}

.quote-card-3d {
  width: 100%;
  max-width: 480px;
  background: #FCFBF7;
  color: #26251F;
  border: 0.5px solid #E2DFD3;
  border-radius: 18px;
  padding: 28px 30px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(38, 32, 24, 0.10), 0 2px 6px rgba(38, 32, 24, 0.05);
  transform-style: preserve-3d;
  transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out);
}

:root[data-theme="dark"] .quote-card-3d {
  background: #21201C;
  color: #E8E3D5;
  border-color: #35332D;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.44);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .quote-card-3d {
    background: #21201C;
    color: #E8E3D5;
    border-color: #35332D;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.44);
  }
}

.quote-card-3d[data-qpaper="kami"] {
  background: #FCFBF7;
  color: #26251F;
  border-color: #E2DFD3;
}
.quote-card-3d[data-qpaper="sage"] {
  background: #E6E7DC;
  color: #2A2C24;
  border-color: #D1D4C4;
}
.quote-card-3d[data-qpaper="night"] {
  background: #1E1D19;
  color: #E8E3D5;
  border-color: #35332D;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}
.quote-card-3d[data-qpaper="night"] .quote-mark-glyph {
  color: #8FA8C8;
}
.quote-card-3d[data-qpaper="night"] .quote-card-thought {
  border-left-color: #8FA8C8;
}

.quote-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--t3);
}

.quote-paper-dots {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.qpaper-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  transition: transform 140ms var(--ease-out), box-shadow 160ms ease, border-color 160ms ease;
}
.qpaper-dot:active { transform: scale(0.9); }
.qpaper-dot[data-qpaper-pick="kami"] { background: #FCFBF7; }
.qpaper-dot[data-qpaper-pick="sage"] { background: #E6E7DC; }
.qpaper-dot[data-qpaper-pick="night"] { background: #1E1D19; }
.qpaper-dot[aria-pressed="true"] {
  border-color: var(--ink-rule);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ink-rule) 26%, transparent);
}

.quote-sheen {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.32), transparent 62%);
  transition: opacity 240ms ease;
}

.quote-mark-glyph {
  font: 700 34px/1 var(--font-serif-en);
  color: var(--ink-rule);
  opacity: 0.45;
  margin-bottom: 6px;
}

.quote-card-body {
  font: 18px/1.88 var(--font-serif-zh);
  margin: 0 0 18px;
}
html[data-lang="en"] .quote-card-body {
  font: 17.5px/1.75 var(--font-serif-en);
}

.quote-card-thought {
  font-size: 13.5px;
  line-height: 1.6;
  padding-left: 12px;
  border-left: 2px solid var(--ink-rule);
  opacity: 0.78;
  margin-bottom: 20px;
}

.quote-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 0.5px solid rgba(128, 128, 128, 0.22);
  font-size: 12.5px;
  opacity: 0.72;
}

/* flomo / Note Card Preview */
.memo-card {
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  font-size: 15px;
  line-height: 1.72;
  color: var(--t1);
}
.memo-tag {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-rule);
  background: color-mix(in srgb, var(--ink-rule) 10%, transparent);
  padding: 2px 8px;
  border-radius: 6px;
  margin-bottom: 10px;
}
.memo-quote {
  margin: 0 0 10px;
  padding-left: 12px;
  border-left: 2px solid var(--line-strong);
  color: var(--t2);
}

/* 3D Flippable Anki Flashcard */
.anki-stage {
  perspective: 1100px;
  max-width: 480px;
  margin: 6px auto 0;
}

.anki-card {
  width: 100%;
  min-height: 242px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 520ms var(--ease-out);
  cursor: pointer;
  display: block;
  text-align: left;
}
@media (max-width: 480px) {
  .anki-card { min-height: 266px; }
}
.anki-card.is-flipped {
  transform: rotateY(180deg);
}

.anki-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 18px;
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 10px 28px rgba(38, 32, 24, 0.08);
}

.anki-back {
  transform: rotateY(180deg);
  background: var(--bg-soft);
}

.anki-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--t3);
}

.anki-word {
  font: 600 28px/1.2 var(--font-serif-en);
  letter-spacing: -0.02em;
  margin: 8px 0 6px;
  color: var(--t1);
}

.anki-context {
  font: 15px/1.68 var(--font-serif-en);
  color: var(--t2);
  margin: 0;
}
.anki-context mark {
  background: var(--hl);
  color: var(--hl-ink);
  padding: 1px 4px;
  border-radius: 3px;
}

.anki-meaning {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--t1);
  margin: 6px 0 6px;
}

.anki-flip-hint {
  font-size: 12.5px;
  color: var(--ink-rule);
  font-weight: 600;
}

/* ==========================================================================
   INTERACTION #3 — Draggable Paper & Night Curtain (60fps clip-path)
   ========================================================================== */

.curtain-shell {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 0.5px solid var(--line);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.curtain-layer {
  padding: 32px 30px 28px;
}

.curtain-day {
  background: #F5F4ED;
  color: #26251F;
}
.curtain-day[data-day-paper="plain"] { background: #FFFFFF; color: #2A2B2E; }
.curtain-day[data-day-paper="sage"] { background: #E6E7DC; color: #2A2C24; }
.curtain-day[data-day-paper="eink"] {
  background: #E9E8E3;
  color: #141414;
  background-image: radial-gradient(rgba(20, 20, 20, 0.055) 0.6px, transparent 0.6px);
  background-size: 4px 4px;
}

.curtain-night {
  position: absolute;
  inset: 0;
  background: #1B1A17;
  color: #E3DED0;
  clip-path: inset(0 0 0 54%);
  pointer-events: none;
}
.curtain-night[data-night-paper="dark"] { background: #121314; color: #D6D6D8; }

.curtain-head {
  font: 600 12px/1.4 var(--font-sans);
  letter-spacing: 0.04em;
  opacity: 0.6;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
}

.curtain-text {
  font: 18px/1.98 var(--font-serif-zh);
  margin: 0;
}
html[data-lang="en"] .curtain-text {
  font: 17.5px/1.88 var(--font-serif-en);
}

.curtain-day .c-hl { background: #EFE3B8; color: #26251F; padding: 1px 3px; border-radius: 3px; }
.curtain-day[data-day-paper="eink"] .c-hl { background: rgba(20, 20, 20, 0.12); color: #141414; }
.curtain-night .c-hl { background: rgba(233, 210, 140, 0.24); color: #ECE7DA; padding: 1px 3px; border-radius: 3px; }

.curtain-day .c-ink { border-bottom: 2px solid #1B365D; padding-bottom: 2px; }
.curtain-day[data-day-paper="eink"] .c-ink { border-bottom-color: #141414; }
.curtain-night .c-ink { border-bottom: 2px solid #8FA8C8; padding-bottom: 2px; }

.curtain-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--ink-rule);
  transform: translateX(0);
  pointer-events: none;
  z-index: 5;
}

.curtain-handle {
  position: absolute;
  top: 50%;
  left: 0;
  width: 38px;
  height: 38px;
  margin-left: -19px;
  margin-top: -19px;
  border-radius: 50%;
  background: var(--card);
  color: var(--t1);
  border: 1px solid var(--line-strong);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.20);
  display: grid;
  place-items: center;
  cursor: ew-resize;
  touch-action: none;
  z-index: 6;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  transition: scale 140ms var(--ease-out);
}
.curtain-handle:active { scale: 0.92; }

.curtain-pickers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--t2);
}

.picker-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip-btn {
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--t2);
  border: 0.5px solid var(--line);
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease, transform 120ms var(--ease-out);
}
.chip-btn:active { transform: scale(0.95); }
.chip-btn[aria-pressed="true"] {
  color: var(--t1);
  border-color: var(--t1);
  font-weight: 600;
  background: var(--card);
}

/* ==========================================================================
   INTERACTION #4 — Spoiler-Free Reading Companion (书伴) Live Demo
   ========================================================================== */

.companion-box {
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}

.companion-excerpt {
  padding: 22px 24px 18px;
  border-bottom: 0.5px solid var(--line);
  font: 16.5px/1.9 var(--font-serif-zh);
}
html[data-lang="en"] .companion-excerpt {
  font: 16.5px/1.82 var(--font-serif-en);
}

.comp-line {
  padding: 1px 4px;
  margin: 0 -4px;
  border-radius: 3px;
  transition: background-color 220ms var(--ease-out), color 200ms ease;
}
.comp-line.is-cited {
  background: var(--hl);
  color: var(--hl-ink);
}
.comp-line.is-unread {
  opacity: 0.38;
  filter: blur(0.4px);
}

.bookmark-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  font: 600 11.5px/1 var(--font-sans);
  color: var(--ink-rule);
}
.bookmark-rule::before,
.bookmark-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--ink-rule);
  opacity: 0.35;
}

.companion-chat {
  padding: 18px 24px 22px;
  background: color-mix(in srgb, var(--bg) 52%, var(--card));
}

.comp-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.prompt-btn {
  font-size: 13.5px;
  font-weight: 550;
  padding: 7px 13px;
  border-radius: 10px;
  background: var(--card);
  border: 0.5px solid var(--line-strong);
  color: var(--t1);
  text-align: left;
  transition: border-color 140ms ease, background-color 140ms ease, transform 120ms var(--ease-out);
}
.prompt-btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .prompt-btn:hover { border-color: var(--t1); }
}
.prompt-btn[aria-pressed="true"] {
  background: var(--t1);
  color: var(--bg);
  border-color: var(--t1);
}

.comp-reply {
  font-size: 15px;
  line-height: 1.72;
  color: var(--t2);
  min-height: 54px;
}
.comp-reply strong { color: var(--t1); font-weight: 650; }

.cite-pill {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 650;
  padding: 1px 7px;
  margin: 0 3px;
  border-radius: 5px;
  background: var(--hl);
  color: var(--hl-ink);
  cursor: pointer;
  vertical-align: baseline;
  transition: transform 120ms var(--ease-out);
}
.cite-pill:active { transform: scale(0.94); }

/* ==========================================================================
   Original-Rhythm Features, Spec Ledger, Pledge, Downloads, FAQ & Footer
   ========================================================================== */

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 32px;
}
.feature-list h3 {
  font-size: 18px;
  line-height: 1.35;
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.feature-list p {
  font-size: 15.5px;
  color: var(--t2);
  margin: 0;
  line-height: 1.65;
}
@media (max-width: 580px) {
  .feature-list { grid-template-columns: 1fr; gap: 22px; }
}

.spec-ledger { border-top: 0.5px solid var(--line); }
.spec-row {
  display: grid;
  grid-template-columns: 144px 1fr;
  gap: 8px 24px;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--line);
  align-items: baseline;
  font-size: 15px;
}
.spec-key { font-weight: 650; color: var(--t1); }
.spec-val { color: var(--t2); line-height: 1.65; }
.spec-val strong { color: var(--t1); font-weight: 600; }
@media (max-width: 560px) {
  .spec-row { grid-template-columns: 1fr; gap: 3px; }
}

.pledge-note {
  margin-top: 32px;
  padding: 22px 24px;
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 16px;
}
.pledge-note blockquote {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.52;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.pledge-note p { margin: 0; font-size: 14.5px; color: var(--t2); }

/* Platform Downloads */
.platform-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.platform-card {
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.platform-card.is-detected { border-color: var(--t1); }
.platform-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.platform-head h3 { margin: 0; font-size: 17px; font-weight: 700; }
.platform-tag { font-size: 12px; color: var(--t3); }
.platform-detected {
  display: none;
  font-size: 11.5px;
  font-weight: 650;
  background: var(--hl);
  color: var(--hl-ink);
  padding: 1px 7px;
  border-radius: 5px;
}
.platform-card.is-detected .platform-detected { display: inline-block; }
.platform-req { font-size: 13px; color: var(--t3); margin-top: -3px; }
.platform-card p, .platform-card ol { margin: 0; font-size: 14.5px; color: var(--t2); line-height: 1.62; }
.platform-card ol { padding-left: 18px; }

@media (max-width: 620px) {
  .platform-grid { grid-template-columns: 1fr; }
}

.get-bar {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
}

/* Download Subpage Toolbar, Version Highlight & Mirror Switch */
.dl-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin: 0 0 14px;
}

.dl-release-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--card);
  border: 0.5px solid var(--line);
  font-size: 13px;
  color: var(--t2);
}
.dl-release-ver {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 650;
  background: var(--hl);
  color: var(--hl-ink);
  padding: 1px 7px;
  border-radius: 5px;
  line-height: 1.45;
}
.dl-release-dot {
  color: var(--line-strong);
  user-select: none;
}
.dl-release-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--t3);
}

.dl-mirror {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--t3);
}
.dl-mirror-seg {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--inset) 88%, transparent);
  border: 0.5px solid var(--line);
}
.dl-mirror-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 0;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(30, 26, 22, 0.08), 0 0 0 0.5px rgba(30, 26, 22, 0.05);
  pointer-events: none;
  opacity: 0;
  transition: transform 220ms var(--ease-out), width 220ms var(--ease-out), opacity 120ms ease;
}
.dl-mirror-seg.has-thumb .dl-mirror-thumb {
  opacity: 1;
}
.dl-mirror-btn {
  position: relative;
  z-index: 1;
  height: 26px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--t3);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 160ms ease, transform 120ms var(--ease-out);
}
.dl-mirror-btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .dl-mirror-btn:hover { color: var(--t1); }
}
.dl-mirror-btn svg {
  width: 12.5px;
  height: 12.5px;
  flex-shrink: 0;
  opacity: 0.58;
  transition: color 160ms ease, opacity 160ms ease;
}
.dl-mirror-btn[aria-pressed="true"] {
  color: var(--t1);
  font-weight: 600;
}
.dl-mirror-seg:not(.has-thumb) .dl-mirror-btn[aria-pressed="true"] {
  background: var(--card);
  box-shadow: 0 1px 3px rgba(30, 26, 22, 0.08), 0 0 0 0.5px rgba(30, 26, 22, 0.05);
}
.dl-mirror-btn[aria-pressed="true"] svg {
  opacity: 0.95;
}
.dl-mirror-btn[data-set-mirror="cn"][aria-pressed="true"] svg {
  color: var(--ink-rule);
}

:root[data-theme="dark"] .dl-mirror-thumb,
:root[data-theme="dark"] .dl-mirror-seg:not(.has-thumb) .dl-mirror-btn[aria-pressed="true"] {
  background: #323337;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.30), 0 0 0 0.5px rgba(255, 255, 255, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dl-mirror-thumb,
  :root:not([data-theme="light"]) .dl-mirror-seg:not(.has-thumb) .dl-mirror-btn[aria-pressed="true"] {
    background: #323337;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.30), 0 0 0 0.5px rgba(255, 255, 255, 0.07);
  }
}
@media (prefers-reduced-motion: reduce) {
  .dl-mirror-thumb { transition: none; }
}

.dl-card-actions {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-sm {
  height: 36px;
  padding: 0 13px;
  border-radius: 9px;
  font-size: 13.5px;
}

.platform-card .btn-ghost {
  background: var(--bg-soft);
  border-color: var(--line);
}
@media (hover: hover) and (pointer: fine) {
  .platform-card .btn-ghost:hover {
    background: var(--inset);
    border-color: var(--line-strong);
  }
}

/* Hairline FAQ */
.faq-list { border-top: 0.5px solid var(--line); }
.faq-item { border-bottom: 0.5px solid var(--line); }
.faq-item summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-plus { font-size: 18px; color: var(--t3); transition: transform 180ms var(--ease-out); }
.faq-item[open] .faq-plus { transform: rotate(45deg); }
.faq-body { padding: 0 0 18px; color: var(--t2); font-size: 15px; line-height: 1.7; }
.faq-body p { margin: 0 0 8px; }
.faq-body p:last-child { margin-bottom: 0; }

/* ==========================================================================
   Subpages (/privacy/, /support/, /download/, /changelog/, /roadmap/, 404)
   Exact original 720px quiet editorial feel
   ========================================================================== */

.doc-head { padding-top: 28px; margin-bottom: 22px; }
.doc-head h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: -0.03em;
}
.doc-lead { margin: 0 0 8px; font-size: 18px; color: var(--t2); max-width: 60ch; }
.doc-date { margin: 0; font-size: 14px; color: var(--t3); }

.doc-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 12px 0;
  border-top: 0.5px solid var(--line);
  border-bottom: 0.5px solid var(--line);
  margin-bottom: 22px;
  font-size: 13.5px;
}
.doc-jump a { text-decoration: none; color: var(--t2); }
@media (hover: hover) and (pointer: fine) { .doc-jump a:hover { color: var(--t1); text-decoration: underline; } }

section.doc {
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 16px;
  padding: 24px 26px 14px;
  margin-top: 18px;
}
section.doc h2 {
  font-size: 19px;
  line-height: 1.35;
  margin: 24px 0 8px;
  font-weight: 700;
  letter-spacing: -0.015em;
  scroll-margin-top: 84px;
}
section.doc h2:first-child { margin-top: 0; }
section.doc p { margin: 0 0 12px; color: var(--t2); line-height: 1.72; }
section.doc ul, section.doc ol { margin: 0 0 14px; padding-left: 20px; color: var(--t2); }
section.doc li { margin-bottom: 8px; line-height: 1.7; }
section.doc b, section.doc strong { color: var(--t1); font-weight: 650; }

.channel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 24px 0 36px;
}
.channel-card {
  background: var(--card);
  border: 0.5px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.channel-card h3 { margin: 0; font-size: 15.5px; font-weight: 700; }
.channel-card p { margin: 0; font-size: 14px; color: var(--t2); line-height: 1.6; }
.channel-act { margin-top: auto; padding-top: 6px; font-size: 14px; font-weight: 600; }
@media (max-width: 640px) { .channel-grid { grid-template-columns: 1fr; } }

.code-box {
  position: relative;
  background: var(--inset);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 12px 0 18px;
  overflow-x: auto;
}
.code-box pre { margin: 0; font: 13.5px/1.65 var(--font-mono); color: var(--t1); }
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--card);
  border: 0.5px solid var(--line-strong);
  color: var(--t1);
  transition: transform 120ms var(--ease-out), background-color 140ms ease;
}
.copy-btn:active { transform: scale(0.95); }
.copy-btn.is-copied { background: var(--hl); color: var(--hl-ink); border-color: transparent; }

/* Changelog & Roadmap */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  border-bottom: 0.5px solid var(--line);
  margin-bottom: 22px;
}
.filter-btn {
  padding: 8px 0;
  font-size: 14px;
  color: var(--t2);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.filter-btn[aria-pressed="true"] { color: var(--t1); font-weight: 650; border-bottom-color: var(--t1); }

.release-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 0.5px solid var(--line);
}
.release-ver {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 750;
}
.release-latest {
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 650;
  background: var(--hl);
  color: var(--hl-ink);
  padding: 1px 7px;
  border-radius: 5px;
  line-height: 1.5;
}
.release-date { font-family: var(--font-mono); font-size: 13px; color: var(--t3); }

.change-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.change-item { display: grid; grid-template-columns: 96px 1fr; gap: 6px 16px; align-items: baseline; }
.change-item[hidden] { display: none; }
.change-cat { font-size: 12.5px; font-weight: 600; color: var(--t3); }
.change-text { font-size: 15px; line-height: 1.68; color: var(--t2); }
.change-text strong { color: var(--t1); font-weight: 650; }
@media (max-width: 540px) { .change-item { grid-template-columns: 1fr; gap: 2px; } }

.changelog-status {
  margin: 4px 0 36px;
  font-size: 15px;
  line-height: 1.68;
  color: var(--t3);
  max-width: 60ch;
}

.dl-release-ver:empty,
.dl-release-date:empty {
  display: none;
}

.stage-block { padding-top: 28px; margin-top: 28px; border-top: 0.5px solid var(--line); }
.stage-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.stage-head h2 { margin: 0; font-size: 20px; font-weight: 700; }
.ms-grid { display: grid; gap: 12px; margin-top: 14px; }
.ms-card { background: var(--card); border: 0.5px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.ms-card.is-now { border-color: var(--t1); }
.ms-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.ms-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.ms-badge { font-family: var(--font-mono); font-size: 12px; color: var(--t3); }
.ms-card.is-now .ms-badge { background: var(--hl); color: var(--hl-ink); padding: 1px 7px; border-radius: 5px; font-weight: 650; }
.ms-card p { margin: 0; font-size: 14.5px; color: var(--t2); line-height: 1.65; }
.ms-fact { margin-top: 10px !important; padding-top: 10px; border-top: 0.5px solid var(--line); font-size: 13.5px !important; color: var(--t1) !important; }

/* Quiet Editorial Footer (720px aligned, structured yet warm) */
footer.site-footer {
  margin-top: 72px;
  border-top: 0.5px solid var(--line);
  padding: 36px 0 calc(52px + env(safe-area-inset-bottom, 0px));
  font-size: 14px;
  color: var(--t2);
}

.footer-cols {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 24px;
}

.footer-cols h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 650;
  color: var(--t1);
}
.footer-cols ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.footer-cols a { text-decoration: none; color: var(--t2); }
@media (hover: hover) and (pointer: fine) {
  .footer-cols a:hover { color: var(--t1); text-decoration: underline; }
}

.footer-meta {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 0.5px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  font-size: 13px;
  color: var(--t3);
}
.footer-meta a { color: var(--t2); }

@media (max-width: 620px) {
  .footer-cols { grid-template-columns: repeat(2, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  .float-nav, .sel-bar, .dict-popover,
  .typeset-drawer, .mobile-sheet, .anki-card, .quote-card-3d {
    transition-duration: 0.01ms !important;
  }
}
