/* ================================================================
   ML & Statistics Visual Study Guide — Shared Stylesheet
   styles.css  (loaded by inject_shared.py into every HTML page)
   Readable, editorial style — light default, high contrast
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&family=Source+Sans+3:wght@400;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ── */
:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface2: #f3f0eb;
  --border: #e5e0d8;
  --text: #2d2a26;
  --heading: #1a1816;
  --muted: #5c5650;
  --primary: #0d7377;
  --a1: var(--primary);
  --a2: #0d7377;
  --a3: #b8860b;
  --a4: #2e7d32;
  --a5: #c62828;
  --code-bg: #f0ede8;
  --nav-bg: rgba(250, 248, 245, 0.98);

  /* Accent palette — used by chapter inline styles */
  --accent:  #0d7377;
  --accent1: #7c3aed;
  --accent2: #0ea5e9;
  --accent3: #f59e0b;
  --accent4: #10b981;
  --accent5: #f43f5e;
  --gold:    #b8860b;

  /* Aliases used by chapter inline styles */
  --card:      var(--surface);
  --bg2:       var(--surface2);
  --highlight: var(--primary);
  --dim:       var(--muted);
}

[data-theme="dark"] {
  --bg: #1e1c1a;
  --surface: #2a2724;
  --surface2: #36332f;
  --border: #45403a;
  --text: #e8e4df;
  --heading: #f5f2ed;
  --muted: #a39e96;
  --primary: #4db8bc;
  --a1: var(--primary);
  --a2: #4db8bc;
  --a3: #e6b800;
  --a4: #66bb6a;
  --a5: #ef5350;
  --code-bg: #252220;
  --nav-bg: rgba(30, 28, 26, 0.98);

  --accent:  #4db8bc;
  --accent1: #a78bfa;
  --accent2: #38bdf8;
  --accent3: #fbbf24;
  --accent4: #34d399;
  --accent5: #fb7185;
  --gold:    #e6b800;

  --card:      var(--surface);
  --bg2:       var(--surface2);
  --highlight: var(--primary);
  --dim:       var(--muted);
}

/* Unify tag colors */
.ch-card { --ch-color: var(--primary) !important; }


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

/* ── Base ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  line-height: 1.75;
  overflow-x: hidden;
}

/* ── Global Nav Bar ── */
#gn-bar {
  position: sticky;
  top: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 13px;
}

#gn-bar a {
  text-decoration: none;
  padding: 5px 13px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: all .18s;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
}

#gn-home {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent) !important;
  font-weight: 600;
  letter-spacing: .02em;
  flex-shrink: 0;
}

#gn-home:hover {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

#gn-prev {
  color: var(--muted);
  border-color: var(--border) !important;
}

#gn-prev::before {
  content: '← ';
}

#gn-prev:hover {
  background: var(--surface2);
  color: var(--text);
}

#gn-next {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 45%, transparent) !important;
  font-weight: 600;
}

#gn-next::after {
  content: ' →';
}

#gn-next:hover {
  background: var(--primary);
  color: var(--surface);
  border-color: var(--primary) !important;
}

#gn-spacer {
  flex: 1;
  min-width: 0;
}

#gn-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Read-time badge (injected by shared.js into nav) ── */
#gn-readtime {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Hero ── */
.hero {
  background: var(--surface);
  padding: 60px 40px 80px;
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.part-badge {
  display: inline-block;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 6px 18px;
  border-radius: 6px;
  margin-bottom: 20px;
  font-family: 'Source Sans 3', system-ui, sans-serif;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 16px;
  line-height: 1.2;
  font-family: 'Source Sans 3', system-ui, sans-serif;
}

.hero p {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto 30px;
}

/* ── Nav Pills ── */
.nav-pills {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.nav-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 18px;
  border-radius: 100px;
  font-size: .8rem;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
}

.nav-pill:hover,
.nav-pill.active {
  background: var(--a1);
  border-color: var(--a1);
  color: var(--heading);
}

/* ── Container ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 60px 30px;
}

section {
  margin-bottom: 80px;
}

/* ── Sections (numbered blocks within chapters) ── */
.section {
  margin-bottom: 48px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

.section-header h2 {
  margin-bottom: 0;
}

.section-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  margin-top: 4px;
}

/* ── Card Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

/* ── Step indicators (walkthrough-style) ── */
.step-num {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
}

/* ── Animate-in (scroll reveal placeholder) ── */
.anim-in {
  animation: fadeSlideUp .5s ease both;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Section Labels ── */
.section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--a2);
  margin-bottom: 10px;
}

