/*
 * Obserwator's GUI: the shell of Nogat's identity (top bar, „Stacje” | map | „Stacja”,
 * resizers, phone sheets, the status bar under the map), the controls and the building
 * blocks of the sections (cards, segmented controls, tables, figures, provenance chips),
 * „Zgłoś uwagę” and the toasts. Ported from the reviewed mockup, after Hydrolog's GUI
 * (src/hydrolog/gui/web/css/app.css at b980187) and Nogat design/README.md. Every colour
 * comes from ../nogat/tokens.css; derived shades use color-mix() on tokens. The map's own
 * rules live in map.css, the charts' in charts.css, the sections' in hydro.css and meteo.css.
 */

:root {
  --left-w: 300px;
  --right-w: 400px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height);
}
h1, h2, h3, h4 { letter-spacing: -0.01em; }
code, pre { font-family: var(--font-mono); }
code { font-size: 0.92em; }
.muted { color: var(--text-3); }
.small { font-size: var(--text-xs); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
.noscript { margin: var(--space-6); font-size: var(--text-md); }
/* index.html's message when the page cannot load its texts (src/main.js) */
.boot-error {
  position: fixed; inset: var(--space-6) var(--space-4) auto; z-index: 90;
  max-width: 640px; margin: 0 auto; padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line); border-left: 3px solid var(--bad); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); font-size: var(--text-md);
}
.ok-text { margin: var(--space-1) 0; color: var(--ok-ink); font-size: var(--text-sm); font-weight: var(--weight-bold); }
.bad-text { color: var(--bad-ink); font-weight: var(--weight-bold); }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control); padding: 0 var(--space-3);
  border: 1px solid var(--line-2); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  font: var(--weight-medium) var(--text-base)/1 var(--font-sans);
  white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background var(--transition), border-color var(--transition);
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--highlight); }
.btn.sm { height: var(--control-sm); padding: 0 var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-sm); }
.btn.icon { width: var(--control); padding: 0; }
.btn.sm.icon { width: var(--control-sm); }
.btn.is-on { border-color: var(--accent); background: var(--accent-soft); }
.btn svg, .icon-svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn .btn-mark { width: 16px; height: 16px; flex: none; }
.link {
  margin: var(--space-1) 0; padding: 0; border: 0; background: none; color: var(--accent);
  cursor: pointer; font: inherit; font-size: var(--text-sm); text-decoration: underline; text-underline-offset: 2px;
}
.link:hover { color: var(--accent-hover); }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  height: var(--control); padding: 0 var(--space-2);
  border: 1px solid var(--line-2); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  font: var(--text-base) var(--font-sans);
  min-width: 0;
}
textarea { height: auto; padding: var(--space-1) var(--space-2); resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { accent-color: var(--accent); margin: 0; width: 15px; height: 15px; flex: none; }

/* Segmented control (ui/seg.js and the sections' Seg) */
.seg {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-md);
  max-width: 100%;
}
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--control-sm); padding: 0 var(--space-3);
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-2);
  font: var(--weight-medium) var(--text-sm)/1.15 var(--font-sans); cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.seg button:hover { color: var(--text); }
.seg button.on, .seg button[aria-pressed="true"], .seg button[aria-checked="true"] {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm);
}
.seg.full { display: flex; }
.seg.full button { flex: 1; justify-content: center; padding: 0 var(--space-1); }
.seg.tiny { padding: 2px; }
.seg.tiny button { min-height: 22px; padding: 0 6px; font-size: var(--text-xs); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 var(--space-2);
  border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: var(--weight-bold); white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; flex: none; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.bad { background: var(--bad-bg); color: var(--bad-ink); }
.badge.info { background: var(--info-bg); color: var(--info-ink); }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 20px; padding: 0 6px;
  border: 1px solid var(--line-2); border-radius: var(--radius-xs);
  background: var(--surface); color: var(--text-2);
  font: var(--text-xs) var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap;
}
button.chip { cursor: pointer; min-height: 24px; padding: 0 8px; }
button.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: var(--weight-bold); }
.chip-unit { color: var(--text-3); font-weight: var(--weight-regular); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1); }

