:root {
  --bg: #0b1220;
  --panel: #111c2e;
  --panel2: #16233a;
  --line: #243550;
  --text: #e8eef8;
  --muted: #8fa3bf;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --accent: #38bdf8;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 800px at 70% -10%, #16294a 0%, #0b1220 55%) fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.app { min-height: 100vh; display: flex; flex-direction: column; max-width: 1360px; margin: 0 auto; padding: 20px clamp(16px, 3vw, 36px) 16px; gap: 18px; }
.top { display: flex; justify-content: space-between; align-items: center; }
.brand { display: flex; gap: 12px; align-items: center; }
.logo { width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(135deg, #22d3ee, #34d399); display: grid; place-items: center; color: #06202a; font-weight: 800; font-size: 18px; }
h1 { font-size: 19px; margin: 0; letter-spacing: .5px; }
.brand p { margin: 2px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.top-right { display: flex; gap: 10px; align-items: center; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.warn-chip { background: #3a1d1d; color: #fca5a5; border: 1px solid #7f1d1d; padding: 4px 10px; border-radius: 999px; font-size: 12px; }
.stage-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; flex: 1; }
.stage { position: relative; background: #050a13; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 9; min-height: 320px; display: flex; align-items: center; justify-content: center; }
#cam { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: none; }
#cam.on { display: block; }
#overlay { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1); pointer-events: none; }
.placeholder { text-align: center; padding: 24px; max-width: 440px; }
.ph-icon { font-size: 38px; }
.placeholder h2 { margin: 10px 0 6px; font-size: 20px; }
.placeholder p { margin: 6px 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.tiny { font-size: 12px; color: #6f86a6; }
.hud { position: absolute; left: 14px; right: 14px; top: 14px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.pill { display: inline-flex; align-items: center; gap: 8px; background: rgba(8, 15, 28, .72); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, .08); padding: 7px 12px; border-radius: 999px; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px rgba(255, 255, 255, .05); }
.dot.ok { background: var(--green); }
.dot.warn { background: var(--amber); }
.dot.bad { background: var(--red); }
.dot.load { background: var(--accent); }
.metrics { display: flex; gap: 10px; background: rgba(8, 15, 28, .72); border: 1px solid rgba(255, 255, 255, .08); padding: 7px 10px; border-radius: 10px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.metrics b { color: var(--text); font-weight: 600; }
.banner { position: absolute; left: 50%; bottom: 18px; transform: translate(-50%, 20px); background: rgba(12, 20, 35, .95); border: 1px solid var(--line); border-left: 4px solid var(--amber); padding: 12px 16px; border-radius: 12px; display: flex; flex-direction: column; gap: 3px; opacity: 0; transition: transform .25s, opacity .25s; min-width: 240px; max-width: 90%; pointer-events: none; }
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner b { font-size: 14px; }
.banner span { color: var(--muted); font-size: 13px; }
.banner.red { border-left-color: var(--red); }
.banner.amber { border-left-color: var(--amber); }
.banner.info { border-left-color: var(--accent); }
.side { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat span { display: block; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat label { font-size: 11px; color: var(--muted); }
.controls { display: flex; flex-direction: column; gap: 10px; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 10px 12px; transition: border-color .15s, background .15s; }
button:hover { border-color: #33507a; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, #0ea5e9, #22c55e); border: none; color: #04121c; font-weight: 700; padding: 12px; }
button.danger { background: #2a1215; border-color: #5b1d24; color: #fca5a5; }
button.ghost { font-size: 13px; padding: 9px 10px; }
button.link { background: none; border: none; color: var(--muted); padding: 4px; text-decoration: underline; text-underline-offset: 3px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.tips h3 { margin: 0 0 8px; font-size: 13px; color: #b9c9df; }
.tips ul { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.side-actions { text-align: right; }
.foot { color: #5f7594; font-size: 11.5px; text-align: center; }
.foot a { color: #7da2cc; }
.mask { position: fixed; inset: 0; background: rgba(2, 6, 14, .6); backdrop-filter: blur(2px); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(420px, 92vw); background: #0d1728; border-left: 1px solid var(--line); z-index: 50; display: flex; flex-direction: column; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 17px; }
.icon-btn { background: none; border: none; font-size: 18px; color: var(--muted); padding: 4px 8px; }
.drawer-body { padding: 18px 20px 40px; overflow: auto; display: flex; flex-direction: column; gap: 22px; }
.drawer-body h3 { margin: 0 0 10px; font-size: 13px; color: #b9c9df; letter-spacing: .5px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 8px; font-size: 13px; }
.seg button.on { background: #123a52; border-color: #1d6a8c; color: #7dd3fc; }
.field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.field output { color: var(--text); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: #22d3ee; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: #22d3ee; }
.hint { margin: 4px 0 0; font-size: 12px; color: #6f86a6; line-height: 1.6; }
.wide { width: 100%; margin-top: 10px; }
.hidden { display: none !important; }
@media (max-width: 980px) {
  .stage-wrap { grid-template-columns: 1fr; }
  .side { display: grid; grid-template-columns: 1fr 1fr; }
  .tips { grid-column: 1 / -1; }
  .side-actions { grid-column: 1 / -1; text-align: center; }
}
@media (max-width: 640px) {
  .app { padding: 12px; }
  .side { grid-template-columns: 1fr; }
  .stage { aspect-ratio: 4 / 3; }
  .hud { flex-direction: column; }
  .metrics { display: none !important; }
}