/* ── Headings ── */
h2 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--heading);
  margin-bottom: 16px;
  line-height: 1.2;
}

h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--a2);
  margin-bottom: 12px;
  margin-top: 24px;
}

p {
  color: var(--muted);
  margin-bottom: 16px;
}

strong {
  color: var(--text);
}

/* ── Grid helpers ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 24px;
}

@media(max-width:768px) {

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--heading) 12%, transparent);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--a1));
}

.card .icon {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}

.card h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 8px;
}

.card p {
  font-size: .875rem;
}

/* ── Definition / Blockquote ── */
.definition {
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  border-left: 4px solid var(--primary);
  border-radius: 0 8px 8px 0;
  padding: 28px 32px;
  margin: 24px 0;
  position: relative;
}

.definition .quote-mark {
  font-size: 4rem;
  color: var(--a1);
  opacity: .3;
  position: absolute;
  top: 8px;
  left: 20px;
  font-family: Georgia, serif;
  line-height: 1;
}

.definition p {
  margin: 0;
  font-size: 1rem;
  color: var(--text);
  padding-left: 20px;
}

.definition cite {
  display: block;
  margin-top: 10px;
  font-size: .8rem;
  color: var(--muted);
  padding-left: 20px;
}

/* ── Memory Anchor ── */
.memory-anchor {
  background: color-mix(in srgb, var(--a3) 10%, var(--surface));
  border-left: 4px solid var(--a3);
  border-radius: 0 8px 8px 0;
  padding: 24px 28px;
  margin: 24px 0;
}

.memory-anchor .anchor-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--a3);
  margin-bottom: 8px;
}

.memory-anchor p {
  color: var(--text);
  margin: 0;
  font-size: .95rem;
}

/* ── Tip Box ── */
.tip-box {
  background: color-mix(in srgb, var(--a2) 8%, var(--surface));
  border-left: 4px solid var(--a2);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin: 20px 0;
  font-size: .88rem;
}

.tip-box .tip-label {
  color: var(--a2);
  font-weight: 700;
  font-size: .75rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.tip-box p {
  margin: 0;
  color: var(--muted);
}

/* ── Code Block ── */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin: 20px 0;
  overflow-x: auto;
  position: relative;
}

.code-block pre {
  margin: 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .82rem;
  line-height: 1.7;
  color: var(--text);
}

.code-block .comment {
  color: var(--muted);
}

.code-block .keyword {
  color: var(--a5);
}

.code-block .string {
  color: var(--a4);
}

.code-block .number {
  color: var(--a3);
}

.code-block .function {
  color: var(--primary);
}

/* ── Copy Button (injected by shared.js) ── */
.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  letter-spacing: .04em;
  z-index: 2;
}

.copy-btn:hover {
  background: color-mix(in srgb, var(--primary) 15%, var(--surface));
  color: var(--primary);
  border-color: var(--primary);
}

.copy-btn.copied {
  background: color-mix(in srgb, var(--a4) 15%, var(--surface));
  color: var(--a4);
  border-color: var(--a4);
}

/* ── Summary Table ── */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 24px;
  font-size: .875rem;
}

.summary-table th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--a2);
  border-bottom: 2px solid var(--border);
}

.summary-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  vertical-align: top;
}

.summary-table tr:hover td {
  background: var(--surface2);
}

/* ── Tags ── */
.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 100px;
  font-size: .72rem;
  font-weight: 600;
}

.tag-sup {
  background: color-mix(in srgb, var(--a1) 18%, transparent);
  color: var(--a1);
}

.tag-unsup {
  background: color-mix(in srgb, var(--a4) 18%, transparent);
  color: var(--a4);
}

