/* Kayavak library: one stylesheet for every page.
   A reading room: running text in Atkinson Hyperlegible Next (a typeface designed for legibility), headings, labels and
   code in k3nme Rounded, both served from this site; warm paper, one accent per volume, a single comfortable column,
   and quiet chrome. Readers can change theme, text size, line width, line spacing and the reading font (the Aa menu,
   library.js); those choices are data attributes on <html>, read here.
   Each volume may set its own --accent, --accent-soft and --sel (light and dark) in a small <style> on its pages. */

@font-face { font-family: "k3nme Rounded"; src: url("fonts/k3nme-rounded.woff2") format("woff2");
  font-weight: 100 800; font-style: normal; font-display: swap; }
@font-face { font-family: "k3nme Rounded"; src: url("fonts/k3nme-rounded-italic.woff2") format("woff2");
  font-weight: 100 800; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("fonts/atkinson-hyperlegible-next-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("fonts/atkinson-hyperlegible-next-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 200 800; font-style: normal; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("fonts/atkinson-hyperlegible-next-latin-wght-italic.woff2") format("woff2");
  font-weight: 200 800; font-style: italic; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Atkinson Hyperlegible Next"; src: url("fonts/atkinson-hyperlegible-next-latin-ext-wght-italic.woff2") format("woff2");
  font-weight: 200 800; font-style: italic; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --font: "k3nme Rounded", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --read: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;   /* running text */
  --display: var(--font); --body: var(--read); --mono: var(--font);
  --paper: #f6f4ef; --panel: #fcfbf8; --sunk: #efece5; --ink: #23221f; --muted: #67635b; --faint: #6e695f; --rule: #e2ddd3;
  --accent: #2f43c9; --accent-soft: #e7eafb; --sel: #c9d1ff;
  --done: #29774c; --done-soft: #e2f1e7; --warn: #a3501d; --warn-soft: #f8ebe0;
  --code-bg: #efece5; --shadow: 0 1px 2px rgba(40, 35, 25, .06), 0 8px 24px rgba(40, 35, 25, .06);
  --s-kw: #8a2a9c; --s-ty: #1d63a8; --s-str: #2a782a; --s-com: #6e695f; --s-num: #ae4c17; --s-fn: #2f43c9; --s-pp: #906000;
  /* reader settings (library.js sets data-size, data-width, data-leading on <html>) */
  --fs: 18px; --measure: 66ch; --leading: 1.68;
  --bar-h: 52px;
  color-scheme: light;
}
:root[data-size="s"] { --fs: 16px; } :root[data-size="l"] { --fs: 19.5px; } :root[data-size="xl"] { --fs: 21px; }
:root[data-font="rounded"] { --read: var(--font); --body: var(--font); --leading: 1.75; }
:root[data-font="rounded"] body { font-size: calc(var(--fs) * .89); }
:root[data-width="narrow"] { --measure: 58ch; } :root[data-width="wide"] { --measure: 82ch; }
:root[data-leading="tight"] { --leading: 1.6; } :root[data-leading="loose"] { --leading: 1.95; }
:root[data-theme="sepia"] {
  --paper: #f1e8d6; --panel: #f7f0e2; --sunk: #e9dec8; --ink: #3a2f22; --muted: #6e5e4a; --faint: #705f49; --rule: #ddcfb6;
  --code-bg: #eadfc9; --done-soft: #e3ead2; --warn-soft: #f3e1cc; --s-com: #6e5f49; --done: #25703f; --accent: #2f43c9; --s-str: #227022; --s-num: #a5430e; --s-pp: #875700; --warn: #9c4916; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="sepia"]) {
  --paper: #151513; --panel: #1c1c19; --sunk: #232320; --ink: #e9e5dc; --muted: #aaa497; --faint: #908b80; --rule: #2f2e2a;
  --accent: #93a2ff; --accent-soft: #1c2246; --done: #6fcf9a; --done-soft: #15301f; --warn: #f0a26b; --warn-soft: #3a2415;
  --code-bg: #20201d; --sel: #2c3570; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  --s-kw: #d59bf0; --s-ty: #7cb8f2; --s-str: #a3d68f; --s-com: #908b80; --s-num: #f0a46b; --s-fn: #a9b5ff; --s-pp: #e3c06b;
  color-scheme: dark; } }
:root[data-theme="dark"] {
  --paper: #151513; --panel: #1c1c19; --sunk: #232320; --ink: #e9e5dc; --muted: #aaa497; --faint: #908b80; --rule: #2f2e2a;
  --accent: #93a2ff; --accent-soft: #1c2246; --done: #6fcf9a; --done-soft: #15301f; --warn: #f0a26b; --warn-soft: #3a2415;
  --code-bg: #20201d; --sel: #2c3570; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  --s-kw: #d59bf0; --s-ty: #7cb8f2; --s-str: #a3d68f; --s-com: #908b80; --s-num: #f0a46b; --s-fn: #a9b5ff; --s-pp: #e3c06b;
  color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + var(--bar-h) + 20px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--read); font-size: var(--fs); line-height: var(--leading);
  font-weight: 400; font-variant-ligatures: contextual; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: var(--sel); }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
b, strong { font-weight: 700; }
/* Headings, labels, navigation and code keep the rounded face; running text reads in --read. */
h1, h2, h3, h4, .bar, .rail, .outline, .lbl, .crumbs, .ch-code, .eyebrow, .chip, .tick, .code, .co-t, .qn, .pager a, .card, .book .c,
.book h3, .tb, .act, .btn, kbd, code, pre, .palette, .pop, .lab, .tool, .ex-l, .ex-tag, .ex-reveal > summary, .tw th, .contents .n, .contents .m,
.session-mark, .session-plan, .se-t, .resume span, .facts b, .trail-card .q, .tmeta, .bmeta, .upd, .toast, .stat, .levels b, .how-steps b { font-family: var(--font); }
i, em { font-style: italic; }
button { font-family: inherit; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: var(--paper); }
.skip { position: absolute; left: 12px; top: -60px; z-index: 40; padding: 8px 12px; background: var(--ink); color: var(--paper); border-radius: 8px; }
.skip:focus { top: 8px; }

/* ---- top bar ---- */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--rule);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.bar-in { display: flex; align-items: center; gap: 10px; height: var(--bar-h); }
.brand { font-weight: 750; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; color: var(--ink); text-decoration: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-weight: 450; font-size: 11px; color: var(--faint); letter-spacing: .06em; margin-left: 10px; text-transform: uppercase; }
.brand:hover { color: var(--accent); }
.home-link { color: var(--faint); text-decoration: none; font-weight: 600; font-size: 13px; padding: 4px 8px 4px 0; border-right: 1px solid var(--rule); margin-right: 2px; white-space: nowrap; }
.home-link:hover { color: var(--accent); }
.menu-btn, .icon-btn { display: none; font: 550 12.5px var(--font); background: transparent; color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; padding: 6px 10px; cursor: pointer; white-space: nowrap; }
.icon-btn { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn:hover, .menu-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn kbd { font: 500 10.5px var(--font); color: var(--faint); border: 1px solid var(--rule); border-radius: 4px; padding: 0 4px; }
.tools-r { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.overall { flex: none; white-space: nowrap; display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meter { width: 110px; height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--done); transition: width .3s; }
.sync { font-size: 11px; color: var(--faint); }
.readbar { position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: var(--accent); transition: width .1s linear; pointer-events: none; }

/* reader settings and search popovers */
.pop { position: fixed; z-index: 35; top: calc(env(safe-area-inset-top, 0px) + var(--bar-h) + 8px); right: max(12px, env(safe-area-inset-right, 0px));
  width: min(340px, calc(100vw - 24px)); background: var(--panel); color: var(--ink); border: 1px solid var(--rule); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px 16px; }
.pop h2 { font-size: 11px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin: 12px 0 6px; }
.pop h2:first-child { margin-top: 0; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--sunk); border-radius: 10px; padding: 3px; }
.seg button { font: 550 12.5px var(--font); color: var(--muted); background: transparent; border: 0; border-radius: 8px; padding: 7px 4px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.seg button .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; border: 1px solid var(--rule); }
.pop .keys { margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.8; }
.pop kbd, .palette kbd { font: 500 11px var(--font); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--paper); color: var(--ink); }
.scrim { position: fixed; inset: 0; z-index: 34; background: rgba(20, 18, 14, .32); }
.palette { position: fixed; z-index: 36; left: 50%; top: max(9vh, calc(env(safe-area-inset-top, 0px) + 16px)); transform: translateX(-50%); width: min(640px, calc(100vw - 24px));
  background: var(--panel); border: 1px solid var(--rule); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; max-height: 78vh; }
