/* ---- tokens ------------------------------------------------------------------------------------ */

:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #edf2f1;
  --surface-alt: #f8faf9;
  --text: #14201e;
  --muted: #5d6b69;
  --border: #dde5e3;
  --accent: #0f766e;
  --accent-hover: #0b5f58;
  --accent-soft: #dff3ef;
  --accent-contrast: #ffffff;
  --danger: #c93b3b;
  --ok: #1f8a5b;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(10 40 35 / 0.05);
  --shadow-lg: 0 8px 24px rgb(10 40 35 / 0.12);
  /* the map */
  --sea: #dcebf0;
  --land: #eef2f1;
  --land-hover: #e2e9e7;
  --land-border: #aebcb9;
  --paint: #14b8a6;
  --paint-fill: color-mix(in srgb, var(--paint) 58%, var(--land));
  --paint-border: #0f766e;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1413;
    --surface: #161e1d;
    --surface-2: #202a28;
    --surface-alt: #1a2321;
    --text: #e7efed;
    --muted: #97a6a3;
    --border: #27322f;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-soft: #123a36;
    --accent-contrast: #062b27;
    --danger: #ff6b6b;
    --ok: #4cc38a;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 8px 24px rgb(0 0 0 / 0.45);
    --sea: #0f1a1e;
    --land: #1f2a28;
    --land-hover: #2a3734;
    --land-border: #445451;
    --paint: #2dd4bf;
    --paint-fill: color-mix(in srgb, var(--paint) 45%, var(--land));
    --paint-border: #5eead4;
  }
}

/* ---- base -------------------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0; letter-spacing: -0.015em; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
p { margin: 0; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.error { color: var(--danger); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- shell ------------------------------------------------------------------------------------- */

/* dvh where supported: on phones 100vh also counts the room behind the browser's toolbars. */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.55rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 760;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
}

/* The house and magnifying glass; the same drawing as the favicon. */
.brand-mark {
  width: 24px;
  height: 24px;
  background: url("/favicon.svg") center / contain no-repeat;
}

.brand--big { font-size: 1.7rem; }
.brand--big .brand-mark { transform: scale(1.35); margin-right: 0.3rem; }

.topnav { display: flex; gap: 0.2rem; flex-wrap: wrap; }

.topnav a {
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 560;
}

/* Hover styles only where there's a real hover: on touch screens they'd stick after a tap. */
@media (hover: hover) {
  .topnav a:hover { background: var(--surface-2); color: var(--text); }
}
.topnav a.active { background: var(--accent-soft); color: var(--accent); }
/* The nav's icons are for the phone tab bar (see "phones" at the end). */
.nav-icon { display: none; }

.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.topbar-email { color: var(--muted); font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.page { flex: 1; padding: 1.75rem 1.25rem 3rem; }
/* A phone turned sideways gets this layout, and index.html's viewport-fit=cover lets the page reach under its notch:
   keep clear of it. (The insets are 0 everywhere else.) */
.topbar, .page {
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
}

.narrow { max-width: 760px; margin: 0 auto; width: 100%; }
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  min-width: 0;
}

