/* AI Engineering Academy — single stylesheet. All colours come from the tokens below. */
:root {
  --bg: #f5f7fa; --surface: #ffffff; --surface-2: #eef2f6; --surface-3: #e3e9f0;
  --ink: #142030; --ink-2: #3c4a5c; --ink-3: #56657a; --line: #d3dbe5; --line-strong: #9aa8b8;
  --accent: #0f766e; --accent-ink: #ffffff; --accent-soft: #e7f1f0; --link: #0f766e; --link-visited: #5a3e9e;
  --applied: #0f766e; --applied-soft: #e7f1f0;
  --ml: #1a56b0; --ml-soft: #e4edfa;
  --lm: #5b45ad; --lm-soft: #ece8f9;
  --ok-ink: #17643a; --ok-bg: #e3f4ea; --warn-ink: #6a4300; --warn-bg: #fdf2dc; --bad-ink: #a12a2a; --bad-bg: #fbe7e7;
  --focus: #0f766e; --focus-halo: #ffffff;
  --shadow: none;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --top: 56px; --sb: 272px; --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --surface: #161d25; --surface-2: #1d2630; --surface-3: #26313d;
    --ink: #e8edf2; --ink-2: #b9c4cf; --ink-3: #a3afbc; --line: #2f3b48; --line-strong: #5d6b7a;
    --accent: #2dd4bf; --accent-ink: #0b1220; --accent-soft: #1a3a3e; --link: #2dd4bf; --link-visited: #c3b3ff;
    --applied: #2dd4bf; --applied-soft: #1a3a3e; --ml: #82b4ff; --ml-soft: #1b2a40; --lm: #b8a8ff; --lm-soft: #262043;
    --ok-ink: #8ee0ad; --ok-bg: #12301f; --warn-ink: #f2cf86; --warn-bg: #2f2510; --bad-ink: #ffaaaa; --bad-bg: #3a1919;
    --focus: #5eead4; --focus-halo: #0f141a; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141a; --surface: #161d25; --surface-2: #1d2630; --surface-3: #26313d;
  --ink: #e8edf2; --ink-2: #b9c4cf; --ink-3: #a3afbc; --line: #2f3b48; --line-strong: #5d6b7a;
  --accent: #2dd4bf; --accent-ink: #0b1220; --accent-soft: #1a3a3e; --link: #2dd4bf; --link-visited: #c3b3ff;
  --applied: #2dd4bf; --applied-soft: #1a3a3e; --ml: #82b4ff; --ml-soft: #1b2a40; --lm: #b8a8ff; --lm-soft: #262043;
  --ok-ink: #8ee0ad; --ok-bg: #12301f; --warn-ink: #f2cf86; --warn-bg: #2f2510; --bad-ink: #ffaaaa; --bad-bg: #3a1919;
  --focus: #5eead4; --focus-halo: #0f141a; --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 16px); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--sans); overflow-wrap: break-word; }
@media (min-width: 1680px) { body { font-size: 17px; } }
img, svg { max-width: 100%; }
a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:visited { color: var(--link-visited); }
a:hover { text-decoration-thickness: 2px; }
a.ext::after { content: "\2197" / ""; font-size: .8em; margin-left: .15em; }
h1, h2, h3, h4 { line-height: 1.25; color: var(--ink); text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 1.4rem + 1.4vw, 2.35rem); letter-spacing: -.015em; margin: .2em 0 .5em; }
h2 { font-size: 1.4rem; margin: 1.6rem 0 .5rem; }
h3 { font-size: 1.15rem; margin: 1.4rem 0 .4rem; }
h4 { font-size: 1rem; margin: 1rem 0 .3rem; }
p, ul, ol, dl { margin: 0 0 1rem; }
ul, ol { padding-left: 1.4rem; }
li { margin: .25rem 0; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); color: var(--ink); padding: .1em .35em; border-radius: 4px; overflow-wrap: anywhere; }
strong { font-weight: 650; }
.small { font-size: .875rem; }
.muted { color: var(--ink-3); }
.lede { font-size: 1.12rem; color: var(--ink-2); max-width: 70ch; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* Focus: visible two-tone ring on every interactive element */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px var(--focus-halo); border-radius: 4px; }
main:focus, section[tabindex="-1"]:focus { outline: none; box-shadow: none; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: .6rem 1rem; border-radius: var(--radius); font-weight: 600; }
.skip-link:focus { top: 8px; color: var(--accent-ink); }

/* ---------- Buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: .45rem .9rem; font: inherit; font-size: .925rem; font-weight: 550; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:visited { color: var(--ink); }
.btn-small { min-height: 36px; font-size: .875rem; padding: .3rem .7rem; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-primary, .btn-primary:visited { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
cite { font-style: italic; }
.btn-quiet:hover { background: var(--surface-2); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.btn-danger { color: var(--bad-ink); border-color: var(--bad-ink); }
.btn-danger:hover { background: var(--bad-bg); }
.link-btn { background: none; border: 0; padding: .3rem .2rem; color: var(--link); font: inherit; font-size: .85rem; cursor: pointer; text-decoration: underline; text-underline-offset: .18em; min-height: 32px; }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
input[type="search"], input[type="number"], select { font: inherit; font-size: .95rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); min-height: 40px; padding: .35rem .6rem; max-width: 100%; }
input::placeholder { color: var(--ink-3); opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); flex: none; margin: .2rem 0 0; }
.field { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; font-weight: 550; color: var(--ink-2); min-width: 0; }
.field-grow { flex: 1 1 14rem; }
.field-error { color: var(--bad-ink); background: var(--bad-bg); padding: .5rem .75rem; border-radius: var(--radius); }
.check-row { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--top); display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; margin-right: auto; }
.brand:visited { color: var(--ink); }
.search { position: relative; flex: 0 1 26rem; min-width: 0; }
.search input { width: 100%; }
.search-results { position: absolute; top: calc(100% + 6px); right: 0; width: min(32rem, 92vw); max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0, 0, 0, .18); padding: .4rem; z-index: 60; }
.search-results ul { list-style: none; margin: 0; padding: 0; }
.search-results a { display: block; padding: .5rem .6rem; border-radius: 6px; text-decoration: none; color: var(--ink); }
.search-results a:hover, .search-results a:focus { background: var(--surface-2); }
.search-results .res-section { display: block; font-size: .78rem; color: var(--ink-3); }
.search-status { font-size: .85rem; color: var(--ink-3); margin: .2rem .6rem; }
.theme-picker { display: flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--ink-2); }
.theme-picker select { min-height: 36px; font-size: .85rem; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--sb) minmax(0, 1fr); min-height: calc(100vh - var(--top)); }
:root[data-sidebar="hidden"] .layout, :root[data-focus="on"] .layout { grid-template-columns: minmax(0, 1fr); }
:root[data-sidebar="hidden"] .sidebar, :root[data-focus="on"] .sidebar { display: none; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
main { flex: 1; padding: 1rem clamp(.75rem, 2vw, 1.75rem) 2.5rem; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2rem; }
.content { min-width: 0; }
/* Prose lines stay readable (about 45–80 characters); grids, tables and code use the full width. */
.content p, .content li, .content dd, .content legend { max-width: 80ch; }
.card p, .card li, .card dd, td p { max-width: none; }
@media (min-width: 1360px) { main.has-toc .content-grid { grid-template-columns: minmax(0, 46rem) 15rem; } }
:root[data-focus="on"] .toc { display: none; }
:root[data-focus="on"] main { margin: 0 auto; width: 100%; max-width: 64rem; }
:root[data-focus="on"] main.wide { max-width: none; }
:root[data-focus="on"] .lesson-rail { display: none; }
:root[data-focus="on"] .lesson-layout { grid-template-columns: minmax(0, 1fr); }
:root[data-focus="on"] .search, :root[data-focus="on"] #sidebar-toggle { display: none; }

