/* ===========================================================================
   SmazTuner -- app.css
   One file. Both themes. No @import, no url(http...), no webfont, no CDN.
   The token set is specified in docs/style.md; verify_build.py checks this
   file against style.md section 9.
   ========================================================================= */

/* ------------------------------------------------------------------ tokens */
:root {
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Cascadia Code", "SF Mono", Menlo,
               Consolas, "DejaVu Sans Mono", "Liberation Mono", monospace;

  --t-3xs: 10.5px;  --t-2xs: 11.5px; --t-xs: 12.5px; --t-sm: 13.5px;
  --t-base: clamp(15px, 0.4vw + 14px, 16.5px);
  --t-md: 18px;     --t-lg: 21px;
  --t-xl: clamp(26px, 2.2vw + 18px, 34px);
  --t-2xl: clamp(34px, 4vw + 20px, 52px);

  --s-1: 2px; --s-2: 4px; --s-3: 8px; --s-4: 12px; --s-5: 16px;
  --s-6: 24px; --s-7: 32px; --s-8: 48px; --s-9: 64px; --s-10: 96px;

  --r-1: 4px; --r-2: 6px; --r-3: 10px; --r-4: 14px; --r-full: 999px;

  --rail-w: 264px; --rail-w-min: 64px; --ctx-w: 272px;
  --header-h: 56px; --measure: 74ch; --page-max: 1560px;
  --gutter: clamp(16px, 3vw, 40px);

  --dur-1: 110ms; --dur-2: 180ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
  --zoom: 1;
  /* the breadcrumb's fade mask needs an opaque stop, so it gets a token too */
  --fade: #000;

  --z-rail: 30; --z-header: 40; --z-scrim: 50; --z-dialog: 60;
}

:root, [data-theme="dark"] {
  --bg: #0b0d10;        --bg-sunk: #0f1216;
  --surface: #14171c;   --surface-2: #1b1f26;  --surface-3: #232833;
  --line: #252a33;      --line-2: #333a46;
  --ink: #e9ecf1;       --ink-2: #a8b0bd;     --ink-3: #727c8b;
  --accent: #5cc8ff;    --accent-ink: #04121b;
  --ok: #4ed99b;        --warn: #f2b23e;       --danger: #ff7a7a;
  --info: #9b8cff;      --teal: #3fd3c4;
  --focus: #5cc8ff;
  --e-1: 0 1px 2px rgb(0 0 0 / .4);
  --e-2: 0 0 0 1px #333a46, 0 16px 40px -12px rgb(0 0 0 / .6);
  --scrim: rgb(0 0 0 / .6);
  --tint: rgb(255 255 255 / .04);
  --tint-2: rgb(255 255 255 / .07);
  --sel: rgb(92 200 255 / .26);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #fbfbf9;        --bg-sunk: #f2f2ef;
  --surface: #ffffff;   --surface-2: #f6f6f3;  --surface-3: #ededea;
  --line: #e1e1dc;      --line-2: #cfcfc8;
  --ink: #14171c;       --ink-2: #4a5058;     --ink-3: #6c737c;
  --accent: #0a6c9e;    --accent-ink: #ffffff;
  --ok: #0a7343;        --warn: #8a5a00;       --danger: #b3261e;
  --info: #5a48c8;      --teal: #0b7268;
  --focus: #0a6c9e;
  --e-1: 0 1px 2px rgb(20 23 28 / .06);
  --e-2: 0 0 0 1px #cfcfc8, 0 16px 40px -12px rgb(20 23 28 / .18);
  --scrim: rgb(20 23 28 / .4);
  --tint: rgb(20 23 28 / .04);
  --tint-2: rgb(20 23 28 / .07);
  --sel: rgb(10 108 158 / .2);
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--s-5));
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-text);
  font-size: var(--t-base);
  line-height: 1.68;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

img, svg, video { max-width: 100%; height: auto; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--sel); }

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: var(--t-xl); line-height: 1.15; letter-spacing: -.02em; }
h2 { font-size: var(--t-lg); line-height: 1.3; }
h3 { font-size: var(--t-md); line-height: 1.45; }
p  { margin: 0 0 var(--s-4); }
ul, ol { margin: 0 0 var(--s-4); padding-left: var(--s-6); }
li { margin: 0 0 var(--s-2); }
li::marker { color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-7) 0; }

