/* DeepInfer Explained - site styles.
   A calm, light reading page (model: a long-form magazine article).
   Light is the default for everyone. Dark mode is opt-in only, through the
   toggle button (it sets data-theme="dark" on <html>); the system setting is
   ignored on purpose.
   Few boxes: white page, hairline rules, pale tints only where they help.
   One link colour. Role colours (emerald / violet / pink / teal / amber) are
   used only as small dots, thin rules and short labels.
   Custom property NAMES are shared with assets/viz/* and page <style> blocks:
   keep the names, change only the values. */

:root {
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", monospace;

  /* neutrals */
  --ink: #292929;          /* body text */
  --ink-strong: #141414;   /* headings */
  --mute: #6b6b6b;         /* secondary text (AA on white) */
  --gray-mid: #a3a3a3;
  --line: #d9d9d9;
  --border: #e9e9e9;
  --panel-bg: #f7f7f7;
  --cell-empty: #f4f4f4;
  --white: #ffffff;
  --bg: #ffffff;
  --surface: #ffffff;
  --sidebar-bg: #fafafa;

  /* role accents: strong + tint (used sparingly) */
  --blue: #1a5fb4;     --blue-tint: #eef3fa;
  --amber: #c26a00;    --amber-tint: #fdf8ef;  --amber-text: #8f4b00;
  --violet: #7c3aed;   --violet-tint: #f6f3fe;
  --teal: #0f766e;     --teal-tint: #f1f8f7;
  --emerald: #059669;  --emerald-tint: #eff8f4;
  --pink: #db2777;     --pink-tint: #fdf3f8;

  /* derived */
  --link: #1a5fb4;
  --link-hover: #0f4a91;
  --code-bg: #f6f8fa;
  --inline-code-bg: #f2f3f5;
  --code-lh: 23px;
  --hl-bg: rgba(26, 95, 180, 0.08);
  --hl-gutter: rgba(26, 95, 180, 0.14);
  --scrim: rgba(20, 20, 20, 0.35);
  --lightbox-bg: rgba(250, 250, 250, 0.97);
  --term-line: #b4b4b4;

  /* code tokens (GitHub light) */
  --tok-comment: #6a737d;
  --tok-keyword: #cf222e;
  --tok-string: #0a3069;
  --tok-number: #0550ae;
  --tok-function: #8250df;
  --tok-class: #953800;
  --tok-op: #3b4048;

  --sidebar-w: 268px;
  --topbar-h: 56px;
  --measure: 720px;     /* prose column */
  --wide: 1100px;       /* figures */
  color-scheme: light;
}

