/* Gyre documentation theme.
 *
 * Hand-written, no build step.  Structure:
 *   1. tokens (light / dark)      5. depth system (dial, blocks, map)
 *   2. base + typography          6. components (callouts, tabs, code, tables, math)
 *   3. layout (topbar, shell)     7. data components (charts, fields, status)
 *   4. navigation + rail          8. home page, search, footer, print
 *
 * Colour roles.  The four depth levels use one hue stepped in lightness (an ordinal
 * ramp, validated: monotone, >= 0.06 OKLCH L between steps, lightest step >= 2:1 on
 * the surface, and each --lvN-ink at least 4.5:1 on its --lvN: the dial prints a digit
 * on every step).  All text meets WCAG AA (4.5:1) in both themes; tests/test_docsite.py
 * computes the ratios from the tokens below, and docs/theme/tools/contrast_sweep.js
 * measures them in a browser.  Text is never dimmed with opacity.  Chart series use a fixed categorical order validated for
 * colour-vision deficiency on both surfaces; status colours are reserved for
 * pass / fail and always carry an icon and a word.
 */

/* ---------------------------------------------------------------- 1. tokens */

:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --surface: #fdfcf9;
  --surface-2: #efede6;
  --surface-3: #e6e3da;
  --ink: #17212b;
  --ink-2: #414d59;
  --muted: #5f6b76;
  --rule: #dcd9cf;
  --rule-2: #c6c2b5;
  --accent: #006687;
  --accent-strong: #004f6a;
  --accent-wash: rgba(0, 102, 135, 0.08);
  --accent-wash-2: rgba(0, 102, 135, 0.14);
  --focus: #0b7fa6;
  --mark: #ffe9a8;

  /* depth levels: ordinal ramp, shallow -> deep */
  --lv1: #72bdda;  --lv1-ink: #082530;
  --lv2: #1a7d9f;  --lv2-ink: #ffffff;
  --lv3: #006687;  --lv3-ink: #ffffff;
  --lv4: #003a53;  --lv4-ink: #ffffff;

  /* callouts */
  --c-note: #2a78d6;
  --c-tip: #12946a;
  --c-warning: #c98500;
  --c-definition: #6250d6;
  --c-result: #008300;

  /* status (reserved) */
  --good: #0ca30c;
  --good-ink: #006300;
  --critical: #d03b3b;
  --critical-ink: #a82424;
  --warn: #c98500;

  /* chart chrome + categorical series (fixed order) */
  --grid: #e4e1d8;
  --axis: #b9b5a8;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --series-other: #8a8f96;

  /* code */
  --code-bg: #f1efe8;
  --code-ink: #1d2733;
  --tok-comment: #586470;
  --tok-keyword: #6a3fb5;
  --tok-string: #2c6b2f;
  --tok-number: #a55200;
  --tok-func: #005f8a;
  --tok-builtin: #7a5200;
  --tok-tag: #9a2f5c;
  --tok-punct: #4a5662;

  --shadow: 0 1px 2px rgba(23, 33, 43, 0.06), 0 8px 24px rgba(23, 33, 43, 0.08);
  --shadow-lg: 0 2px 6px rgba(23, 33, 43, 0.08), 0 24px 60px rgba(23, 33, 43, 0.18);

  --font-prose: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Iowan Old Style",
    "Palatino Linotype", "URW Palladio L", P052, "DejaVu Serif", Georgia, serif;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans",
    "Liberation Sans", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", "DejaVu Sans Mono", monospace;

  --topbar-h: 56px;
  --side-w: 276px;
  --rail-w: 252px;
  --measure: 46rem;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1319;
    --surface: #131b23;
    --surface-2: #1a2430;
    --surface-3: #223040;
    --ink: #e7edf1;
    --ink-2: #b9c4cc;
    --muted: #8a99a5;
    --rule: #25313d;
    --rule-2: #364554;
    --accent: #62c8df;
    --accent-strong: #9ddff0;
    --accent-wash: rgba(98, 200, 223, 0.09);
    --accent-wash-2: rgba(98, 200, 223, 0.17);
    --focus: #8ad8ea;
    --mark: #5c4a12;
    --lv1: #136782;  --lv1-ink: #ffffff;
    --lv2: #1c7fa0;  --lv2-ink: #ffffff;
    --lv3: #50b2d6;  --lv3-ink: #06222c;
    --lv4: #9bdcf6;  --lv4-ink: #06222c;
    --c-note: #3987e5;
    --c-tip: #199e70;
    --c-warning: #c98500;
    --c-definition: #9085e9;
    --c-result: #0ca30c;
    --good: #0ca30c;
    --good-ink: #5fd35f;
    --critical: #e05252;
    --critical-ink: #f08a8a;
    --warn: #e0a019;
    --grid: #222d38;
    --axis: #3b4a59;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --series-other: #7b8791;
    --code-bg: #111920;
    --code-ink: #dbe4ea;
    --tok-comment: #7d8b97;
    --tok-keyword: #b9a3ff;
    --tok-string: #8fd19e;
    --tok-number: #f0b072;
    --tok-func: #7cc8ea;
    --tok-builtin: #e5c07b;
    --tok-tag: #f092b6;
    --tok-punct: #a9b6c1;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1319;
  --surface: #131b23;
  --surface-2: #1a2430;
  --surface-3: #223040;
  --ink: #e7edf1;
  --ink-2: #b9c4cc;
  --muted: #8a99a5;
  --rule: #25313d;
  --rule-2: #364554;
  --accent: #62c8df;
  --accent-strong: #9ddff0;
  --accent-wash: rgba(98, 200, 223, 0.09);
  --accent-wash-2: rgba(98, 200, 223, 0.17);
  --focus: #8ad8ea;
  --mark: #5c4a12;
  --lv1: #136782;  --lv1-ink: #ffffff;
  --lv2: #1c7fa0;  --lv2-ink: #ffffff;
  --lv3: #50b2d6;  --lv3-ink: #06222c;
  --lv4: #9bdcf6;  --lv4-ink: #06222c;
  --c-note: #3987e5;
  --c-tip: #199e70;
  --c-warning: #c98500;
  --c-definition: #9085e9;
  --c-result: #0ca30c;
  --good: #0ca30c;
  --good-ink: #5fd35f;
  --critical: #e05252;
  --critical-ink: #f08a8a;
  --warn: #e0a019;
  --grid: #222d38;
  --axis: #3b4a59;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #7b8791;
  --code-bg: #111920;
  --code-ink: #dbe4ea;
  --tok-comment: #7d8b97;
  --tok-keyword: #b9a3ff;
  --tok-string: #8fd19e;
  --tok-number: #f0b072;
  --tok-func: #7cc8ea;
  --tok-builtin: #e5c07b;
  --tok-tag: #f092b6;
  --tok-punct: #a9b6c1;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.5), 0 24px 60px rgba(0, 0, 0, 0.55);
}

/* ------------------------------------------------------ 2. base + typography */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* Anchors clear the sticky top bar.  (scroll-padding on <html> would do the same but
   also makes the browser scroll the page whenever a control inside the bar is focused.) */
[id] { scroll-margin-top: calc(var(--topbar-h) + 16px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-strong); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 3px;
}

button { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 8px 14px; border-radius: var(--radius);
  background: var(--accent); color: var(--bg); font-weight: 600; text-decoration: none;
}
.skip:focus { top: 10px; color: var(--bg); }

.icon {
  width: 1.1em; height: 1.1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.16em;
}

kbd {
  font: 600 0.72rem/1 var(--font-mono);
  padding: 3px 5px; border: 1px solid var(--rule-2); border-bottom-width: 2px;
  border-radius: 4px; background: var(--surface); color: var(--ink-2);
}

/* long-form text */
.prose {
  font-family: var(--font-prose);
  font-size: 1.0625rem;
  line-height: 1.68;
  color: var(--ink);
  overflow-wrap: break-word;
}
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose dl, .prose blockquote { margin: 0 0 1.05em; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li { margin: 0.25em 0; }
.prose li > p { margin: 0.35em 0; }
.prose li::marker { color: var(--muted); }
.prose strong { font-weight: 700; }
.prose hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }
.prose blockquote {
  margin-left: 0; padding: 0.1em 0 0.1em 1.1em;
  border-left: 3px solid var(--rule-2); color: var(--ink-2); font-style: italic;
}
.prose dt { font-family: var(--font-ui); font-weight: 650; font-size: 0.95rem; margin-top: 0.9em; }
.prose dd { margin: 0.15em 0 0.5em 1.4em; }
.prose mark { background: var(--mark); color: inherit; padding: 0 0.15em; border-radius: 2px; }
.prose abbr[title] { text-decoration: underline dotted; cursor: help; }
.prose img { height: auto; border-radius: 6px; }

.prose h2, .prose h3, .prose h4, .prose h5 {
  font-family: var(--font-ui);
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -0.012em;
  position: relative;
}
.prose h2 {
  font-size: 1.5rem; font-weight: 680;
  margin: 2.5em 0 0.7em; padding-top: 0.9em;
  border-top: 1px solid var(--rule);
}
.prose h3 { font-size: 1.18rem; font-weight: 660; margin: 2em 0 0.55em; }
.prose h4 { font-size: 1rem; font-weight: 660; margin: 1.6em 0 0.4em; }
.prose h5 {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--ink-2); margin: 1.5em 0 0.35em;
}
.prose .lv-body > h2:first-child, .prose .lv-body > h3:first-child { margin-top: 0.4em; }

