:root {
  --bg: #07090d;
  --panel: rgb(12 16 24 / 0.78);
  --text: #e8edf5;
  --muted: #8b96a8;
  --accent: #34d3a0;
  --border: rgb(255 255 255 / 0.08);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
}

#view {
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#video { display: none; }
#splash[hidden] { display: none; }

#splash {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  text-align: center;
  background: radial-gradient(ellipse at center, #111827 0%, var(--bg) 70%);
}
#splash h1 { margin: 0; font-size: clamp(24px, 4vw, 40px); letter-spacing: -0.02em; font-weight: 600; }
.splash-logo { width: min(420px, 80vw); height: auto; margin-bottom: 12px; }

#brand {
  position: fixed;
  top: 16px;
  left: 16px;
  height: clamp(28px, 5vh, 56px);
  width: auto;
  filter: drop-shadow(0 1px 6px rgb(0 0 0 / 0.7));
  pointer-events: none;
}
#brand[hidden] { display: none; }
#splash p { margin: 0; color: var(--muted); max-width: 520px; }
#status { color: var(--accent); min-height: 1.4em; font-variant-numeric: tabular-nums; }
#status.error { color: #ff6b6b; }
.splash-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

button, .file-btn {
  font: inherit;
  color: var(--bg);
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 600;
}
.file-btn { background: transparent; color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: 0.4; cursor: wait; }

#hud {
  position: fixed;
  top: 16px;
  right: 16px;
  width: min(320px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 12px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 12px;
}
#hud[hidden] { display: none; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tile { display: flex; flex-direction: column; padding: 6px 8px; border-radius: 8px; background: rgb(255 255 255 / 0.04); }
.tile span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.tile b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

#hud section + section { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
#hud h2 { margin: 0 0 8px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
#hud h2 small { font-weight: 500; color: var(--accent); font-variant-numeric: tabular-nums; }

.breakdown { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: 12px; }
.breakdown div { display: flex; justify-content: space-between; gap: 6px; }
.breakdown dt { color: var(--muted); }
.breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }

.spark { margin: 8px 0 0; }
.spark figcaption { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.spark em { font-style: normal; font-variant-numeric: tabular-nums; }
.spark canvas { display: block; width: 100%; height: 36px; }

.sys { margin: 12px 0 0; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

#counts {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#counts li {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.06);
  border-left: 3px solid var(--c);
  font-size: 13px;
}

#settings { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 8px; }
#settings summary { cursor: pointer; color: var(--muted); }
#settings label { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
#settings input[type="range"] { flex: 1; }
#settings select { flex: 1; min-width: 0; font: inherit; background: #1b2230; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 4px; }
#settings button { width: 100%; margin-top: 4px; }
output { min-width: 2.5em; text-align: right; font-variant-numeric: tabular-nums; }
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }
