/* ============================================================
   Course textbooks
   Pages exported by learning-assistant's tools/kb_export: statement
   blocks, worked examples, exercises with solution panels, figures,
   and the course front page (layouts/_default/course.html).
   Uses the design tokens from styles.css only.
   ============================================================ */

/* Anchored blocks land below the sticky header (sites may also set scroll-padding-top on html). */
html { scroll-padding-top: calc(var(--nav-height) + var(--space-md)); }

/* --- Statement blocks: definitions, theorems, proofs, ... --- */

.kb-statement {
  --kb-kind: var(--border);
  margin: var(--space-lg) 0;
  padding: var(--space-xs) 0 var(--space-xs) var(--space-lg);
  border-left: 2px solid var(--kb-kind);
}

.kb-statement > :first-child { margin-top: 0; }
.kb-statement > :last-child { margin-bottom: 0; }
.kb-statement > p:first-child > strong:first-child { color: var(--kb-kind); }

.kb-statement--definition { --kb-kind: var(--notes); }
.kb-statement--theorem,
.kb-statement--proposition,
.kb-statement--lemma,
.kb-statement--corollary { --kb-kind: var(--accent); }
.kb-statement--assumptions { --kb-kind: var(--muted); }

.kb-statement--common-mistake {
  --kb-kind: var(--callout-warning);
}

.kb-statement--proof {
  background: none;
  border-left: 2px solid var(--border);
  padding-top: var(--space-xs);
  padding-bottom: var(--space-xs);
}

.kb-statement--proof > p:first-child > strong:first-child {
  color: var(--text);
  font-style: italic;
}

.kb-statement--proof::after {
  content: "∎";
  display: block;
  text-align: right;
  color: var(--muted);
  line-height: 1;
}

/* Long displayed formulas scroll inside the block instead of overflowing the page. */
:is(.kb-statement, .kb-example, .kb-panel) mjx-container[display="true"] {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

/* MathJax 3 cannot break inline formulas, so on a phone a long one scrolls sideways
   instead of widening the page. Scoped to course pages. */
@media (max-width: 600px) {
  .content-area:has(.kb-statement, .kb-exercise-anchor) mjx-container:not([display="true"]) {
    display: inline-block;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    vertical-align: middle;
  }
}

/* --- Worked examples --- */

.kb-example {
  margin: var(--space-xl) 0;
  padding: var(--space-md) 0 var(--space-xs);
  border-top: 1px solid var(--border-light);
}

.kb-example > h3:first-child {
  margin-top: 0;
  font-size: var(--font-size-lg);
}


/* --- Exercises --- */

ol:has(> li .kb-exercise-anchor) { padding-left: 2.25em; }

ol:has(> li .kb-exercise-anchor) > li {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-light);
}

ol:has(> li .kb-exercise-anchor) > li::marker {
  font-weight: 700;
  color: var(--muted);
}

li:has(> p > .kb-exercise-anchor:target),
li:has(> .kb-exercise-anchor:target) {
  background: color-mix(in srgb, var(--accent) 6%, var(--bg));
  box-shadow: -0.75em 0 0 color-mix(in srgb, var(--accent) 6%, var(--bg));
}

/* --- Hint, answer, and solution panels --- */

.kb-panel {
  --kb-kind: var(--accent);
  margin: var(--space-xs) var(--space-sm) var(--space-xs) 0;
}

.kb-panel--hint { --kb-kind: var(--callout-tip); }
.kb-panel--answer { --kb-kind: var(--notes); }
.kb-panel--solution { --kb-kind: var(--callout-example); }

/* Closed panels for one exercise sit in a row; an open one takes the full width. */
.kb-panel:not([open]) { display: inline-block; }

.kb-panel > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-height: 32px;
  padding: 2px 12px;
  list-style: none;
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  user-select: none;
}

.kb-panel > summary::-webkit-details-marker { display: none; }

.kb-panel > summary::before {
  content: "";
  width: 0.4em;
  height: 0.4em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

.kb-panel > summary:hover,
.kb-panel[open] > summary {
  color: var(--kb-kind);
  border-color: var(--kb-kind);
}

.kb-panel > summary:focus-visible {
  outline: 2px solid var(--kb-kind);
  outline-offset: 2px;
}

.kb-panel[open] {
  display: block;
  margin: var(--space-sm) 0 var(--space-md);
  padding: var(--space-xs) var(--space-md);
  border-left: 2px solid var(--kb-kind);
}

.kb-panel[open] > summary {
  margin-bottom: var(--space-sm);
}

.kb-panel[open] > summary::before { transform: rotate(45deg); }
.kb-panel > :last-child { margin-bottom: 0; }

@media (pointer: coarse) {
  .kb-panel > summary { min-height: 44px; padding: 4px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .kb-panel > summary::before { transition: none; }
}

/* --- Figures --- */

figure.course-figure {
  margin: var(--space-xl) 0;
  text-align: left;
}

.course-figure img {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

.course-figure figcaption {
  max-width: 760px;
  margin: var(--space-sm) auto 0;
  font-style: normal;
  text-align: left;
  color: var(--text-secondary);
  line-height: 1.55;
}

.course-figure figcaption strong { color: var(--text); }

/* On a phone, keep labels readable: the figure scrolls sideways instead of shrinking. */
@media (max-width: 600px) {
  figure.course-figure { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .course-figure img { min-width: 520px; }
  .course-figure figcaption { position: sticky; left: 0; max-width: calc(100vw - 2 * var(--space-lg)); }
}

/* --- Course front page --- */

.kb-course .kb-course-fallback { display: none; }

.kb-course {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-2xl);
}

.kb-course__promise {
  font-size: var(--font-size-lg);
  color: var(--text-secondary);
  margin: 0 0 var(--space-md);
}

.kb-course__facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  align-items: center;
  margin-bottom: var(--space-xl);
  font-size: var(--font-size-sm);
  color: var(--muted);
}

.kb-course__badge {
  padding: 0;
  color: var(--muted);
}

.kb-course__section-title {
  font-size: var(--font-size-xl);
  margin: var(--space-xl) 0 var(--space-sm);
}

.kb-course__hint {
  color: var(--muted);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-md);
}

.kb-chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: none;
}

.kb-chapter-list a {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  column-gap: var(--space-md);
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  text-decoration: none;
}

.kb-chapter-list a:hover { background: var(--hover-bg); }
.kb-chapter-list a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.kb-chapter-list__number {
  grid-row: span 3;
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--muted);
  line-height: 1.2;
}

.kb-chapter-list__title { font-weight: 600; }

.kb-chapter-list__abstract {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.kb-chapter-list__meta {
  color: var(--muted);
  font-size: var(--font-size-sm);
}

.kb-course__about { margin-top: var(--space-xl); }

@media (max-width: 600px) {
  .kb-course { padding: 0 var(--space-md) var(--space-xl); }
  .kb-chapter-list a { grid-template-columns: 2rem 1fr; padding: var(--space-md) var(--space-sm); }
}

/* --- Reference links and previews --- */

a.kb-ref {
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
}

a.kb-ref:hover { text-decoration-style: solid; }

.kb-preview {
  position: fixed;
  z-index: 400;
  width: min(440px, calc(100vw - 24px));
  max-height: min(60vh, 520px);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgb(28 25 23 / 18%);
  font-size: 0.95rem;
}

.kb-preview[hidden] { display: none; }

.kb-preview__bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-xs) var(--space-xs) var(--space-md);
  border-bottom: 1px solid var(--border-light);
  font-size: var(--font-size-sm);
}

.kb-preview__title { flex: 1; font-weight: 600; color: var(--text-secondary); }
.kb-preview__go { font-weight: 600; }

