/* GCSE Paper Trainer, in Cecil Jones Academy's colours: school navy for text and buttons,
   turquoise for "you are here", the logo's orange as a warm accent, and the school's
   light blue-grey page background. Each grade keeps its own colour. */

:root {
  color-scheme: light;
  --page: #e8eff3;
  --surface: #ffffff;
  --text: #16214a;
  --text-2: #495456;
  --muted: #747f86;
  --border: #d7e3ea;
  --grid: #e3ebf0;
  --axis: #b9c9d3;
  --accent: #213372;
  --accent-hover: #1b2a5e;
  --accent-ink: #ffffff;
  --accent-soft: #e3e9f6;
  --marker: #58c7d4;
  --marker-soft: rgba(88, 199, 212, 0.38);
  --marker-ink: #0a1023;
  --orange: #e46c37;
  --orange-soft: rgba(228, 108, 55, 0.12);
  --redpen: #d4213d;
  --good: #13915a;
  --warning: #e09a0c;
  --critical: #d4213d;
  --wash: rgba(22, 33, 74, 0.05);
  --shadow: 0 1px 2px rgba(22, 33, 74, 0.05), 0 6px 20px rgba(22, 33, 74, 0.05);
  --series-1: #213372;
  --series-2: #e8622c;
  --series-3: #13915a;
  --series-4: #d99a00;
  --series-5: #c2418a;
  --series-6: #2ba3b1;
  --series-7: #6b4bd8;
  --series-8: #d4213d;
  /* Grade colours, U to 9: red, orange, amber, gold, lime, green (6), teal, blue, purple (9). */
  --g-U: #d4213d;
  --g-1: #d63f1a;
  --g-2: #dc5c0c;
  --g-3: #c27400;
  --g-4: #a3830a;
  --g-5: #5f8f0b;
  --g-6: #1c8f3f;
  --g-7: #0b8584;
  --g-8: #1f63d1;
  --g-9: #7b3fe4;
  --font-body: "Open Sans", Geneva, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Lato", "Open Sans", system-ui, sans-serif;
  --font-hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0a1023;
    --surface: #16214a;
    --text: #f2f6fa;
    --text-2: #b9c6d6;
    --muted: #8a99b2;
    --border: #26346a;
    --grid: #1f2b58;
    --axis: #36468a;
    --accent: #58c7d4;
    --accent-hover: #7ad4de;
    --accent-ink: #0a1023;
    --accent-soft: rgba(88, 199, 212, 0.16);
    --marker: #58c7d4;
    --marker-soft: rgba(88, 199, 212, 0.3);
    --marker-ink: #0a1023;
    --orange: #f08752;
    --orange-soft: rgba(240, 135, 82, 0.16);
    --redpen: #ff6e7f;
    --good: #43c98a;
    --warning: #f0b43c;
    --critical: #ff6e7f;
    --wash: rgba(236, 240, 250, 0.06);
    --shadow: none;
    --series-1: #58c7d4;
    --series-2: #ff8a57;
    --series-3: #43c98a;
    --series-4: #f0b43c;
    --series-5: #f07cb8;
    --series-6: #3cc4c4;
    --series-7: #a48dff;
    --series-8: #ff6e7f;
    --g-U: #ff6e7f;
    --g-1: #ff8259;
    --g-2: #ff9a4d;
    --g-3: #ffb947;
    --g-4: #f0d34e;
    --g-5: #bfe05a;
    --g-6: #5fd98a;
    --g-7: #4fd1c5;
    --g-8: #74a9ff;
    --g-9: #b794ff;
  }
}

.g-U { --g: var(--g-U); }
.g-1 { --g: var(--g-1); }
.g-2 { --g: var(--g-2); }
.g-3 { --g: var(--g-3); }
.g-4 { --g: var(--g-4); }
.g-5 { --g: var(--g-5); }
.g-6 { --g: var(--g-6); }
.g-7 { --g: var(--g-7); }
.g-8 { --g: var(--g-8); }
.g-9 { --g: var(--g-9); }

