/* Blind test — the reviewers are interpreters, not IT users, so: one question per
   screen, no menus, no sidebars, and everything tappable is finger sized. */

/* Light is the base palette; dark only redefines the tokens. The <head> script stamps
   data-theme before the first paint, so there is no third "unset" state to style. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #12141c;
  --muted: #5a6172;
  --line: #d9dee9;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fe;
  --accent-strong: #1a4fa8;
  --ok: #1a7f52;
  --ok-soft: #e6f5ee;
  --bad: #c02f2f;
  --bad-soft: #fdeaea;
  --warn: #a26a00;
  --track: #e3e8f2;
  --scrim: #12141ca8;
  --radius: 14px;
  /* Native widgets (textarea, video controls, scrollbars) follow this, not the tokens. */
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1117;
  --card: #181b24;
  --ink: #e9edf5;
  --muted: #9aa3b8;
  --line: #2b3142;
  --accent: #4c8dff;
  --accent-ink: #0b0e14;
  --accent-soft: #1d2a44;
  --accent-strong: #9dc0ff;
  --ok: #4cc38a;
  --ok-soft: #17301f;
  --bad: #ff6b6b;
  --bad-soft: #35191c;
  --warn: #e0a34a;
  --track: #262b39;
  --scrim: #05070ccc;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body.bt-page {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 19px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

.bt-screen { min-height: 100vh; padding: 20px; }
.bt-card {
  max-width: 720px;
  margin: 28px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.bt-center { text-align: center; }

h1 { font-size: 30px; margin: 0 0 10px; }
.bt-lead { color: var(--muted); margin: 0 0 24px; }
.bt-note { color: var(--muted); font-size: 16px; margin: 12px 0 0; }
.bt-note-warn { color: #b3261e; font-weight: 700; }
.bt-admin-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.bt-admin-tools .bt-note { margin: 0; }
.bt-error { color: var(--bad); min-height: 24px; margin: 10px 0 0; }

/* ── start screen ───────────────────────────────────────────────────────────── */

.bt-field { display: block; margin: 0 0 22px; }
.bt-field > span { display: block; font-weight: 700; margin-bottom: 8px; }

.bt-field input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font: inherit;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: inherit;
}
.bt-field input[type="text"]:focus { outline: none; border-color: var(--accent); }

.bt-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.bt-chip {
  font: inherit;
  padding: 12px 18px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: inherit;
  cursor: pointer;
}
.bt-chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }

.bt-groups { display: grid; gap: 12px; }
.bt-group {
  text-align: left;
  font: inherit;
  padding: 16px 18px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: inherit;
  cursor: pointer;
}
.bt-group[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.bt-group b { display: block; font-size: 21px; }
.bt-group span { color: var(--muted); font-size: 16px; }

.bt-primary, .bt-secondary {
  font: inherit;
  font-weight: 700;
  width: 100%;
  padding: 18px;
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer;
}
.bt-primary { background: var(--accent); color: var(--accent-ink); font-size: 22px; }
.bt-primary:disabled { background: var(--track); color: var(--muted); cursor: not-allowed; }
.bt-secondary { background: var(--card); border-color: var(--line); color: inherit; }

/* ── test screen ────────────────────────────────────────────────────────────── */

/* Sticks under the nav: the A/B/C counters are how the reviewer knows where they are,
   and scrolling down to answer must not take them off screen. */
.bt-topbar {
  position: sticky; top: 63px; z-index: 30;
  max-width: 1180px;
  margin: 0 auto 14px;
  padding: 8px 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 16px;
}
.bt-progress { flex: 1; display: flex; align-items: center; gap: 12px; }
.bt-progress-bar { flex: 1; height: 12px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bt-progress-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.bt-badge {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}
.bt-warmup { color: var(--warn); font-weight: 700; font-size: 16px; }

/* Avatar on the left, the question on the right. The avatar box has to be tall enough
   to show a whole body — head to feet — and a tall box stacked ABOVE the question would
   push the answer off screen, so on a wide screen they sit side by side instead. */
.bt-work {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
}
/* Phases C/V already use both columns for avatar + reference clip, so the panel drops below. */
.bt-work.with-ref { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 1000px) { .bt-work { grid-template-columns: minmax(0, 1fr); } }

.bt-stage {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
.bt-stage.with-ref { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .bt-stage.with-ref { grid-template-columns: 1fr; } }

.bt-media {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}
.bt-media-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

.bt-player-wrap {
  position: relative; width: 100%;
  /* Sized so the avatar and the answer panel share one screen: an interpreter who has
     to scroll to answer loses the take they just watched. */
  /* Portrait-ish: the player frames the avatar to the box, so a short wide box crops
     the head and the feet off. */
  height: clamp(360px, 62vh, 640px);
  background: #10131a; border-radius: 10px; overflow: hidden;
}
.bt-player { width: 100%; height: 100%; border: 0; display: block; }
/* Covers the player so phases A/B cannot be scrubbed. Removed only in phase C/V,
   where the doc explicitly unlocks frame-by-frame inspection. */
.bt-shield { position: absolute; inset: 0; background: transparent; }
.bt-shield.off { display: none; }
.bt-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #cfd6e4; background: #10131a;
}

.bt-video { width: 100%; height: clamp(360px, 62vh, 640px); background: #000; border-radius: 10px; display: block; object-fit: contain; }

.bt-replay {
  font: inherit; font-weight: 700; font-size: 20px;
  margin-top: 12px; width: 100%; padding: 14px;
  border: 2px solid var(--accent); border-radius: 12px;
  background: var(--card); color: var(--accent); cursor: pointer;
}

/* ── answer panel ───────────────────────────────────────────────────────────── */

.bt-panel {
  margin: 0 0 40px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.bt-question { font-size: 26px; font-weight: 700; margin: 0 0 16px; }
.bt-recap { color: var(--muted); margin: 0 0 16px; }
.bt-recap b { color: var(--ink); }

.bt-answer-input {
  width: 100%; font: inherit; font-size: 24px;
  padding: 16px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); color: inherit;
}
.bt-answer-input:focus { outline: none; border-color: var(--accent); }

.bt-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (max-width: 720px) { .bt-options { grid-template-columns: 1fr; } }
.bt-option {
  font: inherit; font-size: 22px; text-align: left;
  padding: 18px 20px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); color: inherit; cursor: pointer;
}
.bt-option[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }

.bt-unsure {
  font: inherit; width: 100%; padding: 14px; margin-bottom: 14px;
  border: 2px dashed var(--line); border-radius: 12px; background: var(--card); color: var(--muted); cursor: pointer;
}
.bt-unsure[aria-pressed="true"] { border-color: var(--warn); color: var(--warn); font-weight: 700; }

.bt-reveal { font-size: 15px; color: var(--muted); margin: 0 0 6px; }
.bt-word { font-size: 34px; font-weight: 800; margin: 0 0 8px; }
.bt-scored { margin: 0 0 18px; font-size: 17px; }
.bt-scored .ok { color: var(--ok); font-weight: 700; }
.bt-scored .bad { color: var(--bad); font-weight: 700; }

.bt-verdicts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.bt-verdict {
  font: inherit; font-size: 22px; font-weight: 700;
  padding: 18px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: inherit; cursor: pointer;
}
.bt-verdict[data-value="ok"][aria-pressed="true"] { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.bt-verdict[data-value="bad"][aria-pressed="true"] { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

.bt-subhead { font-weight: 700; margin: 0 0 8px; }
.bt-tags { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

.bt-comment {
  width: 100%; font: inherit; min-height: 96px;
  padding: 14px; border: 2px solid var(--line); border-radius: 12px; resize: vertical;
  background: var(--card); color: inherit;
}
.bt-comment:focus { outline: none; border-color: var(--accent); }
.bt-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.bt-quick button { font: inherit; font-size: 16px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--muted); cursor: pointer; }

.bt-summary { text-align: left; margin: 20px 0; }
.bt-summary div { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }

.bt-modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: var(--scrim); padding: 20px;
}
.bt-modal-card {
  background: var(--card); border-radius: var(--radius);
  padding: 28px; max-width: 480px; width: 100%; text-align: center;
}
.bt-modal-card h2 { font-size: 26px; margin: 0 0 10px; }
.bt-modal-card p { color: var(--muted); margin: 0 0 24px; }
.bt-modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* The reason modal has nothing to cancel back to, so its one button spans the row. */
.bt-modal-actions.single { grid-template-columns: 1fr; }
.bt-modal-actions .bt-primary { font-size: 20px; }

.bt-toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 14px 22px; border-radius: 10px; z-index: 50;
  max-width: 90vw;
}
.bt-toast.bad { background: var(--bad); }

/* ── theme toggle ───────────────────────────────────────────────────────────── */

.bt-nav {
  position: sticky; top: 0; z-index: 70;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.bt-nav-links { display: flex; flex-wrap: wrap; gap: 8px; }
.bt-nav-links a {
  padding: 8px 14px; border-radius: 999px; font-size: 16px;
  color: var(--muted); text-decoration: none; border: 1px solid transparent;
}
.bt-nav-links a:hover { border-color: var(--line); color: var(--ink); }
.bt-nav-links a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }

.bt-theme {
  flex: 0 0 auto;
  width: 42px; height: 42px; font-size: 20px; line-height: 1;
  border: 2px solid var(--line); border-radius: 50%;
  background: var(--card); color: inherit; cursor: pointer;
}
.bt-theme:hover { border-color: var(--accent); }

/* ── people picker (same shape as the /record signer list) ──────────────────── */

.bt-people-head { display: flex; align-items: flex-start; gap: 16px; justify-content: space-between; }
.bt-add {
  font: inherit; font-weight: 700; white-space: nowrap;
  padding: 12px 18px; border: 2px solid var(--accent); border-radius: 999px;
  background: var(--card); color: var(--accent); cursor: pointer;
}
.bt-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.bt-person {
  font: inherit; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px;
  background: var(--card); color: inherit;
}
.bt-person:hover { border-color: var(--accent); }
.bt-person .bt-person-face {
  width: 42px; height: 42px; flex: 0 0 42px; font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent-soft);
}
.bt-person b { display: block; font-size: 19px; }
.bt-person small { color: var(--muted); font-size: 15px; }
.bt-people-empty { color: var(--muted); padding: 20px 0; }

.bt-avatar {
  width: 88px; height: 88px; margin: 0 auto 16px; font-size: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent-soft);
}
.bt-text {
  font: inherit; width: 100%; margin-top: 12px; padding: 12px;
  border: 0; background: none; color: var(--muted); cursor: pointer; text-decoration: underline;
}

