/* BubblinCrude — dark scientific energy-data UI */
:root {
  --bg: #07090c;
  --bg-panel: #0e1116;
  --bg-elev: #141820;
  --bg-hover: #1a2030;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8ecf2;
  --text-dim: #9aa3b2;
  --text-mute: #6b7382;
  /* Brand accent = oil amber/gold (replaces former teal). */
  --accent: #e8a838;
  --accent-dim: rgba(232, 168, 56, 0.2);
  --accent-deep: #c98a1e;
  --teal: var(--accent);
  --teal-dim: var(--accent-dim);
  --teal-deep: var(--accent-deep);
  --amber: #e8a838;
  --amber-dim: rgba(232, 168, 56, 0.18);
  --amber-deep: #a56f12;
  --gold: #f0d78c;
  --danger: #e85d5d;
  --sweet: #7bc96f;
  --sweet-dim: rgba(123, 201, 111, 0.18);
  --sour: #ef4444;
  --sour-dim: rgba(239, 68, 68, 0.16);
  --light: #f0d78c;
  --heavy: #c98a1e;
  --medium: #d4a84b;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --topbar-h: 72px;
  --filters-w: 260px;
  --inspector-w: 340px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  /* Hidden sync probe — badge shows only vN; heal script reads this. */
  --bc-css: 230;
  --pwa-fill-h: 100%;
  --pwa-extra-b: 0px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  /* Match chrome — pure #000 gaps on iOS Safari read as “black boxes”. */
  background: var(--bg-panel);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* Stop Safari from briefly inflating long Cuts/About copy on navigate. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Kill double-tap page zoom (viewport meta is ignored on modern iOS). */
  touch-action: manipulation;
}

/*
 * Bug B (iOS-full-bleed.txt / GovDash): PWA layout viewport can stay shorter
 * than screen. Grow html/body IN FLOW to fillH — never position:fixed on them,
 * never max-height:100dvh. .app is the only fixed shell.
 */
html.pwa-standalone,
html.pwa-standalone body {
  position: static;
  height: calc(var(--pwa-fill-h, 100%) + var(--pwa-extra-b, 0px));
  min-height: calc(var(--pwa-fill-h, 100%) + var(--pwa-extra-b, 0px));
  max-height: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  background: var(--teal);
  color: #041016;
  padding: 8px 16px;
  font-weight: 600;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
}

.hidden {
  display: none !important;
}

.app {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  max-width: none;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Edge-to-edge. Safe-area painted INSIDE topbar/tray. */
  padding: 0;
  box-sizing: border-box;
  background: var(--bg-panel);
}

/* PWA only: explicit fillH (Bug B). Safari keeps inset:0 above. */
html.pwa-standalone .app {
  top: 0;
  left: 0;
  right: 0;
  bottom: auto;
  width: 100%;
  height: calc(var(--pwa-fill-h, 100%) + var(--pwa-extra-b, 0px));
  min-height: calc(var(--pwa-fill-h, 100%) + var(--pwa-extra-b, 0px));
  overscroll-behavior: none;
}

/* —— Top bar —— */
.topbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--topbar-h);
  padding: calc(4px + env(safe-area-inset-top, 0px))
    calc(16px + env(safe-area-inset-right, 0px)) 8px
    calc(16px + env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  z-index: 40;
}

.topbar-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
}

.brand-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

/* Integer font metrics: fractional title height made the topbar 111.727px tall,
   which put the map — and every marker — on a subpixel row. */
.brand-title {
  margin: 0;
  font-family: Michroma, "IBM Plex Sans", system-ui, sans-serif;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 28px;
  white-space: nowrap;
  text-transform: none;
}

.brand-sub {
  display: none;
  height: 14px;
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 14px;
  color: var(--text-mute);
  white-space: nowrap;
}

.topbar-chrome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  width: 100%;
  min-width: 0;
}

.topbar-search {
  display: none;
  position: relative;
  flex: 1 0 100%;
  order: 2;
  width: 100%;
  min-width: 0;
  max-width: min(420px, 100%);
  margin: 0 auto;
}
.topbar-tools.is-search-open .topbar-search {
  display: block;
}
html:not(.app-home) #btn-search,
html:not(.app-home) #btn-reset-view,
html:not(.app-home) .topbar-search {
  display: none !important;
}

