:root {
  /* Speak to Max brand — change colours and font here only */
  --navy: #0B2545;
  --teal: #13A89E;
  --teal-dark: #0E7C74;      /* teal for text/links on white (readable contrast) */
  --teal-soft: #E3F5F3;
  --coral: #FF6B5B;          /* sparingly: small highlights only */
  --bg: #F5F8FA;
  --card: #ffffff;
  --text: #0B2545;
  --muted: #5B6B80;
  --accent: var(--teal-dark);
  --live: #13A89E;
  --border: #DCE4EC;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-friendly: "Fredoka", "Nunito", system-ui, sans-serif;   /* friendly headings (consent page title) */
  --sun: #FFD166;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 17px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 16px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
header h1 { margin: 0; font-size: 22px; }
.state {
  margin-left: auto;
  font: 13px ui-monospace, Menlo, monospace;
  padding: 2px 8px;
  border-radius: 4px;
  background: #e8eef7;
}

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 { margin-top: 0; font-size: 18px; }

.muted { color: var(--muted); font-size: 14px; }

.row { display: flex; gap: 20px; flex-wrap: wrap; margin: 16px 0; }
video#preview {
  width: 320px;
  max-width: 100%;
  aspect-ratio: 4 / 3;
  background: #111;
  border-radius: 6px;
}
.controls { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 6px; }
.controls label { font-weight: 600; font-size: 14px; margin-top: 8px; }

.meter {
  position: relative;
  height: 14px;
  background: #e5e7eb;
  border-radius: 7px;
  overflow: hidden;
}
#meterBar { height: 100%; width: 0; background: #9ca3af; transition: width 40ms linear; }
#meterBar.speaking { background: var(--live); }
#meterMark { position: absolute; top: 0; bottom: 0; width: 2px; background: #b91c1c; left: 0; }

