/* 第一节 V7 · 基础层。每一页是一张单独设计的网页；这里只放所有页面共用的材料、字体、外框和零件。 */
:root {
  --paper: #f3f1ea;
  --paper-2: #e8e5db;
  --paper-3: #d9d5c8;
  --white: #fdfdfb;
  --ink: #0c0c0e;
  --ink-2: #151518;
  --ink-3: #222227;
  --text: #121214;
  --text-2: #403e3a;
  --muted: #74716a;
  --faint: #a29f96;
  --on-ink: #f1efe9;
  --on-ink-2: #c4c1b8;
  --on-ink-muted: #8d8a82;
  --line: rgba(18, 18, 20, .12);
  --line-2: rgba(18, 18, 20, .22);
  --line-ink: rgba(241, 239, 233, .13);
  --line-ink-2: rgba(241, 239, 233, .26);
  --mark: #ffd84d;
  --mark-2: #ffe783;
  --mark-soft: rgba(255, 216, 77, .34);
  --ok: #23955f;
  --ok-soft: rgba(35, 149, 95, .13);
  --bad: #df4747;
  --bad-soft: rgba(223, 71, 71, .12);
  --amber: #e48a1b;
  --amber-soft: rgba(228, 138, 27, .14);
  --blue: #4c5bd8;
  --blue-soft: rgba(76, 91, 216, .12);

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Noto Sans CJK SC", sans-serif;
  --display: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --gutter: clamp(20px, 4.2vw, 68px);
  --top: 58px;
  --bottom: 76px;
  --ease: cubic-bezier(.2, .7, .1, 1);
  --spring: cubic-bezier(.34, 1.4, .5, 1);

  --t-display: clamp(3rem, 6.4vw, 6.9rem);
  --t-title: clamp(1.95rem, 2.65vw + .55rem, 3.35rem);
  --t-sub: clamp(1.18rem, .7vw + .8rem, 1.5rem);
  --t-lede: clamp(1.02rem, .32vw + .9rem, 1.2rem);
}
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
/* every page is designed at about 1380 × 880; engine.js sets --z so it fits any screen, and 大字号 multiplies it */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--paper);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-synthesis: none;
  transition: background-color .5s var(--ease);
}
body[data-theme="ink"] { background: var(--ink); }
body[data-theme="sage"] { background: #e7ebe3; }
body[data-theme="codex"] { background: #4a5bd8; }
h1, h2, h3, h4, p, ol, ul, dl, dd, figure, blockquote { margin: 0; }
ol, ul { padding: 0; list-style: none; }
h1, h2, h3, h4 { font-weight: 600; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
::selection { background: var(--mark); color: var(--ink); }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; z-index: 100; left: 16px; top: -64px; padding: 10px 16px; background: var(--mark); color: var(--ink); border-radius: 8px; text-decoration: none; }
.skip:focus { top: 10px; }
h1, h2, h3, .t, .d, .lede { word-break: keep-all; overflow-wrap: anywhere; line-break: strict; }

/* ---------- chrome: a quiet frame that takes the colour of the page under it ---------- */
.topbar {
  position: fixed; inset: 0 0 auto; z-index: 30;
  height: var(--top);
  display: flex; align-items: center; gap: 18px;
  padding: 0 var(--gutter);
  color: var(--text);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { margin-right: auto; font-size: .9rem; font-weight: 600; text-decoration: none; white-space: nowrap; letter-spacing: .01em; }
.brand span { margin-left: 10px; font-weight: 400; opacity: .55; }
.top-tools { display: flex; align-items: center; gap: 4px; }
.top-tools button {
  height: 34px; padding: 0 12px; border-radius: 999px;
  font-size: .82rem; opacity: .62;
  transition: opacity .2s, background-color .2s;
}
.top-tools button:hover { opacity: 1; background: rgba(127, 127, 127, .12); }
.top-tools button[aria-pressed="true"] { opacity: 1; background: currentColor; }
.top-tools button[aria-pressed="true"] span { color: var(--paper); }
body[data-theme="ink"] .top-tools button[aria-pressed="true"] span { color: var(--ink); }
#toc-open { opacity: 1; box-shadow: inset 0 0 0 1px var(--line-2); padding: 0 14px; display: inline-flex; gap: 10px; align-items: center; }
#toc-open b { font-family: var(--mono); font-weight: 500; font-size: .76rem; opacity: .6; font-variant-numeric: tabular-nums; }
body[data-theme="ink"] .topbar, body[data-theme="codex"] .topbar { color: var(--on-ink); }
body[data-theme="ink"] #toc-open, body[data-theme="codex"] #toc-open { box-shadow: inset 0 0 0 1px var(--line-ink-2); }
.topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(var(--paper) 30%, rgba(243, 241, 234, 0));
  opacity: 0; transition: opacity .3s;
}
body.scrolled .topbar::before { opacity: 1; }
body[data-theme="ink"] .topbar::before { background: linear-gradient(var(--ink) 30%, rgba(12, 12, 14, 0)); }
body[data-theme="codex"] .topbar::before { background: linear-gradient(rgba(64, 76, 200, .92) 30%, rgba(64, 76, 200, 0)); }
body[data-theme="sage"] .topbar::before { background: linear-gradient(#e7ebe3 30%, rgba(231, 235, 227, 0)); }

.pager {
  position: fixed; inset: auto 0 0; z-index: 30;
  height: var(--bottom);
  display: flex; align-items: center; gap: 18px;
  padding: 0 var(--gutter);
  color: var(--text);
  pointer-events: none;
}
.pager > * { pointer-events: auto; }
.pager::before {
  content: ""; position: absolute; inset: -18px 0 0; z-index: -1; pointer-events: none;
  background: linear-gradient(rgba(243, 241, 234, 0), var(--paper) 62%);
}
body[data-theme="ink"] .pager { color: var(--on-ink); }
body[data-theme="ink"] .pager::before { background: linear-gradient(rgba(12, 12, 14, 0), var(--ink) 62%); }
body[data-theme="codex"] .pager { color: var(--on-ink); }
body[data-theme="codex"] .pager::before { background: linear-gradient(rgba(60, 70, 190, 0), rgba(52, 62, 178, .94) 70%); }
body[data-theme="sage"] .pager::before { background: linear-gradient(rgba(231, 235, 227, 0), #e7ebe3 62%); }
body.bare .pager::before { opacity: 0; }

.rail-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.rail-label { font-size: .78rem; opacity: .62; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail { display: flex; gap: 4px; height: 14px; align-items: center; max-width: 560px; }
.rail button { position: relative; height: 14px; flex: var(--n) 1 0; min-width: 6px; }
.rail button::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 2px; border-radius: 2px; background: currentColor; opacity: .18; transition: opacity .2s; }
.rail button:hover::before { opacity: .4; }
.rail button i { position: absolute; left: 0; top: 6px; height: 2px; border-radius: 2px; background: currentColor; width: 0; transition: width .5s var(--ease); }
.rail button.done i { width: 100%; opacity: .55; }
.rail button.now i { width: var(--p); opacity: 1; }
body[data-theme="ink"] .rail button.now i { background: var(--mark); }

.pager-buttons { display: flex; align-items: center; gap: 8px; }
#prev {
  height: 44px; padding: 0 16px; border-radius: 999px; font-size: .88rem; opacity: .7;
  box-shadow: inset 0 0 0 1px var(--line-2);
}
#prev:hover:not(:disabled) { opacity: 1; }
#prev:disabled { opacity: .25; }
#next {
  height: 48px; padding: 0 8px 0 20px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--paper);
  font-size: .9rem; max-width: min(46vw, 380px);
  transition: transform .25s var(--ease), background-color .25s;
}
#next span { opacity: .6; white-space: nowrap; }
#next strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#next em { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-style: normal; background: rgba(255, 255, 255, .14); transition: transform .3s var(--ease); }
#next:hover:not(:disabled) em { transform: translateX(3px); }
#next:disabled { opacity: .35; }
body[data-theme="ink"] #prev, body[data-theme="codex"] #prev { box-shadow: inset 0 0 0 1px var(--line-ink-2); }
body[data-theme="ink"] #next { background: var(--mark); color: var(--ink); }
body[data-theme="ink"] #next em { background: rgba(0, 0, 0, .1); }
body[data-theme="codex"] #next { background: #fff; color: #111; }
body[data-theme="codex"] #next em { background: rgba(0, 0, 0, .07); }

/* ---------- stage and pages ---------- */
#stage { position: fixed; inset: 0; view-transition-name: stage; }
.page {
  position: absolute; inset: 0;
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--top) + clamp(10px, 2.4vh, 30px)) var(--gutter) calc(var(--bottom) + clamp(14px, 2.4vh, 30px));
  outline: none;
  scrollbar-width: thin;
}
.page > .frame { min-height: 100%; position: relative; display: flex; flex-direction: column; zoom: var(--z, 1); }
.page > .frame > * { flex: 1 0 auto; min-width: 0; }
.page > .frame > * > * { min-width: 0; }
.t-paper { background: var(--paper); color: var(--text); }
.t-ink { background: var(--ink); color: var(--on-ink); }
.t-sage { background: #e7ebe3; color: var(--text); }
.t-codex {
  color: var(--on-ink);
  background:
    radial-gradient(ellipse 55% 45% at 66% 24%, rgba(233, 238, 252, .85), rgba(233, 238, 252, 0) 70%),
    radial-gradient(ellipse 60% 70% at 12% 88%, rgba(44, 56, 190, .9), rgba(44, 56, 190, 0) 70%),
    radial-gradient(ellipse 50% 50% at 92% 82%, rgba(126, 138, 236, .9), rgba(126, 138, 236, 0) 70%),
    linear-gradient(155deg, #4a5bd8 0%, #8a9aee 46%, #5363dc 74%, #3b49c6 100%);
}
.t-codex::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .18; mix-blend-mode: overlay;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='.6'/></svg>");
}

/* ---------- type: four levels, nothing more ---------- */
.k { font-size: .8rem; letter-spacing: .06em; color: var(--muted); display: flex; gap: 10px; align-items: baseline; }
.k b { font-family: var(--mono); font-weight: 500; letter-spacing: 0; }
.t-ink .k, .t-codex .k { color: var(--on-ink-muted); }
.t-codex .k { color: rgba(241, 239, 233, .78); }
.t { font-family: var(--display); font-size: var(--t-title); line-height: 1.12; letter-spacing: -.022em; font-weight: 600; margin-top: 10px; }
.d { font-family: var(--display); font-size: var(--t-display); line-height: 1; letter-spacing: -.035em; font-weight: 650; }
.sub { font-size: var(--t-sub); line-height: 1.4; font-weight: 600; letter-spacing: -.01em; }
.lede { font-size: var(--t-lede); line-height: 1.7; color: var(--text-2); margin-top: 14px; max-width: 34em; }
.t-ink .lede { color: var(--on-ink-2); }
.t-codex .lede { color: rgba(246, 246, 252, .9); }
.note { font-size: .88rem; line-height: 1.65; color: var(--muted); }
.t-ink .note { color: var(--on-ink-muted); }
.t-codex .note { color: rgba(240, 242, 252, .8); }
.mono { font-family: var(--mono); font-size: .84em; letter-spacing: -.01em; }
mark, .hl { background: linear-gradient(transparent 52%, var(--mark-soft) 52%, var(--mark-soft) 92%, transparent 92%); color: inherit; padding: 0 .08em; }
.t-ink mark, .t-ink .hl { background: none; color: var(--mark); }
code { font-family: var(--mono); font-size: .88em; padding: .08em .38em; border-radius: 5px; background: rgba(18, 18, 20, .07); }
.t-ink code { background: rgba(241, 239, 233, .1); }
.t-codex code { background: rgba(255, 255, 255, .16); }

/* sources: one quiet line at the foot of a page */
.src { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; font-size: .78rem; color: var(--muted); margin-top: 22px; }
.src > span { letter-spacing: .04em; }
.src a { text-decoration: none; border-bottom: 1px solid var(--line-2); padding-bottom: 1px; transition: color .2s, border-color .2s; }
.src a:hover { color: var(--text); border-color: currentColor; }
.src a::after { content: " ↗"; font-size: .9em; opacity: .55; }
.t-ink .src, .t-codex .src { color: var(--on-ink-muted); }
.t-codex .src { color: rgba(240, 242, 252, .82); }
.t-ink .src a, .t-codex .src a { border-color: var(--line-ink-2); }
.t-ink .src a:hover, .t-codex .src a:hover { color: var(--on-ink); }

/* inline link that goes out */
.out { text-decoration: none; font-weight: 600; border-bottom: 2px solid var(--mark); padding-bottom: 1px; }
.out::after { content: " ↗"; font-weight: 400; opacity: .6; }

/* menu path: Settings › General › Permissions */
.path { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 0; font-family: var(--mono); font-size: .82rem; letter-spacing: -.01em; }
.path span { padding: 3px 8px; border-radius: 6px; background: rgba(18, 18, 20, .07); white-space: nowrap; }
.path i { font-style: normal; opacity: .45; padding: 0 5px; }
.t-ink .path span { background: rgba(241, 239, 233, .1); }
.t-codex .path span { background: rgba(255, 255, 255, .17); }

kbd {
  display: inline-grid; place-items: center; min-width: 2.1em; height: 2.1em; padding: 0 .55em;
  font-family: var(--sans); font-size: .9em; font-weight: 600;
  border-radius: .45em; background: var(--white); color: var(--text);
  box-shadow: 0 1px 0 1px var(--line-2), 0 3px 0 0 var(--paper-3);
}
.keys { display: inline-flex; align-items: center; gap: .35em; }
.keys .plus { opacity: .45; font-size: .9em; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  font-size: .92rem; font-weight: 600; text-decoration: none; white-space: nowrap;
  background: var(--ink); color: var(--paper);
  transition: transform .2s var(--ease), background-color .2s, color .2s, box-shadow .2s, opacity .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .35; }
.btn.mark { background: var(--mark); color: var(--ink); }
.btn.ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 1px var(--line-2); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: .84rem; }
.t-ink .btn:not(.mark):not(.ghost) { background: var(--on-ink); color: var(--ink); }
.t-ink .btn.ghost, .t-codex .btn.ghost { box-shadow: inset 0 0 0 1px var(--line-ink-2); }
.t-codex .btn:not(.mark):not(.ghost) { background: #fff; color: #111; }

/* segmented choice: the only "control" look in the system */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: rgba(18, 18, 20, .06); }
.seg button { min-height: 36px; padding: 0 15px; border-radius: 999px; font-size: .86rem; color: var(--text-2); transition: background-color .2s, color .2s, box-shadow .2s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--white); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 0 0 1px var(--line); font-weight: 600; }
.t-ink .seg { background: rgba(241, 239, 233, .08); }
.t-ink .seg button { color: var(--on-ink-2); }
.t-ink .seg button[aria-pressed="true"] { background: var(--on-ink); color: var(--ink); box-shadow: none; }
.t-codex .seg { background: rgba(255, 255, 255, .14); }
.t-codex .seg button { color: rgba(255, 255, 255, .85); }
.t-codex .seg button[aria-pressed="true"] { background: #fff; color: #111; }

/* a copyable prompt, drawn like the Codex input it will be pasted into */
.prompt {
  position: relative; border-radius: 18px; background: #fff; color: #111;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .08), 0 14px 40px -18px rgba(20, 24, 60, .35);
  padding: 14px 16px 12px;
}
.prompt-label { font-size: .74rem; color: #8a8a90; letter-spacing: .03em; display: flex; justify-content: space-between; gap: 10px; }
.prompt textarea {
  display: block; width: 100%; margin-top: 6px; border: 0; resize: vertical; background: transparent;
  font-size: .9rem; line-height: 1.72; color: #1b1b1f; min-height: 6.5em; outline: none;
}
.prompt-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.prompt-foot .fb { font-size: .78rem; color: #6b6b72; margin-right: auto; }
.prompt-foot button { height: 34px; padding: 0 14px; border-radius: 999px; background: #111; color: #fff; font-size: .82rem; font-weight: 600; }
.prompt-foot button.done { background: var(--ok); }

/* things that only exist to be looked at closely */
.zoomable { cursor: zoom-in; }
.figure-cap { font-size: .78rem; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.t-ink .figure-cap, .t-codex .figure-cap { color: var(--on-ink-muted); }

/* reveal on arrival: pages stagger their own parts with --i */
.page [data-in] { opacity: 0; transform: translateY(14px); }
.page.in [data-in] { opacity: 1; transform: none; transition: opacity .7s var(--ease), transform .8s var(--ease); transition-delay: calc(var(--i, 0) * 70ms + 80ms); }
html.still .page [data-in] { opacity: 1; transform: none; transition: none; }
html.still *, html.still *::before, html.still *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; }

/* ---------- directory ---------- */
dialog { border: 0; padding: 0; color: var(--text); background: var(--paper); }
dialog::backdrop { background: rgba(8, 8, 10, .5); backdrop-filter: blur(6px); }
#toc {
  width: min(980px, calc(100vw - 24px)); height: min(820px, calc(100dvh - 24px));
  max-width: none; max-height: none; border-radius: 22px;
  display: none; flex-direction: column; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
#toc[open] { display: flex; }
.toc-top { display: flex; gap: 16px; align-items: center; padding: 22px 26px 12px; }
.toc-top h2 { font-size: 1.35rem; margin-right: auto; }
.toc-top button { height: 38px; padding: 0 16px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line-2); font-size: .86rem; }
.toc-tools { display: flex; gap: 10px; align-items: center; padding: 0 26px 14px; flex-wrap: wrap; }
#toc-search { flex: 1; min-width: 200px; height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--white); padding: 0 14px; font-size: .95rem; outline: none; }
#toc-search:focus { border-color: var(--text); }
.toc-list { flex: 1; overflow: auto; padding: 6px 26px 28px; columns: 2 300px; column-gap: 34px; }
.toc-block { break-inside: avoid; padding: 14px 0 12px; border-top: 1px solid var(--line); }
.toc-block h3 { display: flex; gap: 10px; align-items: baseline; font-size: .95rem; margin-bottom: 6px; }
.toc-block h3 b { font-family: var(--mono); font-weight: 500; font-size: .78rem; color: var(--muted); }
.toc-block h3 button { text-align: left; }
.toc-block h3 button:hover { text-decoration: underline; }
.toc-block ol { display: grid; gap: 1px; }
.toc-block li button { width: 100%; text-align: left; display: flex; gap: 10px; align-items: baseline; padding: 5px 8px; margin-left: -8px; border-radius: 8px; font-size: .88rem; color: var(--text-2); }
.toc-block li button:hover { background: rgba(18, 18, 20, .06); color: var(--text); }
.toc-block li button[aria-current] { background: var(--ink); color: var(--paper); }
.toc-block li button i { font-style: normal; font-family: var(--mono); font-size: .72rem; opacity: .5; min-width: 1.8em; font-variant-numeric: tabular-nums; }
#toc-empty { padding: 20px 26px; color: var(--muted); }

#lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; background: rgba(10, 10, 12, .96); color: var(--on-ink); display: none; }
#lightbox[open] { display: grid; grid-template-rows: auto 1fr auto; }
#lightbox .lb-top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; gap: 12px; }
#lightbox .lb-top h2 { font-size: 1rem; font-weight: 600; }
#lightbox .lb-top button { height: 38px; padding: 0 16px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line-ink-2); font-size: .86rem; }
#lightbox .lb-img { overflow: auto; display: grid; place-items: center; padding: 10px 20px; }
#lightbox img { max-width: 100%; max-height: calc(100dvh - 140px); object-fit: contain; border-radius: 10px; }
#lightbox p { padding: 10px 20px 18px; font-size: .84rem; color: var(--on-ink-muted); text-align: center; }

/* ---------- module openers share one particle canvas ---------- */
#lesson-field { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; opacity: 0; pointer-events: none; transition: opacity .6s var(--ease); }
body.field-on #lesson-field { opacity: 1; }
body.field-on #stage .page.is-now { background: transparent; }

/* ---------- page transitions ---------- */
::view-transition-old(stage) { animation: stage-out .42s var(--ease) both; }
::view-transition-new(stage) { animation: stage-in .62s var(--ease) both; }
@keyframes stage-out { to { opacity: 0; transform: translateX(calc(var(--dir, 1) * -3%)) scale(.985); filter: blur(6px); } }
@keyframes stage-in { from { opacity: 0; transform: translateX(calc(var(--dir, 1) * 4%)) scale(1.01); filter: blur(8px); } }
::view-transition-group(*) { animation-duration: .62s; animation-timing-function: var(--ease); }
html[data-dir="back"] { --dir: -1; }
html.still ::view-transition-group(*), html.still ::view-transition-old(*), html.still ::view-transition-new(*) { animation: none !important; }

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

/* ---------- narrow screens ---------- */
@media (max-width: 760px) {
  :root { --top: 52px; --bottom: 70px; }
  .brand span { display: none; }
  #lecture-toggle, #motion-toggle { display: none; }
  .rail-label { display: none; }
  #prev { padding: 0 14px; }
  #next { max-width: 62vw; padding-left: 16px; }
  #next span { display: none; }
  .toc-list { columns: 1; }
  .toc-top, .toc-tools, .toc-list { padding-left: 18px; padding-right: 18px; }
}
@media (max-width: 760px) {
  .toc-mobile-tools { display: flex !important; }
}
.toc-mobile-tools { display: none; gap: 8px; }
.toc-mobile-tools button { height: 38px; padding: 0 14px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line-2); font-size: .84rem; }
.toc-mobile-tools button[aria-pressed="true"] { background: var(--ink); color: var(--paper); box-shadow: none; }
