:root {
  /* ---- Base palette ---- */
  --bg: #ffffff;
  --fg: #1a1d21;
  --muted: #5b6470;
  --panel: #f5f6f8;
  --border: #d5d9df;
  --accent: #0b6bcb;

  /* ---- Status & notifications ---- */
  --note-bg: #fff4d6;
  --note-fg: #4a3500;
  --note-border: #e8c766;

  /* ---- Status colors ---- */
  --good: #11692e;
  --bad: #a4260b;
  --few-bg: #e8ebef;

  /* ---- Type scale (6 steps) ---- */
  --font-size-xs: 0.70rem;
  --font-size-sm: 0.80rem;
  --font-size-base: 0.90rem;
  --font-size-lg: 1.00rem;
  --font-size-xl: 1.05rem;
  --font-size-2xl: 1.15rem;

  /* ---- Spacing scale (4px base) ---- */
  --space-xs: 2px;
  --space-sm: 4px;
  --space-md: 8px;
  --space-lg: 12px;
  --space-xl: 16px;

  /* ---- Radius ---- */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* ---- Focus ring ---- */
  --focus-width: 2px;
  --focus-offset: 2px;
  --focus-color: var(--accent);

  /* ---- Touch targets (minimum 44px) ---- */
  --min-touch-height: 44px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --fg: #e6e9ed;
    --muted: #9aa4b0;
    --panel: #1d2127;
    --border: #343a43;
    --accent: #6cb2ff;

    --note-bg: #3a2f10;
    --note-fg: #f5deaa;
    --note-border: #7a6320;

    --good: #6fd68c;
    --bad: #ff9a80;
    --few-bg: #2a2f37;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }

.top, main, footer {
  max-width: 62rem;
  margin: 0 auto;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
}
.top { padding-top: max(14px, env(safe-area-inset-top)); }
.back { display: inline-block; padding: 8px 0; min-height: var(--min-touch-height); }
h1 { font-size: 1.55rem; line-height: 1.2; margin: 4px 0 8px; }
h2 { font-size: 1.2rem; line-height: 1.25; margin: 0 0 8px; }
.lede { color: var(--muted); margin: 0 0 12px; }
p, li { overflow-wrap: anywhere; }
ul { padding-left: 1.3rem; }
li { margin: 4px 0; }
code {
  font: 0.88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}
section { margin: 0 0 26px; }
.note {
  background: var(--note-bg);
  color: var(--note-fg);
  border: 1px solid var(--note-border);
  border-radius: 8px;
  padding: 12px 14px;
}
.note a { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin: 4px 0 8px; }
.controls label { display: inline-flex; gap: 8px; align-items: center; min-height: var(--min-touch-height); }
select {
  font: inherit;
  color: var(--fg);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  min-height: var(--min-touch-height);
}
input[type="checkbox"] { width: 20px; height: 20px; }
.status { color: var(--muted); margin: 4px 0 8px; min-height: 1.5em; }

.wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
thead th { background: var(--panel); position: sticky; top: 0; white-space: nowrap; padding: 0; }
th.num, td.num { text-align: right; }
th button {
  all: unset;
  box-sizing: border-box;
  display: block;
  width: 100%;
  padding: 10px 10px;
  min-height: var(--min-touch-height);
  cursor: pointer;
  font-weight: 600;
  color: var(--fg);
}
th.num button { text-align: right; }
th button:hover { background: var(--border); }
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
th[aria-sort="ascending"] button::after { content: " \25B2"; font-size: 0.75em; }
th[aria-sort="descending"] button::after { content: " \25BC"; font-size: 0.75em; }
th[aria-sort="none"] button::after { content: " \2195"; font-size: 0.75em; color: var(--muted); }
td.route { min-width: 7rem; }
.sub { display: block; color: var(--muted); font-size: 0.82rem; line-height: 1.3; }
.tag {
  display: inline-block;
  font-size: 0.72rem;
  line-height: 1.3;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 7px;
  margin-left: 4px;
  vertical-align: middle;
  background: var(--panel);
  color: var(--muted);
}
.few-tag { background: var(--few-bg); }
.infer-tag { border-color: var(--note-border); color: var(--note-fg); background: var(--note-bg); }
tr.few td { color: var(--muted); }
tr.few td.route { color: var(--fg); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.small { color: var(--muted); font-size: 0.9rem; }
footer { padding-top: 8px; padding-bottom: max(24px, env(safe-area-inset-bottom)); color: var(--muted); font-size: 0.9rem; }

@media (max-width: 560px) {
  .narrow-hide { display: none; }
  table { table-layout: fixed; }
  thead th:first-child { width: 40%; }
  th button { white-space: normal; line-height: 1.25; }
  .sub { overflow-wrap: anywhere; }
  th, td { padding: 8px 6px; }
  th button { padding: 10px 6px; font-size: 0.9rem; }
  td.route { min-width: 0; }
  h1 { font-size: 1.35rem; }
}
