/* AP Physics 1 study: site styles (tokens, layout, header, components, print).
   Contract: common/ENGINE.md sections 1-3.
   Pages folded in from older work set <body data-shell="lite">: they keep their own styles, and only the
   site header / breadcrumbs / footer (classes .sw-*) are styled for them. Everything else below is scoped with
   :where(body:not([data-shell="lite"])), which adds no specificity, so page styles still win. */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel2: #eef2f8;
  --ink: #111827;
  --muted: #4b5563;
  --line: #d4dae4;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --link: #1d4ed8;
  --focus: #f59e0b;

  --x: #2563eb;   /* position */
  --v: #16a34a;   /* velocity */
  --a: #ea580c;   /* acceleration */
  --f: #7c3aed;   /* force */

  --ok: #15803d;  --okbg: #e7f6ec;
  --bad: #b91c1c; --badbg: #fdecec;
  --warn: #92400e; --warnbg: #fff6e0;
  --info: #1e40af; --infobg: #e8f0fe;

  --basic: #15803d;  --basicbg: #e3f5e8;
  --medium: #a16207; --mediumbg: #fdf3d7;
  --ap: #7c3aed;     --apbg: #efe8fd;

  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
  --maxw: 1100px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* header tokens (prefixed so folded-in pages with their own --bg / --ink keep a stable header) */
  --sw-bg: #ffffff;
  --sw-ink: #111827;
  --sw-muted: #4b5563;
  --sw-line: #d4dae4;
  --sw-accent: #1d4ed8;
  --sw-hover: #eef2f8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1320; --panel: #151d2c; --panel2: #1c2638; --ink: #eef2f8; --muted: #a9b4c6; --line: #2c3850;
    --accent: #6ea0ff; --accent-ink: #0b1220; --link: #8db5ff; --focus: #fbbf24;
    --x: #60a5fa; --v: #4ade80; --a: #fb923c; --f: #a78bfa;
    --ok: #4ade80; --okbg: #12301f; --bad: #f87171; --badbg: #3a1818;
    --warn: #fbbf24; --warnbg: #33270d; --info: #93c5fd; --infobg: #172742;
    --basic: #4ade80; --basicbg: #12301f; --medium: #fbbf24; --mediumbg: #33270d; --ap: #c4b5fd; --apbg: #2a1f4a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --sw-bg: #111827; --sw-ink: #eef2f8; --sw-muted: #a9b4c6; --sw-line: #2c3850; --sw-accent: #8db5ff; --sw-hover: #1c2638;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1320; --panel: #151d2c; --panel2: #1c2638; --ink: #eef2f8; --muted: #a9b4c6; --line: #2c3850;
  --accent: #6ea0ff; --accent-ink: #0b1220; --link: #8db5ff; --focus: #fbbf24;
  --x: #60a5fa; --v: #4ade80; --a: #fb923c; --f: #a78bfa;
  --ok: #4ade80; --okbg: #12301f; --bad: #f87171; --badbg: #3a1818;
  --warn: #fbbf24; --warnbg: #33270d; --info: #93c5fd; --infobg: #172742;
  --basic: #4ade80; --basicbg: #12301f; --medium: #fbbf24; --mediumbg: #33270d; --ap: #c4b5fd; --apbg: #2a1f4a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --sw-bg: #111827; --sw-ink: #eef2f8; --sw-muted: #a9b4c6; --sw-line: #2c3850; --sw-accent: #8db5ff; --sw-hover: #1c2638;
}

