/* Robotics primer: the drawing office.
   Warm technical paper by day, the same drawing on a lit board at night.
   Ink line-work, one safety-orange signal, one blue for flows. */

/* ---------- 1. Tokens ---------- */
:root {
  --paper: #F4EFE4;
  --paper-2: #FBF8F1;
  --paper-3: #ECE6D8;
  --ink: #1C2430;
  --ink-2: #4B5563;
  --ink-3: #7C8794;
  --rule: rgba(28, 36, 48, .22);
  --rule-2: rgba(28, 36, 48, .10);
  --grid: rgba(28, 36, 48, .075);
  --grid-2: rgba(28, 36, 48, .14);
  --accent: #E8641C;
  --accent-ink: #B7460A;
  --accent-soft: rgba(232, 100, 28, .12);
  --flow: #0F7BA6;
  --flow-soft: rgba(15, 123, 166, .12);
  --ok: #2F7D4E;
  --bad: #B03A2E;
  --scrim: rgba(28, 36, 48, .45);

  --font-body: "Source Serif 4", Georgia, "Noto Sans SC", serif;
  --font-ui: "Barlow", "Noto Sans SC", system-ui, sans-serif;
  --font-cond: "Barlow Condensed", "Barlow", "Noto Sans SC", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --font-zh: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans SC", sans-serif;

  --fs-0: .8rem;
  --fs-1: .9rem;
  --fs-2: 1rem;
  --fs-3: 1.2rem;
  --fs-4: 1.55rem;
  --fs-5: 2.3rem;
  --fs-6: clamp(2.5rem, 5.5vw, 4rem);

  --col: 720px;
  --wide: 1000px;
  --gutter: 16px;
  --sidebar: 280px;
  --topbar: 52px;
  --r: 3px;
  --stroke: 1px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F161D;
    --paper-2: #151F28;
    --paper-3: #1B2631;
    --ink: #E9E4D6;
    --ink-2: #B8B3A6;
    --ink-3: #8A867B;
    --rule: rgba(233, 228, 214, .26);
    --rule-2: rgba(233, 228, 214, .12);
    --grid: rgba(233, 228, 214, .07);
    --grid-2: rgba(233, 228, 214, .13);
    --accent: #FF7A2E;
    --accent-ink: #FF9B62;
    --accent-soft: rgba(255, 122, 46, .16);
    --flow: #5FBBE8;
    --flow-soft: rgba(95, 187, 232, .16);
    --ok: #5FBF86;
    --bad: #E0716A;
    --scrim: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --paper: #0F161D;
  --paper-2: #151F28;
  --paper-3: #1B2631;
  --ink: #E9E4D6;
  --ink-2: #B8B3A6;
  --ink-3: #8A867B;
  --rule: rgba(233, 228, 214, .26);
  --rule-2: rgba(233, 228, 214, .12);
  --grid: rgba(233, 228, 214, .07);
  --grid-2: rgba(233, 228, 214, .13);
  --accent: #FF7A2E;
  --accent-ink: #FF9B62;
  --accent-soft: rgba(255, 122, 46, .16);
  --flow: #5FBBE8;
  --flow-soft: rgba(95, 187, 232, .16);
  --ok: #5FBF86;
  --bad: #E0716A;
  --scrim: rgba(0, 0, 0, .6);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar) + 16px);
  color-scheme: light dark;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--fs-2);
  line-height: 1.6;
  font-variant-numeric: lining-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
:lang(zh-Hans), [lang="zh-Hans"], .zh { font-family: var(--font-zh); }
h1, h2, h3, h4 {
  font-family: var(--font-ui);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -.005em;
  margin: 0;
  color: var(--ink);
  text-wrap: balance;
}
h2 { font-size: var(--fs-4); margin-top: 3rem; margin-bottom: .9rem; padding-top: .9rem; border-top: var(--stroke) solid var(--rule); }
h3 { font-size: var(--fs-3); margin-top: 2rem; margin-bottom: .6rem; }
h4 { font-size: var(--fs-2); margin-top: 1.4rem; margin-bottom: .4rem; font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--ink-2); }
p, ul, ol, dl { margin: 0 0 1.1rem; }
ul, ol { padding-left: 1.3rem; }
li { margin-bottom: .35rem; }
li::marker { color: var(--accent); font-family: var(--font-mono); }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-ink); }
strong { font-weight: 600; }
small { font-size: var(--fs-0); }
hr { border: 0; border-top: var(--stroke) solid var(--rule); margin: 2.5rem 0; }
code, kbd, pre { font-family: var(--font-mono); font-size: .88em; }
code { background: var(--paper-3); padding: .08em .35em; border-radius: var(--r); }
pre { background: var(--paper-3); padding: 1rem; border-radius: var(--r); overflow-x: auto; border: var(--stroke) solid var(--rule-2); line-height: 1.5; }
pre code { background: none; padding: 0; }
img, svg { max-width: 100%; height: auto; }
svg { display: block; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: #fff; padding: 8px 12px; font-family: var(--font-ui); }
.skip:focus { top: 8px; }

/* Numbers in UI, tables and stats line up. */
.num, .toc-num, .pager-num, td.n, .stat-n, .spec dd, .g-where, .fig-no, .chapter-kicker { font-variant-numeric: lining-nums tabular-nums; }

/* ---------- 3. Chrome: progress, topbar, sidebar, layout ---------- */
.progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 60; background: transparent; pointer-events: none; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .1s linear; }

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar); z-index: 50;
  display: flex; align-items: center; gap: 10px; padding: 0 var(--gutter);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: var(--stroke) solid var(--rule);
  font-family: var(--font-ui);
}
.brand { font-family: var(--font-cond); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; font-size: .95rem; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand:hover { color: var(--ink); }
.brand .brand-mark { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--accent); border-radius: 50%; vertical-align: -2px; margin-right: 8px; position: relative; }
.brand .brand-mark::after { content: ""; position: absolute; inset: 3px; background: var(--accent); border-radius: 50%; }
.topbar-sheet { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-0); color: var(--ink-3); letter-spacing: .04em; white-space: nowrap; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 36px; height: 36px; padding: 0 10px; border: var(--stroke) solid var(--rule); border-radius: var(--r);
  background: var(--paper-2); color: var(--ink); cursor: pointer; font-family: var(--font-ui); font-size: var(--fs-1); font-weight: 500;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .theme-label { font-family: var(--font-mono); font-size: var(--fs-0); text-transform: lowercase; color: var(--ink-2); }
.theme-btn [data-ico] { display: none; }
:root[data-theme="light"] .theme-btn [data-ico="light"],
:root[data-theme="dark"] .theme-btn [data-ico="dark"],
:root:not([data-theme="light"]):not([data-theme="dark"]) .theme-btn [data-ico="system"] { display: block; }

