/* ==========================================================================
   Africa Disaster Early-Warning Map
   Layout: fixed topbar + sidebar/map split on desktop, sidebar becomes a
   slide-over sheet below 900px.
   ========================================================================== */

:root {
  --bg:            #f4f6f9;
  --surface:       #ffffff;
  --surface-2:     #eef1f6;
  --surface-3:     #e3e8f0;
  --ink:           #14202e;
  --ink-2:         #4a5b70;
  --ink-3:         #7c8ba0;
  --line:          #d8e0ea;
  --line-strong:   #c2cddc;
  --accent:        #0b5cad;
  --accent-ink:    #ffffff;
  --accent-soft:   #e3eefb;
  --danger:        #c0304a;
  --danger-soft:   #fdeaee;
  --warn:          #9a6207;
  --warn-soft:     #fdf3e0;
  --ok:            #16794f;
  --ok-soft:       #e4f5ed;
  --facility:      #0f9d6b;

  --radius:   10px;
  --radius-s: 7px;
  --shadow:   0 1px 2px rgba(16, 32, 52, .07), 0 6px 20px rgba(16, 32, 52, .08);
  --shadow-s: 0 1px 2px rgba(16, 32, 52, .08);
  --topbar-h: 62px;
  --sidebar-w: 380px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0e141c;
    --surface:     #161e29;
    --surface-2:   #1d2735;
    --surface-3:   #263243;
    --ink:         #e8eef6;
    --ink-2:       #a8b7c9;
    --ink-3:       #75869b;
    --line:        #2a3646;
    --line-strong: #3a4859;
    --accent:      #4e9bea;
    --accent-ink:  #05121f;
    --accent-soft: #16293f;
    --danger:      #ff8098;
    --danger-soft: #331721;
    --warn:        #e3b062;
    --warn-soft:   #2f2617;
    --ok:          #58d3a0;
    --ok-soft:     #12291f;
    --facility:    #3ddb9e;
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-s:    0 1px 2px rgba(0,0,0,.4);
  }
}

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

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, p, ul, figure { margin: 0; }
ul { list-style: none; padding: 0; }
a { color: var(--accent); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 2000;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 0 0 var(--radius-s) 0;
}
.skip-link:focus { left: 0; }

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

/* ------------------------------- topbar --------------------------------- */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 900;
}

.topbar__brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

/* Line icons: block-level, never shrink inside flex rows, crisp at small sizes. */
.icon { display: block; flex: none; }

.topbar__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.topbar__mark svg { width: 20px; height: 20px; }

.topbar__title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.topbar__subtitle {
  font-size: 11.5px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Mobile-only. Specificity must beat `.btn { display: inline-flex }`, which is
   defined later in this file — equal specificity would let .btn win. */
.topbar .topbar__toggle { display: none; }

/* freshness pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ink-3);
  flex: none;
}
.pill--live  { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.pill--live .pill__dot { background: var(--ok); }
.pill--cached{ background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.pill--cached .pill__dot { background: var(--warn); }
.pill--error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill--error .pill__dot { background: var(--danger); }
.pill--loading .pill__dot { animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

/* ------------------------------- layout --------------------------------- */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}

.mapwrap { position: relative; min-width: 0; }

.map {
  position: absolute;
  inset: 0;
  background: var(--surface-2);
}

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

.pane { display: flex; flex-direction: column; }
.pane[hidden] { display: none; }

.controls {
  padding: 14px 16px 4px;
  display: grid;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.field { display: grid; gap: 6px; }

.field__label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}

.field__labelrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field__labelactions { display: flex; gap: 10px; }
.field__row { display: flex; gap: 8px; }
.field__row > .input { flex: 1; min-width: 0; }

.field__hint {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.4;
}

.field__searchwrap { position: relative; display: flex; }

.field__clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  border: 0; background: transparent;
  color: var(--ink-3);
  font-size: 18px; line-height: 1;
  width: 24px; height: 24px;
  cursor: pointer;
  border-radius: 50%;
}
.field__clear:hover { background: var(--surface-3); color: var(--ink); }

.input {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 8px 10px;
  min-height: 36px;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { border-color: var(--accent); background: var(--surface); }

.select { appearance: none; padding-right: 28px; cursor: pointer; }

.range {
  width: 100%;
  accent-color: var(--accent);
  height: 22px;
  cursor: pointer;
}

/* segmented control */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
}

.segmented__btn {
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 4px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.segmented__btn:hover { background: var(--surface-3); }
.segmented__btn.is-active {
  background: var(--accent);
  color: var(--accent-ink);
}

/* buttons */
.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  min-height: 36px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; filter: none; }

.btn--secondary {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn--ghost {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line-strong);
}
.btn--danger { background: var(--danger); color: #fff; }
.btn--block { width: 100%; }
.btn--sm { font-size: 12px; padding: 5px 10px; min-height: 30px; }

.linkbtn {
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linkbtn:hover { filter: brightness(1.15); }

/* categories */
.categories { display: grid; gap: 2px; }

.cat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border-radius: var(--radius-s);
  cursor: pointer;
  user-select: none;
}
.cat:hover { background: var(--surface-2); }
.cat input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; flex: none; margin: 0; }

