:root {
  --surface: #ffffff;
  --surface-2: #f4f3f0;
  --ink: #1f1f1d;
  --ink-2: #5c5b57;
  --line: #d9d7d2;
  --accent: #eb6834;
  --accent-ink: #ffffff;
  --find: #2d1b4e;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #222220;
    --surface-2: #2d2d2a;
    --ink: #ecebe7;
    --ink-2: #a9a7a1;
    --line: #45443f;
    --find: #2d1b4e;
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --surface: #222220;
  --surface-2: #2d2d2a;
  --ink: #ecebe7;
  --ink-2: #a9a7a1;
  --line: #45443f;
  --find: #2d1b4e;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--surface-2); }
#map { position: fixed; inset: 0; }

button { font: inherit; color: inherit; cursor: pointer; }
.icon {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  width: 36px; height: 36px; font-size: 20px; line-height: 1; padding: 0;
}

#panel {
  position: absolute; top: 12px; left: 12px; width: 300px; max-width: calc(100vw - 24px);
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px;
}
#panel header { display: flex; align-items: center; justify-content: space-between; }
#panel h1 { font-size: 16px; margin: 0; }
#panel-toggle { width: 28px; height: 28px; font-size: 16px; }
#panel-body { margin-top: 10px; display: grid; gap: 10px; }
#panel.collapsed #panel-body { display: none; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 7px 4px; border-right: 1px solid var(--line); }
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

#legend-label { color: var(--ink-2); margin-bottom: 4px; }
#legend-bar { height: 10px; border-radius: 5px; }
#legend-ticks { position: relative; height: 16px; color: var(--ink-2); font-size: 12px; }
#legend-ticks span { position: absolute; transform: translateX(-50%); top: 2px; white-space: nowrap; }
#legend-ticks span:first-child { transform: none; }
#legend-ticks span:last-child { transform: translateX(-100%); }

.check { display: flex; align-items: center; gap: 8px; }
.check input { width: 16px; height: 16px; margin: 0; }
.check > span { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--find); border: 1.5px solid #fff; box-shadow: 0 0 0 1px var(--find); }

#notes { margin: 0; color: #9c3510; }
.hint { margin: 0; color: var(--ink-2); font-size: 12px; }
details.hint p { margin: 4px 0 0; }
.hint a { color: var(--ink); }
details.hint summary { cursor: pointer; }

#timebar {
  position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px)); display: flex; align-items: center; gap: 8px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 10px;
}
#date-wrap { flex: 1; display: grid; gap: 2px; }
#date-label { text-align: center; font-weight: 600; }
#date-slider { width: 100%; accent-color: var(--accent); }

#error {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 24px);
  background: #fde6da; color: #6b2409; border-radius: 8px; padding: 8px 12px; box-shadow: var(--shadow);
}

.maplibregl-popup-content { background: var(--surface); color: var(--ink); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-popup-close-button { color: var(--ink-2); font-size: 18px; }
.popup h2 { font-size: 14px; margin: 0 0 6px; }
.popup table { border-collapse: collapse; }
.popup td { padding: 1px 0; }
.popup td:last-child { text-align: right; padding-left: 12px; font-variant-numeric: tabular-nums; }
.popup .muted { color: var(--ink-2); }
.popup a { color: var(--find); }

@media (max-width: 600px) {
  #panel { width: calc(100vw - 24px); }
  #timebar { bottom: 54px; }
  .maplibregl-ctrl-top-right { top: auto; bottom: 110px; }
}
