:root {
  --bg: #070b11;
  --panel: rgba(13, 19, 27, 0.86);
  --panel-solid: #0d131b;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #dbe4ee;
  --muted: #8794a4;
  --accent: #5ab4ff;
  --accent-dim: rgba(90, 180, 255, 0.16);
  --danger: #ff6b6b;
  --radius: 8px;
  --panel-w: 268px;
  --top-h: 44px;
  --bottom-h: 92px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 2;
}

.obj-label {
  position: absolute;
  top: 0;
  left: 0;
  margin: 10px 0 0 12px;
  padding: 0;
  font: 10.5px/1.25 "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
  white-space: pre;
  text-shadow: 0 0 4px #000, 0 1px 2px #000;
  will-change: transform;
}
.obj-label.selected {
  font-weight: 700;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.5), 0 1px 3px #000;
}

.hover-tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 6;
  pointer-events: none;
  padding: 5px 9px 6px;
  background: rgba(9, 14, 21, 0.94);
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--muted);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  will-change: transform;
}
.hover-tip[hidden] { display: none; }
.hover-tip .nm { font-size: 12.5px; font-weight: 600; }
.hover-tip .sub { color: var(--muted); font-size: 11px; }
.hover-tip .num {
  margin-top: 2px;
  font: 11px/1.3 ui-monospace, Menlo, Consolas, monospace;
  color: var(--text);
}
.hover-tip .num:empty { display: none; }

/* --- chrome ------------------------------------------------------------- */

#topbar {
  position: fixed;
  z-index: 5;
  top: 0; left: 0; right: 0;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(7, 11, 17, 0.95), rgba(7, 11, 17, 0.55));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--accent);
}
.brand span { color: var(--muted); font-weight: 500; }

.title { font-weight: 600; color: var(--text); }
.spacer { flex: 1; }
.stats {
  font: 11px/1 ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
  white-space: pre;
}

.panel {
  position: fixed;
  z-index: 4;
  top: calc(var(--top-h) + 8px);
  bottom: calc(var(--bottom-h) + 8px);
  width: var(--panel-w);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  overflow: hidden;
}
#left { left: 8px; }
#right { right: 8px; overflow-y: auto; overscroll-behavior: contain; }
#right .panel-head { position: sticky; top: 0; z-index: 1; background: #131a23; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}
.panel-head + .panel-head { border-top: 1px solid var(--line); }

.pill {
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 20px;
  padding: 1px 7px;
}

.filters { padding: 8px; border-bottom: 1px solid var(--line); }
.filters .row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }

input[type="search"], select {
  width: 100%;
  padding: 5px 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  outline: none;
}
input[type="search"]:focus, select:focus { border-color: var(--accent); }
select { flex: 0 0 108px; }

.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; user-select: none; }
.chk input { accent-color: var(--accent); }
.chk:hover { color: var(--text); }
/* a control the current mode has nothing to do with */
.chk:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.chk:has(input:disabled):hover { color: var(--muted); }

.obj-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; min-height: 60px; }

.obj-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 4px 10px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.obj-row:hover { background: rgba(255, 255, 255, 0.05); }
.obj-row.selected { background: var(--accent-dim); border-left-color: var(--accent); }
.obj-row.gone { opacity: 0.42; }
/* The unit being watched stays listed after it dies, so it has to stay readable
   rather than fading out with the rest of the departed. */