.layout { display: block; padding-top: var(--topbar); }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(var(--sidebar), 86vw); z-index: 70;
  background: var(--paper-2); border-right: var(--stroke) solid var(--rule);
  transform: translateX(-102%); transition: transform .28s var(--ease);
  display: flex; flex-direction: column; overflow: hidden;
}
.sidebar.is-open { transform: none; box-shadow: 12px 0 40px rgba(0, 0, 0, .25); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: var(--stroke) solid var(--rule); min-height: var(--topbar); }
.sidebar-foot { flex-wrap: wrap; padding: 10px 12px; border-top: var(--stroke) solid var(--rule); display: flex; align-items: center; justify-content: space-between; gap: 8px; font-family: var(--font-mono); font-size: var(--fs-0); color: var(--ink-3); }
.scrim { position: fixed; inset: 0; z-index: 65; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity .25s; }
.scrim.is-open { opacity: 1; pointer-events: auto; }

.toc { flex: 1; overflow-y: auto; padding: 8px 0 16px; font-family: var(--font-ui); scrollbar-width: thin; }
.toc-part { padding: 10px 0 4px; }
.toc-part-name { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--ink-3); padding: 6px 16px 4px 18px; font-weight: 600; }
.toc-link { display: grid; grid-template-columns: 30px 1fr 16px; align-items: baseline; gap: 6px; padding: 6px 12px 6px 18px; text-decoration: none; color: var(--ink-2); font-size: .92rem; line-height: 1.3; border-left: 3px solid transparent; position: relative; }
.toc-link:hover { color: var(--ink); background: var(--paper-3); }
.toc-link.is-current { color: var(--ink); border-left-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.toc-num { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-3); }
.toc-link.is-current .toc-num { color: var(--accent-ink); }
.toc-link.is-done::after { content: ""; grid-column: 3; width: 9px; height: 5px; border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg) translateY(-2px); align-self: center; }

.main { display: block; min-width: 0; }
/* Narrow screens: one content column with 16px gutters. From 900px the text column
   is capped at --col and .wide elements may spill 140px each side. */
.chapter {
  display: grid;
  grid-template-columns: [full-start] var(--gutter) [wide-start col-start] minmax(0, 1fr) [col-end wide-end] var(--gutter) [full-end];
  padding: 2rem 0 3rem;
}
@media (min-width: 900px) {
  .chapter { grid-template-columns: [full-start] minmax(var(--gutter), 1fr) [wide-start] minmax(0, 140px) [col-start] minmax(0, var(--col)) [col-end] minmax(0, 140px) [wide-end] minmax(var(--gutter), 1fr) [full-end]; }
}
.chapter > * { grid-column: col; min-width: 0; }
.chapter > .wide { grid-column: wide; }
.chapter > .full { grid-column: full; }
.chapter > section, .chapter > .sec { display: contents; }
.chapter > section > *, .chapter > .sec > * { grid-column: col; min-width: 0; }
.chapter > section > .wide, .chapter > .sec > .wide { grid-column: wide; }
.chapter > section > .full, .chapter > .sec > .full { grid-column: full; }

@media (min-width: 1100px) {
  .topbar { display: none; }
  .layout { padding-top: 0; display: block; }
  .sidebar { transform: none; box-shadow: none; width: var(--sidebar); }
  .sidebar .close-btn { display: none; }
  .scrim { display: none; }
  .main { margin-left: var(--sidebar); }
  .chapter { padding: 3.5rem 0 4rem; }
}

/* ---------- 4. Chapter header, meta, footer ---------- */
.chapter-head { margin-bottom: 2rem; padding-bottom: 1.4rem; border-bottom: 2px solid var(--ink); }
.chapter-kicker { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .12em; font-weight: 600; font-size: .85rem; color: var(--accent-ink); margin: 0 0 .5rem; }
.chapter-title { font-size: var(--fs-5); font-weight: 700; letter-spacing: -.015em; line-height: 1.05; }
.chapter-stand { font-size: 1.15rem; color: var(--ink-2); margin: .9rem 0 0; max-width: 40em; text-wrap: pretty; }
.chapter-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 1rem; font-family: var(--font-mono); font-size: var(--fs-0); color: var(--ink-3); letter-spacing: .02em; }
.chapter-meta span::before { content: ""; display: inline-block; width: 6px; height: 6px; border: 1px solid currentColor; margin-right: 8px; vertical-align: 1px; }

.chapter-foot { margin: 2rem auto 0; max-width: var(--wide); padding: 0 var(--gutter) 3rem; }
.done { display: flex; justify-content: center; padding: 1.5rem 0 2rem; border-top: var(--stroke) solid var(--rule); }
.done-btn { display: inline-flex; align-items: center; gap: 10px; padding: 9px 16px; border: var(--stroke) solid var(--ink); background: var(--paper-2); border-radius: var(--r); cursor: pointer; font-family: var(--font-ui); font-weight: 600; font-size: var(--fs-1); }
.done-btn .box { width: 16px; height: 16px; border: 1.5px solid var(--ink); border-radius: 2px; position: relative; }
.done-btn[aria-pressed="true"] { border-color: var(--ok); color: var(--ok); }
.done-btn[aria-pressed="true"] .box { border-color: var(--ok); background: var(--ok); }
.done-btn[aria-pressed="true"] .box::after { content: ""; position: absolute; left: 3px; top: 1px; width: 5px; height: 9px; border-right: 2px solid #fff; border-bottom: 2px solid #fff; transform: rotate(45deg); }
.done-btn .when-on { display: none; }
.done-btn[aria-pressed="true"] .when-on { display: inline; }
.done-btn[aria-pressed="true"] .when-off { display: none; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 0 0 1.5rem; font-family: var(--font-ui); }
.pager a { text-decoration: none; border: var(--stroke) solid var(--rule); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 2px; background: var(--paper-2); color: var(--ink); }
.pager a:hover { border-color: var(--ink); }
.pager-next { text-align: right; }
.pager-dir { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--ink-3); }
.pager-num { font-family: var(--font-mono); font-size: var(--fs-0); color: var(--accent-ink); }
.pager-title { font-weight: 600; font-size: var(--fs-1); line-height: 1.3; }
.pager .is-empty { border: var(--stroke) dashed var(--rule-2); border-radius: var(--r); }
@media (max-width: 520px) { .pager { grid-template-columns: 1fr; } .pager .is-empty { display: none; } .pager-next { text-align: left; } }