/* Dark mode: only when the reader picks it with the toggle. Warm dark gray, off-white text. */
:root[data-theme="dark"] {
  --ink: #e6e3de;
  --ink-strong: #f4f2ee;
  --mute: #a9a59f;
  --gray-mid: #77736e;
  --line: #45423e;
  --border: #363431;
  --panel-bg: #272624;
  --cell-empty: #2b2a28;
  --bg: #1e1d1b;
  --surface: #232220;
  --sidebar-bg: #212020;
  --blue: #8ab4ec;     --blue-tint: rgba(138, 180, 236, 0.10);
  --amber: #e0a85a;    --amber-tint: rgba(224, 168, 90, 0.08);  --amber-text: #e8b673;
  --violet: #b9a2f5;   --violet-tint: rgba(185, 162, 245, 0.10);
  --teal: #6fc7bc;     --teal-tint: rgba(111, 199, 188, 0.08);
  --emerald: #6fcf9f;  --emerald-tint: rgba(111, 207, 159, 0.10);
  --pink: #f09ac1;     --pink-tint: rgba(240, 154, 193, 0.10);
  --link: #8ab4ec;
  --link-hover: #b3cff5;
  --code-bg: #262523;
  --inline-code-bg: #2e2d2a;
  --hl-bg: rgba(138, 180, 236, 0.10);
  --hl-gutter: rgba(138, 180, 236, 0.18);
  --scrim: rgba(0, 0, 0, 0.5);
  --lightbox-bg: rgba(24, 23, 22, 0.97);
  --term-line: #6f6b66;
  --tok-comment: #9a968f;
  --tok-keyword: #f0907f;
  --tok-string: #a5c8f0;
  --tok-number: #8fc1ff;
  --tok-function: #c9b2f5;
  --tok-class: #e7b26f;
  --tok-op: #d6d2cc;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topbar-h) + 20px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  font-feature-settings: "cv11" 1, "ss01" 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 3px; }
code, kbd, pre { font-family: var(--mono); }
:not(pre) > code {
  font-size: 0.8em;
  background: var(--inline-code-bg);
  color: var(--ink);
  border-radius: 4px;
  padding: 0.12em 0.36em;
  overflow-wrap: anywhere;
}
kbd { font-size: 0.8em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.35em; background: var(--surface); }
img { max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 6px 10px; border: 1px solid var(--blue); }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink-strong); text-decoration: none; font-weight: 700; white-space: nowrap; }
.brand:hover { color: var(--ink-strong); text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--blue); color: #ffffff;
  font: 700 11px/1 var(--mono);
}
:root[data-theme="dark"] .brand-mark { color: #1e1d1b; }
.brand-name { font-size: 16px; letter-spacing: -0.01em; }
.search { position: relative; flex: 1; max-width: 400px; margin-left: auto; }
.search input {
  width: 100%; height: 36px;
  padding: 0 12px;
  border: 1px solid transparent; border-radius: 8px;
  background: var(--panel-bg); color: var(--ink);
  font: 14px var(--sans);
}
.search input:focus { background: var(--surface); border-color: var(--line); outline: none; }
.search input::placeholder { color: var(--mute); }
.search-results {
  position: absolute; right: 0; top: 44px;
  width: min(560px, calc(100vw - 32px));
  max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  padding: 6px;
}
.search-results a {
  display: block; padding: 8px 10px; border-radius: 6px;
  color: var(--ink); text-decoration: none;
}
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--panel-bg); color: var(--ink); text-decoration: none; }
.sr-top { display: flex; gap: 8px; align-items: baseline; }
.sr-title { font-weight: 600; font-size: 14.5px; }
.sr-kind { font-size: 12px; color: var(--mute); margin-left: auto; white-space: nowrap; }
.sr-sum { display: block; color: var(--mute); font-size: 13px; line-height: 1.45; margin-top: 2px; }
.sr-empty { padding: 10px; color: var(--mute); font-size: 14px; margin: 0; }
.search-results mark { background: #fff1c2; color: inherit; border-radius: 2px; }
:root[data-theme="dark"] .search-results mark { background: rgba(224, 168, 90, 0.3); }
.theme-btn, .menu-btn {
  flex: none; width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 8px;
  background: transparent; color: var(--mute); cursor: pointer;
}
.theme-btn:hover, .menu-btn:hover { background: var(--panel-bg); color: var(--ink); }
.menu-btn { display: none; gap: 3px; padding: 9px 8px; }
.menu-btn span { display: block; width: 18px; height: 2px; background: currentColor; border-radius: 1px; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 12px 48px;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  font-size: 14px;
}
.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-content: center;
  gap: 40px;
  padding: 36px 32px 72px;
  min-width: 0;
}
/* The article is a 3-track grid: prose sits in the centred middle track,
   figures (.diagram, .viz, .figure-img) span the full width. */
.article {
  min-width: 0; width: 100%; max-width: var(--wide); margin: 0 auto;
  display: grid;
  grid-template-columns: [full-start] minmax(0, 1fr) [prose-start] minmax(0, var(--measure)) [prose-end] minmax(0, 1fr) [full-end];
  align-content: start;
}
.article > * { grid-column: prose; min-width: 0; }
.article > .diagram, .article > .viz, .article > .figure-img { grid-column: full; }
@media (min-width: 1680px) {
  .main { grid-template-columns: minmax(0, var(--wide)) 200px; }
}