.empty { display: flex; flex-direction: column; gap: 0.6rem; }
.empty-title { font-weight: 650; font-size: 1.05rem; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-actions { display: flex; gap: 0.5rem; }

/* ---- controls ---------------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.5rem 0.9rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.btn:disabled { opacity: 0.55; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--danger { color: var(--danger); }
@media (hover: hover) {
  .btn:hover { background: var(--surface-2); }
  .btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
  .btn--ghost:hover { color: var(--text); }
  .btn--danger:hover { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
}
.btn--small { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); color: var(--accent); }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 9px 0 0 9px; }
.btn-group .btn:last-child { border-radius: 0 9px 9px 0; }

.btn--refresh svg { width: 15px; height: 15px; }
.btn--spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn--spinning svg { animation: none; } }

input[type="text"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0.55rem 0.75rem;
  min-width: 0;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.field > span { font-weight: 600; font-size: 0.9rem; }
/* The field around a select with long options. WebKit (every iPhone browser) lays a select's options out as wide as the
   longest one and lets that spill out of the select, invisibly but widening the page, so a phone zooms out to fit.
   Clipping its field stops it; the padding, cancelled by the margin, keeps the focus ring inside the clip. */
.field--select { overflow: hidden; padding: 4px; margin: -4px; }

.title-input {
  flex: 1;
  min-width: 0;
  font-size: 1.1rem !important;
  font-weight: 680;
  border-color: transparent !important;
  background: transparent !important;
  padding: 0.25rem 0.5rem !important;
  margin-left: -0.5rem;
}
@media (hover: hover) { .title-input:hover { border-color: var(--border) !important; } }
.title-input:focus { border-color: var(--accent) !important; background: var(--surface) !important; }

.add-select {
  font-size: 0.82rem !important;
  padding: 0.15rem 0.5rem !important;
  border-radius: 999px !important;
  border-style: dashed !important;
  color: var(--muted) !important;
  cursor: pointer;
}

.hint { font-size: 0.85rem; color: var(--muted); }
.hint b { color: var(--text); font-weight: 650; }
/* Wording that depends on the device's main pointer (a touch screen's is coarse). */
.for-touch { display: none; }
@media (pointer: coarse) {
  .for-touch { display: inline; }
  .for-mouse { display: none; }
}

/* ---- loading & saving --------------------------------------------------------------------------
   Nothing looks empty while it loads, and nothing looks done while it's still being saved. Loading and busy
   states start instantly (they answer the user); leaving them is eased from JS (js/motion.js). */

.loading { display: flex; align-items: center; gap: 0.6rem; margin: 0; color: var(--muted); font-weight: 550; }
.loading::before, .btn[aria-busy="true"]::after, .save-status--saving::before {
  content: "";
  flex: none;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
.loading--page { min-height: 100vh; min-height: 100dvh; justify-content: center; }

.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]:disabled { opacity: 0.8; }
.btn--refresh[aria-busy="true"]::after { content: none; }
input[aria-busy="true"], select[aria-busy="true"], fieldset[aria-busy="true"], .chip-x[aria-busy="true"] { opacity: 0.5; cursor: progress; }
/* Sections being reloaded: dimmed, and not clickable until fresh. */
.card[aria-busy="true"], .stack-lg[aria-busy="true"], .rentals[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

/* ---- chips ------------------------------------------------------------------------------------- */

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 560;
  line-height: 1.5;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--surface));
}
.chip a { color: inherit; text-decoration: none; }
@media (hover: hover) { .chip a:hover { text-decoration: underline; } }

.chip-x {
  border: 0;
  background: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.1rem;
  margin-right: -0.2rem;
  opacity: 0.55;
  cursor: pointer;
}
@media (hover: hover) { .chip-x:hover { opacity: 1; } }

/* ---- login and report -------------------------------------------------------------------------- */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 2rem 1rem;
  background: radial-gradient(60rem 30rem at 50% -10%, var(--accent-soft), transparent 70%);
}

.login-card { width: 100%; max-width: 410px; padding: 2rem; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 1.45rem; }
.login-card .btn--primary { padding: 0.65rem 1rem; }
.sent-icon { font-size: 2.6rem; line-height: 1; color: var(--accent); }

.report-card { max-width: 520px; }
.choices, .checks { display: flex; flex-direction: column; gap: 0.6rem; margin: 0; padding: 0; border: none; min-width: 0; }
.choices legend, .checks legend { font-weight: 600; font-size: 0.9rem; padding: 0; margin-bottom: 0.35rem; }
.choice { display: flex; gap: 0.65rem; align-items: flex-start; padding: 0.75rem 0.85rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
@media (hover: hover) { .choice:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); } }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin: 0.2rem 0 0; accent-color: var(--accent); }
.choice-text { display: flex; flex-direction: column; gap: 0.2rem; }
.choice-warning { color: var(--danger); font-weight: 550; }

/* ---- guide ------------------------------------------------------------------------------------- */

