/* ============================================================================
   Bosch ME7.5 Reference — design system
   Dark-first. Light theme is a token swap, not a second stylesheet.
   ========================================================================= */

:root {
  --f-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
            Consolas, "Liberation Mono", monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --r-full: 999px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  --side-w: 300px;
  --rail-w: 232px;
  --page-max: 820px;

  --dur: 180ms;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* ------------------------------------------------------------------ dark */
:root, [data-theme="dark"] {
  --bg:        #0a0c0f;
  --bg-soft:   #0f1216;
  --surface:   #14181e;
  --surface-2: #1a1f27;
  --surface-3: #222833;
  --line:      #242b35;
  --line-soft: #1b212a;

  --ink:       #e8ecf1;
  --ink-2:     #a7b2c0;
  --ink-3:     #6c7887;
  --ink-4:     #48525f;

  --accent:    #ff2d4b;
  --accent-dim:#c41f38;
  --accent-ink:#ffffff;
  --amber:     #ffb340;
  --teal:      #35d0c0;
  --violet:    #9d8cff;
  --green:     #57d98a;

  --glow: 0 0 0 1px rgba(255,45,75,.30), 0 8px 32px -12px rgba(255,45,75,.45);

  --grid-dot: rgba(255,255,255,.030);
  --shadow-1: 0 1px 2px rgba(0,0,0,.5);
  --shadow-2: 0 12px 32px -16px rgba(0,0,0,.8);
  --code-bg:  #0c1014;
  color-scheme: dark;
}

/* ----------------------------------------------------------------- light */
[data-theme="light"] {
  --bg:        #f6f7f9;
  --bg-soft:   #ffffff;
  --surface:   #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e8ebef;
  --line:      #dfe3e9;
  --line-soft: #eaedf1;

  --ink:       #0e1218;
  --ink-2:     #414c5a;
  --ink-3:     #6b7684;
  --ink-4:     #97a1ad;

  --accent:    #d5002a;
  --accent-dim:#a80022;
  --accent-ink:#ffffff;
  --amber:     #b26a00;
  --teal:      #0d8c80;
  --violet:     #5b45c8;
  --green:     #12874a;

  --glow: 0 0 0 1px rgba(213,0,42,.22), 0 8px 28px -14px rgba(213,0,42,.35);
  --grid-dot: rgba(0,0,0,.035);
  --shadow-1: 0 1px 2px rgba(16,24,40,.06);
  --shadow-2: 0 12px 28px -18px rgba(16,24,40,.28);
  --code-bg:  #f4f6f8;
  color-scheme: light;
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--f-sans);
  font-size: 15.5px;
  line-height: 1.68;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern" 1, "liga" 1;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
  z-index: 0;
}

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

::selection { background: rgba(255,45,75,.30); }

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

/* --------------------------------------------------------------- layout */
.shell { position: relative; z-index: 1; display: flex; min-height: 100vh; }

/* A scroll container's own content can still inflate the document's scrollable
   area, which shows up as a stray horizontal scrollbar on the page itself even
   though every child is contained. The scrolling element is <html>, so it has
   to be clipped there; clip does it without creating a scroll container, so
   position:sticky headers keep working, and hidden is the fallback. */
html, body { overflow-x: hidden; }
@supports (overflow-x: clip) {
  html, body { overflow-x: clip; }
}

.side {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-soft) 82%, transparent);
  backdrop-filter: blur(14px);
  position: sticky; top: 0;
  height: 100vh;
  display: flex; flex-direction: column;
  z-index: 40;
}

.side__brand {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  display: block;
  color: inherit;
}
.side__brand:hover { text-decoration: none; }
.brand__mark {
  display: flex; align-items: center; gap: var(--sp-3);
  font-weight: 700; letter-spacing: -.02em; font-size: 15px;
}
.brand__dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(140deg, var(--accent), #ff6b3d);
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 800;
  box-shadow: 0 4px 14px -4px rgba(255,45,75,.7);
  flex: 0 0 auto;
}
.brand__sub {
  display: block;
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 500;
  color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase;
  margin-top: 2px;
}

