/* ============================================================
   MACHINE LEARNING FOUNDATIONS — LESSON PAGE STYLESHEET
   freeCodeCamp-style 3-column lesson layout (sidebar / content / TOC)
   Re-themed accent: teal/cyan (var(--purple-light)/var(--purple-dark))
   in place of the original violet palette, to visually distinguish
   this ML site from the sibling Hinton-history site.
   All colors, sizes and spacing are exposed as CSS variables in
   :root so this template can be re-skinned for any course/content
   without touching the rules below.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&display=swap');
@import url('https://cdn.jsdelivr.net/npm/hack-font@3/build/web/hack.css');

:root {
  /* ── Brand tokens (swap these to re-theme the whole page) ── */
  --navy:        #0a0a23;
  --navy-80:     #1b1b32;
  --navy-70:     #2a2a40;
  --navy-60:     #3b3b4f;
  --navbar-background: #3b3b4f;
  --white:       #ffffff;
  --off-white:   #f5f6f7;
  --gray-10:     #dfdfe2;
  --gray-20:     #d0d0d5;

  /* Semantic accent colours */
  --purple-light:#7dd3fc;
  --purple-dark: #0e7490;
  --yellow-light:#f1be32;
  --yellow-dark: #4d3800;
  --blue-light:  #99c9ff;
  --blue-dark:   #002ead;
  --green-light: #acd157;
  --green-dark:  #00471b;
  --red:         #d92d20;
  --red-bg:      #fdecea;

  /* ── Callout tokens ── */
  --new-concept-bg:       var(--blue-dark);
  --repeating-concept-bg: var(--blue-light);
  --repeating-concept-label: #1d5fa5;
  --repeating-concept-text:  #163f73;
  --caution-bg:           var(--yellow-dark);
  --best-practice-bg:     var(--green-dark);
  --common-error-bg:      var(--yellow-light);
  --try-it-bg:            var(--green-light);
  --deep-dive-bg:         var(--purple-light);
  --critical-bg:          var(--purple-dark);

  /* ── Layout ── */
  --sidebar-w:   260px;
  --toc-w:       240px;
  --header-h:    56px;
  --topbar-h:    100px;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow-sm:   0 1px 3px rgba(10,10,35,.08);
  --shadow-md:   0 4px 16px rgba(10,10,35,.10);
  --transition:  .2s ease;

  /* ── Type ── */
  --font-body: 'Lato', sans-serif;
  --font-mono: 'Hack', 'Courier New', monospace;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.78;
  color: var(--navy);
  background: var(--off-white);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── TOP BAR (outer brand strip) ── */
.topbar {
  height: var(--topbar-h);
  text-align: center;
  display: block;
  margin: auto;
  padding: 28px;
  z-index: 1000;
  background: var(--navy);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topbar-brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  color: var(--white); font-weight: 700; font-size: 34px; letter-spacing: .5px;
  text-decoration: none; font-family: var(--font-mono);
}
.topbar-brand img { height: 44px; width: auto; display: block; }

/* ── NAV BAR (course-level nav) ── */
.navbar {
  z-index: 1000;
  height: var(--header-h);
  background: var(--navbar-background);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  margin-bottom: 2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.navbar-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--white); font-weight: 700; font-size: 16px; letter-spacing: -.3px;
  text-decoration: none;
}
.navbar-badge {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--purple-light), var(--blue-light));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: var(--navy);
}
.navbar-links { display: flex; align-items: center; gap: 6px; }
.navbar-btn {
  padding: 6px 14px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8); font-size: 13px; font-family: var(--font-body);
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.navbar-btn:hover { background: rgba(255,255,255,.1); color: var(--white); }
.navbar-btn.primary { background: var(--purple-dark); border-color: var(--purple-dark); color: var(--white); }
.navbar-btn.primary:hover { background: #0c5c74; }
.navbar-search {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-sm); padding: 6px 12px;
  color: rgba(255,255,255,.5); font-size: 13px; cursor: text;
  transition: var(--transition);
}
.navbar-search:hover { background: rgba(255,255,255,.15); }
.search-icon { font-size: 14px; }
.navbar-search kbd {
  margin-left: auto; font-size: 10px; opacity: .5;
  background: rgba(255,255,255,.1); padding: 2px 6px; border-radius: 4px;
  font-family: var(--font-mono);
}

