:root {
  --ink: #1d2a31;
  --muted: #5a6a72;
  --line: #dfe5e8;
  --soft: #f4f6f7;
  --panel: #ffffff;
  --water: #1f6fb2;
  --flag: #c92a2a;
  --warn: #e8890c;
  --canal: #2f8f8a;
  --cb-low: #2b7a4b;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #ffffff; color: var(--ink); font: 15px/1.45 var(--font); }
a { color: var(--water); }

#map { position: absolute; inset: 0 0 0 380px; }

#panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: 380px; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line); padding: 18px 20px 24px;
}
h1 { font-size: 22px; line-height: 1.2; margin: 0 0 4px; font-weight: 700; }
.sub { margin: 0 0 14px; color: var(--muted); }

.notice {
  background: #fff8e6; border: 1px solid #f0dca8; border-radius: 6px; padding: 10px 12px;
  font-size: 14px; margin-bottom: 14px;
}
.notice a { display: inline-block; margin-top: 4px; }

.modes { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-bottom: 12px; }
.modes button {
  flex: 1; border: 0; background: var(--soft); padding: 8px; font: 600 15px var(--font); color: var(--muted); cursor: pointer;
}
.modes button.on { background: var(--water); color: #fff; }

section p { margin: 0 0 10px; }
.flag-key { color: var(--flag); font-weight: 600; }
.hint { font-size: 14px; color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 14px; }
.stats div { background: var(--soft); border-radius: 6px; padding: 8px 10px; }
.stats b { display: block; font-size: 20px; line-height: 1.1; }
.stats span { font-size: 13px; color: var(--muted); }

.rain-label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=range] { width: 100%; accent-color: var(--water); }
.ticks { position: relative; height: 34px; margin: 0 8px 6px; font-size: 11.5px; color: var(--muted); }
.ticks span { position: absolute; transform: translateX(-50%); text-align: center; line-height: 1.15; white-space: nowrap; }
.ticks span::before { content: ""; display: block; width: 1px; height: 6px; background: var(--muted); margin: 0 auto 2px; }

.info { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; margin-bottom: 12px; }
.info h2 { font-size: 17px; margin: 0 0 6px; }
.info .close { float: right; border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }
.info table { width: 100%; border-collapse: collapse; font-size: 14px; }
.info td { padding: 3px 0; border-bottom: 1px solid var(--soft); vertical-align: top; }
.info td:last-child { text-align: right; font-weight: 600; }
.info .note { font-size: 13px; color: var(--muted); margin-top: 8px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 13px; font-weight: 600; }
.pill.red { background: #fde8e8; color: var(--flag); }
.pill.green { background: #e3f3e8; color: var(--cb-low); }
.pill.gray { background: var(--soft); color: var(--muted); }

.profile { margin-top: 10px; }
.profile svg { width: 100%; height: auto; display: block; touch-action: none; }
.profile .cap { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; }

.layers { margin: 4px 0 12px; }
.layers summary { font-weight: 600; cursor: pointer; margin-bottom: 6px; }
.layers label { display: block; padding: 2px 0; cursor: pointer; }
.layers small { color: var(--muted); }

.legend { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.ramp { height: 10px; border-radius: 3px; background: linear-gradient(90deg, #cfe8f3 0%, #8cc4e3 10%, #4f9cd0 20%, #1f6fb2 40%, #0d4a8a 60%, #062f5e 100%); }
.ramp-labels { display: flex; justify-content: space-between; margin: 2px 0 8px; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; }
.keys i { display: inline-block; width: 16px; height: 10px; margin-right: 6px; vertical-align: middle; }
.k-flag { background: var(--flag); height: 4px !important; }
.k-cb-low { background: var(--cb-low); border-radius: 50%; width: 9px !important; height: 9px !important; }
.k-cb { background: #fff; border: 1.5px solid #6b7a82; border-radius: 50%; width: 9px !important; height: 9px !important; }
.k-canal { background: var(--canal); height: 4px !important; }
.k-pump { background: var(--canal); width: 10px !important; border: 2px solid #fff; outline: 1px solid var(--canal); }
.k-hood { border-top: 2px dashed var(--ink); height: 0 !important; }

footer { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }
footer a { display: block; margin-top: 4px; }

#readout {
  position: absolute; right: 10px; bottom: 34px; background: rgba(255,255,255,0.94); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 9px; font-size: 13px; pointer-events: none;
}

.maplibregl-ctrl-attrib { font-size: 11px; }

@media (max-width: 760px) {
  #map { inset: 0 0 46vh 0; }
  #panel { top: auto; height: 46vh; width: 100%; border-right: 0; border-top: 1px solid var(--line); padding: 14px 16px 20px; }
  h1 { font-size: 19px; }
  #readout { bottom: calc(46vh + 30px); }
}

/* methodology page */
.doc { max-width: 760px; margin: 0 auto; padding: 28px 16px 60px; }
.doc h1 { font-size: 28px; }
.doc h2 { font-size: 20px; margin-top: 30px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.doc table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.doc th, .doc td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { background: var(--soft); }
.doc .back { display: inline-block; margin-bottom: 12px; }
.doc code { background: var(--soft); padding: 1px 4px; border-radius: 3px; font-size: 13.5px; }
.doc .notice { font-size: 15px; }
