/* Research project pages: shared styles.
   Used by /agentcompress/, /hagd/, /pmp-dacis/ and /laf-yolov10/.
   Chart colours follow the same reference palette as images/papers/*.svg. */

/* ---------- Tokens: light (default) ---------- */
:root {
  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --font-math: "STIX Two Math", "Cambria Math", "Latin Modern Math", math;

  color-scheme: light;
  --bg: #fdfdfc;
  --surface: #f5f5f2;
  --surface-2: #ecebe6;
  --ink: #121211;
  --ink-2: #4a4945;
  --muted: #6b6a64;
  --rule: #e2e1db;
  --rule-strong: #262624;
  --grid: #e3e2dc;
  --axis: #b9b8ae;
  --deemph: #b8b7ae;
  --deemph-2: #dddcd5;
  --tip-bg: #1b1b1a;
  --tip-ink: #fdfdfc;
  --tip-muted: #bdbcb3;
  --topbar-bg: rgba(253, 253, 252, 0.9);

  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --pos: #2a78d6; --neg: #e34948;

  --hm-0: #cde2fb; --hm-1: #9ec5f4; --hm-2: #6da7ec; --hm-3: #5598e7;
  --hm-4: #3987e5; --hm-5: #256abf; --hm-6: #184f95; --hm-7: #0d366b;
  --hm-t-lo: #121211; --hm-t-hi: #ffffff;

  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: #edf3fb;
  --accent-line: #9ec5f4;
}

