.rank-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--well);
  cursor: pointer;
  border-left: 4px solid transparent;
}
.rank-row:hover { background: var(--well-dim); }
.rank-row.b-high     { border-left-color: var(--band-high); }
.rank-row.b-elevated { border-left-color: var(--band-elevated); }
.rank-row.b-watch    { border-left-color: var(--band-watch); }
.rank-row.b-normal   { border-left-color: var(--band-normal); }

.rank-row .score {
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-weight: 700; font-size: 14px; color: #fff;
}
.rank-row .score.b-watch { color: var(--ink); }

/* ── 3-day forecast strip — "Where will the crisis be in 3 days?" ────── */
.forecast-strip {
  border-top: 2px solid var(--th-navy);
  background: var(--well-dim);
}
.forecast-head { padding: 8px 12px 4px; }
.forecast-head .eyebrow { color: var(--th-navy); font-weight: 700; }
.forecast-method { font-size: 10px; color: var(--ink-mid); margin-top: 2px; line-height: 1.3; }
.forecast-empty { padding: 12px; text-align: center; color: var(--ink-mid); font-size: 12px; }
.forecast-row {
  display: grid;
  grid-template-columns: 1fr 130px 32px;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  border-left: 4px solid transparent;
  text-decoration: none; color: var(--ink);
  cursor: pointer;
  transition: background .12s;
}
.forecast-row:hover { background: var(--well); }
.forecast-row.b-high     { border-left-color: var(--band-high); }
.forecast-row.b-elevated { border-left-color: var(--band-elevated); }
.forecast-row.b-watch    { border-left-color: var(--band-watch); }
.forecast-row.b-normal   { border-left-color: var(--band-normal); }
.forecast-name .th { font-weight: 600; font-size: 12.5px; line-height: 1.2; }
.forecast-rain { font-size: 10px; color: var(--ink-mid); font-family: var(--font-num); margin-top: 1px; }
.forecast-rail {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
}
.forecast-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.forecast-h { font-family: var(--font-num); font-size: 9px; color: var(--ink-mid); letter-spacing: 0.04em; }
.forecast-score {
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-weight: 700; font-size: 10.5px; color: #fff;
}
.forecast-score.b-watch { color: var(--ink); }
.forecast-delta {
  text-align: center;
  font-family: var(--font-num);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.forecast-arrow { font-size: 11px; color: var(--th-red); line-height: 1; }
.forecast-delta-num { font-size: 11px; font-weight: 700; color: var(--th-red); }
.forecast-foot {
  padding: 6px 12px 10px;
  font-size: 9.5px; color: var(--ink-low);
  line-height: 1.4; font-style: italic;
  border-top: 1px dashed var(--rule);
}

@media (max-width: 860px) {
  .forecast-row { grid-template-columns: 1fr 110px 30px; }
  .forecast-score { width: 22px; height: 22px; font-size: 9.5px; }
}

/* ── What-if widget — drag the slider, watch the risk map ───────────── */
.whatif-box {
  background: var(--well);
  border-top: 2px solid var(--th-navy);
  padding-bottom: 4px;
}
.whatif-head { padding: 8px 12px 4px; }
.whatif-head .eyebrow { color: var(--th-navy); font-weight: 700; }
.whatif-sub { font-size: 10.5px; color: var(--ink-mid); margin: 4px 0 6px; line-height: 1.3; }
.whatif-slider { padding: 4px 12px 8px; }
.whatif-slider input[type="range"] {
  width: 100%; appearance: none; -webkit-appearance: none;
  height: 4px; background: var(--rule); border-radius: 2px;
  outline: none; cursor: pointer;
}
.whatif-slider input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--th-navy); cursor: pointer;
  border: 2px solid var(--paper);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.whatif-slider input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--th-navy); cursor: pointer;
  border: 2px solid var(--paper); box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.whatif-ticks {
  display: flex; justify-content: space-between;
  font-family: var(--font-num); font-size: 9px; color: var(--ink-low);
  margin-top: 4px;
}
.whatif-readout {
  display: flex; align-items: baseline; gap: 4px;
  margin-top: 6px; justify-content: center;
  background: var(--paper); border: 1px solid var(--rule);
  padding: 4px 10px; border-radius: 3px;
}
.whatif-rain-num { font-family: var(--font-num); font-size: 22px; font-weight: 700; color: var(--th-navy); line-height: 1; }
.whatif-rain-unit { font-size: 11px; color: var(--ink-mid); }
.whatif-summary {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 3px; padding: 6px 12px 4px;
}
.whatif-summary-cell {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 2px; background: var(--paper);
  border-top: 3px solid var(--ink-mid);
}
.whatif-summary-cell:nth-child(1) { border-top-color: var(--band-high); }
.whatif-summary-cell:nth-child(2) { border-top-color: var(--band-elevated); }
.whatif-summary-cell:nth-child(3) { border-top-color: var(--band-watch); }
.whatif-summary-cell:nth-child(4) { border-top-color: var(--band-normal); }
.whatif-summary-cell .num { font-family: var(--font-num); font-weight: 700; font-size: 16px; color: var(--ink); line-height: 1; }
.whatif-summary-cell .lbl { font-size: 8.5px; color: var(--ink-mid); letter-spacing: 0.04em; }
.whatif-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; padding: 4px 12px;
  font-size: 11.5px;
  border-left: 3px solid var(--ink-mid);
}
.whatif-row.b-high     { border-left-color: var(--band-high); }
.whatif-row.b-elevated { border-left-color: var(--band-elevated); }
.whatif-row.b-watch    { border-left-color: var(--band-watch); }
.whatif-row.b-normal   { border-left-color: var(--band-normal); }
.whatif-name { flex: 1 1 auto; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whatif-numbers { display: flex; align-items: center; gap: 4px; font-family: var(--font-num); }
.whatif-num-now { color: var(--ink-mid); }
.whatif-arrow { color: var(--ink-low); }
.whatif-num-new { font-weight: 700; }
.whatif-delta { color: var(--th-red); font-size: 10.5px; }
.whatif-empty { padding: 10px 12px; text-align: center; font-size: 11px; color: var(--ink-mid); font-style: italic; }
.whatif-foot {
  padding: 6px 12px 10px;
  font-size: 9.5px; color: var(--ink-low);
  line-height: 1.4; font-style: italic;
  border-top: 1px dashed var(--rule);
}

/* ── Real-time insights panel — "what's happening now?" patterns ───── */
.ins-head { padding: 10px 12px 6px; }
.ins-head .eyebrow { color: var(--th-navy); font-weight: 700; }
.ins-summary {
  display: flex; align-items: center; gap: 4px;
  margin: 6px 0 4px;
  font-family: var(--font-num);
}
.ins-count {
  display: inline-block; min-width: 22px;
  padding: 2px 6px; text-align: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background: var(--ink-low); border-radius: 3px;
  margin-left: 6px;
}
.ins-count.critical { background: var(--band-high); }
.ins-count.warn     { background: var(--band-elevated); }
.ins-count-label {
  font-size: 9.5px; color: var(--ink-mid);
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-right: 4px;
}
.ins-method { font-size: 9.5px; color: var(--ink-low); line-height: 1.3; font-style: italic; margin: 4px 0 8px; }
.ins-typebar {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 4px 8px 8px;
  border-bottom: 1px dashed var(--rule);
  background: var(--well);
}
.ins-type-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  font-size: 10px; font-weight: 600;
  background: var(--paper);
  border: 1px solid var(--rule);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-ui);
}
.ins-type-chip.off { opacity: 0.4; }
.ins-type-dot { width: 6px; height: 6px; background: var(--th-navy); border-radius: 50%; }
.ins-type-num {
  font-family: var(--font-num); font-size: 10px; color: var(--ink-mid);
  background: var(--well-dim); padding: 0 4px; border-radius: 2px;
}
.ins-empty { padding: 14px 12px; text-align: center; color: var(--ink-mid); font-size: 12px; }
.ins-card {
  display: block;
  margin: 8px;
  padding: 8px 12px 10px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--ink-mid);
  cursor: pointer;
  transition: transform .12s, background .12s, border-color .12s;
}
.ins-card:hover { background: var(--well); transform: translateX(2px); }
.ins-card.hidden-by-type { display: none; }
.ins-card.sev-critical { border-left-color: var(--band-high); }
.ins-card.sev-warn     { border-left-color: var(--band-elevated); }
.ins-card.sev-info     { border-left-color: var(--ink-low); }
.ins-card-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px; flex-wrap: wrap;
}
.ins-type-tag {
  font-family: var(--font-num); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--ink-mid);
}
.ins-sev-tag {
  font-family: var(--font-num); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 2px; color: #fff;
  margin-left: auto;
}
.ins-sev-tag.sev-critical { background: var(--band-high); }
.ins-sev-tag.sev-warn     { background: var(--band-elevated); }
.ins-sev-tag.sev-info     { background: var(--ink-low); }
.ins-title {
  font-size: 13px; font-weight: 600; line-height: 1.35; color: var(--ink);
  margin-bottom: 3px;
}
.ins-body {
  font-size: 11.5px; color: var(--ink-mid); line-height: 1.4;
}
.ins-foot {
  padding: 10px 12px 14px;
  font-size: 10px; color: var(--ink-low); font-style: italic;
  border-top: 1px dashed var(--rule);
  margin-top: 4px;
  line-height: 1.4;
}
.hist-intro .eyebrow { color: var(--th-navy); font-weight: 700; }
.hist-intro p { font-size: 12px; color: var(--ink-mid); margin: 4px 0 6px; line-height: 1.4; }
.hist-card {
  display: block;
  margin: 8px;
  padding: 10px 12px 12px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--ink-mid);
  text-decoration: none; color: var(--ink);
  cursor: pointer;
  transition: transform .12s, background .12s, border-color .12s;
}
.hist-card:hover { background: var(--well); transform: translateX(2px); }
.hist-card.sev-emergency { border-left-color: var(--band-high); }
.hist-card.sev-warning   { border-left-color: var(--band-elevated); }
.hist-card.sev-watch     { border-left-color: var(--band-watch); }
.hist-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;
}
.hist-year {
  font-family: var(--font-num); font-size: 22px; font-weight: 700;
  color: var(--th-navy); line-height: 1; letter-spacing: -0.02em;
}
.hist-sev {
  font-family: var(--font-num); font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 2px 6px; border: 1px solid currentColor;
}
.hist-card.sev-emergency .hist-sev { color: var(--band-high); }
.hist-card.sev-warning   .hist-sev { color: var(--band-elevated); }
.hist-card.sev-watch     .hist-sev { color: var(--band-watch); }
.hist-name { margin-bottom: 6px; }
.hist-name .th { font-size: 13px; font-weight: 600; line-height: 1.3; }
.hist-name .en { font-size: 10.5px; color: var(--ink-mid); font-family: var(--font-num); margin-top: 1px; }
.hist-fact { font-size: 11.5px; color: var(--ink); line-height: 1.45; margin: 4px 0 0; }
.hist-foot {
  padding: 10px 14px 14px;
  font-size: 10px; color: var(--ink-low); font-style: italic;
  border-top: 1px dashed var(--rule);
  margin-top: 6px;
}
.rank-row .who { flex: 1; min-width: 0; }
.rank-row .who .th { font-weight: 600; font-size: 14.5px; }
.rank-row .who .en { font-family: var(--font-num); font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mid); }
.rank-row .stats { text-align: right; flex: none; }
.rank-row .stats .line { font-family: var(--font-num); font-size: 11px; color: var(--ink-mid); }
.rank-row .stats .line b { color: var(--ink); font-weight: 700; }
.rank-row .stats .line .hot { color: var(--th-red); font-weight: 700; }

