/* Earth-2 Skies. Tokens and rules: DESIGN.md. */

:root {
  --bg: #ffffff;
  --surface: #f1f4f2;
  --surface-2: #e4e9e6;
  --ink: #121614;
  --muted: #4e5853;
  --faint: #7d8782;
  --line: #d5dcd8;
  --focus: #3f6e00;
  --accent: #76b900;
  --accent-ink: #3f6e00;
  --on-accent: #ffffff;
  --model-ink: #3f6e00;

  /* The map and its overlays stay dark in both themes. */
  --hero-bg: #070908;
  --hero-fg: #f1f5f2;
  --hero-muted: #9fb0a6;
  --hero-accent: #76b900;
  --hero-panel: #0c0f0dd9;
  --hero-line: #2c3832;
  --grid: #18241c;
  --globe: #0e1411;
  --forecast: var(--hero-accent);
  --observed: #f1f5f2;
  --zone-ph: #e8c547;
  --ring-kr: #9ecbf0;
  --scrim: #070908b3;  /* behind dialogs, both themes */

  /* Forecast map colour classes, lowest first (the map is dark in both themes). */
  --ramp-wind: #4f1d6b, #8c2a6e, #c8443f, #ee8a3c, #fde0c2;
  --ramp-gale: #4f1d6b, #8c2a6e, #c8443f, #ee8a3c;
  --ramp-rain-kma: #00c8ff, #009bf5, #004af5, #00ff00, #00be00, #008c00, #005a00, #ffff00, #ffdc1f, #f9cd00, #e0b900, #ccaa00,
    #ff6600, #ff3200, #d20000, #b40000, #e0a9ff, #c969ff, #b329ff, #9300e4, #b3b4de, #4c4eb1, #000390;
  --ramp-rain-pagasa: #9fd8f5, #2f7fd8, #f2d23a, #f08a24, #d7263d;
  /* Enhanced IR cloud-top classes, warmest first: -31, -42, -54, -64, -70, -76, -81 °C. */
  --ramp-eir: #3d5a8a, #2f7fd0, #38bcd6, #e9f4f6, #f2a3c4, #cf3f8f, #6e1a52;

  --display: "Barlow Semi Condensed", "Noto Sans KR", sans-serif;
  --sans: "Barlow", "Noto Sans KR", sans-serif;
  --mono: "JetBrains Mono", monospace;
  --radius: 4px;
  --panel-w: 380px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e0d; --surface: #151917; --surface-2: #1d2220; --ink: #e9eeea; --muted: #9aa59f;
    --faint: #5f6b65; --line: #26302b; --focus: #76b900; --accent-ink: #76b900; --on-accent: #0c0e0d;
    --model-ink: #76b900; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0e0d; --surface: #151917; --surface-2: #1d2220; --ink: #e9eeea; --muted: #9aa59f;
  --faint: #5f6b65; --line: #26302b; --focus: #76b900; --accent-ink: #76b900; --on-accent: #0c0e0d;
  --model-ink: #76b900; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.45 var(--sans); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.console { display: grid; grid-template-columns: 1fr var(--panel-w); height: 100dvh; }
.console.room { display: block; height: auto; }
.console.room > .map-wrap, .console.room > .panel { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Tap targets: small-looking controls get an invisible 44 px hit area centred on them. */
.hit { position: relative; }
.hit::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }

/* Map */
.map-wrap { position: relative; background: var(--hero-bg); color: var(--hero-fg); min-height: 0; }
#map, #map-b { position: absolute; inset: 0; }
#map-b { pointer-events: none; clip-path: inset(0 0 0 50%); }
.maplibregl-ctrl-attrib { display: none; }

/* Swipe: satellite left of the divider, forecast right of it. */
.swipe { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--hero-fg); pointer-events: none; }
/* The handle stays above the map, so it can always be grabbed. */
.swipe-handle { position: absolute; top: 50%; left: 1px; z-index: 1; display: grid; place-items: center; width: 44px; height: 44px; transform: translate(-50%, -50%);
  border: 2px solid var(--hero-fg); border-radius: 50%; background: var(--hero-panel); color: var(--hero-fg); cursor: ew-resize; pointer-events: auto; touch-action: none; }