.check { display: inline-flex; gap: var(--space-2); align-items: center; font-size: var(--text-sm); color: var(--text-2); cursor: pointer; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: var(--space-2) 0; }
.note { margin: var(--space-2) 0; font-size: var(--text-xs); color: var(--text-3); line-height: 1.45; }
.note code { font-size: var(--text-xs); }
.note-box, .hint-box {
  margin: 0 0 var(--space-3); padding: var(--space-2) 10px;
  border: 1px solid var(--line); border-left: 3px solid var(--info); border-radius: var(--radius-md);
  background: var(--surface-2); color: var(--text-2); font-size: var(--text-sm); line-height: 1.45;
}
.hint-box { border-left-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.group-title {
  margin: var(--space-4) 0 var(--space-2);
  font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.empty-note { margin: var(--space-4) 0; color: var(--text-3); font-size: var(--text-sm); text-align: center; }

.info-btn {
  width: 18px; height: 18px; flex: none; padding: 0;
  display: inline-grid; place-items: center;
  border: 1px solid var(--line-2); border-radius: 50%; background: var(--surface); color: var(--accent);
  font: italic var(--weight-bold) var(--text-xs)/1 var(--font-sans);
  cursor: pointer;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Shell ---------- */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  height: 100%;
}
html[data-host="nogat"] .shell { grid-template-rows: minmax(0, 1fr); }
html[data-host="nogat"] .topbar { display: none !important; }
.topbar {
  grid-row: 1;
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-4) 0 14px;
  min-width: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--tool-obserwator) 55%, transparent);
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: var(--space-2); text-decoration: none; flex: none; }
.brand img { width: 24px; height: 24px; display: block; }
.brand .name { color: var(--tool-obserwator); font-weight: var(--weight-bold); font-size: var(--text-md); letter-spacing: -0.01em; }
/* The operator's mark on an instance (ADR-025; Nogat design/README.md „Operator's mark”):
   logo and title after a divider, the title shortened and, on a phone, left out */
.operator { display: flex; align-items: center; gap: var(--space-2); min-width: 0; min-height: 24px; padding-left: var(--space-3); border-left: 1px solid var(--line); }
.operator img { display: block; flex: none; height: 24px; width: auto; max-width: 120px; object-fit: contain; }
.operator-name { min-width: 0; color: var(--text-2); font-weight: var(--weight-medium); font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) {
  .operator { padding-left: var(--space-2); }
  .operator-name, .operator.no-logo { display: none; }
}
.crumbs { display: flex; align-items: center; gap: var(--space-2); min-width: 0; color: var(--text-3); font-size: var(--text-sm); }
.crumbs .sep { color: var(--line-2); }
.crumbs strong { color: var(--text); font-weight: var(--weight-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs .crumb-river { color: var(--text-3); font-weight: var(--weight-regular); }
.crumbs > span { white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); flex: none; }
.top-actions .guide-btn, .top-actions .feedback-btn { padding: 0 var(--space-2); }
.main { grid-row: 2; min-width: 0; min-height: 0; }
html[data-host="nogat"] .main { grid-row: 1; }

/* ---------- View layout: Stacje | map | Stacja ---------- */
.view-layout {
  position: relative;
  display: grid;
  grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w);
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
}
.view-panel {
  grid-row: 1;
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
  container-type: inline-size;
  background: var(--surface);
}
.view-panel.left { grid-column: 1; border-right: 1px solid var(--line); }
.view-panel.right { grid-column: 3; border-left: 1px solid var(--line); }
.view-panel-body { position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-3) 14px var(--space-6); scrollbar-gutter: stable; }
.view-panel.left .view-panel-body { display: flex; flex-direction: column; padding-bottom: var(--space-3); }
/* The bottom of a panel under its scrolling body: „Regulamin” of a public deployment, a small
   quiet link at the bottom of the left panel (src/attribution.js TermsLink; Nogat DEV-15.7) */
