:root {
  --ink: #1b1a16; --ink-2: #5c5b55; --ink-3: #8a8982;
  --surface: rgba(243, 242, 238, .94); --surface-solid: #f3f2ee; --surface-2: #e6e4de; --border: rgba(0, 0, 0, .1);
  --accent: #1c5cab; --accent-2: #2a78d6; --on-accent: #ffffff; --error: #a3262c;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 12px 32px rgba(0,0,0,.14);
  --map-filter: brightness(.94) saturate(1.08);
  --radius: 14px;
}
:root[data-theme="dark"], :root:not([data-theme="light"]).system-dark {
  --ink: #ecebe6; --ink-2: #aeada6; --ink-3: #7c7b75;
  --surface: rgba(24, 24, 23, .9); --surface-solid: #181817; --surface-2: #26262490; --border: rgba(255, 255, 255, .09);
  --accent: #6da7ec; --accent-2: #86b6ef; --on-accent: #0f1a2b; --error: #f08a8f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.5);
  --map-filter: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--surface-solid); color: var(--ink);
  font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; }
#map { position: absolute; inset: 0; }
#map canvas { filter: var(--map-filter); }
a { color: var(--accent); }

/* top bar */
#bar { position: absolute; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: var(--surface); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--border); z-index: 3; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 16px; letter-spacing: -.01em; }
.mark { width: 22px; height: 22px; color: var(--accent); }
.tabs { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 10px; margin-left: 6px; }
.tabs button { border: 0; background: transparent; color: var(--ink-2); font: inherit; font-weight: 600; font-size: 13px;
  padding: 5px 14px; border-radius: 8px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface-solid); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.gh { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.gh:hover { color: var(--ink); }
.theme { width: 32px; height: 32px; border: 1px solid var(--border); border-radius: 50%; background: transparent; color: var(--ink-2); cursor: pointer;
  display: grid; place-items: center; padding: 0; }
.theme:hover { color: var(--ink); border-color: var(--ink-3); }
.theme svg { width: 16px; height: 16px; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent-2); transition: width .2s; }

/* sheet */
#panel { position: absolute; top: 66px; left: 14px; width: 356px; max-width: calc(100vw - 28px); max-height: calc(100vh - 80px); overflow: auto;
  background: var(--surface); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px 16px; box-shadow: var(--shadow); z-index: 2; }
h1 { margin: 0 0 4px; font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -.015em; }
.lede { margin: 0 0 14px; color: var(--ink-2); font-size: 13.5px; }
.label { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.field { margin: 12px 0; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; }
.field-head .label { margin: 0; }
.value { font-weight: 600; font-size: 15px; }
.meta { margin: 10px 0 0; color: var(--ink-2); font-size: 12.5px; }
.load { display: block; width: 100%; margin: 2px 0 6px; padding: 9px 12px; border: 0; border-radius: 9px; background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 600; cursor: pointer; }
.load:hover { filter: brightness(1.08); }
.muted { color: var(--ink-3); font-size: 12px; }
.error { color: var(--error); font-size: 13px; }

/* time scrubber */
.scrub { -webkit-appearance: none; appearance: none; width: 100%; height: 30px; margin: 4px 0 0; background: transparent; cursor: ew-resize; }
.scrub::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent-2), var(--accent) 60%, #4b3a8a); opacity: .9; }
.scrub::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent-2), var(--accent) 60%, #4b3a8a); }
.scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px; border-radius: 50%; background: var(--surface-solid);
  border: 2.5px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.scrub::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface-solid); border: 2.5px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
.ticks { position: relative; height: 16px; margin-top: 2px; font-size: 10.5px; color: var(--ink-3); }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }

/* segmented controls and switch */
.seg { display: flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: 9px; }
.seg.wrap { flex-wrap: wrap; }
.seg label { flex: 1; text-align: center; font-size: 12.5px; font-weight: 500; color: var(--ink-2); padding: 5px 6px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.seg.wrap label { flex: 0 1 auto; padding: 5px 10px; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--surface-solid); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.switch { display: flex; align-items: center; gap: 10px; margin: 10px 0 2px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.switch input { display: none; }
.switch .knob { position: relative; width: 34px; height: 20px; border-radius: 10px; background: var(--ink-3); opacity: .5; transition: all .15s; flex: none; }
.switch .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked + .knob { background: var(--accent); opacity: 1; }
.switch input:checked + .knob::after { left: 16px; }
.switch.disabled { opacity: .45; pointer-events: none; }

/* legends, tiles, tooltip */
.legend { margin: 12px 0 0; }
.legend .bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; }
.legend .bar span { flex: 1; }
.legend .ticks-row { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.legend .cap { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 4px; }
.tile { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.tile b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.tile span { font-size: 11.5px; color: var(--ink-2); line-height: 1.35; display: block; margin-top: 3px; }
details { margin-top: 12px; font-size: 12.5px; color: var(--ink-2); }
details p { margin: 6px 0; }
summary { cursor: pointer; color: var(--ink); font-weight: 500; }
.tip { position: absolute; pointer-events: none; background: var(--surface); backdrop-filter: blur(10px); color: var(--ink); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 11px; font-size: 12.5px; box-shadow: var(--shadow); max-width: 250px; display: none; z-index: 4; }
.tip table { border-collapse: collapse; margin-top: 5px; }
.tip td { padding: 1px 8px 1px 0; color: var(--ink-2); }
.tip td:last-child { text-align: right; color: var(--ink); }
.tip tr.cur td { font-weight: 600; color: var(--ink); }
.maplibregl-marker { cursor: grab; }
.maplibregl-ctrl-top-right { top: 60px; }

@media (max-width: 560px) {
  #bar { padding: 0 12px; gap: 10px; }
  .brand span { display: none; }
  #panel { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-width: none; max-height: 56vh; border-radius: var(--radius) var(--radius) 0 0;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
  .field.two { grid-template-columns: 1fr; }
}
