:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #262d38;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #30e3a4;
  --accent-dim: #1b6b52;
  --warn: #e3a330;
  --err: #f0616d;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ── Header ─────────────────────────────────────────────── */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; }
.bar h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(227,163,48,.15);
  transition: background .2s, box-shadow .2s;
}
.dot.ready { background: var(--accent); box-shadow: 0 0 0 3px rgba(48,227,164,.15); }
.dot.error { background: var(--err); box-shadow: 0 0 0 3px rgba(240,97,109,.15); }
.status { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; padding: 12px 20px 0; }
.tab {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}
.tab:hover { color: var(--fg); }
.tab.is-active {
  color: var(--fg);
  background: var(--panel);
  border-color: var(--line);
  border-bottom-color: var(--panel);
}

/* ── Layout ─────────────────────────────────────────────── */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  padding: 0 20px 20px;
  align-items: start;
}
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }

.panel { display: none; }
.panel.is-active { display: block; }

.stage {
  position: relative;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  overflow: hidden;
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stage.dragover { border-color: var(--accent); }
.stage video, .stage img {
  display: block;
  max-width: 100%;
  width: 100%;
  height: auto;
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
#webcam { transform: scaleX(-1); }
#webcamCanvas { transform: scaleX(-1); }

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  gap: 4px;
}
.placeholder p { margin: 0; font-size: 15px; color: var(--fg); }
.placeholder span { font-size: 12px; }
.placeholder.hidden { display: none; }

/* ── Controls ───────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
}
.btn {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: #3a4452; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #d9fff1;
}
.btn-primary:hover:not(:disabled) { background: #227f61; border-color: #227f61; }
.fps { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Readout ────────────────────────────────────────────── */
.readout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.readout h2 {
  margin: 18px 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
}
.readout h2 em { font-style: normal; text-transform: none; letter-spacing: 0; opacity: .7; }

.options { display: flex; flex-wrap: wrap; gap: 10px 14px; font-size: 12.5px; color: var(--muted); }
.options label { display: flex; align-items: center; gap: 5px; cursor: pointer; }
.options input[type="checkbox"] { accent-color: var(--accent); }
.options .num input {
  width: 44px;
  padding: 2px 4px;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.stats div {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.stats span { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stats small { color: var(--muted); font-size: 10.5px; }

.blendshapes { list-style: none; margin: 0; padding: 0; }
.blendshapes li { margin-bottom: 5px; font-size: 12px; }
.blendshapes li.empty { color: var(--muted); }
.bs-row { display: flex; justify-content: space-between; gap: 8px; }
.bs-row b { font-weight: 500; }
.bs-row span { color: var(--muted); font-variant-numeric: tabular-nums; }
.bs-bar { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 2px; }
.bs-bar i { display: block; height: 100%; background: var(--accent); }

.matrix {
  margin: 0;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-x: auto;
}
