:root {
  /* Palette matches the front page (home.html) exactly, so the whole product feels like one site: teal brand,
     warm gold accent, the same ink/muted/line neutrals. brand-soft is home's .ico background; the warn pairing
     below (#fff1d4) is home's .rail-key background, both reused verbatim rather than approximated. */
  --bg: #f3f7f7;
  --card: #ffffff;
  --ink: #14273c;
  --dim: #536577;
  --line: #dce6e7;
  --brand: #007968;
  --brand-dark: #073e39;
  --brand-soft: #eaf4ef;
  --gold: #ffca65;
  --ok: #1e8a4c;
  --ok-soft: #e3f4ea;
  --bad: #c0392b;
  --bad-soft: #fbe8e5;
  --warn: #805418;
  --marked: #6b46c1;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 17px/1.5 var(--font); }
.hidden { display: none !important; }
a { color: var(--brand); }

#top {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--card); color: var(--ink); padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}
#top .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 19px; color: var(--ink); font-family: var(--font-display); }
#top .brand-logo { height: 32px; width: auto; display: block; }
#top .brand-sub { font-weight: 600; font-size: 14px; color: var(--dim); padding-left: 10px; border-left: 1px solid var(--line); }
#top .grow { flex: 1; }
#top a, #top button.link { color: var(--brand-dark); opacity: 1; font: inherit; font-weight: 600; background: none; border: none; cursor: pointer; text-decoration: none; padding: 0; }
#top a:hover, #top button.link:hover { text-decoration: underline; }
#who { color: var(--dim); }

main { max-width: 1120px; margin: 0 auto; padding: 22px 16px 60px; }
#v-loading { display: flex; justify-content: center; padding: 120px 0; }
.loadspin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--dim); animation: pk-spin .8s linear infinite; }
@keyframes pk-spin { to { transform: rotate(360deg); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px 22px; }
h1 { font: 700 28px var(--font-display); margin: 0 0 6px; letter-spacing: -.01em; }
h2 { font: 700 22px var(--font-display); margin: 0 0 12px; letter-spacing: -.01em; }
h3 { font: 600 18px var(--font-display); margin: 0 0 8px; }
.sub { color: var(--dim); margin: 0 0 16px; }
.muted { color: var(--dim); font-size: 15px; }

.btn {
  font: 600 16px var(--font); padding: 10px 18px; border-radius: 8px; cursor: pointer;
  background: #fff; color: var(--brand-dark); border: 1.5px solid var(--brand);
}
.btn:hover:not(:disabled) { background: var(--brand-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 5px 11px; font-size: 14px; }
.btn.ghost { border-color: var(--line); color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number], input[type=search], select, textarea {
  font: 400 17px var(--font); padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .opt:focus-within, .pal:focus-visible { outline: 3px solid #7fc4d4; outline-offset: 1px; }
label.field { display: block; font-weight: 600; margin-bottom: 12px; }
label.field > input, label.field > select, label.field > textarea { margin-top: 5px; font-weight: 400; }
.pwbox { position: relative; display: block; margin-top: 5px; }
.pwbox input { width: 100%; padding-right: 36px; box-sizing: border-box; margin-top: 0; }
.pw-eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border: none; cursor: pointer; padding: 0; background-color: var(--dim);
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; -webkit-mask-size: 19px; mask-size: 19px;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E");
}
.pw-eye:hover, .pw-eye:focus-visible { background-color: var(--brand-dark); }
.pw-eye.shown {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cline x1='2' y1='2' x2='22' y2='22'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cline x1='2' y1='2' x2='22' y2='22'/%3E%3C/svg%3E");
}
.note { padding: 10px 14px; border-radius: 8px; background: var(--brand-soft); border: 1px solid #b7d9e1; margin: 12px 0; }
.note.error { background: var(--bad-soft); border-color: #eab5ad; color: #7d241a; }
.note.ok { background: var(--ok-soft); border-color: #b5dcc4; }

/* ---------- sign in ---------- */
#v-login .card { max-width: 440px; margin: 40px auto; }
#code { font-size: 26px; letter-spacing: .25em; text-transform: uppercase; text-align: center; }

/* ---------- test list ---------- */
.tests { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tcard { display: flex; flex-direction: column; gap: 6px; }
.tcard .meta { color: var(--dim); font-size: 15px; }
.tcard .grow { flex: 1; }
.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 12px; }
.badge.new { background: var(--brand-soft); color: var(--brand-dark); }
.badge.progress { background: #fff1d4; color: var(--warn); }
.badge.done { background: var(--ok-soft); color: var(--ok); }

/* ---------- fractions, powers ---------- */
.frac { display: inline-flex; flex-direction: column; text-align: center; vertical-align: middle; margin: 0 2px; font-size: .92em; line-height: 1.15; }
.frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px; }

/* ---------- modal ---------- */
#modal, #pp, #sp { position: fixed; inset: 0; z-index: 20; background: rgba(15, 30, 36, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal .card, #pp .card, #sp .card { max-width: 480px; width: 100%; max-height: 90vh; overflow: auto; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--bg); border-radius: 8px; padding: 8px 12px; }
.stat b { font-size: 22px; display: block; }

/* ---------- result ---------- */
.score-row { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 18px; }
.big { background: var(--brand); color: #fff; border-radius: 12px; padding: 14px 22px; }
.big b { font-size: 40px; line-height: 1; display: block; }
.mini { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 20px; min-width: 110px; }
.mini b { font-size: 26px; display: block; }
table { border-collapse: collapse; width: 100%; font-size: 16px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--dim); font-weight: 600; font-size: 14px; }
/* Every table on these pages doubles as a sortable data grid (see the click-to-sort listener in admin-app.js);
   any header with real text is clickable to sort by that column, except one explicitly opted out with .no-sort. */
th:not(:empty):not(.no-sort) { cursor: pointer; user-select: none; }
th:not(:empty):not(.no-sort):hover { color: var(--fg); }
th.sort-asc::after { content: ' \25B2'; }
th.sort-desc::after { content: ' \25BC'; }
#stu-table { table-layout: fixed; }
#stu-table td.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: inline-block; }
.row-actions > summary {
  list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border: 1.5px solid var(--line); border-radius: 8px;
  font: 600 14px var(--font); color: var(--ink); background: #fff; white-space: nowrap;
}
.row-actions > summary::-webkit-details-marker { display: none; }
.row-actions > summary::after { content: '▾'; font-size: 10px; color: var(--dim); }
.row-actions[open] > summary { border-color: var(--brand); color: var(--brand-dark); }
.row-actions .menu-panel { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; min-width: 190px; }
.row-actions .menu-panel .btn { width: 100%; margin: 0 !important; text-align: left; }
.bar { height: 10px; border-radius: 5px; background: #e4ecee; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: var(--ok); }
.bar.low > i { background: var(--bad); } .bar.mid > i { background: #e0a126; }
.rv { border: 1px solid var(--line); border-left: 6px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: #fff; }
.rv.correct { border-left-color: var(--ok); } .rv.wrong { border-left-color: var(--bad); } .rv.skipped { border-left-color: #9aa9af; }
.rv .opts .opt { cursor: default; font-size: 17px; padding: 8px 12px; }
.rv .opt.right { border-color: var(--ok); background: var(--ok-soft); }
.rv .opt.mine.bad { border-color: var(--bad); background: var(--bad-soft); }
.expl { background: #f6f9fa; border-radius: 8px; padding: 10px 14px; margin-top: 10px; font-size: 16px; }
.focus li { margin-bottom: 4px; }

/* ---------- teacher page ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; position: sticky; top: 0; z-index: 15; background: var(--bg); padding: 10px 0 6px; }
.tab { font: 600 16px var(--font); padding: 9px 18px; border-radius: 8px 8px 0 0; border: 1.5px solid var(--line); border-bottom: none; background: #e9f0f2; cursor: pointer; }
.tab.on { background: #fff; color: var(--brand-dark); border-color: var(--brand); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 160px; }
.row > .btn { flex: 0 0 auto; }
.scroll { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.pill { display: inline-block; font-size: 13px; padding: 1px 8px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); }
.pill.no { background: var(--bad-soft); color: var(--bad); } .pill.yes { background: var(--ok-soft); color: var(--ok); }
.code { font-family: ui-monospace, Consolas, monospace; font-weight: 700; letter-spacing: .12em; }
@media print { #top, .noprint, .tabs { display: none !important; } body { background: #fff; } }

.group-title { margin: 26px 0 10px; font-size: 20px; color: var(--brand-dark); border-bottom: 2px solid var(--brand-soft); padding-bottom: 4px; }
.group-title:first-child { margin-top: 6px; }

/* ---------- sign in / create account ---------- */
.auth-tabs { display: flex; gap: 6px; margin: 4px 0 16px; flex-wrap: wrap; }
.auth-tab { font: 600 15px var(--font); padding: 8px 14px; border-radius: 20px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; }
.auth-tab.on { background: var(--brand); border-color: var(--brand); color: #fff; }
label.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 14px; font-size: 15px; }
label.check input { margin-top: 5px; transform: scale(1.25); accent-color: var(--brand); }

/* ---------- star rating ---------- */
.tstars { display: flex; gap: 4px; margin: 4px 0 12px; }
.tstar { font-size: 40px; line-height: 1; background: none; border: none; color: #c5d3d7; cursor: pointer; padding: 0 2px; }
.tstar.on { color: #e0a126; }
.tstar:focus-visible { outline: 3px solid #7fc4d4; border-radius: 6px; }

/* =====================================================================
   The test screen: one question at a time, the list of all questions on the right
   ===================================================================== */
main.xwide { max-width: 1280px; }
.x-narrow { display: inline-block; }
.x-top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin-bottom: 10px; }
.x-title { font-weight: 700; flex: 1 1 180px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-title small { display: block; font-weight: 400; color: var(--dim); font-size: 13px; }
#timer { font: 700 22px/1 var(--font); font-variant-numeric: tabular-nums; color: var(--brand-dark); background: var(--brand-soft); padding: 7px 12px; border-radius: 8px; }
#timer.low { color: #fff; background: var(--bad); }
.x-secs { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 10px; -webkit-overflow-scrolling: touch; }
.x-sec { flex: 0 0 auto; font: 600 15px var(--font); padding: 7px 14px; border-radius: 20px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; white-space: nowrap; }
.x-sec.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.x-sec span { font-weight: 400; opacity: .85; margin-left: 4px; }
.x-sec:disabled { opacity: .5; cursor: default; }
#res-filters { margin: 14px 0; padding: 14px 16px; background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px; }
#res-filters .field { margin-bottom: 0; min-width: 130px; }
#res-filters .field > select { width: 100%; }
.pie-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 14px 0 18px; }
.pie-card h3 { margin: 0 0 12px; font-size: 15px; }
.pie-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.pie-legend { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--ink); }
.pie-key { display: flex; align-items: center; gap: 8px; }
.pie-key i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: 0 0 auto; }
.x-body { display: block; }
.qhead { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; color: var(--dim); font-size: 15px; margin-bottom: 10px; }
.qhead b { color: var(--ink); }
.qtext { font-size: 20px; line-height: 1.55; margin-bottom: 16px; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; gap: 12px; align-items: baseline; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 19px; background: #fff; }
.opt:hover { border-color: var(--brand); background: #f6fbfc; }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt input { margin: 0; accent-color: var(--brand); transform: scale(1.25); }
.opt b { color: var(--brand-dark); min-width: 1.2em; }
.savestate { display: inline-block; font-size: 14px; font-weight: 600; padding: 3px 10px; border-radius: 12px; }
.savestate.saved { background: var(--ok-soft); color: var(--ok); }
.savestate.unsaved { background: #fff3d6; color: #a86a00; }
.savestate.none { background: var(--brand-soft); color: var(--dim); }
.x-actions { display: none; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
.x-actions .grow { flex: 1; }
.x-sub { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.x-bar { position: sticky; bottom: 0; z-index: 15; background: #fff; border-top: 1px solid var(--line); padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.x-bar .btn { padding: 11px 14px; }
.x-bar .save { flex: 1; }

/* the list of all questions: a drawer on a phone, a fixed column on a computer */
.x-scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 30; display: none; }
.x-scrim.on { display: block; }
.x-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(92vw, 370px); background: #fff; z-index: 40; transform: translateX(102%); transition: transform .22s ease; display: flex; flex-direction: column; border-left: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.x-panel.open { transform: none; }
.x-panel-static { display: none; }
.x-phead { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
.x-phead h3 { margin: 0 0 6px; font-size: 18px; display: flex; justify-content: space-between; align-items: center; }
.x-seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: 8px; overflow: hidden; margin: 4px 0 8px; }
.x-seg button { border: none; background: #fff; color: var(--ink); padding: 4px 12px; font: 400 14px var(--font); cursor: pointer; }
.x-seg button.on { background: var(--brand); color: #fff; }
.x-legend { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 8px; font-size: 13px; color: var(--dim); }
.x-legend i { display: inline-block; width: 13px; height: 13px; border-radius: 4px; vertical-align: -2px; margin-right: 5px; border: 1.5px solid #b8c6cb; }
.x-plist { overflow-y: auto; flex: 1; min-height: 0; padding: 6px 14px 16px; -webkit-overflow-scrolling: touch; }
.x-gh { position: sticky; top: 0; background: #fff; font-weight: 700; color: var(--brand-dark); padding: 8px 0 4px; font-size: 15px; display: flex; justify-content: space-between; z-index: 2; }
.x-gh span { font-weight: 400; color: var(--dim); font-size: 13px; }
.x-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; }
.x-chip { height: 42px; border-radius: 8px; border: 1.5px solid #b8c6cb; background: #fff; color: var(--ink); font: 700 15px var(--font); cursor: pointer; position: relative; }
.x-chip.cur { outline: 3px solid var(--brand); outline-offset: 1px; }
.x-chip.sv, .x-chip.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.x-chip.us { background: #fff3d6; border: 2px dashed #d98a00; color: #a86a00; }
.x-chip.na, .x-chip.wr { background: var(--bad); border-color: var(--bad); color: #fff; }
.x-chip.mk, .x-chip.am { background: var(--marked); border-color: var(--marked); color: #fff; border-radius: 50%; }
.x-chip.am::after { content: ''; position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--ok); border: 2px solid #fff; }
.x-chip.un { background: #8a99a0; border-color: #8a99a0; color: #fff; }
.x-row { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; background: #fff; border: 1.5px solid var(--line); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; cursor: pointer; color: var(--ink); font: 400 14px/1.3 var(--font); }
.x-row.cur { border-color: var(--brand); background: var(--brand-soft); }
.x-row .n { flex: 0 0 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; font-weight: 700; font-size: 14px; border: 1.5px solid #b8c6cb; }
.x-row .n.sv, .x-row .n.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.x-row .n.us { background: #fff3d6; border: 2px dashed #d98a00; color: #a86a00; }
.x-row .n.na, .x-row .n.wr { background: var(--bad); border-color: var(--bad); color: #fff; }
.x-row .n.mk, .x-row .n.am { background: var(--marked); border-color: var(--marked); color: #fff; }
.x-row .n.un { background: #8a99a0; border-color: #8a99a0; color: #fff; }
.x-row .t { flex: 1; min-width: 0; }
.x-row .t span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-row .t small { display: block; color: var(--dim); font-size: 12px; }
.x-psum { padding: 8px 14px 12px; border-top: 1px solid var(--line); font-size: 14px; color: var(--dim); }
.x-dbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.x-dbtns .btn { flex: 1 1 auto; }
.stat.warn { background: #fff3d6; }
.x-toast { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 20px; font-size: 15px; z-index: 70; }
.x-filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 12px; }

/* results rows */
.rv { scroll-margin-top: 90px; }
.rv .x-badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 12px; margin-left: 6px; }
.x-badge.correct { background: var(--ok-soft); color: var(--ok); } .x-badge.wrong { background: var(--bad-soft); color: var(--bad); } .x-badge.skipped { background: #eef2f3; color: var(--dim); border: 1px solid var(--line); }
.rv .x-rowbtns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }

/* past year papers */
.pp-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }
.pp-row b { display: block; }
.pp-row .muted { font-size: 14px; }
.badge.soon { background: #eef2f3; color: var(--dim); }

@media (min-width: 900px) {
  .x-narrow { display: none !important; }
  .x-body { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
  .x-bar { display: none; }
  .x-actions { display: flex; }
  .x-sub { display: none; }
  .x-scrim { display: none !important; }
  .x-panel, .x-panel-static { display: flex; position: sticky; top: 86px; transform: none; width: auto; max-height: calc(100vh - 104px); border: 1px solid var(--line); border-radius: 12px; z-index: 1; }
}

/* figures in questions */
.qimgs { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.qimg { max-width: min(100%, 460px); height: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.optimg { max-width: min(100%, 210px); height: auto; margin-top: 4px; }

/* sign in with Google or Apple */
.social { margin-top: 18px; }
.social .or { display: flex; align-items: center; gap: 10px; color: var(--muted, #5b6b72); font-size: 14px; margin: 0 0 12px; }
.social .or::before, .social .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.social-btn { display: flex; align-items: center; justify-content: center; gap: 10px; box-sizing: border-box; width: 100%; min-height: 46px; padding: 10px 14px; margin-bottom: 10px;
  border-radius: 8px; border: 1.5px solid var(--line); background: #fff; color: #1f1f1f; font: 600 16px var(--font); text-decoration: none; }
.social-btn:hover { background: #f6f8f9; }
.social-btn.apple { background: #000; border-color: #000; color: #fff; }
.social-btn.apple:hover { background: #222; }
.social-btn svg { width: 20px; height: 20px; flex: none; }

/* exam choice, plans and orders */
.exam-pick { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.exam-pick-row { color: var(--dim); margin: 4px 0 14px; }
.exam-pick-row button.link { background: none; border: 0; color: var(--brand-dark); text-decoration: underline; font: inherit; cursor: pointer; padding: 0; }
.badge.lock { background: #fdecc8; color: #7a4b00; }
.plan-banner { border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; background: var(--brand-soft); color: var(--brand-dark); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-banner.warn { background: #fff1d4; color: var(--warn); }
.plan-banner .grow { flex: 1; min-width: 160px; }
.plan-price { font-size: 28px; font-weight: 700; line-height: 1.1; }
.plan-old { text-decoration: line-through; color: var(--dim); font-size: 16px; font-weight: 400; margin-left: 6px; }
.plan-feats { padding-left: 18px; margin: 8px 0; }
.plan-line { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.plan-line.total { border-top: 1.5px solid var(--line); margin-top: 6px; padding-top: 8px; font-weight: 700; font-size: 18px; }
.plan-line.off { color: var(--ok); }
.order-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); }
.pay-box { background: #f7fafb; border: 1.5px dashed var(--line); border-radius: 10px; padding: 12px 14px; margin: 10px 0; white-space: pre-wrap; }
#pl-filter button.link { background: none; border: 0; color: var(--brand-dark); text-decoration: underline; font: inherit; cursor: pointer; padding: 0 2px; }

/* sums and integrals: the limits go above and below the symbol */
.lims { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 3px; line-height: 1; }
.lims .lim-hi, .lims .lim-lo { font-size: .72em; line-height: 1.15; white-space: nowrap; }
.lims .lim-sym { font-size: 1.35em; line-height: 1.05; }
.lims.lim-integral .lim-sym { font-size: 1.7em; line-height: .95; }
/* a written solution: one step on each line */
.sol-steps { margin-top: 4px; }
.sol-step { margin: 4px 0; line-height: 1.5; }

/* results: topics grouped by subject, each group opened and closed with + and - */
.tchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; }
.tgroup { border: 1.5px solid var(--line); border-radius: 12px; margin: 10px 0; overflow: hidden; background: #fff; }
.tgroup-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.tgroup-head:hover { background: #f4f8f9; }
.tgroup-head .tsign { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 20px; line-height: 24px; text-align: center; }
.tgroup-head .tname { flex: 1; font-weight: 600; }
.tgroup-head .tsum { color: var(--dim); font-size: 14px; white-space: nowrap; }
.tgroup-body { padding: 0 14px 12px; }
.tgroup-body table { width: 100%; }

/* ---------- legal pages (Terms, Privacy, Refunds, Contact) ---------- */
.legal { max-width: 760px; margin: 0 auto; line-height: 1.6; }
.legal h1 { margin-top: 0; }
.legal h2 { margin-top: 30px; }
.legal p, .legal ul, .legal ol { margin: 0 0 14px; }
.legal ul, .legal ol { padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal table { margin: 10px 0 18px; }
.legal th, .legal td { border: 1px solid var(--line); }
.legal strong { color: var(--brand-dark); }
.legal-foot { max-width: 1120px; margin: 40px auto 0; padding: 18px 16px 40px; border-top: 1px solid var(--line); text-align: center; }
.legal-foot-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 15px; }
.legal-foot-links a { text-decoration: none; color: var(--brand-dark); font-weight: 600; }
.legal-foot-links a:hover { text-decoration: underline; }
.legal-foot .muted { font-size: 13px; }

/* formulas drawn by KaTeX (public/mathfmt.js): a touch larger than the text around them; a very long one scrolls sideways instead of spilling out */
.katex { font-size: 1.08em; }
.qtext .katex, .sol-step .katex, .opt .katex { display: inline-block; max-width: 100%; overflow-x: auto; overflow-y: hidden; vertical-align: middle; }