/* ---------- sidebar ---------- */
.nav-home { display: block; padding: 6px 10px; margin-bottom: 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 600; }
.nav-home:hover { background: var(--border); color: var(--ink); text-decoration: none; }
.nav-home.current { background: var(--blue-tint); color: var(--ink-strong); }
.nav-sec { margin: 2px 0 8px; }
.nav-sec > summary {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px;
  cursor: pointer; list-style: none;
  font-weight: 600; color: var(--ink-strong);
}
.nav-sec > summary::-webkit-details-marker { display: none; }
.nav-sec > summary::before {
  content: ""; width: 5px; height: 5px; flex: none;
  border-right: 1.5px solid var(--gray-mid); border-bottom: 1.5px solid var(--gray-mid);
  transform: rotate(-45deg); transition: transform 0.15s;
}
.nav-sec[open] > summary::before { transform: rotate(45deg); }
.nav-sec > summary:hover { background: var(--border); }
.nav-count { margin-left: auto; font-size: 11.5px; font-weight: 400; color: var(--gray-mid); font-variant-numeric: tabular-nums; }
.nav-group { margin: 12px 10px 3px 24px; font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: 0.06em; color: var(--gray-mid); }
.sidebar ul { list-style: none; margin: 0; padding: 0 0 0 14px; }
.sidebar li a, .sidebar li.soon {
  display: flex; align-items: baseline; gap: 6px;
  padding: 4px 10px; border-radius: 6px;
  line-height: 1.4;
}
.sidebar li a { color: var(--ink); text-decoration: none; }
.sidebar li a:hover { background: var(--border); color: var(--ink); text-decoration: none; }
.sidebar li a.current { background: var(--blue-tint); color: var(--ink-strong); font-weight: 500; box-shadow: inset 2px 0 0 var(--blue); }
.sidebar li.soon { color: var(--gray-mid); cursor: default; }
.soon-tag {
  margin-left: auto; flex: none;
  font-size: 10.5px; font-weight: 400; letter-spacing: 0.02em;
  color: var(--gray-mid);
}
/* "coming soon" in the text: plain muted words, no badge */
.soon-link { color: var(--mute); cursor: help; }
.article .soon-tag { display: none; }

/* ---------- article ---------- */
.article { font-size: 18px; line-height: 1.7; }
.breadcrumbs { font-size: 13.5px; line-height: 1.5; color: var(--mute); display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.breadcrumbs a { color: var(--mute); }
.breadcrumbs a:hover { color: var(--ink); }
.breadcrumbs .sep { color: var(--gray-mid); }
.page-title {
  font-size: clamp(30px, 4.2vw, 42px); line-height: 1.15; font-weight: 750;
  letter-spacing: -0.017em; color: var(--ink-strong);
  margin: 14px 0 14px; overflow-wrap: anywhere;
}
.page-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: 14.5px; line-height: 1.5; color: var(--mute); margin-bottom: 4px; }
.dd-toggle-all, .quiz-toggle {
  border: 0; background: none; color: var(--link);
  padding: 0; font-size: 14.5px; cursor: pointer;
}
.dd-toggle-all:hover, .quiz-toggle:hover { text-decoration: underline; text-underline-offset: 3px; }

/* code version under the title: one quiet line */
.article .code-version { margin: 0 0 28px; font-size: 13.5px; line-height: 1.5; color: var(--mute); }
.code-version a { color: var(--mute); }
.code-version a:hover { color: var(--link); text-decoration: none; }
.article .code-version code { font-size: 0.92em; background: var(--inline-code-bg); padding: 0.1em 0.4em; border-radius: 4px; }
.code-version a:hover code { background: var(--blue-tint); color: var(--link); }

/* level: a small coloured dot + muted text */
.level {
  display: inline-flex; align-items: center; gap: 7px;
  font: 500 14px/1 var(--sans); color: var(--mute);
}
.level::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gray-mid); }
.level-sm { font-size: 12.5px; gap: 5px; }
.level-sm::before { width: 6px; height: 6px; }
.level-beginner::before { background: var(--emerald); }
.level-intermediate::before { background: var(--violet); }
.level-advanced::before { background: var(--pink); }