.palette input { font: 450 16px var(--font); color: var(--ink); background: transparent; border: 0; border-bottom: 1px solid var(--rule); padding: 16px 18px; outline: none; width: 100%; }
.palette ul { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.palette li a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; }
.palette li a .t { font-weight: 550; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette li a .w { grid-column: 1; font-size: 11.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette li a .k { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.palette li a mark { background: transparent; color: var(--accent); font-weight: 700; }
.palette li[aria-selected="true"] a { background: var(--accent-soft); }
.palette .foot { display: flex; gap: 14px; flex-wrap: wrap; padding: 9px 16px; border-top: 1px solid var(--rule); font-size: 11.5px; color: var(--faint); }
.palette .empty { padding: 18px; color: var(--muted); font-size: 14px; }

/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 288px minmax(0, 1fr); }
.rail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + var(--bar-h) + 1px); height: calc(100vh - var(--bar-h) - 1px - env(safe-area-inset-top, 0px)); overflow-y: auto;
  border-right: 1px solid var(--rule); padding: 22px 12px 48px max(16px, env(safe-area-inset-left, 0px)); background: var(--paper); scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
.rail .lbl, .lbl { font-size: 10.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin: 0 0 8px 8px; }
.rail ol { list-style: none; margin: 0 0 26px; padding: 0; display: grid; gap: 1px; }
.rail a { position: relative; display: grid; grid-template-columns: 46px 1fr auto; gap: 6px; align-items: baseline; padding: 6px 8px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 13px; line-height: 1.4; font-weight: 450; }
.rail a .n { font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.rail a .p { font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.rail a .p.full { color: var(--done); }
.rail a:hover { background: var(--sunk); color: var(--ink); }
.rail a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.rail a[aria-current="page"]::before { content: ""; position: absolute; left: -2px; top: 7px; bottom: 7px; width: 3px; border-radius: 2px; background: var(--accent); }
.rail a[aria-current="page"] .n { color: var(--accent); }
main { min-width: 0; padding-left: max(20px, env(safe-area-inset-left, 0px)); padding-right: max(20px, env(safe-area-inset-right, 0px)); padding-block: 0 96px; }

/* ---- home and volume pages ---- */
.home { max-width: 1040px; margin: 0 auto; padding-top: 44px; }
.cover { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 36px; align-items: end; padding-bottom: 30px; border-bottom: 1px solid var(--rule); }
.cover .vol { font-size: 11.5px; font-weight: 650; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
.cover h1 { font-weight: 780; font-size: clamp(32px, 5.2vw, 56px); line-height: 1.04; letter-spacing: -0.035em; margin: 0; text-wrap: balance; }
.cover p.lede { margin: 18px 0 0; color: var(--muted); max-width: 60ch; font-size: .95em; }
.stat { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; }
.stat div { padding: 16px; border-right: 1px solid var(--rule); }
.stat div:last-child { border-right: 0; }
.stat b { display: block; font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat span { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; }
.home h2 { font-size: 13px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin: 48px 0 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card { display: grid; grid-template-rows: auto auto 1fr auto; gap: 8px; padding: 18px 18px 16px; background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; color: var(--ink); text-decoration: none;
  transition: border-color .15s, transform .15s, box-shadow .15s; }
.card:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--rule)); transform: translateY(-1px); box-shadow: var(--shadow); }
.card .c { font-size: 11px; font-weight: 600; color: var(--accent); letter-spacing: .06em; text-transform: uppercase; }
.card h3 { margin: 0; font-size: 16.5px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.6; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.card .row { display: flex; align-items: center; gap: 10px; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; margin-top: 4px; }
.card .row .meter { flex: 1; width: auto; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.levels div { padding: 14px 16px; background: var(--panel); border: 1px solid var(--rule); border-radius: 12px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.levels b { display: block; font-size: 12px; font-weight: 650; color: var(--accent); margin-bottom: 2px; }
.howto { max-width: 76ch; color: var(--muted); font-size: .95em; }
.howto li { margin-bottom: 8px; }
.howto b { color: var(--ink); }
.langs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { font-size: 11.5px; padding: 3px 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--panel); color: var(--muted); }
.resume { display: flex; align-items: center; gap: 14px; margin: 28px 0 0; padding: 14px 18px; background: var(--accent-soft); border-radius: 14px; color: var(--ink); text-decoration: none; }
.resume span { font-size: 10.5px; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); white-space: nowrap; }
.resume b { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resume small { color: var(--muted); margin-left: auto; white-space: nowrap; font-size: 12px; }
.resume:hover b { text-decoration: underline; }

/* ---- chapter ---- */
.ch-wrap { display: grid; grid-template-columns: minmax(0, 1fr); justify-content: center; }
.ch-inner { max-width: min(100%, calc(var(--measure) + 120px)); margin: 0 auto; padding-top: 40px; }
.ch-head { padding-bottom: 26px; border-bottom: 1px solid var(--rule); margin-bottom: 34px; }
.ch-code { font-size: 12px; font-weight: 650; color: var(--accent); letter-spacing: .14em; margin: 0 0 10px; text-transform: uppercase; }
.ch-head h1 { font-weight: 780; font-size: clamp(30px, 4.6vw, 46px); line-height: 1.08; letter-spacing: -0.035em; margin: 0; text-wrap: balance; }
.ch-blurb { color: var(--muted); margin: 16px 0 0; font-size: .95em; max-width: var(--measure); }
.ch-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 16px; font-size: 11.5px; color: var(--faint); }
.ch-prog { color: var(--done); font-weight: 650; }
.ch-toc { margin-top: 22px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--rule); border-radius: 14px; }
.ch-toc .lbl { margin-left: 0; }
.ch-toc ol { margin: 0; padding-left: 22px; columns: 2 250px; column-gap: 30px; font-size: 13px; line-height: 1.6; }
.ch-toc li { break-inside: avoid; margin-bottom: 4px; color: var(--faint); }
.ch-toc a { color: var(--ink); text-decoration: none; }
.ch-toc a:hover { color: var(--accent); text-decoration: underline; }
.crumbs { font-size: 11.5px; color: var(--faint); margin: 0 0 18px; letter-spacing: .02em; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* "On this page": beside the column on wide screens */
.outline { display: none; }
@media (min-width: 1360px) {
  body.has-outline .ch-inner, body[data-page="volume"] .ch-inner { margin: 0 auto 0 max(24px, calc((100% - var(--measure) - 260px) / 2)); }
  .outline { display: block; position: fixed; top: calc(env(safe-area-inset-top, 0px) + var(--bar-h) + 40px); right: max(24px, env(safe-area-inset-right, 0px)); width: 220px;
    max-height: calc(100vh - var(--bar-h) - 80px); overflow-y: auto; font-size: 12px; line-height: 1.45; scrollbar-width: thin; }
  .outline .lbl { margin-left: 12px; }
  .outline ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
  .outline a { display: block; padding: 5px 0 5px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--faint); text-decoration: none; }
  .outline a:hover { color: var(--ink); }
  .outline a.on { color: var(--ink); border-left-color: var(--accent); font-weight: 600; }
  body.lab-on .outline { display: none; }
}

.prose { max-width: var(--measure); }
.prose > * { min-width: 0; }
.prose p { margin: 0 0 1.05em; }
.prose h2.sec { font-size: 1.55em; font-weight: 760; line-height: 1.2; letter-spacing: -0.03em; margin: 2.6em 0 .7em; padding-top: 1.1em; border-top: 1px solid var(--rule); text-wrap: balance; }
.prose h2.sec:first-child { margin-top: 0; border-top: 0; padding-top: 0; }
.prose h2.has-tick, .prose h3.topic { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.prose h3.topic { font-size: 1.15em; font-weight: 700; line-height: 1.35; margin: 2.1em 0 .6em; letter-spacing: -0.015em; }
.prose h3 .tt, .prose h2 .tt { flex: 1 1 auto; min-width: 0; }
.prose h4 { font-size: 1em; font-weight: 700; margin: 1.6em 0 .4em; }
.tick { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); cursor: pointer;
  padding: 3px 9px 3px 7px; border: 1px solid var(--rule); border-radius: 999px; background: var(--panel); user-select: none; white-space: nowrap; line-height: 1.6; }
.tick input { accent-color: var(--done); width: 14px; height: 14px; margin: 0; cursor: pointer; }
.tick:hover { border-color: var(--done); color: var(--done); }
.tick:has(input:checked) { color: var(--done); border-color: var(--done); background: var(--done-soft); }
.prose p, .prose li { hyphens: auto; overflow-wrap: break-word; }
.prose code { font-size: .9em; background: var(--code-bg); padding: .1em .4em; border-radius: 5px; overflow-wrap: anywhere; }
.prose pre code { background: none; padding: 0; font-size: 13px; }
.prose blockquote { margin: 1.4em 0; padding: 2px 20px; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }
.prose ul, .prose ol { padding-left: 1.6em; margin: 0 0 1.05em; }
.prose li { margin-bottom: .35em; }
.prose li::marker { color: var(--faint); }

.code { margin: 1.5em 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--code-bg); overflow: hidden; }
.code-h { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--rule); padding: 0 6px 0 14px; min-height: 36px; font-size: 10.5px; font-weight: 600; color: var(--faint); letter-spacing: .08em; }
.code-h > span { text-transform: uppercase; }
.tablist { display: flex; flex-wrap: wrap; gap: 2px; padding-block: 4px; flex: 1; min-width: 0; }
.tablist button { font: 600 11.5px var(--font); background: transparent; color: var(--muted); border: 0; border-radius: 7px; padding: 5px 9px; cursor: pointer; }
.tablist button:hover { color: var(--ink); }
.tablist button[aria-selected="true"] { background: var(--panel); color: var(--accent); box-shadow: 0 0 0 1px var(--rule); }
.copy { margin-left: auto; font: 500 11px var(--font); background: transparent; border: 0; color: var(--faint); cursor: pointer; padding: 6px 8px; border-radius: 6px; }
.copy:hover { color: var(--accent); background: var(--panel); }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; font: 13px/1.65 var(--font); tab-size: 4; scrollbar-width: thin; }
.t-k, .t-kd, .t-kn, .t-kr, .t-kc, .t-ow { color: var(--s-kw); }
.t-kt, .t-nc, .t-nn, .t-bp { color: var(--s-ty); }
.t-s, .t-s1, .t-s2, .t-sc, .t-sa, .t-se, .t-sb, .t-sd, .t-sh, .t-si { color: var(--s-str); }
.t-c, .t-c1, .t-cm, .t-cs, .t-ch { color: var(--s-com); font-style: italic; }
.t-cp, .t-cpf, .t-nd, .t-nl { color: var(--s-pp); }
.t-m, .t-mi, .t-mf, .t-mh, .t-mb, .t-mo, .t-il { color: var(--s-num); }
.t-nf, .t-fm, .t-nb { color: var(--s-fn); }
.t-gp { color: var(--faint); user-select: none; }
.t-err { color: inherit; background: none; }