.hanchor {
  position: absolute; left: -1.05em; top: auto; width: 1em;
  font-weight: 400; text-decoration: none; color: var(--muted); opacity: 0;
  transition: opacity 0.12s;
}
.prose h2 > .hanchor { top: 0.9em; }
.prose :is(h2, h3, h4):hover > .hanchor, .hanchor:focus-visible { opacity: 1; }

.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.prose a:hover { text-decoration-color: currentColor; }
.prose a[href^="http"]::after {
  content: "\2197"; font-family: var(--font-ui); font-size: 0.72em;
  margin-left: 0.12em; vertical-align: 0.25em; text-decoration: none; display: inline-block;
}

:not(pre) > code {
  font-family: var(--font-mono); font-size: 0.86em;
  padding: 0.12em 0.36em; border-radius: 4px;
  background: var(--surface-2); color: var(--code-ink);
  overflow-wrap: anywhere;
}

/* ------------------------------------------------------------------ 3. layout */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(12px, 2vw, 24px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  color: var(--ink); text-decoration: none; margin-right: 6px;
}
.brand:hover { color: var(--ink); }
.brand-mark { width: 27px; height: 27px; color: var(--accent); flex: none; }
.brand-name { font-size: 1.12rem; font-weight: 720; letter-spacing: -0.02em; }
.brand-tag {
  font-size: 0.66rem; font-weight: 650; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); padding: 2px 6px; border: 1px solid var(--rule-2); border-radius: 999px;
}

.topbar-space { flex: 1 1 auto; }

.iconbtn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; flex: none;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn .icon { width: 19px; height: 19px; }
.nav-toggle { display: none; }

.search-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  flex: 0 1 250px; min-width: 0; height: 36px; padding: 0 9px 0 11px;
  border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); color: var(--muted); cursor: pointer; text-align: left;
  font-size: 0.88rem;
}
.search-trigger:hover { border-color: var(--rule-2); color: var(--ink-2); }
.search-trigger span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toplink {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px;
  border-radius: var(--radius); color: var(--ink-2); text-decoration: none;
  font-size: 0.86rem; font-weight: 600;
}
.toplink:hover { background: var(--surface-2); color: var(--ink); }

.theme-toggle .icon { display: none; }
html:not([data-theme]) .theme-toggle .i-auto,
html[data-theme="light"] .theme-toggle .i-light,
html[data-theme="dark"] .theme-toggle .i-dark { display: block; }

.shell {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr) var(--rail-w);
  max-width: 1480px; margin: 0 auto;
  align-items: start;
}

.sidebar { grid-column: 1; grid-row: 1; }
.main { grid-column: 2; grid-row: 1; min-width: 0; padding: clamp(20px, 3.4vw, 44px) clamp(16px, 3.6vw, 56px) 64px; }
.rail { grid-column: 3; grid-row: 1; }
.doc { max-width: var(--measure); margin: 0 auto; }

/* ------------------------------------------------------ 4. navigation + rail */

.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 14px 40px 20px;
  border-right: 1px solid var(--rule);
  font-size: 0.875rem;
  scrollbar-width: thin;
}
.side-home {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; margin-bottom: 14px; border-radius: 6px;
  color: var(--ink-2); text-decoration: none; font-weight: 600;
}
.side-home:hover, .side-home[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.side-sec { margin: 0 0 18px; }
.side-title {
  margin: 0 0 4px; padding: 0 10px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted);
}
.side-title a { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 6px; }
.side-title a:hover, .side-title a[aria-current="page"] { color: var(--accent); }
.side-sec ul { list-style: none; margin: 0; padding: 0; }
.side-sec li a {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 6px;
  color: var(--ink-2); text-decoration: none; line-height: 1.35;
}
.side-sec li a span:first-child { flex: 1; min-width: 0; }
.side-sec li a:hover { background: var(--surface-2); color: var(--ink); }
.side-sec li a[aria-current="page"] {
  background: var(--accent-wash-2); color: var(--ink); font-weight: 650;
  box-shadow: inset 2px 0 0 var(--accent);
}
.side-legend {
  margin: 26px 10px 0; padding-top: 14px; border-top: 1px solid var(--rule);
  font-size: 0.74rem; color: var(--muted); line-height: 1.5;
}
.side-legend .lvg { margin-right: 4px; }

.scrim { display: none; }

.rail {
  position: sticky; top: var(--topbar-h);
  max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; overscroll-behavior: contain;
  padding: 30px 20px 40px 8px;
  font-size: 0.8rem;
  scrollbar-width: thin;
}
.rail-title {
  margin: 0 0 8px;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}

.toc { margin-top: 26px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc li a {
  display: flex; align-items: baseline; gap: 7px;
  padding: 3.5px 8px 3.5px 10px; margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--ink-2); text-decoration: none; line-height: 1.35;
}
.toc li a > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.toc li.toc-d3 a { padding-left: 22px; }
.toc li.toc-block a { color: var(--muted); }
.toc li a:hover { color: var(--accent); }
.toc li a.is-current { border-left-color: var(--accent); color: var(--ink); font-weight: 600; }
.toc .lvg { transform: translateY(1px); }
.toc .katex { font-size: 1em; }

/* -------------------------------------------------------- 5. the depth system */

/* level glyph: four rising bars, the first n lit with the ramp */
.lvg {
  display: inline-flex; align-items: flex-end; gap: 1.5px; flex: none;
  height: 11px; vertical-align: -1px;
}
.lvg i { display: block; width: 3px; border-radius: 1px; background: var(--rule-2); }
.lvg i:nth-child(1) { height: 4px; }
.lvg i:nth-child(2) { height: 6.5px; }
.lvg i:nth-child(3) { height: 9px; }
.lvg i:nth-child(4) { height: 11px; }
.lvg[data-level="1"] i:nth-child(-n+1),
.lvg[data-level="2"] i:nth-child(-n+2),
.lvg[data-level="3"] i:nth-child(-n+3),
.lvg[data-level="4"] i:nth-child(-n+4) { background: var(--lv-glyph, var(--lv3)); }
.lvg[data-level="1"] { --lv-glyph: var(--lv1); }
.lvg[data-level="2"] { --lv-glyph: var(--lv2); }
.lvg[data-level="3"] { --lv-glyph: var(--lv3); }
.lvg[data-level="4"] { --lv-glyph: var(--lv4); }
.lvg-text {
  margin-left: 5px; align-self: center;
  font: 700 0.68rem/1 var(--font-ui); letter-spacing: 0.04em; color: var(--ink-2);
}

/* the dial */
.dial { display: inline-flex; align-items: center; gap: 9px; flex: none; }
.dial-label {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted);
}
.dial-stops {
  display: inline-flex; padding: 2px; gap: 2px;
  border: 1px solid var(--rule-2); border-radius: 999px; background: var(--surface);
}
.dial-stop { position: relative; display: block; }
.dial-stop[data-level="1"] { --lv: var(--lv1); --lv-ink: var(--lv1-ink); }
.dial-stop[data-level="2"] { --lv: var(--lv2); --lv-ink: var(--lv2-ink); }
.dial-stop[data-level="3"] { --lv: var(--lv3); --lv-ink: var(--lv3-ink); }
.dial-stop[data-level="4"] { --lv: var(--lv4); --lv-ink: var(--lv4-ink); }
.dial-stop input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: pointer;
}
.dial-cell {
  display: grid; place-items: center;
  width: 31px; height: 27px; border-radius: 4px;
  font-size: 0.8rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--muted);
  transition: background-color 0.16s, color 0.16s;
}
.dial-stop:first-child .dial-cell { border-radius: 999px 4px 4px 999px; }
.dial-stop:last-child .dial-cell { border-radius: 4px 999px 999px 4px; }
.dial-stop:hover .dial-cell { color: var(--ink); background: var(--surface-2); }
html[data-depth="1"] .dial-stop[data-level="1"] .dial-cell,
html[data-depth="2"] .dial-stop:is([data-level="1"], [data-level="2"]) .dial-cell,
html[data-depth="3"] .dial-stop:is([data-level="1"], [data-level="2"], [data-level="3"]) .dial-cell,
html[data-depth="4"] .dial-stop .dial-cell { background: var(--lv); color: var(--lv-ink); }
.dial-stop input:focus-visible + .dial-cell { outline: 2px solid var(--focus); outline-offset: 2px; }
.dial-name {
  min-width: 5.6em; font-size: 0.84rem; font-weight: 650; color: var(--ink);
  white-space: nowrap;
}
.dial-name small { display: block; font-size: 0.68rem; font-weight: 500; color: var(--muted); line-height: 1.1; }

/* level blocks */
.lv { --lv: var(--lv1); position: relative; margin: 1.5rem 0; }
.lv[data-level="2"] { --lv: var(--lv2); }
.lv[data-level="3"] { --lv: var(--lv3); }
.lv[data-level="4"] { --lv: var(--lv4); }

