/* 9702 Paper 1 Practice: answer-sheet styling */
:root {
  --paper: #f4f6f9;
  --surface: #ffffff;
  --ink: #15233b;
  --muted: #56627a;
  --line: #dde3ec;
  --brand: #1d5fc2;
  --brand-dark: #154a98;
  --dropout: #df8396;        /* OMR sheet ink */
  --dropout-tint: #fcf0f3;
  --pencil: #2b2e34;
  --right: #1d7a47;
  --right-tint: #e8f5ee;
  --wrong: #c22a39;
  --wrong-tint: #fdecee;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { 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: 17px; line-height: 1.5;
}
img { max-width: 100%; }
a { color: var(--brand); }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }
.wrap { width: min(1180px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 50; background: #fff; padding: 8px 12px; }
.loading { padding: 64px 0; color: var(--muted); }

/* ---------- masthead ---------- */
.masthead { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.masthead-in { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand img { border-radius: 50%; background: #fff; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; }
.brand-text span { font-size: 13px; opacity: 0.85; }
.tabs { margin-left: auto; display: flex; gap: 4px; }
.account { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.account:empty { display: none; }
.acct-login { background: #fff; color: var(--brand); font-weight: 700; text-decoration: none; padding: 7px 14px; border-radius: 999px; white-space: nowrap; }
.acct-login:hover { background: #eaf1fc; }
.acct-name { max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: 0.95; }
.acct-link { color: #fff; opacity: 0.85; }
.tabs a {
  color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 999px;
  font-weight: 500; font-size: 16px;
}
.tabs a:hover { background: rgba(255,255,255,0.14); }
.tabs a[aria-current="page"] { background: #fff; color: var(--brand); font-weight: 700; }
@media (max-width: 640px) {
  .masthead-in { gap: 8px; padding: 8px 0; }
  .tabs { margin-left: 0; width: 100%; }
  .tabs a { flex: 1; text-align: center; padding: 6px 4px; font-size: 15px; }
  .brand-text span { display: none; }
  .account { margin-left: auto; order: 2; }
  .tabs { order: 3; }
}

/* ---------- generic ---------- */
h1, h2, h3 { line-height: 1.15; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(30px, 4.4vw, 46px); font-weight: 800; }
h2 { font-size: 24px; font-weight: 800; }
h3 { font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: var(--radius-s); padding: 10px 18px; cursor: pointer;
  background: var(--brand); color: #fff; font-weight: 700; text-decoration: none;
  min-height: 44px;
}
.btn:hover { background: var(--brand-dark); }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: inset 0 0 0 2px var(--brand); }
.btn.ghost:hover { background: #eaf1fc; }
.btn.quiet { background: transparent; color: var(--muted); padding-inline: 10px; }
.btn.quiet:hover { color: var(--ink); background: #e9edf3; }
.btn.danger { background: var(--wrong); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 13px;
  cursor: pointer; font-size: 15px; min-height: 36px;
}
.chip[aria-pressed="true"] { border-color: var(--brand); background: #eaf1fc; color: var(--brand-dark); font-weight: 700; }
.tag { display: inline-block; font-size: 13px; padding: 2px 9px; border-radius: 999px; background: #eef1f6; color: var(--muted); }
.tag.easy { background: var(--right-tint); color: var(--right); }
.tag.medium { background: #fff4e0; color: #8a5a00; }
.tag.hard { background: var(--wrong-tint); color: var(--wrong); }

/* ---------- home / topics ---------- */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 40px; align-items: end; padding: 44px 0 28px; }
.hero p { font-size: 19px; color: var(--muted); max-width: 34em; margin: 14px 0 0; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; gap: 18px; padding-top: 28px; } .hero-actions { justify-content: flex-start; } }

.sheet-strip { display: flex; gap: 6px; margin-top: 22px; }
.sheet-strip .lz { width: 48px; height: 24px; font-size: 13px; cursor: default; }

.topic-list { list-style: none; margin: 0 0 32px; padding: 0; }
.topic-list > li { border-top: 1px solid var(--line); }
.topic-list > li:last-child { border-bottom: 1px solid var(--line); }
.topic-row {
  display: grid; grid-template-columns: 44px 1fr 150px 190px; gap: 16px; align-items: center;
  width: 100%; padding: 14px 8px; background: none; border: 0; text-align: left; cursor: pointer;
}
.topic-row:hover { background: #eef2f8; }
.topic-num { font-size: 26px; font-weight: 800; color: var(--dropout); font-variant-numeric: tabular-nums; }
.topic-name { font-size: 19px; font-weight: 700; }
.topic-name small { display: block; font-weight: 400; font-size: 14px; color: var(--muted); }
.topic-count { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.meter { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.meter-bar { height: 8px; background: #e6eaf1; border-radius: 999px; overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: var(--right); border-radius: 999px; }
.setup {
  padding: 4px 8px 22px 68px; display: grid; gap: 14px;
}
.setup-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; gap: 12px; }
.setup-row > span { font-size: 15px; color: var(--muted); }
.setup-go { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
@media (max-width: 720px) {
  .topic-row { grid-template-columns: 34px 1fr; row-gap: 6px; }
  .topic-count, .topic-row .meter { grid-column: 2; }
  .setup { padding-left: 8px; }
  .setup-row { grid-template-columns: 1fr; gap: 6px; }
}
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 8px 0 12px; flex-wrap: wrap; }

/* ---------- lozenges (OMR answer sheet) ---------- */
.lz {
  --c: var(--dropout);
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 32px; border-radius: 50%; border: 2px solid var(--c);
  color: var(--c); background: #fff; font-weight: 700; font-size: 16px;
  padding: 0; cursor: pointer; transition: background-color .12s, color .12s;
}
.lz:hover { background: var(--dropout-tint); }
.lz.filled { background: var(--pencil); border-color: var(--pencil); color: rgba(255,255,255,0.0); }
.lz.filled::after {
  content: ""; position: absolute; inset: 3px 6px; border-radius: 50%;
  background: repeating-linear-gradient(115deg, rgba(255,255,255,0.07) 0 2px, transparent 2px 5px);
}
.lz.correct-ring { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--right); }
.lz.is-right { background: var(--right); border-color: var(--right); color: #fff; }
.lz.is-wrong { background: var(--wrong); border-color: var(--wrong); color: #fff; }
.lz[disabled] { cursor: default; }
.lz-row { display: flex; gap: 14px; flex-wrap: wrap; }
.big .lz { width: 92px; height: 46px; font-size: 21px; }
@media (max-width: 520px) { .big .lz { width: 68px; height: 38px; font-size: 18px; } .lz-row { gap: 10px; } }

/* ---------- question workspace ---------- */
.session-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 18px 0 14px; border-bottom: 1px solid var(--line); margin-bottom: 20px;
}
.session-bar h2 { font-size: 20px; }
.session-bar .grow { flex: 1; }
.progress-line { height: 6px; background: #e3e8ef; border-radius: 999px; overflow: hidden; width: 100%; }
.progress-line i { display: block; height: 100%; background: var(--brand); }
.work { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
@media (max-width: 900px) { .work { grid-template-columns: 1fr; } }
.qfig { margin: 0; padding: 18px; }
.qfig img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.qfig figcaption { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: 14px; color: var(--muted); }
.answer-box { padding: 20px; display: grid; gap: 16px; position: sticky; top: 84px; }
.answer-box .prompt { font-size: 15px; color: var(--muted); margin: 0; }
.verdict { font-size: 22px; font-weight: 800; margin: 0; }
.verdict.ok { color: var(--right); }
.verdict.no { color: var(--wrong); }
.solution { display: grid; gap: 14px; }
.solution h3 { font-size: 16px; margin-bottom: 6px; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.steps li::marker { color: var(--dropout); font-weight: 700; }
.why { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.why li { display: grid; grid-template-columns: 34px 1fr; gap: 8px; padding: 6px 8px; border-radius: var(--radius-s); font-size: 15.5px; }
.why li b { font-weight: 800; }
.why li.ans { background: var(--right-tint); }
.why li.picked { background: var(--wrong-tint); }
.tip { border-left: 4px solid var(--brand); background: #eef4fd; padding: 10px 12px; border-radius: 0 var(--radius-s) var(--radius-s) 0; font-size: 15.5px; }
.tip strong { color: var(--brand-dark); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.kbd { font-size: 13px; color: var(--muted); }

/* ---------- mock exam ---------- */
.timer { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; padding: 4px 12px; border-radius: var(--radius-s); background: #eef1f6; }
.timer.low { background: var(--wrong-tint); color: var(--wrong); }
.mock-work { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
@media (max-width: 980px) { .mock-work { grid-template-columns: 1fr; } }
.answer-sheet { padding: 14px 16px; position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow: auto; background: #fff; border: 2px solid var(--dropout); border-radius: var(--radius-s); }
.answer-sheet h3 { color: var(--dropout); font-size: 15px; margin-bottom: 8px; }
.sheet-cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: 14px; }
.sheet-row { display: grid; grid-template-columns: 26px repeat(4, 1fr); align-items: center; gap: 4px; padding: 2px 3px; border-radius: 4px; }
.sheet-row.current { background: #e9f0fb; }
.sheet-row .qn { font-size: 13px; font-weight: 700; color: var(--dropout); font-variant-numeric: tabular-nums; cursor: pointer; background: none; border: 0; padding: 0; text-align: left; }
.sheet-row.flagged .qn { color: #fff; background: #d68a00; border-radius: 3px; text-align: center; }
.sheet-row .lz { width: 100%; max-width: 36px; height: 17px; font-size: 10px; border-width: 1.5px; }
.sheet-row .lz.correct-ring { box-shadow: 0 0 0 2px var(--right); }
.sheet-legend { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.sheet-toggle { display: none; }
@media (max-width: 980px) {
  .answer-sheet { position: static; max-height: none; }
  .sheet-toggle { display: inline-flex; }
  .answer-sheet.collapsed .sheet-cols, .answer-sheet.collapsed .sheet-legend { display: none; }
}
.flag-btn[aria-pressed="true"] { background: #fff1d6; color: #8a5a00; box-shadow: inset 0 0 0 2px #d68a00; }

/* ---------- mocks page ---------- */
.mock-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 24px; margin: 8px 0 32px; }
@media (max-width: 900px) { .mock-grid { grid-template-columns: 1fr; } }
.mock-card { padding: 22px; display: grid; gap: 14px; align-content: start; }
.year-block { margin-bottom: 14px; }
.year-block h3 { font-size: 22px; color: var(--dropout); margin: 6px 0 6px; font-variant-numeric: tabular-nums; }
.paper-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.paper-btn {
  width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius-s);
  padding: 10px 12px; cursor: pointer; display: grid; gap: 2px;
}
.paper-btn:hover { border-color: var(--brand); }
.paper-btn strong { font-size: 16px; }
.paper-btn span { font-size: 13.5px; color: var(--muted); }
.paper-btn .best { color: var(--right); font-weight: 700; }
.resume { padding: 16px 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; border-color: var(--brand); background: #eef4fd; margin: 18px 0 0; }

/* ---------- results ---------- */
.result-head { display: grid; grid-template-columns: auto 1fr; gap: 28px; align-items: center; padding: 26px 0 18px; }
.score-big { font-size: clamp(56px, 9vw, 96px); font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.score-big small { font-size: 0.4em; color: var(--muted); font-weight: 700; }
.result-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; margin-bottom: 32px; }
@media (max-width: 900px) { .result-grid { grid-template-columns: 1fr; } .result-head { grid-template-columns: 1fr; gap: 8px; } }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bars li { display: grid; grid-template-columns: minmax(150px, 230px) 1fr 54px; gap: 12px; align-items: center; font-size: 15.5px; }
.bars .meter-bar { height: 12px; }
.bars .meter-bar i.mid { background: #d18b00; }
.bars .meter-bar i.low { background: var(--wrong); }
.bars b { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .bars li { grid-template-columns: 1fr 48px; } .bars li .meter-bar { grid-column: 1 / -1; grid-row: 2; } }
.review-list { list-style: none; margin: 0; padding: 0; }
.review-list button { width: 100%; display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 9px 8px; background: none; border: 0; border-top: 1px solid var(--line); text-align: left; cursor: pointer; }
.review-list button:hover { background: #eef2f8; }
.mark { font-weight: 800; font-size: 18px; }
.mark.ok { color: var(--right); }
.mark.no { color: var(--wrong); }

/* ---------- progress ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin: 22px 0 28px; }
.stat { padding: 16px 18px; }
.stat b { display: block; font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 15px; }
.history { width: 100%; border-collapse: collapse; font-size: 15.5px; }
.history th, .history td { text-align: left; padding: 9px 8px; border-top: 1px solid var(--line); }
.history th { font-weight: 700; color: var(--muted); font-size: 14px; }
.history td.num { font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* ---------- overlay ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 25, 45, 0.6); z-index: 60; display: grid; place-items: center; padding: 8px; }
.overlay[hidden] { display: none; }
.dialog { background: #fff; border-radius: var(--radius-m); padding: 22px; width: min(480px, 100%); display: grid; gap: 14px; }
.dialog.wide { width: min(1100px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.zoom { max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto; border-radius: var(--radius-s); background: #fff; }
.zoom img { display: block; width: auto; max-width: none; max-height: none; cursor: zoom-out; }
@media (min-width: 900px) { .zoom img { max-width: calc(100vw - 48px); max-height: calc(100vh - 48px); } }
.zoom-hint { display: none; }
@media (max-width: 640px) { .qfig { padding: 10px; } .zoom-hint { display: inline; } .answer-box { padding: 16px; } }
.foot { padding: 28px 0 40px; color: var(--muted); font-size: 14px; border-top: 1px solid var(--line); margin-top: 40px; }
.foot p { margin: 4px 0; max-width: 70em; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Patreon access ---------- */
.banner { padding: 16px 18px; margin: 0 0 18px; border-color: var(--dropout); background: var(--dropout-tint); display: grid; gap: 10px; }
.banner p { margin: 0; max-width: 70em; }
.banner.warn { border-color: #d68a00; background: #fff4e0; }
.banner code { background: #fff; padding: 1px 6px; border-radius: 4px; }
.paper-btn.locked { background: #f7f8fa; }
.paper-btn.locked strong { color: var(--muted); }
.paper-btn.locked span { color: var(--dropout); font-weight: 700; }
.paper-btn.free { border-color: var(--right); }
.paper-btn.free span { color: var(--right); font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-m); z-index: 70; box-shadow: 0 6px 24px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }
