/* Muay Thai Coach — design system and components (no framework).
 *
 * Themes: light tokens on :root; dark tokens when the OS prefers dark (unless
 * the user forced light) or when data-theme="dark" is set on <html>.
 * Layout targets a maximised MacBook window first (≈1440×820 viewport), then
 * tablets and phones. The training views also have a "focus" mode with very
 * large type for reading the screen from 3 m away.
 */

/* ------------------------------------------------------------------ fonts */
/* Noto Sans Thai (SIL Open Font License), Thai subset, self-hosted so Thai
   names render on every device. Only used for Thai code points. */
@font-face {
  font-family: "Noto Sans Thai";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/noto-sans-thai.woff2") format("woff2");
  unicode-range: U+02D7, U+0303, U+0331, U+0E01-0E5B, U+200C-200D, U+25CC;
}

/* ------------------------------------------------------------------ tokens */
:root {
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans Thai", "Noto Sans", Thonburi, "Leelawadee UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-thai: "Noto Sans Thai", Thonburi, "Sukhumvit Set", "Leelawadee UI", Tahoma, ui-sans-serif, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #f5f3ef;
  --bg-tint: radial-gradient(1100px 520px at 85% -12%, rgba(214, 64, 43, 0.07), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f0ede8;
  --surface-3: #e7e3dc;
  --sunken: #ebe8e2;
  --stage: #101215;
  --line: rgba(24, 22, 20, 0.09);
  --line-2: rgba(24, 22, 20, 0.16);
  --text: #18181a;
  --text-2: #55565b;
  --text-3: #8a8b90;
  --accent: #d6402b;
  --accent-2: #b8321f;
  --accent-ink: #ffffff;
  --accent-soft: rgba(214, 64, 43, 0.1);
  --gold: #a87508;
  --gold-soft: rgba(196, 140, 20, 0.14);
  --blue: #2563d9;
  --blue-soft: rgba(37, 99, 217, 0.11);
  --red: #d6402b;
  --good: #16884a;
  --good-soft: rgba(22, 136, 74, 0.11);
  --warn: #b86e00;
  --warn-soft: rgba(212, 132, 0, 0.13);
  --bad: #cf3326;
  --bad-soft: rgba(207, 51, 38, 0.1);
  --focus: 0 0 0 3px rgba(214, 64, 43, 0.35);
  --shadow-1: 0 1px 2px rgba(20, 16, 12, 0.06), 0 1px 1px rgba(20, 16, 12, 0.04);
  --shadow-2: 0 10px 30px -12px rgba(20, 16, 12, 0.22), 0 2px 6px rgba(20, 16, 12, 0.05);
  --shadow-3: 0 24px 60px -20px rgba(20, 16, 12, 0.35);
  --glass: rgba(245, 243, 239, 0.78);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --header-h: 60px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0d10;
    --bg-tint: radial-gradient(1100px 520px at 85% -12%, rgba(255, 90, 60, 0.1), transparent 60%);
    --surface: #15171b;
    --surface-2: #1b1e23;
    --surface-3: #23272d;
    --sunken: #0f1013;
    --stage: #07080a;
    --line: rgba(255, 255, 255, 0.07);
    --line-2: rgba(255, 255, 255, 0.13);
    --text: #f2f0ec;
    --text-2: #a8abb2;
    --text-3: #6d7179;
    --accent: #ff5a3c;
    --accent-2: #ff7a5f;
    --accent-ink: #160805;
    --accent-soft: rgba(255, 90, 60, 0.14);
    --gold: #f2b84b;
    --gold-soft: rgba(242, 184, 75, 0.13);
    --blue: #5b95ff;
    --blue-soft: rgba(91, 149, 255, 0.14);
    --red: #ff5a3c;
    --good: #3ccf7e;
    --good-soft: rgba(60, 207, 126, 0.13);
    --warn: #f5a524;
    --warn-soft: rgba(245, 165, 36, 0.14);
    --bad: #ff5c4d;
    --bad-soft: rgba(255, 92, 77, 0.13);
    --focus: 0 0 0 3px rgba(255, 90, 60, 0.4);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 28px 70px -20px rgba(0, 0, 0, 0.8);
    --glass: rgba(12, 13, 16, 0.72);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0d10;
  --bg-tint: radial-gradient(1100px 520px at 85% -12%, rgba(255, 90, 60, 0.1), transparent 60%);
  --surface: #15171b;
  --surface-2: #1b1e23;
  --surface-3: #23272d;
  --sunken: #0f1013;
  --stage: #07080a;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.13);
  --text: #f2f0ec;
  --text-2: #a8abb2;
  --text-3: #6d7179;
  --accent: #ff5a3c;
  --accent-2: #ff7a5f;
  --accent-ink: #160805;
  --accent-soft: rgba(255, 90, 60, 0.14);
  --gold: #f2b84b;
  --gold-soft: rgba(242, 184, 75, 0.13);
  --blue: #5b95ff;
  --blue-soft: rgba(91, 149, 255, 0.14);
  --red: #ff5a3c;
  --good: #3ccf7e;
  --good-soft: rgba(60, 207, 126, 0.13);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.14);
  --bad: #ff5c4d;
  --bad-soft: rgba(255, 92, 77, 0.13);
  --focus: 0 0 0 3px rgba(255, 90, 60, 0.4);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 28px 70px -20px rgba(0, 0, 0, 0.8);
  --glass: rgba(12, 13, 16, 0.72);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg-tint), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.55 var(--font);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, canvas, video, svg { max-width: 100%; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-xs); }