.cat__icon { display: grid; place-items: center; width: 18px; height: 18px; flex: none; }
.cat__name { flex: 1; font-size: 13px; }
.cat__count {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: 999px;
}

/* chart */
.disclosure__summary {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
  cursor: pointer;
  list-style: none;
  padding: 2px 0;
}
.disclosure__summary::-webkit-details-marker { display: none; }
.disclosure__summary::before { content: "▸ "; }
.disclosure[open] .disclosure__summary::before { content: "▾ "; }

.chart { display: grid; gap: 5px; padding-top: 8px; }

.chart__row {
  display: grid;
  grid-template-columns: 82px 1fr 34px;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}
.chart__label { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart__track { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.chart__bar { height: 100%; border-radius: 999px; min-width: 2px; transition: width .25s ease; }
.chart__value { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-3); }

/* list header */
.listheader {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 16px 7px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 5;
  border-bottom: 1px solid var(--line);
}

.listheader__count {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}

/* --------------------------- hazard list -------------------------------- */

.hazards { padding: 6px 10px 14px; display: grid; gap: 4px; }

.hazard {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-s);
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
  align-items: start;
}
.hazard:hover { background: var(--surface-2); }
.hazard.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* Category identity as a tinted icon badge (bg + icon colour set inline). */
.catbadge {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
}

.hazard__body { min-width: 0; display: grid; gap: 3px; padding-top: 1px; }

.hazard__title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hazard__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-3);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag--active { background: var(--danger-soft); color: var(--danger); }
.tag--closed { background: var(--surface-3); color: var(--ink-3); }
.tag--source { font-family: var(--mono); font-size: 9.5px; letter-spacing: .04em; }
.tag--dist   { background: var(--accent-soft); color: var(--accent); }

/* states */
.state {
  padding: 34px 22px;
  text-align: center;
  display: grid;
  gap: 10px;
  justify-items: center;
}
.state__icon { color: var(--ink-3); opacity: .85; line-height: 0; }
.state__icon svg { width: 30px; height: 30px; }
.state__title { font-size: 14px; font-weight: 650; }
.state__text { font-size: 12.5px; color: var(--ink-3); max-width: 34ch; line-height: 1.5; }

.skeleton {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 11px;
  padding: 9px 10px;
}
.skeleton__stripe, .skeleton__line {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 240% 100%;
  animation: shimmer 1.3s linear infinite;
}
.skeleton__stripe { width: 30px; height: 30px; border-radius: 8px; }
.skeleton__lines { display: grid; gap: 6px; padding-top: 3px; }
.skeleton__line { height: 10px; }
.skeleton__line--short { width: 45%; height: 8px; }

@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -140% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* --------------------------- detail pane -------------------------------- */

.pane--detail { padding: 12px 16px 18px; gap: 14px; }

.backlink {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 4px 0;
  cursor: pointer;
  text-align: left;
  justify-self: start;
}

.detail { display: grid; gap: 12px; }

.detail__title {
  display: flex;
  align-items: start;
  gap: 10px;
  font-size: 16px;
  font-weight: 680;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.detail__title .catbadge { margin-top: 1px; }

.detail__meta { display: flex; flex-wrap: wrap; gap: 6px; }

.detail__grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  font-size: 12.5px;
  padding: 11px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-s);
}
.detail__key { color: var(--ink-3); font-weight: 600; }
.detail__val { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }

.detail__section { display: grid; gap: 8px; }

.sectionhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.sectionhead__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}

/* facilities */
.facilities { display: grid; gap: 4px; }

.facility {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: start;
  padding: 9px 10px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
}
.facility:hover { border-color: var(--facility); background: var(--surface-2); }

