/*
 * Hydrograf web GUI: Nogat identity, Archiwista panel layout.
 * Ported from Nogat design/mockups/hydrograf (mockup.css).
 * Loads after chrome.css, which owns the shell grid, top bar, theme switch and rail.
 * Every colour, size and font comes from tokens.css; derived shades use color-mix() on tokens.
 */

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

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.d-none { 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 { letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.phone-only { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- 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); }
.btn:disabled { opacity: 0.6; cursor: default; }
.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); }
.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 svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

input[type="text"], input[type="email"], 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-2); resize: vertical; line-height: var(--line-height); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); margin: 0; }
input[type="checkbox"], input[type="radio"] { width: 15px; height: 15px; }
input[type="range"] { width: 100%; height: 16px; }

.seg.full { display: flex; }
.seg.full button { flex: 1; justify-content: center; }

.field { display: grid; gap: var(--space-1); margin: 0 0 var(--space-3); min-width: 0; }
.field > label, .field > .label { font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-2); }
.field .hint { font-size: var(--text-xs); color: var(--text-3); }
/* A number field out of the limits of the API (hydrograph.js), its message under it */
.field.is-invalid input { border-color: var(--bad); background: var(--bad-bg); }
.field.is-invalid input:focus { box-shadow: 0 0 0 var(--space-1) var(--bad-bg); }
.field-err { font-size: var(--text-xs); color: var(--bad-ink); }

/* ---------- View layout ---------- */
.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;
    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 { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-3) 14px var(--space-6); }

