/* Layout: sticky utility bar, single reading column (max 1080px), card grids only where items are peers. */
:root {
  --bg: #f1f4f6;
  --surface: #ffffff;
  --surface-2: #e8eef2;
  --ink: #12202b;
  --muted: #4c5c68;
  --line: #d3dce2;
  --accent: #2a7a3b;
  --accent-ink: #ffffff;
  --accent-soft: #dbeedd;
  --demand: #1f5fb8;
  --supply: #b9500f;
  --good: #1c7547;
  --good-soft: #dcf0e4;
  --bad: #ad3328;
  --bad-soft: #f6dedb;
  --warn: #8a5a05;
  --warn-soft: #f6ead0;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1a22; --surface: #15252f; --surface-2: #1b303c; --ink: #e6edf1; --muted: #9db0bc;
    --line: #28404e; --accent: #86d37a; --accent-ink: #0a2210; --accent-soft: #1b3a22;
    --demand: #7bb0ff; --supply: #ff9d66; --good: #62d394; --good-soft: #15382a;
    --bad: #ff8a7d; --bad-soft: #4a2420; --warn: #f0be5a; --warn-soft: #3d3014; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1a22; --surface: #15252f; --surface-2: #1b303c; --ink: #e6edf1; --muted: #9db0bc;
  --line: #28404e; --accent: #86d37a; --accent-ink: #0a2210; --accent-soft: #1b3a22;
  --demand: #7bb0ff; --supply: #ff9d66; --good: #62d394; --good-soft: #15382a;
  --bad: #ff8a7d; --bad-soft: #4a2420; --warn: #f0be5a; --warn-soft: #3d3014; color-scheme: dark;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 17px; line-height: 1.55; padding-inline: 0; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--muted); }
.wrap { width: 100%; max-width: 1080px; margin-inline: auto; padding-inline: 16px; }

/* top bar */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar .wrap { display: flex; align-items: center; gap: 16px; padding-block: 10px; }
.brand { font-family: var(--f-display); font-weight: 700; font-size: 1.08rem; text-decoration: none; color: var(--ink); white-space: nowrap; display: flex; align-items: baseline; gap: 8px; }
.brand .code { font-family: var(--f-mono); font-size: .8rem; font-weight: 500; background: var(--accent); color: var(--accent-ink); padding: 2px 7px; border-radius: 4px; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 7px 11px; border-radius: 6px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .95rem; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.themebtn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.themebtn:hover { background: var(--surface-2); }

/* menu button, drawer sheet and mobile tab bar */
.menubtn { display: inline-flex; flex-direction: column; justify-content: center; gap: 4px; width: 38px; height: 36px; padding: 0 9px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; cursor: pointer; flex: none; }
.menubtn:hover { background: var(--surface-2); }
.menubtn span { display: block; height: 2px; background: var(--ink); border-radius: 1px; }
.sheet { position: sticky; top: calc(57px + env(safe-area-inset-top, 0px)); z-index: 19; background: var(--surface); border-bottom: 1px solid var(--line); max-height: calc(100vh - 120px); overflow-y: auto; box-shadow: 0 10px 24px rgba(0, 0, 0, .12); }
.sheet .wrap { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 20px; padding-block: 18px; }
.sheet h4 { font-family: var(--f-mono); font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.sheet a { display: block; padding: 7px 8px; border-radius: 6px; text-decoration: none; color: var(--ink); font-weight: 600; }
.sheet a:hover { background: var(--surface-2); }
.sheet a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.sheet a small { display: block; color: var(--muted); font-weight: 400; font-size: .85rem; }
.tabbar { display: none; }

main { padding-block: 28px 56px; display: block; }
.crumbs { font-size: .9rem; color: var(--muted); margin-bottom: 14px; }
.crumbs a { color: var(--muted); }

/* hero */
.hero { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; align-items: center; padding-block: 8px 28px; }
.hero h1 { font-size: clamp(2rem, 5.4vw, 3.4rem); font-weight: 800; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p.lead { font-size: 1.12rem; color: var(--muted); margin-top: 14px; max-width: 52ch; }
.hero .cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.hero svg { width: 100%; height: auto; display: block; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; cursor: pointer; font-size: 1rem; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--accent-soft); filter: none; }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.section-title { font-size: 1.35rem; margin-bottom: 14px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 32px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.tool { display: flex; flex-direction: column; gap: 6px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.tool:hover { border-color: var(--accent); }
.tool h3 { font-size: 1.05rem; }
.tool p { color: var(--muted); font-size: .93rem; }
.tool .meta { font-family: var(--f-mono); font-size: .78rem; color: var(--accent); margin-top: auto; padding-top: 6px; }

/* dashboard */
.dash { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 18px; align-items: end; }
.dash .k { font-family: var(--f-mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dash .v { font-family: var(--f-display); font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.meter > i { display: block; height: 100%; background: var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.input { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 8px 10px; min-width: 0; }

/* unit list */
.units { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.unit { display: flex; gap: 14px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.unit:hover { border-color: var(--accent); }
.unit .n { font-family: var(--f-display); font-weight: 800; font-size: 2rem; color: var(--accent); line-height: 1; }
.unit h3 { font-size: 1.05rem; }
.unit p { color: var(--muted); font-size: .92rem; margin-top: 4px; }

/* notes */
.notes-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; align-items: start; }
.toc { position: sticky; top: calc(64px + env(safe-area-inset-top, 0px)); max-height: calc(100vh - 90px); overflow-y: auto; font-size: .93rem; display: flex; flex-direction: column; gap: 14px; padding-right: 6px; }
.toc h4 { font-size: .98rem; margin-bottom: 4px; }
.toc a { display: block; padding: 4px 8px; border-radius: 5px; text-decoration: none; color: var(--muted); }
.toc a:hover { background: var(--surface-2); color: var(--ink); }
.toc a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.chapter h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.chapter .id { font-family: var(--f-mono); color: var(--accent); font-size: .9rem; }
.chapter ul.points { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 10px; max-width: 68ch; }
.formula { font-family: var(--f-mono); font-size: .98rem; background: var(--accent-soft); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.formula .lab { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.tip { background: var(--warn-soft); border-radius: 8px; padding: 12px 14px; max-width: 68ch; }
.tip b { font-family: var(--f-mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--warn); display: block; margin-bottom: 2px; }
.pager { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.figure { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.figure svg { width: 100%; max-width: 520px; height: auto; display: block; margin-inline: auto; }
.figure figcaption { font-size: .9rem; color: var(--muted); margin-top: 6px; max-width: 68ch; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 13px; font-size: .9rem; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
a.chip { text-decoration: none; color: inherit; display: inline-block; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* practice */
.q-card { max-width: 760px; }
.q-meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-family: var(--f-mono); font-size: .8rem; color: var(--muted); margin-bottom: 10px; }
.q-text { font-size: 1.15rem; font-weight: 600; margin-bottom: 14px; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.opt:hover:not([disabled]) { border-color: var(--accent); background: var(--accent-soft); }
.opt .l { font-family: var(--f-mono); font-weight: 600; color: var(--accent); min-width: 1.2em; }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt[disabled] { cursor: default; }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); }
.verdict { font-weight: 700; margin-bottom: 4px; }
.verdict.ok { color: var(--good); }
.verdict.no { color: var(--bad); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.score { font-family: var(--f-display); font-size: 3rem; font-weight: 800; color: var(--accent); }
.review li { margin-bottom: 8px; }

/* flashcards */
.card-wrap { max-width: 560px; }
.flash { min-height: 220px; width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; justify-content: center; text-align: left; cursor: pointer; gap: 10px; }
.flash:hover { border-color: var(--accent); }
.flash .side { font-family: var(--f-mono); font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.flash .term { font-family: var(--f-display); font-size: 1.7rem; font-weight: 700; }
.flash .def { font-size: 1.12rem; }
.flash textarea { width: 100%; }

/* structured + glossary */
.part { border-top: 1px solid var(--line); padding-top: 14px; }
.cmd { display: inline-block; font-family: var(--f-mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 4px; margin-right: 6px; }
.marks { font-family: var(--f-mono); font-size: .85rem; color: var(--muted); }
textarea.input { width: 100%; min-height: 96px; resize: vertical; margin-top: 8px; }
.markscheme { margin-top: 10px; padding: 12px 14px; background: var(--good-soft); border-radius: 8px; }
.markscheme ul { margin: 6px 0 0; padding-left: 1.1rem; }
.gl { display: grid; gap: 0; }
.gl dt { font-weight: 700; padding-top: 12px; border-top: 1px solid var(--line); }
.gl dd { margin: 2px 0 12px; color: var(--muted); max-width: 70ch; }
.searchbox { width: 100%; padding: 12px 14px; font-size: 1.05rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.hit { padding: 12px 0; border-top: 1px solid var(--line); }
.hit a { font-weight: 700; }
.hit mark { background: var(--warn-soft); color: inherit; border-radius: 2px; }
.tag { font-family: var(--f-mono); font-size: .72rem; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }

/* tables */
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 440px; font-size: .95rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--f-mono); font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
td.num, th.num { font-variant-numeric: tabular-nums; text-align: right; }

/* diagrams */
.diag-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.diag-grid .figure { display: flex; flex-direction: column; gap: 6px; }
.diag-grid h3 { font-size: 1.02rem; }
svg .ax { stroke: var(--ink); stroke-width: 1.6; fill: none; }
svg .gridl { stroke: var(--line); stroke-width: 1; stroke-dasharray: 4 4; fill: none; }
svg .dem { stroke: var(--demand); stroke-width: 3; fill: none; stroke-linecap: round; }
svg .sup { stroke: var(--supply); stroke-width: 3; fill: none; stroke-linecap: round; }
svg .oth { stroke: var(--ink); stroke-width: 2.4; fill: none; stroke-linecap: round; }
svg .ghost { stroke-dasharray: 6 5; opacity: .75; }
svg text { fill: var(--ink); font-family: var(--f-body); font-size: 13px; }
svg text.dm { fill: var(--demand); font-weight: 700; }
svg text.sp { fill: var(--supply); font-weight: 700; }
svg text.sm { font-size: 11.5px; fill: var(--muted); }
svg .dot { fill: var(--ink); }
svg .fillgood { fill: var(--good); opacity: .22; }
svg .fillbad { fill: var(--bad); opacity: .22; }

footer { border-top: 1px solid var(--line); padding-block: 24px 40px; color: var(--muted); font-size: .9rem; }
footer .wrap { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

@media (max-width: 820px) {
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 2px 9px; border: 0; background: transparent; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; cursor: pointer; border-top: 3px solid transparent; min-width: 0; }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }
  footer { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .nav { display: none; }
  .bar .wrap { justify-content: space-between; }
  .brand .name { display: inline; }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .notes-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; max-height: none; }
}
@media (min-width: 821px) {
  .menubtn { display: none; }
  .sheet { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .meter > i { transition: width .4s ease; }
}

/* learning objectives, success criteria, AO skills */
.objectives, .aoskills { display: flex; flex-direction: column; gap: 8px; }
.objectives h2, .aoskills h2 { font-family: var(--f-display); font-size: 1.05rem; margin: 0; display: flex; gap: 10px; align-items: baseline; }
.objectives ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 4px; }
.objectives ul.sc { list-style: none; padding-left: 0; }
.objectives .sc label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.objectives .sc input { margin-top: .3rem; width: 18px; height: 18px; flex: none; accent-color: var(--accent, currentColor); }
.sc-count { font-family: var(--f-mono); font-size: .78rem; font-weight: 400; }
.aogrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.aogrid > div { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }
.aogrid p { margin: 0; font-size: .95rem; }
.aoname { font-weight: 600; font-size: .9rem; }
.check { display: flex; flex-direction: column; gap: 12px; }
.check h2 { font-family: var(--f-display); font-size: 1.05rem; margin: 0; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.chk-q { max-width: 760px; }
.chk-q + .chk-q { border-top: 1px solid var(--line); padding-top: 16px; }

/* diagram lab */
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 820px) { .lab-grid { grid-template-columns: minmax(0, 1fr); } }
.lab-fig svg { width: 100%; height: auto; display: block; }
svg .handle { cursor: grab; stroke: var(--surface); stroke-width: 2.5; }
svg .handle:active { cursor: grabbing; }
svg .handle.dh { fill: var(--demand); }
svg .handle.sh { fill: var(--supply); }
svg .handle:focus { outline: none; stroke: var(--ink); stroke-width: 3; }
#readout { font-size: 1rem; line-height: 1.5; min-height: 5.5em; }
input[type="range"] { width: 100%; accent-color: var(--accent, currentColor); }

/* section sub-navigation, hub headings */
.subnav { position: sticky; top: calc(57px + env(safe-area-inset-top, 0px)); z-index: 18; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.subnav[hidden] { display: none; }
.subnav .wrap { display: flex; align-items: center; gap: 4px; padding-block: 6px; overflow-x: auto; scrollbar-width: none; }
.subnav .wrap::-webkit-scrollbar { display: none; }
.subnav-label { font-family: var(--f-mono); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-right: 8px; white-space: nowrap; }
.subnav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem; white-space: nowrap; }
.subnav a:hover { background: var(--surface); color: var(--ink); }
.subnav a[aria-current="page"] { background: var(--accent); color: #fff; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.sec-head .section-title { margin: 0; }
.labpanel { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; }

/* diagram flip cards */
.flip { perspective: 1200px; cursor: pointer; border-radius: 10px; outline-offset: 3px; }
.flip-inner { display: grid; position: relative; transform-style: preserve-3d; transition: transform .55s ease; }
.flip.is-flipped .flip-inner { transform: rotateY(180deg); }
.flip-face { grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.flip-face .figure { border: 0; padding: 0; background: none; }
.flip-back { transform: rotateY(180deg); font-size: .93rem; }
.flip-back h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 4px; }
.flip-title { font-size: 1.05rem; }
.flip-steps { padding-left: 1.2rem; display: grid; gap: 3px; }
.flip-tip { background: var(--panel, rgba(127,127,127,.1)); border-left: 3px solid var(--accent, currentColor); padding: 6px 10px; border-radius: 4px; }
.flip-hint { margin-top: auto; font-size: .8rem; color: var(--muted); }
.flip-back .btn { align-self: flex-start; }
.flip:hover .flip-face { border-color: var(--accent, var(--line)); }
@media (prefers-reduced-motion: reduce) { .flip-inner { transition: none; } }
.diag-pair { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); margin-block: 14px; }
.diag-pair .figure svg { max-width: 100%; }

/* structured question support levels */
.sq-modes { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 4px; }
.sq-box { margin-bottom: 6px; }
.guide { display: grid; gap: 4px; margin-top: 6px; }
.guide-tip { background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; font-size: .92rem; }
.hint { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 12px; margin-top: 8px; font-size: .92rem; }
.hintlist { display: grid; gap: 0; }
.exam-bar { position: sticky; top: 52px; z-index: 5; display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; margin-bottom: 14px; max-width: 760px; }
.exam-bar b { font-family: var(--f-mono); font-size: 1.15rem; }
.exam-bar.low b { color: var(--bad, #b3261e); }
.selfmark { gap: 10px; align-items: center; margin-top: 8px; }

/* in-depth notes */
.sub-h { font-size: 1.15rem; margin-top: 8px; padding-bottom: 4px; border-bottom: 2px solid var(--accent-soft); }
.explain { display: grid; gap: 14px; }
.ex-sec h3 { font-size: 1.02rem; margin-bottom: 4px; color: var(--accent); }
.ex-sec p { max-width: 68ch; margin: 0 0 8px; line-height: 1.65; }
.ex-example, .ex-mistakes { border-radius: 10px; padding: 12px 16px; max-width: 72ch; }
.ex-example { background: var(--accent-soft); }
.ex-mistakes { background: var(--surface); border: 1px solid var(--line); }
.ex-example h3, .ex-mistakes h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 4px; }
.ex-example p { margin: 0; line-height: 1.6; }
.ex-mistakes ul { margin: 0; padding-left: 1.1rem; display: grid; gap: 3px; }

/* optional hidden scroll bars (notes pages toggle) */
.no-sb, .no-sb * { scrollbar-width: none; -ms-overflow-style: none; }
.no-sb::-webkit-scrollbar, .no-sb *::-webkit-scrollbar { display: none; width: 0; height: 0; }
.sb-toggle { align-self: flex-start; font-size: .8rem; padding: 3px 10px; }
.notes-tools { gap: 8px; align-items: center; flex-wrap: wrap; }
.notes-layout.toc-hidden { grid-template-columns: minmax(0, 1fr); }
.notes-layout.toc-hidden .toc { display: none; }
.notes-layout.toc-hidden .chapter { max-width: 900px; margin-inline: auto; width: 100%; }

/* calculation practice */
table.mini { border-collapse: collapse; margin: 10px 0; font-size: .95rem; }
table.mini th, table.mini td { border: 1px solid var(--line); padding: 4px 12px; text-align: right; }
table.mini th { background: var(--surface-2); text-align: center; }
.calc-result { margin-top: 12px; padding: 8px 12px; border-radius: 8px; }
.calc-result.ok { background: var(--good-soft); }
.calc-result.no { background: var(--bad-soft, rgba(179,38,30,.12)); }
.calc-working { margin-top: 8px; padding: 10px 14px; background: var(--surface-2); border-radius: 8px; }
.calc-working ol { margin: 6px 0 6px; padding-left: 1.2rem; display: grid; gap: 3px; }
.calc-formula { margin-top: 10px; padding: 8px 12px; background: var(--accent-soft); border-radius: 8px; }

/* label it / draw it inside the check for understanding */
.check-practice { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 6px; }
.check-practice .chip[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.check-practice .panel { box-shadow: none; }

/* accounts, teacher dashboard */
.acct-msg { font-size: .92rem; min-height: 1.2em; }
.acct-msg.bad { color: var(--bad); }
.acct-msg.good { color: var(--good); }
.badge { display: inline-block; border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: color-mix(in srgb, var(--good) 16%, var(--surface)); border-color: var(--good); }
.badge.mid { border-color: var(--accent); }
.badge.warn { border-color: var(--bad); color: var(--bad); }
.dash-table { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.dash-table table { min-width: 560px; margin: 0; }
.dash-table th, .dash-table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.dash-table th { background: var(--surface-2); font-size: .85rem; white-space: nowrap; }
.dash-table .num { text-align: right; white-space: nowrap; }
.dash-table .warn-text { color: var(--bad); font-weight: 600; }
.code-box { display: flex; flex-direction: column; align-items: center; border: 1px dashed var(--accent); border-radius: 8px; padding: 8px 18px; }
.code-box b { font-size: 1.6rem; letter-spacing: .12em; }
details.panel summary { cursor: pointer; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
@media (max-width: 700px) { #acctbtn { display: none; } }

[hidden] { display: none !important; }

.pack-steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pack-steps li { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: var(--surface); }
.pack-steps li > span:first-child { flex: 1; min-width: 180px; }

/* data-response questions */
.extract { margin: 0; padding: 10px 14px; border-left: 3px solid var(--accent, #0b5d73); background: var(--surface-2); border-radius: 0 8px 8px 0; font-style: italic; }
.datatable { display: flex; flex-direction: column; gap: 4px; }
.datatable .dt-title { font-size: .92rem; }
.datatable table { min-width: 0; }
.p2-sec { display: inline-block; font-family: var(--mono, monospace); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line, #ccd); }
.p2-off { opacity: .45; }
.p2-pick { cursor: pointer; }
.paste-note { position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 50; background: var(--ink, #14212b); color: var(--bg, #fff); padding: 10px 16px; border-radius: 10px; font-size: .92rem; max-width: min(92vw, 460px); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.paste-note[hidden] { display: none !important; }

/* level switch link in the header */
a.levelbtn { text-decoration: none; color: inherit; }
@media (max-width: 760px) { a.levelbtn { display: none; } }

/* A Level uses a purple accent so the two courses are easy to tell apart */
:root[data-level="al"] { --accent: #5a3d9a; --accent-soft: #e6def5; }
@media (prefers-color-scheme: dark) {
  :root[data-level="al"]:not([data-theme="light"]) { --accent: #b9a3f2; --accent-ink: #1d1236; --accent-soft: #2a2046; }
}
:root[data-level="al"][data-theme="dark"] { --accent: #b9a3f2; --accent-ink: #1d1236; --accent-soft: #2a2046; }

/* level chooser (home page) */
.levels { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.level { display: flex; flex-direction: column; gap: 10px; padding: 26px 24px 22px; background: var(--surface); border: 1px solid var(--line); border-top: 6px solid var(--lv); border-radius: 12px; text-decoration: none; color: var(--ink); transition: transform .12s ease, border-color .12s ease; }
.level:hover { border-color: var(--lv); transform: translateY(-2px); }
.level .code { align-self: flex-start; font-family: var(--f-mono); font-size: .82rem; font-weight: 600; background: var(--lv); color: var(--lv-ink); padding: 3px 9px; border-radius: 5px; }
.level h2 { font-size: 1.7rem; font-weight: 800; }
.level p { color: var(--muted); }
.level ul { margin: 0; padding-left: 1.15rem; color: var(--ink); font-size: .96rem; }
.level .go { margin-top: auto; padding-top: 10px; font-weight: 700; color: var(--lv); }
.level.igcse { --lv: #2a7a3b; --lv-ink: #fff; }
.level.alevel { --lv: #5a3d9a; --lv-ink: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .level.igcse { --lv: #86d37a; --lv-ink: #0a2210; }
  :root:not([data-theme="light"]) .level.alevel { --lv: #b9a3f2; --lv-ink: #1d1236; }
}
:root[data-theme="dark"] .level.igcse { --lv: #86d37a; --lv-ink: #0a2210; }
:root[data-theme="dark"] .level.alevel { --lv: #b9a3f2; --lv-ink: #1d1236; }
.level .badge { align-self: flex-start; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border: 1px solid var(--lv); color: var(--lv); border-radius: 99px; padding: 1px 8px; }
.level .row1 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* essay practice and Paper 4 mock (A Level) */
.es-col { max-width: 760px; }
.es-q { font-size: 1.02rem; font-weight: 600; line-height: 1.4; }
.es-foot { gap: 8px; margin-top: auto; padding-top: 6px; }
.es-foot .meta { margin-top: 0; padding-top: 0; }
textarea.input.es-draft { min-height: 340px; line-height: 1.6; margin-top: 6px; }
.es-count { font-family: var(--f-mono); font-size: .82rem; color: var(--muted); margin-top: 4px; }
.es-ticks { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.es-ticks label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.es-ticks input { margin-top: .3rem; width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.es-plan h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 14px 0 2px; }
.es-plan p, .es-plan li { max-width: 70ch; }
.es-plan ul:not(.es-ticks) { margin: 4px 0 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 6px; }
.es-guide { font-size: .88rem; margin-top: 4px; }
.es-cover { margin-top: 16px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.es-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.es-rate { margin-top: 12px; gap: 10px; }
.es-timer { position: static; max-width: none; margin-bottom: 0; }
.p4-bar { top: calc(114px + env(safe-area-inset-top, 0px)); z-index: 17; }
@media (max-width: 820px) { .p4-bar { top: calc(106px + env(safe-area-inset-top, 0px)); } }

/* data response practice */
svg .dr-s0 { stroke: var(--demand); stroke-width: 2.6; fill: none; stroke-linejoin: round; }
svg .dr-s1 { stroke: var(--supply); stroke-width: 2.6; fill: none; stroke-linejoin: round; }
svg .dr-s2 { stroke: var(--good); stroke-width: 2.6; fill: none; stroke-linejoin: round; }
svg .dr-dash { stroke-dasharray: 7 4; }
svg .dr-f0 { fill: var(--demand); }
svg .dr-f1 { fill: var(--supply); }
svg .dr-f2 { fill: var(--good); }
svg .dr-f3 { fill: var(--warn); }
svg .dr-f4 { fill: var(--bad); }
svg .dr-f5 { fill: var(--muted); }
svg text.dr-onbar { fill: #fff; font-size: 11.5px; font-weight: 700; }
svg text.dr-mark { font-weight: 700; font-size: 13px; }
.dr-figs { display: grid; gap: 14px; }
.dr-fig .dt-title { font-size: .92rem; margin-bottom: 4px; }
.dr-alt { margin-top: 8px; font-size: .88rem; }
.dr-alt summary { cursor: pointer; color: var(--muted); }
.dr-tick { display: flex; gap: 8px; align-items: flex-start; padding: 3px 0; cursor: pointer; }
.dr-tick input { margin-top: 5px; flex: none; }
.dr-total { position: sticky; bottom: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12); }
@media (max-width: 820px) { .dr-total { bottom: 78px; } }
.part { padding-bottom: 12px; }

/* spaced repetition flashcards */
.srs-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 560px; margin-bottom: 8px; }
.srs-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: flex; flex-direction: column; }
.srs-stats b { font-family: var(--f-display); font-size: 1.3rem; color: var(--accent); line-height: 1.1; }
.srs-stats span { font-size: .78rem; color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* coverage map */
table.cov { min-width: 760px; font-size: .9rem; }
table.cov td.cov-gap { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
table.cov tr.cov-unit th { background: var(--surface-2); color: var(--ink); font-family: var(--f-body); font-size: .88rem; text-transform: none; letter-spacing: 0; }
.level .btn { align-self: flex-start; margin-top: auto; background: var(--lv); border-color: var(--lv); color: var(--lv-ink); }
.level .btn:hover { filter: brightness(1.08); }