.topbar-search input {
  width: 100%;
  height: 28px;
  padding: 0 36px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  text-overflow: ellipsis;
}
.topbar-search input::-webkit-search-decoration,
.topbar-search input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}
.topbar-search input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px var(--teal-dim);
}
.search-clear {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  z-index: 2;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.search-clear:hover,
.search-clear:focus-visible {
  color: var(--text);
  background: var(--bg-hover);
  outline: none;
}

/* Lives under the field so phone keyboards don’t hide the only feedback. */
.search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 95;
  max-height: min(42vh, 320px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.search-results.hidden {
  display: none;
}
.search-hit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: 44px;
}
.search-hit:last-child {
  border-bottom: 0;
}
.search-hit:hover,
.search-hit:focus-visible {
  background: var(--bg-hover);
  outline: none;
}
.search-hit-name {
  font-weight: 600;
  font-size: 13px;
}
.search-hit-meta {
  font-size: 11px;
  color: var(--text-mute);
}
.search-results-empty {
  padding: 12px;
  font-size: 12px;
  color: var(--text-mute);
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.nav-link {
  padding: 6px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  text-decoration: none;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.nav-link.is-active,
.nav-link.is-active:hover {
  color: var(--teal);
  background: var(--teal-dim);
}
.nav-link[aria-expanded="true"],
.nav-link[aria-expanded="true"]:hover,
.nav-link[aria-pressed="true"],
.nav-link[aria-pressed="true"]:hover {
  color: var(--teal);
  background: var(--teal-dim);
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-ghost {
  background: transparent;
}
.btn-text {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  min-height: 32px;
  padding: 0 8px;
}
.btn-text:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.seg-btn {
  flex: 1 1 auto;
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.seg-btn[aria-pressed="true"],
.seg-btn[aria-pressed="true"]:hover {
  background: var(--teal-dim);
  border-color: var(--teal);
  color: var(--teal);
}
/* —— Main layout —— */
.main {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1 1 auto;
  min-height: 0;
}

.view-home {
  display: grid;
  grid-template-columns: var(--filters-w) 1fr var(--inspector-w);
  grid-template-rows: 1fr;
  grid-template-areas: "filters map inspector";
  height: 100%;
}

.rail-filters {
  grid-area: filters;
}
.map-pane {
  grid-area: map;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-panel);
}
.map-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
.map {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background: var(--bg-panel);
}
.map-sliders {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 19px;
  align-items: center;
  padding: 4px 14px 5px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  z-index: 4;
}
.map-slider-block {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}
.map-slider-block .filter-label {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.04em;
}
.map-slider-block .range-readout {
  margin: 0;
  font-size: 10px;
  line-height: 1;
  white-space: nowrap;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
}
.map-sliders .dual-range,
.map-sliders .solo-range {
  height: 24px;
  margin: 0;
  position: relative;
  touch-action: none;
}
.map-sliders .dual-range-track,
.map-sliders .solo-range-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  margin-top: -1.5px;
  background: var(--bg-hover);
  border-radius: 2px;
  pointer-events: none;
}
.map-sliders .dual-range-fill,
.map-sliders .solo-range-fill {
  position: absolute;
  top: 0;
  height: 100%;
  left: 0;
  width: 100%;
  background: var(--teal);
  border-radius: 2px;
}
.map-sliders .dual-range input[type="range"],
.map-sliders .solo-range input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 24px;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
}
.map-sliders .dual-range input[type="range"] {
  pointer-events: none;
}
.map-sliders .solo-range input[type="range"] {
  pointer-events: auto;
}
.map-sliders .dual-range input[type="range"]::-webkit-slider-runnable-track,
.map-sliders .solo-range input[type="range"]::-webkit-slider-runnable-track {
  height: 24px;
  background: transparent;
}
.map-sliders .dual-range input[type="range"]::-webkit-slider-thumb,
.map-sliders .solo-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 19px;
  height: 19px;
  margin-top: 2.5px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: grab;
}
.map-sliders .dual-range input[type="range"]::-moz-range-track,
.map-sliders .solo-range input[type="range"]::-moz-range-track {
  height: 3px;
  background: transparent;
  border: none;
}
.map-sliders .dual-range input[type="range"]::-moz-range-thumb,
.map-sliders .solo-range input[type="range"]::-moz-range-thumb {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: grab;
}
/* Hubs and refineries have no gravity/sulfur — keep the row, gray it out. */
.map-sliders.is-inert {
  pointer-events: none;
}
.map-sliders.is-inert .filter-label,
.map-sliders.is-inert .range-readout {
  color: var(--text-mute);
}
.map-sliders.is-inert .dual-range-fill,
.map-sliders.is-inert .solo-range-fill {
  background: #6b7280;
}
.map-sliders.is-inert .dual-range input[type="range"]::-webkit-slider-thumb,
.map-sliders.is-inert .solo-range input[type="range"]::-webkit-slider-thumb,
.map-sliders.is-inert .dual-range input[type="range"]::-moz-range-thumb,
.map-sliders.is-inert .solo-range input[type="range"]::-moz-range-thumb {
  background: #8b929c;
  cursor: default;
  pointer-events: none;
}
.rail-inspector {
  grid-area: inspector;
  border-right: none;
  border-left: 1px solid var(--border);
}

.rail {
  overflow: auto;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 12px;
  -webkit-overflow-scrolling: touch;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.rail-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.filter-block {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.filter-block:last-child {
  border-bottom: none;
}
.filter-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 8px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

/* Dual-handle API band: two native ranges stacked on one track. Thumbs
   take pointer events; the track itself does not, so a tap/drag hits the
   nearest handle instead of whichever input is painted on top. */
.dual-range {
  position: relative;
  height: 28px;
  margin: 2px 0 0;
  touch-action: none;
}
.dual-range-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  margin-top: -2px;
  background: var(--bg-hover);
  border-radius: 2px;
  pointer-events: none;
}
.dual-range-fill {
  position: absolute;
  top: 0;
  height: 100%;
  left: 0;
  right: 0;
  background: var(--teal);
  border-radius: 2px;
}
.dual-range input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 28px;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.dual-range input[type="range"]::-webkit-slider-runnable-track {
  height: 28px;
  background: transparent;
}
.dual-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: grab;
}
.dual-range input[type="range"]::-moz-range-track {
  height: 4px;
  background: transparent;
  border: none;
}
.dual-range input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--teal);
  border: 2px solid var(--bg-panel);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: grab;
}
.dual-range #api-min {
  z-index: 2;
}
.dual-range #api-max {
  z-index: 3;
}

