/* Layout: reference manual. A fixed left rail holds the three themes and their lessons;
   a single reading column (~68ch) carries lessons, with citation chips inline.
   Each exam theme takes an ancient Egyptian pigment: Egyptian blue (lapis), malachite, carnelian. */
:root {
  color-scheme: light;
  --ground: #e9ece8;        /* limestone */
  --surface: #f6f7f4;
  --raised: #ffffff;
  --ink: #18202c;
  --ink-2: #485263;
  --ink-3: #6e7787;
  --rule: #d2d7d1;
  --chip: #e1e5e0;
  --lapis: #1f4f9e;
  --malachite: #17765a;
  --carnelian: #b0432b;
  --ochre: #9a6b12;
  --ochre-wash: #f3e8cf;
  --good: #1c7a4c;
  --bad: #b23a2c;
  --focus: #1f4f9e;

  --font-display: "Spectral", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "IBM Plex Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-arabic: "IBM Plex Sans Arabic", "Geeza Pro", "Noto Sans Arabic", Tahoma, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.1875rem;
  --step-2: 1.5rem;
  --step-3: 2rem;
  --step-4: 2.75rem;

  --radius: 6px;
  --rail: 17.5rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ground: #0e131b;
    --surface: #141b26;
    --raised: #1a2330;
    --ink: #e6e9ee;
    --ink-2: #b3bbc8;
    --ink-3: #8790a0;
    --rule: #2a3443;
    --chip: #222d3c;
    --lapis: #86aaf0;
    --malachite: #5fc79f;
    --carnelian: #ec8b70;
    --ochre: #e2b558;
    --ochre-wash: #2b2415;
    --good: #61cf93;
    --bad: #f08a7a;
    --focus: #86aaf0;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ground: #0e131b;
  --surface: #141b26;
  --raised: #1a2330;
  --ink: #e6e9ee;
  --ink-2: #b3bbc8;
  --ink-3: #8790a0;
  --rule: #2a3443;
  --chip: #222d3c;
  --lapis: #86aaf0;
  --malachite: #5fc79f;
  --carnelian: #ec8b70;
  --ochre: #e2b558;
  --ochre-wash: #2b2415;
  --good: #61cf93;
  --bad: #f08a7a;
  --focus: #86aaf0;
}

/* Theme pigment, set per element with data-pigment */
[data-pigment="lapis"] { --pig: var(--lapis); }
[data-pigment="malachite"] { --pig: var(--malachite); }
[data-pigment="carnelian"] { --pig: var(--carnelian); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; text-wrap: balance; margin: 0; }
p { margin: 0; }
[lang="ar"] { font-family: var(--font-arabic); }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 50; background: var(--raised); padding: .5rem 1rem; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--rule);
  background: var(--surface);
  padding: 1.5rem 1.25rem 2rem;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.brand { display: grid; gap: .15rem; text-decoration: none; }
.brand-eyebrow { font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.brand-name { font-family: var(--font-display); font-size: 1.375rem; font-weight: 600; }
.brand-ar { font-family: var(--font-arabic); font-size: .8125rem; color: var(--ink-2); }

.nav-main { display: grid; gap: .125rem; }
.nav-link {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .4rem .6rem; border-radius: var(--radius); text-decoration: none; color: var(--ink-2);
  font-size: .9375rem;
}
.nav-link:hover { background: var(--chip); color: var(--ink); }
.nav-link[aria-current="page"] { background: var(--chip); color: var(--ink); font-weight: 600; }

.nav-theme { display: grid; gap: .25rem; }
.nav-theme-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 .6rem; text-decoration: none;
  font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--pig);
}
.nav-theme-head span[lang="ar"] { font-size: .8125rem; letter-spacing: 0; text-transform: none; color: var(--ink-3); }
.nav-lessons { list-style: none; margin: 0; padding: 0; display: grid; }
.nav-lesson {
  display: grid; grid-template-columns: .75rem 1fr; gap: .5rem; align-items: baseline;
  padding: .25rem .6rem; border-radius: var(--radius); text-decoration: none;
  font-size: .875rem; color: var(--ink-2); line-height: 1.35;
}
.nav-lesson:hover { background: var(--chip); color: var(--ink); }
.nav-lesson[aria-current="page"] { color: var(--ink); background: var(--chip); }
.nav-lesson.is-coming { color: var(--ink-3); }
.dot { width: .5rem; height: .5rem; border-radius: 50%; border: 1.5px solid var(--pig); display: inline-block; transform: translateY(-1px); }
.dot.is-started { background: linear-gradient(90deg, var(--pig) 50%, transparent 50%); }
.dot.is-done { background: var(--pig); }
.dot.is-coming { border-style: dotted; border-color: var(--ink-3); }

