/* ============================================================
   app.css — layout, nav, sidebar, landing, components, responsive
   ============================================================ */

/* ---------- Dot grid (sole decorative element) ---------- */
.dotgrid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.55;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0) 72%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0) 72%);
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav__inner {
  max-width: var(--container);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  gap: var(--sp-8);
}
.nav__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}
.nav__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
}
.nav__title { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.03em; }
.nav__title-accent { color: var(--primary); }

.nav__links { display: flex; gap: var(--sp-2); margin: 0 auto; }
.nav__links a {
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.nav__links a:hover, .nav__links a.is-active { color: var(--text); background: var(--bg-alt); }

.nav__actions { display: flex; align-items: center; gap: var(--sp-2); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--bg-alt); color: var(--text); }

.icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

/* Search trigger */
.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text-3);
  font-size: 14px;
  transition: border-color var(--dur) var(--ease);
}
.search-trigger:hover { border-color: var(--primary); }
.search-trigger__kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 2px 6px;
  color: var(--text-2);
}

/* ---------- Layout ---------- */
.layout {
  max-width: var(--container);
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: var(--sp-8);
  padding: var(--sp-8) var(--gutter) var(--sp-16);
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar { position: sticky; top: calc(var(--nav-h) + var(--sp-8)); max-height: calc(100vh - var(--nav-h) - var(--sp-16)); overflow-y: auto; }
.sidebar__tree { display: flex; flex-direction: column; gap: 2px; }

.sidebar__part {
  font-size: var(--fs-overline);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
  padding: var(--sp-3) var(--sp-2) var(--sp-1);
}
.sidebar__part:not(:first-child) { margin-top: var(--sp-4); }

.sidebar__link {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar__link:hover { background: var(--bg-alt); color: var(--text); }
.sidebar__link.is-active { background: var(--primary-tint); color: var(--primary); }
.sidebar__num { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
.sidebar__link.is-active .sidebar__num { color: var(--primary); }

.sidebar__home {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--text);
  font-weight: 600;
  font-size: var(--fs-small);
  text-decoration: none;
}
.sidebar__home:hover { background: var(--bg-alt); }

/* ---------- Main ---------- */
.main { min-width: 0; }
.main__inner { min-height: 60vh; }

/* ---------- Landing ---------- */
.hero {
  position: relative;
  padding: var(--sp-16) var(--sp-6) var(--sp-12);
  border-bottom: 1px solid var(--border);
}
.hero__overline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-overline);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--sp-4);
}
.hero__title {
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  letter-spacing: -0.04em;
  font-weight: 700;
  margin-bottom: var(--sp-5);
}
.hero__title .accent { color: var(--primary); }
.hero__lede {
  max-width: 60ch;
  font-size: 18px;
  color: var(--text-2);
  margin-bottom: var(--sp-8);
}
.hero__stats { display: flex; flex-wrap: wrap; gap: var(--sp-8); }
.hero__stat .num { font-family: var(--font-display); font-size: var(--fs-subhead); font-weight: 700; letter-spacing: -0.03em; }
.hero__stat .label { font-size: var(--fs-caption); color: var(--text-3); }

.hero__thesis {
  margin-top: var(--sp-8);
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.hero__thesis-title { font-size: var(--fs-overline); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); margin-bottom: var(--sp-2); }

/* Section headings */
.section {
  padding: var(--sp-16) 0 var(--sp-4);
  scroll-margin-top: calc(var(--nav-h) + var(--sp-4));
}
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-6); }
.section__title { font-size: var(--fs-section); line-height: var(--lh-section); }
.section__desc { color: var(--text-2); max-width: 56ch; margin-top: var(--sp-2); }

