/* Anomaly Explorer — chrome borrowed from /v3/wx & /v3/soil_moisture so the
   pages read as the same family (viewer card, pill row, playback bar, sidebar, legend).
   Everything is namespaced under .anom-page so nothing leaks into the site header/footer. */

.anom-page, .anom-page * { box-sizing: border-box; }
.viewer-page { max-width: min(1800px, calc(100% - 32px)); margin: 0 auto; padding: 0 0 32px; }
@media (min-width: 769px) { .site-header { top: 16px; margin-top: 16px; margin-bottom: 16px; } }

.anom-page .viewer-card { background: #fff; 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; }

/* ── Pill row ── */
.anom-page .viewer-pillbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; position: relative; z-index: 1200; }
.anom-page .viewer-pillbar .spacer { flex: 1 1 auto; }
.anom-page .pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; background: #fff;
  border: 1px solid #e2e8f0; border-radius: 999px; color: #0f172a; font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s; box-shadow: 0 1px 2px rgba(15,23,42,.03); white-space: nowrap; }
.anom-page .pill:hover { background: #f8fafc; border-color: #cbd5e1; }
.anom-page .pill.is-active, .anom-page .pill-icon.is-on { background: #047857; border-color: #047857; color: #fff; }
.anom-page .pill-icon { width: 30px; height: 30px; padding: 0; border-radius: 50%; justify-content: center; color: #64748b; font-size: 14px; }
.anom-page .pill-icon:hover { color: #0f172a; }
.anom-page .pill-group { display: inline-flex; gap: 4px; padding: 3px; background: #f1f5f9; border-radius: 999px; }
.anom-page .pill-group .pill { height: 26px; border-color: transparent; background: transparent; box-shadow: none; font-weight: 600; }
.anom-page .pill-group .pill.is-active { background: #047857; color: #fff; }
.anom-page .pill-lbl { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #64748b; margin-left: 4px; }

/* ── Custom dropdown (mirrors a hidden <select>) ── */
.anom-page .model-dropdown { position: relative; }
.anom-page .model-dropdown__toggle { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px 0 14px; background: #fff;
  border: 1px solid rgba(4,120,87,.3); border-radius: 10px; color: #0f172a; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 4px rgba(4,120,87,.1); transition: border-color .15s, box-shadow .15s; white-space: nowrap; }
.anom-page .model-dropdown__toggle:hover { border-color: rgba(4,120,87,.6); }
.anom-page .model-dropdown__toggle[aria-expanded="true"] { border-color: #047857; box-shadow: 0 0 0 3px rgba(4,120,87,.12); }
.anom-page .model-dropdown__kicker { font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #64748b; }
.anom-page .model-dropdown__icon { font-size: 10px; color: #64748b; transition: transform .15s; }
.anom-page .model-dropdown__toggle[aria-expanded="true"] .model-dropdown__icon { transform: rotate(180deg); }
.anom-page .model-dropdown__menu { display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 220px; max-height: 60vh; overflow-y: auto; background: #fff;
  border: 1px solid #e2e8f0; border-radius: 12px; box-shadow: 0 12px 30px rgba(15,23,42,.16); padding: 6px; z-index: 1300; }
.anom-page .model-dropdown__menu--open { display: block; }
.anom-page .model-dropdown__group-header { padding: 8px 10px 4px; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #64748b; }
.anom-page .model-dropdown__item { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; background: transparent; border-radius: 8px;
  font: inherit; font-size: 13px; font-weight: 600; color: #0f172a; cursor: pointer; }
.anom-page .model-dropdown__item:hover { background: #f1f5f9; }
.anom-page .model-dropdown__item--active { background: rgba(4,120,87,.10); color: #047857; }
.anom-page .model-dropdown__item .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }

/* ── Playback bar ── */
.anom-page .forecast-bar { flex: 1 1 auto; min-width: 300px; display: flex; align-items: center; gap: 10px; color: #0f172a; }
.anom-page .frame-viewer-playback { display: inline-flex; align-items: center; gap: 2px; background: #fff; border: 1px solid rgba(4,120,87,.3); border-radius: 10px; padding: 3px; height: 38px; box-shadow: 0 2px 4px rgba(4,120,87,.1); flex-shrink: 0; }
.anom-page .frame-viewer-btn { background: transparent; border: none; border-radius: 7px; color: #047857; width: 32px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: .85rem; line-height: 1; padding: 0; transition: background .15s; }
.anom-page .frame-viewer-btn:hover { background: rgba(4,120,87,.08); }
.anom-page .frame-viewer-btn--play { background: rgba(4,120,87,.1); }
.anom-page .frame-viewer-slider-wrapper { flex: 1 1 0; min-width: 160px; display: flex; align-self: center; }
.anom-page .frame-viewer-slider { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; background: rgba(0,0,0,.1); border-radius: 4px; outline: none; cursor: pointer; border: none; }
.anom-page .frame-viewer-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; background: rgba(255,255,255,.95); border-radius: 50%; cursor: grab; border: 2px solid rgba(4,120,87,.75); box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.anom-page .frame-viewer-slider::-moz-range-thumb { width: 18px; height: 18px; background: rgba(255,255,255,.95); border-radius: 50%; cursor: grab; border: 2px solid rgba(4,120,87,.75); }
.anom-page .fw-meta { display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; line-height: 1.1; min-width: 96px; height: 38px; padding: 0 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; }
.anom-page .tb-fh { font-weight: 700; font-size: 12px; color: #0f172a; white-space: nowrap; }

/* ── Body: sidebar + main ── */
.anom-page .viewer-body { display: grid; grid-template-columns: 290px minmax(0,1fr); gap: 12px; }
.anom-page .wx-sidebar { position: relative; background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; overflow: hidden; min-height: 0; display: flex; flex-direction: column; max-height: clamp(400px, calc(100vh - 256px), 840px); }
.anom-page .wx-sidebar__head { padding: 10px 12px; border-bottom: 1px solid #e2e8f0; display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.anom-page .vt-title { font-size: 15px; font-weight: 800; color: #0f172a; line-height: 1.25; letter-spacing: -.005em; }
.anom-page .vt-valid { font-size: 12.5px; font-weight: 700; color: #0f172a; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.anom-page .wx-sidebar__run-age { font-size: 11px; color: #64748b; font-variant-numeric: tabular-nums; }
.anom-page .wx-sidebar__scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.anom-page .wx-sidebar__group { border-bottom: 1px solid #f1f5f9; }
.anom-page .wx-sidebar__group-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: none; background: transparent; cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: #334155; }
.anom-page .wx-sidebar__chevron { font-size: 10px; color: #94a3b8; transition: transform .2s; }
.anom-page .wx-sidebar__group.is-open .wx-sidebar__chevron { transform: rotate(180deg); }
.anom-page .wx-sidebar__group.is-open .wx-sidebar__group-toggle { color: #047857; }
.anom-page .wx-sidebar__group-items { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s; }
.anom-page .wx-sidebar__group.is-open .wx-sidebar__group-items { grid-template-rows: 1fr; }
.anom-page .wx-sidebar__group-items > div { overflow: hidden; }
.anom-page .wx-sidebar__item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 7px 12px 7px 18px; border: none; border-left: 3px solid transparent; background: transparent;
  font: inherit; font-size: 13px; font-weight: 600; color: #0f172a; cursor: pointer; }
.anom-page .wx-sidebar__item:hover { background: #f8fafc; }
.anom-page .wx-sidebar__item.is-active { background: rgba(4,120,87,.08); border-left-color: #047857; color: #047857; }
.anom-page .wx-sidebar__item .sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.anom-page .wx-sidebar__item .sub { margin-left: auto; font-size: 11px; color: #64748b; font-weight: 600; }
.anom-page .wx-sidebar__about { padding: 10px 12px 14px; font-size: 12px; line-height: 1.45; color: #475569; }
.anom-page .wx-sidebar__about p { margin: 0 0 8px; }
.anom-page .wx-sidebar__about strong { color: #0f172a; }
.anom-page .wx-sidebar__block { padding: 8px 12px 10px; font-size: 12.5px; color: #334155; }
.anom-page .wx-sidebar__block dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0 0 6px; }
.anom-page .wx-sidebar__block dt { color: #64748b; }
.anom-page .wx-sidebar__block dd { margin: 0; font-variant-numeric: tabular-nums; }
.anom-page .headline { font-size: 12.5px; margin: 6px 0; padding: 7px 9px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; line-height: 1.35; }
.anom-page .headline b { color: #0f172a; }
.anom-page .goto { display: flex; gap: 6px; align-items: center; padding: 6px 12px 10px; }
.anom-page .goto input { width: 74px; font: inherit; font-size: 12.5px; padding: 5px 7px; border: 1px solid #e2e8f0; border-radius: 8px; }

/* ── Main pane ── */
.anom-page .viewer-main { min-width: 0; }
.anom-page .map-pane { position: relative; z-index: 0; isolation: isolate; width: 100%; height: clamp(400px, calc(100vh - 256px), 840px); border-radius: 12px; overflow: hidden; border: 1px solid #e2e8f0; background: #dfe9f3; }
.anom-page .map-pane.img-pane { height: auto; background: #f8fafc; display: flex; align-items: center; justify-content: center; min-height: 300px; }
.anom-page .map-pane.img-pane img { display: block; width: 100%; height: auto; }
.anom-page .map-pane.plot-pane { height: auto; min-height: 0; background: #fff; padding: 6px; }
.anom-page #map { position: absolute; inset: 0; }
.anom-page .leaflet-container { font: inherit; }
.anom-page .readout { position: absolute; right: 12px; top: 12px; background: rgba(15,22,38,.92); border: 1px solid rgba(255,255,255,.1); border-radius: 8px; padding: 6px 10px;
  font-size: 12px; line-height: 1.3; z-index: 800; pointer-events: none; color: #e6edf6; max-width: 340px; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
.anom-page .readout .r-loc { color: #9bb1cb; font-variant-numeric: tabular-nums; }
.anom-page .legend-horizontal { display: grid; grid-template-columns: max-content 1fr; column-gap: 14px; row-gap: 2px; align-items: center; margin-top: 8px; padding: 6px 12px 5px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; color: #0f172a; }
.anom-page .legend-label { font-size: 12px; font-weight: 700; white-space: nowrap; }
.anom-page .legend-bar-wrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.anom-page .legend-swatches { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: 14px; border-radius: 4px; overflow: hidden; border: 1px solid #cbd5e1; }
.anom-page .legend-swatches span { display: block; }
.anom-page .legend-ticks { position: relative; height: 13px; font-variant-numeric: tabular-nums; font-size: 11px; font-weight: 600; color: #334155; }
.anom-page .legend-ticks span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.anom-page .legend-desc { grid-column: 1 / span 2; padding-top: 5px; border-top: 1px solid #e2e8f0; font-size: 11px; color: #64748b; line-height: 1.3; }

/* ── Cards below the viewer ── */
.anom-page .results { margin-top: 14px; }
.anom-page .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.anom-page .grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .anom-page .grid2, .anom-page .grid3 { grid-template-columns: 1fr; } }
.anom-page .card { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; min-width: 0;
  box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.anom-page .card h3 { margin: 0 0 8px; font-size: 15px; font-weight: 800; letter-spacing: -.005em; }
.anom-page .card h3 .muted { font-weight: 500; }
.anom-page .card .bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 8px; position: relative; z-index: 5; }
.anom-page .muted { color: #64748b; font-size: 12px; }
.anom-page .note { color: #64748b; font-size: 11.5px; margin-top: 6px; line-height: 1.4; }
.anom-page .plot { width: 100%; height: 340px; }
.anom-page .plot.tall { height: 420px; } .anom-page .plot.short { height: 240px; }
.anom-page .hidden { display: none !important; }
.anom-page .mono { font-family: "IBM Plex Sans", ui-monospace, Menlo, monospace; font-size: 12px; font-variant-numeric: tabular-nums; }
.anom-page .placeholder { color: #64748b; padding: 22px 8px; text-align: center; font-size: 13px; }
.anom-page table.odds { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.anom-page table.odds th, .anom-page table.odds td { padding: 5px 6px; text-align: right; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.anom-page table.odds th { font-weight: 800; color: #64748b; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.anom-page table.odds td:first-child, .anom-page table.odds th:first-child { text-align: left; }
.anom-page table.odds tr { cursor: pointer; }
.anom-page table.odds tr:hover td { background: #f8fafc; }
.anom-page table.odds tr.sel td { background: rgba(4,120,87,.08); }
.anom-page table.odds tr.hdr td { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #334155; background: #f8fafc; cursor: default; }
.anom-page .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.anom-page .pct { display: inline-block; min-width: 44px; padding: 1px 5px; border-radius: 4px; }
.anom-page table.ev { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.anom-page table.ev th, .anom-page table.ev td { padding: 4px 6px; border-bottom: 1px solid #f1f5f9; text-align: left; white-space: nowrap; }
.anom-page table.ev th { position: sticky; top: 0; background: #fff; font-size: 10.5px; color: #64748b; text-transform: uppercase; letter-spacing: .06em; }
.anom-page .pillx { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; color: #fff; font-weight: 700; }
.anom-page .summary .big { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.anom-page .summary dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 8px 0; font-size: 13px; }
.anom-page .summary dt { color: #64748b; }
.anom-page .summary dd { margin: 0; }
.anom-page #evCanvas { width: 100%; height: auto; border-radius: 8px; background: #dfe9f3; display: block; }
.anom-page .notes { display: grid; gap: 14px; margin-top: 18px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.anom-page .notecard { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 16px 18px; }
.anom-page .notecard h3 { margin: 0 0 8px; font-size: 15px; font-weight: 800; }
.anom-page .notecard p, .anom-page .notecard li { color: #475569; font-size: 13.5px; line-height: 1.55; margin: 0 0 .5em; }
.anom-page .notecard ul { margin: 0; padding-left: 1.1em; }
.anom-page .toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; z-index: 99; opacity: 0; transition: opacity .2s; pointer-events: none; }
.anom-page .toast.show { opacity: 1; }
.anom-page .stale { color: #b45309; }

@media (max-width: 820px) {
  .viewer-page { max-width: 100%; padding: 0 0 20px; }
  .anom-page .viewer-card { padding: 10px 10px 12px; border-radius: 12px; }
  .anom-page .viewer-body { grid-template-columns: minmax(0,1fr); }
  .anom-page .wx-sidebar { max-height: none; }
  .anom-page .map-pane { height: clamp(360px, 62vh, 640px); }
  .anom-page .forecast-bar { order: 10; flex-basis: 100%; min-width: 0; }
  .anom-page .legend-horizontal { grid-template-columns: 1fr; }
  .anom-page .legend-desc { grid-column: 1; }
  .anom-page .pill-static { display: none; }
}

/* ── Anomaly Explorer additions ── */
.anom-page .date-range { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 10px; background: #fff; border: 1px solid rgba(4,120,87,.3); border-radius: 10px; box-shadow: 0 2px 4px rgba(4,120,87,.1); }
.anom-page .date-range input[type=date] { font: inherit; font-size: 13px; font-weight: 600; color: #0f172a; border: none; background: transparent; padding: 2px 0; width: 132px; }
.anom-page .date-range input[type=date]:focus { outline: none; }
.anom-page .date-sep { color: #64748b; font-weight: 700; }
.anom-page .pill-go { background: #047857; border-color: #047857; color: #fff; height: 38px; padding: 0 16px; border-radius: 10px; font-size: 13px; }
.anom-page .pill-go:hover { background: #065f46; border-color: #065f46; }
.anom-page .img-pane { flex-direction: column; }
.anom-page .img-pane .placeholder { font-size: 14px; }
.anom-page .img-pane .readout { top: 10px; right: 10px; }
.anom-page .plot-pane { margin-top: 10px; }
.anom-page .src-strip { display: flex; flex-wrap: wrap; gap: 2px; margin: 4px 0 6px; }
.anom-page .src-strip span { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.anom-page .src-legend { display: flex; flex-wrap: wrap; gap: 8px 12px; font-size: 11.5px; color: #64748b; }
.anom-page .src-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.anom-page .sw-era5 { background: #3b7dd8; } .anom-page .sw-era5t { background: #9dc1ef; } .anom-page .sw-ecmwf { background: #e8892b; } .anom-page .sw-miss { background: #c9ced4; }
.anom-page .src-note, .anom-page .rank-text { font-size: 12px; color: #475569; margin-top: 6px; line-height: 1.35; }
.anom-page .wx-sidebar__block dd b { font-weight: 700; color: #0f172a; }
@media (max-width: 768px) { .anom-page .date-range { width: 100%; justify-content: space-between; } .anom-page .date-range input[type=date] { width: 118px; } }
.anom-page img[hidden], .anom-page [hidden] { display: none !important; }
.anom-page .viewer-pillbar .pill-group .pill { font-size: 12.5px; padding: 0 10px; }

/* Colour-bar controls: Range ± box (reuses .date-range) + palette swatches + disabled state */
.anom-page .range-box input[type=number] { font: inherit; font-size: 13px; font-weight: 600; color: #0f172a; border: none; background: transparent; padding: 2px 0; width: 64px; -moz-appearance: textfield; }
.anom-page .range-box input[type=number]::-webkit-inner-spin-button, .anom-page .range-box input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.anom-page .range-box input[type=number]:focus { outline: none; }
.anom-page .range-box input::placeholder { color: #94a3b8; font-weight: 500; }
.anom-page .range-units { font-size: 12px; color: #64748b; }
.anom-page #cmapDrop .model-dropdown__item .sw { width: 34px; }
.anom-page .is-disabled { opacity: .45; pointer-events: none; }
@media (max-width: 768px) { .anom-page .range-box { width: auto; justify-content: flex-start; } }
