/* Hydrological, site styles */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-var.260c81a4759b.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-var-ext.1ad231aac0a8.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --border: #e3e8ef;
  --border-strong: #cfd7e2;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --primary: #1a6fe0;
  --primary-hover: #155dc0;
  --primary-soft: #eaf2fd;
  --focus: #1a6fe0;
  --code-bg: #111a2b;
  --code-text: #d7e3f4;
  --code-str: #9fd0ff;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 2px 8px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-lg: 0 18px 50px rgba(16, 24, 40, .18);
  --radius: 10px;
  --radius-sm: 7px;

  --tone-slate-bg: #eef1f6; --tone-slate-fg: #334155; --tone-slate-ic: #475569;
  --tone-green-bg: #e7f5ea; --tone-green-fg: #1e6b36; --tone-green-ic: #2e9b4f;
  --tone-blue-bg: #e7f0fc;  --tone-blue-fg: #1b4f9c;  --tone-blue-ic: #2a78d6;
  --tone-teal-bg: #e3f5f3;  --tone-teal-fg: #0f6b63;  --tone-teal-ic: #189b8f;
  --tone-amber-bg: #fbf0e1; --tone-amber-fg: #8a4f0d; --tone-amber-ic: #b7701d;

  --lg-river: #3b82c4;
  --lg-basin-fill: #cfe8c8;
  --lg-basin-line: #7fb477;
  --lg-lake: #9ccbef;
  --lg-lake-line: #5e9fd4;
  --lg-gauge: #2463d6;
  --lg-res: #f28a2e;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b121d;
    --surface: #111a27;
    --surface-2: #0f1723;
    --surface-3: #1a2535;
    --border: #223044;
    --border-strong: #2e3e56;
    --text: #e8eef7;
    --text-2: #c6d2e2;
    --muted: #8e9db2;
    --primary: #4b93f3;
    --primary-hover: #6aa6f6;
    --primary-soft: #16273f;
    --focus: #6aa6f6;
    --code-bg: #070c15;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 2px 10px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
    --tone-slate-bg: #1c2738; --tone-slate-fg: #c3cfdf; --tone-slate-ic: #a9b8cc;
    --tone-green-bg: #13291d; --tone-green-fg: #8bd6a2; --tone-green-ic: #5cc27d;
    --tone-blue-bg: #13243c;  --tone-blue-fg: #9cc4f7;  --tone-blue-ic: #6aa6f6;
    --tone-teal-bg: #0f2a2a;  --tone-teal-fg: #7fd6cc;  --tone-teal-ic: #45bfb2;
    --tone-amber-bg: #2c2112; --tone-amber-fg: #f0c07e; --tone-amber-ic: #e3a04a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b121d; --surface: #111a27; --surface-2: #0f1723; --surface-3: #1a2535;
  --border: #223044; --border-strong: #2e3e56; --text: #e8eef7; --text-2: #c6d2e2; --muted: #8e9db2;
  --primary: #4b93f3; --primary-hover: #6aa6f6; --primary-soft: #16273f; --focus: #6aa6f6; --code-bg: #070c15;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 2px 10px rgba(0, 0, 0, .45); --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  --tone-slate-bg: #1c2738; --tone-slate-fg: #c3cfdf; --tone-slate-ic: #a9b8cc;
  --tone-green-bg: #13291d; --tone-green-fg: #8bd6a2; --tone-green-ic: #5cc27d;
  --tone-blue-bg: #13243c;  --tone-blue-fg: #9cc4f7;  --tone-blue-ic: #6aa6f6;
  --tone-teal-bg: #0f2a2a;  --tone-teal-fg: #7fd6cc;  --tone-teal-ic: #45bfb2;
  --tone-amber-bg: #2c2112; --tone-amber-fg: #f0c07e; --tone-amber-ic: #e3a04a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
code, pre, .mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  height: 68px; padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-logo { width: 46px; height: 38px; }
.brand-logo.sm { width: 34px; height: 28px; }
.brand-name { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; }
.brand-tagline { color: var(--muted); font-size: .92rem; white-space: nowrap; }
.topnav { display: flex; gap: 6px; margin: 0 auto; }
.topnav a {
  color: var(--text); font-weight: 500; padding: 8px 14px; border-radius: 8px;
}
.topnav a:hover { background: var(--surface-3); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--primary); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.top-actions .menu-btn { display: none; }
.topnav .nav-auth { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  font: inherit; font-weight: 500; font-size: .93rem;
  border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn .icon { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-3); }