.rail-foot { margin-top: auto; display: flex; gap: .5rem; align-items: center; color: var(--ink-3); font-size: .8125rem; }
.theme-toggle { background: none; border: 1px solid var(--rule); border-radius: var(--radius); padding: .25rem .6rem; cursor: pointer; color: var(--ink-2); font-size: .8125rem; }
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }

.menu-btn { display: none; }

main {
  min-width: 0;
  padding-block: 2.5rem 5rem;
  padding-left: max(16px, env(safe-area-inset-left, 0px), 3vw);
  padding-right: max(16px, env(safe-area-inset-right, 0px), 3vw);
}
.page { max-width: 68rem; margin: 0 auto; display: grid; gap: 2.5rem; }
.read { max-width: 44rem; }

/* ---------- Shared pieces ---------- */
.eyebrow { font-family: var(--font-mono); font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--pig, var(--ink-3)); }
.lede { font-size: var(--step-1); color: var(--ink-2); max-width: 40rem; line-height: 1.5; }
.muted { color: var(--ink-3); }
.small { font-size: var(--step--1); }

.btn {
  display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; text-decoration: none;
  border-radius: var(--radius); padding: .6rem 1.1rem; font-weight: 600; font-size: .9375rem;
  border: 1px solid var(--ink); background: var(--ink); color: var(--ground);
}
.btn:hover { filter: brightness(1.15); }
.btn-quiet { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-quiet:hover { border-color: var(--ink-3); filter: none; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }

.cite {
  display: inline-block; white-space: nowrap; text-decoration: none;
  font-family: var(--font-mono); font-size: .6875rem; line-height: 1; letter-spacing: .01em;
  padding: .28em .45em; margin: 0 .1em; border-radius: 3px; vertical-align: .15em;
  background: var(--chip); color: var(--ink-2);
}
.cite:hover { color: var(--ink); background: var(--rule); }
.cite.is-gdpr { background: transparent; border: 1px dashed var(--rule); }
.unverified {
  font-family: var(--font-mono); font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em;
  padding: .2em .45em; border-radius: 3px; vertical-align: .15em;
  color: var(--ochre); border: 1px dashed var(--ochre);
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--rule); padding-bottom: .6rem; }
.section-head h2 { font-size: var(--step-2); }

/* ---------- Home ---------- */
.hero { display: grid; gap: 1.5rem; }
.hero h1 { font-size: clamp(2rem, 4.5vw, var(--step-4)); max-width: 20ch; }
.readiness { display: grid; gap: 1.1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 1.5rem; }
.ready-row { display: grid; grid-template-columns: 8.5rem 1fr 4.5rem; gap: 1rem; align-items: center; }
.ready-name { display: grid; line-height: 1.2; }
.ready-name strong { color: var(--pig); font-weight: 600; }
.ready-track { position: relative; height: .875rem; background: var(--chip); border-radius: 2px; }
.ready-fill { position: absolute; inset: 0 auto 0 0; background: var(--pig); border-radius: 2px; transition: width .6s ease; }
.ready-mark { position: absolute; top: -.4rem; bottom: -.4rem; left: 80%; border-left: 2px solid var(--ink); }
.ready-pct { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.125rem; }
.ready-legend { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: var(--step--1); color: var(--ink-3); padding-left: 9.5rem; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.tile {
  display: grid; gap: .5rem; align-content: start; text-decoration: none;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 1.25rem;
}
a.tile:hover { border-color: var(--ink-3); }
.tile h3 { font-size: var(--step-1); }
.tile .theme-ar { font-family: var(--font-arabic); color: var(--ink-3); font-size: .9375rem; }
.tile-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.tile-meta { display: flex; gap: 1rem; flex-wrap: wrap; font-size: var(--step--1); color: var(--ink-3); margin-top: .25rem; }
.tile-meta .num { color: var(--ink); }
.pig-rule { height: 3px; width: 2.5rem; background: var(--pig); border-radius: 2px; }

.continue { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--raised); }
.continue h3 { font-size: var(--step-1); }

