/* The viewer is hosted inside the Ag-Wx page chrome (styles_v3.css
   handles body / html resets and the .site-header). We only need our
   own box-sizing default and the page-wrapper that centers the card. */
.viewer-card, .viewer-card * { box-sizing: border-box; }

/* ============================================================
   Page wrapper — matches the .site-header / .wrap width (1400px)
   so the viewer card aligns with the top nav edges.
   ============================================================ */
.viewer-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 0 32px;
}

/* ============================================================
   Viewer card — gdd_pro-style white surface holding everything.
   ============================================================ */
.viewer-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 28px rgba(15, 23, 42, .06);
  padding: 16px 18px 18px;
}

/* ── Header row: title + forecast bar + logo ── */
.viewer-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}
.viewer-titleblock {
  /* Pinned to 38% so the slider's left edge never moves when the VALID
     line text width changes (12PM → 6PM, 7-char vs 5-char timezones, etc).
     Without the fix the bar visibly jittered each forecast hour. */
  flex: 0 0 38%;
  min-width: 0;
}
.vt-line {
  line-height: 1.35;
  /* Keep each line single-row so the titleblock height is also fixed. */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vt-title {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -.005em;
  margin-bottom: 2px;
}
.vt-run {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.vt-valid {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.viewer-logo {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.viewer-logo:empty { display: none; }

/* ── Pill row ── */
.viewer-pillbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}
.pill:hover { background: #f8fafc; border-color: #cbd5e1; }
.pill:active { transform: translateY(0.5px); }
/* "Pro" badge inside the Compare pill — Compare is a pro-only tool. */
.pill-pro {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: #fff;
  background: #0f766e;
  padding: 2px 5px;
  border-radius: 5px;
  line-height: 1;
}
.pill-select { padding: 0 6px 0 12px; position: relative; }
.pill-select select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  letter-spacing: .15px;
  padding: 0 22px 0 0;
  height: 100%;
  cursor: pointer;
  outline: none;
  /* keep the chosen value visible — was invisible before */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%2364748b' d='M2 4l4 4 4-4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 4px center;
  background-size: 10px;
}
.pill-select select option { background: #ffffff; color: #0f172a; }
.pill-var { max-width: 320px; }
.pill-var select { max-width: 280px; text-overflow: ellipsis; }

.pill-spacer { flex: 1; }

.pill-icon {
  width: 32px; padding: 0;
  justify-content: center;
  font-size: 14px;
  color: #475569;
}
.pill-icon:hover { color: #0f172a; }

/* ============================================================
   Map pane — the map fills it; overlays are absolutely positioned.
   ============================================================ */
.map-pane {
  position: relative;
  width: 100%;
  /* Sized so the whole viewer card fits in a typical viewport without
     vertical scroll. ~310px of chrome above and below the map (site
     header + card padding + title-row + pillbar + legend). */
  height: clamp(400px, calc(100vh - 310px), 800px);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}
#map {
  position: absolute;
  inset: 0;
}

/* --- first-paint splash (scoped to map pane) --- */
#splash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 100% at 50% 0%, #1a2a4a 0%, #0b1220 65%);
  z-index: 20;
  transition: opacity 0.55s ease;
}
#splash.hidden {
  opacity: 0;
  pointer-events: none;
}
.splash-card { text-align: center; color: #e6edf6; }
.splash-logo {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 2px solid rgba(105, 200, 255, .3);
  border-top-color: #69c8ff;
  animation: splash-spin 0.9s linear infinite;
}
@keyframes splash-spin { to { transform: rotate(360deg); } }
.splash-title {
  font-size: 18px;
  font-weight: 600;
  color: #e6edf6;
}
.splash-sub {
  margin-top: 4px;
  color: #9bb1cb;
  font-size: 12px;
}

/* ============================================================
   Forecast bar — lives in the viewer-header row next to the title.
   Compact so the map gets the bulk of the card height.
   ============================================================ */
/* Both .forecast-bar and .frame-viewer-controls set display:flex, which
   overrides the browser's default [hidden] { display: none }. Restore
   it so JS toggling `.hidden = true` in overlay mode actually hides
   the playback row. */
.forecast-bar[hidden] { display: none; }
.forecast-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  color: #0f172a;
}
.tb-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #0f172a;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.tb-btn:hover { background: #f1f5f9; }
.tb-btn:active { transform: scale(.96); }
.tb-speed {
  height: 24px;
  width: 30px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.tb-speed:hover { background: #f1f5f9; }
.tb-speed:active { transform: scale(.95); }
.fw-meta {
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  min-width: 78px;
  text-align: left;
  padding-right: 6px;
  border-right: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.tb-fh   { font-weight: 700; font-size: 12px; color: #0f172a; }
.tb-time { color: #64748b; font-size: 10px; }

.fw-track {
  position: relative;
  flex: 1;
  min-width: 0;
  padding-top: 14px;
}
.tb-now {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, #047857 30%, #047857 70%, transparent);
  opacity: .85;
  transform: translateX(-1px);
  pointer-events: none;
}

#time-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 24px;
  background: transparent;
}
#time-slider::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: #e2e8f0;
}
#time-slider::-moz-range-track {
  height: 6px; border-radius: 3px;
  background: #e2e8f0;
}
#time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #047857;
  border: 3px solid #ffffff;
  margin-top: -6px;
  cursor: grab;
  box-shadow: 0 1px 4px rgba(4, 120, 87, .35);
}
#time-slider::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #047857;
  border: 3px solid #ffffff;
  cursor: grab;
}

/* ============================================================
   Horizontal legend — full-width strip below the map pane.
   ============================================================ */
.legend-horizontal {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 14px;
  row-gap: 4px;
  align-items: center;
  margin-top: 10px;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: #0f172a;
}
.legend-horizontal .legend-label {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
  color: #0f172a;
  max-width: 220px;
  line-height: 1.25;
}
.legend-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
#legend-canvas {
  display: block;
  width: 100%;
  height: 22px;
  border-radius: 3px;
  border: 1px solid #e2e8f0;
}
.legend-horizontal .legend-ticks {
  position: relative;
  height: 14px;
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
}
.legend-horizontal .legend-ticks span {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
}
.legend-desc {
  grid-column: 1 / span 2;
  padding-top: 6px;
  border-top: 1px solid #e2e8f0;
  font-size: 11px;
  color: #64748b;
  line-height: 1.3;
}
.legend-desc[hidden] { display: none; }

/* ============================================================
   Overlay-mode legend (SPC outlooks / NWS hazards). Pinned to the
   bottom-left of the map pane (absolute-positioned inside it) so
   it's always visible without scrolling, regardless of viewport
   height. Semi-opaque white card so it reads cleanly over any
   basemap. Wraps to multiple rows when the hazard list is long.
   ============================================================ */
.overlay-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  /* Sized to content rather than stretched across the map — the long
     NWS hazard list wraps vertically into a tidy lower-left card. Cap
     the width so it never crowds the map on narrow viewports. */
  max-width: min(340px, calc(100% - 24px));
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  color: #0f172a;
}
.overlay-legend[hidden] { display: none; }
.overlay-legend-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.overlay-legend-rows {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
}
.overlay-legend-row {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #1e293b;
  white-space: nowrap;
}
.overlay-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(15, 23, 42, 0.25);
  flex-shrink: 0;
}