.co { margin: 1.6em 0; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--rule); background: var(--panel); font-size: .95em; }
.co > :last-child { margin-bottom: 0; }
.co > p:first-of-type:not(.co-t) { margin-top: 0; }
.co-t { margin: 0 0 6px !important; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.co-note { border-left: 3px solid var(--accent); } .co-note .co-t { color: var(--accent); }
.co-tip { background: var(--done-soft); border-color: transparent; } .co-tip .co-t { color: var(--done); }
.co-warn { background: var(--warn-soft); border-color: transparent; } .co-warn .co-t { color: var(--warn); }
.co-deep { border-style: dashed; } .co-deep .co-t { color: var(--muted); }
.co-rule { border-left: 3px solid var(--ink); } .co-rule .co-t { color: var(--ink); }
/* blocks for every subject (tools/book): definitions, laws, worked examples, practicals, applications */
.co-definition, .co-theorem, .co-formula { border-left: 3px solid var(--accent); background: var(--accent-soft); border-color: transparent; }
.co-definition .co-t, .co-theorem .co-t, .co-formula .co-t { color: var(--accent); }
.co-formula p:not(.co-t) { font-family: var(--mono); font-size: .95em; }
.co-worked { border-left: 3px solid var(--done); } .co-worked .co-t { color: var(--done); }
.co-practical { border: 1.5px solid var(--rule); background: var(--panel); } .co-practical .co-t { color: var(--ink); }
.co-safety { background: var(--warn-soft); border-color: transparent; } .co-safety .co-t { color: var(--warn); }
.co-applied { border-left: 3px solid var(--done); background: var(--done-soft); border-color: transparent; } .co-applied .co-t { color: var(--done); }
.co-source, .co-history, .co-vocab { border-style: dashed; } .co-source .co-t, .co-history .co-t, .co-vocab .co-t { color: var(--muted); }
.reveal { margin: .8em 0; border: 1px solid var(--rule); border-radius: 10px; padding: 0 14px; background: var(--paper); }
.reveal > summary { cursor: pointer; padding: 10px 0; font: 650 .9em var(--font); color: var(--accent); }
.reveal[open] { padding-bottom: 8px; }

.tw { overflow-x: auto; margin: 1.5em 0; border: 1px solid var(--rule); border-radius: 12px; background: var(--panel); scrollbar-width: thin; }
.tw table { border-collapse: collapse; width: 100%; font-size: .85em; line-height: 1.55; }
.tw th, .tw td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.tw th { font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); background: var(--sunk); white-space: nowrap; }
.tw tr:last-child td { border-bottom: 0; }
.tw td code { white-space: nowrap; }

.fig { margin: 1.8em 0; padding: 18px; border: 1px solid var(--rule); border-radius: 12px; background: var(--panel); overflow-x: auto; }
.fig svg { display: block; width: 100%; min-width: 540px; height: auto; margin: 0 auto; }
.fig figcaption { margin-top: 12px; font-size: 12px; line-height: 1.55; color: var(--muted); }
.dg { font-family: var(--font); font-size: 12px; }
.dg text { fill: var(--ink); }
.dg .m { fill: var(--muted); }
.dg .ac { fill: var(--accent); }
.dg .b { fill: var(--panel); stroke: var(--muted); stroke-width: 1.2; }
.dg .a { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.2; }
.dg .g { fill: var(--done-soft); stroke: var(--done); stroke-width: 1.2; }
.dg .w { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 1.2; }
.dg .ln { stroke: var(--muted); stroke-width: 1.3; fill: none; }
.dg .la { stroke: var(--accent); stroke-width: 1.5; fill: none; }
.dg .lw { stroke: var(--warn); stroke-width: 1.5; fill: none; }
.dg .dash { stroke-dasharray: 4 3; }
.ah { fill: var(--muted); } .ah-a { fill: var(--accent); } .ah-w { fill: var(--warn); }


/* ---- quiz ---- */
.quiz { margin-top: 72px; padding: 26px; background: var(--panel); border: 1px solid var(--rule); border-radius: 16px; max-width: var(--measure); }
.quiz h2 { font-size: 1.4em; font-weight: 760; margin: 0 0 4px; letter-spacing: -0.025em; }
.quiz .sub { margin: 0 0 18px; color: var(--muted); font-size: .88em; }
.qq { padding: 20px 0; border-top: 1px solid var(--rule); }
.qq .qn { font-size: 10.5px; font-weight: 650; color: var(--faint); letter-spacing: .12em; margin-bottom: 6px; }
.qq .qt { font-weight: 600; margin: 0 0 12px; }
.qq .qt code { font-size: .88em; background: var(--code-bg); padding: 1px 5px; border-radius: 4px; }
.opts { display: grid; gap: 7px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 10px 13px; font: 400 .92em/1.55 var(--font); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; cursor: pointer; transition: border-color .12s; }
.opt .l { font-weight: 650; font-size: 12px; line-height: 1.95; color: var(--faint); flex: none; }
.opt code { font-size: .88em; }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt:disabled { cursor: default; }
.opt.right { border-color: var(--done); background: var(--done-soft); }
.opt.wrong { border-color: var(--warn); background: var(--warn-soft); }
.why { margin: 12px 0 0; font-size: .9em; color: var(--muted); padding-left: 14px; border-left: 2px solid var(--rule); }
.why b { color: var(--ink); }
.qfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); }
.qfoot b { color: var(--ink); font-size: 16px; }
.btn { font: 600 12.5px var(--font); padding: 8px 14px; border-radius: 9px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--panel); border-color: var(--accent); }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 48px; max-width: var(--measure); }
.pager a { display: block; padding: 16px 18px; border: 1px solid var(--rule); border-radius: 14px; background: var(--panel); color: var(--ink); text-decoration: none; font-weight: 650; font-size: 14px; line-height: 1.35; transition: border-color .15s; }
.pager a span { display: block; font-size: 10.5px; font-weight: 500; color: var(--faint); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .1em; }
.pager a:hover { border-color: var(--accent); }
.pager .next { text-align: right; grid-column: 2; }
.to-top { position: fixed; z-index: 15; right: max(18px, env(safe-area-inset-right, 0px)); bottom: max(18px, env(safe-area-inset-bottom, 0px)); width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--panel); color: var(--muted); box-shadow: var(--shadow); cursor: pointer; font: 600 16px var(--font); opacity: 0; pointer-events: none; transition: opacity .2s; }
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { color: var(--accent); border-color: var(--accent); }
body.lab-on .to-top { display: none; }

