:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11,11,11,0.12);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --sel: rgba(42,120,214,0.12);
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --changed: rgba(250,178,25,0.18);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242423;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255,255,255,0.12);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --sel: rgba(57,135,229,0.18);
    --accent: #3987e5;
    --good-text: #0ca30c;
    --changed: rgba(250,178,25,0.14);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 11px; cursor: pointer;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
input[type=text], input[type=number], input:not([type]) {
  background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 4px 6px;
}
input[type=number] { width: 7.5em; }
input.bad { border-color: var(--critical); outline: 1px solid var(--critical); }
input.changed, td.changed input { background: var(--changed); }
code { font-family: ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.brand .logo { width: 20px; height: 20px; }
.biglogo { width: 64px; height: 64px; }
.file { flex: 1; min-width: 12em; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file .dirty { color: var(--critical); font-weight: 600; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
main { padding: 12px 16px 40px; max-width: 1600px; margin: 0 auto; }
.empty { display: grid; place-items: center; min-height: 70vh; }
.dropzone {
  text-align: center; padding: 48px 56px; border: 2px dashed var(--axis); border-radius: 12px; background: var(--surface);
}
body.dragging .dropzone, body.dragging .plotcard { border-color: var(--accent); }
.summary { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 8px 2px 12px; }
.summary div { display: flex; flex-direction: column; }
.summary .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.summary .v { font-variant-numeric: tabular-nums; }
.plotcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.plottools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.spacer { flex: 1; }
.legend { display: flex; gap: 14px; color: var(--ink-2); font-size: 13px; }
.legend span::before { content: ""; display: inline-block; width: 16px; height: 2px; margin-right: 6px; vertical-align: middle; background: var(--c); }
.legend span.dash::before { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.plotwrap { position: relative; height: 46vh; min-height: 280px; }
#plot { width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.12);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tooltip .sw { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 5px; }
.hint { padding-top: 4px; }
.chk { display: inline-flex; gap: 5px; align-items: center; white-space: nowrap; }
.tabs { display: flex; gap: 2px; margin-top: 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs button { border: none; border-radius: 6px 6px 0 0; background: transparent; padding: 7px 14px; color: var(--ink-2); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }
.badge { font-size: 11px; padding: 0 6px; border-radius: 9px; margin-left: 4px; }
.badge.fail { background: var(--critical); color: #fff; }
.badge.warn { background: var(--warning); color: #000; }
.badge.ok { background: var(--good); color: #fff; }
.tabpanel { background: var(--surface); border: 1px solid var(--border); border-top: none; border-radius: 0 0 10px 10px; padding: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.tablewrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { border-bottom: 1px solid var(--grid); padding: 3px 5px; text-align: left; white-space: nowrap; }
table.grid th { font-weight: 600; font-size: 12px; color: var(--ink-2); position: sticky; top: 0; background: var(--surface); }
table.grid td input { width: 6.5em; padding: 2px 4px; }
table.grid td input.wide { width: 14em; }
table.grid td input.code { width: 5.5em; font-family: ui-monospace, Consolas, monospace; }
table.grid tr.sel td { background: var(--sel); }
table.grid tr.end td:first-child { font-weight: 600; }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 8px 18px; }
.field { display: flex; flex-direction: column; gap: 2px; }
.field > span { font-size: 12px; color: var(--ink-2); }
.field > span em { color: var(--muted); font-style: normal; }
.field input { width: 100%; }
.field .help { font-size: 11px; color: var(--muted); }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-bottom: 10px; }
.tool { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.tool h4 { margin: 0 0 2px; }
.tool p { margin: 0 0 6px; }
.tool input[type=number] { width: 6em; }
.hex, .json { background: var(--surface-2); border-radius: 6px; padding: 10px; overflow: auto; max-height: 50vh; font: 12px/1.35 ui-monospace, Consolas, monospace; }
.checks h3 { margin: 12px 0 4px; font-size: 13px; color: var(--ink-2); }
.check { display: grid; grid-template-columns: 58px 1fr; gap: 8px; padding: 2px 0; }
.st { font-size: 11px; font-weight: 700; border-radius: 4px; text-align: center; padding: 1px 0; height: fit-content; }
.st.Pass { color: var(--good-text); border: 1px solid var(--good); }
.st.Fail { color: #fff; background: var(--critical); }
.st.Warn { color: #000; background: var(--warning); }
.st.Info { color: var(--ink-2); border: 1px solid var(--axis); }
.check .d { color: var(--ink-2); word-break: break-word; }
.verdict { font-weight: 600; margin: 4px 0 8px; }
.verdict.ok { color: var(--good-text); }
.verdict.bad { color: var(--critical); }
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink); width: min(760px, 94vw); padding: 18px 20px; }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h2 { margin-top: 0; }
dialog .field input { width: 100%; }
dialog .chk { display: flex; margin: 8px 0; white-space: normal; }
#exResult { max-height: 50vh; overflow: auto; margin-top: 10px; }
.dlgbtns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--surface); padding: 8px 14px; border-radius: 8px; max-width: 90vw; white-space: pre-wrap;
}
.toast.err { background: var(--critical); color: #fff; }
h3 { font-size: 14px; margin: 16px 0 6px; }
.chk.strong { font-weight: 600; }
/* ---- web: accounts & credits */
a { color: var(--accent); }
a.brand { color: var(--ink); text-decoration: none; }
body.busy, body.busy * { cursor: progress !important; }
body.signedout .actions > button { display: none; }
.authwrap { display: grid; place-items: center; min-height: 75vh; }
.authcard { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 24px 28px; text-align: center; }
.authcard h1 { margin: 4px 0 0; }
.authcard h2 { font-size: 18px; margin: 18px 0 10px; }
.authcard form, .authcard .authview { text-align: left; }
.authcard .field { margin-bottom: 10px; }
.authcard .field input { width: 100%; padding: 7px 9px; }
.authcard input[type=email], .authcard input[type=password] { background: var(--surface); border: 1px solid var(--border); border-radius: 5px; }
.authcard .terms { white-space: normal; align-items: flex-start; margin: 6px 0 12px; }
.authcard p.small { text-align: center; }
button.wide { width: 100%; padding: 8px; margin-top: 4px; }
.authmsg { margin-top: 12px; padding: 8px 10px; border-radius: 6px; background: var(--surface-2); text-align: left; white-space: pre-wrap; }
.authmsg.err { background: var(--critical); color: #fff; }
#captchaBox { margin: 8px 0; }
.account { display: inline-flex; gap: 6px; align-items: center; }
button.credits b { font-variant-numeric: tabular-nums; }
button.credits.nocredits { border-color: var(--critical); color: var(--critical); }
.footer { text-align: center; padding: 16px; }
.footer a { color: var(--muted); }
.excost { padding: 8px 10px; border-radius: 6px; background: var(--surface-2); }
.excost.ok { color: var(--good-text); }
.excost.bad { color: var(--critical); }
.packs { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 12px 0; }
.pack { border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.packcredits { font-size: 18px; font-weight: 700; }
.packprice { font-size: 22px; font-weight: 700; color: var(--accent); }
.packwas { text-decoration: line-through; color: var(--muted); font-size: 13px; }
.pack .button { margin-top: 8px; }
a.button { display: inline-block; padding: 6px 16px; border-radius: 6px; text-decoration: none; border: 1px solid var(--border); background: var(--surface); color: var(--ink); }
a.button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.notice { padding: 8px 10px; border-left: 3px solid var(--warning); background: var(--surface-2); }
#devBar:empty { display: none; }
#devBar { position: fixed; right: 12px; bottom: 12px; z-index: 30; background: #222; color: #eee; padding: 10px; border-radius: 8px; font-size: 12px; max-width: 320px; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
#devBar button { font-size: 12px; padding: 3px 7px; margin: 2px; color: #111; background: #eee; }
.evpanel { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.evpanel .head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.evpanel .head b { margin-right: 6px; }
.evpanel table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
.evpanel td, .evpanel th { padding: 2px 10px 2px 0; text-align: left; white-space: nowrap; }
.evpanel th { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.evpanel .diff { color: var(--critical); }
.evpanel .same { color: var(--good-text); }
.readout { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 10px; font-variant-numeric: tabular-nums; }
.readout span { color: var(--muted); font-size: 12px; margin-right: 4px; }
td.meas { color: var(--ink-2); }
select { background: var(--surface); border: 1px solid var(--border); border-radius: 5px; padding: 3px 4px; }
