:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --ink: #17191e;
  --ink-2: #3a3e47;
  --muted: #5d636e;
  --line: #d9dad6;
  --line-2: #e7e7e3;
  --accent: #2c46b8;
  --accent-ink: #ffffff;
  --accent-soft: #e8ecfa;
  --ok: #1d6f46;
  --ok-bg: #e5f2ea;
  --bad: #b3261e;
  --bad-bg: #fbe9e7;
  --warn: #7c5400;
  --warn-bg: #f8efd9;
  --bar: #2c46b8;
  --focus: #2c46b8;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121418; --surface: #1a1d22; --surface-2: #20242a; --ink: #e9eaee; --ink-2: #c9ccd3; --muted: #9ba1ad;
    --line: #2f343c; --line-2: #262a31; --accent: #8fa3ff; --accent-ink: #0d1020; --accent-soft: #232a45;
    --ok: #6cc996; --ok-bg: #16291f; --bad: #ff8f84; --bad-bg: #321a18; --warn: #e3b75e; --warn-bg: #2c2413;
    --bar: #8fa3ff; --focus: #8fa3ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121418; --surface: #1a1d22; --surface-2: #20242a; --ink: #e9eaee; --ink-2: #c9ccd3; --muted: #9ba1ad;
  --line: #2f343c; --line-2: #262a31; --accent: #8fa3ff; --accent-ink: #0d1020; --accent-soft: #232a45;
  --ok: #6cc996; --ok-bg: #16291f; --bad: #ff8f84; --bad-bg: #321a18; --warn: #e3b75e; --warn-bg: #2c2413;
  --bar: #8fa3ff; --focus: #8fa3ff; color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.55 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
.mono, code, input, textarea, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* header */
.top { border-bottom: 1px solid var(--line); background: var(--surface); }
.top-in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .02em; color: var(--ink); text-decoration: none; font-size: 15px; }
.brand-mark { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 5px; background: var(--accent); color: var(--accent-ink); font: 600 15px var(--mono); }
.brand-sep { color: var(--muted); font-weight: 400; }
.top-nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.top-nav a { color: var(--ink-2); text-decoration: none; font-size: 14px; padding: 6px 8px; border-radius: 4px; }
.top-nav a:hover, .top-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.theme-btn { font: 500 13px var(--sans); color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 4px; padding: 5px 9px; cursor: pointer; margin-left: 4px; }

/* intro */
.intro { padding: 28px 0 8px; }
h1 { font-size: clamp(26px, 6.4vw, 38px); line-height: 1.15; letter-spacing: -.01em; margin: 0 0 12px; font-weight: 700; }
.lede { margin: 0 0 12px; color: var(--ink-2); max-width: 64ch; }
.note-line { margin: 0; font-size: 14px; color: var(--muted); display: flex; gap: 8px; align-items: baseline; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; transform: translateY(-1px); }

