:root {
  --bg: #070b14;
  --panel: #0d1424;
  --panel-2: #121b30;
  --line: #1f2b45;
  --text: #dbe6ff;
  --muted: #7d8db0;
  --accent: #38e1ff;
  --prone: #4f8bff;
  --trans: #ffb547;
  --stand: #3df5a0;
  --rec: #ff4d6a;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, select, .filebtn {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled), .filebtn:hover, select:hover { border-color: var(--accent); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); color: #001018; border-color: var(--accent); font-weight: 600; }
button.recording { background: var(--rec); border-color: var(--rec); color: #fff; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); cursor: pointer; }

.topbar { height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.brand .logo { color: var(--accent); }
.brand .sub { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.top-right { display: flex; align-items: center; gap: 14px; }
.playlink { color: #001018; background: var(--accent); text-decoration: none; font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.status { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.layout { display: grid; grid-template-columns: 380px 1fr; height: calc(100% - 52px); }
.side { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px;
  border-right: 1px solid var(--line); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-head select { padding: 4px 8px; font-size: 12px; }
h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.row > button, .row > .filebtn { flex: 1; text-align: center; }
.row.small { font-size: 12px; gap: 12px; }
.row.small select { padding: 3px 6px; font-size: 12px; }

.cam-wrap { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 8px; overflow: hidden; }
.cam-wrap video, .cam-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 20px; color: var(--muted); font-size: 13px; }
.countdown { position: absolute; inset: 0; display: none; place-items: center; font-size: 96px;
  font-weight: 800; color: #fff; text-shadow: 0 0 30px var(--accent); background: rgba(0,0,0,.35); }
.countdown.on { display: grid; }
.rec-dot { position: absolute; top: 8px; left: 8px; display: none; background: var(--rec); color: #fff;
  font: 700 11px var(--mono); padding: 3px 7px; border-radius: 4px; }
.rec-dot.on { display: block; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .4; } }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.metric { background: var(--panel-2); border-radius: 8px; padding: 10px; }
.metric .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.metric .v { font: 600 20px var(--mono); margin-top: 2px; }
.metric .h { font-size: 11px; color: var(--muted); margin-top: 2px; }
.metric.wide { grid-column: span 2; }
.good { color: var(--stand); } .warn { color: var(--trans); } .bad { color: var(--rec); }
.muted { color: var(--muted); margin: 0; grid-column: span 2; }

.stage { display: flex; flex-direction: column; min-width: 0; }
.viewport { position: relative; flex: 1; min-height: 300px; }
.viewport canvas { display: block; }
.hud { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between;
  pointer-events: none; }
.hud > * { pointer-events: auto; }
.phase { font: 700 12px var(--mono); letter-spacing: .1em; padding: 5px 10px; border-radius: 6px;
  border: 1px solid currentColor; color: var(--accent); background: rgba(7,11,20,.7); }
.views { display: flex; gap: 6px; }
.views button { padding: 5px 10px; font-size: 12px; background: rgba(13,20,36,.8); }
.hud-bottom-right { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 12px; align-items: center;
  font-size: 12px; background: rgba(7,11,20,.7); padding: 6px 10px; border-radius: 8px; }
.hud-bottom-right select { padding: 3px 6px; font-size: 12px; }

.transport { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.transport .icon { width: 40px; padding: 7px 0; }
.scrub { position: relative; flex: 1; height: 28px; }
.scrub canvas { position: absolute; left: 0; right: 0; top: 10px; height: 8px; width: 100%; border-radius: 4px; }
.scrub input { position: absolute; inset: 0; width: 100%; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
.scrub input::-webkit-slider-runnable-track { height: 28px; background: transparent; }
.scrub input::-webkit-slider-thumb { -webkit-appearance: none; width: 4px; height: 28px; background: #fff; border-radius: 2px; box-shadow: 0 0 8px var(--accent); }
.scrub input::-moz-range-thumb { width: 4px; height: 28px; background: #fff; border: 0; border-radius: 2px; }
.time { font: 12px var(--mono); color: var(--muted); min-width: 100px; text-align: right; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); }
  .viewport { height: 60vh; }
  .transport { flex-wrap: wrap; }
  .brand .sub { display: none; }
}