.article h2, .article h3, .article h4 { color: var(--ink-strong); overflow-wrap: anywhere; }
.article h2 { font-size: 28px; line-height: 1.25; font-weight: 700; letter-spacing: -0.012em; margin: 34px 0 14px; }
.article h3 { font-size: 21.5px; line-height: 1.3; font-weight: 700; letter-spacing: -0.006em; margin: 24px 0 10px; }
.article h4 { font-size: 18px; line-height: 1.4; font-weight: 700; margin: 22px 0 6px; }
.h-anchor { margin-left: 8px; color: var(--gray-mid); text-decoration: none; font-weight: 400; opacity: 0; }
.h-anchor:hover { color: var(--mute); text-decoration: none; }
h2:hover .h-anchor, h3:hover .h-anchor, .h-anchor:focus { opacity: 1; }
.article p { margin: 0 0 1.05em; }
.article ul, .article ol { padding-left: 1.5em; margin: 0 0 1.05em; }
.article li { margin: 0.3em 0; }
.article li::marker { color: var(--mute); }
.article li > p { margin: 0 0 0.4em; }
.article dl { margin: 0 0 1em; }
.article strong { font-weight: 650; color: var(--ink-strong); }
.article hr { border: 0; border-top: 1px solid var(--border); margin: 36px 0; }
.article blockquote { margin: 0 0 1.05em; padding: 2px 0 2px 18px; border-left: 3px solid var(--line); color: var(--mute); }

/* tables: horizontal hairlines only; scroll inside themselves */
.article table {
  display: block; max-width: 100%; overflow-x: auto;
  border-collapse: collapse; margin: 6px 0 26px;
  font-size: 15.5px; line-height: 1.55;
}
.article th, .article td { border: 0; border-bottom: 1px solid var(--border); padding: 10px 18px 10px 0; text-align: left; vertical-align: top; }
.article th:last-child, .article td:last-child { padding-right: 0; }
.article th { font-weight: 600; color: var(--ink-strong); border-bottom: 1.5px solid var(--line); font-size: 14.5px; }
.article tbody tr:last-child td { border-bottom: 0; }
.article td code, .article th code { white-space: nowrap; overflow-wrap: normal; }
.article table.env-table { display: table; width: 100%; table-layout: fixed; }
.article .env-table th:first-child, .article .env-table td:first-child { width: 42%; }
.article .env-table td code { white-space: normal; overflow-wrap: anywhere; }
.article .env-table td:first-child > code:first-child { font-weight: 600; font-size: 0.76em; color: var(--ink-strong); }

.article pre:not(.code-excerpt pre) {
  margin: 0 0 22px; padding: 14px 18px;
  background: var(--code-bg); border: 0; border-radius: 8px;
  overflow-x: auto; font-size: 14.5px; line-height: var(--code-lh);
}

/* in one sentence: a lead paragraph, no box */
.one-sentence { margin: 0 0 14px; }
.one-sentence-label { margin: 0 0 6px !important; font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--mute); }
.one-sentence-text { margin: 0 !important; font-size: 21.5px; line-height: 1.55; font-weight: 400; color: var(--ink-strong); letter-spacing: -0.006em; }

/* before you read: one compact, quiet panel */
.before-read { margin: 0 0 26px; padding: 12px 16px; border-radius: 8px; background: var(--panel-bg); font-size: 15px; line-height: 1.6; color: var(--mute); }
.before-read-title { margin: 0 0 2px !important; font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--mute); }
.before-read p { margin: 0; display: inline; }
.before-read p:not(.before-read-title)::after { content: " "; }
.before-read-title { display: block !important; }
.before-read ul { display: inline; margin: 0; padding: 0; list-style: none; }
.before-read li { display: inline; margin: 0; }
.before-read li + li::before { content: " · "; color: var(--gray-mid); }
.before-read .level-sm { margin-left: 4px; vertical-align: 1px; }
.before-read a { font-weight: 500; }