/* tabs */
.tabs { display: flex; gap: 0; margin: 20px 0 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { font: 600 15px var(--sans); color: var(--muted); background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.panel { padding: 16px 0 8px; }

/* cards and forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.fields { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.fields.f2 { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field.wide { grid-column: 1 / -1; }
input, select, textarea { width: 100%; min-width: 0; font-size: 16px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 9px 10px; }
select { font-family: var(--sans); font-size: 15px; }
textarea { resize: vertical; line-height: 1.5; font-size: 14px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: 13.5px; color: var(--muted); margin: 10px 0 0; }
.ex-lines { list-style: none; margin: 6px 0 0; padding: 0; font: 13px/1.6 var(--mono); color: var(--ink-2); }
.ex-lines li { overflow-wrap: anywhere; }
.options { margin-top: 12px; border-top: 1px solid var(--line-2); padding-top: 10px; }
.options summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.options .fields { margin-top: 10px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.btn { font: 600 15px var(--sans); padding: 9px 16px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.examples { font-size: 13.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.link { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-family: var(--mono); font-size: 13px; }
.form-error { color: var(--bad); font-size: 14px; margin: 10px 0 0; }

/* results */
.result { margin-top: 14px; }
.verdict { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 10px; }
.verdict.ok { border-left-color: var(--ok); }
.verdict.bad { border-left-color: var(--bad); }
.verdict.na { border-left-color: var(--muted); }
.verdict-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 6px; }
.verdict-head h3 { margin: 0; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.pill { display: inline-block; font: 600 14px var(--sans); padding: 2px 10px; border-radius: 999px; }
.pill.ok { color: var(--ok); background: var(--ok-bg); }
.pill.bad { color: var(--bad); background: var(--bad-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.na { color: var(--muted); background: var(--surface-2); }
.sentence { margin: 0; color: var(--ink-2); }
.near { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.near b { font-family: var(--mono); color: var(--ink); font-weight: 500; }
.conv-table { margin-top: 10px; border-collapse: collapse; font-size: 13.5px; }
.conv-table th, .conv-table td { text-align: left; padding: 3px 14px 3px 0; font-weight: 400; }
.conv-table th { color: var(--muted); }
.flag { margin: 10px 0 0; padding: 8px 10px; border-radius: 5px; background: var(--warn-bg); color: var(--warn); font-size: 14px; }
.ok-t { color: var(--ok); font-weight: 600; } .bad-t { color: var(--bad); font-weight: 600; } .na-t { color: var(--muted); }

/* batch table */
.tally { margin: 0 0 8px; font-size: 14.5px; color: var(--ink-2); }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); max-width: 100%; }
table.res { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.res th, table.res td { padding: 7px 10px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: top; white-space: nowrap; }
table.res th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
table.res td.num { text-align: right; }
table.res td.note { white-space: normal; min-width: 260px; color: var(--muted); font-size: 13px; }
table.res tr.row-bad td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
table.res tr.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
table.res tr:last-child td { border-bottom: 0; }

/* sprite */
.status { font-size: 14.5px; color: var(--ink-2); margin-bottom: 10px; }
.status p { margin: 0 0 6px; }
.hists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.hist { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 8px 6px; min-width: 0; }
.hist svg { display: block; width: 100%; height: auto; }
.hist .cap { font: 12px/1.35 var(--mono); color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.hist .bar { fill: var(--bar); }
.hist .axis { stroke: var(--line); }
.hist .tick { fill: var(--muted); font: 11px var(--mono); }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -1px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* caution + footer */
.caution { margin: 28px 0 8px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.caution h2 { margin: 0 0 6px; font-size: 16px; }
.caution p { margin: 0; color: var(--ink-2); font-size: 15px; }
.foot { margin-top: 28px; border-top: 1px solid var(--line); background: var(--surface); }
.foot-in { display: grid; gap: 16px; padding-top: 18px; padding-bottom: 24px; font-size: 13.5px; color: var(--muted); }
.foot-in p { margin: 0 0 6px; }
.foot-h { font-weight: 600; color: var(--ink-2); }
.foot a { overflow-wrap: anywhere; }

/* method pages */
.prose { max-width: 70ch; padding: 24px 0 8px; }
.prose h1 { margin-bottom: 8px; }
.prose h2 { font-size: 19px; margin: 26px 0 8px; }
.prose p, .prose li { color: var(--ink-2); }
.prose .cite { font-size: 14.5px; padding: 12px 14px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 0 var(--r) var(--r) 0; }
.prose .worked { font-family: var(--mono); font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; overflow-x: auto; white-space: pre; line-height: 1.6; }
.prose .back { font-size: 14px; }

@media (min-width: 640px) {
  .fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fields.f3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fields.f2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 20px; }
  .hists { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .foot-in { grid-template-columns: 1.3fr 1fr; gap: 32px; }
}
@media (min-width: 900px) { .hists { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
