/* EquiStat. Colour tokens for light and dark themes; data colours live in js/palette.js. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d67;
  --line: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #246dc8;                              /* links and focus rings: 5.0:1 on the surface */
  --accent-fill: #246dc8;                         /* selected buttons, under white text: 5.1:1 */
  --ring: rgba(11, 11, 11, 0.1);
  --swatch-ring: rgba(11, 11, 11, 0.55);         /* ring round small colour swatches */
  --map-ctrl-bg: #ffffff;                         /* map zoom buttons and attribution */
  --map-attrib-bg: rgba(255, 255, 255, 0.6);
  --map-ctrl-icon: none;                          /* dark mode inverts the dark button icons */
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242423; --ink: #f0efec; --ink-2: #c3c2b7;
    --muted: #9a988f; --line: #2c2c2a; --axis: #383835; --accent: #3987e5; --accent-fill: #2468c0;
    --ring: rgba(255, 255, 255, 0.1);
    --swatch-ring: rgba(255, 255, 255, 0.45); --map-ctrl-bg: #242423; --map-attrib-bg: rgba(26, 26, 25, 0.8);
    --map-ctrl-icon: invert(1); --shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  }
}
/* The toggle's choice: same values as above, so a choice of dark wins over a light system setting */
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242423; --ink: #f0efec; --ink-2: #c3c2b7;
  --muted: #9a988f; --line: #2c2c2a; --axis: #383835; --accent: #3987e5; --accent-fill: #2468c0;
  --ring: rgba(255, 255, 255, 0.1);
  --swatch-ring: rgba(255, 255, 255, 0.45); --map-ctrl-bg: #242423; --map-attrib-bg: rgba(26, 26, 25, 0.8);
  --map-ctrl-icon: invert(1); --shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 14px/1.45 var(--font); display: flex; flex-direction: column; height: 100vh;
  height: 100dvh; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 13px; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); }
h3 { font-size: 14px; margin: 0 0 6px; }
a { color: var(--accent); }
code { font-size: 12px; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 30; background: var(--surface); color: var(--ink); padding: 8px 12px;
  border-radius: 6px; box-shadow: var(--shadow); }
.skip-link:focus { top: 8px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 8px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.subtitle { margin: 2px 0 0; color: var(--ink-2); font-size: 13px; text-wrap: balance; }   /* no word left alone on a line */
.brand { flex: 1 1 0; min-width: 0; }

/* Find a place: the box in the header and its list of matches */
.search { position: relative; flex: 0 1 250px; min-width: 200px; }
.search-icon { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; padding: 6px 10px 6px 29px; border: 1px solid var(--axis); border-radius: 6px; background: var(--page);
  font-size: 13px; }
.search input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.place-results { position: absolute; top: calc(100% + 4px); left: 0; width: max(100%, 340px); max-width: calc(100vw - 32px); z-index: 40; margin: 0; padding: 4px 0; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  max-height: 320px; overflow-y: auto; }
.place-results li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 6px 10px;
  cursor: pointer; font-size: 13px; }
.place-results li[aria-selected="true"] { background: var(--surface-2); }
.place-results .place-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.place-results .place-none { color: var(--muted); cursor: default; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }
.link-button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer;
  text-decoration: none; color: var(--ink); font-size: 13px; white-space: nowrap; }
.link-button:hover { background: var(--surface-2); }

/* Three columns from 1100 px: controls, map, results */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr) 400px; grid-template-areas: "controls map panel";
  flex: 1; min-height: 0; }