::selection { background: var(--accent-soft); }

h1, h2, h3, h4 { margin: 0 0 0.45em; line-height: 1.2; letter-spacing: -0.015em; font-weight: 700; }
h1 { font-size: clamp(1.7rem, 2.4vw, 2.3rem); letter-spacing: -0.025em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.8em; }
ul, ol { margin: 0 0 0.8em; padding-left: 1.25em; }
li + li { margin-top: 0.25em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 0.86rem; }
.tiny { font-size: 0.76rem; }
.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); }
.thai { font-family: var(--font-thai); line-height: 1.5; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-tight { display: flex; align-items: center; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 16px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; z-index: 100; padding: 8px 12px; background: var(--accent); color: var(--accent-ink); border-radius: var(--radius-xs); }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.icon-lg { width: 22px; height: 22px; }

/* ------------------------------------------------------------------ header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) clamp(14px, 2.4vw, 32px) 0;
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--glass);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand-name { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name b { font-size: 0.98rem; letter-spacing: -0.01em; }
.brand-name span { font-family: var(--font-thai); font-size: 0.72rem; color: var(--text-3); letter-spacing: 0.02em; }
.nav { display: flex; gap: 2px; margin-left: 8px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.nav a.active .icon { color: var(--accent); }
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }

/* Mobile bottom navigation */
.tabbar { display: none; }
@media (max-width: 760px) {
  :root { --header-h: 54px; }
  .nav { display: none; }
  .brand-name span { display: none; }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--glass);
    -webkit-backdrop-filter: saturate(160%) blur(18px);
    backdrop-filter: saturate(160%) blur(18px);
    border-top: 1px solid var(--line);
  }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 0.68rem; font-weight: 600; text-decoration: none; color: var(--text-3); border-radius: 10px; }
  .tabbar a.active { color: var(--accent); }
  .tabbar .icon { width: 22px; height: 22px; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
}

/* ------------------------------------------------------------------ page */
.page { width: min(1320px, 100%); margin: 0 auto; padding: clamp(18px, 2.6vw, 34px) clamp(14px, 2.4vw, 32px) 48px; }
.page-wide { width: min(1680px, 100%); }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--text-2); max-width: 70ch; }
.section { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.loading-page { display: grid; place-items: center; min-height: 50vh; color: var(--text-3); }

.site-footer { padding: 24px clamp(14px, 2.4vw, 32px) 36px; color: var(--text-3); font-size: 0.8rem; text-align: center; }

/* ------------------------------------------------------------------ surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 18px;
}
.card-flat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card h3 { margin-bottom: 0.35em; }
.card-link { text-decoration: none; display: block; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s; }
.card-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); border-color: var(--line-2); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.kbd { font: 600 0.75rem var(--mono); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: 0 6px 18px -8px var(--accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-dark { background: var(--text); color: var(--bg); border-color: transparent; }
.btn-dark:hover { background: var(--text-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.84rem; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 1rem; }
.btn-xl { height: 58px; padding: 0 30px; font-size: 1.1rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.on { color: var(--accent); background: var(--accent-soft); }
.icon-btn-sm { width: 30px; height: 30px; }
.icon-btn-solid { background: var(--surface); border-color: var(--line-2); color: var(--text); }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button {
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-weight: 600;
  font-size: 0.84rem;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.seg-sm button { height: 26px; padding: 0 9px; font-size: 0.78rem; }

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip.on { background: var(--text); color: var(--bg); border-color: transparent; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge-gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.badge-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ------------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 0.8rem; font-weight: 700; color: var(--text-2); }
select, input[type="text"], input[type="number"], input[type="url"], textarea {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}
select { padding-right: 30px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
select:hover, input:hover { border-color: var(--text-3); }
input[type="range"] { accent-color: var(--accent); width: 100%; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }

/* Toggle switch: <label class="switch"><input type="checkbox"><span></span></label> */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-2); transition: background 0.18s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); transition: transform 0.18s; }
.switch input:checked + span { background: var(--accent); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--focus); }

.setting-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 14px 0; border-top: 1px solid var(--line); }
.setting-row:first-of-type { border-top: 0; }
/* Label and control side by side when they fit; otherwise the control
   wraps under the label (a long segmented control overlapped its label in
   the two-column exam setup at tablet-landscape widths). */
.setting-row .setting-text { flex: 1 1 180px; min-width: 0; }
.setting-row .setting-text b { display: block; font-size: 0.94rem; }
.setting-row .setting-text span { display: block; color: var(--text-2); font-size: 0.84rem; margin-top: 2px; }
.setting-control { flex: 0 1 auto; min-width: 0; max-width: 100%; display: flex; align-items: center; gap: 8px; }
@media (max-width: 640px) {
  .setting-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .setting-row .setting-text { flex: none; } /* a flex-basis would become a height here */
  .setting-control { justify-content: flex-start; }
}

