/* Canada Citizenship Prep — shared styles.
   Layout: a study binder. Sticky top bar (bottom tab bar on phones), one centred column per page,
   the flag's 1:2:1 red-white-red band as the masthead detail. */
:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --ink: #1a1e29;
  --muted: #586072;
  --line: #dde1e9;
  --red: #b0122c;
  --red-soft: #fbe8eb;
  --key: #0b57b0;
  --key-soft: #e7f0fb;
  --good: #17784a;
  --good-soft: #e3f4ea;
  --warn: #8a5a00;
  --warn-soft: #fbf1dc;
  --note: #eef2f8;
  --rule: #e8eef7;
  --mark: #ffe58a;
  --learn: #8fd0aa;
  --unseen: #cdd2dc;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(20,30,60,.06);
  --display: "Newsreader", Georgia, "Times New Roman", serif;
  --body: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --bar-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111319; --surface: #191c24; --ink: #e7e9ef; --muted: #a2a9b8; --line: #2b2f3a;
    --red: #ff6b7d; --red-soft: #3a1820; --key: #7fb8ff; --key-soft: #182638;
    --good: #5fd39a; --good-soft: #15301f; --warn: #f2c35b; --warn-soft: #33290f;
    --note: #1e2330; --rule: #222837; --shadow: 0 1px 2px rgba(0,0,0,.3);
    --learn: #2f7d55; --unseen: #3a3f4c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111319; --surface: #191c24; --ink: #e7e9ef; --muted: #a2a9b8; --line: #2b2f3a;
  --red: #ff6b7d; --red-soft: #3a1820; --key: #7fb8ff; --key-soft: #182638;
  --good: #5fd39a; --good-soft: #15301f; --warn: #f2c35b; --warn-soft: #33290f;
  --note: #1e2330; --rule: #222837; --shadow: 0 1px 2px rgba(0,0,0,.3);
  --learn: #2f7d55; --unseen: #3a3f4c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--bar-h) + 16px); -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.6; }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--key); }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--key); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition: none !important; animation: none !important; } }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.flag { display: grid; grid-template-columns: 1fr 2fr 1fr; height: 5px; }
.flag span:nth-child(odd) { background: var(--red); }
.flag span:nth-child(2) { background: var(--surface); }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.topbar-in { max-width: 1180px; margin: 0 auto; height: var(--bar-h); display: flex; align-items: center; gap: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-family: var(--display); font-weight: 650; font-size: 19px; white-space: nowrap; }
.brand-mark { width: 26px; height: 26px; flex: none; }
.mainnav { display: flex; gap: 2px; margin-left: auto; }
.mainnav a { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; }
.mainnav a:hover { color: var(--ink); background: var(--bg); }
.mainnav a[aria-current="page"] { color: var(--red); background: var(--red-soft); }
.mainnav svg { width: 18px; height: 18px; flex: none; }
.theme-btn { flex: none; width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn:hover { color: var(--ink); }

@media (max-width: 760px) {
  .brand-text { font-size: 17px; }
  .theme-btn { margin-left: auto; }
  .mainnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0; background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px)); }
  .mainnav a { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; flex: 1; text-align: center; }
  .mainnav svg { width: 22px; height: 22px; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- page shell ---------- */
.page { max-width: 1180px; margin: 0 auto; padding-block: 28px 64px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.narrow { max-width: 820px; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.eyebrow { font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--red); }
h1 { font-family: var(--display); font-weight: 650; font-size: clamp(32px, 5vw, 48px); line-height: 1.05; margin: 6px 0 10px; text-wrap: balance; }
h2 { font-family: var(--display); font-weight: 650; font-size: clamp(22px, 3vw, 28px); line-height: 1.15; margin: 0; text-wrap: balance; }
h3 { font-family: var(--display); font-weight: 650; font-size: 20px; margin: 0; text-wrap: balance; }
.lede { color: var(--muted); margin: 0; max-width: 62ch; font-size: 17px; }
.source { color: var(--muted); margin: 10px 0 0; max-width: 72ch; font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px clamp(16px, 3vw, 28px); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; padding: 10px 18px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.3; }
.btn:hover:not(:disabled) { border-color: var(--key); }
.btn.go { background: var(--key); border-color: var(--key); color: var(--surface); }
.btn.red { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--key); cursor: pointer; text-decoration: underline; font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.stat b { display: block; font-family: var(--mono); font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface); }
.seg button { background: none; border: 0; padding: 6px 14px; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--key); color: var(--surface); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.chip { font-size: 14px; white-space: nowrap; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--key); border-color: var(--key); color: var(--surface); }
.chip span { font-family: var(--mono); font-size: 12px; opacity: .8; margin-left: 4px; }