.site-foot { max-width: 1040px; margin: 72px auto 0; padding: 20px 0 0; border-top: 1px solid var(--rule); font-size: 11.5px; line-height: 1.7; color: var(--faint); }
.site-foot a { color: var(--muted); }

/* library home */
.lib { max-width: 1040px; margin: 0 auto; padding: 56px max(20px, env(safe-area-inset-left, 0px)) 96px; }
.lib .cover { grid-template-columns: minmax(0, 1fr); border-bottom: 0; padding-bottom: 8px; }
.lib .cover h1 { font-size: clamp(34px, 6vw, 64px); max-width: 16ch; }
.shelf { margin-top: 48px; }
.shelf h2 { font-size: 22px; font-weight: 760; margin: 0 0 6px; letter-spacing: -0.02em; color: var(--ink); text-transform: none; }
.shelf > p { margin: 0 0 18px; color: var(--muted); max-width: 72ch; font-size: .9em; }
.card .c b { font-weight: 650; }

/* exercise blocks: answer box, then hints, then solution */
.ex-answer { margin: 12px 0 8px; }
.ex-answer label { display: block; font-size: 10.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); margin-bottom: 6px; }
.ex-answer textarea { width: 100%; min-height: 90px; padding: 11px 13px; font: 400 .92em/1.6 var(--font); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 10px; resize: vertical; }
.ex-answer textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ex-reveal { margin: 8px 0 0; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper); }
.ex-reveal > summary { cursor: pointer; padding: 9px 13px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); list-style: none; }
.ex-reveal > summary::-webkit-details-marker { display: none; }
.ex-reveal > summary::before { content: "▸ "; }
.ex-reveal[open] > summary::before { content: "▾ "; }
.ex-reveal > :not(summary) { margin: 0; padding: 0 13px 13px; }
.ex-hint > summary { color: var(--muted); }

.chapter { display: block; }

/* ---- the Lab: whiteboard and chapter tools beside the chapter ---- */
.lab-open { flex: none; font: 600 12.5px var(--font); background: var(--accent); color: var(--panel); border: 1px solid var(--accent); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.lab-open:hover { filter: brightness(1.08); }
.lab-open[aria-expanded="true"] { background: transparent; color: var(--accent); }
.lab { position: fixed; z-index: 24; top: calc(env(safe-area-inset-top, 0px) + var(--bar-h) + 1px); right: 0; bottom: 0; width: min(760px, 50vw);
  display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--rule); box-shadow: -12px 0 32px rgba(0,0,0,.07); }
body.lab-on .shell { margin-right: min(760px, 50vw); grid-template-columns: minmax(0, 1fr); }
body.lab-on .shell .rail { display: none; }
.lab-head { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--rule); }
.lab-tabs { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; min-width: 0; }
.lab-tabs button { font: 600 12px var(--font); background: transparent; color: var(--muted); border: 0; border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.lab-tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
.lab-close { font: 16px var(--font); background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 6px 10px; border-radius: 8px; }
.lab-close:hover { color: var(--accent); background: var(--accent-soft); }
.lab-body { flex: 1; min-height: 0; position: relative; }
.lab-pane { position: absolute; inset: 0; overflow: auto; }
.lab-pane.board { overflow: hidden; display: flex; flex-direction: column; }
.board-host { flex: 1; min-height: 0; padding: 12px; font-size: 13px; color: var(--muted); }
.board-host .excalidraw { --zIndex-modal: 30; }
.lab-note { margin: 0; padding: 0 12px; min-height: 0; font-size: 12px; color: var(--warn); }
.lab-note:not(:empty) { padding: 8px 12px; background: var(--warn-soft); }
/* tools */
.tool { padding: 16px 18px 40px; font-size: 15px; line-height: 1.55; }
.tool h3 { font-weight: 700; font-size: 17px; margin: 0 0 4px; }
.tool .hint { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
.tool label { display: inline-flex; flex-direction: column; gap: 4px; font: 600 11px var(--font); letter-spacing: .06em; text-transform: uppercase; color: var(--faint); margin: 0 10px 10px 0; }
.tool input, .tool select, .tool textarea { font: 14px var(--font); color: var(--ink); background: var(--paper); border: 1px solid var(--rule); border-radius: 6px; padding: 7px 9px; text-transform: none; letter-spacing: 0; }
.tool textarea { width: 100%; min-height: 70px; }
.tool input:focus, .tool select:focus, .tool textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tool .row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 4px; }
.tool .out { margin-top: 12px; overflow-x: auto; }
.tool table { border-collapse: collapse; font: 13px var(--font); margin: 8px 0; }
.tool th, .tool td { border: 1px solid var(--rule); padding: 4px 8px; text-align: left; vertical-align: top; }
.tool th { background: var(--code-bg); color: var(--muted); font-weight: 600; }
.tool .mono { font-family: var(--font); }
.tool .ok { color: var(--done); } .tool .bad { color: var(--warn); }
.tool .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.tool .chip { font: 12px var(--font); }
.tool .chip.hit { background: var(--done-soft); color: var(--done); border-color: var(--done); }
.tool .chip.miss { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.tool .stat { display: inline-block; margin: 6px 16px 0 0; font: 13px var(--font); color: var(--muted); }
.tool .stat b { color: var(--ink); font-size: 16px; }
.tool .bars { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding: 8px; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; }
.tool .bars i { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; position: relative; }
.tool .bars i.cmp { background: var(--warn); } .tool .bars i.done { background: var(--done); }
.tool .gantt { display: flex; margin: 8px 0; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; font: 12px var(--font); }
.tool .gantt span { padding: 8px 4px; text-align: center; border-right: 1px solid var(--rule); white-space: nowrap; overflow: hidden; }
.tool .tree { font: 13px/1.5 var(--font); white-space: pre; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 12px; }
.tool .bucket { display: flex; gap: 6px; align-items: center; font: 13px var(--font); padding: 3px 0; border-bottom: 1px dashed var(--rule); }
.tool .bucket b { width: 34px; color: var(--faint); font-weight: 600; }


/* Exercise gates (practice volumes): your answer first, then hints, then the solution. */
li.todo { list-style: none; margin-left: -1.2em; } li.todo::before { content: "☐"; display: inline-block; width: 1.4em; color: var(--faint); }
li.todo.done::before { content: "☑"; }
.ex { margin: 16px 0 30px; padding: 16px 18px; border: 1px solid var(--rule); border-radius: 14px; background: var(--panel); }
.ex-l { display: block; font-size: 12.5px; font-weight: 650; margin-bottom: 8px; } .ex-l span { font-weight: 400; color: var(--faint); }
.ex textarea { width: 100%; box-sizing: border-box; min-height: 130px; padding: 12px; border: 1px solid var(--rule); border-radius: 10px; font: 400 .92em/1.6 var(--font); background: var(--paper); color: var(--ink); resize: vertical; }
.ex textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.ex-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 10px; }
.ex-msg { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--faint); flex: 1 1 240px; }
.ex-btn, .ex-rate button { font: 600 12.5px var(--font); padding: 8px 13px; min-height: 34px; border-radius: 9px; border: 1px solid var(--accent); background: var(--accent); color: var(--panel); cursor: pointer; }
.ex-btn:disabled { background: transparent; color: var(--faint); border-color: var(--rule); cursor: not-allowed; }
.ex-open { margin-top: 16px; padding: 14px 16px; border-radius: 10px; border: 1px dashed var(--rule); }
.ex-solution { border-style: solid; border-color: var(--accent); }
.ex-tag { margin: 0 0 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.ex-rate { margin-top: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12.5px; }
.ex-rate button { background: transparent; color: var(--accent); }
.ex-rate button[aria-pressed="true"] { background: var(--accent); color: var(--panel); }

/* ---- small screens ---- */

/* ---- the library's doors: Learn, Practice, Cheatsheets ---- */
.topnav { display: flex; gap: 2px; margin-right: 6px; }
.topnav a { font-size: 12.5px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; border: 1px solid transparent; }
.topnav a:hover { color: var(--ink); background: var(--sunk); }
.topnav a[aria-current] { color: var(--ink); background: var(--panel); border-color: var(--rule); box-shadow: 0 2px 0 var(--rule); }

/* ---- tactile buttons: a solid edge underneath that presses in ---- */
.tb { font: 650 13px var(--font); display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 10px; cursor: pointer;
  border: 1.5px solid color-mix(in srgb, var(--ink) 70%, transparent); background: var(--panel); color: var(--ink); box-shadow: 0 3px 0 color-mix(in srgb, var(--ink) 70%, transparent);
  transition: transform .06s, box-shadow .06s; white-space: nowrap; }
.tb:hover:not(:disabled) { background: var(--sunk); }
.tb:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 70%, transparent); }
.tb:disabled { opacity: .45; cursor: default; box-shadow: none; border-color: var(--rule); }
.tb.primary { background: var(--done-soft); }
.tb.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--done-soft) 70%, var(--done) 30%); }
.pager a, .btn { box-shadow: 0 2px 0 var(--rule); }
.pager a:active, .btn:active { transform: translateY(1px); box-shadow: none; }