/* ── Station detail ──────────────────────────────────────────────────────── */
.detail-back { margin: 10px 12px 0; }
.detail-block { background: var(--well); border-bottom: 1px solid var(--rule); padding: 10px 12px; }
.detail-block h3 { font-size: 15px; font-weight: 600; }
.detail-kv { display: flex; justify-content: space-between; padding: 3px 0; font-size: 13px; }
.detail-kv .v { font-family: var(--font-num); font-weight: 500; }
.spark { width: 100%; height: 64px; margin-top: 6px; }
.spark polyline { fill: none; stroke: var(--rain); stroke-width: 1.5; }
.spark .axis { font-family: var(--font-num); font-size: 8.5px; fill: var(--ink-low); }

/* Detail panel chart — full 72-hour station time-series */
.detail-chart { display: block; width: 100%; height: 120px; margin-top: 4px; }
.chart-legend {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 8px; font-family: var(--font-num); font-size: 9.5px;
  color: var(--ink-mid); letter-spacing: 0.04em; text-transform: uppercase;
}
.chart-legend .dot {
  display: inline-block; width: 8px; height: 8px;
  margin-right: 2px; margin-left: 6px; border: 1px solid;
}
.chart-legend .dot.warn   { background: rgba(232,106,16,0.18); border-color: #E86A10; }
.chart-legend .dot.danger { background: rgba(165,25,49,0.18);  border-color: #A51931; }

/* Sparkline in ranking row — a 24h preview of the province's max water level */
.rank-row .mini-spark { display: block; width: 64px; height: 22px; flex: none; }

/* ── Right rail tabs ─────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--rule-strong); background: var(--well); flex: none; }
.tabs button {
  flex: 1; border: none; border-right: 1px solid var(--rule);
  padding: 8px 1px 6px; font-size: 11.5px; font-weight: 600; background: var(--well-dim);
}
.tabs button:last-child { border-right: none; }
.tabs button.active { background: var(--well); border-bottom: 3px solid var(--th-navy); }
.tabs button .cnt { font-family: var(--font-num); font-size: 10px; color: var(--th-red); font-weight: 700; }

.tabpane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tabpane.active { display: flex; }

/* ── Running tap ─────────────────────────────────────────────────────────── */
.tap-row {
  display: flex; gap: 8px; align-items: baseline;
  padding: 6px 10px;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
  background: var(--well);
}
.tap-row.fresh { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: #FDF3D7; } }
.tap-row .t { font-family: var(--font-num); font-size: 10.5px; color: var(--ink-low); flex: none; width: 40px; }
.tap-row .sq { width: 8px; height: 8px; flex: none; align-self: center; }
.tap-row .sq.sev0 { background: var(--rule-strong); opacity: 0.25; }
.tap-row .sq.sev1 { background: var(--rain); }
.tap-row .sq.sev2 { background: var(--lv4); }
.tap-row .sq.sev3 { background: var(--th-red); }
.tap-row .msg { flex: 1; min-width: 0; }
.tap-row .src { font-family: var(--font-num); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-low); }

.tap-paused {
  padding: 4px 10px; background: var(--band-watch); color: var(--ink);
  font-size: 12px; font-weight: 600; cursor: pointer; flex: none;
}

/* ── Alerts / news lists ─────────────────────────────────────────────────── */
.alert-row { padding: 8px 12px; border-bottom: 1px solid var(--rule); background: var(--well); font-size: 13.5px; display: flex; gap: 8px; }
.alert-row .badge { margin-top: 2px; }
.alert-row .when { font-family: var(--font-num); font-size: 10.5px; color: var(--ink-low); }
.news-row { padding: 8px 12px; border-bottom: 1px solid var(--rule); background: var(--well); font-size: 13.5px; }
.news-row a { text-decoration: none; }
.news-row a:hover { text-decoration: underline; }
.news-row .when { font-family: var(--font-num); font-size: 10px; color: var(--ink-low); }

/* ── Chat ────────────────────────────────────────────────────────────────── */
#chat-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 92%; padding: 8px 10px; font-size: 13.5px; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--th-navy); color: var(--ink-inv); }
.chat-msg.bot  { align-self: flex-start; background: var(--well); border: 1px solid var(--rule-strong); }
.chat-msg.offline { border-left: 4px solid var(--band-watch); font-family: var(--font-num); font-size: 11.5px; }
.chat-msg .kn { margin-top: 6px; font-size: 10px; color: var(--ink-low); font-family: var(--font-num); }
#chat-form { display: flex; border-top: 1px solid var(--rule-strong); flex: none; }
#chat-input { flex: 1; border: none; padding: 10px; }
#chat-send { border: none; border-left: 1px solid var(--rule-strong); padding: 0 16px; font-weight: 700; }
.chat-status { padding: 4px 10px; font-family: var(--font-num); font-size: 10px; color: var(--ink-low); border-top: 1px solid var(--rule); flex: none; }
.chat-status .on { color: var(--band-normal); }
.chat-status .off { color: var(--th-red); }

/* ── Map controls & legend (transit signage style) ───────────────────────── */
.mapctl {
  background: var(--well);
  border: 1px solid var(--rule-strong) !important;
  font-family: var(--font-ui);
}
.mapctl .row { display: flex; align-items: center; gap: 6px; padding: 4px 8px; border-bottom: 1px solid var(--rule); cursor: pointer; font-size: 12.5px; user-select: none; }
.mapctl .row:last-child { border-bottom: none; }
.mapctl .row .sw { width: 12px; height: 12px; border: 1px solid var(--ink); flex: none; }
.mapctl .row.on .sw { background: var(--th-navy); }
.mapctl .row .lbl { flex: 1; }
.mapctl-group {
  padding: 6px 8px 2px; font-family: var(--font-num); font-size: 9px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mid);
  background: var(--well-dim); border-bottom: 1px solid var(--rule);
}

/* ── Thai TV live grid — 15 simultaneous muted-autoplay YouTube embeds ──── */
.mapctl .tv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 6px 6px 8px;
  max-height: 240px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mapctl .tv-live-grid {
  /* Live grid is taller — 15 iframes need more headroom. */
  max-height: min(80vh, 720px);
}
.mapctl .tv-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 5px 3px 4px;
  background: var(--well);
  border: 1px solid var(--rule);
  border-radius: 3px;
  text-decoration: none; color: var(--ink);
  min-height: 50px;
  cursor: pointer;
  transition: transform .12s, border-color .12s, background .12s;
  overflow: hidden;
}
.mapctl .tv-card:hover { transform: translateY(-1px); border-color: var(--th-navy); background: #fff; }
.mapctl .tv-card:active { transform: translateY(0); }
.mapctl .tv-card .tv-logo {
  font-family: var(--font-num);
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  padding: 3px 5px;
  border-radius: 2px;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  max-width: 100%;
  text-align: center;
}
.mapctl .tv-card .tv-name {
  font-size: 9px;
  line-height: 1.1;
  color: var(--ink-mid);
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mapctl .tv-card .tv-live {
  position: absolute; top: 3px; right: 3px;
  width: 5px; height: 5px; background: #E53935;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,0.6);
  animation: blink 1.6s steps(2) infinite;
}

/* Live tile: each one is a 16:9 video embed with a small name strip. */
.mapctl .tv-tile {
  position: relative;
  display: block;
  text-decoration: none;
  border: 1px solid var(--rule);
  background: #000;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s, transform .12s;
}
.mapctl .tv-tile:hover { border-color: var(--th-navy); transform: translateY(-1px); }
.mapctl .tv-tile .tv-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
  display: block;
  object-fit: cover;
  background: #000;
  /* iOS needs playsinline + muted + autoplay to allow autostart */
}
/* OFFICIAL_ONLY / error fallback: hide the video, show the brand strip
   and a "visit official site" hint. Same pattern as nsp-prototype. */
.mapctl .tv-tile.tv-error .tv-video { display: none; }
.mapctl .tv-tile.tv-error::after {
  content: "↗ visit official site";
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-size: 9.5px;
  color: rgba(255,255,255,0.85);
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.55) 100%);
  z-index: 1;
  pointer-events: none;
}
.mapctl .tv-tile .tv-live-dot {
  position: absolute; top: 3px; right: 3px;
  width: 6px; height: 6px; background: #E53935;
  border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(0,0,0,0.5);
  z-index: 2;
  animation: blink 1.6s steps(2) infinite;
}
.mapctl .tv-tile.tv-error .tv-live-dot { background: var(--ink-mid); animation: none; }
.mapctl .tv-tile .tv-tile-name {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 5px;
  padding: 2px 5px;
  color: #fff;
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.02em;
  z-index: 2;
  opacity: 0;                  /* hidden by default, slides up on hover */
  transform: translateY(100%);
  transition: opacity .15s, transform .15s;
}
.mapctl .tv-tile:hover .tv-tile-name { opacity: 1; transform: translateY(0); }
.mapctl .tv-tile .tv-tile-brand {
  font-family: var(--font-num); font-weight: 700;
  padding: 1px 4px; background: rgba(0,0,0,0.35); border-radius: 1px;
}
.mapctl .tv-tile .tv-tile-full {
  font-size: 9px; opacity: 0.95;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1 1 auto; min-width: 0;
}