.range-readout {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.check-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  min-height: 28px;
}
.check input {
  accent-color: var(--teal);
}

.active-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  font-size: 11px;
  color: var(--text-dim);
}
.chip button {
  border: none;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}
.chip-dismiss {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-dim);
}

.saved-views {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.saved-btn {
  text-align: left;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.saved-btn:hover {
  border-color: var(--teal);
  color: var(--text);
}

/* —— Map —— */
.leaflet-container {
  background: var(--bg-panel);
  font: inherit;
  /* Keep tile layers from widening the layout viewport on iOS Safari. */
  max-width: 100%;
}
.leaflet-control-zoom a {
  background: var(--bg-panel) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
  width: 32px !important;
  height: 32px !important;
  line-height: 32px !important;
}

.topbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 5px;
  position: relative;
  width: 100%;
}
.layer-toggle,
.color-toggle {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(14, 17, 22, 0.92);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.layer-toggle .color-btn + .color-btn,
.color-btn + .color-btn,
.color-help {
  border-left: 1px solid var(--border);
}
.layer-toggle .color-btn {
  padding: 0 6px;
}
.color-btn,
.color-help,
.map-reset {
  min-height: 24px;
  min-width: 24px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.color-help {
  min-width: 24px;
  padding: 0 7px;
  color: var(--text-mute);
}
.color-btn[aria-pressed="true"],
.color-btn[aria-pressed="true"]:hover,
.color-btn[aria-pressed="true"]:focus {
  background: var(--teal-dim);
  color: var(--teal);
}
.color-help[aria-expanded="true"],
.color-help[aria-expanded="true"]:hover,
.color-help[aria-expanded="true"]:focus {
  color: var(--teal);
}
.map-reset {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(14, 17, 22, 0.92);
  backdrop-filter: blur(8px);
  font-weight: 500;
  font-size: 10px;
  padding: 0 8px;
}
.map-reset[aria-pressed="true"] {
  background: var(--teal-dim);
  color: var(--teal);
  border-color: var(--teal);
}
/* Real pointer only — touch leaves :hover stuck and washed pressed/expanded gold. */
@media (hover: hover) {
  .map-reset:hover:not([aria-pressed="true"]) {
    color: var(--text);
  }
  .color-btn:hover:not([aria-pressed="true"]) {
    color: var(--text);
  }
  .color-help:hover:not([aria-expanded="true"]) {
    color: var(--text);
  }
  .nav-link:hover:not(.is-active):not([aria-expanded="true"]):not([aria-pressed="true"]) {
    color: var(--text);
    background: var(--bg-hover);
  }
}
.legend-scale {
  flex: 1 0 100%;
  order: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 14px;
}
.legend-ramp {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: min(168px, 62vw);
}
.legend-ramp-bar {
  flex: 1 1 auto;
  min-width: 0;
  height: 7px;
  border-radius: 99px;
  border: 1px solid var(--border);
}
.legend-ramp-end {
  flex: 0 0 auto;
  font-size: 10px;
  line-height: 1;
  color: var(--text-mute);
  font-family: var(--mono);
  white-space: nowrap;
}
.legend-ramp-roles {
  width: auto;
  max-width: 100%;
  gap: 10px;
}
.legend-role {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  line-height: 1;
  color: var(--text-mute);
  white-space: nowrap;
}
.legend-role i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55);
}
.legend-help {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  width: min(260px, 92vw);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(14, 17, 22, 0.94);
  backdrop-filter: blur(8px);
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-dim);
  text-align: center;
}
.legend-help.hidden {
  display: none !important;
}