.btn-sm { height: 34px; padding: 0 12px; font-size: .85rem; gap: 6px; }
.btn-sm .icon { width: 16px; height: 16px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.sm .icon { width: 17px; height: 17px; }

.usermenu { position: relative; }
.usermenu summary { list-style: none; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
}
.usermenu-panel a, .usermenu-panel button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border-radius: 6px; color: var(--text);
  font: inherit; font-size: .92rem; background: none; border: 0; cursor: pointer; text-align: left;
}
.usermenu-panel a:hover, .usermenu-panel button:hover { background: var(--surface-3); text-decoration: none; }
.usermenu-panel form { margin: 0; }

.flash-wrap { max-width: 1100px; margin: 12px auto 0; padding: 0 16px; }
.flash { padding: 10px 14px; border-radius: 8px; background: var(--primary-soft); color: var(--text); margin-bottom: 8px; border: 1px solid var(--border); }
.flash-error { background: #fdecec; color: #8a1c1c; border-color: #f5c2c2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flash-error { background: #3a1416; color: #f6c1c1; border-color: #6b2a2d; } }
:root[data-theme="dark"] .flash-error { background: #3a1416; color: #f6c1c1; border-color: #6b2a2d; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 5px;
  font-size: .75rem; font-weight: 500;
  background: var(--tone-slate-bg); color: var(--tone-slate-fg);
}
.chip .icon { width: 13px; height: 13px; stroke-width: 2; }
.tone-green .icon, .chip.tone-green .icon { color: var(--tone-green-ic); }
.chip.tone-green { background: var(--tone-green-bg); color: var(--tone-green-fg); }
.chip.tone-blue { background: var(--tone-blue-bg); color: var(--tone-blue-fg); }
.chip.tone-teal { background: var(--tone-teal-bg); color: var(--tone-teal-fg); }
.chip.tone-amber { background: var(--tone-amber-bg); color: var(--tone-amber-fg); }
.chip.tone-slate { background: var(--tone-slate-bg); color: var(--tone-slate-fg); }
.chip.tone-blue .icon { color: var(--tone-blue-ic); }
.chip.tone-teal .icon { color: var(--tone-teal-ic); }
.chip.tone-amber .icon { color: var(--tone-amber-ic); }
.chip.tone-slate .icon { color: var(--tone-slate-ic); }

.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: .92rem; }
.link-arrow .icon { width: 17px; height: 17px; }

/* ---------- home layout ---------- */
.page-home { overflow-x: hidden; }
.home {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 392px;
  min-height: calc(100vh - 68px);
}
.sidebar {
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 68px; align-self: start;
  height: calc(100vh - 68px); overflow-y: auto;
}
.catnav { display: flex; flex-direction: column; gap: 2px; }
.cat {
  display: flex; align-items: center; gap: 14px;
  height: 42px; padding: 0 12px; border-radius: 8px;
  color: var(--text); font-weight: 500; font-size: .95rem;
}
.cat:hover { background: var(--surface-3); text-decoration: none; }
.cat .icon { width: 21px; height: 21px; color: var(--tone-slate-ic); }
.cat.tone-green .icon { color: var(--tone-green-ic); }
.cat.tone-blue .icon { color: var(--tone-blue-ic); }
.cat.tone-teal .icon { color: var(--tone-teal-ic); }
.cat.tone-amber .icon { color: var(--tone-amber-ic); }
.cat .count { margin-left: auto; font-size: .78rem; color: var(--muted); font-weight: 500; opacity: 0; transition: opacity .15s; }
.cat:hover .count, .cat.is-active .count { opacity: 1; }
.cat.is-active { background: var(--primary-soft); color: var(--primary); }
.cat.is-active .icon { color: var(--primary); }
.note-card {
  display: flex; gap: 10px; margin: 26px 8px 8px; padding: 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .84rem; color: var(--text-2);
}
.note-card .icon { width: 18px; height: 18px; color: var(--muted); margin-top: 2px; }
.note-card p { margin: 0 0 10px; }
.note-card .link-arrow { font-size: .84rem; }

