:root {
  --bg: #ffffff;
  --fg: #1d1d1f;
  --muted: #6b6b70;
  --line: #d8d8dc;
  --accent: #e8590c;
  --seg-on: #1d1d1f;
  --seg-on-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f22;
    --fg: #f2f2f4;
    --muted: #a1a1a8;
    --line: #3a3a40;
    --seg-on: #f2f2f4;
    --seg-on-fg: #1d1d1f;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--fg); background: var(--bg); }
#map { position: absolute; inset: 0; }

.panel {
  position: absolute; top: 12px; left: 12px; width: 320px; max-height: calc(100% - 24px);
  overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); z-index: 2;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panel.collapsed #panel-body { display: none; }
.panel.collapsed .panel-head { margin-bottom: 0; }
.panel-head strong { cursor: default; }

button, .button {
  font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; display: inline-block;
}
button:hover, .button:hover { border-color: var(--muted); }
.icon { padding: 2px 10px; }
.row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.seg { flex: 1 1 auto; padding: 6px 4px; }
.seg.on { background: var(--seg-on); color: var(--seg-on-fg); border-color: var(--seg-on); }

.slider { display: block; margin: 10px 0; }
.slider span { display: block; color: var(--muted); margin-bottom: 2px; }
.slider input { width: 100%; }

.legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-top: 4px; }
.ramp { flex: 1; height: 10px; border-radius: 3px;
  background: linear-gradient(to right, #000004, #420a68, #932667, #dd513a, #fca50a, #fcffa4); }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0; }

#search { position: relative; }
#search-input { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--bg); color: var(--fg); }
#search-results { position: absolute; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 0;
  list-style: none; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  max-height: 240px; overflow-y: auto; z-index: 3; }
#search-results li { padding: 8px 10px; cursor: pointer; }
#search-results li:hover, #search-results li.active { background: rgba(127, 127, 127, 0.15); }

details summary { cursor: pointer; margin-top: 8px; font-weight: 600; }
#zone-list { list-style: none; padding: 0; margin: 6px 0; }
#zone-list li { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line); }
#zone-list li span { flex: 1; cursor: pointer; }
#zone-list li button { padding: 2px 8px; font-size: 12px; }

.maplibregl-popup-content { color: #1d1d1f; font-size: 13px; min-width: 220px; }
.popup h3 { margin: 0 0 2px; font-size: 14px; }
.popup .sub { color: #6b6b70; margin-bottom: 6px; }
.popup table { border-collapse: collapse; width: 100%; }
.popup th, .popup td { text-align: right; padding: 2px 4px; }
.popup th:first-child, .popup td:first-child { text-align: left; }
.popup .note { color: #b54708; font-size: 12px; margin-top: 6px; }

@media (max-width: 600px) {
  .panel { top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 55%;
    border-radius: 12px 12px 0 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .maplibregl-ctrl-bottom-right { margin-bottom: 56px; }
}