code, kbd, samp, pre { font-family: var(--font-mono); }
code {
  font-size: .9em; background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: var(--r-1); padding: .1em .32em;
  /* Inline code wraps: a 70-character document filename has to break somewhere
     or it pushes 420px of page width past a 320px screen. `break-word` only
     breaks a run that cannot fit, so ordinary identifiers are untouched. */
  overflow-wrap: break-word; word-break: normal;
}
/* Inside a table cell an identifier is a value being compared down a column,
   so it scrolls rather than wrapping. Breaking C167CR-LM across two lines is a
   wrong answer, not a wrapped one. */
td code, th code, caption code, .nowrap code, .mono code, pre code {
  overflow-wrap: normal; word-break: keep-all;
}
pre {
  margin: 0 0 var(--s-5); background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: var(--r-2); padding: var(--s-4);
  overflow-x: auto; font-size: var(--t-xs); line-height: 1.55;
  tab-size: 2;
}
pre code { background: none; border: 0; padding: 0; font-size: 1em; }
kbd {
  font-size: var(--t-3xs); background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: var(--r-1); padding: .1em .4em;
}

.sr, .sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: var(--s-4); top: var(--s-2); z-index: var(--z-dialog);
  transform: translateY(-200%);
  background: var(--accent); color: var(--accent-ink); padding: var(--s-2) var(--s-4);
  border-radius: var(--r-2); font-size: var(--t-sm); font-weight: 600;
}
.skip:focus { transform: none; }

/* ------------------------------------------------------------------ layout */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.wrap {
  width: 100%; max-width: var(--page-max); margin: 0 auto;
  padding: 0 var(--gutter);
}

.body {
  flex: 1;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  align-items: start;
  gap: 0;
}
.body[data-ctx="1"] { grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--ctx-w); }
.body[data-rail="min"] { grid-template-columns: var(--rail-w-min) minmax(0, 1fr); }
.body[data-rail="min"][data-ctx="1"] {
  grid-template-columns: var(--rail-w-min) minmax(0, 1fr) var(--ctx-w);
}

/* ------------------------------------------------------------------ header */
.hdr {
  position: sticky; top: 0; z-index: var(--z-header);
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.hdr__in {
  height: 100%; display: flex; align-items: center; gap: var(--s-4);
  max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter);
}

.brand {
  display: flex; align-items: center; gap: var(--s-3); color: var(--ink);
  font-weight: 700; font-size: var(--t-sm); letter-spacing: -.01em;
  flex: 0 0 auto; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 28px; height: 28px; border-radius: var(--r-2); display: grid;
  place-items: center; background: var(--accent); color: var(--accent-ink);
  font-size: var(--t-3xs); font-weight: 800; letter-spacing: 0;
  font-family: var(--font-mono);
}
.brand__txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand__sub { font-size: var(--t-3xs); color: var(--ink-3); font-weight: 500; letter-spacing: .02em; }

.crumb { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.crumb ol {
  display: flex; align-items: center; gap: var(--s-2); list-style: none;
  margin: 0; padding: 0; font-size: var(--t-xs); white-space: nowrap;
  overflow: hidden; mask-image: linear-gradient(90deg, var(--fade) 88%, transparent);
}
.crumb li { display: flex; align-items: center; gap: var(--s-2); margin: 0; min-width: 0; }
.crumb li + li::before { content: "/"; color: var(--ink-3); }
.crumb a { color: var(--ink-2); }
.crumb [aria-current] { color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumb__drop { display: none; }

.hdr__act { display: flex; align-items: center; gap: var(--s-2); flex: 0 0 auto; }

.omni {
  display: flex; align-items: center; gap: var(--s-2);
  height: 34px; padding: 0 var(--s-2) 0 var(--s-3);
  background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: var(--r-2); color: var(--ink-3); font-size: var(--t-xs);
  min-width: 200px; cursor: pointer;
}
.omni:hover { border-color: var(--line-2); color: var(--ink-2); }
.omni__k { margin-left: auto; }

.iconbtn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line);
  border-radius: var(--r-2); color: var(--ink-2); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--line-2); }
.iconbtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.railtoggle { display: none; }

/* -------------------------------------------------------------------- rail */
.rail {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: var(--s-5) var(--s-3) var(--s-8);
}
.rail__group + .rail__group { margin-top: var(--s-6); }
.rail__label {
  font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 600; padding: 0 var(--s-3) var(--s-2);
}
.rail__link {
  display: flex; align-items: center; gap: var(--s-3);
  height: 38px; padding: 0 var(--s-3); border-radius: var(--r-2);
  color: var(--ink-2); font-size: var(--t-sm); position: relative;
}
.rail__link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.rail__link[aria-current] { background: var(--surface-3); color: var(--ink); font-weight: 600; }
.rail__link[aria-current]::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: var(--r-full); background: var(--accent);
}
.rail__link svg { width: 16px; height: 16px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.7; }
.rail__n { margin-left: auto; font-family: var(--font-mono); font-size: var(--t-3xs); color: var(--ink-3); }