/* Chapter cards */
.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-5);
}
.chapter-card { display: flex; flex-direction: column; cursor: pointer; text-align: left; }
.chapter-card__body { display: flex; flex-direction: column; gap: var(--sp-2); flex: 1; }
.chapter-card__num { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--primary); }
.chapter-card__title { font-size: var(--fs-subhead); font-weight: 600; letter-spacing: -0.03em; color: var(--text); }
.chapter-card__subtitle { font-size: var(--fs-small); color: var(--text-2); }
.chapter-card__desc { font-size: var(--fs-small); color: var(--text-2); flex: 1; }
.chapter-card__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--sp-2); }

/* ---------- Concept map ---------- */
.map-wrap {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  overflow-x: auto;
}
/* graph shell */
.graph-shell { display: flex; flex-direction: column; gap: var(--sp-3); }
.graph-toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; justify-content: space-between; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-2);
  padding: 4px 9px; border: 1px solid var(--border); border-radius: var(--r-full);
  background: var(--surface);
  transition: opacity var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.legend-item:hover { border-color: var(--primary); }
.legend-item.is-off { opacity: 0.38; text-decoration: line-through; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend-num { font-family: var(--font-mono); color: var(--text-3); }
.graph-actions { display: flex; gap: 8px; }

.graph-canvas {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}
.graph-svg {
  width: 100%; height: auto; display: block;
  touch-action: none; cursor: grab; user-select: none;
}
.graph-svg:active { cursor: grabbing; }

/* edges: thin, light; cross-links dashed; hover turns indigo */
.g-edge { stroke: var(--border); stroke-width: 1; opacity: 0.55; transition: opacity var(--dur), stroke var(--dur), stroke-width var(--dur); }
.g-edge.is-cross { stroke-dasharray: 3 4; opacity: 0.4; }
.g-edge.is-active { stroke: var(--primary); opacity: 1; stroke-width: 1.6; stroke-dasharray: none; }
.g-edge.is-dim { opacity: 0.06; }

/* nodes: white pill hubs + small concept dots */
.g-node { cursor: pointer; }
.g-node .g-hub-rect {
  fill: var(--surface);
  stroke-width: 1.4;
  transition: fill var(--dur) var(--ease), stroke var(--dur) var(--ease);
}
.g-node.is-hub text {
  font-family: var(--font-body); font-size: 11.5px; font-weight: 600;
  fill: var(--text); pointer-events: none;
}
.g-node .g-dot { opacity: 0.78; transition: opacity var(--dur) var(--ease); }
.g-node .g-label {
  font-family: var(--font-body); font-size: 10px; fill: var(--text-2);
  opacity: 0;
  pointer-events: none;
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
  transition: opacity var(--dur) var(--ease);
}
.g-node.is-active .g-label { opacity: 1; }
.g-node.is-active .g-dot { opacity: 1; }
.g-node.is-hub.is-active .g-hub-rect { fill: var(--primary-tint); }
.g-node.is-dim { opacity: 0.16; }

.graph-status { font-size: var(--fs-caption); color: var(--text-2); min-height: 1.3em; }
.graph-hint { font-size: var(--fs-caption); color: var(--text-3); margin: 0; }
@media (max-width: 700px) { .graph-hint { display: none; } }

/* ---------- Timeline ---------- */
.timeline {
  position: relative;
  padding: var(--sp-8) 0 var(--sp-4);
}
.timeline__axis { position: relative; height: 48px; }
.timeline__line { position: absolute; top: 23px; left: 0; right: 0; height: 2px; background: var(--border); }
.timeline__band { position: absolute; top: 0; height: 48px; border-left: 1px dashed var(--border); }
.timeline__band-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: var(--fs-caption);
  color: var(--text-3);
  white-space: nowrap;
}
.timeline__events { display: flex; flex-direction: column; gap: var(--sp-2); margin-top: var(--sp-2); }
.timeline__event { display: flex; gap: var(--sp-4); align-items: baseline; padding: 8px 12px; border-radius: var(--r-md); }
.timeline__event:hover { background: var(--bg-alt); }
.timeline__event .yr { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--primary); min-width: 48px; }
.timeline__event .what { font-size: var(--fs-small); }
.timeline__event .who { font-size: var(--fs-caption); color: var(--text-3); }