.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.bar.red i { background: var(--red); }

.pill { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 3px 10px; border-radius: 999px; }
.pill.pass { background: var(--good-soft); color: var(--good); }
.pill.fail { background: var(--red-soft); color: var(--red); }
.pill.info { background: var(--key-soft); color: var(--key); }

.callout { border-radius: 10px; padding: 14px 16px; background: var(--note); }
.callout.warn { background: var(--warn-soft); }
.callout b:first-child { display: block; }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 24px; }
.foot-in { max-width: 1180px; margin: 0 auto; padding-block: 24px 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); color: var(--muted); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.foot-in p { margin: 0; max-width: 90ch; }
/* Narrow pages (practice, mock, flashcards, legal): the footer lines up with the content column. */
body:has(main.narrow) .foot-in { max-width: 820px; }

/* ---------- home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; align-items: end; }
@media (max-width: 820px) { .hero { grid-template-columns: minmax(0, 1fr); } }
.hero .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.hero .stat { padding: 12px; }
.hero .stat b { font-size: 22px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.steps a { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); }
.steps a:hover { border-color: var(--key); }
.steps .n { font-family: var(--mono); font-size: 12px; color: var(--red); letter-spacing: .08em; }
.steps strong { font-family: var(--display); font-size: 21px; }
.steps span { color: var(--muted); font-size: 14px; }
.steps .meter { margin-top: auto; padding-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.topic-table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.topic-table th, .topic-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.topic-table th { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.topic-table td.num { width: 90px; }
.topic-table .pcol { width: 42%; min-width: 120px; }
.topic-table .links { white-space: nowrap; text-align: right; }
.topic-table .links a { font-size: 13px; margin-left: 10px; }
.tbl { overflow-x: auto; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }

/* ---------- notes ---------- */
.notes-head { display: flex; flex-wrap: wrap; gap: 16px 32px; align-items: end; justify-content: space-between; margin-bottom: 24px; }
.search { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 0 1 340px; }
.search label { font-size: 13px; font-weight: 600; color: var(--muted); }
.search input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); width: 100%; }
.search small { color: var(--muted); min-height: 1.2em; }
.notes-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 40px; }
nav.toc { position: sticky; top: calc(var(--bar-h) + 20px); align-self: start; max-height: calc(100vh - var(--bar-h) - 40px); overflow-y: auto; }
nav.toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
nav.toc a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 14px; border-left: 2px solid transparent; }
nav.toc a:hover { color: var(--ink); background: var(--surface); }
nav.toc a.on { color: var(--red); border-left-color: var(--red); background: var(--surface); font-weight: 600; }
.notes { min-width: 0; display: flex; flex-direction: column; gap: 28px; }
section.ch { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px clamp(16px, 3vw, 32px) 28px; min-width: 0; }
section.ch > header { margin-bottom: 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 16px; row-gap: 4px; align-items: end; }
section.ch > header > .eyebrow, section.ch > header > h2 { grid-column: 1; }
section.ch > header > .ch-actions { grid-column: 2; grid-row: 1 / span 2; }
@media (max-width: 640px) {
  section.ch > header { grid-template-columns: minmax(0, 1fr); }
  section.ch > header > .ch-actions { grid-column: 1; grid-row: auto; margin-top: 8px; }
}
.ch-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.notes h3 { margin: 22px 0 6px; }
.notes .sub:first-of-type h3 { margin-top: 8px; }
.notes ul { margin: 0; padding-left: 20px; }
.notes li { margin: 4px 0; max-width: 72ch; }
.notes li::marker { color: var(--red); }
.notes ul ul { margin-top: 2px; }
.notes ul ul li::marker { color: var(--muted); }
.notes b, .notes strong { font-weight: 700; color: var(--key); }
.d { font-family: var(--mono); font-size: .9em; font-weight: 500; color: var(--red); white-space: nowrap; }
.tip { background: var(--red-soft); border-radius: 8px; padding: 12px 16px; margin: 14px 0 4px; max-width: 76ch; }
.tip > b:first-child { color: var(--red); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; display: block; margin-bottom: 2px; }
.note { background: var(--note); border-radius: 8px; padding: 12px 16px; margin: 14px 0 4px; max-width: 76ch; }
.note > b:first-child { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 2px; }
.notes table { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
.notes th, .notes td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.notes th { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.notes .tbl { margin: 8px 0; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.cols > div { min-width: 0; }
.cols h4 { margin: 8px 0 4px; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.timeline { display: flex; flex-direction: column; border-left: 2px solid var(--line); margin-left: 6px; }
.ev { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 5px 0 5px 14px; position: relative; }
.ev::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--red); }
.oath { font-family: var(--display); font-size: 18px; line-height: 1.5; border-left: 3px solid var(--red); padding: 4px 0 4px 16px; margin: 8px 0; max-width: 60ch; }
.notes .hide { display: none !important; }
mark { background: var(--mark); color: #1a1e29; border-radius: 2px; }
.to-top { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 15; }
@media (max-width: 900px) {
  .notes-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  nav.toc { position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top, 0px)); z-index: 5; max-height: none; overflow-x: auto; overflow-y: hidden; background: var(--bg); margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); padding: 10px max(16px, env(safe-area-inset-left, 0px)); border-bottom: 1px solid var(--line); }
  nav.toc ol { flex-direction: row; gap: 6px; width: max-content; }
  nav.toc a { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; white-space: nowrap; background: var(--surface); }
  nav.toc a.on { border-color: var(--red); }
  .ev { grid-template-columns: 78px minmax(0, 1fr); }
  .to-top { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- questions (practice + mock) ---------- */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.mode { text-align: left; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.mode:hover:not(:disabled) { border-color: var(--key); }
.mode:disabled { opacity: .55; cursor: not-allowed; }
.mode strong { font-size: 16px; }
.mode small { color: var(--muted); }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.topic { color: inherit; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.topic:hover { border-color: var(--key); }
.topic[aria-pressed="true"] { border-color: var(--key); background: var(--key-soft); box-shadow: inset 0 0 0 1px var(--key); }
.topic .chk { flex: none; width: 18px; height: 18px; margin-right: 8px; border: 2px solid var(--muted); border-radius: 5px; background: var(--surface); position: relative; }
.topic[aria-pressed="true"] .chk { background: var(--key); border-color: var(--key); }
.topic[aria-pressed="true"] .chk::after { content: ""; position: absolute; left: 4px; top: 0; width: 5px; height: 10px; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.panel-sep { gap: 14px; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.chapter-tools { display: inline-flex; gap: 8px; }
.big-go { align-self: stretch; padding: 14px 20px; font-size: 17px; }
.topic .t { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.topic .t span { white-space: nowrap; flex: none; font-family: var(--mono); font-weight: 500; font-size: 13px; color: var(--muted); }
.topic small { color: var(--muted); font-size: 12px; }
.qtop { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.qtop .meta { font-family: var(--mono); font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer { font-family: var(--mono); font-size: 15px; padding: 3px 12px; border-radius: 999px; background: var(--key-soft); color: var(--key); font-variant-numeric: tabular-nums; }
.timer.low { background: var(--red-soft); color: var(--red); }
.progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--red); transition: width .2s; }
.qtext { font-family: var(--display); font-size: clamp(21px, 3vw, 27px); line-height: 1.3; font-weight: 500; margin: 4px 0; text-wrap: pretty; }
.tf-tag { font-family: var(--body); font-size: 13px; font-weight: 600; color: var(--key); display: block; margin-bottom: 4px; letter-spacing: .04em; text-transform: uppercase; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { color: inherit; text-align: left; background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; }
.opt .k { font-family: var(--mono); font-size: 13px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; text-align: center; line-height: 22px; height: 24px; }
.opt:hover:not(:disabled) { border-color: var(--key); }
.opt.sel { border-color: var(--key); background: var(--key-soft); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt:disabled { cursor: default; }
.feedback { border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.feedback.ok { background: var(--good-soft); }
.feedback.no { background: var(--red-soft); }
.feedback.ok b { color: var(--good); }
.feedback.no b { color: var(--red); }
.feedback a { font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; }
.dots button { width: 32px; height: 32px; font: 500 12px var(--mono); border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--muted); cursor: pointer; padding: 0; position: relative; }
.dots button.done { background: var(--key-soft); color: var(--key); border-color: var(--key); }
.dots button.flag::after { content: ""; position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--warn); border: 2px solid var(--surface); }
.dots button.cur { outline: 2px solid var(--red); outline-offset: 1px; }
.flagbtn[aria-pressed="true"] { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.score { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.score .big { font-family: var(--display); font-size: 56px; font-weight: 650; line-height: 1; font-variant-numeric: tabular-nums; }
.review { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.review li { border: 1px solid var(--line); border-left: 4px solid var(--red); border-radius: 8px; padding: 10px 14px; background: var(--bg); }
.review li.ok { border-left-color: var(--good); }
.review .q { font-weight: 600; }
.review .a { font-size: 14px; color: var(--muted); }
.review .a em { font-style: normal; color: var(--good); font-weight: 600; }
.review .a s { color: var(--red); }
.breakdown { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 20px; }
.breakdown div { display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.breakdown .lbl { display: flex; justify-content: space-between; gap: 8px; }
.breakdown .lbl span { font-family: var(--mono); color: var(--muted); }
.confirm { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: 10px; padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; }

/* ---------- paywall ---------- */
.lock { text-align: center; align-items: center; padding-block: 36px; }
.lock .price { font-family: var(--display); font-size: 44px; font-weight: 650; }
.lock ul { text-align: left; margin: 0; padding-left: 20px; color: var(--muted); }

/* ---------- flashcards ---------- */
.fc-bar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.fc-count { font-family: var(--mono); font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.toggles { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.toggles label { font-size: 14px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.toggles input { accent-color: var(--key); width: 16px; height: 16px; }
.stage { perspective: 1400px; }
.card { position: relative; width: 100%; min-height: 340px; cursor: pointer; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.2,.7,.2,1); border: 0; padding: 0; background: none; color: inherit; text-align: left; display: block; }
.card.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); padding: 22px clamp(18px, 4vw, 34px); display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); overflow-y: auto; }
.face.lined { background-image: repeating-linear-gradient(to bottom, transparent 0, transparent 33px, var(--rule) 33px, var(--rule) 34px); background-position: 0 70px; }
.face.lined::before { content: ""; position: absolute; top: 58px; left: 0; right: 0; height: 2px; background: var(--red); opacity: .55; }
.face.turned { transform: rotateY(180deg); border-color: var(--key); }
.face .tag { display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); min-height: 30px; }
.face .tag b { color: var(--red); font-weight: 500; }
.prompt { font-family: var(--display); font-size: clamp(22px, 3.4vw, 30px); line-height: 1.25; font-weight: 500; margin: auto 0; text-wrap: pretty; }
.prompt small { display: block; font-family: var(--body); font-size: 13px; font-weight: 600; color: var(--key); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.answer { font-family: var(--display); font-size: clamp(24px, 3.8vw, 32px); line-height: 1.2; font-weight: 650; color: var(--key); margin-top: auto; text-wrap: balance; }
.ex { color: var(--ink); margin: 0; max-width: 60ch; }
.qsmall { color: var(--muted); font-size: 14px; margin: 0 0 auto; }
.flip-hint { font-size: 13px; color: var(--muted); }
.fc-controls { display: grid; grid-template-columns: auto 1fr 1fr auto; gap: 10px; }
.fc-controls .again { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.fc-controls .got { border-color: var(--good); color: var(--good); background: var(--good-soft); }
.empty { text-align: center; padding: 40px 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty strong { font-family: var(--display); font-size: 24px; color: var(--ink); }
@media (max-width: 520px) {
  .fc-controls { grid-template-columns: 1fr 1fr; }
  .fc-controls .nav { order: 2; }
  .card { min-height: 380px; }
  .score .big { font-size: 46px; }
}

/* ---------- print (notes) ---------- */
@media print {
  .topbar, .mainnav, nav.toc, .search, .foot, .ch-actions, .to-top, .skip, .no-print { display: none !important; }
  body { background: #fff; color: #000; padding: 0; }
  .notes-grid { display: block; }
  section.ch { border: 0; padding: 0; break-inside: auto; }
  section.ch + section.ch { break-before: page; }
  .notes b, .d { color: #000; }
}

/* ---------- account (sign-in) ---------- */
.account { position: relative; flex: none; }
@media (min-width: 761px) { .account { margin-left: 4px; } }
@media (max-width: 760px) { .account { margin-left: auto; } .account + .theme-btn { margin-left: 0; } }
.acct-btn { height: 38px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; padding: 0 14px; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; }
.acct-btn:hover { border-color: var(--key); }
.acct-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--key); color: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.acct-btn.me { padding: 0 6px; }
.acct-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: min(320px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(10,20,40,.18); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.acct-pop p { margin: 0; font-size: 14px; color: var(--muted); }
.acct-pop .who { font-weight: 600; color: var(--ink); word-break: break-all; }
/* Google's button iframe is light-scheme; inside a color-scheme:dark page the browser paints an opaque white box
   behind it. Matching the slot to the iframe's scheme keeps the iframe transparent (theme is chosen via renderButton). */
.gsi-slot { min-height: 44px; display: flex; justify-content: center; color-scheme: light; }
.banner { position: sticky; top: calc(var(--bar-h) + env(safe-area-inset-top, 0px)); z-index: 15; }
.banner .callout { margin: 0; }

/* ---------- mastery bar: green mastered, light green learning, red to review, grey not answered ---------- */
.pbar { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pbar-track { display: flex; height: 10px; background: var(--unseen); border-radius: 999px; overflow: hidden; }
.pbar.big .pbar-track { height: 22px; box-shadow: inset 0 1px 3px rgba(0,0,0,.12); }
.pbar.thin .pbar-track { height: 8px; }
.pbar-track i { display: block; height: 100%; min-width: 3px; transition: width .5s ease; background-image: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0) 60%); }
.pbar-track i + i { box-shadow: -2px 0 0 var(--surface); }
.s-mastered { background-color: var(--good); }
.s-learning { background-color: var(--learn); }
.s-missed { background-color: var(--red); }
.s-new { background-color: var(--unseen); }
.pbar-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--muted); align-items: center; }
.pbar-legend strong { color: var(--ink); font-family: var(--mono); font-weight: 500; }
.pbar-of { margin-left: auto; }
.pdot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; flex: none; }
.qnum { font-family: var(--mono); font-size: 12px; color: var(--muted); background: var(--note); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
#pbar { margin: 4px 0 2px; }

/* ---------- test-date countdown ---------- */
.countdown:empty { display: none; }
.countdown .cd { display: flex; flex-wrap: wrap; gap: 2px 12px; justify-content: space-between; align-items: baseline; background: var(--key-soft); border-radius: 10px; padding: 10px 14px; }
.countdown .cd strong { font-family: var(--display); font-size: 20px; }
.countdown .cd span { color: var(--muted); font-size: 14px; }
.countdown input[type="date"] { font: inherit; font-size: 15px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }

/* ---------- mock mix slider: one bar, two handles ---------- */
.mixer { position: relative; height: 40px; }
.mixer-track { position: absolute; left: 15px; right: 15px; top: 12px; height: 16px; border-radius: 8px;
  background: linear-gradient(to right, var(--red) 0 var(--a), var(--unseen) var(--a) var(--b), var(--good) var(--b) 100%); box-shadow: inset 0 1px 3px rgba(0,0,0,.15); }
.mixer input[type="range"] { position: absolute; inset: 0; width: 100%; height: 40px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.mixer input[type="range"]::-webkit-slider-runnable-track { background: transparent; height: 40px; }
.mixer input[type="range"]::-moz-range-track { background: transparent; }
.mixer input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 30px; height: 30px; margin-top: 5px; border-radius: 50%; background: var(--surface); border: 3px solid var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: grab; }
.mixer input[type="range"]::-moz-range-thumb { pointer-events: auto; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 3px solid var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.3); cursor: grab; }
.mixer input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 3px solid var(--key); outline-offset: 2px; }
.mixer input[type="range"]:focus-visible::-moz-range-thumb { outline: 3px solid var(--key); outline-offset: 2px; }
.mixer-legend { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mixer-item { display: flex; gap: 8px; align-items: flex-start; background: var(--bg); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.mixer-item .pdot { margin-top: 6px; }
.mixer-item strong { display: block; font-size: 15px; }
.mixer-item small { display: block; color: var(--muted); font-size: 12px; }
.mixer-item.short small { color: var(--warn); }
@media (max-width: 520px) { .mixer-legend { grid-template-columns: minmax(0, 1fr); } }

/* ---------- celebrations ---------- */
.cele { position: fixed; left: 50%; top: calc(var(--bar-h) + 20px); transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 18px; box-shadow: 0 18px 50px rgba(0,0,0,.28);
  width: max-content; max-width: min(540px, calc(100vw - 32px)); animation: cele-in .5s cubic-bezier(.2, 1.4, .4, 1); transition: opacity .4s, transform .4s; }
.cele strong { display: block; font-family: var(--display); font-size: 22px; line-height: 1.2; }
.cele span { color: var(--muted); font-size: 14px; }
.cele .btn { flex: none; }
.cele-badge { width: 72px; height: 72px; flex: none; animation: cele-pop .9s cubic-bezier(.2, 1.4, .4, 1); }
.cele-all { border: 2px solid #f2c35b; }
.cele.out { opacity: 0; transform: translate(-50%, -12px); }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 59; }
@keyframes cele-in { from { opacity: 0; transform: translate(-50%, -24px) scale(.92); } }
@keyframes cele-pop { from { transform: rotate(-35deg) scale(.3); } }
@media (max-width: 520px) { .cele { flex-wrap: wrap; } .cele-badge { width: 56px; height: 56px; } }
@media print { .cele, .confetti { display: none !important; } }

/* ---------- mastered-chapter badge, shown wherever the chapter is named ---------- */
/* the same rosette as the celebration pop-up, sized so its ribbons and leaf still read */
.ch-badge { width: 32px; height: 32px; vertical-align: middle; margin: -6px 0 -6px 8px; flex: none; display: inline-block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); }
h2 .ch-badge { width: 48px; height: 48px; margin: -10px 0 -10px 12px; }
.chip .ch-badge { width: 24px; height: 24px; margin: -6px 0 -6px 2px; }
nav.toc .ch-badge { width: 24px; height: 24px; margin: -4px 0 -4px 6px; }
.topic .tname { font-weight: 600; display: inline-flex; align-items: center; min-width: 0; }
.all-badge { width: 40px; height: 40px; margin-left: auto; margin-right: 8px; }
.lock .price small { font-family: var(--body); font-size: 16px; font-weight: 500; color: var(--muted); }
.unlock-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 14px; background: var(--warn-soft); border-radius: 10px; padding: 10px 14px; font-size: 15px; }
.fc-controls + .unlock-row, .stage ~ .unlock-row { margin-top: 14px; }

.legend-explain { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.legend-explain dt { font-weight: 600; color: var(--ink); }
.legend-explain dd { margin: 0; }
#ready-bar .legend-explain, #pbar .legend-explain { margin-top: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--key); flex: none; margin: 0; }

/* ---------- legal pages (terms.html, privacy.html, fr/) ---------- */
.legal h2 { margin: 34px 0 8px; }
.legal h3 { margin: 20px 0 6px; }
.legal p, .legal ul { margin: 0 0 12px; max-width: 72ch; }
.legal ul { padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal .meta { color: var(--muted); font-size: 13px; }

/* the refund + terms line beside every Unlock button (DC.access.fineprint) */
.fine { margin: 0; }
.unlock-row .fine { flex-basis: 100%; }
.upsell .fine { margin-top: 6px; }

/* "Report a problem with this question" (DC.reportLink): quiet, so it never competes with the answer */
.report { font-size: 13px; color: var(--muted); }
.report:hover, .report:focus-visible { color: var(--key); }
.feedback .report { font-size: 13px; margin-top: 4px; }
.review .report { display: inline-block; margin-top: 2px; }
.report-row { margin: 10px 0 0; text-align: center; }
@media print { .report, .report-row { display: none; } }