/* ── LESSON SEARCH MODAL ── */
.search-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,10,35,.7);
  z-index: 2100;
  align-items: flex-start;
  justify-content: center;
  padding: 90px 24px 24px;
}
.search-modal-overlay.open { display: flex; }
.search-modal {
  width: min(560px, 100%);
  max-height: min(70vh, 640px);
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(10,10,35,.4);
  display: flex;
  flex-direction: column;
}
.search-modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-10);
  flex-shrink: 0;
}
.search-modal-input {
  flex: 1;
  border: none; outline: none;
  font-family: 'Lato', sans-serif;
  font-size: 15px;
  color: var(--navy);
  background: transparent;
}
.search-modal-input::placeholder { color: var(--navy-60); opacity: .6; }
.search-modal-close {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: none;
  background: var(--off-white);
  color: var(--navy-60);
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.search-modal-close:hover { background: var(--gray-10); color: var(--navy); }
.search-modal-results { overflow-y: auto; padding: 8px; }
.search-modal-result {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: var(--transition);
}
.search-modal-result:hover,
.search-modal-result.active { background: var(--off-white); }
.search-modal-result-title {
  font-family: 'Lato', sans-serif; font-size: 14px; font-weight: 700;
  color: var(--navy);
}
.search-modal-result-meta {
  font-family: 'Lato', sans-serif; font-size: 12px;
  color: var(--navy-60); margin-top: 2px;
}
.search-modal-result mark {
  background: var(--new-concept-bg); color: var(--white);
  border-radius: 3px; padding: 0 2px;
}
.search-modal-empty {
  padding: 28px 16px; text-align: center;
  font-family: 'Lato', sans-serif; font-size: 13.5px;
  color: var(--navy-60);
}

/* ── MAIN 3-COLUMN LAYOUT ── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--toc-w);
  grid-template-rows: auto;
  min-height: calc(100vh - var(--header-h));
}

/* ── LEFT SIDEBAR — LESSON NAVIGATOR ── */
.sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overflow-x: hidden;
  background: var(--white);
  border-right: 1px solid var(--gray-10);
  scrollbar-width: thin; scrollbar-color: var(--gray-10) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-10); border-radius: 4px; }

.sidebar-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--gray-10);
  position: sticky; top: 0; background: var(--white); z-index: 10;
}
.sidebar-title {
  font-size: 11px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--navy-60);
}
.progress-bar-wrap {
  margin-top: 8px; height: 4px; background: var(--gray-10);
  border-radius: 4px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--purple-dark), var(--blue-dark));
  border-radius: 4px;
  transition: width 1s ease;
}
.progress-label { display: flex; justify-content: space-between; margin-top: 5px; font-size: 11px; color: var(--navy-60); }

/* ── SIDEBAR ACCORDION — one collapsible section per part ──
   Rendered dynamically by engine.js: a clickable header (part label +
   lesson count + chevron) toggles its own dropdown of lessons. Multiple
   parts can be open at once; each toggles independently. */
.part-group { border-bottom: 1px solid var(--gray-10); }
.part-group:last-child { border-bottom: none; }
.part-header {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: none; border: none; cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.part-header:hover { background: var(--off-white); }
.part-header-label {
  flex: 1; min-width: 0;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--navy);
}
.part-header-count {
  flex-shrink: 0;
  font-size: 10.5px; font-weight: 600;
  color: var(--navy-60);
  background: var(--gray-10);
  border-radius: 20px;
  padding: 1px 8px;
}
.part-header-chevron {
  flex-shrink: 0;
  font-size: 18px; font-weight: 700; color: var(--navy-60);
  line-height: 1;
  transition: transform .2s ease, color .2s ease;
}
.part-header:hover .part-header-chevron { color: var(--navy); }
.part-group.open .part-header-chevron { transform: rotate(180deg); }
.part-lessons {
  max-height: 0;
  overflow: hidden;
  transition: max-height .25s ease;
}
.part-group.open .part-lessons { max-height: 4000px; }