/* ---------- Sidebar ---------- */
.sidebar { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border-right: 1px solid var(--line); padding: 1rem .75rem 2rem; }
.sidebar-search label { display: block; font-size: .8rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
.sidebar-search input { width: 100%; }
.nav-actions { display: flex; gap: .5rem; margin: .4rem 0 .5rem; }
.nav-heading { margin: .35rem 0 0; font-size: .95rem; }
.nav-toggle { width: 100%; display: flex; align-items: center; gap: .5rem; padding: .5rem .5rem; min-height: 40px; background: none; border: 0; border-radius: 6px; color: var(--ink); font: inherit; font-weight: 650; text-align: left; cursor: pointer; }
.nav-toggle:hover { background: var(--surface-2); }
.nav-title { flex: 1; }
.nav-count { font-size: .75rem; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border-radius: 999px; padding: .05rem .5rem; }
.chev { width: .55rem; height: .55rem; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(-45deg); transition: transform .15s; flex: none; }
.nav-toggle[aria-expanded="true"] .chev { transform: rotate(45deg); }
.nav-list { list-style: none; margin: 0 0 .4rem; padding: 0 0 0 .25rem; }
.nav-list li { margin: 0; }
.nav-list a { display: flex; gap: .5rem; align-items: flex-start; padding: .35rem .5rem; border-radius: 6px; font-size: .9rem; line-height: 1.4; color: var(--ink-2); text-decoration: none; min-height: 34px; }
.nav-list a:visited { color: var(--ink-2); }
.nav-list a:hover { background: var(--surface-2); color: var(--ink); }
.nav-list a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: 650; box-shadow: inset 3px 0 0 var(--accent); }
.nav-label { flex: 1; }
.nav-level { font-size: .7rem; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3rem; white-space: nowrap; }
.nav-check { flex: none; width: 1rem; height: 1rem; margin-top: .15rem; border: 1.5px solid var(--line-strong); border-radius: 50%; }
.is-done > .nav-check, [data-done="true"] > .nav-check { background: var(--ok-ink); border-color: var(--ok-ink); position: relative; }
[data-done="true"] > .nav-check::after { content: ""; position: absolute; left: .28rem; top: .1rem; width: .25rem; height: .5rem; border: solid var(--surface); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.nav-group.filtered-out, .nav-list li.filtered-out { display: none; }
.sidebar-note { margin-top: 1rem; font-size: .8rem; color: var(--ink-3); }
.scrim { display: none; }

/* Mobile and tablet: sidebar becomes a drawer */
@media (max-width: 1023.98px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; top: var(--top); left: 0; bottom: 0; height: auto; width: min(22rem, 88vw); z-index: 50; transform: translateX(-105%); visibility: hidden; transition: transform .2s ease, visibility 0s linear .2s; box-shadow: 4px 0 24px rgba(0, 0, 0, .25); }
  :root[data-sidebar="hidden"] .sidebar { display: block; }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; }
  body.drawer-open .scrim { display: block; position: fixed; inset: var(--top) 0 0 0; background: rgba(0, 0, 0, .45); z-index: 45; }
  body.drawer-open { overflow: hidden; }
  .brand-text { font-size: .95rem; }
}
@media (max-width: 720px) {
  .topbar { gap: .25rem; padding: 0 .4rem; }
  .btn-label { display: none; }
  #sidebar-toggle .btn-label { display: none; }
  .brand-text { display: none; }
  .search { flex: 1 1 auto; }
  .theme-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}

/* ---------- Breadcrumbs and TOC ---------- */
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; padding: 0; margin: 0 0 .75rem; font-size: .85rem; color: var(--ink-3); }
.crumbs li { margin: 0; }
.crumbs li + li::before { content: "/"; margin-right: .3rem; color: var(--ink-3); }
.crumbs a { color: var(--ink-2); }
.toc { position: sticky; top: calc(var(--top) + 1.25rem); align-self: start; display: none; font-size: .875rem; border-left: 1px solid var(--line); padding-left: 1rem; }
@media (min-width: 1360px) { main.has-toc .toc { display: block; } }
.toc-title { font-size: .85rem; margin: 0 0 .5rem; color: var(--ink-2); }
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc a { color: var(--ink-2); text-decoration: none; display: block; padding: .2rem 0; }
.toc a:hover, .toc a.active { color: var(--link); text-decoration: underline; }