/* Ring is drawn with box-shadow, not border: a border-box border would eat
   into the dot and leave a translucent rim that reads as hollow. */
.stream-marker-hit {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
}
.stream-marker {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  border: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
.stream-marker.is-selected {
  width: 8px;
  height: 8px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.9),
    0 0 0 2px rgba(255, 255, 255, 0.95);
}

.leaflet-tooltip.stream-tip {
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  box-shadow: var(--shadow);
  font-size: 11px;
  max-width: none;
  line-height: 1.25;
  /* Leaflet tooltips are pointer-events:none unless interactive; keep that
     path honest so the Compare button can receive the click. */
  pointer-events: auto;
}
.leaflet-tooltip.stream-tip::before {
  border-top-color: var(--bg-panel);
}
.tip-name {
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 1px;
}
.tip-meta {
  color: var(--text-dim);
  font-size: 10px;
}
.tip-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  margin: 4px 0 0;
  align-items: center;
}
.tip-pills .pill {
  padding: 0 5px;
  font-size: 9px;
}

/* —— Inspector —— */
.inspector {
  height: 100%;
}
.inspector-empty {
  padding: 24px 8px;
  text-align: center;
  color: var(--text-mute);
}
.empty-title {
  font-weight: 600;
  color: var(--text-dim);
  margin: 0 0 6px;
}
.empty-body {
  margin: 0;
  font-size: 13px;
}

.insp-header {
  margin-bottom: 8px;
}
.insp-title-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.insp-title-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 2px;
}
.insp-expand {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin: -4px 0 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}
.insp-expand-icon {
  display: block;
  width: 8px;
  height: 8px;
  margin: 8px auto 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-135deg);
}
.view-home.is-insp-expanded .insp-expand-icon {
  margin-top: 6px;
  transform: rotate(45deg);
}
.insp-expand:hover,
.insp-expand:focus-visible {
  color: var(--text);
  background: var(--bg-hover);
  outline: none;
}
.insp-name {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.insp-clear {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  margin: -4px -4px 0 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.insp-clear:hover,
.insp-clear:focus-visible {
  color: var(--text);
  background: var(--bg-hover);
  outline: none;
}
.insp-aliases {
  margin: 1px 0 0;
  font-size: 11px;
  color: var(--text-mute);
}
.insp-loc {
  margin: 3px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0;
  align-items: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font-family: inherit;
  margin: 0;
  cursor: default;
  white-space: nowrap;
}
button.pill {
  cursor: pointer;
}
.pill-light {
  background: var(--teal-dim);
  color: var(--teal);
  border-color: rgba(46, 196, 182, 0.35);
}
.pill-medium {
  background: rgba(91, 141, 239, 0.18);
  color: var(--medium);
  border-color: rgba(91, 141, 239, 0.35);
}
.pill-heavy,
.pill-extra-heavy {
  background: var(--amber-dim);
  color: var(--amber);
  border-color: rgba(232, 168, 56, 0.35);
}
.pill-sweet {
  background: var(--sweet-dim);
  color: var(--sweet);
  border-color: rgba(34, 197, 94, 0.35);
}
.pill-sour {
  background: var(--sour-dim);
  color: var(--sour);
  border-color: rgba(239, 68, 68, 0.35);
}
.pill-kind {
  background: var(--bg-elev);
  color: var(--text-dim);
  border-color: var(--border);
}
.pill-compare {
  background: var(--teal);
  color: #041016;
  border-color: var(--teal);
}
.pill-compare.is-done {
  background: var(--bg-elev);
  color: var(--text-mute);
  border-color: var(--border);
  opacity: 0.75;
}
.insp-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 8px;
}
.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.flag-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-mute);
  font-size: 10px;
  cursor: help;
  padding: 0;
}
.flag-btn:hover,
.flag-btn:focus-visible {
  border-color: var(--teal);
  color: var(--teal);
}
.flag-btn.is-word {
  width: auto;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 9px;
  letter-spacing: 0.03em;
  text-transform: lowercase;
}
.pill-est {
  color: var(--text-dim);
  border-style: dashed;
}