.guide { max-width: 760px; margin: 0.5rem auto 0; display: flex; flex-direction: column; gap: 1.5rem; }
.guide-head { display: flex; flex-direction: column; gap: 0.35rem; }
.guide-lead { color: var(--muted); font-size: 1.05rem; }
.guide-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1rem; }
.guide-step { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 1.1rem; }
.guide-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.guide-icon svg { width: 24px; height: 24px; }
.guide-body { display: flex; flex-direction: column; align-items: flex-start; gap: 0.65rem; }
.guide-body h2 { margin: 0; }
.guide-kicker { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.guide-gestures b { font-weight: 650; }
.guide-progress { font-weight: 600; color: var(--accent); }
.guide-link::after { content: "→"; }
.guide-foot { font-size: 0.9rem; }

/* ---- filters ----------------------------------------------------------------------------------- */

.filter-card { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; }
.filter-card-main { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.filter-card h2 { margin: 0; }
.filter-name { color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
@media (hover: hover) { .filter-name:hover { color: var(--accent); } }
.filter-summary { overflow-wrap: anywhere; }
.filter-card-actions { display: flex; gap: 0.35rem; flex: none; }

/* the editor */
.editor-wrap { max-width: 1100px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 0.75rem; }
.back-link { align-self: flex-start; text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.editor-head { display: flex; align-items: center; gap: 1rem; }
.editor-head .title-input { font-size: 1.5rem !important; letter-spacing: -0.015em; }
.save-status { display: inline-flex; align-items: center; gap: 0.45rem; flex: none; font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.save-status--saved { color: var(--ok); }
.save-status--error { color: var(--danger); }
.editor-matches { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; align-items: baseline; }
.editor-count { font-weight: 650; }
.editor-limits h2, .editor-area h2, .editor-dates h2, .editor-kinds h2 { margin: 0; }

.ranges { display: grid; grid-template-columns: max-content minmax(0, 20rem) max-content; gap: 0.6rem 1rem; align-items: center; }
.range { display: contents; }
.range-label { font-weight: 600; }
.range-fields { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.range-input { width: 100%; }
.range-unit-inline { display: none; font-weight: 500; }
/* A date field is as wide as its date needs: WebKit on iPhones shrinks an empty one to nothing otherwise. */
.range-input[type="date"] { min-height: 2.6rem; min-width: 8.5rem; }

/* Yes · Any · No per property type and tenure (FLT-15). */
.switches { display: grid; grid-template-columns: minmax(0, max-content) max-content; gap: 0.45rem 1.5rem; align-items: center; }
.switches-head { grid-column: 1 / -1; margin: 0.5rem 0 0; font-size: 0.95rem; }
.switches-head:first-child { margin-top: 0; }
.switch { display: contents; }
.switch-label { font-weight: 550; }
.switch .btn { min-width: 3.3rem; justify-content: center; }
.switch .switch-no[aria-pressed="true"] { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.switch .switch-any[aria-pressed="true"] { color: var(--text); background: var(--surface-2); border-color: var(--border); }

.selection-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.selection-count { font-weight: 650; }

/* ---- the postcode map -------------------------------------------------------------------------- */

.map-panel { display: flex; flex-direction: column; gap: 0.6rem; }
.map-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1rem; }
/* Erase, when on, is red: it's the one that removes things. */
.btn.tool-erase[aria-pressed="true"] {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
.map-find { display: flex; gap: 0.4rem; flex: 1; min-width: min(100%, 16rem); max-width: 26rem; }
.map-find-input { flex: 1; }

.map {
  position: relative;
  height: min(70vh, 720px);
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--sea);
  cursor: crosshair;
  /* Every finger on the map is the map's own (postcode-map.js): no page scroll, zoom, text selection or callout. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.map:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.map--grab, .map--panning { cursor: grab; }
.map--panning { cursor: grabbing; }
.map-svg { display: block; width: 100%; height: 100%; }

.pc { fill: var(--land); stroke: var(--land-border); stroke-width: 0.8; stroke-linejoin: round; vector-effect: non-scaling-stroke; fill-rule: evenodd; }
.pc--hover { fill: var(--land-hover); stroke: var(--text); stroke-width: 1.6; }
.pc--on { fill: var(--paint-fill); stroke: var(--paint-border); }
.pc--on.pc--hover { fill: color-mix(in srgb, var(--paint) 72%, var(--land)); stroke: var(--text); }
.map--erase .pc--hover { stroke: var(--danger); }

.map-inset { fill: none; stroke: var(--land-border); stroke-width: 1; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.map-labels { pointer-events: none; }
.pc-label, .map-inset-label { fill: var(--muted); font-family: system-ui, sans-serif; font-weight: 650; text-anchor: middle; dominant-baseline: middle; }
.pc-label--on { fill: var(--text); }
.map-inset-label { text-anchor: start; }

.map-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.map-tip--pinned { transform: translateX(-50%); }
.map-tip-on { opacity: 0.75; font-size: 0.78rem; }

.map-zoom { position: absolute; right: 0.6rem; top: 0.6rem; z-index: 4; display: flex; flex-direction: column; gap: 0.3rem; }
.map-zoom-btn { width: 2.2rem; height: 2.2rem; padding: 0; font-size: 1.1rem; box-shadow: var(--shadow); }
.map-credit { font-size: 0.75rem; color: var(--muted); }

/* ---- browse ------------------------------------------------------------------------------------ */

.browse { max-width: 900px; margin: 0 auto; width: 100%; }
.browse-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0.75rem 1rem; }
.browse-controls select { width: 100%; }
.browse-summary { display: flex; flex-direction: column; gap: 0.2rem; }
.browse-filter-summary { overflow-wrap: anywhere; }
.browse-count { font-weight: 600; }

.rentals { display: flex; flex-direction: column; gap: 0.9rem; }
.rental { display: flex; gap: 1.1rem; }
.rental-img { flex: none; width: 150px; height: 112px; object-fit: cover; border-radius: 9px; background: var(--surface-2); }
.rental-main { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; flex: 1; }
.rental-price strong { font-size: 1.3rem; letter-spacing: -0.01em; }
.rental-kind { margin-left: 0.6rem; padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--surface-2); font-size: 0.8rem; font-weight: 600; vertical-align: 0.2em; white-space: nowrap; }
.rental-when { font-size: 0.9rem; }
.rental-facts { font-weight: 600; }
.rental-title { font-size: 1rem; font-weight: 560; margin: 0.15rem 0 0; overflow-wrap: anywhere; }
.rental-where { overflow-wrap: anywhere; }
.rental-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.3rem 1rem; margin-top: 0.3rem; align-items: baseline; }
.rental-link { font-weight: 600; }
.more-row { display: flex; justify-content: center; }

/* ---- monitors ---------------------------------------------------------------------------------- */

.check { display: flex; align-items: center; gap: 0.55rem; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent); }
.monitor-card { display: flex; flex-direction: column; gap: 0.7rem; }
.monitor-head { display: flex; align-items: center; gap: 0.6rem; }

/* ---- toasts ------------------------------------------------------------------------------------ */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  max-width: min(90vw, 520px);
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-weight: 560;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.2s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}
.toast--error { background: var(--danger); color: #fff; }
.toast--leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---- phones -------------------------------------------------------------------------------------
   One breakpoint, by width. The nav becomes a tab bar at the bottom and the top bar keeps the brand and Log out.
   How things react to touch doesn't depend on this; that follows the pointer (hover/pointer queries), so a
   touchscreen laptop gets the wide layout and a narrow desktop window this one. */

@media (max-width: 720px) {
  :root { --tabbar-h: 58px; }

  /* Room for the tab bar, which is fixed over the bottom of the page, and an iPhone's home indicator
     (safe-area-inset-bottom, with viewport-fit=cover; 0 elsewhere). */
  .shell { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

  .topbar { gap: 0.75rem; padding: 0.4rem 0.75rem; }
  .topbar-email { display: none; }
  .topbar-end .btn { padding: 0.4rem 0.6rem; }

  .topnav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.15rem;
    padding: 0.3rem 0.3rem calc(0.3rem + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .topnav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    padding: 0 0.1rem;
    border-radius: 10px;
    font-size: 0.72rem;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
  }
  .nav-icon { display: block; width: 22px; height: 22px; }
  .nav-icon svg { display: block; width: 100%; height: 100%; }

  .toasts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 0.75rem); }

  h1 { font-size: 1.4rem; }
  .page { padding: 1rem 0.75rem 2rem; }
  .card { padding: 1rem; }
  .login-card { padding: 1.5rem 1.25rem; }
  .btn-label { display: none; }

  .guide-step { column-gap: 0.8rem; }
  .guide-icon { width: 38px; height: 38px; border-radius: 10px; }
  .guide-icon svg { width: 20px; height: 20px; }

  .filter-card { flex-direction: column; gap: 0.6rem; }
  .editor-head .title-input { font-size: 1.25rem !important; }
  .ranges { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .range-label { margin-top: 0.35rem; }
  .range-unit { display: none; }
  .range-unit-inline { display: inline; }
  .range-input[type="date"] { min-width: 0; }
  .switches { grid-template-columns: minmax(0, 1fr) max-content; column-gap: 0.75rem; }
  .switch .btn { min-width: 0; }
  /* The map takes most of the screen, but leaves room above and below to scroll the page past it (MAP-16). */
  .map { height: 62vh; height: 62dvh; min-height: 260px; }
  .map-find { max-width: none; }

  .browse-controls { grid-template-columns: minmax(0, 1fr); gap: 0.5rem; }
  .rental { flex-direction: column; gap: 0.6rem; }
  .rental-img { width: 100%; height: 170px; }
}

/* Touch screens: text fields at 16px (iOS zooms into smaller ones when they get focus), and bigger targets for
   the small controls. The × keeps its place in the chip: its negative margins cancel the extra padding. */
@media (pointer: coarse) {
  input[type="text"], input[type="email"], input[type="number"], input[type="date"], select, textarea { font-size: 16px; }
  .add-select { font-size: 16px !important; }
  .chip-x { padding: 0.3rem 0.4rem; margin: -0.3rem -0.5rem -0.3rem -0.1rem; }
  .map-zoom-btn { width: 2.6rem; height: 2.6rem; }
}
