/* ==========================================================================
   getibphysics — stylesheet
   1. Design tokens        6. Study guides
   2. Base                 7. Question bank
   3. Components           8. Flashcards
   4. Site chrome          9. Data booklet
   5. Layout              10. Dialog · Responsive · Motion · Print
   ========================================================================== */


/* ==========================================================================
   1. Design tokens
   ========================================================================== */

/* Bundled font (SIL OFL, licence in vendor/fonts-ui). Latin subset, variable weight 100–900. */
@font-face {
  font-family: "Inter UI";
  src: url("vendor/fonts-ui/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* Typography — one family, light weights. System stack is the offline fallback. */
  --font-sans: "Inter UI", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Consolas, monospace;

  /* Surfaces and text */
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --ink: #0d0d0d;
  --ink-2: #333333;
  --muted: #6e6e6e;
  --line: #e2e2e2;
  --line-strong: #a3a3a3;

  /* Brand — monochrome with a single cobalt accent */
  --accent: #1f3df5;
  --accent-strong: #1530c8;
  --accent-text: #1f3df5;
  --accent-soft: #eceffe;
  --accent-2: #0d0d0d;
  --on-accent: #ffffff;

  /* Feedback */
  --right: #17803a;
  --right-soft: #e8f4ec;
  --wrong: #c8271c;
  --wrong-soft: #fbeae8;

  --backdrop: rgb(13 13 13 / .55);

  /* Scale */
  --max-width: 1280px;
  --gutter: clamp(16px, 4vw, 40px);
  --header-h: 65px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --ink: #f0f0f0;
  --ink-2: #c6c6c6;
  --muted: #8e8e8e;
  --line: #262626;
  --line-strong: #4d4d4d;

  --accent: #8b9cff;
  --accent-strong: #aab6ff;
  --accent-text: #8b9cff;
  --accent-soft: #151a38;
  --accent-2: #f0f0f0;
  --on-accent: #0a0a0a;

  --right: #4cc072;
  --right-soft: #0f2618;
  --wrong: #ff6d60;
  --wrong-soft: #2b1210;

  --backdrop: rgb(0 0 0 / .7);
}

[data-key] { --tc: var(--ink); }


/* ==========================================================================
   2. Base
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 400 16px/1.6 var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app { flex: 1; }

h1, h2, h3, h4 { margin: 0; line-height: 1.15; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
ul { margin: 0; padding: 0; list-style: none; }
img, svg { max-width: 100%; }
a { color: inherit; text-decoration: none; }
strong { font-weight: 500; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; text-align: inherit; }
button:disabled { cursor: not-allowed; }
summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
[id] { scroll-margin-top: calc(var(--header-h) + 16px); }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

kbd {
  font: 400 12px var(--font-mono);
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
}

.muted { color: var(--muted); }
.tiny { font-size: 12px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 10px 16px;
  color: var(--on-accent);
  background: var(--accent);
  font-weight: 500;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.noscript {
  margin: 24px var(--gutter);
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.noscript a { color: var(--accent-text); text-decoration: underline; }


/* ==========================================================================
   3. Components
   ========================================================================== */

/* Small uppercase label used above headings and for panel titles */
.eyebrow,
.panel-title,
.side-label,
.filter-label,
.aside-label,
.count-label {
  font: 500 12px/1.3 var(--font-sans);
  letter-spacing: .09em;
  text-transform: uppercase;
}

.eyebrow,
.panel-title { color: var(--accent-text); }
.side-label,
.filter-label,
.aside-label,
.count-label { color: var(--muted); }

.lede {
  max-width: 60ch;
  font-size: clamp(1.0625rem, 1rem + .3vw, 1.25rem);
  line-height: 1.55;
  color: var(--ink-2);
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  transition: background .2s, border-color .2s, color .2s;
}
.button:hover:not(:disabled) { color: var(--bg); background: var(--ink); }
.button:disabled { opacity: .4; }
.button.small { min-height: 38px; padding: 0 14px; font-size: 13px; }
.button.primary {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
.button.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }

.text-button {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-text);
  text-underline-offset: 3px;
}
.text-button:hover:not(:disabled) { text-decoration: underline; }
.text-button:disabled { opacity: .45; }
.text-button.danger { color: var(--wrong); }

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  border: 1px solid var(--line);
  transition: color .2s, border-color .2s;
}
.icon-button:hover { color: var(--ink); border-color: var(--line-strong); }