/* ---------- Lessons ---------- */
.lesson-head { margin-bottom: 1rem; }
.eyebrow-line { margin: 0; font-size: .9rem; }
.meta-row { display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; margin: .25rem 0 .75rem; }
.meta { font-size: .875rem; color: var(--ink-2); }
.badge { display: inline-block; font-size: .75rem; font-weight: 650; line-height: 1.5; padding: .05rem .5rem; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge-core { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.badge-optional { background: var(--surface-2); color: var(--ink-2); }
.badge-advanced { background: var(--lm-soft); color: var(--lm); border-color: transparent; }
.badge-beginner { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.badge-intermediate { background: var(--applied-soft); color: var(--applied); border-color: transparent; }
.badge-expert { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.track-badge-applied { background: var(--applied-soft); color: var(--applied); border-color: transparent; }
.track-badge-ml { background: var(--ml-soft); color: var(--ml); border-color: transparent; }
.track-badge-lm { background: var(--lm-soft); color: var(--lm); border-color: transparent; }
.goal-box { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: .9rem 1.1rem; margin: 0 0 1.5rem; }
.goal-box p { margin: .3rem 0; }
.lesson-section { margin-top: 1.5rem; }
.lesson-section > h2 { padding-top: .5rem; border-top: 1px solid var(--line); }
.callout { border-radius: var(--radius); padding: .8rem 1rem; margin: 1rem 0; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.callout p:last-child { margin-bottom: 0; }
.callout-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.callout-warn a, .callout-warn strong { color: var(--warn-ink); }
.callout-ok { background: var(--ok-bg); color: var(--ok-ink); border-color: transparent; }
.callout-ok code, .callout-warn code { background: var(--surface); }
figure.code { margin: 1rem 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
figure.code figcaption { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 600; color: var(--ink-2); background: var(--surface-2); padding: .3rem .4rem .3rem .8rem; border-bottom: 1px solid var(--line); }
figure.code pre { margin: 0; padding: .85rem 1rem; overflow-x: auto; font: .85rem/1.55 var(--mono); color: var(--ink); background: var(--surface); }
figure.code code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.copy-btn { font: inherit; font-size: .78rem; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; padding: .15rem .55rem; cursor: pointer; min-height: 30px; }
.table-wrap { overflow-x: auto; margin: 1rem 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .925rem; }
th, td { text-align: left; vertical-align: top; padding: .55rem .75rem; border-bottom: 1px solid var(--line); }
thead th { background: var(--surface-2); color: var(--ink); font-weight: 650; }
tbody tr:last-child > * { border-bottom: 0; }
tbody th { font-weight: 650; }
.qa { padding-left: 1.3rem; }
.qa > li { margin-bottom: 1rem; }
.qa-q { margin-bottom: .3rem; font-weight: 550; }
.qa-controls { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }
details { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 0 .8rem; }
details > summary { cursor: pointer; padding: .5rem 0; font-weight: 600; color: var(--link); min-height: 36px; }
details[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: .5rem; }
.completion { margin-top: 2.5rem; padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.completion h2 { margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2rem; }
.pager a { display: flex; flex-direction: column; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); text-decoration: none; font-weight: 600; color: var(--ink); }
.pager a:visited { color: var(--ink); }
.pager a:hover { border-color: var(--accent); }
.pager-next { text-align: right; }
@media (max-width: 560px) { .pager { grid-template-columns: 1fr; } .pager-next { text-align: left; } }

/* ---------- Generic cards, grids ---------- */
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: 1.25rem 2rem; }
.three-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem 1.5rem; }
.card-list { list-style: none; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.card-list.two { grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr)); }
.card { margin: 0; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-kicker { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; font-size: .82rem; color: var(--ink-2); margin-bottom: .4rem; }
.card-title { font-size: 1.08rem; margin: .1rem 0 .5rem; }
.card-title a { text-decoration: none; display: inline-flex; gap: .45rem; align-items: flex-start; }
.card-title a:hover { text-decoration: underline; }
.card-plain { padding: .6rem 0; border-bottom: 1px solid var(--line); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; }
.kv dt { font-weight: 650; color: var(--ink); }
.kv dd { margin: 0; color: var(--ink-2); }
@media (max-width: 560px) { .kv { grid-template-columns: minmax(0, 1fr); } .kv dd { margin-bottom: .4rem; } }
.spec { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .2rem .8rem; font-size: .875rem; }
.spec dt { color: var(--ink-3); font-weight: 600; }
.spec dd { margin: 0; color: var(--ink); }
.spec.compact { font-size: .82rem; }
.support { list-style: none; padding: 0; font-size: .875rem; }
.support li { display: flex; gap: .45rem; align-items: baseline; }
.sup-mark { flex: none; width: .7rem; height: .7rem; border-radius: 2px; }
.sup-ok .sup-mark { background: var(--ok-ink); }
.sup-mid .sup-mark { background: var(--warn-ink); border-radius: 50%; }
.sup-no .sup-mark { border: 2px solid var(--ink-3); }

/* Filters */
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; padding: .85rem 1rem; margin: 1rem 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.filter-status { flex-basis: 100%; margin: 0; font-size: .875rem; color: var(--ink-2); }
.empty-state { padding: 1.25rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center; color: var(--ink-2); background: var(--surface); }

/* Stack tables into cards on narrow screens */
@media (max-width: 720px) {
  .stack-on-mobile { overflow: visible; border: 0; background: none; }
  .stack-on-mobile table, .stack-on-mobile tbody, .stack-on-mobile tr, .stack-on-mobile th, .stack-on-mobile td { display: block; width: 100%; }
  .stack-on-mobile thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .stack-on-mobile tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: .75rem; }
  .stack-on-mobile tbody th { background: var(--surface-2); }
  .stack-on-mobile td::before { content: attr(data-label); display: block; font-size: .78rem; font-weight: 650; color: var(--ink-3); }
}

/* ---------- Home ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 2rem; align-items: center; padding: 1rem 0 1.5rem; border-bottom: 1px solid var(--line); }
.hero h1 { font-size: clamp(2rem, 1.5rem + 2.2vw, 3rem); max-width: 18ch; }
.hero-facts { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; }
.hero-facts span { font-size: .875rem; font-weight: 600; color: var(--ink-2); border: 1px solid var(--line); background: var(--surface); padding: .2rem .6rem; border-radius: 999px; }
.hero-figure { margin: 0; }
.svg-box { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.svg-label { fill: var(--ink); font: 600 12px var(--sans); }
.svg-line { fill: none; stroke-width: 3; }
.track-applied-stroke { stroke: var(--applied); } .track-ml-stroke { stroke: var(--ml); } .track-lm-stroke { stroke: var(--lm); }
@media (max-width: 820px) { .hero { grid-template-columns: minmax(0, 1fr); } .hero-figure { max-width: 24rem; } }
.route-grid, .track-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); margin-bottom: 1rem; }
.route-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; min-width: 0; }
.route-card h3 { margin-top: .2rem; }
.route-steps { font-size: .925rem; }
.track-card { display: flex; flex-direction: column; gap: .5rem; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--applied); color: var(--ink); text-decoration: none; min-width: 0; }
.track-card:visited { color: var(--ink); }
a.track-card:hover { border-color: var(--line-strong); }
.track-card.track-ml { border-top-color: var(--ml); } .track-card.track-lm { border-top-color: var(--lm); }
.track-name { font-weight: 700; font-size: 1.08rem; margin: 0; }
.track-sum { color: var(--ink-2); }
.track-more { color: var(--link); font-weight: 600; text-decoration: underline; text-underline-offset: .18em; }
.th-applied { box-shadow: inset 0 -3px 0 var(--applied); } .th-ml { box-shadow: inset 0 -3px 0 var(--ml); } .th-lm { box-shadow: inset 0 -3px 0 var(--lm); }

/* Sprint */
.sprint { list-style: none; padding: 0; counter-reset: none; }
.sprint-week { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.sprint-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1rem; }
.sprint-head h2 { margin: 0; font-size: 1.2rem; }
.sprint-n { font-weight: 700; color: var(--accent); }

/* Module lesson list */
.lesson-list { list-style: none; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); }
.lesson-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; margin: 0; }
.lesson-item > a { display: inline-flex; gap: .5rem; align-items: flex-start; font-weight: 650; font-size: 1.04rem; text-decoration: none; }
.lesson-item > a:hover .lesson-item-title { text-decoration: underline; }
.lesson-item p { margin: .3rem 0 0; color: var(--ink-2); }

/* Horizontal flow (wraps to vertical on small screens) */
.hflow { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1.6rem; margin: 1rem 0 1.5rem; counter-reset: hf; }
.hflow > li { position: relative; flex: 1 1 10rem; min-width: 0; margin: 0; padding: .7rem .8rem; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); display: flex; flex-direction: column; gap: .2rem; }
.hflow > li span { font-size: .875rem; color: var(--ink-2); }
.hflow > li + li::before { content: ""; position: absolute; left: -1.45rem; top: 50%; width: 1.2rem; border-top: 2px solid var(--line-strong); }
.hflow > li + li::after { content: ""; position: absolute; left: -.45rem; top: calc(50% - 5px); border: 5px solid transparent; border-left: 7px solid var(--line-strong); border-right: 0; }
@media (max-width: 900px) {
  .hflow { flex-direction: column; gap: 1.4rem; }
  .hflow > li { flex-basis: auto; }
  .hflow > li + li::before { left: 1.2rem; top: -1.35rem; width: 0; height: 1.1rem; border-top: 0; border-left: 2px solid var(--line-strong); }
  .hflow > li + li::after { left: calc(1.2rem - 4px); top: -.4rem; border: 5px solid transparent; border-top: 7px solid var(--line-strong); border-bottom: 0; }
}
.hflow.vertical-sm { flex-direction: column; gap: 1.4rem; }
.hflow.vertical-sm > li { flex: 0 0 auto; }
.hflow.vertical-sm > li + li::before { left: 1.2rem; top: -1.35rem; width: 0; height: 1.1rem; border-top: 0; border-left: 2px solid var(--line-strong); }
.hflow.vertical-sm > li + li::after { left: calc(1.2rem - 4px); top: -.4rem; border: 5px solid transparent; border-top: 7px solid var(--line-strong); border-bottom: 0; }

