/* EDA-Game: quiet chrome, detailed lessons. One accent, hairlines, system type. */
:root {
  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --bg-3: #ebebef;
  --ink: #1d1d1f;
  --ink-2: #424245;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.1);
  --line-2: rgba(0, 0, 0, 0.16);
  --accent: #0066cc;
  --accent-ink: #ffffff;
  --accent-soft: rgba(0, 102, 204, 0.08);
  --good: #1a7f37;
  --good-soft: #eaf6ed;
  --bad: #c0281b;
  --bad-soft: #fcecea;
  --code-bg: #f5f5f7;
  --header-h: 52px;
  --radius: 12px;
  --measure: 34em; /* about 70 characters of 18px lesson text */
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111112;
    --bg-2: #1c1c1e;
    --bg-3: #2c2c2e;
    --ink: #f5f5f7;
    --ink-2: #d2d2d7;
    --muted: #a1a1a6;
    --line: rgba(255, 255, 255, 0.12);
    --line-2: rgba(255, 255, 255, 0.2);
    --accent: #3d9bff;
    --accent-ink: #001a33;
    --accent-soft: rgba(61, 155, 255, 0.12);
    --good: #4cd571;
    --good-soft: rgba(48, 209, 88, 0.12);
    --bad: #ff7b72;
    --bad-soft: rgba(255, 69, 58, 0.13);
    --code-bg: #1c1c1e;
  }
}

:root[data-theme="dark"] {
    --bg: #111112;
    --bg-2: #1c1c1e;
    --bg-3: #2c2c2e;
    --ink: #f5f5f7;
    --ink-2: #d2d2d7;
    --muted: #a1a1a6;
    --line: rgba(255, 255, 255, 0.12);
    --line-2: rgba(255, 255, 255, 0.2);
    --accent: #3d9bff;
    --accent-ink: #001a33;
    --accent-soft: rgba(61, 155, 255, 0.12);
    --good: #4cd571;
    --good-soft: rgba(48, 209, 88, 0.12);
    --bad: #ff7b72;
    --bad-soft: rgba(255, 69, 58, 0.13);
    --code-bg: #1c1c1e;
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------- Base ---------- */
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.55 var(--sans); letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.15em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 50; padding: 8px 14px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: 14px; }
.skip:focus { top: 8px; }
.loading { padding: 64px 0; text-align: center; }
.eyebrow { font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--muted); margin: 0; }
.lede { font-size: 19px; line-height: 1.5; color: var(--ink-2); margin: 0; max-width: 40em; }

/* ---------- Header ---------- */
.top { position: sticky; top: 0; z-index: 20; height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line); }
.top-in { max-width: 1200px; height: 100%; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { white-space: nowrap; font: 600 17px/1 var(--display); color: var(--ink); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.top nav { display: flex; gap: 4px; }
.top nav a { font-size: 14px; color: var(--ink-2); padding: 6px 10px; border-radius: 8px; }
.top nav a:hover { color: var(--ink); text-decoration: none; background: var(--bg-2); }
.top nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 0 24px 96px; }

/* ---------- Buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 500 15px/1 var(--sans); padding: 10px 16px; min-height: 40px; border-radius: 980px;
  border: 1px solid var(--line-2); background: transparent; color: var(--ink); cursor: pointer; }
.btn:hover { text-decoration: none; background: var(--bg-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.4; cursor: default; filter: none; }
.btn.lg { font-size: 17px; padding: 12px 22px; min-height: 46px; }
.field { font: inherit; font-size: 16px; padding: 10px 14px; min-height: 44px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); }
.field:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.cta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 28px; }
.cta-note { color: var(--muted); font-size: 15px; }

/* Thin progress meter, used everywhere progress shows. */
.meter { display: inline-block; position: relative; width: 56px; height: 4px; border-radius: 2px;
  background: var(--bg-3); overflow: hidden; vertical-align: middle; flex: none; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 2px; }

/* ---------- Home ---------- */
.hero { padding: 88px 0 72px; max-width: 900px; }
.hero h1 { font-size: clamp(36px, 6vw, 56px); line-height: 1.07; letter-spacing: -0.03em; font-weight: 700; margin: 0 0 14px; }
.overall { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); margin: 22px 0 0; }
.overall .meter { width: 120px; }

