/* One column: introduction, what to compare, the run bar, the flash maps,
   the results, then each design's detail. how-it-works.html and
   licences.html are text pages (main.doc). */
:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #fcfcfb;
  --fg: #0b0b0b;
  --muted: #52514e;
  --faint: #898781;
  --rule: #e1e0d9;
  --grid: #ecebe6;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --o-data: #b9b8b1; --o-copy: #e87ba4; --o-journal: #008300; --o-meta: #6250d6; --o-other: #e34948;
  --eu-0: #b9b8b1; --eu-1: #2a78d6;
  --warn: #a35a00;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, Menlo, monospace;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f0e; --surface: #1a1a19; --fg: #f0efec; --muted: #c3c2b7; --faint: #898781;
    --rule: #2e2e2b; --grid: #262624; --axis: #383835; --accent: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --o-data: #5c5b56; --o-copy: #d55181; --o-journal: #008300; --o-meta: #9085e9; --o-other: #e66767;
    --eu-0: #4a4945; --eu-1: #5598e7;
    --warn: #f0a640;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0e; --surface: #1a1a19; --fg: #f0efec; --muted: #c3c2b7; --faint: #898781;
  --rule: #2e2e2b; --grid: #262624; --axis: #383835; --accent: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --o-data: #5c5b56; --o-copy: #d55181; --o-journal: #008300; --o-meta: #9085e9; --o-other: #e66767;
  --eu-0: #4a4945; --eu-1: #5598e7;
  --warn: #f0a640;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font-ui); font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 1.1rem + 2vw, 2.4rem); line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.95rem; }
a { color: var(--accent); }
code { font-family: var(--font-mono); font-size: 0.85em; }
button { font: 500 0.9rem var(--font-ui); padding: 7px 14px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface); color: var(--fg); cursor: pointer; }
button:hover { border-color: var(--axis); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select, input[type="number"] { font: 0.88rem var(--font-ui); padding: 5px 8px; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); color: var(--fg); }