/* ── segment progress + group 3 ─────────────────────────────────────────────── */

.bt-segments { display: flex; gap: 8px; flex-wrap: wrap; }
.bt-seg {
  font: inherit;
  padding: 6px 12px; border-radius: 999px; font-size: 15px; font-weight: 700;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
  background: var(--card); cursor: pointer;
}
.bt-seg:hover:not(:disabled) { border-color: var(--accent); color: var(--ink); }
.bt-seg:disabled { cursor: default; }
.bt-seg.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.bt-seg.done { opacity: .55; }

.bt-missing { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.bt-missing span {
  padding: 8px 14px; border-radius: 999px; font-size: 16px;
  border: 1px solid var(--line); color: var(--ink); background: var(--card);
}
.bt-missing span.rejected { border-color: var(--bad); color: var(--bad); }

/* ── pinned verdict bar (segment C) ─────────────────────────────────────────── */

.bt-actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 12px 20px;
  background: var(--card);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 20px #0003;
}
/* One row, always: a two-row bar eats a third of a laptop screen and pushes the
   fields it is asking about behind itself. */
.bt-actionbar-inner { max-width: 1180px; margin: 0 auto; display: flex; gap: 12px; align-items: stretch; }
.bt-actionbar .bt-verdicts { flex: 1; margin-bottom: 0; }
.bt-actionbar .bt-primary { flex: 0 0 300px; width: auto; margin: 0; font-size: 19px; padding: 14px; }
@media (max-width: 720px) {
  .bt-actionbar-inner { flex-direction: column; }
  .bt-actionbar .bt-primary { flex: none; width: 100%; }
}
/* Room so the pinned bar never covers the end of the comment box. */
.bt-panel { padding-bottom: 120px; }

/* Segment C used to shrink these to keep the verdict buttons in view; the buttons are
   pinned to the window now, so C uses the same box as A and B. The player fits the
   avatar to its canvas, so a shorter box is exactly why C looked further away. */

.bt-word-heading {
  max-width: 1180px; margin: 0 auto 12px;
  font-size: 30px; font-weight: 800; text-align: center;
  padding: 10px 16px; border-radius: var(--radius);
  background: var(--accent-soft); color: var(--accent-strong);
}
.bt-word-heading small { display: block; font-size: 15px; font-weight: 600; opacity: .8; }
