/* ==========================================================================
   RTA Guide — shared styles
   Colour tokens live on :root; dark values are redefined for the OS setting
   and for an explicit data-theme="dark" toggle.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f1f1ed;
  --surface-3: #e7e7e1;
  --border: #e0dfd8;
  --border-strong: #c7c6be;
  --text: #15161a;
  --text-2: #43454b;
  --muted: #676970;
  --accent: #1c5cab;
  --accent-hover: #184f95;
  --accent-soft: #e8f0fa;
  --accent-ink: #ffffff;
  --focus: #2a78d6;

  --info-bg: #e8f0fa;
  --info-border: #86b6ef;
  --info-ink: #184f95;
  --tip-bg: #e9f5ee;
  --tip-border: #62b98f;
  --tip-ink: #0f5535;
  --warn-bg: #fdf4df;
  --warn-border: #e2ad3f;
  --warn-ink: #6a4800;
  --bad-ink: #b3261e;
  --good-ink: #0f6b2f;

  --series-1: #2a78d6;
  --bar-neutral: #bdbcb4;
  --grid: #e9e8e2;

  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 14px rgba(20, 20, 20, .05);
  --radius: 12px;
  --radius-sm: 8px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --header-h: 60px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111214;
    --surface: #18191c;
    --surface-2: #202125;
    --surface-3: #2a2b30;
    --border: #2d2f34;
    --border-strong: #41444a;
    --text: #f1f1ee;
    --text-2: #cbcac2;
    --muted: #9d9d96;
    --accent: #6da7ec;
    --accent-hover: #9ec5f4;
    --accent-soft: #172940;
    --accent-ink: #0b1a2c;
    --focus: #86b6ef;
    --info-bg: #15253a;
    --info-border: #2f5f99;
    --info-ink: #b7d3f6;
    --tip-bg: #12261c;
    --tip-border: #2e7a55;
    --tip-ink: #a9e4c6;
    --warn-bg: #2a2312;
    --warn-border: #8c6b1f;
    --warn-ink: #f2d593;
    --bad-ink: #ff8a80;
    --good-ink: #7fd89b;
    --series-1: #3987e5;
    --bar-neutral: #55575d;
    --grid: #2a2c31;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214;
  --surface: #18191c;
  --surface-2: #202125;
  --surface-3: #2a2b30;
  --border: #2d2f34;
  --border-strong: #41444a;
  --text: #f1f1ee;
  --text-2: #cbcac2;
  --muted: #9d9d96;
  --accent: #6da7ec;
  --accent-hover: #9ec5f4;
  --accent-soft: #172940;
  --accent-ink: #0b1a2c;
  --focus: #86b6ef;
  --info-bg: #15253a;
  --info-border: #2f5f99;
  --info-ink: #b7d3f6;
  --tip-bg: #12261c;
  --tip-border: #2e7a55;
  --tip-ink: #a9e4c6;
  --warn-bg: #2a2312;
  --warn-border: #8c6b1f;
  --warn-ink: #f2d593;
  --bad-ink: #ff8a80;
  --good-ink: #7fd89b;
  --series-1: #3987e5;
  --bar-neutral: #55575d;
  --grid: #2a2c31;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
}

/* --- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--font);
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 4.4vw, 2.9rem); letter-spacing: -.025em; }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.85rem); letter-spacing: -.02em; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.3em; }
li { margin: .25em 0; }
code, kbd { font-family: var(--mono); font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.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: 16px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px;
}
.skip:focus { top: 10px; }

/* --- Header -------------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .inner {
  max-width: 1200px; height: 100%; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; }
.brand:hover { color: var(--text); }
.brand svg { flex: none; }
.brand small { font-weight: 500; color: var(--muted); }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.site-nav a {
  color: var(--text-2); text-decoration: none; padding: 7px 12px; border-radius: 8px; font-size: .95rem; font-weight: 550;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 10px; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
[data-theme-icon="sun"] { display: none; }
:root[data-theme="dark"] [data-theme-icon="sun"] { display: block; }
:root[data-theme="dark"] [data-theme-icon="moon"] { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-theme-icon="sun"] { display: block; }
  :root:not([data-theme="light"]) [data-theme-icon="moon"] { display: none; }
}
@media (max-width: 520px) {
  .brand small { display: none; }
  .site-nav a { padding: 7px 9px; }
}

/* --- Layout -------------------------------------------------------------- */
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.layout {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 48px;
}
@media (min-width: 1040px) {
  .layout { grid-template-columns: 232px minmax(0, 1fr); }
}
main { min-width: 0; }
.content { max-width: 780px; }