/* Tags */
.tag {
  display: inline-block;
  align-self: start;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--ink-2);
  background: var(--surface-2);
}
.tag-hl {
  color: var(--accent-text);
  background: var(--accent-soft);
}

/* Progress */
.progress-track {
  height: 6px;
  overflow: hidden;
  background: var(--line);
}
.progress-fill {
  height: 100%;
  min-width: 0;
  background: var(--accent);
  transition: width .4s var(--ease);
}

/* Form fields */
.filter-field {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

input[type="search"],
select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--ink);
  background-color: var(--bg);
  border: 1px solid var(--line-strong);
  transition: border-color .2s;
}
input[type="search"]::placeholder { color: var(--muted); opacity: .8; }
input[type="search"]:hover,
select:hover { border-color: var(--muted); }
input[type="search"]:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  outline: 1px solid var(--accent);
  outline-offset: -2px;
}
select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%238a9099' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  text-overflow: ellipsis;
}
/* Range slider: hairline track, square thumb */
input[type="range"] { width: 100%; height: 20px; margin: 0; background: transparent; appearance: none; -webkit-appearance: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--ink); }
input[type="range"]::-moz-range-track { height: 1px; background: var(--ink); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -7px; background: var(--accent); border: 0; border-radius: 0; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; background: var(--accent); border: 0; border-radius: 0; }

/* Tables */
.table-wrap {
  position: relative; /* contains any absolutely positioned descendants so they cannot widen the page */
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
}
table { width: 100%; border-collapse: collapse; }
th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}
td { padding: 14px 16px; vertical-align: top; border-top: 1px solid var(--line); }

/* Empty state */
.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 56px 24px;
  text-align: center;
  border: 1px dashed var(--line-strong);
}
.empty-state h2 { font: 300 1.5rem/1.2 var(--font-sans); }
.empty-state p { max-width: 44ch; color: var(--muted); }
.empty-state .button { margin-top: 10px; }

/* Maths */
.katex { font-size: 1.08em; }
.katex-display { margin: 1em 0; padding: 4px 0; overflow-x: auto; overflow-y: hidden; }
.katex-display > .katex { white-space: nowrap; }
.math-error { font-family: var(--font-mono); font-size: .9em; color: var(--wrong); }

@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.screen-enter { animation: enter .35s var(--ease) both; }
.question-card.screen-enter { animation: none; }


/* ==========================================================================
   4. Site chrome — header, footer
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  max-width: var(--max-width);
  height: 64px;
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: none;
  color: var(--ink);
}
.brand img { display: block; width: 207px; height: auto; }
:root[data-theme="dark"] .brand img { filter: invert(1); }

.primary-nav {
  display: flex;
  gap: 4px;
}
.primary-nav a {
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 400;
  color: var(--ink-2);
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.primary-nav a:hover { color: var(--ink); background: var(--surface-2); }
.primary-nav a[aria-current="page"] {
  color: var(--accent-text);
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.theme-toggle,
.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  border: 1px solid var(--line-strong);
  transition: color .2s, border-color .2s, background .2s;
}
.theme-toggle { padding: 0 14px 0 12px; }
.help-button { width: 38px; }
.theme-toggle:hover,
.help-button:hover { color: var(--ink); border-color: var(--ink); background: var(--surface); }

/* Sun / moon drawn in CSS so the icon follows the active theme. */
.theme-icon {
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] .theme-icon {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4' fill='black'/%3E%3Cpath d='M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E");
}

.site-footer {
  margin-top: 80px;
  border-top: 1px solid var(--line);
}
.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px var(--gutter);
  font-size: 13px;
  color: var(--muted);
}
.footer-brand { font-weight: 500; color: var(--ink-2); }
.footer-dot { margin: 0 4px; color: var(--line-strong); }
.save-status { display: inline-flex; align-items: center; gap: 8px; }
.save-status::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--right);
}
.save-status.storage-error { color: var(--wrong); }
.save-status.storage-error::before { background: var(--wrong); }
.site-footer .text-button { color: var(--muted); font-size: 13px; }
.site-footer .text-button:hover { color: var(--ink); }


/* ==========================================================================
   5. Layout — page shell, workspace, sidebar
   ========================================================================== */

.page-shell {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.workspace {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  gap: clamp(32px, 4vw, 56px);
  align-items: start;
  padding-top: 40px;
}
.workspace-content { min-width: 0; padding-bottom: 24px; }
.workspace-content:focus { outline: none; }

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.sidebar-heading h2 { font: 500 15px/1.3 var(--font-sans); }

.filter-summary { font-size: 13px; line-height: 1.55; color: var(--muted); }
.filter-divider {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.filter-divider .eyebrow { margin-bottom: 12px; }
.stat-list {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--ink-2);
}
.stat-list strong { color: var(--ink); font-variant-numeric: tabular-nums; }

.sidebar-links { display: grid; justify-items: start; gap: 12px; }

/* Mobile filter drawer toggle (hidden on desktop) */
.mobile-filters { display: none; }


/* ==========================================================================
   6. Study guides
   ========================================================================== */

/* ---- Overview ---- */

.overview { padding-bottom: 24px; }

.page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 40px;
  align-items: end;
  padding: clamp(40px, 7vw, 88px) 0 clamp(32px, 5vw, 56px);
}
.page-heading-text { display: grid; gap: 18px; }
.page-heading h1,
.tool-heading h1,
.lesson-header h1 {
  font-family: var(--font-sans);
  font-weight: 250;
  letter-spacing: -.035em;
}
.page-heading h1 { font-size: clamp(2.5rem, 1.5rem + 4.5vw, 4.5rem); line-height: 1; }

.heading-aside {
  display: grid;
  gap: 10px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.big-number {
  font: 200 clamp(2.5rem, 2rem + 2vw, 3.25rem)/1 var(--font-sans);
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.big-number .muted { font-size: .5em; letter-spacing: 0; }
.heading-aside .progress-track { margin-top: 6px; }

.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: clamp(32px, 4vw, 56px);
  align-items: start;
}

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  margin-bottom: 20px;
}
.section-heading h2 { font: 300 1.75rem/1.2 var(--font-sans); letter-spacing: -.015em; }
.section-heading .muted { font-size: 13px; }

/* Theme groups (accordion cards) */
.theme-group {
  margin-bottom: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color .2s;
}
.theme-group[open] { border-color: var(--line-strong); }

.theme-group > summary {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto 20px;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
}
.theme-group > summary:hover .theme-title { color: var(--accent-text); }

.theme-letter {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  font: 300 1.375rem/1 var(--font-sans);
  color: var(--tc);
  border: 1px solid var(--line-strong);
}
.theme-title { font-size: 1.0625rem; font-weight: 500; line-height: 1.3; transition: color .2s; }
.theme-count { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Chevron shared by accordions */
.expand-mark {
  width: 8px;
  height: 8px;
  margin: 0 4px 2px 0;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .25s var(--ease);
}
.theme-group[open] .expand-mark { transform: rotate(-135deg) translate(-2px, -2px); }

.topic-list { display: grid; }

.topic-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto 64px 20px;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  transition: background .15s;
}
.topic-row:hover { background: var(--surface-2); }
.topic-row:hover .row-arrow { color: var(--accent-text); transform: translateX(3px); }

.topic-code {
  font: 400 13px var(--font-mono);
  color: var(--muted);
}
.topic-name { font-weight: 400; line-height: 1.35; }
.duration { font-size: 13px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.row-arrow { color: var(--muted); text-align: right; transition: transform .2s var(--ease), color .2s; }

/* Side column */
.overview-side { display: flex; flex-direction: column; gap: 12px; }
.overview-side .side-label { order: -2; margin-bottom: 4px; }
.side-link-primary { order: -1; }

.side-link {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 18px 56px 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color .2s, transform .2s var(--ease);
}
.side-link strong { font-size: 15px; }
.side-link span:not(.arrow) { font-size: 13px; color: var(--muted); }
.side-link .arrow {
  position: absolute;
  top: 50%;
  right: 20px;
  font-size: 18px;
  color: var(--accent-text);
  transform: translateY(-50%);
  transition: transform .2s var(--ease);
}
.side-link:hover { border-color: var(--accent); }
.side-link:hover .arrow { transform: translate(4px, -50%); }

.side-link-primary {
  background: var(--accent);
  border-color: var(--accent);
}
.side-link-primary strong,
.side-link-primary .arrow { color: var(--on-accent); }
.side-link-primary span:not(.arrow) { color: color-mix(in srgb, var(--on-accent) 82%, transparent); }
.side-link-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.diagram-art {
  margin: 4px 0;
  padding: 16px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.diagram-art svg { display: block; width: 100%; height: auto; }
.diagram-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.diagram-caption span:first-child { letter-spacing: .06em; text-transform: uppercase; font-weight: 500; }
.diagram-caption span:last-child { font-family: var(--font-sans); font-style: italic; }

/* ---- Lesson sidebar ---- */

.sidebar-theme { border-top: 1px solid var(--line); }
.sidebar-theme:first-of-type { border-top: 0; }
.sidebar-theme > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
}
.sidebar-theme .theme-letter { width: 28px; height: 28px; font-size: 1rem; flex: none; }
.sidebar-theme .topic-list { gap: 2px; padding-bottom: 10px; }

.sidebar-topic {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink-2);
  transition: background .15s, color .15s;
}
.sidebar-topic:hover { color: var(--ink); background: var(--surface-2); }
.sidebar-topic.active { color: var(--accent-text); background: var(--accent-soft); font-weight: 500; }
.sidebar-topic .topic-code { font-size: 12px; }
.sidebar-topic .done { color: var(--right); font-weight: 500; }
.lesson-sidebar .filter-summary { margin-top: 8px; }

