/* Ex Study Bench — industrial nameplate theme */
:root {
  color-scheme: light;
  --paper: #e6eae8;
  --surface: #f7f8f6;
  --surface-2: #dde2e0;
  --ink: #182024;
  --muted: #56636c;
  --line: #c1c9c7;
  --line-strong: #97a2a0;
  --hazard: #f2b705;
  --hazard-ink: #3a2c00;
  --ok: #2b8a3e;
  --ok-bg: #e3f4e6;
  --bad: #c92a2a;
  --bad-bg: #fbe5e5;
  --warn: #b35c00;
  --warn-bg: #fff1d6;
  --info-bg: #e3edf7;
  --focus: #1971c2;
  --plate-1: #d9ddda;
  --plate-2: #c9cfcc;
  --plate-line: rgba(255, 255, 255, .35);
  --rivet: #9aa3a1;
  --engrave-hi: rgba(255, 255, 255, .7);
  --shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 2px 0 rgba(24, 32, 36, .08), 0 8px 24px -12px rgba(24, 32, 36, .35);

  /* standard identity colours (validated categorical set) */
  --c-iec0: #d9480f;
  --c-iec11: #1971c2;
  --c-iso34: #2b8a3e;
  --c-atex: #7048e8;
  /* sequential ramp for mastery (one hue, light → dark) */
  --seq-0: #e3e8e6;
  --seq-1: #b5dccf;
  --seq-2: #74bfa8;
  --seq-3: #2f9a7e;
  --seq-4: #126b55;

  /* diagram palette */
  --d-a1: #d9480f;
  --d-a2: #b86e00;
  --d-a3: #0b7f8f;
  --d-a4: #1971c2;
  --d-a5: #7048e8;
  --d-a6: #4f6f5a;
  --d-on: #ffffff;

  --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif-condensed, system-ui, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;
  --r-s: 4px;
  --r-m: 8px;
  --r-l: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #111618;
    --surface: #192023;
    --surface-2: #222b2f;
    --ink: #e4eaec;
    --muted: #96a4ac;
    --line: #313d44;
    --line-strong: #4b5961;
    --hazard: #f2b705;
    --ok: #51b866;
    --ok-bg: #16301d;
    --bad: #ef6363;
    --bad-bg: #3a1a1a;
    --warn: #f0a33a;
    --warn-bg: #3a2a10;
    --info-bg: #182a3b;
    --focus: #74b6ff;
    --plate-1: #2a3337;
    --plate-2: #232b2f;
    --plate-line: rgba(255, 255, 255, .035);
    --rivet: #57636a;
    --engrave-hi: rgba(0, 0, 0, .55);
    --shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 10px 28px -14px rgba(0, 0, 0, .8);
    --c-iec0: #e0601f;
    --c-iec11: #3a8ee6;
    --c-iso34: #3fa356;
    --c-atex: #8c6cf0;
    --seq-0: #253034;
    --seq-1: #1d4a3f;
    --seq-2: #1f6d59;
    --seq-3: #2e9a7d;
    --seq-4: #5fd0ac;
    --d-a1: #d4561c;
    --d-a2: #b07400;
    --d-a3: #12808f;
    --d-a4: #2f7fd0;
    --d-a5: #7a5ae0;
    --d-a6: #557a62;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111618;
  --surface: #192023;
  --surface-2: #222b2f;
  --ink: #e4eaec;
  --muted: #96a4ac;
  --line: #313d44;
  --line-strong: #4b5961;
  --ok: #51b866;
  --ok-bg: #16301d;
  --bad: #ef6363;
  --bad-bg: #3a1a1a;
  --warn: #f0a33a;
  --warn-bg: #3a2a10;
  --info-bg: #182a3b;
  --focus: #74b6ff;
  --plate-1: #2a3337;
  --plate-2: #232b2f;
  --plate-line: rgba(255, 255, 255, .035);
  --rivet: #57636a;
  --engrave-hi: rgba(0, 0, 0, .55);
  --shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 10px 28px -14px rgba(0, 0, 0, .8);
  --c-iec0: #e0601f;
  --c-iec11: #3a8ee6;
  --c-iso34: #3fa356;
  --c-atex: #8c6cf0;
  --seq-0: #253034;
  --seq-1: #1d4a3f;
  --seq-2: #1f6d59;
  --seq-3: #2e9a7d;
  --seq-4: #5fd0ac;
  --d-a1: #d4561c;
  --d-a2: #b07400;
  --d-a3: #12808f;
  --d-a4: #2f7fd0;
  --d-a5: #7a5ae0;
  --d-a6: #557a62;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.55 var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; letter-spacing: .005em; }
h1 { font-size: clamp(2rem, 4.5vw, 2.9rem); }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.3rem; }
p { margin: 0 0 .9em; }
a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
code, .mono { font-family: var(--font-mono); font-size: .9em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
button { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.loading { padding: 4rem 0; color: var(--muted); text-align: center; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(16px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 700 1.35rem/1 var(--font-display); }
.brand svg { width: 28px; height: 28px; }
.brand-nut { fill: var(--ink); }
.brand-bore { fill: var(--hazard); }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a { text-decoration: none; padding: 6px 12px; border-radius: var(--r-m); font-weight: 500; }
.topnav a[aria-current="page"] { background: var(--surface-2); }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: var(--r-m); width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 28px 16px 48px; outline: none; }
main:focus, main:focus-visible { outline: none; }
.foot { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; padding: 16px max(16px, calc((100vw - 1180px) / 2)); }
.foot p { margin: 0; max-width: 80ch; }
.verify-chip {
  display: inline-block; font-size: .72rem; font-weight: 600; line-height: 1; padding: 3px 6px; border-radius: 3px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid currentColor; vertical-align: 1px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--r-m); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 42px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.accent { background: var(--c, var(--ink)); color: #fff; border-color: transparent; }
.btn.accent:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.small { min-height: 34px; padding: 5px 12px; font-size: .92rem; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* standard identity */
.std-iec60079-0 { --c: var(--c-iec0); }
.std-iec60079-11 { --c: var(--c-iec11); }
.std-iso80079-34 { --c: var(--c-iso34); }
.std-atex-2014-34 { --c: var(--c-atex); }

/* ---------- home ---------- */
.home-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; margin-bottom: 28px; }
.home-head h1 { margin-bottom: .2em; max-width: 24ch; }
.home-head p { color: var(--muted); max-width: 62ch; margin: 0; }
.bench-strip { display: flex; gap: 22px; font-size: .95rem; color: var(--muted); }
.bench-strip b { display: block; font: 600 1.9rem/1 var(--font-display); color: var(--ink); }

.plates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.plate {
  position: relative; display: flex; flex-direction: column; gap: 14px;
  padding: 26px 28px 22px 34px; border-radius: var(--r-l);
  color: var(--ink); text-decoration: none; cursor: pointer;
  background:
    radial-gradient(circle at 14px 14px, var(--rivet) 0 4px, transparent 5px),
    radial-gradient(circle at calc(100% - 14px) 14px, var(--rivet) 0 4px, transparent 5px),
    radial-gradient(circle at 14px calc(100% - 14px), var(--rivet) 0 4px, transparent 5px),
    radial-gradient(circle at calc(100% - 14px) calc(100% - 14px), var(--rivet) 0 4px, transparent 5px),
    repeating-linear-gradient(180deg, var(--plate-line) 0 1px, transparent 1px 3px),
    linear-gradient(160deg, var(--plate-1), var(--plate-2));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.plate::before { content: ''; position: absolute; left: 0; top: 18px; bottom: 18px; width: 7px; border-radius: 0 4px 4px 0; background: var(--c); }
.plate:hover { transform: translateY(-2px); }
.plate-top { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: start; }
.plate-num {
  font: 700 clamp(2.2rem, 4vw, 3rem)/.95 var(--font-display);
  letter-spacing: .01em; margin: 0;
  text-shadow: 0 1px 0 var(--engrave-hi);
}
.plate-title { font: 600 1.25rem/1.2 var(--font-display); margin: 6px 0 0; color: var(--ink); }
.plate-ed { font-size: .85rem; color: var(--muted); margin: 2px 0 0; }
.plate-sum { color: var(--muted); font-size: .95rem; margin: 0; max-width: 54ch; flex: 1; }
.plate-specs {
  display: grid; grid-template-columns: repeat(4, 1fr); margin: 0;
  border: 1px solid var(--line-strong); border-radius: var(--r-s); overflow: hidden;
}
.plate-specs div { padding: 6px 10px; border-right: 1px solid var(--line-strong); }
.plate-specs div:last-child { border-right: 0; }
.plate-specs dt { font-size: .74rem; color: var(--muted); }
.plate-specs dd { margin: 0; font: 600 1.15rem/1.2 var(--font-display); }
.plate .btn-row { margin-top: 2px; position: relative; z-index: 1; }
.plate .stretch { text-decoration: none; }
.plate .stretch::after { content: ''; position: absolute; inset: 0; border-radius: var(--r-l); }
.plate:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.plate .stretch:focus-visible { outline: none; }

.gauge { width: 96px; height: 70px; }
.gauge .g-track { stroke: var(--line-strong); }
.gauge .g-val { stroke: var(--c); }
.gauge .g-num { fill: var(--ink); font: 700 22px var(--font-display); }
.gauge .g-lbl { fill: var(--muted); font: 500 10px var(--font-body); }

/* ---------- standard page ---------- */
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.std-head { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 3px solid var(--c); }
.std-head h1 { margin: 0; }
.std-head p { margin: 4px 0 0; color: var(--muted); }
.std-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px 20px; }
.panel h2, .panel h3 { margin-top: 0; }
.mode-panel { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 14px; }
.mode-list { display: grid; gap: 8px; }
.mode-opt {
  display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; text-align: left;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--paper); cursor: pointer;
}
.mode-opt input { margin: 4px 0 0; accent-color: var(--c); }
.mode-opt b { display: block; font-weight: 600; }
.mode-opt small { color: var(--muted); font-size: .84rem; line-height: 1.35; display: block; }
.mode-opt:has(input:checked) { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.count-row { display: flex; gap: 6px; flex-wrap: wrap; }
.count-row label { flex: 1; }
.count-row input { position: absolute; opacity: 0; }
.count-row span { display: block; text-align: center; padding: 6px 0; border: 1px solid var(--line); border-radius: var(--r-s); cursor: pointer; font-weight: 600; }
.count-row input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.count-row input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.field-label { font-size: .88rem; color: var(--muted); margin: 0 0 6px; }

.topic-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.topic-row { display: grid; grid-template-columns: 92px minmax(0, 1fr) 150px auto; gap: 14px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.topic-clause { font: 600 .95rem/1.2 var(--font-display); color: var(--muted); }
.topic-name { font-weight: 500; }
.topic-name small { display: block; color: var(--muted); font-size: .82rem; font-weight: 400; }
.topic-actions { display: flex; gap: 6px; }
.meter { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; display: block; }
.meter > i { display: block; height: 100%; background: var(--c, var(--ink)); border-radius: 4px; }
.meter-lbl { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.resume-banner { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--warn-bg); border: 1px solid var(--hazard); border-radius: var(--r-m); padding: 12px 16px; margin-bottom: 20px; }
.resume-banner p { margin: 0; }

/* ---------- quiz ---------- */
.quiz { max-width: 820px; margin: 0 auto; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; font-size: .9rem; color: var(--muted); }
.progress-track { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-bottom: 22px; }
.progress-track > i { display: block; height: 100%; background: var(--c); transition: width .25s ease; }
.q-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; font-size: .88rem; }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); }
.tag.clause { color: var(--c); border-color: var(--c); font-weight: 600; }
.diff { display: inline-flex; gap: 3px; }
.diff i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.diff i.on { background: var(--muted); }
.q-text { font: 500 1.3rem/1.45 var(--font-body); margin: 0 0 6px; }
.q-hint { color: var(--muted); font-size: .92rem; margin-bottom: 16px; }
.q-hint b { color: var(--ink); }
.options { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.opt {
  width: 100%; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start;
  text-align: left; padding: 12px 14px; background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--r-m); cursor: pointer; line-height: 1.45;
}
.opt:hover:not(:disabled) { border-color: var(--line-strong); }
.opt .key {
  width: 30px; height: 30px; display: grid; place-items: center; border: 1.5px solid var(--line-strong);
  font: 700 .95rem var(--font-display); color: var(--muted);
}
.opt[role="radio"] .key { border-radius: 50%; }
.opt[role="checkbox"] .key { border-radius: 6px; }
.opt[aria-checked="true"] { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.opt[aria-checked="true"] .key { background: var(--c); border-color: var(--c); color: #fff; }
.opt:disabled { cursor: default; }
.opt.is-correct { border-color: var(--ok); background: var(--ok-bg); box-shadow: none; }
.opt.is-correct .key { background: var(--ok); border-color: var(--ok); color: #fff; }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: none; }
.opt.is-wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.opt.is-missed { border-style: dashed; border-color: var(--ok); }
.opt-note { display: block; margin-top: 6px; font-size: .9rem; color: var(--muted); }
.opt-flag { display: inline-block; font-size: .78rem; font-weight: 600; margin-left: 6px; }
.opt.is-correct .opt-flag { color: var(--ok); }
.opt.is-wrong .opt-flag { color: var(--bad); }
.opt.is-missed .opt-flag { color: var(--ok); }
.quiz-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.kbd-hint { color: var(--muted); font-size: .82rem; }
kbd { font: 600 .78rem var(--font-mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; background: var(--surface); }

.feedback { margin-top: 22px; border-radius: var(--r-l); border: 1px solid var(--line); background: var(--surface); overflow: hidden; animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.fb-head { display: flex; gap: 12px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.fb-head svg { width: 26px; height: 26px; flex: none; }
.fb-head h2 { margin: 0; font-size: 1.45rem; }
.fb-head p { margin: 0; color: var(--muted); font-size: .92rem; }
.feedback.ok .fb-head { background: var(--ok-bg); }
.feedback.ok .fb-head svg { color: var(--ok); }
.feedback.bad .fb-head { background: var(--bad-bg); }
.feedback.bad .fb-head svg { color: var(--bad); }
.fb-body { padding: 18px 20px 20px; display: grid; gap: 16px; }
.fb-answer { font-weight: 600; }
.fb-expl { margin: 0; }
.figure { margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px; }
.figure svg { display: block; width: 100%; height: auto; max-height: 460px; }
.figure figcaption { color: var(--muted); font-size: .82rem; margin-top: 6px; }
.note-drawer { border: 1px solid var(--line); border-radius: var(--r-m); background: var(--paper); }
.note-drawer > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.note-drawer > summary::-webkit-details-marker { display: none; }
.note-drawer > summary::before { content: ''; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.note-drawer[open] > summary::before { transform: rotate(45deg); }
.note-drawer .drawer-body { padding: 0 16px 14px; }

/* summary */
.summary-hero { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; margin-bottom: 24px; }
.score-big { font: 700 4.5rem/1 var(--font-display); }
.score-big small { font-size: 1.6rem; color: var(--muted); }
.breakdown { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.breakdown td, .breakdown th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: .95rem; }
.breakdown th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.missed-list { display: grid; gap: 10px; }
.missed-item { border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.missed-item > summary { padding: 12px 14px; cursor: pointer; }
.missed-item .mi-body { padding: 0 14px 14px; }

/* ---------- notes ---------- */
.notes-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 32px; align-items: start; }
.notes-nav { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; padding-right: 6px; }
.notes-nav ol { list-style: none; margin: 0; padding: 0; }
.notes-nav a { display: grid; grid-template-columns: 58px 1fr 14px; gap: 6px; padding: 6px 8px; border-radius: var(--r-s); text-decoration: none; font-size: .9rem; line-height: 1.3; }
.notes-nav a:hover { background: var(--surface-2); }
.notes-nav a[aria-current="page"] { background: var(--surface); box-shadow: inset 3px 0 0 var(--c); font-weight: 600; }
.notes-nav .nn-clause { color: var(--muted); font-family: var(--font-display); font-weight: 600; }
.notes-nav .nn-read { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--line-strong); margin-top: 4px; }
.notes-nav .nn-read.on { background: var(--c); border-color: var(--c); }
.notes-nav-toggle { display: none; }
.note-article { max-width: 760px; }
.note-article .lead { font-size: 1.12rem; color: var(--ink); }
.note-sec { border-top: 1px solid var(--line); }
.note-sec > summary { list-style: none; cursor: pointer; padding: 14px 0; display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.note-sec > summary::-webkit-details-marker { display: none; }
.note-sec > summary h2 { font-size: 1.35rem; margin: 0; }
.note-sec > summary .chev { width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; flex: none; }
.note-sec:not([open]) > summary .chev { transform: rotate(-45deg); }
.note-sec .sec-body { padding-bottom: 18px; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin-bottom: .3em; }
.prose table, table.tbl { border-collapse: collapse; width: 100%; margin: 0 0 1em; font-size: .93rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); font-weight: 600; }
.keypoints { list-style: none; padding: 12px 14px !important; margin: 0 0 1em; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-m); display: grid; gap: 6px; }
.keypoints li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; margin: 0 !important; }
.keypoints input { margin: 4px 0 0; accent-color: var(--c); width: 16px; height: 16px; }
.keypoints label { cursor: pointer; }
.callout { border-left: 4px solid; border-radius: 0 var(--r-m) var(--r-m) 0; padding: 10px 14px; margin: 0 0 1em; }
.callout b { display: block; margin-bottom: 2px; }
.callout.tip { border-color: var(--ok); background: var(--ok-bg); }
.callout.warn { border-color: var(--warn); background: var(--warn-bg); }
.callout.info { border-color: var(--focus); background: var(--info-bg); }
.note-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 26px; padding-top: 18px; border-top: 3px solid var(--c); }

/* ---------- widgets ---------- */
.widget { border: 1.5px solid var(--c, var(--line-strong)); border-radius: var(--r-l); background: var(--surface); padding: 16px 18px; margin: 0 0 1.4em; }
.widget h3 { margin: 0 0 4px; }
.widget > p.w-sub { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.w-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.w-grid label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
select, input[type="number"], input[type="text"] {
  font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: var(--r-s); padding: 7px 9px; width: 100%;
}
input[type="range"] { width: 100%; accent-color: var(--c, var(--ink)); }
.marking-out {
  font: 700 clamp(1.3rem, 3.4vw, 1.9rem)/1.2 var(--font-mono); padding: 14px 16px; border-radius: var(--r-m);
  background: var(--paper); border: 1px dashed var(--line-strong); display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px;
}
.marking-out button { all: unset; cursor: pointer; border-bottom: 3px solid transparent; }
.marking-out button:hover, .marking-out button[aria-pressed="true"] { border-bottom-color: var(--c, var(--hazard)); }
.marking-out button:focus-visible { outline: 3px solid var(--focus); }
.w-explain { font-size: .95rem; min-height: 3em; }
.w-warn { color: var(--warn); font-size: .9rem; }
.w-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.w-table th, .w-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.w-table th { background: var(--surface-2); }
.w-table tr.hit td { background: var(--warn-bg); font-weight: 600; }
.w-table td.cell-hot { background: var(--info-bg); outline: 2px solid var(--focus); outline-offset: -2px; }
.w-table tr[data-row] { cursor: pointer; }
.w-result { padding: 12px 14px; border-radius: var(--r-m); background: var(--paper); border: 1px solid var(--line); }
.w-result .big { font: 700 1.8rem/1.1 var(--font-display); }
.module-chain { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0 10px; }
.module { padding: 6px 12px; border-radius: var(--r-m); background: var(--c, var(--ink)); color: #fff; font-weight: 600; }
.module.alt { background: transparent; color: var(--ink); border: 1.5px dashed var(--line-strong); }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-m); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: 8px 16px; cursor: pointer; font-weight: 600; border-right: 1px solid var(--line-strong); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--c, var(--ink)); color: #fff; }
.fault-ladder { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.fault-step { padding: 10px; border-radius: var(--r-m); border: 1.5px solid var(--line); text-align: center; font-size: .9rem; }
.fault-step b { display: block; font: 700 1.2rem var(--font-display); }
.fault-step.on { border-color: var(--c); background: var(--info-bg); }
.fault-step.off { opacity: .45; border-style: dashed; }

/* ---------- progress ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 26px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 16px; }
.kpi b { display: block; font: 700 2.2rem/1.05 var(--font-display); }
.kpi span { color: var(--muted); font-size: .9rem; }
.prog-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; margin-bottom: 22px; }
.std-bars { display: grid; gap: 14px; }
.std-bar-row { display: grid; grid-template-columns: 150px 1fr 54px; gap: 12px; align-items: center; }
.std-bar-row .meter { height: 12px; border-radius: 6px; }
.std-bar-row .meter > i { border-radius: 6px; }
.std-bar-row b { text-align: right; font-family: var(--font-display); font-size: 1.1rem; }
.heat-block { margin-bottom: 14px; }
.heat-block h3 { font-size: 1.05rem; margin-bottom: 6px; }
.heat { display: flex; flex-wrap: wrap; gap: 3px; }
.heat a { width: 22px; height: 22px; border-radius: 4px; background: var(--seq-0); display: block; }
.heat a:hover, .heat a:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.heat a[data-l="1"] { background: var(--seq-1); }
.heat a[data-l="2"] { background: var(--seq-2); }
.heat a[data-l="3"] { background: var(--seq-3); }
.heat a[data-l="4"] { background: var(--seq-4); }
.heat-legend { display: flex; gap: 4px; align-items: center; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.heat-legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-wrap .grid-l { stroke: var(--line); stroke-width: 1; }
.chart-wrap .axis-t { fill: var(--muted); font: 500 11px var(--font-body); }
.chart-wrap .ln { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.chart-wrap .pt { stroke: var(--surface); stroke-width: 2; }
.chart-wrap .hit { fill: transparent; cursor: pointer; }
.chart-wrap .xhair { stroke: var(--line-strong); stroke-dasharray: 3 3; }
.tooltip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); padding: 6px 9px; border-radius: 6px; font-size: .82rem; line-height: 1.35; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 3; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .85rem; color: var(--muted); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.weak-list { list-style: none; padding: 0; margin: 0; }
.weak-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.weak-list small { display: block; color: var(--muted); }
.empty { color: var(--muted); padding: 14px 0; }
.data-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.table-toggle { margin-top: 8px; font-size: .88rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- diagram classes (used by all SVGs) ---------- */
svg .dg-text { fill: var(--ink); font-family: var(--font-body); }
svg .dg-muted { fill: var(--muted); font-family: var(--font-body); }
svg .dg-on { fill: var(--d-on); font-family: var(--font-body); }
svg text { font-family: var(--font-body); }
svg .dg-box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.2; }
svg .dg-bg { fill: var(--surface-2); }
svg .dg-line { stroke: var(--ink); stroke-width: 1.6; fill: none; }
svg .dg-thin { stroke: var(--muted); stroke-width: 1; fill: none; }
svg .dg-arrow { stroke: var(--ink); stroke-width: 1.6; fill: none; }
svg .dg-arrowhead { fill: var(--ink); stroke: none; }
svg .dg-a1 { fill: var(--d-a1); } svg .dg-a1s { stroke: var(--d-a1); fill: none; stroke-width: 2; }
svg .dg-a2 { fill: var(--d-a2); } svg .dg-a2s { stroke: var(--d-a2); fill: none; stroke-width: 2; }
svg .dg-a3 { fill: var(--d-a3); } svg .dg-a3s { stroke: var(--d-a3); fill: none; stroke-width: 2; }
svg .dg-a4 { fill: var(--d-a4); } svg .dg-a4s { stroke: var(--d-a4); fill: none; stroke-width: 2; }
svg .dg-a5 { fill: var(--d-a5); } svg .dg-a5s { stroke: var(--d-a5); fill: none; stroke-width: 2; }
svg .dg-a6 { fill: var(--d-a6); } svg .dg-a6s { stroke: var(--d-a6); fill: none; stroke-width: 2; }
svg .dg-ok { fill: var(--ok); } svg .dg-oks { stroke: var(--ok); fill: none; stroke-width: 2; }
svg .dg-bad { fill: var(--bad); } svg .dg-bads { stroke: var(--bad); fill: none; stroke-width: 2; }
svg .dg-warn { fill: var(--hazard); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .std-layout { grid-template-columns: 1fr; }
  .mode-panel { position: static; order: -1; }
  .prog-grid { grid-template-columns: 1fr; }
  .notes-layout { grid-template-columns: 1fr; }
  .notes-nav { position: static; max-height: none; }
  .notes-nav-toggle { display: inline-flex; margin-bottom: 10px; }
  .notes-nav:not(.open) ol { display: none; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .plates { grid-template-columns: 1fr; }
  .home-head { grid-template-columns: 1fr; }
  .plate { padding: 22px 18px 18px 26px; }
  .plate-specs { grid-template-columns: repeat(2, 1fr); }
  .plate-specs div:nth-child(2) { border-right: 0; }
  .plate-specs div:nth-child(-n+2) { border-bottom: 1px solid var(--line-strong); }
  .topic-row { grid-template-columns: 64px minmax(0, 1fr); }
  .topic-row .topic-meter { grid-column: 2; }
  .topic-row .topic-actions { grid-column: 2; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .std-bar-row { grid-template-columns: 110px 1fr 46px; }
  .summary-hero { grid-template-columns: 1fr; }
  .std-head { grid-template-columns: 1fr; }
  .topnav a { padding: 6px 8px; }
  .brand span { display: none; }
}