.panel-foot { flex: none; padding: 4px 14px 6px; border-top: 1px solid var(--line); font-size: var(--text-xs); line-height: 1.35; }
.panel-foot .terms-link { color: var(--text-3); text-decoration: underline; text-decoration-color: var(--line-2); }
.panel-foot .terms-link:hover { color: var(--text-2); }
.panel-head {
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 46px; padding: 0 var(--space-2) 0 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.panel-head h2 { margin: 0; font-size: var(--text-md); font-weight: var(--weight-bold); }
.panel-head .sub { min-width: 0; color: var(--text-3); font: var(--text-xs) var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head .btn { margin-left: auto; }
.grip { display: none; }

.resizer {
  grid-row: 1;
  position: relative;
  width: 10px; z-index: 24;
  cursor: col-resize; touch-action: none; outline: none;
}
.resizer.r-left { grid-column: 1; justify-self: end; margin-right: -5px; }
.resizer.r-right { grid-column: 3; justify-self: start; margin-left: -5px; }
.resizer::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 4px; width: 2px;
  border-radius: 2px; background: transparent; transition: background 0.15s;
}
.resizer::after {
  content: ""; position: absolute; top: 50%; left: 2px; width: 6px; height: 36px; margin-top: -18px;
  border-radius: 4px; background: var(--accent); opacity: 0; transition: opacity 0.15s;
}
.resizer:hover::before, .resizer:active::before, .resizer:focus-visible::before, .resizer.dragging::before { background: var(--accent); }
.resizer:hover::after, .resizer:active::after, .resizer:focus-visible::after, .resizer.dragging::after { opacity: 1; }
body.resizing { cursor: col-resize; user-select: none; }
body.resizing .view-center, body.resizing .view-panel { pointer-events: none; }

.view-center { grid-row: 1; grid-column: 2; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.view-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  min-height: 46px; padding: 6px var(--space-3);
  background: var(--surface); border-bottom: 1px solid var(--line);
  flex: none;
}
.view-bar .hint { color: var(--text-3); font-size: var(--text-sm); }
.view-bar .end { margin-left: auto; display: flex; gap: var(--space-2); }
.view-body { position: relative; flex: 1; min-height: 0; }
.panel-toggle { display: none; max-width: 220px; min-width: 0; }
.panel-toggle .label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 861px) {
  .view-panel.collapsed { display: none; }
  .panel-toggle:not(.is-open) { display: inline-flex; }
}