.side__scroll { overflow-y: auto; flex: 1; padding: var(--sp-4) 0 var(--sp-6); }
.side__scroll::-webkit-scrollbar { width: 9px; }
.side__scroll::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: 99px; border: 3px solid transparent;
  background-clip: content-box;
}

.navgroup { margin-bottom: var(--sp-4); }
.navgroup__label {
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-4);
  padding: var(--sp-3) var(--sp-5) var(--sp-2);
}
.navlink {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 6px var(--sp-5); color: var(--ink-2);
  font-size: 13.5px; line-height: 1.4;
  border-left: 2px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.navlink:hover { background: var(--surface); color: var(--ink); text-decoration: none; }
.navlink.is-active {
  color: var(--ink); background: var(--surface);
  border-left-color: var(--accent); font-weight: 500;
}
.navlink__num {
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-4);
  min-width: 22px; text-align: right; flex: 0 0 auto;
}
.navlink.is-active .navlink__num { color: var(--accent); }
.navlink__txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* topbar sits above; content and the toc rail sit side by side below it */
.body { flex: 1; min-width: 0; display: flex; align-items: flex-start; }
.content {
  flex: 1; min-width: 0;
  max-width: var(--page-max);
  padding: var(--sp-7) var(--sp-6) var(--sp-8);
  margin: 0 auto;
  width: 100%;
}
.content--wide { max-width: 1240px; }

/* ------------------------------------------------------------ right rail */
.rail {
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  border-left: 1px solid var(--line-soft);
  padding: var(--sp-7) var(--sp-5) var(--sp-8);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  font-size: 12.5px;
}
.rail__label {
  font-family: var(--f-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-4);
  margin-bottom: var(--sp-3);
}
.rail a {
  display: block; padding: 3px 0 3px var(--sp-3);
  color: var(--ink-3); border-left: 2px solid var(--line);
  line-height: 1.45;
}
.rail a:hover { color: var(--ink); text-decoration: none; }
.rail a.is-active { color: var(--ink); border-left-color: var(--accent); }
.rail a.lvl-3 { padding-left: var(--sp-5); font-size: 12px; }

/* --------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 45;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.topbar__crumb {
  font-family: var(--f-mono); font-size: 12px; color: var(--ink-3);
  display: flex; align-items: center; gap: var(--sp-2); min-width: 0;
}
.topbar__crumb b { color: var(--ink); font-weight: 500; }
.topbar__spacer { flex: 1; }

.iconbtn {
  height: 32px; min-width: 32px; padding: 0 var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink-2);
  font-family: var(--f-mono); font-size: 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: var(--sp-2);
  transition: all var(--dur) var(--ease);
}
.iconbtn:hover { color: var(--ink); border-color: var(--surface-3); background: var(--surface-2); }
.burger { display: none; }

/* ---------------------------------------------------------------- search */
.search { position: relative; flex: 1; max-width: 460px; }
.search input {
  width: 100%; height: 34px;
  padding: 0 var(--sp-4) 0 34px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink);
  font-family: var(--f-sans); font-size: 13.5px;
}
.search input::placeholder { color: var(--ink-4); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--glow); }
.search__icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ink-4); pointer-events: none; display: flex; font-size: 15px;
}
.search__kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--f-mono); font-size: 10px; color: var(--ink-4);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px;
  pointer-events: none;
}
.search__results {
  position: absolute; top: 40px; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--shadow-2);
  max-height: 62vh; overflow-y: auto; display: none; z-index: 60;
}
.search__results.is-open { display: block; }
.sresult {
  display: block; padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft); color: inherit;
}
.sresult:last-child { border-bottom: 0; }
.sresult:hover, .sresult.is-sel { background: var(--surface-2); text-decoration: none; }
.sresult__t { font-size: 13.5px; color: var(--ink); }
.sresult__t mark { background: color-mix(in srgb, var(--amber) 30%, transparent); color: inherit; border-radius: 2px; padding: 0 1px; }
.sresult__m {
  font-family: var(--f-mono); font-size: 10.5px; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px;
}
.sresult__p { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.sresult__p mark { background: color-mix(in srgb, var(--amber) 26%, transparent); color: var(--ink-2); border-radius: 2px; }
.search__empty { padding: var(--sp-4); color: var(--ink-3); font-size: 13px; text-align: center; }

/* ------------------------------------------------------------------ type */
h1, h2, h3, h4, h5, h6 {
  line-height: 1.22; letter-spacing: -.021em; font-weight: 650;
  color: var(--ink); scroll-margin-top: 84px;
}
h1 { font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.5rem); margin: 0 0 var(--sp-4); letter-spacing: -.032em; }
h2 { font-size: 1.42rem; margin: var(--sp-7) 0 var(--sp-4); padding-bottom: var(--sp-2); border-bottom: 1px solid var(--line-soft); }
h3 { font-size: 1.16rem; margin: var(--sp-6) 0 var(--sp-3); }
h4 { font-size: 1.01rem; margin: var(--sp-5) 0 var(--sp-2); color: var(--ink-2); }
h5 { font-size: .93rem; margin: var(--sp-4) 0 var(--sp-2); color: var(--ink-3); }