.lv-toggle {
  appearance: none; border: 0; background: none; margin: 0; text-align: left;
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.2rem 0; cursor: pointer;
  font-family: var(--font-ui); color: var(--ink); line-height: 1.3;
}
.lv-kicker {
  flex: none; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2); white-space: nowrap;
}
.lv-title { flex: 1 1 auto; min-width: 0; font-size: 1rem; font-weight: 660; letter-spacing: -0.005em; }
.lv-teaser { font-family: var(--font-prose); font-weight: 400; font-style: italic; color: var(--ink-2); }
.lv-meta { flex: none; font-size: 0.74rem; color: var(--muted); white-space: nowrap; display: none; }
.lv-chevron { flex: none; color: var(--muted); transition: transform 0.16s; transform: rotate(180deg); }
.lv-toggle:hover .lv-chevron { color: var(--accent); }

/* open, explicit: a rail in the level's colour */
.lv:not(.lv-implicit) { padding-left: 1.05rem; border-left: 3px solid var(--lv); }
.lv:not(.lv-implicit) > .lv-head { margin-bottom: 0.55rem; }
.lv-body > :first-child { margin-top: 0; }
.lv-body > :last-child { margin-bottom: 0; }
/* open, implicit (the page's own level): seamless */
.lv-implicit > .lv-head { display: none; }

/* folded: a compact "go deeper" stub.  Driven by the dial (html[data-depth]) and by the
   reader's per-block choice ([data-user]); see site.js. */
html[data-depth="1"] .lv:is([data-level="2"], [data-level="3"], [data-level="4"]):not([data-user="open"]),
html[data-depth="2"] .lv:is([data-level="3"], [data-level="4"]):not([data-user="open"]),
html[data-depth="3"] .lv[data-level="4"]:not([data-user="open"]),
.lv[data-user="closed"] {
  padding: 0;
  border: 1px solid var(--rule); border-left: 3px solid var(--lv);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface);
  transition: border-color 0.15s, background-color 0.15s;

  & > .lv-body { display: none; }
  & > .lv-head { display: block; margin: 0; }
  & > .lv-head .lv-toggle { padding: 0.55rem 0.8rem 0.55rem 0.85rem; }
  & > .lv-head .lv-meta { display: inline; }
  & > .lv-head .lv-title { font-size: 0.95rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  & > .lv-head .lv-chevron { transform: none; }
  &:hover { border-color: var(--lv); background: color-mix(in srgb, var(--lv) 6%, var(--surface)); }
}

.js .lv-body { animation: lv-in 0.18s ease-out; }
@keyframes lv-in { from { opacity: 0.35; } to { opacity: 1; } }

/* depth notice under the lead */
.depth-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 0 0 1.6rem; padding: 0.6rem 0.85rem;
  border: 1px dashed var(--rule-2); border-radius: var(--radius);
  font-size: 0.86rem; color: var(--ink-2);
}
.depth-note .icon { color: var(--accent); }
.depth-note-text { flex: 1 1 16rem; }
.btn {
  appearance: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border: 1px solid var(--rule-2); border-radius: 999px;
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
  font: 600 0.8rem/1.3 var(--font-ui);
}
.btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: var(--bg); }

/* depth map (right rail) */
.dm-rows { list-style: none; margin: 0; padding: 0; }
.dm-row {
  appearance: none; border: 0; background: none; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 2.6em 1fr 3.2em; align-items: center; gap: 6px;
  width: 100%; padding: 3px 4px; border-radius: 5px;
  font: 600 0.74rem/1.2 var(--font-ui); color: var(--ink-2);
}
.dm-row:hover { background: var(--surface-2); }
.dm-row[data-level="1"] { --lv: var(--lv1); }
.dm-row[data-level="2"] { --lv: var(--lv2); }
.dm-row[data-level="3"] { --lv: var(--lv3); }
.dm-row[data-level="4"] { --lv: var(--lv4); }
.dm-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.dm-fill { display: block; height: 100%; min-width: 0; border-radius: 999px; background: var(--lv); }
.dm-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 500; }
html[data-depth="1"] .dm-row:is([data-level="2"], [data-level="3"], [data-level="4"]),
html[data-depth="2"] .dm-row:is([data-level="3"], [data-level="4"]),
html[data-depth="3"] .dm-row[data-level="4"] {
  & .dm-fill { background: repeating-linear-gradient(135deg, var(--lv) 0 2px, transparent 2px 5px); }
  & .dm-label { color: var(--muted); }
}
.dm-status { margin: 8px 4px 0; color: var(--muted); line-height: 1.4; }
.dm-status strong { color: var(--ink); font-weight: 650; }
.dm-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 2px 0; }
.dm-actions .btn { font-size: 0.72rem; padding: 3px 9px; }

/* Entries of passages folded at the current dial: muted ink (still >= 4.5:1) and a
   faded level glyph; the text itself is never made translucent. */
html[data-depth="1"] .toc li:is([data-level="2"], [data-level="3"], [data-level="4"]),
html[data-depth="2"] .toc li:is([data-level="3"], [data-level="4"]),
html[data-depth="3"] .toc li[data-level="4"] {
  & a:not(.is-current):not(:hover) { color: var(--muted); }
  & .lvg { opacity: 0.5; }
}

/* "this page continues at depth N": one per dial position, shown at that position */
.depth-more {
  display: none; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 2.2rem 0 0; padding: 0.8rem 1rem;
  border: 1px solid var(--rule-2); border-left: 4px solid var(--accent); border-radius: var(--radius);
  background: var(--surface); font-family: var(--font-ui); font-size: 0.88rem; color: var(--ink-2);
}
.depth-more p { flex: 1 1 18rem; margin: 0; }
.depth-more strong { color: var(--ink); }
html.js[data-depth="1"] .depth-more[data-at="1"],
html.js[data-depth="2"] .depth-more[data-at="2"],
html.js[data-depth="3"] .depth-more[data-at="3"] { display: flex; }

/* Without JavaScript every level is unfolded and math is already typeset; controls
   that only work with it are not drawn. */
.no-js .needs-js, .no-js .lv-chevron, .no-js .viz-tools, .no-js .depth-more { display: none !important; }
.no-js .lv-toggle { cursor: default; }
.nojs-note {
  margin: 0 0 1.6rem; padding: 0.6rem 0.85rem; border: 1px dashed var(--rule-2);
  border-radius: var(--radius); font: 0.86rem/1.5 var(--font-ui); color: var(--ink-2);
}

/* reading-path bar */
.pathbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  margin: 0 0 1.4rem; padding: 0.55rem 0.85rem;
  border: 1px solid var(--rule); border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0; background: var(--surface);
  font-size: 0.84rem; color: var(--ink-2);
}
.pathbar strong { color: var(--ink); }
.pathbar-steps { flex: 1 1 auto; }
.pathbar a { font-weight: 600; text-decoration: none; }
.pathbar .iconbtn { width: 26px; height: 26px; }

/* ------------------------------------------------------------- 6. components */

/* page header */
.crumbs {
  margin: 0 0 10px; font-size: 0.74rem; font-weight: 650; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.crumbs a { color: inherit; text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 0.5em; }

.doc-head h1 {
  margin: 0 0 0.45em;
  font-size: clamp(1.85rem, 1.3rem + 2vw, 2.5rem); font-weight: 720; line-height: 1.12;
  letter-spacing: -0.025em; text-wrap: balance;
}
.lead {
  margin: 0 0 1.1rem; padding: 0.15rem 0 0.2rem 1.1rem;
  border-left: 3px solid var(--lv1);
  font-family: var(--font-prose); font-size: 1.22rem; line-height: 1.5; color: var(--ink);
  text-wrap: pretty;
}
.lead-tag {
  display: flex; align-items: center; gap: 7px; margin-bottom: 0.3rem;
  font: 700 0.68rem/1 var(--font-ui); letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--ink-2);
}
.doc-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px;
  margin: 0 0 1.9rem; font-size: 0.78rem; color: var(--muted);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); color: var(--ink-2); font-weight: 550; white-space: nowrap;
  text-decoration: none;
}
a.chip:hover { border-color: var(--accent); color: var(--accent-strong); }

/* callouts */
.callout {
  --c: var(--c-note);
  margin: 1.5rem 0; padding: 0.8rem 1rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--c) 28%, var(--rule));
  border-left: 3px solid var(--c);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: color-mix(in srgb, var(--c) 6%, var(--surface));
}
.callout-tip { --c: var(--c-tip); }
.callout-warning { --c: var(--c-warning); }
.callout-definition { --c: var(--c-definition); }
.callout-result { --c: var(--c-result); }
.callout-title {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin: 0 0 0.3rem !important;
  font-family: var(--font-ui); line-height: 1.3;
}
.callout-title .icon { color: var(--c); width: 1.05rem; height: 1.05rem; }
.callout-kind { font-size: 0.7rem; font-weight: 750; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-2); }
.callout-name { font-size: 0.97rem; font-weight: 660; color: var(--ink); }
.callout-name::before { content: "\00b7"; margin-right: 0.5rem; color: var(--muted); font-weight: 400; }
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-definition .callout-body, .callout-result .callout-body { font-style: normal; }