/* ---------- Stacje: search, filters, list ---------- */
.station-list { display: flex; flex-direction: column; gap: var(--space-2); min-height: 0; }
.search { position: relative; display: block; flex: none; }
.search svg { position: absolute; left: 9px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; fill: none; stroke: var(--text-3); stroke-width: 1.8; stroke-linecap: round; pointer-events: none; }
.search input { width: 100%; padding-left: 30px; }
.filters { display: grid; gap: 6px; flex: none; }
/* „Rodzaj stacji”: Hydrologiczne and Meteorologiczne side by side, Wszystkie under them */
.seg.kinds { display: grid; grid-template-columns: 1fr 1fr; }
.seg.kinds button:last-child { grid-column: 1 / -1; }
.check-row { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); padding: 2px 2px 0; }
.counts { margin: 0; padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; flex: none; }
.counts strong { color: var(--text); }
.stations { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.st-item {
  display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; grid-template-areas: "sym name code" "sym sub sub";
  align-items: center; gap: 0 8px;
  width: 100%; min-height: 40px; padding: 4px 6px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text);
  font: var(--text-sm) var(--font-sans); text-align: left; cursor: pointer;
}
.st-item:hover { background: var(--surface-2); }
.st-item.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.st-item .st-sym { grid-area: sym; }
.st-name { grid-area: name; min-width: 0; font-weight: var(--weight-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-code { grid-area: code; color: var(--text-3); font-size: var(--text-xs); }
.st-sub { grid-area: sub; min-width: 0; color: var(--text-3); font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.cell-sub { display: block; font-size: 10.5px; color: var(--text-3); font-weight: var(--weight-regular); }
.no-loc { color: var(--warn-ink); }
.more { align-self: center; margin: var(--space-2) 0; }

/* ---------- Stacja: header and accordion ---------- */
.station-head { margin: 0 0 var(--space-3); }
.station-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--space-2); }
.station-title h3 { margin: 0; font-size: var(--text-lg); }
.station-title .river { color: var(--text-2); font-size: var(--text-md); }
.station-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: var(--space-2) 0 0; }
.station-tags .chip { font-size: var(--text-xs); }
.station-head .note-box { margin: var(--space-3) 0 0; }
.acc { display: grid; gap: var(--space-2); }
.acc-item { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); min-width: 0; }
.acc-item.open { box-shadow: var(--shadow-sm); }
.acc-head { margin: 0; }
.acc-head button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px var(--space-3); border: 0; border-radius: var(--radius-lg);
  background: transparent; color: var(--text); cursor: pointer; text-align: left;
  font: var(--weight-bold) var(--text-base) var(--font-sans);
}
.acc-head button:hover { background: var(--surface-2); }
.acc-item.open .acc-head button { border-bottom: 1px solid var(--line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.acc-title { flex: 1; min-width: 0; }
.acc-meta { color: var(--text-3); font-size: var(--text-xs); font-weight: var(--weight-regular); }
.chev { width: 14px; height: 14px; flex: none; fill: none; stroke: var(--text-3); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--transition); }
.acc-item.open .chev { transform: rotate(180deg); }
.acc-body { padding: var(--space-3); min-width: 0; }
.acc-body > :last-child { margin-bottom: 0; }

/* ---------- Building blocks of the sections (sections/common.js) ---------- */
.ana { margin: 0 0 var(--space-3); min-width: 0; }
.ana + .ana { padding-top: var(--space-3); border-top: 1px solid var(--line); }
.ana-head { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-2); }
.ana-head h3 { margin: 0; font-size: var(--text-md); font-weight: var(--weight-bold); }
.ana-info {
  margin: 0 0 var(--space-2); padding: var(--space-2) var(--space-3);
  border: 1px solid color-mix(in srgb, var(--info) 35%, var(--line)); border-radius: var(--radius-md);
  background: var(--info-bg); color: var(--text); font-size: var(--text-sm); line-height: 1.5;
}
.ana-info p { margin: 0; white-space: pre-line; }
.ana-info p + p { margin-top: var(--space-2); }
.ana-body { transition: opacity 0.15s; min-width: 0; }
.ana-body.is-loading { opacity: 0.5; }
.ana-error {
  margin: 0 0 var(--space-2); padding: var(--space-2) 10px;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line)); border-left: 3px solid var(--bad);
  border-radius: var(--radius-md); background: var(--bad-bg); color: var(--bad-ink); font-size: var(--text-sm);
}
.ana-prov { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: var(--space-2) 0 0; }
.prov {
  display: inline-flex; align-items: center; gap: 4px; min-height: 20px; padding: 0 8px;
  border: 1px solid var(--line-2); border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--text-2); font-size: var(--text-xs); line-height: 1.3;
}
.prov code { font-size: var(--text-xs); color: var(--text); }
.prov-hydrolog { border-color: color-mix(in srgb, var(--tool-hydrolog) 55%, var(--line)); background: color-mix(in srgb, var(--tool-hydrolog) 12%, var(--surface)); color: var(--text); }
.prov-hydrolog::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--tool-hydrolog); flex: none; }

