:root {
  --bg: #ffffff;
  --fg: #1d2330;
  --muted: #5d6676;
  --border: #d9dde4;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  --c1: #1a9850; --c2: #91cf60; --c3: #fee08b; --c4: #fc8d59; --c5: #d73027;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c2029; --fg: #e8eaee; --muted: #a2a9b6; --border: #353b47; --shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: absolute; inset: 0; }

#panel {
  position: absolute; top: 12px; left: 12px; width: 280px; max-width: calc(100% - 24px);
  background: var(--bg); color: var(--fg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); padding: 14px 16px; z-index: 2;
}
h1 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.sub { margin: 2px 0 12px; color: var(--muted); }
label { display: block; margin: 8px 0; font-weight: 500; }
select, input { display: block; width: 100%; margin-top: 4px; padding: 6px 8px; font: inherit;
  color: var(--fg); background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
#custom label { font-weight: 400; }

.legend { margin-top: 12px; }
.bar { height: 10px; border-radius: 5px;
  background: linear-gradient(to right, var(--c1), var(--c2), var(--c3), var(--c4), var(--c5)); }
.ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 3px; }
.hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

.maplibregl-popup-content { font: 13px/1.4 system-ui, sans-serif; color: #1d2330; }
.maplibregl-popup-content b { font-size: 15px; }

@media (max-width: 600px) {
  #panel { top: auto; bottom: 28px; left: 16px; right: 16px; width: auto; max-width: none; padding: 10px 12px; }
  .sub, #panel .hint:first-of-type { display: none; }
  label { margin: 6px 0; }
}