.lesson-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 16px; cursor: pointer;
  border-left: 3px solid transparent;
  transition: var(--transition); text-decoration: none;
  color: inherit; position: relative;
}
.lesson-item:hover { background: var(--off-white); }
.lesson-item.active { background: #e0f7fa; border-left-color: var(--purple-dark); }
.lesson-item.done .lesson-num { background: var(--green-dark); color: var(--white); }
.lesson-num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--gray-10); color: var(--navy-60);
  font-size: 10px; font-weight: 600; display: flex; align-items: center; justify-content: center;
  margin-top: 1px; transition: var(--transition);
}
.lesson-item.active .lesson-num { background: var(--purple-dark); color: var(--white); }
.lesson-info { flex: 1; min-width: 0; }
.lesson-name { font-size: 13px; font-weight: 500; color: var(--navy); line-height: 1.3; }
.lesson-item.active .lesson-name { color: var(--purple-dark); }
.lesson-meta { font-size: 11px; color: var(--navy-60); margin-top: 1px; }
.lesson-badge { font-size: 10px; padding: 1px 7px; border-radius: 20px; font-weight: 500; flex-shrink: 0; margin-top: 2px; }
.badge-new { background: #eef1ff; color: var(--blue-dark); }
.badge-lab { background: #f3fbea; color: var(--green-dark); }

/* READ PAPER AND COLAB NOTEBOOK RESOURCES */

/* ── ACTION LINKS & BADGES ── */
.action-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.action-badge img { height: 26px; display: block; }
.action-badge:hover { opacity: .85; }
.action-badge.github { background: #24292e; }

/* ── PDF MODAL ── */
.pdf-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,10,35,.7);
  z-index: 2100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pdf-modal-overlay.open { display: flex; }
.pdf-modal {
  position: relative;
  width: min(900px, 100%);
  height: min(90vh, 1100px);
  background: var(--white);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(10,10,35,.4);
  display: flex;
  flex-direction: column;
}
.pdf-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--navy);
  color: var(--white);
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  font-weight: 700;
}
.pdf-modal-close {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.12);
  color: var(--white);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.pdf-modal-close:hover { background: rgba(255,255,255,.25); }
.pdf-modal-frame { flex: 1; border: none; width: 100%; }


/* ── content images are clickable to zoom ── */
.content-body img {
  cursor: zoom-in;
  transition: opacity var(--transition);
}
.content-body img:hover { opacity: .92; }

/* ── IMAGE LIGHTBOX ── */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10,10,35,.7);
  z-index: 2200;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.lightbox-overlay.open { display: flex; }
.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  box-shadow: 0 12px 48px rgba(0,0,0,.5);
  cursor: zoom-out;
}
.lightbox-close {
  position: fixed;
  top: 24px;
  right: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.12);
  color: var(--white);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ── VIDEO EMBEDS ── */
.video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 24px 0 8px;
  background: var(--navy-80);
}
.video-wrap iframe,
.video-wrap video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.video-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: rgba(10, 10, 35, .18);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, background .2s ease;
}
.video-play-overlay.show { opacity: 1; pointer-events: auto; }
.video-play-overlay:hover { background: rgba(10, 10, 35, .28); }
.video-play-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: rgba(255,255,255,.92);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  transition: transform .15s ease;
}
.video-play-overlay:hover .video-play-icon { transform: scale(1.08); }
.video-play-icon svg { width: 26px; height: 26px; margin-left: 4px; fill: var(--purple-dark); }
.video-caption {
  font-size: 13px;
  color: var(--navy-60);
  margin: 0 0 24px;
  text-align: center;
}
.video-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 24px;
}
.video-links .action-badge.colab { padding: 0; background: none; }
.video-links .action-badge.colab img { height: 28px; }
.video-github-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #24292e;
  transition: var(--transition);
  flex-shrink: 0;
}
.video-github-btn:hover { background: #33393f; }
.video-github-btn svg { width: 17px; height: 17px; fill: var(--white); }

.video-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--purple-dark);
  margin: 24px 0 10px;
}