/* ---------- 2. Base (site pages only) ---------- */
:where(body:not([data-shell="lite"])) {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.6 var(--font);
  -webkit-text-size-adjust: 100%;
  overflow-wrap: break-word;
}
:where(body:not([data-shell="lite"])) *,
:where(body:not([data-shell="lite"])) *::before,
:where(body:not([data-shell="lite"])) *::after { box-sizing: border-box; }
:where(body:not([data-shell="lite"])) main {
  display: block;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px var(--gutter) 40px;
}
:where(body:not([data-shell="lite"])) :is(h1, h2, h3, h4) { line-height: 1.25; margin: 1.4em 0 .5em; }
:where(body:not([data-shell="lite"])) h1 { font-size: 2rem; margin-top: .6em; }
:where(body:not([data-shell="lite"])) h2 { font-size: 1.5rem; }
:where(body:not([data-shell="lite"])) h3 { font-size: 1.2rem; }
:where(body:not([data-shell="lite"])) p { margin: .6em 0; }
:where(body:not([data-shell="lite"])) a { color: var(--link); text-underline-offset: 2px; }
:where(body:not([data-shell="lite"])) img,
:where(body:not([data-shell="lite"])) svg,
:where(body:not([data-shell="lite"])) canvas,
:where(body:not([data-shell="lite"])) video { max-width: 100%; }
:where(body:not([data-shell="lite"])) img { height: auto; }
:where(body:not([data-shell="lite"])) code { font-family: var(--mono); font-size: .9em; background: var(--panel2); padding: 1px 5px; border-radius: 5px; }
:where(body:not([data-shell="lite"])) table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
:where(body:not([data-shell="lite"])) :is(th, td) { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
:where(body:not([data-shell="lite"])) th { background: var(--panel2); }
:where(body:not([data-shell="lite"])) .lead { font-size: 1.12rem; color: var(--muted); max-width: 60rem; }
:where(body:not([data-shell="lite"])) .muted { color: var(--muted); }

/* big, friendly controls */
:where(body:not([data-shell="lite"])) :is(button, .btn, select, input[type="number"], input[type="text"]) {
  min-height: 44px;
  font: inherit;
  font-size: 1rem;
}
:where(body:not([data-shell="lite"])) :is(button, .btn) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
:where(body:not([data-shell="lite"])) :is(button, .btn):hover { background: var(--panel2); }
:where(body:not([data-shell="lite"])) .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
:where(body:not([data-shell="lite"])) input[type="range"] { min-height: 44px; width: 100%; accent-color: var(--accent); }
:where(body:not([data-shell="lite"])) input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--accent); }
:where(body:not([data-shell="lite"])) :is(input[type="number"], input[type="text"], select) {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink);
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- 3. Layout helpers ---------- */
:where(body:not([data-shell="lite"])) .grid2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 900px) {
  :where(body:not([data-shell="lite"])) .grid2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
:where(body:not([data-shell="lite"])) .cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 640px) { :where(body:not([data-shell="lite"])) .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { :where(body:not([data-shell="lite"])) .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
:where(body:not([data-shell="lite"])) .card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  min-width: 0;
}
:where(body:not([data-shell="lite"])) .card > :first-child { margin-top: 0; }
:where(body:not([data-shell="lite"])) .card h2, :where(body:not([data-shell="lite"])) .card h3 { margin: 0 0 .4em; }

/* ---------- 4. Topic page sections (ENGINE.md section 2) ---------- */
:where(body:not([data-shell="lite"])) :is(.story, .idea, .lab, .examples, .practice, .mistakes) {
  margin: 28px 0;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
:where(body:not([data-shell="lite"])) :is(.story, .idea, .lab, .examples, .practice, .mistakes) > h2:first-child { margin-top: 0; }
@media (max-width: 599px) {
  :where(body:not([data-shell="lite"])) :is(.story, .idea, .lab, .examples, .practice, .mistakes) { padding: 14px 12px; }
}
/* small section label above each section heading */
:where(body:not([data-shell="lite"])) :is(.story, .idea, .lab, .examples, .practice, .mistakes)::before {
  display: block; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px;
}
:where(body:not([data-shell="lite"])) .story::before { content: "1 · Story"; }
:where(body:not([data-shell="lite"])) .idea::before { content: "2 · The idea"; }
:where(body:not([data-shell="lite"])) .lab::before { content: "3 · Play"; }
:where(body:not([data-shell="lite"])) .examples::before { content: "4 · Worked examples"; }
:where(body:not([data-shell="lite"])) .practice::before { content: "5 · Practice"; }
:where(body:not([data-shell="lite"])) .mistakes::before { content: "6 · Common mistakes"; }

:where(body:not([data-shell="lite"])) .story { border-left: 6px solid var(--x); font-size: 1.05rem; }
:where(body:not([data-shell="lite"])) .idea { border-left: 6px solid var(--accent); }
:where(body:not([data-shell="lite"])) .lab { border-left: 6px solid var(--v); }
:where(body:not([data-shell="lite"])) .examples { border-left: 6px solid var(--a); }
:where(body:not([data-shell="lite"])) .practice { border-left: 6px solid var(--f); }
:where(body:not([data-shell="lite"])) .mistakes { border-left: 6px solid var(--bad); }

/* worked steps */
:where(body:not([data-shell="lite"])) .worked {
  margin: 16px 0; padding: 14px 16px; background: var(--panel2); border-radius: 10px; border: 1px dashed var(--line);
}
:where(body:not([data-shell="lite"])) .worked > :first-child { margin-top: 0; }
:where(body:not([data-shell="lite"])) ol.steps { counter-reset: step; list-style: none; padding: 0; margin: 12px 0; }
:where(body:not([data-shell="lite"])) ol.steps > li {
  counter-increment: step; position: relative; padding: 8px 0 10px 48px; border-bottom: 1px solid var(--line);
}
:where(body:not([data-shell="lite"])) ol.steps > li:last-child { border-bottom: 0; }
:where(body:not([data-shell="lite"])) ol.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 6px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; background: var(--accent); color: var(--accent-ink);
}
:where(body:not([data-shell="lite"])) span.why {
  display: block; margin-top: 4px; color: var(--muted); font-size: .95rem; font-style: italic;
}
:where(body:not([data-shell="lite"])) span.why::before { content: "Why: "; font-weight: 700; font-style: normal; }

/* sim container (the engine fills it; engine.css styles the inside) */
:where(body:not([data-shell="lite"])) .sim {
  margin: 16px 0; min-height: 120px; min-width: 0; max-width: 100%;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); padding: 10px;
}