button {
  font: inherit;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  align-self: flex-start;
}
button.secondary { background: #fff; color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }

select, input { font: inherit; padding: 6px; border: 1px solid var(--border); border-radius: 6px; }

.phase { font-size: 26px; font-weight: 600; margin-bottom: 4px; }
.phase.listening { color: var(--live); }
#phaseDetail { min-height: 1.5em; margin-bottom: 12px; }

#summary { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 12px; }
.stat b { display: block; font-size: 22px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.transcript { min-width: 260px; }
tr.current { background: #f0f7ff; }

/* ---------- Stage 1 additions ---------- */
h3 { font-size: 15px; margin: 18px 0 8px; }
.banner { background: #fff7e6; border: 1px solid #f5d38a; border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; font-size: 14px; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 20px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
.form-grid label .muted { font-weight: 400; }
.checklist { margin: 0 0 8px; padding-left: 20px; font-size: 15px; }
.checklist li { margin-bottom: 4px; }

.examiner { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.examiner-name { font-size: 20px; font-weight: 600; }
.clock { margin-left: auto; text-align: right; }
.clock b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.notice { background: #f0f7ff; border: 1px solid #bcd6f5; border-radius: 8px; padding: 12px 16px; margin-top: 12px; }
.notice p { margin: 0 0 8px; }

.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.overlay[hidden] { display: none; }
.dialog { background: var(--card); border-radius: 10px; padding: 24px; max-width: 460px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.dialog p:first-child { font-size: 18px; font-weight: 600; margin-top: 0; }
.dialog-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.tester summary { cursor: pointer; }
.tester .buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.tester label.inline { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-top: 8px; }
.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 16px; margin-top: 12px; font-size: 14px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 20px; }
.settings-grid label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.settings-grid input { width: 80px; }

/* ---------- modes, repeat, caption, practice bar ---------- */
.modes { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.mode { flex: 1; min-width: 260px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: 14px; }
.mode:has(input:checked) { border-color: var(--accent); background: #f0f7ff; }
#repeatBtn { margin-top: 12px; }
.caption { background: #f8fafc; border-left: 4px solid var(--accent); padding: 10px 14px; margin-top: 12px; font-size: 17px; }
.practice-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--border); padding: 10px 16px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; z-index: 5; box-shadow: 0 -4px 12px rgba(0,0,0,.06); }
.practice-bar[hidden] { display: none; }
body.practice main { padding-bottom: 90px; }
button.on { background: var(--accent); color: #fff; }

/* ---------- Part 2 ---------- */
.cue-card { border: 2px solid var(--text); border-radius: 6px; padding: 16px 20px; margin-top: 12px; max-width: 560px; background: #fffef8; font-size: 17px; }
.cue-card p { margin: 0 0 6px; }
.cue-card .cue-say { margin-top: 10px; }
.cue-card ul { margin: 0; padding-left: 22px; }
.prep-timer { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.prep-timer b { font-size: 34px; font-variant-numeric: tabular-nums; }
.heard { margin-top: 12px; padding: 8px 12px; border: 1px dashed var(--border); border-radius: 6px; font-size: 15px; }

/* Anything marked hidden stays hidden, even if its own style sets a display. */
[hidden] { display: none !important; }

/* ---------- developer bar (?dev=1 only) ---------- */
.dev-bar { position: sticky; top: 0; z-index: 6; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #fff7e6; border: 1px dashed #d97706; border-radius: 8px; padding: 8px 12px; margin-bottom: 16px; font-size: 14px; }
.dev-bar button { padding: 4px 10px; font-size: 14px; }

/* ---------- Part 3 ---------- */
.buttons-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.buttons-row #repeatBtn { margin-top: 0; }
.dev-level { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.dev-level select { padding: 3px 6px; }
.slow-switch { display: inline-flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 15px; cursor: pointer; }

/* ---------- the examiner face: large and centred at the top; question text, timers and buttons BELOW it ----------
   The face height is limited so the controls below always stay on screen on a laptop; smaller on narrow screens. */
.test-card { padding: 0 0 4px; overflow: hidden; }
.stage { position: relative; background: #ffffff; }
.avatar-box { height: min(48vh, 520px); display: flex; justify-content: center; background: #ffffff; }
.avatar-box svg { height: 100%; width: auto; max-width: 100%; display: block; }
@media (max-width: 640px) { .avatar-box { height: min(34vh, 320px); } }
@media (max-height: 700px) { .avatar-box { height: 40vh; } }
.test-card.with-card .avatar-box { height: min(30vh, 300px); }   /* Part 2: card + timer need the room */
.stage-top { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 16px; pointer-events: none; }
.name-tag, .stage-top .clock { background: rgba(255, 255, 255, 0.85); border-radius: 8px; padding: 6px 12px; }
.stage-top .clock { margin-left: auto; text-align: right; }
.stage .caption { width: min(640px, calc(100% - 32px)); margin: 8px auto 0; }
.chest { width: min(640px, calc(100% - 32px)); margin: 8px auto 12px; }
.chest .phase { font-size: 20px; margin-bottom: 0; }
.chest #phaseDetail { min-height: 1.2em; margin-bottom: 6px; }
.chest .cue-card { max-width: none; margin-top: 6px; }
.chest .buttons-row { align-items: center; margin-top: 8px; }
.chest .slow-switch { margin-top: 0; }
.chest .notice { margin-top: 8px; }

/* ---------- "Before you start" (large plain text, one screen on a laptop) ---------- */
.dialog.bys { max-width: 720px; padding: 28px 32px; }
.dialog.bys h2 { font-size: 28px; margin: 0 0 14px; }
.dialog.bys ul { margin: 0 0 22px; padding-left: 24px; font-size: 20px; line-height: 1.45; }
.dialog.bys li { margin-bottom: 10px; }
.dialog.bys button { font-size: 20px; padding: 12px 28px; }
@media (max-height: 700px) { .dialog.bys ul { font-size: 18px; } .dialog.bys li { margin-bottom: 6px; } }
.stage-top .clock b { font-size: 18px; display: inline; }

/* ---------- consent page ---------- */
.consent { max-width: 820px; margin: 0 auto 16px; }
.consent h2 { font-size: 24px; }
.consent-text { font-size: 17px; line-height: 1.55; max-height: 52vh; overflow-y: auto; padding: 4px 12px 4px 0; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.consent-text p { margin: 0 0 10px; }
.consent-text mark { background: #fde68a; padding: 0 3px; border-radius: 3px; }
.consent-box { display: flex; gap: 10px; align-items: flex-start; font-size: 17px; margin: 10px 0; cursor: pointer; }
.consent-box input { width: 20px; height: 20px; margin-top: 3px; flex: none; }
.consent-box .req { color: var(--muted); font-size: 14px; }
.consent-box.optional { color: #374151; }
.consent #consentGo { font-size: 18px; padding: 10px 26px; margin-top: 8px; }
.code-note { font-size: 17px; background: #f0f7ff; border: 1px solid #bcd6f5; border-radius: 8px; padding: 10px 14px; }

/* "Before you start": scrolls on a phone, the Start button always visible */
.dialog.bys { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dialog.bys ul { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.dialog.bys #bysGo { flex: none; align-self: stretch; }


/* ================= Brand + mobile first (Spanish sample-collection version) ================= */
img, svg, video { max-width: 100%; }
.site-header { align-items: center; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--navy); }
.brand .logo { width: 40px; height: 34px; flex: none; }
.wordmark { font-size: 26px; letter-spacing: -0.3px; line-height: 1; }
.wm-light { font-weight: 300; }
.wm-bold { font-weight: 800; }
body:not(.dev) .dev-only-tag, .dev-only-tag:empty { display: none; }
main { padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.card { border-radius: var(--radius); padding: 24px; border-color: var(--border); box-shadow: 0 1px 2px rgba(11, 37, 69, .04); }
.card h2 { font-size: 22px; font-weight: 800; color: var(--navy); }
.narrow { max-width: 680px; margin-left: auto; margin-right: auto; }
.lead { font-size: 19px; line-height: 1.5; }
.small { font-size: 14px; }
a { color: var(--teal-dark); }

/* Buttons: teal with navy text (white on this teal is too faint to read comfortably) */
button { min-height: 48px; padding: 10px 20px; border-radius: 999px; border: 2px solid var(--teal); background: var(--teal);
  color: var(--navy); font-weight: 700; touch-action: manipulation; }
button:hover:not(:disabled) { filter: brightness(1.05); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
button.secondary { background: #fff; color: var(--navy); border-color: var(--border); }
button.on { background: var(--teal); color: var(--navy); }
button.big { font-size: 19px; padding: 12px 28px; }
.dev-bar button, .settings-grid button { min-height: 36px; }
select, input, textarea { font: inherit; min-height: 44px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; color: var(--text); max-width: 100%; }
textarea { width: 100%; min-height: 88px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--teal-dark); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin: 16px 0 6px; }
.field input { width: 100%; font-weight: 400; }

/* Consent page: the whole text scrolls with the page (no inner scroll box on phones) */
.consent h2 { font-size: 24px; }
.consent-text { max-height: none; overflow: visible; padding: 0; font-size: 17px; }
.consent-section h3 { font-size: 18px; font-weight: 800; color: var(--navy); margin: 22px 0 8px; }
.consent-section ul { padding-left: 22px; margin: 0 0 10px; }
.consent-section li { margin-bottom: 6px; }
.consent-box { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; align-items: flex-start; }
.consent-box:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.consent-box input { width: 22px; height: 22px; margin-top: 2px; }
.consent-box.optional { color: var(--text); }
.consent #consentGo { width: 100%; margin-top: 12px; }

/* Consent page, layered (Nov 2026): friendly title + illustration, short summary, full text behind a link,
   then every choice (so people who skip the reading still reach the boxes straight away) */
.friendly { font-family: var(--font-friendly); font-weight: 600; letter-spacing: 0.2px; }
.consent-hero { text-align: center; margin-bottom: 8px; }
.consent-art { width: 200px; height: auto; display: block; margin: 0 auto 6px; }
.consent .consent-hero h2 { font-size: 36px; margin: 0; color: var(--navy); }
.consent-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 16px; }
.consent-summary { background: var(--teal-soft); border-radius: var(--radius-sm); padding: 14px 18px; margin: 16px 0 10px; }
.consent-summary h3 { margin: 0 0 6px; font-size: 18px; font-weight: 800; }
.consent-summary ul { margin: 0; padding-left: 20px; }
.consent-summary li { margin-bottom: 4px; }
.consent-full { margin: 0 0 8px; }
.consent-full summary { cursor: pointer; color: var(--teal-dark); font-weight: 700; min-height: 44px; display: flex; align-items: center; gap: 6px; }
.consent-full[open] summary { margin-bottom: 4px; }
.consent-full .consent-text { border-left: 3px solid var(--border); padding-left: 14px; }
.keep-choice { border: 2px solid var(--teal); border-radius: var(--radius-sm); padding: 12px 14px 4px; margin: 16px 0 10px; min-width: 0; }
.keep-choice legend { padding: 0 6px; font-size: 18px; }
.keep-choice > p { margin: 0 0 6px; }
.consent-box input[type="radio"] { width: 22px; height: 22px; }
#consentMissing:empty, #consentNote:empty { display: none; }

/* End-of-test question (only for those who chose "No"): a friendly pop-up */
.modal-back { position: fixed; inset: 0; background: rgba(11, 37, 69, .45); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50; }
.modal-back[hidden] { display: none; }
.modal-card { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 520px; width: 100%; max-height: calc(100dvh - 32px);
  overflow-y: auto; box-shadow: 0 10px 40px rgba(11, 37, 69, .25); text-align: center; }
.modal-card h2 { margin: 0 0 10px; font-size: 28px; color: var(--navy); }
.modal-card button { width: 100%; margin-top: 10px; }
.modal-card button.big { height: auto; line-height: 1.3; }

/* Device check */
#deviceCheck h2 { color: var(--navy); }
#deviceCheck #copyLink { width: 100%; }

/* Survey */
.sq { border: 0; padding: 0; margin: 0 0 22px; min-width: 0; }
.sq legend { font-weight: 700; margin-bottom: 10px; padding: 0; }
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale-pt { position: relative; }
.scale-pt input { position: absolute; opacity: 0; inset: 0; }
.scale-pt span { display: flex; align-items: center; justify-content: center; min-height: 48px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-weight: 800; font-size: 18px; cursor: pointer; background: #fff; }
.scale-pt input:checked + span { border-color: var(--teal); background: var(--teal-soft); }
.scale-pt input:focus-visible + span { outline: 3px solid var(--coral); outline-offset: 2px; }
.scale-ends { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); margin-top: 6px; }
.choice { display: flex; gap: 10px; align-items: center; min-height: 48px; padding: 8px 14px; margin-bottom: 8px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.choice input { width: 20px; height: 20px; flex: none; }
.survey-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.survey-buttons button { flex: 1 1 160px; }
#thanks .lead { font-size: 20px; }

/* Test screen: the face on a white panel; fixed height so expressions never move the layout */
.test-card { border-radius: var(--radius); }
.avatar-box { height: min(48dvh, 520px); }
.name-tag { font-weight: 700; color: var(--navy); }
.code-note { background: var(--teal-soft); border-color: #bfe6e2; }
.notice { background: var(--teal-soft); border-color: #bfe6e2; }
.caption { border-left-color: var(--teal); }
.mode:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }
.mode { border-radius: var(--radius-sm); }
tr.current { background: var(--teal-soft); }
.state { background: var(--teal-soft); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  main { padding: 10px; }
  .card { padding: 18px 16px; border-radius: 14px; }
  .wordmark { font-size: 22px; }
  .brand .logo { width: 34px; height: 29px; }
  .avatar-box { height: min(34dvh, 300px); }
  .test-card.with-card .avatar-box { height: min(24dvh, 220px); }
  .lead { font-size: 17px; }
  .mode, .controls { min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .stage-top { padding: 8px; }
  .name-tag, .stage-top .clock { padding: 4px 8px; font-size: 14px; }
  .chest { width: calc(100% - 20px); }
  .dialog.bys { padding: 20px 18px; }
  .dialog.bys h2 { font-size: 22px; }
  .dialog.bys ul { font-size: 17px; padding-left: 20px; }
  .dialog.bys button { font-size: 18px; }
  .practice-bar button { flex: 1 1 40%; }
  video#preview { width: 100%; }
  .consent .consent-hero h2 { font-size: 30px; }
  .consent-art { width: 160px; }
  .modal-card { padding: 20px 16px; }
}
@media (max-width: 640px) { .dev-bar { position: static; } }

/* Developer-only tools on the consent page (?dev=1) */
.dev-only-box { margin-top: 1rem; padding: .75rem 1rem; border: 2px dashed #b9c4cf; border-radius: 12px; display: grid; gap: .6rem; }
.dev-only-box select { margin-left: .4rem; }

/* Setup page: information boxes + English/Español switch (also in "Before you start") */
.info-area { margin: 1.25rem 0; }
.lang-switch { display: inline-flex; border: 2px solid var(--teal, #13A89E); border-radius: 999px; overflow: hidden; margin-bottom: .5rem; }
.lang-btn { min-height: 40px; padding: .35rem 1rem; border: 0; border-radius: 0; background: transparent; color: inherit; font-weight: 700; box-shadow: none; }
.lang-btn[aria-pressed="true"] { background: var(--teal, #13A89E); color: #0B2545; }
.info-box { background: #fff; border: 1px solid #d6e0e8; border-radius: 16px; padding: .25rem 1rem; margin: .6rem 0; }
.info-box > summary { cursor: pointer; font-weight: 800; padding: .75rem 0; min-height: 48px; display: flex; align-items: center; }
.info-box[open] > summary { border-bottom: 1px solid #e3eaf0; margin-bottom: .5rem; }
.info-box h4 { margin: 1rem 0 .3rem; }
.info-box ul { margin: .2rem 0 .6rem; padding-left: 1.3rem; }
.info-box li { margin: .3rem 0; line-height: 1.5; }
.info-box li.plain { list-style: none; margin-left: -1.3rem; font-style: italic; }
.key-point { color: #C2410C; background: #FFF4E5; padding: 0 .25rem; border-radius: 4px; }
.bys .lang-switch { margin-bottom: .25rem; align-self: flex-start; width: auto; }
.bys .lang-btn { width: auto; flex: 0 0 auto; }

/* Exam mode: Part 2 preparation without a visible countdown (only the "ready" button) */
.prep-timer.no-clock #prepLabel, .prep-timer.no-clock #prepTime, .prep-timer.no-clock #prepNote { display: none; }
