/* English Placement Test
   One typeface, Atkinson Hyperlegible, chosen because it was designed to keep
   similar letters (I l 1, O 0, a o) easy to tell apart, which matters for
   people reading English as a new language. The one bold element is the
   progress track at the top: yellow marks where the student is. Everything
   else stays quiet so the questions get the attention. */

:root {
  --paper: #FAFBF9;
  --ink: #18303C;
  --ink-soft: #4B5F69;
  --lake: #1D5C80;
  --lake-deep: #154561;
  --lake-wash: #E8F1F6;
  --mist: #DCE5EA;
  --sun: #F4C430;
  --moss: #2F7A55;
  --moss-wash: #E7F3EC;
  --alert: #A8321F;
  --alert-wash: #FBECE8;

  --font: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --step-0: 1.125rem;   /* 18px body on phones */
  --step-1: 1.25rem;
  --step-2: 1.5625rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;

  --gutter: 16px;
  --radius: 10px;
  --top-h: 72px;
  --foot-h: 84px;
  color-scheme: light;
}

@media (min-width: 900px) {
  :root { --step-0: 1.25rem; --gutter: 32px; }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step-0);
  line-height: 1.55;
  overflow-x: hidden;
}

main:focus { outline: none; }

h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 700; }
h1 { font-size: var(--step-4); letter-spacing: -0.01em; }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 0.75em; }

a { color: var(--lake); }

:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 2px;
  border-radius: 4px;
}

[hidden] { display: none !important; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- top bar and progress track ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px var(--gutter);
  background: var(--ink);
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 4px rgba(244, 196, 48, 0.25);
}
.brand-name { font-weight: 700; font-size: var(--step-1); }

.track {
  flex: 1 1 auto;
  display: flex;
  justify-content: flex-end;
  gap: 20px;
  min-width: 0;
}