/* callouts: a thin left rule and, for note/warning, a very pale tint */
.callout { margin: 6px 0 26px; padding: 14px 20px; border-left: 3px solid var(--line); border-radius: 0 6px 6px 0; font-size: 17px; line-height: 1.65; }
.callout-title { margin: 0 0 4px !important; font-weight: 650; font-size: 15.5px; color: var(--ink-strong); }
.callout-body > :last-child { margin-bottom: 0; }
.callout-note { border-left-color: var(--blue); background: var(--blue-tint); }
.callout-warning { border-left-color: var(--amber); background: var(--amber-tint); }
.callout-warning .callout-title { color: var(--amber-text); }
.callout-simplified { border-left-color: var(--line); background: transparent; padding-top: 4px; padding-bottom: 4px; }
.callout-simplified .callout-title { color: var(--mute); }

/* deep dive: a clean expandable section with a simple header row */
.deepdive { margin: 6px 0 26px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.deepdive + .deepdive { margin-top: -27px; border-top: 0; }
.deepdive > summary {
  display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap;
  padding: 14px 2px; cursor: pointer; list-style: none;
}
.deepdive > summary:hover .dd-title { color: var(--link); }
.deepdive > summary::-webkit-details-marker { display: none; }
.deepdive > summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px; flex: none;
  border-right: 1.5px solid var(--mute); border-bottom: 1.5px solid var(--mute);
  transform: rotate(45deg) translate(-2px, -2px); transition: transform 0.15s;
}
.deepdive[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.dd-label { flex: none; font: 600 11.5px var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--teal); }
.article .dd-title { margin: 0; font-size: 19px; line-height: 1.35; flex: 1 1 260px; }
.dd-body { padding: 2px 0 10px; }
.dd-body > h4:first-child { margin-top: 8px; }

/* tours */
.stop { margin-top: 8px; }
.stop-title { display: flex; align-items: center; gap: 12px; }
.stop-num { flex: none; display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--panel-bg); border: 1px solid var(--line); color: var(--ink-strong); font: 700 14px var(--sans); }

/* quiz: a plain numbered list */
.quiz h2 { margin-bottom: 12px; }
.q-list { list-style: none; padding: 0 !important; margin: 0; }
.q { margin: 0 !important; padding: 16px 0; border-bottom: 1px solid var(--border); }
.q:first-child { border-top: 1px solid var(--border); }
.q-text { display: flex; gap: 12px; align-items: baseline; }
.q-text > div { flex: 1; }
.q-text p:last-child { margin-bottom: 0; }
.q-num { flex: none; min-width: 1.4em; font-weight: 700; color: var(--mute); font-variant-numeric: tabular-nums; }
.q-num::after { content: "."; }
.q-level { flex: none; font-size: 12.5px; color: var(--gray-mid); }
.q-answer { margin: 8px 0 0 calc(1.4em + 12px); }
.q-answer > summary { cursor: pointer; color: var(--link); font-size: 15px; font-weight: 500; width: fit-content; }
.q-answer-body { margin-top: 10px; padding: 2px 0 2px 16px; border-left: 2px solid var(--line); }
.q-answer-body > :last-child { margin-bottom: 0; }
.quiz-tools { margin: 14px 0 0; }