/* ---------- base ---------- */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--text);
  font: 15px/1.6 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-head); color: var(--text); letter-spacing: -0.015em; }
h1 { font-size: 34px; line-height: 1.15; font-weight: 900; margin: 0; }
h2 { font-size: 21px; line-height: 1.25; font-weight: 700; margin: 0 0 12px; }
h3 { font-size: 17px; line-height: 1.3; font-weight: 700; margin: 0 0 6px; }
p { margin: 0 0 10px; }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--marker-soft); color: inherit; }

.icon { flex: none; }
.muted { color: var(--muted); }
.secondary { color: var(--text-2); }
.small { font-size: 14px; }
.error { color: var(--critical); }
.error:empty { display: none; }
.hint { font-size: 14px; color: var(--text-2); font-weight: 400; margin: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: grid; gap: 14px; }
.stack > *, .page > * { min-width: 0; }
.center { text-align: center; }

/* ---------- top bar ---------- */

/* Header in the school website's style: white bar, logo on the left, small spaced capitals. */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 26px;
  height: 76px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(22, 33, 74, 0.05);
}
.brand { display: inline-flex; align-items: center; gap: 14px; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-logo { height: 46px; width: auto; display: block; }
.brand-name { padding-left: 14px; border-left: 2px solid var(--border); font-family: var(--font-head); font-weight: 900; font-size: 16px; line-height: 1.1; color: var(--text); }
.brand-name small { display: block; font-weight: 700; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--marker); }
.topbar nav { display: flex; gap: 2px; min-width: 0; }
.topbar nav a, .nav-settings {
  position: relative;
  padding: 10px 11px;
  color: var(--text-2);
  text-decoration: none;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.topbar nav a:hover, .nav-settings:hover { color: var(--text); }
.topbar nav a::after, .nav-settings::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 2px;
  height: 3px;
  border-radius: 3px;
  background: var(--marker);
  transform: scaleX(0);
  transition: transform 0.15s;
}
.topbar nav a:hover::after { transform: scaleX(0.5); }
.topbar nav a.active, .nav-settings.active { color: var(--text); }
.topbar nav a.active::after, .nav-settings.active::after { transform: scaleX(1); }
.nav-settings { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; }

main { flex: 1; min-height: 0; overflow: auto; }

/* ---------- page layout ---------- */

.page { max-width: 1040px; margin: 0 auto; padding: 36px 24px 72px; }
.page.wide { max-width: 1200px; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-intro { margin-bottom: 26px; }
.page-intro h1 { margin-bottom: 8px; }
.lead { margin: 8px 0 0; max-width: 62ch; color: var(--text-2); font-size: 17px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 14px; font-size: 15px; font-weight: 700; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 34px 0 12px; }
.section-title h2 { margin: 0; }
.section-title a { font-weight: 700; font-size: 15px; text-decoration: none; }
.group-title { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--text); margin: 28px 0 12px; letter-spacing: -0.01em; }

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

button, .btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--axis);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--wash); border-color: var(--axis); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.quiet, .btn.quiet { border-color: transparent; background: none; color: var(--text-2); padding: 8px 10px; }
button.quiet:hover, .btn.quiet:hover { background: var(--wash); color: var(--text); }
button.danger { background: var(--critical); border-color: var(--critical); color: #fff; }
button.danger:hover { background: var(--critical); filter: brightness(1.08); }
button.big, .btn.big { padding: 12px 26px; font-size: 16px; }
.link-btn { background: none; border: none; padding: 6px 8px; color: var(--accent); font-weight: 700; cursor: pointer; }
.link-btn:hover { background: none; text-decoration: underline; }
.link-btn.danger { color: var(--critical); }
.icon-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 10px;
  color: var(--text-2);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--wash); color: var(--text); }