/* Body scrolls when content overflows viewport (15 channels can be tall). */
.mapctl-body { max-height: min(70vh, 640px); overflow-y: auto; overscroll-behavior: contain; }

/* Live grid deserves a slightly taller body so more channels are visible. */
.mapctl-body:has(.tv-live-grid) { max-height: min(80vh, 720px); }

@media (max-width: 480px) {
  .mapctl .tv-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Data-source catalog ─────────────────────────────────────────────────── */
.src-section {
  padding: 10px 12px 4px; font-family: var(--font-num); font-size: 9.5px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-mid);
  background: var(--well-dim); border-bottom: 1px solid var(--rule-strong);
}
.src-jaxa, .src-export, .src-card {
  padding: 10px 12px; border-bottom: 1px solid var(--rule); background: var(--well);
  font-size: 13px;
}
.src-jaxa p, .src-export p { margin: 4px 0 8px; line-height: 1.45; color: var(--ink-mid); }
.src-head { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.src-kind {
  font-family: var(--font-num); font-size: 9px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 2px 6px; background: var(--th-navy); color: #fff;
}
.src-kind.satellite { background: #1565C0; }
.src-kind.reference { background: #5D4037; }
.src-stored { font-size: 11px; color: var(--ink-low); }
.src-name { font-weight: 600; font-size: 14px; }
.src-agency { font-size: 12px; color: var(--ink-mid); margin: 2px 0; }
.src-meta { font-size: 11.5px; color: var(--ink-low); font-family: var(--font-num); }
.src-note { font-size: 12px; color: var(--ink-mid); margin-top: 4px; line-height: 1.4; }
.src-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.src-links a, .src-links code {
  font-size: 11.5px; color: var(--rain); text-decoration: none;
  font-family: var(--font-num);
}
.src-links a:hover { text-decoration: underline; }
.src-api { background: var(--well-dim); padding: 2px 5px; font-size: 10.5px; }
.src-days { margin-top: 8px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.src-day {
  font-family: var(--font-num); font-size: 11px; padding: 2px 6px;
  border: 1px solid var(--rule-strong); background: var(--well-dim); color: var(--ink);
  text-decoration: none;
}
.src-day:hover { background: var(--th-navy); color: #fff; }

.legend { background: var(--well); border: 1px solid var(--rule-strong); padding: 6px 8px; font-size: 11px; }
.legend .lrow { display: flex; align-items: center; gap: 6px; padding: 1.5px 0; }
.legend .lsw { width: 11px; height: 11px; flex: none; }
.legend .lsw.round { border-radius: 50% !important; }

.radarctl { background: var(--well); border: 1px solid var(--rule-strong); padding: 4px 8px; display: flex; align-items: center; gap: 8px; font-family: var(--font-num); font-size: 11px; }
.radarctl button { border: 1px solid var(--ink); padding: 1px 7px; font-size: 11px; }

/* ── Split-pane map controls (compact, top-left of #map-b) ───────────── */
.mapctl-b {
  font-family: var(--font-ui);
  font-size: 11.5px;
  max-width: 220px;
  min-width: 180px;
}
.mapctl-b .row {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 7px; border-bottom: 1px solid var(--rule);
  cursor: pointer; user-select: none;
}
.mapctl-b .row:last-child { border-bottom: none; }
.mapctl-b .row .sw {
  width: 10px; height: 10px; border: 1px solid var(--ink); flex: none;
}
.mapctl-b .row.on .sw { background: var(--th-navy); }
.mapctl-b .row .lbl { flex: 1; }
.mapctl-b .mapctl-group {
  padding: 4px 7px 1px;
  font-family: var(--font-num); font-size: 8.5px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-mid);
  background: var(--well-dim);
  border-bottom: 1px solid var(--rule);
}
.mapctl-b .mapctl-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 7px; background: var(--well);
  font-family: var(--font-num); font-size: 9px;
  letter-spacing: 0.08em; text-transform: uppercase;
  border-bottom: 1px solid var(--rule-strong);
  cursor: pointer;
}
.mapctl-b .mapctl-head .sw {
  display: inline-block; width: 10px; height: 10px;
  background: var(--th-navy); margin-right: 6px;
}
/* Station badges on the map (level 4/5 get numbered squares) */
.stn-badge {
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-weight: 700; font-size: 11px; color: #fff;
  border: 1.5px solid #fff;
}
.stn-badge.lv4 { background: var(--lv4); }
.stn-badge.lv5 { background: var(--lv5); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.18); } }

.leaflet-popup-content-wrapper { border: 1px solid var(--rule-strong); }
.leaflet-popup-content { font-family: var(--font-ui); font-size: 13px; margin: 10px 12px; }
.leaflet-popup-content .pop-name { font-weight: 700; }
.leaflet-popup-content .pop-en { font-family: var(--font-num); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-mid); }
.leaflet-popup-content .pop-kv { display: flex; justify-content: space-between; gap: 16px; padding: 1px 0; }
.leaflet-popup-content .pop-kv .v { font-family: var(--font-num); }