/* ============================================================
   Settings popover (anchored top-right, just below the pillbar)
   ============================================================ */
.ctl-popover {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  width: 260px;
  z-index: 7;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .18);
  padding: 10px 12px;
  font-size: 12px;
  color: #0f172a;
}
.ctl-popover.open { display: block; }
.ctl-popover .ctl-body { display: block; }
.ctl-row {
  display: grid;
  grid-template-columns: 72px 1fr 42px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.ctl-row > span:first-child { color: #64748b; font-weight: 600; }
.ctl-row .ctl-val {
  text-align: right; font-variant-numeric: tabular-nums; color: #0f172a;
}
.ctl-row input[type="range"] { width: 100%; accent-color: #047857; }
.ctl-row input[type="checkbox"] {
  justify-self: start; width: 18px; height: 18px;
  accent-color: #047857;
}
.ctl-row[hidden] { display: none; }
.ctl-section-label {
  margin: 10px 0 2px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #94a3b8;
}
.ctl-row-checkbox {
  grid-template-columns: 1fr auto;
  padding: 4px 0;
}
.ctl-row-checkbox input[type="checkbox"] { justify-self: end; }
.ctl-row-actions {
  grid-template-columns: 1fr;
  margin-top: 4px;
}
.ctl-row-actions button {
  width: 100%;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.ctl-row-actions button:hover { background: #f1f5f9; border-color: #cbd5e1; }
.ctl-row select {
  grid-column: 2 / span 2;
  appearance: none;
  -webkit-appearance: none;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  border-radius: 8px;
  padding: 5px 22px 5px 8px;
  font: inherit;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path fill='%2364748b' d='M2 4l4 4 4-4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 10px;
}

/* MapLibre attribution placement inside the map pane */
.maplibregl-ctrl-bottom-right { z-index: 2; }
.maplibregl-ctrl-attrib.maplibregl-compact { font-size: 10px; }

/* --- value readout (hover/touch) — follows the cursor inside map-pane --- */
.readout {
  position: absolute;
  left: 0; top: 0;
  background: rgba(15, 22, 38, .92);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 8px;
  padding: 5px 9px;
  backdrop-filter: blur(8px);
  font-size: 12px;
  line-height: 1.25;
  z-index: 6;
  pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  white-space: nowrap;
  color: #e6edf6;
  transform: translate(14px, 14px);
}
.r-loc { color: #9bb1cb; font-variant-numeric: tabular-nums; }
.r-val { color: #e6edf6; font-weight: 600; font-size: 16px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.r-val .r-alt {
  color: #9bb1cb;
  font-weight: 500;
  font-size: 12px;
  margin-left: 4px;
}

/* --- help overlay (full-page) --- */
.help[hidden] { display: none; }
.help {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 26, .78);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px 24px;
  font-size: 13px;
  max-width: 400px;
  color: #0f172a;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.help-title {
  font-size: 14px;
  font-weight: 700;
  color: #047857;
  margin-bottom: 12px;
}
.help table { border-collapse: collapse; width: 100%; }
.help td {
  padding: 6px 8px;
  vertical-align: middle;
}
.help td:first-child {
  white-space: nowrap;
  color: #64748b;
}
.help kbd {
  display: inline-block;
  padding: 1px 6px;
  margin: 0 1px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-bottom-width: 2px;
  border-radius: 4px;
  font: inherit;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.help-hint {
  margin-top: 14px;
  text-align: center;
  color: #94a3b8;
  font-size: 11px;
}

/* --- thin top loader inside map pane --- */
.loader {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 2px;
  z-index: 9;
  pointer-events: none;
}
.loader .bar {
  height: 100%;
  width: 30%;
  background: #047857;
  animation: ld 1.1s linear infinite;
}
@keyframes ld {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* ============================================================
   Mobile tweaks
   ============================================================ */
@media (max-width: 820px) {
  .viewer-page { padding: 12px 10px 24px; }
  .viewer-card { padding: 12px 12px 14px; border-radius: 14px; }
  .viewer-header { flex-direction: column; align-items: stretch; gap: 8px; }
  .viewer-logo { justify-content: flex-start; }
  .vt-title { font-size: 15px; }
  .map-pane { height: min(60vh, 520px); min-height: 360px; }
  .forecast-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 10px;
  }
  .fw-meta {
    border-right: none;
    min-width: 0;
  }
  .fw-track {
    flex-basis: 100%;
  }
  .legend-horizontal {
    grid-template-columns: 1fr;
    padding: 8px 12px;
  }
  .legend-horizontal .legend-label {
    grid-row: auto;
    max-width: none;
  }
  #legend-canvas { height: 18px; }
  .legend-horizontal .legend-ticks { font-size: 10px; }
  .ctl-popover { right: 8px; top: 8px; width: calc(100% - 16px); max-width: 320px; }
}

/* ============================================================
   Model dropdowns + frame-viewer controls
   Ported from homepage/v3/model_viewer.css so the in-page model
   selector and playback row match the look of the model_selection
   page. Relies on --brand / --ink / --ring tokens from styles_v3.
   ============================================================ */
.model-dropdown { position: relative; }
.model-dropdown__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1px solid rgba(4, 120, 87, 0.3);
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--brand, #047857);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(4, 120, 87, 0.1);
  font-family: inherit;
  min-width: 120px;
  justify-content: space-between;
  line-height: 1;
}
.model-dropdown__toggle:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--ink, #0f172a);
  border-color: rgba(4, 120, 87, 0.5);
  box-shadow: 0 4px 8px rgba(4, 120, 87, 0.15);
}
.model-dropdown__toggle:active { box-shadow: 0 1px 2px rgba(4, 120, 87, 0.1); }
.model-dropdown__toggle[aria-expanded="true"] {
  background: rgba(4, 120, 87, 0.08);
  border-color: var(--brand, #047857);
  color: var(--brand, #047857);
  border-radius: 10px 10px 0 0;
}
.model-dropdown__icon {
  font-size: 10px;
  transition: transform 0.2s ease;
  color: var(--brand, #047857);
}
.model-dropdown__toggle:hover .model-dropdown__icon { color: var(--ink, #0f172a); }
.model-dropdown__toggle[aria-expanded="true"] .model-dropdown__icon { transform: rotate(180deg); }
.model-dropdown__menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 100%;
  width: max-content;
  max-width: 360px;
  background: #fff;
  border: 1px solid rgba(4, 120, 87, 0.3);
  border-top: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.18s ease;
  z-index: 1000;
  overflow: hidden;
  max-height: 70vh;
  overflow-y: auto;
}
.model-dropdown__menu--open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.model-dropdown__item {
  display: block;
  padding: 10px 14px;
  color: var(--ink, #0f172a);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid rgba(4, 120, 87, 0.1);
  transition: all 0.15s ease;
  cursor: pointer;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.model-dropdown__item:last-child { border-bottom: none; }
.model-dropdown__item:hover {
  background: rgba(4, 120, 87, 0.08);
  color: var(--brand, #047857);
}
.model-dropdown__item--active {
  background: var(--brand, #047857);
  color: #fff;
}
.model-dropdown__item--active:hover {
  background: #065f46;
  color: #fff;
}
.model-dropdown__group-header {
  padding: 8px 14px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid rgba(4, 120, 87, 0.08);
}
.model-dropdown__group-header:not(:first-child) { border-top: 1px solid rgba(4, 120, 87, 0.08); }

/* Frame-viewer playback controls — sit inside .forecast-bar */
.frame-viewer-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.frame-viewer-playback {
  display: flex;
  align-items: center;
  gap: 4px;
}
.frame-viewer-btn {
  background: transparent;
  border: 1px solid rgba(4, 120, 87, 0.3);
  border-radius: 10px;
  color: var(--brand, #047857);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  box-shadow: 0 2px 4px rgba(4, 120, 87, 0.1);
  line-height: 1;
  flex-shrink: 0;
  padding: 0;
}
.frame-viewer-btn:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--ink, #0f172a);
  border-color: rgba(4, 120, 87, 0.5);
  box-shadow: 0 4px 8px rgba(4, 120, 87, 0.15);
}
.frame-viewer-btn:active { box-shadow: 0 1px 2px rgba(4, 120, 87, 0.1); }
.frame-viewer-btn--play {
  background: rgba(4, 120, 87, 0.06);
  border: 1px solid rgba(4, 120, 87, 0.5);
  color: var(--brand, #047857);
}
.frame-viewer-btn--play:hover {
  background: rgba(4, 120, 87, 0.1);
  color: var(--brand, #047857);
  border-color: var(--brand, #047857);
  box-shadow: 0 4px 8px rgba(4, 120, 87, 0.18);
}
.frame-viewer-btn--play.playing {
  background: var(--brand, #047857);
  border-color: var(--brand, #047857);
  color: #fff;
  box-shadow: 0 2px 6px rgba(4, 120, 87, 0.3);
}
.frame-viewer-btn--play.playing:hover {
  background: #065f46;
  border-color: #065f46;
  color: #fff;
}
.frame-viewer-slider-wrapper {
  flex: 1 1 0;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  align-self: center;
  position: relative;
}
.frame-viewer-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  border: none;
}
.frame-viewer-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  cursor: grab;
  border: 2px solid rgba(4, 120, 87, 0.75);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.frame-viewer-slider::-webkit-slider-thumb:hover {
  border-color: var(--brand, #047857);
  background: #fff;
  box-shadow: 0 2px 6px rgba(4, 120, 87, 0.25);
}
.frame-viewer-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  background: #065f46;
  border-color: #065f46;
}
.frame-viewer-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  cursor: grab;
  border: 2px solid rgba(4, 120, 87, 0.75);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.frame-viewer-slider::-moz-range-thumb:hover { border-color: var(--brand, #047857); background: #fff; }
.frame-viewer-slider::-moz-range-thumb:active { cursor: grabbing; background: #065f46; border-color: #065f46; }
.frame-viewer-slider::-moz-range-track { height: 8px; background: rgba(0, 0, 0, 0.1); border-radius: 4px; border: none; }
.frame-viewer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.frame-viewer-speed-buttons {
  display: inline-flex;
  background: transparent;
  border: 1px solid rgba(4, 120, 87, 0.3);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  box-shadow: 0 2px 4px rgba(4, 120, 87, 0.1);
}
.frame-viewer-speed-btn {
  background: transparent;
  border: none;
  color: var(--brand, #047857);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1;
}
.frame-viewer-speed-btn:hover { background: rgba(15, 23, 42, 0.04); color: var(--ink, #0f172a); }
.frame-viewer-speed-btn.is-active {
  background: var(--brand, #047857);
  color: #fff;
  box-shadow: 0 1px 3px rgba(4, 120, 87, 0.25);
}
.frame-viewer-speed-btn.is-active:hover { background: #065f46; color: #fff; }

/* "Compare" link in the main viewer pillbar (it's an <a>, styled as a pill). */
.pill-compare { text-decoration: none; font-weight: 600; white-space: nowrap; }

/* ============================ Compare Models view ============================ */
.cmp-page { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 20px; }
.cmp-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
}
.cmp-back {
  display: inline-flex; align-items: center; height: 34px; padding: 0 12px;
  border: 1px solid rgba(4,120,87,.3); border-radius: 9px; color: var(--brand,#047857);
  font-weight: 600; text-decoration: none; background: #fff;
}
.cmp-back:hover { background: rgba(15,23,42,.04); }
.cmp-field { display: flex; flex-direction: column; gap: 3px; font-size: 11px;
  font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .03em; }
.cmp-field select {
  height: 34px; min-width: 130px; padding: 0 8px; border-radius: 9px;
  border: 1px solid rgba(4,120,87,.3); background: #fff; color: #0f172a;
  font-size: 14px; font-weight: 600; font-family: inherit;
}
.cmp-modes { display: inline-flex; border: 1px solid rgba(4,120,87,.3);
  border-radius: 9px; overflow: hidden; height: 34px; align-self: flex-end; }
.cmp-mode-btn {
  border: 0; background: #fff; color: #475569; font-weight: 600; font-size: 13px;
  padding: 0 14px; cursor: pointer; font-family: inherit;
}
.cmp-mode-btn + .cmp-mode-btn { border-left: 1px solid rgba(4,120,87,.2); }
.cmp-mode-btn.is-active { background: var(--brand,#047857); color: #fff; }
.cmp-mode-btn:disabled { opacity: .4; cursor: not-allowed; }

.cmp-maps {
  position: relative; display: flex; gap: 6px;
  height: 72vh; min-height: 460px;
  border-radius: 12px; overflow: hidden; background: #e5e7eb;
}
.cmp-pane { position: relative; flex: 1 1 0; min-width: 0; }
.cmp-pane[hidden] { display: none; }
.cmp-map { position: absolute; inset: 0; }
.cmp-mlabel {
  position: absolute; top: 10px; left: 10px; z-index: 5;
  padding: 4px 10px; border-radius: 8px; font-weight: 700; font-size: 14px;
  color: #0f172a; background: rgba(255,255,255,.88);
  box-shadow: 0 1px 4px rgba(0,0,0,.18); pointer-events: none;
}
/* In difference mode pane A fills the row (pane B is [hidden]). */
.cmp-diff-mode .cmp-pane { flex: 1 1 100%; }

.cmp-loader {
  position: absolute; inset: 0; z-index: 10; display: flex; gap: 10px;
  align-items: center; justify-content: center;
  background: rgba(255,255,255,.55); font-weight: 600; color: #0f172a;
  pointer-events: none;
}
/* The explicit display:flex above would otherwise beat the `hidden`
   attribute's UA `display:none`, leaving the spinner stuck on screen. */
.cmp-loader[hidden] { display: none; }
.cmp-spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid rgba(4,120,87,.25); border-top-color: var(--brand,#047857);
  animation: splash-spin .9s linear infinite;
}

.cmp-footer { display: flex; flex-direction: column; gap: 10px; }
.cmp-time-row { display: flex; align-items: center; gap: 12px; }
.cmp-fh { font-weight: 700; color: #0f172a; min-width: 64px; }
.cmp-slider { flex: 1; }
.cmp-valid { font-weight: 700; color: #0f172a; font-size: 15px; min-width: 220px; text-align: right; }
.cmp-legend { position: relative; max-width: 380px; }
.cmp-legend-label { font-size: 12px; font-weight: 700; color: #0f172a; margin-bottom: 3px; }
.cmp-legend canvas { display: block; width: 360px; height: 12px; border-radius: 3px; }
.cmp-legend-ticks { position: relative; height: 14px; font-size: 10px; color: #475569; }
.cmp-legend-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
/* Difference legend: plain-language end labels (which model is higher). */
.cmp-legend-ends { display: flex; justify-content: space-between; gap: 8px; margin-top: 1px; font-size: 10px; font-weight: 700; }
.cmp-legend-ends[hidden] { display: none; }
.cmp-legend-ends .lo { color: #1d4ed8; }   /* blue end — model B higher */
.cmp-legend-ends .hi { color: #b91c1c; }   /* red end — model A higher */

/* Hover readout on the compare maps (mirrors the viewer's .readout). */
.cmp-readout {
  position: absolute; left: 0; top: 0;
  background: rgba(15, 22, 38, .92);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 8px; padding: 6px 10px;
  backdrop-filter: blur(8px);
  font-size: 12px; line-height: 1.3;
  z-index: 6; pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
  white-space: nowrap; color: #e6edf6;
  transform: translate(14px, 14px);
}
.cmp-readout[hidden] { display: none; }
.cmp-ro-loc { color: #9bb1cb; font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.cmp-ro-row { display: flex; justify-content: space-between; gap: 14px; font-variant-numeric: tabular-nums; }
.cmp-ro-row span { color: #9bb1cb; }
.cmp-ro-row b { color: #e6edf6; font-weight: 700; }
.cmp-ro-diff {
  margin-top: 3px; padding-top: 3px;
  border-top: 1px solid rgba(255, 255, 255, .12);
  color: #e6edf6; font-weight: 600; font-variant-numeric: tabular-nums;
}

@media (max-width: 760px) {
  /* Phones: stack the two maps; comparison is desktop-first. */
  .cmp-maps { flex-direction: column; height: auto; }
  .cmp-pane { height: 44vh; }
  .cmp-valid { min-width: 0; }
}