.anchor {
  opacity: 0; margin-left: .4em; color: var(--ink-4);
  font-weight: 400; text-decoration: none;
}
h1:hover .anchor, h2:hover .anchor, h3:hover .anchor, h4:hover .anchor { opacity: 1; }
.anchor:hover { color: var(--accent); }

p { margin: 0 0 var(--sp-4); }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: var(--sp-6) 0; }

strong { color: var(--ink); font-weight: 620; }
em { color: var(--ink-2); }

code {
  font-family: var(--f-mono);
  font-size: .875em;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: .1em .34em;
  color: var(--teal);
  /* Inline code must be able to break. nowrap here is what made a 650px span
     push the whole document sideways, and it also stopped table cells from
     ever wrapping. Short tokens are unaffected; only long ones wrap. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
a code { color: inherit; }

pre.code {
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow-x: auto;
  position: relative;
  font-size: 12.5px;
  line-height: 1.55;
}
pre.code code {
  background: none; border: 0; padding: 0; color: var(--ink-2);
  font-size: inherit; white-space: pre; display: block;
}
/* Data blocks: reflow instead of scrolling. overflow-wrap:anywhere is what
   actually breaks a long unbroken token, which is the usual culprit. */
pre.code.wrap { white-space: pre-wrap; overflow-x: hidden; }
pre.code.wrap code { white-space: pre-wrap; overflow-wrap: anywhere; }
/* Drawing blocks: columns are load-bearing, so they keep white-space:pre and
   are scaled down to fit by fitart.js. The auto here is the no-JS fallback. */
pre.code.art { overflow-x: auto; }
pre.code.art > code { transform-origin: top left; will-change: transform; }
pre.code::before {
  content: attr(data-lang);
  position: absolute; top: 0; right: 0;
  font-family: var(--f-mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-4);
  background: var(--surface-2);
  border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
  border-radius: 0 var(--r-md) 0 var(--r-md);
  padding: 3px 9px;
}

/* ----------------------------------------------------------------- lists */
.list-wrap ul, .list-wrap ol { margin: 0 0 var(--sp-4); padding-left: 1.4em; }
.list-wrap li { margin: var(--sp-1) 0; }
.list-wrap li > ul, .list-wrap li > ol { margin: var(--sp-1) 0; }
.list-wrap ul { list-style: none; padding-left: 1.15em; }
.list-wrap ul > li { position: relative; }
.list-wrap ul > li::before {
  content: ""; position: absolute; left: -.85em; top: .72em;
  width: 4px; height: 4px; border-radius: 50%; background: var(--ink-4);
}
.list-wrap ol { list-style: decimal; }
.list-wrap ol > li::marker { color: var(--accent); font-family: var(--f-mono); font-size: .9em; }

/* ---------------------------------------------------------------- tables */
.table-wrap {
  margin: 0 0 var(--sp-5);
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
caption {
  caption-side: top; text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
}
.table-wrap:has(caption) { border-radius: 0 0 var(--r-md) var(--r-md); }
thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  /* headers wrap too: nowrap here is the main reason wide tables scroll */
  white-space: normal;
  overflow-wrap: normal;
}
tbody td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  color: var(--ink-2);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tbody td:first-child { color: var(--ink); }
/* Long unbroken tokens inside a cell (offsets, part numbers) must NOT be split
   across lines -- "C167CR-LM" broken as "C167C R-LM" is a wrong answer, not a
   wrapped one. Cells wrap at spaces; a table whose columns cannot fit keeps a
   contained horizontal scroll instead of corrupting its own data. */
tbody td { overflow-wrap: normal; }
td code, th code { white-space: nowrap; overflow-wrap: normal; }

/* Narrow screens: trade type size and padding for a table that fits, so a data
   table normally needs no horizontal scrollbar. overflow-x stays auto rather
   than visible -- with visible, one table that cannot shrink pushes the whole
   page sideways, which is worse than a scrollbar inside the table. */
@media (max-width: 760px) {
  table { font-size: 11.5px; }
  thead th { padding: var(--sp-2) var(--sp-2); font-size: 9px; letter-spacing: .04em; }
  tbody td { padding: var(--sp-2) var(--sp-2); }
  caption { font-size: 9.5px; padding: var(--sp-2) var(--sp-3); }
  /* The library keeps its first three chips on one line so a desktop row stays
     two lines tall. Seven columns will not fit a phone that way, so on a
     narrow screen the chips wrap instead. */
  table.sortable .nowrap { white-space: normal; }
  .toolbar input, .toolbar select { max-width: 100%; min-width: 0; }
}

/* The cross-reference map is injected into a .card, not a .chart, so the
   .chart svg sizing rule never reached it: the svg kept its intrinsic size,
   sat inline, and pushed the document sideways. */
#c-graph svg, .card > svg {
  display: block; width: 100%; height: auto; overflow: hidden;
}