/* ── Connected waterways: cascade nodes + lag chips ──────────────────────── */
.reach-node { border: 2px solid #fff; transform: rotate(45deg); }
.lag-chip {
  font-family: var(--font-num); font-size: 9px; font-weight: 700;
  color: var(--th-navy); background: rgba(246,244,239,0.85);
  padding: 0 3px; text-align: center; white-space: nowrap;
  border: 1px solid var(--rule);
}

/* ── Water-flow direction layer (primary-school explainer) ──────────────── */
.flow-arrow {
  width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 7px solid; /* color set inline per band */
  opacity: 0.75;
}
.flow-schematic-label, .flow-outlet-label {
  font-family: var(--font-num); font-size: 9px; font-style: italic;
  color: var(--ink-mid); white-space: nowrap; text-shadow: 0 0 3px var(--paper), 0 0 3px var(--paper);
}
.flow-outlet-label { color: var(--th-navy); font-weight: 700; font-style: normal; }

/* Historical flood pins + extent polygons */
.hist-pin {
  font-family: var(--font-num); font-weight: 700; font-size: 11px; color: #fff;
  padding: 2px 4px; border: 1.5px solid #fff; text-align: center; white-space: nowrap;
  opacity: 0.9;
}
/* Impact-stats chips inside the flood-extent polygon popup */
.leaflet-popup-content .pop-kv-row {
  display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 2px;
}
.leaflet-popup-content .hist-stat {
  font-family: var(--font-num); font-size: 10.5px; font-weight: 600;
  padding: 2px 6px; background: var(--well-dim); border: 1px solid var(--rule);
  color: var(--th-navy);
}

/* ── Waterways panel: cascade chain ──────────────────────────────────────── */
.cascade-flow { padding: 8px 12px; }
.cascade-step {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0; position: relative;
}
.cascade-step + .cascade-step { border-top: 1px dashed var(--rule); }
.cascade-node-sq {
  width: 26px; height: 26px; flex: none; transform: rotate(45deg);
  border: 2px solid #fff; margin: 3px 8px;
}
.cascade-body { flex: 1; min-width: 0; }
.cascade-body .nm { font-weight: 600; font-size: 13.5px; }
.cascade-body .q { font-family: var(--font-num); font-size: 11.5px; color: var(--ink-mid); }
.cascade-body .q b { color: var(--ink); }
.cascade-lag {
  font-family: var(--font-num); font-size: 10px; color: var(--ink-low);
  text-align: right; flex: none;
}
.cascade-lag .eta { color: var(--rain); font-weight: 700; font-size: 12px; }

.wx-method { padding: 8px 12px; font-size: 11.5px; color: var(--ink-mid); border-bottom: 1px solid var(--rule); background: var(--well-dim); }

/* Wetness (API) rows */
.wet-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--rule); background: var(--well); }
.wet-bar { flex: 1; height: 8px; background: var(--well-dim); position: relative; }
.wet-bar > div { position: absolute; left: 0; top: 0; bottom: 0; }
.wet-sat > div  { background: #0039A6; }
.wet-wet > div  { background: #1D66A8; }
.wet-moist > div{ background: #7FA9C9; }
.wet-dry > div  { background: #C9C2B4; }
.wet-row .nm { width: 92px; flex: none; font-size: 12.5px; }
.wet-row .val { font-family: var(--font-num); font-size: 11px; width: 58px; text-align: right; flex: none; color: var(--ink-mid); }

/* ENSO chip */
.enso-chip { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--rule-strong); background: var(--well); }
.enso-dot { width: 12px; height: 12px; flex: none; }
.enso-la_nina .enso-dot, .enso-la_nina_strong .enso-dot { background: #0039A6; }
.enso-el_nino .enso-dot, .enso-el_nino_strong .enso-dot { background: #E86A10; }
.enso-neutral .enso-dot { background: #8A8A8A; }
.enso-chip .txt { flex: 1; min-width: 0; }
.enso-chip .txt .h { font-weight: 700; font-size: 13px; }
.enso-chip .txt .s { font-size: 10.5px; color: var(--ink-mid); }
.enso-chip .oni { font-family: var(--font-num); font-weight: 700; font-size: 15px; }

/* Loading state */
#boot {
  position: fixed; inset: 0; background: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  z-index: 9999;
}
#boot .bar { width: 220px; height: 4px; background: var(--rule); overflow: hidden; }
#boot .bar div { width: 40%; height: 100%; background: var(--th-navy); animation: load 1.2s ease-in-out infinite; }
#boot .boot-retry {
  margin-top: 8px; padding: 8px 20px; border: 2px solid var(--th-navy);
  background: var(--th-navy); color: #fff; font-family: var(--font-ui);
  font-size: 13px; cursor: pointer;
}
#boot .boot-retry:hover { background: #1a1640; }
@keyframes load { 0% { transform: translateX(-100%);} 100% { transform: translateX(320%);} }

/* ── The Flood Library: search + TOC ─────────────────────────────────────── */
.lib-search-bar { padding: 8px 12px; border-bottom: 1px solid var(--rule-strong); background: var(--well); flex: none; }
.lib-search-bar input { width: 100%; }
.lib-results { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }

.lib-group-head {
  padding: 8px 12px 4px; font-family: var(--font-num); font-size: 9.5px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-mid);
  background: var(--well-dim); border-bottom: 1px solid var(--rule-strong);
}
.lib-toc-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--rule); background: var(--well); cursor: pointer;
}
.lib-toc-row:hover { background: var(--well-dim); }
.lib-toc-title { flex: 1; min-width: 0; }
.lib-toc-title .th { font-weight: 600; font-size: 13.5px; }
.lib-toc-title .en { font-family: var(--font-num); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-mid); }
.lib-toc-n { font-family: var(--font-num); font-size: 10.5px; color: var(--ink-low); flex: none; }

