:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --card: #ffffff;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --grid: #e6e5e1;
  --axis: #c9c8c1;
  --accent: #2a78d6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --muted-series: #8a8984;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #1a1a19; --surface-2: #232321; --card: #20201e;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9a998f;
    --grid: #33332f; --axis: #4a4a45; --accent: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --muted-series: #8f8e86;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #1a1a19; --surface-2: #232321; --card: #20201e;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #9a998f;
  --grid: #33332f; --axis: #4a4a45; --accent: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --muted-series: #8f8e86;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--surface); color: var(--text-primary); }
body { font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
main { max-width: 1040px; margin: 0 auto; padding: 0 16px 64px; }
a { color: var(--accent); }

header.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 32px 0 8px; }
.brand h1 { margin: 0; font-size: clamp(28px, 5vw, 44px); line-height: 1.1; letter-spacing: -0.01em; }
.brand .sub { margin: 10px 0 0; color: var(--text-secondary); max-width: 640px; font-size: 17px; }
.controls { display: flex; gap: 6px; flex-shrink: 0; }
.controls button {
  font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--grid);
  background: var(--card); color: var(--text-secondary); cursor: pointer;
}
.controls button[aria-pressed="true"] { color: var(--text-primary); border-color: var(--text-muted); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 24px 0 8px; }
.tile { background: var(--card); border: 1px solid var(--grid); border-radius: 12px; padding: 14px 16px; }
.tile .label { color: var(--text-secondary); font-size: 14px; }
.tile .value { font-size: 30px; font-weight: 650; margin-top: 2px; }
.tile .note { color: var(--text-muted); font-size: 13px; }

section { margin-top: 44px; }
section > h2 { font-size: 24px; margin: 0 0 6px; }
section > p.lead { color: var(--text-secondary); margin: 0 0 16px; max-width: 760px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.filters select, .filters button {
  font: inherit; font-size: 14px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--grid);
  background: var(--card); color: var(--text-primary); cursor: pointer;
}
.filters button[aria-pressed="true"] { border-color: var(--text-muted); font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } header.top { flex-direction: column; } }

figure.card { margin: 0; background: var(--card); border: 1px solid var(--grid); border-radius: 12px; padding: 14px 14px 8px; min-width: 0; }
figure.card + figure.card { margin-top: 16px; }
.grid2 figure.card + figure.card { margin-top: 0; }
figure.card figcaption { font-weight: 600; margin-bottom: 2px; }
figure.card .desc { color: var(--text-secondary); font-size: 14px; margin: 0 0 8px; }

.chart { position: relative; }
.plot { position: relative; width: 100%; }
.plot svg { display: block; overflow: visible; }
.grid line { stroke: var(--grid); stroke-width: 1; }
.grid line.zero { stroke: var(--axis); }
.tick { fill: var(--text-muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.value { fill: var(--text-secondary); font-size: 12px; }
.crosshair { stroke: var(--text-muted); stroke-width: 1; }
.marker { stroke: var(--text-secondary); stroke-width: 1; }
.marker-label { fill: var(--text-secondary); font-size: 12px; }
.dot { stroke: var(--card); stroke-width: 2; }
.hit:focus { outline: none; }
.hit:focus-visible { outline: 2px solid var(--accent); }
.bar.hover { filter: brightness(1.12); }
.bar:focus-visible { outline: 2px solid var(--accent); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 2px 0; font: inherit;
  font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.legend-item[aria-pressed="false"] { opacity: 0.4; }
.legend-key { display: inline-block; width: 16px; height: 2px; border-radius: 2px; }
.legend-key.bar { width: 10px; height: 10px; border-radius: 3px; }
.legend-key.dash { background-image: linear-gradient(90deg, var(--card) 50%, transparent 50%) !important; background-size: 6px 2px; }

.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--card); border: 1px solid var(--grid);
  border-radius: 8px; padding: 8px 10px; box-shadow: 0 4px 16px rgb(0 0 0 / 0.12); min-width: 160px; font-size: 13px; }
.tip-title { color: var(--text-secondary); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.tip-key { width: 12px; height: 2px; border-radius: 2px; flex-shrink: 0; }
.tip-value { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.tip-label { color: var(--text-muted); }

.table-view { margin-top: 6px; font-size: 13px; color: var(--text-secondary); }
.table-view summary { cursor: pointer; }
.table-wrap { max-height: 260px; overflow: auto; margin-top: 6px; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
caption { text-align: left; color: var(--text-muted); padding-bottom: 4px; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--grid); }
th { color: var(--text-secondary); font-weight: 600; position: sticky; top: 0; background: var(--card); }

.board td.num, .board th.num { text-align: right; }
.board tr.best td { font-weight: 650; color: var(--text-primary); }
.callout { background: var(--surface-2); border-radius: 12px; padding: 12px 16px; color: var(--text-secondary); margin-top: 16px; }
.callout strong { color: var(--text-primary); }
.pending { color: var(--text-muted); font-style: italic; }
footer { margin-top: 56px; color: var(--text-muted); font-size: 14px; border-top: 1px solid var(--grid); padding-top: 16px; }
footer p { margin: 6px 0; }

.ask-status { color: var(--text-secondary); font-size: 14px; min-height: 1.5em; margin: 0 0 8px; }
.ask-status.error { color: var(--s8); }
.ask-note { color: var(--text-muted); font-size: 13px; margin-top: 10px; max-width: 760px; }
#ask-days { display: inline-flex; flex-wrap: wrap; gap: 6px; }
#ask .tiles { margin-top: 0; }
.stale { opacity: 0.45; transition: opacity 0.2s; }

#map { height: 440px; border-radius: 8px; z-index: 0; }
@media (max-width: 760px) { #map { height: 360px; } }
.map-card { padding: 8px; }
.map-legend { margin: 8px 4px 2px; }
.pin { display: block; border: 2px solid var(--card); box-shadow: 0 1px 4px rgb(0 0 0 / 0.25); }
.pin-bikes { background: var(--s1); border-radius: 50%; }
.pin-air { background: var(--s3); border-radius: 3px; }
.pin-weather { background: var(--s4); transform: rotate(45deg); border-radius: 2px; }
.leaflet-div-icon { background: transparent; border: 0; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text-primary); }
.leaflet-popup-content { margin: 12px 14px; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
.pop-title { font-weight: 650; margin-bottom: 2px; }
.pop-sub { color: var(--text-muted); font-size: 12px; margin-bottom: 6px; }
.pop-row { display: flex; justify-content: space-between; gap: 14px; }
.pop-row strong { font-variant-numeric: tabular-nums; }
.pop-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.pop-actions button { font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--grid); background: var(--surface-2); color: var(--text-primary); cursor: pointer; }
.legend-key.pin-shape { width: 10px; height: 10px; border: 0; box-shadow: none; }
.leaflet-container { background: var(--surface-2); font: inherit; }
.leaflet-control-attribution { font-size: 10px; }
.map-dark .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.9) saturate(0.6); }
#map:not(.map-dark) .leaflet-tile-pane { filter: saturate(0.55) brightness(1.03); }