/* The centre column fills the window: the map takes the height and the
   datasets sit in one scrollable row pinned under it. */
.center {
  display: flex; flex-direction: column; min-width: 0;
  height: calc(100vh - 68px); padding: 0 16px 12px;
  position: sticky; top: 68px; align-self: start;
}
.panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 68px; align-self: start;
  height: calc(100vh - 68px); overflow-y: auto;
  scrollbar-width: thin;
}
.panel-inner { padding: 20px 22px 28px; }
.panel.is-loading .panel-inner { opacity: .55; transition: opacity .1s; }
.panel-top { display: flex; align-items: center; justify-content: space-between; }
.save-btn.is-saved { color: var(--primary); border-color: var(--primary); }
.save-btn.is-saved .icon { fill: currentColor; }
.panel-title { font-size: 1.32rem; font-weight: 700; margin: 10px 0 6px; }
.panel-title a { color: var(--text); }
.panel-sub { color: var(--text-2); font-size: .93rem; margin-bottom: 12px; }
.panel-img { margin: 0 0 14px; position: relative; }
.panel-img img { width: 100%; height: 150px; object-fit: cover; border-radius: 6px; background: var(--surface-3); }
.panel-img figcaption { font-size: .7rem; color: var(--muted); margin-top: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; }
.tabs button {
  font: inherit; font-size: .88rem; font-weight: 500; color: var(--text-2);
  background: none; border: 0; padding: 8px 10px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.facts { display: grid; grid-template-columns: 128px 1fr; gap: 8px 12px; margin: 0 0 12px; font-size: .9rem; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.ext { display: inline; overflow-wrap: anywhere; }
.ext .icon { width: 15px; height: 15px; vertical-align: -3px; margin-left: 5px; }
.cite { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-size: .85rem; }
.cite p { margin-bottom: 8px; }
.plain-list { list-style: none; padding: 0; margin: 0 0 10px; font-size: .92rem; }
.plain-list li { padding: 4px 0; }

.panel-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 14px; }
.panel-actions .btn { min-width: 0; }
.panel-actions.three { grid-template-columns: .95fr 1fr 1.3fr; gap: 6px; margin-top: 10px; }
.panel-actions.three .btn { padding: 0 6px; font-size: .78rem; gap: 5px; }
.panel-actions.three .btn .icon { width: 15px; height: 15px; }
.panel-actions .btn { width: 100%; }

.code { margin-top: 16px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.code-tabs { display: flex; align-items: center; gap: 2px; padding: 6px 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.code-tabs button[role="tab"] {
  font: inherit; font-size: .85rem; font-weight: 500; color: var(--text-2);
  background: none; border: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer;
}
.code-tabs button[aria-selected="true"] { color: var(--primary); background: var(--primary-soft); }
.code-copy {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: .82rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
.code-copy .icon { width: 15px; height: 15px; }
.code pre {
  margin: 0; padding: 14px 16px; background: var(--code-bg); color: var(--code-text);
  font-size: .78rem; line-height: 1.6; overflow-x: auto; white-space: pre;
  max-height: 320px;
}
.code .tok-str { color: var(--code-str); }
.code .tok-com { color: #7f8ea6; }
.code .tok-kw { color: #f2b872; }
.panel-more { margin-top: 14px; font-size: .86rem; }

/* ---------- map card ---------- */
.mapcard {
  position: relative; margin-top: 0; flex: 1 1 auto; min-height: 360px;
  border-radius: 0 0 var(--radius) var(--radius); overflow: hidden;
  border: 1px solid var(--border); border-top: 0;
  background: #cfe0ec;
  isolation: isolate;
}
.mapcard.is-globe {
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.85) 50%, transparent 51%),
    radial-gradient(1px 1px at 27% 72%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 43% 12%, rgba(255,255,255,.75) 50%, transparent 51%),
    radial-gradient(1px 1px at 61% 86%, rgba(255,255,255,.55) 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 78% 24%, rgba(255,255,255,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 64%, rgba(255,255,255,.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 52%, rgba(255,255,255,.5) 50%, transparent 51%),
    radial-gradient(1.3px 1.3px at 94% 9%, rgba(255,255,255,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 35% 40%, rgba(255,255,255,.35) 50%, transparent 51%),
    radial-gradient(1px 1px at 70% 50%, rgba(255,255,255,.35) 50%, transparent 51%),
    radial-gradient(ellipse at 50% 55%, #173659 0%, #0c1c33 45%, #060d1a 100%);
  background-size: 310px 290px, 370px 330px, 270px 250px, 410px 390px, 330px 300px, 290px 350px, 450px 410px, 380px 360px, 230px 210px, 260px 240px, 100% 100%;
}
.mapcard > .map { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-noscript { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; margin: 0; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.mapcard .maplibregl-ctrl-bottom-left { left: 8px; bottom: 54px; }
.maplibregl-ctrl.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(255,255,255,.85); }
.mapcard.is-drawing .map canvas { cursor: crosshair !important; }
.hydro-popup .maplibregl-popup-content {
  padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-family: var(--font); background: var(--surface); color: var(--text);
}
.hydro-popup .maplibregl-popup-tip { border-top-color: var(--surface); border-bottom-color: var(--surface); }
.hydro-popup .maplibregl-popup-close-button { font-size: 18px; padding: 2px 8px; color: var(--muted); }
.pp-kind { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 2px; }
.pp-name { font-weight: 600; font-size: .95rem; margin: 0 0 3px; padding-right: 14px; }
.pp-meta { font-size: .8rem; color: var(--text-2); margin: 0 0 3px; }
.pp-btn { margin-top: 6px; }
.hydro-marker {
  width: 16px; height: 16px; border-radius: 50%;
  background: #e5484d; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0,0,0,.35);
}

.map-search {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  width: min(598px, calc(100% - 90px));
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 6px 0 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: var(--shadow);
}
.map-search > .icon { color: var(--text-2); width: 19px; height: 19px; }
.map-search input {
  flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none;
  font: inherit; font-size: .93rem; color: var(--text);
}
.map-search input::placeholder { color: var(--muted); }
.map-search-filter {
  display: grid; place-items: center; width: 44px; height: 30px;
  border: 0; border-left: 1px solid var(--border); background: none; color: var(--text-2); cursor: pointer;
}
.map-search-filter[aria-expanded="true"], .map-search-filter.has-region { color: var(--primary); }
.map-search-results, .filter-pop {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg);
  max-height: 360px; overflow-y: auto;
}
.filter-pop { padding: 14px; max-height: none; }
.result-group { padding: 6px 0; }
.result-group + .result-group { border-top: 1px solid var(--border); }
.result-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 4px 14px; }
.result {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 14px; border: 0; background: none; cursor: pointer; text-align: left;
  font: inherit; color: var(--text);
}
.result:hover, .result.is-active { background: var(--surface-3); text-decoration: none; }
.result .icon { width: 17px; height: 17px; color: var(--muted); }
.result-name { font-weight: 500; font-size: .92rem; }
.result-detail { color: var(--muted); font-size: .8rem; margin-left: auto; text-align: right; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-empty { padding: 12px 14px; color: var(--muted); font-size: .9rem; }

.pop-title { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 6px; }
.pop-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.pop-field { display: grid; gap: 4px; font-size: .82rem; color: var(--text-2); }
.pop-field input, .field input, .field select, .field textarea {
  font: inherit; font-size: .9rem; height: 36px; padding: 0 10px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px;
}

.map-controls {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  display: flex; flex-direction: column; gap: 10px;
}
.ctl-group { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); overflow: hidden; }
.ctl-group button + button { border-top: 1px solid var(--border); }
.map-controls button {
  display: grid; place-items: center; width: 36px; height: 36px;
  background: var(--surface); border: 0; color: var(--text); cursor: pointer;
}
.map-controls .ctl { border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.map-controls button:hover { background: var(--surface-3); }
.map-controls button[aria-pressed="true"], .map-controls button[aria-expanded="true"] { color: var(--primary); }
.map-controls .icon { width: 19px; height: 19px; }

.layers-pop {
  position: absolute; top: 12px; right: 58px; z-index: 6; width: 290px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 14px; font-size: .87rem;
}
.layers-pop label { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; cursor: pointer; }
.layers-pop input { margin-top: 3px; accent-color: var(--primary); }
.layers-pop .pop-title:not(:first-child) { margin-top: 12px; }
.pop-foot { margin: 10px 0 0; font-size: .8rem; }

.map-tip {
  position: absolute; left: 0; top: 0; z-index: 7; pointer-events: none;
  background: rgba(17, 24, 39, .92); color: #fff; border-radius: 6px;
  padding: 7px 10px; font-size: .78rem; line-height: 1.35;
  display: grid; white-space: nowrap; will-change: transform;
  font-variant-numeric: tabular-nums;
}
.map-tip strong { font-weight: 600; }
.map-preview-note {
  position: absolute; z-index: 5; left: 50%; top: 62px; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: var(--shadow); padding: 5px 8px 5px 14px; font-size: .8rem;
  display: flex; align-items: center; gap: 8px; max-width: calc(100% - 140px);
}
.map-preview-note button { border: 0; background: none; cursor: pointer; color: var(--muted); display: grid; }
.map-preview-note .icon { width: 16px; height: 16px; }

.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 4px 6px; max-width: calc(100% - 300px);
}
.map-legend button {
  display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 9px;
  border: 0; background: none; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: .84rem; color: var(--text);
}
.map-legend button:hover { background: var(--surface-3); }
.map-legend button[aria-pressed="false"] { color: var(--muted); }
.map-legend button[aria-pressed="false"] i { opacity: .35; }
.map-legend i { display: inline-block; flex: none; }
.lg-river { width: 18px; height: 2px; background: var(--lg-river); border-radius: 2px; }
.lg-basin { width: 16px; height: 12px; background: var(--lg-basin-fill); border: 1px solid var(--lg-basin-line); border-radius: 2px; }
.lg-lake { width: 16px; height: 12px; background: var(--lg-lake); border: 1px solid var(--lg-lake-line); border-radius: 2px; }
.lg-gauge, .lg-res { width: 10px; height: 10px; border-radius: 50%; background: var(--lg-gauge); box-shadow: 0 0 0 1.5px #fff; }
.lg-res { background: var(--lg-res); }

.map-br { position: absolute; right: 12px; bottom: 12px; z-index: 5; display: flex; align-items: flex-end; gap: 8px; }
.map-scale {
  height: 32px; display: flex; align-items: flex-end; padding: 0 8px 6px;
  font-size: .8rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
}
.map-scale .bar { border: 1.5px solid var(--text); border-top: 0; height: 7px; display: grid; place-items: end center; position: relative; }
.map-scale .bar span { position: absolute; bottom: 7px; left: 0; right: 0; text-align: center; white-space: nowrap; font-size: .76rem; }
@media (hover: none) { .map-coords { display: none; } }
.map-coords {
  height: 32px; display: grid; place-items: center; padding: 0 10px;
  font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  min-width: 108px;
}
.compass {
  position: absolute; right: 18px; bottom: 56px; width: 54px; height: 54px;
  border: 0; background: none; padding: 0; cursor: pointer;
}
.compass svg { width: 54px; height: 54px; }
.compass-ring { fill: rgba(255,255,255,.12); stroke: rgba(255,255,255,.75); stroke-width: 1.2; }
.compass text { fill: #fff; font-size: 9px; font-weight: 600; font-family: var(--font); }
.needle-n { fill: #e5484d; }
.needle-s { fill: #f3f4f6; }
.mapcard:not(.is-globe) .compass-ring { fill: rgba(255,255,255,.85); stroke: var(--border-strong); }
.mapcard:not(.is-globe) .compass text { fill: var(--text); }
.mapcard:not(.is-globe) .needle-s { fill: #9aa4b2; }
.mapcard:not(.is-globe) .compass:not(.is-rotated) { display: none; }

/* ---------- featured grid ---------- */
.featured {
  margin-top: 10px; padding: 12px 14px 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.center .featured { flex: none; }
.featured .section-head { align-items: center; margin-bottom: 10px; }
.featured .section-head h2 { font-size: 1.1rem; margin: 0; }
.featured .section-head p { font-size: .85rem; }
.head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.head-actions .icon-btn { width: 32px; height: 32px; }
.head-actions .icon-btn .icon { width: 17px; height: 17px; }
.head-actions .icon-btn:disabled { opacity: .35; cursor: default; }
.drow {
  display: grid; grid-auto-flow: column; grid-auto-columns: 340px; gap: 10px;
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity;
  padding-bottom: 8px; scrollbar-width: thin;
}
.drow > * { scroll-snap-align: start; }
.drow .dcard { padding: 10px; gap: 12px; }
.drow .dcard-thumb { width: 84px; height: 72px; }
.drow .dcard-title { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; font-size: .95rem; }
.drow .dcard-meta { flex-wrap: nowrap; overflow: hidden; max-width: 100%; }
.drow .dcard-meta span { flex: none; }
.drow .dcard-meta span:last-child { flex: 0 1 auto; min-width: 0; }
.dcard-more {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius); color: var(--primary);
  font-weight: 500; font-size: .92rem; padding: 12px; text-align: center; min-height: 100px;
}
.dcard-more:hover { background: var(--primary-soft); text-decoration: none; }
.dcard-more .icon { width: 20px; height: 20px; }
.drow .empty { grid-column: 1 / -1; padding: 30px 4px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.section-head h2 { font-size: 1.25rem; margin-bottom: 2px; }
.section-head p { color: var(--text-2); font-size: .92rem; margin: 0; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.dcard {
  display: flex; align-items: center; gap: 14px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
.dcard:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.dcard.is-selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.dcard-thumb { width: 96px; height: 78px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-3); }
.dcard-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; align-items: flex-start; }
.dcard-title { font-weight: 600; font-size: .98rem; line-height: 1.25; margin-top: 3px; }
.dcard-source { color: var(--text-2); font-size: .8rem; }
.dcard-meta { color: var(--text-2); font-size: .78rem; display: flex; flex-wrap: wrap; }
.dcard-meta { max-width: 100%; }
.dcard-meta span { white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.dcard-meta span + span::before { content: "|"; margin: 0 7px; color: var(--border-strong); }
.dcard-chev { color: var(--text-2); width: 18px; height: 18px; }
.empty { color: var(--muted); padding: 20px 4px; margin: 0; }

/* ---------- dialogs ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(10, 16, 28, .45); }
.palette {
  width: min(640px, calc(100vw - 32px)); margin-top: 10vh; padding: 0;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg);
}
.palette-bar { display: flex; align-items: center; gap: 10px; padding: 0 14px; height: 54px; border-bottom: 1px solid var(--border); }
.palette-bar input { flex: 1; border: 0; outline: 0; background: none; font: inherit; font-size: 1rem; color: var(--text); }
.palette-bar kbd { font-family: var(--font); font-size: .72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.palette-results { max-height: 60vh; overflow-y: auto; }
.palette-hint { padding: 14px; color: var(--muted); font-size: .9rem; margin: 0; }

.links-dialog {
  width: min(760px, calc(100vw - 32px)); max-height: 86vh; padding: 0;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-lg);
}
.links-dialog[open] { display: flex; flex-direction: column; }
.dialog-head { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 1.15rem; margin-bottom: 2px; }
.dialog-head p { margin: 0; }
.dialog-body { padding: 8px 20px 16px; overflow-y: auto; }
.dialog-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.lgroup { padding: 12px 0; }
.lgroup + .lgroup { border-top: 1px solid var(--border); }
.lgroup h3 { font-size: .95rem; margin-bottom: 4px; }
.lgroup .auth { display: inline-block; font-size: .75rem; background: var(--tone-amber-bg); color: var(--tone-amber-fg); border-radius: 4px; padding: 1px 7px; margin-bottom: 6px; }
.lgroup .note { font-size: .82rem; color: var(--muted); margin: 0 0 6px; }
.lgroup ol { margin: 0; padding-left: 1.4em; max-height: 220px; overflow-y: auto; font-size: .82rem; }
.lgroup li { padding: 2px 0; overflow-wrap: anywhere; }
.lgroup li a { font-family: var(--mono); font-size: .78rem; }
.lgroup .more { font-size: .8rem; color: var(--muted); }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: .88rem; box-shadow: var(--shadow-lg); animation: toast-in .18s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- content pages ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 32px 24px 56px; }
.page-narrow { max-width: 820px; }
.page-head { margin-bottom: 24px; }
.page-head p { color: var(--text-2); font-size: 1.02rem; max-width: 760px; }
.crumbs { font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.richtext { font-size: 1rem; line-height: 1.65; color: var(--text-2); }
.richtext h2 { color: var(--text); margin: 1.6em 0 .5em; font-size: 1.25rem; }
.richtext h3 { color: var(--text); margin: 1.3em 0 .4em; }
.richtext code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.richtext pre { background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: 8px; overflow-x: auto; font-size: .82rem; line-height: 1.6; }
.richtext pre code { background: none; padding: 0; }
.richtext table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: 1em 0; }
.richtext th, .richtext td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
.richtext th { color: var(--text); font-weight: 600; }

.list-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; }
.filters { position: sticky; top: 88px; align-self: start; display: grid; gap: 18px; }
.filters fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 4px; }
.filters legend { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.filters label { display: flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; }
.filters input[type="checkbox"], .filters input[type="radio"] { accent-color: var(--primary); }
.filters select, .filters input[type="search"] {
  width: 100%; font: inherit; font-size: .9rem; height: 38px; padding: 0 10px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px;
}
.list-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.list-bar .count { color: var(--text-2); }
.bbox-pill { display: inline-flex; align-items: center; gap: 8px; background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: .84rem; }
.bbox-pill a { display: grid; color: inherit; }
.bbox-pill .icon { width: 15px; height: 15px; }
.rows { display: grid; gap: 10px; }
.row {
  display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 16px; align-items: center;
  padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
}
.row:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.row img { width: 120px; height: 80px; object-fit: cover; border-radius: 6px; background: var(--surface-3); }
.row h3 { margin: 4px 0 2px; font-size: 1.02rem; }
.row p { margin: 0; font-size: .87rem; color: var(--text-2); }
.row .dcard-meta { margin-top: 4px; }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 20px; align-items: center; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 28px; }
.detail-head { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.detail-title { font-size: 2rem; margin: 6px 0 4px; }
.detail-sub { color: var(--text-2); font-size: 1.05rem; margin-bottom: 16px; }
.detail-side { display: grid; gap: 16px; align-self: start; position: sticky; top: 88px; }
.detail-side img { width: 100%; height: 200px; object-fit: cover; border-radius: 8px; }
.minimap { height: 220px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #cfe0ec; }
.method { padding: 12px 0; border-top: 1px solid var(--border); }
.method:first-child { border-top: 0; padding-top: 0; }
.method h3 { font-size: .95rem; margin-bottom: 2px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.method .kind { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-3); border-radius: 4px; padding: 1px 6px; }
.bbox-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.bbox-form input { flex: 1; min-width: 200px; font-family: var(--mono); font-size: .85rem; height: 36px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--text); }

.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.source-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); }
.source-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.source-card strong { font-size: 1rem; }
.source-card span { color: var(--text-2); font-size: .86rem; }

.auth-card { max-width: 420px; margin: 48px auto; }
.auth-card h1 { font-size: 1.5rem; }
.field { display: grid; gap: 5px; margin-bottom: 14px; font-size: .9rem; }
.field input, .field select { height: 40px; width: 100%; }
.field textarea { height: auto; padding: 8px 10px; width: 100%; }
.field .errorlist { color: #b42318; font-size: .82rem; margin: 0; padding: 0; list-style: none; }
.helptext, .field small { color: var(--muted); font-size: .8rem; }
.errorlist { color: #b42318; font-size: .85rem; padding-left: 1.1em; }

.stats { display: flex; gap: 32px; margin: 20px 0; flex-wrap: wrap; }
.stats div { display: grid; }
.stats strong { font-size: 1.8rem; color: var(--text); }
.stats span { color: var(--muted); font-size: .88rem; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 24px; }
.footer-inner { max-width: 1180px; margin: 0 auto; padding: 24px; display: flex; gap: 32px; justify-content: space-between; flex-wrap: wrap; }
.footer-brand { display: flex; gap: 12px; max-width: 520px; color: var(--text-2); font-size: .88rem; }
.footer-brand p { margin: 0; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; font-size: .9rem; }
.footer-links a { color: var(--text-2); }

/* ---------- responsive ---------- */
@media (max-width: 1380px) {
  .home { grid-template-columns: 210px minmax(0, 1fr) 360px; }
  .brand-tagline { display: none; }
}
@media (max-width: 1180px) {
  .home { grid-template-columns: 200px minmax(0, 1fr); }
  .center { position: static; }
  .panel { grid-column: 2; position: static; height: auto; border-left: 0; margin: 0 16px 24px; border: 1px solid var(--border); border-radius: var(--radius); }
  .detail-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-side { position: static; }
}
@media (max-width: 900px) {
  .topbar { padding: 0 14px; gap: 10px; }
  .topnav {
    display: none; position: absolute; top: 68px; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 8px; margin: 0;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .topnav.is-open { display: flex; }
  .topnav a { padding: 12px 14px; }
  .top-actions .menu-btn { display: inline-grid; }
  .hide-sm { display: none; }
  .home { display: block; }
  .sidebar {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border);
    padding: 10px 12px; overflow-x: auto;
  }
  .catnav { flex-direction: row; gap: 6px; }
  .cat { height: 36px; flex: none; border: 1px solid var(--border); gap: 8px; font-size: .88rem; }
  .cat .count { display: none; }
  .note-card { display: none; }
  /* Map and dataset row fill the screen under the category chips; the
     detail panel follows below. */
  .center { padding: 10px 12px 10px; height: calc(100vh - 68px - 57px); height: calc(100svh - 68px - 57px); min-height: 480px; }
  .mapcard { min-height: 280px; border-top: 1px solid var(--border); border-radius: var(--radius); }
  .drow { grid-auto-columns: 82%; scroll-snap-type: x mandatory; }
  .panel { margin: 0 12px 20px; }
  .list-layout { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
  .page { padding: 20px 16px 40px; }
}
@media (max-width: 600px) {
  .top-actions .btn-primary, .top-actions .usermenu { display: none; }
  .topnav.is-open .nav-auth { display: block; border-top: 1px solid var(--border); }
  .topnav.is-open .nav-auth + .nav-auth { border-top: 0; }
  .compass { display: none; }
  .brand-name { font-size: 1.3rem; }
  .brand-logo { width: 36px; height: 30px; }
  .top-actions .btn-primary { padding: 0 12px; }
  .map-search { top: 10px; left: 10px; width: calc(100% - 64px); height: 38px; }
  .map-controls { top: 10px; right: 10px; gap: 8px; }
  .map-controls .ctl-group { display: none; }  /* pinch to zoom */
  .map-controls button { width: 34px; height: 34px; }
  .map-legend {
    left: 10px; bottom: 10px; max-width: calc(100% - 104px);
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 2px 4px;
  }
  .map-legend::-webkit-scrollbar { display: none; }
  .map-legend button { height: 28px; padding: 0 7px; font-size: .76rem; flex: none; }
  .map-br { right: 10px; bottom: 10px; }
  .map-scale { height: 32px; font-size: .72rem; }
  .map-coords { display: none; }
  .drow .dcard-title { -webkit-line-clamp: 2; }
  .mapcard .maplibregl-ctrl-bottom-left { bottom: 46px; left: 6px; }
  .featured { padding: 10px 10px 4px; }
  .featured .section-head { margin-bottom: 8px; }
  .featured .section-head h2 { font-size: 1rem; }
  .featured .section-head p { display: none; }
  .featured .link-arrow { font-size: .85rem; }
  .panel-actions.three { grid-template-columns: 1fr; }
  .panel-inner { padding: 16px 14px 22px; }
  .tabs button { padding: 8px 8px; font-size: .84rem; }
  .panel-actions .btn { padding: 0 10px; }
  .facts { grid-template-columns: 110px 1fr; }
  .row { grid-template-columns: 80px minmax(0, 1fr); }
  .row img { width: 80px; height: 64px; }
  .row .dcard-chev { display: none; }
  .dgrid { grid-template-columns: 1fr; }
  .head-actions .icon-btn { display: none; }
  .layers-pop { right: 12px; left: 12px; width: auto; top: 60px; }
  h1, .detail-title { font-size: 1.55rem; }
}
