.viz-root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --plan: #c9c7bf;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --serious: #ec835a;
  --critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --plan: #4a4a46;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: #f9f9f7; }
@media (prefers-color-scheme: dark) { body { background: #0d0d0d; } }
.viz-root {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text-primary);
  background: var(--page);
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  line-height: 1.45;
}
h1 { font-size: 28px; margin: 0 0 6px; font-weight: 650; }
h1 .tag { font-size: 16px; font-weight: 400; color: var(--text-secondary); margin-left: 8px; font-style: italic; }
h2 { font-size: 17px; margin: 0; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 4px; font-weight: 600; color: var(--text-secondary); }
.lede { color: var(--text-secondary); max-width: 760px; margin: 0 0 18px; }
.hint { color: var(--text-secondary); font-size: 13px; margin: 6px 0 10px; }

.controls {
  display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-end;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
}
.controls label { display: flex; flex-direction: column; font-size: 12px; color: var(--text-secondary); gap: 3px; min-width: 130px; }
.controls output { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.controls label:has(output) { flex-direction: column; }
.controls select, .controls input[type="time"] { font: inherit; font-size: 13px; padding: 3px 4px; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--axis); border-radius: 6px; }
.controls .inc-only[hidden] { display: none; }
.day { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-left: auto; }
button { font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 6px; border: 1px solid var(--axis); background: var(--surface-1); color: var(--text-primary); cursor: pointer; }
button:hover { background: var(--grid); }
button:disabled { opacity: 0.6; cursor: progress; }

.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 14px 0 8px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 26px; font-weight: 600; margin: 2px 0; }
.tile.hero .value { font-size: 48px; line-height: 1.1; }
.tile .note { font-size: 11.5px; color: var(--muted); }
.story { max-width: 900px; margin: 4px 0 18px; }

.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 14px 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-secondary); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 2px; border-radius: 1px; }
.legend i.dot { width: 10px; height: 10px; border-radius: 50%; }
.legend i.pill { width: auto; height: auto; font-style: normal; font-size: 11px; font-weight: 600; padding: 0 4px; border-radius: 4px; background: var(--serious); color: #0b0b0b; }
.legend i.plan { height: 1px; background: var(--plan); }
.legend i.inc { height: 10px; width: 12px; background: var(--serious); opacity: 0.35; }
.marey-wrap { position: relative; }
canvas { width: 100%; display: block; }
#marey-now { position: absolute; left: 0; top: 0; pointer-events: none; }
.map-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 18px; margin-top: 8px; }
.map-wrap { position: relative; }
.map-side { display: flex; flex-direction: column; gap: 10px; }
.clock { font-size: 48px; font-weight: 600; line-height: 1; }
.play { display: flex; gap: 8px; }
.play select { font: inherit; font-size: 13px; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--axis); border-radius: 6px; }
.now-stats { font-size: 13px; color: var(--text-secondary); }
.now-stats b { color: var(--text-primary); }
#late-list { margin: 0; padding-left: 20px; font-size: 13px; }
#late-list li { cursor: pointer; padding: 2px 0; }
#late-list li:hover { text-decoration: underline; }
#late-list .k { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
#map { cursor: pointer; }
.window { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
.window input { flex: 1; }
.tip {
  position: absolute; pointer-events: none; background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); max-width: 300px; z-index: 5;
}
.tip b { font-weight: 600; }
.tip .k { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.panel { position: relative; }
.sweep-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
details { margin-top: 10px; font-size: 13px; }
summary { cursor: pointer; color: var(--text-secondary); }
table { border-collapse: collapse; margin-top: 8px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 3px 10px; text-align: right; border-bottom: 1px solid var(--grid); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; }
footer { margin-top: 26px; font-size: 13.5px; color: var(--text-secondary); max-width: 900px; }
footer h2 { color: var(--text-primary); margin-bottom: 4px; }
footer li { margin: 4px 0; }
.fine { font-size: 12px; color: var(--muted); }
a { color: var(--series-1); }

@media (max-width: 800px) {
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile.hero { grid-column: span 2; }
  .sweep-grid { grid-template-columns: 1fr; }
  .map-grid { grid-template-columns: 1fr; }
  .day { margin-left: 0; }
}