/* worked examples */
:where(body:not([data-shell="lite"])) .example {
  margin: 16px 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
:where(body:not([data-shell="lite"])) .example > h3:first-child { margin-top: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
:where(body:not([data-shell="lite"])) span.level {
  display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor; vertical-align: middle;
}
:where(body:not([data-shell="lite"])) span.level.basic { color: var(--basic); background: var(--basicbg); }
:where(body:not([data-shell="lite"])) span.level.medium { color: var(--medium); background: var(--mediumbg); }
:where(body:not([data-shell="lite"])) span.level.ap { color: var(--ap); background: var(--apbg); }

/* reveals: details.solution / details.answer */
:where(body:not([data-shell="lite"])) details:is(.solution, .answer) {
  margin: 12px 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
:where(body:not([data-shell="lite"])) details:is(.solution, .answer) > summary {
  min-height: 44px; display: flex; align-items: center; gap: 8px; padding: 8px 14px; cursor: pointer;
  font-weight: 600; color: var(--link); list-style: none; border-radius: 10px;
}
:where(body:not([data-shell="lite"])) details:is(.solution, .answer) > summary::-webkit-details-marker { display: none; }
:where(body:not([data-shell="lite"])) details:is(.solution, .answer) > summary::before {
  content: "▸"; display: inline-block; transition: transform .15s; font-size: .9em;
}
:where(body:not([data-shell="lite"])) details:is(.solution, .answer)[open] > summary::before { transform: rotate(90deg); }
:where(body:not([data-shell="lite"])) details:is(.solution, .answer)[open] > summary { border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
:where(body:not([data-shell="lite"])) details:is(.solution, .answer) > :not(summary) { margin-left: 14px; margin-right: 14px; }
:where(body:not([data-shell="lite"])) details:is(.solution, .answer) > :last-child:not(summary) { margin-bottom: 14px; }

/* practice */
:where(body:not([data-shell="lite"])) .practice > ol { padding-left: 1.4em; }
:where(body:not([data-shell="lite"])) .practice > ol > li { margin: 18px 0; padding-left: 4px; }
:where(body:not([data-shell="lite"])) .mcq { margin: 12px 0; }
:where(body:not([data-shell="lite"])) .mcq .choices { display: grid; gap: 8px; }
:where(body:not([data-shell="lite"])) .mcq button.choice {
  display: flex; width: 100%; justify-content: flex-start; text-align: left; margin: 6px 0;
  min-height: 48px; padding: 10px 14px; border: 2px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--ink);
  font-weight: 500; line-height: 1.4;
}
:where(body:not([data-shell="lite"])) .mcq button.choice:hover:not(:disabled) { border-color: var(--accent); }
:where(body:not([data-shell="lite"])) .mcq button.choice.right { border-color: var(--ok); background: var(--okbg); color: var(--ink); }
:where(body:not([data-shell="lite"])) .mcq button.choice.right::after { content: "✓ correct"; margin-left: auto; padding-left: 12px; color: var(--ok); font-weight: 700; white-space: nowrap; }
:where(body:not([data-shell="lite"])) .mcq button.choice.wrong { border-color: var(--bad); background: var(--badbg); color: var(--ink); }
:where(body:not([data-shell="lite"])) .mcq button.choice.wrong::after { content: "✗ not this one"; margin-left: auto; padding-left: 12px; color: var(--bad); font-weight: 700; white-space: nowrap; }
:where(body:not([data-shell="lite"])) .mcq button.choice:disabled { cursor: default; opacity: 1; }
:where(body:not([data-shell="lite"])) .mcq.done button.choice:not(.right):not(.wrong) { opacity: .6; }
:where(body:not([data-shell="lite"])) .mcq .mcq-feedback { margin: 8px 0 0; padding: 10px 14px; border-radius: 10px; }
:where(body:not([data-shell="lite"])) .mcq .mcq-feedback:empty { display: none; }
:where(body:not([data-shell="lite"])) .mcq .mcq-feedback.ok { background: var(--okbg); border: 1px solid var(--ok); }
:where(body:not([data-shell="lite"])) .mcq .mcq-feedback.bad { background: var(--badbg); border: 1px solid var(--bad); }

/* common mistakes */
:where(body:not([data-shell="lite"])) .mistake {
  margin: 14px 0; padding: 12px 16px; border-radius: 10px; background: var(--badbg); border-left: 5px solid var(--bad);
}
:where(body:not([data-shell="lite"])) .mistake > :first-child { margin-top: 0; }
:where(body:not([data-shell="lite"])) .mistake > :last-child { margin-bottom: 0; }

/* callouts */
:where(body:not([data-shell="lite"])) :is(.callout, .note) {
  margin: 16px 0; padding: 12px 16px; border-radius: 10px;
}
:where(body:not([data-shell="lite"])) .callout { background: var(--infobg); border-left: 5px solid var(--info); }
:where(body:not([data-shell="lite"])) .note { background: var(--warnbg); border-left: 5px solid var(--warn); }
:where(body:not([data-shell="lite"])) :is(.callout, .note) > :first-child { margin-top: 0; }
:where(body:not([data-shell="lite"])) :is(.callout, .note) > :last-child { margin-bottom: 0; }

/* colour key: <div class="key"><span class="x">position</span><span class="v">velocity</span>... */
:where(body:not([data-shell="lite"])) .key { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 10px 0; font-size: .95rem; }
:where(body:not([data-shell="lite"])) .key > span { display: inline-flex; align-items: center; gap: 6px; }
:where(body:not([data-shell="lite"])) .key > span::before { content: ""; width: 22px; height: 5px; border-radius: 3px; background: currentColor; }
:where(body:not([data-shell="lite"])) span.x { color: var(--x); }
:where(body:not([data-shell="lite"])) span.v { color: var(--v); }
:where(body:not([data-shell="lite"])) span.a { color: var(--a); }
:where(body:not([data-shell="lite"])) span.f { color: var(--f); }

/* centred maths line */
:where(body:not([data-shell="lite"])) .formula {
  display: block; text-align: center; margin: 14px auto; padding: 10px 14px; max-width: 100%; overflow-x: auto;
  font-family: "Cambria Math", "STIX Two Math", Georgia, serif; font-size: 1.25rem; background: var(--panel2); border-radius: 10px;
}

/* small label */
:where(body:not([data-shell="lite"])) .tag {
  display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 10px; margin: 2px 4px 2px 0;
  border-radius: 999px; background: var(--panel2); color: var(--muted); border: 1px solid var(--line);
}

/* ---------- 5. Site chrome: header, menu, breadcrumbs, footer (all pages, incl. folded-in ones) ---------- */
.sw-top {
  position: sticky; top: 0; z-index: 1000;
  background: var(--sw-bg); color: var(--sw-ink);
  border-bottom: 1px solid var(--sw-line);
  font: 16px/1.4 var(--font);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
.sw-top *, .sw-crumbs *, .sw-foot *, .sw-crumbs, .sw-foot { box-sizing: border-box; }
.sw-top .sw-bar {
  max-width: var(--maxw); margin: 0 auto; padding: 6px var(--gutter);
  display: flex; align-items: center; gap: 10px; min-height: 56px;
}
.sw-top a.sw-title {
  font-weight: 800; font-size: 1.05rem; color: var(--sw-ink); text-decoration: none; margin-right: auto;
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; white-space: nowrap;
}
.sw-top .sw-logo { width: 26px; height: 26px; flex: none; }
.sw-top nav.sw-quick { display: none; gap: 2px; }
@media (min-width: 900px) { .sw-top nav.sw-quick { display: flex; } }
.sw-top nav.sw-quick a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 8px;
  color: var(--sw-ink); text-decoration: none; font-size: .95rem; background: none; border: 0;
}
.sw-top nav.sw-quick a:hover { background: var(--sw-hover); }
.sw-top nav.sw-quick a[aria-current="page"], .sw-top nav.sw-quick a.sw-here { color: var(--sw-accent); font-weight: 700; }
.sw-top button.sw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; padding: 0 12px; margin: 0;
  font: 600 15px/1 var(--font); color: var(--sw-ink); background: var(--sw-bg);
  border: 1px solid var(--sw-line); border-radius: 10px; cursor: pointer; box-shadow: none; width: auto; height: auto;
  text-transform: none; letter-spacing: normal;
}
.sw-top button.sw-btn:hover { background: var(--sw-hover); }
.sw-top button.sw-btn svg { width: 20px; height: 20px; }

.sw-menu {
  max-width: var(--maxw); margin: 0 auto; padding: 8px var(--gutter) 16px;
  max-height: calc(100vh - 64px); overflow-y: auto; border-top: 1px solid var(--sw-line);
}
.sw-menu[hidden] { display: none; }
.sw-menu .sw-menu-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px 24px; }
@media (min-width: 700px) { .sw-menu .sw-menu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .sw-menu .sw-menu-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sw-menu h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--sw-muted); margin: 12px 0 2px; font-weight: 700; }
.sw-menu ul { list-style: none; margin: 0; padding: 0; }
.sw-menu a {
  display: flex; align-items: center; min-height: 40px; padding: 4px 8px; border-radius: 8px;
  color: var(--sw-ink); text-decoration: none; font-size: .95rem;
}
.sw-menu a:hover { background: var(--sw-hover); }
.sw-menu a[aria-current="page"] { color: var(--sw-accent); font-weight: 700; }
.sw-menu a.sw-unit-link { font-weight: 700; }