/* --- Table of contents --------------------------------------------------- */
.toc { display: none; }
@media (min-width: 1040px) {
  .toc {
    display: block; position: sticky; top: calc(var(--header-h) + 24px);
    align-self: start; max-height: calc(100vh - var(--header-h) - 48px); overflow: auto;
    padding: 8px 0 24px;
  }
}
.toc h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 10px 12px; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { margin: 0; counter-increment: toc; }
.toc a {
  display: flex; gap: 10px; padding: 6px 12px; border-radius: 8px; line-height: 1.35;
  color: var(--text-2); text-decoration: none; font-size: .9rem;
  border-left: 2px solid transparent;
}
.toc a::before { content: counter(toc); color: var(--muted); font-variant-numeric: tabular-nums; min-width: 1.2em; font-size: .85em; padding-top: .1em; }
.toc a:hover { background: var(--surface-2); color: var(--text); }
.toc a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

.toc-mobile { margin: 24px 0 0; }
@media (min-width: 1040px) { .toc-mobile { display: none; } }
.toc-mobile summary { cursor: pointer; font-weight: 600; }
.toc-mobile ol { margin: 10px 0 0; }

/* --- Hero ---------------------------------------------------------------- */
.hero { padding: 56px 0 24px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .8rem; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px;
}
.hero .lede { font-size: 1.18rem; color: var(--text-2); max-width: 64ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 18px; }
.source-line { font-size: .88rem; color: var(--muted); max-width: 70ch; }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 10px 16px; border-radius: 10px; font: inherit; font-weight: 600; font-size: .95rem;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  text-decoration: none; cursor: pointer; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.small { padding: 6px 11px; font-size: .85rem; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--bad-ink); }
.btn svg { width: 16px; height: 16px; }