/* ---------- page ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1240px; margin: 0 auto; padding: 16px 24px 0; }
.wordmark { font-weight: 600; font-size: 1.1rem; color: var(--fg); text-decoration: none; letter-spacing: -0.01em; }
.wordmark span { color: var(--faint); }
.top nav { display: flex; align-items: center; gap: 18px; font-size: 0.9rem; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover { color: var(--fg); }

main { max-width: 1240px; margin: 0 auto; padding: 0 24px 64px; display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); }
.intro { padding: 40px 0 4px; max-width: 760px; }
.intro p { color: var(--muted); font-size: 1.05rem; margin: 14px 0 0; }

.results-head, .setup-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; margin-bottom: 14px; }
.caption { color: var(--muted); font-size: 0.85rem; margin: 0; max-width: 80ch; }
.caption.warn { color: var(--fg); margin: 2px 0 6px; }

/* ---------- setup ---------- */
.mode { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; padding: 2px; background: var(--surface); }
.mode button { border: 0; background: none; padding: 5px 12px; color: var(--muted); border-radius: 6px; }
.mode button[aria-pressed="true"] { background: var(--bg); color: var(--fg); box-shadow: 0 0 0 1px var(--rule); }
.setup { display: grid; gap: 12px; }
.setup-head { margin-bottom: 0; }
.shared, .card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.configs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 12px; align-items: start; }
.card { box-shadow: inset 0 3px 0 var(--c); }
.card-head { display: flex; gap: 10px; align-items: center; min-width: 0; }
.card-head .tag { font-weight: 600; font-size: 1rem; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.card .tag::before { content: ""; width: 14px; height: 0; border-top: 3px solid var(--c); border-radius: 2px; }
.card-head select { flex: 1; min-width: 0; font-weight: 500; }
.card-head button { padding: 3px 9px; color: var(--muted); }
.add { justify-self: start; border-style: dashed; color: var(--muted); }
.summary { margin: 0; font-size: 0.88rem; color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr)); gap: 10px 14px; margin: 10px 0; }
.field { display: grid; gap: 3px; font-size: 0.8rem; min-width: 0; align-content: end; }
.field span { color: var(--muted); }
.field input[type="number"], .field select { width: 100%; }
.field input[type="checkbox"] { justify-self: start; margin: 4px 0; }
details summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
details.json { margin-top: 4px; }
textarea { width: 100%; min-height: 90px; font: 0.8rem/1.4 var(--font-mono); border: 1px solid var(--rule); border-radius: 6px; padding: 8px; background: var(--bg); color: var(--fg); }
.err { color: var(--o-other); font-size: 0.85rem; margin: 0; white-space: pre-wrap; }
.err::before { content: "\26A0  "; }
.note { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* ---------- run bar ---------- */
.runbar { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; margin: -8px -16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }
.runbar #run { min-width: 92px; font-size: 0.95rem; }
.progress { flex: 1 1 260px; display: grid; gap: 4px; min-width: 0; }
.track { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.track .fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; }
.clock { font-size: 0.82rem; color: var(--muted); }
.hours { display: flex; gap: 6px; align-items: center; font-size: 0.88rem; color: var(--muted); }
.hours input { width: 72px; }
.speed { display: flex; gap: 8px; align-items: center; font-size: 0.8rem; color: var(--faint); }
.speed input { width: 110px; accent-color: var(--accent); }

/* ---------- panels ---------- */
.flash, .results, .detail { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 20px 22px; min-width: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--muted); }
.key { display: inline-flex; align-items: center; gap: 7px; }
.legend .line, td .line { width: 18px; height: 0; border-top: 3px solid; border-radius: 2px; display: inline-block; }
.box { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.armhead { display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.armhead::before { content: ""; flex: none; width: 18px; height: 0; border-top: 3px solid var(--c); border-radius: 2px; }

/* the flash maps */
.flash-key { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 0.85rem; color: var(--muted); margin-bottom: 16px; }
.cell { width: 14px; height: 14px; border-radius: 3px; display: inline-block; flex: none; }
.cell.valid { background: linear-gradient(to top, var(--eu-1) 65%, var(--eu-0) 65%); }
.cell.stale { background: var(--eu-0); }
.cell.open { background: linear-gradient(to top, var(--eu-1) 30%, var(--eu-0) 30% 60%, transparent 60%); box-shadow: inset 0 0 0 2px var(--fg); }
.cell.free { box-shadow: inset 0 0 0 1px var(--axis); }
.maps { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 24px 32px; }
.map { display: grid; gap: 10px; align-content: start; min-width: 0; }
.map canvas, .arm canvas { width: 100%; display: block; }
.map .cap { height: 56px; }
.map .euh { height: 110px; }

/* results */
.score-wrap { overflow-x: auto; margin-bottom: 6px; container-type: inline-size; }
table { border-collapse: collapse; width: 100%; }
table.score { font-size: 0.95rem; min-width: 640px; }
table.score th { font-size: 0.78rem; font-weight: 500; color: var(--muted); text-align: right; padding: 6px 10px; vertical-align: bottom; line-height: 1.25; }
table.score th span { display: block; color: var(--faint); font-weight: 400; }
table.score td { text-align: right; padding: 4px 10px 10px; font-weight: 500; white-space: nowrap; }
table.score th:first-child, table.score td:first-child { text-align: left; padding-left: 0; }
/* A design's name across the table, then its numbers under its letter. */
table.score tr.name td { padding: 10px 0 0; border-top: 1px solid var(--rule); text-align: left; white-space: normal; }
table.score tr.name .line { margin-right: 8px; vertical-align: middle; }
/* Pinned to the left edge and no wider than the scroll box (100cqw of
   .score-wrap), so the whole name shows at any sideways scroll. */
table.score tr.name span { position: sticky; left: 0; display: inline-block; max-width: 100cqw; }
table.score tr.nums th { text-align: left; padding: 4px 10px 10px 0; font-size: inherit; color: var(--faint); font-weight: 600;
  width: 1.5em; position: sticky; left: 0; background: var(--surface); vertical-align: middle; line-height: inherit; }
#score { margin-bottom: 24px; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 24px 32px; }
.charts.key { grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); }
.chart { min-width: 0; }
.chart .unit { margin: 1px 0 6px; font-size: 0.8rem; color: var(--faint); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.dashkey { display: inline-flex; align-items: center; gap: 6px; }
.dashkey i { width: 16px; height: 0; border-top: 2px dashed var(--muted); }
.chart .plot { width: 100%; height: 180px; }
.charts.key .plot { height: 240px; }
details.more { margin-top: 28px; border-top: 1px solid var(--rule); padding-top: 16px; }
details.more > summary { font-size: 0.95rem; font-weight: 500; color: var(--fg); margin-bottom: 16px; }

/* per design */
.arms { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 24px 32px; }
.arm { display: grid; gap: 6px; align-content: start; min-width: 0; }
.arm .sub { margin: 10px 0 0; font-size: 0.8rem; color: var(--faint); }
.arm .stack { width: 100%; height: 160px; }
.arm .latp { width: 100%; height: 160px; }
.arm .fall { height: 120px; }
table.bands { font-size: 0.85rem; }
table.bands td, table.bands th { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--rule); }
table.bands th { font-weight: 500; color: var(--muted); font-size: 0.78rem; }
table.bands td:first-child, table.bands th:first-child { text-align: left; }
table.bands .box { margin-right: 7px; vertical-align: -1px; }
table.bands tr.total td { color: var(--muted); }


main.doc { display: block; max-width: 760px; }
.doc h2 { margin-top: 32px; }
.doc h3 { margin-top: 20px; font-size: 0.95rem; }
.doc p, .doc li { color: var(--muted); }
.doc b { color: var(--fg); font-weight: 600; }
.doc pre { font-family: var(--font-mono); font-size: 0.78rem; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted);
  background: var(--surface); border-radius: 6px; padding: 10px 12px; }

.stat.warn { color: var(--warn); }
/* The charts' tooltip (ECharts positions it; tooltip.className). */
.ec-tip { font-size: 0.82rem; }
@media (pointer: coarse) { .fine-only { display: none; } }
.ec-tip .t { color: var(--muted); margin-bottom: 4px; }
.ec-tip .row { display: grid; grid-template-columns: 14px auto 1fr; gap: 7px; align-items: center; }
.ec-tip .row .k { width: 12px; height: 0; }
.ec-tip .row strong { font-weight: 600; }
.ec-tip .row span { color: var(--muted); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; }

@media (max-width: 760px) {
  .maps, .arms { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .intro { padding-top: 24px; }
  .flash, .results, .detail { padding: 16px 14px; }
  .runbar { margin: -8px -16px; padding: 10px 16px; }
  .speed { display: none; }
  .top { flex-wrap: wrap; row-gap: 8px; }
  .top nav { gap: 12px; font-size: 0.85rem; white-space: nowrap; }
}