/* ---------- Playground / demos ---------- */
.playground-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--sp-5);
}
.demo {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.demo__head { padding: var(--sp-4) var(--sp-5) 0; }
.demo__title { font-size: var(--fs-subhead); font-weight: 600; letter-spacing: -0.03em; }
.demo__sub { font-size: var(--fs-caption); color: var(--text-2); margin-top: 2px; }
.demo__stage { padding: var(--sp-3) var(--sp-5); }
.demo__stage canvas { display: block; width: 100%; border-radius: var(--r-md); }
.demo__controls { display: flex; flex-wrap: wrap; gap: var(--sp-4); padding: var(--sp-3) var(--sp-5) var(--sp-5); align-items: center; }
.demo__ctrl { display: flex; flex-direction: column; gap: 4px; flex: 1 1 120px; }
.demo__ctrl label { font-size: var(--fs-caption); color: var(--text-2); }
.demo__readout { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--text-2); min-height: 1.2em; padding: 0 var(--sp-5) var(--sp-4); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 9999px;
  background: var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--primary);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--primary); cursor: pointer;
}

/* ---------- Chapter view ---------- */
.chapter-view { animation: fadein var(--dur) var(--ease); }
.chapter-header {
  padding: var(--sp-8) 0 var(--sp-6);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-8);
}
.chapter-header__overline { font-size: var(--fs-overline); letter-spacing: 0.08em; text-transform: uppercase; color: var(--primary); font-weight: 600; }
.chapter-header__title { font-size: var(--fs-headline); line-height: var(--lh-headline); letter-spacing: -0.04em; margin: var(--sp-2) 0 var(--sp-3); }
.chapter-header__subtitle { font-size: 18px; color: var(--text-2); }
.chapter-header__meta { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-4); }

.chapter-nav { display: flex; justify-content: space-between; gap: var(--sp-4); margin-top: var(--sp-12); padding-top: var(--sp-6); border-top: 1px solid var(--border); }
.chapter-nav__link { display: flex; flex-direction: column; gap: 2px; max-width: 48%; }
.chapter-nav__link--next { text-align: right; align-items: flex-end; }
.chapter-nav__dir { font-size: var(--fs-caption); color: var(--text-3); }
.chapter-nav__name { font-weight: 600; color: var(--text); }
.chapter-nav__link:hover .chapter-nav__name { color: var(--primary); }

.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-small); font-weight: 500; margin-bottom: var(--sp-4); }

/* ---------- Search modal ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: start center;
  padding: 12vh 24px 24px;
}
.search-overlay[hidden] { display: none; }
.search-modal {
  width: 100%;
  max-width: 620px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.search-modal__input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}
.search-modal__input input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
  outline: none;
}
.search-modal__input input::placeholder { color: var(--neutral); }
.search-modal__esc {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 2px 6px;
}
.search-modal__results { max-height: 50vh; overflow-y: auto; }
.search-result { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.search-result:hover { background: var(--bg-alt); }
.search-result:last-child { border-bottom: none; }
.search-result__title { font-weight: 600; color: var(--text); font-size: var(--fs-small); }
.search-result__excerpt { font-size: var(--fs-caption); color: var(--text-2); }
.search-result__match { background: var(--warning-tint); border-radius: 2px; padding: 0 1px; }
.search-empty { padding: var(--sp-8); text-align: center; color: var(--text-3); font-size: var(--fs-small); }

/* ---------- Loading ---------- */
.loading { display: grid; place-items: center; gap: var(--sp-4); min-height: 50vh; }
.loading__bar { width: 160px; height: 4px; border-radius: 9999px; background: var(--border); overflow: hidden; position: relative; }
.loading__bar::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--primary);
  border-radius: 9999px;
  animation: load 1.2s var(--ease) infinite;
}
.loading__text { color: var(--text-3); font-size: var(--fs-small); }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }

@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Responsive ---------- */
#nav-toggle { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    bottom: 0;
    width: min(320px, 84vw);
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform var(--dur) var(--ease);
    z-index: 60;
    padding: var(--sp-4);
    max-height: none;
  }
  .sidebar.is-open { transform: none; }
  #nav-toggle { display: grid; }
  .nav__links { display: none; }
  .search-trigger__label { display: none; }
}

@media (max-width: 560px) {
  .layout { padding: var(--sp-4) var(--sp-4) var(--sp-12); }
  .hero { padding: var(--sp-10) 0 var(--sp-8); }
  .chapters-grid, .playground-grid { grid-template-columns: 1fr; }
  .chapter-nav { flex-direction: column; }
  .chapter-nav__link { max-width: 100%; }
  .chapter-nav__link--next { align-items: flex-start; text-align: left; }
}

/* ============================================================
   Composed chapter view (ingested blocks)
   ============================================================ */
.chapter-header__source {
  font-size: var(--fs-caption);
  color: var(--text-3);
  margin-top: var(--sp-3);
}
.overline {
  font-size: var(--fs-overline);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  font-weight: 600;
  margin-bottom: var(--sp-3);
}

/* overview card */
.chapter-overview { margin-bottom: var(--sp-8); }
.overview-lead { font-size: 16px; color: var(--text-2); margin-bottom: var(--sp-5); max-width: 72ch; }
.overview-stats { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-bottom: var(--sp-6); }
.overview-stat { display: flex; align-items: baseline; gap: 6px; padding: 8px 12px; background: var(--bg-alt); border-radius: var(--r-md); }
.overview-stat__num { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.overview-stat__label { font-size: var(--fs-caption); color: var(--text-3); }
.overview-cols { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-8); }
@media (max-width: 780px) { .overview-cols { grid-template-columns: 1fr; } }

.toc-list { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow: auto; }
.toc-list li { border-bottom: 1px solid var(--border); }
.toc-link { display: flex; gap: 10px; padding: 8px 4px; color: var(--text-2); font-size: var(--fs-small); }
.toc-link:hover { color: var(--primary); }
.toc-num { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); min-width: 22px; }

.formula-index summary { cursor: pointer; font-size: var(--fs-small); color: var(--text-2); padding: 6px 0; }
.formula-index__list { max-height: 340px; overflow: auto; }
.formula-index__row { border-bottom: 1px solid var(--border); }
.formula-index__link { display: flex; gap: 10px; align-items: center; padding: 7px 4px; color: var(--text); }
.formula-index__sec { font-family: var(--font-mono); font-size: 11px; color: var(--primary); min-width: 34px; }
.formula-index__tex { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.formula-index__tex .katex { font-size: 0.9em; }

/* article sections */
.article { display: flex; flex-direction: column; }
.article-section { padding: var(--sp-6) 0; border-bottom: 1px solid var(--border); scroll-margin-top: calc(var(--nav-h) + 24px); }
.article-section__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: var(--sp-3); flex-wrap: wrap; }
.article-section__num { font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--primary); }
.article-section__title { font-size: var(--fs-subhead); font-weight: 600; letter-spacing: -0.03em; }
.article-section__src { font-size: var(--fs-caption); color: var(--text-3); margin-left: auto; }
.article-section__body { max-width: 82ch; }

/* blocks */
.blk-p { margin: 0 0 var(--sp-4); }
.blk-h { font-size: 18px; margin: var(--sp-6) 0 var(--sp-2); }
.blk-list { margin: 0 0 var(--sp-4); padding-left: 22px; }
.blk-list li { margin: 4px 0; }
.formula-block { margin: var(--sp-4) 0; overflow-x: auto; padding: 2px 0; }
.blk-table-wrap { overflow-x: auto; margin: var(--sp-4) 0; }
.blk-table { border-collapse: collapse; width: 100%; font-size: var(--fs-small); border: 1px solid var(--border); border-radius: var(--r-md); display: table; }
.blk-table th, .blk-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.blk-table thead { background: var(--surface-2); }
.blk-table th { color: var(--text-2); font-weight: 600; }
.blk-code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; overflow: auto; font-size: 13px; }