/* ---------- Roadmaps ---------- */
.roadmap-bar { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; align-items: center; justify-content: space-between; margin: 1rem 0; }
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.tab { font: inherit; font-weight: 650; font-size: .95rem; padding: .5rem 1rem; min-height: 42px; border-radius: var(--radius); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tab.track-applied[aria-selected="true"] { box-shadow: inset 0 -4px 0 var(--applied); }
.tab.track-ml[aria-selected="true"] { box-shadow: inset 0 -4px 0 var(--ml); }
.tab.track-lm[aria-selected="true"] { box-shadow: inset 0 -4px 0 var(--lm); }
.expand-controls { display: flex; flex-wrap: wrap; gap: .4rem; }
.roadmap { --track: var(--applied); --track-soft: var(--applied-soft); }
.roadmap.track-ml { --track: var(--ml); --track-soft: var(--ml-soft); }
.roadmap.track-lm { --track: var(--lm); --track-soft: var(--lm-soft); }
.roadmap > h2 { margin-top: .5rem; }
.overview { display: none; margin: 1rem 0 1.5rem; }
@media (min-width: 1200px) { .overview { display: block; } }
.overview ol { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(var(--steps, 9), minmax(0, 1fr)); }
.overview ol.steps-9 { --steps: 9; } .overview ol.steps-10 { --steps: 10; } .overview ol.steps-12 { --steps: 12; }
.overview li { position: relative; margin: 0; text-align: center; }
.overview li + li::before { content: ""; position: absolute; top: 1.05rem; right: calc(50% + 1.15rem); width: calc(100% - 2.3rem); border-top: 2px solid var(--track); }
.overview li + li::after { content: ""; position: absolute; top: calc(1.05rem - 5px); right: calc(50% + 1.15rem); border: 5px solid transparent; border-left: 7px solid var(--track); border-right: 0; }
.overview a { display: flex; flex-direction: column; align-items: center; gap: .3rem; text-decoration: none; color: var(--ink); font-size: .8rem; font-weight: 600; padding: 0 .2rem; }
.overview a:visited { color: var(--ink); }
.ov-n { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%; border: 2px solid var(--track); background: var(--track-soft); color: var(--ink); font-weight: 700; }
.overview a:hover .ov-n { background: var(--track); color: var(--surface); }
.flow { list-style: none; padding: 0; margin: 0; }
.node { position: relative; margin: 0; padding: 0 0 1.4rem 3.25rem; }
.node::before { content: ""; position: absolute; left: 1.05rem; top: 2.3rem; bottom: .2rem; border-left: 2px solid var(--track, var(--line-strong)); }
.node::after { content: ""; position: absolute; left: calc(1.05rem - 5px); bottom: 0; border: 6px solid transparent; border-top: 8px solid var(--track, var(--line-strong)); border-bottom: 0; }
.node:last-child::before, .node:last-child::after { display: none; }
.node-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; box-shadow: var(--shadow); }
.node-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; }
.node-n { position: absolute; left: 0; top: .35rem; display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--track, var(--accent)); color: var(--surface); font-weight: 700; }
.node-title { margin: 0; font-size: 1.05rem; flex: 1 1 14rem; font-weight: 650; }
.node-effort { font-size: .82rem; font-weight: 600; color: var(--ink-2); background: var(--surface-2); padding: .05rem .5rem; border-radius: 4px; }
.node-desc { margin: .35rem 0 .5rem; color: var(--ink-2); }
.node-toggle { font: inherit; font-size: .875rem; font-weight: 600; color: var(--link); background: none; border: 1px solid var(--line); border-radius: 6px; padding: .25rem .65rem; min-height: 36px; cursor: pointer; }
.node-toggle:hover { background: var(--surface-2); }
.node-toggle[aria-expanded="true"] .when-closed, .node-toggle[aria-expanded="false"] .when-open { display: none; }
.node-panel { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line); }
.node-lessons { margin: 0; padding-left: 1.1rem; }
.flow-simple .node { padding-bottom: 1.1rem; }
.flow-simple .node-title { font-size: 1rem; font-weight: 550; }
.flow-simple { --track: var(--accent); }

/* Assessment and progress */
.mcq { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .8rem 1rem; margin: 0; min-width: 0; }
.mcq legend { font-weight: 600; padding: 0 .3rem; }
.opt { display: flex; gap: .55rem; align-items: flex-start; padding: .3rem 0; cursor: pointer; }
.mcq-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: .5rem 0; }
.mcq-feedback { margin: 0; font-weight: 600; }
.mcq-feedback.ok { color: var(--ok-ink); } .mcq-feedback.bad { color: var(--bad-ink); }
.mcq-list > li { margin-bottom: 1rem; }
.checklist { list-style: none; padding: 0; }
.dash { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
.dash-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.dash-item h3 { margin: 0 0 .4rem; font-size: 1rem; }
.bar { height: .6rem; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.calendar-form { align-items: flex-end; }

/* Footer, back to top */
.site-footer { padding: 1.25rem clamp(1rem, 3vw, 2.75rem) 2rem; border-top: 1px solid var(--line); font-size: .85rem; color: var(--ink-2); }
.site-footer p { margin: .3rem 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; list-style: none; padding: 0; margin: .3rem 0; }
.to-top { position: fixed; right: 1rem; bottom: 1rem; z-index: 30; box-shadow: var(--shadow); }
.glossary { margin: 0; }
.glossary dt { font-weight: 700; }
.glossary dd { margin: .2rem 0 0; color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .node-n, .ov-n, .nav-check { forced-color-adjust: none; border: 1px solid CanvasText; }
  .tab[aria-selected="true"] { outline: 2px solid Highlight; }
}

/* Print: show everything, hide chrome */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --ink: #000; --ink-2: #222; --ink-3: #333; --line: #bbb; }
  .topbar, .sidebar, .scrim, .toc, .to-top, .site-footer, .filters, .roadmap-bar, .node-toggle, .actions, .qa-controls, .pager, .copy-btn, .skip-link, .nav-actions { display: none !important; }
  .layout { display: block; }
  main { padding: 0; }
  .node-panel[hidden], .roadmap[hidden], details > *:not(summary) { display: block !important; }
  details { border: 0; padding: 0; }
  .card, .node-card, .lesson-item { box-shadow: none; break-inside: avoid; }
  a.ext::after { content: " (" attr(href) ")"; font-size: .8em; }
  figure.code pre { white-space: pre-wrap; }
}

/* ---------- Lesson layout with side panel (fills wide screens) ---------- */
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 1.75rem; }
.lesson-head h1 { margin-bottom: .4rem; }
.goal-line { font-size: 1.05rem; color: var(--ink-2); margin: 0 0 .5rem; }
.lesson-rail { display: grid; gap: .75rem; margin: .5rem 0 .5rem; }
.rail-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; font-size: .9rem; }
.rail-title { font-size: .95rem; margin: 0 0 .5rem; }
.rail-sub { font-size: .85rem; margin: .7rem 0 .25rem; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .25rem .75rem; margin: 0; }
.facts dt { color: var(--ink-3); font-weight: 600; }
.facts dd { margin: 0; max-width: none; }
.rail-list, .rail-toc { margin: 0; padding-left: 1.1rem; }
.rail-list li, .rail-toc li { margin: .15rem 0; max-width: none; }
.rail-toc a { color: var(--ink-2); }
.toc-card { display: none; }
@media (min-width: 1200px) {
  .lesson-layout { grid-template-columns: minmax(0, 1fr) 17.5rem; }
  .lesson-head, .lesson-body { grid-column: 1; }
  .lesson-rail { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: calc(var(--top) + .75rem); align-self: start; max-height: calc(100vh - var(--top) - 1.5rem); overflow-y: auto; margin: 0; }
  .toc-card { display: block; }
}
@media (min-width: 720px) and (max-width: 1199.98px) { .lesson-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.lesson-body > .lesson-section:first-child > h2 { border-top: 0; }
.plain-list { list-style: none; padding: 0; }
.plain-list li { margin: .4rem 0; }
.stage-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); }
.catalogue { grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: .75rem; }
.catalogue .card { padding: .75rem .9rem; }
.catalogue .card-title { font-size: 1rem; }
table.formula code { white-space: normal; }
.content-grid > .content > section > h2:first-child { margin-top: 1.25rem; }