.rail__find { padding: 0 var(--s-2) var(--s-3); }
.rail__find input {
  width: 100%; height: 32px; padding: 0 var(--s-3); font-size: var(--t-xs);
  background: var(--bg-sunk); border: 1px solid var(--line);
  border-radius: var(--r-2); color: var(--ink); font-family: inherit;
}
.rail__find input::placeholder { color: var(--ink-3); }

.body[data-rail="min"] .rail { padding: var(--s-5) var(--s-2) var(--s-8); }
.body[data-rail="min"] .rail__label,
.body[data-rail="min"] .rail__n,
.body[data-rail="min"] .rail__find { display: none; }
.body[data-rail="min"] .rail__link { justify-content: center; padding: 0; }
.body[data-rail="min"] .rail__t { display: none; }
@media (min-width: 901px) { .body[data-rail="min"] .rail__link::after {
  content: attr(data-tip); position: absolute; left: calc(100% + var(--s-3));
  background: var(--surface-3); color: var(--ink); border: 1px solid var(--line-2);
  padding: var(--s-1) var(--s-3); border-radius: var(--r-2); font-size: var(--t-xs);
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity var(--dur-1);
  box-shadow: var(--e-1); z-index: var(--z-rail);
} .body[data-rail="min"] .rail__link:hover::after,
.body[data-rail="min"] .rail__link:focus-visible::after { opacity: 1; } }

/* --------------------------------------------------------------------- main */
.main { min-width: 0; padding: var(--s-7) 0 var(--s-9); }
.main__in { max-width: var(--measure); }
/* the launcher and the search page have no rail, so they carry the page gutter
   themselves -- otherwise their content runs flush to the viewport edge */
.main__in--pad {
  max-width: none; padding: 0 var(--gutter);
  width: 100%; max-width: calc(var(--page-max) - 2 * var(--gutter));
  margin: 0 auto;
}
.main--wide .main__in { max-width: none; }

.phead { margin-bottom: var(--s-6); }
.phead__loc {
  font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 600; margin-bottom: var(--s-3);
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
}
.phead__loc .dot { color: var(--ink-3); }
.phead h1 { margin-bottom: var(--s-3); }
.lead { font-size: var(--t-md); line-height: 1.5; color: var(--ink-2); margin: 0; max-width: var(--measure); }

.facets {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
  margin: var(--s-5) 0 var(--s-6); padding: var(--s-4) 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: var(--t-xs);
}
.facets__k {
  font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 600;
}
.facets details { margin: 0; }
.facets summary { cursor: pointer; color: var(--ink-2); list-style: none; display: inline-flex; align-items: center; gap: var(--s-2); }
.facets summary::-webkit-details-marker { display: none; }
.facets summary::before { content: "▸"; color: var(--ink-3); }
.facets details[open] summary::before { content: "▾"; }
.facets__chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-3); max-width: 640px; }

/* ---------------------------------------------------------------- prose */
.prose > * { max-width: var(--measure); }
.prose > .full, .prose > .table-wrap, .prose > .art, .prose > figure { max-width: none; }
.prose h2 {
  margin: var(--s-8) 0 var(--s-3); padding-top: var(--s-5);
  border-top: 1px solid var(--line); scroll-margin-top: calc(var(--header-h) + var(--s-5));
}
.prose h2:first-child { margin-top: var(--s-6); }
.prose h3 { margin: var(--s-6) 0 var(--s-3); scroll-margin-top: calc(var(--header-h) + var(--s-5)); }
.prose h4 { margin: var(--s-5) 0 var(--s-2); font-size: var(--t-sm); color: var(--ink-2); }
.prose ul, .prose ol { padding-left: var(--s-6); }
.prose li > ul, .prose li > ol { margin: var(--s-2) 0 0; }
.prose blockquote {
  margin: 0 0 var(--s-5); padding: var(--s-4) var(--s-5);
  border-left: 3px solid var(--info); background: var(--surface);
  border-radius: 0 var(--r-2) var(--r-2) 0; color: var(--ink-2);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 650; color: var(--ink); }