/* callouts */
.callout { border: 1px solid var(--border); border-left: 3px solid var(--primary); background: var(--surface); border-radius: var(--r-md); padding: 14px 16px; margin: var(--sp-4) 0; }
.callout__label { font-size: var(--fs-overline); letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; color: var(--primary); margin-bottom: 6px; }
.callout__body > *:last-child { margin-bottom: 0; }
.callout__body p { margin: 0 0 var(--sp-2); color: var(--text-2); }
.callout__body .formula-block { margin: var(--sp-2) 0; }
.callout--supplement { border-left-color: var(--warning); background: var(--warning-tint); }
.callout--supplement .callout__label { color: var(--warning); }
.callout--note { border-left-color: var(--neutral); background: var(--bg-alt); }
.callout--note .callout__label { color: var(--text-3); }
.callout--quote { border-left-color: var(--secondary); background: var(--secondary-tint); }
.callout--quote .callout__label { color: var(--secondary); }
.callout--definition { border-left-color: var(--primary); background: var(--primary-tint); }
.callout--theorem { border-left-color: var(--success); background: var(--success-tint); }
.callout--theorem .callout__label { color: var(--success); }
.callout--proof { border-left-color: var(--border); background: var(--surface-2); }
.callout--proof .callout__label { color: var(--text-3); }
.callout--example { border-left-color: var(--success); }
.callout--example .callout__label { color: var(--success); }
.callout--problem { border-left-color: var(--warning); }
.callout--problem .callout__label { color: var(--warning); }

/* appendix source map */
.appendix { margin-top: var(--sp-12); padding-top: var(--sp-8); border-top: 1px solid var(--border); }
.appendix__title { font-size: var(--fs-section); margin-bottom: var(--sp-2); }
.appendix__desc { color: var(--text-2); font-size: var(--fs-small); margin-bottom: var(--sp-4); }
.filter-chips { display: flex; gap: 8px; margin-bottom: var(--sp-3); }
.source-map-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--border); border-radius: var(--r-md); }
.source-map { border-collapse: collapse; width: 100%; font-size: var(--fs-caption); }
.source-map th, .source-map td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.source-map thead { position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
.source-map th { color: var(--text-2); font-weight: 600; }
.source-map td.mono { font-family: var(--font-mono); color: var(--text-2); white-space: nowrap; }
.source-map td.cm-cell { white-space: nowrap; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--border); margin-right: 6px; vertical-align: middle; }
.dot--on { background: var(--success); }

.related { margin-top: var(--sp-8); }
.chapter-nav__inner { display: flex; justify-content: space-between; gap: var(--sp-4); width: 100%; }

/* precision: .prose table would otherwise force display:block on typed tables */
.prose .blk-table { display: table; }
.prose .blk-table-wrap { margin: var(--sp-4) 0; }

/* inline math inside headings must match the heading scale */
.article-section__title .katex { font-size: 0.9em; }
.toc-title .katex { font-size: 1em; }
.chapter-header__title .katex { font-size: 0.9em; }

/* degree → size cue: hub halo grows with connection count */
.g-halo { opacity: 0.1; pointer-events: none; }
.g-node.is-hub.is-active .g-halo { opacity: 0.2; }

/* vis-network container */
.graph-canvas { height: 560px; }
.graph-canvas .vis-network { outline: none; }
@media (max-width: 700px) { .graph-canvas { height: 440px; } }

/* wider graph canvas for always-on labels */
.graph-canvas { height: 720px; }
@media (max-width: 700px) { .graph-canvas { height: 520px; } }

/* always-on labels need more room */
.graph-canvas { height: 760px; }