.lib-result-row {
  padding: 8px 12px; border-bottom: 1px solid var(--rule); background: var(--well); cursor: pointer;
}
.lib-result-row:hover { background: var(--well-dim); }
.lib-result-ctx {
  font-family: var(--font-num); font-size: 9.5px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-low);
}
.lib-result-title { font-weight: 600; font-size: 13.5px; margin-top: 2px; }
.lib-snippet { font-size: 12.5px; color: var(--ink-mid); line-height: 1.45; margin-top: 4px; }
.lib-snippet mark { background: #FDE9B8; color: var(--ink); padding: 0 1px; }

/* ── The Flood Library: reader overlay ───────────────────────────────────── */
#library-overlay {
  position: fixed; inset: 0; z-index: 5600;
  background: var(--paper);
  display: flex; flex-direction: column;
}
#library-overlay[hidden] { display: none; }
.library-head {
  height: var(--header-h); flex: none;
  background: var(--th-navy); color: var(--ink-inv);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  border-bottom: 3px solid var(--th-red);
}
.library-head .sign { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.library-head .sign .th { font-weight: 700; font-size: 16px; }
.library-head .sign .en {
  font-family: var(--font-num); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; opacity: 0.85;
}
.library-head .sign .doc-title {
  font-size: 12.5px; color: var(--ink-inv); opacity: 0.75;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-left: 1px solid rgba(246,244,239,0.35); padding-left: 8px; margin-left: 2px;
}
.library-head button {
  border: 1px solid rgba(246,244,239,0.5); background: transparent; color: var(--ink-inv);
  font-weight: 600; padding: 5px 12px; flex: none;
}
.library-head button:hover { background: var(--ink-inv); color: var(--th-navy); }

.lib-reader { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
/* Equations: honest monospace blocks (no math engine) */
.lib-article .eq {
  margin: 10px 0; padding: 10px 12px;
  background: var(--well-dim); border-left: 3px solid var(--rain);
  overflow-x: auto;
}
.lib-article .eq code { font-family: var(--font-num); font-size: 12.5px; background: none; }
.lib-article .eq-inline { font-family: var(--font-num); font-size: 0.92em; background: var(--well-dim); padding: 0 3px; }
.lib-article {
  max-width: 780px; margin: 0 auto; width: 100%;
  padding: 32px clamp(16px, 5vw, 48px) 8px;
  font-size: 15px; line-height: 1.6; color: var(--ink);
}
.lib-article h1, .lib-article h2, .lib-article h3, .lib-article h4 {
  color: var(--th-navy); line-height: 1.3; margin: 22px 0 10px;
}
.lib-article h1 { font-size: 24px; margin-top: 0; }
.lib-article h2 { font-size: 19px; }
.lib-article h3 { font-size: 16px; }
.lib-article h4 { font-size: 14px; letter-spacing: 0.02em; }
.lib-article p { margin: 10px 0; }
.lib-article ul, .lib-article ol { margin: 10px 0; padding-left: 24px; }
.lib-article li { margin: 4px 0; }
.lib-article a { color: var(--rain); text-decoration: underline; }
.lib-article blockquote {
  margin: 14px 0; padding: 4px 14px; border-left: 3px solid var(--th-navy);
  color: var(--ink-mid); background: var(--well-dim);
}
.lib-article table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 13.5px; }
.lib-article th, .lib-article td { border: 1px solid var(--rule); padding: 6px 8px; text-align: left; }
.lib-article th { background: var(--well-dim); font-weight: 600; }
.lib-article pre {
  background: var(--well-dim); border: 1px solid var(--rule); padding: 10px 12px;
  overflow-x: auto; margin: 14px 0;
}
.lib-article code { font-family: var(--font-num); font-size: 12.5px; }
.lib-article pre code { font-size: 12.5px; }
.lib-article mark { background: #FDE9B8; color: var(--ink); padding: 0 1px; }
.lib-article img { max-width: 100%; }
.lib-article hr { border: none; border-top: 1px solid var(--rule); margin: 20px 0; }

.lib-nav {
  flex: none; max-width: 780px; margin: 0 auto; width: 100%;
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px clamp(16px, 5vw, 48px) 28px;
}
.lib-nav button { padding: 7px 14px; }

@media (max-width: 860px) {
  .lib-article, .lib-nav { max-width: 100%; }
}

/* ── About overlay: tab navigation ─────────────────────────────────────────── */
.about-tabs {
  display: flex; gap: 0; flex: 1; justify-content: center;
}
.about-tab {
  border: none; border-bottom: 3px solid transparent;
  background: transparent; color: var(--ink-inv); opacity: 0.6;
  padding: 4px 16px; font-size: 11px; font-weight: 600; line-height: 1.2;
  text-align: center;
}
.about-tab .en-lbl {
  font-family: var(--font-num); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
}
.about-tab:hover { opacity: 1; background: rgba(246,244,239,0.1); }
.about-tab.active { opacity: 1; border-bottom-color: var(--th-red); background: rgba(246,244,239,0.08); }

/* Show/hide panes inside the About overlay */
.about-pane { display: none; }
.about-pane.active { display: block; }
.about-pane[data-about-pane="research"] {
  padding: 0; max-width: 100%; overflow: hidden;
}
.research-scroll {
  max-width: 860px; margin: 0 auto; width: 100%;
  padding: 28px clamp(16px, 4vw, 48px) 48px;
  overflow-y: auto; max-height: calc(100vh - var(--header-h));
}

/* ── Research paper panel ─────────────────────────────────────────────────── */
.research-svg { width: 100%; height: auto; max-width: 760px; display: block; margin: 0 auto; }

.rp-hero {
  text-align: center; padding: 24px 0 32px;
  border-bottom: 1px solid var(--rule); margin-bottom: 28px;
}
.rp-hero-eyebrow {
  font-family: var(--font-num); font-size: 10px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-low);
  margin-bottom: 12px;
}
.rp-hero-title {
  font-size: clamp(20px, 3vw, 28px); font-weight: 700; color: var(--th-navy);
  line-height: 1.25; margin-bottom: 16px;
}
.rp-hero-meta {
  font-size: 13px; color: var(--ink-mid); line-height: 1.6;
}
.rp-hero-meta code { font-family: var(--font-num); font-size: 12px; }
.rp-abstract {
  margin-top: 20px; padding: 16px 20px; background: var(--well-dim);
  border-left: 3px solid var(--th-navy); text-align: left;
}
.rp-abstract p { font-size: 13.5px; line-height: 1.6; color: var(--ink); }

.rp-section {
  margin-bottom: 32px;
}
.rp-section h2 {
  font-size: 18px; font-weight: 700; color: var(--th-navy);
  margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.rp-section h3 {
  font-size: 14px; font-weight: 600; color: var(--ink); margin: 16px 0 8px;
}
.rp-section p {
  font-size: 14px; line-height: 1.65; color: var(--ink); margin: 10px 0;
}
.rp-lead { font-size: 14.5px; color: var(--ink-mid); }

.rp-figure {
  margin: 16px 0; padding: 12px; background: var(--well-dim);
  border: 1px solid var(--rule); overflow-x: auto;
}

/* Pipeline cards */
.rp-pipeline-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px; margin: 16px 0;
}
.rp-pipeline-card {
  display: flex; gap: 12px; background: var(--well);
  border: 1px solid var(--rule); padding: 12px;
}
.rp-pipeline-num {
  width: 28px; height: 28px; flex: none; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-num); font-weight: 700; font-size: 13px; color: #fff;
  background: var(--th-navy);
}
.rp-pipeline-body { flex: 1; min-width: 0; }
.rp-pipeline-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.rp-pipeline-agency { font-size: 12px; color: var(--ink-mid); margin: 2px 0; }
.rp-pipeline-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.rp-tag {
  font-family: var(--font-num); font-size: 10px; padding: 2px 6px;
  background: var(--well-dim); color: var(--ink); border: 1px solid var(--rule);
}
.rp-tag-mono { font-weight: 600; color: var(--rain); }
.rp-pipeline-note { font-size: 12px; color: var(--ink-mid); margin-top: 4px; line-height: 1.4; }
.rp-pipeline-link {
  display: inline-block; margin-top: 6px; font-family: var(--font-num);
  font-size: 11px; color: var(--rain); text-decoration: none;
}
.rp-pipeline-link:hover { text-decoration: underline; }
.rp-jaxa-note {
  margin-top: 12px; padding: 10px 12px; background: var(--well-dim);
  border-left: 3px solid #1565C0; font-size: 12.5px; color: var(--ink-mid);
}