.prose a[data-broken] { color: var(--danger); text-decoration: underline wavy; }
.prose figure { margin: 0 0 var(--s-5); }
.prose figcaption { font-size: var(--t-xs); color: var(--ink-3); margin-top: var(--s-2); }
.prose hr { margin: var(--s-7) 0; }

/* ------------------------------------------------------------------ tables */
.table-wrap {
  margin: 0 0 var(--s-5);
  border: 1px solid var(--line); border-radius: var(--r-3);
  background: var(--surface); overflow: auto; position: relative;
  max-height: min(78vh, 900px);
}
.table-wrap[data-short] { max-height: none; }
.table-wrap:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; font-size: var(--t-xs); }
caption { caption-side: top; text-align: left; padding: var(--s-3) var(--s-4); font-size: var(--t-2xs); color: var(--ink-3); border-bottom: 1px solid var(--line); }
th, td { padding: var(--s-3) var(--s-4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--bg-sunk);
  font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); font-weight: 600; white-space: nowrap;
}
tbody tr:nth-child(even) { background: var(--tint); }
tbody tr:hover { background: var(--tint-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono, td .mono { font-family: var(--font-mono); }
.nowrap { white-space: nowrap; }
.tbl--sticky1 td:first-child, .tbl--sticky1 th:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
  border-right: 1px solid var(--line);
}
.tbl--sticky1 thead th:first-child { z-index: 3; background: var(--bg-sunk); }
.tbl--sticky1 tbody tr:nth-child(even) td:first-child { background: color-mix(in srgb, var(--surface) 96%, var(--ink) 4%); }
/* The cue sits at the top-right of the scroll box, beside the header row, so it
   is visible the moment the content overflows rather than at the bottom of a
   scroll area the reader has not reached yet. */
.scrollcue {
  display: none; position: absolute; top: 2px; right: 6px; z-index: 4;
  padding: 1px var(--s-3); font-size: var(--t-3xs);
  color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: var(--r-full); pointer-events: none; white-space: nowrap;
}
.table-wrap[data-over="1"] .scrollcue { display: block; }
.table-wrap { position: relative; }

/* the map matrix's per-row detail: collapsed by default, because thirteen open
   panels bury the table they belong to */
.mapdetail > summary {
  cursor: pointer; font-size: var(--t-2xs); color: var(--ink-3);
  list-style: none; display: inline-flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) 0;
}
.mapdetail > summary::-webkit-details-marker { display: none; }
.mapdetail > summary::before { content: "▸"; color: var(--accent); }
.mapdetail[open] > summary::before { content: "▾"; }
.mapdetail > summary:hover { color: var(--ink-2); }
.row-detail > td { background: var(--bg-sunk); padding: var(--s-2) var(--s-4); }
.row-detail { border-bottom: 1px solid var(--line); }
.tbl--cards { display: none; }
.cards { display: grid; gap: var(--s-3); }
.card-row {
  border: 1px solid var(--line); border-radius: var(--r-3); padding: var(--s-4);
  background: var(--surface); display: grid; gap: var(--s-2);
}
.card-row dt { font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.card-row dd { margin: 0 0 var(--s-2); font-size: var(--t-xs); }
.card-row dd:last-child { margin-bottom: 0; }
.card-row--link:hover { border-color: var(--line-2); }
.card-row--link { display: block; color: inherit; }
.card-row--link:hover { text-decoration: none; }
.card-row__t { font-size: var(--t-sm); font-weight: 600; color: var(--ink); margin-bottom: var(--s-1); }

.density-compact th, .density-compact td { padding: var(--s-2) var(--s-3); }

/* -------------------------------------------------------------------- art */
.art {
  margin: 0 0 var(--s-5); border: 1px solid var(--line); border-radius: var(--r-3);
  background: var(--bg-sunk); overflow: hidden;
}
.art__bar {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3);
  border-bottom: 1px solid var(--line); background: var(--surface); font-size: var(--t-3xs);
}
.art__t { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.art__bar .grow { flex: 1; }
.art pre { margin: 0; border: 0; border-radius: 0; background: none; padding: var(--s-4); }
.art__more {
  display: block; width: 100%; padding: var(--s-2); font-size: var(--t-2xs);
  background: var(--surface-2); border: 0; border-top: 1px solid var(--line);
  color: var(--ink-2); cursor: pointer; font-family: inherit;
}
.art__more:hover { background: var(--surface-3); color: var(--ink); }
.copy {
  display: inline-flex; align-items: center; gap: var(--s-1); height: 22px;
  padding: 0 var(--s-2); font-size: var(--t-3xs); font-family: var(--font-text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-1);
  color: var(--ink-3); cursor: pointer; flex: 0 0 auto;
}
.copy:hover { color: var(--ink); border-color: var(--line-2); }
.copy[data-done="1"] { color: var(--ok); border-color: var(--ok); }
.addr { cursor: copy; border-bottom: 1px dotted var(--ink-3); }
.addr:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* -------------------------------------------------------------------- math */
.mx { font-family: var(--font-mono); font-size: .94em; white-space: nowrap; }
.mx--block {
  display: block; white-space: normal; text-align: center; margin: var(--s-5) 0;
  padding: var(--s-4) var(--s-5); background: var(--bg-sunk);
  border: 1px solid var(--line); border-radius: var(--r-3); overflow-x: auto;
}
.mx--block .mx-row { display: block; margin: 0 0 var(--s-2); }
.mx--block .mx-row:last-child { margin-bottom: 0; }
.mx-src { font-family: var(--font-mono); font-size: .9em; color: var(--warn); word-break: break-all; }
.mx__op { padding: 0 .28em; }
.mx__frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 .18em; }
.mx__frac > span:first-child { border-bottom: 1px solid currentColor; padding: 0 .3em; }
.mx__frac > span:last-child { padding: 0 .3em; }
.mx__sqrt { border-top: 1px solid currentColor; padding: 0 .25em 0 .1em; margin-left: .1em; }
.mx__sub { font-size: .72em; vertical-align: -.28em; }
.mx__sup { font-size: .72em; vertical-align: .42em; }
.mx__brace { font-size: 1.5em; vertical-align: -.22em; line-height: 1; }
.mx__sum, .mx__int { font-size: 1.35em; vertical-align: -.28em; line-height: 1; }
.mx__ud { display: inline-grid; grid-template-rows: auto auto; vertical-align: middle; text-align: center; font-size: .82em; margin: 0 .15em; }
.mx__ud > span:first-child { border-bottom: 1px solid currentColor; }
.mx__op--big { font-size: 1.15em; vertical-align: -.1em; padding: 0 .2em; }

