:root {
  --void: #05080f;
  --glass: rgba(8, 13, 23, 0.8);
  --glass-strong: rgba(8, 13, 23, 0.94);
  --surface: rgba(17, 25, 42, 0.72);
  --line: rgba(255, 255, 255, 0.085);
  --line-hi: rgba(255, 255, 255, 0.2);
  --text: #f5f7fb;
  --text-soft: #d5dfee;
  --muted: #93a3bc;
  --dim: #697993;
  --accent: #ef4444;
  --accent-bg: rgba(239, 68, 68, 0.14);
  --accent-line: rgba(239, 68, 68, 0.4);
  --ok: #22c55e;
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --radius: 13px;
  --gap: 14px;
  --rail-w: 344px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  color: var(--text);
  font-family: var(--sans);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

button, input { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Dual-Stage Viewport Stack ---------- */
.stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}
.stage-cosmic {
  z-index: 0;
  background: radial-gradient(circle at 46% 48%, #0a1428 0%, #03060d 70%);
  cursor: grab;
  touch-action: none;
}
.stage-cosmic:active { cursor: grabbing; }
.stage-cosmic canvas { display: block; }

.stage-street {
  z-index: 1;
  background: var(--void);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.42s ease, visibility 0s linear 0.42s;
}
.stage-street.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.42s ease, visibility 0s;
}
.stage-street .maplibregl-canvas-container.maplibregl-interactive { cursor: crosshair; }

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 48% 50%, transparent 64%, rgba(3, 5, 11, 0.52) 100%);
  z-index: 2;
}

.stage-notice {
  position: fixed;
  left: calc((100vw - var(--rail-w) - 2 * var(--gap)) / 2);
  top: 46%;
  transform: translate(-50%, -50%);
  z-index: 3;
  margin: 0;
  max-width: 320px;
  padding: 11px 15px;
  border-radius: 11px;
  border: 1px solid var(--line-hi);
  background: var(--glass-strong);
  color: var(--text-soft);
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
}

/* Map attribution sits just above the dock's left corner, never underneath it */
.stage-street .maplibregl-ctrl-bottom-left {
  left: var(--dock-left, 104px);
  bottom: var(--dock-clear, 118px);
  max-width: min(520px, calc(100vw - 24px));
}
.maplibregl-ctrl-attrib {
  background: rgba(5, 8, 15, 0.58) !important;
  color: var(--dim) !important;
  font-family: var(--sans) !important;
  font-size: 10px !important;
  backdrop-filter: blur(8px);
}
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }

.hud-top-left,
.hud-top-right,
.hud-rail,
.hud-dock {
  position: fixed;
  z-index: 10;
}

/* ---------- Top-Left Command Column ---------- */
.hud-top-left {
  top: var(--gap);
  left: var(--gap);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  max-width: calc(100vw - 500px);
  pointer-events: none;
  z-index: 11;
}
.hud-top-left > * { pointer-events: auto; }

.top-row {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s ease;
}
.brand-chip:hover { border-color: var(--line-hi); }

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  flex-shrink: 0;
}

.search-shell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  width: 274px;
  min-width: 150px;
  flex-shrink: 1;
  padding: 0 13px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: border-color 0.15s ease, width 0.2s ease, opacity 0.2s ease;
}
.search-shell:focus-within {
  border-color: var(--accent);
  width: 316px;
}
.search-shell.is-off {
  opacity: 0.45;
  pointer-events: none;
}
.search-shell .ico {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex-shrink: 0;
}
.search-shell input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--sans);
}
.search-shell input::placeholder { color: var(--dim); font-weight: 400; }
.search-shell input::-webkit-search-cancel-button { display: none; }
.kbd-hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
}

.search-dropdown {
  position: absolute;
  top: 46px;
  left: 0;
  right: 0;
  min-width: 232px;
  background: var(--glass-strong);
  backdrop-filter: blur(20px);
  border: 1px solid var(--line-hi);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.6);
  z-index: 30;
}
.search-cap {
  padding: 7px 13px 5px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
.search-item {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 13px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}
.search-item:last-child { border-bottom: 0; }
.search-item:hover,
.search-item:focus-visible { background: rgba(255, 255, 255, 0.06); outline: none; }
.search-item-meta {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Multi-World Switcher Pill */
.world-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 3px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.world-btn {
  appearance: none;
  height: 28px;
  padding: 0 13px 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.world-btn:hover { color: var(--text); }
.world-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 700;
}
.world-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--wc, #93a3bc);
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.38);
  flex-shrink: 0;
}

