:root {
  --bg: #0a0f1a;
  --panel: rgba(12, 18, 31, 0.9);
  --panel-solid: #0e1524;
  --line: #1c2740;
  --text: #dbe4f2;
  --muted: #7f8da6;
  --amber: #f5b942;
  --amber-dim: rgba(245, 185, 66, 0.25);
  --past: #9cc4ff;
  --interp: #5a7fb3;
  --nowcast: #5fd3c4;
  --future: #b89cff;
  --a: #e6edf7;
  --b: #e6edf7;
  --radius: 10px;
  --font-ui: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 var(--font-ui);
  display: grid;
  grid-template-rows: auto auto 1fr auto;   /* header, description strip, panes, timeline */
  height: 100vh;
  overflow: hidden;
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
button, select, input { font: inherit; color: inherit; }
select {
  background: #121a2b;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}
select:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 1px;
}

/* top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-solid);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-mark {
  width: 10px; height: 10px; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #7cf2b1, #1f9c5c 70%);
  box-shadow: 0 0 12px #2fd37c88;
  align-self: center;
}
.brand-name { font-weight: 600; letter-spacing: 0.01em; }
.brand-sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.about {
  display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; align-items: baseline;
  padding: 7px 16px 8px; border-bottom: 1px solid var(--line);
  background: var(--panel-solid); font-size: 12.5px; color: var(--muted); line-height: 1.4;
}
.about b { color: var(--amber); font-weight: 600; font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; }
.about span { color: var(--text); }
.topbar-controls { display: flex; align-items: center; gap: 14px; }
.field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.seg button {
  background: transparent; border: 0; padding: 5px 11px; color: var(--muted); cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: #1a2338; color: var(--text); }
.readout { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.readout .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }

/* panes */
.panes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px;
  background: var(--line); min-height: 0;
}
.panes[data-view="a"] { grid-template-columns: 1fr; }
.panes[data-view="b"] { grid-template-columns: 1fr; }
.panes[data-view="a"] .pane[data-pane="b"],
.panes[data-view="b"] .pane[data-pane="a"] { display: none; }
.pane { position: relative; background: var(--bg); min-height: 0; }
.map { position: absolute; inset: 0; }
.maplibregl-ctrl-attrib { display: none; }

.card {
  position: absolute; top: 12px; left: 12px; width: 300px;
  background: var(--panel); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 30px #0008;
  z-index: 2;
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.pane-letter {
  font-family: var(--font-mono); font-weight: 600; font-size: 13px;
  width: 24px; height: 24px; display: grid; place-items: center;
  border-radius: 6px; background: #1a2338; color: var(--amber);
}
.card-head .preset { flex: 1 1 0; min-width: 0; font-weight: 500; }   /* may shrink: keeps the collapse button in view */
.card-head .collapse {
  flex: 0 0 auto; width: 26px; height: 26px; padding: 0; cursor: pointer;
  background: transparent; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); font-size: 13px; line-height: 1;
}
.card-head .collapse:hover { color: var(--text); border-color: #2c3b5c; }
.card.collapsed .card-body { display: none; }   /* title and the two stats lines stay */
.card-body { padding: 6px 12px 8px; display: grid; gap: 3px; }
.row {
  display: grid; grid-template-columns: 118px 1fr auto; align-items: center; gap: 8px;
  font-size: 12.5px; min-height: 28px;
}
.row > span { color: var(--muted); }
.row select { width: 100%; min-width: 0; font-size: 12px; padding: 3px 6px; }
.row input[type="range"] { width: 100%; accent-color: var(--amber); }
.row output { font-size: 11.5px; color: var(--muted); min-width: 32px; text-align: right; }
.row.check { grid-template-columns: 1fr auto; }
.row.check input { accent-color: var(--amber); width: 15px; height: 15px; }
.card-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px;
  padding: 8px 12px 10px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--muted);
}
.card-stats .big { grid-column: 1 / -1; color: var(--text); font-size: 12.5px; font-weight: 600; }
.card-stats span:last-child { grid-column: 1 / -1; color: var(--amber); }
.card-stats span:last-child:empty { display: none; }