/* -------------------------------------------------------------- callout */
blockquote.callout {
  margin: 0 0 var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border-radius: 0 var(--r-md) var(--r-md) 0;
  color: var(--ink-2); font-size: 14.5px;
}
blockquote.callout p:last-child { margin-bottom: 0; }
blockquote.callout strong { color: var(--ink); }

/* ------------------------------------------------------------------ math */
.math {
  font-family: var(--f-mono); font-size: .87em;
  color: var(--violet);
  background: color-mix(in srgb, var(--violet) 9%, transparent);
  border-radius: 3px; padding: .05em .3em;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.math-block {
  display: block; white-space: normal;
  margin: var(--sp-3) 0; padding: var(--sp-3) var(--sp-4);
  border-left: 2px solid color-mix(in srgb, var(--violet) 40%, transparent);
  overflow-x: auto;
}
.katex { font-size: 1.02em; }
.katex-display { margin: var(--sp-4) 0 !important; overflow-x: auto; overflow-y: hidden; }

/* ----------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}
.card--pad-lg { padding: var(--sp-6); }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }

/* ----------------------------------------------------------------- stats */
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), transparent);
}
.stat--teal::after  { background: linear-gradient(180deg, var(--teal), transparent); }
.stat--amber::after { background: linear-gradient(180deg, var(--amber), transparent); }
.stat--violet::after{ background: linear-gradient(180deg, var(--violet), transparent); }
.stat__v {
  font-family: var(--f-mono); font-size: 1.85rem; font-weight: 700;
  letter-spacing: -.03em; line-height: 1.1; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat__k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); margin-top: var(--sp-2);
  font-family: var(--f-mono); font-weight: 500;
}
.stat__s { font-size: 12px; color: var(--ink-4); margin-top: var(--sp-2); }