/* the formula index's source label is a sentence, so it wraps like one */
.fx-head { align-items: flex-start; }
.fx-src {
  font-size: var(--t-2xs); color: var(--ink-3); min-width: 0; flex: 1 1 240px;
  overflow-wrap: anywhere; line-height: 1.45;
}

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-size: var(--t-3xs); font-weight: 600; letter-spacing: .01em;
  padding: 1px var(--s-2); border-radius: var(--r-full);
  border: 1px solid currentColor; white-space: nowrap; line-height: 1.6;
}
.badge--ok { color: var(--ok); }
.badge--warn { color: var(--warn); }
.badge--danger { color: var(--danger); }
.badge--info { color: var(--info); }
.badge--neutral { color: var(--ink-3); }
.badge--accent { color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-size: var(--t-xs); padding: 1px var(--s-3); border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2);
  font-family: var(--font-mono); white-space: nowrap;
}
a.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip--accent { color: var(--accent); border-color: var(--accent); background: none; }
.chip--teal { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 45%, transparent); }
button.chip { cursor: pointer; font-family: var(--font-text); }
button.chip:hover { border-color: var(--accent); color: var(--accent); }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 38px; padding: 0 var(--s-5); border-radius: var(--r-2);
  background: var(--surface-2); border: 1px solid var(--line-2);
  color: var(--ink); font-size: var(--t-sm); font-weight: 600;
  font-family: inherit; cursor: pointer;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn--sm { height: 30px; padding: 0 var(--s-3); font-size: var(--t-xs); }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.btnrow { display: flex; flex-wrap: wrap; gap: var(--s-3); margin: var(--s-5) 0; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-2); overflow: hidden; }
