:root {
  --ink: #16133d;
  --ink-soft: #4a4770;
  --paper: #fbfaf6;
  --card: #ffffff;
  --line: #e4e1d8;
  --mark: #ffe14d;
  --accent: #4b3bf0;
  --good: #16865a;
  --mid: #c98714;
  --bad: #c9372f;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
/* Classes below set display, which would otherwise beat the hidden attribute. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.15; margin: 1.2em 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: 2rem; font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 750; }
mark { background: linear-gradient(transparent 12%, var(--mark) 12%, var(--mark) 88%, transparent 88%); color: inherit; padding: 0 0.15em; }
main { max-width: 760px; margin: 0 auto; padding: 0 18px 48px; }
main.narrow { max-width: 560px; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; max-width: 760px; margin: 0 auto; }
.brand { display: flex; gap: 8px; align-items: center; font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.top nav a { color: var(--ink); font-weight: 600; text-decoration: none; }
.foot { max-width: 760px; margin: 0 auto; padding: 24px 18px 40px; color: var(--ink-soft); font-size: 0.85rem; border-top: 1px solid var(--line); }
.foot .links a { margin-right: 14px; color: var(--ink-soft); }
.kicker { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; font-weight: 700; color: var(--ink-soft); margin: 1.4em 0 0; }
.lede { font-size: 1.1rem; color: var(--ink-soft); }
.small { font-size: 0.88rem; color: var(--ink-soft); }
.fine { font-size: 0.8rem; color: var(--ink-soft); }
.center { text-align: center; }
.note { background: #eef7f1; border-left: 4px solid var(--good); padding: 10px 14px; border-radius: 8px; }
.error { background: #fbeceb; border-left: 4px solid var(--bad); padding: 10px 14px; border-radius: 8px; color: #7a1d17; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: grid; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px; border-radius: 999px; border: 2px solid var(--ink);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn-main { background: var(--ink); color: #fff; }
.btn-big { width: 100%; min-height: 58px; font-size: 1.08rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.chip { display: inline-block; background: var(--mark); color: var(--ink); border-radius: 999px; padding: 2px 10px; font-size: 0.78rem; font-weight: 700; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }

/* landing */
.hero h1 { font-size: 2.35rem; margin-top: 0.4em; }
.maker { display: grid; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 18px 0; box-shadow: 0 6px 24px rgba(22, 19, 61, 0.06); }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pick { background: var(--mark); color: var(--ink); }
.picked { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.picked li { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 0.92rem; }
.picked li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details summary { cursor: pointer; font-weight: 650; padding: 6px 0; }
textarea, input[type="text"], input:not([type]), input[type="email"], input[type="number"], input[type="password"] {
  width: 100%; font: inherit; padding: 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { display: grid; gap: 6px; margin: 10px 0; border: 0; padding: 0; }
.field > span, .field legend { font-weight: 650; font-size: 0.92rem; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-block; border: 1.5px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 0.92rem; background: #fff; }
.seg input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.steps-list { padding-left: 1.2em; }
.steps-list li { margin: 0.6em 0; }
.honest ul, .includes { padding-left: 1.2em; }
.decks { display: grid; gap: 16px; }
.deck { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.deck h2 { margin-top: 0.3em; }
.slides-strip { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 10px 0; }
.mini-slide { border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 0.78rem; display: grid; gap: 4px; background: var(--paper); aspect-ratio: 16 / 10; overflow: hidden; }

/* progress */
.progress { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 18px 0; }
.progress .steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 10px; }
.progress .steps li { flex: 1; text-align: center; font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); border-bottom: 4px solid var(--line); padding-bottom: 6px; }
.progress .steps li.on { color: var(--ink); border-color: var(--mark); }
.progress .steps li.done { color: var(--good); border-color: var(--good); }
.progress .status { font-size: 1.15rem; font-weight: 700; min-height: 1.5em; }
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 3%; background: var(--accent); transition: width 0.4s ease; }
.spinner { width: 36px; height: 36px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; margin: 16px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* taking an exam */
.exam-head { position: sticky; top: 0; background: var(--paper); padding: 6px 0 10px; z-index: 2; border-bottom: 1px solid var(--line); }
.exam-head h1 { font-size: 1.35rem; margin: 0.2em 0; }
.timer { font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.over { color: var(--bad); }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.dots button { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--ink-soft); background: #fff; font-size: 0.65rem; padding: 0; color: var(--ink); }
.dots button.answered { background: var(--ink); color: #fff; border-color: var(--ink); }
.dots button.here { outline: 3px solid var(--mark); }
.questions { list-style: none; padding: 0; margin: 0; }
.q { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.q-meta { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 0.8rem; color: var(--ink-soft); margin: 0; flex-wrap: wrap; }
.q-prompt { font-size: 1.12rem; font-weight: 650; white-space: pre-wrap; }
.q-src { font-size: 0.8rem; color: var(--ink-soft); margin: 10px 0 0; }
.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 12px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; cursor: pointer; background: #fff; }
.choice input { position: absolute; opacity: 0; }
.choice:has(input:checked) { border-color: var(--ink); background: #f3f1ff; }
.choice:has(input:focus-visible) { outline: 2px solid var(--accent); }
.letter { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid var(--ink-soft); font-weight: 800; font-size: 0.85rem; }
.choice:has(input:checked) .letter { background: var(--ink); color: #fff; border-color: var(--ink); }
.exam-nav { display: flex; gap: 10px; justify-content: space-between; margin: 10px 0; }
.exam-nav .btn { flex: 1; }
.stepping .q { display: none; }
.stepping .q.here { display: block; }
.submit-row { margin: 18px 0; display: grid; gap: 10px; }
.grading { text-align: center; padding: 40px 0; font-weight: 700; font-size: 1.2rem; }

/* results */
.score-card { text-align: center; background: var(--ink); color: #fff; border-radius: var(--radius); padding: 18px; margin-top: 16px; }
.score-card .kicker { color: #c9c6ec; margin-top: 0; }
.score-card h1 { font-size: 1.25rem; margin: 0.3em 0; }
.score { margin: 0.2em 0; display: flex; justify-content: center; align-items: baseline; gap: 8px; }
.score .big { font-size: 3.4rem; font-weight: 900; line-height: 1; }
.score .of { font-size: 1.4rem; color: #c9c6ec; }
.score .pct { background: var(--mark); color: var(--ink); border-radius: 999px; padding: 2px 10px; font-weight: 800; }
.topic-bars { list-style: none; padding: 0; display: grid; gap: 10px; }
.topic-bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.t-name { font-weight: 650; }
.t-pct { font-size: 0.85rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.t-bar { grid-column: 1 / -1; height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.t-bar span { display: block; height: 100%; border-radius: 999px; }
.t-bar .low { background: var(--bad); }
.t-bar .mid { background: var(--mid); }
.t-bar .high { background: var(--good); }
.next { display: grid; gap: 12px; margin: 22px 0; }
.rev-list { list-style: none; padding: 0; }
.rev { background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; }
.rev.right { border-left-color: var(--good); }
.rev.partial { border-left-color: var(--mid); }
.rev.wrong { border-left-color: var(--bad); }
.rev .mark { font-weight: 800; }
.rev.right .mark { color: var(--good); }
.rev.partial .mark { color: var(--mid); }
.rev.wrong .mark { color: var(--bad); }
.rev-choices { list-style: none; padding: 0; display: grid; gap: 6px; }
.rev-choices li { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); }
.rev-choices .is-answer { border-color: var(--good); background: #eef7f1; }
.rev-choices .is-picked { border-color: var(--bad); background: #fbeceb; }
.rev-text p { white-space: pre-wrap; }
.rubric { font-size: 0.88rem; color: var(--ink-soft); }
.feedback { font-weight: 600; }
.src { margin: 10px 0 0; border-left: 4px solid var(--mark); background: #fffbe0; padding: 8px 12px; border-radius: 0 10px 10px 0; font-size: 0.9rem; }
.src p { margin: 0.2em 0; }
.src-quote { font-style: italic; }
.flag { margin-top: 8px; font-size: 0.85rem; }
.danger { margin-top: 32px; }

/* flashcards */
.cards { display: grid; gap: 12px; margin: 16px 0; }
.flash { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 3px 12px rgba(22, 19, 61, 0.05); }
.flash summary { list-style: none; padding: 18px; display: grid; gap: 8px; }
.flash summary::-webkit-details-marker { display: none; }
.flash .front { font-size: 1.08rem; font-weight: 650; white-space: pre-wrap; }
.flash .tap { font-size: 0.78rem; color: var(--ink-soft); }
.flash[open] .tap { display: none; }
.flash .back { padding: 0 18px 18px; border-top: 2px dashed var(--line); }
.flash .back p { white-space: pre-wrap; }

/* account, subscribe */
.terms-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; font-size: 0.92rem; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 2px; }
.plan { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; }
.code { font-size: 2.6rem; font-weight: 900; letter-spacing: 0.12em; text-align: center; background: var(--mark); border-radius: var(--radius); padding: 14px; font-variant-numeric: tabular-nums; }
.code-input { font-size: 1.6rem; text-align: center; letter-spacing: 0.15em; text-transform: uppercase; }
.exam-list { padding-left: 1.2em; }
.exam-list li { margin: 6px 0; }

/* admin */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; white-space: nowrap; }
tr.total td { font-weight: 800; }
code { word-break: break-all; }

.devbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 12px; background: #2b2a33; color: #fff; font-size: 0.75rem; z-index: 10; }
.devbar button { font-size: 0.75rem; }

@media (min-width: 720px) {
  .hero h1 { font-size: 3.2rem; }
  .slides-strip { grid-template-columns: repeat(4, 1fr); }
}

/* sending an exam to classmates */
.share { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 2px 16px 14px; margin: 22px 0; }
.share h2 { margin-top: 0.8em; }
.share-link { width: 100%; margin: 4px 0 10px; }
.make-own { display: grid; gap: 6px; }
.make-own p { margin: 0; }