/* related + prev/next */
.related ul { list-style: none; padding: 0 !important; margin: 0; }
.related li { margin: 0 0 10px; }
.related li a { font-weight: 600; }
.related .soon-link { color: var(--mute); }
.rel-sum { display: block; color: var(--mute); font-size: 15.5px; line-height: 1.5; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 56px 0 28px; }
.pn { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--ink); min-width: 0; }
.pn:hover { border-color: var(--line); background: var(--panel-bg); text-decoration: none; color: var(--ink); }
.pn-next { text-align: right; grid-column: 2; }
.pn-dir { font-size: 13px; color: var(--mute); }
.pn-title { font-weight: 600; font-size: 16.5px; color: var(--link); overflow-wrap: anywhere; }
.page-foot { font-size: 13px; line-height: 1.6; color: var(--mute); border-top: 1px solid var(--border); padding-top: 16px; margin-top: 8px; }
.page-foot a { color: var(--mute); text-decoration: underline; text-decoration-color: var(--line); }
.page-foot p { margin: 0 0 6px; }
.page-foot .foot-sha { font-size: 0.95em; background: none; padding: 0; color: inherit; overflow-wrap: anywhere; }

/* table of contents (only on very wide screens) */
.toc { display: none; }
@media (min-width: 1680px) {
  .toc {
    display: block; position: sticky; top: calc(var(--topbar-h) + 36px);
    align-self: start; max-height: calc(100vh - var(--topbar-h) - 60px); overflow-y: auto;
    font-size: 13px;
  }
}
.toc-title { margin: 0 0 8px; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--gray-mid); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: 3px 0; color: var(--mute); text-decoration: none; line-height: 1.4; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--ink-strong); font-weight: 600; }
.toc-l3 a { padding-left: 12px; font-size: 12.5px; }

/* glossary terms: a quiet dotted underline + tooltip */
a.term { color: inherit; text-decoration: underline dotted var(--term-line); text-decoration-thickness: 1.5px; text-underline-offset: 4px; cursor: help; }
a.term:hover { color: inherit; text-decoration-color: var(--link); text-decoration-style: dotted; }
.tooltip {
  position: fixed; z-index: 60; max-width: min(340px, calc(100vw - 24px));
  padding: 10px 13px; border-radius: 8px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.10);
  font-size: 14px; line-height: 1.5;
  pointer-events: none;
}
.tooltip strong { display: block; margin-bottom: 2px; color: var(--ink-strong); }
.tooltip .tt-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--mute); }

/* code citations (file:line): a small light-gray monospace pill */
a.cite { text-decoration: none; }
a.cite code { font-size: 0.74em; color: var(--mute); background: var(--inline-code-bg); padding: 0.18em 0.45em; border-radius: 5px; vertical-align: 0.06em; }
a.cite:hover { text-decoration: none; }
a.cite:hover code { color: var(--link); background: var(--blue-tint); }