/* --- Sections ------------------------------------------------------------ */
.section { padding: 40px 0 16px; border-top: 1px solid var(--border); }
.section:first-of-type { border-top: 0; }
.section > .kicker { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.section-intro { font-size: 1.05rem; color: var(--text-2); }
.src {
  display: inline-block; font-size: .72rem; font-weight: 600; letter-spacing: .01em;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  padding: 0 6px; border-radius: 6px; margin-left: 4px; vertical-align: .12em; white-space: nowrap;
}

/* --- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card h3 { margin-bottom: .35em; }
.card p:last-child, .card ul:last-child { margin-bottom: 0; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stat { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.card .label { font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }

/* --- Formula ------------------------------------------------------------- */
.formula {
  margin: 20px 0; padding: 20px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.formula .eq {
  font-family: var(--mono); font-size: clamp(.86rem, 1.9vw, 1.02rem); line-height: 1.9;
  overflow-x: auto; white-space: nowrap; padding-bottom: 4px;
}
.formula .eq b { color: var(--accent); font-weight: 700; }
.formula ul { margin: 12px 0 0; font-size: .92rem; color: var(--text-2); }

/* --- Callouts ------------------------------------------------------------ */
.callout {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 12px;
  padding: 14px 16px; border-radius: var(--radius-sm); margin: 18px 0;
  background: var(--info-bg); border: 1px solid var(--info-border); color: var(--text);
}
.callout svg { width: 20px; height: 20px; color: var(--info-ink); margin-top: 2px; }
.callout strong.tag { display: block; color: var(--info-ink); font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout.tip { background: var(--tip-bg); border-color: var(--tip-border); }
.callout.tip svg, .callout.tip strong.tag { color: var(--tip-ink); }
.callout.warn { background: var(--warn-bg); border-color: var(--warn-border); }
.callout.warn svg, .callout.warn strong.tag { color: var(--warn-ink); }

/* --- Steps --------------------------------------------------------------- */
.steps { list-style: none; padding: 0; margin: 20px 0; counter-reset: step; }
.steps > li {
  position: relative; counter-increment: step; margin: 0; padding: 0 0 22px 56px;
}
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; border: 1px solid var(--info-border);
}
.steps > li::after {
  content: ""; position: absolute; left: 18px; top: 42px; bottom: 4px; width: 2px; background: var(--border);
}
.steps > li:last-child::after { display: none; }
.steps > li:last-child { padding-bottom: 4px; }
.steps h3 { font-size: 1.08rem; margin: 6px 0 4px; }
.steps p { margin: 0 0 .4em; color: var(--text-2); }
.steps.letters > li::before { content: counter(step, upper-alpha); }

/* --- Funnel -------------------------------------------------------------- */
.funnel { list-style: none; margin: 24px 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.funnel li {
  margin: 0 auto; width: var(--w, 100%); max-width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  font-size: .95rem;
}
.funnel li b { font-weight: 650; }
.funnel li span { color: var(--muted); font-size: .82rem; text-align: right; }
.funnel li.method { background: var(--accent-soft); border-color: var(--info-border); }
.funnel li.method span { color: var(--info-ink); }
@media (max-width: 560px) {
  .funnel li { width: 100% !important; flex-direction: column; align-items: flex-start; gap: 0; }
  .funnel li span { text-align: left; }
}

/* --- Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
thead th { background: var(--surface-2); font-weight: 650; font-size: .82rem; color: var(--text-2); white-space: nowrap; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody th { font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.c, th.c { text-align: center; }
tfoot td, tfoot th { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--border-strong); border-bottom: 0; }
.cell-yes { color: var(--good-ink); font-weight: 600; }
.cell-no { color: var(--muted); }
.caption { font-size: .85rem; color: var(--muted); margin-top: -8px; }

/* --- Chips --------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: .78rem; font-weight: 650; border: 1px solid var(--border-strong); color: var(--text-2); background: var(--surface);
  white-space: nowrap;
}
.chip.imp-H { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip.imp-M { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.chip.imp-L { background: var(--surface); color: var(--text-2); }
.chip.imp-NA { background: transparent; color: var(--muted); border-style: dashed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Key element reference (accordion) ----------------------------------- */
.ke-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 22px 0; }
details.ke {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
details.ke > summary {
  list-style: none; cursor: pointer; padding: 16px 18px; display: grid;
  grid-template-columns: 46px minmax(0, 1fr) 20px; gap: 12px; align-items: center;
}
details.ke > summary::-webkit-details-marker { display: none; }
details.ke > summary .num {
  width: 46px; height: 46px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 750; font-size: .95rem;
}
details.ke > summary h3 { margin: 0; font-size: 1.05rem; }
details.ke > summary p { margin: 2px 0 0; font-size: .88rem; color: var(--muted); }
details.ke > summary .chev { transition: transform .15s ease; color: var(--muted); }
details.ke[open] > summary .chev { transform: rotate(180deg); }
details.ke .ke-body { padding: 0 18px 18px; border-top: 1px solid var(--border); }
.ke-body h4 { margin: 18px 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.imp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
.imp-grid div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; font-size: .82rem; color: var(--text-2); display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.kt-table td:first-child { font-family: var(--mono); font-size: .82rem; color: var(--muted); white-space: nowrap; width: 3.5em; }
.kt-table td:nth-child(2) { font-weight: 600; min-width: 11em; }
.ask-list li { margin: .3em 0; }

/* --- Checklist ----------------------------------------------------------- */
.checklist { list-style: none; padding: 0; margin: 12px 0 22px; }
.checklist li { margin: 0; }
.checklist label {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
}
.checklist label:hover { background: var(--surface-2); }
.checklist input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--border-strong); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .2s ease; }

/* --- Glossary ------------------------------------------------------------ */
dl.glossary { display: grid; grid-template-columns: minmax(90px, max-content) minmax(0, 1fr); gap: 8px 18px; margin: 18px 0; }
dl.glossary dt { font-weight: 700; font-family: var(--mono); font-size: .88rem; padding-top: .15em; }
dl.glossary dd { margin: 0; color: var(--text-2); }
@media (max-width: 520px) { dl.glossary { grid-template-columns: 1fr; gap: 2px; } dl.glossary dd { margin-bottom: 10px; } }

/* --- Footer -------------------------------------------------------------- */
.site-footer { margin-top: 64px; border-top: 1px solid var(--border); background: var(--surface); }
.site-footer .inner { max-width: 1200px; margin: 0 auto; padding: 28px 16px 40px; font-size: .88rem; color: var(--muted); }
.site-footer p { margin: 0 0 .6em; max-width: 90ch; }

/* ==========================================================================
   Workbench
   ========================================================================== */
.wb-hero { padding: 40px 0 8px; }
.wb-hero .lede { font-size: 1.08rem; color: var(--text-2); max-width: 70ch; }
.wb-section { margin: 26px 0; }
.wb-section > header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.wb-section > header h2 { margin: 0; font-size: 1.35rem; }
.wb-section > header p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .82rem; font-weight: 650; color: var(--text-2); }
input[type="text"], input[type="number"], select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
textarea { width: 100%; resize: vertical; min-height: 64px; font-size: .9rem; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.setup-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.design-list { display: grid; gap: 8px; }
.design-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 36px; gap: 8px; align-items: center; }
.design-row .badge {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-3); font-weight: 700; font-size: .85rem; color: var(--text-2);
}
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.sum-ok { color: var(--good-ink); font-weight: 650; }
.sum-off { color: var(--warn-ink); font-weight: 650; }
.pill-status { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; }
.pill-status svg { width: 14px; height: 14px; }