.tag-semi {
  background: color-mix(in srgb, var(--a3) 18%, transparent);
  color: var(--a3);
}

.tag-rl {
  background: color-mix(in srgb, var(--a5) 18%, transparent);
  color: var(--a5);
}

/* ── Chapter Quiz (click to reveal) ── */
.quiz-section {
  margin-top: 48px;
  margin-bottom: 32px;
}
.quiz-section h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}
.quiz-section > p {
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 24px;
}
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 14px;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.quiz-card:hover {
  background: var(--surface2);
  border-color: var(--a2);
}
.quiz-card.revealed .quiz-a { display: block; }
.quiz-card.revealed .quiz-hint { display: none; }
.quiz-q {
  font-weight: 600;
  color: var(--heading);
  font-size: .95rem;
  margin-bottom: 8px;
}
.quiz-hint {
  font-size: .82rem;
  color: var(--muted);
  font-style: italic;
}
.quiz-a {
  display: none;
  font-size: .9rem;
  color: var(--text);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.quiz-a strong { color: var(--a4); }
.quiz-card[tabindex="0"]:focus {
  outline: 2px solid var(--a1);
  outline-offset: 2px;
}

/* ── Page Nav (prev/next at bottom) ── */
.page-nav {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 60px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.page-nav a {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 28px;
  border-radius: 12px;
  font-size: .88rem;
  font-weight: 600;
  text-decoration: none;
  transition: all .2s;
}

.page-nav a:hover,
.page-nav a.next {
  background: var(--a1);
  border-color: var(--a1);
  color: var(--heading);
}

/* ── Scroll-reveal animation (toggled by shared.js IntersectionObserver) ── */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity .55s ease, transform .55s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ── */
@media(max-width:600px) {
  #gn-bar {
    padding: 7px 10px;
    font-size: 11px;
    gap: 5px;
  }

  #gn-prev,
  #gn-next {
    padding: 4px 9px;
  }

  .hero {
    padding: 50px 20px 60px;
  }

  .container {
    padding: 40px 16px;
  }
}
/* ── Theme Toggle ── */
.theme-toggle {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover {
  color: var(--text);
  background: var(--surface2);
}

/* ── Global Search Bar ── */
.global-search-container {
  max-width: 600px;
  margin: 30px auto 0;
  position: relative;
}
.global-search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 20px 14px 45px;
  border-radius: 100px;
  font-size: 1rem;
  outline: none;
  transition: all .25s;
}
.global-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.global-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.1rem;
}

/* ── Pyodide Live Code ── */
.run-btn {
  position: absolute;
  top: 10px;
  right: 90px;
  background: color-mix(in srgb, var(--a3) 15%, var(--surface));
  border: 1px solid var(--a3);
  color: var(--a3);
  font-size: .72rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all .2s;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  z-index: 2;
}
.run-btn:hover {
  background: var(--a3);
  color: #fff;
}
.output-block {
  background: var(--code-bg);
  border: 1px dashed var(--a3);
  border-top: none;
  margin-top: -24px;
  margin-bottom: 20px;
  padding: 24px 24px 20px;
  border-radius: 0 0 12px 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .8rem;
  color: var(--text);
  white-space: pre-wrap;
  display: none;
}
.output-block.visible {
  display: block;
}

/* ── Editable Code ── */
.code-block code[contenteditable="true"] {
    outline: none;
    cursor: text;
}
.code-block code[contenteditable="true"]:focus {
    box-shadow: inset 0 0 0 2px var(--a1);
    border-radius: 6px;
}

/* ── Edit Hint ── */
.edit-hint {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-family: 'Source Sans 3', system-ui, sans-serif;
    font-size: .7rem;
    color: var(--muted);
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.2s;
}
.code-block:hover .edit-hint,
.code-block:focus-within .edit-hint {
    opacity: 0;
}

/* ── Reset Button ── */
.reset-btn {
    position: absolute;
    top: 10px;
    right: 160px;
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font-size: .75rem;
    font-family: 'Source Sans 3', system-ui, sans-serif;
    z-index: 2;
    transition: background 0.15s, color 0.15s;
}
.reset-btn:hover {
    background: var(--a5);
    color: #fff;
}