/* timeline */
.timeline {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel-solid);
}
.transport { display: flex; align-items: center; gap: 6px; }
.play {
  width: 38px; height: 38px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--amber); color: #1a1200; display: grid; place-items: center;
}
.play svg path { fill: currentColor; }
.play .ico-pause { display: none; }
.play.playing .ico-play { display: none; }
.play.playing .ico-pause { display: block; }
.ghost {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line);
  background: transparent; color: var(--text); cursor: pointer; font-size: 18px; line-height: 1;
}
.ghost:hover { background: #1a2338; }
.transport select { font-size: 12px; }

.track-wrap { min-width: 0; position: relative; }
.track-legend {
  display: flex; gap: 14px; font-size: 10.5px; color: var(--muted);
  position: absolute; top: -2px; left: 0;
}
.lg-a::before, .lg-b::before { content: ""; display: inline-block; width: 2px; height: 9px; background: var(--text); margin-right: 5px; vertical-align: -1px; }
.lg-kind .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.sw-past { background: var(--past); }
.sw-interp { background: var(--interp); }
.sw-nowcast { background: var(--nowcast); }
.sw-future { background: var(--future); }
.card { max-height: calc(100% - 24px); overflow: auto; }
#track { display: block; width: 100%; height: 72px; cursor: pointer; touch-action: none; }

.time { text-align: right; min-width: 170px; }
#time-main { font-size: 22px; font-weight: 600; letter-spacing: 0.02em; color: var(--amber); }
#time-sub { font-size: 11px; color: var(--muted); }

.attrib {
  position: fixed; right: 8px; bottom: 104px; font-size: 10px; color: #6b7891;
  background: #0a0f1acc; padding: 2px 6px; border-radius: 4px; z-index: 3;
}
.attrib a { color: inherit; }

@media (max-width: 1100px) {
  .brand-sub { display: none; }
  .card { width: 260px; }
  .row { grid-template-columns: 100px 1fr auto; }
}
@media (max-width: 800px) {
  .panes { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  .timeline { grid-template-columns: auto 1fr; }
  .time { grid-column: 1 / -1; text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  .brand-mark { box-shadow: none; }
}

/* shown when the playhead is outside a pane's frame window */
.nodata {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  z-index: 2; pointer-events: none; text-align: center;
  padding: 12px 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px);
  color: var(--text); font-size: 13px; max-width: 320px;
}
.nodata b { display: block; color: var(--amber); font-family: var(--font-mono); font-size: 15px; margin-bottom: 4px; }
.nodata span { color: var(--muted); font-size: 12px; }

/* demo switcher in the top bar */
.brand-name { text-decoration: none; color: var(--text); }
.demos { display: inline-flex; gap: 1px; margin-left: 6px; border: 1px solid var(--line); border-radius: 7px; padding: 2px; white-space: nowrap; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.demos::-webkit-scrollbar { display: none; }
.demos a { color: var(--muted); text-decoration: none; font-size: 12px; padding: 3px 7px; border-radius: 5px; white-space: nowrap; }
.brand-name { white-space: nowrap; }
@media (max-width: 1700px) { .brand-sub { display: none; } .demos a { padding: 3px 5px; font-size: 11px; } }
@media (max-width: 1250px) { .demos a { padding: 3px 5px; font-size: 11px; } }
.demos a.on { background: #1a2338; color: var(--text); }
.demos a:hover { color: var(--text); }

/* warm-up strip: informational, small, at the top of the pane; the pane keeps loading behind it */
.nodata.warming {
  top: 10px; transform: translateX(-50%); padding: 6px 12px; max-width: 90%;
  background: rgba(70, 52, 8, 0.92); border-color: #b08a2e; font-size: 12px; white-space: nowrap;
}
.nodata.warming b { display: inline; color: #ffd970; font-size: 12px; margin: 0 8px 0 0; }
.nodata.warming span { color: #e8d9a8; }