/* ---------- Theme page ---------- */
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--rule); }
.lesson-row {
  display: grid; grid-template-columns: 1.25rem minmax(0, 1fr) auto; gap: 1rem; align-items: center;
  padding: .9rem .25rem; border-bottom: 1px solid var(--rule); text-decoration: none;
}
a.lesson-row:hover { background: var(--surface); }
.lesson-row h3 { font-family: var(--font-body); font-size: 1rem; font-weight: 600; }
.lesson-row .muted { font-size: var(--step--1); }
.badge { font-family: var(--font-mono); font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em; padding: .25em .55em; border-radius: 3px; background: var(--chip); color: var(--ink-2); white-space: nowrap; }
.badge.is-pass { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.badge.is-below { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }

/* ---------- Lesson ---------- */
.lesson-head { display: grid; gap: .75rem; }
.lesson-head h1 { font-size: clamp(2rem, 4vw, var(--step-4)); }
.lesson-ar { font-family: var(--font-arabic); font-size: var(--step-1); color: var(--ink-2); }
.lesson-tabs {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; gap: .25rem; overflow-x: auto; padding: .5rem 0;
  background: var(--ground); border-bottom: 1px solid var(--rule);
}
.lesson-tabs a { text-decoration: none; padding: .35rem .75rem; border-radius: var(--radius); font-size: .875rem; color: var(--ink-2); white-space: nowrap; }
.lesson-tabs a:hover { background: var(--chip); color: var(--ink); }

.clocks { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; }
.clock {
  display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; align-items: center;
  padding: 1rem 1.1rem; border-radius: 10px; background: var(--surface); border: 1px solid var(--rule);
}
.clock-face {
  grid-row: span 3; width: 4.25rem; height: 4.25rem; border-radius: 50%;
  display: grid; place-content: center; text-align: center;
  border: 3px solid var(--pig);
  background: conic-gradient(from 0deg, color-mix(in srgb, var(--pig) 16%, transparent) 0 75%, transparent 75% 100%);
}
.clock-value { font-family: var(--font-mono); font-weight: 600; font-size: 1.375rem; line-height: 1; }
.clock-unit { font-family: var(--font-mono); font-size: .5625rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); line-height: 1.2; max-width: 3.5rem; }
.clock-label { font-weight: 600; line-height: 1.25; }
.clock-from { font-size: var(--step--1); color: var(--ink-2); line-height: 1.35; }

.rule-block { display: grid; gap: .75rem; padding-block: 1.25rem; border-top: 1px solid var(--rule); }
.rule-block:first-of-type { border-top: 0; }
.rule-block h3 { font-size: var(--step-2); }
.prose { display: grid; gap: .85rem; }
.prose ul { margin: 0; padding-left: 1.2rem; display: grid; gap: .3rem; }
.prose strong { font-weight: 600; }