.map { border-top: 1px solid var(--line); padding-top: 40px; }
.map-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.map-head h2 { font-size: 24px; letter-spacing: -0.02em; margin: 0; }
.map-head p { margin: 0; font-size: 15px; }
.layer { display: grid; grid-template-columns: 72px 1fr; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.layer:first-of-type { border-top: 0; }
.layer-n { margin: 0; padding-top: 12px; font: 500 13px/1 var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: flex; flex-direction: column; justify-content: space-between; gap: 10px; height: 100%;
  padding: 12px 14px; border-radius: 10px; background: var(--bg-2); color: var(--ink); min-height: 72px; }
.tile:hover { text-decoration: none; background: var(--bg-3); }
.t-name { font-size: 15px; font-weight: 500; line-height: 1.3; }
.t-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tile.started .t-meta { color: var(--ink-2); }

/* ---------- Generic pages ---------- */
.page { max-width: 820px; padding-top: 56px; }
.page-head { margin-bottom: 36px; }
.page-head h1 { font-size: 40px; letter-spacing: -0.03em; line-height: 1.1; margin: 0 0 10px; }

/* Tracks */
.tracks { list-style: none; margin: 0; padding: 0; }
.track { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; align-items: start;
  padding: 24px 0; border-top: 1px solid var(--line); }
.track h2 { font-size: 20px; letter-spacing: -0.015em; margin: 0 0 6px; }
.track .tr-main p { margin: 0; color: var(--ink-2); font-size: 15px; max-width: 60ch; }
.track .tr-main .tr-meta { color: var(--muted); font-size: 13px; margin-top: 8px; }
.tr-path { grid-column: 1 / -1; font-size: 14px; }
.tr-path summary { cursor: pointer; color: var(--accent); width: max-content; }
.tr-path ol { columns: 2; column-gap: 32px; margin: 12px 0 0; padding-left: 24px; color: var(--muted); }
.tr-path li { break-inside: avoid; padding: 2px 0; }
.tr-path li span { margin-left: 8px; font-size: 12px; }

/* ---------- Study layout ---------- */
.study { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 56px; align-items: start; }
.contents-btn { display: none; }
.scrim { display: none; }
.side { position: sticky; top: var(--header-h); max-height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 28px 8px 40px 0; font-size: 13.5px; overscroll-behavior: contain; scrollbar-width: thin; }
.side-head { padding: 0 8px 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.side-dom { display: block; font-weight: 600; font-size: 15px; color: var(--ink); line-height: 1.3; }
.side-dom.on { color: var(--accent); }
.side-prog { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-prog .meter { flex: 1; width: auto; }
.side-h { font: 600 11.5px/1.3 var(--sans); letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); margin: 20px 8px 6px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a { display: flex; gap: 10px; align-items: baseline; padding: 5px 8px; border-radius: 8px; color: var(--ink-2); line-height: 1.35; }
.side li a:hover { text-decoration: none; background: var(--bg-2); color: var(--ink); }
.side li a.on { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; border: 1.25px solid var(--line-2); transform: translateY(-1px); }
.side a.started .dot { border-color: var(--accent); }
.side a.done .dot { background: var(--good); border-color: var(--good); }
.side a.on .dot { border-color: var(--accent); }
.side a.on.done .dot { background: var(--good); border-color: var(--good); }

.reader { min-width: 0; width: 100%; max-width: var(--measure); margin: 0 auto; padding-top: 32px; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

.builds, .prose .builds { font-size: 14px; color: var(--muted); margin: -4px 0 28px; line-height: 1.6; letter-spacing: 0; }
.builds-k { font-weight: 500; color: var(--ink-2); margin-right: 6px; }
.builds a, .builds span:not(.builds-k):not(.sep) { color: var(--ink-2); }
.builds a, .prose .builds a { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 0.2em; }
.builds a:hover { color: var(--accent); text-decoration-color: currentColor; }
.builds .sep { margin: 0 8px; color: var(--line-2); }

/* Domain landing */
.dom-head { padding-bottom: 36px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.dom-head h1 { font-size: 40px; line-height: 1.1; letter-spacing: -0.03em; margin: 8px 0 14px; }
.dom-head .lede { font-size: 18px; }
.dom-prog { display: flex; align-items: center; gap: 10px; margin-top: 22px; font-size: 14px; color: var(--muted); }
.dom-prog .meter { width: 160px; }
.dom-head .cta { margin-top: 22px; }
.dom-head .builds { margin: 22px 0 0; }
.sec-h { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); margin: 0 0 8px; }
.subs { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.subs li { counter-increment: s; border-top: 1px solid var(--line); }
.subs li:first-child { border-top: 0; }
.subs a { display: grid; grid-template-columns: 28px 1fr auto; gap: 2px 12px; padding: 14px 8px; margin: 0 -8px; border-radius: 10px; color: var(--ink); }
.subs a::before { content: counter(s); grid-row: 1 / 3; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; padding-top: 1px; }
.subs a:hover { text-decoration: none; background: var(--bg-2); }
.s-title { font-weight: 500; }
.s-first { grid-column: 2; font-size: 14px; color: var(--muted); }
.s-meta { grid-column: 3; grid-row: 1 / 3; align-self: center; display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Lesson typography ---------- */
.prose { font-size: 18px; line-height: 1.68; color: var(--ink); letter-spacing: -0.005em; overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose pre, .prose table { margin: 0 0 1.1em; }
.prose h1 { font-size: 38px; line-height: 1.12; letter-spacing: -0.03em; font-weight: 700; margin: 0 0 18px; }
.prose h2 { font-size: 24px; line-height: 1.25; letter-spacing: -0.02em; font-weight: 600; margin: 2.1em 0 0.6em; }
.prose h3 { font-size: 19px; line-height: 1.3; letter-spacing: -0.01em; font-weight: 600; margin: 1.8em 0 0.5em; }
.prose h4 { font-size: 17px; margin: 1.5em 0 0.4em; }
.lesson > h1 + p, .lesson > .builds + p { font-size: 20px; line-height: 1.6; color: var(--ink-2); }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 0.3em 0; padding-left: 0.2em; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 600; }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 0.18em; }
.prose blockquote { margin-left: 0; padding: 2px 0 2px 18px; border-left: 3px solid var(--line-2); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose code { font-family: var(--mono); font-size: 0.86em; background: var(--code-bg); padding: 0.12em 0.36em; border-radius: 5px; }
.prose pre { font-family: var(--mono); font-size: 14.5px; line-height: 1.55; background: var(--code-bg); padding: 16px 18px; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15.5px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { font-weight: 600; border-bottom-color: var(--line-2); }
.prose img { max-width: 100%; height: auto; }
.prose .katex { font-size: 1.06em; }
.prose .katex-display { margin: 1.3em 0; padding: 4px 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.prose .katex-display > .katex { font-size: 1.12em; }

/* ---------- Practice ---------- */
.practice { margin-top: 56px; padding: 28px 28px 24px; border-radius: 18px; background: var(--bg-2);
  border: 1px solid transparent; }
.practice.is-good { border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.practice.is-bad { border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.p-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.p-head h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0; }
.streak { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.streak i { width: 8px; height: 8px; border-radius: 50%; background: var(--bg-3); border: 1px solid var(--line-2); }
.streak i.on { background: var(--accent); border-color: var(--accent); }
.streak.learned i { background: var(--good); border-color: var(--good); }
.streak.learned span { color: var(--good); font-weight: 600; }
.streak span { margin-left: 4px; }
.q.prose { font-size: 18px; margin-bottom: 18px; }
.q.prose p:last-child { margin-bottom: 0; }
.opts { display: grid; gap: 8px; }
.opts button { display: flex; align-items: flex-start; gap: 12px; text-align: left; width: 100%;
  font: inherit; font-size: 16.5px; line-height: 1.45; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.opts button:hover:not(:disabled) { border-color: var(--line-2); }
.opts kbd { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; margin-top: -1px;
  border-radius: 6px; border: 1px solid var(--line-2); font: 600 12px/1 var(--sans); color: var(--muted); }
.opts .o-t { min-width: 0; overflow-wrap: anywhere; }
.opts .o-t .katex-display { margin: 0.3em 0; }
.opts button[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.opts button[aria-checked="true"] kbd { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opts button:disabled { cursor: default; opacity: 0.6; }
.opts button.right { opacity: 1; border-color: var(--good); box-shadow: 0 0 0 1px var(--good) inset; background: var(--good-soft); }
.opts button.right kbd { background: var(--good); border-color: var(--good); color: var(--bg); }
.opts button.wrong { opacity: 1; border-color: var(--bad); box-shadow: 0 0 0 1px var(--bad) inset; background: var(--bad-soft); }
.opts button.wrong kbd { background: var(--bad); border-color: var(--bad); color: var(--bg); }
.p-act { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.num { display: flex; gap: 10px; flex-wrap: wrap; }
.num .field { flex: 1 1 180px; max-width: 280px; font-variant-numeric: tabular-nums; }
.num + .hint { margin-top: 10px; }
.fb { margin-top: 18px; padding: 16px 18px; border-radius: 12px; }
.fb.good { background: var(--good-soft); }
.fb.bad { background: var(--bad-soft); }
.fb-t { margin: 0; font-weight: 600; display: flex; gap: 10px; align-items: baseline; }
.fb.good .fb-t { color: var(--good); }
.fb.bad .fb-t { color: var(--bad); }
.fb-i { flex: none; }
.fb .ex { margin-top: 8px; font-size: 16px; line-height: 1.6; color: var(--ink); }
.fb .ex p:last-child { margin-bottom: 0; }

/* Pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); }
.pg { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; color: var(--ink); min-width: 0; }
.pg:hover { text-decoration: none; background: var(--bg-2); }
.pg.next { text-align: right; grid-column: 2; }
.pg-k { font-size: 12px; color: var(--muted); }
.pg-l { font-size: 15px; font-weight: 500; color: var(--accent); }
.pg.prev .pg-k::before { content: "← "; }
.pg.next .pg-k::after { content: " →"; }

/* ---------- Glossary ---------- */
.gbar { position: sticky; top: var(--header-h); z-index: 10; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 0; margin-bottom: 8px; background: var(--bg); border-bottom: 1px solid var(--line); }
.gbar #gq { flex: 1 1 260px; }
.gbar select { flex: 0 1 200px; min-width: 0; cursor: pointer; }
.gn { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--muted); }
.gn:empty { display: none; }
.gdom { scroll-margin-top: calc(var(--header-h) + 84px); padding-top: 16px; }
.gdom h2 { font-size: 26px; letter-spacing: -0.02em; margin: 40px 0 6px; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.covers { font-size: 14px; color: var(--muted); margin: 0 0 8px; }
.covers summary { cursor: pointer; width: max-content; }
.covers ul { margin: 8px 0; padding-left: 20px; }
.gsub h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); margin: 28px 0 4px; }
.gsub dl { margin: 0; }
.gc { padding: 14px 0; border-top: 1px solid var(--line); }
.gsub dl .gc:first-child { border-top: 0; }
.gc dt a { font-weight: 600; font-size: 16px; color: var(--ink); }
.gc dt a:hover { color: var(--accent); }
.gc dd { margin: 4px 0 0; }
.g-def { margin: 0; font-size: 15.5px; line-height: 1.55; color: var(--ink-2); }
.g-ideas { margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.empty { padding: 40px 0; text-align: center; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .btn, .tile, .side li a, .opts button, .pg, .subs a, .top nav a { transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease; }
  .meter i { transition: width 0.4s ease; }
  .side { transition: transform 0.25s ease; }
}

/* ---------- Narrow screens ---------- */
@media (max-width: 960px) {
  .study { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .contents-btn { display: flex; align-items: center; gap: 10px; position: sticky; top: var(--header-h); z-index: 12;
    width: calc(100% + 48px); margin: 0 -24px; padding: 10px 24px; font: 500 14px/1.2 var(--sans);
    background: color-mix(in srgb, var(--bg) 88%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border: 0; border-bottom: 1px solid var(--line); color: var(--ink); cursor: pointer; text-align: left; }
  .contents-btn span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .contents-btn .muted { font-variant-numeric: tabular-nums; }
  .side { position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; width: min(320px, 86vw); max-height: none;
    padding: 20px 12px 40px; background: var(--bg); border-right: 1px solid var(--line);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.15); transform: translateX(-105%); visibility: hidden; }
  body.drawer-open .side { transform: none; visibility: visible; }
  body.drawer-open { overflow: hidden; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.35); }
  .scrim[hidden] { display: none; }
  .reader { max-width: none; padding-top: 20px; }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 960px) {
  .side { transition: transform 0.25s ease, visibility 0.25s; }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  main { padding: 0 16px 72px; }
  .top-in { padding: 0 16px; }
  .top nav a { padding: 6px 7px; font-size: 13.5px; }
  .contents-btn { width: calc(100% + 32px); margin: 0 -16px; padding: 10px 16px; }
  .hero { padding: 48px 0 44px; }
  .lede { font-size: 17px; }
  .layer { grid-template-columns: 1fr; gap: 8px; }
  .layer-n { padding-top: 4px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .tile { min-height: 76px; padding: 10px 12px; }
  .t-name { font-size: 14px; }
  .page { padding-top: 36px; }
  .page-head h1, .dom-head h1 { font-size: 32px; }
  .track { grid-template-columns: 1fr; }
  .track .btn { justify-self: start; }
  .tr-path ol { columns: 1; }
  .prose { font-size: 17px; line-height: 1.65; }
  .prose h1 { font-size: 30px; }
  .prose h2 { font-size: 21px; }
  .lesson > h1 + p, .lesson > .builds + p { font-size: 18px; }
  .practice { margin: 44px -16px 0; padding: 22px 16px 20px; border-radius: 0; }
  .opts button { font-size: 16px; }
  .hint { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pg.next { grid-column: 1; }
  .subs a { grid-template-columns: 22px 1fr auto; }
}
@media (max-width: 400px) {
  .top-in { gap: 8px; }
  .top nav { gap: 0; }
  .top nav a { padding: 6px 6px; font-size: 13px; }
}
@media (max-width: 360px) {
  .tiles { grid-template-columns: 1fr; }
}

/* ---------- Annotations and Ask Claude ---------- */
:root { --hl: rgba(255, 204, 0, 0.32); --hl-note: rgba(255, 170, 0, 0.42); --shadow: 0 8px 28px rgba(0, 0, 0, 0.14), 0 1px 3px rgba(0, 0, 0, 0.08); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --hl: rgba(255, 214, 10, 0.22); --hl-note: rgba(255, 179, 0, 0.32); --shadow: 0 8px 28px rgba(0, 0, 0, 0.5); } }
:root[data-theme="dark"] { --hl: rgba(255, 214, 10, 0.22); --hl-note: rgba(255, 179, 0, 0.32); --shadow: 0 8px 28px rgba(0, 0, 0, 0.5); }
mark.ann { background: var(--hl); color: inherit; border-radius: 2px; cursor: pointer; padding: 0 1px; }
mark.ann.has-note { background: var(--hl-note); box-shadow: inset 0 -1.5px 0 rgba(200, 120, 0, 0.7); }
mark.ann.flash { outline: 2px solid var(--accent); outline-offset: 2px; }
.ann-bar { position: fixed; z-index: 60; display: flex; gap: 2px; padding: 4px; background: var(--ink); border-radius: 10px; box-shadow: var(--shadow); }
.ann-bar button { font: 500 13px/1 var(--sans); color: var(--bg); background: transparent; border: 0; padding: 8px 10px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.ann-bar button:hover, .ann-bar button:focus-visible { background: rgba(127, 127, 127, 0.28); outline: none; }
body:not(.can-ask) .ask-only { display: none; }
.ann-pop { position: fixed; z-index: 61; width: min(360px, calc(100vw - 16px)); background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: grid; gap: 10px; }
.ann-pop blockquote, .ann-quote { margin: 0; padding: 2px 0 2px 10px; border-left: 2px solid var(--hl-note); color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.ann-pop textarea, .ann-chat-f textarea { width: 100%; font: 15px/1.45 var(--sans); color: var(--ink); background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; }
.ann-pop textarea:focus, .ann-chat-f textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.ann-row { display: flex; gap: 8px; align-items: center; }
.ann-flex { flex: 1; }
.ann-ui .btn { font: 500 14px/1 var(--sans); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink); cursor: pointer; }
.ann-ui .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ann-ui .btn.quiet { border-color: transparent; color: var(--muted); }
.ann-ui .btn:disabled { opacity: 0.5; cursor: default; }
.small { font-size: 13px; }
.ann-margin { margin: 40px 0 8px; max-width: var(--measure); }
.ann-hint { margin: 0; }
.ann-h { font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 0 8px; letter-spacing: 0; }
.ann-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ann-item { display: grid; gap: 2px; width: 100%; text-align: left; font: inherit; background: transparent; border: 0; border-left: 2px solid var(--hl-note); padding: 6px 10px; cursor: pointer; color: var(--ink); border-radius: 0 6px 6px 0; }
.ann-item:hover { background: var(--bg-2); }
.ann-q { font-size: 14px; color: var(--ink-2); }
.ann-t { font-size: 14px; }
.ann-k { font-size: 12px; color: var(--accent); font-weight: 600; }
.ann-chat { position: fixed; z-index: 55; top: calc(var(--header-h) + env(safe-area-inset-top, 0px)); right: 0; bottom: 0; width: min(420px, 100vw); display: flex; flex-direction: column; background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--shadow); padding-right: env(safe-area-inset-right, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.ann-chat-h { display: flex; gap: 8px; align-items: baseline; padding: 12px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.ann-chat-h .muted { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ann-chat-body { flex: 1; overflow-y: auto; padding: 16px; display: grid; gap: 14px; align-content: start; }
.ann-chat-f { border-top: 1px solid var(--line); padding: 12px 16px; display: grid; gap: 8px; }
.msg { font-size: 15px; line-height: 1.55; min-width: 0; overflow-wrap: anywhere; }
.msg.user { justify-self: end; max-width: 88%; background: var(--bg-2); border-radius: 12px; padding: 8px 12px; }
.msg.assistant p { margin: 0 0 0.6em; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.thinking { color: var(--muted); }
.msg .katex-display { overflow-x: auto; overflow-y: hidden; }
@media (min-width: 1200px) { body.chat-open main { padding-right: 420px; } }
.ann-group { padding-block: 18px; border-top: 1px solid var(--line); }
.ann-group h2 { font-size: 18px; margin: 0 0 10px; }
.ann-entry { margin: 0 0 12px; }
.ann-entry blockquote { margin: 0; padding-left: 12px; border-left: 2px solid var(--hl-note); color: var(--ink-2); }
.ann-entry p { margin: 6px 0 0 14px; }
.ann-entry summary { cursor: pointer; font-weight: 500; }
.ann-entry .msg { margin: 8px 0; }
@media (prefers-reduced-motion: no-preference) { .ann-bar, .ann-pop { animation: ann-in 120ms ease-out; } }
@keyframes ann-in { from { opacity: 0; transform: translateY(4px); } }
