:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-1-hover: #1c5cab;
  --seq-hi: #104281;
  --wash: rgba(42, 120, 214, 0.08);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-hover: #6da7ec;
    --seq-hi: #6da7ec;
    --wash: rgba(57, 135, 229, 0.12);
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-1-hover: #6da7ec;
  --seq-hi: #6da7ec;
  --wash: rgba(57, 135, 229, 0.12);
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--series-1); text-underline-offset: 2px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px 48px; }

/* Header */
.top {
  display: flex; flex-wrap: wrap; gap: 16px 32px;
  justify-content: space-between; align-items: flex-end;
  padding: 32px 0 20px;
}
.top > div { max-width: 720px; }
.eyebrow { margin: 0 0 4px; font-size: 13px; color: var(--text-secondary); letter-spacing: 0.02em; }
h1 { margin: 0; font-size: 30px; line-height: 1.15; font-weight: 650; letter-spacing: -0.01em; }
.lede { margin: 10px 0 0; color: var(--text-secondary); max-width: 65ch; }
.updated { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-secondary); text-align: right; }

/* Filters: one row above everything they scope */
.filters {
  position: sticky; top: 0; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end;
  padding: 12px 0; margin-bottom: 8px;
  background: var(--page);
  border-bottom: 1px solid var(--grid);
}
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-secondary); }
.field.grow { flex: 1 1 200px; }
.field.custom { flex-direction: row; gap: 8px; }
.field.custom label { display: flex; flex-direction: column; gap: 3px; }
.field[hidden], .custom[hidden] { display: none; }
select, input[type="date"], input[type="search"] {
  font: inherit; font-size: 14px; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 10px; min-height: 36px; max-width: 100%;
}
input[type="search"] { width: 100%; }
select:focus-visible, input:focus-visible, button:focus-visible, [tabindex]:focus-visible, a:focus-visible {
  outline: 2px solid var(--series-1); outline-offset: 2px;
}
button { font: inherit; cursor: pointer; }
.ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; min-height: 36px;
}
.ghost:hover { background: var(--wash); color: var(--text-primary); }
.ghost.small { font-size: 12px; padding: 4px 10px; min-height: 28px; }

.status { color: var(--text-secondary); padding: 24px 0; }
.status:empty { display: none; }

/* Stat tiles */
.stats {
  display: grid; gap: 12px; margin: 16px 0;
  grid-template-columns: 1.4fr repeat(3, 1fr);
}
.tile, .card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
}
.tile { padding: 16px 18px; min-width: 0; }
.tile .label { font-size: 13px; color: var(--text-secondary); }
.tile .value { font-size: 30px; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.tile .value.small { font-size: 20px; line-height: 1.3; padding-top: 6px; }
.tile.hero .value { font-size: 52px; line-height: 1.05; letter-spacing: -0.02em; }
.tile .sub { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* Cards */
.card { padding: 18px 20px; margin-bottom: 12px; min-width: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid .card { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.grid + .card { margin-top: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
h2 { margin: 0; font-size: 17px; font-weight: 620; }
h3 { margin: 20px 0 8px; font-size: 14px; font-weight: 600; }
.note { margin: 2px 0 0; font-size: 13px; color: var(--text-secondary); }
.foot { margin: 10px 0 0; font-size: 12px; color: var(--text-secondary); }

/* Time chart */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--series-1); outline-offset: 4px; border-radius: 4px; }
.axis text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
.bar { fill: var(--series-1); }
.bar.partial { fill-opacity: 0.45; }
.bar.on { fill: var(--series-1-hover); }
.hit { fill: transparent; cursor: default; }
.hit.on { fill: var(--wash); }

/* Horizontal bars (category, disposition, location) */
.bars { display: flex; flex-direction: column; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: minmax(120px, 40%) 1fr 3.5em; align-items: center; gap: 10px;
  padding: 4px 6px; margin: 0 -6px; border-radius: 6px;
  background: none; border: 0; color: inherit; text-align: left; font-size: 13px; width: calc(100% + 12px);
}
.bar-row.clickable:hover, .bar-row.clickable:focus-visible { background: var(--wash); }
.bar-row .name { color: var(--text-primary); overflow-wrap: anywhere; line-height: 1.3; }
.bar-row .track { height: 14px; position: relative; }
.bar-row .fill {
  position: absolute; left: 0; top: 0; bottom: 0; min-width: 2px;
  background: var(--series-1); border-radius: 0 4px 4px 0;
}
.bar-row.dim .fill { opacity: 0.3; }
.bar-row.sel .name { font-weight: 650; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-secondary); }

/* Heatmap */
.heat { display: grid; grid-template-columns: 34px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 11px; max-width: 900px; }
.heat .dow { color: var(--text-muted); align-self: center; }
.heat .hr { color: var(--text-muted); text-align: left; white-space: nowrap; font-variant-numeric: tabular-nums; height: 16px; }
.heat .cell { height: 22px; border-radius: 3px; }
.heat .cell:hover, .heat .cell:focus-visible { outline: 2px solid var(--text-primary); outline-offset: -1px; }
.scale { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--text-secondary); }
.scale .ramp {
  width: 120px; height: 10px; border-radius: 3px;
  background: linear-gradient(90deg, color-mix(in oklab, var(--seq-hi) 6%, var(--surface-1)), var(--seq-hi));
}

/* Tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 7px 10px 7px 0; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data th { font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
table.data th button {
  background: none; border: 0; padding: 0; color: inherit; font-weight: inherit; font-size: inherit;
}
table.data th button[aria-sort]::after { content: " ↓"; }
table.data th button[aria-sort="ascending"]::after { content: " ↑"; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.when { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.muted { color: var(--text-secondary); }
#list-table { min-width: 860px; }
#addr-table td:first-child button {
  background: none; border: 0; padding: 0; color: var(--series-1); text-align: left; font-size: inherit;
  text-decoration: underline; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}
.table-view { max-height: 360px; overflow: auto; }
.more { margin-top: 12px; }

.about ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-secondary); max-width: 80ch; }
.about li { margin-bottom: 8px; }
.about strong { color: var(--text-primary); font-weight: 600; }

/* Tooltip: value leads, label follows */
.tooltip {
  position: fixed; z-index: 20; pointer-events: none;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); font-size: 12px; max-width: 240px;
}
.tooltip .tv { font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 6px; }
.tooltip .tv .key { width: 12px; height: 2px; background: var(--series-1); border-radius: 1px; }
.tooltip .tl { color: var(--text-secondary); margin-top: 2px; }

@media (max-width: 900px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .tile.hero, .stats .tile:last-child { grid-column: 1 / -1; }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  h1 { font-size: 24px; }
  .updated { text-align: left; }
  .filters { position: static; }
  .field { flex: 1 1 140px; }
  .field.custom { flex-basis: 100%; }
  .tile.hero .value { font-size: 44px; }
  .tile .value { font-size: 24px; }
  .card { padding: 14px; }
  .heat { grid-template-columns: 28px repeat(24, minmax(0, 1fr)); gap: 1px; }
  .heat .hr { font-size: 9px; }
  .bar-row { grid-template-columns: minmax(96px, 42%) 1fr 3em; }
}
