:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2430;
  --muted: #667085;
  --line: #e2e6ec; /* separators (decorative) */
  --field-line: #858e9c; /* borders of inputs and outline buttons: ≥ 3:1 on the panel */
  --accent: #1565c0; /* white text on it ≥ 4.5:1; also link and badge text */
  --accent-ink: #ffffff;
  --accent-soft: #e3f0fc;
  --ok: #2e7d32;
  --warn: #9a5b00;
  --bad: #c62828;
  --toast-bad: #c62828; /* white text on it, both themes */
  --focus: #1565c0;
  --radius: 8px;
  --shadow: 0 2px 10px rgba(16, 24, 40, .12);
  --tb-btn: 36px; /* toolbar button */
  --float-w: 360px; /* floating panel (wide screens) */
  --sidebar-w: 380px; /* sidebar (wide screens; 0 under the phone layout) */
  /* messages (toast, busy popup): upper middle of the open map, clear of the toolbar and the zoom buttons */
  --msg-top: max(64px, 28vh);
  --msg-left: calc(var(--tb-btn) + 24px); /* the toolbar column at the map's left edge */
  color-scheme: light;
}
/* Dark tokens: the same set in both blocks (system setting and explicit choice). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --panel: #1a2029; --text: #e6e9ef; --muted: #98a2b3; --line: #2b3440; --field-line: #7a8596;
    --accent: #4aa3f0; --accent-ink: #0b1220; --accent-soft: #1d3247;
    --ok: #66bb6a; --warn: #f0a33a; --bad: #ff6b6b; --focus: #7cc0ff; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --panel: #1a2029; --text: #e6e9ef; --muted: #98a2b3; --line: #2b3440; --field-line: #7a8596;
  --accent: #4aa3f0; --accent-ink: #0b1220; --accent-soft: #1d3247;
  --ok: #66bb6a; --warn: #f0a33a; --bad: #ff6b6b; --focus: #7cc0ff; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px;
  padding: 6px 12px; cursor: pointer;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--field-line); }
button.danger { background: var(--toast-bad); color: #fff; }
button.small { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: .45; cursor: default; }
input, select {
  background: var(--panel); border: 1px solid var(--field-line); border-radius: 6px; padding: 5px 8px; min-width: 0;
}
input[type="number"] { width: 100%; }
input[type="range"] { width: 100%; padding: 0; }
input[type="checkbox"] { width: auto; }
label { display: block; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
h3:first-child { margin-top: 4px; }
/* keyboard focus: always visible, in the theme's focus colour */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.toolbar button:focus-visible, .panel-head button:focus-visible { outline-offset: 0; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
  /* above the map's toolbar and hint (6) and the sheet (10): the address results and the phone menu drop over them */
  z-index: 11;
}
.brand { display: flex; align-items: center; gap: 6px; font-weight: 650; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; fill: var(--accent); }
.search { position: relative; display: flex; gap: 6px; flex: 1 1 280px; max-width: 520px; }
.search input { flex: 1; }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px 0; list-style: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 20;
  max-height: 50vh; overflow: auto;
}
.search-results li { padding: 6px 10px; cursor: pointer; }
.search-results li:hover, .search-results li:focus { background: var(--accent-soft); }
.search-results li:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.search-results li small { display: block; color: var(--muted); font-size: 12px; }
.topbar-right { display: flex; gap: 6px; align-items: center; margin-left: auto; }
#imagery { max-width: 240px; }

/* ---------------------------------------------------------------- layout */
.layout { flex: 1; display: flex; min-height: 0; }
.map-wrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: #2a2f36; }
#map.white-map { background: #fff; }
.sidebar {
  position: relative; width: var(--sidebar-w); display: flex; flex-direction: column; background: var(--panel);
  border-left: 1px solid var(--line); min-height: 0;
}
/* the current view (#panel) and, while it floats, the sidebar's overview (#overview) */
.panel { display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--panel); }
.panel[hidden] { display: none; }
.panel-head h2:focus { outline: none; }
.panel-head h2:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.head-tools { display: none; }