.quality-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 10px;
}
.metric-tile {
  position: relative;
  padding: 5px 22px 5px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  min-width: 0;
}
.metric-tile > .flag-btn {
  position: absolute;
  top: 4px;
  right: 4px;
}
.metric-tile .k {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-mute);
}
.metric-tile .v {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  margin-top: 1px;
  line-height: 1.1;
}
.metric-tile .u {
  font-size: 9px;
  color: var(--text-mute);
  margin-top: 0;
}
.metric-tile.is-teal .v {
  color: var(--teal);
}
.metric-tile.is-amber .v {
  color: var(--amber);
}
.metric-tile.is-ramp .v {
  color: var(--metric-v);
}
.metric-tile.is-mute .v {
  color: var(--text-mute);
}

.block {
  margin-bottom: 10px;
}
.block-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 5px;
}

.sara-bar {
  display: flex;
  height: 18px;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.sara-seg {
  height: 100%;
  min-width: 0;
}
.sara-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.sara-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 4px;
}

.thermo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.thermo-row {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.thermo-row:hover,
.thermo-row:focus-visible {
  border-color: var(--border);
  background: var(--bg-hover);
}
.thermo-label {
  font-size: 12px;
  color: var(--text-dim);
}
.thermo-track {
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.thermo-fill {
  /* Must be block: width:% is ignored on inline spans, so the bar stayed
     0px wide inside the dark track (numbers only — looked blank/black). */
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ff5a2e, #4a8fd4, #e8f2ff);
}
.thermo-val {
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
  color: var(--text);
}

.note-box {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 12px;
  color: var(--text-dim);
}
.note-box strong {
  color: var(--text);
  font-weight: 600;
}

.related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.related-chip {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(232, 168, 56, 0.5);
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.related-chip::after {
  content: " →";
  color: var(--accent);
  font-weight: 700;
}
@media (hover: hover) {
  .related-chip:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #041016;
  }
  .related-chip:hover::after {
    color: #041016;
  }
}
.related-chip:active {
  background: var(--accent);
  border-color: var(--accent);
  color: #041016;
}
.related-chip:active::after {
  color: #041016;
}

.assay-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.assay-table th,
.assay-table td {
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
}
.assay-table th {
  color: var(--text-mute);
  font-weight: 500;
}
.assay-table td.num {
  font-family: var(--mono);
}

/* —— Compare tray (under map sliders) —— */
.compare-tray {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  min-height: 0;
  overflow: hidden;
  box-sizing: border-box;
  z-index: 4;
}
/* Mac / iPad: match slider row height + buffer under tray so the map
   stage is shorter and the belt fit sits flush (kills the slim top gap). */
@media (min-width: 700px) {
  .insp-expand {
    display: none !important;
  }
  .compare-tray {
    height: 34px;
    min-height: 34px;
    padding-top: 0;
    padding-bottom: 0;
  }
  .map-pane {
    padding-bottom: 17px;
  }
}
.compare-tray[hidden] {
  display: none !important;
}
.insp-blurb {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dim);
}
.insp-block {
  margin-top: 12px;
}
.insp-block h3 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
  font-weight: 600;
}

