:root {
  --bg: #0b1118;
  --panel: rgba(13, 20, 29, 0.94);
  --panel-solid: #0f1721;
  --sheet-bg: #0f141a;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9eef3;
  --muted: #8d9bab;
  --dim: #5f6d7c;
  --accent: #ff6a3d;
  --accent-soft: rgba(255, 106, 61, 0.16);
  --live: #5df0a4;
  --warn: #ffc466;
  --radius: 16px;
  --sheet-peek: 140px; /* first paint only; app.js measures the real detents */
  --sheet-half: 46vh;
  --sheet-overdraw: 160px; /* sheet extends this far below the screen so overshoot never shows a gap */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: #7fd0ff; }

#map { position: fixed; inset: 0; }
/* Map credits ("i"): collapsed by app.js after load; when opened, a solid readable pill. */
.maplibregl-ctrl-attrib { font-size: 11.5px; line-height: 1.45; color: #d3d9df; background: rgba(15, 20, 26, 0.96) !important; border: 1px solid rgba(255, 255, 255, 0.1); }
.maplibregl-ctrl-attrib a { color: #d3d9df; text-decoration: none; }
.maplibregl-ctrl-attrib.maplibregl-compact { margin: 0 12px 4px 0 !important; border-radius: 14px; min-height: 28px; color: #d3d9df !important; background: rgba(15, 20, 26, 0.96) !important; }
.maplibregl-ctrl-attrib.maplibregl-compact-show { box-sizing: border-box; max-width: calc(100vw - 166px); padding: 5px 34px 5px 12px; }
.maplibregl-ctrl-attrib-button { width: 28px !important; height: 28px !important; filter: invert(1) opacity(0.7); background-color: transparent !important; }
/* --sheet-visible is written by app.js every frame, so these controls ride on top of the sheet. */
.maplibregl-ctrl-bottom-right { bottom: calc(var(--sheet-visible, var(--sheet-peek)) + 8px) !important; }
body[data-sheet='full'] .maplibregl-ctrl-bottom-right { display: none; }
.maplibregl-ctrl-top-left { display: none; }
.maplibregl-ctrl-group { background: rgba(13, 20, 29, 0.85) !important; border: 1px solid var(--line); border-radius: 12px !important; box-shadow: none !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 36px !important; height: 36px !important; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--line) !important; }
.maplibregl-ctrl-group .maplibregl-ctrl-icon { filter: invert(1) opacity(0.75); }

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 10px;
  background: linear-gradient(180deg, rgba(11, 17, 24, 0.92), rgba(11, 17, 24, 0.0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--dim); }
body[data-status='live'] .brand-mark { background: var(--live); box-shadow: 0 0 10px rgba(93, 240, 164, 0.7); animation: blink 2.4s ease-in-out infinite; }
body[data-status='backfilling'] .brand-mark { background: var(--warn); box-shadow: 0 0 10px rgba(255, 196, 102, 0.6); }
body[data-status='stale'] .brand-mark, body[data-status='error'] .brand-mark { background: #ff6b6b; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: 0.14em; }
.brand-text span { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.status-pill {
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(13, 20, 29, 0.85);
  color: var(--muted);
}
.status-pill[data-state='live'] { color: var(--live); border-color: rgba(93, 240, 164, 0.4); }
.status-pill[data-state='live']::before { content: '●'; margin-right: 5px; animation: blink 1.6s ease-in-out infinite; }
.status-pill[data-state='backfilling'] { color: var(--warn); border-color: rgba(255, 196, 102, 0.4); }
.status-pill[data-state='stale'], .status-pill[data-state='error'] { color: #ff8b8b; border-color: rgba(255, 110, 110, 0.4); }
@keyframes blink { 50% { opacity: 0.35; } }
.icon-btn {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(13, 20, 29, 0.85);
  backdrop-filter: blur(12px);
}
.icon-btn:active { transform: scale(0.96); }

.window-chips {
  position: fixed;
  left: 12px;
  bottom: calc(var(--sheet-visible, var(--sheet-peek)) + 8px);
  z-index: 20;
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(13, 20, 29, 0.85);
  backdrop-filter: blur(12px);
}
.window-chips button {
  padding: 6px 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-radius: 999px;
}
.window-chips button.active { color: var(--text); background: rgba(255, 255, 255, 0.12); }
body[data-sheet='full'] .window-chips { opacity: 0; pointer-events: none; }

/* ── Bottom sheet ────────────────────────────────────── */
/* Always laid out at full height; app.js slides it with a transform (spring physics).
   The data-state transforms below only cover the first paint before app.js takes over. */
.sheet {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(-1 * var(--sheet-overdraw));
  z-index: 30;
  display: flex;
  flex-direction: column;
  height: calc(100% - 56px - var(--safe-top) + var(--sheet-overdraw));
  padding-bottom: calc(var(--safe-bottom) + var(--sheet-overdraw));
  background: var(--sheet-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
  transform: translate3d(0, calc(100% - var(--sheet-overdraw) - var(--sheet-half)), 0);
  will-change: transform;
  touch-action: none;
}
.sheet[data-state='peek'] { transform: translate3d(0, calc(100% - var(--sheet-overdraw) - var(--sheet-peek) - var(--safe-bottom)), 0); }
.sheet[data-state='full'] { transform: translate3d(0, 0, 0); }
body.sheet-dragging { -webkit-user-select: none; user-select: none; cursor: grabbing; }
.sheet-handle { display: flex; justify-content: center; padding: 8px 0 6px; cursor: grab; }
.sheet-handle span { width: 36px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.18); }

/* ── Timeline strip ──────────────────────────────────── */
.tl { padding: 0 16px; }
.tl-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 32px; }
.tl-filters { display: flex; gap: 2px; margin-left: -6px; }
.tl-filters button { padding: 6px 6px; font-size: 12.5px; font-weight: 600; color: var(--dim); }
.tl-filters button[aria-pressed='true'] { color: var(--text); }
.tl-readout { display: flex; align-items: center; gap: 8px; min-width: 0; }
#cursor-label { font-family: var(--mono); font-size: 11.5px; color: #cdb48a; white-space: nowrap; font-variant-numeric: tabular-nums; }
body[data-live='true'] #cursor-label { color: #7fbf9c; }
.tl-live { padding: 2px 8px; font-size: 10.5px; font-weight: 600; color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.09); border-radius: 999px; }
body[data-live='true'] .tl-live { display: none; }

.tl-stage { position: relative; margin-top: 6px; touch-action: none; -webkit-user-select: none; user-select: none; cursor: ew-resize; }
#tl-chart { display: block; width: 100%; height: 80px; }
.tl-thumb {
  position: absolute;
  top: 50px; left: 0;
  width: 15px; height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border-radius: 50%;
  background: #eef1f4;
  border: 2px solid var(--sheet-bg);
  will-change: transform;
  outline: none;
}
.tl-thumb:focus-visible { box-shadow: 0 0 0 2px rgba(238, 241, 244, 0.6); }
.unit-toggle { position: absolute; right: 0; bottom: 0; display: flex; align-items: center; font-family: var(--mono); font-size: 10px; color: var(--dim); }
.unit-toggle button { padding: 4px 5px; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em; color: var(--dim); }
.unit-toggle button[aria-pressed='true'] { color: var(--text); }
.unit-toggle button:disabled { opacity: 0.4; cursor: default; }

.tl-steps { display: flex; align-items: center; justify-content: center; gap: 2px; height: 52px; }
.tl-steps button { padding: 8px 7px; font-family: var(--mono); font-size: 11px; color: #75808b; }
.tl-steps .tl-play {
  width: 36px; height: 36px;
  margin: 0 10px;
  padding: 0;
  display: grid; place-items: center;
  color: var(--text);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
}
.tl-play svg { width: 15px; height: 15px; }
.tl-filters button:active, .tl-steps button:active, .tl-live:active, .window-chips button:active { transform: scale(0.96); }

.tabs { display: flex; justify-content: space-around; padding: 0 6px; border-top: 1px solid rgba(255, 255, 255, 0.05); border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.tabs button { flex: 1; padding: 11px 4px; font-size: 12.5px; font-weight: 600; color: var(--dim); }
.tabs button[aria-selected='true'] { color: var(--text); }
.tab-count { font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--dim); margin-left: 4px; }

.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.sheet-body::after { content: ''; display: block; height: var(--sheet-hidden, 0px); }
.panel { padding: 10px 14px 24px; }
.panel[hidden] { display: none; }
.sitrep {
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  line-height: 1.5;
  color: #aab4be;
}
.coverage, .muted { font-size: 12px; color: var(--muted); line-height: 1.45; }
.coverage { margin-bottom: 8px; }

.feed, .list { list-style: none; }
.feed-day {
  position: sticky; top: 0; z-index: 1;
  padding: 8px 2px 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted);
  background: var(--sheet-bg);
}
.feed-item, .list-item {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 3px 10px;
  width: 100%;
  padding: 11px 2px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.feed-item:active, .list-item:active { background: rgba(255, 255, 255, 0.04); }
.feed-item.selected { background: rgba(255, 255, 255, 0.05); }
.feed-item.future { opacity: 0.42; }
.feed-time { grid-row: 1 / span 3; display: flex; flex-direction: column; gap: 2px; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.feed-time small { font-size: 10px; color: var(--dim); }
.feed-type { display: flex; align-items: center; gap: 6px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.feed-type::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--item-accent, #9fb3c8); filter: saturate(0.55) brightness(0.85); }
.feed-headline { font-size: 13.5px; font-weight: 500; line-height: 1.35; color: #d5dbe1; }
.feed-meta { font-size: 11px; color: var(--dim); }
.list-item { grid-template-columns: 14px 1fr; align-items: start; }
.list-swatch { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--item-accent); filter: saturate(0.6) brightness(0.9); }
.list-title { font-size: 14px; font-weight: 600; }
.list-sub { grid-column: 2; font-size: 12px; color: var(--muted); line-height: 1.4; }

.approx-banner {
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--warn);
  background: rgba(255, 196, 102, 0.08);
  border: 1px dashed rgba(255, 196, 102, 0.45);
  border-radius: 10px;
}
.zones-history { margin-bottom: 6px; }
.zones-history p { margin-bottom: 6px; }
.zones-history .sources { margin-bottom: 6px; }

.back-btn { padding: 4px 0 10px; font-size: 14px; color: #7fd0ff; }
.detail h2 { font-size: 18px; line-height: 1.3; margin: 2px 0 8px; }
.detail .kicker { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: var(--item-accent, var(--accent)); }
.detail p { font-size: 13px; line-height: 1.5; color: var(--text); margin-bottom: 8px; }
.detail .meta { font-size: 12px; color: var(--muted); }
.detail .warning { padding: 8px 10px; font-size: 12px; color: var(--warn); background: rgba(255, 196, 102, 0.08); border: 1px dashed rgba(255, 196, 102, 0.45); border-radius: 10px; margin: 10px 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions a, .actions button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}
.actions a.primary { background: var(--accent-soft); border-color: rgba(255, 106, 61, 0.45); color: #ffd3c4; }
.sources { font-size: 12px; color: var(--muted); line-height: 1.5; }
.sources a { display: block; }
.empty { padding: 14px 4px; font-size: 13px; color: var(--muted); }

.panel h2 { font-size: 16px; margin-bottom: 6px; }
.panel h3 { font-size: 13px; margin: 12px 0 4px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
#panel-about p { font-size: 13px; line-height: 1.5; margin-bottom: 6px; }

@media (max-width: 899px) {
  .brand-text span, .status-pill, .sat-link { display: none; }
  .topbar { gap: 10px; }
  .brand-text strong { font-size: 14px; letter-spacing: 0.12em; white-space: nowrap; }
}
@media (max-width: 359px) {
  .tl-steps button { padding: 8px 4px; }
}

@media (min-width: 900px) {
  :root { --sheet-half: 100%; }
  .sheet { left: auto; right: 16px; top: calc(72px + var(--safe-top)); bottom: 16px; width: 420px; height: auto !important; padding-bottom: var(--safe-bottom); transform: none !important; border-radius: var(--radius); border: 1px solid var(--line); }
  .sheet-body::after { display: none; }
  .sheet-handle { display: none; }
  .window-chips { left: 16px; bottom: 16px; }
  body[data-sheet] .window-chips { opacity: 1; pointer-events: auto; }
  .maplibregl-ctrl-top-left { display: block; top: calc(64px + var(--safe-top)); }
  .maplibregl-ctrl-bottom-right { right: 452px; bottom: 16px !important; display: block !important; }
  .maplibregl-ctrl-attrib.maplibregl-compact-show { max-width: 420px; }
}