/* wide screens: anything but the overview floats left of the sidebar, over the map */
@media (min-width: 821px) {
  body.floating { --float-space: calc(var(--float-w) + 24px); }
  body.floating #panel {
    position: absolute; z-index: 8; top: 12px; right: calc(100% + 12px); width: var(--float-w); max-height: calc(100% - 24px);
    flex: none; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 28px rgba(16, 24, 40, .3); overflow: hidden;
  }
  body.floating #panel .panel-body { padding-bottom: 16px; }
  /* map overlays stay clear of it */
  body.floating .legend { right: calc(var(--float-space) + 8px); }
  body.floating .ol-attribution { right: calc(var(--float-space) + .5em); }
}
@media (min-width: 821px) and (max-width: 1100px) {
  :root { --float-w: 320px; }
}


/* ---------------------------------------------------------------- map UI */
.toolbar {
  position: absolute; top: 80px; left: 8px; display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); padding: 4px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.toolbar button { width: var(--tb-btn); height: var(--tb-btn); padding: 6px; background: transparent; color: var(--text); }
.toolbar button svg { width: 100%; height: 100%; fill: currentColor; stroke: currentColor; }
.toolbar button.active { background: var(--accent); color: var(--accent-ink); }
.toolbar hr { border: 0; border-top: 1px solid var(--line); margin: 2px 0; width: 100%; }
/* ruler and overview: in line on wide screens, behind "Meer" on phones */
.tb-more { display: contents; }
.toolbar .tb-more-btn, .tb-label { display: none; }
.head-tools button { width: var(--tb-btn); height: var(--tb-btn); padding: 6px; background: transparent; color: var(--text); flex: none; }
.head-tools button svg { width: 100%; height: 100%; fill: none; stroke: currentColor; }
.hint {
  position: absolute; left: calc((100% - var(--float-space, 0px)) / 2); top: 10px; transform: translateX(-50%);
  width: max-content; max-width: calc(100% - var(--float-space, 0px) - 120px);
  background: rgba(20, 24, 30, .82); color: #fff; padding: 6px 12px; border-radius: 20px; font-size: 13px;
  pointer-events: none; text-align: center;
}
.hint:empty { display: none; }
/* the hint's button ("Verdeler verplaatsen"): clickable in the click-through hint */
.hint.has-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; }
.hint .hint-action {
  pointer-events: auto; background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 14px; padding: 2px 10px; font-size: 12px; min-height: 26px; cursor: pointer;
}
.hint .hint-action[aria-pressed="true"] { background: #fff; color: #10141a; border-color: #fff; }
.legend {
  position: absolute; right: 8px; bottom: 30px; background: var(--panel); padding: 8px 10px;
  border-radius: var(--radius); box-shadow: var(--shadow); font-size: 12px; min-width: 180px;
}
.legend .bar { height: 10px; border-radius: 3px; margin: 4px 0 2px; }
/* ticks sit at their value's place on the bar (linear to 2×, log beyond) */
.legend .ticks { position: relative; height: 15px; color: var(--muted); }
.legend .ticks span { position: absolute; top: 0; white-space: nowrap; }
.ol-attribution { font-size: 11px; }
.ol-zoom { top: 8px; left: 8px; }
.ol-scale-line { left: 8px; right: auto; bottom: 8px; }

/* low wide screens (a phone held landscape, 844 × 390): the toolbar wraps
   into columns so every tool stays on the screen; on touch the zoom buttons
   give way (pinch zooms) and the toolbar starts at the top */
@media (min-width: 821px) and (max-height: 640px) {
  /* messages below a top bar that may wrap to two rows and the hint under it */
  :root { --msg-top: max(170px, 28vh); --msg-left: calc(3 * var(--tb-btn) + 32px); }
  /* too little map beside the floating panel: the message may lie over the panel, not over the tools */
  .toast, .busy { --msg-room: max(280px, calc(100vw - var(--sidebar-w) - var(--msg-left))); }
  .toolbar {
    display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, var(--tb-btn));
    max-height: calc(100% - 80px - 8px);
  }
  .toolbar hr { display: none; }
}
@media (min-width: 821px) and (max-height: 640px) and (pointer: coarse) {
  .ol-zoom { display: none; }
  .toolbar { top: 8px; max-height: calc(100% - 16px); }
}