/* ---------- Diagrams (HTML + CSS; colours from theme tokens; stack in narrow containers) ---------- */
.diagram { container-type: inline-size; margin: 1.25rem 0 1.5rem; padding: .9rem 1rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: calc(var(--radius) + 2px); box-shadow: var(--shadow); break-inside: avoid; --dg-gap: 1.7rem; }
.diagram > figcaption { font-weight: 650; font-size: 1rem; color: var(--ink); margin: 0 0 .8rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .55rem; }
.dg-kicker { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); padding: .1rem .5rem; border-radius: 4px; }
.dg-note { margin: .8rem 0 0; font-size: .875rem; color: var(--ink-2); max-width: none; }
.k-plain { --k: var(--line-strong); --kbg: var(--surface); }
.k-input { --k: var(--applied); --kbg: var(--applied-soft); }
.k-process { --k: var(--ink-3); --kbg: var(--surface-2); }
.k-model { --k: var(--lm); --kbg: var(--lm-soft); }
.k-output { --k: var(--ok-ink); --kbg: var(--ok-bg); }
.k-store { --k: var(--ml); --kbg: var(--ml-soft); }
.k-warn { --k: var(--warn-ink); --kbg: var(--warn-bg); }
.k-bad { --k: var(--bad-ink); --kbg: var(--bad-bg); }
.dg-box { position: relative; min-width: 0; margin: 0; padding: .6rem .75rem .65rem; background: var(--kbg, var(--surface)); color: var(--ink); border: 1px solid var(--line-strong); border-top: 4px solid var(--k, var(--line-strong)); border-radius: var(--radius); display: flex; flex-direction: column; gap: .15rem; overflow-wrap: anywhere; }
.dg-tag { font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); }
.dg-label { font-size: .95rem; line-height: 1.3; font-weight: 650; }
.dg-detail { font-size: .85rem; line-height: 1.4; color: var(--ink-2); font-weight: 400; }
.dg-box code, .dg-col code, .dg-seg code, .dg-nest code { font-size: .85em; background: var(--surface); }

/* flow / loop / lanes: numbered boxes joined by arrows */
.dg-flow { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--c, 3), minmax(0, 1fr)); gap: var(--dg-gap); counter-reset: dg; }
.dg-flow.c2 { --c: 2; } .dg-flow.c3 { --c: 3; } .dg-flow.c4 { --c: 4; }
.dg-flow > .dg-box { counter-increment: dg; padding-left: 2.3rem; }
.dg-flow > .dg-box > .dg-tag:first-child { padding-right: 0; }
.dg-flow > .dg-box::after { content: counter(dg); position: absolute; left: .55rem; top: .55rem; display: grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--ink); color: var(--surface); font-size: .75rem; font-weight: 700; }
.dg-flow > .dg-box + .dg-box::before { content: ""; position: absolute; left: calc(-1 * var(--dg-gap) + .2rem); top: 1.5rem; width: calc(var(--dg-gap) - .55rem); border-top: 2px solid var(--ink-3); }
.dg-flow > .dg-box + .dg-box > .dg-label::before { content: ""; position: absolute; left: -.4rem; top: calc(1.5rem - 5px); border: 5px solid transparent; border-left: 7px solid var(--ink-3); border-right: 0; }
.dg-flow.c2 > .dg-box:nth-child(2n+1)::before, .dg-flow.c3 > .dg-box:nth-child(3n+1)::before, .dg-flow.c4 > .dg-box:nth-child(4n+1)::before,
.dg-flow.c2 > .dg-box:nth-child(2n+1) > .dg-label::before, .dg-flow.c3 > .dg-box:nth-child(3n+1) > .dg-label::before, .dg-flow.c4 > .dg-box:nth-child(4n+1) > .dg-label::before { display: none; }
.dg-return { margin: .8rem 0 0; padding: .4rem .8rem; border: 2px dashed var(--ink-3); border-radius: var(--radius); font-weight: 600; font-size: .9rem; color: var(--ink); text-align: center; max-width: none; }
.dg-lane { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem 1rem; align-items: start; padding: .8rem 0; border-top: 1px dashed var(--line); }
.dg-lane:first-of-type { border-top: 0; padding-top: 0; }
.dg-lane-title { margin: .3rem 0 0; font-size: .9rem; color: var(--ink); border-left: 4px solid var(--k, var(--line-strong)); padding-left: .55rem; }

/* layers: stacked bars with a down arrow between them */
.dg-layers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.1rem; }
.dg-layers > .dg-box { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: .15rem 1rem; border-top-width: 1px; border-left: 6px solid var(--k); }
.dg-layers > .dg-box .dg-label { flex: 0 1 15rem; }
.dg-layers > .dg-box .dg-detail { flex: 1 1 14rem; }
.dg-layers > .dg-box .dg-tag { flex: 0 0 100%; }
.dg-layers > .dg-box + .dg-box::before { content: ""; position: absolute; left: 1.4rem; top: -1.05rem; height: .8rem; border-left: 2px solid var(--ink-3); }
.dg-layers > .dg-box + .dg-box::after { content: ""; position: absolute; left: calc(1.4rem - 4px); top: -.35rem; border: 5px solid transparent; border-top: 7px solid var(--ink-3); border-bottom: 0; }