/* Minimal Legend */
.hud-legend {
  background: var(--glass);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 9px 12px;
  max-width: 252px;
}
.legend-hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.38;
}
.legend-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 11px;
  margin-top: 7px;
}
.legend-swatches:empty { display: none; }
.swatch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
}
.swatch-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- Top-Right Controls ---------- */
.hud-top-right {
  top: var(--gap);
  right: var(--gap);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 12;
}

.hud-btn {
  appearance: none;
  height: 36px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(16px);
  color: var(--text-soft);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.hud-btn:hover { border-color: var(--line-hi); color: var(--text); }
.hud-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: #ffffff;
}

/* Segmented View Mode Pill: Orbital 3D | Street 3D */
.view-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 36px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(16px);
}
.view-seg {
  appearance: none;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}
.view-seg:hover { color: var(--text); }
.view-seg.active {
  background: var(--accent-bg);
  box-shadow: inset 0 0 0 1px var(--accent);
  color: #ffffff;
  font-weight: 600;
}
.view-seg[aria-disabled="true"] {
  color: var(--dim);
  opacity: 0.6;
  cursor: not-allowed;
}
.view-seg.is-loading { color: var(--text-soft); cursor: progress; }
.view-seg.is-loading::after {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 7px;
  border-radius: 50%;
  border: 1.5px solid var(--line-hi);
  border-top-color: var(--accent);
  vertical-align: -1px;
  animation: segSpin 0.7s linear infinite;
}
@keyframes segSpin { to { transform: rotate(360deg); } }

.view-pill[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line-hi);
  background: var(--glass-strong);
  color: var(--text-soft);
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-3px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
.view-pill[data-tip]:hover::after,
.view-pill[data-tip]:focus-within::after {
  opacity: 1;
  transform: none;
}