.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 { color: var(--text-3); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head .btn { margin-left: auto; }
.panel-head .btn + .btn { margin-left: 0; }
.grip { display: none; }

.resizer {
    grid-row: 1;
    position: relative;
    width: 10px; z-index: 24;
    cursor: col-resize; touch-action: none; outline: none;
}
#left-resizer { grid-column: 1; justify-self: end; margin-right: -5px; }
#right-resizer { 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; }

/* ---------- Layers panel (rows rendered by layers.js) ---------- */
.group { margin: 0 0 var(--space-4); }
.group-title {
    margin: var(--space-2) 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;
}
.layer {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) 36px;
    grid-template-rows: var(--control-sm) 18px;
    align-items: center; column-gap: var(--space-2);
    padding: 2px var(--space-1) 6px var(--space-2);
    border-radius: var(--radius-md);
}
.layer > input[type="checkbox"] { grid-area: 1 / 1; }
.layer .name { grid-area: 1 / 2 / 2 / 4; }
.layer > input[type="range"] { grid-area: 2 / 2; }
.layer .val { grid-area: 2 / 3; }
.layer:hover { background: var(--surface-2); }
.layer .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layer .val { font-size: var(--text-xs); color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.layer.off .name { color: var(--text-2); }
/* Row with an (i) (analysis results): the button sits in the value column of the name line */
.layer.has-info .name { grid-column: 2 / 3; }
.layer > .info-btn { grid-area: 1 / 3; justify-self: end; margin: 0; }
.layer-extra { margin: 2px 0 var(--space-2) 32px; padding: var(--space-2) var(--space-2) var(--space-1); border-left: 2px solid var(--line); }
.layer-extra .field { margin-bottom: var(--space-2); }
.layer-extra select { height: var(--control-sm); font-size: var(--text-sm); }
.radio-list { display: grid; gap: 1px; }
.radio-list label {
    display: flex; align-items: center; gap: var(--space-2);
    min-height: 30px; padding: 0 var(--space-2); border-radius: var(--radius-md); cursor: pointer;
}
.radio-list label:hover { background: var(--surface-2); }
.radio-list label:has(input:checked) { background: var(--accent-soft); }

/* ---------- Centre ---------- */
.view-center { grid-row: 1; grid-column: 2; position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.map-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    min-height: 46px; padding: 7px var(--space-3);
    background: var(--surface); border-bottom: 1px solid var(--line);
    flex: none;
}
.map-bar .hint { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: var(--text-sm); }
.map-bar .hint svg { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.map-bar .hint:has(#draw-instructions:not(.d-none)) #map-hint-text { display: none; }
.map-bar .end { margin-left: auto; display: flex; gap: var(--space-2); }

.map-wrap { position: relative; flex: 1; min-height: 0; overflow: hidden; background: var(--surface-2); }
/* Own stacking context: Leaflet panes (z 400-1000) stay below the resizers and sheets */
#map { position: absolute; inset: 0; z-index: 0; }

/* The foot of the view across its width, under the map and the panels: the strip of provider
 * lines and the statement of the service. On phones the sheets stop above it (js/shell.js
 * sets --view-foot-h) */
.view-foot { grid-row: 2; grid-column: 1 / -1; flex: none; background: var(--surface); }

/* The view's one strip of provider lines (Nogat DEV-20.5, kit nogat-sources.css: 12 px, muted) */
#view-sources { padding: var(--space-1) var(--space-3); border-top: 1px solid var(--line); }

/* ---------- Leaflet, restyled with tokens ---------- */
.map-wrap .leaflet-container {
    background: var(--surface-2);
    font: var(--text-sm)/var(--line-height) var(--font-sans);
    color: var(--text);
}
.leaflet-container { cursor: grab; }
.leaflet-container.cursor-crosshair { cursor: crosshair; }
.map-wrap .leaflet-container a { color: var(--accent); }
.basemap-grey { filter: grayscale(1); }

.map-wrap .leaflet-right .leaflet-control { margin-right: var(--space-3); }
.map-wrap .leaflet-left .leaflet-control { margin-left: var(--space-3); }
.map-wrap .leaflet-top .leaflet-control { margin-top: var(--space-3); }
.map-wrap .leaflet-bottom .leaflet-control { margin-bottom: var(--space-3); }
.map-wrap .leaflet-bottom.leaflet-left { bottom: 22px; }
.map-wrap .leaflet-bottom.leaflet-right .leaflet-control-zoom { margin-bottom: 18px; }

.map-wrap .leaflet-bar {
    border: 1px solid var(--line); border-radius: var(--radius-md);
    background: var(--surface); box-shadow: var(--shadow); overflow: hidden;
}
.map-wrap .leaflet-bar a {
    width: var(--control); height: var(--control); line-height: var(--control);
    background: transparent; color: var(--text); border-bottom: 1px solid var(--line);
    font: var(--weight-bold) 17px/var(--control) var(--font-sans); text-indent: 0;
}
.map-wrap .leaflet-bar a:first-child,
.map-wrap .leaflet-bar a:last-child { border-radius: 0; }
.map-wrap .leaflet-bar a:last-child { border-bottom: 0; }
.map-wrap .leaflet-bar a:hover, .map-wrap .leaflet-bar a:focus { background: var(--surface-2); color: var(--text); }
.map-wrap .leaflet-bar a.leaflet-disabled { background: transparent; color: var(--text-3); }

.map-wrap .leaflet-control-attribution {
    margin: 0;
    padding: 1px 6px;
    font-size: 10px; color: var(--text-3);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    border-top-left-radius: var(--radius-xs);
}
.map-wrap .leaflet-control-attribution a { color: var(--text-2); }
.map-wrap .leaflet-control-scale-line {
    border-color: var(--text); color: var(--text-2);
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    font-size: var(--text-xs); font-variant-numeric: tabular-nums;
}

.map-wrap .leaflet-popup-content-wrapper,
.map-wrap .leaflet-popup-tip {
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.map-wrap .leaflet-popup-content-wrapper { border: 1px solid var(--line); border-radius: var(--radius-lg); }
.map-wrap .leaflet-popup-content { margin: var(--space-3) var(--space-6) var(--space-3) var(--space-4); font-size: var(--text-base); line-height: var(--line-height); }
.map-wrap a.leaflet-popup-close-button { color: var(--text-3); }
.map-wrap a.leaflet-popup-close-button:hover { color: var(--text); }

.map-wrap .leaflet-tooltip {
    background: var(--surface); color: var(--text); border: 1px solid var(--line);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
    font: var(--text-sm)/var(--line-height) var(--font-sans); font-variant-numeric: tabular-nums;
}
.map-wrap .leaflet-tooltip-top::before { border-top-color: var(--surface); }
.map-wrap .leaflet-tooltip-bottom::before { border-bottom-color: var(--surface); }
.map-wrap .leaflet-tooltip-left::before { border-left-color: var(--surface); }
.map-wrap .leaflet-tooltip-right::before { border-right-color: var(--surface); }

/* Delineation preview (map.js): pulses while the server merges the boundary */
.leaflet-preview-pane.waiting { animation: preview-wait 1.6s ease-in-out infinite; }
@keyframes preview-wait { 50% { opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .leaflet-preview-pane.waiting { animation: none; } }

/* Cursor coordinates (coords.js, bottom-left under the legends); touch screens have no cursor */
.map-wrap .coord-readout {
    display: flex; align-items: center; gap: var(--space-2);
    padding: 2px var(--space-2) 2px 2px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow);
    font-size: var(--text-xs); color: var(--text); white-space: nowrap;
}
.map-wrap .coord-readout select { height: var(--control-sm); padding: 0 var(--space-1); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.coord-readout.empty .coord-value, .coord-readout .coord-zone { color: var(--text-3); }
@media (hover: none) { .map-wrap .coord-readout { display: none; } }

/* Layer legends (map.js, bottom-left) */
.layer-legend {
    width: 196px; padding: 10px var(--space-3);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow);
    font-size: var(--text-xs); color: var(--text-2); line-height: var(--line-height);
}
.layer-legend-title { margin: 0 0 6px; font-weight: var(--weight-bold); color: var(--text); }
.legend-gradient { height: 10px; border-radius: var(--radius-xs); border: 1px solid var(--line); }
.legend-labels { display: flex; justify-content: space-between; margin-top: 3px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.legend-item { display: flex; align-items: center; gap: var(--space-2); margin: 2px 0; }
.legend-swatch { width: 16px; height: 10px; flex: none; border-radius: 2px; border: 1px solid var(--line); }
.legend-line { width: 32px; height: 16px; flex: none; }
.layer-legend-note { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }

/* ---------- Profile drawer ---------- */
.profile-drawer {
    position: absolute; left: var(--space-3); right: var(--space-3); bottom: var(--space-3); z-index: 4;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
/* Tools over the top of the map: drawing a profile (map.js), what „Wybierz zlewnię” delineates (app.js) */
.map-tools {
    position: absolute; top: var(--space-3); left: 50%; transform: translateX(-50%); z-index: 5;
    display: flex; align-items: center; gap: var(--space-2); max-width: calc(100% - 2 * var(--space-3));
    padding: var(--space-1) var(--space-2); background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-md); box-shadow: var(--shadow);
}
.map-tools[hidden] { display: none; }
.map-tools .draw-count { color: var(--text-2); font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.profile-drawer .panel-head { min-height: 40px; }
.profile-drawer .panel-head h2 { font-size: var(--text-base); }
.profile-drawer .chart { margin: 0; padding: var(--space-2) var(--space-3) var(--space-3); }
.profile-drawer .notice { margin-bottom: var(--space-2); }
/* With the drawer open, legends step aside and the zoom moves to the top (mockup) */
.map-wrap:has(> .profile-drawer:not([hidden])) .leaflet-bottom.leaflet-left { display: none; }
.map-wrap:has(> .profile-drawer:not([hidden])) .leaflet-bottom.leaflet-right { top: 0; bottom: auto; }
.map-wrap:has(> .profile-drawer:not([hidden])) .leaflet-bottom.leaflet-right .leaflet-control-zoom { margin-top: var(--space-3); margin-bottom: var(--space-2); }

/* ---------- Results panel ---------- */
#panel-instruction { margin: 0; font-size: var(--text-sm); }
.loading {
    display: flex; align-items: center; justify-content: center; gap: var(--space-2);
    padding: var(--space-6) 0; color: var(--text-2); font-size: var(--text-sm);
}
.spinner {
    width: 16px; height: 16px; flex: none;
    border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.summary {
    display: grid; grid-template-columns: repeat(var(--kpi-count, 4), minmax(0, 1fr)); gap: 1px;
    margin: 0 0 var(--space-3);
    background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden;
}
.kpi { padding: var(--space-2) 10px; background: var(--surface); min-width: 0; }
.kpi .k { font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .v { font-size: var(--text-md); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .u { font-size: var(--text-xs); color: var(--text-2); font-weight: var(--weight-regular); }

.notice {
    display: flex; gap: var(--space-2); align-items: flex-start;
    margin: 0 0 var(--space-3); padding: var(--space-2) 10px;
    border-radius: var(--radius-md); background: var(--info-bg); color: var(--info-ink); font-size: var(--text-sm);
}
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.bad { background: var(--bad-bg); color: var(--bad-ink); }
.notice.has-action { flex-direction: column; }
.notice svg { width: 15px; height: 15px; flex: none; margin-top: 1px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

.steps { display: grid; gap: var(--space-2); counter-reset: step; }
.steps + .notice, .hydro-notices { margin-top: var(--space-2); }
.step { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.step:not(.d-none) { counter-increment: step; }
.step > summary {
    display: flex; align-items: center; gap: 10px;
    padding: 10px var(--space-3); list-style: none; cursor: pointer; user-select: none;
    border-radius: var(--radius-lg);
}
.step > summary::-webkit-details-marker { display: none; }
.step > summary:hover { background: var(--surface-2); }
.step-num {
    width: 22px; height: 22px; flex: none;
    display: grid; place-items: center; border-radius: 50%;
    background: var(--surface-2); color: var(--text-2);
    font-size: var(--text-xs); font-weight: var(--weight-bold); font-variant-numeric: tabular-nums;
}
.step-num::before { content: counter(step); }
.step .title { font-weight: var(--weight-bold); }
.step .meta { margin-left: auto; color: var(--text-3); font-size: var(--text-xs); white-space: nowrap; font-variant-numeric: tabular-nums; }
.step .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); }
.step[open] { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); box-shadow: 0 0 0 3px var(--accent-soft); }
.step[open] > summary { border-bottom: 1px solid var(--line); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.step[open] .step-num { background: var(--accent); color: var(--accent-ink); }
.step[open] .chev { transform: rotate(180deg); }
.step-body { padding: var(--space-3); }
.step-body > :last-child { margin-bottom: 0; }

.params { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.params th, .params td { padding: 6px 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-2); }
.params td { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.params td.u { width: 64px; padding-left: 6px; text-align: left; color: var(--text-3); font-size: var(--text-sm); }
.params tbody tr:hover th, .params tbody tr:hover td { background: var(--surface-2); }

/* Water balance and hydrograph metadata (hydrograph.js) */
.balance-table { width: 100%; border-collapse: collapse; margin: 0 0 var(--space-3); font-size: var(--text-sm); }
.balance-table td { padding: 4px 0; border-bottom: 1px solid var(--line); color: var(--text-2); vertical-align: baseline; }
.balance-table tr:last-child td { border-bottom: 0; }
.balance-table td:last-child { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: var(--space-2); }
/* Export of the hietogram and its PMAXTP points (rain-export.js) */
.rain-export { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); }
.rain-export-label { font-size: var(--text-sm); color: var(--text-2); }
@media (max-width: 860px) {
    .rain-export .btn { height: var(--control-touch); }
}
.hydro-summary {
    margin: 0 0 var(--space-3); padding: var(--space-2) 10px;
    border: 1px solid color-mix(in srgb, var(--info) 45%, var(--line)); border-radius: var(--radius-md);
    background: var(--info-bg); color: var(--info-ink);
    font-size: var(--text-sm); font-weight: var(--weight-bold);
}

.chart { margin: 0 0 var(--space-3); }
.chart-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 6px; font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-2); }
.chart-title span { font-weight: var(--weight-regular); color: var(--text-3); font-size: var(--text-xs); }
.chart-container { position: relative; height: 220px; }
/* Percentage max-width drops the canvas min-content width, so columns can shrink */
.chart-container canvas { max-width: 100%; }
.chart-container.chart-sm { height: 170px; }
.chart-container.chart-md { height: 180px; }
.chart-container.chart-profile { height: 170px; }

/* Chart legends and share bars (charts.js; marker colours set from the tokens) */
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin-top: 6px; font-size: var(--text-xs); color: var(--text-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: var(--space-4); height: 3px; flex: none; border-radius: 2px; }
.chart-container.chart-stack { height: var(--space-4); margin: 0 0 var(--space-2); border-radius: var(--radius-xs); overflow: hidden; }
.share-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.share-list li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; align-items: center; gap: var(--space-2); min-height: 24px; font-size: var(--text-sm); }
.share-list .dot { width: 10px; height: 10px; border-radius: 2px; }
.share-list .pct { font-variant-numeric: tabular-nums; font-weight: var(--weight-bold); text-align: right; min-width: 44px; }
.share-list .x { color: var(--text-3); font-size: var(--text-xs); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }

/* ---------- Explanation markers and applicability notes (info.js) ---------- */
.info-label { display: flex; align-items: center; gap: var(--space-1); min-width: 0; }
.info-btn {
    position: relative; display: inline-grid; place-items: center; flex: none;
    width: 15px; height: 15px; margin: 0 0 0 var(--space-1); padding: 0;
    border: 1px solid var(--line-2); border-radius: 50%;
    background: var(--surface); color: var(--text-3);
    font-family: var(--font-sans); font-size: var(--text-xs); font-style: normal; font-weight: var(--weight-bold); line-height: 1;
    vertical-align: 1px; cursor: pointer;
}
.info-label .info-btn { margin-left: 0; }
/* Larger hit area than the glyph, for touch */
.info-btn::after { content: ""; position: absolute; inset: -7px; }
.info-btn:hover, .info-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.info-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.info-tip {
    position: fixed; top: 0; left: 0; z-index: 50;
    max-width: 360px; padding: var(--space-3);
    overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
    border: 1px solid var(--line-2); border-radius: var(--radius-md);
    background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-lg);
    font-size: var(--text-sm); font-weight: var(--weight-regular); line-height: var(--line-height);
    overflow-wrap: break-word;
}
.info-tip[hidden] { display: none; }
.info-tip :where(p) { margin: 0; }
/* Formulas: the platform math font (MathML), body text keeps Lato */
.info-tip math { font-family: math, "STIX Two Math", "Cambria Math", "Latin Modern Math", serif; font-size: var(--text-base); color: var(--text); }
.info-tip-head { margin: 0 0 var(--space-1); color: var(--text); font-size: var(--text-base); font-weight: var(--weight-bold); }
.info-tip-head math { font-weight: var(--weight-regular); }
.info-tip-def, .info-tip-read { margin-bottom: var(--space-2); }
.info-tip-formula {
    display: grid; gap: var(--space-2); margin: 0 0 var(--space-2); padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm); background: var(--surface-2); overflow-x: auto;
}
.info-tip-formula math { font-size: var(--text-md); }
.info-tip-k { color: var(--text-3); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.info-tip-where { margin: 0 0 var(--space-2); }
.info-tip-vars { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px var(--space-2); margin: 2px 0 0; }
.info-tip-vars dt { color: var(--text); font-weight: var(--weight-regular); }
.info-tip-vars dd { margin: 0; }
.info-tip-u { color: var(--text-3); white-space: nowrap; }
.info-tip-unit { margin-bottom: var(--space-2); }
.info-tip-src, .info-tip-more { margin-top: var(--space-2); color: var(--text-3); font-size: var(--text-xs); }
.info-tip-src .info-tip-k { color: var(--text-2); }
.info-tip-more a { color: var(--accent); }
.info-tip-option { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--line); }
.info-tip-option > .info-tip-k { margin-bottom: 2px; }
.info-note { margin: 0; font-size: var(--text-xs); line-height: var(--line-height); color: var(--text-3); }
.info-note[hidden] { display: none; }
.info-note-k { font-weight: var(--weight-bold); color: var(--text-2); }
.info-nowrap { white-space: nowrap; }
.hydro-stat { display: inline-flex; align-items: center; margin-right: var(--space-4); white-space: nowrap; }
.hydro-stat:last-child { margin-right: 0; }

/* ---------- Hietogram and Hydrogram forms: 2-column grid (hydrograph.js, custom-rain.js) ---------- */
/* Two columns at every width. A field spans three rows (label, control, applicability
   note), so neighbours keep labels and controls in line when a label wraps or only one
   of them has a note; hidden fields leave no hole. */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-3); }
.form-grid > .field { grid-row: span 3; grid-template-rows: subgrid; row-gap: 0; }
.form-grid > .field.wide { grid-column: 1 / -1; }
.form-grid > .field > :first-child { align-self: end; margin-bottom: var(--space-1); }
.form-grid > .field > .info-note { margin-top: var(--space-1); }
/* Snyder ignores Tc: its method is greyed out, with a note why instead of its
   applicability note (hydrograph.js) */
.form-grid select:disabled { background: var(--surface-2); color: var(--text-3); cursor: not-allowed; }
#hydro-tc-method:disabled + .info-note { display: none; }

/* ---------- Own rainfall series, Hietogram section (custom-rain.js) ---------- */
.custom-rain { margin: 0 0 var(--space-3); }
.custom-rain-title { margin: 0 0 var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text); }
.custom-rain-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-2); }
.custom-rain-hint { margin: 0 0 var(--space-2); font-size: var(--text-xs); color: var(--text-3); }
.custom-rain-hint code { font-family: var(--font-mono); color: var(--text-2); }
.custom-rain-table {
    max-height: calc(var(--space-16) * 4); overflow-y: auto; margin: 0 0 var(--space-2);
    border: 1px solid var(--line); border-radius: var(--radius-md);
}
/* Separate borders: a collapsed border would scroll away from the sticky header */
.custom-rain-table table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.custom-rain-table th, .custom-rain-table td { padding: calc(var(--space-1) / 2) var(--space-2); text-align: right; }
.custom-rain-table thead th {
    position: sticky; top: 0; z-index: 1;
    padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--line); background: var(--surface-2);
    font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--text-2);
}
.custom-rain-table tbody th { width: 40%; font-weight: var(--weight-regular); color: var(--text-3); }
.custom-rain-table tbody tr + tr > * { border-top: 1px solid var(--line); }
.custom-rain-table input { width: 100%; height: var(--control-sm); text-align: right; font-variant-numeric: tabular-nums; }
.custom-rain input.is-invalid { border-color: var(--bad); background: var(--bad-bg); }
.custom-rain input.is-invalid:focus { box-shadow: 0 0 0 var(--space-1) var(--bad-bg); }
.custom-rain-sum { margin: 0 0 var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-2); }
.custom-rain .notice { margin-bottom: var(--space-2); }