/* tabs */
.tabs { margin: 1.5rem 0; }
.tab-list {
  display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--rule);
}
.tab {
  appearance: none; border: 0; background: none; cursor: pointer; white-space: nowrap;
  padding: 7px 13px 8px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0;
  font: 600 0.84rem/1.2 var(--font-ui); color: var(--muted);
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-panel { padding-top: 0.9rem; }
.tab-panel > :first-child { margin-top: 0; }
.tab-panel > :last-child { margin-bottom: 0; }
.js .tab-panel:not(.is-active) { display: none; }
.no-js .tab-list { display: none; }
.no-js .tab-panel::before {
  content: attr(data-label); display: block; margin-bottom: 0.4rem;
  font: 700 0.7rem/1 var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}

/* code */
.code {
  margin: 1.4rem 0; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--code-bg); overflow: hidden;
}
.code-bar {
  display: flex; align-items: center; gap: 10px; min-height: 30px;
  padding: 0 6px 0 13px; border-bottom: 1px solid var(--rule);
  font-family: var(--font-ui);
}
.code-lang { font: 650 0.66rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.code-title { font: 600 0.78rem/1 var(--font-mono); color: var(--ink-2); }
.code-copy {
  appearance: none; margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border: 0; border-radius: 5px; background: none; cursor: pointer;
  font: 600 0.72rem/1 var(--font-ui); color: var(--muted);
}
.code-copy:hover { background: var(--surface-3); color: var(--ink); }
.code-copy.is-done { color: var(--good-ink); }
.no-js .code-copy { display: none; }
.hl pre {
  margin: 0; padding: 0.85rem 1rem; overflow-x: auto;
  font: 0.845rem/1.6 var(--font-mono); color: var(--code-ink);
  tab-size: 4; scrollbar-width: thin;
}
.hl code { font: inherit; background: none; padding: 0; }
.hl .hll { display: block; margin: 0 -1rem; padding: 0 1rem; background: var(--accent-wash-2); box-shadow: inset 2px 0 0 var(--accent); }
.hl :is(.c, .c1, .cm, .ch, .cs, .cp, .cpf) { color: var(--tok-comment); font-style: italic; }
.hl :is(.k, .kn, .kd, .kc, .kr, .kp, .kt, .ow) { color: var(--tok-keyword); }
.hl :is(.s, .s1, .s2, .sb, .sc, .sd, .sh, .sa, .se, .si, .sx, .sr, .ss, .dl) { color: var(--tok-string); }
.hl :is(.m, .mi, .mf, .mh, .mo, .mb, .il) { color: var(--tok-number); }
.hl :is(.nf, .fm, .nc, .nn) { color: var(--tok-func); }
.hl :is(.nb, .bp, .nd, .ne, .no) { color: var(--tok-builtin); }
.hl :is(.nt, .na, .nl) { color: var(--tok-tag); }
.hl :is(.nv, .vc, .vg, .vi) { color: var(--tok-func); }
.hl :is(.o, .p) { color: var(--tok-punct); }
.hl .gp { color: var(--tok-comment); user-select: none; }
.hl .go { color: var(--ink-2); }
.hl .err { color: inherit; }

/* tables */
.table-wrap { margin: 1.4rem 0; overflow-x: auto; scrollbar-width: thin; }
.table-wrap table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: 0.9rem; line-height: 1.45; }
.table-wrap th {
  text-align: left; font-weight: 660; font-size: 0.82rem; color: var(--ink);
  padding: 7px 12px 7px 0; border-bottom: 1.5px solid var(--ink-2); white-space: nowrap; vertical-align: bottom;
}
.table-wrap td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table-wrap tr:last-child td { border-bottom-color: var(--rule-2); }
.table-wrap :is(th, td):last-child { padding-right: 0; }
.table-wrap code { white-space: nowrap; overflow-wrap: normal; }      /* identifiers stay whole; the table scrolls */
.table-wrap :is(th, td)[align="right"], .table-wrap .num { text-align: right; }
.table-wrap :is(th, td)[align="center"] { text-align: center; }
table.data { font-variant-numeric: tabular-nums; }
table.data td.num { font-family: var(--font-mono); font-size: 0.84rem; }
table.data :is(td, th).num { white-space: nowrap; }
table.data td.txt { min-width: 7rem; }
.viz.data-table { overflow: hidden; }
.viz .table-wrap { max-width: 100%; }
table.data tbody tr:hover td { background: var(--accent-wash); }

/* mathematics */
/* inline formulas may break at relations and binary operators (KaTeX marks those places) */
.math.inline { white-space: normal; }
.math.display {
  display: block; margin: 1.25em 0; padding: 0.15em 0;
  overflow-x: auto; overflow-y: hidden; text-align: center;
  scrollbar-width: thin;
}
.math:not(.is-rendered) { font-family: var(--font-mono); font-size: 0.85em; color: var(--ink-2); white-space: pre-wrap; }
.math.display:target { background: var(--accent-wash); border-radius: var(--radius); box-shadow: 0 0 0 6px var(--accent-wash); }
.katex { font-size: 1.1em; }
.math.display .katex-display { margin: 0; }
.math.display .katex-display > .katex { white-space: nowrap; }
.eqref { font-family: var(--font-ui); font-size: 0.92em; white-space: nowrap; }
.eqref.is-broken { color: var(--critical-ink); }

/* footnotes */
.fnref a { font-family: var(--font-ui); font-weight: 650; font-size: 0.78em; padding: 0 0.15em; text-decoration: none; }
.footnotes { margin-top: 3rem; font-size: 0.94em; color: var(--ink-2); }
.footnotes h2 { font-size: 1.05rem !important; }
.footnotes li { }
.footnotes li:target { background: var(--accent-wash); }
.fn-back { margin-left: 0.4em; text-decoration: none !important; font-family: var(--font-ui); }
.footnotes li > p:last-of-type { display: inline; }

/* diagrams: inline SVG coloured through these classes / variables */
.diagram { margin: 1.8rem auto; text-align: center; }
.diagram-art svg { display: block; margin: 0 auto; max-width: 100%; height: auto; overflow: visible; }
.diagram figcaption, .viz-note {
  margin-top: 0.6rem; font-family: var(--font-ui); font-size: 0.84rem; color: var(--muted); line-height: 1.45;
}
.diagram figcaption p { margin: 0; }
svg .dg-line { fill: none; stroke: var(--ink-2); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
svg .dg-faint { fill: none; stroke: var(--rule-2); stroke-width: 1; }
svg .dg-accent { fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg .dg-box { fill: var(--surface); stroke: var(--rule-2); stroke-width: 1.2; }
svg .dg-box-accent { fill: var(--accent-wash-2); stroke: var(--accent); stroke-width: 1.2; }
svg .dg-fill { fill: var(--ink-2); stroke: none; }
svg .dg-fill-accent { fill: var(--accent); stroke: none; }
svg .dg-text { fill: var(--ink); font: 600 13px var(--font-ui); }
svg .dg-small { fill: var(--muted); font: 500 11px var(--font-ui); }
svg .dg-mono { fill: var(--ink-2); font: 500 11.5px var(--font-mono); }
svg .dg-l1 { fill: var(--lv1); } svg .dg-l2 { fill: var(--lv2); }
svg .dg-l3 { fill: var(--lv3); } svg .dg-l4 { fill: var(--lv4); }

/* component lists inside prose are not text lists */
.prose :is(.checks, .study-grid, .pagecards, .level-legend) { padding-left: 0; }
.prose :is(.check, .study-card, .level-row, .pagecards > li) { margin: 0; }

/* page lists, level legend */
.pagecards { list-style: none; margin: 1.5rem 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr)); }
.pagecards li { margin: 0; }
.pagecard {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; height: 100%;
  padding: 0.8rem 0.95rem; border: 1px solid var(--rule); border-radius: var(--radius);
  background: var(--surface); text-decoration: none !important; color: var(--ink) !important;
  font-family: var(--font-ui); transition: border-color 0.15s, box-shadow 0.15s;
}
.pagecard:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.pagecard-title { font-weight: 660; font-size: 0.97rem; line-height: 1.3; }
.pagecard-sum { grid-column: 1 / -1; font-size: 0.84rem; line-height: 1.45; color: var(--ink-2); }
.pagecard .lvg { margin-top: 3px; }

.level-legend { list-style: none; margin: 1.4rem 0; padding: 0; font-family: var(--font-ui); font-size: 0.9rem; }
.level-row {
  display: grid; grid-template-columns: 4.4em 7em 1fr; gap: 4px 14px; align-items: baseline;
  padding: 8px 0; margin: 0; border-bottom: 1px solid var(--rule);
}
.level-name { font-weight: 680; }
.level-what { color: var(--ink-2); }
.level-who { grid-column: 3; font-size: 0.8rem; color: var(--muted); }