.swipe-handle svg { width: 22px; height: 22px; }

.map-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; }
.map-tools { display: flex; gap: 8px; margin-left: auto; }
.tool-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 14px; background: var(--hero-panel);
  border: 1px solid var(--hero-line); border-radius: var(--radius); color: var(--hero-fg); font-weight: 600; cursor: pointer; pointer-events: auto; }
.tool-btn svg { width: 20px; height: 20px; }
.tool-btn[aria-expanded="true"] { box-shadow: inset 0 -2px 0 var(--hero-fg); }
.seg { display: flex; background: var(--hero-panel); border: 1px solid var(--hero-line); border-radius: var(--radius); pointer-events: auto; }
.seg button { min-height: 44px; min-width: 44px; padding: 0 14px; border: 0; background: none; color: var(--hero-muted); font-weight: 600; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--hero-line); }
.seg button[aria-pressed="true"] { color: var(--hero-fg); box-shadow: inset 0 -2px 0 var(--hero-fg); }
.seg button:disabled { color: var(--hero-muted); text-decoration: line-through; cursor: not-allowed; }

.map-note { position: absolute; top: calc(var(--top-h, 56px) + 12px); left: 12px; max-width: min(360px, calc(100% - 24px)); padding: 8px 12px; background: var(--hero-panel);
  border: 1px solid var(--hero-line); border-radius: var(--radius); color: var(--hero-fg); font-size: 13px; }

/* Layers panel */
.layers { position: absolute; top: calc(var(--top-h, 56px) + 8px); right: 12px; width: 280px;
  /* Stops above the time bar, so its rows never sit over the slider. */
  max-height: calc(100% - var(--top-h, 56px) - var(--bar-h, 76px) - 36px); overflow-y: auto; padding: 0 12px 8px;
  background: var(--hero-panel); border: 1px solid var(--hero-line); border-radius: var(--radius); color: var(--hero-fg); font-size: 14px; color-scheme: dark; z-index: 2; }
