:root {
  --bg: #05080f;
  --panel: rgba(4, 7, 14, 0.84);
  --panel-solid: #070b14;
  --line: rgba(130, 160, 210, 0.18);
  --text: #e6ecff;
  --dim: #8a99bb;
  --accent: #ff7a2e;
  --live: #ff3b2f;
  --replay: #ffd23f;
  --blue: #4d9dff;
  --radius: 10px;
  --head: 'Barlow Condensed', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.4 var(--body); overflow: hidden; }
button { font: inherit; color: inherit; }
a { color: #9ec3ff; }

#map { position: fixed; inset: 0; }

/* ---------- header ---------- */
.top { position: fixed; top: 14px; left: 20px; right: 20px; display: flex; align-items: flex-start; justify-content: space-between; pointer-events: none; z-index: 5; }
.brand { pointer-events: auto; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9); }
.brand h1 { margin: 0; font: 600 22px/1.1 var(--head); letter-spacing: 0.06em; text-transform: uppercase; }
.brand p { margin: 4px 0 0; font: 600 13px/1.2 var(--head); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent); }
.tabs { display: none; gap: 6px; pointer-events: auto; }

/* ---------- panels ---------- */
.panel { position: fixed; z-index: 4; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 14px 16px; overflow: auto; }
.panel.left { top: 80px; left: 20px; width: 300px; border-top: 2px solid var(--accent); max-height: calc(100vh - 290px); }
.panel.right { top: 14px; right: 20px; width: 370px; border-top: 2px solid var(--blue); max-height: calc(100vh - 230px); }
.panel h2 { margin: 0 0 2px; font: 600 15px/1.2 var(--head); letter-spacing: 0.1em; text-transform: uppercase; }
.panel .sub { margin: 0 0 10px; color: var(--dim); font-size: 12px; }

.types { list-style: none; margin: 0; padding: 0; }
.types button { display: grid; grid-template-columns: 14px 1fr auto; gap: 4px 10px; align-items: center; width: 100%; padding: 6px 6px; margin: 0 -6px; background: none; border: 0; border-radius: 6px; cursor: pointer; text-align: left; }
.types button:hover { background: rgba(255, 255, 255, 0.05); }
.types button.off { opacity: 0.32; }
.types .sw { width: 12px; height: 12px; border-radius: 3px; }
.types .n { font-variant-numeric: tabular-nums; }
.types .bar { grid-column: 2 / 4; height: 4px; border-radius: 2px; opacity: 0.6; }

.stats { margin: 10px 0 0; padding-top: 10px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.stats div { display: flex; justify-content: space-between; }
.stats dt { color: var(--dim); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 12px; color: var(--dim); }
.legend span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; background: var(--c); vertical-align: -1px; }