.ke-weight-table input[type="number"] { width: 84px; text-align: right; }
.ke-weight-table td { vertical-align: middle; }
.ke-weight-table .bar-cell { width: 34%; min-width: 120px; }
.mini-bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.mini-bar > div { height: 100%; background: var(--series-1); border-radius: 99px; }

details.score-ke { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 10px; }
details.score-ke > summary {
  list-style: none; cursor: pointer; padding: 14px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
}
details.score-ke > summary::-webkit-details-marker { display: none; }
details.score-ke > summary h3 { margin: 0; font-size: 1rem; flex: 1 1 220px; }
details.score-ke > summary h3 .k { color: var(--accent); margin-right: 6px; font-family: var(--mono); font-size: .9rem; }
.ke-scores { display: flex; flex-wrap: wrap; gap: 6px; }
.ke-score-pill { font-size: .78rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-variant-numeric: tabular-nums; border: 1px solid var(--border); }
.ke-score-pill b { color: var(--text); }
.score-body { border-top: 1px solid var(--border); padding: 4px 0 12px; }
.score-scroll { overflow-x: auto; }
.kt-grid { min-width: calc(380px + var(--n, 3) * 70px); }
.kt-row {
  display: grid; align-items: center; gap: 8px; padding: 8px 16px;
  grid-template-columns: minmax(220px, 1fr) 78px repeat(var(--n, 3), 62px) 34px;
  border-bottom: 1px solid var(--border);
}
.kt-row.head { font-size: .75rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); padding-top: 10px; padding-bottom: 6px; }
.kt-row.head .dname { text-transform: none; letter-spacing: 0; font-size: .78rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.kt-row .ktname { font-size: .92rem; line-height: 1.35; }
.kt-row .ktname .id { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-right: 6px; }
.kt-row .ktname .hint { display: block; font-size: .8rem; color: var(--muted); }
.kt-row input[type="number"] { width: 78px; text-align: right; padding: 6px 8px; }
.kt-row select { width: 62px; padding: 6px 4px; text-align: center; }
.kt-row select.s1 { border-color: var(--bad-ink); }
.kt-row.zero .ktname { opacity: .55; }
.kt-row .note-btn { width: 34px; height: 34px; }
.kt-row .note-btn.has { color: var(--accent); border-color: var(--info-border); background: var(--accent-soft); }
.kt-note { grid-column: 1 / -1; display: none; }
.kt-note.open { display: block; }
@media (max-width: 640px) {
  .kt-grid { min-width: calc(120px + var(--n, 3) * 46px); }
  .kt-row {
    grid-template-columns: 64px repeat(var(--n, 3), minmax(40px, 1fr)) 34px;
    gap: 6px 6px; padding: 10px 12px;
  }
  .kt-row .ktname { grid-column: 1 / -1; }
  .kt-row.head > span:first-child { display: none; }
  .kt-row input[type="number"], .kt-row select { width: 100%; }
}
details.score-ke > summary { position: relative; padding-right: 46px; }
details.score-ke > summary > svg { position: absolute; right: 16px; top: 17px; color: var(--muted); transition: transform .15s ease; }
details.score-ke[open] > summary > svg { transform: rotate(180deg); }
.kt-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px 0; font-size: .88rem; }
.rubric { font-size: .85rem; color: var(--text-2); }

