:root {
  --bg: #0d2240; --panel: #16304f; --panel2: #1f416a; --text: #f4f7fb; --muted: #a9bdd6;
  --ok: #7ee2a8; --bad: #ff9c8a; --na: #8aa0bb; --gold: #ffd23f;
  font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
button, select, input { font: inherit; }
button, select { background: var(--panel2); color: var(--text); border: 1px solid #36598a; border-radius: 10px; padding: 8px 12px; cursor: pointer; }
button.primary { background: #2b7a4b; border-color: #3fa868; }
button.danger { background: #6b2a2a; border-color: #94403e; }
button:disabled { opacity: .5; }
input { background: #0b1b33; color: var(--text); border: 1px solid #36598a; border-radius: 8px; padding: 8px; width: 100%; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 12px; background: #0a1a31; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; } .tag { font-weight: 400; font-size: 12px; color: var(--gold); margin-left: 6px; }
.controls { display: flex; gap: 6px; flex-wrap: wrap; }
#pose { max-width: 62vw; }
.layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 12px; padding: 12px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.stage { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; }
.stage.portrait { aspect-ratio: 3 / 4; }
#video, #overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.mirror #video, .mirror #overlay { transform: scaleX(-1); }
.refimg { position: absolute; right: 8px; top: 8px; height: 34%; background: #fff; border-radius: 8px; opacity: .92; }
.status { position: absolute; left: 8px; top: 8px; background: rgba(0,0,0,.6); padding: 4px 10px; border-radius: 8px; font-size: 14px; max-width: 60%; }
.coach { margin-top: 8px; background: #0a1a31; border-radius: 10px; padding: 8px 12px; font-size: clamp(18px, 3.2vw, 32px); font-weight: 700; text-align: center; min-height: 1.6em; }
.legend { margin-top: 6px; }
.lg { display: inline-block; width: 22px; height: 5px; border-radius: 3px; vertical-align: middle; }
.lg.used { background: #7ee2a8; } .lg.unused { background: rgba(232,241,255,.35); } .lg.ext { background: #9fd8ff; }
.holdbar { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: rgba(255,255,255,.12); }
.holdbar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .1s linear; }
.repline { display: flex; gap: 14px; flex-wrap: wrap; padding: 8px 2px; font-size: 15px; }
#reps { color: var(--gold); font-weight: 700; }
.card { background: var(--panel); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.card h3 { margin: 2px 0 8px; font-size: 17px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
table.comps { width: 100%; border-collapse: collapse; font-size: 14px; }
table.comps td, table.comps th { padding: 4px 4px; border-bottom: 1px solid #24476f; text-align: left; }
table.comps th { color: var(--muted); font-weight: 400; }
td.st { font-weight: 700; text-align: center; width: 28px; }
.pass { color: var(--ok); } .fail { color: var(--bad); } .na { color: var(--na); }
.trial { background: var(--panel2); border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.trial .sys { font-size: 15px; }
.trial .row button { flex: 1; font-size: 17px; padding: 10px; }
.btn-ok { background: #2b7a4b !important; } .btn-bad { background: #8a3b2f !important; }
.stats { font-size: 15px; line-height: 1.6; }
.stats table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; }
.stats td, .stats th { border-bottom: 1px solid #24476f; padding: 3px; text-align: left; }
dialog { background: var(--panel); color: var(--text); border: 1px solid #36598a; border-radius: 14px; width: min(440px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
.settings label { display: block; margin: 10px 0; }
.settings label.check { display: flex; gap: 8px; align-items: center; }
.settings label.check input { width: auto; }