/* ---------- code excerpts ---------- */
.code-excerpt { margin: 6px 0 28px; }
.code-excerpt > .code-head { background: var(--code-bg); border-radius: 8px 8px 0 0; }
.code-excerpt > .code-body { background: var(--code-bg); border-radius: 0 0 8px 8px; overflow: hidden; }
.code-excerpt:has(.code-tr) > .code-body { border-radius: 0; }
.code-head {
  display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap;
  padding: 9px 14px 0; font-size: 12.5px; line-height: 1.5;
}
.code-title { font-weight: 600; color: var(--ink); font-size: 13px; }
.code-path { font-family: var(--mono); color: var(--mute); text-decoration: none; overflow-wrap: anywhere; min-width: 0; }
.code-path:hover { color: var(--link); }
.code-actions { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.code-gh { color: var(--mute); text-decoration: none; white-space: nowrap; }
.code-gh:hover { color: var(--link); }
.code-copy { border: 0; background: none; color: var(--mute); padding: 0; font-size: 12.5px; cursor: pointer; }
.code-copy:hover { color: var(--ink); }
.code-copy.done { color: var(--emerald); }
.code-body { display: flex; font: 14.5px/var(--code-lh) var(--mono); }
.code-gutter {
  flex: none; padding: 10px 0 14px; text-align: right; user-select: none;
  color: var(--gray-mid); font-size: 12.5px;
}
.code-gutter .ln { display: block; height: var(--code-lh); padding: 0 6px 0 14px; }
.code-gutter .ln.hl { background: var(--hl-gutter); color: var(--ink); font-weight: 600; }
.code-scroll { flex: 1; min-width: 0; overflow-x: auto; }
.code-inner { position: relative; width: max-content; min-width: 100%; padding: 10px 0 14px; }
.hl-bar { position: absolute; left: 0; right: 0; height: var(--code-lh); margin-top: 10px; background: var(--hl-bg); pointer-events: none; }
.code-excerpt pre { margin: 0; padding: 0 18px 0 12px; background: transparent; position: relative; font: inherit; line-height: var(--code-lh); tab-size: 4; }
.code-excerpt pre code { font: inherit; background: none; border: 0; padding: 0; white-space: pre; color: var(--ink); }
.code-caption { padding: 10px 2px 0; background: var(--bg); font-size: 15px; line-height: 1.55; font-style: italic; color: var(--mute); }
.code-tr { padding: 10px 14px 12px; background: var(--code-bg); border-radius: 0 0 8px 8px; border-top: 1px solid var(--border); font-size: 15px; line-height: 1.55; }
.code-tr-title { margin: 0 0 4px !important; font-weight: 600; font-size: 12.5px; color: var(--mute); }
.code-tr ul { margin: 0 !important; padding-left: 0 !important; list-style: none; }
.code-tr li { margin: 3px 0; }
.tr-line { display: inline-block; min-width: 3.4em; font: 500 12.5px var(--mono); color: var(--mute); }
.tr-line::before { content: "line "; font-weight: 400; }
.code-tr + .code-caption { border-top: 0; }

/* prism tokens (only applied when Prism loads; plain text otherwise) */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: var(--tok-comment); font-style: italic; }
.token.keyword, .token.builtin, .token.important, .token.atrule { color: var(--tok-keyword); }
.token.string, .token.char, .token.attr-value, .token.regex, .token.triple-quoted-string { color: var(--tok-string); }
.token.number, .token.boolean, .token.constant { color: var(--tok-number); }
.token.function, .token.decorator, .token.annotation { color: var(--tok-function); }
.token.class-name, .token.macro, .token.directive { color: var(--tok-class); }
.token.operator, .token.punctuation { color: var(--tok-op); }