/* ---- Lesson ---- */

.lesson-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.lesson-header {
  display: grid;
  justify-items: start;
  gap: 16px;
  max-width: 760px;
  padding-bottom: 40px;
  border-bottom: 1px solid var(--line);
}
.lesson-header h1 { font-size: clamp(2.25rem, 1.5rem + 3.4vw, 3.75rem); line-height: 1.04; }

.lesson-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: clamp(32px, 5vw, 64px);
  align-items: start;
}
.lesson-article { min-width: 0; max-width: 740px; }

.lesson-section { padding-top: 44px; }
.lesson-section h2,
.worked-example h2 {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 16px;
  font: 300 clamp(1.5rem, 1.3rem + .8vw, 1.875rem)/1.2 var(--font-sans);
  letter-spacing: -.015em;
}
.section-number {
  flex: none;
  padding: 3px 9px;
  font: 400 12px/1.4 var(--font-mono);
  letter-spacing: 0;
  color: var(--accent-text);
  background: var(--accent-soft);
  transform: translateY(-3px);
}

.prose,
.solution {
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  font-weight: 350;
  line-height: 1.75;
}
.prose p + p { margin-top: 1.1em; }
.prose ul { margin: 1em 0; padding-left: 1.3em; list-style: disc; }
.prose li + li { margin-top: .4em; }

.equation-panel,
.interactive-plot {
  margin-top: 44px;
  padding: clamp(20px, 4vw, 32px);
  background: var(--surface);
  border: 1px solid var(--line);
}
.panel-title { margin-bottom: 8px; }
.equation-item { padding: 16px 0; border-top: 1px solid var(--line); }
.equation-item:first-of-type { border-top: 0; }
.equation-item .katex-display { margin: .4em 0 .6em; }
.equation-item .katex { font-size: 1.2em; }
.equation-note { font-size: 14px; line-height: 1.6; color: var(--muted); }
.equation-panel .text-button { margin-top: 12px; }

.worked-example {
  margin-top: 44px;
  padding: clamp(20px, 4vw, 32px);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-left: 4px solid var(--accent);
}
.worked-question { font-size: 1.0625rem; font-weight: 350; line-height: 1.7; }
.worked-example details { margin-top: 20px; }
.worked-example summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent-text);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  transition: background .2s;
}
.worked-example summary:hover { background: var(--accent-soft); }
.worked-example summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-bottom: 3px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform .2s;
}
.worked-example details[open] summary::after { margin-bottom: -2px; transform: rotate(-135deg); }
.solution { margin-top: 20px; padding-top: 20px; border-top: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line)); }

.pitfalls,
.checklist { display: grid; gap: 12px; }
.pitfalls li,
.checklist li {
  position: relative;
  padding-left: 32px;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 350;
  line-height: 1.65;
}
.pitfalls li::before,
.checklist li::before {
  content: "";
  position: absolute;
  top: .42em;
  left: 0;
  width: 18px;
  height: 18px;
}
.pitfalls li::before {
  top: .62em;
  width: 8px;
  height: 8px;
  left: 5px;
  background: var(--ink);
}
.checklist li::before {
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
}

.lesson-complete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding: 24px 0;
  border-top: 1px solid var(--line);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.lesson-article .pager { padding-top: 24px; border-top: 1px solid var(--line); }

.lesson-toc {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  padding-top: 44px;
}
.toc-inner { display: grid; gap: 2px; }
.toc-inner .side-label { margin-bottom: 10px; }
.toc-inner a {
  padding: 6px 0 6px 14px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  border-left: 2px solid var(--line);
  transition: color .15s, border-color .15s;
}
.toc-inner a:hover { color: var(--ink); border-left-color: var(--accent); }

/* Interactive graphs */
.interactive-plot svg { display: block; width: 100%; height: auto; margin: 8px 0 12px; }
.plot-curve { fill: none; stroke: var(--accent); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.plot-grid { fill: none; stroke: var(--line); stroke-width: .8; }
.plot-axis { fill: none; stroke: var(--line-strong); stroke-width: 1.2; }
.plot-area { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
.plot-labels { fill: var(--ink-2); font-family: var(--font-sans); font-weight: 500; }
.plot-ticks { fill: var(--muted); font-family: var(--font-mono); }
.plot-controls {
  display: grid;
  grid-template-columns: auto minmax(120px, 1fr) minmax(86px, auto);
  align-items: center;
  gap: 16px;
  font-size: 14px;
  font-weight: 500;
}
.plot-controls output { font: 400 13px var(--font-mono); text-align: right; color: var(--accent-text); }
.plot-caption { margin-top: 12px; font-size: 14px; line-height: 1.6; color: var(--muted); }


/* ==========================================================================
   7. Question bank
   ========================================================================== */

.tool-heading { display: grid; gap: 14px; margin-bottom: 32px; }
.tool-heading h1 { font-size: clamp(2.25rem, 1.5rem + 3.4vw, 3.5rem); line-height: 1.04; }
.tool-heading-row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 32px; }
.tool-heading-row > div { display: grid; gap: 12px; }

.stat-inline {
  display: grid;
  gap: 2px;
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-align: right;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
}
.stat-inline strong {
  font: 300 2rem/1.1 var(--font-sans);
  letter-spacing: -.02em;
  text-transform: none;
  color: var(--ink);
}

.tool-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 24px;
  padding: 0 0 14px;
  border-bottom: 1px solid var(--line);
}
.tool-topbar > span { font-size: 14px; font-weight: 500; color: var(--ink-2); }

.question-card {
  padding: clamp(20px, 4vw, 40px);
  background: var(--surface);
  border: 1px solid var(--line);
}