.titleblock { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); border: var(--stroke) solid var(--ink); font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; color: var(--ink-2); }
.titleblock > div { padding: 6px 10px; border-right: var(--stroke) solid var(--rule); min-width: 0; }
.titleblock > div:last-child { border-right: 0; }
.titleblock b { display: block; color: var(--ink); font-weight: 700; letter-spacing: .04em; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 5. Text components ---------- */
.lead { font-size: 1.15rem; color: var(--ink-2); }
.duo { display: grid; grid-template-columns: 1fr; border: var(--stroke) solid var(--rule); border-radius: var(--r); margin: 1.4rem 0 1.8rem; overflow: hidden; background: var(--paper-2); }
.duo > div { padding: 14px 16px 6px; min-width: 0; }
.duo-real { border-bottom: var(--stroke) solid var(--rule); }
.duo-eli5 { background: var(--paper); }
.duo h4, .duo .duo-label { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 700; margin: 0 0 .5rem; color: var(--ink-3); display: flex; align-items: center; gap: 8px; }
.duo-eli5 h4, .duo-eli5 .duo-label { color: var(--accent-ink); }
.duo h4::before, .duo .duo-label::before { content: ""; width: 14px; height: 2px; background: currentColor; }
.duo p { font-size: var(--fs-1); }
.duo p:last-child { margin-bottom: .6rem; }
@media (min-width: 700px) {
  .duo { grid-template-columns: 1fr 1fr; }
  .duo-real { border-bottom: 0; border-right: var(--stroke) solid var(--rule); }
}

/* Term chips: dotted ink underline, Chinese inline after the first mention. */
.t { border-bottom: 1px dotted var(--ink-2); cursor: help; text-decoration: none; color: inherit; padding-bottom: 1px; }
.t:hover, .t.is-open { border-bottom-color: var(--accent); color: var(--accent-ink); }
.t-zh { font-family: var(--font-zh); font-size: .92em; color: var(--ink-2); margin-left: .35em; }
.t.is-open .t-zh, .t:hover .t-zh { color: var(--accent-ink); }
.zh-inline { font-family: var(--font-zh); color: var(--ink-2); font-size: .95em; }
.py { font-family: var(--font-mono); font-size: .8em; color: var(--ink-3); letter-spacing: .01em; }

.popover {
  position: absolute; z-index: 80; width: min(360px, calc(100vw - 2 * var(--gutter)));
  background: var(--paper-2); color: var(--ink); border: var(--stroke) solid var(--ink); border-radius: var(--r);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18); padding: 12px 14px 10px; font-family: var(--font-body); font-size: var(--fs-1); line-height: 1.5;
}
.popover[hidden] { display: none; }
.pop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; border-bottom: var(--stroke) solid var(--rule); padding-bottom: 6px; margin-bottom: 8px; }
.pop-term { font-family: var(--font-ui); font-weight: 700; font-size: 1rem; }
.pop-zh { font-family: var(--font-zh); text-align: right; line-height: 1.25; }
.pop-zh .py { display: block; }
.pop-row { display: grid; grid-template-columns: 38px 1fr; gap: 8px; margin: 0 0 6px; }
.pop-row .g-label { margin-top: 3px; }
.pop-foot { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); margin-top: 6px; }
.pop-foot a { color: var(--ink-2); }

/* Epistemic chips */
.chip { display: inline-block; font-family: var(--font-mono); font-size: .68rem; line-height: 1; letter-spacing: .04em; text-transform: uppercase; padding: 4px 6px 3px; border-radius: 2px; border: 1px solid var(--rule); color: var(--ink-2); vertical-align: .18em; white-space: nowrap; background: var(--paper-2); }
.chip.ver { border-color: var(--ok); color: var(--ok); }
.chip.est { border-style: dashed; border-color: var(--ink-3); }
.chip.deb { border-color: var(--accent); color: var(--accent-ink); }
.chip.chk { border-color: var(--bad); color: var(--bad); background: repeating-linear-gradient(135deg, transparent 0 3px, var(--rule-2) 3px 4px); }
.chip.ver::before { content: "\2713\00a0"; }
.chip.chk::before { content: "?\00a0"; }

/* Callouts */
.note { position: relative; margin: 1.5rem 0; padding: 12px 16px 6px 18px; border-left: 3px solid var(--ink); background: var(--paper-2); border-radius: 0 var(--r) var(--r) 0; font-size: var(--fs-1); }
.note > .note-label { display: block; font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 700; margin-bottom: .4rem; color: var(--ink-2); }
.note p:last-child { margin-bottom: .6rem; }
.note-key { border-left-color: var(--ink); }
.note-trap { border-left-color: var(--bad); }
.note-trap > .note-label { color: var(--bad); }
.note-founder { border-left-color: var(--accent); background: var(--accent-soft); }
.note-founder > .note-label { color: var(--accent-ink); }
.note-sz { border-left-color: var(--flow); background: var(--flow-soft); }
.note-sz > .note-label { color: var(--flow); }
.note-sz .say { display: grid; grid-template-columns: 1fr; gap: 2px 16px; margin: 0 0 .8rem; }
.note-sz .say .cn { font-family: var(--font-zh); font-size: 1.15rem; line-height: 1.4; }
.note-sz .say .py { display: block; }
.note-sz .say .en { color: var(--ink-2); }

/* Terms-in-this-chapter table */
.terms-table { margin: 1.5rem 0; border: var(--stroke) solid var(--rule); border-radius: var(--r); overflow: hidden; background: var(--paper-2); }
.terms-table table { width: 100%; border-collapse: collapse; font-size: var(--fs-1); }
.terms-table th { text-align: left; font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; color: var(--ink-3); padding: 8px 12px; border-bottom: var(--stroke) solid var(--ink); background: var(--paper-3); font-weight: 700; }
.terms-table td { padding: 10px 12px; border-bottom: var(--stroke) solid var(--rule-2); vertical-align: top; }
.terms-table tr:last-child td { border-bottom: 0; }
.terms-table td:first-child { font-family: var(--font-ui); font-weight: 600; white-space: nowrap; }
.terms-table .cn { font-family: var(--font-zh); font-size: 1rem; display: block; }
.terms-table .py { display: block; }
@media (max-width: 700px) {
  .terms-table thead { display: none; }
  .terms-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; padding: 10px 12px; border-bottom: var(--stroke) solid var(--rule-2); }
  .terms-table td { display: block; padding: 2px 0; border: 0; }
  .terms-table td:nth-child(3), .terms-table td:nth-child(4) { grid-column: 1 / -1; }
  .terms-table td:nth-child(n+3)::before { content: attr(data-label); font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .1em; font-size: .68rem; color: var(--ink-3); display: block; margin-top: 6px; }
  .terms-table td:first-child { white-space: normal; }
}