.tray-chips {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}
.tray-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  margin-left: auto;
}
.btn-tray {
  min-height: 22px;
  height: 22px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.btn-tray-go {
  background: var(--teal);
  border-color: var(--teal);
  color: #041016;
}
.btn-tray-go:hover:not(:disabled) {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
  color: #041016;
}
.tray-chip {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 1px 1px 1px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  flex: 0 1 auto;
  min-width: 0;
}
.tray-chip .name {
  font-weight: 600;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.tray-chip .meta {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-mute);
}
.tray-chip .rm {
  border: none;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  min-width: 16px;
  min-height: 18px;
  padding: 0;
  flex-shrink: 0;
}

/* —— Compare board —— */
.view-compare,
.view-stream,
.view-page {
  overflow: auto;
  padding: 20px calc(24px + env(safe-area-inset-right, 0px)) 40px
    calc(24px + env(safe-area-inset-left, 0px));
  -webkit-overflow-scrolling: touch;
}

.compare-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.compare-head h2 {
  margin: 0;
  font-size: 22px;
}
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}
.compare-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
}
.compare-card h3 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.origin-map {
  height: 180px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.metric-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.mb-group .mb-label {
  font-size: 11px;
  color: var(--text-mute);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mb-row {
  display: grid;
  grid-template-columns: 90px 1fr 56px;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}
.mb-name {
  font-size: 12px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mb-track {
  height: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.mb-fill {
  height: 100%;
}
.mb-val {
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
}

.tbp-chart {
  width: 100%;
  height: 240px;
}
.tbp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}
.tbp-swatch {
  display: inline-block;
  width: 14px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

.contrast-sentence {
  margin-top: 20px;
  padding: 14px 16px;
  border-left: 3px solid var(--amber);
  background: var(--bg-panel);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

.stream-cards-swipe {
  display: none;
}

/* —— Page views —— */
.page-title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
}
.page-lead {
  margin: 0 0 24px;
  color: var(--text-dim);
  max-width: 62ch;
  font-size: 14px;
  line-height: 1.45;
}
.cut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.cut-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.cut-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin: 0 0 4px;
}
.cut-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  line-height: 1.25;
}
.cut-meta {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--teal);
  margin-bottom: 10px;
}
.cut-blurb {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
}
.cut-section {
  margin: 0 0 12px;
}
.cut-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 5px;
}
.cut-list {
  margin: 0;
  padding-left: 1.1em;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}
.cut-list li + li {
  margin-top: 2px;
}
.cut-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cut-hhv-note {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}
.cut-hhv-val {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}
.cut-rich {
  margin: 0;
  font-size: 12px;
  color: var(--teal);
  line-height: 1.4;
}
.cut-poor {
  margin: 0;
  font-size: 12px;
  color: var(--amber);
  line-height: 1.4;
}
.cut-card.is-target {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.mol-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
}
.mol-filter {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text-dim);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.mol-filter.is-active {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-dim);
}
.mol-section {
  margin: 0 0 22px;
}
.mol-section-title {
  margin: 0 0 4px;
  font-size: 15px;
}
.mol-section-lead {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}
.mol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.mol-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  min-width: 0;
}
.mol-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.mol-card h4 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  min-width: 0;
}
.mol-formula {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--teal);
  white-space: nowrap;
  flex: 0 0 auto;
}
.mol-blurb {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}
.mol-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
}
.found-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--teal-dim);
  color: var(--teal);
  font-size: 11px;
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.about-block {
  max-width: 68ch;
  margin-bottom: 24px;
}
.about-block h3 {
  margin: 0 0 8px;
  font-size: 15px;
}
.about-block p,
.about-block li {
  color: var(--text-dim);
  font-size: 14px;
}
.glossary {
  margin: 0;
  display: grid;
  gap: 10px 0;
}
.glossary dt {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.glossary dd {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dim);
}
.glossary dt.is-target,
#g-quality-flags.is-target h3 {
  color: var(--teal);
  outline: 1px solid var(--teal);
  outline-offset: 4px;
  border-radius: 4px;
}
.flag-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.flag-list li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
}
.flag-list strong {
  color: var(--teal);
  font-family: var(--mono);
  font-size: 12px;
}