/* ── TABLE ── */
.table-wrap {
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--gray-10);
  border-radius: var(--radius);
}
.content-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-family: 'Lato', sans-serif;
}
.content-table caption {
  caption-side: top;
  text-align: left;
  padding: 14px 18px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--purple-dark);
  background: var(--off-white);
  border-bottom: 1px solid var(--gray-10);
}
.content-table thead th {
  background: var(--navy);
  color: var(--white);
  text-align: left;
  padding: 12px 18px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .03em;
  white-space: nowrap;
}
.content-table tbody td {
  padding: 12px 18px;
  border-top: 1px solid var(--gray-10);
  color: #2c2c45;
  vertical-align: top;
  font-size: 18px;
}
.content-table tbody tr:nth-child(even) { background: var(--off-white); }
.content-table tbody tr:hover { background: #e0f7fa; }
.content-table td strong { color: var(--navy); }

/* ── MAIN CONTENT AREA ── */
.main { min-width: 0; background: var(--white); }

.lesson-header {
  background: var(--navy);
  padding: 32px 48px 28px;
  position: relative; overflow: hidden;
}
.lesson-header::before {
  content: '';
  position: absolute; top: -60px; right: -60px;
  width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(219,184,255,.12) 0%, transparent 70%);
}
.lesson-breadcrumb {
  font-size: 12px; color: rgba(255,255,255,.5); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.lesson-breadcrumb a { color: rgba(255,255,255,.5); text-decoration: none; }
.lesson-breadcrumb a:hover { color: var(--purple-light); }
.lesson-breadcrumb span.sep { opacity: .4; }
.lesson-main-title {
  font-size: 28px; font-weight: 900; color: var(--white); letter-spacing: -.3px;
  line-height: 1.2; margin-bottom: 10px; font-family: var(--font-body);
}
.lesson-subtitle { font-size: 15px; color: rgba(255,255,255,.65); max-width: 540px; font-weight: 300; line-height: 1.7; }
.lesson-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.lesson-tag {
  font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 500;
  border: 1px solid rgba(255,255,255,.15); color: rgba(255,255,255,.7);
  background: rgba(255,255,255,.07);
}
.lesson-actions { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.action-btn {
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; font-family: var(--font-body);
  cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; gap: 7px; border: none;
}
.action-btn.outline { background: rgba(255,255,255,.1); color: var(--white); border: 1px solid rgba(255,255,255,.2); }
.action-btn.outline:hover { background: rgba(255,255,255,.18); }
.action-btn.accent { background: var(--purple-dark); color: var(--white); }
.action-btn.accent:hover { background: #0c5c74; }

.content-body { padding: 40px 48px 80px;  } /* max-width: 780px; */

/* ── CONTENT TYPOGRAPHY ── */
.content-body h2 {
  font-size: 22px; font-weight: 700; color: var(--navy);
  margin: 40px 0 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-10);
  letter-spacing: -.2px; font-family: var(--font-body);
}
.content-body h2:first-child { margin-top: 0; }
.content-body h3 { font-size: 18px; font-weight: 700; color: var(--navy); margin: 28px 0 10px; font-family: var(--font-body); }
.content-body p { margin-bottom: 16px; color: #2c2c45; line-height: 1.85; font-weight: 400; }
.content-body a { color: var(--purple-dark); text-decoration: underline; text-underline-offset: 3px; }
.content-body strong { font-weight: 700; color: var(--navy); }
.content-body ul, .content-body ol { margin: 0 0 16px 20px; }
.content-body li { margin-bottom: 6px; color: #2c2c45; font-weight: 400; }
.content-body img { max-width: 100%; border-radius: var(--radius); margin: 8px 0 24px; display: block; }

/* ── ALERT CALLOUT CARDS ── */
.callout {
  border-radius: var(--radius); padding: 16px 20px;
  margin: 24px 0; border-left: 4px solid;
  display: flex; gap: 14px; align-items: flex-start;
}
.callout-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.callout-body { flex: 1; }
.callout-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.callout-text { font-size: 14px; line-height: 1.6; }

/* one modifier class per callout "type" — add more by following the same pattern */
.callout-new       { background: var(--new-concept-bg); border-color: var(--new-concept-bg); }
.callout-new .callout-label, .callout-new .callout-text { color: var(--white); }

.callout-caution    { background: var(--caution-bg); border-color: var(--caution-bg); }
.callout-caution .callout-label, .callout-caution .callout-text { color: var(--white); }

.callout-best       { background: var(--best-practice-bg); border-color: var(--try-it-bg); }
.callout-best .callout-label, .callout-best .callout-text { color: var(--white); }

.callout-error      { background: var(--common-error-bg); border-color: var(--caution-bg); }
.callout-error .callout-label, .callout-error .callout-text { color: var(--navy); }

/* ── CODE BLOCK ── */
.code-block { background: var(--navy-80); border-radius: var(--radius); padding: 20px 24px; margin: 24px 0; overflow-x: auto; position: relative; }
.code-lang {
  position: absolute; top: 10px; right: 14px;
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.3); font-family: var(--font-mono);
}
.code-block pre { font-family: var(--font-mono); font-size: 13.5px; line-height: 1.75; color: #c8d3f5; white-space: pre; tab-size: 2; }
.code-block .kw { color: #c099ff; }
.code-block .fn { color: #82aaff; }
.code-block .str { color: #c3e88d; }
.code-block .cm { color: rgba(200,211,245,.4); font-style: italic; }
.code-block .num { color: #f78c6c; }
.copy-btn {
  position: absolute; top: 10px; right: 60px;
  padding: 4px 10px; border-radius: 4px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.5); font-size: 11px; font-family: var(--font-body);
  cursor: pointer; transition: var(--transition);
}
.copy-btn:hover { background: rgba(255,255,255,.2); color: var(--white); }

/* ── MATH BLOCK (KaTeX) ── */
.math-block {
  background: var(--off-white);
  border: 1px solid var(--gray-10);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
  overflow-x: auto;
  text-align: center;
}
.math-block .katex-display { margin: 0; }
.math-block .katex { font-size: 1.15em; }

/* ── KEY TERM CHIPS ── */
.term-chip {
  display: inline-block; padding: 1px 9px; border-radius: 20px;
  font-size: 12.5px; font-weight: 400; font-family: var(--font-mono);
  background: #e0f7fa; color: var(--purple-dark);
  border: 1px solid rgba(14,116,144,.15);
  white-space: nowrap;
}
.inline-code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--off-white); padding: 2px 6px; border-radius: 4px;
}

/* ── QUIZ MINI-WIDGET ── */
.quiz-card { background: var(--off-white); border: 1px solid var(--gray-10); border-radius: var(--radius); padding: 24px; margin: 32px 0; }
.quiz-header { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--purple-dark); margin-bottom: 12px; }
.quiz-question { font-size: 15px; font-weight: 500; color: var(--navy); margin-bottom: 16px; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-10); background: var(--white);
  font-size: 15px; cursor: pointer; transition: var(--transition);
  text-align: left; font-family: var(--font-body); font-weight: 400; color: var(--navy);
}
.quiz-option:hover { border-color: var(--purple-light); background: #f0fdfa; }
.quiz-option:disabled { cursor: default; }
.quiz-option.correct { border-color: var(--try-it-bg); background: var(--best-practice-bg); color: var(--white); }
.quiz-option.wrong { border-color: var(--red); background: var(--red-bg); color: var(--red); }

/* ── SHARED SCORE/FEEDBACK BANNER — sits at the TOP of quiz & quizSet cards ── */
.quiz-score-banner {
  display: none;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-family: 'Lato', sans-serif;
}
.quiz-score-banner.show { display: block; }
.quiz-score-banner.pass { background: var(--best-practice-bg); color: var(--white); }
.quiz-score-banner.fail { background: var(--common-error-bg); color: var(--navy); }
.quiz-score-pct { font-size: 22px; font-weight: 800; letter-spacing: -.2px; line-height: 1.3; }
.quiz-score-detail { margin-top: 4px; font-size: 14px; font-weight: 500; opacity: .9; line-height: 1.5; }


/* NEW QUIZ STYLE */

/* ── QUIZ SET (multi-question, graded on submit) ── */
.quizset-card {
  background: var(--off-white);
  border: 1px solid var(--gray-10);
  border-radius: var(--radius);
  padding: 24px;
  margin: 32px 0;
}
.quizset-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--purple-dark); margin-bottom: 20px;
}
.quizset-question-block { margin-bottom: 26px; }
.quizset-question-block:last-of-type { margin-bottom: 22px; }
.quizset-question-num {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--navy-60); margin-bottom: 6px;
}
.quizset-question-text { font-size: 15px; font-weight: 500; color: var(--navy); margin-bottom: 12px; }
.quizset-options { display: flex; flex-direction: column; gap: 8px; }
.quizset-option {
  padding: 10px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-10); background: var(--white);
  font-size: 14.5px; cursor: pointer; transition: var(--transition);
  text-align: left; font-family: 'Lato', sans-serif; font-weight: 400; color: var(--navy);
}
.quizset-option:hover { border-color: var(--purple-light); background: #f0fdfa; }
.quizset-option.selected { border-color: var(--purple-dark); background: #e0f7fa; }
.quizset-option.correct { border-color: var(--try-it-bg); background: var(--best-practice-bg); color: var(--white); }
.quizset-option.wrong { border-color: var(--red); background: var(--red-bg); color: var(--red); }
.quizset-option:disabled { cursor: default; }
.quizset-explanation {
  margin-top: 8px; font-size: 13px; color: var(--navy-60);
  display: none; padding-left: 2px;
}
.quizset-explanation.show { display: block; }
.quizset-submit-btn {
  padding: 10px 22px; border-radius: var(--radius-sm); border: none;
  background: var(--purple-dark); color: var(--white);
  font-family: 'Lato', sans-serif; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
}
.quizset-submit-btn:hover { background: #0c5c74; }
.quizset-submit-btn:disabled { opacity: .5; cursor: default; }
/* positioning tweak only — visual styling now comes from the shared .quiz-score-banner class */
.quizset-score-banner { margin-bottom: 20px; }

/* ── SECTION DIVIDER ── */
.section-divider { height: 1px; background: var(--gray-10); margin: 40px 0; }

/* ── LESSON NAVIGATION FOOTER ── */
.lesson-nav-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 48px; border-top: 1px solid var(--gray-10);
  background: var(--white);
}
.nav-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: var(--radius);
  border: 1.5px solid var(--gray-10); background: var(--white);
  font-family: var(--font-body); font-size: 14px; cursor: pointer;
  transition: var(--transition); color: var(--navy); text-decoration: none;
}
.nav-btn:hover { border-color: var(--purple-dark); color: var(--purple-dark); background: #f0fdfa; }
.nav-btn-label { font-size: 11px; color: var(--navy-60); display: block; margin-bottom: 2px; }
.nav-btn-title { font-weight: 600; }
.nav-btn.next { flex-direction: row-reverse; text-align: right; }
.nav-btn.next .nav-arrow { transform: rotate(180deg); }
.nav-btn.disabled { opacity: .4; pointer-events: none; }

/* ── RIGHT TOC — SECTION NAVIGATOR ── */
.toc {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto; overflow-x: hidden;
  background: var(--off-white);
  border-left: 1px solid var(--gray-10);
  scrollbar-width: thin; scrollbar-color: var(--gray-10) transparent;
}
.toc::-webkit-scrollbar { width: 4px; }
.toc::-webkit-scrollbar-thumb { background: var(--gray-10); border-radius: 4px; }
.toc-inner { padding: 20px 16px; }
.toc-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--navy-60); margin-bottom: 12px; }
.toc-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.toc-item a {
  display: block; padding: 5px 10px;
  font-size: 13px; color: var(--navy-60); text-decoration: none;
  border-radius: var(--radius-sm); border-left: 2px solid transparent;
  transition: var(--transition); line-height: 1.4;
}
.toc-item a:hover { color: var(--navy); background: var(--gray-10); }
.toc-item.active a { color: var(--purple-dark); font-weight: 600; border-left-color: var(--purple-dark); background: #e0f7fa; }
.toc-item.sub a { padding-left: 22px; font-size: 12px; }

.toc-meta { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--gray-10); }
.toc-meta-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--navy-60); margin-bottom: 8px; }
.toc-meta-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.legend { margin-top: 24px; }
.legend-title { font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--navy-60); margin-bottom: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--navy-60); margin-bottom: 7px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* ── MOBILE TOGGLE ── */
.mob-toggle {
  display: none; position: fixed; bottom: 20px; right: 20px; z-index: 900;
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--purple-dark); color: var(--white);
  border: none; font-size: 22px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(14,116,144,.4);
  align-items: center; justify-content: center;
}