.facility__icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  color: var(--facility);
  background: color-mix(in srgb, var(--facility) 14%, transparent);
}
.facility__body { min-width: 0; display: grid; gap: 3px; }
.facility__top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.facility__name { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.facility__dist {
  font-size: 11px;
  font-weight: 700;
  color: var(--facility);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.facility__meta { font-size: 11.5px; color: var(--ink-3); overflow-wrap: anywhere; }

/* mirror provenance */
.mirrornote {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  padding: 6px 9px;
  border-radius: var(--radius-s);
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.mirrornote code { font-family: var(--mono); font-size: 10.5px; }
.mirrornote--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.mirrornote--ok   { background: var(--ok-soft);   color: var(--ok);   border-color: transparent; }

/* ---------------------------- banners ----------------------------------- */

.banners {
  position: absolute;
  /* Clear Leaflet's zoom control, which sits at left:10px and is ~34px wide. */
  top: 10px; left: 54px; right: 10px;
  z-index: 800;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.banner {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--ink-3);
  box-shadow: var(--shadow);
  animation: slidein .22s ease;
}
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.banner--error { border-left-color: var(--danger); }
.banner--warn  { border-left-color: var(--warn); }
.banner--info  { border-left-color: var(--accent); }
.banner--ok    { border-left-color: var(--ok); }

.banner__body { flex: 1; min-width: 0; display: grid; gap: 2px; }
.banner__title { font-size: 13px; font-weight: 650; }
.banner__text { font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; line-height: 1.45; }
.banner__actions { display: flex; gap: 6px; align-items: center; flex: none; }

.banner__close {
  font: inherit;
  font-size: 17px;
  line-height: 1;
  background: none;
  border: 0;
  color: var(--ink-3);
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  flex: none;
}
.banner__close:hover { background: var(--surface-2); color: var(--ink); }

/* map overlay (hard failure state — never a blank map) */
.mapoverlay {
  position: absolute;
  inset: 0;
  z-index: 700;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(2px);
  padding: 20px;
}
.mapoverlay[hidden] { display: none; }

.mapoverlay__card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
  max-width: 400px;
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
}

/* legend */
.legend {
  position: absolute;
  left: 10px;
  bottom: 22px;
  z-index: 600;
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-s);
  padding: 9px 11px;
  display: grid;
  gap: 4px;
  max-width: 190px;
  backdrop-filter: blur(6px);
}
.legend[hidden] { display: none; }
.legend__title {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-3);
  margin-bottom: 2px;
}
.legend__row { display: flex; align-items: center; gap: 7px; font-size: 11px; color: var(--ink-2); }
.legend__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.legend__dot--hollow { background: transparent !important; border: 2px dashed var(--ink-3); }

/* ---------------------------- account ----------------------------------- */

.account {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: grid;
  gap: 9px;
}
.account[hidden] { display: none; }

.account__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.account__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
}
.account__user { font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.account__form { display: grid; gap: 7px; }
.account__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.account__msg { font-size: 11.5px; line-height: 1.4; }
.account__msg--error { color: var(--danger); }
.account__msg--ok { color: var(--ok); }

.prefs { display: grid; gap: 7px; font-size: 12px; }
.prefs__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.prefs__val { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* -------------------------- attribution --------------------------------- */

.attribution {
  padding: 12px 16px 18px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--ink-3);
  display: grid;
  gap: 3px;
}
.attribution a { color: var(--ink-2); }

/* --------------------------- leaflet bits ------------------------------- */

.leaflet-container {
  font: inherit;
  background: var(--surface-2);
}

.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--surface);
  color: var(--ink);
}
.leaflet-popup-tip { background: var(--surface); }
.leaflet-popup-content { margin: 12px 14px; min-width: 200px; }

.popup { display: grid; gap: 8px; }
.popup__title { display: flex; align-items: start; gap: 7px; font-size: 13px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.popup__titleicon { flex: none; margin-top: 1px; }
.popup__meta { display: flex; flex-wrap: wrap; gap: 5px; }
.popup__row { font-size: 11.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.popup__actions { display: grid; gap: 5px; }

.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--surface);
  color: var(--ink);
  border-bottom-color: var(--line);
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 85%, transparent) !important;
  color: var(--ink-3) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--ink-2) !important; }

@media (prefers-color-scheme: dark) {
  /* Tone the raster basemap down so markers stay legible in dark mode. */
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.7); }
}

.hazard-marker--selected { filter: drop-shadow(0 0 6px var(--accent)); }

/* --------------------------- responsive --------------------------------- */

@media (max-width: 900px) {
  /* Two rows: brand + toggle on top, freshness pills beneath. The height is
     fixed because .sidebar is positioned against it. */
  :root { --topbar-h: 84px; }

  .topbar {
    flex-wrap: wrap;
    align-content: center;
    gap: 4px 10px;
    padding: 6px 12px;
  }
  .topbar__subtitle { display: none; }
  .topbar__brand { flex: 1 1 auto; min-width: 0; gap: 8px; }
  /* min-width:0 on the flex child is what actually lets the title ellipsise. */
  .topbar__brand > div { min-width: 0; }
  .topbar__title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar .topbar__toggle { display: inline-flex; flex: none; }
  .topbar__status {
    order: 5;
    flex: 1 0 100%;
    margin-left: 0;
    justify-content: flex-start;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .topbar__status::-webkit-scrollbar { display: none; }
  .pill { font-size: 10px; padding: 2px 7px; }

  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: absolute;
    /* Must beat Leaflet's controls (z-index 1000), or the zoom buttons show
       through the sheet. */
    z-index: 1200;
    inset: var(--topbar-h) 0 0 0;
    border-right: 0;
    transform: translateY(100%);
    transition: transform .24s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: none; }

  .mapwrap { position: relative; height: calc(100dvh - var(--topbar-h)); }
  .banners { top: 8px; left: 50px; right: 8px; }
  .legend { bottom: 26px; left: 8px; max-width: 150px; }
}

@media (max-width: 400px) {
  .account__actions { grid-template-columns: 1fr; }
  .chart__row { grid-template-columns: 66px 1fr 28px; }
}