.obj-row.selected.gone { opacity: 0.85; border-left-style: dashed; }
.obj-row .dot { width: 8px; height: 8px; border-radius: 50%; background: #888; }
.obj-row .nm { display: flex; align-items: baseline; gap: 5px; overflow: hidden; }
.obj-row .who { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-row .what {
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
}
.obj-row .sub {
  color: var(--muted);
  font: 11px/1 ui-monospace, Menlo, Consolas, monospace;
  white-space: nowrap;
}
.obj-row.gone .sub { color: var(--accent); }

.layers { padding: 8px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
.layers .chk { font-size: 12px; }

/* --- inspector ----------------------------------------------------------- */

.inspector { padding: 10px; flex: 0 0 auto; }
.inspector.empty .insp-grid { opacity: 0.4; }
.insp-title { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.insp-title .dot { width: 10px; height: 10px; border-radius: 50%; background: transparent; flex: none; }
.insp-sub { color: var(--muted); font-size: 11.5px; margin: 2px 0 8px 18px; }

.insp-grid { display: grid; grid-template-columns: 84px 1fr; gap: 3px 8px; margin: 0; }
.insp-grid dt { color: var(--muted); font-size: 11px; }
.insp-grid dd { margin: 0; font: 11.5px/1.4 ui-monospace, Menlo, Consolas, monospace; overflow-wrap: anywhere; }

.viewopts { padding: 8px 10px; display: grid; gap: 6px; }
.slider { display: grid; gap: 4px; color: var(--muted); }
.slider b { color: var(--text); font-weight: 600; }
.slider input { width: 100%; accent-color: var(--accent); }

.keys { padding: 8px 10px 10px; color: var(--muted); font-size: 11.5px; display: grid; gap: 3px; }
.keys b { color: var(--text); font-weight: 600; }

kbd {
  display: inline-block;
  min-width: 14px;
  padding: 0 4px;
  font: 10px/16px ui-monospace, Menlo, Consolas, monospace;
  text-align: center;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
}

/* --- transport ----------------------------------------------------------- */

#transport {
  position: fixed;
  z-index: 5;
  left: 0; right: 0; bottom: 0;
  height: var(--bottom-h);
  background: linear-gradient(0deg, rgba(7, 11, 17, 0.97), rgba(7, 11, 17, 0.72));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
}

#timeline {
  width: 100%;
  height: 46px;
  display: block;
  cursor: pointer;
  touch-action: none;
}

.tbar { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 46px; }

.btn {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 10px;
  font: inherit;
  cursor: pointer;
  line-height: 1.1;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn.play { width: 42px; font-size: 15px; color: var(--accent); }
.btn.tiny { padding: 2px 7px; }
.btn.wide { width: 100%; margin-top: 4px; }

.speed {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  padding: 2px 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.speed span {
  min-width: 42px;
  text-align: center;
  font: 12px/1 ui-monospace, Menlo, Consolas, monospace;
  color: var(--accent);
}

.clock { text-align: right; font: 12px/1.3 ui-monospace, Menlo, Consolas, monospace; }
/* A full date plus a zone offset is a long string; keep it inside the bar
   rather than letting it run off the edge of the window. */
.clock .mission { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.clock .elapsed { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* --- loader -------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 35%, #16283c 0%, #070b11 70%);
}
.overlay[hidden] { display: none; }

.loader-card {
  width: min(560px, 100%);
  /* a data/ folder full of recordings makes a long list — the list scrolls,
     and the card itself never grows past the viewport */
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}
.loader-card h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.lead { color: var(--muted); margin: 6px 0 18px; }
code { font: 12px ui-monospace, Menlo, Consolas, monospace; background: rgba(255,255,255,0.07); padding: 1px 5px; border-radius: 4px; }

.recordings {
  display: grid;
  /* minmax(0, …) caps the track at the card's width, so a tile with a long
     label ellipsizes instead of pushing the whole column out of the card */
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  margin-bottom: 14px;
  max-height: 42vh;
  overflow-y: auto;
}
.recordings[hidden] { display: none; }
.rec {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.rec:hover { border-color: var(--accent); background: var(--accent-dim); }
.rec .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec .sz { color: var(--muted); font-size: 11.5px; white-space: nowrap; flex-shrink: 0; }

.dropzone {
  display: grid;
  gap: 3px;
  place-items: center;
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-dim); color: var(--text); }
.dropzone strong { color: var(--text); font-size: 13.5px; }

.progress { margin-top: 16px; }
.progress .bar { height: 5px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; }
.progress .bar > div { height: 100%; width: 0; background: var(--accent); transition: width 0.12s linear; }
.progress .muted { margin-top: 7px; }
.muted { color: var(--muted); font-size: 12px; }
.error { margin-top: 14px; color: var(--danger); font-size: 12.5px; white-space: pre-wrap; }

@media (max-width: 1080px) {
  :root { --panel-w: 224px; }
}
@media (max-width: 820px) {
  #right { display: none; }
}

/* --- overview strip ------------------------------------------------------ */

#overviewWrap {
  position: relative;
  border-bottom: 1px solid var(--line);
  background: #080d13;
}
#overviewWrap[hidden] { display: none; }
#overview {
  width: 100%;
  height: 34px;
  display: block;
  cursor: grab;
  touch-action: none;
}
#overview:active { cursor: grabbing; }
.ovlabel {
  position: absolute;
  left: 8px;
  top: 2px;
  font-size: 10px;
  color: rgba(150, 168, 186, 0.35);
  pointer-events: none;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 0.15s;
}
#overviewWrap:hover .ovlabel { opacity: 1; }

/* --- transport extras ---------------------------------------------------- */

.zoomsel {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-left: 10px;
  margin-left: 6px;
  border-left: 1px solid var(--line);
}
.zoomsel[hidden] { display: none; }
.zoomsel .lbl { color: var(--muted); font-size: 11px; }
#zoomVal { min-width: 34px; text-align: center; font-variant-numeric: tabular-nums; font-size: 12px; }

.seglabel {
  color: var(--muted);
  font-size: 11.5px;
  margin-right: 12px;
  white-space: nowrap;
}

.buffering {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-right: 12px;
  font-size: 11.5px;
  color: var(--accent);
  white-space: nowrap;
}
.buffering[hidden] { display: none; }
.buffering .spin {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(90, 180, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- start screen tabs --------------------------------------------------- */

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 7px 12px;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

.tabpane { display: none; }
.tabpane.on { display: block; }
.hint { color: var(--muted); font-size: 12.5px; margin: 0 0 14px; line-height: 1.5; }

.dropzone.slim { padding: 14px; }
.urlrow { display: flex; gap: 8px; margin: 12px 0; }
.urlrow input {
  flex: 1;
  min-width: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 10px;
}
.urlrow input:focus { outline: none; border-color: var(--accent); }

/* --- build tab ----------------------------------------------------------- */

.buildgrid { display: grid; gap: 10px; }
.buildgrid .row { display: flex; gap: 10px; }
.field { display: grid; gap: 4px; flex: 1; min-width: 0; }
.field > span { color: var(--muted); font-size: 11.5px; }
.field.wide { width: 100%; }
.field select,
.field input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 6px 8px;
  width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); }

.btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}
.btn.primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.buildlist {
  font: 11.5px ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  max-height: 110px;
  overflow: auto;
  color: var(--text);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
}
.buildlist.muted { color: var(--muted); }

.buildlog {
  margin-top: 14px;
  font: 11.5px ui-monospace, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  max-height: 220px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
}
.buildlog[hidden] { display: none; }
.buildlog .hd { color: var(--text); }
.buildlog .muted { color: var(--muted); }
.buildlog .err { color: var(--danger); }
.buildlog > div { color: rgba(200, 214, 228, 0.85); }

/* Three controls do not fit on one line once a timeline adds its own scope
   toggle, so the filter row wraps and the select keeps a sane minimum. */
.filters .row { flex-wrap: wrap; row-gap: 6px; align-items: center; }
.filters .row > select { flex: 1 1 110px; min-width: 96px; width: auto; }
/* the kind filter has nothing to act on while the roster is showing */
.filters .row > select:disabled { opacity: 0.45; cursor: not-allowed; }
.filters .chk { flex: 0 0 auto; }
.filters .chk span { white-space: nowrap; font-size: 11.5px; }

/* --- scrubber hover tooltip ---------------------------------------------- */

.scrubtip {
  position: fixed;
  z-index: 20;
  left: 0;
  top: 0;
  pointer-events: none;
  background: rgba(10, 15, 21, 0.96);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 5px 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.scrubtip[hidden] { display: none; }
.scrubtip .when { font-size: 12px; color: var(--text); }
.scrubtip .sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.scrubtip .sub:empty { display: none; }

/* The clock readout doubles as the UTC / local toggle. `font: inherit` does not
   carry colour, and a button otherwise falls back to the UA's black, so the
   colour has to be stated - including for the disabled state, which a single
   recording uses because a mission clock has no zone to switch to. */
button.clock {
  appearance: none;
  background: none;
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  padding: 2px 6px;
  flex: 0 0 auto;
  margin-right: 2px;
}
button.clock:hover:not(:disabled) { background: rgba(255, 255, 255, 0.07); border-color: var(--line); }
button.clock:disabled { color: var(--text); cursor: default; opacity: 1; }
button.clock .mission { color: var(--text); }
.tbar .seglabel { overflow: hidden; text-overflow: ellipsis; }