html.pwa-standalone:not(.app-home) .view-compare,
html.pwa-standalone:not(.app-home) .view-stream,
html.pwa-standalone:not(.app-home) .view-page {
  padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
}

/* —— Popover / modal / sheet / drawer —— */
.popover {
  position: absolute;
  top: calc(var(--topbar-h) + var(--safe-t));
  right: 16px;
  z-index: 80;
  width: 260px;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}
.popover fieldset {
  border: none;
  margin: 0 0 12px;
  padding: 0;
}
.popover legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-mute);
  margin-bottom: 6px;
}
.popover label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.modal-head h2 {
  margin: 0;
  font-size: 16px;
}
#picker-search {
  width: 100%;
  height: 40px;
  margin-bottom: 10px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.picker-list {
  overflow: auto;
  flex: 1;
  min-height: 0;
}
.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.picker-item:hover {
  background: var(--bg-hover);
}
.picker-item .sub {
  font-size: 11px;
  color: var(--text-mute);
}


.compare-stream-swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.swatch-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.swatch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* —— Responsive: tablet —— */
@media (max-width: 1099px) {
  .view-home {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    grid-template-areas: "map";
  }
  .rail-filters {
    display: none;
  }
  .rail-inspector {
    display: none;
  }
  .brand-sub-text {
    display: none;
  }
  .compare-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Responsive: phone —— */
@media (max-width: 699px) {
  .topbar {
    gap: 6px 8px;
    padding: calc(2px + env(safe-area-inset-top, 0px))
      calc(10px + env(safe-area-inset-right, 0px)) 6px
      calc(10px + env(safe-area-inset-left, 0px));
  }
  .brand-title {
    font-size: 22px;
    line-height: 24px;
  }
  .topbar-nav {
    gap: 2px;
  }
  .nav-link {
    padding: 6px 8px;
    font-size: 12px;
  }
  /* The belt is roughly 2:1, so a full-width world map cannot also be tall.
     The map element is sized to the belt in JS; the inspector takes the rest
     rather than leaving a dead slab where the poles used to be. */
  .view-home {
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "map"
      "inspector";
  }
  .map-pane.is-belt-cut {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .is-belt-cut .map-stage {
    flex: 0 0 auto;
  }
  .is-belt-cut .map {
    position: relative;
    inset: auto;
    width: 100%;
    flex: 0 0 auto;
  }
  .map-sliders {
    grid-template-columns: 1fr;
    gap: 2px 0;
    padding: 4px 14px 5px;
  }
  .rail-inspector {
    display: block;
    border-left: none;
    border-top: 1px solid var(--border);
    min-height: 0;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 0px));
  }
  .view-home.is-insp-expanded .map-stage,
  .view-home.is-insp-expanded .map-sliders {
    display: none !important;
  }
  .leaflet-control-zoom {
    display: none !important;
  }
  .legend-ramp-roles {
    gap: 8px;
  }
  .view-compare,
  .view-stream,
  .view-page {
    padding: 14px calc(12px + env(safe-area-inset-right, 0px)) 32px
      calc(12px + env(safe-area-inset-left, 0px));
  }
  .stream-cards-swipe {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin-bottom: 16px;
    padding-bottom: 4px;
  }
  .swipe-card {
    flex: 0 0 78%;
    scroll-snap-align: start;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-panel);
  }
  .mb-row {
    grid-template-columns: 72px 1fr 48px;
  }
}

@media (max-width: 1099px) and (min-width: 700px) {
  /* tablet: inspector as right drawer when open */
  .rail-inspector.is-drawer-open {
    display: block;
    position: fixed;
    top: calc(var(--topbar-h) + var(--safe-t));
    right: 0;
    bottom: 0;
    width: min(360px, 90vw);
    z-index: 50;
    box-shadow: var(--shadow);
  }
  .compare-tray {
    /* Height/buffer set in the ≥700px rule; keep safe-area in the pane pad. */
    padding-bottom: 0;
  }
}
@media (min-width: 700px) and (max-width: 1099px) {
  .map-pane {
    padding-bottom: max(17px, env(safe-area-inset-bottom, 0px));
  }
}

/* Landscape phone: keep map usable */
@media (max-height: 500px) and (orientation: landscape) {
  .brand-sub-text {
    display: none;
  }
  .topbar {
    min-height: 48px;
  }
}