/* Limitations + warning */
.rp-limitations { padding-left: 20px; }
.rp-limitations li {
  font-size: 13.5px; color: var(--ink); margin: 6px 0; line-height: 1.5;
}
.rp-warning {
  margin-top: 16px; padding: 12px 16px; background: rgba(165,25,49,0.08);
  border-left: 4px solid var(--th-red); font-size: 13px; font-weight: 600;
  color: var(--th-red); line-height: 1.5;
}

/* Citations */
.rp-citations { padding-left: 20px; }
.rp-citations li {
  font-size: 12.5px; color: var(--ink-mid); margin: 5px 0; line-height: 1.45;
}

/* Download section */
.rp-download-section {
  background: var(--well); border: 1px solid var(--rule); padding: 24px;
}
.rp-download-actions {
  display: flex; align-items: center; gap: 16px; margin: 20px 0;
  flex-wrap: wrap;
}
.rp-download-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 24px; background: var(--th-navy); color: var(--ink-inv);
  border: none; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background 0.15s;
}
.rp-download-btn:hover { background: #1a1640; }
.rp-download-icon { font-size: 20px; }
.rp-download-meta { font-size: 12px; color: var(--ink-mid); font-family: var(--font-num); }

.rp-dict { margin-top: 20px; }
.rp-dict-table {
  width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px;
}
.rp-dict-table th, .rp-dict-table td {
  border: 1px solid var(--rule); padding: 6px 10px; text-align: left;
}
.rp-dict-table th { background: var(--well-dim); font-weight: 600; color: var(--ink); }
.rp-dict-table td code { font-family: var(--font-num); font-size: 11.5px; color: var(--rain); }

.rp-api-ref { margin-top: 20px; }
.rp-api-ref pre {
  background: var(--well-dim); border: 1px solid var(--rule);
  padding: 12px 14px; overflow-x: auto; margin-top: 8px;
}
.rp-api-ref code { font-family: var(--font-num); font-size: 12px; line-height: 1.6; }

.rp-footer {
  margin-top: 32px; padding: 16px 0; border-top: 1px solid var(--rule);
  font-size: 11px; color: var(--ink-low); text-align: center; line-height: 1.5;
}

@media (max-width: 860px) {
  .research-scroll { max-width: 100%; }
  .rp-pipeline-grid { grid-template-columns: 1fr; }
  .rp-download-section { padding: 16px; }
}

/* ── Universal place search ─────────────────────────────────────────────────── */
.searchbox {
  position: relative; display: flex; align-items: center;
  padding: 6px 6px 6px 0;
}
.searchbox input {
  width: 180px; font-size: 12.5px; font-weight: 500;
  background: var(--well); color: var(--ink);
  border: 1px solid rgba(246,244,239,0.5);
  padding: 5px 26px 5px 8px;
}
.searchbox input:focus {
  outline: 2px solid #E8B33C;
  outline-offset: -1px;
  width: 240px;
}
.searchbox #search-clear {
  position: absolute; right: 4px;
  border: none; background: transparent; color: var(--ink-inv);
  opacity: 0.5; font-size: 11px; padding: 2px 6px; cursor: pointer;
}
.searchbox #search-clear:hover { opacity: 1; }
.search-results {
  position: absolute; top: 100%; right: 0; z-index: 6000;
  width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--rule-strong);
  border-top: 2px solid var(--th-navy);
  box-shadow: 0 6px 18px rgba(0,0,0,0.12) !important;
}
.search-result {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 8px 12px; cursor: pointer;
  border-bottom: 1px solid var(--rule);
}
.search-result:hover, .search-result.hover, .search-result.selected {
  background: var(--well-dim);
}
.search-result.selected { border-left: 3px solid var(--th-navy); }
.sr-icon { font-size: 16px; flex: none; line-height: 1.2; }
.sr-body { flex: 1; min-width: 0; }
.sr-name { font-weight: 600; font-size: 13.5px; color: var(--ink); display: block; }
.sr-ctx { font-family: var(--font-num); font-size: 10px; color: var(--ink-mid); display: block; margin-top: 1px; }
.search-empty {
  padding: 16px; text-align: center; font-size: 13px; color: var(--ink-mid);
}

