:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #16202e;
  --muted: #5d6b80;
  --line: #dde3ed;
  --brand: #1f5fd6;
  --brand-dark: #17489f;
  --ok: #128a55;
  --bad: #c5303a;
  --warn: #b26a00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,32,58,.06), 0 6px 20px rgba(16,32,58,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px 64px; }
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 860px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.logo { font-weight: 700; letter-spacing: -.3px; margin-right: auto; text-decoration: none; color: var(--ink); }
.logo span { color: var(--brand); }
.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 18px;
  background: #eef3fd; color: var(--brand-dark);
  border: 1px solid #cfe0ff; border-radius: 999px; padding: 4px 14px;
}
.timer.warn { background: #fff4e2; color: var(--warn); border-color: #ffd79a; }
.timer.danger { background: #fdecec; color: var(--bad); border-color: #f6bfc2; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
h1 { font-size: 28px; line-height: 1.25; margin: 28px 0 6px; letter-spacing: -.5px; }
h2 { font-size: 20px; margin: 0 0 4px; letter-spacing: -.2px; }
.sub { color: var(--muted); margin: 0 0 24px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin: 0 0 18px;
}
.part-head { border-left: 4px solid var(--brand); padding-left: 12px; margin-bottom: 18px; }
.part-head .instr { color: var(--muted); font-size: 15px; margin: 6px 0 0; }
.stim {
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin: 12px 0; white-space: pre-wrap;
}
.stim.notice { text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; }
.stim .meta { font-size: 13px; color: var(--muted); white-space: normal; margin-bottom: 8px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.q { padding: 18px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.q-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; border-radius: 8px;
  background: #eef3fd; color: var(--brand-dark); font-weight: 700; font-size: 14px;
  margin-right: 8px; padding: 0 6px;
}
.q-prompt { font-weight: 600; }
.opts { margin: 10px 0 0; display: grid; gap: 8px; }
.opt {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; background: #fff; transition: border-color .12s, background .12s;
}
.opt:hover { border-color: #b9c8e4; background: #fbfcff; }
.opt input { margin: 4px 0 0; accent-color: var(--brand); flex: none; }
.opt .letter { font-weight: 700; color: var(--muted); flex: none; }
.opt.chosen { border-color: var(--brand); background: #f3f7ff; }
.opt.correct { border-color: var(--ok); background: #eefaf3; }
.opt.wrong { border-color: var(--bad); background: #fdf0f1; }
.passage p { margin: 0 0 12px; }
.passage .heading { font-weight: 700; font-size: 17px; margin-bottom: 10px; }
.cloze { line-height: 2.4; white-space: pre-wrap; }
.gap-input {
  display: inline-block; width: 130px; padding: 4px 8px; margin: 0 2px;
  border: 0; border-bottom: 2px solid var(--brand); background: #f3f7ff;
  border-radius: 6px 6px 0 0; font: inherit; font-size: 15px; text-align: center;
}
.gap-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.gap-num {
  display: inline-block; min-width: 24px; height: 22px; line-height: 22px; text-align: center;
  background: var(--brand); color: #fff; border-radius: 6px; font-size: 12px; font-weight: 700;
  margin-right: 4px; vertical-align: 2px;
}
.match-texts { display: grid; gap: 14px; margin-bottom: 18px; }
.match-text { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; background: #fbfcfe; }
.match-text .label {
  display: inline-block; background: var(--brand); color: #fff; font-weight: 700;
  border-radius: 6px; padding: 0 9px; margin-right: 8px;
}
.match-text h3 { display: inline; font-size: 16px; }
.match-text p { margin: 10px 0 0; font-size: 15px; }
.pick-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.pick {
  border: 1px solid var(--line); background: #fff; border-radius: 10px;
  min-width: 52px; padding: 8px 14px; font-weight: 700; cursor: pointer; font: inherit; font-weight: 700;
}
.pick:hover { border-color: #b9c8e4; }
.pick.chosen { background: var(--brand); color: #fff; border-color: var(--brand); }
.pick.correct { background: #eefaf3; border-color: var(--ok); color: var(--ok); }
.pick.wrong { background: #fdf0f1; border-color: var(--bad); color: var(--bad); }
.pics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.pic { border: 1px solid var(--line); border-radius: 10px; padding: 14px 10px; text-align: center; background: #fbfcfe; }
.pic .emoji { font-size: 40px; line-height: 1.2; }
.pic .caption { font-size: 13px; color: var(--muted); margin-top: 8px; }
textarea {
  width: 100%; min-height: 190px; padding: 12px 14px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; resize: vertical; background: #fff;
}
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.wordcount { font-size: 14px; color: var(--muted); margin-top: 6px; }
.wordcount.ok { color: var(--ok); font-weight: 600; }
.bullets { margin: 10px 0 14px; padding-left: 20px; }
.bullets li { margin: 4px 0; }
label.field { display: block; margin: 0 0 14px; }
label.field span { display: block; font-weight: 600; margin-bottom: 6px; font-size: 15px; }
input[type=text] {
  width: 100%; padding: 11px 13px; font: inherit;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
input[type=text]:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border: 0; border-radius: 10px;
  padding: 12px 22px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f3f7ff; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.nav-parts { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 18px; }
.nav-parts button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 7px 13px; font: inherit; font-size: 14px; cursor: pointer;
}
.nav-parts button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.nav-parts button.done::after { content: " ✓"; color: var(--ok); font-weight: 700; }
.nav-parts button.active.done::after { color: #cdf0de; }
.score-hero { text-align: center; padding: 28px 20px; }
.score-big { font-size: 56px; font-weight: 800; letter-spacing: -2px; line-height: 1; }
.grade {
  display: inline-block; margin-top: 12px; padding: 6px 18px; border-radius: 999px;
  font-weight: 700; font-size: 15px;
}
.grade.pass-a { background: #e3f7ec; color: #0b6b41; }
.grade.pass-b { background: #eaf3ff; color: #17489f; }
.grade.pass-c { background: #fff6e5; color: #8a5200; }
.grade.fail  { background: #fdecec; color: var(--bad); }
.breakdown { width: 100%; border-collapse: collapse; margin-top: 8px; }
.breakdown th, .breakdown td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 15px; }
.breakdown th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.breakdown td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.tag.ok { background: #e3f7ec; color: var(--ok); }
.tag.bad { background: #fdecec; color: var(--bad); }
.tag.info { background: #eef3fd; color: var(--brand-dark); }
.note { font-size: 14px; color: var(--muted); background: #fbfcfe; border: 1px solid var(--line); border-left: 3px solid var(--warn); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.history { display: grid; gap: 8px; }
.history-row {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; background: #fff; font-size: 15px;
}
.history-row .when { color: var(--muted); font-size: 13px; }
.status { font-size: 14px; color: var(--muted); }
.modal-back {
  position: fixed; inset: 0; background: rgba(16,32,58,.45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal { background: #fff; border-radius: var(--radius); padding: 24px; max-width: 420px; box-shadow: var(--shadow); }
.modal h2 { margin-bottom: 10px; }
.hidden { display: none !important; }
@media (max-width: 600px) {
  h1 { font-size: 23px; }
  .score-big { font-size: 44px; }
  .pics { grid-template-columns: 1fr; }
  .card { padding: 16px; }
}
@media print { .topbar, .actions, .btn { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }

/* ---------- test menu on the home page ---------- */
.section-title { font-size: 20px; margin: 26px 0 12px; letter-spacing: -.2px; }
.exam-menu { display: grid; gap: 10px; margin-bottom: 26px; }
.exam-item {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; transition: border-color .12s, box-shadow .12s;
}
.exam-item:hover { border-color: var(--brand); }
.exam-item:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,95,214,.15); }
.exam-open {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 15px 16px; border: 0; background: none; font: inherit; color: inherit;
  text-align: left; cursor: pointer;
}
.exam-open:hover { background: #f7faff; }
.exam-open:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
/* Outlined, never filled — a filled blue box reads as a "start" button. */
.exam-code {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 10px;
  border: 2px solid var(--brand); color: var(--brand-dark);
  background: transparent; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
}
.exam-info { flex: 1 1 auto; min-width: 0; }
.exam-name { display: block; font-weight: 600; letter-spacing: -.2px; }
.exam-meta { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.exam-result { flex: none; text-align: right; }
.exam-result .scale { font-weight: 700; font-size: 19px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.exam-result .none { color: var(--muted); font-size: 13px; }
.exam-open .chev { flex: none; color: var(--muted); font-size: 20px; line-height: 1; }
.exam-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 16px; border-top: 1px solid var(--line); background: #fbfcfe;
  font-size: 13px; color: var(--muted);
}
.exam-foot .btn { font-size: 13px; padding: 5px 11px; }
.btn.danger { color: var(--bad); border-color: #f0c7ca; background: #fff; }
.btn.danger:hover { background: #fdf0f1; border-color: var(--bad); }
@media (max-width: 520px) {
  .exam-open { gap: 11px; padding: 13px 13px; }
  .exam-code { width: 36px; height: 36px; font-size: 14px; }
  .exam-name { font-size: 15px; }
  .exam-foot { padding: 8px 13px; }
}
