/* Layout idea: a workbench. Inputs on the left read like the circuit list inside a breaker-panel door;
   results on the right read like an equipment nameplate, with one bold element: the runtime ruler. */
:root {
  --paper: #edf0f2;      /* tank white, cooled toward steel */
  --surface: #ffffff;
  --sunk: #e2e7eb;
  --ink: #14212b;
  --muted: #52616d;
  --line: #c5ced6;
  --signal: #ffc400;     /* safety-label yellow */
  --signal-ink: #14212b;
  --flame: #0f5fd0;      /* propane-flame blue: links, fuel bars */
  --ok: #17754a;
  --warn: #a8500a;
  --crit: #b3261e;
  --ok-bg: #e2f2ea; --warn-bg: #fbeedd; --crit-bg: #fae4e2;
  --chrome: #14212b;     /* header, dock and call-to-action strips: dark in both themes */
  --btn: #14212b; --btn-ink: #ffffff;
  --display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1a22; --surface: #17252f; --sunk: #1e303c; --ink: #e8eef2; --muted: #a3b3bf; --line: #314553;
    --signal: #ffc400; --signal-ink: #14212b; --flame: #7ab2ff; --ok: #62c796; --warn: #f0a860; --crit: #f58d84;
    --ok-bg: #173327; --warn-bg: #3a2a14; --crit-bg: #3d1f1d; --chrome: #0a1218; --btn: #ffc400; --btn-ink: #14212b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1a22; --surface: #17252f; --sunk: #1e303c; --ink: #e8eef2; --muted: #a3b3bf; --line: #314553;
  --signal: #ffc400; --signal-ink: #14212b; --flame: #7ab2ff; --ok: #62c796; --warn: #f0a860; --crit: #f58d84;
  --ok-bg: #173327; --warn-bg: #3a2a14; --crit-bg: #3d1f1d; --chrome: #0a1218; --btn: #ffc400; --btn-ink: #14212b; color-scheme: dark;
}