.years { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; font-size: var(--text-sm); color: var(--text-2); }
.years label { display: inline-flex; align-items: center; gap: 6px; }
.years input { width: 5.6em; height: var(--control-sm); font-variant-numeric: tabular-nums; }
.years button {
  height: var(--control-sm); padding: 0 var(--space-2);
  border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent); color: var(--accent-ink);
  font: var(--weight-medium) var(--text-sm)/1 var(--font-sans); cursor: pointer;
}
.years button:hover { background: var(--accent-hover); }
.years button:disabled { opacity: 0.5; cursor: not-allowed; }
.years-note { flex-basis: 100%; font-size: var(--text-xs); color: var(--text-3); line-height: 1.4; }
.years-note.warn { padding: 2px var(--space-2); border-left: 3px solid var(--warn); border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-ink); }

.table-wrap { overflow: auto; max-width: 100%; margin: 0 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-md); }
.table-wrap > .link { margin: var(--space-1) var(--space-2) var(--space-2); }
.tbl { width: 100%; border-collapse: collapse; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: 4px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--text-2); font-weight: var(--weight-bold); font-size: var(--text-xs);
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--surface-2); }

/* Read by assistive technology, not drawn (the page's <h1>) */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; margin: 0 0 var(--space-3); background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.figures > div { padding: var(--space-2) 10px; background: var(--surface); min-width: 0; }
.figures dt { font-size: var(--text-xs); color: var(--text-3); }
.figures dd { margin: 2px 0 0; font-size: var(--text-md); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }
.figures dd.figure-note { margin: 0; font-size: inherit; font-weight: inherit; }
.figures small { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--text-2); line-height: 1.25; }
/* A stale value (`current hydro`'s `flow_stale`): struck through, with a warning note */
.figures .stale dd:not(.figure-note) { color: var(--text-3); text-decoration: line-through; }
.stale-note { color: var(--warn-ink); }

.params { width: 100%; border-collapse: collapse; font-size: var(--text-sm); margin: 0 0 var(--space-2); }
.params th, .params td { padding: 5px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: var(--weight-regular); vertical-align: baseline; }
.params tr:last-child th, .params tr:last-child td { border-bottom: 0; }
.params th { color: var(--text-2); padding-right: var(--space-3); width: 42%; }
.params td { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.params.compact th, .params.compact td { padding: 4px 0; }
.params.compact td { text-align: right; }
.row-sub { display: block; margin-top: 1px; font-size: var(--text-xs); color: var(--text-3); }

pre.code {
  margin: 0 0 var(--space-2); padding: var(--space-2) var(--space-3);
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius-md);
  font-size: var(--text-xs); line-height: 1.5;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
/* The arguments of a command line (sections/pobierz.js Command), each a span: the line
   breaks between them, never after the hyphens of an option; one longer than the line
   wraps inside itself */
pre.code .arg { display: inline-block; max-width: 100%; vertical-align: top; }
.cli { margin: var(--space-2) 0; }
.cli-head { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 4px; }
.cli-head .label { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-2); }
.cli-head .btn { margin-left: auto; }
.cli textarea, .handoff-field { width: 100%; font: var(--text-xs) var(--font-mono); }
.fmt {
  display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 18px; padding: 0 4px;
  border: 1px solid var(--line-2); border-radius: var(--radius-xs);
  font: var(--weight-bold) var(--text-xs) var(--font-mono); color: var(--text-2); background: var(--surface-2);
}
.files .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.licence { margin: var(--space-2) 0 0; font-size: var(--text-xs); color: var(--text-2); line-height: 1.45; }
.licence p { margin: 0 0 4px; }
.handoff-box { margin: 0 0 var(--space-2); }
.handoff-var h4, .coverage h4 { margin: var(--space-3) 0 var(--space-1); font-size: var(--text-sm); }
.coverage h4 .muted { font-weight: var(--weight-regular); font-size: var(--text-xs); }