.delta-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); }
.delta { width: 100%; border-collapse: collapse; min-width: 40rem; font-size: .9375rem; }
.delta th, .delta td { text-align: left; vertical-align: top; padding: .85rem 1rem; border-bottom: 1px solid var(--rule); line-height: 1.5; }
.delta tr:last-child td { border-bottom: 0; }
.delta thead th { font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.delta td:first-child { font-weight: 600; width: 22%; }
.delta td.eg { width: 42%; background: color-mix(in srgb, var(--pig) 7%, transparent); }
.delta thead th.eg { color: var(--pig); }

.scenarios { display: grid; gap: 1rem; }
.scenario { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 1.25rem 1.35rem; display: grid; gap: .75rem; }
.scenario h3 { font-size: var(--step-1); }
.scenario .facts { color: var(--ink-2); }
.scenario .ask { font-weight: 600; }
.scenario details { border-top: 1px dashed var(--rule); padding-top: .75rem; }
.scenario summary { cursor: pointer; font-weight: 600; color: var(--pig); list-style: none; display: inline-flex; gap: .4rem; align-items: center; }
.scenario summary::-webkit-details-marker { display: none; }
.scenario summary::before { content: "+"; font-family: var(--font-mono); }
.scenario details[open] summary::before { content: "−"; }
.scenario details .prose { margin-top: .75rem; }

.flags { display: grid; gap: .75rem; }
.flag { border-radius: 8px; padding: 1rem 1.15rem; display: grid; gap: .35rem; border: 1px solid var(--rule); background: var(--surface); }
.flag-kind { font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.flag.is-conflict, .flag.is-unverified { border-color: color-mix(in srgb, var(--ochre) 55%, var(--rule)); background: var(--ochre-wash); }
.flag.is-conflict .flag-kind, .flag.is-unverified .flag-kind { color: var(--ochre); }
.flag.is-unverified { border-style: dashed; }
.flag h3 { font-family: var(--font-body); font-size: 1rem; font-weight: 600; }

/* ---------- Quiz / exam question ---------- */
.quiz { display: grid; gap: 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 1.5rem; }
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.progress-pips { display: flex; gap: .3rem; flex-wrap: wrap; }
.pip { width: .9rem; height: .3rem; border-radius: 2px; background: var(--chip); }
.pip.is-now { background: var(--ink-3); }
.pip.is-right { background: var(--good); }
.pip.is-wrong { background: var(--bad); }
.stem { font-size: var(--step-1); font-weight: 600; line-height: 1.45; max-width: 46rem; }
.options { display: grid; gap: .6rem; }
.option {
  display: grid; grid-template-columns: 1.75rem 1fr; gap: .75rem; align-items: start; text-align: left;
  padding: .8rem 1rem; border-radius: 8px; border: 1px solid var(--rule); background: var(--raised);
  cursor: pointer; line-height: 1.45; width: 100%;
}
.option:hover:not([disabled]) { border-color: var(--ink-3); }
.option .key { font-family: var(--font-mono); font-size: .8125rem; color: var(--ink-3); border: 1px solid var(--rule); border-radius: 4px; text-align: center; line-height: 1.5rem; }
.option.is-picked { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.option.is-right { border-color: var(--good); box-shadow: inset 0 0 0 1px var(--good); background: color-mix(in srgb, var(--good) 9%, var(--raised)); }
.option.is-wrong { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--raised)); }
.option[disabled] { cursor: default; }
.feedback { display: grid; gap: .5rem; padding: 1rem 1.15rem; border-radius: 8px; background: var(--raised); border-left: 3px solid var(--good); }
.feedback.is-wrong { border-left-color: var(--bad); }
.feedback strong { font-weight: 600; }
.result { display: grid; gap: 1rem; justify-items: start; }
.big-score { font-family: var(--font-mono); font-size: clamp(2.5rem, 7vw, 4rem); line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- Flashcards ---------- */
.pick-themes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.pick { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 1rem 1.15rem; display: grid; gap: .5rem; align-content: start; }
.check { display: grid; grid-template-columns: 1.1rem 1fr auto; gap: .6rem; align-items: center; font-size: .9375rem; cursor: pointer; }
.check input { accent-color: var(--pig); width: 1rem; height: 1rem; margin: 0; }
.check.is-head { font-weight: 600; color: var(--pig); border-bottom: 1px solid var(--rule); padding-bottom: .5rem; }
.check.is-off { color: var(--ink-3); cursor: not-allowed; }

.deck { display: grid; gap: 1.25rem; justify-items: center; }
.card {
  width: min(100%, 38rem); min-height: 17rem; perspective: 1400px; cursor: pointer; background: none; border: 0; padding: 0;
}
.card-inner { position: relative; width: 100%; min-height: 17rem; transform-style: preserve-3d; transition: transform .45s ease; }
.card.is-flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 14px; padding: 1.75rem; display: grid; align-content: space-between; gap: 1rem; text-align: left;
  background: var(--raised); border: 1px solid var(--rule);
  box-shadow: 0 1px 0 var(--rule), 0 14px 30px -18px rgba(10, 20, 40, .35);
}
.card-face::before { content: ""; position: absolute; left: 0; top: 1.5rem; bottom: 1.5rem; width: 3px; background: var(--pig); border-radius: 0 2px 2px 0; }
.card-back { transform: rotateY(180deg); }
.card-text { font-family: var(--font-display); font-size: var(--step-2); line-height: 1.3; }
.card-back .card-text { font-family: var(--font-body); font-size: var(--step-1); font-weight: 500; line-height: 1.5; }
.card-foot { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; color: var(--ink-3); font-size: var(--step--1); }
.grade { display: flex; gap: .6rem; flex-wrap: wrap; justify-content: center; }
.boxes { display: flex; gap: .25rem; align-items: end; }
.boxes span { width: .45rem; background: var(--chip); border-radius: 1px; }
.boxes span.is-on { background: var(--pig); }

/* ---------- Exam ---------- */
.exam-bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 6;
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: var(--raised); border: 1px solid var(--rule); border-radius: 10px;
}
.timer { font-family: var(--font-mono); font-size: 1.375rem; font-variant-numeric: tabular-nums; }
.timer.is-low { color: var(--bad); }
.navgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.25rem, 1fr)); gap: .35rem; }
.navgrid button {
  font-family: var(--font-mono); font-size: .8125rem; padding: .35rem 0; border-radius: 4px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--raised); color: var(--ink-2); position: relative;
}
.navgrid button.is-answered { background: var(--chip); color: var(--ink); }
.navgrid button.is-current { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.navgrid button.is-flagged::after { content: ""; position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--ochre); }
.navgrid button.is-right { background: color-mix(in srgb, var(--good) 22%, var(--raised)); }
.navgrid button.is-wrong { background: color-mix(in srgb, var(--bad) 20%, var(--raised)); }
.exam-layout { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; gap: 1.5rem; align-items: start; }
.exam-side { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 5rem); display: grid; gap: 1rem; }
.theme-chip { display: inline-flex; gap: .4rem; align-items: center; font-family: var(--font-mono); font-size: .6875rem; text-transform: uppercase; letter-spacing: .1em; color: var(--pig); }
.theme-chip::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--pig); }