.status { display: flex; align-items: center; gap: 10px; }
.status .dot { width: 12px; height: 12px; border-radius: 3px; background: var(--live); animation: blink 1.2s ease-in-out infinite; }
.status.replay .dot { background: var(--replay); animation: none; }
.status strong { font: 700 20px/1 var(--head); letter-spacing: 0.08em; color: var(--live); }
.status.replay strong { color: var(--replay); }
.status .clock { margin-left: auto; font-variant-numeric: tabular-nums; }
.fresh { margin: 8px 0 2px; color: #ffcf73; font-size: 12.5px; }
.note { margin: 0 0 12px; color: var(--dim); font-size: 12px; }
@keyframes blink { 50% { opacity: 0.35; } }

.latest { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.latest button { display: grid; grid-template-columns: 4px 1fr auto; gap: 2px 10px; width: 100%; padding: 6px 8px 6px 0; background: none; border: 0; border-radius: 6px; text-align: left; cursor: pointer; }
.latest button:hover { background: rgba(255, 255, 255, 0.05); }
.latest button.new { background: rgba(255, 59, 47, 0.16); }
.latest .stripe { grid-row: 1 / 3; border-radius: 2px; }
.latest .when { grid-column: 2 / 4; color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.latest .what { grid-column: 2; grid-row: 2; font-size: 13.5px; }
.latest .len { grid-row: 2; grid-column: 3; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.empty { color: var(--dim); }

/* ---------- banner + detail card ---------- */
.banner { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 6; min-width: 320px; max-width: calc(100vw - 40px); padding: 12px 24px; background: rgba(20, 4, 4, 0.92); border: 1px solid var(--live); border-width: 3px 1px; border-radius: 8px; text-align: center; }
.banner strong { display: block; font: 700 20px/1.2 var(--head); letter-spacing: 0.08em; text-transform: uppercase; }
.banner span { color: #e2e6f2; font-size: 13px; }

.card { position: fixed; z-index: 6; left: 50%; bottom: 200px; transform: translateX(-50%); width: min(460px, calc(100vw - 40px)); max-height: 46vh; overflow: auto; background: var(--panel-solid); border: 1px solid var(--line); border-top: 2px solid var(--accent); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6); }
.card header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.card h2 { margin: 0; font: 600 17px/1.2 var(--head); letter-spacing: 0.05em; }
.card .count { color: var(--dim); }
.card .x { margin-left: auto; background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: var(--dim); }
.card ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.card li { display: grid; grid-template-columns: 4px 1fr; gap: 0 10px; }
.card li .stripe { grid-row: 1 / 3; border-radius: 2px; }
.card li .when { color: var(--dim); font-size: 12px; }

/* ---------- timeline ---------- */
.timeline { position: fixed; left: 20px; right: 20px; bottom: 12px; z-index: 4; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); padding: 10px 16px 8px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.controls .spacer { flex: 1; }
.controls button, .tabs button, dialog .primary { padding: 6px 11px; border-radius: 7px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); cursor: pointer; font-size: 13px; white-space: nowrap; }
.controls button:hover, .tabs button:hover { background: rgba(255, 255, 255, 0.1); }
.controls .primary, dialog .primary { background: var(--accent); border-color: var(--accent); color: #140600; font-weight: 600; }
.controls .live.on { border-color: var(--live); color: #ff8a80; }
.chart { margin-top: 8px; }
.chart-head { display: flex; justify-content: space-between; color: var(--dim); font-size: 11.5px; letter-spacing: 0.04em; text-transform: uppercase; }
#bars { display: block; width: 100%; height: 86px; margin-top: 4px; cursor: pointer; touch-action: none; }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 16px; margin-top: 4px; color: var(--dim); font-size: 11px; }
.foot a { color: var(--dim); }
#credits, #credits .cesium-widget-credits { position: static !important; display: flex; align-items: center; gap: 8px; }
#credits .cesium-credit-textContainer, #credits .cesium-credit-logoContainer { display: inline; position: static !important; }
#credits img { height: 14px; vertical-align: middle; filter: grayscale(1) brightness(1.6); opacity: 0.7; }
#credits, #credits * { color: var(--dim) !important; font-size: 11px !important; }

/* ---------- about dialog ---------- */
dialog { max-width: min(560px, calc(100vw - 32px)); background: var(--panel-solid); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 22px 24px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 8px; font: 600 22px/1.2 var(--head); letter-spacing: 0.04em; }
dialog h3 { margin: 16px 0 6px; font: 600 15px/1.2 var(--head); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
dialog ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
dialog .small { font-size: 12.5px; color: var(--dim); }
dialog .primary { margin-top: 16px; }
#aboutBtn { background: none; border: 0; color: var(--dim); text-decoration: underline; cursor: pointer; font-size: 11px; padding: 0; }

.fatal { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; font-size: 16px; }

/* ---------- phones and small tablets ---------- */
@media (max-width: 760px) {
  .top { top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px; }
  .brand h1 { font-size: 17px; }
  .brand p { display: none; }
  .tabs { display: flex; }
  .panel { display: none; left: 12px !important; right: 12px !important; width: auto !important; top: 64px !important; max-height: calc(100vh - 290px) !important; }
  .panel.open { display: block; }
  .timeline { left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); padding: 8px 10px 6px; }
  .controls { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .controls::-webkit-scrollbar { display: none; }
  .controls .spacer { display: none; }
  .chart-head .hint { display: none; }
  #bars { height: 64px; }
  .card { bottom: 190px; }
  .banner { top: 64px; min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { .status .dot { animation: none; } }
