:root {
  --bg: #f6fafc;
  --surface: #ffffff;
  --ink: #0b2545;
  --muted: #4a607a;
  --accent: #0a8fa8;
  --accent-dark: #066b7e;
  --line: #d6e4ec;
  --good: #1a9850;
  --moderate: #e6a700;
  --severe: #d73027;
  --nodata: #8a94a0;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  overflow-x: hidden;
}
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 3000; }
.skip:focus { left: 8px; top: 8px; }
a { color: var(--accent-dark); }
:focus-visible { outline: 3px solid #f0a500; outline-offset: 2px; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Header */
.top { position: sticky; top: 0; z-index: 1500; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(6px); }
.top-in { max-width: 1200px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; letter-spacing: .04em; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand-drop { width: 14px; height: 18px; background: var(--accent); border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; display: inline-block; }
.menu { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.menu a { display: inline-block; padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--ink); font-size: .92rem; font-weight: 500; }
@media (max-width: 899px) {
  .top-in { padding: 6px 12px; gap: 4px; }
  .menu { gap: 2px 4px; }
  .menu a { padding: 6px 10px; font-size: .84rem; background: #eef6f9; }
}
.menu a:hover { background: #e3f3f7; }

/* Sections */
.sec { padding: 28px 0; }
.sec-alt { background: #eaf5f9; }
.sec-map { padding-top: 16px; }
h1.h-main { margin: 4px 0 4px; font-size: clamp(1.5rem, 4.5vw, 2.3rem); line-height: 1.15; }
h1.h-main span { display: block; color: var(--accent-dark); font-weight: 600; font-size: .6em; margin-top: 2px; }
h2 { font-size: clamp(1.25rem, 3.2vw, 1.7rem); margin: 0 0 10px; }
h3 { font-size: 1.05rem; margin: 18px 0 6px; }
.lead { margin: 0 0 10px; color: var(--muted); }
.muted { color: var(--muted); }

/* Legend */
.legend { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px 14px; }
.legend li { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; font-size: .9rem; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(11,37,69,.35); flex: none; }
.dot.good { background: var(--good); } .dot.moderate { background: var(--moderate); }
.dot.severe { background: var(--severe); } .dot.nodata { background: var(--nodata); }

/* Map + card */
.map-layout { display: grid; grid-template-columns: 1fr; gap: 14px; }
.map-box { position: relative; }
#map { height: 62vh; min-height: 380px; border-radius: var(--radius); border: 1px solid var(--line); background: #dcebf1; z-index: 1; }
.map-note { margin: 8px 0 0; padding: 10px 12px; background: #fff8e1; border: 1px solid #f0d98a; border-radius: 10px; font-size: .92rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px 16px; position: relative; box-shadow: 0 6px 24px rgba(11,37,69,.12); }
.card[hidden] { display: none; }
.card-close { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #eef4f8; color: var(--ink); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.card-close:hover { background: #dce9f1; }
.card h3 { margin: 0 44px 4px 0; font-size: 1.15rem; }
.card .river { color: var(--accent-dark); font-weight: 600; font-size: .9rem; margin: 0; }
.card .desc { margin: 8px 0; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .95rem; background: #f1f6f9; border: 1px solid var(--line); }
.kv { margin: 10px 0; padding: 0; list-style: none; font-size: .95rem; }
.kv li { padding: 4px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 12px; }
.kv li span:first-child { color: var(--muted); }
.kv li span:last-child { text-align: right; font-weight: 500; }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 18px; border-radius: 12px; background: var(--accent); color: #fff; font-weight: 600; text-decoration: none; border: 0; cursor: pointer; font: inherit; font-weight: 600; }
.btn:hover { background: var(--accent-dark); }
.pending { margin: 10px 0 0; padding: 10px 12px; background: #fff8e1; border: 1px solid #f0d98a; border-radius: 10px; font-size: .92rem; }
.src { font-size: .88rem; color: var(--muted); margin: 8px 0; }

/* Mobile bottom sheet */
@media (max-width: 899px) {
  .card { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2000; border-radius: 18px 18px 0 0; max-height: 52vh; overflow-y: auto; padding-bottom: 20px; }
  #map { height: 66vh; }
}
@media (min-width: 900px) {
  .map-layout { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .map-layout:has(.card[hidden]) { grid-template-columns: 1fr; }
  #map { height: 70vh; }
  .card { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; }
}

/* Station list */
.river-group { margin: 20px 0 8px; }
.river-group h3 { margin: 0 0 8px; }
.river-group .overall { margin: 0 0 10px; font-size: .93rem; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.item { text-align: left; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--nodata); border-radius: 12px; padding: 12px 14px; cursor: pointer; font: inherit; color: inherit; width: 100%; min-height: 56px; }
.item:hover { border-color: var(--accent); }
.item.good { border-left-color: var(--good); } .item.moderate { border-left-color: var(--moderate); }
.item.severe { border-left-color: var(--severe); } .item.nodata { border-left-color: var(--nodata); }
.item strong { display: block; }
.item .st { font-size: .9rem; color: var(--muted); display: block; margin-top: 2px; }
.item .loc { font-size: .85rem; color: #7a5b00; display: block; margin-top: 4px; }
.item .loc.ok { color: var(--accent-dark); }

.ranges { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 10px 0 0; }
.ranges h4 { margin: 0 0 6px; font-size: .98rem; }
.ranges table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.ranges td { padding: 4px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.ranges td:last-child { text-align: right; white-space: nowrap; padding-left: 10px; }
.ranges .note { font-size: .85rem; color: var(--muted); margin: 6px 0 0; }

.empty { background: var(--surface); border: 1px dashed #9db8c7; border-radius: 12px; padding: 16px; }
.empty p { margin: 0 0 6px; }
.prot-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); counter-reset: p; }
.prot-list li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; counter-increment: p; }
.prot-list li::before { content: counter(p); display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; margin-bottom: 6px; }
.prot-list h3 { margin: 0 0 6px; }
.qa details { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 6px 0; }
.qa summary { cursor: pointer; font-weight: 600; min-height: 36px; display: flex; align-items: center; }

/* Leaflet marker */
.marker-target { display: grid; place-items: center; }
.mk { width: 25px; height: 25px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(11,37,69,.55), 0 2px 6px rgba(0,0,0,.35); cursor: pointer; }
.mk.good { background: var(--good); } .mk.moderate { background: var(--moderate); }
.mk.severe { background: var(--severe); } .mk.nodata { background: var(--nodata); }
.mk.active { transform: scale(1.2); box-shadow: 0 0 0 3px var(--ink), 0 2px 8px rgba(0,0,0,.4); }

.foot { padding: 20px 0 90px; font-size: .88rem; color: var(--muted); border-top: 1px solid var(--line); }
@media (min-width: 900px) { .foot { padding-bottom: 24px; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