.layers fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.layers fieldset + fieldset { margin-top: 4px; border-top: 1px solid var(--hero-line); }
.layers legend { padding: 12px 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--hero-muted); }
.layers .seg { margin: 4px 0; width: fit-content; }
.layers .hint { color: var(--hero-muted); font-size: 13px; }
.layers .field-off { margin: 0 0 4px; }
.opt { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.opt input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.opt:has(input:disabled) { color: var(--hero-muted); cursor: not-allowed; }

.map-bottom { position: absolute; left: 12px; right: 12px; bottom: calc(var(--bar-h, 76px) + 24px); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; pointer-events: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 6px 10px; max-width: 100%;
  background: var(--hero-panel); border: 1px solid var(--hero-line); border-radius: var(--radius); font-size: 13px; color: var(--hero-fg); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 18px; height: 0; border-top: 2px solid; }
.sw-forecast { border-color: var(--forecast); }
.sw-observed { border-color: var(--observed); }
.sw-after { border-color: var(--observed); border-top-style: dashed; }
.sw-mean { border-top: 3px dotted var(--forecast); }
.sw-run { border-top-width: 1px; border-color: var(--forecast); opacity: .65; }
.sw-zone { border-color: var(--zone-ph); }

/* One-line key: the colour classes as a strip, edge values under it, the unit after it. */
.field-key { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 4px 10px 16px 18px; background: var(--hero-panel);
  border: 1px solid var(--hero-line); border-radius: var(--radius); font-size: 12px; color: var(--hero-fg); pointer-events: auto; }
.fk-scale { position: relative; display: block; width: clamp(150px, 30vw, 260px); }
.fk-bar { display: flex; height: 8px; }
.fk-bar i { flex: 1; }
.fk-labels { position: absolute; left: 0; right: 0; top: 10px; }
.fk-labels b { position: absolute; transform: translateX(-50%); font: 500 12px/1 var(--mono); white-space: nowrap; }
.fk-unit { color: var(--hero-muted); white-space: nowrap; }

.storm-label { pointer-events: none; padding: 2px 6px; background: var(--hero-panel); border: 1px solid var(--hero-line); border-radius: var(--radius);
  color: var(--hero-fg); font: 600 13px/1.3 var(--sans); white-space: nowrap; transform: translate(14px, -50%); }
.storm-label b { font-family: var(--display); font-size: 15px; }

/* Time bar */
.timebar { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; align-items: center; gap: 4px; padding: 6px 12px 6px 6px;
  background: var(--hero-panel); border: 1px solid var(--hero-line); border-radius: var(--radius); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0; border: 0; border-radius: var(--radius);
  background: none; color: inherit; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }
.play .i-pause, .play[aria-pressed="true"] .i-play { display: none; }
.play[aria-pressed="true"] .i-pause { display: block; }
.time-track { flex: 1; min-width: 0; padding-left: 8px; }
.time-read, .time-axis { pointer-events: none; }
.time-read { display: flex; gap: 10px; align-items: baseline; font-size: 13px; }
.time-kind { font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; color: var(--hero-muted); }
.time-kind.forecast { color: var(--hero-accent); }
.range-wrap { position: relative; }
#time { display: block; width: 100%; height: 44px; margin: -6px 0; accent-color: var(--hero-fg); cursor: pointer; }
.now-mark { position: absolute; top: 8px; bottom: 8px; width: 2px; background: var(--hero-accent); pointer-events: none; transform: translateX(-1px); }
.time-axis { position: relative; display: flex; justify-content: space-between; font-size: 12px; color: var(--hero-muted); }
.axis-now { position: absolute; transform: translateX(-50%); color: var(--hero-accent); font-weight: 600; }
.time-axis.no-obs > span:first-child { visibility: hidden; }
.time-axis.no-obs .axis-now { transform: none; }

/* Panel (overview) */
.panel { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); background: var(--bg); }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; }
h1 { font-size: 26px; line-height: 1.1; }
h2 { font-size: 20px; }
.cycle { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.theme { color: var(--muted); border: 1px solid var(--line); background: var(--surface); }
.theme .i-moon { display: none; }
:root[data-theme="light"] .theme .i-sun { display: none; }
:root[data-theme="light"] .theme .i-moon { display: block; }

.hero { position: relative; padding: 16px; background-color: var(--hero-bg); color: var(--hero-fg); border-top: 3px solid var(--hero-accent); border-radius: var(--radius);
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px; background-position: -1px -1px; }
.eyebrow { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--hero-muted); }
.hero h2 { font-size: 28px; margin-top: 6px; }
.hero h2 .local { color: var(--hero-muted); font-weight: 600; }
.hero dl, .lead dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0 0; font-size: 13px; }
.hero dt { color: var(--hero-muted); }
.hero dd { margin: 0; }
.hero dd .num, .storm-row .meta .num { white-space: nowrap; }
.lead { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hero-line); }
.lead .lead-when { color: var(--hero-fg); font-size: 13px; letter-spacing: 0; text-transform: none; }
.lead dl { margin-top: 8px; }
.chart-title { margin: 14px 0 0; font-size: 13px; font-weight: 600; }
.chart { display: block; width: 100%; height: auto; margin-top: 4px; }
.chart text { fill: var(--hero-muted); font: 500 12px var(--mono); }
.chart .c-grid { stroke: var(--hero-line); }
.chart .c-run { fill: none; stroke: var(--forecast); stroke-opacity: .65; stroke-width: 1.25; }
.chart .c-real { fill: none; stroke: var(--observed); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .c-obs { fill: var(--observed); }
.chart .c-real-dot { fill: var(--hero-bg); stroke: var(--observed); stroke-width: 1.5; }
.chart .c-cursor { stroke: var(--hero-fg); stroke-width: 1; }
.chart .c-mean { fill: none; stroke: var(--forecast); stroke-width: 2; }
.chart-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 0; font-size: 13px; }
.chart-key span { display: inline-flex; align-items: center; gap: 6px; }
.chart-key .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--observed); }
.hero .credit { margin: 12px 0 0; font-size: 13px; color: var(--hero-muted); }