.question-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.question-topic { margin-right: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
.question-save {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  transition: color .2s, border-color .2s, background .2s;
}
.question-save:hover { color: var(--ink); border-color: var(--line-strong); }
.question-save[aria-pressed="true"] {
  color: var(--accent-text);
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

.question-prompt {
  max-width: 68ch;
  margin: 24px 0 28px;
  font: 300 clamp(1.1875rem, 1.1rem + .4vw, 1.375rem)/1.6 var(--font-sans);
}
.question-diagram { margin-bottom: 28px; }

.question-options { display: grid; gap: 10px; }

.answer-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 62px;
  padding: 14px 18px;
  font-size: 1rem;
  line-height: 1.5;
  text-align: left;
  background: var(--surface);
  border: 1.5px solid var(--line);
  transition: border-color .15s, background .15s, transform .15s var(--ease);
}
.answer-option:not(:disabled):hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.answer-option:not(:disabled):active { transform: scale(.995); }
.answer-option:disabled { cursor: default; }
.answer-option:disabled:not(.correct):not(.wrong) { opacity: .55; }

.answer-letter {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font: 500 13px var(--font-sans);
  color: var(--muted);
  border: 1.5px solid var(--line-strong);
  transition: background .15s, color .15s, border-color .15s;
}
.answer-indicator { font-size: 12px; font-weight: 500; white-space: nowrap; }

.answer-option.selected { border-color: var(--accent); background: var(--accent-soft); }
.answer-option.selected .answer-letter { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

.answer-option.correct { border-color: var(--right); background: var(--right-soft); }
.answer-option.correct .answer-letter { color: var(--surface); background: var(--right); border-color: var(--right); }
.answer-option.correct .answer-indicator { color: var(--right); }

.answer-option.wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.answer-option.wrong .answer-letter { color: var(--surface); background: var(--wrong); border-color: var(--wrong); }
.answer-option.wrong .answer-indicator { color: var(--wrong); }

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-top: 28px;
}
.answer-hint { font-size: 13px; color: var(--muted); }

.explanation {
  margin-top: 28px;
  padding: 20px 24px;
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
}
.explanation h2 { margin-bottom: 8px; font: 500 1rem/1.3 var(--font-sans); }
.explanation p { font: 400 1.0625rem/1.7 var(--font-sans); color: var(--ink-2); }

.question-card + .pager { margin-top: 20px; }
.question-id { font: 400 13px var(--font-mono); color: var(--muted); }

.question-jump { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 24px; }
.jump-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  font: 400 13px var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color .15s, color .15s, background .15s;
}
.jump-button:hover { color: var(--ink); border-color: var(--line-strong); }
.jump-button.answered { color: var(--accent-text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.jump-button.current { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }


/* ==========================================================================
   8. Flashcards
   ========================================================================== */

.view-switch {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
}
.view-switch .button {
  min-height: 34px;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.view-switch .button:hover:not(:disabled) { color: var(--ink); background: transparent; border-color: transparent; }
.view-switch .button.active { color: var(--ink); background: var(--surface); }

.deck-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  font-size: 13px;
  color: var(--muted);
}
.deck-status strong { color: var(--ink-2); text-transform: capitalize; }

.flash-stage { margin: 16px 0 20px; }

.flashcard {
  display: grid;
  width: 100%;
  min-height: 360px;
  overflow: hidden;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color .2s, transform .2s var(--ease);
}
.flashcard:hover { border-color: var(--line-strong); }

.card-face {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: clamp(24px, 5vw, 44px);
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}
.card-back {
  background: var(--surface);
  opacity: 0;
  transform: translateY(14px);
}
.flashcard.flipped .card-front { opacity: 0; transform: translateY(-14px); }
.flashcard.flipped .card-back { opacity: 1; transform: none; }

.card-face-label { font: 500 12px/1.3 var(--font-sans); letter-spacing: .09em; text-transform: uppercase; color: var(--accent-text); }
.card-term {
  margin-block: auto;
  font: 300 clamp(2rem, 1.4rem + 3vw, 3.25rem)/1.1 var(--font-sans);
  letter-spacing: -.02em;
  text-wrap: balance;
}
.card-definition { margin-top: auto; font: 300 clamp(1.1875rem, 1.1rem + .5vw, 1.5rem)/1.5 var(--font-sans); }
.card-detail { margin-bottom: auto; font-size: 15px; line-height: 1.6; color: var(--muted); }
.card-face-hint { font-size: 13px; color: var(--muted); }

.card-rating { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.card-controls { margin-top: 0; }
.deck-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 24px;
}

.vocab-table { min-width: 640px; }
.vocab-table td:first-child { font: 300 1.0625rem/1.4 var(--font-sans); white-space: nowrap; }
.vocab-table td:nth-child(3) { font: 400 13px var(--font-mono); color: var(--accent-text); white-space: nowrap; }
.vocab-table td:last-child { white-space: nowrap; }
.vocab-table [data-card-status] { text-transform: capitalize; }
.vocab-table .equation-note { margin-top: 4px; }


/* ==========================================================================
   9. Data booklet
   ========================================================================== */

.booklet-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.booklet-tabs::-webkit-scrollbar { display: none; }
.booklet-tabs button {
  flex: none;
  margin-bottom: -1px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.booklet-tabs button:hover { color: var(--ink); }
.booklet-tabs button.active { color: var(--accent-text); border-bottom-color: var(--accent); }

.booklet-note { max-width: 70ch; margin: 20px 0 16px; font-size: 15px; line-height: 1.65; color: var(--muted); }
.count-label { margin-bottom: 12px; }

.formula-entry {
  position: relative;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color .2s;
}
.formula-entry[open] { border-color: var(--line-strong); }
.formula-entry > summary { display: block; padding: 18px 52px 12px 22px; }
.formula-entry > summary::after {
  content: "";
  position: absolute;
  top: 26px;
  right: 24px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .25s var(--ease);
}
.formula-entry[open] > summary::after { top: 30px; transform: rotate(-135deg); }

.formula-title-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.formula-name { font-size: 1rem; font-weight: 500; }
.formula-page { margin-left: auto; font-size: 12px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.formula-display { display: block; overflow-x: auto; }
.formula-display .katex-display { margin: .3em 0 .1em; text-align: left; }
.formula-display .katex-display > .katex { text-align: left; }

.formula-body { padding: 4px 22px 22px; }
.formula-body > p { max-width: 70ch; margin-bottom: 16px; font-size: 15px; line-height: 1.65; color: var(--ink-2); }
.variable-table { min-width: 460px; }
.variable-table td { padding: 10px 16px; font-size: 14px; }
.variable-table td:first-child { width: 90px; }
.formula-source { margin-top: 16px; }

.constant-entry {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 20px;
  padding: 22px 0;
  border-top: 1px solid var(--line);
}
.constant-symbol {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  font-size: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
}
.constant-content { display: grid; gap: 4px; }
.constant-content h3 { font-size: 1rem; font-weight: 500; }
.constant-value { font-size: 1.1rem; color: var(--accent-text); }
.constant-content p { font-size: 14px; line-height: 1.6; color: var(--muted); }

.subsection-title { margin: 56px 0 20px; font: 300 1.75rem/1.2 var(--font-sans); letter-spacing: -.015em; }
.prefix-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.prefix-item {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.prefix-item strong { font-size: 14px; }
.prefix-item strong span { color: var(--accent-text); font-family: var(--font-mono); }
.prefix-item .katex { color: var(--muted); }
.conversion-entry { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; padding: 14px 0; border-top: 1px solid var(--line); }
.conversion-entry p { font-size: 14px; color: var(--muted); }

.booklet-reader-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.page-select { flex: 1; max-width: 440px; }
.booklet-figure { margin: 0; }
.booklet-page {
  display: block;
  width: 100%;
  max-width: 840px;
  height: auto;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--line);
}
:root[data-theme="dark"] .booklet-page { filter: invert(.9); }
.booklet-page-caption { margin-top: 14px; font-size: 13px; text-align: center; color: var(--muted); }


/* ==========================================================================
   10. Dialog · Responsive · Motion · Print
   ========================================================================== */

/* ---- About dialog ---- */

dialog {
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: calc(100dvh - 32px);
  padding: clamp(20px, 4vw, 32px);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}
dialog::backdrop { background: var(--backdrop); }
dialog[open] { animation: enter .25s var(--ease); }
.dialog-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
dialog h2 { margin-bottom: 20px; font: 300 1.875rem/1.15 var(--font-sans); letter-spacing: -.02em; }
dialog h3 { margin: 24px 0 8px; font-size: 15px; font-weight: 500; }
dialog p { margin-bottom: 12px; font-size: 15px; line-height: 1.65; color: var(--ink-2); }
dialog .muted { color: var(--muted); }
dialog .tiny { font-size: 12px; }
.dialog-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 24px 0 16px; }
.reset-confirm {
  margin: 0 0 16px;
  padding: 16px 18px;
  background: var(--wrong-soft);
  border: 1px solid color-mix(in srgb, var(--wrong) 35%, transparent);
}
.reset-confirm p { color: var(--ink); }
.reset-confirm-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---- ≤ 1100px: drop the table of contents, slim the side columns ---- */

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 248px minmax(0, 1fr); }
  .lesson-body { display: block; }
  .lesson-toc { display: none; }
  .page-heading { grid-template-columns: minmax(0, 1fr) 260px; }
  .overview-layout { grid-template-columns: minmax(0, 1fr) 280px; }
}

/* ---- ≤ 860px: single column, two-row header, filter drawer ---- */

@media (max-width: 860px) {
  :root { --header-h: 108px; }

  .site-header-inner {
    flex-wrap: wrap;
    gap: 0 12px;
    height: auto;
    padding-top: 10px;
    padding-bottom: 0;
  }
  .brand { min-height: 44px; }
  .header-actions { min-height: 44px; }
  .primary-nav {
    order: 3;
    flex: 1 0 100%;
    gap: 0;
    margin: 0 calc(var(--gutter) * -1);
    padding: 0 36px 0 calc(var(--gutter) - 14px);
    overflow-x: auto;
    scrollbar-width: none;
    /* Fade the right edge to hint that the tabs scroll. */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent);
  }
  .primary-nav::-webkit-scrollbar { display: none; }
  .primary-nav a { padding: 12px 14px; }
  .primary-nav a[aria-current="page"] { background: none; box-shadow: inset 0 -2px 0 var(--accent); }

  .page-heading { grid-template-columns: 1fr; gap: 28px; }
  .heading-aside { max-width: 360px; }
  .overview-layout { grid-template-columns: 1fr; }

  .workspace { display: block; padding-top: 8px; }
  .workspace-content { padding-top: 24px; }

  .mobile-filters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding: 4px 4px 4px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
  }
  .mobile-filters > span { padding-right: 12px; font-size: 12px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .mobile-filters button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
  }
  .mobile-filters button::after {
    content: "+";
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 1;
    color: var(--accent-text);
    background: var(--accent-soft);
  }
  .mobile-filters button[aria-expanded="true"]::after { content: "−"; }

  .sidebar {
    display: none;
    position: static;
    max-height: none;
    margin-top: 12px;
    overflow: visible;
  }
  .sidebar.filters-open { display: block; }
  .sidebar.lesson-sidebar.filters-open { max-height: 70vh; overflow-y: auto; }
}

