/* Direction: the page is a bench next to a bike computer. The one memorable element is the head-unit
   screen (reflective LCD, 7-segment numerals, ghost segments) that reads out the loaded file.
   Everything else is quiet: one family (Archivo, narrow cut for headings and numbers), ink buttons,
   blue only for links, no cards-for-everything, sentence-case labels. Left aligned, one column. */
@font-face {
  font-family: "DSEG7";
  src: url("fonts/DSEG7Classic-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: block;
}
:root {
  color-scheme: light;
  --page: #f3f4f1;
  --surface: #ffffff;
  --ink: #1c1e1b;
  --muted: #5b6157;
  --line: #cfd3cb;
  --grid: #e4e7e1;
  --link: #1f4fd1;
  --btn: #1c1e1b; --btn-ink: #f3f4f1;
  --ok: #2b6e2f; --warn: #9a5b00;
  --series-speed: #2a78d6;  /* dataviz slot 1, validated on #ffffff */
  --series-hr: #eb6834;     /* dataviz slot 2 */
  --dim: rgba(243, 244, 241, 0.80);
  --edge: #1c1e1b;
  /* head unit */
  --bezel: #2b2e29; --screen: #c3ccb3; --seg: #1f2619; --seg-ghost: rgba(31, 38, 25, 0.075); --screen-text: #3a4532;
  --font: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-seg: "DSEG7", "Archivo", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #121411; --surface: #1a1d19; --ink: #e8ebe4; --muted: #a1a89b; --line: #343a31; --grid: #262b24;
    --link: #8fb0ff; --btn: #e8ebe4; --btn-ink: #121411; --ok: #7fc784; --warn: #f0b04c;
    --series-speed: #3987e5; --series-hr: #d95926; --dim: rgba(18, 20, 17, 0.78); --edge: #e8ebe4;
    --bezel: #050605; --screen: #0f120d; --seg: #e3ead8; --seg-ghost: rgba(227, 234, 216, 0.06); --screen-text: #aeb8a2;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #121411; --surface: #1a1d19; --ink: #e8ebe4; --muted: #a1a89b; --line: #343a31; --grid: #262b24;
  --link: #8fb0ff; --btn: #e8ebe4; --btn-ink: #121411; --ok: #7fc784; --warn: #f0b04c;
  --series-speed: #3987e5; --series-hr: #d95926; --dim: rgba(18, 20, 17, 0.78); --edge: #e8ebe4;
  --bezel: #050605; --screen: #0f120d; --seg: #e3ead8; --seg-ghost: rgba(227, 234, 216, 0.06); --screen-text: #aeb8a2;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 16px/1.55 var(--font); font-variation-settings: "wdth" 100; }
a { color: var(--link); text-underline-offset: 3px; }
code { font: inherit; font-weight: 600; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
h1, h2 { font-weight: 700; font-variation-settings: "wdth" 75; letter-spacing: -0.005em; text-wrap: balance; }

/* page frame */
.masthead, .bench, .foot { width: min(880px, 100% - 32px); margin-inline: auto; }
.masthead { padding: 40px 0 22px; }
h1 { font-size: 3.1rem; line-height: 0.95; margin: 0 0 10px; }
.lead { margin: 0; color: var(--muted); max-width: 60ch; font-size: 1.05rem; }
.lead strong { color: var(--ink); font-weight: 600; }
.bench { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; padding-bottom: 56px; }
.bench > *, .intake > *, .pane > * { min-width: 0; }

/* ---------- head unit: the one loud element ---------- */
.unit { background: var(--bezel); border-radius: 18px; padding: 14px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.screen { background: var(--screen); border-radius: 6px; padding: 14px 18px 16px; color: var(--screen-text);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.22); display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 18px; }
.screen-top { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 0.88rem; font-variation-settings: "wdth" 85; border-bottom: 1px solid color-mix(in srgb, var(--seg) 22%, transparent); padding-bottom: 6px; }
.screen-top .file { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen-top .alert { color: var(--seg); font-weight: 700; }
.field { display: grid; gap: 2px; align-content: start; }
.field.big { grid-column: span 3; }
.field.small { grid-column: span 2; }
.field-label { font-size: 0.82rem; font-variation-settings: "wdth" 85; }
.seg { position: relative; display: inline-block; font-family: var(--font-seg); font-weight: 700; color: var(--seg); line-height: 1; white-space: nowrap; font-size: clamp(1.5rem, 4.2vw, 2.1rem); }
.field.big .seg { font-size: clamp(2.2rem, 7vw, 3.6rem); }
.seg .ghost { position: absolute; inset: 0; color: var(--seg-ghost); }
.seg .val { position: relative; }
.seg-unit { font-size: 0.85rem; margin-left: 6px; font-variation-settings: "wdth" 85; }

/* ---------- intake ---------- */
.intake { display: grid; gap: 10px; }
.drop { display: grid; gap: 2px; padding: 22px 18px; border: 1.5px dashed var(--line); border-radius: 8px; background: transparent; cursor: pointer; }
.drop:hover, .drop.over { border-color: var(--ink); background: var(--surface); }
.drop-title { font-weight: 600; font-size: 1.05rem; }
.like-link { color: var(--link); text-decoration: underline; text-underline-offset: 3px; }
.drop-hint { color: var(--muted); font-size: 0.92rem; }
.intake-links { display: grid; gap: 4px; font-size: 0.94rem; color: var(--muted); }
.intake-links p { margin: 0; }
.link-btn { font: inherit; color: var(--link); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.example-list { list-style: none; margin: 2px 0 0; padding: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; }
.example-list li { display: contents; }
.example-list .link-btn { font-weight: 600; justify-self: start; }

.files { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.files:empty { display: none; }
.file { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: baseline; gap: 2px 12px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.file input[type=radio] { accent-color: var(--ink); margin: 0; align-self: center; }
.file .name { font-weight: 600; word-break: break-all; }
.file .state { font-weight: 500; font-size: 0.9rem; margin-left: 8px; word-break: normal; }
.file .state.ok { color: var(--ok); }
.file .state.warn { color: var(--warn); }
.file .state.example { color: var(--muted); font-weight: 400; }
.file .meta { grid-column: 2 / -1; color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.file .x { background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: 0.88rem; padding: 2px 8px; border-radius: 4px; }
.file .x:hover { border-color: var(--line); color: var(--ink); }

/* ---------- workbench ---------- */
.workbench { border-top: 2px solid var(--ink); padding-top: 2px; }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { font: 600 1rem var(--font); font-variation-settings: "wdth" 85; color: var(--muted); background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 0 9px; cursor: pointer; white-space: nowrap; }
.tabs button:hover:not(:disabled) { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs button:disabled { opacity: 0.4; cursor: not-allowed; }
.pane { padding: 16px 0 4px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.help { margin: 0; color: var(--muted); max-width: 68ch; }

.charts { position: relative; display: grid; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 10px 0 4px; }
.chart { margin: 0; }
.chart figcaption { font-size: 0.88rem; margin: 0 0 2px 12px; }
.chart-title { font-weight: 600; }
.chart-unit { color: var(--muted); }
canvas { display: block; width: 100%; touch-action: pan-y; }
.tip { position: absolute; z-index: 2; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.10); padding: 8px 10px; font-size: 0.86rem; display: grid; gap: 3px; min-width: 150px; font-variant-numeric: tabular-nums; }
.tip-time { color: var(--muted); font-size: 0.8rem; }
.tip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 6px; }
.tip-row b { font-weight: 600; }
.tip-row span:last-child { color: var(--muted); }
.key { width: 12px; height: 2px; border-radius: 1px; }

.range { position: relative; height: 30px; margin: -4px 4px 0 36px; }
.range input { position: absolute; inset: 0; width: 100%; margin: 0; height: 30px; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.range input::-webkit-slider-runnable-track { height: 4px; background: transparent; }
.range input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 16px; height: 26px; margin-top: -11px; border-radius: 3px; background: var(--edge); border: 2px solid var(--page); cursor: ew-resize; }
.range input::-moz-range-thumb { pointer-events: auto; width: 14px; height: 24px; border-radius: 3px; background: var(--edge); border: 2px solid var(--page); cursor: ew-resize; }
.range input:focus-visible { outline: none; }
.range input:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--link); }
.range::before { content: ""; position: absolute; left: 0; right: 0; top: 13px; height: 4px; border-radius: 2px; background: var(--line); }

.readout { display: flex; flex-wrap: wrap; gap: 4px 22px; font-variant-numeric: tabular-nums; }
.readout:empty { display: none; }
.readout .kv { display: inline-flex; gap: 6px; align-items: baseline; }
.readout .k { color: var(--muted); font-size: 0.9rem; }
.readout .v { font-weight: 700; font-size: 1.15rem; font-variation-settings: "wdth" 80; }
.readout .v.cut { color: var(--muted); }

.table-view summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 0.92rem; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th { color: var(--muted); font-weight: 600; font-size: 0.86rem; border-bottom-color: var(--line); }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; max-width: 520px; }
.field-input { display: grid; gap: 4px; color: var(--muted); font-size: 0.92rem; font-weight: 500; }
select, input[type=number] { font: 400 1rem var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 9px 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.primary { font: 600 1rem var(--font); color: var(--btn-ink); background: var(--btn); border: 0; border-radius: 4px; padding: 11px 18px; cursor: pointer; }
.primary:hover { opacity: 0.88; }
.primary:disabled { opacity: 0.35; cursor: not-allowed; }
a.primary { display: inline-block; text-decoration: none; }

.issues { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.issues li::marker { color: var(--warn); }
.merge-list { margin: 0; padding-left: 22px; display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.merge-list .when { color: var(--muted); }

.result { margin-top: 16px; padding: 14px 0 0; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.result.err { color: var(--warn); }
.result-head { font-variant-numeric: tabular-nums; }
.result-head strong { color: var(--ok); }
.result ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.94rem; }
.result .after { margin: 0; color: var(--muted); font-size: 0.9rem; max-width: 68ch; }
.dl { justify-self: start; }

/* ---------- editor's guide text ---------- */
.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 32px; padding-top: 22px; border-top: 1px solid var(--line); margin-top: 18px; }
.guide h2 { font-size: 1.4rem; margin: 6px 0 4px; }
.guide p { margin: 0; color: var(--muted); max-width: 62ch; }
.faq { grid-column: 1 / -1; }
.faq details { border-top: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin-top: 6px; }
.foot { color: var(--muted); font-size: 0.86rem; padding: 0 0 32px; }

/* ---------- how-to article ---------- */
.brand-link { color: var(--ink); text-decoration: none; font-weight: 700; font-variation-settings: "wdth" 75; font-size: 1.3rem; }
.doc-head { width: min(720px, 100% - 32px); padding-bottom: 0; }
.doc { width: min(720px, 100% - 32px); margin-inline: auto; padding-bottom: 56px; display: grid; gap: 26px; }
.doc > * { min-width: 0; }
.doc h1 { font-size: 2.9rem; margin: 14px 0 0; }
.doc h2 { font-size: 1.55rem; margin: 0 0 8px; }
.doc .lead { font-size: 1.08rem; }
.doc p { margin: 0 0 8px; max-width: 66ch; }
.doc section { scroll-margin-top: 16px; }
.answer { border-top: 2px solid var(--ink); padding-top: 8px; }
.answer h2 { font-size: 1.2rem; margin-bottom: 4px; }
.answer td { white-space: normal; text-align: left; vertical-align: top; }
.answer th { text-align: left; }
.answer .yes { color: var(--ok); font-weight: 600; }
.answer .partly { color: var(--warn); font-weight: 600; }
.jump { margin: -8px 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 0.95rem; }
.steps { margin: 0 0 8px; padding-left: 1.6em; display: grid; gap: 8px; max-width: 66ch; }
.steps li::marker { font-weight: 700; }
.note { color: var(--muted); font-size: 0.95rem; }
.sources { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; max-width: 70ch; }
.sources dt { font-weight: 600; }
.sources dd { margin: 0; }
.cta { border-top: 2px solid var(--ink); padding-top: 10px; }
.cta .primary { margin-top: 6px; }

@media (max-width: 560px) {
  h1 { font-size: 2.4rem; }
  .doc h1 { font-size: 2.2rem; }
  .screen { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 14px 14px; }
  .field.big { grid-column: 1 / -1; }
  .field.small { grid-column: span 1; }
  .field.big .seg { font-size: 2.6rem; }
  .seg { font-size: 1.45rem; }
  .screen-top { flex-direction: column; gap: 0; }
  .unit { padding: 10px; border-radius: 14px; }
  .sources { grid-template-columns: 1fr; gap: 2px; }
  .sources dd { margin-bottom: 10px; }
  .answer thead { display: none; }
  .answer tr { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
  .answer td { display: block; border: 0; padding: 0; }
  .answer td:first-child { font-weight: 600; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