.storm-row { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.storm-row + .storm-row { margin-top: 8px; }
.basin + .basin { margin-top: 16px; }
.basin-name { margin: 0 0 8px; font: 600 12px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.storm-row h3 { font-size: 20px; }
.storm-row .local { color: var(--muted); font-weight: 600; }
.storm-row .meta { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.storm-row .row-num { grid-row: 1; grid-column: 2; font: 700 18px/1 var(--mono); color: var(--ink); align-self: center; }
.storm-row[aria-current="true"] { border-color: var(--ink); }

.hint { color: var(--muted); }

.replays h2 { font-size: 20px; margin-bottom: 8px; }
.replay-row { display: flex; flex-direction: column; justify-content: center; min-height: 44px; padding: 8px 12px; color: var(--ink); text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.replay-row + .replay-row { margin-top: 8px; }
.replay-row .meta { font-size: 13px; color: var(--muted); }
.replay-row[aria-current="page"] { border-color: var(--ink); }

.official { padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.official p { margin: 6px 0 8px; color: var(--muted); font-size: 13px; }
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; margin: 4px 4px 0 0; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg); color: var(--ink); font-weight: 600; text-decoration: none; }
.btn svg { width: 18px; height: 18px; color: var(--muted); }

.credits { font-size: 13px; color: var(--muted); }
.credits p { margin: 0 0 4px; }

/* Control room: top bar, tile row, pane grid, time bar. From 1,100 px it all fits one screen. */
.room-ui { position: relative; display: grid; height: 100dvh; background: var(--bg);
  grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 76px minmax(0, 1fr) auto;
  grid-template-areas: "top links" "tiles tiles" "panes panes" "time time"; }
/* Tight gaps and button padding keep the top bar and the official links on one row from 1,100 px, with two storms. */
.topbar { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.topbar > * { flex: none; }
.topbar .seg button { padding: 0 9px; }
.topbar .tool-btn { padding: 0 10px; }
.brand h1 { font-size: 20px; }
.brand .cycle { margin: 0; font-size: 12px; }
.room-tools { display: flex; gap: 8px; }
.topbar .tool-btn { background: var(--surface); border-color: var(--line); color: var(--ink); }
.topbar .tool-btn[aria-expanded="true"] { box-shadow: inset 0 -2px 0 var(--ink); }
.official-links { grid-area: links; display: flex; flex-wrap: wrap; align-items: center; gap: 0 6px; margin: 0; padding: 8px 16px 8px 0;
  border-bottom: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.official-links a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: var(--ink); font-weight: 600; white-space: nowrap; }
.official-links svg { width: 16px; height: 16px; color: var(--muted); }

/* Tile row: six equal tiles, each a caps label, one number and one short line. A tap opens its dialog. */
.tiles { grid-area: tiles; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 8px 16px 0; }
.tile { display: flex; flex-direction: column; justify-content: center; min-width: 0; padding: 4px 10px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }
.tile:hover { border-color: var(--faint); }
.tile > span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tile-label { font: 600 12px/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tile-main { font: 700 26px/1.1 var(--mono); font-variant-numeric: tabular-nums; }
.tile-main .unit { font-size: 13px; font-weight: 500; }
.tile-sub { font-size: 12px; line-height: 1.3; color: var(--muted); font-variant-numeric: tabular-nums; }
.unit { margin-left: .2em; }

/* Tile dialog: a centred panel from 768 px, a bottom sheet on phones. */
.sheet { width: min(480px, calc(100% - 32px)); max-width: none; max-height: 80dvh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); }
.sheet[open] { display: flex; }
.sheet::backdrop { background: var(--scrim); }
.sheet-in { display: flex; flex-direction: column; flex: 1; min-width: 0; min-height: 0; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex: none; padding: 8px 4px 8px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 20px; line-height: 1.2; margin-top: 4px; }
.sheet-head .icon-btn { color: var(--muted); }
.dlg-when { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.sheet-body { overflow-y: auto; padding: 4px 16px 16px; font-size: 14px; }
.sheet-body h3 { margin: 14px 0 6px; font: 600 12px/1.3 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sheet-body h3 .num { letter-spacing: 0; text-transform: none; }
.sheet-body dl { display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr); gap: 6px 12px; margin: 12px 0 0; }
.sheet-body h3 + dl { margin-top: 0; }
.sheet-body dt { color: var(--muted); }
.sheet-body dd { margin: 0; }
.sheet-body .note { margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.sheet-body .credit { margin: 14px 0 0; font-size: 13px; color: var(--model-ink); }

.pane-tabs { grid-area: tabs; display: none; }
.panes { grid-area: panes; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 8px; min-height: 0; padding: 8px 16px; }
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
/* Above the pane body, so the header buttons' hit areas reach over its top edge. */
.pane-head { position: relative; z-index: 1; display: flex; align-items: center; gap: 4px; flex: none; height: 36px; padding-left: 10px; touch-action: pan-y; }
.pane-title { margin: 0 4px 0 0; font: 600 13px/1.2 var(--sans); color: var(--ink); white-space: nowrap; }
.pane-when { flex: 1; min-width: 0; overflow: hidden; text-align: right; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; color: var(--muted); }
.pane-btn { display: inline-grid; place-items: center; flex: none; min-width: 44px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.pane-btn[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
.pane-btn.icon { width: 44px; height: 36px; padding: 0; border: 0; background: none; box-shadow: none; }
.pane-btn.icon svg { width: 18px; height: 18px; }
.pane-btn .i-min, .pane-btn[aria-pressed="true"] .i-max { display: none; }
.pane-btn[aria-pressed="true"] .i-min { display: block; }
.pane-head .seg { flex: 1; min-width: 0; flex-wrap: nowrap; }
.pane-head .seg button { min-height: 28px; padding: 0 8px; font-size: 12px; white-space: nowrap; }
.pane-body { position: relative; flex: 1; min-height: 0; background: var(--hero-bg); color: var(--hero-fg); }
.pane-map, .pane-body #map, .pane-body #map-b { position: absolute; inset: 0; }
.pane-empty { position: absolute; inset: 0; display: grid; place-items: center; place-content: center; gap: 4px; margin: 0; padding: 16px; text-align: center; font-size: 13px; color: var(--hero-fg); pointer-events: none; }
.room-ui .swipe-handle { top: 50%; }
/* With Swipe on, the Satellite pane's empty-state text sits top left, left of the divider and clear of the handle. */
.swipe:not([hidden]) ~ .pane-empty { right: auto; bottom: auto; width: var(--swipe-at, 50%); place-items: start; place-content: start; text-align: left; }
/* The key: one line under the map. Map colours sit on the map's own dark background, so they read in both themes. */
/* A key longer than the pane scrolls sideways inside the footer. */
.pane-key { display: flex; align-items: center; gap: 12px; flex: none; height: 28px; padding: 0 10px 0 14px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none;
  white-space: nowrap; font-size: 12px; color: var(--ink); }
.pane-key > * { flex: none; }
.pane-key .field-key { align-self: flex-start; min-height: 0; padding: 4px 0 0; gap: 8px; background: none; border: 0; color: inherit; }
.pane-key .fk-scale { flex: none; width: 150px; }
.pane-key .fk-bar { outline: 2px solid var(--hero-bg); background: var(--hero-bg); }
.pane-key .fk-unit { color: var(--muted); }
.lg { display: inline-flex; align-items: center; gap: 12px; }
.lg span, .pane-key > span { display: inline-flex; align-items: center; gap: 6px; }
.pane-key .sw { box-shadow: 0 0 0 3px var(--hero-bg); background: var(--hero-bg); }
.pane-key .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--observed); box-shadow: 0 0 0 3px var(--hero-bg); }
.key-note { color: var(--muted); }
.room-ui .layers { top: calc(var(--room-top, 64px) + 4px); right: 16px; max-height: calc(100% - var(--room-top, 64px) - var(--bar-h, 76px) - 24px); }
.room-ui .timebar { grid-area: time; position: static; margin: 0 16px 12px; background: var(--hero-bg); color: var(--hero-fg); }

/* Charts pane */
#body-charts .chart { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; }
.pt-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 36px; padding: 0 8px 0 10px; font-size: 13px; }
.pt-head .pane-btn { background: var(--hero-bg); border-color: var(--hero-line); color: var(--hero-fg); }
.pt-chart { position: absolute; left: 0; right: 0; top: 36px; bottom: 0; }
.chart .c-bar { fill: var(--forecast); fill-opacity: .65; }
.chart .c-label { fill: var(--hero-muted); font: 600 12px var(--sans); }

/* 768 to 1,099 px: two columns of panes at least 240 px tall; the page may scroll. */
@media (max-width: 1099px) {
  .room-ui { height: auto; min-height: 100dvh; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 76px 1fr auto;
    grid-template-areas: "top" "links" "tiles" "panes" "time"; }
  .official-links { padding-left: 16px; }
  /* Tiles keep their 26 px numbers whole: below about 900 px the row scrolls sideways. */
  .tiles { grid-template-columns: repeat(6, minmax(132px, 1fr)); overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 16px; scrollbar-width: none; }
  .tile { scroll-snap-align: start; }
  .panes { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(240px, 1fr)); }
}
/* Enlarged: one pane fills the grid. */
.panes.enlarged { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.panes.enlarged .pane:not(.on) { display: none; }

/* Plain segmented controls (top bar, Charts pane) */
.seg.plain { flex-wrap: wrap; width: fit-content; background: var(--surface); border-color: var(--line); }
.seg.plain button { color: var(--muted); }
.seg.plain button + button { border-left-color: var(--line); }
.seg.plain button[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

/* Phones: the map on top, the panel below it. */
@media (max-width: 767px) {
  .console { display: block; height: auto; }
  .map-wrap { height: 72dvh; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .panel-body { overflow: visible; }
  .seg button { padding: 0 10px; }
  .legend { display: none; }
  .time-read { flex-wrap: wrap; row-gap: 0; }
  /* The swipe handle sits above the keys and time bar, below the top bar. */
  .swipe-handle { top: max(35%, calc(var(--top-h, 56px) + 34px)); }
  .layers { left: 12px; right: 12px; width: auto; max-height: min(60dvh, calc(100% - var(--top-h, 56px) - var(--bar-h, 76px) - 36px)); }

  /* Control room: one pane at a time under a tab strip; the official links go below the time bar. */
  .room-ui { height: 100dvh; min-height: 0; grid-template-rows: auto 76px auto minmax(0, 1fr) auto auto;
    grid-template-areas: "top" "tiles" "tabs" "panes" "time" "links"; }
  .brand { display: none; }
  .topbar { padding: 8px; }
  .official-links { padding: 0 8px; border-bottom: 0; }
  /* The tile row scrolls sideways; the padding keeps the first and last tiles' edges in view. */
  .tiles { display: flex; padding: 8px 8px 0; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 8px; scrollbar-width: none; }
  .tile { flex: none; width: 132px; scroll-snap-align: start; }
  .sheet { width: 100%; margin: auto 0 0; border-width: 1px 0 0; border-radius: var(--radius) var(--radius) 0 0; }
  .pane-tabs { display: flex; overflow-x: auto; padding: 0 8px; border-bottom: 1px solid var(--line); scrollbar-width: none; touch-action: pan-y; }
  .pane-tabs button { flex: none; min-height: 44px; min-width: 44px; padding: 0 12px; border: 0; background: none; color: var(--muted); font-weight: 600; cursor: pointer; }
  .pane-tabs button[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }
  .panes, .panes.enlarged { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); padding: 8px; }
  .panes .pane:not(.on) { display: none; }
  .pane-btn[data-enlarge] { display: none; }
  .room-ui .timebar { margin: 0 8px 8px; }
}