/* ---- chapter header: chips and the Scroll / Steps switch ---- */
.ch-meta { align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--ink);
  border: 1.5px solid color-mix(in srgb, var(--ink) 55%, transparent); background: var(--panel); line-height: 1.5; white-space: nowrap; }
.chip.c-time { background: var(--warn-soft); } .chip.c-topics { background: var(--done-soft); } .chip.c-quiz { background: var(--accent-soft); }
/* ---- diagrams full screen ---- */
.zoomable { position: relative; }
.zoom-btn { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--rule); background: var(--panel); color: var(--muted);
  font: 600 15px var(--font); cursor: pointer; opacity: .55; transition: opacity .15s; box-shadow: 0 2px 0 var(--rule); }
.zoomable:hover .zoom-btn, .zoom-btn:focus-visible { opacity: 1; }
.zoom-btn:hover { color: var(--accent); border-color: var(--accent); }
body.lb-on { overflow: hidden; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: var(--paper); display: flex; flex-direction: column; }
.lb-bar { display: flex; align-items: center; gap: 8px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--rule); }
.lb-t { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-bar button { font: 650 12.5px var(--font); padding: 6px 11px; border-radius: 9px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); cursor: pointer; box-shadow: 0 2px 0 var(--rule); }
.lb-bar button kbd { font: 500 10px var(--font); color: var(--faint); }
.lb-stage { flex: 1; overflow: hidden; cursor: grab; touch-action: none;
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 14%, transparent) 1px, transparent 1px); background-size: 22px 22px; }
.lb-stage:active { cursor: grabbing; }
.lb-pan { width: 100%; height: 100%; display: grid; place-items: center; transform-origin: 0 0; padding: 4vh 4vw; }
.lb-svg { width: min(100%, 1200px); height: auto; max-height: 100%; }


/* ---- cheatsheets ---- */
.sheets { max-width: 1100px; margin: 0 auto; padding: 36px max(16px, env(safe-area-inset-right, 0px)) 60px max(16px, env(safe-area-inset-left, 0px)); }
.sheets .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.sheet-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.sheet { background: var(--panel); border: 1.5px solid color-mix(in srgb, var(--ink) 45%, transparent); border-radius: 16px; padding: 16px 18px; box-shadow: 0 3px 0 color-mix(in srgb, var(--ink) 30%, transparent); font-size: 13px; line-height: 1.55; break-inside: avoid; }
.sheet h2 { font-size: 15px; margin: 0 0 4px; letter-spacing: -0.01em; }
.sheet h2 a { color: var(--ink); text-decoration: none; } .sheet h2 a:hover { color: var(--accent); }
.sheet .num { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; color: var(--accent); text-transform: uppercase; }
.sheet h3 { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
.sheet ul, .sheet ol { padding-left: 18px; margin: 0; } .sheet li { margin: 0 0 4px; }
.sheet p { margin: 0 0 8px; }
.sheet .tw { overflow-x: auto; } .sheet table { font-size: 12px; }
.sheet-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 18px 0 24px; }
.sheet-tools input { font: 500 13px var(--font); padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--rule); background: var(--panel); color: var(--ink); min-width: 240px; flex: 1; max-width: 420px; }
@media print { .sheet-tools, .bar { display: none !important; } .sheet-list { display: block; } .sheet { box-shadow: none; margin-bottom: 12px; } }


/* ===================================================================================================================
   The library's own pages (tools/site_pages.py): the front door, Shelves, Trails, Workbench, Recaps, Desk, About.
   They share one column and one header so that the same things are always in the same places.
   =================================================================================================================== */
.page { max-width: 1080px; margin: 0 auto; padding: 44px max(20px, env(safe-area-inset-right, 0px)) 96px max(20px, env(safe-area-inset-left, 0px)); }
.page-head { padding-bottom: 28px; border-bottom: 1px solid var(--rule); margin-bottom: 8px; max-width: 820px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
.page-head h1, .hero h1 { font-weight: 780; font-size: clamp(32px, 5vw, 52px); line-height: 1.06; letter-spacing: -0.035em; margin: 0; text-wrap: balance; }
.lede { color: var(--muted); font-size: 1.05em; line-height: 1.6; margin: 16px 0 0; max-width: 62ch; }
.page-head .chips { margin: 18px 0 0; }
.sect { margin-top: 56px; }
.sect > h2, .vol-h { font-size: 24px; font-weight: 760; letter-spacing: -0.02em; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; max-width: 70ch; }
.more { margin: 18px 0 0; font-weight: 650; }
.more a, .sub a, .lede a { color: var(--accent); }

/* front door */
.hero { padding: 28px 0 8px; max-width: 900px; }
.hero h1 { font-size: clamp(36px, 6.2vw, 68px); max-width: 17ch; }
.hero .lede { font-size: 1.12em; max-width: 60ch; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0 0; }
.facts { list-style: none; display: flex; flex-wrap: wrap; gap: 10px 28px; padding: 22px 0 0; margin: 30px 0 0; border-top: 1px solid var(--rule); color: var(--muted); font-size: .92em; }
.facts b { color: var(--ink); font-size: 1.25em; margin-right: 4px; }
.continue-slot:empty { display: none; }
.trail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.trail-card { display: flex; flex-direction: column; gap: 10px; padding: 20px 20px 18px; border-radius: 16px; background: var(--panel); color: var(--ink); text-decoration: none;
  border: 1.5px solid color-mix(in srgb, var(--ink) 40%, transparent); box-shadow: 0 3px 0 color-mix(in srgb, var(--ink) 30%, transparent); transition: transform .12s, box-shadow .12s; }
.trail-card:hover { transform: translateY(-2px); box-shadow: 0 5px 0 color-mix(in srgb, var(--ink) 35%, transparent); }
.trail-card:active { transform: translateY(1px); box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 35%, transparent); }
.trail-card .q { font-size: 18px; font-weight: 750; line-height: 1.3; letter-spacing: -0.01em; }
.trail-card .q::before { content: "“"; color: var(--accent); }
.trail-card .q::after { content: "”"; color: var(--accent); }
.trail-card .for { color: var(--muted); font-size: .9em; line-height: 1.5; }
.tmeta, .bmeta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--faint); margin-top: auto; }
.tgo { font-weight: 700; font-size: .9em; color: var(--accent); }
.tprog { color: var(--done); }
.how-steps { list-style: none; counter-reset: hs; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; padding: 0; margin: 0; }
.how-steps li { counter-increment: hs; padding: 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--rule); }
.how-steps li::before { content: counter(hs); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 700 13px var(--font); margin-bottom: 10px; }
.how-steps b { display: block; font-size: 15px; margin-bottom: 4px; }
.how-steps span { color: var(--muted); font-size: .9em; line-height: 1.55; }
.subject { padding: 22px; border-radius: 16px; background: var(--panel); border: 1px solid var(--rule); }
.subject h3 { margin: 0 0 6px; font-size: 20px; }
.subject p { margin: 0 0 10px; color: var(--muted); }
.smeta { font-size: 12px; color: var(--faint) !important; }
.titles { columns: 3 220px; column-gap: 24px; padding: 0; margin: 8px 0 18px; list-style: none; font-size: .92em; }
.titles li { break-inside: avoid; padding: 3px 0; }
.titles a { color: var(--ink); text-decoration: none; } .titles a:hover { color: var(--accent); text-decoration: underline; }
.trust-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.trust-grid > div { padding: 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--rule); }
.trust-grid h3 { margin: 0 0 6px; font-size: 15px; }
.trust-grid p { margin: 0; color: var(--muted); font-size: .9em; line-height: 1.6; }

