html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; overflow: hidden;
}
.tab-nav, .map-header { flex: 0 0 auto; }

.map-header {
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.map-header h1 { font-size: 1.3rem; font-weight: 700; color: var(--text-strong); }
.map-controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

.ctrl { display: flex; align-items: center; gap: 8px; }
.ctrl-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* Universe segmented control */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.seg button {
  background: var(--bg-card); color: var(--muted); border: none; cursor: pointer;
  font: inherit; font-size: 0.82rem; padding: 6px 12px; border-left: 1px solid var(--border);
}
.seg button:first-child { border-left: none; }
.seg button.active { background: var(--accent); color: #0f1117; font-weight: 600; }

/* View select */
select.view-select {
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 10px; font: inherit; font-size: 0.85rem; cursor: pointer;
}

/* Legend */
.legend { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.legend-bar { width: 160px; height: 12px; border-radius: 3px; }
.legend-txt { font-size: 0.72rem; color: var(--muted); }

.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--muted); }
.live-dot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-dim); }
.live-dot.live .dot { background: var(--up); box-shadow: 0 0 6px var(--up); }
.live-dot.extended .dot { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }

.map-area { flex: 1 1 auto; min-height: 0; position: relative; background: var(--bg-panel); overflow: hidden; }
#treemap { width: 100%; height: 100%; }
/* Vertical swipes over the canvas pan the PAGE; the chart keeps taps/hover. */
#treemap, #treemap > div, #treemap canvas { touch-action: pan-y; }
.map-loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.9rem;
}
@media (max-width: 720px) {
  /* Condensed header: title + color scale share the first row (legend jumps
     up via flex order), controls wrap below, everything tighter — the saved
     vertical space goes to the map. */
  .map-header { padding: 8px 12px; gap: 6px 10px; }
  .map-header h1 { font-size: 0.95rem; }
  .map-controls { order: 2; width: 100%; gap: 8px 12px; }
  .ctrl { gap: 6px; }
  .ctrl-label { font-size: 0.62rem; }
  .seg button { font-size: 0.72rem; padding: 4px 8px; }
  select.view-select { font-size: 0.75rem; padding: 4px 7px; }
  .legend { order: 1; margin-left: auto; gap: 6px; }
  .legend-bar { width: 84px; height: 10px; }
  .legend-txt { font-size: 0.62rem; }
  .live-dot { font-size: 0.62rem; }
  /* Mobile: normal page scroll (nav.js footer sits below the map) instead of
     the desktop fill-viewport layout. */
  body { overflow: auto; }
  .map-area { flex: 0 0 auto; height: min(72vh, 580px); }
}

/* Data age beside the connection dot (STO-270). The dot says the stream is up;
   this says when the tiles last changed, which is the question a reader has. */
.map-age { margin-left: 6px; font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--muted); cursor: help; }
.map-age.stale { color: var(--down); }