progress { appearance: none; -webkit-appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width 0.2s; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* ------------------------------------------------------------------ move names */
.move-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.move-name .th { font-family: var(--font-thai); font-weight: 700; font-size: 1.05rem; line-height: 1.35; color: var(--text); }
.move-name .rom { font-weight: 650; font-size: 0.86rem; color: var(--accent); letter-spacing: 0.01em; }
.move-name .tr { font-size: 0.84rem; color: var(--text-2); }
.move-name.lg .th { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.25; letter-spacing: 0; }
.move-name.lg .rom { font-size: 1.15rem; }
.move-name.lg .tr { font-size: 1rem; }
.say-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px 0 9px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); font-size: 0.8rem; font-weight: 700; }
.say-btn:hover { color: var(--accent); border-color: var(--accent); }
.say-btn.playing { color: var(--accent-ink); background: var(--accent); border-color: transparent; }
.pron { font: 600 0.82rem var(--mono); color: var(--text-3); }

/* ------------------------------------------------------------------ home */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: clamp(18px, 3vw, 44px);
  align-items: center;
  min-height: min(560px, calc(100vh - 160px));
}
.hero h1 { font-size: clamp(2.2rem, 4.6vw, 3.9rem); line-height: 1.02; letter-spacing: -0.04em; margin-bottom: 0.3em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero .lead { font-size: clamp(1rem, 1.3vw, 1.15rem); color: var(--text-2); max-width: 46ch; margin-bottom: 1.4em; }
.hero .btn-lg { padding: 0 20px; }
.hero-figure { position: relative; aspect-ratio: 1 / 1; max-height: 560px; width: 100%; border-radius: 28px; overflow: hidden; background: radial-gradient(70% 60% at 50% 35%, var(--surface-3), var(--surface-2) 60%, var(--sunken)); border: 1px solid var(--line); box-shadow: var(--shadow-2); }
.hero-figure canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-figure .hero-caption { position: absolute; left: 18px; bottom: 16px; right: 18px; display: flex; align-items: flex-end; gap: 12px; pointer-events: none; }
.hero-stats { display: flex; gap: 22px; margin-top: 26px; flex-wrap: wrap; }
.hero-stats div b { display: block; font-size: 1.5rem; letter-spacing: -0.02em; }
.hero-stats div span { font-size: 0.8rem; color: var(--text-3); }
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-figure { aspect-ratio: 4 / 3; }
}