/* ----------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--r-full);
  background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--f-mono); font-size: 11px; color: var(--ink-2);
  white-space: nowrap;
}
.chip--accent { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.chip--teal   { color: var(--teal);   border-color: color-mix(in srgb, var(--teal) 35%, var(--line));   background: color-mix(in srgb, var(--teal) 10%, transparent); }
.chip--amber  { color: var(--amber);  border-color: color-mix(in srgb, var(--amber) 35%, var(--line));  background: color-mix(in srgb, var(--amber) 10%, transparent); }
.chip--violet { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 35%, var(--line)); background: color-mix(in srgb, var(--violet) 10%, transparent); }
.chip a { color: inherit; }
button.chip { cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ------------------------------------------------------------- meta strip */
.metastrip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; margin: 0 0 var(--sp-6);
}
.metastrip__cell { background: var(--surface); padding: var(--sp-3) var(--sp-4); }
.metastrip__k {
  font-family: var(--f-mono); font-size: 9.5px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-4);
  margin-bottom: 4px;
}
.metastrip__v { font-size: 13px; color: var(--ink-2); }
.metastrip__v--long { font-size: 12px; line-height: 1.75; }

/* ------------------------------------------------------------------ hero */
.hero { padding: var(--sp-7) 0 var(--sp-6); }
.hero__eyebrow {
  font-family: var(--f-mono); font-size: 11px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--accent);
  display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4);
}
.hero__eyebrow::after { content: ""; height: 1px; flex: 1; background: linear-gradient(90deg, var(--accent), transparent); }
.hero h1 { font-size: clamp(1.9rem, 1.4rem + 2.2vw, 3rem); letter-spacing: -.035em; line-height: 1.06; max-width: 20ch; }
.hero__lead {
  font-size: clamp(1rem, .95rem + .3vw, 1.18rem);
  color: var(--ink-2); max-width: 62ch; line-height: 1.6;
  margin-top: var(--sp-4);
}
.hero__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-5); }

.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 40px; padding: 0 var(--sp-5);
  border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.btn:hover { border-color: var(--surface-3); background: var(--surface-2); text-decoration: none; transform: translateY(-1px); }
.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: 0 8px 22px -10px color-mix(in srgb, var(--accent) 70%, transparent);
}
.btn--primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

/* ---------------------------------------------------------------- charts */
.chart {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--sp-5);
  margin: 0 0 var(--sp-5);
}
.chart__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-4); }
.chart__t { font-size: 14.5px; font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.chart__s { font-size: 12px; color: var(--ink-4); font-family: var(--f-mono); }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart svg text { font-family: var(--f-mono); font-size: 10.5px; fill: var(--ink-3); }
.chart svg .lbl { fill: var(--ink-2); }
.chart svg .val { fill: var(--ink); font-weight: 600; }
.chart svg .gridline { stroke: var(--line-soft); stroke-width: 1; }
.chart svg .axisline { stroke: var(--line); stroke-width: 1; }

/* Mermaid: the diagram is the card content, the source is the fallback */
.mermaid { display: flex; justify-content: center; overflow-x: auto; }
.mermaid svg { max-width: 100%; height: auto; }
.mermaid .nodeLabel, .mermaid .label, .mermaid text { font-family: var(--f-mono) !important; }
pre.mermaid-src {
  display: none;
  margin: var(--sp-4) 0 0; padding: var(--sp-4);
  background: var(--code-bg); border: 1px dashed var(--line);
  border-radius: var(--r-sm); overflow-x: hidden;
  font-size: 11.5px; line-height: 1.5; color: var(--ink-2);
  /* this is source code, not a drawing: wrap it, never scroll it */
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.chart:has(.mermaid[data-failed]) pre.mermaid-src { display: block; }

.bar { transition: opacity var(--dur) var(--ease); cursor: pointer; }
.bar:hover { opacity: .78; }

.legend { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin-top: var(--sp-4); }
.legend__i { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-3); }
.legend__sw { width: 10px; height: 10px; border-radius: 3px; }

.tip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 6px 10px; font-size: 12px; box-shadow: var(--shadow-2);
  opacity: 0; transition: opacity 120ms var(--ease);
  max-width: 280px;
}
.tip.is-on { opacity: 1; }
.tip b { color: var(--accent); }