.icon-btn.star.on { color: #e6a700; }

input[type="text"], input[type="search"], input[type="number"], textarea, select {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--axis);
  background: var(--surface);
  color: var(--text);
}
select { width: auto; padding: 9px 12px; cursor: pointer; }
input[type="text"]:focus, input[type="search"]:focus, input[type="number"]:focus, textarea:focus, select:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; display: block; }
textarea.code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 14px; tab-size: 4; }

input.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 44px;
  height: 26px;
  margin: 0;
  border-radius: 999px;
  background: var(--axis);
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}
input.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::after { transform: translateX(18px); }
input.switch:disabled { opacity: 0.45; cursor: default; }

input.slider {
  --fill: 50%;
  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--grid) var(--fill));
  cursor: pointer;
}
input.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); box-shadow: 0 2px 6px rgba(23, 32, 51, 0.2); }
input.slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
input.slider:focus-visible { outline-offset: 6px; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button { border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.pills button.on { background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--wash);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.tier-higher { background: color-mix(in srgb, var(--series-7) 14%, transparent); color: var(--text); }
.chip.tier-foundation { background: color-mix(in srgb, var(--series-3) 16%, transparent); color: var(--text); }
.chip.mini { background: var(--orange-soft); color: var(--orange); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--axis);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
  display: inline-block;
}
.spinner.big { width: 36px; height: 36px; border-width: 3px; }
.spinner.small { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- surfaces ---------- */

.card, .sheet {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
}
/* Lists inside one sheet, separated by rules like lines on a page. */
.rows { padding: 0; }
.rows > * { padding: 16px 20px; }
.rows > * + * { border-top: 1px solid var(--border); }
.notice { background: var(--accent-soft); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; font-size: 15px; }
.center-state { display: grid; justify-items: center; gap: 14px; padding: 90px 24px; text-align: center; max-width: 560px; margin: 0 auto; }
.empty { text-align: center; padding: 44px 24px; }
.empty ol { display: inline-block; text-align: left; color: var(--text-2); margin: 8px 0 18px; padding-left: 20px; }

/* "More actions" menus */
.menu-wrap { position: relative; }
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  min-width: 210px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(23, 32, 51, 0.16);
}
.menu-item { width: 100%; justify-content: flex-start; border: 0; border-radius: 8px; padding: 9px 12px; background: none; font-weight: 700; color: var(--text); }
.menu-item:hover { background: var(--wash); border: 0; }
.menu-item.danger { color: var(--critical); }

.modal-back { position: fixed; inset: 0; background: rgba(14, 20, 36, 0.5); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { max-width: 440px; width: 100%; }
.modal h2 { margin-bottom: 8px; }

/* ---------- grades: written in red pen, circled like a teacher's mark ---------- */

.grade-mark {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 36px;
  padding: 0 8px;
  color: var(--g, var(--redpen));
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 27px;
  line-height: 1;
  white-space: nowrap;
}
.grade-mark.wide { min-width: 62px; }
.grade-mark svg { position: absolute; inset: -2px -4px; width: calc(100% + 8px); height: calc(100% + 4px); overflow: visible; }
.grade-mark path { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.grade-mark .gv { position: relative; transform: rotate(-4deg); }
.grade-mark.big { min-width: 132px; height: 100px; font-size: 78px; }
.grade-mark.big.wide { min-width: 170px; }
.grade-mark.big path { stroke-width: 3.2; stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw-loop 0.9s 0.25s ease-out forwards; }
@keyframes draw-loop { to { stroke-dashoffset: 0; } }

/* ---------- home ---------- */

.home-hero {
  margin-bottom: 24px;
  padding: 34px 34px 30px;
  border-radius: 20px;
  background: #213372;
  color: #ffffff;
  position: relative;
  overflow: hidden;
}
.home-hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%; border: 26px solid rgba(88, 199, 212, 0.25); }
.home-hero h1 { font-size: 40px; color: #ffffff; position: relative; }
.home-hero .school { display: block; margin-bottom: 8px; font-weight: 700; color: #58c7d4; position: relative; }
.home-hero .lead { color: #d3dcf0; position: relative; }
.continue { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; border-left: 5px solid var(--orange); }
.continue .what { flex: 1; min-width: 220px; }
.continue .what strong { display: block; font-size: 17px; }
.start-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
/* Start tiles are drawn as exam sheets with a folded corner. */
.start-tile {
  position: relative;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 22px 22px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px 0 16px 16px;
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.start-tile::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 30px;
  height: 30px;
  background: linear-gradient(225deg, var(--page) 50%, var(--grid) 50%);
  border-bottom-left-radius: 6px;
}
.start-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.start-tile .tile-icon { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.start-tile:nth-child(2) .tile-icon { background: rgba(88, 199, 212, 0.18); color: #2b8f9b; }
.start-tile:nth-child(3) .tile-icon { background: var(--orange-soft); color: var(--orange); }
.start-tile strong { font-family: var(--font-head); font-size: 20px; letter-spacing: -0.01em; }
.start-tile span { color: var(--text-2); }
.home-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.result-row { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--text); }
.result-row:hover { background: var(--wash); }
.result-row .what { flex: 1; min-width: 0; }
.result-row .what strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-row .score { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); }
.points-mini .points-figure .big { font-size: 44px; }
.how-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.how-steps li { counter-increment: step; padding-left: 46px; position: relative; color: var(--text-2); }
.how-steps li::before { content: counter(step); position: absolute; left: 0; top: -2px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-family: var(--font-head); }
.how-steps strong { display: block; color: var(--text); }

/* ---------- papers ---------- */

.paper-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.paper-row .info { flex: 1; min-width: 240px; display: grid; gap: 5px; }
.paper-row .title { font-weight: 700; font-size: 16px; }
.paper-row .meta { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; color: var(--text-2); font-size: 14px; }
.paper-row .chips { gap: 6px; }
.paper-row .actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.paper-row .status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.paper-row .status.error { color: var(--critical); }

.form { display: grid; gap: 18px; max-width: 580px; }
.form label { display: grid; gap: 6px; font-weight: 700; font-size: 15px; }
.form label span { font-weight: 400; color: var(--text-2); font-size: 14px; }
.form input[type="file"] { font: inherit; }

/* ---------- attempt ---------- */

.attempt { height: 100%; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(380px, 1fr); }
.attempt.no-pdf { grid-template-columns: minmax(0, 820px); justify-content: center; }
.pdf-pane { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--grid); }
.pdf-tools { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); font-size: 14px; color: var(--text-2); }
.pdf-tools .tabs { display: flex; gap: 4px; overflow-x: auto; min-width: 0; }
.pdf-tools .tab { padding: 5px 11px; font-size: 13px; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--text-2); }
.pdf-tools .tab.on { background: var(--marker-soft); color: var(--text); }
.pdf-scroll { flex: 1; overflow: auto; padding: 14px; }
.pdf-pages { margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.16); border-radius: 2px; }
/* Out of flow, so the canvas's own pixel size can never stretch the page box. */
.pdf-page canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.answer-pane { display: flex; flex-direction: column; min-height: 0; }
.answer-head { flex: none; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.answer-head .title { font-family: var(--font-head); font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.answer-scroll { flex: 1; overflow: auto; padding: 16px 18px 90px; display: grid; gap: 14px; align-content: start; }
.timer { font-variant-numeric: tabular-nums; }
.audio-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.audio-bar audio { flex: 1; min-width: 0; height: 36px; }
.audio-bar select { flex: none; }

.question { padding: 16px; }
.question .q-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.question .q-id { font-family: var(--font-head); font-weight: 750; font-size: 17px; }
.question .q-prompt { color: var(--text); font-size: 15px; margin-bottom: 12px; white-space: pre-wrap; }
.question .q-from { font-size: 13px; color: var(--muted); }
.options { display: grid; gap: 6px; }
.options label { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; }
.options label:hover { background: var(--wash); }

/* ---------- results ---------- */

.hero { display: flex; gap: 32px; align-items: center; flex-wrap: wrap; padding: 26px; }
.hero .figure { font-family: var(--font-head); font-size: 54px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.hero .summary { flex: 1; min-width: 260px; color: var(--text-2); font-size: 16px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.two-col ul { margin: 0; padding-left: 20px; color: var(--text-2); }
.two-col li + li { margin-top: 6px; }

.mark { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mark::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--warning); }
.mark.full::before { background: var(--good); }
.mark.zero::before { background: var(--critical); }
.answer-box { background: var(--wash); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; margin-bottom: 12px; }
.answer-box.code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 14px; }
.label { font-size: 14px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }

.grade-card .ladder { display: flex; gap: 8px; flex-wrap: wrap; }
.ladder-step {
  display: grid;
  justify-items: center;
  min-width: 56px;
  padding: 7px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-variant-numeric: tabular-nums;
}
.ladder-step { border-top: 4px solid var(--g, var(--border)); }
.ladder-step .lg { font-family: var(--font-head); font-weight: 750; font-size: 17px; color: var(--g, var(--text)); }
.ladder-step .lm { font-size: 12px; color: var(--text-2); }
.ladder-step.counts-u { opacity: 0.45; }
.ladder-step.on { border-color: var(--g); box-shadow: 0 0 0 1px var(--g); background: color-mix(in srgb, var(--g) 10%, var(--surface)); }
.grade-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 2px; margin-top: 14px; color: var(--text-2); font-size: 14px; }
.grade-key .grade-mark { min-width: 34px; height: 28px; font-size: 22px; padding: 0 4px; }

/* ---------- progress ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.tile .value { font-family: var(--font-head); font-size: 32px; font-weight: 800; line-height: 1.15; letter-spacing: -0.02em; }
.tile .name { color: var(--text-2); font-size: 14px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--text-2); margin-bottom: 8px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.swatch.m { background: var(--good); }
.swatch.l { background: var(--warning); }
.swatch.n { background: var(--wash); box-shadow: inset 0 0 0 1px var(--axis); }
.chart { position: relative; }
.chart svg { display: block; }
.chart text { font-size: 12px; fill: var(--muted); font-variant-numeric: tabular-nums; font-family: var(--font-body); }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  width: max-content;
  max-width: 260px;
  z-index: 2;
}
.tooltip .t-title { font-weight: 700; }
.topic-group + .topic-group { margin-top: 18px; }
.topic-row { display: grid; grid-template-columns: minmax(120px, 220px) 1fr 140px; gap: 12px; align-items: center; padding: 5px 0; font-size: 15px; }
.topic-row .track { height: 12px; background: var(--wash); border-radius: 999px; overflow: hidden; }
.topic-row .bar { height: 100%; min-width: 3px; border-radius: 999px; }
.topic-row .val { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-weight: 700; color: var(--text-2); font-size: 14px; }
th, td { padding: 10px 10px; border-bottom: 1px solid var(--grid); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ---------- AQA library ---------- */

.search { max-width: 320px; }
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.subject-tile { display: grid; gap: 6px; align-content: start; text-decoration: none; color: var(--text); padding: 16px 18px; transition: border-color 0.15s; }
.subject-tile:hover { border-color: var(--accent); }
.subject-tile .name { font-family: var(--font-head); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.tile-chips { gap: 6px; }
.filters { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filter { display: flex; gap: 8px; align-items: center; font-size: 15px; color: var(--text-2); font-weight: 700; }
.filter select { max-width: 340px; font-weight: 400; }
.series-group .group-title { margin-top: 26px; }

/* ---------- flashcards ---------- */

.maker { padding: 24px; }
.maker-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; }
.maker-head h2 { margin: 2px 0 4px; }
.maker-head p { margin: 0; }
.maker-icon { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.maker-form { display: grid; gap: 18px; max-width: 660px; margin-top: 20px; }
.field { display: grid; gap: 7px; }
.field-name { font-weight: 700; font-size: 15px; }
.field select { width: 100%; }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -8px; }
.suggestion { border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.suggestion.on { background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
/* Flashcard sets look like index cards: a red top rule over faint blue lines. */
.deck-card {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 18px 18px 16px;
  text-decoration: none;
  color: var(--text);
  border-radius: 8px;
  background:
    linear-gradient(var(--surface), var(--surface)) top / 100% 46px no-repeat,
    linear-gradient(var(--orange), var(--orange)) 0 46px / 100% 1.5px no-repeat,
    repeating-linear-gradient(var(--surface) 0 27px, color-mix(in srgb, var(--series-1) 14%, transparent) 27px 28px) 0 47px,
    var(--surface);
  transition: transform 0.15s, border-color 0.15s;
}
.deck-card:hover { transform: rotate(-0.6deg) translateY(-2px); border-color: var(--axis); }
.deck-card .title { font-family: var(--font-head); font-weight: 700; font-size: 18px; min-height: 28px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-card .source { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-bar, .mastery-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--grid); }
.mastery-bar { height: 12px; margin: 14px 0 10px; }
.mini-bar .m, .mastery-bar .m { background: var(--good); }
.mini-bar .l, .mastery-bar .l { background: var(--warning); }

.set-head h1 { font-size: 32px; }
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin: 24px 0 14px; }
.mode-tile {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 4px solid var(--grid);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.mode-tile:hover { border-bottom-color: #4255ff; }
.mode-tile strong { display: block; font-size: 17px; font-family: var(--font-head); }
.mode-tile small { display: block; color: var(--text-2); font-size: 14px; }
.mode-icon { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: rgba(66, 85, 255, 0.12); color: #4255ff; }
.set-actions { margin-bottom: 16px; }
.set-progress .legend { margin: 0; }
.term-group { margin-top: 28px; }
.term-group h2 { margin-bottom: 2px; }
.term-group > p { margin: 0; }
.term-list { display: grid; gap: 8px; margin-top: 12px; }
.term-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) auto;
  gap: 16px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px 14px 18px;
}
.term-row .t { font-weight: 700; border-right: 2px solid var(--grid); padding-right: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.term-row .d { white-space: pre-wrap; overflow-wrap: anywhere; }
.term-row .acts { display: flex; margin-top: -6px; }

.edit-meta { display: grid; gap: 20px; }
.edit-field { display: grid; gap: 4px; }
.edit-field textarea, .edit-field input {
  border: none;
  border-bottom: 2px solid var(--text);
  border-radius: 0;
  padding: 6px 2px;
  background: transparent;
  resize: none;
  overflow: hidden;
}
.edit-field textarea:focus, .edit-field input:focus { outline: none; border-bottom-color: var(--accent); }
.title-input { font-size: 18px; }
.field-label { font-size: 13px; font-weight: 700; color: var(--muted); }
.edit-card { padding: 0; }
.edit-card-head { display: flex; align-items: center; padding: 6px 10px 6px 18px; border-bottom: 1px solid var(--border); }
.edit-card-head .num { font-weight: 700; color: var(--text-2); }
.edit-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 16px 18px 18px; }
.add-card { width: 100%; margin-top: 12px; padding: 22px; border: 2px dashed var(--axis); border-radius: 14px; background: transparent; color: var(--text-2); }
.add-card:hover { border-color: var(--accent); color: var(--accent); background: transparent; }
.import-panel { margin-bottom: 16px; }
.import-panel textarea { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13.5px; }

/* ---------- grades and points ---------- */

.points-hero { padding: 24px; }
.points-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.points-figure { display: flex; align-items: baseline; gap: 8px; }
.points-figure .big { font-family: var(--font-head); font-size: 60px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.points-figure .of { font-size: 20px; color: var(--text-2); }
.target-input, .num-input { width: 86px; font: inherit; font-size: 20px; font-weight: 700; padding: 4px 8px; border-radius: 10px; border: 1px solid var(--axis); background: var(--surface); color: var(--text); }
.num-input { font-size: 16px; width: 96px; }
.points-verdict { font-weight: 700; color: var(--text-2); }
.points-verdict.done { color: var(--good); }
.points-bar { height: 14px; margin-top: 16px; border-radius: 999px; background: var(--grid); overflow: hidden; }
.points-bar span { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.4s; }
.points-bar span.done { background: var(--good); }
.grades-table td { vertical-align: middle; }
.grades-table tr.excluded td { opacity: 0.5; }
.grades-table .subject-name { font-weight: 700; }
.grades-table select { max-width: 190px; }
.grades-table .center, .grades-table th.center { text-align: center; }
.points-cell { font-weight: 700; font-size: 17px; }
.add-subject { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.add-subject input { flex: 1; min-width: 200px; width: auto; }
details.how summary { cursor: pointer; font-weight: 700; }
details.how[open] summary { margin-bottom: 10px; }
details.how p { color: var(--text-2); font-size: 15px; }

.settings-page { max-width: 780px; }
.set-section { margin-bottom: 16px; }
.set-section h2 { margin-bottom: 6px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--grid); }
.set-section h2 + .set-row { border-top: 0; }
.set-row select { max-width: 300px; }
.opt-label { display: block; font-weight: 700; }
.opt-note { display: block; font-size: 14px; color: var(--text-2); }
.save-state { min-width: 120px; text-align: right; }
.reset-section { border-color: color-mix(in srgb, var(--critical) 35%, var(--border)); }
.reset-section h2 { color: var(--critical); }
.reset-section .set-row { align-items: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--surface);
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.gone { opacity: 0; transform: translate(-50%, 8px); }

/* ---------- mini paper builder ---------- */

.builder { padding: 6px 24px; }
.builder-step { padding: 20px 0; }
.builder-step + .builder-step, .pool-line + .builder-step { border-top: 1px solid var(--border); }
.builder-step h2 { font-size: 19px; margin-bottom: 10px; }
.builder-step .field + .field, .builder-step .switch-row + .field { margin-top: 14px; }
.step-note { color: var(--text-2); font-size: 15px; margin: -4px 0 12px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; cursor: pointer; }
.switch-title { display: block; font-weight: 700; }
.switch-note { display: block; font-size: 14px; color: var(--text-2); max-width: 54ch; }
.pool-line { display: grid; gap: 8px; justify-items: start; padding: 0 0 20px; color: var(--text-2); font-size: 15px; }
.pool-line p { margin: 0; display: flex; align-items: center; gap: 8px; }
.pending { color: var(--text-2); }
.chip-toggle { border-radius: 999px; padding: 6px 12px; font-size: 14px; gap: 8px; }
.chip-toggle .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip-toggle.on { background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }
.chip-toggle.on .count { color: var(--marker-ink); opacity: 0.7; }
.slider-row { display: flex; align-items: center; gap: 18px; margin-top: 6px; }
.big-count { min-width: 56px; text-align: right; font-family: var(--font-head); font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.builder-bar {
  position: sticky;
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 16px 14px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(23, 32, 51, 0.12);
}
.builder-summary { display: grid; }
.builder-summary strong { font-family: var(--font-head); font-size: 19px; }
.builder-summary span { color: var(--text-2); font-size: 14px; }

/* ---------- stats ---------- */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; }
.fact { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--marker); border-radius: 14px; }
.fact span { font-size: 13px; color: var(--text-2); font-weight: 700; }
.fact strong { font-family: var(--font-head); font-size: 17px; }
.fact small { color: var(--text-2); }
.stats-controls { margin-bottom: 14px; }
.stat-table { padding: 0; overflow: hidden; }
.stat-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.3fr) minmax(150px, 2fr) 74px 84px 84px minmax(130px, 1fr);
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 18px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 400;
  text-align: left;
  white-space: normal;
}
button.stat-row:hover { background: var(--wash); border: 0; }
.stat-item + .stat-item, .stat-head + .stat-item { border-top: 1px solid var(--border); }
.stat-head { font-size: 13px; font-weight: 700; color: var(--text-2); background: var(--page); padding-top: 10px; padding-bottom: 10px; }
.stat-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.stat-name { display: grid; min-width: 0; }
.stat-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-avg { font-family: var(--font-head); font-weight: 900; font-size: 20px; color: var(--g, var(--text)); }
.stat-you { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.stat-you small { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.stat-you .chev { margin-left: auto; color: var(--muted); transition: transform 0.15s; }
.stat-item.open .chev { transform: rotate(180deg); }
.stat-item.open > .stat-row { background: var(--accent-soft); }
.spread { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--grid); }
.spread span { background: var(--g); min-width: 1px; }
.stat-detail { padding: 6px 18px 22px; background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.stat-detail h3 { margin: 14px 0 10px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 26px; }
.hist { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 18px; }
.hist-col { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.hist-bar { width: 100%; max-width: 44px; background: var(--g); border-radius: 6px 6px 2px 2px; }
.hist-val { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.hist-label { font-family: var(--font-head); font-weight: 900; font-size: 14px; color: var(--g); }
.hist.double .hist-label { font-size: 10px; }
.hist.double .hist-val { font-size: 9px; }
.you-box { display: flex; align-items: center; gap: 14px; }
.you-box p { margin: 0; }
.trend-table { margin-bottom: 14px; }
.trend-table h4 { margin: 8px 0 4px; font-family: var(--font-head); font-size: 15px; }
.trend-table table, .stat-detail table { background: var(--surface); border-radius: 10px; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .start-grid, .how-steps { grid-template-columns: 1fr; }
  .home-cols { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .topbar { gap: 12px; padding: 0 12px; }
  .topbar nav { overflow-x: auto; scrollbar-width: none; }
  .topbar nav a { padding: 8px 9px; }
  .nav-settings span, .brand .brand-name { display: none; }
  .topbar { height: 64px; }
  .brand-logo { height: 36px; }
  .attempt { grid-template-columns: 1fr; grid-template-rows: 45% 55%; }
  .pdf-pane { border-right: 0; border-bottom: 1px solid var(--border); }
  .topic-row { grid-template-columns: 1fr 100px; }
  .topic-row .track { grid-column: 1 / -1; grid-row: 2; }
  .edit-fields { grid-template-columns: 1fr; gap: 16px; }
  .term-row { grid-template-columns: minmax(0, 1fr) auto; }
  .term-row .t { border-right: 0; padding-right: 0; }
  .term-row .d { grid-column: 1; }
  .term-row .acts { grid-column: 2; grid-row: 1 / span 2; }
}

@media (max-width: 760px) {
  .stat-row { grid-template-columns: minmax(0, 1fr) 64px 76px; }
  .stat-row .spread, .stat-row .hide-sm, .stat-head span:nth-child(2) { display: none; }
  .stat-you { grid-column: 1 / -1; justify-content: flex-start; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .page { padding: 24px 16px 64px; }
  h1, .home-hero h1 { font-size: 28px; }
  .home-hero { padding: 24px 20px; }
  .brand { display: none; }
  .set-row { flex-direction: column; align-items: flex-start; }
  .grades-table .src { display: none; }
  .grades-table th, .grades-table td { padding: 8px 6px; }
  .grades-table select { max-width: 120px; }
  .points-figure .big { font-size: 46px; }
  .builder { padding: 4px 16px; }
  .builder-bar { flex-direction: column; align-items: stretch; }
  .hero { gap: 20px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile .value { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .grade-mark.big path { animation: none; stroke-dashoffset: 0; }
  .start-tile, .deck-card { transition: none; }
}