.seg button {
  height: 30px; padding: 0 var(--s-3); font-size: var(--t-xs); font-family: inherit;
  background: var(--surface); border: 0; border-right: 1px solid var(--line);
  color: var(--ink-2); cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------------ inputs */
.field { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.field > label, .lbl {
  font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 600;
}
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  width: 100%; height: 36px; padding: 0 var(--s-3);
  font-family: inherit; font-size: var(--t-sm); color: var(--ink);
  background: var(--bg-sunk); border: 1px solid var(--line-2);
  border-radius: var(--r-2);
}
input::placeholder { color: var(--ink-3); }
input:hover, select:hover { border-color: var(--ink-3); }
input:focus-visible, select:focus-visible { border-color: var(--accent); }
select { cursor: pointer; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3);
  padding: var(--s-3) 0 var(--s-5); position: sticky; top: var(--header-h);
  background: var(--bg); z-index: 5; border-bottom: 1px solid var(--line);
  margin-bottom: var(--s-5);
}
.toolbar input[type="search"] { flex: 1 1 220px; min-width: 160px; }
.toolbar select { width: auto; min-width: 130px; }
.toolbar__n { font-size: var(--t-xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.toolbar__n b { color: var(--ink-2); font-weight: 600; }

.grp { display: grid; gap: var(--s-3); }
.grp--2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grp--3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grp--4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }

.panel {
  border: 1px solid var(--line); border-radius: var(--r-3);
  background: var(--surface); padding: var(--s-5); margin-bottom: var(--s-5);
}
.panel--pad { padding: var(--s-4); }
.panel__t { font-size: var(--t-sm); font-weight: 650; margin-bottom: var(--s-2); }
.panel__d { font-size: var(--t-xs); color: var(--ink-3); margin: 0 0 var(--s-4); }

.note {
  border: 1px solid var(--line); border-left: 3px solid var(--info);
  background: var(--surface); border-radius: 0 var(--r-2) var(--r-2) 0;
  padding: var(--s-4); margin: 0 0 var(--s-5); font-size: var(--t-xs); color: var(--ink-2);
}
.note--warn { border-left-color: var(--warn); }
.note--danger { border-left-color: var(--danger); }
.note strong { color: var(--ink); }
.note p:last-child { margin-bottom: 0; }

.stat { padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); }
.stat__v { font-size: var(--t-xl); font-weight: 700; line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat__k { font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; margin-top: var(--s-1); }
.stat__s { font-size: var(--t-2xs); color: var(--ink-3); margin-top: var(--s-1); }

.linklist { display: grid; gap: var(--s-1); margin: 0; padding: 0; list-style: none; }
.linkrow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s-3);
  align-items: baseline; padding: var(--s-3) var(--s-4); border-radius: var(--r-2);
  border: 1px solid var(--line); background: var(--surface); color: inherit;
}
.linkrow:hover { border-color: var(--line-2); background: var(--surface-2); text-decoration: none; }
.linkrow__n { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--ink-3); min-width: 2.6ch; }
.linkrow__t { font-size: var(--t-sm); font-weight: 600; color: var(--ink); }
.linkrow__d { grid-column: 2 / -1; font-size: var(--t-xs); color: var(--ink-3); margin: 0; }
.linkrow__m { font-size: var(--t-3xs); color: var(--ink-3); font-family: var(--font-mono); white-space: nowrap; }
.linkrow__n--b { min-width: 3.6ch; }

.grouphd {
  display: flex; align-items: baseline; gap: var(--s-3);
  margin: var(--s-7) 0 var(--s-3); padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--line-2);
}
.grouphd:first-child { margin-top: 0; }
.grouphd__n { font-family: var(--font-mono); font-size: var(--t-xs); color: var(--accent); font-weight: 600; }
.grouphd__t { font-size: var(--t-sm); font-weight: 650; }
.grouphd__m { margin-left: auto; font-size: var(--t-2xs); color: var(--ink-3); }

/* -------------------------------------------------------------- context rail */
.ctx {
  position: sticky; top: var(--header-h);
  max-height: calc(100vh - var(--header-h)); overflow-y: auto; overscroll-behavior: contain;
  padding: var(--s-7) var(--s-5) var(--s-8) var(--s-5);
  border-left: 1px solid var(--line); font-size: var(--t-xs);
}
.ctx__l { font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; margin-bottom: var(--s-3); }
.ctx ol { list-style: none; margin: 0; padding: 0; }
.ctx ol ol { padding-left: var(--s-3); margin-top: var(--s-1); }
.ctx li { margin: 0; }
.ctx a {
  display: block; padding: var(--s-1) var(--s-3); border-left: 2px solid var(--line);
  color: var(--ink-3); line-height: 1.45;
}
.ctx a:hover { color: var(--ink-2); border-left-color: var(--line-2); text-decoration: none; }
.ctx a[data-on] { color: var(--ink); border-left-color: var(--accent); font-weight: 600; }
.ctx a[data-l="3"] { padding-left: var(--s-6); }
.ctx__top { display: none; margin-top: var(--s-4); }
.ctx__top[data-on] { display: block; }
.ctxmobile { display: none; }