/* compare: side-by-side columns */
.dg-compare { display: grid; gap: .8rem; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); }
.dg-compare.cols2 { --n: 2; } .dg-compare.cols3 { --n: 3; } .dg-compare.cols4 { --n: 4; }
.dg-col { background: var(--kbg, var(--surface)); border: 1px solid var(--line-strong); border-top: 4px solid var(--k, var(--line-strong)); border-radius: var(--radius); padding: .6rem .8rem .5rem; min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.dg-col-title { margin: 0 0 .35rem; font-size: .98rem; }
.dg-col ul { margin: 0; padding-left: 1.1rem; }
.dg-col li { margin: .3rem 0; font-size: .9rem; max-width: none; }

/* nest: boxes inside boxes */
.dg-nest { background: var(--kbg, var(--surface)); border: 2px solid var(--k, var(--line-strong)); border-radius: calc(var(--radius) + 4px); padding: .6rem .75rem .75rem; color: var(--ink); }
.dg-nest-head { display: flex; flex-direction: column; gap: .1rem; margin-bottom: .55rem; }

/* matrix: 2 by 2 grid with axis labels */
.dg-matrix { display: grid; grid-template-columns: 6.5rem repeat(2, minmax(0, 1fr)); gap: .5rem; align-items: stretch; }
.dg-axis { font-size: .85rem; font-weight: 650; color: var(--ink); text-align: center; align-self: end; padding: 0 .2rem .1rem; overflow-wrap: anywhere; }
.dg-axis-y { align-self: center; text-align: right; }

/* fan (one to many) and merge (many to one) */
.dg-fan { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: var(--dg-gap); align-items: center; }
.dg-fan-out { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.dg-fan:not(.dg-merge) .dg-fan-out > .dg-box::before { content: ""; position: absolute; left: calc(-1 * var(--dg-gap) + .2rem); top: 50%; width: calc(var(--dg-gap) - .55rem); border-top: 2px solid var(--ink-3); }
.dg-fan:not(.dg-merge) .dg-fan-out > .dg-box::after { content: ""; position: absolute; left: -.4rem; top: calc(50% - 5px); border: 5px solid transparent; border-left: 7px solid var(--ink-3); border-right: 0; }
.dg-merge { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.dg-merge .dg-fan-out > .dg-box::before { content: ""; position: absolute; right: calc(-1 * var(--dg-gap) + .2rem); top: 50%; width: calc(var(--dg-gap) - .55rem); border-top: 2px solid var(--ink-3); }
.dg-merge .dg-fan-out > .dg-box::after { content: ""; position: absolute; right: -.4rem; top: calc(50% - 5px); border: 5px solid transparent; border-left: 7px solid var(--ink-3); border-right: 0; }

/* bar: one strip split into proportional parts (illustrative) */
.dg-bar { list-style: none; margin: 0; padding: 0; display: flex; gap: 3px; }
.dg-seg { min-width: 0; margin: 0; padding: .5rem .55rem; background: var(--kbg, var(--surface)); border: 1px solid var(--line-strong); border-top: 4px solid var(--k, var(--line-strong)); border-radius: 6px; display: flex; flex-direction: column; gap: .1rem; overflow-wrap: anywhere; color: var(--ink); }
.dg-seg .dg-label { font-size: .85rem; }
.dg-seg .dg-detail { font-size: .8rem; }
.dg-bar > .w5{flex:5 1 0}.dg-bar>.w10{flex:10 1 0}.dg-bar>.w15{flex:15 1 0}.dg-bar>.w20{flex:20 1 0}.dg-bar>.w25{flex:25 1 0}.dg-bar>.w30{flex:30 1 0}.dg-bar>.w35{flex:35 1 0}.dg-bar>.w40{flex:40 1 0}.dg-bar>.w45{flex:45 1 0}.dg-bar>.w50{flex:50 1 0}.dg-bar>.w55{flex:55 1 0}.dg-bar>.w60{flex:60 1 0}.dg-bar>.w65{flex:65 1 0}.dg-bar>.w70{flex:70 1 0}.dg-bar>.w75{flex:75 1 0}.dg-bar>.w80{flex:80 1 0}.dg-bar>.w85{flex:85 1 0}.dg-bar>.w90{flex:90 1 0}.dg-bar>.w95{flex:95 1 0}.dg-bar>.w100{flex:100 1 0}

/* narrow containers (the container is the diagram, so this works beside the sidebar and rail) */
@container (max-width: 720px) {
  .dg-flow.c4 { --c: 2; }
  .dg-flow.c4 > .dg-box:nth-child(2n+1)::before, .dg-flow.c4 > .dg-box:nth-child(2n+1) > .dg-label::before { display: none; }
  .dg-compare.cols3, .dg-compare.cols4 { --n: 2; }
}
@container (max-width: 560px) {
  .dg-flow.c2, .dg-flow.c3, .dg-flow.c4 { --c: 1; gap: 1.5rem; }
  .diagram .dg-flow.dg-flow > .dg-box + .dg-box::before { display: block; left: 1.15rem; top: -1.4rem; width: 0; height: 1.1rem; border: 0; border-left: 2px solid var(--ink-3); }
  .diagram .dg-flow.dg-flow > .dg-box + .dg-box > .dg-label::before { display: block; left: calc(1.15rem - 4px); top: -.4rem; border: 5px solid transparent; border-top: 7px solid var(--ink-3); border-bottom: 0; }
  .dg-compare.cols2, .dg-compare.cols3, .dg-compare.cols4 { --n: 1; }
  .dg-matrix { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dg-matrix .dg-corner { display: none; }
  .dg-axis-y { grid-column: 1 / -1; text-align: left; align-self: end; margin-top: .3rem; }
  .dg-fan, .dg-merge { grid-template-columns: minmax(0, 1fr); gap: 1.2rem; }
  .dg-fan .dg-fan-out > .dg-box::before, .dg-fan .dg-fan-out > .dg-box::after { display: none; }
  .dg-bar { flex-direction: column; }
  .dg-bar > .dg-seg.dg-seg { flex: 0 0 auto; }
}
@media print { .diagram { box-shadow: none; } }

/* fan / merge: a vertical spine joins the arrows to the single box */
.dg-fan-out { position: relative; }
.dg-fan:not(.dg-merge) .dg-fan-out::before { content: ""; position: absolute; left: calc(-1 * var(--dg-gap) + .2rem); top: 2.2rem; bottom: 2.2rem; border-left: 2px solid var(--ink-3); }
.dg-merge .dg-fan-out::before { content: ""; position: absolute; right: calc(-1 * var(--dg-gap) + .2rem); top: 2.2rem; bottom: 2.2rem; border-left: 2px solid var(--ink-3); }
.dg-fan:not(.dg-merge) > .dg-src::after { content: ""; position: absolute; right: -.25rem; top: 50%; width: .25rem; border-top: 2px solid var(--ink-3); }
.dg-merge > .dg-src::after { content: ""; position: absolute; left: -.25rem; top: 50%; width: .25rem; border-top: 2px solid var(--ink-3); }
@container (max-width: 560px) { .dg-fan-out::before, .dg-fan > .dg-src::after { display: none; } }

/* ================= Refinements: readable type, wide-screen layout, older-browser fallbacks ================= */

/* Typography: larger, calmer body text; clear heading scale; comfortable line length */
body { font-size: 17px; line-height: 1.65; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-kerning: normal; }
@media (min-width: 1680px) { body { font-size: 18px; } }
@media (max-width: 380px) { body { font-size: 16px; } }
h1, h2, h3, h4 { font-weight: 700; letter-spacing: -.012em; line-height: 1.22; }
h1 { font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.6rem); margin: .25em 0 .45em; }
h2 { font-size: 1.6rem; margin: 2rem 0 .6rem; }
h3 { font-size: 1.25rem; margin: 1.6rem 0 .45rem; }
h4 { font-size: 1.05rem; margin: 1.2rem 0 .35rem; }
.lede { font-size: 1.18rem; line-height: 1.6; max-width: 75ch; }
.content p, .content li, .content dd, .content legend { max-width: 76ch; }
.lesson-body p, .lesson-body li { line-height: 1.72; }
.lesson-body li { margin: .35rem 0; }
.lesson-section > h2 { padding-top: .75rem; margin-top: 2.25rem; }
.goal-line { font-size: 1.12rem; line-height: 1.55; }
th { font-weight: 650; }
tbody tr:nth-child(even) > td { background: var(--surface-2); }
@media (max-width: 720px) { h2 { font-size: 1.4rem; } h3 { font-size: 1.15rem; } .lede { font-size: 1.08rem; } }

/* Card-like list items fill their grid cell instead of the 76-character prose limit */
.content .sprint-week, .content .node, .content .hflow > li, .content .flow > li, .content .card-list > li, .content .catalogue > li, .content .lesson-item, .content .gl-item, .content .card li { max-width: none; }

/* Wide screens: roadmap steps in two columns (the numbers keep the order), plan weeks in two columns */
@media (min-width: 1400px) {
  .content:not(.cols) .flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.5rem; align-items: start; }
  .content:not(.cols) .flow > .node::before, .content:not(.cols) .flow > .node::after { display: none; }
  .content:not(.cols) .flow > .node { padding-bottom: 1rem; }
}
@media (min-width: 1400px) {
  .sprint { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; align-items: start; }
  .sprint-week { margin: 0; height: 100%; }
}

/* Glossary: cards in as many columns as fit */
@media (min-width: 900px) {
  .glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr)); gap: .75rem 1.25rem; align-items: start; }
  .gl-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; }
  .gl-item dd, .gl-item dt { max-width: none; }
}