/* ---------- Dane ---------- */
.ds-title { margin: 0 0 var(--space-2); font-weight: var(--weight-bold); color: var(--text-2); }
.data-controls { display: grid; gap: var(--space-2); margin: 0 0 var(--space-3); }
.years-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.data-chart { margin: 0 0 var(--space-3); }
.data-chart .chart { margin: 0; }
.data-table .tbl td { white-space: nowrap; }
.flag {
  display: inline-block; margin-left: 4px; padding: 0 4px; border-radius: var(--radius-xs);
  background: var(--warn-bg); color: var(--warn-ink); font-size: 10px; font-weight: var(--weight-bold);
}
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); font-size: var(--text-xs); }
.data-foot { margin: var(--space-3) 0 0; padding: var(--space-2) 0 0; border-top: 1px solid var(--line); font-size: var(--text-xs); color: var(--text-3); line-height: 1.45; }
.data-foot p { margin: 0 0 4px; }

/* ---------- The foot of the view across its width, under the map and both panels (after
   Hydrograf's #view-foot): the view's one strip of provider lines, the kit's <nogat-sources>
   (its own 12 px muted text, Nogat DEV-20.5) with the basemap's credit run on after it. On a
   phone the sheets stop above it (--view-foot-h) ---------- */
.view-foot { grid-row: 2; grid-column: 1 / -1; min-width: 0; border-top: 1px solid var(--line); background: var(--surface); }
.view-sources {
  padding: 4px 12px 5px;
  font-size: var(--text-sm); line-height: var(--line-height); color: var(--text-3);
}
.view-sources nogat-sources:not([hidden]),
.view-sources .nogat-sources-strip { display: inline; }
.view-sources nogat-sources:not([hidden]) + .map-basemap::before { content: " · "; }
/* The welcome window of a first visit (src/ui/welcome.js): a .modal with the kit's sources */
.welcome .intro { margin: 0 0 var(--space-3); color: var(--text-2); }

/* ---------- Without a station ---------- */
.no-station .params th { width: 64%; }

/* ---------- „Zgłoś uwagę”: a native modal <dialog> (after Hydrolog's GUI) and the toasts ---------- */
dialog.modal {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: color-mix(in srgb, var(--code-bg) 45%, transparent); }
.modal-head { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-2) var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: var(--text-lg); }
.modal-head .btn { margin-left: auto; }
.modal-body { padding: var(--space-4) var(--space-4) var(--space-2); }
.modal-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--space-2); padding: var(--space-2) var(--space-4) var(--space-4); }
.field { display: grid; gap: var(--space-1); margin: 0 0 var(--space-3); }
.field > label { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-2); }
.feedback .intro { margin: 0 0 var(--space-3); color: var(--text-2); }
.feedback textarea { width: 100%; min-height: 120px; line-height: 1.45; }
.fb-under { display: flex; align-items: flex-start; gap: var(--space-3); }
.fb-note { flex: 1 1 auto; margin: 0; font-size: var(--text-sm); color: var(--text-2); line-height: 1.45; }
.feedback .counter { flex: none; font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.fb-note a { overflow-wrap: anywhere; }
.fb-error {
  margin: 0 0 var(--space-3); padding: var(--space-2) 10px;
  border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--line)); border-left: 3px solid var(--bad); border-radius: var(--radius-md);
  background: var(--bad-bg); color: var(--bad-ink); font-size: var(--text-sm); line-height: 1.45;
}
.fb-context { margin: 0 0 var(--space-2); padding: var(--space-2) 10px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); }
.fb-context h3 { margin: 0 0 var(--space-1); font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.fb-context dl { display: grid; gap: 2px; margin: 0; font-size: var(--text-sm); }
.fb-context dl > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--space-2); }
.fb-context dt { color: var(--text-3); }
.fb-context dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.fb-context dd code { font-size: var(--text-xs); }