/* books, as cards (Shelves, Trails, Workbench, Recaps) */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.book { display: flex; flex-direction: column; gap: 8px; padding: 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--rule); color: var(--ink); text-decoration: none; transition: border-color .15s, transform .15s; }
.book:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--rule)); transform: translateY(-1px); }
.book .c { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.book h3 { margin: 0; font-size: 17px; line-height: 1.3; }
.book p { margin: 0; color: var(--muted); font-size: .86em; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bstart { font-size: 12.5px; font-weight: 650; color: var(--accent); }
.bstart::before { content: "→ "; }
.bstart.started { color: var(--done); } .bstart.started::before { content: "◐ "; }
.card p { font-family: var(--read); }

/* contents: a volume's chapters, a trail's steps */
.contents { list-style: none; padding: 0; margin: 10px 0 0; border-top: 1px solid var(--rule); }
.contents li > a { display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 4px 16px; align-items: baseline; padding: 14px 6px; border-bottom: 1px solid var(--rule);
  color: var(--ink); text-decoration: none; }
.contents li > a:hover { background: var(--panel); }
.contents li:has(> .also) > a { border-bottom: 0; padding-bottom: 4px; }
.contents .also { display: block; padding: 0 6px 12px 80px; border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--faint); }
.contents .also a { color: var(--muted); }
@media (max-width: 560px) { .contents .also { padding-left: 68px; } }
.contents .n { font-size: 12px; color: var(--accent); font-weight: 650; }
.contents .t b { display: block; font-weight: 700; font-size: 1.02em; line-height: 1.35; }
.contents .t small { display: block; color: var(--muted); font-size: .84em; line-height: 1.5; margin-top: 3px; }
.contents .m { font-size: 12px; color: var(--faint); white-space: nowrap; }
.contents .pr { grid-column: 2 / 4; display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--faint); }
.contents .pr .meter { width: 120px; }
.contents .pr:has(span:empty) .meter i[style="width: 0%;"] { display: none; }
.contents li.wk { padding: 22px 6px 8px; font: 700 12px var(--font); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); border-bottom: 1px solid var(--rule); }
.contents.trail a.done .n::after { content: " ✓"; color: var(--done); }
.contents.trail a.done b { color: var(--muted); }
.contents.trail .pt { color: var(--done); font-weight: 650; }
.contents.trail .pr .meter { display: none; }
.vol-inner { max-width: min(100%, calc(var(--measure) + 120px)); }
.vol-howto { margin-top: 26px; font-size: .95em; }
.vol-howto h2 { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin: 30px 0 12px; }
.vol-howto .levels { margin-bottom: 16px; }
.vol-h { margin-top: 44px; }

/* under a chapter's or volume's heading: updated date, share, corrections, start */
.ch-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: -14px 0 26px; font-size: 13px; color: var(--faint); }
.ch-head + .ch-actions { margin-top: -18px; }
.page-head .ch-actions { margin: 22px 0 0; }
.act { font: 600 12.5px var(--font); color: var(--muted); background: none; border: 0; padding: 4px 0; cursor: pointer; text-decoration: none; border-bottom: 1px dashed var(--rule); }
.act:hover { color: var(--accent); border-bottom-color: var(--accent); }
.upd { font-size: 12px; }
.vol-actions .tb { margin-right: 6px; }
.tb small { font-weight: 450; color: var(--muted); }
a.tb { text-decoration: none; }
.tb.primary { background: var(--accent); color: var(--panel); border-color: color-mix(in srgb, var(--accent) 70%, var(--ink)); box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 55%, var(--ink)); }
.tb.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.tb.primary small { color: color-mix(in srgb, var(--panel) 80%, transparent); }
.tb.file { position: relative; }