/* Pages made of short parallel sections use two balanced columns on wide screens */
@media (min-width: 1360px) {
  .content.cols { column-count: 2; column-gap: 3rem; }
  .content.cols > :not(section):not(#checkpoints), .content.cols > section.completion { column-span: all; }
  .content.cols > section { break-inside: avoid-column; margin-top: 0; }
  .content.cols > section > h2:first-child { margin-top: 0; }
}

/* Lessons: when the lesson column is wide, diagrams sit beside the text instead of leaving it empty */
.lesson-body { container-type: inline-size; container-name: lesson; }
.lesson-section { display: flow-root; }
/* Prose sections flow into two columns when the lesson area is wide; diagrams, code, tables and headings span the full width */
@container lesson (min-width: 880px) { .lesson-section.prose-cols { column-count: 2; column-gap: 2.75rem; } }
.lesson-section.prose-cols > h2, .lesson-section.prose-cols > h3, .lesson-section.prose-cols > h4, .lesson-section.prose-cols > figure, .lesson-section.prose-cols > .table-wrap, .lesson-section.prose-cols > .callout { column-span: all; }
.lesson-section.prose-cols > p, .lesson-section.prose-cols li { max-width: none; orphans: 2; widows: 2; }
.lesson-section.prose-cols li { break-inside: avoid; }

/* Older browsers without container queries: same stacking rules based on the screen width */
@supports not (container-type: inline-size) {
  .diagram .dg-flow.c4 { --c: 2; }
  .dg-flow.c4 > .dg-box:nth-child(2n+1)::before, .dg-flow.c4 > .dg-box:nth-child(2n+1) > .dg-label::before { display: none; }
  @media (max-width: 640px) {
    .dg-flow.c2, .dg-flow.c3, .dg-flow.c4 { --c: 1; gap: 1.5rem; }
    .diagram .dg-flow.dg-flow > .dg-box + .dg-box::before { display: block; left: 1.15rem; top: -1.4rem; width: 0; height: 1.1rem; border: 0; border-left: 2px solid var(--ink-3); }
    .diagram .dg-flow.dg-flow > .dg-box + .dg-box > .dg-label::before { display: block; left: calc(1.15rem - 4px); top: -.4rem; border: 5px solid transparent; border-top: 7px solid var(--ink-3); border-bottom: 0; }
    .dg-compare.cols2, .dg-compare.cols3, .dg-compare.cols4 { --n: 1; }
    .dg-matrix { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .dg-matrix .dg-corner { display: none; }
    .dg-axis-y { grid-column: 1 / -1; text-align: left; align-self: end; margin-top: .3rem; }
    .dg-fan, .dg-merge { grid-template-columns: minmax(0, 1fr); gap: 1.2rem; }
    .dg-fan .dg-fan-out > .dg-box::before, .dg-fan .dg-fan-out > .dg-box::after, .dg-fan-out::before, .dg-fan > .dg-src::after { display: none; }
    .dg-bar { flex-direction: column; }
    .dg-bar > .dg-seg.dg-seg { flex: 0 0 auto; }
  }
}
@media (max-width: 720px) { .dg-lane-title { font-size: .95rem; } }
@media (min-width: 1360px) {
  .content.cols > section.checkpoint { break-inside: auto; margin-bottom: 1.5rem; }
  .content.cols .mcq-list > li { break-inside: avoid-column; }
}
@media (max-width: 820px) { .hero-figure { margin-left: auto; margin-right: auto; } }
.lesson-body > .lesson-section:first-child { margin-top: .25rem; }
.lesson-body > .lesson-section:first-child > h2 { margin-top: .5rem; padding-top: 0; }

/* Five-step flows: three per row in medium widths, all five in one row when the diagram is wide */
.dg-flow.c5 { --c: 3; }
.dg-flow.c5 > .dg-box:nth-child(3n+1)::before, .dg-flow.c5 > .dg-box:nth-child(3n+1) > .dg-label::before { display: none; }
@container (min-width: 900px) {
  .dg-flow.c5 { --c: 5; }
  .dg-flow.c5 > .dg-box:nth-child(4)::before, .dg-flow.c5 > .dg-box:nth-child(4) > .dg-label::before { display: block; }
}
@container (max-width: 560px) { .dg-flow.c5 { --c: 1; gap: 1.5rem; } }
/* Fan and merge: the single box stays compact; the many boxes get the room */
.dg-fan { grid-template-columns: minmax(11rem, 17rem) minmax(0, 1fr); }
.dg-merge { grid-template-columns: minmax(0, 1fr) minmax(11rem, 17rem); }
@container (max-width: 560px) { .dg-fan, .dg-merge { grid-template-columns: minmax(0, 1fr); } }

/* ================= Report-style presentation (numbered panels, left-bar callouts, pills, tinted tables) ================= */

/* Status pills (like Verified / Assumed / Open) */
.pill { display: inline-block; font-size: .72rem; font-weight: 700; line-height: 1.5; border-radius: 999px; padding: .02rem .55rem; white-space: nowrap; vertical-align: middle; background: var(--surface-2); color: var(--ink-2); }
.pill-ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill-warn { background: var(--warn-bg); color: var(--warn-ink); }
.pill-bad { background: var(--bad-bg); color: var(--bad-ink); }
.code-status { display: block; margin: 0 0 .45rem; }
.code-status:last-child { margin-bottom: 0; }
.facts-detail { display: block; margin-top: .15rem; font-size: .8rem; color: var(--ink-3); line-height: 1.4; overflow-wrap: anywhere; }

/* Each lesson section is a bordered panel with a numbered badge heading */
.lesson-body { counter-reset: sec; }
.lesson-body > .lesson-section, .lesson-body > .completion { counter-increment: sec; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem 1.15rem; margin: 0 0 1.1rem; box-shadow: var(--shadow); }
.lesson-body > .lesson-section > h2, .lesson-body > .lesson-section:first-child > h2, .lesson-body > .completion > h2 { display: flex; align-items: center; gap: .65rem; margin: 0 0 .85rem; padding: 0 0 .5rem; border-top: 0; border-bottom: 2px solid var(--line); font-size: 1.4rem; }
.lesson-body > .lesson-section > h2::before, .lesson-body > .completion > h2::before { content: counter(sec); display: inline-grid; place-items: center; flex: none; min-width: 1.85rem; height: 1.85rem; padding: 0 .45rem; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: .95rem; font-weight: 700; letter-spacing: 0; }
.lesson-body > .completion { margin-top: 0; }
.lesson-section .diagram { box-shadow: none; }
.lesson-section > h3, .lesson-section > h4 { margin-top: 1.3rem; }

/* The same panel and badge on about, quiz, case and capstone pages */
.content.cols { counter-reset: sec2; }
.content.cols > section, .content.cols #checkpoints > section { counter-increment: sec2; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem 1.15rem; margin: 0 0 1.1rem; box-shadow: var(--shadow); }
.content.cols > section > h2:first-child, .content.cols #checkpoints > section > h2:first-child { display: flex; align-items: center; gap: .65rem; margin: 0 0 .85rem; padding: 0 0 .5rem; border-bottom: 2px solid var(--line); font-size: 1.35rem; }
.content.cols > section > h2:first-child::before, .content.cols #checkpoints > section > h2:first-child::before { content: counter(sec2); display: inline-grid; place-items: center; flex: none; min-width: 1.85rem; height: 1.85rem; padding: 0 .45rem; border-radius: 6px; background: var(--accent); color: var(--accent-ink); font-size: .95rem; font-weight: 700; }

/* Callouts: tinted block with a coloured bar on the left */
.callout { border: 0; border-left: 4px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--accent-soft); padding: .7rem 1rem; }
.callout-warn { border-left-color: var(--warn-ink); background: var(--warn-bg); }
.callout-ok { border-left-color: var(--ok-ink); background: var(--ok-bg); }

/* Tables: tinted header row and bordered cells on larger screens */
.table-wrap { border: 0; border-radius: 0; background: transparent; }
tbody tr:nth-child(even) > td { background: transparent; }
@media (min-width: 721px) {
  table { font-size: .9rem; }
  th, td { border: 1px solid var(--line); padding: .45rem .7rem; }
  thead th { background: var(--accent-soft); }
}

/* Cards sit on a quiet background inside panels */
.lesson-section .card, .content.cols .card { background: var(--bg); box-shadow: none; }

@media (max-width: 720px) {
  .lesson-body > .lesson-section, .lesson-body > .completion, .content.cols > section, .content.cols #checkpoints > section { padding: .8rem .85rem 1rem; border-radius: 8px; }
  .lesson-body > .lesson-section > h2, .lesson-body > .completion > h2 { font-size: 1.25rem; }
}
@media print { .lesson-body > .lesson-section, .lesson-body > .completion, .content.cols > section { box-shadow: none; } }
/* Pages without panels: same heading underline as the numbered panels */
.content:not(.cols) > h2 { border-bottom: 2px solid var(--line); padding-bottom: .4rem; }
.code-status .pill { white-space: normal; max-width: 100%; overflow-wrap: anywhere; border-radius: 12px; }

/* ---------- Overview pages: intro text uses the width; part pages get an "at a glance" panel ---------- */
.lede { max-width: min(100%, 110ch); }
.hero h1 { max-width: 24ch; }
.hero-text .lede { max-width: none; }
.page-intro { display: block; }
.page-intro .lede { max-width: none; }
.glance { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1.1rem 1rem; margin: .5rem 0 1.25rem; box-shadow: var(--shadow); font-size: .92rem; }
.glance-title { font-size: 1rem; margin: 0 0 .6rem; padding: 0; border: 0; }
.chip-list { display: flex; flex-wrap: wrap; gap: .35rem; list-style: none; margin: .35rem 0 0; padding: 0; }
.chip-list li { margin: 0; max-width: none; }
.chip-list a { display: inline-block; font-size: .8rem; line-height: 1.5; padding: .05rem .6rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--ink); text-decoration: none; }
.chip-list a:hover { border-color: var(--accent); }
@media (min-width: 1000px) {
  .page-intro { display: grid; grid-template-columns: minmax(0, 1fr) minmax(17rem, 25rem); gap: 0 2.5rem; align-items: start; }
  .glance { margin-top: 1.4rem; }
}
.key-terms-title { font-size: 1rem; margin: 1.1rem 0 .1rem; padding: 0; border: 0; color: var(--ink-2); }