.notice { padding: .9rem 1.1rem; border-radius: 8px; border: 1px dashed color-mix(in srgb, var(--ochre) 60%, var(--rule)); background: var(--ochre-wash); color: var(--ink); font-size: .9375rem; }

.facts-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 1rem; margin: 0; }
.facts-list div { border-top: 1px solid var(--rule); padding-top: .6rem; }
.facts-list dt { font-family: var(--font-mono); font-size: .6875rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); }
.facts-list dd { margin: .2rem 0 0; font-family: var(--font-mono); font-size: 1.375rem; font-variant-numeric: tabular-nums; }

/* ---------- Tables (progress, sources) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.table th, .table td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table th { font-family: var(--font-mono); font-size: .6875rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); font-weight: 500; }
.table td.num { text-align: right; }

.danger-zone { border: 1px solid color-mix(in srgb, var(--bad) 45%, var(--rule)); border-radius: 10px; padding: 1.25rem; display: grid; gap: .75rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--ground); padding: .6rem 1.1rem; border-radius: 8px; font-size: .9375rem; z-index: 60;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(86vw, 20rem);
    transform: translateX(-105%); transition: transform .25s ease;
    padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
    padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
    box-shadow: 0 0 40px rgba(0, 0, 0, .25);
  }
  .rail.is-open { transform: none; }
  .menu-btn {
    display: inline-flex; position: fixed; z-index: 30;
    top: calc(.75rem + env(safe-area-inset-top, 0px)); left: max(.75rem, env(safe-area-inset-left, 0px));
    background: var(--raised); border: 1px solid var(--rule); border-radius: var(--radius); padding: .4rem .7rem; cursor: pointer; font-size: .875rem;
  }
  main { padding-top: 4rem; }
  .grid-3, .pick-themes { grid-template-columns: 1fr; }
  .exam-layout { grid-template-columns: 1fr; }
  .exam-side { position: static; }
}
@media (max-width: 560px) {
  .ready-row { grid-template-columns: 6rem 1fr 3.5rem; gap: .6rem; }
  .ready-legend { padding-left: 0; }
  .lesson-row { grid-template-columns: 1rem minmax(0, 1fr); }
  .lesson-row .badge { grid-column: 2; justify-self: start; }
  .quiz { padding: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Added with the app scripts ---------- */