/* share a part: the # beside headings */
.anchor { opacity: 0; margin-left: 2px; font: 600 .8em var(--font); color: var(--faint); text-decoration: none; padding: 0 4px; border-radius: 6px; transition: opacity .15s; }
h2:hover .anchor, h3:hover .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--accent); background: var(--accent-soft); }
@media (pointer: coarse) { .anchor { opacity: .5; } }
.share-pop { width: min(340px, calc(100vw - 24px)); }
.share-t { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.share-row { display: flex; gap: 8px; }
.share-row input { flex: 1; min-width: 0; font: 12px var(--font); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--rule); background: var(--paper); color: var(--ink); }
.share-row .tb { padding: 7px 12px; }
.share-to { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.share-to a { font: 600 12px var(--font); padding: 6px 10px; border-radius: 8px; border: 1px solid var(--rule); color: var(--ink); text-decoration: none; background: var(--paper); }
.share-to a:hover { border-color: var(--accent); color: var(--accent); }
.toast { position: fixed; z-index: 70; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); opacity: 0; transition: opacity .2s, transform .2s;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.in { opacity: 1; transform: translate(-50%, 0); }

/* sessions: a chapter in parts of about ten minutes */
.session-plan { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -8px 0 30px; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--rule); }
.session-plan .lbl { margin: 0 8px 0 0; flex-basis: 100%; }
.session-plan a { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); text-decoration: none; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--rule); background: var(--paper); }
.session-plan a .d { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--sunk); color: var(--ink); font-weight: 700; font-size: 11px; }
.session-plan a:hover { border-color: var(--accent); color: var(--accent); }
.session-plan a.ok .d { background: var(--done); color: var(--panel); }
.session-plan a.ok .d::after { content: ""; }
.session-mark { display: flex; justify-content: space-between; gap: 12px; margin: 3.4em 0 -1.4em; padding: 10px 0 0; border-top: 3px solid var(--ink); font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); }
.session-mark span:last-child { color: var(--faint); }
.session-mark + h2.sec { border-top: 0; }
.session-end { margin: 2.6em 0 0; padding: 20px 22px; border-radius: 16px; background: var(--panel); border: 1.5px solid color-mix(in srgb, var(--ink) 40%, transparent); box-shadow: 0 3px 0 color-mix(in srgb, var(--ink) 25%, transparent); }
.se-t { margin: 0 0 10px !important; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.se-q { font-weight: 650; margin: 0 0 12px !important; }
.session-end .why { margin-top: 12px; }
.se-go { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 18px; }
.resume.pickup { margin: -14px 0 30px; }

/* the library menu (small screens) and its doors */
.doors-btn { display: none; }
.doors-pop nav { display: grid; gap: 2px; }
.doors-pop a { display: grid; gap: 1px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.doors-pop a b { font-size: 14px; } .doors-pop a span { font-size: 12px; color: var(--faint); }
.doors-pop a:hover, .doors-pop a[aria-current] { background: var(--accent-soft); }
@media (max-width: 1240px) { body[data-page="chapter"] .topnav, body[data-page="volume"] .topnav { display: none; } body[data-page="chapter"] .doors-btn, body[data-page="volume"] .doors-btn { display: inline-flex; } }

/* desk */
.desk-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 140px; gap: 4px 16px; align-items: center; padding: 14px 6px; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.desk-row:hover { background: var(--panel); }
.desk-row .c { font: 650 11px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.desk-row .meter { width: 100%; }
.desk-row small { grid-column: 2 / 4; color: var(--faint); font-size: 12px; }
.move-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.move { padding: 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--rule); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.move h3 { margin: 0; font-size: 16px; } .move p { margin: 0; color: var(--muted); font-size: .9em; }
.move-msg { min-height: 1.4em; color: var(--done); font-weight: 600; }
.move-link { width: 100%; min-height: 90px; font: 12px var(--font); }
.cert-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.cert-row b { font-size: 16px; } .cert-row span { color: var(--muted); font-size: .9em; }
.cert-row label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.cert-row input { font: 15px var(--read); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); }
.tool-list { columns: 2 280px; padding-left: 1.2em; } .tool-list li { margin-bottom: 6px; } .tool-list small { color: var(--faint); }
.changes { list-style: none; padding: 0; margin: 24px 0 0; max-width: 760px; }
.changes li { padding: 22px 0; border-bottom: 1px solid var(--rule); }
.changes time { font: 650 12px var(--font); color: var(--accent); letter-spacing: .06em; }
.changes h2 { margin: 6px 0 8px; font-size: 20px; letter-spacing: -0.01em; }
.changes p { margin: 0; color: var(--muted); }
.prose.about { max-width: 70ch; margin-top: 28px; }
.prose.about h2 { font-size: 22px; margin: 1.8em 0 .5em; }

/* code: long lines can wrap */
.code.wrap pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.wrap-btn[aria-pressed="true"] { color: var(--accent); }
.site-foot p { margin: 0 0 6px; }


/* ---- running code: Run buttons, output, the bench ---- */
.run-btn { color: var(--accent) !important; font-weight: 700 !important; }
.run-btn:disabled { opacity: .5; }
.run-out { border-top: 1px dashed var(--rule); background: var(--panel); }
.run-out:empty { display: none; }
.run-h { display: flex; justify-content: space-between; padding: 8px 16px 0; font: 700 10.5px var(--font); letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.run-out pre { margin: 0; padding: 8px 16px 14px; font: 13px/1.6 var(--font); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 420px; overflow: auto; }
.r-err { color: var(--warn); } .r-info { color: var(--faint); font-style: italic; }
.run-open { display: inline-block; margin: 0 16px 12px; font: 600 12px var(--font); }
.bench { display: flex; flex-direction: column; gap: 10px; }
.bench-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.bench-bar label { display: inline-flex; align-items: center; gap: 8px; font: 600 12px var(--font); color: var(--muted); text-transform: none; letter-spacing: 0; margin: 0; flex-direction: row; }
.bench-bar select { font: 13px var(--font); padding: 7px 9px; border-radius: 8px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); max-width: 340px; }
.bench-k { font-size: 11px; color: var(--faint); }
.bench-code { width: 100%; min-height: 300px; resize: vertical; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--rule); background: var(--code-bg); color: var(--ink);
  font: 13.5px/1.6 var(--font); tab-size: 4; white-space: pre; overflow: auto; }
.bench-code:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.bench-out { border: 1px solid var(--rule); border-radius: 12px; min-height: 60px; }
.bench-note, .bench-local { font-size: 12.5px; color: var(--faint); margin: 0; }
.bench-local { color: var(--warn); background: var(--warn-soft); padding: 8px 12px; border-radius: 8px; }
.lab-code .bench-code { min-height: 240px; }
body[data-page="code"] #bench { margin-top: 24px; }
body[data-page="code"] .bench-code { min-height: 380px; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; z-index: 25; top: calc(env(safe-area-inset-top, 0px) + var(--bar-h) + 1px); left: 0; bottom: 0; width: min(330px, 88vw); height: auto; background: var(--panel);
    transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 0 0 100vmax transparent; }
  .rail.open { transform: none; box-shadow: 0 0 0 100vmax rgba(20, 18, 14, .35); }
  .menu-btn { display: inline-block; }
  .cover { grid-template-columns: minmax(0, 1fr); }
  .meter { width: 60px; }
  .sync, .brand small, .icon-btn kbd { display: none; }
  .topnav a[data-k="learn"] { display: none; }
  .lab { width: 100vw; left: 0; border-left: 0; }
  body.lab-on .shell { margin-right: 0; }
}
@media (max-width: 760px) {
  .topnav { display: none; }
  .doors-btn { display: inline-flex; }
}
@media (max-width: 560px) {
  .topnav { display: none; }
  .page { padding-top: 28px; }
  .contents li > a { grid-template-columns: 46px minmax(0, 1fr); }
  .contents .m { grid-column: 2; }
  .desk-row { grid-template-columns: 1fr; }
  .desk-row small { grid-column: 1; }
  .session-mark { margin-top: 2.6em; }
  :root { --bar-h: 50px; }
  body { font-size: calc(var(--fs) - 1px); }
  .bar .overall { display: none; }
  .brand { font-size: 14px; }
  .bar-in { gap: 7px; }
  .home-link { display: none; }
  .icon-btn .lbl-t { display: none; }
  .pager { grid-template-columns: 1fr; } .pager .next { grid-column: 1; }
  .quiz { padding: 18px 15px; }
  .prose h2.sec { font-size: 1.4em; }
  .stat b { font-size: 21px; }
  .lab-open { padding: 5px 9px; }
  .ch-inner { padding-top: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
@media print {
  .bar, .rail, .pager, .quiz, .tick, .ex-answer, .lab, .lab-open, .outline, .to-top, .pop, .palette { display: none !important; }
  .shell { display: block; } body { background: #fff; color: #000; font-size: 11pt; }
}
kbd { font: 500 .8em var(--font); border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35em; background: var(--panel); color: var(--ink); }
.prose p, .prose li { hyphens: manual; }

/* ---- scenes: diagrams that move (assets/scenes.js, data in scene-data.js) ---- */
.scene { margin: 2em 0; border: 1.5px solid var(--rule); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.scene:not(.sc-on) { padding: 14px 18px; }
.scene:not(.sc-on) figcaption { font: 600 14px var(--font); color: var(--muted); }
.scene:focus { outline: none; }
.scene:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sc-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.sc-eye { margin: 0; font: 700 11px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.sc-title { margin: 2px 0 0; font: 650 15px var(--font); color: var(--ink); line-height: 1.3; }
.sc-ctrl { display: flex; gap: 6px; flex: none; }
.sc-ctrl button { font: 600 12px var(--font); padding: 6px 10px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); color: var(--ink); cursor: pointer; }
.sc-ctrl button:hover { background: var(--sunk); }
.sc-main { display: grid; grid-template-columns: minmax(0, 1fr); }
.sc-stage { position: relative; background: var(--paper); border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; }
.sc-svg { display: block; width: 100%; height: auto; }
.sc-metrics { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.sc-m { display: flex; flex-direction: column; gap: 1px; padding: 5px 10px; border: 1px solid var(--rule); border-radius: 9px; background: var(--panel); min-width: 74px; }
.sc-m span { font: 600 10.5px var(--font); color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.sc-m b { font: 700 14px var(--font); color: var(--ink); font-variant-numeric: tabular-nums; }
.sc-m-bad { border-color: color-mix(in srgb, var(--warn) 55%, var(--rule)); background: var(--warn-soft); } .sc-m-bad b { color: var(--warn); }
.sc-m-good { border-color: color-mix(in srgb, var(--done) 55%, var(--rule)); background: var(--done-soft); } .sc-m-good b { color: var(--done); }
.sc-legend { display: flex; flex-wrap: wrap; gap: 14px; padding: 0 14px 10px; font: 600 12px var(--font); color: var(--muted); }
.sc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sc-legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.sc-k-req { background: var(--accent); } .sc-k-res { background: var(--done); } .sc-k-hs { background: var(--s-pp); } .sc-k-data { background: var(--s-kw); } .sc-k-lost { background: var(--warn); }
.sc-side { padding: 16px 20px; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; row-gap: 6px; align-items: start; min-width: 0; min-height: 15em; }
.sc-side > * { grid-column: 1; }
.sc-side > .sc-nav { grid-column: 2; grid-row: 1 / span 4; flex-direction: column; align-items: stretch; margin: 0; padding: 0; width: 13em; }
.sc-side > .sc-keys { grid-column: 2; grid-row: 5; }
.sc-stepno { margin: 0; display: flex; gap: 8px; align-items: center; font: 650 12px var(--font); color: var(--faint); }
.sc-tag { font: 700 10.5px var(--font); text-transform: uppercase; letter-spacing: .06em; padding: 2px 7px; border-radius: 6px; background: var(--sunk); color: var(--muted); }
.sc-tag-problem { background: var(--warn-soft); color: var(--warn); } .sc-tag-recap, .sc-tag-start { background: var(--accent-soft); color: var(--accent); }
.sc-h { margin: 0; font: 700 18px/1.3 var(--font); color: var(--ink); }
.sc-text { font-size: .9em; line-height: 1.6; color: var(--ink); }
.sc-text p, .sc-text ul { margin: 0 0 .6em; } .sc-text ul { padding-left: 1.2em; } .sc-text li { margin: .2em 0; }
.sc-key { border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; padding: 8px 12px; font-size: .86em; }
.sc-key p:first-child { margin: 0 0 2px; font: 700 10.5px var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.sc-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.sc-nav .tb { white-space: normal; text-align: left; }
.sc-keys { margin: 0; font: 500 11.5px var(--font); color: var(--faint); }
.sc-dots { list-style: none; margin: 0; padding: 10px 12px; display: flex; gap: 4px; overflow-x: auto; border-top: 1px solid var(--rule); scrollbar-width: thin; }
.sc-dots button { display: flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid transparent; border-radius: 999px; background: none; color: var(--muted); font: 600 12px var(--font); cursor: pointer; white-space: nowrap; }
.sc-dots .d { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--sunk); font-size: 11px; }
.sc-dots button.seen .d { background: var(--done-soft); color: var(--done); }
.sc-dots button[aria-current] { border-color: var(--rule); background: var(--paper); color: var(--ink); }
.sc-dots button[aria-current] .d { background: var(--accent); color: var(--panel); }
/* the drawing */
.sc-dot { fill: var(--rule); }
.sc-node { transition: opacity .35s; }
.sc-node.sc-dim, .sc-link.sc-dim { opacity: .16; }
.sc-body { stroke: var(--ink); stroke-width: 1.6; fill: var(--panel); transition: fill .3s, stroke .3s; }
.sc-edge { fill: color-mix(in srgb, var(--ink) 75%, transparent); }
.sc-accent { fill: var(--accent-soft); } .sc-done { fill: var(--done-soft); } .sc-warn { fill: var(--warn-soft); } .sc-plain { fill: var(--panel); }
.sc-lid.sc-body { fill: color-mix(in srgb, var(--panel) 60%, var(--sunk)); }
.sc-slot { fill: var(--sunk); stroke: var(--rule); }
.sc-led { fill: var(--done); }
.sc-screen { fill: var(--sunk); }
.sc-pin { stroke: var(--ink); stroke-width: 2; }
.sc-lbl { font: 700 15px var(--font); fill: var(--ink); }
.sc-on-screen { font-size: 14px; }
.sc-sub { font: 500 12px var(--font); fill: var(--muted); }
.sc-pl { font: 700 12.5px var(--font); fill: var(--ink); }
.sc-note { font: 600 14px var(--font); fill: var(--ink); }
.sc-ring { fill: none; stroke: var(--rule); stroke-width: 10; }
.sc-cell { fill: var(--panel); stroke: var(--ink); stroke-width: 1.3; transition: fill .3s; }
.sc-filled .sc-cell { fill: var(--accent-soft); }
.sc-chl .sc-cell { fill: color-mix(in srgb, var(--accent) 30%, var(--panel)); stroke: var(--accent); stroke-width: 2.4; }
.sc-cv { font: 650 13px var(--font); fill: var(--ink); }
.sc-ix { font: 500 10.5px var(--font); fill: var(--faint); }
.sc-hl .sc-body, .sc-hl .sc-cell { stroke: var(--accent); stroke-width: 3; }
.sc-bad .sc-body, .sc-bad .sc-cell { stroke: var(--warn); stroke-width: 3; fill: var(--warn-soft); }
.sc-good .sc-body, .sc-good .sc-cell { stroke: var(--done); stroke-width: 3; fill: var(--done-soft); }
.sc-link { stroke: var(--faint); stroke-width: 1.6; transition: opacity .35s; }
.sc-dash { stroke-dasharray: 5 6; }
.sc-cut { stroke: var(--warn); stroke-dasharray: 3 7; opacity: .7; }
.sc-trail { stroke-width: 2.4; stroke-dasharray: 2 7; stroke-linecap: round; opacity: .7; }
.sc-pkt { stroke: var(--panel); stroke-width: 2.5; }
.sc-ftag rect { fill: var(--panel); stroke-width: 1.4; }
.sc-ftag text { font: 650 12px var(--font); fill: var(--ink); }
.sc-ftag { transition: opacity .25s; }
.sc-f-req .sc-trail, .sc-f-req .sc-ftag rect { stroke: var(--accent); } .sc-f-req .sc-pkt { fill: var(--accent); }
.sc-f-res .sc-trail, .sc-f-res .sc-ftag rect { stroke: var(--done); } .sc-f-res .sc-pkt { fill: var(--done); }
.sc-f-hs .sc-trail, .sc-f-hs .sc-ftag rect { stroke: var(--s-pp); } .sc-f-hs .sc-pkt { fill: var(--s-pp); }
.sc-f-data .sc-trail, .sc-f-data .sc-ftag rect { stroke: var(--s-kw); } .sc-f-data .sc-pkt { fill: var(--s-kw); }
.sc-f-lost .sc-trail, .sc-f-lost .sc-ftag rect { stroke: var(--warn); } .sc-f-lost .sc-pkt { fill: var(--warn); }
.sc-badge rect { fill: var(--ink); } .sc-badge text { font: 650 12px var(--font); fill: var(--panel); }
.sc-badge-bad rect { fill: var(--warn); }
/* full screen */
.scene.sc-full { position: fixed; inset: 12px; z-index: 90; margin: 0; overflow: auto; display: flex; flex-direction: column; }
.scene.sc-full .sc-main { flex: 1; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.scene.sc-full .sc-stage { border-bottom: 0; border-right: 1px solid var(--rule); }
.scene.sc-full .sc-side { display: flex; flex-direction: column; }
.scene.sc-full .sc-side > .sc-nav { flex-direction: row; width: auto; margin-top: auto; }
.scene.sc-full .sc-stage { justify-content: center; }
@media (max-width: 860px) {
  .sc-side { display: flex; flex-direction: column; min-height: 0; }
  .sc-side > .sc-nav { flex-direction: row; width: auto; margin-top: 8px; }
  .sc-keys { display: none; }
  .sc-top { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  .sc-stage { overflow-x: auto; }
  .sc-svg { min-width: 600px; }
  .sc-metrics, .sc-legend { position: sticky; left: 0; }
}
@media (prefers-reduced-motion: reduce) { .sc-node, .sc-link, .sc-body, .sc-cell { transition: none; } }
@media print { .scene { break-inside: avoid; } .sc-ctrl, .sc-nav, .sc-dots, .sc-keys { display: none; } }

/* ---- QR codes (share popover, desk) ---- */
.share-qr { margin-top: 8px; }
.qr-box { margin-top: 8px; text-align: center; }
.qr-box .qr, .move-qr .qr { width: 180px; height: 180px; display: block; margin: 0 auto; border-radius: 8px; image-rendering: pixelated; }
.move-qr { margin: 12px 0; }
.move-qr .qr { width: 220px; height: 220px; margin: 0; }
.feed-qr .qr { width: 180px; height: 180px; margin: 6px 0 12px; border-radius: 8px; }
.follow .readers li { margin: .35em 0; }
.feed-row { max-width: 520px; }
.run-ask { padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--panel); font-size: .9em; }
.run-ask p { margin: 0 0 8px; } .run-ask-b { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.run-ask label { font-size: .9em; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }

/* ---- shelves to come (tools/subjects.json) ---- */
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 16px; grid-auto-flow: row dense; }
.plan { --tint: hsl(var(--hue) 55% 50%); position: relative; border: 1.5px solid var(--rule); border-radius: 16px; padding: 18px 20px 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tint) 7%, var(--panel)), var(--panel) 70%); overflow: hidden; }
.plan::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--tint); opacity: .75; }
.plan:has(.plan-all[open]) { grid-column: 1 / -1; }
.plan-k { margin: 0 0 4px; font: 600 12px var(--font); color: var(--muted); display: flex; gap: 8px; align-items: center; }
.plan-k span { font-weight: 700; font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--tint) 16%, transparent); color: color-mix(in srgb, var(--tint) 70%, var(--ink)); }
.plan h3 { margin: 0 0 6px; font: 700 1.2em/1.25 var(--font); color: var(--ink); }
.plan-b { margin: 0 0 8px; font-size: .92em; line-height: 1.55; color: var(--muted); }
.plan-for { margin: 0 0 8px; font-size: .85em; color: var(--muted); }
.plan-chips { list-style: none; margin: 10px 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.plan-chips li { font: 600 12px var(--font); padding: 4px 9px; border-radius: 8px; background: var(--paper); border: 1px solid var(--rule); color: var(--ink); }
.plan-chips .plan-more { color: var(--muted); border-style: dashed; }
.plan-all { margin-top: 6px; }
.plan-all > summary { cursor: pointer; font: 650 13px var(--font); color: var(--accent); padding: 6px 0; width: fit-content; }
.plan-all[open] > summary { margin-bottom: 6px; }
.plan-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 24px; }
.plan-col h4 { margin: 8px 0 4px; font: 700 11.5px var(--font); text-transform: uppercase; letter-spacing: .05em; color: var(--ink); }
.plan-col ol { margin: 0 0 8px; padding-left: 1.3em; font-size: .88em; color: var(--muted); }
.plan-col li { margin: 2px 0; }

/* offline copy of a book (library.js, sw.js) */
.offline-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }
.offline-row .sub { color: var(--muted); font-size: 14px; }

/* predict, then see (reading setting "Predict outputs before seeing them") */
.predict { margin: 18px 0; padding: 12px 14px; border: 1px dashed var(--rule); border-radius: 10px; background: var(--panel, transparent); }
.predict label { display: block; font: 600 14px var(--font); }
.predict textarea { display: block; width: 100%; box-sizing: border-box; margin: 8px 0 10px; padding: 8px 10px; font: 13.5px/1.5 var(--mono, monospace);
  border: 1px solid var(--rule); border-radius: 8px; background: var(--paper, transparent); color: inherit; resize: vertical; }
.predict.shown { border-style: solid; }
.predict.shown textarea { opacity: .85; }

/* accessibility pass (2026-11-20): links in running text are underlined; long inline code wraps on phones */
.crumbs a, .site-foot a, .sub a, .lede a, .page-head a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }
p code, li code, td code, dd code { overflow-wrap: anywhere; }
pre:focus-visible, .tw:focus-visible, .fig:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rail a[aria-current="page"] .p { color: var(--muted); }