/* previous / next */
.doc-foot { margin-top: 3.4rem; padding-top: 1.4rem; border-top: 1px solid var(--rule); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager a {
  display: flex; flex-direction: column; gap: 3px; padding: 0.75rem 0.95rem;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface);
  text-decoration: none; color: var(--ink); transition: border-color 0.15s;
}
.pager a:hover { border-color: var(--accent); }
.pager .pager-dir { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.pager .pager-title { font-weight: 650; font-size: 0.95rem; }
.pager .next { text-align: right; grid-column: 2; }
.doc-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 1.2rem; font-size: 0.78rem; }

/* ------------------------------------------------------- 7. data components */

.viz {
  margin: 1.8rem 0; padding: 0.95rem 1.1rem 0.8rem;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--surface);
  font-family: var(--font-ui);
}
.viz-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 0.6rem; }
.viz-title { font-size: 0.98rem; font-weight: 680; color: var(--ink); letter-spacing: -0.005em; }
.viz-sub { font-size: 0.8rem; color: var(--muted); }
.viz-tools { margin-left: auto; display: inline-flex; gap: 4px; align-self: center; }
.viz-tools button {
  appearance: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface);
  font: 600 0.72rem/1 var(--font-ui); color: var(--ink-2); cursor: pointer;
}
.viz-tools button:hover { border-color: var(--accent); color: var(--accent-strong); }
.viz-note { margin: 0.5rem 0 0; }
.viz-nojs { margin: 0; font-size: 0.86rem; color: var(--muted); }

.synthetic-tag {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border: 1px dashed var(--warn); border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  font-size: 0.66rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink);
}
.stale-tag {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--surface);
  font-size: 0.66rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2);
}
.study-card.is-stale { border-style: dashed; }
.viz.is-synthetic { border-style: dashed; border-color: color-mix(in srgb, var(--warn) 55%, var(--rule)); }

.viz-prov {
  display: flex; align-items: baseline; gap: 7px;
  margin: 0.7rem 0 0; padding-top: 0.55rem; border-top: 1px solid var(--rule);
  font-size: 0.74rem; color: var(--muted); line-height: 1.5;
}
.viz-prov .icon { width: 0.95rem; height: 0.95rem; align-self: flex-start; margin-top: 0.2em; }
.viz-prov > span { min-width: 0; overflow-wrap: anywhere; }
.viz-prov code { font-size: 0.95em; background: none; padding: 0; color: var(--ink-2); }
.viz-prov .sep { margin: 0 0.15em; }
.viz-prov { flex-wrap: wrap; }
.viz-prov .prov-text { flex: 1 1 14rem; }
.viz-prov a { color: var(--accent); }
/* relation of the record's revision to the build's: a word and an icon, never colour alone */
.prov-rel {
  display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 1px 8px;
  border: 1px solid var(--rule-2); border-radius: 999px; background: var(--surface);
  font: 650 0.7rem/1.5 var(--font-ui); color: var(--ink-2); white-space: nowrap;
}
.prov-rel .icon { width: 0.85rem; height: 0.85rem; margin: 0; align-self: center; color: var(--good); }
.prov-rel:is(.is-unknown, .is-same-dirty) .icon { color: var(--muted); }
.prov-rel.is-same-dirty { border-style: dashed; white-space: normal; }
.studies-mismatch.is-info { border-color: var(--rule-2); background: var(--surface); }
.studies-mismatch.is-info .icon { color: var(--muted); }
.prov-rel:is(.is-other, .is-dirty) {
  border-color: var(--warn); border-style: dashed; color: var(--ink);
  background: color-mix(in srgb, var(--warn) 14%, var(--surface));
}
.prov-rel:is(.is-other, .is-dirty) .icon { color: var(--warn); }
.study-rev { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 5px 0 0; font-size: 0.74rem; color: var(--muted); }
.study-rev code { background: none; padding: 0; color: var(--ink-2); }
.study-rev .prov-rel { border-radius: 6px; white-space: normal; }
.studies-mismatch {
  display: flex; align-items: flex-start; gap: 8px; margin: 0 0 0.9rem; padding: 0.6rem 0.8rem;
  border: 1px dashed var(--warn); border-radius: var(--radius);
  background: color-mix(in srgb, var(--warn) 10%, var(--surface)); font-size: 0.86rem; color: var(--ink);
}
.studies-mismatch .icon { flex: none; margin-top: 0.15em; color: var(--warn); }
.studies-mismatch code { background: none; padding: 0; }
.viz-prov.is-synthetic { color: var(--ink-2); }
.viz-prov.is-synthetic .icon { color: var(--warn); }

.viz-missing {
  display: flex; gap: 0.75rem; align-items: flex-start;
  margin: 1.6rem 0; padding: 0.85rem 1rem;
  border: 1px dashed var(--rule-2); border-radius: var(--radius);
  background: repeating-linear-gradient(135deg, transparent 0 9px, var(--accent-wash) 9px 10px);
  font-family: var(--font-ui); font-size: 0.88rem; line-height: 1.5; color: var(--ink-2);
}
.viz-missing .icon { width: 1.25rem; height: 1.25rem; margin-top: 0.1rem; color: var(--muted); }
.viz-missing strong { color: var(--ink); }
.viz-missing.is-error { border-color: var(--critical); }
.viz-missing.is-error .icon { color: var(--critical); }
.viz-missing-detail { color: var(--muted); }

/* charts */
.chart-plot { position: relative; min-height: 120px; }
.chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart-plot:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: 6px; }
.ch-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.ch-grid-minor { stroke: var(--grid); stroke-width: 1; opacity: 0.55; shape-rendering: crispEdges; }
.ch-axis { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.ch-tick { fill: var(--muted); font: 500 11px var(--font-ui); font-variant-numeric: tabular-nums; }
.ch-label { fill: var(--ink-2); font: 600 11.5px var(--font-ui); }
.ch-cat { fill: var(--ink-2); font: 500 11.5px var(--font-ui); }
.ch-band { fill: var(--accent-wash-2); }
.ch-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-dot { stroke: var(--surface); stroke-width: 2; }
.ch-dot-in { stroke: none; }
.ch-bar { shape-rendering: geometricPrecision; }
.ch-ref { fill: none; stroke: var(--muted); stroke-width: 1.25; stroke-linecap: round; }
.ch-ref-tri { fill: color-mix(in srgb, var(--muted) 16%, transparent); stroke: var(--muted); stroke-width: 1; stroke-linejoin: round; }
.ch-ref-label { fill: var(--muted); font: 600 11px var(--font-ui); }
.ch-end { fill: var(--ink-2); font: 600 11.5px var(--font-ui); }
.ch-cross { stroke: var(--ink-2); stroke-width: 1; opacity: 0.5; shape-rendering: crispEdges; pointer-events: none; }
.ch-hit { fill: transparent; }
.ch-dim { opacity: 0.18; }
.ch-s1 { stroke: var(--series-1); } .ch-f1 { fill: var(--series-1); }
.ch-s2 { stroke: var(--series-2); } .ch-f2 { fill: var(--series-2); }
.ch-s3 { stroke: var(--series-3); } .ch-f3 { fill: var(--series-3); }
.ch-s4 { stroke: var(--series-4); } .ch-f4 { fill: var(--series-4); }
.ch-s5 { stroke: var(--series-5); } .ch-f5 { fill: var(--series-5); }
.ch-s6 { stroke: var(--series-6); } .ch-f6 { fill: var(--series-6); }
.ch-s7 { stroke: var(--series-7); } .ch-f7 { fill: var(--series-7); }
.ch-s8 { stroke: var(--series-8); } .ch-f8 { fill: var(--series-8); }
.ch-s0 { stroke: var(--series-other); } .ch-f0 { fill: var(--series-other); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 2px 6px; margin-top: 0.35rem; }
.chart-legend:empty { display: none; }
.lg-item {
  appearance: none; display: inline-flex; align-items: center; gap: 7px;
  padding: 3px 8px; border: 0; border-radius: 999px; background: none; cursor: pointer;
  font: 550 0.78rem/1.2 var(--font-ui); color: var(--ink-2);
}
.lg-item:hover { background: var(--surface-2); color: var(--ink); }
.lg-item[aria-pressed="false"] { color: var(--muted); text-decoration: line-through; }
.lg-item[aria-pressed="false"] .lg-key { opacity: 0.3; }
.lg-key { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid; border-radius: 2px; }
.lg-key.is-bar { width: 10px; height: 10px; border: 0; border-radius: 2px; }
.lg-key.is-dot { border-radius: 50%; }
.lg-key.is-dashed { border-top-style: dashed; width: 20px; }
.lg-key.is-tri { width: 0; height: 0; border: 0; border-left: 14px solid transparent; border-bottom: 8px solid var(--muted); border-radius: 0; opacity: 0.7; }
.lg-ref { display: inline-flex; align-items: center; gap: 7px; padding: 3px 8px; font: 500 0.78rem/1.2 var(--font-ui); color: var(--muted); }
.chart-dropped { font-style: italic; }

.viz-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 8.5rem; max-width: 17rem;
  padding: 7px 10px 8px; border: 1px solid var(--rule-2); border-radius: 8px;
  background: var(--surface); box-shadow: var(--shadow);
  font: 500 0.76rem/1.35 var(--font-ui); color: var(--ink-2);
}
.viz-tip-head { margin-bottom: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.viz-tip-row { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 7px; }
.viz-tip-key { width: 12px; border-top: 2.5px solid; border-radius: 2px; }
.viz-tip-val { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

.viz-table { margin-top: 0.5rem; font-size: 0.82rem; }
.viz-table summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none;
  padding: 3px 8px; margin-left: -8px; border-radius: 6px;
  font-weight: 600; font-size: 0.76rem; color: var(--ink-2);
}
.viz-table summary::-webkit-details-marker { display: none; }
.viz-table summary:hover { background: var(--surface-2); color: var(--ink); }
.viz-table .table-wrap { margin: 0.5rem 0 0; max-height: 22rem; overflow-y: auto; }
.viz-table-more { margin: 0.4rem 0 0; color: var(--muted); }
.viz.data-table .table-wrap { margin: 0; }

/* status + studies */
.status-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 7px;
  border-radius: 999px; border: 1px solid; font-size: 0.74rem; font-weight: 720; letter-spacing: 0.03em;
  background: var(--surface);
}
.badge .icon { width: 1rem; height: 1rem; }
.badge-pass { color: var(--good-ink); border-color: color-mix(in srgb, var(--good) 55%, var(--rule)); background: color-mix(in srgb, var(--good) 9%, var(--surface)); }
.badge-pass .icon { color: var(--good); }
.badge-fail { color: var(--critical-ink); border-color: color-mix(in srgb, var(--critical) 60%, var(--rule)); background: color-mix(in srgb, var(--critical) 9%, var(--surface)); }
.badge-fail .icon { color: var(--critical); }
.badge-unknown { color: var(--muted); border-color: var(--rule-2); }
.status-desc { margin: 0.6rem 0 0; font-size: 0.88rem; color: var(--ink-2); line-height: 1.5; }
/* The value and the expectation take what they need up to a cap and wrap beyond it; the
   name keeps a readable width.  (With two unbounded "auto" columns one long expectation
   squeezed every name of the list to a column one character wide.) */
