:root {
  --bg: #14161a; --card: #1e2127; --line: #2c3038; --text: #f2f3f5; --muted: #9aa1ad;
  --accent: #ff7a1a; --good: #2fbf71; --bad: #ff5d5d; --warn: #ffb020;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Sarabun", sans-serif;
  font-size: 16px; line-height: 1.5; padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.45rem; margin: .4rem 0 .2rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .5rem; color: var(--muted); font-weight: 600; }
ol, ul { padding-left: 1.2rem; margin: 0; }
li { margin: .25rem 0; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 16px; background: rgba(20,22,26,.94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .3px; white-space: nowrap; }
.brand span { color: var(--accent); }
main { max-width: 680px; margin: 0 auto; padding: 8px 16px 24px; }

.pill { display: inline-flex; align-items: center; gap: 6px; max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: .85rem; cursor: pointer; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.pill-connected .dot { background: var(--good); }
.pill-connecting .dot, .pill-reconnecting .dot { background: var(--warn); animation: blink 1s infinite; }
.pill-error .dot { background: var(--bad); }
@keyframes blink { 50% { opacity: .3; } }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; text-align: center; padding: 14px 4px; color: var(--muted); font-weight: 600; }
.tabs a.on { color: var(--accent); }

.muted { color: var(--muted); font-size: .92rem; }
.center { text-align: center; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row.gap { justify-content: flex-start; gap: 8px; }
.wrap { flex-wrap: wrap; }
.list { display: grid; gap: 10px; margin-top: 12px; }
.card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card.drill:active { border-color: var(--accent); }
.card.warn { border-color: var(--warn); }
.card.hint { border-color: #3a3f4a; display: grid; gap: 10px; }
.card.good { border-color: var(--good); }
.warn { color: var(--warn); }
.banner { background: #3b2a12; color: var(--warn); border-radius: 10px; padding: 8px 12px; margin: 8px 0; font-size: .9rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: #2a2e36; color: #cfd3da; white-space: nowrap; }
.chips.filter .chip { padding: 6px 12px; font-size: .88rem; }
.chip.on { background: var(--accent); color: #111; }
.tag { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 6px; background: #2a2e36; color: #cfd3da; margin-right: 6px; }
.tag.demo { background: #3b2a12; color: var(--warn); }
.tag.bad { background: #3a1d1f; color: var(--bad); }
.tag.good { background: #163325; color: var(--good); }

.btn { display: inline-flex; justify-content: center; align-items: center; min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 0;
  background: var(--accent); color: #111; font: inherit; font-weight: 700; cursor: pointer; text-align: center; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; margin-top: 12px; }
.btn:disabled, .btn.disabled { opacity: .4; pointer-events: none; }
.btn.ghost.big, a.btn.ghost { width: 100%; margin-top: 10px; }
.sticky { position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); padding-top: 8px; background: linear-gradient(transparent, var(--bg) 30%); }

.back { display: inline-block; color: var(--muted); margin: 6px 0; padding: 4px 0; }
.video { position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden; background: #000; margin: 12px 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video.placeholder { display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); background: var(--card); font-size: .9rem; padding: 12px; text-align: center; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 10px 0; }
.grid > div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; }
.grid b { font-size: 1.2rem; }
ul.check { list-style: none; padding: 0; }
ul.check li { padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; margin: 6px 0; }

.progress { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 8px 0; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.stage { text-align: center; padding: 28px 12px; margin: 14px 0; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); }
.stage.wait { border-color: var(--warn); }
.stage.go { border-color: var(--good); }
.big-num { font-size: 2.6rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tick { display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin: 6px 0; background: var(--card); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.tick input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); margin-top: 1px; }
.tick.miss input { accent-color: var(--bad); }
table.shots { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.shots th, .shots td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.shots th { color: var(--muted); font-weight: 600; font-size: .85rem; }

.bars { display: grid; gap: 10px; margin: 8px 0; }
.bar-row { display: grid; grid-template-columns: minmax(0, 9.5rem) 1fr 3rem; align-items: center; gap: 10px; }
.bar-label { font-size: .9rem; overflow-wrap: anywhere; }
.bar { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--bad); border-radius: 6px; }
.bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
pre.log { background: #0d0f12; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: .75rem; max-height: 320px; overflow: auto; white-space: pre-wrap; word-break: break-all; }

/* post-rep review: pass / miss per item */
.verdict { display: flex; gap: 8px; align-items: stretch; margin: 6px 0; }
.verdict-btn { flex: 1; display: flex; gap: 12px; align-items: flex-start; text-align: left; padding: 12px; min-height: 48px;
  background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 12px; font: inherit; cursor: pointer; }
.verdict .mark { flex: none; width: 4.6rem; font-weight: 700; font-size: .9rem; }
.verdict.is-pass .mark { color: var(--good); }
.verdict.is-miss .verdict-btn { border-color: var(--bad); background: #2a1719; }
.verdict.is-miss .mark { color: var(--bad); }
.verdict .vtext { overflow-wrap: anywhere; }
.verdict .remove { flex: none; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.tag.mine { background: #1d2a3f; color: #8fb8ff; }
.add-other { display: flex; gap: 8px; margin: 12px 0 4px; }
.add-other input { flex: 1; min-width: 0; min-height: 44px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: #0d0f12; color: var(--text); font: inherit; }
.add-other input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.small { font-size: .8rem; }