/* ---------------------------------------------------------------- forms */
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; }
.field select, .field input { width: 100%; }
.field { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.field > input, .field > select { color: var(--text); font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.warn { color: var(--warn); font-size: 12px; }
.warn::before { content: "⚠ "; }
.bad { color: var(--bad); }
.good { color: var(--ok); }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
table.data th { text-align: right; color: var(--muted); font-weight: 500; padding: 3px 4px; border-bottom: 1px solid var(--line); }
table.data td { text-align: right; padding: 3px 4px; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data tr.clickable { cursor: pointer; }
/* the overview's Fittingen rows light up like the Slangen rows (owner 2026-10-14) */
table.data tr.clickable:hover, table.data.fit-table tbody tr:hover { background: var(--accent-soft); }
table.data input { padding: 2px 4px; font-size: 12px; text-align: right; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.list li .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.big-number { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
canvas.profile { width: 100%; height: 90px; display: block; border: 1px solid var(--line); border-radius: 6px; }
canvas.profile[data-mode="abs"] { height: auto; aspect-ratio: 680 / 260; }
.profile-legend { margin: 4px 0 0; }

/* ---------------------------------------------------------------- dialogs */
.dialog {
  border: 0; border-radius: 12px; padding: 20px; width: min(440px, calc(100vw - 32px));
  background: var(--panel); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .3);
}
.dialog::backdrop { background: rgba(10, 14, 20, .45); }
.dialog h2 { margin: 0 0 12px; font-size: 18px; }
.dialog form { display: flex; flex-direction: column; gap: 10px; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.dialog form.ask p { margin: 0; overflow-wrap: anywhere; }
/* a file input styled as an outline button */
label.file-btn { display: inline-flex; align-items: center; cursor: pointer; border: 1px solid var(--field-line); border-radius: 6px; padding: 2px 8px; font-size: 12px; }
label.file-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
/* messages sit over the middle of the map left open: right of the toolbar,
   left of the sidebar and the floating panel (at least 200 px wide) */
.toast, .busy {
  --msg-room: max(200px, calc(100vw - var(--sidebar-w) - var(--float-space, 0px) - var(--msg-left)));
  left: calc(var(--msg-left) + var(--msg-room) / 2); top: var(--msg-top); max-width: min(520px, calc(var(--msg-room) - 24px));
}
.toast {
  position: fixed; transform: translateX(-50%); z-index: 50; width: max-content; text-align: center;
  background: #1d2430; color: #fff; padding: 8px 16px; border-radius: 8px; box-shadow: var(--shadow);
}
.toast .toast-action { margin-left: 8px; background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.toast.error { background: var(--toast-bad); }
/* a change the user should notice (e.g. the map switching units) */
.toast.prominent {
  background: var(--accent); color: var(--accent-ink); font-size: 15px; font-weight: 600;
  padding: 12px 20px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.35);
  animation: toast-pop .35s ease-out;
}
@keyframes toast-pop { from { transform: translateX(-50%) scale(.9); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .toast.prominent { animation: none; } }
/* busy indicator (busy.js): fades in after 300 ms; the fade and the spinner run on the compositor.
   Blue as the prominent toast (owner 2026-10-17), wider than a toast and never cut off: a long
   progress line (the planner's, with its time indication at the end) wraps onto more lines */
.busy {
  position: fixed; right: auto; bottom: auto; transform: translateX(-50%); z-index: 60; margin: 0;
  display: flex; align-items: center; gap: 10px; width: max-content;
  max-width: min(760px, calc(var(--msg-room) - 24px), calc(100vw - 24px));
  background: var(--accent); color: var(--accent-ink); border: 0; padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.35);
  font-size: 14px; pointer-events: none; overflow: visible;
  animation: busy-in .15s ease-out .3s both;
}
.busy-text { overflow-wrap: anywhere; }
.busy .spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2.5px solid color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor;
  animation: spin .8s linear infinite; will-change: transform;
}
.busy .busy-stop { pointer-events: auto; flex: none; background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 60%, transparent); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes busy-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .busy .spinner { animation-duration: 2.4s; } }


/* options a sprinkler model does not have */
input:disabled, select:disabled { opacity: .5; cursor: not-allowed; background: var(--bg); }
button.small.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.legend-labels { position: relative; display: flex; justify-content: space-between; color: var(--muted); }
.legend-labels span:nth-child(2) { position: absolute; top: 0; white-space: nowrap; }
canvas.chart { width: 100%; height: auto; aspect-ratio: 680 / 320; display: block; border: 1px solid var(--line); border-radius: 6px; }

/* ---------------------------------------------------------------- panel */
.panel-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 48px; }
.panel-head h2 { flex: 1; margin: 0; font-size: 16px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-head button.icon { padding: 2px 9px; font-size: 15px; line-height: 1.4; }
.panel-body { padding: 12px 14px 40px; overflow: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.sheet-handle { display: none; }
/* Instellingen and Weergave (Overzicht) look alike: bordered cards with a bold summary */
details.model-details, details.display-details, details.parts-details { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; }
details.model-details summary, details.display-details summary, details.parts-details summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.toolbar button.active svg { stroke: currentColor; }


.draw-bar {
  position: absolute; left: calc((100% - var(--float-space, 0px)) / 2); top: 10px; transform: translateX(-50%); z-index: 6;
  display: flex; gap: 6px; padding: 6px; background: var(--panel); border-radius: 10px; box-shadow: var(--shadow);
}
.draw-bar[hidden] { display: none; }
.draw-bar button { padding: 8px 14px; }
.model-card { display: flex; gap: 10px; align-items: center; margin: 4px 0 10px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius); }
.model-card div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.model-card strong { font-size: 13px; line-height: 1.3; }
ul.links { margin: 0 0 6px; padding-left: 18px; font-size: 13px; }
ul.links a { color: var(--accent); }
.sources-footer { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 4px; }

/* ---------------------------------------------------------------- round 2: compact panels */
/* hint bar: top centre, below the draw bar while drawing */
.draw-bar:not([hidden]) ~ .hint { top: 64px; }
.nowrap { white-space: nowrap; }
.tip {
  display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border: 1px solid currentColor;
  border-radius: 50%; color: var(--muted); cursor: help; font: italic 600 10px/1 Georgia, serif; text-transform: none; vertical-align: 1px;
}
h3 .tip { text-transform: none; }
.picker { display: grid; gap: 6px; margin-bottom: 4px; }
/* the hits scroll in a short box; the selects stay shown under it (owner, 2026-10-13: always show the dropdowns) */
.pick-hits:has(> button) { max-height: 13.5em; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--line, #ccd); border-radius: 8px; padding: 4px; }
.pick-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.pick-row select { width: 100%; color: var(--text); font-size: 14px; }
.pick-row.pump-controller { grid-template-columns: auto minmax(0, 1fr) auto; margin-top: 8px; }
.pick-row.tap-kind { grid-template-columns: 64px minmax(0, 1fr) auto; margin: 6px 0; }
.bucket-sizes { margin-top: 6px; }
.bucket-at { margin-bottom: 4px; }
.catalogue { margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.required { margin-top: 8px; }
.run-time .big-input { font-size: 20px; font-weight: 650; padding: 2px 8px; font-variant-numeric: tabular-nums; }
details.calc-model, details.well-details { margin-top: 8px; }
details.calc-model summary, details.well-details summary { cursor: pointer; font-size: 12px; color: var(--muted); }
details.well-details summary { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin-top: 14px; }
details.well-details .depth-mode { margin: 6px 0 8px; gap: 12px; }
ol.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
ol.steps button.step { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 8px 10px; }
ol.steps .n { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); align-items: center; justify-content: center; font-size: 12px; flex: none; }
ol.steps button.step.done { color: var(--muted); }
ol.steps button.step.done .n { background: var(--ok); color: #fff; }

/* ---------------------------------------------------------------- legend chip (phone) */
.legend-toggle { display: none; }
.legend-mini { display: inline-block; width: 40px; height: 8px; border-radius: 3px; }

/* ---------------------------------------------------------------- top-bar menu (phone) */
.topbar .menu-btn { display: none; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; flex: none; }
/* the header's buy button (account without a licence here; owner 2026-10-20: filled with the accent): right after the account button, its border
   the precipitation ramp (heatmap.js STOPS at their legend positions); on a phone, its icon left of the menu */
#btn-pay[hidden] { display: none; }
.topbar .pay-btn {
  order: 1; margin-left: -6px; color: var(--accent-ink); font-weight: 600; white-space: nowrap; border: 2px solid transparent;
  background: linear-gradient(var(--accent), var(--accent)) padding-box,
    linear-gradient(to right, rgb(255,255,204) 0%, rgb(199,233,180) 8.75%, rgb(65,182,196) 17.5%, rgb(34,94,168) 26.25%, rgb(8,29,88) 35%,
      rgb(110,50,160) 70%, rgb(231,41,138) 79%, rgb(248,149,64) 88%, rgb(252,206,37) 100%) border-box;
}
.topbar .pay-btn:hover { filter: brightness(1.1); background: linear-gradient(var(--accent), var(--accent)) padding-box,
    linear-gradient(to right, rgb(255,255,204) 0%, rgb(199,233,180) 8.75%, rgb(65,182,196) 17.5%, rgb(34,94,168) 26.25%, rgb(8,29,88) 35%,
      rgb(110,50,160) 70%, rgb(231,41,138) 79%, rgb(248,149,64) 88%, rgb(252,206,37) 100%) border-box; }
.pay-btn svg { stroke-width: 2; color: var(--accent-ink); }
/* the text from 1024 px (no star there); the row makes room while the button shows: from 641 px the search
   button's icon (to 1340 px), the tutorial's icon (to 1300 px) and a narrower base map; below 1024 px the star only */
@media (min-width: 1024px) { .pay-btn svg { display: none; } }
@media (min-width: 641px) and (max-width: 1023px) { .pay-btn .label { display: none; } }
@media (min-width: 641px) and (max-width: 1340px) {
  .topbar:has(#btn-pay:not([hidden])) .search button .label { display: none; }
  .topbar:has(#btn-pay:not([hidden])) .search button { padding: 6px 10px; }
}
@media (min-width: 641px) and (max-width: 1300px) {
  .topbar:has(#btn-pay:not([hidden])) .tour-btn .label { display: none; }
  .topbar:has(#btn-pay:not([hidden])) .tour-btn svg { display: block; }
  .topbar:has(#btn-pay:not([hidden])) #imagery { max-width: 110px; }
}
@media (min-width: 641px) and (max-width: 900px) { .topbar:has(#btn-pay:not([hidden])) #imagery { max-width: 96px; } }
@media (min-width: 641px) and (max-width: 700px) { .topbar:has(#btn-pay:not([hidden])) #imagery { max-width: 64px; } }
@media (max-width: 640px) { .topbar .pay-btn { order: 0; margin-left: 0; padding: 6px 10px; } .pay-btn .label { display: none; } }

/* ---------------------------------------------------------------- phone and tablet portrait: map + bottom sheet */
@media (max-width: 820px) {
  :root { --sidebar-w: 0px; --msg-top: max(130px, 28vh); --msg-left: 0px; } /* below the phone toolbar and the hint */
  .brand span { display: none; }
  #imagery { max-width: 130px; }
  /* toolbar bottom = top 8 + one row + paddings 2×4 */
  .layout { position: relative; display: block; flex: 1; --tb-bottom: calc(8px + var(--tb-btn) + 8px); }
  .map-wrap { position: absolute; inset: 0; }
  /* fully open, the sheet still leaves the toolbar (tools, undo, redo) free */
  .sidebar {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: min(85%, calc(100% - var(--tb-bottom) - 8px)); z-index: 10;
    border: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -4px 24px rgba(0, 0, 0, .28);
    transition: transform .3s cubic-bezier(.2, .8, .2, 1);
  }
  .sidebar.dragging { transition: none; }
  /* the grip bar sits over the top of the title bar; both drag the sheet */
  .sheet-handle {
    display: flex; justify-content: center; align-items: flex-start; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 120px; height: 44px; padding-top: 6px; z-index: 1; touch-action: none; cursor: grab;
  }
  .sheet-handle span { width: 40px; height: 5px; border-radius: 3px; background: var(--field-line); }
  .panel-head { touch-action: none; min-height: 52px; padding: 16px 14px 6px; position: relative; }

  /* toolbar: one row of the six drawing tools and "Meer" (ruler, overview);
     undo and redo are in the sheet's title bar (sheet.js) */
  .toolbar {
    flex-direction: row; flex-wrap: nowrap; top: 8px; bottom: auto; left: 8px; right: auto; max-width: calc(100% - 16px);
    gap: 4px; z-index: 6;
  }
  .toolbar button { flex: 0 0 var(--tb-btn); }
  .toolbar hr { display: none; }
  .toolbar .tb-more-btn { display: inline-flex; }
  .toolbar .tb-more-btn svg { fill: currentColor; stroke: none; }
  .toolbar .tb-more {
    display: none; position: absolute; top: calc(100% + 4px); right: 0; z-index: 7; flex-direction: column; gap: 2px; padding: 4px;
    min-width: 170px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .toolbar.more-open .tb-more { display: flex; }
  .toolbar .tb-more button { flex: none; width: 100%; height: auto; min-height: var(--tb-btn); display: flex; align-items: center; gap: 10px; padding: 6px 10px; text-align: left; }
  .toolbar .tb-more button svg { width: 24px; height: 24px; flex: none; }
  .tb-label { display: inline; font-size: 14px; }
  .head-tools { display: flex; gap: 2px; margin-left: auto; }
  /* zoom: pinch on touch screens; top right with a mouse */
  .ol-zoom { top: 8px; left: auto; right: 8px; }

  .draw-bar { top: calc(var(--tb-bottom) + 8px); left: 8px; right: auto; transform: none; max-width: calc(100% - 16px); }
  /* hint: a compact line (two at most) under the toolbar; it fades after a few seconds (main.js) */
  .hint {
    top: calc(var(--tb-bottom) + 6px); max-width: calc(100% - 32px); font-size: 12px; line-height: 1.35; padding: 3px 10px;
    border-radius: 12px; transition: opacity .6s;
  }
  .hint:not(:empty) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* with a button: no clamp (it would cut the button off); a finger-sized button */
  .hint.has-action:not(:empty) { display: flex; -webkit-line-clamp: unset; overflow: visible; }
  .hint .hint-action { min-height: 32px; }
  .hint.faded { opacity: 0; }
  .draw-bar:not([hidden]) ~ .hint { top: calc(var(--tb-bottom) + 8px + var(--tb-btn) + 12px + 6px); }

  /* above the visible part of the sheet (sheet.js sets --sheet-visible) */
  .ol-scale-line { bottom: calc(var(--sheet-visible, 56px) + 8px); }
  .ol-attribution { bottom: calc(var(--sheet-visible, 56px) + 8px); right: 8px; }
  .legend { top: auto; right: 8px; bottom: calc(var(--sheet-visible, 56px) + 8px + var(--tb-btn) + 8px); min-width: 0; max-width: calc(100% - 16px); }
  .legend.collapsed { padding: 0; }
  .legend .legend-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%; background: transparent; color: var(--text); padding: 6px 10px;
    min-height: var(--tb-btn); font-size: 12px; font-weight: 600;
  }
  .legend:not(.collapsed) .legend-toggle { padding: 0 0 4px; }
  .legend:not(.collapsed) .legend-mini { display: none; }
  .legend.collapsed .legend-body { display: none; }
  body[data-sheet="full"] .legend, body[data-sheet="full"] .ol-attribution, body[data-sheet="full"] .ol-scale-line { visibility: hidden; }
}

/* phone: one top-bar row (search + menu); imagery, language, project and account in the menu */
@media (max-width: 640px) {
  .topbar { flex-wrap: nowrap; gap: 8px; padding: 8px; position: relative; }
  .search { flex: 1 1 auto; min-width: 0; }
  .search button .label { display: none; }
  .search button { padding: 6px 10px; }
  .topbar .menu-btn { display: inline-flex; }
  .topbar-right {
    display: none; position: absolute; top: calc(100% + 4px); right: 8px; z-index: 30; flex-direction: column; align-items: stretch;
    gap: 8px; padding: 10px; min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  }
  .topbar.menu-open .topbar-right { display: flex; }
  /* long source names: the menu stays inside the screen */
  .topbar-right #imagery { max-width: calc(100vw - 40px); }
  .topbar-right button { text-align: left; }
}

/* touch screens: every control at least 44 px (WCAG 2.5.5); desktop keeps its density */
@media (pointer: coarse) {
  :root { --tb-btn: 44px; }
  .toolbar button { padding: 9px; }
  button, select, .search input, .panel-body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), .dialog input { min-height: 44px; }
  button.small { min-width: 44px; padding: 4px 12px; font-size: 14px; }
  .panel-head button.icon, .icon-btn { min-width: 44px; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; margin: 0 4px 0 0; }
  label.row:has(> input[type="checkbox"]), label.row:has(> input[type="radio"]), label.row.small:has(input) { min-height: 44px; }
  input[type="color"] { min-height: 44px; min-width: 44px; padding: 2px; }
  /* sliders: a 44 px track and thumb hit area, a 28 px visible thumb */
  input[type="range"] { -webkit-appearance: none; appearance: none; height: 44px; background: transparent; }
  input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--field-line); }
  input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 44px; height: 44px; margin-top: -19px; border-radius: 50%;
    background: var(--accent); border: 8px solid transparent; background-clip: padding-box;
  }
  input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--field-line); }
  input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 8px solid transparent; background-clip: padding-box; }
  .search-results li { min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
  .tip { width: 24px; height: 24px; font-size: 13px; }
  .draw-bar button { min-height: 44px; }
  label.file-btn { min-height: 44px; padding: 4px 12px; font-size: 14px; }
  .ol-control button { width: 44px; height: 44px; font-size: 20px; }
  .ol-attribution.ol-collapsed button, .ol-attribution button { width: 44px; height: 44px; }
  ol.steps button.step { min-height: 44px; }
  /* every disclosure line is a 44 px target */
  details > summary, details.model-details summary, details.display-details summary, details.parts-details summary { min-height: 44px; padding-block: 12px; box-sizing: border-box; }
  .list li { min-height: 52px; }
  ul.links a { display: inline-block; padding: 10px 0; }
}
@media (max-width: 820px) and (pointer: coarse) {
  .ol-zoom { display: none; }
}
/* visually hidden, still focusable (file input inside its label) */
.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); }

/* Pump: operating points per group, the stored curve with its points */
table.data.op-table tr.on td { font-weight: 600; }
table.data.op-table tr.faded td { color: var(--muted); }
svg.curve-chart { width: 100%; height: auto; display: block; border: 1px solid var(--line); border-radius: 6px; font: 20px system-ui, sans-serif; touch-action: manipulation; }
svg.curve-chart text { fill: var(--muted); }
svg.curve-chart .grid { stroke: var(--line); stroke-width: 1; }
svg.curve-chart .curve { fill: none; stroke: #1e88e5; stroke-width: 4; }
svg.curve-chart .curve.ext { stroke-dasharray: 10 8; }
svg.curve-chart .pt .hit { fill: transparent; }
svg.curve-chart .pt .dot { fill: #1e88e5; stroke: var(--panel, #fff); stroke-width: 2; }
svg.curve-chart .pt.chart .dot { fill: var(--panel, #fff); stroke: #1e88e5; stroke-width: 3; }
svg.curve-chart .pt { cursor: pointer; outline: none; }
svg.curve-chart .pt.on .dot, svg.curve-chart .pt:focus-visible .dot { r: 10; stroke: var(--text); }
.curve-value { min-height: 1.3em; margin: 4px 0 0; font-variant-numeric: tabular-nums; }
.curve-legend { margin: 2px 0; }
.lg-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #1e88e5; border: 2px solid #1e88e5; vertical-align: middle; }
.lg-dot.open { background: transparent; }
.lg-dash { display: inline-block; width: 22px; border-top: 3px dashed #1e88e5; vertical-align: middle; }
.lg-line { display: inline-block; width: 22px; border-top: 3px solid #1e88e5; vertical-align: middle; }
.lg-dots { display: inline-block; width: 22px; border-top: 3px dotted var(--muted); vertical-align: middle; }

/* pump search: hits under the field, then the type → brand → (series →) model picker */
.pump-search input, .pick-search input { width: 100%; margin: 2px 0 4px; }
.pump-hits, .pick-hits { display: grid; gap: 4px; margin-bottom: 6px; }
.pump-hits:empty, .pick-hits:empty { display: none; }
.pump-hit { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; padding: 5px 10px; }
.pump-hit strong { font-size: 13px; font-weight: 600; }
/* too little pressure: required operating point and pumps that meet it; pressure regulator choice */
.need { margin: 6px 0 8px; }
.need-pumps { display: grid; gap: 4px; }
.reg-block, .thr-block { margin-top: 10px; }
/* label above the select: "Régulateur de pression" / "Druckregler" never squeezed into a column */
.reg-block .pick-row, .thr-block .pick-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
.reg-block .pick-row + .pick-row, .reg-block .grid2, .thr-block .grid2 { margin-top: 4px; }
.reg-block p, .thr-block p { margin: 4px 0 0; }

/* area tool: garden / cut-out / planting; planting colours */
.seg { display: flex; gap: 4px; }
.seg button { flex: 1 1 0; min-width: 0; padding-inline: 4px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.swatch-btn { width: 30px; height: 30px; padding: 0; border-radius: 50%; background: var(--sw); border: 2px solid var(--field-line); }
.swatch-btn.on { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (pointer: coarse) {
  .swatch-btn { width: 44px; height: 44px; }
}

/* "Neerslag meten": readout beside the pointer / above the pinned spot (map.js); the 30 × 30 cm square is on the map */
.probe-overlay { pointer-events: none !important; }
.probe-readout {
  background: var(--panel); color: var(--text); border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
  padding: 4px 9px; font-size: 12px; line-height: 1.4; white-space: nowrap; font-variant-numeric: tabular-nums; pointer-events: none;
}
.probe-readout .probe-val strong { font-size: 14px; font-weight: 650; }
.probe-cmp { color: var(--muted); }
.probe-cmp strong { color: var(--text); font-weight: 600; }
/* the heat map's colour of that amount; the outline keeps dark blue visible in dark mode */
.probe-sw { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; border-radius: 3px; box-shadow: 0 0 0 1px var(--field-line); }
.probe-last { margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.probe-last .probe-val strong { font-size: 20px; }
.probe-last .probe-cmp { font-size: 13px; }
.probe-ref { margin: 4px 0 0; }

/* overlay drawings (panels/overlay.js): the selected line, its settings */
.ov-list li.on .grow { font-weight: 600; }
.ov-list li input[type="checkbox"] { margin: 0; }
.ov-menu { margin-top: 8px; }

/* ---- accounts, free tier and pass (account.js, copy protection 2026-10-15) */
.wall-dialog { width: min(400px, calc(100vw - 32px)); }
.wall-dialog::backdrop { background: rgba(10, 14, 20, .35); }
.wall .wall-links { margin: 10px 0 0; }
.wall .wall-new { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line, #d9dee5); text-align: center; }
.wall .wall-new p { margin: 0 0 8px; }
.wall .wall-new button { width: 100%; }
.wall .wall-tour { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line, #d9dee5); text-align: center; }
.dialog label.check { display: flex; gap: 8px; align-items: flex-start; }
/* flex: none, or a long text squeezes the box (owner 2026-10-20: the limits box was tiny) */
.dialog label.check input { min-height: 0; margin-top: 2px; flex: none; width: 18px; height: 18px; }
#dlg-pay { width: min(440px, calc(100vw - 32px)); }
#dlg-pay .pay-price { font-size: 18px; font-weight: 600; margin: 4px 0; }
/* what a pass gives: a compact checklist */
#dlg-pay .pay-list { list-style: none; margin: 4px 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
#dlg-pay .pay-list li { display: flex; gap: 8px; align-items: flex-start; overflow-wrap: anywhere; }
#dlg-pay .pay-list svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: none; stroke: var(--accent); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
#dlg-pay p { margin: 0; }
/* free time up: the app behind the pay dialog is blurred (the design stays) */
body.paywalled main.layout, body.paywalled #topbar { filter: blur(7px); pointer-events: none; user-select: none; }
#dlg-pay::backdrop { background: rgba(10, 14, 20, .35); }
/* shopping list rows a free account doesn't get */
.bom-table tr.bom-locked td span { filter: blur(4px); color: var(--muted, #6b7280); user-select: none; }
.bom-more { margin: 6px 0; }
.locked-hint { margin: 4px 0 0; }
.pump-hit.locked, .pick-hits .locked { opacity: .5; }
.dialog p.bad:empty { display: none; }
/* sprinkler suggestions: a head placed without a model (suggest.js) */
.place-mode { margin-bottom: 8px; }
.sg-panel { margin-top: 12px; border-top: 1px solid var(--line, #ccd); padding-top: 8px; }
.sg-panel h3 { margin: 0 0 6px; font-size: 14px; }
.sg-brands { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-bottom: 4px; }
.sg-brands .grp-check { display: inline-flex; align-items: center; gap: 4px; }
.sg-at { margin: 2px 0 6px; }
.sg-row { width: 100%; min-width: 0; }
.sg-row strong, .sg-row span { overflow-wrap: anywhere; }