/* Results */
.results-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 980px) { .results-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.results-grid .span-2 { grid-column: 1 / -1; }
.panel h3 { font-size: 1.02rem; margin-bottom: 4px; }
.panel .sub { font-size: .86rem; color: var(--muted); margin-bottom: 14px; }
.headline { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: baseline; }
.headline .big { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }

.rank-chart { display: grid; gap: 10px; }
.rank-row { display: grid; grid-template-columns: minmax(80px, 150px) minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: .9rem; }
.rank-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.rank-row .nm small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; }
.rank-track { position: relative; height: 22px; }
.rank-track .gl { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid); }
.rank-track .bar { position: absolute; left: 0; top: 4px; height: 14px; border-radius: 0 4px 4px 0; background: var(--bar-neutral); }
.rank-track .bar.lead { background: var(--series-1); }
.rank-row .val { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; }
.rank-axis { display: grid; grid-template-columns: minmax(80px, 150px) minmax(0, 1fr) 44px; gap: 10px; font-size: .74rem; color: var(--muted); }
.rank-axis .ticks { position: relative; height: 16px; }
.rank-axis .ticks span { position: absolute; transform: translateX(-50%); }

.heat-wrap { overflow-x: auto; }
table.heat { border-collapse: separate; border-spacing: 3px; font-size: .82rem; width: auto; min-width: 100%; }
table.heat th, table.heat td { border: 0; padding: 0; }
table.heat thead th { background: none; text-align: center; font-size: .74rem; color: var(--muted); padding: 0 2px 4px; white-space: nowrap; }
table.heat tbody th { font-weight: 600; padding-right: 8px; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; font-size: .84rem; vertical-align: middle; }
table.heat td.cell {
  width: 42px; min-width: 38px; height: 36px; text-align: center; vertical-align: middle; border-radius: 6px;
  font-variant-numeric: tabular-nums; font-weight: 650; cursor: default;
}
table.heat td.cell.empty { background: repeating-linear-gradient(135deg, var(--surface-2) 0 4px, var(--surface-3) 4px 8px); color: var(--muted); font-weight: 500; }
table.heat td.cell.off { background: transparent; color: var(--muted); font-weight: 400; }
.heat-legend { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.heat-legend .ramp { width: 160px; height: 10px; border-radius: 99px; }

.flag-list { list-style: none; padding: 0; margin: 0; }
.flag-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .9rem; align-items: start; }
.flag-list li:last-child { border-bottom: 0; }
.flag-list svg { width: 16px; height: 16px; color: var(--warn-ink); margin-top: 3px; }
.flag-list .w { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .82rem; white-space: nowrap; }

table.sens td.changed { color: var(--bad-ink); font-weight: 700; }
table.sens td.same { color: var(--muted); }

.tooltip {
  position: fixed; z-index: 80; pointer-events: none; max-width: 280px;
  background: var(--text); color: var(--surface); padding: 8px 10px; border-radius: 8px;
  font-size: .8rem; line-height: 1.4; box-shadow: var(--shadow); opacity: 0; transition: opacity .08s;
}
.tooltip.show { opacity: 1; }

.totals-bar {
  position: sticky; bottom: 12px; z-index: 30; margin: 20px auto 0; width: fit-content; max-width: calc(100% - 8px);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 8px 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; box-shadow: var(--shadow);
  font-size: .85rem;
}
.totals-bar b { font-variant-numeric: tabular-nums; }
.totals-bar .lead b { color: var(--accent); }
.totals-bar a { font-weight: 650; }

/* --- Print --------------------------------------------------------------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --shadow: none; }
  .site-header, .toc, .toc-mobile, .hero-actions, .no-print, .totals-bar, .site-footer .no-print { display: none !important; }
  body { font-size: 11pt; }
  .section { break-inside: avoid-page; }
  details.ke, details.score-ke { break-inside: avoid; }
  a { color: inherit; }
}