/* ------------------------------------------------------------------- pager */
.pager {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3);
  margin-top: var(--s-8); padding-top: var(--s-5); border-top: 1px solid var(--line);
}
.pager a {
  display: grid; gap: 2px; padding: var(--s-4); border: 1px solid var(--line);
  border-radius: var(--r-3); background: var(--surface); color: inherit; min-width: 0;
}
.pager a:hover { border-color: var(--line-2); background: var(--surface-2); text-decoration: none; }
.pager a:last-child { text-align: right; }
.pager__k { font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.pager__t { font-size: var(--t-sm); color: var(--ink); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager__empty { border: 0; background: none; }

/* ------------------------------------------------------------------- footer */
.ftr {
  border-top: 1px solid var(--line); margin-top: var(--s-9);
  padding: var(--s-6) 0 var(--s-8); font-size: var(--t-xs); color: var(--ink-3);
}
.ftr__in { display: flex; flex-wrap: wrap; gap: var(--s-5); align-items: center; max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter); }
.ftr nav { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.ftr a { color: var(--ink-2); }
.ftr p { margin: 0; }

/* ------------------------------------------------------------------ palette */
dialog {
  padding: 0; border: 0; background: transparent; color: var(--ink);
  max-width: min(760px, calc(100vw - 2 * var(--gutter)));
  width: 100%;
}
dialog::backdrop { background: var(--scrim); }
.pal {
  background: var(--surface); border-radius: var(--r-4); box-shadow: var(--e-2);
  overflow: hidden; display: flex; flex-direction: column; max-height: min(72vh, 640px);
}
.pal__q { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); border-bottom: 1px solid var(--line); }
.pal__q svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: var(--ink-3); stroke-width: 1.7; }
.pal__q input { flex: 1; height: 40px; border: 0; background: none; font-size: var(--t-md); }
.pal__q input:focus-visible { outline: none; }
.pal__body { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); flex: 1; min-height: 0; }
.pal__res { overflow-y: auto; padding: var(--s-2); border-right: 1px solid var(--line); }
.pal__prev { overflow-y: auto; padding: var(--s-4); font-size: var(--t-xs); color: var(--ink-2); background: var(--bg-sunk); }
.pal__prev h3 { font-size: var(--t-sm); color: var(--ink); margin-bottom: var(--s-2); }
.pal__prev dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s-2) var(--s-3); margin: 0; }
.pal__prev dt { font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; }
.pal__prev dd { margin: 0; font-family: var(--font-mono); font-size: var(--t-2xs); word-break: break-word; }
.pal__g { font-size: var(--t-3xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: var(--s-3) var(--s-3) var(--s-1); }
.pal__i {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s-3);
  align-items: baseline; padding: var(--s-2) var(--s-3); border-radius: var(--r-2);
  color: var(--ink-2); cursor: pointer;
}
.pal__i[aria-selected="true"] { background: var(--surface-3); color: var(--ink); }
.pal__i:hover { background: var(--surface-2); }
.pal__t { font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal__t mark { background: none; color: var(--accent); font-weight: 700; }
.pal__k { font-size: var(--t-3xs); font-family: var(--font-mono); color: var(--ink-3); }
.pal__n { font-size: var(--t-3xs); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pal__e { display: block; font-size: var(--t-2xs); color: var(--ink-3); grid-column: 2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal__f { padding: var(--s-2) var(--s-4); border-top: 1px solid var(--line); font-size: var(--t-3xs); color: var(--ink-3); display: flex; gap: var(--s-4); flex-wrap: wrap; }
.pal__e:empty, .pal__f:empty { display: none; }
.pal__prev:empty::after { content: "Type to search every chapter, symbol, address, formula and fault code."; color: var(--ink-3); }

/* ------------------------------------------------------------------- tools */
.tool { border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); padding: var(--s-5); margin-bottom: var(--s-5); scroll-margin-top: calc(var(--header-h) + var(--s-5)); }
.tool__t { font-size: var(--t-md); font-weight: 650; margin-bottom: var(--s-2); }
.tool__d { font-size: var(--t-xs); color: var(--ink-3); margin: 0 0 var(--s-4); }
.out {
  font-family: var(--font-mono); font-size: var(--t-sm); background: var(--bg-sunk);
  border: 1px solid var(--line); border-radius: var(--r-2); padding: var(--s-3) var(--s-4);
  overflow-x: auto; white-space: pre-wrap; word-break: break-word; min-height: 40px;
}
.bitgrid { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.bit {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--s-3);
  align-items: center; padding: var(--s-2) var(--s-3); border: 1px solid var(--line);
  border-radius: var(--r-2); background: var(--bg-sunk); font-size: var(--t-xs);
}
.bit[data-on="1"] { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--bg-sunk)); }
.bit input { width: auto; height: auto; }
.bit__b { font-family: var(--font-mono); color: var(--ink-3); font-size: var(--t-3xs); }

