:root {
  --bg: #0f1115;
  --card: #181b22;
  --line: #2a2f3a;
  --text: #f2f3f5;
  --muted: #8b93a3;
  --accent: #ff7a3d;
  --left: #4fb4ff;
  --right: #ffcc4d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { display: flex; flex-direction: column; min-height: 100dvh; }
button { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a0d05; font-weight: 600; font-size: 18px; padding: 14px 28px; }
.muted { color: var(--muted); }

#stage { position: relative; background: #000; aspect-ratio: 4 / 3; max-height: 60dvh; width: 100%; overflow: hidden; }
#mirror { position: absolute; inset: 0; }
#mirror.flipped { transform: scaleX(-1); }
#video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.pill { position: absolute; top: 10px; left: 10px; background: rgba(0,0,0,.65); padding: 6px 12px; border-radius: 999px; font-weight: 600; }
.pill.small { left: auto; right: 10px; font-weight: 400; font-size: 13px; }
#status.running { background: var(--accent); color: #1a0d05; }
#status.warn { background: #b33; }

#start-screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; background: var(--bg); }
#start-screen h1 { margin: 0; font-size: 24px; }
#start-screen p { margin: 0; max-width: 420px; }
#start-screen .seg { width: 100%; max-width: 420px; }
#start-screen .seg button { font-size: 14px; padding: 8px 10px; }
.file { color: var(--muted); font-size: 14px; text-decoration: underline; cursor: pointer; }
.file input { display: none; }

#panel { padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
#readout { text-align: center; }
#readout span { font-variant-numeric: tabular-nums; font-weight: 700; }
#readout small { display: block; color: var(--muted); font-size: 13px; }
.big span { font-size: clamp(64px, 22vw, 140px); line-height: 1; color: var(--accent); }
.row { display: flex; justify-content: space-around; margin-top: 6px; }
.row span { font-size: 32px; }
#compare { min-height: 1.4em; margin-top: 6px; }
#diag { font-size: 13px; min-height: 1.3em; }

#graph { width: 100%; height: 120px; background: var(--card); border-radius: 10px; }
.legend { font-size: 12px; margin: -4px 0 0; }

.controls { display: flex; flex-direction: column; gap: 14px; }
.group { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 14px; color: var(--muted); }
.label b { color: var(--text); font-weight: 600; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; }
.seg button.on { background: var(--accent); border-color: var(--accent); color: #1a0d05; font-weight: 600; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.buttons { display: flex; gap: 8px; }
.buttons button { flex: 1; }

/* Landscape phones and laptops: camera left, numbers right */
@media (orientation: landscape) and (min-width: 700px) {
  main { flex-direction: row; height: 100dvh; }
  #stage { flex: 1.4; aspect-ratio: auto; max-height: none; height: 100dvh; }
  #panel { flex: 1; overflow-y: auto; max-width: 460px; }
}