.stack { display: grid; gap: 1.25rem; align-content: start; }
.stack-tight { display: grid; gap: .4rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.file-input { max-width: 100%; font-size: 1rem; }
.deck-after { display: grid; gap: 1rem; justify-items: center; width: min(100%, 38rem); }
.narrow-only { display: none; }
.exam-nav-toggle { display: none; }
.scrim { display: none; }
@media (hover: none) { .kbd-hint { display: none; } }
@media (max-width: 960px) {
  .scrim:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .35); }
  /* Keep sticky bars clear of the fixed Menu button. */
  .exam-bar, .lesson-tabs { padding-left: 4.75rem; }
  .exam-nav-toggle { display: inline-flex; justify-self: start; }
  .exam-side:not(.is-open) .navgrid, .exam-side:not(.is-open) .exam-legend { display: none; }
}
@media (max-width: 560px) {
  .wide-only { display: none; }
  .narrow-only { display: inline; }
  .exam-bar { gap: .5rem; padding-block: .5rem; }
  .exam-bar .btn-row { gap: .5rem; }
  .btn, .theme-toggle, .menu-btn, .nav-link, .nav-lesson, .lesson-tabs a { min-height: 44px; }
  .lesson-tabs a { display: inline-flex; align-items: center; }
  .nav-lesson { align-items: center; }
  .navgrid { grid-template-columns: repeat(auto-fill, minmax(2.75rem, 1fr)); }
  .navgrid button { min-height: 44px; }
  .check { min-height: 44px; }
  .option { min-height: 44px; }
  .grade { width: 100%; }
  .grade .btn { flex: 1 1 0; justify-content: center; }
}
.page section[id], .scenario[id] { scroll-margin-top: 4.5rem; }

/* ---------- Saving consent prompt ---------- */
.consent {
  position: fixed; z-index: 55;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  width: min(26rem, calc(100vw - 2rem));
  display: grid; gap: .75rem;
  padding: 1.25rem 1.35rem; border-radius: 12px;
  background: var(--raised); border: 1px solid var(--rule);
  box-shadow: 0 18px 40px -16px rgba(10, 20, 40, .45);
}
.consent h2 { font-size: var(--step-1); }
.consent p { font-size: .9375rem; color: var(--ink-2); }
@media (max-width: 560px) {
  .consent { left: max(.75rem, env(safe-area-inset-left, 0px)); right: max(.75rem, env(safe-area-inset-right, 0px)); width: auto; bottom: calc(.75rem + env(safe-area-inset-bottom, 0px)); }
  .consent .btn { flex: 1 1 auto; justify-content: center; }
}

/* Empty placeholder slots (e.g. a notice with nothing to say) must not take a grid gap. */
.page > :empty:not([aria-live]):not([role]), .stack > :empty:not([aria-live]):not([role]) { display: none; }