/* ── SQL Output Tables ── */
.output-block table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    margin: 4px 0;
}
.output-block table th {
    background: var(--card);
    font-weight: 600;
    text-align: left;
    padding: 6px 10px;
    border-bottom: 2px solid var(--border);
    color: var(--primary);
    font-family: 'Source Sans 3', system-ui, sans-serif;
}
.output-block table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    color: var(--text);
}
.output-block table tr:hover td {
    background: var(--highlight);
}
.output-block .row-count {
    font-size: .75rem;
    color: var(--muted);
    margin-top: 6px;
    font-family: 'Source Sans 3', system-ui, sans-serif;
}

/* ── Matplotlib Output Images ── */
.output-block img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    display: block;
}

/* ── Loading Progress ── */
.output-block .loading-progress {
    color: var(--muted);
    font-style: italic;
    font-size: .8rem;
}
.output-block .loading-progress .done {
    color: var(--a4);
}

/* ── Run SQL Button (distinct color from Python) ── */
.run-sql-btn {
    position: absolute;
    top: 10px;
    right: 90px;
    padding: 3px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--primary);
    cursor: pointer;
    font-size: .75rem;
    font-family: 'Source Sans 3', system-ui, sans-serif;
    z-index: 2;
    transition: background 0.15s, color 0.15s;
}
.run-sql-btn:hover {
    background: var(--primary);
    color: #fff;
}

/* ── Concept Cards (ch_15 / ch_14 style) ── */
.concept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--card-color, var(--primary));
  border-radius: 0 10px 10px 0;
  padding: 16px 20px;
  margin-bottom: 12px;
}

.concept-card h4 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--card-color, var(--heading));
  margin-bottom: 6px;
}

.concept-card p {
  font-size: .88rem;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}

/* ── Memory Box (ch_14 style) ── */
.mem-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent3);
  border-radius: 0 10px 10px 0;
  padding: 16px 20px;
  margin-bottom: 12px;
}

.mem-box .icon {
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.mem-box h4 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 6px;
}

.mem-box p {
  font-size: .88rem;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}

/* ── Memory Hook ── */
.memory-hook {
  background: color-mix(in srgb, var(--accent3) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent3) 25%, var(--border));
  border-radius: 10px;
  padding: 20px 24px;
  margin: 20px 0;
}

.memory-hook p {
  font-size: .95rem;
  line-height: 1.7;
  color: var(--text);
  margin: 0;
}

/* ── Timeline Items ── */
.tl-item {
  position: relative;
  padding-left: 24px;
  margin-bottom: 16px;
  border-left: 2px solid var(--border);
}

.tl-item::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot-color, var(--primary));
}

.tl-item h4 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 4px;
}

.tl-item p {
  font-size: .88rem;
  color: var(--text);
  line-height: 1.6;
  margin: 0;
}

/* ── Part Navigation (multi-part chapters) ── */
.part-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.part-btn {
  padding: 8px 20px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  font-family: 'Source Sans 3', system-ui, sans-serif;
}

.part-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.part-btn.active {
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border-color: var(--primary);
  color: var(--primary);
}

.part-section {
  display: none;
}

.part-section.active {
  display: block;
}

/* ── Part Hero ── */
.part-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}

.part-num {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  opacity: .3;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  line-height: 1;
}

.part-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--heading);
}

.part-tagline {
  font-size: .88rem;
  color: var(--muted);
  margin-top: 4px;
}

/* ── Formula Block ── */
.formula {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 24px;
  margin: 16px 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .9rem;
  color: var(--text);
  line-height: 1.8;
  overflow-x: auto;
}

/* ── Neuron / Arrow (ch_14 RNN diagrams) ── */
.neuron {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  text-align: center;
  line-height: 1.1;
  flex-shrink: 0;
}

.arrow-line {
  height: 2px;
  flex: 1;
  min-width: 24px;
  background: var(--border);
  border-radius: 1px;
}