/* ---------- Advanced mode, Hydrogram section (advanced.js) ---------- */
.adv { margin: 0 0 var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--line); }
.adv-switch {
    display: flex; align-items: center; gap: var(--space-2);
    font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-2); cursor: pointer;
}
.adv-switch input[type="checkbox"] {
    appearance: none; position: relative; flex: none;
    width: var(--space-8); height: calc(var(--space-4) + var(--space-1)); border-radius: var(--radius-pill);
    background: var(--line-2); cursor: pointer; transition: background var(--transition);
}
.adv-switch input[type="checkbox"]::before {
    content: ""; position: absolute; top: var(--space-1); left: var(--space-1); width: var(--space-3); height: var(--space-3);
    border-radius: 50%; background: var(--text-3); transition: transform var(--transition), background var(--transition);
}
.adv-switch input[type="checkbox"]:checked { background: var(--accent); }
.adv-switch input[type="checkbox"]:checked::before { transform: translateX(var(--space-3)); background: var(--accent-ink); }
.adv-count { margin-left: auto; font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--warn-ink); }
.adv-form { margin-top: var(--space-3); container-type: inline-size; }
.adv-intro { margin: 0 0 var(--space-3); font-size: var(--text-xs); color: var(--text-3); }
.adv-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-3); }
.adv-field { display: grid; grid-template-rows: subgrid; grid-row: span 4; row-gap: calc(var(--space-1) / 2); margin: 0 0 var(--space-3); min-width: 0; }
.adv-field > label {
    display: flex; align-items: flex-end; gap: var(--space-1); min-width: 0;
    font-size: var(--text-sm); font-weight: var(--weight-bold); color: var(--text-2);
}
.adv-flag { display: none; }
.adv-field.is-edited .adv-flag {
    display: inline-block; flex: none; width: var(--space-2); height: var(--space-2); margin-bottom: var(--space-1);
    border-radius: 50%; background: var(--warn); overflow: hidden; text-indent: 100%; white-space: nowrap;
}
.adv-line { display: grid; grid-template-columns: minmax(0, 1fr) var(--space-12) auto; align-items: center; gap: var(--space-1); }
.adv-line input { width: 100%; font-variant-numeric: tabular-nums; }
.adv-unit { font-size: var(--text-xs); color: var(--text-3); white-space: nowrap; }
.adv-reset:disabled { visibility: hidden; }
.adv-field.is-edited input { border-color: var(--warn); background: var(--warn-bg); color: var(--text); }
.adv-field.is-invalid input { border-color: var(--bad); background: var(--bad-bg); }
.adv-field.is-invalid input:focus { box-shadow: 0 0 0 var(--space-1) var(--bad-bg); }
.adv-orig { font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.adv-err { font-size: var(--text-xs); color: var(--bad-ink); }
.adv-form > .notice { margin-bottom: var(--space-2); }
/* Two columns only while an input keeps room for its value next to the unit and reset */
@container (max-width: 319px) {
    .adv-fields { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
    .adv-fields { grid-template-columns: minmax(0, 1fr); }
    .adv-switch input[type="checkbox"] { width: calc(var(--space-8) + var(--space-3)); height: var(--space-6); }
    .adv-switch input[type="checkbox"]::before { width: var(--space-4); height: var(--space-4); }
    .adv-switch input[type="checkbox"]:checked::before { transform: translateX(calc(var(--space-4) + var(--space-1))); }
    .adv-line .btn.adv-reset { width: var(--control-touch); height: var(--control-touch); }
}

/* ---------- Hand-off to Hydrolog, below the sections of the results panel (handoff.js) ---------- */
.handoff {
    margin-top: var(--space-3); padding: var(--space-3);
    border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface);
}
.handoff-head { display: flex; align-items: baseline; gap: var(--space-2); margin: 0 0 var(--space-1); }
.handoff-head h3 { margin: 0; font-size: var(--text-base); font-weight: var(--weight-bold); }
.handoff-head .meta { margin-left: auto; color: var(--text-3); font-size: var(--text-xs); white-space: nowrap; }
.handoff-note { margin: 0 0 var(--space-3); font-size: var(--text-sm); color: var(--text-2); }
.handoff-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.handoff-status { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--ok-ink); }
.handoff-status:empty { display: none; }
.handoff-status a { color: var(--accent); }
.handoff-fallback { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
/* The kit's copy shows and hides the field; its box follows it */
.handoff-fallback:has(> textarea[hidden]) { display: none; }
.handoff-fallback label { font-size: var(--text-sm); color: var(--text-2); }
.handoff-fallback textarea { width: 100%; font-family: var(--font-mono); font-size: var(--text-xs); }
.handoff-fallback .btn { justify-self: start; }
@media (max-width: 860px) {
    .handoff-actions .btn { height: var(--control-touch); }
    .handoff-fallback textarea { font-size: var(--text-site); }
}

/* ---------- „Wybierz zlewnię” → „Sieć zlewni”: its section of the results panel and its map labels (network.js) ---------- */
/* The network view hides the parts of the watershed; the sections of the parameters
   show only for a selected element (app.js: data-view, data-element) */
#results-panel[data-view="network"] #panel-instruction,
#results-panel[data-view="network"] #panel-auto-select-info,
#results-panel[data-view="network"] #acc-hietogram,
#results-panel[data-view="network"] #acc-hydrograph,
#results-panel[data-view="network"] #hydrograph-limit,
#results-panel[data-view="network"] #hydrograph-notices,
#results-panel[data-view="network"]:not([data-element]) #panel-results { display: none !important; }
#results-panel[data-view="network"][data-element] #panel-results { display: block !important; }

.network { margin: 0 0 var(--space-3); }
.network-intro { margin: 0 0 var(--space-1); font-size: var(--text-sm); color: var(--text-2); }
.network-snap { margin: 0 0 var(--space-3); font-size: var(--text-xs); color: var(--text-3); }
.network-points { display: grid; gap: var(--space-1); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.network-empty { font-size: var(--text-sm); color: var(--text-3); }
.net-point {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2);
    padding: var(--space-1) var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-md);
}
.net-point.is-bad { border-color: var(--bad); background: var(--bad-bg); }
.net-point-body { display: grid; gap: 2px; min-width: 0; }
.net-point-body input { width: 100%; height: var(--control-sm); font-size: var(--text-sm); }
.net-point-meta { font-size: var(--text-xs); color: var(--text-3); }
.net-point-meta.is-approx { color: var(--text-2); }
.net-badge {
    display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px;
    border: 2px solid var(--text); border-radius: var(--radius-pill); background: var(--surface);
    font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--text);
}
.net-point.is-outlet .net-badge { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.net-point.is-bad .net-badge { border-color: var(--bad); }
.network-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); }
/* The preview of the points on its way: small, beside the buttons; the panel's spinner is for the characteristics */
.network-pending { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-3); }
.network-pending .spinner { width: 12px; height: 12px; border-width: 1.5px; }