.sw-crumbs {
  max-width: var(--maxw); margin: 0 auto; padding: 10px var(--gutter) 0;
  font: 15px/1.5 var(--font); color: var(--sw-muted);
}
.sw-crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 2px 0; }
.sw-crumbs li { display: inline-flex; align-items: center; min-width: 0; }
.sw-crumbs li + li::before { content: "›"; margin: 0 8px; color: var(--sw-muted); }
.sw-crumbs a { color: var(--sw-accent); text-decoration: none; padding: 6px 0; display: inline-block; }
.sw-crumbs a:hover { text-decoration: underline; }
.sw-crumbs [aria-current="page"] { color: var(--sw-ink); }

.sw-foot {
  max-width: var(--maxw); margin: 24px auto 0; padding: 0 var(--gutter) 32px;
  font: 16px/1.5 var(--font); color: var(--sw-ink);
}
.sw-foot .sw-done {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin: 0 0 16px; border: 1px solid var(--sw-line); border-radius: 12px; background: var(--sw-bg);
}
.sw-foot .sw-done label { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 600; }
.sw-foot .sw-done input { width: 26px; height: 26px; margin: 0; accent-color: var(--sw-accent); cursor: pointer; }
.sw-foot .sw-done .sw-done-msg { color: var(--sw-muted); font-size: .95rem; }
.sw-foot .sw-pn { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
@media (min-width: 640px) { .sw-foot .sw-pn { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.sw-foot .sw-pn a {
  display: flex; flex-direction: column; justify-content: center; min-height: 56px; padding: 10px 16px;
  border: 1px solid var(--sw-line); border-radius: 12px; background: var(--sw-bg); color: var(--sw-ink); text-decoration: none;
}
.sw-foot .sw-pn a:hover { border-color: var(--sw-accent); }
.sw-foot .sw-pn a small { color: var(--sw-muted); font-size: .85rem; }
.sw-foot .sw-pn a span { color: var(--sw-accent); font-weight: 700; }
.sw-foot .sw-pn a.sw-next { text-align: right; grid-column: -2; }
.sw-foot .sw-note { margin: 18px 0 0; font-size: .85rem; color: var(--sw-muted); text-align: center; }
.sw-foot .sw-note a { color: var(--sw-accent); }

/* unit cards and topic lists generated by site.js */
.sw-units { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin: 16px 0; }
@media (min-width: 700px) { .sw-units { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .sw-units { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sw-unit {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0;
}
.sw-unit h3 { margin: 0 0 4px; font-size: 1.15rem; }
.sw-unit h3 a { color: var(--ink); text-decoration: none; }
.sw-unit h3 a:hover { color: var(--link); text-decoration: underline; }
.sw-unit .sw-unit-n { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sw-meter { height: 8px; border-radius: 999px; background: var(--panel2); overflow: hidden; margin: 8px 0 4px; border: 1px solid var(--line); }
.sw-meter > i { display: block; height: 100%; background: var(--v); width: 0; }
.sw-meter-text { font-size: .85rem; color: var(--muted); margin: 0 0 8px; }
.sw-topics { list-style: none; margin: 4px 0 0; padding: 0; }
.sw-topics li { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; }
.sw-topics li a { color: var(--link); text-decoration: none; padding: 4px 0; display: inline-block; }
.sw-topics li a:hover { text-decoration: underline; }
.sw-topics .sw-check { flex: none; width: 1.2em; text-align: center; color: var(--muted); font-weight: 700; }
.sw-topics li.sw-is-done .sw-check { color: var(--ok); }
.sw-topics li.sw-extra { font-size: .95rem; }
.sw-topics li.sw-extra .sw-check { color: var(--muted); }
.sw-topic-list { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.sw-topic-list li {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; align-items: start;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.sw-topic-list .sw-num {
  grid-row: span 2; width: 52px; height: 52px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; background: var(--panel2); color: var(--ink);
}
.sw-topic-list li.sw-is-done .sw-num { background: var(--okbg); color: var(--ok); }
.sw-topic-list a { font-weight: 700; font-size: 1.08rem; color: var(--link); text-decoration: none; }
.sw-topic-list a:hover { text-decoration: underline; }
.sw-topic-list p { margin: 0; color: var(--muted); font-size: .98rem; }

/* ---------- 6. Print ---------- */
@media print {
  .sw-top, .sw-menu, .sw-foot .sw-pn, .sw-foot .sw-done, .sw-crumbs { display: none !important; }
  :where(body:not([data-shell="lite"])) { background: #fff; color: #000; font-size: 12pt; }
  :where(body:not([data-shell="lite"])) main { max-width: none; padding: 0; }
  :where(body:not([data-shell="lite"])) :is(.story, .idea, .lab, .examples, .practice, .mistakes, .example, .worked, .card) {
    box-shadow: none; background: #fff; break-inside: avoid-page;
  }
  :where(body:not([data-shell="lite"])) .sim { break-inside: avoid; }
  :where(body:not([data-shell="lite"])) a { color: #000; }
  /* answers stay hidden when printing: closed details print only their summary, which we hide too */
  :where(body:not([data-shell="lite"])) details:is(.solution, .answer):not([open]) > summary { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* the button display rules must not override the hidden attribute */
[hidden] { display: none !important; }

/* ---------- self pacing (common/pace.js) ---------- */
.pace-pre { border: 2px dashed var(--accent); border-radius: var(--radius); padding: 12px 16px; margin: 16px 0; }
.pace-pre > h2 { margin-top: 0; }
.pace-out:empty { display: none; }
.pace-good { color: var(--ok, #15803d); font-weight: 600; }
.pace-note { color: var(--muted); }
.pace-mini { border-left: 6px solid var(--accent); background: var(--panel2); border-radius: var(--radius); padding: 10px 14px; margin: 16px 0; }
.pace-mini::before { content: "Quick check"; display: block; font-weight: 700; color: var(--accent); margin-bottom: 4px; }
.pace-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pace-btn { min-height: 44px; padding: 8px 14px; border-radius: 10px; border: 1.5px solid var(--accent); background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; }
.pace-btn.pace-go, .pace-btn.pace-skip { background: var(--accent); color: #fff; }
.pace-btn:disabled { opacity: .55; cursor: default; }
.pace-extra { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0 16px; }
.pace-extra::before { content: "Another example"; display: block; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.pace-badge { display: inline-block; font-size: .78em; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; vertical-align: middle; white-space: nowrap; }
.pace-badge.pace-mastered { color: var(--ok, #15803d); }
.pace-badge.pace-known { color: var(--accent); }
.pace-badge.pace-started { color: var(--muted); }

/* auto voice switch (header) */
.sw-voice[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }
@media (max-width: 520px) { .sw-voice .sw-voice-text { font-size: 0.85em; } }