/* ---------------------------------------------------------------- diagrams */
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s-4); }
.dcard {
  display: flex; flex-direction: column; border: 1px solid var(--line);
  border-radius: var(--r-3); background: var(--surface); overflow: hidden; color: inherit;
  min-width: 0; max-width: 100%;
}
.dcard:hover { border-color: var(--line-2); text-decoration: none; }
.dcard__h { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); }
.dcard__t { font-size: var(--t-sm); font-weight: 650; color: var(--ink); overflow-wrap: anywhere; }
.dcard__m { font-size: var(--t-3xs); color: var(--ink-3); font-family: var(--font-mono); margin-top: var(--s-1); }
.dcard__b { position: relative; padding: var(--s-3) var(--s-4); background: var(--bg-sunk); flex: 1; min-width: 0; }
/* A 130-column drawing does not fit a 320px card, and clipping it makes the
   preview unreadable -- which is exactly the defect this page was rebuilt to
   fix (audit 3.6). So the art is a real horizontal scroll container and the
   card only fades the vertical tail. */
.dcard__b pre {
  margin: 0; border: 0; background: none; padding: 0; font-size: var(--t-2xs);
  line-height: 1.35; max-height: 132px; overflow: hidden;
  overflow-x: auto; overscroll-behavior-x: contain;
}
.dcard__b pre code { white-space: pre; }
.dcard__b::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 48px; pointer-events: none;
  background: linear-gradient(transparent, var(--bg-sunk));
}
.dcard__o {
  padding: var(--s-2) var(--s-4); font-size: var(--t-2xs); color: var(--accent);
  border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: var(--s-3);
}
.dcard__o::after { content: "\2197"; }

.pal-wrap { position: fixed; inset: 0; z-index: var(--z-dialog); display: grid; place-items: center; padding: var(--gutter); }
.pal-scrim { position: absolute; inset: 0; background: var(--scrim); }
.pal-wrap > .pal { position: relative; z-index: 1; max-height: min(86vh, 900px); width: min(1100px, 100%); display: flex; flex-direction: column; }

.zoom { display: flex; align-items: center; gap: var(--s-2); }
.zoom__n { font-size: var(--t-3xs); color: var(--ink-3); font-family: var(--font-mono); min-width: 4ch; text-align: center; }
.art--zoom pre { font-size: calc(var(--t-xs) * var(--zoom, 1)); }

/* ------------------------------------------------------------------- graph */
.graph { border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); overflow: auto; }
.graph svg { display: block; }
.graph a:focus-visible { outline: 2px solid var(--focus); }
.gnode circle { transition: r var(--dur-1); }
.gnode:hover circle { stroke: var(--accent); stroke-width: 2; }

/* ------------------------------------------------------------------- misc */
.heat { display: block; width: 100%; height: auto; }
.legend { display: flex; align-items: center; gap: var(--s-3); font-size: var(--t-3xs); color: var(--ink-3); flex-wrap: wrap; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); }

.miss { color: var(--ink-3); font-family: var(--font-mono); font-size: var(--t-2xs); }
.hl { background: var(--sel); border-radius: 2px; padding: 0 1px; }

.empty { padding: var(--s-7) var(--s-5); text-align: center; color: var(--ink-3); border: 1px dashed var(--line-2); border-radius: var(--r-3); font-size: var(--t-sm); }

.sr-tabs { display: none; }
[data-hide] { display: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  .rail__link[aria-current]::before { background: Highlight; }
  .badge, .chip, .btn, .panel, .card-row { border: 1px solid CanvasText; }
  thead th { background: Canvas; }
  :focus-visible { outline: 2px solid Highlight; }
}

@media print {
  .hdr, .rail, .ctx, .pager, .toolbar, .ftr, .skip, dialog { display: none !important; }
  .body, .body[data-ctx="1"] { display: block; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .table-wrap { max-height: none; overflow: visible; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; }
  pre, .art { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
}