.track-section { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.track-name { font-size: 0.85rem; color: #B9CBD4; white-space: nowrap; }
.track-section.is-current .track-name { color: #fff; font-weight: 700; }

.track-stops { display: flex; align-items: center; gap: 0; }
.stop {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #7F98A5;
  background: transparent;
  flex: 0 0 auto;
}
.stop + .stop { margin-left: 14px; position: relative; }
.stop + .stop::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  width: 14px;
  height: 2px;
  background: #7F98A5;
  transform: translateY(-50%);
  margin-right: 2px;
}
.stop.is-done { background: #7FB3CF; border-color: #7FB3CF; }
.stop.is-done + .stop::before { background: #7FB3CF; }
.stop.is-now {
  background: var(--sun);
  border-color: var(--sun);
  box-shadow: 0 0 0 4px rgba(244, 196, 48, 0.3);
}
.stop.is-pending { border-style: dashed; }

.track-phone { display: none; font-size: 0.95rem; color: #DDE7EC; text-align: right; }

@media (max-width: 760px) {
  .top { gap: 12px; }
  .brand-name { font-size: 1rem; }
  .track-section { display: none; }
  .track-phone { display: block; flex: 1 1 auto; }
}

/* ---------- start page ---------- */

.start {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  padding-top: 56px;
  padding-bottom: 64px;
}
.start h1 { max-width: 14ch; margin-bottom: 20px; }
.start .lead { font-size: var(--step-1); color: var(--ink-soft); max-width: 36ch; }

.parts { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; max-width: 34rem; }
.parts li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 12px; align-items: baseline; padding-bottom: 14px; border-bottom: 1px solid var(--mist); }
.parts b { font-size: var(--step-1); }
.parts span { color: var(--ink-soft); }

.need {
  margin-top: 24px;
  padding: 14px 16px;
  border-left: 4px solid var(--sun);
  background: #FFF8DD;
  max-width: 34rem;
}

.panel-intro { color: var(--ink-soft); margin: 8px 0 24px; }

.panel {
  background: #fff;
  border: 1px solid var(--mist);
  border-radius: var(--radius);
  padding: 28px;
}

@media (max-width: 860px) {
  .start { grid-template-columns: 1fr; gap: 32px; padding-top: 32px; }
  .panel { padding: 20px; }
}

/* ---------- form controls ---------- */

.field { display: grid; gap: 6px; margin-bottom: 20px; }
.field label { font-weight: 700; }
.field input[type="text"], .field input[type="email"] {
  font: inherit;
  padding: 12px 14px;
  border: 2px solid #A9BAC3;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input:focus { border-color: var(--lake); }

.check { display: grid; grid-template-columns: 28px 1fr; gap: 12px; align-items: start; margin: 8px 0 24px; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 3px 0 0; accent-color: var(--lake); }

.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 8px;
  padding: 14px 26px;
  min-height: 52px;
  cursor: pointer;
  background: var(--lake);
  color: #fff;
}
.btn:hover:not(:disabled) { background: var(--lake-deep); }
.btn:disabled { background: #B7C6CE; color: #EEF3F5; cursor: not-allowed; }
.btn-quiet { background: transparent; color: var(--lake); border: 2px solid var(--lake); }
.btn-quiet:hover:not(:disabled) { background: var(--lake-wash); }
.btn-wide { width: 100%; }

.error {
  color: var(--alert);
  background: var(--alert-wash);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 18px;
}

/* ---------- test page ---------- */

.test { padding-top: 28px; padding-bottom: calc(var(--foot-h) + 40px); }

.task-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.task-head p { margin: 0; color: var(--ink-soft); }

.notice {
  background: #FFF8DD;
  border-left: 4px solid var(--sun);
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 1rem;
}

.task-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}
.task-grid.single { grid-template-columns: minmax(0, 48rem); }

.material {
  position: sticky;
  top: calc(var(--top-h) + 20px);
  max-height: calc(100vh - var(--top-h) - var(--foot-h) - 48px);
  overflow-y: auto;
  padding: 4px 20px 4px 0;
  border-right: 1px solid var(--mist);
}
.material-text { white-space: pre-line; max-width: 65ch; }
.material-text.passage { font-size: var(--step-0); line-height: 1.7; }

.listen {
  background: var(--lake-wash);
  border-radius: var(--radius);
  padding: 18px;
  margin-top: 16px;
}
.listen audio { width: 100%; display: block; }
.listen p { margin: 0 0 12px; font-weight: 700; }

.picture-missing { margin: 16px 0; padding: 12px 16px; border-radius: 8px; background: #FBEDEA; color: var(--alert, #A8321F); }
.picture { display: block; max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0; border: 1px solid var(--mist); }

.questions { display: grid; gap: 36px; }

.q { border: 0; margin: 0; padding: 0; min-width: 0; }
.q legend, .q .q-text { font-weight: 700; padding: 0; margin-bottom: 14px; white-space: pre-line; max-width: 65ch; }

.options { display: grid; gap: 10px; }
.option {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 2px solid var(--mist);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.option:hover { border-color: #9DB6C3; }
.option input { width: 22px; height: 22px; margin: 0; accent-color: var(--lake); }
.option:has(input:checked) { border-color: var(--lake); background: var(--lake-wash); }
.option:has(input:focus-visible) { outline: 3px solid var(--sun); outline-offset: 2px; }

textarea {
  font: inherit;
  width: 100%;
  min-height: 9rem;
  padding: 12px 14px;
  border: 2px solid #A9BAC3;
  border-radius: 8px;
  resize: vertical;
  color: var(--ink);
  background: #fff;
  line-height: 1.5;
}
textarea:focus { border-color: var(--lake); }
.words { font-size: 1rem; color: var(--ink-soft); margin-top: 6px; }
.words.over { color: var(--alert); }

/* recorder */
.recorder {
  margin-top: 20px;
  padding: 20px;
  border: 2px solid var(--mist);
  border-radius: var(--radius);
  background: #fff;
  display: grid;
  gap: 14px;
}
.rec-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rec-btn { display: inline-flex; align-items: center; gap: 12px; }
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; flex: 0 0 auto; }
.rec-btn.is-recording { background: var(--alert); }
.rec-btn.is-recording:hover { background: #8C2918; }
.rec-time { font-variant-numeric: tabular-nums; font-size: var(--step-1); font-weight: 700; }
.rec-status { margin: 0; color: var(--ink-soft); }
.rec-status.ok { color: var(--moss); font-weight: 700; }
.rec-status.bad { color: var(--alert); font-weight: 700; }
.recorder audio { width: 100%; }

@media (prefers-reduced-motion: no-preference) {
  .rec-btn.is-recording .rec-dot { animation: pulse 1.2s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: 0.35; } }

/* footer action bar */
.foot {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  min-height: var(--foot-h);
  background: #fff;
  border-top: 1px solid var(--mist);
}
.foot .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: var(--foot-h); }
.foot-note { margin: 0; color: var(--ink-soft); }
.foot-note b { color: var(--ink); }

@media (max-width: 860px) {
  .task-grid { grid-template-columns: 1fr; gap: 28px; }
  .material { position: static; max-height: none; overflow: visible; padding: 0 0 24px; border-right: 0; border-bottom: 1px solid var(--mist); }
  .foot .wrap { flex-direction: column; align-items: stretch; gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .foot .btn { width: 100%; }
  .test { padding-bottom: 170px; }
}

/* ---------- review and done ---------- */

.review { padding-top: 32px; padding-bottom: 160px; max-width: 54rem; }
.review h1 { margin-bottom: 10px; }
.review > p { color: var(--ink-soft); }
.review-task { margin-top: 32px; }
.review-task h2 { font-size: var(--step-2); margin-bottom: 12px; }
.review-item { padding: 12px 0; border-bottom: 1px solid var(--mist); }
.review-item .q-text { font-weight: 700; white-space: pre-line; margin-bottom: 4px; }
.review-answer { white-space: pre-wrap; overflow-wrap: anywhere; }
.review-answer.empty { color: var(--alert); }

.done { padding-top: 72px; padding-bottom: 72px; max-width: 42rem; }
.done-mark {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--moss);
  display: grid; place-items: center;
  margin-bottom: 28px;
}
.done-mark svg { width: 34px; height: 34px; }
.done h1 { margin-bottom: 18px; }
.done p { font-size: var(--step-1); }
.done .when { color: var(--ink-soft); font-size: var(--step-0); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--foot-h) + 16px);
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100% - 32px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
}

.busy { opacity: 0.7; pointer-events: none; }