.checks {
  list-style: none; margin: 0.7rem 0 0; padding: 0; border-top: 1px solid var(--rule);
  display: grid; grid-template-columns: 1.2rem minmax(11rem, 1fr) fit-content(10rem) fit-content(16rem);
  column-gap: 12px;
}
.check {
  display: grid; grid-template-columns: subgrid; grid-column: 1 / -1; row-gap: 2px; align-items: baseline;
  padding: 6px 0; margin: 0; border-bottom: 1px solid var(--rule); font-size: 0.86rem;
}
.check .icon { align-self: center; width: 1.05rem; height: 1.05rem; }
.check.is-pass .icon { color: var(--good); }
.check.is-fail .icon { color: var(--critical); }
.check-name { color: var(--ink); }
.check-value { font: 600 0.82rem var(--font-mono); color: var(--ink); text-align: right; overflow-wrap: anywhere; }
.check-expected { font-size: 0.78rem; color: var(--muted); overflow-wrap: anywhere; }
.check-word { display: none; }
.check.is-fail .check-word {
  display: inline; grid-column: 2 / -1; font-size: 0.72rem; font-weight: 750; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--critical-ink);
}
.study-notes { margin: 0.7rem 0 0; padding: 0.5rem 0.75rem; border-left: 3px solid var(--rule); font-size: 0.86rem; line-height: 1.5; color: var(--ink-2); }
.study-notes-label { display: block; margin-bottom: 0.15rem; font-size: 0.66rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.status-error { margin: 0.7rem 0 0; padding: 0.6rem 0.8rem; border: 1px solid color-mix(in srgb, var(--critical) 45%, var(--rule)); border-radius: var(--radius); background: color-mix(in srgb, var(--critical) 6%, var(--surface)); font-size: 0.84rem; }
.status-error-line { margin: 0; font-family: var(--font-mono); font-size: 0.8rem; color: var(--ink); overflow-wrap: anywhere; }
.status-error summary { cursor: pointer; margin-top: 0.4rem; font-size: 0.76rem; font-weight: 600; color: var(--ink-2); }
.status-error pre { margin: 0.5rem 0 0; max-height: 18rem; overflow: auto; font: 0.74rem/1.5 var(--font-mono); color: var(--ink-2); white-space: pre; }

.studies-summary { display: flex; align-items: center; gap: 8px; margin: 0 0 0.8rem; font-size: 0.95rem; }
.studies-summary .icon { color: var(--muted); width: 1.2rem; height: 1.2rem; }
.studies-summary.is-pass .icon { color: var(--good); }
.studies-summary.is-fail .icon { color: var(--critical); }
.study-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr)); }
.study-card { margin: 0; padding: 0.7rem 0.8rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--bg); }
.study-card[data-passed="false"] { border-color: color-mix(in srgb, var(--critical) 55%, var(--rule)); }
.study-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.study-title { margin: 0.5rem 0 0.1rem; font-weight: 660; font-size: 0.93rem; line-height: 1.3; }
.study-id, .study-foot { margin: 0; font-size: 0.74rem; color: var(--muted); }
.study-id code, .study-foot code { background: none; padding: 0; }

/* field viewer */
.fv-stage {
  position: relative; height: var(--fv-height, 420px); min-height: 200px;
  border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden;
  background: var(--bg);
}
.fv-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; outline: none; }
.fv-stage.is-active canvas { touch-action: none; }
.fv-stage.is-dragging canvas { cursor: grabbing; }
.fv-stage.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.fv-stage:has(canvas:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.fv-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 0.6rem; font-size: 0.8rem; }
.fv-bar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; }
.fv-bar select {
  appearance: none; padding: 4px 26px 4px 9px; border: 1px solid var(--rule-2); border-radius: 6px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5l3 3 3-3' fill='none' stroke='%237b8791' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 7px center / 12px;
  color: var(--ink); font: 600 0.8rem/1.3 var(--font-ui); cursor: pointer;
}
.fv-btn {
  appearance: none; display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px;
  border: 1px solid var(--rule-2); border-radius: 6px; background: var(--surface); cursor: pointer;
  font: 600 0.78rem/1.3 var(--font-ui); color: var(--ink-2);
}
.fv-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.fv-btn[aria-pressed="true"] { background: var(--accent-wash-2); border-color: var(--accent); color: var(--ink); }
.fv-bar .fv-space { flex: 1 1 auto; }
.fv-group { display: inline-flex; }
.fv-group .fv-btn { min-width: 30px; justify-content: center; padding: 4px 7px; border-radius: 0; margin-left: -1px; }
.fv-group .fv-btn:first-child { border-radius: 6px 0 0 6px; margin-left: 0; }
.fv-group .fv-btn:last-child { border-radius: 0 6px 6px 0; }
.fv-group .fv-btn:hover { position: relative; z-index: 1; }
.fv-readout {
  position: absolute; left: 8px; bottom: 8px; z-index: 2; pointer-events: none;
  padding: 4px 8px; border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--rule);
  font: 600 0.74rem/1.3 var(--font-mono); color: var(--ink); font-variant-numeric: tabular-nums;
}
.fv-readout:empty { display: none; }
.fv-window { position: absolute; z-index: 1; box-sizing: border-box; pointer-events: none; border: 1px dashed var(--rule-2); }
.fv-window[hidden] { display: none; }
.fv-hint {
  position: absolute; right: 8px; top: 8px; z-index: 2; pointer-events: none;
  padding: 4px 8px; border-radius: 6px; background: color-mix(in srgb, var(--surface) 90%, transparent);
  border: 1px solid var(--rule); font-size: 0.72rem; color: var(--ink-2);
  opacity: 0; transition: opacity 0.2s;
}
.fv-hint.is-shown { opacity: 1; }
.fv-message { position: absolute; inset: 0; display: grid; place-items: center; padding: 1rem; text-align: center; font-size: 0.86rem; color: var(--muted); }
.fv-legend { display: grid; grid-template-columns: auto minmax(120px, 340px) auto; align-items: center; gap: 4px 10px; margin-top: 0.6rem; font-size: 0.76rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.fv-legend canvas { width: 100%; height: 12px; border-radius: 3px; display: block; border: 1px solid var(--rule); }
.fv-legend-name { grid-column: 1 / -1; font-weight: 650; color: var(--ink); }
.fv-legend-min, .fv-legend-max { font-family: var(--font-mono); }
.fv-fields { margin: 0.5rem 0 0; font-size: 0.76rem; color: var(--muted); line-height: 1.5; }
.js .fv-fields { display: none; }

/* --------------------------------------------- 8. home, search, footer, print */

.home { max-width: 1180px; margin: 0 auto; padding: clamp(24px, 4vw, 56px) clamp(16px, 4vw, 40px) 40px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 0 14px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; color: var(--accent);
}
.hero h1 {
  margin: 0 0 0.5em; font-size: clamp(2.1rem, 1.2rem + 3.2vw, 3.35rem); font-weight: 740;
  line-height: 1.06; letter-spacing: -0.032em; text-wrap: balance;
}
.hero-text { margin: 0 0 1.5rem; font-family: var(--font-prose); font-size: 1.2rem; line-height: 1.55; color: var(--ink-2); max-width: 34rem; text-wrap: pretty; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-actions .btn { padding: 9px 16px; font-size: 0.9rem; border-radius: var(--radius); }
.hero-figure { margin: 0; }
.hero-art { display: block; width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--rule); }
.hero-figure figcaption { margin-top: 8px; font-size: 0.72rem; color: var(--muted); line-height: 1.4; }
.ha-bg { fill: var(--surface); }
.ha-cell { fill: var(--accent); stroke: none; }
.ha-node { fill: none; stroke: var(--rule-2); stroke-width: 0.6; opacity: 0.75; }
.ha-edge { fill: none; stroke: var(--ink-2); stroke-width: 0.9; opacity: 0.55; }
.ha-stream { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-linecap: round; opacity: 0.9; }
.ha-orbit { fill: none; stroke: var(--accent-strong); stroke-width: 1.7; }
.ha-dots { fill: var(--ink); opacity: 0.8; }

.home-section { margin-top: clamp(40px, 6vw, 76px); }
.home-kicker { margin: 0 0 6px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.11em; text-transform: uppercase; color: var(--accent); }
.home-section > h2 { margin: 0 0 0.35em; font-size: clamp(1.4rem, 1.1rem + 1vw, 1.8rem); font-weight: 710; letter-spacing: -0.02em; line-height: 1.2; }
.home-intro { margin: 0 0 1.4rem; max-width: 44rem; font-family: var(--font-prose); font-size: 1.06rem; line-height: 1.6; color: var(--ink-2); }

.depth-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: var(--surface); }
.depth-step {
  appearance: none; border: 0; border-right: 1px solid var(--rule); background: none; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; gap: 5px; width: 100%; height: 100%; padding: 16px 16px 18px;
  color: var(--ink); font-family: var(--font-ui); position: relative;
}
.depth-steps li:last-child .depth-step { border-right: 0; }
.depth-step::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--lv); opacity: 0.28; }
.depth-step[data-level="1"] { --lv: var(--lv1); } .depth-step[data-level="2"] { --lv: var(--lv2); }
.depth-step[data-level="3"] { --lv: var(--lv3); } .depth-step[data-level="4"] { --lv: var(--lv4); }
html[data-depth="1"] .depth-step[data-level="1"]::before,
html[data-depth="2"] .depth-step:is([data-level="1"], [data-level="2"])::before,
html[data-depth="3"] .depth-step:is([data-level="1"], [data-level="2"], [data-level="3"])::before,
html[data-depth="4"] .depth-step::before { opacity: 1; }
.depth-step:hover { background: var(--accent-wash); }
.depth-step-top { display: flex; align-items: center; gap: 8px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-2); }
.depth-step-name { font-size: 1.12rem; font-weight: 700; letter-spacing: -0.01em; }
.depth-step-what { font-size: 0.86rem; color: var(--ink-2); line-height: 1.4; }
.depth-step-who { font-size: 0.76rem; color: var(--muted); }
.depth-step-state { margin-top: auto; padding-top: 8px; font-size: 0.72rem; font-weight: 650; color: var(--muted); }
html[data-depth="1"] .depth-step[data-level="1"] .depth-step-state::after,
html[data-depth="2"] .depth-step[data-level="2"] .depth-step-state::after,
html[data-depth="3"] .depth-step[data-level="3"] .depth-step-state::after,
html[data-depth="4"] .depth-step[data-level="4"] .depth-step-state::after { content: "your dial is here"; color: var(--accent); }