/* ---------- 6. Figures ---------- */
.fig { margin: 1.8rem 0 2rem; border: var(--stroke) solid var(--ink); border-radius: var(--r); overflow: hidden; background: var(--paper-2); }
.fig-title { display: flex; align-items: stretch; border-bottom: var(--stroke) solid var(--ink); font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .1em; font-size: .74rem; font-weight: 600; color: var(--ink-2); background: var(--paper-2); min-width: 0; }
.fig-title > span { padding: 6px 10px; border-right: var(--stroke) solid var(--rule); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fig-title > span:last-child { border-right: 0; }
.fig-title .fig-no { font-family: var(--font-mono); font-weight: 500; color: var(--accent-ink); letter-spacing: .04em; text-transform: none; flex: 0 0 auto; }
.fig-title .fig-name { color: var(--ink); font-weight: 700; flex: 1 0 auto; }
.fig-title .fig-view { color: var(--ink-3); flex: 0 1 auto; min-width: 0; }
@media (max-width: 480px) { .fig-title .fig-view { display: none; } .fig-title .fig-name { flex: 1 1 auto; min-width: 0; } }
.fig-body {
  position: relative; padding: 16px;
  background-color: var(--paper-2);
  background-image:
    linear-gradient(var(--grid-2) 1px, transparent 1px), linear-gradient(90deg, var(--grid-2) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px;
}
.fig-body.plain { background-image: none; }
.fig-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
/* --fig-min: below this width the drawing scrolls instead of shrinking (labels stay legible).
   --fig-max: about 1.3 times the viewBox width, so labels never balloon on wide screens. */
.fig-scroll > svg { min-width: var(--fig-min, 640px); width: 100%; max-width: var(--fig-max, none); margin: 0 auto; }
.fig-grid > svg { max-width: 440px; margin: 0 auto; }
.fig svg { color: var(--ink); font-family: var(--font-mono); }
.fig figcaption { padding: 10px 14px 12px; font-size: var(--fs-1); color: var(--ink-2); border-top: var(--stroke) solid var(--rule); background: var(--paper-2); }
.fig figcaption b, .fig figcaption strong { color: var(--ink); }
.fig-key { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 14px; border-top: var(--stroke) solid var(--rule-2); font-family: var(--font-ui); font-size: var(--fs-0); color: var(--ink-2); background: var(--paper-2); list-style: none; margin: 0; }
.fig-key li { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.fig-key .k { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border: 1px solid var(--ink); border-radius: 50%; font-family: var(--font-mono); font-size: .66rem; }
.fig-key .zh { color: var(--ink-3); }
.fig-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 12px; border-top: var(--stroke) solid var(--rule-2); background: var(--paper-2); font-family: var(--font-ui); font-size: var(--fs-0); }
.fig-controls .readout { margin-left: auto; font-family: var(--font-mono); color: var(--ink-2); }
.fig-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 700px) { .fig-grid { grid-template-columns: 1fr 1fr; } }
.icon-btn.is-on { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

/* SVG drawing classes. Strokes use currentColor so both themes work. */
.ink { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ink-fill { fill: var(--paper-2); stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.ink-fill-3 { fill: var(--paper-3); stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.thin { stroke: currentColor; fill: none; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }
.hair { stroke: currentColor; fill: none; stroke-width: .75; stroke-linecap: round; }
.hidden-line { stroke: currentColor; fill: none; stroke-width: 1; stroke-dasharray: 6 4; opacity: .7; }
.centre-line { stroke: currentColor; fill: none; stroke-width: .75; stroke-dasharray: 14 4 3 4; opacity: .7; }
.hatch { fill: url(#hatch); stroke: currentColor; stroke-width: 1.25; }
.hatch-acc { fill: url(#hatch-acc); stroke: var(--accent); stroke-width: 1.25; }
.acc { stroke: var(--accent); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.acc-fill { fill: var(--accent); stroke: none; }
.acc-text { fill: var(--accent-ink); }
.flow-line { stroke: var(--flow); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.flow-fill { fill: var(--flow); stroke: none; }
.flow-text { fill: var(--flow); }
.soft { fill: var(--paper-3); stroke: none; }
.far { opacity: .42; }
.lbl { font-family: var(--font-mono); font-size: 12px; font-weight: 500; fill: currentColor; stroke: none; }
.lbl-s { font-family: var(--font-mono); font-size: 11px; fill: var(--ink-2); stroke: none; }
.lbl-b { font-family: var(--font-cond); font-size: 14px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; fill: currentColor; stroke: none; }
.lbl-zh { font-family: var(--font-zh); font-size: 12px; fill: var(--ink-2); stroke: none; }
.lbl-num { font-family: var(--font-cond); font-size: 22px; font-weight: 700; fill: currentColor; stroke: none; }
.balloon circle { fill: var(--paper-2); stroke: currentColor; stroke-width: 1.25; }
.balloon text { font-family: var(--font-mono); font-size: 11px; font-weight: 500; fill: currentColor; text-anchor: middle; }
.balloon-acc circle { stroke: var(--accent); }
.balloon-acc text { fill: var(--accent-ink); }
.leader { stroke: currentColor; stroke-width: .75; fill: none; marker-end: url(#dot); }
.dim line, .dim path { stroke: currentColor; stroke-width: .75; fill: none; }
.dim .dim-line { marker-start: url(#dim); marker-end: url(#dim); }
.dim text { font-family: var(--font-mono); font-size: 11px; fill: currentColor; text-anchor: middle; }
.dot { fill: var(--flow); stroke: none; }
.dot-acc { fill: var(--accent); stroke: none; }
.dot-ink { fill: currentColor; stroke: none; }
.joint-mark { fill: var(--paper-2); stroke: var(--accent); stroke-width: 2; }
.joint-mark-in { fill: var(--accent); stroke: none; }
.gear-teeth { fill: var(--paper-3); stroke: currentColor; stroke-width: 1.25; stroke-linejoin: round; }
.gear-teeth.acc-part { fill: var(--accent-soft); stroke: var(--accent); }
.gear-teeth.ring-teeth, .gear-teeth.hd-circ { fill: var(--paper-3); }
.gear-teeth.hd-flex { fill: var(--paper-2); }
.gear-teeth.hd-mark { fill: var(--accent); stroke: var(--accent); }
.box-lbl { font-family: var(--font-ui); font-size: 13px; font-weight: 600; fill: currentColor; stroke: none; }
.box-sub { font-family: var(--font-mono); font-size: 10.5px; fill: var(--ink-3); stroke: none; }
.pulse { stroke-dasharray: 6 10; animation: dash 1.1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -16; } }

/* Animations play only while visible (primer.js adds .is-playing) and never under reduced motion. */
[data-anim] * { animation-play-state: paused; }
[data-anim].is-playing * { animation-play-state: running; }
html[data-motion="off"] [data-anim].is-playing * { animation: none !important; }
html[data-motion="off"] .pulse { animation: none; stroke-dasharray: none; }

/* Reveal on scroll (only when JS is running) */
html.js .reveal:not(.is-in) { opacity: 0; transform: translateY(10px); }
html.js .reveal { transition: opacity .6s var(--ease), transform .6s var(--ease); }
html[data-motion="off"].js .reveal:not(.is-in) { opacity: 1; transform: none; }

/* ---------- 7. Data components ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 1.4rem 0 1.8rem; }
.stat { border: var(--stroke) solid var(--rule); border-radius: var(--r); padding: 12px 14px 10px; background: var(--paper-2); display: grid; gap: 2px; align-content: start; position: relative; }
.stat::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; background: var(--accent); }
.stat-n { font-family: var(--font-cond); font-weight: 700; font-size: 2rem; line-height: 1; letter-spacing: -.01em; }
.stat-n small { font-size: .5em; font-weight: 600; color: var(--ink-2); margin-left: 2px; letter-spacing: 0; }
.stat-l { font-family: var(--font-ui); font-size: var(--fs-1); color: var(--ink-2); line-height: 1.3; }
.stat-src { font-family: var(--font-mono); font-size: .68rem; color: var(--ink-3); margin-top: 6px; }

.spec { margin: 1.5rem 0; border: var(--stroke) solid var(--ink); border-radius: var(--r); overflow: hidden; background: var(--paper-2); }
.spec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 12px; border-bottom: var(--stroke) solid var(--ink); background: var(--paper-3); font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .1em; font-size: .74rem; color: var(--ink-2); }
.spec-head b { color: var(--ink); font-size: 1rem; letter-spacing: .04em; }
.spec-head .asof { margin-left: auto; font-family: var(--font-mono); text-transform: none; letter-spacing: 0; color: var(--ink-3); }
.spec dl { display: grid; grid-template-columns: minmax(110px, 36%) 1fr; margin: 0; font-size: var(--fs-1); }
.spec dt { padding: 8px 12px; border-bottom: var(--stroke) solid var(--rule-2); font-family: var(--font-ui); color: var(--ink-2); font-weight: 500; }
.spec dd { padding: 8px 12px; margin: 0; border-bottom: var(--stroke) solid var(--rule-2); border-left: var(--stroke) solid var(--rule-2); font-family: var(--font-ui); }
.spec dt:nth-last-of-type(1), .spec dd:last-of-type { border-bottom: 0; }
@media (min-width: 700px) { .spec.two dl { grid-template-columns: minmax(110px, 22%) 1fr minmax(110px, 22%) 1fr; } }

.table-scroll { overflow-x: auto; margin: 1.4rem 0 1.8rem; border: var(--stroke) solid var(--rule); border-radius: var(--r); background: var(--paper-2); scrollbar-width: thin; }
.cmp { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: var(--fs-1); min-width: 560px; }
.cmp th, .cmp td { padding: 9px 12px; border-bottom: var(--stroke) solid var(--rule-2); text-align: left; vertical-align: top; }
.cmp thead th { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .1em; font-size: .72rem; color: var(--ink-3); background: var(--paper-3); border-bottom: var(--stroke) solid var(--ink); font-weight: 700; position: sticky; top: 0; }
.cmp tbody th { font-weight: 600; position: sticky; left: 0; background: var(--paper-2); border-right: var(--stroke) solid var(--rule-2); }
.cmp tr:last-child td, .cmp tr:last-child th { border-bottom: 0; }
.cmp td.n { text-align: right; font-family: var(--font-mono); font-size: .84rem; }
.cmp td.good { color: var(--ok); font-weight: 600; }
.cmp td.bad { color: var(--bad); font-weight: 600; }
.cmp .bar { display: inline-block; height: 8px; background: var(--accent); vertical-align: middle; margin-right: 6px; border-radius: 1px; }

/* ---------- 8. Sequence components: steps, timeline, tabs, accordion, exam ---------- */
.steps { margin: 1.6rem 0 2rem; border: var(--stroke) solid var(--rule); border-radius: var(--r); background: var(--paper-2); overflow: hidden; }
.steps > .fig { margin: 0; border: 0; border-bottom: var(--stroke) solid var(--rule); border-radius: 0; }
.steps-controls { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: var(--stroke) solid var(--rule-2); font-family: var(--font-ui); font-size: var(--fs-0); flex-wrap: wrap; }
.steps-controls .icon-btn { height: 32px; min-width: 32px; }
.steps-controls input[type="range"] { flex: 1 1 120px; min-width: 100px; accent-color: var(--accent); }
.steps-controls .steps-pos { font-family: var(--font-mono); color: var(--ink-2); min-width: 4ch; text-align: right; }
.steps-list { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.step { display: grid; grid-template-columns: 34px 1fr; grid-template-areas: "n title" "n body"; gap: 0 12px; padding: 10px 14px; border-bottom: var(--stroke) solid var(--rule-2); cursor: pointer; font-size: var(--fs-1); margin: 0; }
.step:last-child { border-bottom: 0; }
.step::before { grid-area: n; counter-increment: step; content: counter(step, decimal-leading-zero); font-family: var(--font-mono); font-size: .8rem; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 50%; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; margin-top: 1px; background: var(--paper-2); }
.step.is-current { background: var(--accent-soft); }
.step.is-current::before { border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.step b { grid-area: title; font-family: var(--font-ui); display: block; }
.step p { grid-area: body; margin: 2px 0 0; color: var(--ink-2); }
[data-steps] [data-on] { transition: opacity .35s var(--ease); }
[data-steps] [data-on]:not(.is-on) { opacity: .28; }

.timeline { list-style: none; margin: 1.6rem 0 2rem; padding: 0 0 0 22px; border-left: 2px solid var(--ink); position: relative; }
.timeline li { position: relative; padding: 0 0 1.2rem 8px; margin: 0; }
.timeline li::before { content: ""; position: absolute; left: -29px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink); }
.timeline li.acc::before { background: var(--accent); border-color: var(--accent); }
.timeline time { display: block; font-family: var(--font-mono); font-size: var(--fs-0); color: var(--accent-ink); letter-spacing: .02em; }
.timeline b { font-family: var(--font-ui); }
.timeline p { margin: 2px 0 0; color: var(--ink-2); font-size: var(--fs-1); }

.tabs { margin: 1.6rem 0 2rem; border: var(--stroke) solid var(--rule); border-radius: var(--r); background: var(--paper-2); overflow: hidden; }
.tablist { display: flex; overflow-x: auto; border-bottom: var(--stroke) solid var(--ink); background: var(--paper-3); scrollbar-width: none; }
.tab { flex: 0 0 auto; padding: 10px 14px; border: 0; background: none; cursor: pointer; font-family: var(--font-ui); font-weight: 600; font-size: var(--fs-1); color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); background: var(--paper-2); }
.tab-panel { padding: 14px 16px 4px; font-size: var(--fs-1); }
.tab-panel[hidden] { display: none; }
html:not(.js) .tab-panel { display: block !important; border-top: var(--stroke) solid var(--rule-2); }

details.acc { border: var(--stroke) solid var(--rule); border-radius: var(--r); margin: 0 0 8px; background: var(--paper-2); }
details.acc summary { cursor: pointer; padding: 10px 14px; font-family: var(--font-ui); font-weight: 600; font-size: var(--fs-1); list-style: none; display: flex; align-items: center; gap: 10px; }
details.acc summary::-webkit-details-marker { display: none; }
details.acc summary::before { content: ""; width: 8px; height: 8px; border-right: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); transform: rotate(-45deg); transition: transform .2s; flex: 0 0 auto; }
details.acc[open] summary::before { transform: rotate(45deg); }
details.acc[open] summary { border-bottom: var(--stroke) solid var(--rule-2); }
details.acc .acc-body { padding: 10px 14px 4px; font-size: var(--fs-1); }
details.acc.sources summary { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .1em; font-size: .74rem; color: var(--ink-2); }
details.acc.sources ol { font-size: var(--fs-0); color: var(--ink-2); padding-left: 1.4rem; }
details.acc.sources a { word-break: break-all; }

.exam { border: var(--stroke) solid var(--ink); border-radius: var(--r); margin: 0 0 12px; background: var(--paper-2); }
.exam summary { cursor: pointer; padding: 12px 14px 12px 52px; position: relative; font-family: var(--font-ui); font-weight: 600; list-style: none; line-height: 1.35; }
.exam summary::-webkit-details-marker { display: none; }
.exam summary::before { content: "Q" attr(data-q); position: absolute; left: 12px; top: 12px; font-family: var(--font-mono); font-size: .72rem; color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 2px; padding: 2px 5px; line-height: 1; }
.exam summary .exam-hint { display: block; font-weight: 400; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; }
.exam[open] summary .exam-hint { display: none; }
.exam-answer { padding: 4px 14px 6px 52px; border-top: var(--stroke) solid var(--rule-2); font-size: var(--fs-1); }
.exam-answer .g-label { margin-right: 6px; }
.exam-tools { display: flex; gap: 8px; margin: 0 0 12px; }

/* ---------- 9. Robot selector cards ---------- */
.robots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 1.4rem 0 2rem; list-style: none; padding: 0; }
.robot-card { border: var(--stroke) solid var(--rule); border-radius: var(--r); background: var(--paper-2); text-decoration: none; color: var(--ink); display: grid; grid-template-rows: auto 1fr; overflow: hidden; margin: 0; }
.robot-card:hover { border-color: var(--ink); color: var(--ink); }
.robot-card .robot-art { height: 150px; display: grid; place-items: center; padding: 10px; border-bottom: var(--stroke) solid var(--rule-2); background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 12px 12px; }
.robot-card .robot-art svg { height: 100%; width: auto; color: var(--ink); }
.robot-card .robot-body { padding: 8px 10px 10px; display: grid; gap: 2px; font-family: var(--font-ui); }
.robot-card .robot-name { font-weight: 700; font-size: var(--fs-1); line-height: 1.2; }
.robot-card .robot-maker { font-size: .78rem; color: var(--ink-2); }
.robot-card .robot-meta { font-family: var(--font-mono); font-size: .68rem; color: var(--ink-3); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 2px 8px; }
.robot-card .robot-class { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .1em; font-size: .66rem; color: var(--accent-ink); }

/* ---------- 10. Chapter cards (cover reading path) ---------- */
.parts { display: grid; gap: 1.6rem; margin: 1.5rem 0 2.5rem; }
.part-head { display: flex; align-items: baseline; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 10px; font-family: var(--font-ui); }
.part-head .part-num { font-family: var(--font-cond); font-weight: 700; font-size: 1.6rem; color: var(--accent-ink); line-height: 1; }
.part-head h3 { margin: 0; font-size: var(--fs-3); }
.part-head .part-time { margin-left: auto; font-family: var(--font-mono); font-size: var(--fs-0); color: var(--ink-3); white-space: nowrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; list-style: none; padding: 0; margin: 0; }
.card { display: grid; grid-template-rows: auto 1fr auto; gap: 6px; padding: 12px 14px 10px; border: var(--stroke) solid var(--rule); border-radius: var(--r); background: var(--paper-2); text-decoration: none; color: var(--ink); min-height: 132px; position: relative; font-family: var(--font-ui); }
.card:hover { border-color: var(--ink); color: var(--ink); }
.card .card-num { font-family: var(--font-mono); font-size: var(--fs-0); color: var(--accent-ink); letter-spacing: .04em; }
.card .card-title { font-weight: 700; font-size: 1.02rem; line-height: 1.2; }
.card .card-desc { font-family: var(--font-body); font-size: var(--fs-0); color: var(--ink-2); line-height: 1.45; }
.card .card-foot { font-family: var(--font-mono); font-size: .68rem; color: var(--ink-3); display: flex; justify-content: space-between; margin-top: 4px; }
.card.is-done::after { content: ""; position: absolute; right: 12px; top: 14px; width: 10px; height: 5px; border-left: 2px solid var(--ok); border-bottom: 2px solid var(--ok); transform: rotate(-45deg); }

/* ---------- 11. Cover ---------- */
.pg-index .chapter { padding-top: 1.5rem; }
.hero { display: grid; gap: 1.5rem; align-items: center; margin-bottom: 2rem; }
.hero-copy { display: grid; gap: 1rem; align-content: center; }
.hero-title { font-size: var(--fs-6); font-weight: 700; line-height: .98; letter-spacing: -.025em; }
.hero-title .acc-word { color: var(--accent-ink); }
.hero-stand { font-size: 1.15rem; color: var(--ink-2); max-width: 34em; text-wrap: pretty; margin: 0; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-family: var(--font-ui); }
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: var(--r); border: var(--stroke) solid var(--ink); background: var(--ink); color: var(--paper); text-decoration: none; font-weight: 600; font-family: var(--font-ui); font-size: var(--fs-1); }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--paper-3); color: var(--ink); }
.hero-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--font-mono); font-size: var(--fs-0); color: var(--ink-3); margin: 0; padding: 0; list-style: none; }
.hero .fig { margin: 0; }
.hero .fig-body { padding: 12px 10px; }
@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 4fr) minmax(0, 6fr); gap: 2.5rem; }
}

/* ---------- 12. Glossary and Shenzhen sheet ---------- */
.gloss-tools { position: sticky; top: var(--topbar); z-index: 20; background: var(--paper); padding: 10px 0 8px; border-bottom: var(--stroke) solid var(--rule); margin-bottom: 8px; display: grid; gap: 8px; font-family: var(--font-ui); }
@media (min-width: 1100px) { .gloss-tools { top: 0; } }
.gloss-search input { width: 100%; padding: 10px 12px; border: var(--stroke) solid var(--ink); border-radius: var(--r); background: var(--paper-2); color: var(--ink); font: inherit; font-family: var(--font-ui); font-size: 1rem; }
.gloss-sz { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-1); }
.gloss-sz input { accent-color: var(--accent); width: 16px; height: 16px; }
.gloss-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.gloss-filter { padding: 5px 10px; border: var(--stroke) solid var(--rule); border-radius: 999px; background: var(--paper-2); cursor: pointer; font-family: var(--font-ui); font-size: .8rem; color: var(--ink-2); }
.gloss-filter.is-on { border-color: var(--ink); background: var(--ink); color: var(--paper); }
.gloss-count { font-family: var(--font-mono); font-size: var(--fs-0); color: var(--ink-3); margin: 0; }
.gloss-list { display: grid; gap: 8px; }
.gloss-row { display: grid; grid-template-columns: 1fr; gap: 4px 16px; padding: 12px 14px; border: var(--stroke) solid var(--rule); border-radius: var(--r); background: var(--paper-2); scroll-margin-top: 140px; }
.gloss-row[hidden] { display: none; }
.gloss-row:target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.g-term { font-family: var(--font-ui); font-size: 1.05rem; margin: 0; font-weight: 700; }
.g-zh { font-family: var(--font-zh); line-height: 1.3; }
.g-zh:empty { display: none; }
.g-zh-cn { font-size: 1.1rem; margin-right: 8px; }
.g-py { font-family: var(--font-mono); font-size: .8rem; color: var(--ink-3); }
.g-eli5, .g-def { margin: 0; font-size: var(--fs-1); display: grid; grid-template-columns: 38px 1fr; gap: 8px; }
.g-label { display: inline-block; font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .1em; font-size: .66rem; font-weight: 700; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 2px; padding: 2px 4px 1px; line-height: 1; height: fit-content; margin-top: 4px; text-align: center; }
.g-eli5 .g-label { color: var(--accent-ink); border-color: var(--accent); }
.g-where { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); text-decoration: none; justify-self: start; }
.g-where:hover { color: var(--accent-ink); }
@media (min-width: 760px) {
  .gloss-row { grid-template-columns: 200px 1fr auto; grid-template-areas: "term eli5 where" "zh def where"; align-items: start; }
  .g-term { grid-area: term; }
  .g-zh { grid-area: zh; }
  .g-eli5 { grid-area: eli5; }
  .g-def { grid-area: def; }
  .g-where { grid-area: where; }
}

.sz-sheet { columns: 1; column-gap: 24px; margin: 1.5rem 0 2rem; }
.sz-group { break-inside: avoid; border: var(--stroke) solid var(--ink); border-radius: var(--r); margin: 0 0 14px; background: var(--paper-2); overflow: hidden; }
.sz-group h3 { margin: 0; padding: 6px 12px; font-family: var(--font-cond); text-transform: uppercase; letter-spacing: .12em; font-size: .74rem; background: var(--paper-3); border-bottom: var(--stroke) solid var(--ink); color: var(--ink-2); }
.sz-group dl { margin: 0; }
.sz-item { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 7px 12px; border-bottom: var(--stroke) solid var(--rule-2); font-size: var(--fs-1); align-items: baseline; }
.sz-item:last-child { border-bottom: 0; }
.sz-item dt { font-family: var(--font-ui); font-weight: 500; }
.sz-item dd { margin: 0; text-align: right; }
.sz-cn { font-family: var(--font-zh); font-size: 1.05rem; display: block; }
.sz-py { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-3); display: block; }
@media (min-width: 700px) { .sz-sheet { columns: 2; } }

/* ---------- 13. Print: the Shenzhen cheat sheet on paper ---------- */
@media print {
  :root { --paper: #fff; --paper-2: #fff; --paper-3: #f2f2f2; --ink: #000; --ink-2: #222; --ink-3: #555; --rule: #999; --rule-2: #ccc; --accent: #d4550f; --accent-ink: #b7460a; }
  html { font-size: 11pt; }
  body { background: #fff; color: #000; }
  .topbar, .sidebar, .scrim, .progress, .done, .pager, .popover, .fig-controls, .steps-controls, .gloss-tools, .skip, .theme-btn, .hero-cta, .no-print { display: none !important; }
  .layout { padding: 0; }
  .main { margin: 0; }
  .chapter { display: block; padding: 0; }
  .chapter > * { max-width: none; }
  .sz-sheet { columns: 2; column-gap: 8mm; }
  .sz-group { border-color: #000; page-break-inside: avoid; }
  .sz-item { padding: 3px 8px; border-bottom-color: #ccc; }
  .fig { page-break-inside: avoid; }
  .fig-body { background-image: none; }
  a { text-decoration: none; color: #000; }
  .titleblock { margin-top: 8mm; }
  details.acc, details.exam { border-color: #000; }
  details.acc:not([open]) .acc-body, .exam:not([open]) .exam-answer { display: none; }
}

/* Full-screen figures and phone hints */
.fig-title { position: relative; }
.fig-expand { margin-left: auto; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 34px; border: 0; border-left: var(--stroke) solid var(--rule); background: transparent; color: var(--ink-2); cursor: pointer; padding: 0; }
.fig-expand svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.fig-expand:hover, .fig-expand:focus-visible { color: var(--accent-ink); background: var(--accent-soft); }
.fig-hint { display: none; margin: 0; padding: 6px 14px; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); background: var(--paper-2); border-top: var(--stroke) solid var(--rule); }
.fig.is-scrollable .fig-hint { display: block; }
.fig-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; background: var(--paper); }
.fig-overlay[hidden] { display: none; }
.fig-overlay-bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: var(--stroke) solid var(--rule); }
.fig-overlay-hint { flex: 1; font-family: var(--font-mono); font-size: .75rem; color: var(--ink-3); }
.fig-overlay-body { flex: 1; overflow: auto; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.fig-overlay .fig { margin: 0; min-height: 100%; }
.fig-overlay .fig-expand { display: none; }
.fig-overlay .fig-hint { display: none !important; }
.fig-overlay .fig-scroll { overflow: visible; }
.fig-overlay .fig-scroll > svg, .fig-overlay .fig-body > svg { min-width: 0; max-width: none; width: 100%; height: auto; max-height: calc(100dvh - 120px); }
@media (orientation: landscape) { .fig-overlay-hint { visibility: hidden; } }
html.fig-open, html.fig-open body { overflow: hidden; }

/* Offline status */
.offline-status { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); }
.offline-status.is-complete { color: var(--ok); }
.sidebar-foot .offline-status { display: block; width: 100%; margin-bottom: 6px; }
.offline-card { margin: 2rem 0; padding: 16px 18px; border: var(--stroke) solid var(--ink); border-radius: var(--r); background: var(--paper-2); }
.offline-card h2 { margin-top: 0; }
.offline-card ol { margin: .6rem 0 .8rem; }
.offline-card .offline-status { font-size: .85rem; }
@media (orientation: landscape) and (max-height: 520px) {
  .fig-overlay-bar { position: absolute; top: 0; right: 0; z-index: 2; border: 0; padding: 6px; background: transparent; }
  .fig-overlay-body { padding: 4px; }
  .fig-overlay .fig > .fig-title { display: none; }
  .fig-overlay .fig-scroll > svg, .fig-overlay .fig-body > svg { max-height: calc(100dvh - 24px); }
}

/* Animations switch */
.motion-btn { width: auto; padding: 0 10px; font-family: var(--font-mono); font-size: .72rem; color: var(--ink-2); }
.motion-note { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 1.2rem; padding: 10px 14px; border: var(--stroke) solid var(--accent); border-radius: var(--r); background: var(--accent-soft); font-family: var(--font-ui); font-size: var(--fs-1); color: var(--ink); }
.motion-note p { margin: 0; flex: 1 1 220px; }
.motion-note button { font: inherit; font-weight: 600; padding: 6px 12px; border-radius: var(--r); border: var(--stroke) solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; }
.motion-note button.ghost { background: transparent; color: var(--ink); }

/* ---------- Isometric drawings ----------
   Solids drawn by tools/iso with the anatomy kit (vendored in tools/iso/kit). The class
   rules follow the kit's iso.css at skill commit e6600ff; the colours are the primer's own
   tokens, so a drawing follows the light, dark and public themes. Each face leans from
   --paper-2 toward --ink by one of five steps. By day the top is bare paper and the sides
   darken; at night ink is the light colour, so the order flips and the top is brightest.
   The motor steps do the same toward --accent. */
:root {
  --iso-top: 0%; --iso-s3: 3%; --iso-s2: 6%; --iso-s1: 9.5%; --iso-s0: 14%;
  --iso-lit-top: 5%; --iso-lit-s3: 12%; --iso-lit-s2: 18%; --iso-lit-s1: 25%; --iso-lit-s0: 33%;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --iso-top: 9%; --iso-s3: 6.5%; --iso-s2: 4.5%; --iso-s1: 2.5%; --iso-s0: 0%;
    --iso-lit-top: 36%; --iso-lit-s3: 28%; --iso-lit-s2: 22%; --iso-lit-s1: 16%; --iso-lit-s0: 11%;
  }
}
:root[data-theme="dark"] {
  --iso-top: 9%; --iso-s3: 6.5%; --iso-s2: 4.5%; --iso-s1: 2.5%; --iso-s0: 0%;
  --iso-lit-top: 36%; --iso-lit-s3: 28%; --iso-lit-s2: 22%; --iso-lit-s1: 16%; --iso-lit-s0: 11%;
}
.iso-svg {
  --anatomy-paper: var(--paper-2);
  --anatomy-top: color-mix(in srgb, var(--ink) var(--iso-top), var(--paper-2));
  --anatomy-shade-3: color-mix(in srgb, var(--ink) var(--iso-s3), var(--paper-2));
  --anatomy-shade-2: color-mix(in srgb, var(--ink) var(--iso-s2), var(--paper-2));
  --anatomy-shade-1: color-mix(in srgb, var(--ink) var(--iso-s1), var(--paper-2));
  --anatomy-shade-0: color-mix(in srgb, var(--ink) var(--iso-s0), var(--paper-2));
  --anatomy-lit: var(--accent);
  --anatomy-lit-top: color-mix(in srgb, var(--accent) var(--iso-lit-top), var(--paper-2));
  --anatomy-lit-3: color-mix(in srgb, var(--accent) var(--iso-lit-s3), var(--paper-2));
  --anatomy-lit-2: color-mix(in srgb, var(--accent) var(--iso-lit-s2), var(--paper-2));
  --anatomy-lit-1: color-mix(in srgb, var(--accent) var(--iso-lit-s1), var(--paper-2));
  --anatomy-lit-0: color-mix(in srgb, var(--accent) var(--iso-lit-s0), var(--paper-2));
  --anatomy-hi: var(--ink);
  --anatomy-mid: color-mix(in srgb, var(--ink-2) 70%, var(--paper-2));
  --anatomy-lo: color-mix(in srgb, var(--ink-3) 60%, var(--paper-2));
  --anatomy-faint: var(--rule);
  --anatomy-dot: var(--ink);
  --anatomy-halo: var(--scrim);
  display: block; overflow: visible;
}
.iso-svg path, .iso-svg circle { vector-effect: non-scaling-stroke; }
.iso-fill { fill: var(--anatomy-paper); stroke: none; }
.iso-shade, .iso-top { stroke: none; }
.iso-top { fill: var(--anatomy-top); }
.iso-shade[data-shade="0"] { fill: var(--anatomy-shade-0); }
.iso-shade[data-shade="1"] { fill: var(--anatomy-shade-1); }
.iso-shade[data-shade="2"] { fill: var(--anatomy-shade-2); }
.iso-shade[data-shade="3"] { fill: var(--anatomy-shade-3); }
/* The kit gives a lit solid one flat shade. A motor is the subject here, so it keeps four. */
.iso-solid[data-lit] > .iso-fill, .iso-solid[data-lit] > .iso-top { fill: var(--anatomy-lit-top); }
.iso-solid[data-lit] > .iso-shade[data-shade="0"] { fill: var(--anatomy-lit-0); }
.iso-solid[data-lit] > .iso-shade[data-shade="1"] { fill: var(--anatomy-lit-1); }
.iso-solid[data-lit] > .iso-shade[data-shade="2"] { fill: var(--anatomy-lit-2); }
.iso-solid[data-lit] > .iso-shade[data-shade="3"] { fill: var(--anatomy-lit-3); }
/* Smooth-shaded solids are many abutting sheets: each strokes itself in its own fill to close the hairline seams. */
.iso-solid[data-seamless] > .iso-shade, .iso-solid[data-seamless] > .iso-top { stroke: currentColor; stroke-width: .4; stroke-linejoin: round; }
.iso-solid[data-seamless] > .iso-top { color: var(--anatomy-top); }
.iso-solid[data-seamless] > .iso-shade[data-shade="0"] { color: var(--anatomy-shade-0); }
.iso-solid[data-seamless] > .iso-shade[data-shade="1"] { color: var(--anatomy-shade-1); }
.iso-solid[data-seamless] > .iso-shade[data-shade="2"] { color: var(--anatomy-shade-2); }
.iso-solid[data-seamless] > .iso-shade[data-shade="3"] { color: var(--anatomy-shade-3); }
.iso-solid[data-seamless][data-lit] > .iso-top { color: var(--anatomy-lit-top); }
.iso-solid[data-seamless][data-lit] > .iso-shade[data-shade="0"] { color: var(--anatomy-lit-0); }
.iso-solid[data-seamless][data-lit] > .iso-shade[data-shade="1"] { color: var(--anatomy-lit-1); }
.iso-solid[data-seamless][data-lit] > .iso-shade[data-shade="2"] { color: var(--anatomy-lit-2); }
.iso-solid[data-seamless][data-lit] > .iso-shade[data-shade="3"] { color: var(--anatomy-lit-3); }
.iso-halo { fill: var(--anatomy-halo); stroke: none; filter: blur(9px); opacity: .5; transform: translateY(3px); }
.iso-line { fill: none; stroke: var(--anatomy-lo); stroke-width: .6px; stroke-linecap: round; stroke-linejoin: round; }
.iso-line[data-tone="hi"] { stroke: var(--anatomy-hi); }
.iso-line[data-tone="mid"] { stroke: var(--anatomy-mid); }
.iso-line[data-tone="faint"] { stroke: var(--anatomy-faint); }
.iso-solid[data-lit] > .iso-edge, .iso-solid[data-lit] > .iso-crease, .iso-line[data-tone="lit"] { stroke: var(--anatomy-lit); }
.iso-dots circle { fill: var(--anatomy-dot); stroke: none; opacity: .32; }
.iso-dots[data-tone="hi"] circle { opacity: .85; }
.iso-dots[data-tone="mid"] circle { opacity: .45; }
.iso-dots[data-tone="lo"] circle { opacity: .22; }
@media print { .iso-halo { display: none; } }