/* Overview pages: no empty grid cells, and text boxes use their full width */
.lesson-list { grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); }
.content p, .content li, .content dd, .content legend { max-width: 100ch; }
.callout p, .callout li, .goal-box p, .card p, .glance p { max-width: none; }

/* ================= Applied Maths - Statistics (collapsible topics, formula blocks) ================= */
.maths-list { display: grid; gap: .6rem; margin-top: .75rem; }
.maths-item { background: var(--bg); padding: 0 1rem; }
.maths-item > summary { font-size: 1.02rem; padding: .65rem 0; color: var(--ink); }
.maths-item > summary::marker { color: var(--accent); }
.maths-item[open] > summary { color: var(--link); }
.maths-body { padding: 0 0 .9rem; }
.maths-body p, .maths-body ul, .maths-body ol { max-width: none; }
.maths-body p { margin: .5rem 0; }
.formula { margin: .75rem 0; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--accent-soft); }
.formula-title { margin: 0; padding: .35rem .85rem 0; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.formula pre { margin: 0; padding: .35rem .85rem .75rem; background: transparent; border: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.02rem; line-height: 1.55; color: var(--ink); }
.formula code { background: transparent; padding: 0; font-size: inherit; }

/* ---------- Advertising slots (AdSense build only; hidden in print) ---------- */
.ad-slot { margin: 1rem 0; padding: .5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-height: 280px; overflow: hidden; }
.ad-slot .ad-label { margin: 0 0 .35rem; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-2); }
.ad-slot ins.adsbygoogle { display: block; min-height: 250px; }
.ad-slot-footer { max-width: 970px; margin-inline: auto; min-height: 120px; }
.ad-slot-end { max-width: 76ch; }
:root[data-focus="on"] .ad-slot { display: none; }
@media print { .ad-slot { display: none !important; } }

/* ---------- Collapsible side panels (lesson rail, part overview) and the hide button ---------- */
.rail-details > summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; cursor: pointer; list-style: none; }
.rail-details > summary::-webkit-details-marker { display: none; }
.rail-details > summary::after { content: ""; flex: none; width: .5rem; height: .5rem; margin: 0 .25rem .2rem 0; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); }
.rail-details[open] > summary::after { margin: .2rem .25rem 0 0; transform: rotate(-135deg); }
.rail-details[open] > summary { margin-bottom: .5rem; }
.rail-details > summary .rail-title, .rail-details > summary .glance-title { margin: 0; }
.rail-toggle-row { margin: .25rem 0 .5rem; }
:root[data-rail="hidden"] .lesson-rail { display: none; }
:root[data-rail="hidden"] .lesson-layout { grid-template-columns: minmax(0, 1fr); }
:root[data-focus="on"] .rail-toggle-row { display: none; }
@media print { .rail-toggle-row { display: none !important; } }
/* Side panels already have their own card; remove the generic details frame inside them. */
details.rail-details { border: 0; border-radius: 0; background: none; padding: 0; }
details.rail-details > summary { padding: 0 0 .1rem; min-height: 0; color: var(--ink); border-bottom: 0; }
details.rail-details[open] > summary { border-bottom: 1px solid var(--line); padding-bottom: .4rem; }

/* ---------- Edge tabs: slide the left / right panel away so the page uses the whole screen (desktop) ---------- */
.edge-tab { display: none; position: fixed; top: 45vh; z-index: 30; width: 20px; height: 56px; padding: 0; align-items: center; justify-content: center; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); cursor: pointer; }
.edge-tab:hover { background: var(--surface-2); color: var(--ink); }
.edge-tab::before { content: ""; width: .45rem; height: .45rem; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; }
.edge-left { left: calc(var(--sb) - 1px); border-left: 0; border-radius: 0 8px 8px 0; }
.edge-left::before { transform: rotate(45deg); margin-left: .15rem; }
.edge-left[aria-expanded="false"]::before { transform: rotate(-135deg); margin: 0 .15rem 0 0; }
:root[data-sidebar="hidden"] .edge-left { left: 0; }
.edge-right { right: 0; border-right: 0; border-radius: 8px 0 0 8px; }
.edge-right::before { transform: rotate(-135deg); margin-right: .15rem; }
.edge-right[aria-expanded="false"]::before { transform: rotate(45deg); margin: 0 0 0 .15rem; }
@media (min-width: 1024px) { .edge-left { display: flex; } }
@media (min-width: 1200px) { .edge-right { display: flex; } }
:root[data-focus="on"] .edge-tab { display: none; }
@media print { .edge-tab { display: none !important; } }

/* ---------- Theme: teal accent, lighter weight (owner decision 2026-11-11) ----------
   Tokens at the top hold the colours. This block flattens the numbered section panels:
   a thin divider instead of a shadowed box, and an outlined number instead of a solid badge. */
.lesson-body > .lesson-section, .lesson-body > .completion, .content.cols > section, .content.cols #checkpoints > section { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; padding: .25rem 0 1.35rem; margin: 0 0 1.35rem; }
.lesson-body > .lesson-section > h2, .lesson-body > .lesson-section:first-child > h2, .lesson-body > .completion > h2, .content.cols > section > h2:first-child, .content.cols #checkpoints > section > h2:first-child { border-bottom: 0; padding-bottom: 0; margin-bottom: .75rem; }
.lesson-body > .lesson-section > h2::before, .lesson-body > .completion > h2::before, .content.cols > section > h2:first-child::before, .content.cols #checkpoints > section > h2:first-child::before { background: transparent; color: var(--accent); border: 1.5px solid var(--accent); }
.lesson-section .card, .content.cols .card { background: var(--surface); }
@media (max-width: 720px) {
  .lesson-body > .lesson-section, .lesson-body > .completion, .content.cols > section, .content.cols #checkpoints > section { padding: .2rem 0 1.1rem; border-radius: 0; }
}

/* ---------- Scrollbars: thin and quiet, from the theme tokens (page, sidebar, side panel, tables, code) ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.sidebar:hover, .lesson-rail:hover, .search-results:hover, .table-wrap:hover, pre:hover, .m-code:hover { scrollbar-color: var(--accent) transparent; }
.sidebar, .lesson-rail { scrollbar-gutter: stable; }
@supports not (scrollbar-color: auto) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
  ::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: content-box; }
}
