/* ================= tokens ================= */
:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #eef0f3; --line: #e1e4e8;
  --fg: #14161a; --muted: #5b626c; --accent: #1f6feb;
  --red: #c62828; --red-bg: #fdecea; --orange: #d9480f; --orange-bg: #fff1e6; --orange-fg: #b03a06;
  --yellow: #f5b800; --yellow-bg: #fff8db; --green: #2e7d32; --warn-bg: #fff4e5; --warn-fg: #6b3a00;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-6: 24px;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .06);
  --tabbar-h: 64px; --donate: #db2777;
  color-scheme: light;
}
/* Dark theme: theme.js sets data-theme from the saved choice or the system setting. */
html[data-theme="dark"] {
  --bg: #0e1014; --surface: #171a20; --surface-2: #1f232a; --line: #2a2f38;
  --fg: #e6e8eb; --muted: #98a0aa; --accent: #6ea8fe;
  --red: #f87171; --red-bg: #3d1212; --orange: #fb923c; --orange-bg: #3f230c; --orange-fg: #fb923c;
  --yellow: #facc15; --yellow-bg: #3a2e06; --green: #4ade80; --warn-bg: #3a2a12; --warn-fg: #ffd8a8;
  --shadow-1: none; --donate: #f472b6;
  color-scheme: dark;
}

/* ================= base ================= */
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
main { max-width: 640px; margin: 0 auto; padding: var(--s-2) var(--s-4) var(--s-4); }
h1 { font-size: 1.75rem; margin: 0; }
h2 { margin: 0; }
p { margin: 0; }
a { color: inherit; }
time { font-variant-numeric: tabular-nums; }
small { color: var(--muted); }
.lead { color: var(--muted); margin: var(--s-2) 0 var(--s-4); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: var(--fg); }
select { padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
button.primary { padding: var(--s-3); border-radius: var(--r-md); border: 0; background: var(--fg); color: var(--bg); font-weight: 600; min-height: 44px; }

/* ================= icons (Lucide sprite) ================= */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 14px; height: 14px; vertical-align: -2px; margin-left: 2px; }
.icon.filled { fill: currentColor; }
.icon.end { margin-left: auto; color: var(--muted); }