/* ---------- diagrams: full width, hairline frame, italic caption below ---------- */
.diagram { margin: 14px 0 34px; }
.diagram-card { background: #ffffff; border: 1px solid var(--border); border-radius: 6px; padding: 0; overflow: hidden; }
:root[data-theme="dark"] .diagram-card { border-color: transparent; }
.diagram-zoom { all: unset; display: block; width: 100%; cursor: zoom-in; }
.diagram-zoom:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.diagram-zoom svg { display: block; width: 100%; height: auto; }
.diagram-meta {
  max-width: var(--measure); margin: 10px auto 0;
  text-align: center; font-size: 15px; line-height: 1.55; color: var(--mute);
}
.diagram-meta figcaption { display: inline; font-style: italic; }
.diagram-meta figcaption code { font-style: normal; }
.diagram-open { display: inline-block; margin-left: 10px; font-size: 13px; white-space: nowrap; color: var(--mute); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.diagram-open:hover { color: var(--link); }
.lightbox { position: fixed; inset: 0; z-index: 80; background: var(--lightbox-bg); display: flex; flex-direction: column; }
.lightbox[hidden] { display: none; }
.lightbox-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--mute); font-size: 13px; background: var(--bg); border-bottom: 1px solid var(--border); }
.lightbox-close { margin-left: auto; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 6px; padding: 4px 12px; cursor: pointer; }
.lightbox-body { flex: 1; overflow: auto; padding: 16px; }
.lightbox-body svg { display: block; background: #ffffff; border-radius: 6px; margin: 0 auto; max-width: none; box-shadow: 0 0 0 1px var(--border); }

/* ---------- glossary page ---------- */
.glossary-jump { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.glossary-jump a { font: 600 15px var(--sans); padding: 2px 6px; border-radius: 4px; text-decoration: none; }
.glossary-jump a:hover { background: var(--panel-bg); }
dl.glossary dt { font-weight: 700; font-size: 19px; color: var(--ink-strong); margin-top: 24px; scroll-margin-top: calc(var(--topbar-h) + 20px); }
dl.glossary dt:target { color: var(--link); }
dl.glossary dd { margin: 4px 0 0; padding-left: 0; border-left: 0; }
.g-alias { font-weight: 400; font-size: 14px; color: var(--mute); margin-left: 6px; }
.g-short { font-weight: 400; }
.g-more { font-size: 15.5px; color: var(--mute); }

/* ---------- home ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 16px 0 24px; padding: 0 !important; list-style: none; }
.cards > li { margin: 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; }
/* Lighter versions of page-local styles (src/index.html, src/code/index.html).
   Higher specificity so they win over the page <style> blocks. */
/* The page-local styles in src/index.html own the look of the map boxes; here only the width. */
.article > .sm { grid-column: full; justify-self: center; width: 100%; max-width: 980px; margin: 14px 0 28px; }
.article .sm-d { font-size: 14.5px; line-height: 1.5; }
.article .paths > li { border: 0; padding: 0; border-radius: 0; }
.article .paths h3 { font-size: 18px; }
.article .paths ol, .article .paths ul { font-size: 16px; padding-left: 1.7em; }
.article .ct-tag { border: 0; padding: 0; color: var(--gray-mid); }
.article .ct-name { font-size: 15px; }
.article .ct-body { font-size: 16px; }

/* ---------- mobile ---------- */
.scrim { position: fixed; inset: var(--topbar-h) 0 0 0; background: var(--scrim); z-index: 34; }
.scrim[hidden] { display: none; }
@media (max-width: 1100px) {
  .main { padding: 32px 28px 64px; }
}
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-grid; }
  .sidebar {
    position: fixed; z-index: 35; left: 0; top: var(--topbar-h);
    width: min(320px, 86vw); height: calc(100vh - var(--topbar-h));
    transform: translateX(-102%); transition: transform 0.2s ease;
    border-right: 1px solid var(--line);
    background: var(--bg);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open { overflow: hidden; }
  .main { padding: 24px 16px 48px; }
}
@media (max-width: 560px) {
  .brand-name { display: none; }
  .search { max-width: none; }
  .topbar { gap: 8px; padding: 0 12px; }
  .article { font-size: 17px; line-height: 1.68; }
  .page-title { font-size: 29px; }
  .article h2 { font-size: 23.5px; margin-top: 34px; }
  .article h3 { font-size: 19.5px; }
  .article .dd-title { font-size: 17.5px; }
  .one-sentence-text { font-size: 19px; }
  .callout { padding: 12px 14px; font-size: 16px; }
  .prevnext { grid-template-columns: 1fr; }
  .pn-next { grid-column: 1; }
  .code-body { font-size: 13.5px; }
  .code-gutter .ln { padding: 0 4px 0 8px; }
  .code-excerpt pre { padding: 0 12px 0 8px; }
  .code-head { padding: 8px 12px 0; }
  .q-answer { margin-left: 0; }
  .article table { font-size: 14.5px; }
  .article table.env-table, .article .env-table tbody, .article .env-table tr, .article .env-table td { display: block; width: 100% !important; }
  .article .env-table thead { display: none; }
  .article .env-table tr { padding: 14px 0; border-bottom: 1px solid var(--border); }
  .article .env-table tbody tr:last-child { border-bottom: 0; }
  .article .env-table td { border: 0; padding: 0; }
  .article .env-table td:first-child { color: var(--mute); font-size: 14px; }
  .article .env-table td:first-child > code:first-child { display: inline-block; margin-bottom: 2px; font-size: 14.5px; }
  .article .env-table td + td { margin-top: 8px; }
  .diagram-meta { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .topbar, .sidebar, .toc, .prevnext, .code-copy, .dd-toggle-all, .quiz-toggle { display: none !important; }
  .layout { display: block; }
  .deepdive > .dd-body, .q-answer-body { display: block !important; }
}