.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.feature { position: relative; overflow: hidden; }
.feature .icon-wrap { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 12px; }
.feature p { color: var(--text-2); font-size: 0.9rem; margin: 0; }
.feature .go { position: absolute; top: 18px; right: 18px; color: var(--text-3); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cat-tile { display: flex; flex-direction: column; gap: 8px; padding: 16px; }
.cat-tile .cat-top { display: flex; align-items: center; justify-content: space-between; }
.cat-tile .th { font-family: var(--font-thai); font-weight: 700; font-size: 1.05rem; }
.cat-tile .meter { height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.cat-tile .meter i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ------------------------------------------------------------------ learn */
.learn { display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 26px; align-items: start; }
.learn-side { position: sticky; top: calc(var(--header-h) + 20px); display: flex; flex-direction: column; gap: 2px; }
.learn-side .side-title { margin: 14px 10px 6px; }
.learn-side .side-title:first-child { margin-top: 0; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; text-decoration: none; color: var(--text-2); font-weight: 600; font-size: 0.9rem; border: 0; background: none; text-align: left; width: 100%; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.side-link .count { margin-left: auto; font-size: 0.75rem; color: var(--text-3); font-weight: 600; }
.side-link .th { font-family: var(--font-thai); font-size: 0.78rem; color: var(--text-3); font-weight: 500; }
.learn-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search input { width: 100%; padding-left: 36px; border-radius: 999px; }
.search .icon { position: absolute; left: 12px; top: 10px; color: var(--text-3); }
.tech-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.tech-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tech-card .thumb { position: relative; aspect-ratio: 4 / 3; background: radial-gradient(80% 70% at 50% 30%, var(--surface-3), var(--surface-2)); border-bottom: 1px solid var(--line); }
.tech-card .thumb img, .tech-card .thumb canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tech-card .thumb .badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 5px; }
.tech-card .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.tech-card .foot { display: flex; align-items: center; gap: 6px; margin-top: auto; }
.cat-section + .cat-section { margin-top: 34px; }
.cat-section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.cat-section-head h2 { margin: 0; }
.cat-section-head .th { font-family: var(--font-thai); color: var(--text-3); font-weight: 600; }
@media (max-width: 900px) {
  .learn { grid-template-columns: 1fr; }
  .learn-side { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; scrollbar-width: none; }
  .learn-side .side-title { display: none; }
  .side-link { width: auto; white-space: nowrap; border: 1px solid var(--line); }
  .side-link .th, .side-link .count { display: none; }
}

/* Technique detail */
.detail { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(330px, 0.85fr); gap: 24px; align-items: start; }
.detail-stage { position: sticky; top: calc(var(--header-h) + 16px); }
.viewer {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: calc(100vh - var(--header-h) - 150px);
  border-radius: 22px;
  overflow: hidden;
  background: radial-gradient(75% 65% at 50% 30%, var(--surface-3), var(--surface-2) 55%, var(--sunken));
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  touch-action: none;
}
.viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.viewer canvas:active { cursor: grabbing; }
.viewer-hud { position: absolute; inset: 12px 12px auto 12px; display: flex; align-items: flex-start; gap: 8px; pointer-events: none; }
.viewer-hud > * { pointer-events: auto; }
.viewer-phase { position: absolute; left: 16px; bottom: 14px; right: 16px; display: flex; align-items: flex-end; gap: 10px; pointer-events: none; }
.phase-pill { display: inline-flex; flex-direction: column; padding: 8px 12px; border-radius: 12px; background: var(--glass); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--line); max-width: 70%; }
.phase-pill b { font-size: 0.92rem; }
.phase-pill span { font-size: 0.75rem; color: var(--text-3); }
.player-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.scrub { flex: 1; min-width: 140px; display: flex; align-items: center; gap: 8px; }
.scrub input { flex: 1; }
.layer-toggles { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.detail-info { display: flex; flex-direction: column; gap: 16px; }
.detail-head { display: flex; flex-direction: column; gap: 10px; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: step; position: relative; padding-left: 36px; margin: 0; color: var(--text); }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 0.78rem; font-weight: 800; display: grid; place-items: center; }
.bullets { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.bullets li { position: relative; padding-left: 26px; margin: 0; }
.bullets li .icon { position: absolute; left: 0; top: 3px; width: 16px; height: 16px; }
.bullets.good .icon { color: var(--good); }
.bullets.bad .icon { color: var(--bad); }
.bullets.info .icon { color: var(--blue); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.metric { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.metric b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.metric span { font-size: 0.72rem; color: var(--text-3); font-weight: 600; }
.metric.good b { color: var(--good); }
.metric.warn b { color: var(--warn); }
.metric.bad b { color: var(--bad); }
@media (max-width: 980px) {
  .detail { grid-template-columns: 1fr; }
  .detail-stage { position: static; }
}

/* ------------------------------------------------------------------ live / train */
.train { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.train-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stage {
  position: relative;
  container-type: inline-size; /* cqw: on-stage text scales with the stage */
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - var(--header-h) - 120px);
  background: var(--stage);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-2);
  color: #f4f2ee;
}
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.stage video.mirror { transform: scaleX(-1); }
.stage canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.stage-top { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; pointer-events: none; z-index: 3; }
.hud-pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; background: rgba(10, 11, 13, 0.6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); color: #e9e7e3; font-size: 0.75rem; font-weight: 700; border: 1px solid rgba(255, 255, 255, 0.08); }
.hud-pill.warn { background: rgba(245, 165, 36, 0.9); color: #1b1203; }
.hud-pill.bad { background: rgba(255, 92, 77, 0.92); color: #fff; }
.hud-pill.good { background: rgba(60, 207, 126, 0.9); color: #04140a; }
.hud-pill.rec { background: rgba(255, 59, 48, 0.92); color: #fff; }
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; background: radial-gradient(60% 60% at 50% 45%, rgba(20, 22, 26, 0.75), rgba(7, 8, 10, 0.94)); z-index: 5; }
.stage-msg > div { max-width: 520px; }
.stage-msg h2 { font-size: clamp(1.3rem, 2.4vw, 1.9rem); color: #fff; }
.stage-msg p { color: #b9bcc3; }
.stage-banner { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); z-index: 4; width: max-content; padding: 12px 22px; border-radius: 18px; background: rgba(10, 11, 13, 0.72); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.1); text-align: center; max-width: 86%; }
.stage-banner .big { font-size: clamp(1.1rem, 2.2vw, 1.7rem); font-weight: 800; letter-spacing: -0.01em; }
.stage-banner .sub { color: #b9bcc3; font-size: 0.86rem; }
.stage-guide { position: absolute; inset: 0; z-index: 2; display: grid; place-items: center; pointer-events: none; }
.stage-guide svg { height: 86%; opacity: 0.32; }
.stage-corner { position: absolute; right: 12px; bottom: 12px; width: 26%; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: rgba(12, 13, 16, 0.55); border: 1px solid rgba(255, 255, 255, 0.1); z-index: 3; }
.stage-corner canvas { width: 100%; height: 100%; }
.stage-feedback { position: absolute; left: 16px; bottom: 16px; z-index: 4; display: flex; flex-direction: column; gap: 6px; max-width: 60%; pointer-events: none; }
.calib { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 4; width: min(420px, 86%); padding: 14px 18px; border-radius: 18px; background: rgba(10, 11, 13, 0.78); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid rgba(255, 255, 255, 0.1); text-align: center; display: flex; flex-direction: column; gap: 8px; }
.calib .big { font-weight: 800; font-size: 1.05rem; }
.calib .small { color: #b9bcc3; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-tabs { display: flex; }
.panel-body { min-height: 200px; }
.feed { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - var(--header-h) - 360px); min-height: 160px; overflow-y: auto; padding-right: 2px; }
.feed-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.feed-item.new { animation: pop 0.35s ease; }
.feed-item .title { font-weight: 700; font-size: 0.92rem; }
.feed-item .meta { font-size: 0.76rem; color: var(--text-3); }
.feed-item .tips { grid-column: 1 / -1; font-size: 0.82rem; color: var(--text-2); white-space: pre-line; }
.feed-item .checks { grid-column: 1 / -1; }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
.empty { padding: 28px 16px; text-align: center; color: var(--text-3); font-size: 0.88rem; border: 1px dashed var(--line-2); border-radius: 14px; }
@media (max-width: 1100px) {
  .train { grid-template-columns: 1fr; }
  .feed { max-height: 360px; }
}

/* Score ring */
.score { display: inline-grid; place-items: center; border-radius: 50%; font-weight: 800; font-variant-numeric: tabular-nums; flex: none; }
.score-md { width: 40px; height: 40px; font-size: 0.95rem; }
.score-lg { width: 64px; height: 64px; font-size: 1.4rem; }
.score-good { background: var(--good-soft); color: var(--good); box-shadow: inset 0 0 0 2px var(--good); }
.score-warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); }
.score-bad { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }
.score-na { background: var(--surface-2); color: var(--text-3); box-shadow: inset 0 0 0 2px var(--line-2); }

/* Check list */
.checks { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.check { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); margin: 0; }
.check-icon { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; font-weight: 900; }
.check-good .check-icon { background: var(--good-soft); color: var(--good); }
.check-warn .check-icon { background: var(--warn-soft); color: var(--warn); }
.check-bad .check-icon { background: var(--bad-soft); color: var(--bad); }
.check-label { font-weight: 600; font-size: 0.86rem; }
.check-value { font-size: 0.78rem; color: var(--text-3); font-variant-numeric: tabular-nums; }
.check-tip { grid-column: 2 / -1; font-size: 0.8rem; color: var(--text-2); }
.checks.compact .check { padding: 6px 8px; }

.rep-bar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; }
.rep-dot { aspect-ratio: 1; border-radius: 9px; display: grid; place-items: center; font-size: 0.74rem; font-weight: 800; background: var(--surface-2); color: var(--text-3); border: 1px solid var(--line); }
.rep-dot.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.rep-dot.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.rep-dot.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

.combo-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.combo-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.84rem; font-weight: 600; }
.combo-chip.current { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.combo-chip.done { background: var(--good-soft); color: var(--good); border-color: transparent; }
.combo-chip.missed { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.combo-arrow { color: var(--text-3); font-size: 0.8rem; }

/* Focus (distance) mode: the stage fills the window and type gets huge. */
body.focus-mode { overflow: hidden; }
body.focus-mode .app-header, body.focus-mode .tabbar, body.focus-mode .site-footer { display: none; }
.focus-shell { position: fixed; inset: 0; z-index: 60; background: #050506; display: grid; grid-template-rows: minmax(0, 1fr); }
.focus-shell .stage { max-height: none; height: 100%; aspect-ratio: auto; border-radius: 0; }
.focus-shell .stage-banner { top: 4vh; padding: 2vh 3vw; border-radius: 24px; }
.focus-shell .stage-banner .big { font-size: clamp(2rem, 6vw, 5.5rem); }
.focus-shell .stage-banner .sub { font-size: clamp(1rem, 2.2vw, 2rem); }
.focus-shell .hud-pill { height: auto; padding: 0.4vh 1.2vw; font-size: clamp(0.8rem, 1.5vw, 1.4rem); }
/* Read from 2.5–3.5 m: round clock bottom-left, calibration and messages big. */
.focus-shell .hud-pill.stage-timer { position: fixed; left: 2vw; bottom: 2.5vh; padding: 0.5vh 1.6vw; font-size: clamp(1.4rem, 3.6vw, 3.6rem); font-variant-numeric: tabular-nums; }
.focus-shell .calib { width: min(56vw, 940px); bottom: 14vh; padding: 2.2vh 2.4vw; gap: 1.4vh; border-radius: 24px; }
.focus-shell .stage-corner { width: 20%; }
/* A framing problem stalls calibration: show only the gate hint meanwhile. */
.stage:has(> .gate-hint:not([hidden])) > .calib { display: none; }
.focus-shell .calib .big { font-size: clamp(1.6rem, 4vw, 4rem); line-height: 1.15; }
.focus-shell .calib .small { font-size: clamp(1rem, 2.2vw, 2.2rem); }
.focus-shell .calib progress { height: clamp(8px, 1.4vh, 16px); }
.focus-shell .stage-msg > div { max-width: min(80vw, 1100px); }
.focus-shell .stage-msg h2 { font-size: clamp(1.6rem, 3.8vw, 3.8rem); }
.focus-shell .stage-msg p { font-size: clamp(1rem, 1.9vw, 1.9rem); }
.focus-shell .stage-banner .combo-chips { justify-content: center; gap: 0.6vw; margin-top: 1vh; }
.focus-shell .stage-banner .combo-chip { font-size: clamp(1rem, 2.6vw, 2.6rem); padding: 0.2em 0.55em; border-radius: 0.4em; }
.focus-shell .stage-banner .combo-arrow { font-size: clamp(1rem, 2.4vw, 2.4rem); color: #b9bcc3; }
/* The banner is always dark: fixed high-contrast chip colours in both themes. */
.stage-banner .combo-chip { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.16); color: #eceef2; }
.stage-banner .combo-chip.current { background: rgba(255, 90, 60, 0.2); border-color: #ff8a6f; color: #ffb3a1; }
.stage-banner .combo-chip.done { background: rgba(60, 207, 126, 0.2); border-color: transparent; color: #5ee89c; }
.stage-banner .combo-chip.missed { background: rgba(255, 92, 77, 0.22); border-color: transparent; color: #ff8577; text-decoration: line-through; }
/* The big technique flash replaces the banner while it shows (they overlapped). */
.stage-banner { transition: opacity 0.15s; }
.stage:has(> .big-flash:not([hidden])) > .stage-banner { opacity: 0; }
.focus-exit { position: absolute; top: 14px; right: 14px; z-index: 8; }
.big-flash { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; pointer-events: none; }
.big-flash > div { text-align: center; padding: 2vh 4vw; border-radius: 28px; background: rgba(8, 9, 11, 0.62); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: flashIn 0.25s ease; }
.big-flash .bf-title { font-size: clamp(1.8rem, 6vw, 6rem); font-weight: 900; letter-spacing: -0.03em; line-height: 1.05; }
.big-flash .bf-sub { font-size: clamp(1rem, 2.4vw, 2.2rem); color: #c9ccd2; margin-top: 0.4em; }
.big-flash .bf-score { font-size: clamp(3rem, 12vw, 11rem); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.big-flash.good .bf-score, .big-flash.good .bf-title { color: #4be08f; }
.big-flash.warn .bf-score, .big-flash.warn .bf-title { color: #ffb84a; }
.big-flash.bad .bf-score, .big-flash.bad .bf-title { color: #ff6b5c; }
@keyframes flashIn { from { transform: scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ exam */
.exam { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 26vw, 380px); gap: 18px; align-items: start; }
.exam-stage { position: relative; container-type: inline-size; aspect-ratio: 16 / 9; max-height: calc(100vh - var(--header-h) - 120px); width: 100%; border-radius: 22px; overflow: hidden; background: var(--stage); box-shadow: var(--shadow-2); color: #f4f2ee; }
.exam-stage:fullscreen { aspect-ratio: auto; max-height: none; border-radius: 0; }
.exam-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0.55; }
.exam-stage video.mirror { transform: scaleX(-1); }
.exam-stage canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Drill text is read from 2.5–3.5 m: sized to the stage (1cqw ≈ 10 px on a
   maximised 13–15" laptop), call-out and verdict ≥ 64 px there. */
.callout { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2cqw 3cqw; pointer-events: none; }
.callout-text { display: flex; flex-direction: column; align-items: center; gap: 0.4cqw; max-width: 100%; padding: 1cqw 6cqw 1.6cqw; background: radial-gradient(closest-side, rgba(5, 6, 8, 0.66), rgba(5, 6, 8, 0.45) 62%, rgba(5, 6, 8, 0)); }
.callout .c-num { font-size: clamp(13px, 2.2cqw, 36px); font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: rgba(255, 255, 255, 0.72); font-variant-numeric: tabular-nums; }
.callout .c-th { font-family: var(--font-thai); font-size: clamp(40px, 12cqw, 220px); font-weight: 800; line-height: 1.32; color: #fff; text-shadow: 0 4px 30px rgba(0, 0, 0, 0.7); max-width: 100%; }
.callout .c-th .icon { width: 0.8em; height: 0.8em; stroke-width: 1.6; }
.callout .c-rom { font-size: clamp(24px, 6.6cqw, 120px); font-weight: 800; line-height: 1.12; color: #ff9178; letter-spacing: -0.01em; text-shadow: 0 2px 20px rgba(0, 0, 0, 0.7); }
.callout .c-tr { font-size: clamp(17px, 3.6cqw, 64px); font-weight: 650; line-height: 1.25; color: #eceef2; text-shadow: 0 2px 16px rgba(0, 0, 0, 0.7); }
.callout .c-hidden { filter: blur(14px); opacity: 0.5; }
/* Review: the verdict is the headline, the answer shrinks above it. */
.exam-stage.review .c-th { font-size: clamp(30px, 7.6cqw, 140px); }
.exam-stage.review .c-rom { font-size: clamp(20px, 4.4cqw, 80px); }
.exam-stage.review .c-tr { font-size: clamp(15px, 3.2cqw, 56px); }
.exam-stage.review .exam-pip, .exam-stage.review .gate-hint { display: none; }
.timer-ring { position: absolute; right: 2.5cqw; top: 2.5cqw; z-index: 4; width: clamp(64px, 15cqw, 240px); aspect-ratio: 1; }
.timer-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring circle { fill: none; stroke-width: 9; }
.timer-ring .track { stroke: rgba(255, 255, 255, 0.18); }
.timer-ring .bar { stroke: #ff5a3c; stroke-linecap: round; transition: stroke-dashoffset 0.1s linear; }
.timer-ring .t { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 900; font-size: clamp(22px, 6cqw, 96px); font-variant-numeric: tabular-nums; color: #fff; }
.verdict { display: flex; align-items: center; gap: 0.3em; margin-top: 1.2cqw; padding: 0.2em 0.55em; max-width: 100%; border-radius: 0.32em; background: rgba(8, 9, 11, 0.86); border: 0.06em solid currentColor; font-size: clamp(22px, 6.8cqw, 124px); font-weight: 900; line-height: 1.12; text-align: left; animation: flashIn 0.25s ease; }
.verdict > .icon { width: 1em; height: 1em; stroke-width: 2.6; }
.verdict.pass { color: #4be08f; }
.verdict.close { color: #ffb84a; }
.verdict.fail { color: #ff6b5c; }
.verdict .v-main { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.verdict .v-sub { font-size: max(14px, 0.48em); color: #e6e8ec; font-weight: 700; line-height: 1.3; }
.verdict .v-sub .thai { line-height: 1.3; }
.exam-pip { position: absolute; left: 1.4cqw; bottom: 1.4cqw; width: 18cqw; aspect-ratio: 1; border-radius: 16px; overflow: hidden; z-index: 4; background: rgba(12, 13, 16, 0.6); border: 1px solid rgba(255, 255, 255, 0.1); }
.exam-pip canvas { width: 100%; height: 100%; }
/* Camera gate hint (views/train.js GateHint): exam = bottom centre, Train = middle. */
.gate-hint { position: absolute; left: 50%; bottom: 2.5cqw; transform: translateX(-50%); z-index: 7; width: max-content; max-width: 92%; display: flex; align-items: center; gap: 0.45em; padding: 0.3em 0.6em 0.36em; border-radius: 0.36em; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); font-size: clamp(22px, 6.4cqw, 104px); text-align: left; pointer-events: none; animation: flashIn 0.25s ease; }
.gate-hint.mid { top: 50%; bottom: auto; transform: translate(-50%, -50%); }
/* Exam: while the hint shows, the call-out moves up and the live pip steps aside. */
.exam-stage:has(> .gate-hint:not([hidden])) .callout { justify-content: flex-start; padding-top: 3cqw; }
.exam-stage:has(> .gate-hint:not([hidden])) .c-th { font-size: clamp(36px, 9cqw, 160px); }
.exam-stage:has(> .gate-hint:not([hidden])) .exam-pip { display: none; }
.gate-hint.warn { background: #f5a524; color: #1b1203; }
.gate-hint.bad { background: #d92d20; color: #fff; }
.gate-hint > .icon { width: 1em; height: 1em; stroke-width: 2.4; }
.gate-hint .g-head { font-weight: 900; line-height: 1.1; letter-spacing: -0.01em; }
.gate-hint .g-text { font-size: max(14px, 0.5em); font-weight: 700; line-height: 1.25; margin-top: 0.15em; }
.exam-progress { display: flex; gap: 3px; flex-wrap: wrap; }
.exam-progress i { width: 14px; height: 6px; border-radius: 3px; background: var(--surface-3); }
.exam-progress i.pass { background: var(--good); }
.exam-progress i.close { background: var(--warn); }
.exam-progress i.fail { background: var(--bad); }
.exam-progress i.cur { background: var(--accent); }
.result-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.result-row + .result-row { margin-top: 6px; }
.pool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.pool-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); cursor: pointer; }
.pool-item input { flex: none; }
.pool-item .th { font-family: var(--font-thai); font-weight: 700; }
.quiz-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quiz-option { padding: 0; overflow: hidden; border: 2px solid var(--line); background: var(--surface); border-radius: var(--radius); cursor: pointer; text-align: left; display: flex; flex-direction: column; }
.quiz-option:hover { border-color: var(--text-3); }
.quiz-option.right { border-color: var(--good); background: var(--good-soft); }
.quiz-option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.quiz-option .thumb { aspect-ratio: 4 / 3; background: radial-gradient(80% 70% at 50% 30%, var(--surface-3), var(--surface-2)); position: relative; }
.quiz-option .thumb canvas, .quiz-option .thumb img { position: absolute; inset: 0; width: 100%; height: 100%; }
.quiz-option .label { padding: 10px 12px; }
@media (max-width: 1100px) {
  .exam { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .quiz-options { grid-template-columns: 1fr 1fr; gap: 8px; }
}

/* ------------------------------------------------------------------ video analysis */
.drop { display: grid; place-items: center; text-align: center; gap: 6px; padding: clamp(30px, 6vw, 70px) 20px; border: 2px dashed var(--line-2); border-radius: 22px; background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .icon-wrap { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; }
.video-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.timeline { position: relative; height: 54px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; overflow: hidden; }
.timeline canvas { width: 100%; height: 100%; display: block; }
.progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
@media (max-width: 1100px) { .video-layout { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ settings */
.settings { display: grid; grid-template-columns: 220px minmax(0, 760px); gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--header-h) + 20px); display: flex; flex-direction: column; gap: 2px; }
.settings section { scroll-margin-top: calc(var(--header-h) + 16px); }
.settings section + section { margin-top: 18px; }
.settings h2 { font-size: 1.1rem; margin-bottom: 6px; }
@media (max-width: 860px) {
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { display: none; }
}

/* ------------------------------------------------------------------ toasts, dialogs */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(560px, 92vw); }
.toast { padding: 10px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 600; font-size: 0.88rem; box-shadow: var(--shadow-3); transition: opacity 0.35s, transform 0.35s; text-align: center; }
.toast-good { background: var(--good); color: #fff; }
.toast-error { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
@media (max-width: 760px) { .toasts { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }

.menu { position: absolute; z-index: 70; min-width: 200px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-3); }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 9px; background: none; text-align: left; font-size: 0.88rem; font-weight: 600; color: var(--text-2); }
.menu button:hover { background: var(--surface-2); color: var(--text); }
.menu button.on { color: var(--accent); }

.callout-card { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--blue-soft); color: var(--text); }
.callout-card .icon { color: var(--blue); margin-top: 2px; }
.callout-card.warn { background: var(--warn-soft); }
.callout-card.warn .icon { color: var(--warn); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------------ player embeds */
.clip-player { display: flex; flex-direction: column; min-width: 0; }
.hero-figure .clip-player, .hero-figure .viewer { position: absolute; inset: 0; }
.hero-figure .viewer { aspect-ratio: auto; max-height: none; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.hero-figure .hero-caption { z-index: 2; }
.hero-figure .phase-pill .move-name .th { font-size: 1.3rem; }
.viewer .viewer-hud .badge { box-shadow: var(--shadow-1); }
.thumb-figure { position: absolute; inset: 0; }
.tech-card .thumb .thumb-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.empty-thumb { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); }
details summary { cursor: pointer; }

/* Khan syllabus */
.armband { display: inline-block; width: 34px; height: 12px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line-2); flex: none; }
.khan-card summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; flex-wrap: wrap; }
.khan-card summary::-webkit-details-marker { display: none; }
.khan-items { display: flex; flex-direction: column; gap: 2px; }
.khan-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 7px 10px; border-radius: 10px; text-decoration: none; color: inherit; }
a.khan-item:hover { background: var(--surface-2); }
.khan-item .thai { font-weight: 700; }
.khan-item .rom { color: var(--accent); font-weight: 650; font-size: 0.86rem; }

/* Two-person demonstrations (Mae Mai): legend for the figures. */
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.legend-ghost { background: #4d8dff; opacity: 0.75; }
.legend-body { background: #c98e5e; margin-left: 10px; }
.setting-row .setting-text span.good { color: var(--good); }
.setting-row .setting-text span.bad { color: var(--bad); }

/* Exam setup: settings card + info column; one column on tablets / phones. */
.exam-setup { grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); align-items: start; }
@media (max-width: 900px) { .exam-setup { grid-template-columns: minmax(0, 1fr); } }

/* Phones: segmented controls scroll sideways instead of running off-screen,
   and the camera stage is portrait (a phone held upright films upright). */
@media (max-width: 760px) {
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: none; }
  .stage, .exam-stage { aspect-ratio: 3 / 4; max-height: 72vh; }
  .exam-stage:has(> .gate-hint:not([hidden])) .callout { padding-top: 24cqw; } /* clear the timer ring */
  .stage-msg { padding: 16px; }
  .stage-msg p { font-size: 0.9rem; }
}
/* Grid and flex children may shrink below their content's width (long
   segmented controls scroll instead of widening the page). */
.grid > *, .settings > *, .card { min-width: 0; }

/* Tablets / narrow laptop windows: the full header just fits. */
@media (min-width: 761px) and (max-width: 940px) {
  .brand-name span { display: none; }
  .nav { margin-left: 2px; }
  .nav a { padding-left: 9px; padding-right: 9px; gap: 6px; }
  .header-tools { gap: 2px; }
}

/* Thai counting cards (Learn → Khan syllabus). */
.number-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; max-width: 820px; }
@media (max-width: 560px) { .number-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.cat-section { scroll-margin-top: calc(var(--header-h) + 16px); }
.number-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 10px; text-align: center; }
.number-card .digit { font-family: var(--font-thai); font-size: 1.9rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.number-card .thai { font-family: var(--font-thai); font-weight: 700; font-size: 1.05rem; }
.number-card .rom { font-weight: 650; font-size: 0.86rem; color: var(--text-2); }
.number-card .say-btn { margin-top: 6px; }

/* Khan syllabus study notes (data/khan-guide.js). */
.khan-guide > summary { list-style: none; cursor: pointer; }
.khan-guide > summary::-webkit-details-marker { display: none; }
.khan-guide[open] > summary .icon:last-child { transform: rotate(180deg); }
.khan-guide-body { padding: 4px 14px 14px; color: var(--text-2); max-width: 80ch; }
.khan-guide-body p { margin: 0 0 10px; }

/* Home hero: the move caption replaces the player's step label (they overlapped). */
.hero-figure .viewer-phase { display: none; }

/* Study-note demo (fitness drills in the Khan syllabus). */
.khan-guide-demo { margin: 10px 0 12px; max-width: 640px; }
