:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #5b6474;
  --line: #e3e0d8;
  --accent: #1f5f8b;
  --accent-soft: #e8f1f7;
  --good: #1e7a46;
  --good-soft: #e7f5ec;
  --bad: #b3261e;
  --bad-soft: #fbeceb;
  --radius: 10px;
  --wrap: 760px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1b1f26;
    --text: #e7e9ee;
    --muted: #a3abb9;
    --line: #2c323c;
    --accent: #6cb3e6;
    --accent-soft: #1d2a36;
    --good: #5fcf8e;
    --good-soft: #17281f;
    --bad: #f08a83;
    --bad-soft: #2d1a19;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
header.site { border-bottom: 1px solid var(--line); background: var(--surface); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
nav.top a { margin-left: 16px; text-decoration: none; color: var(--muted); font-size: 15px; }
nav.top a:first-child { margin-left: 0; }
main { padding: 24px 0 48px; }
h1 { font-size: 30px; line-height: 1.25; margin: 8px 0 12px; }
h2 { font-size: 22px; line-height: 1.3; margin: 32px 0 10px; }
h3 { font-size: 18px; margin: 20px 0 8px; }
.lead { font-size: 19px; color: var(--muted); }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.meta { font-size: 14px; color: var(--muted); }
.card-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.card-list li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card-list .tag { font-size: 13px; color: var(--muted); }
.soon { color: var(--muted); }
table { border-collapse: collapse; width: 100%; font-size: 15px; margin: 12px 0; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
th { background: var(--accent-soft); }
.note { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; font-size: 15px; }

/* quiz */
ol.quiz { padding-left: 0; list-style: none; counter-reset: q; }
ol.quiz > li.q { counter-increment: q; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
li.q .stem { margin: 0 0 10px; font-weight: 600; }
li.q .stem::before { content: counter(q) ". "; color: var(--muted); }
ol.opts { list-style: none; padding: 0; margin: 0 0 8px; }
ol.opts li { margin: 6px 0; }
ol.opts label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
ol.opts input { margin-top: 5px; flex: none; }
ol.opts .letter { font-weight: 600; color: var(--muted); min-width: 1.2em; }
ol.opts label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
li.q.correct { border-color: var(--good); }
li.q.wrong { border-color: var(--bad); }
ol.opts label.is-answer { background: var(--good-soft); border-color: var(--good); }
ol.opts label.is-picked-wrong { background: var(--bad-soft); border-color: var(--bad); }
details.exp { margin-top: 6px; font-size: 15px; }
details.exp summary { cursor: pointer; color: var(--accent); }
details.exp p { margin: 8px 0; }
.src { color: var(--muted); font-size: 14px; }
.quiz-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
button { font: inherit; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
button.secondary { background: transparent; color: var(--accent); }
.score { font-weight: 600; }
footer.site { border-top: 1px solid var(--line); padding: 20px 0 32px; font-size: 14px; color: var(--muted); }
footer.site a { color: var(--muted); margin-right: 14px; }
@media (max-width: 520px) {
  body { font-size: 16px; }
  h1 { font-size: 25px; }
  nav.top a { margin-left: 12px; }
}

/* links styled as buttons */
a.cta { display: inline-block; padding: 9px 16px; border-radius: 8px; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; margin-right: 8px; }

/* timed practice exam */
.exam-app { margin: 18px 0 8px; }
.exam-app button { margin: 4px 8px 4px 0; }
.exam-start { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.exam-bar { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; font-weight: 600; }
.exam-timer.low { color: var(--bad); }
.exam-q { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.exam-q .stem { font-weight: 600; margin: 0 0 10px; }
.exam-nav { display: flex; flex-wrap: wrap; gap: 0; }
.exam-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.exam-palette button { margin: 0; padding: 6px 0; background: var(--surface); color: var(--text); border: 1px solid var(--line); font-size: 14px; }
.exam-palette button.answered { background: var(--accent-soft); border-color: var(--accent); }
.exam-palette button.flagged::after { content: " ⚑"; color: var(--bad); }
.exam-palette button.current { outline: 2px solid var(--accent); outline-offset: 1px; }
.exam-submit { margin-top: 16px; }
.exam-confirm { margin-top: 10px; }
.exam-result { border-radius: var(--radius); padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); }
.exam-result.pass { border-color: var(--good); background: var(--good-soft); }
.exam-result.fail { border-color: var(--bad); background: var(--bad-soft); }
.exam-score { font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.exam-topics tr.weak td { color: var(--bad); }
.exam-review { padding-left: 20px; }
.exam-review li { margin-bottom: 18px; }
.exam-review .stem { font-weight: 600; margin-bottom: 4px; }
.exam-review .yours { color: var(--bad); margin: 2px 0; }
.exam-review .right { color: var(--good); margin: 2px 0; }