.toast-host { position: fixed; left: 50%; bottom: var(--space-6); z-index: 80; transform: translateX(-50%); }
.toast {
  display: flex; align-items: center; gap: var(--space-2);
  max-width: calc(100vw - 24px); padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  background: var(--code-bg); color: var(--code-text);
  font-size: var(--text-base);
}
.toast::before { content: ""; width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--ok); }
.toast.bad::before { background: var(--bad); }

/* ---------- Narrow desktop ---------- */
@media (max-width: 1240px) and (min-width: 861px) {
  :root { --left-w: 260px; --right-w: 360px; }
  .view-bar .hint { display: none; }
}
@media (max-width: 1100px) and (min-width: 861px) {
  .top-actions .seg .label, .top-actions .feedback-btn .label, .top-actions .guide-btn .label { display: none; }
  .crumbs { display: none; }
}

/* ---------- Phone ---------- */
@media (max-width: 860px) {
  .shell { grid-template-rows: 48px minmax(0, 1fr); }
  .topbar { gap: var(--space-2); padding: 0 var(--space-2); }
  .crumbs, .top-actions .seg .label, .top-actions .feedback-btn .label, .top-actions .guide-btn .label { display: none; }
  .top-actions .feedback-btn, .top-actions .guide-btn { width: var(--control); padding: 0; }
  .modal-foot .btn { flex: 1 1 auto; height: var(--control-touch); }
  .fb-under { flex-direction: column; gap: 2px; }
  .feedback .counter { align-self: flex-end; }
  .top-actions { gap: var(--space-1); }
  .top-actions .seg button { padding: 0 6px; }

  .view-layout { display: flex; flex-direction: column; }
  .view-center { flex: 1; }
  .resizer { display: none; }
  .panel-toggle { display: inline-flex; }

  /* The sheets stop above the foot of the view, so its strip of provider lines stays in sight */
  .view-panel {
    position: fixed; left: 0; right: 0; bottom: var(--view-foot-h, 0px); z-index: 30;
    height: min(74vh, 640px, calc(100dvh - 104px - var(--view-foot-h, 0px)));
    border: 1px solid var(--line); border-bottom: 0;
    border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg);
    transform: translateY(110%); visibility: hidden;
    transition: transform 0.25s ease, visibility 0.25s;
  }
  .view-panel.left, .view-panel.right { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .view-panel.open { transform: none; visibility: visible; }
  .panel-head { position: relative; min-height: 52px; padding: 10px var(--space-2) 6px var(--space-4); }
  .grip {
    display: block; position: absolute; top: 6px; left: 50%; width: 36px; height: 4px; margin-left: -18px;
    border-radius: var(--radius-pill); background: var(--line-2); cursor: pointer;
  }
  .view-bar { flex-wrap: nowrap; overflow-x: auto; padding: 6px 8px; gap: 6px; scrollbar-width: none; }
  .view-bar .hint { display: none; }
  /* The station's button shrinks to what the bar leaves, its name cut with an ellipsis */
  .view-bar .end { margin-left: 0; flex: 0 1 auto; min-width: 0; }
  .view-bar .panel-toggle.left { flex: none; }
  .view-bar .seg { flex: none; }
  .view-bar .seg button { padding: 0 8px; }
  .panel-toggle { max-width: 140px; }

  input[type="text"], input[type="search"], input[type="number"], select, textarea { font-size: var(--text-site); }
  input[type="search"] { height: var(--control-touch); }
  .st-item { min-height: 44px; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .view-foot { flex: none; max-height: 34%; overflow-y: auto; }
  .view-sources { padding: 4px 8px 5px; }
}
/* A narrow phone: the mark alone names the tool, so every action of the bar fits */
@media (max-width: 430px) {
  .brand .name { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .view-panel { transition: none; }
  .ana-body { transition: none; }
}