/* ── RESPONSIVE ── */
@media (max-width: 1100px) {
  .toc { display: none; }
  .layout { grid-template-columns: var(--sidebar-w) 1fr; }
}
@media (max-width: 720px) {
  :root { --sidebar-w: 0px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: -280px; top: var(--header-h); width: 280px; z-index: 800;
    transition: left .3s ease;
    height: calc(100vh - var(--header-h));
    box-shadow: none;
  }
  .sidebar.open { left: 0; box-shadow: var(--shadow-md); }
  .mob-toggle { display: flex; }
  .content-body { padding: 24px 20px 60px; }
  .lesson-header { padding: 24px 20px 20px; }
  .lesson-main-title { font-size: 20px; }
  .lesson-nav-footer { padding: 16px 20px; }
  .navbar-links .navbar-btn:not(.primary) { display: none; }
  .navbar-search { display: none; }
}
@media (max-width: 480px) {
  .lesson-nav-footer { flex-direction: column; gap: 10px; }
  .nav-btn { width: 100%; justify-content: center; }
  .nav-btn.next { flex-direction: row; text-align: left; }
}


 .site-footer {
    background: var(--navy);
    padding: 40px 48px 28px;
    margin-top: 0;
  }
  .site-footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    /* display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 28px; */
        margin: auto;
  }
  .site-footer-brand {
    font-family: 'Hack', 'Courier New', monospace;
    font-size: 16px;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 6px;
  }
  .site-footer-tagline {
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    color: rgba(255,255,255,.5);
    max-width: 360px;
    line-height: 1.7;
    text-align: center;
    margin: auto;
  }
  .site-footer-container {
      margin: auto;
      text-align: center;
    }
  .site-footer-links {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
  }
  .site-footer-links a,
  .site-footer-links button {
    font-family: 'Lato', sans-serif;
    font-size: 13px;
    color: rgba(255,255,255,.65);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: var(--transition);
  }
  .site-footer-links a:hover,
  .site-footer-links button:hover { color: var(--purple-light); }
  .site-footer-bottom {
    max-width: 1100px;
    margin: 24px auto 0;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,.1);
    font-family: 'Lato', sans-serif;
    font-size: 12px;
    color: rgba(255,255,255,.35);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
  }
  @media (max-width: 720px) {
    .site-footer { padding: 32px 20px 24px; }
    .site-footer-inner { flex-direction: column; }
  }