/* Per-paper accents: one validated palette hue each. */
.acc-blue   { --accent: #2a78d6; --accent-ink: #1c5cab; --accent-wash: #edf3fb; --accent-line: #9ec5f4; }
.acc-violet { --accent: #4a3aa7; --accent-ink: #4a3aa7; --accent-wash: #f1effa; --accent-line: #b9b1e8; }
.acc-green  { --accent: #008300; --accent-ink: #006300; --accent-wash: #edf6ec; --accent-line: #9fd19f; }
.acc-orange { --accent: #eb6834; --accent-ink: #b0441a; --accent-wash: #fdf1eb; --accent-line: #f5b89c; }

/* Tinted grounds carried over from the portfolio's theme picker. */
:root[data-theme="yellow"] { --bg: #faf8f4; --surface: #f2eee6; --surface-2: #e9e3d7; --topbar-bg: rgba(250, 248, 244, 0.9); }
:root[data-theme="blue"]   { --bg: #f3f5f8; --surface: #e9edf3; --surface-2: #dfe5ee; --topbar-bg: rgba(243, 245, 248, 0.9); }

/* ---------- Tokens: dark (OS setting, unless the visitor picked a theme) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --surface-2: #242422;
    --ink: #efeee9; --ink-2: #c4c3ba; --muted: #8f8e87;
    --rule: #2d2d2a; --rule-strong: #d9d8d0; --grid: #2b2b29; --axis: #4a4a45;
    --deemph: #5a5954; --deemph-2: #353532;
    --tip-bg: #efeee9; --tip-ink: #121211; --tip-muted: #55544f;
    --topbar-bg: rgba(17, 17, 16, 0.88);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --pos: #3987e5; --neg: #e66767;
    --hm-0: #0d366b; --hm-1: #184f95; --hm-2: #1c5cab; --hm-3: #256abf;
    --hm-4: #3987e5; --hm-5: #6da7ec; --hm-6: #9ec5f4; --hm-7: #cde2fb;
    --hm-t-lo: #efeee9; --hm-t-hi: #121211;
  }
  :root:not([data-theme]) .acc-blue   { --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: #15243a; --accent-line: #256abf; }
  :root:not([data-theme]) .acc-violet { --accent: #9085e9; --accent-ink: #b3abf2; --accent-wash: #221f38; --accent-line: #5a4fb8; }
  :root:not([data-theme]) .acc-green  { --accent: #008300; --accent-ink: #5cbf5c; --accent-wash: #13241a; --accent-line: #2e6b2e; }
  :root:not([data-theme]) .acc-orange { --accent: #d95926; --accent-ink: #f0906a; --accent-wash: #2d1c13; --accent-line: #8a3a18; }
}

/* ---------- Tokens: dark (explicit choice, synced with the portfolio) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #242422;
  --ink: #efeee9; --ink-2: #c4c3ba; --muted: #8f8e87;
  --rule: #2d2d2a; --rule-strong: #d9d8d0; --grid: #2b2b29; --axis: #4a4a45;
  --deemph: #5a5954; --deemph-2: #353532;
  --tip-bg: #efeee9; --tip-ink: #121211; --tip-muted: #55544f;
  --topbar-bg: rgba(17, 17, 16, 0.88);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --pos: #3987e5; --neg: #e66767;
  --hm-0: #0d366b; --hm-1: #184f95; --hm-2: #1c5cab; --hm-3: #256abf;
  --hm-4: #3987e5; --hm-5: #6da7ec; --hm-6: #9ec5f4; --hm-7: #cde2fb;
  --hm-t-lo: #efeee9; --hm-t-hi: #121211;
}
:root[data-theme="dark"] .acc-blue   { --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: #15243a; --accent-line: #256abf; }
:root[data-theme="dark"] .acc-violet { --accent: #9085e9; --accent-ink: #b3abf2; --accent-wash: #221f38; --accent-line: #5a4fb8; }
:root[data-theme="dark"] .acc-green  { --accent: #008300; --accent-ink: #5cbf5c; --accent-wash: #13241a; --accent-line: #2e6b2e; }
:root[data-theme="dark"] .acc-orange { --accent: #d95926; --accent-ink: #f0906a; --accent-wash: #2d1c13; --accent-line: #8a3a18; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 18px/1.62 var(--font-serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--accent-line); color: var(--ink); }
b, strong { font-weight: 600; }
code, kbd { font-family: var(--font-mono); font-size: 0.86em; }
sub, sup { line-height: 0; }
math { font-family: var(--font-math); }

.wrap { max-width: 1280px; margin: 0 auto; padding-inline: clamp(16px, 4vw, 40px); }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--ink); color: var(--bg); padding: 8px 12px; font: 500 14px var(--font-sans); }
.skip:focus { left: 16px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30;
  background: var(--topbar-bg);
  -webkit-backdrop-filter: saturate(1.2) blur(10px); backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-sans);
}
.topbar-in { display: flex; align-items: center; gap: 20px; min-height: 52px; }
.home { font: 600 15px/1.2 var(--font-sans); color: var(--ink); text-decoration: none; white-space: nowrap; }
.home:hover { color: var(--accent-ink); }
.home .back { color: var(--muted); font-weight: 400; margin-right: 6px; }
.papers { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.papers::-webkit-scrollbar { display: none; }
.papers a {
  font: 500 13.5px/1 var(--font-sans); color: var(--ink-2); text-decoration: none;
  padding: 9px 10px; border-radius: 3px; white-space: nowrap;
}
.papers a:hover { color: var(--ink); background: var(--surface); }
.papers a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); border-radius: 0; }
.theme {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border: 1px solid var(--rule); border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer;
}
.theme:hover { color: var(--ink); border-color: var(--axis); }
.theme svg { width: 16px; height: 16px; }
@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; row-gap: 0; padding-block: 6px 0; }
  .home { order: 1; }
  .theme { order: 2; margin-left: auto; width: 32px; height: 32px; }
  .papers { order: 3; flex-basis: 100%; margin-left: -10px; }
}

/* ---------- Header ---------- */
.hero { padding-block: clamp(36px, 6vw, 64px) 8px; }
.eyebrow {
  font: 500 12px/1.5 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0;
}
.eyebrow .name { color: var(--accent-ink); font-weight: 600; }
h1.title {
  font: 600 clamp(29px, 4.2vw, 48px)/1.1 var(--font-sans);
  letter-spacing: -0.021em; text-wrap: balance; max-width: 30ch; margin: 14px 0 0;
}
.subtitle { font: 400 clamp(18px, 2vw, 22px)/1.4 var(--font-sans); color: var(--ink-2); margin: 10px 0 0; max-width: 40ch; text-wrap: balance; }
.byline { margin-top: 22px; font-family: var(--font-sans); }
.authors { font-size: 16.5px; line-height: 1.55; margin: 0; }
.authors .me { font-weight: 600; }
.authors sup { font-size: 0.7em; color: var(--muted); margin-left: 1px; }
.affil { font-size: 14.5px; line-height: 1.5; color: var(--ink-2); margin: 4px 0 0; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 14px/1 var(--font-sans); color: var(--ink); text-decoration: none;
  padding: 10px 14px 10px 12px; border: 1px solid var(--axis); border-radius: 3px; background: var(--bg);
  cursor: pointer;
}
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn .meta { font: 400 12px/1 var(--font-mono); color: var(--muted); }
.btn.primary .meta { color: var(--deemph); }

.thesis {
  font: 400 clamp(20px, 2.15vw, 24px)/1.48 var(--font-serif);
  max-width: 36em; margin: 36px 0 0; text-wrap: pretty;
}
.thesis strong { font-weight: 600; }

/* Key numbers: a spec-sheet row, not cards. */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1.5px solid var(--rule-strong); border-bottom: 1px solid var(--rule);
  margin: 34px 0 0; font-family: var(--font-sans);
}
.stat { padding: 16px 18px 18px 0; min-width: 0; }
.stat + .stat { padding-left: 18px; border-left: 1px solid var(--rule); }
.stat .v { font-weight: 600; font-size: clamp(26px, 3vw, 34px); line-height: 1.05; letter-spacing: -0.02em; }
.stat .v small { font-size: 0.5em; font-weight: 500; letter-spacing: 0; color: var(--ink-2); margin-left: 3px; }
.stat .l { font-size: 13.5px; line-height: 1.4; color: var(--ink-2); margin-top: 8px; }
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(odd) { padding-left: 0; border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--rule); }
}

/* ---------- Page grid: contents rail + main column ---------- */
.page { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 0 56px; padding-block: 24px 64px; }
.toc { position: sticky; top: 76px; align-self: start; font-family: var(--font-sans); padding-top: 44px; }
.toc p { font: 500 11px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--rule); }
.toc a {
  display: block; font-size: 13.5px; line-height: 1.35; color: var(--ink-2); text-decoration: none;
  padding: 6px 0 6px 14px; margin-left: -1px; border-left: 2px solid transparent;
}
.toc a:hover { color: var(--ink); }
.toc a.active { color: var(--ink); border-left-color: var(--accent); font-weight: 500; }
main { min-width: 0; }
@media (max-width: 1080px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

/* ---------- Sections & prose ---------- */
section { padding-top: 44px; scroll-margin-top: 64px; }
section:first-child { padding-top: 36px; }
h2 {
  font: 600 clamp(23px, 2.4vw, 27px)/1.2 var(--font-sans); letter-spacing: -0.012em;
  margin: 0 0 16px; text-wrap: balance;
}
h2 .kicker {
  display: block; font: 500 11.5px/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-ink); margin-bottom: 10px;
}
h3 { font: 600 18px/1.35 var(--font-sans); margin: 30px 0 8px; letter-spacing: -0.005em; }
main p, main li { max-width: 680px; }
main p { margin: 0 0 16px; }
main ul, main ol.plain { padding-left: 1.2em; margin: 0 0 18px; }
main li { margin: 0 0 8px; }
main li::marker { color: var(--muted); }
.lead-in { font-family: var(--font-sans); font-weight: 600; font-size: 0.92em; }
.small { font-size: 15.5px; line-height: 1.55; color: var(--ink-2); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* Equations */
.eq { margin: 14px 0 20px; padding: 4px 0; overflow-x: auto; overflow-y: hidden; max-width: 680px; }
.eq math { font-size: 1.1em; }
.eq-note { font: 400 14px/1.5 var(--font-sans); color: var(--ink-2); margin: -10px 0 18px; max-width: 680px; }

/* Novelty comparison: prior practice vs this paper */
.contrast { width: 100%; max-width: 860px; border-collapse: collapse; font: 400 15px/1.5 var(--font-sans); margin: 8px 0 8px; }
.contrast th, .contrast td { text-align: left; vertical-align: top; padding: 12px 16px 12px 0; border-bottom: 1px solid var(--rule); }
.contrast thead th { font: 500 11.5px/1.3 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); border-bottom: 1.5px solid var(--rule-strong); padding-top: 0; }
.contrast tbody th { font-weight: 600; width: 22%; color: var(--ink); }
.contrast td.new { color: var(--ink); }
.contrast thead th.new { color: var(--accent-ink); }
.contrast td.old { color: var(--ink-2); }
@media (max-width: 640px) {
  .contrast, .contrast tbody, .contrast tr, .contrast th, .contrast td { display: block; width: 100%; }
  .contrast thead { display: none; }
  .contrast tbody tr { border-bottom: 1px solid var(--rule); padding: 10px 0; }
  .contrast tbody th, .contrast td { border: 0; padding: 2px 0; }
  .contrast tbody th { width: 100%; padding-bottom: 4px; }
  .contrast td.old::before { content: "Before: "; color: var(--muted); }
  .contrast td.new::before { content: "Here: "; color: var(--accent-ink); font-weight: 600; }
}

/* Notes: hairline top and bottom, labelled. */
.note {
  border-top: 1.5px solid var(--rule-strong); border-bottom: 1px solid var(--rule);
  padding: 14px 0 12px; margin: 24px 0; max-width: 760px;
  font: 400 15.5px/1.55 var(--font-sans); color: var(--ink-2);
}
.note .label { display: block; font: 500 11.5px/1.2 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); margin-bottom: 8px; }
.note p { margin: 0 0 10px; max-width: none; }
.note p:last-child { margin-bottom: 0; }
.note strong { color: var(--ink); }

/* ---------- Figures ---------- */
figure { margin: 30px 0 36px; }
.fig-title { font: 600 16.5px/1.35 var(--font-sans); margin: 0 0 12px; max-width: 760px; text-wrap: balance; }
.panel { background: var(--surface); border-radius: 4px; padding: clamp(12px, 2.2vw, 22px); }
.panel.scroll { overflow-x: auto; }
.panel.scroll > svg { min-width: 760px; }
figcaption { font: 400 14px/1.55 var(--font-sans); color: var(--ink-2); margin-top: 12px; max-width: 800px; }
figcaption b { color: var(--ink); font-weight: 600; }
.fig-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 760px) { .fig-pair { grid-template-columns: minmax(0, 1fr); } }
.fig-pair .sub { font: 600 14px/1.35 var(--font-sans); margin: 0 0 8px; }