.kb-preview__close {
  min-width: 32px;
  min-height: 32px;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.kb-preview__close:hover { background: var(--hover-bg); color: var(--text); }

.kb-preview__body {
  overflow: auto;
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

.kb-preview__body .kb-statement,
.kb-preview__body .kb-example,
.kb-preview__body figure.course-figure { margin: 0; }

.kb-preview__body .kb-example { border: none; padding: 0; }
.kb-preview__body .kb-example > h3:first-child { font-size: var(--font-size-base); }
.kb-preview__chapter { font-weight: 600; margin-bottom: var(--space-xs); }
.kb-preview__body > .kb-preview__content > :last-child { margin-bottom: 0; }

.kb-preview--sheet {
  left: 0;
  right: 0;
  top: auto;
  bottom: 0;
  width: 100%;
  max-height: 70vh;
  border-radius: 14px 14px 0 0;
}

/* --- Back / continue pills and status toast --- */

.kb-pill,
.kb-pill-row {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 350;
}

.kb-pill-row { display: flex; align-items: center; gap: var(--space-xs); }
.kb-pill-row .kb-pill { position: static; transform: none; }

.kb-pill,
.kb-pill__dismiss {
  min-height: 40px;
  padding: 6px 16px;
  font: inherit;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 6px 20px rgb(28 25 23 / 14%);
  cursor: pointer;
  white-space: nowrap;
  max-width: calc(100vw - 96px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-pill__dismiss { padding: 6px 12px; }
.kb-pill:hover, .kb-pill__dismiss:hover { border-color: var(--accent); color: var(--accent); }
.kb-pill[hidden] { display: none; }

.kb-toast {
  position: fixed;
  left: 50%;
  top: calc(var(--nav-height) + var(--space-md));
  transform: translateX(-50%);
  z-index: 450;
  padding: 6px 14px;
  font-size: var(--font-size-sm);
  color: var(--bg);
  background: var(--text);
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.kb-toast--visible { opacity: 0.92; }

/* The knowledge base's reading bar sits at the bottom on phones. */
@media (max-width: 768px) {
  .kb-pill, .kb-pill-row { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

/* --- Notes --- */

.kb-note-btn { display: none; }

html.kb-js .kb-noteable { position: relative; }

html.kb-js .kb-note-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 2px;
  right: -40px;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  font-size: 0;
}

html.kb-js .kb-note-btn::before { content: "✎"; font-size: 15px; line-height: 1; }

html.kb-js .kb-noteable:hover > .kb-note-btn,
html.kb-js .kb-note-btn:focus-visible { opacity: 1; border-color: var(--border); }
html.kb-js .kb-note-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Statements and examples have their own padding: keep the button inside their frame. */
html.kb-js :is(.kb-statement, .kb-example, figure.course-figure) > .kb-note-btn { right: 4px; top: 4px; }

@media (pointer: coarse), (max-width: 900px) {
  html.kb-js .kb-note-btn { opacity: 0.55; right: 0; width: 36px; height: 36px; border-color: var(--border-light); }
  html.kb-js h2.kb-noteable { padding-right: 44px; }
  html.kb-js li.kb-noteable { padding-right: 40px; }
}

.kb-note {
  margin: var(--space-sm) 0 var(--space-md);
  padding: 2px var(--space-md);
  border-left: 2px solid var(--callout-tip);
  font-size: 0.95rem;
}

.kb-note__head { display: flex; align-items: center; gap: var(--space-sm); margin-bottom: 2px; }

.kb-note__label,
.kb-note__edit {
  padding: 0;
  font: inherit;
  font-size: var(--font-size-sm);
  background: none;
  border: none;
  cursor: pointer;
}

.kb-note__label { font-weight: 600; color: var(--text-secondary); text-align: left; }
.kb-note__edit { margin-left: auto; color: var(--accent); }
.kb-note__label:hover, .kb-note__edit:hover { text-decoration: underline; }
.kb-note__text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.kb-side-notes { position: relative; }

.kb-side-notes .kb-note {
  position: absolute;
  left: 0;
  right: 0;
  margin: 0;
  font-size: var(--font-size-sm);
}

.kb-note-editor {
  margin: var(--space-sm) 0 var(--space-md);
  padding: 0;
}

.kb-note-editor__text {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: var(--space-sm);
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
}

.kb-note-editor__actions,
.kb-course-notes__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

:is(.kb-note-editor, .kb-course-notes, .kb-check, .kb-chapter-tools, .kb-recall-controls, .kb-recall, .kb-recall-session) .kb-button {
  min-height: 36px;
  padding: 4px 14px;
  font: inherit;
  font-size: var(--font-size-sm);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

:is(.kb-note-editor, .kb-course-notes, .kb-check, .kb-chapter-tools, .kb-recall-controls, .kb-recall, .kb-recall-session) .kb-button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
:is(.kb-note-editor, .kb-course-notes, .kb-check, .kb-chapter-tools, .kb-recall-controls, .kb-recall, .kb-recall-session) .kb-button:disabled { opacity: 0.5; cursor: default; }
:is(.kb-note-editor, .kb-course-notes, .kb-check, .kb-chapter-tools, .kb-recall-controls, .kb-recall, .kb-recall-session) .kb-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kb-note-editor__save { font-weight: 600; }
.kb-note-editor__delete { margin-left: auto; }

@media (pointer: coarse) {
  :is(.kb-note-editor, .kb-course-notes, .kb-check, .kb-chapter-tools, .kb-recall-controls, .kb-recall, .kb-recall-session) .kb-button { min-height: 44px; }
}

.kb-notes-moved {
  margin-top: var(--space-2xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* --- Course front page: continue reading, progress, notes --- */

.kb-course__continue { margin: calc(-1 * var(--space-md)) 0 var(--space-lg); }
.kb-course__continue-link { font-weight: 600; }
.kb-course__continue-link::after { content: " →"; }

.kb-chapter-status { white-space: nowrap; }
.kb-chapter-status--read { color: var(--callout-tip); font-weight: 600; }
.kb-chapter-status--started { color: var(--accent); }

.kb-course-notes__group h3 { font-size: var(--font-size-base); margin: var(--space-lg) 0 var(--space-xs); }

.kb-course-notes__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 var(--space-md);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-light);
}

.kb-course-notes__item a { font-weight: 600; }
.kb-course-notes__item .kb-note__edit { margin-left: auto; }
.kb-course-notes__item .kb-note__text { flex-basis: 100%; color: var(--text-secondary); }

/* --- Chapter header: what it builds on, tools --- */

.kb-chapter-deps {
  margin: 0 0 var(--space-sm);
  color: var(--muted);
  font-size: var(--font-size-sm);
}

.kb-chapter-tools {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: 0 0 var(--space-lg);
}

.kb-chapter-tools__recall[aria-pressed="true"] {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  font-weight: 600;
}

/* --- Answer checks --- */

.kb-check {
  --kb-kind: var(--callout-tip);
  margin: var(--space-sm) 0;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--kb-kind);
  border-radius: 0 6px 6px 0;
  font-size: var(--font-size-sm);
}

.kb-check[hidden] { display: none; }
.kb-check__title { margin: 0 0 var(--space-xs); font-weight: 600; color: var(--text-secondary); }

.kb-check__field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-sm);
  margin: 0 0 var(--space-sm);
  padding: 0;
  border: none;
  min-width: 0;
}

.kb-check__field > label,
.kb-check__field > legend { color: var(--text); }
.kb-check__field > legend { padding: 0; margin-bottom: var(--space-xs); }

.kb-check__field input[type="text"] {
  flex: 1 1 12rem;
  max-width: 22rem;
  min-height: 36px;
  padding: 4px 10px;
  font: inherit;
  font-family: var(--font-mono, ui-monospace, monospace);
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.kb-check__field input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.kb-check__unit { color: var(--text-secondary); }

.kb-check__field--choice { display: block; }
.kb-check__option { display: inline-flex; align-items: baseline; gap: 6px; margin: 0 var(--space-md) var(--space-xs) 0; cursor: pointer; }
.kb-check__field--choice .kb-check__mark { display: block; }

.kb-check__mark { font-weight: 600; }
.kb-check__field--right .kb-check__mark { color: var(--callout-tip); }
.kb-check__field--wrong .kb-check__mark { color: var(--callout-warning); }
.kb-check__field--right input[type="text"] { border-color: var(--callout-tip); }
.kb-check__field--wrong input[type="text"] { border-color: var(--callout-warning); }

.kb-check__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.kb-check__result { color: var(--text-secondary); }
.kb-check--solved .kb-check__title::after { content: " ✓"; color: var(--callout-tip); }

@media (pointer: coarse) {
  .kb-check__field input[type="text"] { min-height: 44px; font-size: 16px; }
  .kb-check__option { min-height: 44px; align-items: center; }
}

/* --- Recall mode on chapter pages --- */

.kb-recall-controls { display: none; }

.kb-recall-on .kb-recallable .kb-recall-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.kb-recall-on .kb-recallable:not(.kb-recall-shown) .kb-recall-rest,
.kb-recall-on .kb-recallable:not(.kb-recall-shown) > :not(:first-child):not(.kb-recall-controls):not(.kb-note-btn),
.kb-recall-on .kb-recall-proof:not(.kb-recall-proof--shown) { display: none; }

.kb-recall-controls [hidden] { display: none; }
.kb-recall-controls__status { color: var(--muted); font-size: var(--font-size-sm); }
.kb-recall-controls__knew { font-weight: 600; }

/* --- Recall section and sessions on the course page --- */

.kb-recall__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm) var(--space-md); }
.kb-recall__actions label { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); color: var(--text-secondary); font-size: var(--font-size-sm); }

.kb-recall__scope {
  min-height: 36px;
  max-width: 100%;
  padding: 4px 8px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.kb-recall-session { width: min(720px, calc(100% - 24px)); }
.kb-recall-session__body { padding: var(--space-md) var(--space-lg) var(--space-lg); max-height: 75vh; overflow: auto; }
.kb-recall-session__progress { margin: 0; color: var(--muted); font-size: var(--font-size-sm); }
.kb-recall-session__where { font-size: var(--font-size-sm); }
.kb-recall-session__prompt { margin: var(--space-md) 0 var(--space-xs); font-size: var(--font-size-lg); font-weight: 600; }
.kb-recall-session__statement .kb-statement { margin: var(--space-sm) 0; }
.kb-recall-session__statement mjx-container[display="true"] { overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.kb-recall-session__actions { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: var(--space-md); }
.kb-recall-session__actions [hidden] { display: none; }
.kb-recall-session__knew { font-weight: 600; }
.kb-recall-session__done { font-size: var(--font-size-lg); font-weight: 600; }

/* --- Chapter and course maps --- */

.kb-chapter-list__deps { grid-column: 2; color: var(--muted); font-size: var(--font-size-sm); }
.kb-chapter-list__number { grid-row: span 4; }

.kb-course-maps__grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-lg) var(--space-xl);
  align-items: flex-start;
}

.kb-map {
  margin: 0;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.kb-map figcaption {
  max-width: 34rem;
  margin-bottom: var(--space-sm);
  color: var(--muted);
  font-size: var(--font-size-sm);
}

.kb-map__svg { display: block; width: 100%; height: auto; }

.kb-map__node rect { fill: var(--surface); stroke: var(--border); stroke-width: 1; }
.kb-map__node text { fill: var(--text); font-family: inherit; }
.kb-map__title { font-size: 13px; }
.kb-map__node .kb-map__kicker { font-size: 11px; fill: var(--muted); letter-spacing: 0.02em; }
a.kb-map__node:hover rect,
a.kb-map__node:focus-visible rect { stroke: var(--accent); stroke-width: 2; }
a.kb-map__node:focus { outline: none; }
a.kb-map__node:hover .kb-map__title { fill: var(--accent); }

.kb-map__node--current rect { stroke: var(--accent); stroke-width: 2; fill: color-mix(in srgb, var(--accent) 10%, var(--bg)); }
.kb-map__node--current .kb-map__title { font-weight: 700; }
.kb-map__node--absent rect { stroke-dasharray: 4 3; fill: none; }
.kb-map__node--absent text { fill: var(--muted); }
.kb-map__node--started rect { stroke: var(--accent); }
.kb-map__node--read rect { stroke: var(--callout-tip); stroke-width: 2; fill: color-mix(in srgb, var(--callout-tip) 10%, var(--bg)); }

/* The course library as levels (generated learning-assistant section page). */
.kb-levels { margin: var(--space-md) 0 var(--space-lg); }
.kb-levels__level { padding: var(--space-sm) 0; border-top: 1px solid var(--border-light); }
.kb-levels__title { margin: 0 0 var(--space-xs); font-weight: 600; color: var(--muted); font-size: var(--font-size-sm); text-transform: uppercase; letter-spacing: 0.04em; }
.kb-levels ul { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-lg); list-style: none; margin: 0; padding: 0; }
.kb-levels li { display: flex; flex-direction: column; margin: 0; }
.kb-levels li > a { font-weight: 600; }
.kb-levels__after { color: var(--muted); font-size: var(--font-size-sm); }

.kb-map__edge { fill: none; stroke: var(--muted); stroke-width: 1.4; opacity: 0.7; }
.kb-map__edge--current { stroke: var(--accent); opacity: 1; }
.kb-map__arrow { fill: var(--muted); }

/* --- Keyboard shortcuts dialog --- */

.kb-shortcuts { width: min(460px, calc(100% - 24px)); }
.kb-shortcuts__list { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-sm) var(--space-md); margin: 0; padding: var(--space-md) var(--space-lg) var(--space-lg); }
.kb-shortcuts__list dt { margin: 0; }
.kb-shortcuts__list dd { margin: 0; color: var(--text-secondary); }

@media (prefers-reduced-motion: reduce) {
  .kb-toast { transition: none; }
}

/* --- Print and Export PDF --- */

@media print {
  .kb-panel,
  .kb-panel[open] { display: block; }
  .kb-panel > summary { border: none; padding: 0; min-height: 0; background: none; }
  .kb-panel > summary::before { display: none; }
  .kb-statement,
  .kb-example,
  .course-figure { break-inside: avoid; }
  figure.course-figure { overflow: visible; }
  .course-figure img { min-width: 0; }
  .kb-note-btn, .kb-note-editor, .kb-preview, .kb-pill, .kb-pill-row, .kb-toast, .kb-side-notes,
  .kb-check, .kb-chapter-tools, .kb-recall-controls, .kb-recall, .kb-course-maps { display: none !important; }
  /* Recall mode never hides anything on paper. */
  .kb-recall-on .kb-recallable .kb-recall-rest { display: inline !important; }
  .kb-recall-on .kb-recallable > :not(.kb-recall-controls):not(.kb-note-btn),
  .kb-recall-on .kb-recall-proof { display: block !important; }
  a.kb-ref { text-decoration: none; color: inherit; }
}

/* Mixed practice sessions */
.kb-practice-session__exercise { list-style: none; padding: 0; margin: var(--space-sm) 0 var(--space-md); }
.kb-practice-session__exercise > li { padding-right: 0; }
.kb-practice-session .kb-recall-session__body { max-height: 70vh; overflow: auto; }

/* Explain in your own words: a quiet text control at the end of a statement */
.kb-explain-row { margin: 0; line-height: 1.6; }
.kb-explain-btn { padding: 0; font: inherit; font-size: var(--font-size-sm); color: var(--muted); background: none; border: 0; cursor: pointer; opacity: 0; transition: opacity .15s; }
.kb-noteable:hover .kb-explain-btn, .kb-noteable:focus-within .kb-explain-btn, .kb-explain-btn:focus-visible { opacity: 1; }
.kb-explain-btn:hover { color: var(--accent); text-decoration: underline; }
@media (pointer: coarse) { .kb-explain-btn { opacity: 1; } }
.kb-statement > .kb-explain-row:last-child { margin-bottom: 0; }

/* Stepwise proofs */
.kb-proof-steps { display: flex; gap: 1rem; margin: var(--space-xs) 0 0; }
.kb-proof-steps button { padding: 0; font: inherit; font-size: var(--font-size-sm); color: var(--accent); background: none; border: 0; cursor: pointer; }
.kb-proof-steps button:hover { text-decoration: underline; }