/* ── Place detail card (left rail) ──────────────────────────────────────────── */
.place-card {
  overflow-y: auto; flex: 1; min-height: 0;
  background: var(--paper);
}
.place-loading {
  padding: 20px; text-align: center; font-size: 13px; color: var(--ink-mid);
}
.place-close {
  position: absolute; top: 6px; right: 8px;
  border: none; background: transparent; font-size: 14px;
  cursor: pointer; opacity: 0.5; z-index: 10;
}
.place-close:hover { opacity: 1; }
.place-header {
  padding: 12px 14px 8px; border-bottom: 1px solid var(--rule-strong);
  background: var(--well);
}
.place-name { font-weight: 700; font-size: 16px; color: var(--ink); }
.place-type {
  font-family: var(--font-num); font-size: 10.5px;
  color: var(--ink-mid); margin-top: 2px;
  letter-spacing: 0.04em;
}
.place-section {
  padding: 10px 14px; border-bottom: 1px solid var(--rule);
}
.place-score-band {
  display: flex; align-items: center; gap: 12px;
  border-left: 4px solid; padding-left: 10px;
}
.place-score-val { font-family: var(--font-num); font-size: 24px; font-weight: 700; }
.place-score-label { font-weight: 600; font-size: 14px; }
.place-score-detail {
  font-family: var(--font-num); font-size: 11px; color: var(--ink-mid);
  line-height: 1.5; flex: 1;
}
.place-fc {
  font-family: var(--font-num); font-size: 22px; font-weight: 700;
}
.place-station {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  cursor: pointer; font-size: 12.5px;
}
.place-station:hover { background: var(--well-dim); }
.place-station .badge { flex: none; }
.place-station .ps-rain {
  width: 8px; height: 8px; flex: none;
}
.place-station .ps-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-station .ps-val {
  font-family: var(--font-num); font-size: 11.5px; font-weight: 600;
  flex: none; color: var(--ink);
}
.place-empty {
  font-size: 12px; color: var(--ink-low); padding: 6px 0; font-style: italic;
}
.place-hist {
  display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12.5px;
}
.hist-year {
  font-family: var(--font-num); font-size: 10px; font-weight: 700; color: #fff;
  padding: 2px 5px; flex: none;
}
.hist-name { color: var(--ink-mid); }
.place-blurb {
  font-size: 12.5px; color: var(--ink-mid); line-height: 1.5; font-style: italic;
}
.place-warning {
  padding: 10px 14px; font-size: 11px; color: var(--ink-low);
  border-top: 1px solid var(--rule); background: var(--well-dim);
  line-height: 1.45;
}

@media (max-width: 860px) {
  .searchbox { display: none; }
  .search-results { width: calc(100vw - 20px); right: 10px; }
}