/* Diagrams (hand-drawn inline SVG, themed through tokens) */
svg.dg { display: block; width: 100%; height: auto; font-family: var(--font-sans); }
.dg text { fill: var(--ink); font-size: 13.5px; }
.dg .t-b { font-weight: 600; }
.dg .t-2 { fill: var(--ink-2); font-size: 12.5px; }
.dg .t-m { fill: var(--muted); font-family: var(--font-mono); font-size: 11.5px; }
.dg .t-mi { fill: var(--ink-2); font-family: var(--font-mono); font-size: 12px; }
.dg .t-acc { fill: var(--accent-ink); }
.dg .t-lab { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; fill: var(--muted); }
.dg .t-lab-acc { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; fill: var(--accent-ink); font-weight: 500; }
.dg .box { fill: var(--bg); stroke: var(--axis); stroke-width: 1.2; }
.dg .box-new { fill: var(--bg); stroke: var(--accent); stroke-width: 1.6; }
.dg .band { fill: var(--surface-2); }
.dg .band-new { fill: var(--accent-wash); stroke: var(--accent-line); stroke-width: 1; }
.dg .ln { stroke: var(--ink-2); stroke-width: 1.4; fill: none; }
.dg .ln-new { stroke: var(--accent); stroke-width: 1.8; fill: none; }
.dg .ln-soft { stroke: var(--axis); stroke-width: 1; fill: none; }
.dg .ln-dash { stroke: var(--muted); stroke-width: 1.3; fill: none; stroke-dasharray: 5 4; }
.dg .ah { fill: var(--ink-2); }
.dg .ah-new { fill: var(--accent); }
.dg .ah-dash { fill: var(--muted); }
.dg .f-acc { fill: var(--accent); }
.dg .f-wash { fill: var(--accent-wash); }
.dg .f-ink { fill: var(--ink); }
.dg .f-ink2 { fill: var(--ink-2); }
.dg .f-mute { fill: var(--deemph); }
.dg .f-mute2 { fill: var(--deemph-2); }
.dg .f-grid { fill: var(--grid); }
.dg .f-bg { fill: var(--bg); }
.dg .f-s1 { fill: var(--s1); } .dg .f-s2 { fill: var(--s2); } .dg .f-s3 { fill: var(--s3); }
.dg .f-neg { fill: var(--neg); } .dg .f-pos { fill: var(--pos); }
.dg .st-acc { stroke: var(--accent); } .dg .st-mute { stroke: var(--deemph); } .dg .st-grid { stroke: var(--grid); }
.dg .st-s1 { stroke: var(--s1); } .dg .st-s2 { stroke: var(--s2); } .dg .st-neg { stroke: var(--neg); }