/* ---- ≤ 560px: phone refinements ---- */

@media (max-width: 560px) {
  .brand img { width: 170px; }
  .theme-label { display: none; }
  .theme-toggle { width: 38px; padding: 0; }

  .site-footer { margin-top: 56px; }
  .site-footer-inner { flex-direction: column; align-items: flex-start; }

  .theme-group > summary { grid-template-columns: 40px minmax(0, 1fr) 16px; gap: 12px; padding: 16px; }
  .theme-letter { width: 40px; height: 40px; }
  .theme-count { display: none; }
  .topic-row { grid-template-columns: 44px minmax(0, 1fr) auto 16px; gap: 10px; padding: 14px 16px; }
  .topic-row .duration { display: none; }

  .lesson-section { padding-top: 36px; }
  .lesson-section h2 { gap: 10px; }
  .lesson-complete { flex-direction: column; align-items: stretch; }
  .lesson-complete .button { width: 100%; }
  .lesson-complete .text-button { justify-content: center; }
  .lesson-article .pager { flex-direction: column-reverse; align-items: stretch; }
  .lesson-article .pager .button { width: 100%; }
  .lesson-article .pager span:empty { display: none; }

  .tool-heading-row { align-items: flex-start; }
  .stat-inline { text-align: left; }
  .plot-labels { font-size: 20px; }
  .plot-ticks { font-size: 16px; }
  .plot-controls { grid-template-columns: 1fr auto; }
  .plot-controls input { grid-column: 1 / -1; grid-row: 2; }

  .answer-option { grid-template-columns: auto minmax(0, 1fr); gap: 12px; padding: 12px 14px; }
  .answer-indicator { grid-column: 2; }
  .answer-actions .button { flex: 1 1 100%; }

  .pager .question-id { order: -1; flex-basis: 100%; text-align: center; }
  .pager .button { flex: 1; }
  .jump-button { width: 36px; height: 36px; }

  .flashcard { min-height: 320px; }
  .card-rating .button { padding: 0 12px; }

  .constant-entry { grid-template-columns: 48px minmax(0, 1fr); gap: 14px; }
  .constant-symbol { width: 48px; height: 48px; }
  .formula-entry > summary { padding: 16px 44px 10px 16px; }
  .formula-entry > summary::after { top: 22px; right: 18px; }
  .formula-entry[open] > summary::after { top: 26px; }
  .formula-page { margin-left: 0; flex-basis: 100%; }
  .formula-body { padding: 4px 16px 18px; }
  .booklet-reader-toolbar .button { flex: none; }

  .dialog-actions .button { flex: 1 1 100%; }
  .reset-confirm-actions .button { flex: 1 1 100%; }
}

/* ---- Motion ---- */

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

/* ---- Print: study guides read as clean documents ---- */

@media print {
  :root,
  :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #f4f4f4;
    --ink: #111; --ink-2: #222; --muted: #555;
    --line: #ccc; --line-strong: #aaa;
    --accent-text: #0a6a62; --accent-soft: #eef7f5;
  }
  body { background: #fff; font-size: 11pt; }
  .site-header, .sidebar, .mobile-filters, .lesson-toc, .site-footer,
  .lesson-complete, .lesson-topline, .help-button, .pager { display: none !important; }
  .workspace, .lesson-body { display: block; padding: 0; }
  .page-shell { max-width: none; padding: 0; }
  .lesson-section, .formula-entry, .equation-panel, .worked-example { break-inside: avoid; }
  .worked-example details:not([open]) .solution { display: block; }
  .screen-enter { animation: none; }
  .booklet-page { filter: none !important; }
}