/* ---------- Home intro and About ---------- */
.intro { padding-bottom: .5rem; }
.intro-points { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; margin: .25rem 0 0; }
.intro-points div { border-top: 2px solid var(--ink); padding-top: .75rem; display: grid; gap: .35rem; align-content: start; }
.intro-points dt { font-family: var(--font-mono); font-size: .6875rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.intro-points dd { margin: 0; font-size: .9375rem; color: var(--ink-2); line-height: 1.55; }
.prose h2 { font-size: var(--step-2); margin-top: .5rem; }
.link-list { list-style: none; padding-left: 0 !important; gap: .9rem !important; }
.link-list a { font-weight: 600; }
@media (max-width: 960px) { .intro-points { grid-template-columns: 1fr; } }

/* ---------- Analytics ---------- */
.ready-row[data-pigment=""] { --pig: var(--ink-2); } /* skill rows have no theme colour */
.readiness.is-wide .ready-row { grid-template-columns: minmax(8.5rem, 16rem) 1fr 4.5rem; }
.weak-item { display: grid; gap: .4rem; }
.weak-actions { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.weak-line { font-size: .9375rem; color: var(--ink-2); }
.weak-line strong { color: var(--ink); }
.trend-wrap { background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 1rem; display: grid; gap: .5rem; }
.trend { width: 100%; height: auto; display: block; overflow: visible; }
.trend-grid { stroke: var(--rule); stroke-width: 1; }
.trend-text { fill: var(--ink-3); font-family: var(--font-mono); font-size: 12px; }
.trend-pass { stroke: var(--bad); stroke-width: 1.5; stroke-dasharray: 6 4; }
.trend-pass-label { fill: var(--bad); }
.trend-line { fill: none; stroke: var(--lapis); stroke-width: 2.5; stroke-linejoin: round; }
.trend-dot { fill: var(--lapis); stroke: var(--surface); stroke-width: 2; }
.trend-dot.is-preview { fill: var(--surface); stroke: var(--lapis); stroke-width: 2; }
.trend-key { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--lapis); border: 2px solid var(--lapis); vertical-align: -1px; }
.trend-key.is-preview { background: transparent; margin-left: .75rem; }
@media (max-width: 560px) {
  .readiness.is-wide .ready-row { grid-template-columns: minmax(0, 1fr) 3.5rem; }
  .readiness.is-wide .ready-name { grid-column: 1 / -1; }
  .trend-text { font-size: 16px; }
  .weak-actions a { min-height: 44px; display: inline-flex; align-items: center; }
}

/* Guideline citations are not links (the PDFs are not shipped): no click affordance. */
span.cite { cursor: help; text-decoration: underline dotted; text-underline-offset: 2px; }
span.cite:hover { color: var(--ink-2); background: var(--chip); }

/* Citation tooltip (positioned by initTooltips in app.js) */
.tooltip {
  position: fixed; z-index: 70; max-width: min(20rem, calc(100vw - 16px));
  padding: .5rem .7rem; border-radius: 6px;
  background: var(--ink); color: var(--ground);
  font-family: var(--font-body); font-size: .8125rem; line-height: 1.45;
  box-shadow: 0 8px 24px -10px rgba(10, 20, 40, .5);
  pointer-events: none;
}

/* ---------- Privacy People (film) promotion ---------- */
.film-card {
  display: grid; grid-template-columns: auto 1fr; gap: .7rem; align-items: start;
  padding: .9rem 1rem; border-radius: 8px;
  border: 1px solid var(--rule); background: var(--raised);
}
.film-card .film-icon { color: var(--carnelian); margin-top: .15rem; }
.film-card p { margin: 0; }
.film-eyebrow { font-family: var(--font-mono); font-size: .625rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.film-title { font-family: var(--font-display); font-size: 1.125rem; font-weight: 600; line-height: 1.2; margin-top: .1rem !important; }
.film-text { font-size: .8125rem; color: var(--ink-2); line-height: 1.45; margin-top: .25rem !important; }
.film-link { display: inline-block; margin-top: .45rem; font-size: .8125rem; font-weight: 600; color: var(--ink); text-underline-offset: 3px; }
.film-link::after { content: " ↗"; }
.film-link:hover { color: var(--carnelian); }
.film-line {
  display: flex; gap: .6rem; align-items: flex-start;
  padding-top: .9rem; border-top: 1px solid var(--rule);
  font-size: .875rem; color: var(--ink-2);
}
.film-line .film-icon { flex: none; color: var(--carnelian); width: 18px; height: 18px; margin-top: .1rem; }
.film-line a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }
.film-line a:hover { color: var(--carnelian); }