.controls { grid-area: controls; }
.map-wrap { grid-area: map; }
.panel { grid-area: panel; }
.pane-tabs { display: none; }
.controls, .panel { overflow-y: auto; background: var(--surface); padding: 12px 14px; overscroll-behavior: contain; }
.controls { border-right: 1px solid var(--line); }
.panel { border-left: 1px solid var(--line); }
.panel:focus { outline: none; }
.controls section { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.controls section:last-child { border-bottom: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }

.segmented { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
/* The label holds its hidden radio, so the radio stays inside the scrolling column (an input
   placed against the page made the whole page scrollable) */
.segmented label { position: relative; flex: 1 1 auto; text-align: center; padding: 5px 3px; cursor: pointer; font-size: 13px;
  white-space: nowrap; }      /* sized to the label: three labels of different lengths fit on one line */
.segmented label + label { border-left: 1px solid var(--line); }
.segmented input { position: absolute; inset: 0; margin: 0; opacity: 0; pointer-events: none; }
.segmented label:hover { background: var(--surface-2); }
.segmented label:has(input:checked) { background: var(--accent-fill); color: #fff; border-color: var(--accent-fill); }
.segmented label:has(input:disabled) { color: var(--muted); cursor: default; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

.presets, .role-toggles { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; align-items: center; }
.presets button, .role-toggles button, .wide { border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; font-size: 12px; }
.presets button:hover, .role-toggles button:hover, .wide:hover { border-color: var(--axis); }
.role-toggles button[aria-pressed="true"] { background: var(--accent-fill); color: #fff; border-color: var(--accent-fill); }
.wide { width: 100%; margin-top: 8px; padding: 6px; }
.network { margin: 8px 0; }
.network-head { display: flex; align-items: center; gap: 6px; }
.network-head > label { font-weight: 600; display: flex; gap: 6px; align-items: center; flex: 1; }
.network-head > .region { font-weight: 600; flex: 1; font-size: 13px; }
.disclose { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12px; padding: 2px 4px; white-space: nowrap; }
.disclose::before { content: "▸ "; }
.disclose[aria-expanded="true"]::before { content: "▾ "; }
/* Secondary settings, folded until wanted (opened by a link that changes one of them) */
.more { margin-top: 10px; }
.more > summary { cursor: pointer; font-size: 12px; color: var(--accent); list-style: none; width: fit-content; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::before { content: "▸ "; }
.more[open] > summary::before { content: "▾ "; }
.hospital { display: flex; gap: 6px; align-items: center; padding: 2px 0 2px 18px; font-size: 13px; }
.hospital .role { font-size: 10px; border: 1px solid var(--axis); border-radius: 3px; padding: 0 3px; color: var(--ink-2);
  white-space: nowrap; }
.base-row { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; font-size: 13px; }
.base-row .role { font-size: 10px; border: 1px solid var(--axis); border-radius: 3px; padding: 0 3px; color: var(--ink-2);
  white-space: nowrap; }
.base-row .base-status { font-size: 11px; color: var(--muted); }
.hospital .closed-note { font-size: 11px; color: var(--muted); }
.check-line { display: flex; gap: 6px; align-items: baseline; margin-top: 10px; font-size: 13px; cursor: pointer; }
.radio-list { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.radio-list label { display: flex; gap: 6px; align-items: baseline; cursor: pointer; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; font-size: 13px; }
.checks label { display: flex; gap: 5px; align-items: center; }
.checks .sw, .legend .sw, .chart-tip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px;
  box-shadow: 0 0 0 1px var(--swatch-ring); vertical-align: -1px; }
fieldset { border: 0; padding: 0; margin: 10px 0 0; }
legend { font-size: 12px; color: var(--ink-2); padding: 0; margin-bottom: 4px; }
.field-row { display: flex; gap: 10px; margin-top: 10px; font-size: 13px; }
.field-row select { margin-left: 4px; }

.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
.status { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: var(--surface); padding: 6px 12px;
  border-radius: 6px; box-shadow: var(--shadow); font-size: 13px; z-index: 3; display: flex; align-items: center; gap: 10px;
  max-width: calc(100% - 24px); }
.status:empty { display: none; }
.status progress { width: 90px; height: 6px; accent-color: var(--accent); }
.status button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: 3px 8px; cursor: pointer; }

/* The legend: the colour scale, always shown (one row of steps), then the symbols, which fold
   away on a narrow map */
.map-legend { position: absolute; left: 10px; top: 10px; background: var(--surface); border-radius: 6px; padding: 6px 10px;
  box-shadow: var(--shadow); font-size: 11.5px; line-height: 1.35; width: 222px; max-height: calc(100% - 60px); overflow-y: auto; }
.map-legend summary { cursor: pointer; font-weight: 600; font-size: 11.5px; color: var(--ink-2); margin-top: 5px; }
.map-legend details[open] summary { margin-bottom: 2px; }
.map-legend h3 { font-size: 11.5px; margin: 7px 0 3px; font-weight: 600; }
.map-legend h3:first-child { margin-top: 0; }
#legend-symbols-body h3:first-child { margin-top: 2px; }
.map-legend .scale { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 2px; }
.map-legend .scale .box { display: block; width: auto; height: 10px; border-radius: 2px; }
.map-legend .scale span.step { font-size: 10.5px; color: var(--ink-2); text-align: center; white-space: nowrap; }
.map-legend .scale-ends { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-2); }
.map-legend .items { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.map-legend .row { display: flex; align-items: center; gap: 5px; }
.map-legend .box { width: 14px; height: 10px; border-radius: 2px; flex: none; }
.map-legend .dot { width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 1px var(--swatch-ring); flex: none; }
.map-legend .dot.hollow { background: transparent !important; box-shadow: none; border: 1.6px solid; }
.map-legend .note { margin: 3px 0 0; }
.map-legend h3 + .note { margin: 0 0 4px; }
.map-legend .change-scale { display: grid; grid-template-columns: auto 1fr; gap: 3px 6px; align-items: start; }
.map-legend .change-scale .side { font-size: 10.5px; color: var(--ink-2); line-height: 10px; }
.check-line:has(input:disabled) { color: var(--muted); cursor: default; }

/* Hover label: the ED under the pointer and its value */
.map-tip { position: absolute; z-index: 2; pointer-events: none; background: var(--surface); color: var(--ink); border-radius: 6px;
  padding: 4px 8px; font-size: 12px; box-shadow: var(--shadow); max-width: 240px; }
.map-tip b { display: block; font-weight: 600; }

.hospital-marker { display: flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; cursor: pointer; }
.hm-icon { width: 18px; height: 18px; border-radius: 4px; background: #0b0b0b; color: #fff; font: 700 15px/18px var(--font);
  text-align: center; box-shadow: 0 0 0 2px #fff; }
.role-mtc .hm-icon { background: #7a1fa2; width: 22px; height: 22px; line-height: 22px; }
.role-type-1-ed .hm-icon { border-radius: 50%; }     /* NI Type 1 EDs: a circle, not a trauma unit square */
.hospital-marker.off .hm-icon { background: #fff; color: #6f6d67; box-shadow: 0 0 0 2px #6f6d67; }
.hospital-marker.hidden { display: none; }
/* A centre service's centres (its view only): a glyph on the service's colour, hollow when switched
   off or closed. PPCI: a heart on crimson. Thrombectomy: an S (stroke) on dark green. */
.centre-marker .hm-icon { font-size: 12px; }
.centre-marker.svc-ppci .hm-icon, .legend-centre.svc-ppci { background: #9b1c31; }
.centre-marker.svc-evt .hm-icon, .legend-centre.svc-evt { background: #1e6b30; }
.centre-marker.off .hm-icon { background: #fff; color: #6f6d67; }
.legend-centre { display: inline-block; width: 12px; height: 12px; border-radius: 3px; color: #fff; flex: none;
  font: 700 8px/12px var(--font); text-align: center; box-shadow: 0 0 0 1.5px #fff; }
.legend-centre.off { background: #fff; color: #6f6d67; box-shadow: inset 0 0 0 1.5px #6f6d67; }
.legend-hosp { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: #0b0b0b; flex: none;
  box-shadow: 0 0 0 1.5px #fff; }
.legend-hosp.role-mtc { background: #7a1fa2; }
.legend-hosp.role-type-1-ed { border-radius: 50%; }
.legend-hosp.off { background: #fff; box-shadow: inset 0 0 0 2px #6f6d67; }
/* Helicopter bases: a circle with an H (the heliport sign), hollow when switched off */
.base-marker { display: flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; cursor: pointer; }
.base-marker.hidden { display: none; }
.bm-icon { width: 20px; height: 20px; border-radius: 50%; background: #0b0b0b; color: #fff; font: 700 12px/20px var(--font);
  text-align: center; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px #0b0b0b; }
.base-marker.off .bm-icon { background: #fff; color: #6f6d67; box-shadow: 0 0 0 2px #6f6d67; }
.base-marker:hover .hm-label, .base-marker:focus-visible .hm-label { display: inline; }
/* Ambulance stations: a small diamond (not a circle or square, which are taken) */
.station-marker { border: 0; background: none; padding: 0; cursor: pointer; width: 14px; height: 14px; display: flex;
  align-items: center; justify-content: center; }
.station-marker.hidden { display: none; }
.sm-icon { width: 8px; height: 8px; background: #0b0b0b; transform: rotate(45deg); box-shadow: 0 0 0 1.5px #fff; }
.legend-station { display: inline-block; width: 8px; height: 8px; background: #0b0b0b; transform: rotate(45deg);
  box-shadow: 0 0 0 1.5px #fff; margin: 0 3px 0 2px; flex: none; }
.legend-base { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #0b0b0b; color: #fff; flex: none;
  font: 700 8px/12px var(--font); text-align: center; box-shadow: 0 0 0 1.5px #fff; }
.legend-base.off { background: #fff; color: #6f6d67; box-shadow: inset 0 0 0 1.5px #6f6d67; }
.map-legend .ring-sample { width: 22px; height: 8px; flex: none; }
.hm-label { display: none; background: rgba(255, 255, 255, 0.92); color: #0b0b0b; border-radius: 3px; padding: 0 4px; font-size: 11px;
  white-space: nowrap; }
.hospital-marker:hover .hm-label, .hospital-marker:focus-visible .hm-label, .zoomed-in .hm-label { display: inline; }

/* Downloads, at the top of the results */
.downloads { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; font-size: 12px; color: var(--ink-2); }
.downloads .link-button { font-size: 12px; padding: 3px 8px; }
.downloads .link-button[aria-busy="true"] { cursor: progress; color: var(--muted); }
.panel-section { margin-bottom: 18px; }
.panel-section > p { margin: 4px 0 8px; color: var(--ink-2); font-size: 12px; }
.scenario-line { font-size: 12px; color: var(--ink-2); margin-bottom: 10px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; margin-bottom: 8px; }
.tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tile { border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: var(--surface); }
.tile[data-tip] { cursor: help; }
.tile-label { font-size: 11px; color: var(--ink-2); }
.tile-value { font-size: 20px; font-weight: 600; white-space: nowrap; }
.tile-cmp { font-size: 11px; color: var(--muted); }
.tile-cmp .delta { display: block; color: var(--ink-2); font-weight: 600; }
.undef { font-size: 13px; font-weight: 400; color: var(--muted); }
.chart { margin: 0 0 12px; }
.chart figcaption { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 9px; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: var(--ring); }
.legend { display: flex; gap: 12px; font-size: 11px; color: var(--ink-2); margin: 2px 0; }
.legend .sw, .chart-tip .sw { border-radius: 2px; box-shadow: none; }
.note { font-size: 11px; color: var(--muted); margin: 2px 0; }
.table-view summary { font-size: 11px; color: var(--muted); cursor: pointer; }
.table-view table { border-collapse: collapse; font-size: 11px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.table-view th, .table-view td { padding: 1px 8px 1px 0; text-align: right; border-bottom: 1px solid var(--line); }
.table-view th:first-child { text-align: left; }
.chart-tip { position: fixed; pointer-events: none; opacity: 0; transition: opacity 0.08s; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 10; max-width: 260px; }

.air-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
.air-table th, .air-table td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.air-table thead th { font-weight: 400; color: var(--ink-2); text-align: right; font-size: 11px; }
.air-table thead th:first-child, .air-table tbody th { text-align: left; }
.air-table tbody th { font-weight: 400; }
.air-table td { text-align: right; font-weight: 600; white-space: nowrap; }
.air-table td .cmp { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.air-table .group th { padding-top: 10px; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.air-table tbody tr:not(.group) th { padding-left: 10px; }
.about ul { padding-left: 18px; font-size: 12px; color: var(--ink-2); }
.about li { margin-bottom: 6px; }
.about:focus { outline: none; }
.footer { padding: 6px 16px; font-size: 11px; line-height: 1.4; color: var(--ink-2); background: var(--surface); border-top: 1px solid var(--line); }
.footer p { margin: 0; }

.to-map { position: fixed; right: 12px; bottom: 16px; z-index: 20; border: 0; border-radius: 20px; padding: 10px 14px;
  background: var(--accent-fill); color: #fff; font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); cursor: pointer; }
.to-map::before { content: "↑ "; }

.popup h3 { margin: 0 0 4px; font-size: 14px; }
.popup table { border-collapse: collapse; font-size: 12px; width: 100%; }
.popup th { text-align: left; font-weight: 400; color: var(--ink-2); padding: 1px 8px 1px 0; }
.popup td { text-align: right; font-variant-numeric: tabular-nums; }
.popup .sub { font-size: 11px; color: var(--muted); margin: 6px 0 2px; }
.popup .two-col tr:first-child th { text-align: right; font-size: 11px; color: var(--muted); white-space: nowrap; }
.popup .two-col td { padding-left: 10px; }
.panel-section > p.sooner { color: var(--ink); }
.panel-section h3.sub-heading { font-size: 13px; font-weight: 600; margin: 12px 0 2px; }
.air-table .year-row th { font-weight: 600; }
.maplibregl-popup { z-index: 3; }        /* over the map's scale bar and credits, which a tall popup can reach */
.maplibregl-popup-content { color: var(--ink); background: var(--surface); max-height: 70vh; overflow-y: auto; }
.maplibregl-popup-close-button { color: var(--ink-2); font-size: 18px; width: 26px; height: 26px; }
.maplibregl-popup-anchor-top .maplibregl-popup-tip, .maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--surface); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
/* Map controls: zoom buttons and attribution follow the theme */
.maplibregl-ctrl-group { background: var(--map-ctrl-bg); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line); }
.maplibregl-ctrl button .maplibregl-ctrl-icon { filter: var(--map-ctrl-icon); }
.maplibregl-ctrl-attrib-button { filter: var(--map-ctrl-icon); }
.maplibregl-ctrl.maplibregl-ctrl-attrib, .maplibregl-ctrl-attrib.maplibregl-compact { background: var(--map-attrib-bg); color: var(--ink-2); }
.maplibregl-ctrl-attrib a { color: var(--ink-2); }
.maplibregl-ctrl-scale { background: var(--map-attrib-bg); color: var(--ink-2); border-color: var(--ink-2); }

/* Below 1100 px: the controls and the results share one column, switched with tabs */
@media (max-width: 1099px) {
  .pane-tabs { display: flex; grid-area: tabs; background: var(--surface); border-bottom: 1px solid var(--line); }
  .pane-tabs [role="tab"] { flex: 1; border: 0; background: none; padding: 10px 8px; font-size: 14px; font-weight: 600;
    color: var(--ink-2); cursor: pointer; border-bottom: 3px solid transparent; }
  .pane-tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent-fill); }
  .pane-tabs [role="tab"]:focus-visible { outline-offset: -3px; }
  .controls, .panel { grid-area: pane; border: 0; }
  .layout[data-pane="controls"] .panel, .layout[data-pane="panel"] .controls { display: none; }
}
/* 700-1099 px (tablets, small laptops): the column on the left, the map beside it, always in view */
@media (min-width: 700px) and (max-width: 1099px) {
  .layout { grid-template-columns: minmax(300px, 40%) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "tabs map" "pane map"; }
  .pane-tabs, .controls, .panel { border-right: 1px solid var(--line); }
  .subtitle { font-size: 12px; }
  .top-actions { flex-wrap: nowrap; gap: 6px; }
  .top-actions .link-button { font-size: 12px; padding: 4px 8px; }
}
/* 700-979 px: the search box on a line of its own under the title and buttons */
@media (min-width: 700px) and (max-width: 979px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .search { order: 1; flex: 1 1 100%; }
}
/* Phones: the map on top, then the tabs (they stay at the top of the screen while scrolling) */
@media (max-width: 699px) {
  body { height: auto; display: block; }
  .layout { display: flex; flex-direction: column; }
  /* The legend sits in a strip under the map rather than over it: any corner of a phone-sized
     map covers part of Ireland */
  .map-wrap { order: -1; }
  #map { position: relative; inset: auto; height: 56vh; height: 56svh; min-height: 280px; }
  .map-legend { position: static; width: auto; max-height: none; overflow: visible; border-radius: 0; box-shadow: none;
    border-bottom: 1px solid var(--line); padding: 6px 16px 8px; }
  .pane-tabs { position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 0 var(--line); }
  .controls, .panel { overflow: visible; padding: 12px 16px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 16px; }
  .subtitle { font-size: 12px; }
  .top-actions { gap: 6px; }
  .top-actions .link-button { font-size: 12px; padding: 4px 8px; }
  .search { flex: none; max-width: none; }
  .search input { font-size: 16px; }       /* 16 px: phones do not zoom in on a focused box */
  .footer { padding: 8px 16px 64px; }      /* room for the "Back to the map" button */
}
/* Touch screens: bigger targets */
@media (pointer: coarse) {
  .hospital, .base-row, .checks label, .radio-list label, .network-head > label { min-height: 34px; align-items: center; }
  .check-line { min-height: 34px; align-items: center; }
  .segmented label { padding: 9px 4px; }
  .presets button, .role-toggles button { padding: 7px 10px; font-size: 13px; }
  .disclose { padding: 8px 6px; }
  .more > summary { padding: 8px 0; }
  .table-view summary { padding: 6px 0; }
  input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; flex: none; }
  .field-row select { min-height: 34px; }
}
@media (forced-colors: active) {
  .segmented label:has(input:checked) { outline: 2px solid CanvasText; }
  .pane-tabs [role="tab"][aria-selected="true"] { text-decoration: underline; }
}
@media (prefers-reduced-motion: reduce) {
  .chart-tip { transition: none; }
}