/* ================= app bar, chips ================= */
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s-2);
  max-width: 640px; margin: 0 auto; padding: calc(var(--s-2) + env(safe-area-inset-top)) var(--s-3) var(--s-2) var(--s-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.area-switch { display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; flex: 1; background: none; border: 0; padding: var(--s-1) 0; text-align: left; cursor: pointer; }
.area-switch.static { cursor: default; }
.area-switch .city { font-size: .8rem; color: var(--muted); }
.area-switch .title { display: flex; align-items: center; gap: var(--s-1); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.area-switch .title .icon { color: var(--muted); }
.appbar-actions { display: flex; gap: var(--s-1); }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: var(--r-pill); border: 0; background: transparent; color: var(--fg); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }
.lang-btn {
  display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 var(--s-2); flex: none;
  border-radius: var(--r-pill); color: var(--fg); font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-decoration: none;
}
.lang-btn:hover { background: var(--surface-2); }
.icon-btn .icon { width: 22px; height: 22px; }
#fav[aria-pressed="true"] { color: var(--orange); }
#fav[aria-pressed="true"] .icon { fill: currentColor; }
.chips { display: flex; gap: var(--s-2); overflow-x: auto; max-width: 640px; margin: 0 auto; padding: 0 var(--s-4) var(--s-2); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 36px; padding: 6px 12px;
  border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-size: .9rem; white-space: nowrap; cursor: pointer;
}
.chip .icon { width: 16px; height: 16px; }
.chip .icon.filled { color: var(--orange); }
.chip.current { border-color: var(--fg); font-weight: 700; }
.chip.add { padding: 6px 10px; }

/* ================= alarm block ================= */
.action { margin-top: var(--s-2); font-weight: 700; }
/* Live indicator: breathing dot while SSE is alive, grey when it is not. */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: breathe 2s ease-in-out infinite; }
body.offline .live .dot { background: var(--muted); animation: none; }
.live-line { display: flex; justify-content: flex-end; margin-bottom: var(--s-2); }
.live-line .live { font-size: 1.5rem; font-weight: 700; color: var(--fg); gap: 8px; }
.live-line .live .dot { width: 10px; height: 10px; }
@keyframes breathe { 50% { opacity: .35; } }
/* The map hint names the gesture of the device: tap, or hover and click. */
.hint-pointer { display: none; }
@media (hover: hover) and (pointer: fine) { .hint-touch { display: none; } .hint-pointer { display: inline; } }
/* Status line (_statusline.html): alarm regions or calm, and mentions. */
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 var(--s-3); font-size: .9rem; color: var(--muted); }
.status-line .st-head { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--fg); }
.status-line.on .st-head { color: var(--red); }
.status-line .st-head .icon { width: 18px; height: 18px; }
.status-line .st-calm { color: var(--green); }
.status-line .st-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.status-line .st-region { display: inline-flex; align-items: center; gap: 5px; color: var(--fg); font-weight: 600; }
.status-line .st-region svg { width: 14px; height: 14px; flex: none; }
.st-sw { stroke: #8b929c; }
.st-sw.st-yellow { fill: #fde68a; } .st-sw.st-orange { fill: #fdba74; } .st-sw.st-red { fill: #f87171; } .st-sw.st-unknown { fill: #d1d5db; }
.status-line > .st-mentions:first-child::first-letter { text-transform: uppercase; }
.status-line .st-head + .st-mentions::before, .status-line .st-region + .st-mentions::before, .status-line .st-more + .st-mentions::before { content: "· "; }
.sw-hatch { stroke: #b91c1c; stroke-opacity: .5; }
.sw-hatch.grey { stroke: #6b7280; }
/* Dark theme: the keys match the dark map fills. */
html[data-theme="dark"] :is(.st-sw.st-yellow, .legend .sw-yellow) { fill: #4a3c0c; }
html[data-theme="dark"] :is(.st-sw.st-orange, .legend .sw-orange) { fill: #4d2a0e; }
html[data-theme="dark"] :is(.st-sw.st-red, .legend .sw-red) { fill: #6b1d1d; }
html[data-theme="dark"] :is(.st-sw.st-unknown, .legend .sw-unknown) { fill: #2f333b; }
html[data-theme="dark"] .sw-hatch { stroke: #f87171; }
html[data-theme="dark"] .sw-hatch.grey { stroke: #9ca3af; }
/* Hovered zone (app.js draws it over the neighbours). */
.outlines .hover-line { stroke: var(--fg); stroke-opacity: .85; }

/* ================= cards, rows, feed ================= */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-4); margin-bottom: var(--s-3); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; gap: var(--s-2); font-size: .95rem; font-weight: 600; margin: 0 0 var(--s-2); }
.card-head .icon { width: 18px; height: 18px; color: var(--muted); }
.card-head-row { display: flex; align-items: center; justify-content: space-between; margin: -10px -8px 0 0; }
.card-head-row .card-head { margin: 0; }
/* The clock rides in the head row of the first card: after the heading, before the button. */
.card-head-row .clock { order: 1; margin: 0 0 0 auto; padding-left: var(--s-2); }
.card-head-row .clock .live { font-size: 1.25rem; }
.card-head-row .icon-btn { order: 2; }
.here > .card-head-row { margin: -4px 0 var(--s-2); }
.map-pane > .card-head-row { margin: 0 -8px 0 0; }
.map-pane > .card-head-row:not(:has(.icon-btn)) { margin-right: 0; }
.minimap { margin-bottom: var(--s-3); }
.big { font-size: 1.25rem; font-weight: 700; }
.here-place { margin: 4px 0 0; font-weight: 600; }
.here-time { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.here.hit { background: var(--red-bg); border-color: var(--red); }
.here.hit .card-head, .here.hit .card-head .icon { color: var(--red); }
.here .here-time + .near, .here .src + .near { margin-top: var(--s-2); border-top: 1px solid var(--line); }
.src { margin-top: 6px; font-size: .9rem; color: var(--muted); }
.src a { text-decoration: none; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: var(--s-3); min-height: 48px; padding: var(--s-2) 0; border-top: 1px solid var(--line); text-decoration: none; }
.rows li:first-child .row { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row time { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.row.mine { color: var(--red); font-weight: 700; }
.row:active { transform: scale(.98); }
.rows .none { padding: var(--s-3) 0; color: var(--muted); }
.tag { display: inline-block; padding: 1px 7px; border-radius: var(--r-sm); background: var(--orange-bg); color: var(--orange-fg); font-size: .8125rem; line-height: 1.3; font-weight: 600; vertical-align: 2px; }
.feed ol { list-style: none; margin: 0; padding: 0; }
.feed li { padding: var(--s-2) 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.meta { font-size: .8rem; color: var(--muted); }
.text { white-space: pre-line; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.feed details summary, details.more summary { display: flex; align-items: center; gap: var(--s-2); list-style: none; cursor: pointer; min-height: 44px; color: var(--muted); font-weight: 600; border-top: 1px solid var(--line); }
.feed details summary::-webkit-details-marker, details.more summary::-webkit-details-marker { display: none; }
.feed details[open] summary .icon, details.more[open] summary .icon { transform: rotate(180deg); }
.warn-box { display: flex; gap: var(--s-2); align-items: flex-start; margin: var(--s-2) 0 var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--warn-bg); color: var(--warn-fg); font-size: .9rem; }
.warn-box .icon { width: 18px; height: 18px; margin-top: 1px; }
/* Reconnecting: calm, not an alarm colour. */
.offline-banner { position: sticky; top: 72px; z-index: 15; display: flex; gap: var(--s-2); align-items: center; margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); font-size: .9rem; }
.offline-banner .icon { width: 16px; height: 16px; }
body > footer { max-width: 640px; margin: var(--s-6) auto 0; padding: 0 var(--s-4) var(--s-4); font-size: .8rem; color: var(--muted); }
body > footer p { margin: 0 0 6px; }
/* Desktop: one row, wrapping only where it doesn't fit. A phone is too narrow, it keeps a line per item. */
@media (min-width: 1024px) {
  body > footer { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
  body > footer p { margin: 0; }
}
.ic-link { display: inline-flex; align-items: center; gap: 4px; vertical-align: middle; }
.ic-link .icon { width: 16px; height: 16px; }

/* ================= tab bar ================= */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 200px; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .75rem; font-weight: 600;
}
.tabbar a .icon { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar a.off { opacity: .4; pointer-events: none; }
.tabbar a[aria-current="page"] .icon { stroke-width: 2.4; }
/* Donate: the bar's last item, so it is always in the corner and covers nothing. */
.tabbar a.donate { flex: none; width: 96px; color: var(--donate); white-space: nowrap; }
.donate-ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--donate); color: #fff; animation: donate-ring 3s ease-out infinite; }
.tabbar a.donate .donate-ic .icon { width: 20px; height: 20px; stroke-width: 2; animation: heartbeat 3s ease-in-out infinite; }
@keyframes heartbeat { 0%, 30%, 100% { transform: scale(1); } 7% { transform: scale(1.25); } 14% { transform: scale(1); } 21% { transform: scale(1.18); } }
@keyframes donate-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--donate) 55%, transparent); } 40%, 100% { box-shadow: 0 0 0 10px transparent; } }
/* No pulse while the page shows an alarm or a threat here: the heart must not compete with it (app.js sets .alarm). */
body.alarm .donate-ic, body.alarm .tabbar a.donate .donate-ic .icon { animation: none; }
/* Wide portrait: the tabs stay centred, the heart goes to the right edge. */
@media (min-width: 700px) {
  .tabbar::before { content: ""; flex: none; width: 96px; margin-right: auto; }
  .tabbar a.donate { margin-left: auto; }
}

/* ================= sheet (area switcher) ================= */
.sheet {
  width: 100%; max-width: 560px; max-height: 85vh; margin: auto auto 0; padding: var(--s-4) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom));
  border: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--surface); color: var(--fg); overflow-y: auto; overscroll-behavior: contain;
}
/* iOS scrolls the page under a modal dialog; lock it while the sheet is open */
html:has(.sheet[open]) { overflow: hidden; }
.sheet::backdrop { background: rgb(0 0 0 / .45); }
.sheet[open] { animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 700px) { .sheet { margin: auto; border-radius: var(--r-lg); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-3); }
.sheet-head h2 { font-size: 1.1rem; }
.sheet > .row { border-top: 1px solid var(--line); margin-top: var(--s-2); }
.search { display: flex; align-items: center; gap: var(--s-2); padding: 0 var(--s-3); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2); }
.search .icon { color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; padding: var(--s-3) 0; outline: none; }
#sheet-results:not(:empty), #q-results:not(:empty) { margin-top: var(--s-2); }
#sheet-favs:not(:empty) { margin-top: var(--s-3); }
#sheet-favs .icon.filled { color: var(--orange); }

/* ================= segmented control ================= */
.segmented { display: flex; gap: 2px; padding: 3px; margin: var(--s-4) 0 var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.segmented > * {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  border: 0; border-radius: calc(var(--r-md) - 3px); background: transparent; color: var(--muted); font-weight: 600; font-size: .9rem; text-decoration: none; cursor: pointer;
}
.segmented .icon { width: 16px; height: 16px; }
.segmented [aria-checked="true"], .segmented [aria-current="page"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-1); }

/* ================= pick page ================= */
.picker { display: grid; gap: var(--s-2); margin-top: var(--s-4); }
.picker label { font-weight: 600; font-size: .9rem; color: var(--muted); }
.feedback textarea, .feedback input[type=text] { font: inherit; color: var(--fg); padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
.feedback textarea { resize: vertical; min-height: 8rem; }
.feedback label.check { display: flex; align-items: center; gap: var(--s-2); font-weight: 400; color: var(--fg); min-height: 44px; }
.feedback label.check input { width: 20px; height: 20px; margin: 0; }
.feedback .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.map-hint { margin-top: var(--s-6); }

/* ================= schematic maps (pick page) ================= */
.map { width: min(960px, calc(100vw - 32px)); position: relative; left: 50%; transform: translateX(-50%); margin-bottom: var(--s-6); }
.map-scroll { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.map svg { display: block; width: 100%; height: auto; }
.cell:hover path, .cell:focus path { filter: brightness(.93); }
.cell.mine path { stroke: #1d4ed8; stroke-width: 3; }
.river { opacity: .75; pointer-events: none; stroke-linecap: round; stroke-linejoin: round; }
.labels { pointer-events: none; }
.label text:not(.lbl-mini) { font-size: 16px; font-weight: 500; paint-order: stroke; stroke: #ffffffcc; stroke-width: 4px; }
#map-kyiv .label .lbl-d { font-size: 14px; }
.label.jump text { font-size: 22px; font-weight: 700; }
.label.mine text { font-weight: 800; }
.label .lbl-m { display: none; }
@media (max-width: 700px) {
  .label text.lbl-d { display: none; }
  .label text.lbl-m { display: inline; font-size: 30px; stroke-width: 7px; }
  .label.jump text.lbl-m { font-size: 40px; }
  .label circle { r: 8; }
}
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: var(--s-2) 2px 0; margin: 0; font-size: .85rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend svg { width: 14px; height: 14px; }
.legend svg.wide { width: 44px; }
html[data-theme="dark"] .cell path { stroke: #0e1014; }
html[data-theme="dark"] .label text { fill: #e6e8eb; stroke: #0e1014cc; }
html[data-theme="dark"] .label circle { fill: #98a0aa; }
/* Dark: muted zone tints, so colour stays for danger. */
html[data-theme="dark"] .g-right, html[data-theme="dark"] .g-right path { fill: #2a2722; }
html[data-theme="dark"] .g-left, html[data-theme="dark"] .g-left path { fill: #1f262f; }
html[data-theme="dark"] .g-kyiv, html[data-theme="dark"] .g-kyiv path { fill: #2a2e36; }
html[data-theme="dark"] .g-73, html[data-theme="dark"] .g-73 path { fill: #25222d; }
html[data-theme="dark"] .g-74, html[data-theme="dark"] .g-74 path { fill: #1f2923; }
html[data-theme="dark"] .g-75, html[data-theme="dark"] .g-75 path { fill: #2a2229; }
html[data-theme="dark"] .g-76, html[data-theme="dark"] .g-76 path { fill: #24281d; }
html[data-theme="dark"] .g-77, html[data-theme="dark"] .g-77 path { fill: #2a2824; }
html[data-theme="dark"] .g-78, html[data-theme="dark"] .g-78 path { fill: #1d2929; }
html[data-theme="dark"] .g-79, html[data-theme="dark"] .g-79 path { fill: #20232d; }

/* ================= live danger map ================= */
.live.mini .label .lbl-mini { font-weight: 500; paint-order: stroke; stroke: #ffffffcc; stroke-width: 3px; }
html[data-theme="dark"] .live .zone path:first-of-type { fill: #1f232a; stroke: #0e1014; }
html[data-theme="dark"] .live .zone.al-yellow path:first-of-type { fill: #4a3c0c; }
html[data-theme="dark"] .live .zone.al-orange path:first-of-type { fill: #4d2a0e; }
html[data-theme="dark"] .live .zone.al-red path:first-of-type { fill: #6b1d1d; }
html[data-theme="dark"] .live .zone.al-unknown path:first-of-type { fill: #2f333b; }
/* Hatching on red and unknown-level zones (_zmap.html): red lines on red, grey on unknown. */
.zoomable .hatch line { stroke: #b91c1c; stroke-opacity: .18; }
.zoomable .zone.al-unknown .hatch-over { opacity: .6; filter: grayscale(1); }
html[data-theme="dark"] .zoomable .hatch line { stroke: #f87171; stroke-opacity: .22; }

html[data-theme="dark"] .live .mine-line { stroke: #60a5fa; }
html[data-theme="dark"] .live .rings circle { stroke: #f87171; }
html[data-theme="dark"] .live .rings circle[r="6"] { fill: #f87171; }
.live-legend { margin-bottom: var(--s-2); }

/* ================= history ================= */
.facts { margin: 0; padding-left: 18px; }
.facts li { margin: 4px 0; }
/* ================= history ================= */
/* Stat tiles: the answer first, the detail under it. */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-2); margin-bottom: var(--s-2); }
.tile { display: flex; flex-direction: column; gap: 2px; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); min-width: 0; }
.tile-label { font-size: .8rem; color: var(--muted); }
.tile strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; line-height: 1.25; }
.tile strong.none { font-size: 1rem; font-weight: 500; color: var(--muted); }
.tile-sub { font-size: .8rem; color: var(--muted); }
.tile.mine strong { color: var(--accent); }
.tile-kinds { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .9rem; }
.tile-kinds > span { display: inline-flex; align-items: center; gap: 4px; }
/* Timeline: HTML labels, SVG tracks in % (no viewBox), so text keeps its size. */
.tl { display: grid; gap: 6px; }
.tl-row { display: grid; grid-template-columns: var(--tl-label, 7.5rem) minmax(0, 1fr); align-items: center; gap: var(--s-2); }
.tl-label { font-size: .8rem; color: var(--muted); line-height: 1.2; overflow-wrap: anywhere; }
.tl-track { display: block; width: 100%; height: 22px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.tl-axis .tl-track { height: 16px; background: none; overflow: visible; }
.tl-axis text { font-size: 11px; fill: var(--muted); }
.tl-grid { stroke: var(--line); stroke-width: 1; }
.al-red { fill: var(--red); } .al-orange { fill: var(--orange); } .al-yellow { fill: var(--yellow); } .al-unknown { fill: var(--muted); }
.tl-mine rect, .nr-mine rect { fill: var(--accent); }
.tl-near rect { fill: var(--muted); opacity: .6; }
.tl-legend { padding-top: var(--s-3); }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.al-red { background: var(--red); } .sw.al-orange { background: var(--orange); } .sw.al-yellow { background: var(--yellow); }
.sw + .sw { margin-left: -4px; } .sw-mine { background: var(--accent); } .sw-near { background: var(--muted); opacity: .6; }
/* 7 nights: a row per night, each on the same 18:00–09:00 axis. */
.night-row { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) 7rem auto; align-items: center; gap: var(--s-2); min-height: 48px; padding: var(--s-1) 0; border-top: 1px solid var(--line); text-decoration: none; }
.nights .card-head + .night-row, .nr-axis + .night-row { border-top: 0; }
.night-row.nr-axis { min-height: 0; padding: 0; }
.nr-axis .tl-track { height: 16px; background: none; overflow: visible; }
.nr-axis text { font-size: 11px; fill: var(--muted); }
.nr-label { font-size: .85rem; }
.nr-track { height: 26px; }
.nr-facts { display: flex; align-items: center; gap: 4px; font-size: .85rem; font-variant-numeric: tabular-nums; }
.impacts ol, .groups, .groups ol { list-style: none; margin: 0; padding: 0; }
.groups > li { padding: var(--s-2) 0; border-top: 1px solid var(--line); }
.groups > li:first-child { border-top: 0; padding-top: 0; }
.g-time { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.groups ol li + li { margin-top: 6px; }
.impacts li + li { margin-top: var(--s-2); }
@media (max-width: 520px) {
  .tl-row { --tl-label: 5.5rem; }
  .night-row { grid-template-columns: 5.5rem minmax(0, 1fr) 6.5rem; }
  .night-row > .icon.end, .nr-axis > span:last-child { display: none; }
  /* 3-hour labels overlap on a phone: the day and the week keep every 6 hours. */
  .tl-axis.dense text.minor, .nr-axis text.minor { display: none; }
  /* Two tiles a row; an odd last one takes the whole row. */
  .tiles { grid-template-columns: 1fr 1fr; }
  .tiles > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ================= motion ================= */
@view-transition { navigation: auto; }
.appbar { view-transition-name: appbar; }
.chips { view-transition-name: chips; }
.tabbar { view-transition-name: tabbar; }
.icon-btn:active, .chip:active, .tabbar a:active, button.primary:active { transform: scale(.97); }
/* Tap feedback (app.js): the tapped tab pulses and a bar runs at the top until the next page shows. */
html.navigating body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: 3px;
  background: var(--accent); transform-origin: left; animation: nav-bar 8s cubic-bezier(.1, .7, .3, 1) forwards;
}
@keyframes nav-bar { from { transform: scaleX(.08); } to { transform: scaleX(.92); } }
.tabbar a.loading .icon, .period a.loading { animation: breathe 1s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  @view-transition { navigation: none; }
}
.map, section { scroll-margin-top: 88px; }

/* ================= install page ================= */
.steps { margin: var(--s-2) 0 0; padding-left: 22px; }
.steps li { margin: 6px 0; }
.steps .icon.sm { width: 16px; height: 16px; vertical-align: -3px; }
.install-btn { display: flex; align-items: center; justify-content: center; gap: var(--s-2); width: 100%; margin-bottom: var(--s-3); }
.install.first { border-color: var(--accent); }
.warn-box.ok { background: var(--surface); color: var(--green); border: 1px solid var(--green); }
@media (display-mode: standalone) { .hide-standalone { display: none !important; } }

/* Install hint at the top of every page. */
.install-hint { display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-3); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); font-size: .9rem; }
.install-hint > .icon { width: 18px; height: 18px; color: var(--accent); flex: none; }
.install-hint .grow { flex: 1; min-width: 0; }
.install-hint-btn { flex: none; padding: 6px 12px; border-radius: var(--r-pill); background: var(--fg); color: var(--bg); text-decoration: none; font-weight: 600; white-space: nowrap; }
.install-hint-x { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.install-hint-x .icon { width: 18px; height: 18px; }
.install-hint[hidden] { display: none; }
@media (display-mode: standalone) { .install-hint { display: none; } }

/* Alarm badge by the area name (app.js). */
.area-switch .title { flex-wrap: wrap; }
.title-end { display: inline-flex; align-items: center; gap: var(--s-1); }
.alarm-badge { padding: 2px 8px; border-radius: var(--r-pill); font-size: .8rem; font-weight: 700; line-height: 1.4; white-space: nowrap; color: #fff; background: #5b626c; }
.alarm-badge[hidden] { display: none; }
.alarm-badge[data-alarm="off"] { background: #2e7d32; }
.alarm-badge[data-alarm="yellow"] { background: #f5b800; color: #14161a; }
.alarm-badge[data-alarm="orange"] { background: #d9480f; }
.alarm-badge[data-alarm="red"] { background: #c62828; }

/* ================= inline hints: onboarding as you go ================= */
.card-head { flex-wrap: wrap; }
.hint { font-weight: 400; font-size: .8rem; color: var(--muted); }
.hint .icon.sm { width: 13px; height: 13px; vertical-align: -2px; margin: 0; }
.hint-inline { text-decoration: underline dotted; text-underline-offset: 3px; }

/* ================= threat types ================= */
.kind { display: inline-flex; vertical-align: -3px; }
.kind .icon { width: 18px; height: 18px; }
.big .kind { margin-right: 6px; vertical-align: -1px; }
.big .kind .icon { width: 22px; height: 22px; }
.meta .kind .icon { width: 14px; height: 14px; }
.k-ballistic, .k-cruise, .k-jet, .k-drone, .k-impact { color: #dc2626; }
.icon.kind-none { width: 18px; height: 18px; color: var(--muted); }
.kinds-legend { margin-top: var(--s-2); }
.kinds-legend .icon { width: 16px; height: 16px; }
html[data-theme="dark"] .live .mark .halo { fill: #0e1014; }
html[data-theme="dark"] .live .mark svg { color: #f87171; }
html[data-theme="dark"] .live .mark .halo { stroke: #f87171; }
html[data-theme="dark"] .zoomable :is(.mk .casing, .alt-casing) { stroke: #0e1014; }
html[data-theme="dark"] .zoomable .mk .halo { fill: #0e1014; }
html[data-theme="dark"] .zoomable .rings [stroke="#dc2626"] { stroke: #f87171; }
html[data-theme="dark"] .zoomable .rings [fill="#dc2626"] { fill: #f87171; }
html[data-theme="dark"] .mine-swatch { stroke: #60a5fa; }
html[data-theme="dark"] :is(.k-ballistic, .k-cruise, .k-jet, .k-drone, .k-impact) { color: #f87171; }

/* ================= legends, reconnect ================= */
.legend-box { margin-top: var(--s-2); border-top: 1px solid var(--line); }
.legend-box summary { display: flex; align-items: center; gap: var(--s-2); min-height: 40px; list-style: none; cursor: pointer; color: var(--muted); font-size: .85rem; font-weight: 600; }
.legend-box summary::-webkit-details-marker { display: none; }
.legend-box summary .icon { width: 16px; height: 16px; }
.legend-box[open] summary .icon.end { transform: rotate(180deg); }
.legend-box .legend { padding-top: 0; padding-bottom: var(--s-2); }
.offline-banner { font-weight: 400; }
.offline-banner strong { font-weight: 700; }
.icon.spin { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
html[data-theme="dark"] .zoomable .impact-halo { color: #0e1014; }
/* The map's red in the dark theme: impacts, descent badge, edge counts, legend. */
html[data-theme="dark"] .zoomable .impact svg:not(.impact-halo) { color: #f87171; }
html[data-theme="dark"] .live .alt-badge circle { fill: #f87171; stroke: #0e1014; }
html[data-theme="dark"] .edge-n { color: #f87171; }
html[data-theme="dark"] .legend [stroke="#dc2626"] { stroke: #f87171; }
html[data-theme="dark"] .legend [fill="#dc2626"] { fill: #f87171; }
html[data-theme="dark"] .legend svg[color="#dc2626"] { color: #f87171; }
.legend svg[color] { fill: none; }

/* ================= zoomable map ================= */
.zmap { position: relative; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.minimap .zmap { margin: var(--s-2) 0 var(--s-1); border-radius: var(--r-md); }
/* The live map slot before its first fragment arrives: the map's own box. */
.live-map:empty { aspect-ratio: 1 / 1; margin: var(--s-2) 0 var(--s-1); border-radius: var(--r-md); background: var(--surface-2); }
.zoomable { display: block; width: 100%; height: auto; aspect-ratio: 1 / 1; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; --k: 10; }
.zoomable .pin > .mk { transform: scale(var(--k)); }
/* A target heading here, not arrived yet: a dashed outline. */
.zoomable .rings .mk.due .halo { stroke-dasharray: 4 3; }
.zoomable .clustered { display: none; }
.zoomable .cluster { cursor: pointer; }
.zoomable text { font-weight: 500; paint-order: stroke; stroke: #ffffffd9; pointer-events: none; }
.zoomable .lvx { display: none; }
.zoomable[data-lv="0"] .lv0, .zoomable[data-lv="1"] .lv1, .zoomable[data-lv="2"] .lv2,
.zoomable[data-lv="3"] .lv3, .zoomable[data-lv="4"] .lv4, .zoomable[data-lv="5"] .lv5,
.zoomable[data-lv="6"] .lv6, .zoomable[data-lv="7"] .lv7, .zoomable[data-lv="8"] .lv8,
.zoomable[data-lv="9"] .lv9, .zoomable[data-lv="10"] .lv10 { display: inline; }
/* A name cut by the view's edge or under the map controls (app.js). */
.zoomable .lvx.cut { display: none; }
.zoomable text.mine { font-weight: 800; }
.edge-marks { position: absolute; inset: 0; pointer-events: none; }
.edge-group { position: absolute; pointer-events: auto; display: flex; align-items: center; gap: 4px; padding: 2px 7px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-1); cursor: pointer; }
.edge-group.top { top: 6px; transform: translateX(-50%); }
.edge-group.bottom { bottom: 6px; transform: translateX(-50%); }
.edge-group.left { left: 6px; transform: translateY(-50%); flex-direction: column; padding: 6px 3px; gap: 1px; }
.edge-group.right { right: 6px; transform: translateY(-50%); flex-direction: column; padding: 6px 3px; gap: 1px; }
.edge-group .edge-arrow { display: inline; width: 9px; height: 9px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.edge-n { font-size: 13px; font-weight: 800; line-height: 18px; min-width: 14px; text-align: center; color: #dc2626; }
/* View settings (app.js sets the body classes). Move arrows are opt-in. */
body:not(.moves-on) .zmap .moves, body:not(.moves-on) .legend-move { display: none; }
body.mv-no-impacts .zmap .impacts { display: none; }
/* With an own area: names only for it and zones with threat marks (app.js
   fillNames); faint borders past its neighbours. */
body:not(.mv-labels) .zmap[data-own] .zlabels .lvx { display: none; }
body.mv-labels .zmap .zlabels .nb { display: none; }
body:not(.mv-borders) .zmap[data-own] .zoomable .zone:not(.focus) path:first-of-type { stroke-opacity: .15; }
.view-set { position: absolute; right: 56px; top: 8px; z-index: 6; width: min(250px, calc(100% - 64px)); max-height: calc(100% - 16px); overflow: auto; padding: var(--s-2) var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.view-set fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.view-set legend { padding: 0 0 var(--s-1); font-weight: 700; font-size: .9rem; }
.view-set label { display: flex; align-items: center; gap: var(--s-2); min-height: 40px; font-size: .9rem; cursor: pointer; }
.view-set input { width: 18px; height: 18px; margin: 0; flex: none; }
.view-set .view-side { display: none; margin-top: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--line); }
.view-side-row { display: flex; gap: var(--s-3); }
.view-need { margin: var(--s-1) 0 0; font-size: .8rem; color: var(--muted); }
.zmap[data-own] .view-need { display: none; }
/* Until the first use: the settings button pulses (a still ring with reduced motion). */
body.mv-new .view-btn { animation: view-ring 2.4s ease-out infinite; }
@keyframes view-ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); } 50%, 100% { box-shadow: 0 0 0 10px transparent; } }
@media (prefers-reduced-motion: reduce) { body.mv-new .view-btn { box-shadow: 0 0 0 3px var(--accent); } }
/* How to read the map: a popup by the controls, larger marks and room for the full texts. */
.legend-pop { position: absolute; right: 56px; top: 8px; z-index: 6; width: min(360px, calc(100% - 64px)); max-height: calc(100% - 16px); overflow: auto; padding: var(--s-2) var(--s-3) var(--s-3); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.legend-pop, .view-set { box-shadow: 0 6px 24px rgb(0 0 0 / .18); }
.zoom-ctl .icon-btn[aria-expanded="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
/* Phone: the map is too small for the full texts, the legend opens as a bottom sheet. */
@media (max-width: 520px) {
  .map { left: auto; transform: none; }
  .legend-pop { position: fixed; left: var(--s-4); right: var(--s-4); top: auto; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-2)); width: auto; max-height: 70dvh; z-index: 30; }
}
.legend-pop-head { display: flex; align-items: center; justify-content: space-between; margin: 0 -8px var(--s-1) 0; }
.legend-pop-head h2 { font-size: .9rem; font-weight: 700; }
.legend-pop .legend { flex-direction: column; gap: var(--s-2); padding: 0; font-size: .9rem; color: var(--fg); }
.legend-pop .legend li { align-items: flex-start; gap: var(--s-3); }
.legend-pop .legend svg { width: 22px; height: 22px; flex: none; }
.legend-pop .legend + .legend { margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line); }
.legend-sub { margin: 0 0 var(--s-2); font-size: .85rem; font-weight: 600; color: var(--muted); }
.zmap:not([data-own]) .legend-mine { display: none; }
.zoom-ctl { position: absolute; right: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.zoom-ctl .icon-btn { width: 40px; height: 40px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
html[data-theme="dark"] .zoomable text { fill: #f3f4f6; stroke: #0e1014; }
html[data-theme="dark"] .zoomable .dots circle { fill: #98a0aa; }
.zoomable:active { cursor: grabbing; }
html[data-theme="dark"] .zoomable .zlabels circle { fill: #98a0aa; }
html[data-theme="dark"] .city-border { stroke: #9ca3af; }
html[data-theme="dark"] .city-border.halo { stroke: #0e1014; }
html[data-theme="dark"] .legend line[stroke="#6b7280"] { stroke: #9ca3af; }
html[data-theme="dark"] .cell.mine path { stroke: #60a5fa; }
/* Own area: spotlight veil, double outline, own name. */
.own-label text { font-weight: 800; }
html[data-theme="dark"] .mine-halo { stroke: #0e1014; }
html[data-theme="dark"] .zoomable .mine-line { stroke: #60a5fa; }
html[data-theme="dark"] .zoomable .own-label text { fill: #93c5fd; }
/* Zone borders inside alarm areas: a darker shade of the fill, not grey. */
.zoomable .zone.al-yellow path:first-of-type { stroke: #d4a017; stroke-opacity: .55; }
.zoomable .zone.al-orange path:first-of-type { stroke: #e0772c; stroke-opacity: .55; }
.zoomable .zone.al-red path:first-of-type { stroke: #e35d5d; stroke-opacity: .55; }
/* Dark theme: one light-grey, half-transparent border on every fill: visible
   on the dark alarm fills, quieter than the white label text. */
html[data-theme="dark"] .zoomable .zone path:first-of-type,
html[data-theme="dark"] .zoomable .zone.al-yellow path:first-of-type,
html[data-theme="dark"] .zoomable .zone.al-orange path:first-of-type,
html[data-theme="dark"] .zoomable .zone.al-red path:first-of-type { stroke: #d1d5db; stroke-opacity: .38; }

/* ================= tap card on map marks ================= */
.zoomable .tap { cursor: pointer; }
.zoomable .tap:focus { outline: none; }
.map-card { position: absolute; z-index: 5; width: min(300px, calc(100% - 16px)); max-height: 60%; overflow: auto;
  padding: var(--s-3); border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 6px 24px rgb(0 0 0 / .18); font-size: .9rem; }
.map-card.peek { pointer-events: none; animation: peek-in .12s ease-out; }
@keyframes peek-in { from { opacity: 0; } }
.map-card .card-x { position: absolute; top: 4px; right: 6px; width: 32px; height: 32px; border: 0; background: none; font-size: 1.3rem; color: var(--muted); cursor: pointer; }
.map-card .card-title { font-weight: 700; padding-right: 28px; }
.map-card .card-time { color: var(--muted); margin-bottom: 6px; }
.map-card .card-post { display: block; padding: 6px 0; border-top: 1px solid var(--line); text-decoration: none; }
.map-card .card-src { color: var(--muted); font-size: .8rem; }
.map-card .card-text { overflow-wrap: anywhere; }
/* Pull-to-refresh indicator (installed app only) */
.ptr { position: fixed; left: 50%; top: calc(6px + env(safe-area-inset-top)); z-index: 40; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 50%; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-1); color: var(--muted); opacity: 0; transform: translate(-50%, 0); pointer-events: none; }
.ptr.ready { color: var(--accent); }
.ptr.spin .icon { animation: spin 0.8s linear infinite; }
.map-card .card-go { display: inline-flex; margin-top: var(--s-2); padding: 8px 12px; border-radius: var(--r-pill); background: var(--fg); color: var(--bg); text-decoration: none; font-weight: 600; }
.zoomable .zone.sel path:first-of-type { stroke: var(--accent); stroke-width: 2.5; stroke-opacity: 1; }
.map-card .card-alt { font-weight: 600; margin-bottom: 4px; }
.map-card .card-alt.alt-low { color: var(--red); }
.tag.tag-low { background: var(--red-bg); color: var(--red); }
/* Older than LOW_FRESH: outlined, not faded, so the text keeps its contrast. */
.tag.old { background: none; box-shadow: inset 0 0 0 1px currentColor; }
.tag.tag-high { background: var(--surface-2); color: inherit; font-weight: 500; }
.map-card .card-path { font-size: .85rem; margin-bottom: 6px; }
/* Expected, not reported: dashed like the mark on the map. */
.map-card .card-eta { font-weight: 600; margin-bottom: 6px; }
.tag.tag-count { background: var(--surface-2); color: inherit; font-weight: 700; }
.tag.tag-due { background: none; border: 1px dashed currentColor; color: inherit; font-weight: 500; }

/* ================= landscape: phones on their side, desktops ==========   Portrait stays the single column above. In landscape the tab bar becomes a
   left rail, the app bar items and the chips share one row, and pages lay out
   in columns. #status keeps its HTMX swap: its sections are grid items by
   class, and on /map it is display: contents so they join main's grid. */
.sheet { max-height: 85dvh; }
@media (orientation: landscape) and (max-height: 500px), (orientation: landscape) and (min-width: 1024px) {
  :root { --rail-w: 72px; --gut: var(--s-4); }
  body {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-content: start;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) calc(var(--rail-w) + env(safe-area-inset-left));
  }
  .tabbar {
    top: 0; right: auto; width: calc(var(--rail-w) + env(safe-area-inset-left)); flex-direction: column; justify-content: flex-start;
    padding: calc(var(--s-2) + env(safe-area-inset-top)) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
    border-top: 0; border-right: 1px solid var(--line);
  }
  .tabbar a { flex: none; max-width: none; }
  .tabbar::before { content: none; }
  .tabbar a.donate { width: auto; margin: auto 0 var(--s-2); font-size: .65rem; }
  /* App bar: its items and the chips become one row of body's grid. */
  .appbar { display: contents; }
  .area-switch { grid-column: 1; grid-row: 1; padding: calc(var(--s-2) + env(safe-area-inset-top)) var(--s-4) var(--s-2) var(--gut); }
  .chips { grid-column: 2; grid-row: 1; align-self: center; max-width: none; margin: 0; padding: var(--s-2) 0; }
  .appbar-actions { grid-column: 3; grid-row: 1; align-self: center; padding-right: var(--s-2); }
  main { grid-column: 1 / -1; grid-row: 2; max-width: none; margin: 0; padding: 0 var(--gut) var(--gut); }
  .appbar, .chips { view-transition-name: none; }
  .offline-banner { top: var(--s-2); }
  .map, section { scroll-margin-top: var(--s-2); }
  .ptr { left: calc(50% + var(--rail-w) / 2); }
  .sheet { margin: auto; border-radius: var(--r-lg); }

  body > footer { grid-column: 1 / -1; max-width: none; margin: 0; padding: var(--s-2) var(--gut) var(--s-4); }
  /* History: summary and timeline across the page, posts in a side column. */
  body[data-page="history"] .segmented { margin-top: 0; }
  .hist { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); column-gap: var(--s-3); align-items: start; }
  .hist-side { position: sticky; top: var(--s-2); }
  .hist-side .feed { max-height: calc(100dvh - 160px); overflow: auto; }
  .tl-row { --tl-label: 10rem; }
}

/* Phone on its side: 390 px of height, so every pixel of chrome counts. */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --side-w: 220px; --mini-h: calc(100dvh - 124px); --map-h: calc(100dvh - var(--s-4) - env(safe-area-inset-bottom)); --gut: var(--s-3); }
  /* Area: the map on the left, sticky, the list beside it. */
  body[data-page="area"] #status { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: var(--s-3); align-items: start; }
  #status > * { grid-column: 2; }
  #status > .minimap { grid-column: 1; grid-row: 1 / span 40; position: sticky; top: var(--s-2); margin-bottom: 0; }
  .minimap .zmap, .minimap .live-map:empty { height: var(--mini-h); aspect-ratio: auto; }
  .minimap .zoomable { aspect-ratio: auto; height: 100%; }

  /* Map: full height on the left, the rest in a side column. */
  body[data-page="map"] main { display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w); column-gap: var(--s-3); align-items: start; }
  body[data-page="map"] main > *, body[data-page="map"] #status > * { grid-column: 2; }
  body[data-page="map"] #status { display: contents; }
  body[data-page="map"] .map-lead { margin: 0 0 var(--s-2); }
  body[data-page="map"] #status > .map { grid-column: 1; grid-row: 1 / span 20; position: sticky; top: var(--s-2); }
  .map { width: auto; left: auto; transform: none; margin: 0; }
  .map .zmap { height: var(--map-h); }
  .map .zoomable { aspect-ratio: auto; height: 100%; }

  /* The pick page: two columns, the map on the left. */
  body[data-page="index"] main { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); column-gap: var(--s-3); align-items: start; }
  body[data-page="index"] main > * { grid-column: 2; }
  body[data-page="index"] main > .map { grid-column: 1; grid-row: 1 / span 20; }
  body[data-page="index"] main > .map .zmap { height: calc(var(--map-h) - 60px); }
  .tabbar { justify-content: center; }
  .tabbar a { height: 60px; }
  .tabbar::before { content: ""; flex: none; height: 60px; margin-bottom: auto; }
  .area-switch .city { display: none; }
  .area-switch .title { font-size: 1.15rem; }
  .area-switch .title, .area-switch { white-space: nowrap; }
  .icon-btn { width: 40px; height: 40px; }
  .card { padding: var(--s-3); }
  /* The map page has no bar: the rail names it, the map needs the height. */
  body[data-page="map"] .area-switch { display: none; }
  body[data-page="map"] main { padding-top: var(--s-2); }
  body[data-page="map"] .map > .card-head-row .card-head { display: none; }
  .map-card { max-height: calc(100% - 16px); width: min(280px, 45%); }
  .sheet { max-height: calc(100dvh - 16px); }
}

/* Desktop and tablets on their side: one shell for every page. The app bar,
   then main, then the footer, always in view. Pages with a map put it on the
   left at full height and the rest in a side column; only main scrolls, so
   the map stays and the side column moves under it (the scrollbar sits by
   the side column). #status is display: contents so its sections join main's
   grid; it keeps its HTMX swap. */
@media (orientation: landscape) and (min-width: 1024px) {
  :root { --side-w: clamp(340px, 27vw, 400px); --gut: var(--s-6); }
  .tabbar a { height: 68px; }
  body { height: 100dvh; overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto; padding-bottom: 0; }
  main { grid-row: 2; overflow-y: auto; overscroll-behavior: contain; container-type: size; padding: 0 var(--gut) var(--s-4); }
  body > footer { grid-row: 3; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; padding: var(--s-2) var(--gut); border-top: 1px solid var(--line); background: var(--bg); }
  .offline-banner { top: 0; }

  body:is([data-page="area"], [data-page="map"], [data-page="index"]) main {
    display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w); column-gap: var(--s-4); align-items: start; align-content: start;
  }
  #status { display: contents; }
  main > *, #status > * { grid-column: 2; min-width: 0; }
  :is(main, #status) > .map-pane {
    grid-column: 1; grid-row: 1 / span 40; position: sticky; top: 0; height: 100cqh;
    display: flex; flex-direction: column; width: auto; left: auto; transform: none; margin: 0;
  }
  .map-pane > .live-map, .map-pane > .zmap { flex: 1 1 0; min-height: 0; margin: 0; }
  .map-pane .live-map:empty { aspect-ratio: auto; margin: 0; }
  .map-pane .zmap { height: 100%; margin: 0; }
  .map-pane .zoomable { height: 100%; aspect-ratio: auto; }
  .map-pane > .card-head, .map-pane > .card-head-row { flex: none; min-height: 44px; margin: 0 -8px var(--s-2) 0; }
  .map-pane > .card-head-row:not(:has(.icon-btn)) { margin-right: 0; }
  .map-pane > .legend { flex: none; }
  /* The mention count gets its own line in the narrow side column. */
  .status-line .st-mentions { flex-basis: 100%; }
  .status-line .st-mentions::before { content: none !important; }
  /* The side column starts level with the map, below the map's head row. */
  body:is([data-page="area"], [data-page="map"], [data-page="index"]) main::before { content: ""; grid-column: 2; height: calc(44px + var(--s-2)); }
  /* The danger card stays on top of the side column; the rest scrolls under it. */
  #status > .here { position: sticky; top: 0; z-index: 2; }

  /* The map on the right, if chosen in the sheet. */
  .view-set .view-side { display: block; }
  .view-set:has(.view-side) { width: min(310px, calc(100% - 64px)); }
  html[data-map-side="right"] body:is([data-page="area"], [data-page="map"], [data-page="index"]) main { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  html[data-map-side="right"] :is(main, #status) > * { grid-column: 1; }
  html[data-map-side="right"] :is(main, #status) > .map-pane { grid-column: 2; }
  html[data-map-side="right"] body:is([data-page="area"], [data-page="map"], [data-page="index"]) main::before { grid-column: 1; }

  /* Pages without a map: text pages keep a readable width. */
  body:not([data-page="area"], [data-page="map"], [data-page="index"], [data-page="history"]) main > * { max-width: 760px; }
  .hist { grid-template-columns: minmax(0, 1fr) var(--side-w); column-gap: var(--s-4); }
  .hist-side { top: 0; }
  .hist-side .feed { max-height: calc(100cqh - 120px); }
}
/* Narrower desktops: the footer keeps one row, the extras go. */
@media (orientation: landscape) and (min-width: 1024px) and (max-width: 1479px) {
  .foot-extra { display: none; }
}

/* ================= moves ================= */
html[data-theme="dark"] .moves .casing, html[data-theme="dark"] .moves .head { stroke: #0e1014; }
html[data-theme="dark"] .moves .stroke { stroke: #f87171; }
html[data-theme="dark"] .moves .head { fill: #f87171; }

/* ================= locate ================= */
button.row { width: 100%; background: none; border: 0; border-top: 1px solid var(--line); color: inherit; text-align: left; cursor: pointer; }
button.row:disabled { opacity: .6; cursor: progress; }
.locate-btn { display: flex; align-items: center; justify-content: center; gap: var(--s-2); width: 100%; margin-bottom: var(--s-3); }
.locate-msg { margin: var(--s-1) 0 var(--s-2); font-size: .9rem; color: var(--muted); }

/* ================= promo: the author's channel, donations ================= */
.promo { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: var(--s-2); }
.promo p { padding-right: 32px; }
.promo-btn, .donate-btn { display: inline-flex; align-items: center; gap: var(--s-2); padding: 8px 14px; border-radius: var(--r-pill); background: var(--fg); color: var(--bg); text-decoration: none; font-weight: 600; min-height: 40px; }
.promo-btn .icon, .donate-btn .icon { width: 18px; height: 18px; }
.promo-btn.donate, .donate-btn { background: var(--donate); color: #fff; }
.promo .promo-x { position: absolute; top: 4px; right: 4px; width: 36px; height: 36px; border: 0; background: none; font-size: 1.3rem; color: var(--muted); cursor: pointer; }
.donate-btn { justify-content: center; width: 100%; padding: var(--s-3); border-radius: var(--r-md); margin-bottom: var(--s-2); }

.card > .lead:first-child { margin-top: 0; }
.ways-head { font-size: .95rem; font-weight: 600; margin: var(--s-4) 0 var(--s-2); }
.rows-card { padding-top: var(--s-1); padding-bottom: var(--s-1); }
.rows-card > .row:first-child { border-top: 0; }

/* ================= night page: previous and next night ================= */
.night-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin: 0 0 var(--s-3); }
.night-nav h2 { font-size: 1.05rem; text-align: center; }
.night-nav a { display: inline-flex; align-items: center; gap: 2px; min-width: 64px; min-height: 44px; color: var(--muted); text-decoration: none; font-size: .9rem; }
.night-nav a:last-child { justify-content: flex-end; }
.night-nav > span { min-width: 64px; }

/* ================= error pages: 404 and 500 ================= */
.error-card { --tone: var(--accent); position: relative; overflow: hidden; text-align: center; padding: var(--s-6) var(--s-4); margin-top: var(--s-4); }
.error-card.error-server { --tone: var(--orange); }
.error-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--tone); }
.error-badge {
  display: inline-grid; place-items: center; width: 64px; height: 64px; margin: var(--s-2) auto var(--s-3);
  border-radius: var(--r-pill); color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, transparent);
}
.error-badge .icon { width: 30px; height: 30px; }
.error-code {
  font-size: clamp(4rem, 22vw, 6.5rem); font-weight: 800; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  color: color-mix(in srgb, var(--tone) 22%, var(--line)); margin: 0 0 var(--s-2);
}
.error-card h1 { font-size: 1.4rem; }
.error-card .lead { max-width: 30em; margin: var(--s-2) auto var(--s-6); }
.error-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2); }
.error-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); flex: 1 1 160px; max-width: 240px; min-height: 44px;
  padding: var(--s-2) var(--s-4); border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2);
  text-decoration: none; font-weight: 600;
}
.error-btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.error-btn .icon { width: 18px; height: 18px; }
.error-btn:active { transform: scale(.97); }