.network-result.is-outdated { opacity: 0.55; }
.network-stage { margin: 0 0 var(--space-2); font-size: var(--text-xs); color: var(--text-3); }
.network-result > .summary { --kpi-count: 4; }
.network-kinds { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin: 0 0 var(--space-2); padding: 0; list-style: none; font-size: var(--text-sm); }
.net-kind-item { display: inline-flex; align-items: center; gap: 6px; }
.net-swatch { width: 16px; height: 10px; flex: none; border: 1.5px solid; border-radius: 2px; }
.net-swatch.headwater, .net-id.headwater, .net-label.headwater { --kind: var(--warn); }
.net-swatch.intermediate, .net-id.intermediate, .net-label.intermediate { --kind: var(--tool-hydraulik); }
.net-id.reach, .net-label.reach { --kind: var(--info); }
.net-id.junction { --kind: var(--text-3); }
.net-swatch { border-color: var(--kind); background: color-mix(in srgb, var(--kind) 25%, var(--surface)); }

.network-tree { width: 100%; border-collapse: collapse; margin: 0 0 var(--space-3); font-size: var(--text-sm); }
.network-tree caption { caption-side: top; text-align: left; margin: 0 0 var(--space-1); font-size: var(--text-xs); color: var(--text-3); }
.network-tree thead th { padding: 0 0 4px; border-bottom: 1px solid var(--line-2); text-align: left; font-size: var(--text-xs); font-weight: var(--weight-regular); color: var(--text-3); }
.network-tree thead th:not(:first-child) { text-align: right; }
.network-tree th, .network-tree td { padding: 3px 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.network-tree tbody th {
    padding-left: calc(var(--depth, 0) * 14px); text-align: left; font-weight: var(--weight-regular); color: var(--text-2);
}
.network-tree tbody td { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.network-tree tbody td.u { padding-left: 4px; text-align: left; color: var(--text-3); font-size: var(--text-xs); }
.network-tree tr.is-junction th { color: var(--text-3); }
.network-tree tr.is-selected th, .network-tree tr.is-selected td { background: var(--accent-soft); }
.net-row-btn {
    display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit;
    font: inherit; text-align: left; cursor: pointer;
}
.net-row-btn:hover { color: var(--text); text-decoration: underline; }
.net-id {
    display: inline-block; min-width: 26px; padding: 0 4px; margin-right: 2px;
    border: 1px solid var(--kind); border-radius: var(--radius-xs);
    background: color-mix(in srgb, var(--kind) 14%, var(--surface));
    font-size: var(--text-xs); font-weight: var(--weight-bold); text-align: center; color: var(--text);
}
.network-selection { margin: 0 0 var(--space-3); padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.network-selection-head { display: flex; align-items: center; gap: var(--space-2); }
.network-selection-head h3 { flex: 1; margin: 0; font-size: var(--text-base); font-weight: var(--weight-bold); }
.network-selection-kind { margin: var(--space-1) 0 0; font-size: var(--text-sm); color: var(--text-2); }
.network-selection-kind:empty { display: none; }
.network-selection .params { margin-top: var(--space-2); }
.network-selection .params:has(tbody:empty) { display: none; }
.net-kind { font-weight: var(--weight-bold); color: var(--text); }

/* Point markers (the closing section, J1, P1, …) and the labels of the elements and reaches */
.net-marker span {
    display: grid; place-items: center; width: 28px; height: 28px; box-sizing: border-box;
    border: 2px solid var(--text); border-radius: var(--radius-pill); background: var(--surface);
    box-shadow: var(--shadow); font: var(--weight-bold) var(--text-xs)/1 var(--font-sans); color: var(--text);
}
.net-marker.is-outlet span { border-color: var(--surface); background: var(--accent); color: var(--accent-ink); }
/* A point drawn to a node of the network (N3) */
.net-marker.at-node span { border-style: double; border-width: 4px; }
.net-marker.is-bad span { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 45%, transparent); }
/* A point inside its unit in the preview: the outline of its elements follows the whole unit */
.net-marker.inside-unit span { border-style: dashed; }
.net-marker.inside-unit::after {
    content: "≈"; position: absolute; top: -6px; right: -8px;
    display: grid; place-items: center; min-width: 16px; height: 16px; padding: 0 2px; box-sizing: border-box;
    border: 1.5px solid var(--text); border-radius: var(--radius-pill); background: var(--surface);
    font: var(--weight-bold) var(--text-xs)/1 var(--font-sans); color: var(--text);
}
.net-label span {
    display: inline-block; transform: translate(-50%, -50%); padding: 1px 5px; white-space: nowrap;
    border: 1.5px solid var(--kind); border-radius: var(--radius-xs); background: var(--surface);
    box-shadow: var(--shadow-sm); font: var(--weight-bold) var(--text-xs)/1.3 var(--font-sans); color: var(--text);
    cursor: pointer;
}
.net-label.is-selected span { background: var(--kind); color: var(--surface); }
@media (max-width: 860px) {
    .network-actions .btn { height: var(--control-touch); }
    .net-point-body input { height: var(--control-touch); font-size: var(--text-site); }
}

/* ---------- Feedback dialog ---------- */
dialog.modal {
    width: min(520px, calc(100% - 32px)); max-height: calc(100vh - 32px); overflow: auto;
    padding: 0;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: color-mix(in srgb, var(--code-bg) 45%, transparent); }
.modal .panel-head { min-height: 52px; padding-left: var(--space-4); }
.modal-body { padding: var(--space-4); }
.modal-body p { margin: 0 0 var(--space-3); color: var(--text-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--line); background: var(--bg); }
.counter { justify-self: end; font-size: var(--text-xs); color: var(--text-3); }
.check { display: flex; gap: var(--space-2); align-items: flex-start; font-size: var(--text-sm); color: var(--text-2); }
.check input { margin-top: 2px; flex: none; }
#feedback-form textarea:disabled { background: var(--surface-2); color: var(--text-2); cursor: not-allowed; }
#feedback-form .hint a { color: var(--accent); }
.modal-body p.muted { color: var(--text-3); font-size: var(--text-sm); }
.modal-body .feedback-status { margin: var(--space-3) 0 0; font-size: var(--text-sm); font-weight: var(--weight-bold); }
.modal-body .feedback-status.ok { color: var(--ok-ink); }
.modal-body .feedback-status.bad { color: var(--bad-ink); }

/* ---------- Welcome dialog ---------- */
.welcome #welcome-text p { color: var(--text); font-size: var(--text-site); line-height: var(--line-height); }
.welcome .check { margin-top: var(--space-1); }
/* The full provider lines and the terms, as the dialog of the strip shows them (kit fillSources, nogat-sources.css) */
.welcome-sources { margin: 0 0 var(--space-3); padding-top: var(--space-1); border-top: 1px solid var(--line); }
.welcome-sources .nogat-sources-regulamin { margin: var(--space-3) 0 0; }

/* ---------- Narrow desktop: panels at their minimum ---------- */
@media (max-width: 1240px) and (min-width: 861px) {
    :root { --left-w: 260px; --right-w: 340px; }
    .map-bar .hint { display: none; }
}

@media (min-width: 861px) {
    .view-panel.collapsed { display: none; }
    .phone-only.show { display: inline-flex !important; }
}

/* ---------- Phone ---------- */
@media (max-width: 860px) {
    .view-layout { display: flex; flex-direction: column; }
    .view-center { flex: 1; }
    .resizer { display: none; }
    .phone-only { display: inline-flex !important; }

    .view-panel {
        /* Above the rail and the foot of the view, so the strip of provider lines stays in sight */
        position: fixed; left: 0; right: 0; bottom: calc(58px + var(--view-foot-h, 0px)); z-index: 30;
        height: min(74vh, 640px, calc(100vh - 114px - 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.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;
    }
    /* A finger-sized target around the thin handle */
    .grip::before { content: ""; position: absolute; inset: -6px -14px -8px; }

    /* Two rows: the sheet buttons, then the four modes across the full width */
    .map-bar { row-gap: 6px; padding: 6px 10px; }
    .map-bar .hint { display: none; }
    .map-bar .end { margin-left: auto; }
    #mode-toolbar { order: 1; flex: 1 0 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
    #mode-toolbar button {
        height: auto; min-height: 36px; padding: 3px var(--space-1);
        justify-content: center; text-align: center; white-space: normal; line-height: 1.15;
    }
    .layer-legend { width: 170px; }
    /* Attribution wraps to two lines here (base map + MZP or NMT); legends stay above it */
    .map-wrap .leaflet-bottom.leaflet-left { bottom: 36px; }
    .profile-drawer { left: var(--space-2); right: var(--space-2); bottom: var(--space-2); }
    .map-tools { top: var(--space-2); left: var(--space-2); right: var(--space-2); transform: none; max-width: none; flex-wrap: wrap; justify-content: center; }
    .map-tools .seg.full { flex: 1; }
    .map-tools .draw-count { flex-basis: 100%; text-align: center; white-space: normal; }

    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .layer { grid-template-columns: 18px minmax(0, 1fr) 40px; grid-template-rows: var(--control) 22px; }

    input[type="text"], input[type="email"], input[type="number"], select, textarea { font-size: var(--text-site); height: var(--control-touch); }
    textarea { height: auto; }
    .layer-extra select { height: var(--control-touch); font-size: var(--text-site); }
    dialog.modal {
        width: 100%; max-width: 100%; max-height: 92vh;
        margin: auto 0 0; border-bottom: 0;
        border-radius: 16px 16px 0 0;
    }
}

/* ---------- Point card (identify mode, identify.js) ---------- */
.identify-card {
    position: absolute; top: var(--space-3); right: var(--space-3); z-index: 4;
    display: flex; flex-direction: column;
    width: min(360px, calc(100% - 2 * var(--space-3)));
    max-height: calc(100% - 2 * var(--space-3));
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.identify-card .panel-head { min-height: 40px; }
.identify-card .panel-head h2 { font-size: var(--text-base); }
.identify-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--space-2) var(--space-3) var(--space-3); }
.identify-body > .notice { margin: var(--space-1) 0 0; }
.identify-section + .identify-section { margin-top: var(--space-3); padding-top: var(--space-2); border-top: 1px solid var(--line); }
.identify-section 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;
}
.identify-section .params { font-size: var(--text-sm); }
/* Short labels stay on one line; names of streams, water bodies and results wrap */
.identify-section .params th { white-space: nowrap; }
.identify-section .params td { white-space: normal; overflow-wrap: anywhere; }
.identify-section .params th.identify-subhead { padding-top: var(--space-2); white-space: normal; color: var(--text); font-weight: var(--weight-bold); }
.identify-source, .identify-note { margin: var(--space-1) 0 0; font-size: var(--text-xs); color: var(--text-3); }
.identify-coords {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
    column-gap: var(--space-2); row-gap: 2px;
    margin: 0 0 var(--space-1); font-size: var(--text-sm);
}
.identify-coords .k { color: var(--text-2); }
.identify-coords .v { overflow-wrap: anywhere; }
/* Off-screen field of the copy fallback (no Clipboard API over plain HTTP) */
.identify-clip { position: fixed; top: 0; left: -9999px; opacity: 0; }

@media (max-width: 860px) {
    /* A sheet at the bottom of the map, like the profile drawer */
    .identify-card { top: auto; left: var(--space-2); right: var(--space-2); bottom: var(--space-2); width: auto; max-height: 58%; }
}