*, *::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(--body); }
img, svg { max-width: 100%; }
a { color: var(--flame); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--flame); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.05; margin: 0; text-wrap: balance; letter-spacing: 0.005em; }
h1 { font-size: clamp(2.3rem, 5.2vw, 3.6rem); }
h2 { font-size: 1.75rem; font-weight: 600; }
h3 { font-size: 1.3rem; font-weight: 600; }
p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; line-height: 1.45; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 760px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header and footer */
.top { background: var(--chrome); color: #f3f6f8; }
.top .wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font: 700 1.5rem/1 var(--display); letter-spacing: 0.01em; }
.brand-mark { background: var(--signal); color: var(--signal-ink); font: 700 1rem/1 var(--display); padding: 6px 7px 5px; border-radius: 3px; letter-spacing: 0.03em; }
.top nav { display: flex; gap: 4px 20px; flex-wrap: wrap; margin-left: auto; }
.top nav a { color: #dbe3e9; text-decoration: none; font-size: 0.95rem; padding: 4px 0; border-bottom: 2px solid transparent; }
.top nav a:hover, .top nav a[aria-current="page"] { border-bottom-color: var(--signal); color: #fff; }
.foot { margin-top: 72px; border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--muted); font-size: 0.9rem; }
.foot .wrap { display: grid; gap: 14px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 20px; }
.foot a { color: var(--muted); }

/* Intro */
.intro { padding: 36px 0 22px; display: grid; gap: 12px; }
.intro p { max-width: 62ch; font-size: 1.12rem; color: var(--muted); }

/* Workbench */
.bench { display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); gap: 28px; align-items: start; }
.bench > * { min-width: 0; }
@media (max-width: 940px) { .bench { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; }
.card > h2 { margin-bottom: 4px; }
.card > .lede { color: var(--muted); margin-bottom: 14px; }

/* Panel schedule (load list) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 6px; }
.chip { font: inherit; font-size: 0.95rem; background: var(--surface); color: var(--ink); border: 1.5px solid var(--ink); border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.chip:hover { background: var(--sunk); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.group-title { font: 600 1.05rem/1.2 var(--display); letter-spacing: 0.02em; color: var(--muted); padding: 14px 0 6px; border-bottom: 2px solid var(--ink); display: flex; justify-content: space-between; gap: 12px; }
.loads { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); column-gap: 20px; }
.load { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); cursor: pointer; min-height: 44px; }
.load input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.breaker { width: 38px; height: 22px; border-radius: 3px; background: var(--sunk); border: 1px solid var(--line); position: relative; flex: none; }
.breaker::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 16px; border-radius: 2px; background: var(--muted); transition: transform 0.12s ease, background 0.12s ease; }
.load input:checked + .breaker { background: var(--chrome); border-color: var(--chrome); }
.load input:checked + .breaker::after { transform: translateX(17px); background: var(--signal); }
.load input:focus-visible + .breaker { outline: 3px solid var(--flame); outline-offset: 2px; }
.load-name { font-size: 0.95rem; line-height: 1.25; }
.load-w { font-size: 0.8rem; color: var(--muted); text-align: right; white-space: nowrap; }

/* Form rows */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 20px; }
.field { display: grid; gap: 5px; align-content: start; }
.field > label, .field > .lab { font-size: 0.92rem; font-weight: 700; }
.field .hint { font-size: 0.82rem; color: var(--muted); line-height: 1.35; }
select, input[type="number"] { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--muted); border-radius: 4px; padding: 8px 10px; width: 100%; min-height: 42px; }
input[type="range"] { width: 100%; accent-color: var(--ink); min-height: 28px; }
.seg { display: flex; flex-wrap: wrap; gap: 0; border: 1.5px solid var(--ink); border-radius: 4px; overflow: hidden; width: fit-content; max-width: 100%; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: block; padding: 8px 13px; font-size: 0.93rem; border-right: 1px solid var(--line); background: var(--surface); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--ink); color: var(--surface); }
.seg input:focus-visible + span { outline: 3px solid var(--flame); outline-offset: -3px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.95rem; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
details.more > summary { cursor: pointer; font-weight: 700; font-size: 0.95rem; padding: 6px 0; }
details.more[open] > summary { margin-bottom: 10px; }

/* Nameplate readouts */
.plate { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.plate > div { padding: 14px 16px 12px; border-right: 1px solid var(--line); display: grid; gap: 2px; align-content: start; }
.plate > div:last-child { border-right: 0; }
.plate .k { font-size: 0.84rem; color: var(--muted); line-height: 1.25; }
.plate .v { font: 700 2.5rem/1 var(--display); font-variant-numeric: tabular-nums; }
.plate .v small { font: 600 1.1rem/1 var(--display); margin-left: 4px; color: var(--muted); }
.plate .s { font-size: 0.8rem; color: var(--muted); line-height: 1.3; }
@media (max-width: 520px) { .plate { grid-template-columns: 1fr; } .plate > div { border-right: 0; border-bottom: 1px solid var(--line); } .plate > div:last-child { border-bottom: 0; } }

/* Verdict: a safety label */
.verdict { background: var(--signal); color: var(--signal-ink); border-radius: var(--r); padding: 20px; display: grid; gap: 10px; border: 2px solid var(--ink); }
.verdict .tag { font-size: 0.9rem; font-weight: 700; }
.verdict h2 { font-size: clamp(1.7rem, 3.4vw, 2.3rem); font-weight: 700; }
.verdict p { max-width: 60ch; }
.verdict ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 0.95rem; }
.verdict .btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.btn { display: inline-block; font: 700 1rem/1.2 var(--body); padding: 11px 18px; border-radius: 4px; text-decoration: none; border: 2px solid var(--btn); cursor: pointer; background: var(--btn); color: var(--btn-ink); }
.btn:hover { filter: brightness(1.15); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.verdict .btn { background: #14212b; color: #fff; border-color: #14212b; }
.btn.ghost:hover { background: rgba(20, 33, 43, 0.1); }
.verdict .btn.ghost { background: transparent; color: var(--signal-ink); border-color: var(--signal-ink); }
.verdict a:not(.btn) { color: var(--signal-ink); }

/* Runtime ruler */
.ruler { display: grid; gap: 10px; }
.ruler-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; align-items: center; }
.ruler-row .name { font-size: 0.9rem; line-height: 1.2; }
.track { position: relative; height: 26px; background: var(--sunk); border-radius: 3px; }
.bar { position: absolute; left: 0; top: 0; bottom: 0; background: var(--flame); border-radius: 3px; min-width: 3px; }
.bar.battery { background: var(--ok); }
.bar.endless { background: repeating-linear-gradient(-45deg, var(--flame) 0 10px, color-mix(in srgb, var(--flame) 70%, var(--surface)) 10px 20px); }
.bar.none { background: transparent; }
.track .val { position: absolute; top: 50%; transform: translateY(-50%); font-size: 0.82rem; font-weight: 700; white-space: nowrap; padding: 2px 8px; font-variant-numeric: tabular-nums; z-index: 2; background: var(--sunk); border-radius: 3px; }
.track .val.in { right: 0; color: var(--surface); background: transparent; }
.track .target { position: absolute; top: -5px; bottom: -5px; width: 0; border-left: 2px dashed var(--ink); z-index: 1; }
.ruler-axis { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; font-size: 0.78rem; color: var(--muted); }
.ruler-axis .ticks { position: relative; height: 18px; }
.ruler-axis .ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ruler-axis .ticks span:first-child { transform: none; }
.ruler-axis .ticks span.last { transform: translateX(-100%); }
.ruler-key { font-size: 0.84rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.ruler-key i { display: inline-block; width: 14px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: baseline; }
.ruler-key .dash { width: 0; height: 14px; border-left: 2px dashed var(--ink); border-radius: 0; vertical-align: middle; }
@media (max-width: 520px) { .ruler-row, .ruler-axis { grid-template-columns: 1fr; gap: 4px; } .ruler-axis > :first-child { display: none; } }

/* Option cards */
.opts { display: grid; gap: 14px; }
.opt { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 10px; }
.opt.fit { border-left-color: var(--ok); }
.opt.short { border-left-color: var(--warn); }
.opt.no { border-left-color: var(--line); }
.opt.picked { border-color: var(--ink); border-left-color: var(--signal); box-shadow: inset 0 0 0 1px var(--ink); }
.opt-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; justify-content: space-between; }
.pill { font-size: 0.8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.off { background: var(--sunk); color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px 18px; margin: 0; }
.facts div { display: grid; gap: 1px; }
.facts dt { font-size: 0.8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.opt .notes { font-size: 0.9rem; color: var(--muted); display: grid; gap: 4px; }
.opt .links { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.95rem; }

/* Notes and tables */
.note { border-left: 6px solid var(--line); background: var(--surface); padding: 12px 16px; border-radius: 0 var(--r) var(--r) 0; font-size: 0.95rem; display: grid; gap: 6px; }
.note.warn { border-left-color: var(--warn); background: var(--warn-bg); }
.note.crit { border-left-color: var(--crit); background: var(--crit-bg); }
.note.ok { border-left-color: var(--ok); background: var(--ok-bg); }
.note.caution { border-left: 0; padding-left: 26px; position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.note.caution::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 12px; border-radius: var(--r) 0 0 var(--r); background: repeating-linear-gradient(-45deg, var(--signal) 0 8px, #14212b 8px 16px); }
.note strong { font-weight: 700; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: 0.84rem; color: var(--muted); font-weight: 700; border-bottom: 2px solid var(--ink); white-space: nowrap; }
td.r, th.r { text-align: right; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
.stretch { margin: 0; padding: 0; list-style: none; display: grid; gap: 0; }
.stretch li { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.stretch li:last-child { border-bottom: 0; }
.stretch .d { font: 700 1.35rem/1 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.stretch .w { grid-column: 1 / -1; font-size: 0.88rem; color: var(--muted); }

/* Sticky summary on phones */
.dock { display: none; }
@media (max-width: 940px) {
  .dock { display: flex; position: sticky; bottom: 0; z-index: 5; background: var(--chrome); color: #fff; padding: 10px 16px; gap: 12px; align-items: center; justify-content: space-between; font-size: 0.9rem; margin: 20px -20px 0; }
  .dock a { color: var(--signal); font-weight: 700; white-space: nowrap; }
}

/* Article pages */
.prose { display: grid; gap: 18px; padding-top: 34px; }
.prose > * { min-width: 0; }
.prose h1 { font-size: clamp(2rem, 4.6vw, 3rem); }
.prose h2 { margin-top: 18px; }
.prose p, .prose li { max-width: 68ch; }
.prose ul, .prose ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.prose .answer { font-size: 1.18rem; background: var(--surface); border: 2px solid var(--ink); border-radius: var(--r); padding: 18px 20px; max-width: none; }
.prose .answer strong { background: var(--signal); color: var(--signal-ink); padding: 0 5px; border-radius: 2px; }
.crumbs { font-size: 0.86rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.cards a { display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--ink); }
.cards a strong { font: 600 1.2rem/1.15 var(--display); }
.cards a span { font-size: 0.9rem; color: var(--muted); }
.linklist { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.95rem; }
.calc { display: grid; gap: 16px; }
.calc .out { display: grid; gap: 14px; }
.cta-strip { background: var(--chrome); color: #fff; border-radius: var(--r); padding: 20px; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; }
.cta-strip p { max-width: 52ch; }
.cta-strip .btn { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); }

@media print {
  .top nav, .dock, .btns, .foot nav, .no-print { display: none !important; }
  body { background: #fff; font-size: 12pt; }
  .bench { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