/* ---------- Charts (drawn by paper.js) ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font-sans); }
.chart .legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font: 400 13px/1.3 var(--font-sans); color: var(--ink-2); margin: 0 0 10px; }
.chart .legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart .legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; flex: none; }
.chart .legend i.line { height: 2px; width: 16px; border-radius: 1px; }
.chart .legend i.dot { border-radius: 50%; width: 10px; height: 10px; }
.chart .legend i.ring { border-radius: 50%; width: 10px; height: 10px; background: transparent !important; border: 2px solid; }
.chart .legend i.ref { height: 0; width: 18px; border-top: 1.5px dashed var(--ink-2); border-radius: 0; }
.c-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.c-axis { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.c-zero { stroke: var(--ink-2); stroke-width: 1; shape-rendering: crispEdges; }
.c-tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.c-lab { fill: var(--ink-2); font-size: 13px; }
.c-lab-b { fill: var(--ink); font-size: 13px; font-weight: 600; }
.c-val { fill: var(--ink); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.c-val-b { fill: var(--ink); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.c-note { fill: var(--muted); font-size: 11.5px; }
.c-lab, .c-lab-b, .c-val, .c-val-b, .c-ref-t, .c-note { paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.c-title { fill: var(--ink-2); font-size: 12px; }
.c-ref { stroke: var(--ink-2); stroke-width: 1.4; stroke-dasharray: 5 4; fill: none; }
.c-ref-t { fill: var(--ink-2); font-size: 12px; }
.c-err { stroke: var(--ink-2); stroke-width: 1.3; }
.c-conn { stroke: var(--axis); stroke-width: 2; }
.c-cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.mark { cursor: default; transition: opacity 0.12s ease, filter 0.12s ease; }
.mark:hover { filter: brightness(1.07) saturate(1.05); }
.mark:focus { outline: none; }
.mark:focus-visible { stroke: var(--ink); stroke-width: 2px; }
.hit { fill: transparent; }
.hm-cell { stroke: var(--surface); stroke-width: 2px; }
.hm-0 { fill: var(--hm-0); } .hm-1 { fill: var(--hm-1); } .hm-2 { fill: var(--hm-2); } .hm-3 { fill: var(--hm-3); }
.hm-4 { fill: var(--hm-4); } .hm-5 { fill: var(--hm-5); } .hm-6 { fill: var(--hm-6); } .hm-7 { fill: var(--hm-7); }
.hm-t { font-size: 12.5px; font-variant-numeric: tabular-nums; pointer-events: none; }
.hm-t.lo { fill: var(--hm-t-lo); } .hm-t.hi { fill: var(--hm-t-hi); } .hm-t.mid { fill: #121211; }
.scale { display: flex; align-items: center; gap: 8px; font: 400 12px/1 var(--font-sans); color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.scale .bins { display: flex; gap: 2px; }
.scale .bins i { width: 22px; height: 10px; display: block; }

.tip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 280px;
  background: var(--tip-bg); color: var(--tip-ink); border-radius: 4px; padding: 8px 10px;
  font: 400 12.5px/1.4 var(--font-sans); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.tip .t-head { color: var(--tip-muted); font-size: 12px; margin-bottom: 3px; }
.tip .t-row { display: flex; align-items: center; gap: 8px; }
.tip .t-row i { width: 12px; height: 2px; border-radius: 1px; flex: none; }
.tip .t-v { font-weight: 600; font-variant-numeric: tabular-nums; }
.tip .t-k { color: var(--tip-muted); }

.chart-data { margin-top: 12px; font-family: var(--font-sans); }
.chart-data summary { font: 500 12.5px/1.4 var(--font-sans); color: var(--ink-2); cursor: pointer; display: inline-block; padding: 2px 0; }
.chart-data summary:hover { color: var(--ink); }
.chart-data[open] summary { margin-bottom: 8px; }
.tbl-wrap { overflow-x: auto; }

/* ---------- Tables (booktabs) ---------- */
.table-fig { margin: 28px 0 36px; }
.table-fig > .caption, table.bt caption {
  caption-side: top; text-align: left; font: 400 14px/1.5 var(--font-sans); color: var(--ink-2);
  padding: 0 0 10px; max-width: 800px;
}
.table-fig > .caption b, table.bt caption b { color: var(--ink); font-weight: 600; }
table.bt { border-collapse: collapse; width: 100%; font: 400 14.5px/1.4 var(--font-sans); font-variant-numeric: tabular-nums; }
table.bt th, table.bt td { padding: 8px 12px; text-align: right; white-space: nowrap; }
table.bt th:first-child, table.bt td:first-child { text-align: left; padding-left: 0; white-space: normal; }
table.bt td.l, table.bt th.l { text-align: left; white-space: normal; }
table.bt thead th { font-weight: 600; color: var(--ink); border-top: 1.5px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); vertical-align: bottom; }
table.bt thead tr + tr th { border-top: 0; }
table.bt thead th .u { display: block; font: 400 11.5px/1.3 var(--font-mono); color: var(--muted); }
table.bt tbody tr:last-child td, table.bt tbody tr:last-child th { border-bottom: 1.5px solid var(--rule-strong); }
table.bt tr.mid td, table.bt tr.mid th { border-top: 1px solid var(--rule); }
table.bt tr.ours td, table.bt tr.ours th { background: var(--accent-wash); font-weight: 600; }
table.bt tr.ours td:first-child { box-shadow: inset 3px 0 0 var(--accent); padding-left: 10px; }
table.bt td.best { font-weight: 600; }
table.bt td .pm, table.bt td .sd { color: var(--muted); font-size: 0.86em; font-weight: 400; margin-left: 2px; }
table.bt td.neg { color: var(--ink); }
table.bt.small { font-size: 13.5px; }
table.bt.small th, table.bt.small td { padding: 6px 10px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.status svg { width: 13px; height: 13px; flex: none; }
.status.pass { color: var(--ink); } .status.pass svg { color: #0ca30c; }
.status.fail { color: var(--ink); } .status.fail svg { color: #d03b3b; }
.status.fix { color: var(--ink); } .status.fix svg { color: #c98500; }

/* ---------- Media ---------- */
.shots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.shots figure { margin: 0; }
.shots img { display: block; width: 100%; height: auto; border-radius: 3px; background: var(--surface-2); aspect-ratio: 16 / 9; object-fit: cover; }
.shots .tag { font: 500 11.5px/1 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-ink); margin: 10px 0 4px; display: block; }
.shots p { font: 400 13.5px/1.5 var(--font-sans); color: var(--ink-2); margin: 0; }
@media (max-width: 760px) { .shots { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Citation ---------- */
.cite { position: relative; max-width: 800px; }
.cite pre {
  margin: 0; padding: 16px 18px; background: var(--surface); border-radius: 4px; overflow-x: auto;
  font: 400 13px/1.6 var(--font-mono); color: var(--ink);
}
.copy {
  position: absolute; top: 10px; right: 10px; font: 500 12.5px/1 var(--font-sans);
  padding: 7px 10px; border-radius: 3px; border: 1px solid var(--axis); background: var(--bg); color: var(--ink); cursor: pointer;
}
.copy:hover { border-color: var(--ink); }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--rule); padding-block: 28px 40px; font: 400 14px/1.6 var(--font-sans); color: var(--ink-2); }
.foot-in { display: flex; flex-wrap: wrap; gap: 12px 32px; justify-content: space-between; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot a { color: var(--ink-2); }
.foot a:hover { color: var(--ink); }

/* ---------- Print: a clean handout ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --ink-2: #222; --muted: #555; }
  .topbar, .toc, .links, .theme, .copy, .chart-data, .skip, .foot nav { display: none !important; }
  .page { grid-template-columns: 1fr; padding: 0; }
  body { font-size: 11pt; }
  .panel { border: 1px solid #ccc; }
  figure, .table-fig { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