.paths { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr)); }
.path-card { display: flex; flex-direction: column; margin: 0; padding: 1.05rem 1.1rem 1rem; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); }
.path-head { display: flex; align-items: center; gap: 10px; }
.path-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; background: var(--accent-wash-2); color: var(--accent); flex: none; }
.path-icon .icon { width: 20px; height: 20px; }
.path-card h3 { margin: 0; font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.path-who { margin: 0.6rem 0 0.7rem; font-size: 0.88rem; line-height: 1.45; color: var(--ink-2); }
.path-depth { display: inline-flex; align-items: center; gap: 7px; font-size: 0.74rem; font-weight: 600; color: var(--muted); }
.path-steps { list-style: none; counter-reset: step; margin: 0.8rem 0 0.9rem; padding: 0; border-top: 1px solid var(--rule); font-size: 0.86rem; }
.path-steps li { counter-increment: step; margin: 0; border-bottom: 1px solid var(--rule); }
.path-steps a { display: grid; grid-template-columns: 1.5em 1fr auto; gap: 6px; align-items: baseline; padding: 6px 0; color: var(--ink); text-decoration: none; }
.path-steps a::before { content: counter(step); font-size: 0.72rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.path-steps a:hover { color: var(--accent-strong); }
.path-start { margin-top: auto; align-self: flex-start; }

.highlights { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--rule); border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; }
@media (max-width: 980px) { .highlights { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .highlights { grid-template-columns: 1fr; } }
.highlight { margin: 0; padding: 1.1rem 1.15rem 1.15rem; background: var(--surface); }
.highlight .icon { width: 22px; height: 22px; color: var(--accent); }
.highlight h3 { margin: 0.55rem 0 0.3rem; font-size: 1rem; font-weight: 690; letter-spacing: -0.01em; }
.highlight p { margin: 0; font-size: 0.88rem; line-height: 1.5; color: var(--ink-2); }
.highlight a { display: inline-block; margin-top: 0.5rem; font-size: 0.82rem; font-weight: 650; text-decoration: none; }

.sections { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.section-card { display: flex; flex-direction: column; gap: 4px; height: 100%; padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); color: var(--ink); text-decoration: none; transition: border-color 0.15s, box-shadow 0.15s; }
.section-card:hover { border-color: var(--accent); box-shadow: var(--shadow); color: var(--ink); }
.section-card strong { font-size: 1rem; font-weight: 690; }
.section-card span { font-size: 0.84rem; color: var(--ink-2); line-height: 1.45; }
.section-card small { margin-top: auto; padding-top: 6px; display: flex; align-items: center; gap: 8px; font-size: 0.74rem; color: var(--muted); }

.deploy { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; }
.deploy-card { padding: 1.05rem 1.15rem; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); }
.deploy-card h3 { display: flex; align-items: center; gap: 9px; margin: 0 0 0.7rem; font-size: 1rem; font-weight: 690; }
.deploy-card dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; margin: 0; font-size: 0.86rem; }
.deploy-card dt { color: var(--muted); }
.deploy-card dd { margin: 0; color: var(--ink); font-family: var(--font-mono); font-size: 0.82rem; overflow-wrap: anywhere; }
.deploy-card ul { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.deploy-card li { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.deploy-card li:last-child { border-bottom: 0; }
.deploy-card li a { font-weight: 650; text-decoration: none; }
.deploy-card li span { display: block; font-size: 0.8rem; color: var(--muted); }
.stamp-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
[data-stamp-state="live"] .stamp-dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }
[data-stamp-state="mismatch"] .stamp-dot { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.home-body { max-width: var(--measure); margin-top: clamp(36px, 5vw, 60px); }

.sitefoot {
  border-top: 1px solid var(--rule); margin-top: 24px;
  padding: 18px clamp(16px, 3vw, 32px) 28px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px;
  font-size: 0.78rem; color: var(--muted);
}
.sitefoot .stamp { display: inline-flex; align-items: center; gap: 9px; flex: 1 1 22rem; min-width: 0; line-height: 1.5; }
.sitefoot code { background: none; padding: 0; color: var(--ink-2); }
.sitefoot nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.sitefoot nav a { color: var(--ink-2); text-decoration: none; font-weight: 600; }
.sitefoot nav a:hover { color: var(--accent); }

/* search */
.search {
  width: min(680px, calc(100vw - 24px)); max-height: min(78vh, 720px);
  margin: 9vh auto 0; padding: 0; border: 1px solid var(--rule-2); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
  overflow: hidden; flex-direction: column;
}
.search[open] { display: flex; }
.search::backdrop { background: rgba(10, 16, 22, 0.45); backdrop-filter: blur(2px); }
.search-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.search-box .icon { width: 20px; height: 20px; color: var(--muted); }
.search-box input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink);
  font: 500 1.05rem/1.4 var(--font-ui);
}
.search-box input::-webkit-search-cancel-button { display: none; }
.search-close { appearance: none; border: 0; background: none; cursor: pointer; padding: 0; }
.search-status { padding: 8px 16px 0; font-size: 0.76rem; color: var(--muted); min-height: 1.6rem; }
.search-results { list-style: none; margin: 0; padding: 6px 8px 10px; overflow-y: auto; flex: 1 1 auto; }
.search-results li { margin: 0; }
.search-hit { display: block; padding: 9px 10px; border-radius: 9px; color: var(--ink); text-decoration: none; border: 1px solid transparent; }
.search-hit:hover, .search-hit.is-active { background: var(--accent-wash-2); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--ink); }
.search-hit-top { display: flex; align-items: center; gap: 8px; font-size: 0.7rem; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.search-hit-top .lvg { margin-left: auto; }
.search-hit-title { display: block; margin-top: 2px; font-weight: 670; font-size: 0.98rem; }
.search-hit-title small { font-weight: 500; font-size: 0.86rem; color: var(--ink-2); }
.search-hit-snip { display: block; margin-top: 2px; font-size: 0.84rem; line-height: 1.45; color: var(--ink-2); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.search-hit mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-hint { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 9px 16px; border-top: 1px solid var(--rule); font-size: 0.72rem; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 22px; z-index: 60; transform: translate(-50%, 12px);
  display: inline-flex; align-items: center; gap: 9px; max-width: calc(100vw - 32px);
  padding: 8px 14px; border: 1px solid var(--rule-2); border-radius: 999px;
  background: var(--surface); box-shadow: var(--shadow); color: var(--ink);
  font-size: 0.84rem; font-weight: 600; opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .rail {
    position: static; grid-column: 2; grid-row: 1; max-height: none; overflow: visible;
    padding: 20px clamp(16px, 3.6vw, 56px) 0;
  }
  .rail-inner { max-width: var(--measure); margin: 0 auto; padding: 12px 14px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); }
  .main { grid-column: 2; grid-row: 2; padding-top: 22px; }
  .depthmap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 18px; align-items: start; }
  .depthmap .rail-title { grid-column: 1 / -1; }
  .dm-rows { min-width: 13rem; }
  .dm-side { align-self: center; }
  .toc { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--rule); }
  .toc:not(.is-open) ol { display: none; }
  .toc .rail-title { margin: 0; }
  .toc-toggle { display: inline-flex !important; }
  .toc.is-open ol { margin-top: 8px; }
}