/* ---------------------------------------------------------------- tables UI */
.toolbar {
  display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center;
  margin-bottom: var(--sp-4);
}
.toolbar input, .toolbar select {
  height: 34px; padding: 0 var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font-size: 13px;
  font-family: var(--f-sans);
}
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); }
.toolbar input { min-width: 220px; }
.toolbar__count { margin-left: auto; font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-4); }

.sortable th[data-sort] { cursor: pointer; user-select: none; }
.sortable th[data-sort]:hover { color: var(--ink); }
.sortable th[data-sort]::after { content: " \2195"; opacity: .35; }
.sortable th[data-sort].asc::after  { content: " \2191"; opacity: 1; color: var(--accent); }
.sortable th[data-sort].desc::after { content: " \2193"; opacity: 1; color: var(--accent); }

/* ---------------------------------------------------------------- gallery */
.dgrid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.dcard {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); overflow: hidden; color: inherit;
  display: flex; flex-direction: column;
  transition: all var(--dur) var(--ease);
}
.dcard:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-2); text-decoration: none; }
.dcard__head { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--line-soft); }
.dcard__t { font-size: 12.5px; color: var(--ink); font-weight: 550; }
.dcard__m { font-family: var(--f-mono); font-size: 10px; color: var(--ink-4); text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }
.dcard__body {
  padding: var(--sp-3); overflow: hidden; flex: 1;
  background: var(--code-bg);
  height: 240px; position: relative;
}
.dcard__body::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 60px;
  background: linear-gradient(transparent, var(--code-bg));
}
.dcard__body pre {
  margin: 0; font-family: var(--f-mono); font-size: 7.4px; line-height: 1.2;
  color: var(--ink-2); white-space: pre; transform-origin: top left;
}

/* ---------------------------------------------------------------- footer */
.pager {
  display: flex; justify-content: space-between; gap: var(--sp-4);
  margin-top: var(--sp-7); padding-top: var(--sp-5);
  border-top: 1px solid var(--line-soft);
}
.pager a {
  display: flex; flex-direction: column; gap: 2px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); color: var(--ink-2); min-width: 0; max-width: 46%;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; color: var(--ink); }
.pager__k { font-family: var(--f-mono); font-size: 9.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-4); }
.pager__t { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager a.next { text-align: right; margin-left: auto; }

/* --------------------------------------------------------------- utility */
.muted { color: var(--ink-3); }
.mono { font-family: var(--f-mono); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.center { text-align: center; }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.nowrap { white-space: nowrap; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.section-label {
  font-family: var(--f-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-4);
  display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-7) 0 var(--sp-4);
}
.section-label::after { content: ""; height: 1px; flex: 1; background: var(--line-soft); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1180px) { .rail { display: none; } }
@media (max-width: 900px) {
  .side {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    box-shadow: var(--shadow-2);
  }
  body.nav-open .side { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 35; }
  .burger { display: inline-flex; }
  .content { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
  .search { max-width: none; }
  .search__kbd { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 15px; }
  .topbar { padding: var(--sp-2) var(--sp-3); }
  .topbar__crumb { display: none; }
  h1 { font-size: 1.6rem; }
}

@media print {
  .side, .rail, .topbar, .pager, .search { display: none !important; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .content { max-width: none; padding: 0; }
  pre.code, .table-wrap, .card, .chart { break-inside: avoid; border-color: #ccc; }
  a { color: #000; text-decoration: underline; }
}