/* ---------- Right Editorial Telemetry Rail ---------- */
.hud-rail {
  top: 62px;
  right: var(--gap);
  width: var(--rail-w);
  max-height: calc(100dvh - 76px);
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(145%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
}

.drawer-handle { display: none; }

.rail-body {
  padding: 14px 15px 11px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.rail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.loc-block { min-width: 0; flex: 1; }
.city-title {
  margin: 0;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coords-line {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sev-pill {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-soft);
  border: 1px solid rgba(148, 163, 184, 0.34);
}
.sev-critical { background: rgba(239, 68, 68, 0.16); color: #fca5a5; border-color: rgba(239, 68, 68, 0.42); }
.sev-severe   { background: rgba(249, 115, 22, 0.16); color: #fdba74; border-color: rgba(249, 115, 22, 0.42); }
.sev-guarded  { background: rgba(245, 158, 11, 0.16); color: #fde68a; border-color: rgba(245, 158, 11, 0.42); }
.sev-low      { background: rgba(34, 197, 94, 0.15); color: #86efac; border-color: rgba(34, 197, 94, 0.38); }

/* 2x2 Editorial Metric Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}
.kpi-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 10px;
  min-width: 0;
}
.kpi-lbl {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-val {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 14.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-val[data-size="sm"] { font-size: 12.5px; line-height: 19px; }
.kpi-val[data-size="xs"] { font-size: 11.5px; line-height: 19px; letter-spacing: -0.03em; }
.kpi-cell:first-child .kpi-val { color: var(--accent); }

.verdict-line {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 400;
  color: var(--text-soft);
  line-height: 1.44;
  user-select: text;
}

/* TON 618 Dual Relativistic Clock */
.rel-clock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 0 12px;
  align-items: end;
  margin-bottom: 10px;
  padding: 7px 11px 8px;
  border-radius: 9px;
  border: 1px solid var(--accent-line);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.025), var(--accent-bg));
}
.rel-cell { min-width: 0; }
.rel-cell-earth {
  padding-left: 12px;
  border-left: 1px solid var(--line);
}
.rel-lbl {
  display: block;
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.2;
  white-space: nowrap;
}
.rel-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 2px;
}
.rel-val {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text);
}
.rel-row .rel-val { margin-top: 0; color: var(--accent); }
.rel-ratio {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rail-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 10px;
}
.act-btn {
  appearance: none;
  height: 33px;
  padding: 0 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s ease, filter 0.15s ease;
}
.act-btn:hover { border-color: var(--line-hi); }
.act-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  flex: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.act-primary:hover { filter: brightness(1.08); }
.act-yt {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}
.toast {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ok);
  white-space: nowrap;
}
.toast:empty { display: none; }

/* Segmented Rail Tabs (Timeline / Survival / Physics) */
.rail-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 9px;
}
.rail-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.rail-tab:hover { color: var(--text); }
.rail-tab.active {
  color: var(--text);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
}
.clock-chip {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.tab-stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.tl-row {
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  border-left: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.18s ease, background 0.18s ease;
}
.tl-row.active {
  border-color: rgba(255, 255, 255, 0.08);
  border-left-color: var(--accent);
  background: var(--accent-bg);
}
.tl-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.tl-h {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  min-width: 0;
}
.tl-t {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.tl-d {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 3px;
  line-height: 1.42;
}

/* Rail density steps: app.js raises data-density until the active tab fits with zero scroll.
   1 tightens spacing, 2 also slims the chrome, 3 clamps timeline copy to two lines, 4 to one. */
.hud-rail[data-density] .rail-body { padding-top: 12px; padding-bottom: 9px; }
.hud-rail[data-density] .rail-head,
.hud-rail[data-density] .kpi-grid,
.hud-rail[data-density] .verdict-line,
.hud-rail[data-density] .rel-clock,
.hud-rail[data-density] .rail-actions { margin-bottom: 8px; }
.hud-rail[data-density] .rail-tabs { padding-bottom: 6px; margin-bottom: 7px; }
.hud-rail[data-density] .timeline { gap: 4px; }
.hud-rail[data-density] .tl-row { padding: 5px 9px; }
.hud-rail[data-density] .tl-d { margin-top: 2px; line-height: 1.36; }
.hud-rail[data-density] .yt-bridge { padding: 8px 12px 9px; }
.hud-rail[data-density] .survival-list,
.hud-rail[data-density] .physics-panel { gap: 5px; }
.hud-rail[data-density] .surv-item,
.hud-rail[data-density] .phys-card { padding: 7px 10px; }

.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .rail-body { padding-top: 11px; padding-bottom: 8px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .rail-head,
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .kpi-grid,
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .verdict-line,
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .rel-clock,
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .rail-actions { margin-bottom: 7px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .kpi-grid { gap: 6px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .kpi-cell { padding: 4px 10px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .rel-clock { padding: 5px 11px 6px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .rail-tabs { padding-bottom: 5px; margin-bottom: 6px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .timeline { gap: 3px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .tl-row { padding: 4px 9px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .yt-bridge { padding: 7px 12px 8px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .yt-card { padding: 5px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .yt-thumb-wrap { width: 68px; height: 38px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .yt-title { -webkit-line-clamp: 1; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .surv-desc { line-height: 1.36; margin-top: 2px; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .physics-panel { line-height: 1.38; }
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .surv-item,
.hud-rail:is([data-density="2"], [data-density="3"], [data-density="4"]) .phys-card { padding: 5px 10px; }

.hud-rail:is([data-density="3"], [data-density="4"]) .tl-h {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-rail:is([data-density="3"], [data-density="4"]) .tl-d {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.hud-rail[data-density="4"] .tl-d { -webkit-line-clamp: 1; }
.hud-rail[data-density="4"] .verdict-line {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.survival-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.surv-item {
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.surv-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.surv-desc {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.44;
}

.physics-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.46;
}
.phys-card {
  padding: 9px 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.phys-card strong {
  display: block;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 2px;
}

/* Pinned YouTube Video Bridge */
.yt-bridge {
  padding: 10px 12px 11px;
  border-top: 1px solid var(--line);
  background: rgba(5, 8, 15, 0.65);
  flex-shrink: 0;
}
.yt-card {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(11, 17, 29, 0.85);
  border-radius: 10px;
  padding: 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease;
}
.yt-card:hover { border-color: var(--accent); }
.yt-thumb-wrap {
  position: relative;
  width: 82px;
  height: 46px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  background: #04070d;
}
.yt-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.yt-play-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 18px;
  border-radius: 5px;
  background: rgba(220, 38, 38, 0.94);
}
.yt-play-dot::after {
  content: "";
  position: absolute;
  left: 9px;
  top: 4px;
  border-style: solid;
  border-width: 5px 0 5px 8px;
  border-color: transparent transparent transparent #fff;
}
.yt-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.yt-kicker {
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.01em;
}
.yt-title {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-soft);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Bottom Mission Control Dock ---------- */
.hud-dock {
  left: calc((100vw - var(--rail-w) - var(--gap)) / 2);
  bottom: 16px;
  transform: translateX(-50%);
  width: min(700px, calc(100vw - var(--rail-w) - 4 * var(--gap)));
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(145%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
  container-type: inline-size;
}

.scenario-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 5px;
}
.sc-tab {
  appearance: none;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 6px;
  font-family: var(--display);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.sc-tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.075); }
.sc-tab.active {
  color: #ffffff;
  font-weight: 700;
  background: var(--accent-bg);
  border-color: var(--accent);
}
@container (max-width: 590px) {
  .scenario-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.dock-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ctrl-group {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.ctrl-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
  flex-shrink: 0;
}
.play-btn {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--accent-bg);
  color: #ffffff;
  font-size: 11px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.play-btn:hover { background: var(--accent); }
.slider-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ctrl-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.ctrl-head > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mono-val {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #ffffff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.55);
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #ffffff;
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- Video Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(3, 6, 12, 0.84);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal-box {
  width: min(760px, 100%);
  background: #090f1b;
  border: 1px solid var(--line-hi);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.72);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-title {
  margin: 2px 0 0;
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-frame {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  border-radius: 10px;
  overflow: hidden;
  background: #020409;
  border: 1px solid var(--line);
}
.modal-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.modal-foot {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.modal-foot p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  flex: 1;
  min-width: 220px;
  line-height: 1.48;
}

/* ---------- Streamer Mode ---------- */
body.streamer-mode .yt-bridge,
body.streamer-mode .hud-legend { display: none; }
body.streamer-mode { --rail-w: 368px; }
body.streamer-mode .city-title { font-size: 25px; }
body.streamer-mode .kpi-val { font-size: 17px; }

/* ---------- Street 3D Ground Zero Beacon ---------- */
.gz-marker {
  position: relative;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: var(--accent);
  box-shadow: 0 0 16px var(--accent);
  cursor: pointer;
}
.gz-marker::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0.6;
  animation: gzPulse 2.2s ease-out infinite;
}
@keyframes gzPulse {
  0% { transform: scale(0.75); opacity: 0.8; }
  100% { transform: scale(2.1); opacity: 0; }
}

/* ---------- Tablet ---------- */
@media (max-width: 1080px) {
  .hud-legend { display: none; }
  .brand-chip .brand-name { display: none; }
  .brand-chip { padding: 0 13px; }
  .hud-dock {
    left: var(--gap);
    transform: none;
    width: calc(100vw - var(--rail-w) - 3 * var(--gap));
  }
  .stage-notice { left: 50%; }
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .hud-top-left {
    top: 10px;
    left: 10px;
    right: 10px;
    max-width: none;
    gap: 6px;
  }
  .top-row { width: 100%; gap: 6px; }
  .brand-chip { padding: 0 11px; height: 36px; }
  .search-shell { flex: 1; width: auto; height: 36px; }
  .search-shell:focus-within { width: auto; }
  .kbd-hint { display: none; }

  /* Row 2: view pill left, sound and B-Roll right. Row 3: world switcher. */
  .hud-top-right {
    top: 52px;
    right: 10px;
    left: 10px;
    gap: 5px;
  }
  .hud-top-right .view-pill { margin-right: auto; }
  .hud-btn { height: 30px; padding: 0 10px; font-size: 11.5px; }
  .hud-btn-streamer { display: none; }
  .view-pill { height: 30px; padding: 2px; }
  .view-seg { height: 24px; padding: 0 10px; font-size: 11.5px; }
  .view-pill[data-tip]::after { left: 0; right: auto; }

  .world-switch { margin-top: 36px; height: 30px; padding: 2px; }
  .world-btn { height: 24px; padding: 0 10px 0 8px; font-size: 11.5px; gap: 6px; }
  .world-dot { width: 8px; height: 8px; }

  .hud-dock {
    left: 10px;
    right: 10px;
    bottom: 58px;
    width: auto;
    transform: none;
    padding: 7px 9px 8px;
    gap: 7px;
    border-radius: 12px;
  }
  .scenario-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .sc-tab { font-size: 11.5px; padding: 5px 4px; border-radius: 7px; }
  .dock-controls { flex-direction: column; align-items: stretch; gap: 7px; }
  .ctrl-group { gap: 8px; }
  .ctrl-param { padding-left: 36px; }
  .ctrl-divider { display: none; }
  .play-btn { width: 28px; height: 28px; font-size: 10px; }
  .slider-col { gap: 4px; }
  .ctrl-head, .mono-val { font-size: 11px; }

  .hud-rail {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 42px;
    transition: max-height 0.25s ease;
    border-radius: 12px;
  }
  .hud-rail.mobile-open {
    max-height: 76dvh;
    z-index: 25;
  }
  .rail-body { overflow-y: auto; }
  .tab-stage { flex: none; overflow: visible; }
  .drawer-handle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    height: 42px;
    padding: 0 14px;
    background: var(--glass-strong);
    border: 0;
    color: var(--text);
    font-family: var(--display);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
  }
  .drawer-handle #mobileHandleSummary {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .handle-grip {
    width: 24px;
    height: 3px;
    border-radius: 999px;
    background: var(--line-hi);
    flex-shrink: 0;
  }
  .handle-chev { flex-shrink: 0; transition: transform 0.2s ease; }
  .hud-rail.mobile-open .handle-chev { transform: rotate(180deg); }
  .stage-notice { top: 40%; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-street,
  .stage-street.is-active { transition: none; }
  .gz-marker::after,
  .view-seg.is-loading::after { animation: none; }
}