.toc-toggle {
  display: none; appearance: none; border: 0; background: none; padding: 2px 0; cursor: pointer;
  align-items: center; gap: 6px; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
}
.toc-toggle .icon { transition: transform 0.15s; }
.toc.is-open .toc-toggle .icon { transform: rotate(180deg); }

@media (max-width: 860px) {
  .nav-toggle { display: inline-grid; }
  .shell { display: block; }
  .sidebar {
    position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; height: auto; width: min(86vw, 320px);
    padding-top: 18px; background: var(--bg); border-right: 1px solid var(--rule-2);
    transform: translateX(-102%); transition: transform 0.2s ease; visibility: hidden;
    box-shadow: var(--shadow-lg);
  }
  .nav-open .sidebar { transform: none; visibility: visible; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(10, 16, 22, 0.45); }
  .rail { padding: 16px 16px 0; }
  .main { padding: 18px 16px 48px; }
  .brand-tag, .dial-label, .toplink span, .search-trigger kbd { display: none; }
  .search-trigger { flex: 0 0 36px; width: 36px; padding: 0; justify-content: center; border-color: transparent; background: none; color: var(--ink-2); }
  .search-trigger span { display: none; }
  .search-trigger .icon { width: 19px; height: 19px; }
  .topbar { gap: 6px; }
  .dial-name { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero-figure { order: -1; max-width: 520px; }
  .depth-steps { grid-template-columns: 1fr 1fr; }
  .depth-steps li:nth-child(2) .depth-step { border-right: 0; }
  .depth-steps li:nth-child(-n+2) .depth-step { border-bottom: 1px solid var(--rule); }
  .deploy { grid-template-columns: 1fr; }
  .hanchor { display: none; }
  .checks { grid-template-columns: 1.2rem minmax(0, 1fr) auto; }
  .check-expected { grid-column: 2 / -1; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
  .level-row { grid-template-columns: 4.4em 1fr; }
  .level-what, .level-who { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .depthmap { grid-template-columns: minmax(0, 1fr); }
  .dm-side { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
  .dm-status { margin: 4px 4px 0; }
  .dm-actions { margin: 4px 2px 0; }
  .prose { font-size: 1rem; }
  .lead { font-size: 1.1rem; }
  .dial-cell { width: 27px; height: 26px; }
  .brand-name { font-size: 1.02rem; }
  .lv-kicker { display: none; }
  .depth-steps { grid-template-columns: 1fr; }
  .depth-steps .depth-step { border-right: 0; border-bottom: 1px solid var(--rule); }
  .toplink { display: none; }
}

/* the home page keeps the navigation in a drawer at every width */
.is-home .nav-toggle { display: inline-grid; }
.is-home .sidebar {
  position: fixed; z-index: 50; top: 0; left: 0; bottom: 0; height: auto; width: min(86vw, 320px);
  padding-top: 18px; background: var(--bg); border-right: 1px solid var(--rule-2);
  transform: translateX(-102%); transition: transform 0.2s ease; visibility: hidden; box-shadow: var(--shadow-lg);
}
.is-home.nav-open .sidebar { transform: none; visibility: visible; }
.is-home.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(10, 16, 22, 0.45); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .lvg i { background: GrayText; }
  .lvg[data-level="1"] i:nth-child(-n+1), .lvg[data-level="2"] i:nth-child(-n+2),
  .lvg[data-level="3"] i:nth-child(-n+3), .lvg[data-level="4"] i:nth-child(-n+4) { background: CanvasText; }
  .dial-cell { border: 1px solid transparent; }
  html[data-depth="1"] .dial-stop[data-level="1"] .dial-cell,
  html[data-depth="2"] .dial-stop:is([data-level="1"], [data-level="2"]) .dial-cell,
  html[data-depth="3"] .dial-stop:is([data-level="1"], [data-level="2"], [data-level="3"]) .dial-cell,
  html[data-depth="4"] .dial-stop .dial-cell { background: Highlight; color: HighlightText; }
}

/* ------------------------------------------------------------------- print */

@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    color-scheme: light;
    --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --surface-3: #e8e8e8;
    --ink: #000; --ink-2: #222; --muted: #555; --rule: #ccc; --rule-2: #999;
    --accent: #00506b; --accent-strong: #003a53; --accent-wash: transparent; --accent-wash-2: #eef4f6;
    --lv1: #72bdda; --lv2: #1a7d9f; --lv3: #006687; --lv4: #003a53;
    --code-bg: #f6f6f6; --code-ink: #111; --grid: #ddd; --axis: #888;
    --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
    --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
    --tok-comment: #555; --tok-keyword: #5b2da8; --tok-string: #1f5c22; --tok-number: #8a4500;
    --tok-func: #004f73; --tok-builtin: #624200; --tok-tag: #7d2149; --tok-punct: #333;
  }
  body { background: #fff; font-size: 11pt; }
  .topbar, .sidebar, .scrim, .rail, .search, .toast, .depth-note, .pathbar, .doc-foot, .skip,
  .code-copy, .viz-tools, .lv-chevron, .lv-meta, .hanchor, .sitefoot nav, .fv-bar, .dm-actions,
  .hero-actions, .toc-toggle { display: none !important; }
  .shell { display: block; max-width: none; }
  .main, .home { padding: 0; }
  .doc { max-width: none; }
  /* everything unfolds on paper, labelled with its level */
  .lv, .lv[data-user="closed"] { border: 0 !important; border-left: 2pt solid var(--lv) !important; border-radius: 0 !important; padding: 0 0 0 10pt !important; background: none !important; }
  .lv > .lv-body { display: block !important; animation: none !important; }
  .lv-implicit { border-left: 0 !important; padding-left: 0 !important; }
  .lv-implicit > .lv-head { display: none !important; }
  .lv-toggle { padding: 0 !important; }
  .js .tab-panel:not(.is-active) { display: block; }
  .tab-list { display: none; }
  .tab-panel::before { content: attr(data-label); display: block; font: 700 8pt var(--font-ui); letter-spacing: 0.08em; text-transform: uppercase; color: #555; }
  .viz-table[open] > .table-wrap { max-height: none; }
  .code, .viz, .callout, .math.display, figure, table { break-inside: avoid; }
  .prose h2, .prose h3, .prose h4 { break-after: avoid; }
  .hl pre { white-space: pre-wrap; overflow: visible; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; vertical-align: baseline; }
  .sitefoot { border-top: 1px solid #999; padding: 8pt 0 0; margin-top: 18pt; }
  .math.display { overflow: visible; }
}

/* Without JavaScript the navigation drawer cannot open: where the navigation would be
   a drawer (narrow screens, the home page) it follows the content instead. */
.no-js .nav-toggle { display: none !important; }
.no-js.is-home .shell { display: flex; flex-direction: column; }
.no-js.is-home .sidebar {
  position: static; order: 3; transform: none; visibility: visible; width: auto; height: auto;
  box-shadow: none; border-right: 0; border-top: 1px solid var(--rule); padding: 22px 20px 40px;
}
.no-js.is-home .shell > * { min-width: 0; width: 100%; }
@media (max-width: 1180px) {
  /* the table of contents cannot be toggled: show it, with its plain title */
  .no-js .toc-toggle { display: none !important; }
  .no-js .toc:not(.is-open) ol { display: block; margin-top: 8px; }
  .no-js .toc { margin-top: 0; padding-top: 0; border-top: 0; }
}
@media (max-width: 860px) {
  .no-js .shell { display: flex; flex-direction: column; }
  .no-js .shell > * { min-width: 0; width: 100%; }
  .no-js .sidebar {
    position: static; order: 3; transform: none; visibility: visible; width: auto; height: auto;
    box-shadow: none; border-right: 0; border-top: 1px solid var(--rule); padding: 22px 20px 40px;
  }
}
