/* ============================================================
   wesslen.github.io — style.css
   Dark editorial theme for a data science / GenAI blog
   ============================================================ */

/* ── Google Fonts ────────────────────────────────────────── */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:ital,wght@0,400;0,600;1,400&display=swap");

/* ── CSS Custom Properties (dark mode default) ───────────── */
:root {
  /* ── Surfaces ── */
  --bg: #ffffff;
  --surface: #f8f9fa;
  --surface-2: #f1f3f4;
  --border: #e8eaed;
  --border-strong: #dadce0;
  --text: #202124;
  --muted: #5f6368;

  /* ── Brand accent ── */
  --accent: #1a73e8;
  --accent-rgb: 26, 115, 232;
  --accent-dim: rgba(26, 115, 232, 0.1);
  --accent-glow: rgba(26, 115, 232, 0.22);
  --accent-hover: #1768d1;

  /* ── Secondary accent (citations, h3, IMPORTANT) ── */
  --accent2: #7c3aed;
  --accent2-rgb: 124, 58, 237;
  --accent2-dim: rgba(124, 58, 237, 0.1);

  /* ── Code ── */
  --code-bg: #f6f8fa;
  --code-text: #24292e;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 3px rgba(60, 64, 67, 0.12), 0 1px 2px rgba(60, 64, 67, 0.07);
  --shadow-md: 0 2px 8px rgba(60, 64, 67, 0.12), 0 1px 4px rgba(60, 64, 67, 0.07);
  --shadow-lg: 0 4px 20px rgba(60, 64, 67, 0.12), 0 2px 8px rgba(60, 64, 67, 0.07);

  /* ── Typography ── */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --font-label: "JetBrains Mono", "Fira Code", monospace;

  /* ── Geometry ── */
  --radius: 8px;
  --transition: 0.2s ease;
}

/* ── Light Mode ──────────────────────────────────────────── */
[data-theme="light"] {
  /* ── Surfaces ── */
  --bg: #ffffff;
  --surface: #f8f9fa;
  --surface-2: #f1f3f4;
  --border: #e8eaed;
  --border-strong: #dadce0;
  --text: #202124;
  --muted: #5f6368;

  /* ── Brand accent ── */
  --accent: #1a73e8;
  --accent-rgb: 26, 115, 232;
  --accent-dim: rgba(26, 115, 232, 0.1);
  --accent-glow: rgba(26, 115, 232, 0.22);
  --accent-hover: #1768d1;

  /* ── Secondary accent (citations, h3, IMPORTANT) ── */
  --accent2: #7c3aed;
  --accent2-rgb: 124, 58, 237;
  --accent2-dim: rgba(124, 58, 237, 0.1);

  /* ── Code ── */
  --code-bg: #f6f8fa;
  --code-text: #24292e;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 3px rgba(60, 64, 67, 0.12), 0 1px 2px rgba(60, 64, 67, 0.07);
  --shadow-md: 0 2px 8px rgba(60, 64, 67, 0.12), 0 1px 4px rgba(60, 64, 67, 0.07);
  --shadow-lg: 0 4px 20px rgba(60, 64, 67, 0.12), 0 2px 8px rgba(60, 64, 67, 0.07);

  /* ── Typography ── */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --font-label: "JetBrains Mono", "Fira Code", monospace;

  /* ── Geometry ── */
  --radius: 8px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  /* ── Surfaces ── */
  --bg: #1c2128;
  --surface: #22272e;
  --surface-2: #2d333b;
  --border: #373e47;
  --border-strong: #444c56;
  --text: #cdd9e5;
  --muted: #768390;

  /* ── Brand accent ── */
  --accent: #1a73e8;
  --accent-rgb: 26, 115, 232;
  --accent-dim: rgba(26, 115, 232, 0.1);
  --accent-glow: rgba(26, 115, 232, 0.22);
  --accent-hover: #1768d1;

  /* ── Secondary accent (citations, h3, IMPORTANT) ── */
  --accent2: #7c3aed;
  --accent2-rgb: 124, 58, 237;
  --accent2-dim: rgba(124, 58, 237, 0.1);

  /* ── Code ── */
  --code-bg: #161b22;
  --code-text: #e6edf3;

  /* ── Shadows ── */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.35), 0 1px 4px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.25);

  /* ── Typography ── */
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", monospace;
  --font-label: "JetBrains Mono", "Fira Code", monospace;

  /* ── Geometry ── */
  --radius: 8px;
  --transition: 0.2s ease;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
  overflow-x: hidden; /* prevent page-level horizontal scroll; vertical scroll unaffected */
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition:
    background var(--transition),
    color var(--transition);
  min-height: 100vh;
  overflow-x: hidden; /* belt-and-suspenders alongside html overflow-x: hidden */
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity var(--transition);
}
a:hover {
  opacity: 0.8;
}

img {
  max-width: 100%;
  display: block;
}

/* ── Reading Progress Bar ────────────────────────────────── */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--accent);
  z-index: 1000;
  transition: width 0.1s linear;
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ── Site Header ─────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  transition: background var(--transition);
}

[data-theme="light"] .site-header {
  background: rgba(246, 248, 250, 0.85);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-title .cursor {
  display: inline-block;
  color: var(--accent);
  animation: blink 1.1s step-end infinite;
  margin-left: 1px;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── Theme Toggle ────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius);
  width: 44px; /* 44px minimum touch target */
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  touch-action: manipulation; /* remove 300ms tap delay */
  transition:
    border-color var(--transition),
    color var(--transition),
    background var(--transition);
}
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Hero / Dot-Grid ─────────────────────────────────────── */
.hero {
  position: relative;
  padding: 4rem 1.5rem 2rem;
  overflow: hidden;
}

/* Dot-grid background (notebook feel) */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.5;
  pointer-events: none;
}

/* Fade edges of dot grid */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 40%, var(--bg) 85%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.hero h1 {
  font-family: var(--font-mono);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  color: var(--text);
}

.hero-desc {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 540px;
}

/* ── Layout ──────────────────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Post List ───────────────────────────────────────────── */
.posts-section {
  padding: 1rem 1.5rem 4rem;
}

.posts-header {
  max-width: 760px;
  margin: 0 auto 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
  width: 100%;
}

.post-list {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  list-style: none;
}

/* ── Layout A — Compact Expandable Rows ─────────────────── */
.post-list-a {
  max-width: 760px;
  margin: 0 auto;
}

.series-group-a {
  border-left: 2px solid var(--border);
  margin-bottom: 0.25rem;
}
.series-header-a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 1rem 0.5rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent2);
  letter-spacing: 0.06em;
  border-left: 2px solid var(--accent2);
  margin-left: -2px;
}
.series-header-a .series-count {
  background: var(--accent2-dim);
  border: 1px solid var(--accent2);
  border-radius: 20px;
  padding: 0.1em 0.55em;
  font-size: 0.65rem;
}
.series-slides-link {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0.1em 0.45em;
  opacity: 0.75;
  transition:
    opacity 0.12s,
    background 0.12s;
}
.series-slides-link:hover {
  opacity: 1;
  background: var(--accent-dim);
}

.row-a {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.55rem 1rem 0.55rem 1.25rem;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}
.series-group-a .row-a {
  padding-left: 1.5rem;
}
.row-a:hover {
  background: var(--surface);
}
.row-a.expanded {
  background: var(--surface);
}

.row-a-chevron {
  font-size: 0.6rem;
  color: var(--muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  margin-top: 0.15em;
}
.row-a.expanded .row-a-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}

.row-a-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  flex: 1;
  line-height: 1.3;
}
.row-a:hover .row-a-title,
.row-a.expanded .row-a-title {
  color: var(--accent);
}

.row-a-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 0.2rem;
}
.row-a-date {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--muted);
  white-space: nowrap;
}
.row-a-tags {
  display: flex;
  gap: 0.3rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.row-a-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  padding: 0.1em 0.5em;
  border-radius: 20px;
  border: 1px solid;
  opacity: 0.75;
}
.row-a-expand {
  display: none;
  padding: 0.65rem 1.25rem 0.9rem 2.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
}
.series-group-a .row-a-expand {
  padding-left: 3rem;
}
.row-a-expand.open {
  display: block;
}
.row-a-desc {
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 0.6rem;
}
.row-a-link {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
}
.row-a-link:hover {
  opacity: 0.8;
}

.standalone-divider-a {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  padding: 0.9rem 1rem 0.4rem;
  opacity: 0.6;
}

/* ── Draft badge ─────────────────────────────────────────── */
.draft-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 400;
  color: var(--accent2);
  background: var(--accent2-dim);
  border: 1px solid var(--accent2);
  border-radius: 3px;
  padding: 0.05em 0.4em;
  margin-left: 0.4em;
  vertical-align: middle;
  letter-spacing: 0.04em;
}
.row-a-draft .row-a-title {
  opacity: 0.75;
}
.row-a-draft .row-a-date {
  opacity: 0.5;
}

/* ── Pinned intro card ───────────────────────────────────── */
.intro-card-a {
  max-width: 760px;
  margin: 0 auto 2rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-dim);
  padding: 1rem 1.5rem 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}
.intro-card-a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.intro-label-a {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  flex-shrink: 0;
  white-space: nowrap;
  opacity: 0.8;
}
.intro-title-a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  flex: 1;
  line-height: 1.3;
}
.intro-card-a:hover .intro-title-a {
  opacity: 0.8;
}
.intro-desc-a {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
  flex: 2;
}

/* ── Tag Pills ───────────────────────────────────────────── */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  padding: 0.2em 0.65em;
  border-radius: 20px;
  border: 1px solid;
  font-weight: 400;
  /* Color set dynamically via JS hue rotation */
}

/* ── Post Page Layout ────────────────────────────────────── */
.post-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
  overflow-x: clip; /* clip any child overflow before it reaches the page scroll width */
}

/* Prevent grid item from expanding beyond track width when content
   (tables, code blocks) has a wide min-content size. Without this,
   the 1fr column can blow past the viewport on mobile.
   overflow-x: clip clips any table/code that escapes inner scroll wrappers
   without creating a new scroll container (preserves sticky positioning). */
#article-col {
  min-width: 0;
  overflow-x: clip;
}

@media (min-width: 1200px) {
  .post-layout {
    grid-template-columns: 1fr 240px;
    gap: 4rem;
    align-items: start;
  }
}

/* ── Post Top Nav (back + next) ──────────────────────────── */
.post-top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

/* ── Back Link ───────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  transition: color var(--transition);
}
.back-link:hover {
  color: var(--accent);
  opacity: 1;
}
.back-link svg {
  width: 14px;
  height: 14px;
}

/* ── Next Post Link ──────────────────────────────────────── */
.next-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  transition: color var(--transition);
}
.next-link:hover {
  color: var(--accent);
  opacity: 1;
}
.next-link svg {
  width: 14px;
  height: 14px;
}

/* ── Post Header ─────────────────────────────────────────── */
.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.post-eyebrow {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.post-read-time {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2em 0.75em;
}

.post-title {
  font-family: var(--font-mono);
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.post-description {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.65;
}

/* ── Prose ───────────────────────────────────────────────── */
.prose {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
  word-break: break-word; /* prevent long URLs from blowing out mobile layout */
  overflow-wrap: break-word;
}

/* h2: left accent bar — from Charlotte's content-slide title treatment */
.prose h2 {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.4rem;
  padding-left: 0.85rem;
  border-left: 3px solid var(--accent);
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.prose h3 {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 2rem 0 0.6rem;
  padding-left: 0.6rem;
  border-left: 2px solid var(--accent2);
}

.prose p {
  margin-bottom: 1.25rem;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-dim);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--transition);
}
.prose a:hover {
  text-decoration-color: var(--accent);
}

.prose blockquote {
  margin: 1.75rem 0;
  padding: 1rem 1.5rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
  font-style: italic;
}
.prose blockquote p {
  margin-bottom: 0;
}

/* ── GitHub-style Alerts ─────────────────────────────────── */
.prose .gh-alert {
  margin: 1.75rem 0;
  padding: 0.85rem 1.25rem;
  border-left: 4px solid;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: normal;
  color: var(--text);
}
.prose .gh-alert p {
  margin-bottom: 0.35rem;
}
.prose .gh-alert p:last-child {
  margin-bottom: 0;
}
.prose .gh-alert ul,
.prose .gh-alert ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}
.prose .gh-alert li {
  margin-bottom: 0.3rem;
}
.prose .gh-alert li:last-child {
  margin-bottom: 0;
}
.prose .gh-alert > :last-child {
  margin-bottom: 0;
}
.prose .gh-alert-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

/* NOTE — blue */
.prose .gh-alert-note {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--accent);
}
.prose .gh-alert-note .gh-alert-title {
  color: var(--accent);
}

/* TIP — green */
.prose .gh-alert-tip {
  background: rgba(63, 185, 80, 0.08);
  border-color: #3fb950;
}
.prose .gh-alert-tip .gh-alert-title {
  color: #3fb950;
}
[data-theme="light"] .gh-alert-tip {
  background: rgba(31, 136, 61, 0.08);
  border-color: #1a7f37;
}
[data-theme="light"] .gh-alert-tip .gh-alert-title {
  color: #1a7f37;
}

/* IMPORTANT — violet */
.prose .gh-alert-important {
  background: rgba(167, 139, 250, 0.1);
  border-color: var(--accent2);
}
.prose .gh-alert-important .gh-alert-title {
  color: var(--accent2);
}

/* WARNING — amber */
.prose .gh-alert-warning {
  background: rgba(210, 153, 34, 0.1);
  border-color: #d29922;
}
.prose .gh-alert-warning .gh-alert-title {
  color: #d29922;
}
[data-theme="light"] .gh-alert-warning {
  background: rgba(154, 103, 0, 0.08);
  border-color: #9a6700;
}
[data-theme="light"] .gh-alert-warning .gh-alert-title {
  color: #9a6700;
}

/* CAUTION — red */
.prose .gh-alert-caution {
  background: rgba(248, 81, 73, 0.08);
  border-color: #f85149;
}
.prose .gh-alert-caution .gh-alert-title {
  color: #f85149;
}
[data-theme="light"] .gh-alert-caution {
  background: rgba(207, 34, 46, 0.08);
  border-color: #cf222e;
}
[data-theme="light"] .gh-alert-caution .gh-alert-title {
  color: #cf222e;
}

.prose ul,
.prose ol {
  margin: 0.75rem 0 1.25rem 1.25rem;
}
.prose li {
  margin-bottom: 0.35rem;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}
.prose em {
  color: var(--muted);
}

/* ── Inline Code ─────────────────────────────────────────── */
.prose code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.855em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.2em 0.55em;
  color: var(--code-text);
}

/* ── Code Blocks ─────────────────────────────────────────── */
.prose pre {
  position: relative;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden; /* was: visible — hidden clips wide code to the border box;
                       code { overflow-x: auto } handles horizontal scrolling */
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  padding: 5px; /* inset gap between border and code background */
}

/* Language label tab */
.prose pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 3rem; /* leave room for copy button */
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.3rem 0.6rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-strong);
  border-left: 1px solid var(--border-strong);
  border-radius: 0 0 0 4px;
  z-index: 2;
}

.prose pre code {
  display: block;
  overflow-x: auto;
  padding: 1.3rem 1.75rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.65;
  background: var(--code-bg) !important;
  color: var(--code-text);
  border-radius: calc(var(--radius) - 3px); /* inset from pre border */
  -webkit-overflow-scrolling: touch; /* smooth momentum scroll on iOS */
}

/* Copy button */
.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 0.25rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity var(--transition),
    color var(--transition),
    border-color var(--transition);
  z-index: 5;
}

.prose pre:hover .copy-btn {
  opacity: 1;
}
.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.copy-btn.copied {
  color: #3fb950;
  border-color: #3fb950;
}

/* ── Tables ──────────────────────────────────────────────── */

/* Wrapper div injected by wrapTables() — owns the scroll */
.table-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.75rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.prose table {
  /* min-width: 100% fills the scroll wrapper when content is narrow;
     no width: 100% — that was causing Chrome to propagate the table's
     min-content width up through the scroll wrapper to the page. */
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.885rem;
  /* margin/border/overflow now owned by wrapper */
  margin: 0;
  border: none;
  border-radius: 0;
}

.prose thead {
  background: var(--surface);
}

.prose thead th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.75rem 1.1rem;
  border-bottom: 2px solid var(--accent);
  text-align: left;
  white-space: normal; /* was: nowrap — nowrap forced multi-column tables to huge min-content widths */
  font-weight: 600;
}

.prose tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.prose tbody tr:last-child {
  border-bottom: none;
}
.prose tbody tr:hover {
  background: var(--accent-dim);
}

.prose tbody td {
  padding: 0.65rem 1.1rem;
  vertical-align: top;
  line-height: 1.55;
  /* Override the prose-level word-break so long table content
     triggers horizontal scroll instead of mid-word breaking */
  word-break: normal;
  overflow-wrap: normal;
}

/* ── Callout / Key-Insight Box ───────────────────────────── */
/* Usage: <div class="callout">text</div> in markdown */
.callout {
  margin: 1.75rem 0;
  padding: 1.1rem 1.4rem;
  background: var(--accent-dim);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.975rem;
  line-height: 1.7;
  color: var(--text);
}

.callout strong {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 0.4rem;
}

/* ── Pull Quote ──────────────────────────────────────────── */
/* Usage in markdown: > [!QUOTE]                             */
/*                    > Quote text here.                     */
/*                    > — Attribution, *Work* (year)        */
.prose .pullquote {
  margin: 2.5rem 0;
  padding: 1.75rem 2rem 1.5rem;
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.prose .pullquote::before {
  content: "\201C";
  position: absolute;
  top: 0.5rem;
  right: 1.25rem;
  font-size: 3.5rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.18;
  font-family: Georgia, "Times New Roman", serif;
  pointer-events: none;
  user-select: none;
}
.prose .pullquote-text {
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--text);
  font-style: italic;
  margin: 0 0 0.9rem;
}
.prose .pullquote-attr {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  margin: 0;
}

/* ── Citations & Footnotes ───────────────────────────────── */
/* Inline superscript: [^1] renders as <sup class="cite-ref"> */
.cite-ref {
  line-height: 0;
  vertical-align: super;
  font-size: 0.72em;
}

.cite-ref a {
  font-family: var(--font-mono);
  color: var(--accent2);
  text-decoration: none;
  padding: 0.05em 0.2em;
  border-radius: 3px;
  border: 1px solid var(--accent2-dim);
  background: var(--accent2-dim);
  font-size: 1em;
  transition:
    background var(--transition),
    border-color var(--transition);
}

.cite-ref a:hover {
  background: rgba(167, 139, 250, 0.22);
  border-color: var(--accent2);
  opacity: 1;
  text-decoration: none;
}

[data-theme="light"] .cite-ref a:hover {
  background: rgba(124, 58, 237, 0.15);
}

/* References section at end of post */
.citations {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border);
}

.citations-heading {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  /* override all prose h2 decoration */
  border: none !important;
  border-left: none !important;
  border-bottom: none !important;
  padding: 0 !important;
  margin: 0 0 1rem !important;
}

.cite-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent2);
  flex-shrink: 0;
  min-width: 1.5rem;
  font-weight: 600;
}

.cite-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.cite-list li {
  font-size: 0.865rem;
  color: var(--muted);
  line-height: 1.6;
  display: flex;
  gap: 0.65rem;
  align-items: baseline;
}

.cite-list li a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-dim);
  word-break: break-all;
}

.cite-back {
  font-size: 0.85em;
  color: var(--accent2) !important;
  text-decoration: none !important;
  margin-left: 0.4rem;
  flex-shrink: 0;
}
.cite-back:hover {
  opacity: 0.7;
}

/* ── YouTube Embeds ──────────────────────────────────────── */
/* Inline syntax: [youtube: VIDEO_ID] or [youtube: VIDEO_ID?t=120] */
.yt-embed {
  margin: 2rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.yt-embed iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: none;
}

.yt-caption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.4rem;
  letter-spacing: 0.02em;
}

/* ── TOC Sidebar ─────────────────────────────────────────── */
.toc-sidebar {
  display: none;
  min-width: 0; /* prevent 240px grid track from expanding beyond its declared width */
}

@media (min-width: 1200px) {
  .toc-sidebar {
    display: block;
    position: sticky;
    top: 72px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    border-left: 1px solid var(--border);
    padding-left: 1.5rem;
  }
}

.toc-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.toc-item a {
  font-size: 0.82rem;
  color: var(--muted);
  display: block;
  padding: 0.2rem 0;
  line-height: 1.4;
  transition:
    color var(--transition),
    padding-left var(--transition);
  border-left: 2px solid transparent;
  padding-left: 0.6rem;
  margin-left: -0.6rem;
}

.toc-item a:hover,
.toc-item a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  opacity: 1;
}

.toc-item.h3 a {
  padding-left: 1.4rem;
  margin-left: -0.6rem;
  font-size: 0.78rem;
}

/* Mobile TOC toggle */
.toc-mobile {
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

@media (min-width: 1200px) {
  .toc-mobile {
    display: none;
  }
}

.toc-mobile-toggle {
  width: 100%;
  background: var(--surface);
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.85rem 1rem;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  touch-action: manipulation; /* remove 300ms tap delay */
  min-height: 44px; /* minimum touch target height */
}

.toc-mobile-toggle .toc-chevron {
  transition: transform 0.2s ease;
  font-size: 0.7rem;
  color: var(--muted);
}
.toc-mobile.open .toc-chevron {
  transform: rotate(180deg);
}

.toc-mobile-body {
  display: none;
  padding: 0.5rem 1rem 1rem;
  background: var(--surface);
}
.toc-mobile.open .toc-mobile-body {
  display: block;
}

.toc-mobile-body .toc-list {
  gap: 0.15rem;
}

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.site-footer a {
  color: var(--muted);
}
.site-footer a:hover {
  color: var(--accent);
  opacity: 1;
}
.footer-disclaimer {
  margin-top: 0.5rem;
  font-size: 0.65rem;
  opacity: 0.6;
  line-height: 1.5;
}

/* ── Loading / Error States ──────────────────────────────── */
.loading-state,
.error-state {
  text-align: center;
  padding: 4rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--muted);
}

.loading-dots::after {
  content: "";
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0% {
    content: "";
  }
  25% {
    content: ".";
  }
  50% {
    content: "..";
  }
  75% {
    content: "...";
  }
  100% {
    content: "";
  }
}

/* ── Highlight.js overrides ──────────────────────────────── */
.hljs {
  background: var(--code-bg) !important;
  color: var(--code-text); /* base token colour — always light, code island is always dark */
  padding: 0 !important;
}

/* ── Responsive tweaks ───────────────────────────────────── */

/* Tablet: 641px – 1199px ---------------------------------- */
@media (min-width: 641px) and (max-width: 1199px) {
  /* Constrain line length so text doesn't span the full tablet width */
  .prose {
    max-width: 680px;
  }
  /* Give the hero a comfortable mid-range padding */
  .hero {
    padding: 3rem 2rem 2.5rem;
  }
  .posts-section {
    padding: 2rem 2rem 4rem;
  }
  .post-layout {
    padding: 2rem 2rem 5rem;
  }
}

/* Small mobile: ≤ 640px ------------------------------------ */
@media (max-width: 640px) {
  /* Shrink site title so it fits alongside the 44px toggle */
  .header-actions {
    gap: 0.4rem;
  }
  .nav-link {
    padding: 0.25rem 0.35rem;
    font-size: 0.72rem;
  }

  /* Layout A rows: meta wrapper keeps date+tags tightly grouped on mobile */
  .row-a-tags {
    justify-content: flex-end;
  }
  .site-title {
    font-size: 0.9rem;
  }

  .post-layout {
    padding: 1.5rem 1rem 4rem;
  }
  .posts-section {
    padding: 1.5rem 1rem 4rem;
  }
  .hero {
    padding: 2.5rem 1rem 2rem;
  }
  .prose pre code {
    padding: 1.1rem 1.25rem;
    font-size: 0.82rem;
  }
  .yt-embed {
    margin: 1.5rem 0;
  }

  /* Tighten blockquote / alert padding on narrow screens */
  .prose blockquote,
  .prose .gh-alert {
    padding: 0.75rem 1rem;
  }
}

/* Tiny: ≤ 360px (Galaxy S8, SE 1st gen, etc.) ------------- */
@media (max-width: 360px) {
  .header-actions {
    gap: 0.25rem;
  }
  .nav-link {
    padding: 0.2rem 0.28rem;
    font-size: 0.68rem;
  }
  .site-title {
    font-size: 0.8rem;
    letter-spacing: -0.01em;
  }
  .hero h1 {
    font-size: 1.35rem;
  }
}

/* ── Nav Link (About etc. in site header) ────────────────── */
.nav-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 0.25rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition:
    color var(--transition),
    border-color var(--transition),
    background var(--transition);
  white-space: nowrap;
}
.nav-link:hover,
.nav-link.active {
  color: var(--accent);
  border-color: var(--border);
  background: var(--accent-dim);
  opacity: 1;
}

/* ── Collapsible References (post.html) ──────────────────── */
.citations-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  margin-bottom: 1rem;
}

.citations-toggle:hover .citations-heading {
  color: var(--accent);
}

.citations-chevron {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.citations-toggle[aria-expanded="false"] .citations-chevron {
  transform: rotate(-90deg);
}

.cite-list.collapsed {
  display: none;
}

/* ── Post Navigation ─────────────────────────────────────── */
.post-nav {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.post-nav-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.post-nav-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.post-nav-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color var(--transition);
}

.post-nav-card:hover {
  border-color: var(--accent);
}

.post-nav-meta {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.post-nav-title {
  font-size: 0.9rem;
  color: var(--fg);
  font-weight: 600;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .post-nav-cards {
    grid-template-columns: 1fr;
  }
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* ── Collapsible Math / Details Blocks ───────────────────── */
.math-details {
  margin: 1.75rem 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
}

.math-details summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  color: var(--accent2);
  letter-spacing: 0.02em;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: background 0.15s;
}

.math-details summary::-webkit-details-marker {
  display: none;
}

.math-details summary::before {
  content: "▸";
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.math-details[open] summary::before {
  transform: rotate(90deg);
}

.math-details[open] summary {
  border-bottom-color: var(--border);
  background: var(--accent2-dim);
}

.math-details summary:hover {
  background: var(--accent2-dim);
}

.math-inner {
  padding: 1.25rem 1.25rem 1rem;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
}

.math-inner p {
  margin: 0 0 0.75rem;
}

.math-inner p:last-child {
  margin-bottom: 0;
}

.math-inner .MJX-TEX,
.math-inner mjx-container {
  overflow-x: auto;
  max-width: 100%;
}

/* Displayed (block) math: center and allow scroll on mobile */
.math-inner mjx-container[display="true"] {
  display: block;
  overflow-x: auto;
  padding: 0.5rem 0;
}

/* Tool link / iframe container for interactive models */
.model-embed {
  margin: 2rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.model-embed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.model-embed-label {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.model-embed-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
}

.model-embed-link:hover {
  text-decoration: underline;
}

.model-embed iframe {
  display: block;
  width: 100%;
  border: none;
  background: #0d1219;
  transition: filter 0.3s ease;
}

/* Light mode: invert luminance, hue-rotate to approximately restore colors */
[data-theme="light"] .model-embed iframe {
  filter: invert(1) hue-rotate(180deg);
}

.model-embed-mobile-note {
  display: none;
  padding: 1rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 768px) {
  .model-embed iframe {
    display: none;
  }
  .model-embed-mobile-note {
    display: block;
  }
}

/* ── Term Definition Tooltips ────────────────────────────────
   Applied to first occurrences of glossary terms in posts.
   .term-def: the inline span wrapping the matched text.
   .term-tooltip: the floating card (one shared instance, moved by JS).
─────────────────────────────────────────────────────────────── */
.term-def {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  color: inherit;
  /* no color shift — keep prose tone, just dotted underline */
}
.term-def:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.term-tooltip {
  position: absolute;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  max-width: 300px;
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  font-size: 0.8rem;
  line-height: 1.55;
  transition: opacity 0.12s ease;
}
[data-theme="light"] .term-tooltip {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.term-tooltip-term {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.term-tooltip-full {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.72rem;
}
.term-tooltip-def {
  color: var(--text);
  margin-bottom: 0.4rem;
}
.term-tooltip-more {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent2);
  text-decoration: none;
  margin-top: 0.1rem;
  opacity: 0.85;
}
.term-tooltip-more:hover {
  opacity: 1;
}

/* ── Footnote Popup Tooltips ─────────────────────────────────
   Shown on hover/focus/click of inline footnote superscripts.
   Uses accent2 (violet) to stay distinct from glossary tooltips
   (which use accent/teal + dotted underline).
   The existing violet pill on .cite-ref a is the visual cue —
   no additional underline is added.
─────────────────────────────────────────────────────────────── */
.fn-tooltip {
  position: absolute;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--accent2-dim);
  border-left: 3px solid var(--accent2);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  max-width: 320px;
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  font-size: 0.8rem;
  line-height: 1.55;
}
[data-theme="light"] .fn-tooltip {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.fn-tooltip-num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--accent2);
  margin-bottom: 0.3rem;
  opacity: 0.8;
}
.fn-tooltip-text {
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.6;
}
.fn-tooltip-text a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--accent-dim);
  word-break: break-all;
}

/* ── Search ──────────────────────────────────────────────── */
#search-wrap {
  max-width: 760px;
  margin: -0.5rem auto 1rem;
  position: relative;
  display: flex;
  align-items: center;
}

#search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.5rem 2.2rem 0.5rem 0.85rem;
  outline: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  /* Remove browser default search input chrome */
  -webkit-appearance: none;
  appearance: none;
}
#search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
#search-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
#search-input::-webkit-search-cancel-button,
#search-input::-webkit-search-decoration {
  display: none;
}

#search-clear {
  position: absolute;
  right: 0.55rem;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.6rem;
  display: none;
  padding: 0.25rem 0.35rem;
  border-radius: 3px;
  line-height: 1;
  user-select: none;
  transition: color var(--transition);
}
#search-clear:hover {
  color: var(--text);
}

/* ── Search results panel ───────────────────────────────── */
#search-results {
  display: none;
  max-width: 760px;
  margin: 0 auto 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}
#search-results.active {
  display: block;
}

.sr-count {
  padding: 0.35rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.04em;
}

.sr-empty {
  padding: 1rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.sr-item {
  display: block;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition);
}
.sr-item:last-child {
  border-bottom: none;
}
.sr-item:hover,
.sr-item.sr-focused {
  background: var(--surface);
}

.sr-item-header {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}
.sr-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  flex: 1;
  min-width: 0;
}
.sr-series {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--accent2);
  background: var(--accent2-dim);
  border: 1px solid var(--accent2);
  border-radius: 20px;
  padding: 0.1em 0.5em;
  white-space: nowrap;
  flex-shrink: 0;
}
.sr-date {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  flex-shrink: 0;
}
.sr-glossary-badge {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: #34d399; /* emerald — distinct from series violet */
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 20px;
  padding: 0.1em 0.5em;
  white-space: nowrap;
  flex-shrink: 0;
}
[data-theme="light"] .sr-glossary-badge {
  color: #059669;
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.3);
}
.sr-snippet {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.55;
}
.sr-snippet mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 0.1em;
  font-style: normal;
}

@media (max-width: 640px) {
  #search-wrap {
    margin-top: -0.25rem;
  }
  .sr-series {
    display: none;
  } /* series badge too wide on phones */
}

/* ── Header search icon button ───────────────────────────── */
.search-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  transition:
    color var(--transition),
    background var(--transition);
  padding: 0;
  flex-shrink: 0;
}
.search-trigger:hover {
  color: var(--text);
  background: var(--surface);
}
.search-trigger svg {
  display: block;
}

/* ── Search modal overlay ────────────────────────────────── */
#sm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: flex-start;
  justify-content: center;
  padding-top: clamp(4rem, 10vh, 8rem);
}
#sm-overlay.sm-open {
  display: flex;
}

#sm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
[data-theme="light"] #sm-backdrop {
  background: rgba(0, 0, 0, 0.35);
}

#sm-panel {
  position: relative;
  width: min(620px, calc(100vw - 2rem));
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - clamp(4rem, 10vh, 8rem) - 2rem);
}
[data-theme="light"] #sm-panel {
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

#sm-input-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#sm-search-icon {
  color: var(--muted);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
#sm-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  -webkit-appearance: none;
  appearance: none;
}
#sm-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
#sm-input::-webkit-search-cancel-button {
  display: none;
}

#sm-esc-hint {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.15em 0.45em;
  cursor: pointer;
  flex-shrink: 0;
  user-select: none;
}
#sm-esc-hint:hover {
  color: var(--text);
}

#sm-results {
  overflow-y: auto;
  overscroll-behavior: contain;
  flex: 1;
}

.sm-empty {
  padding: 1.25rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.sm-item {
  display: block;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition);
}
.sm-item:last-child {
  border-bottom: none;
}
.sm-item:hover,
.sm-item.sm-focused {
  background: var(--surface);
}

.sm-item-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  flex-wrap: wrap;
}
.sm-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--accent);
  flex: 1;
  min-width: 0;
}
.sm-badge {
  font-family: var(--font-mono);
  font-size: 0.57rem;
  color: var(--accent2);
  background: var(--accent2-dim);
  border: 1px solid var(--accent2);
  border-radius: 20px;
  padding: 0.1em 0.5em;
  white-space: nowrap;
  flex-shrink: 0;
}
.sm-badge-glossary {
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.35);
}
[data-theme="light"] .sm-badge-glossary {
  color: #059669;
  background: rgba(5, 150, 105, 0.08);
  border-color: rgba(5, 150, 105, 0.3);
}
.sm-date {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  flex-shrink: 0;
}
.sm-snippet {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
}
.sm-snippet mark {
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 0.1em;
  font-style: normal;
}

#sm-footer {
  display: flex;
  gap: 1rem;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
#sm-footer span {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
#sm-footer kbd {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1em 0.35em;
  color: var(--muted);
}

.sm-body-lock {
  overflow: hidden;
}

@media (max-width: 640px) {
  #sm-overlay {
    padding-top: 0;
    align-items: flex-end;
  }
  #sm-panel {
    width: 100vw;
    border-radius: calc(var(--radius) * 1.5) calc(var(--radius) * 1.5) 0 0;
    max-height: 80vh;
  }
  #sm-footer {
    display: none;
  }
  .sm-badge {
    display: none;
  }
}

/* ── Hamburger / Mobile Nav ──────────────────────────────── */
/* Button: hidden on desktop, shown on mobile */
.nav-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  touch-action: manipulation;
  flex-shrink: 0;
  transition:
    border-color var(--transition),
    color var(--transition);
}
.nav-hamburger:hover {
  color: var(--text);
  border-color: var(--muted);
}

/* Dropdown panel: fixed below the sticky header */
.mobile-nav {
  display: none;
  position: fixed;
  top: 56px; /* matches .header-inner height */
  left: 0;
  right: 0;
  z-index: 99;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1.25rem 0.75rem;
  flex-direction: column;
  gap: 0.15rem;
  /* Subtle slide-in */
  animation: mobileNavIn 0.15s ease;
}
.mobile-nav.open {
  display: flex;
}
@keyframes mobileNavIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.mobile-nav .nav-link {
  font-size: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  display: block;
}

/* On mobile: hide nav-links from header row, show hamburger */
@media (max-width: 640px) {
  .header-actions .nav-link {
    display: none;
  }
  .nav-hamburger {
    display: flex;
  }
}

/* ── Quiz widget ─────────────────────────────────────────── */
.quiz-section {
  margin: 3rem 0 2rem;
  border-top: 1px solid var(--border);
  padding-top: 2rem;
}

.quiz-header {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 1.25rem;
}

.quiz-progress {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.875rem;
}

.quiz-objective-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent2);
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
  opacity: 0.75;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.quiz-question-image {
  display: block;
  width: 100%;
  max-width: 560px;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid var(--border);
  margin: 0 0 1rem 0;
}

.quiz-question {
  font-size: 0.975rem;
  line-height: 1.65;
  color: var(--text);
  margin: 0 0 1.125rem 0;
  font-weight: 500;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.55;
  transition:
    border-color 0.15s,
    background 0.15s;
  width: 100%;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option.correct {
  border-color: #2ea043;
  background: rgba(46, 160, 67, 0.1);
}

.quiz-option.incorrect {
  border-color: #f85149;
  background: rgba(248, 81, 73, 0.08);
}

.quiz-option.revealed-correct {
  border-color: #2ea043;
  background: rgba(46, 160, 67, 0.06);
}

[data-theme="light"] .quiz-option.correct {
  background: rgba(46, 160, 67, 0.08);
}

[data-theme="light"] .quiz-option.incorrect {
  background: rgba(204, 0, 0, 0.06);
  border-color: #cc0000;
}

[data-theme="light"] .quiz-option.revealed-correct {
  background: rgba(46, 160, 67, 0.06);
}

.option-letter {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  min-width: 1.1rem;
  padding-top: 0.1rem;
  flex-shrink: 0;
}

.option-text {
  flex: 1;
}

.quiz-explanation {
  margin-top: 1rem;
  padding: 0.875rem 1rem;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0;
}

.quiz-explanation-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.quiz-explanation-text {
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--text);
  margin: 0;
}

.quiz-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.quiz-btn {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    background 0.15s,
    color 0.15s;
}

.quiz-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* End screen */
.quiz-end {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  text-align: center;
}

.quiz-score {
  font-family: var(--font-mono);
  font-size: 2.25rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.quiz-score-label {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0 0 1.5rem 0;
}

.quiz-end-actions {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Quiz progress layer ─────────────────────────────── */

/* Revisit nudge (post quiz header) */
.quiz-revisit-nudge {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
  margin-bottom: 1rem;
  opacity: 0.8;
}

/* Browser-local disclaimer (inside quiz end screen) */
.quiz-local-note {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 1.25rem;
  opacity: 0.6;
}

/* Checkmark badge on post index cards */
.quiz-done-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: #2ea043;
  border: 1px solid #2ea043;
  border-radius: 3px;
  padding: 0 0.3rem;
  line-height: 1.5;
  margin-left: 0.45rem;
  vertical-align: middle;
  opacity: 0.85;
  flex-shrink: 0;
  position: relative;
  top: -0.05em;
}

/* Module progress indicator on slides cards */
.module-progress-indicator {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  color: #2ea043;
  margin-top: 0.25rem;
  opacity: 0.9;
}

/* ═══════════════════════════════════════════════════════════
   Index page: intro feature + module grid
   ═══════════════════════════════════════════════════════════ */

.index-modules {
  padding: 1.5rem 1.5rem 4rem;
}
.index-modules-inner {
  max-width: 860px;
  margin: 0 auto;
}

/* ── Wide intro post card ─────────────────────────────── */
.index-intro-feature {
  display: grid;
  grid-template-columns: minmax(auto, 220px) 1fr;
  grid-template-areas:
    "label desc"
    "title desc"
    "link  desc";
  align-items: start;
  column-gap: 2rem;
  row-gap: 0.3rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-dim);
  padding: 1rem 1.5rem 1rem 1.75rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}
.index-intro-feature::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
}
.intro-feature-label {
  grid-area: label;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  opacity: 0.8;
  align-self: end;
}
.intro-feature-title {
  grid-area: title;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  line-height: 1.3;
}
.intro-feature-title:hover {
  opacity: 0.8;
}
.intro-feature-desc {
  grid-area: desc;
  align-self: center;
  font-size: 0.875rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}
.intro-feature-link {
  grid-area: link;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent);
  text-decoration: none;
  align-self: start;
}
.intro-feature-link:hover {
  opacity: 0.8;
}

/* ═══════════════════════════════════════════════════════════
   Slide card grid (shared: index.html + slides.html)
   ═══════════════════════════════════════════════════════════ */

.slides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}
.slide-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.4rem 1.1rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: border-color 0.15s;
  min-width: 0;
}
.slide-card:hover {
  border-color: var(--accent2);
}
.slide-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.slide-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  margin: 0;
}
.slide-card-badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.15em 0.55em;
  border-radius: 3px;
  white-space: nowrap;
  flex-shrink: 0;
}
.slide-card-badge.published {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
}
.slide-card-badge.soon {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}
.slide-card-desc {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}
.slide-card-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: auto;
  padding-top: 0.75rem;
  flex-wrap: wrap;
}
.slide-btn {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.3em 0.85em;
  border-radius: 4px;
  text-decoration: none;
  border: 1px solid;
  transition:
    background 0.12s,
    color 0.12s;
  line-height: 1.5;
}
.slide-btn-html {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.slide-btn-html:hover {
  background: var(--accent);
  color: var(--bg);
}
.slide-btn-pdf {
  background: var(--accent2-dim);
  border-color: var(--accent2);
  color: var(--accent2);
}
.slide-btn-pdf:hover {
  background: var(--accent2);
  color: var(--bg);
}
.slide-btn-quiz {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent2);
  background: rgba(124, 58, 237, 0.08);
  color: var(--accent2);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    background 0.15s,
    color 0.15s;
  text-decoration: none;
  display: inline-block;
}
.slide-btn-quiz:hover {
  background: var(--accent2);
  color: #fff;
}
.slide-btn-quiz[aria-disabled="true"] {
  opacity: 0.38;
  cursor: not-allowed;
  background: transparent;
  border-color: var(--muted);
  color: var(--muted);
  pointer-events: auto;
}
.slide-btn-quiz[aria-disabled="true"]:hover {
  background: transparent;
  color: var(--muted);
}
/* tooltip wrapper for locked quiz button */
.quiz-btn-wrap {
  position: relative;
  display: inline-block;
}
.quiz-btn-wrap[data-locked]::after {
  content: attr(data-locked);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  white-space: nowrap;
  padding: 0.3em 0.6em;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.quiz-btn-wrap[data-locked]:hover::after {
  opacity: 1;
}
.slide-card-divider {
  height: 1px;
  background: var(--border);
  margin: 0.25rem 0;
}

/* ── Slide card post items (scp) ──────────────────────── */
.scp-list {
  border-top: 1px solid var(--border);
  margin-top: 0.1rem;
  padding-top: 0.15rem;
  min-width: 0;
}
.scp-item {
  position: relative;
  border-radius: 3px;
  transition: background 0.12s;
  min-width: 0;
}
.scp-item:hover {
  background: var(--surface-2);
}
.scp-header {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  padding: 0.3rem 0.3rem 0.2rem;
}
.scp-chevron {
  font-size: 0.5rem;
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 0.32rem;
  transition:
    transform 0.15s,
    color 0.15s;
}
.scp-item:hover .scp-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}
.scp-title-row {
  flex: 1;
  min-width: 0;
}
.scp-title {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  text-decoration: none;
}
.scp-item:hover .scp-title {
  color: var(--accent);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.scp-date {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  margin-top: 0.1rem;
  opacity: 0.7;
}
.scp-quiz-check {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--muted);
  flex-shrink: 0;
  margin-top: 0.05rem;
  opacity: 0.4;
  line-height: 1;
  user-select: none;
}
.scp-quiz-done {
  color: #2ea043;
  opacity: 1;
}
.scp-expand {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  box-shadow: var(--shadow-md);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.scp-item:hover .scp-expand {
  opacity: 1;
  pointer-events: auto;
}
.scp-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0.15rem 0 0.3rem;
}
.scp-foot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.4rem;
}
.scp-link {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
  text-decoration: none;
}
.scp-link:hover {
  opacity: 0.8;
}
.scp-tags {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
}

/* ── Module quiz modal ────────────────────────────────── */
.module-quiz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 900;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.module-quiz-dialog {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.module-quiz-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.module-quiz-dialog-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.module-quiz-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  line-height: 1;
  transition:
    color 0.15s,
    background 0.15s;
}
.module-quiz-close:hover {
  color: var(--text);
  background: var(--surface-2);
}
.module-quiz-dialog-body {
  padding: 1.5rem 1.25rem;
}
.quiz-loading {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 2rem 0;
}
.quiz-progress-bar-wrap {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 0.5rem;
  overflow: hidden;
}
.quiz-progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.quiz-progress-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}
.quiz-end-module {
  text-align: center;
}
.quiz-breakdown {
  margin: 1.25rem auto 1.5rem;
  max-width: 320px;
  text-align: left;
}
.quiz-breakdown-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}
.quiz-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.825rem;
  gap: 1rem;
}
.quiz-breakdown-name {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}
.quiz-breakdown-score {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text);
  flex-shrink: 0;
}
.quiz-breakdown-score.perfect {
  color: #2ea043;
}

/* ── Module grid responsive ───────────────────────────── */
@media (max-width: 640px) {
  /* Single-column card grid */
  .slides-grid {
    grid-template-columns: 1fr;
  }
  .index-modules {
    padding: 1rem 1rem 3rem;
  }

  /* Intro feature: collapse 2-col grid to stacked single column */
  .index-intro-feature {
    grid-template-columns: 1fr;
    grid-template-areas:
      "label"
      "title"
      "desc"
      "link";
    row-gap: 0.4rem;
    padding: 0.85rem 1.1rem 0.85rem 1.4rem;
  }
  .intro-feature-desc {
    align-self: auto;
  }

  /* Tooltip: clamp to card width so it can't bleed off screen */
  .scp-expand {
    left: 0;
    right: 0;
    max-width: 100%;
  }

  /* Slide card: tighter padding on small screens */
  .slide-card {
    padding: 1rem 1rem 0.9rem;
  }
}

/* ── Module pass/fail badge ──────────────────────────────── */
.quiz-module-pass,
.quiz-module-fail {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.quiz-module-pass {
  color: #2ea043;
}
.quiz-module-fail {
  color: var(--muted);
}

/* ── Dev mode banner ──────────────────────────────────── */
.dev-mode-banner {
  position: fixed;
  bottom: 0.75rem;
  right: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  background: rgba(255, 200, 0, 0.12);
  border: 1px solid rgba(255, 200, 0, 0.4);
  color: rgba(255, 200, 0, 0.8);
  padding: 0.25em 0.6em;
  border-radius: 4px;
  pointer-events: none;
  z-index: 9999;
  letter-spacing: 0.06em;
}

/* ── Completion zone ──────────────────────────────────── */
.completion-zone {
  margin: 2rem auto 0;
  max-width: 680px;
  padding: 0 1rem;
}
.completion-zone-inner {
  border: 1px solid var(--accent2);
  border-radius: var(--radius);
  background: rgba(124, 58, 237, 0.06);
  padding: 1.5rem 2rem;
  text-align: center;
  transition:
    opacity 0.3s,
    filter 0.3s;
}
/* Locked state: visible but greyed out until all module tests are passed */
.completion-zone--locked .completion-zone-inner {
  border-color: var(--border);
  background: var(--surface);
  opacity: 0.45;
  filter: grayscale(0.6);
}
.completion-zone--locked .completion-label {
  color: var(--muted);
}
/* Show locked/done message variants based on state */
.completion-label--done,
.completion-desc--done {
  display: none;
}
.completion-zone--locked .completion-label--locked,
.completion-zone--locked .completion-desc--locked {
  display: block;
}
.completion-zone--locked .completion-label--done,
.completion-zone--locked .completion-desc--done {
  display: none;
}
.completion-label--locked,
.completion-desc--locked {
  display: none;
}
.completion-zone--locked .completion-cert-btn,
.completion-zone--locked .completion-exam-btn {
  border-color: var(--border);
  background: transparent;
  color: var(--muted);
  cursor: not-allowed;
  pointer-events: none;
}
.completion-label {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent2);
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.4rem;
}
.completion-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 1.25rem;
}
.completion-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}
.completion-cert-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent2);
  background: rgba(124, 58, 237, 0.08);
  color: var(--accent2);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    background 0.15s,
    color 0.15s;
}
.completion-cert-btn:hover {
  background: var(--accent2);
  color: #fff;
}
.completion-exam-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    background 0.15s,
    color 0.15s;
}
.completion-exam-btn:hover {
  background: var(--accent);
  color: var(--bg);
}

/* ── Progress backup zone ─────────────────────────────── */
.quiz-backup-zone {
  margin: 2rem auto 0;
  max-width: 680px;
  padding: 1.25rem 1rem 0;
  border-top: 1px solid var(--border);
}

.quiz-backup-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.7rem;
}

.quiz-backup-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
  align-items: center;
}

.quiz-backup-btn {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
  display: inline-block;
  line-height: 1.4;
  user-select: none;
}

.quiz-backup-btn:hover,
label.quiz-backup-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.quiz-backup-btn:disabled,
.quiz-backup-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

label.quiz-backup-btn-upload input[type="file"] {
  display: none;
}

.quiz-backup-note {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  opacity: 0.7;
  margin: 0;
  line-height: 1.55;
}

.quiz-backup-status {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  margin-top: 0.5rem;
  min-height: 1.1rem;
}

.quiz-backup-status-ok {
  color: #16a34a;
}
.quiz-backup-status-error {
  color: #dc2626;
}

/* ── Certificate overlay ──────────────────────────────── */
.cert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}
.cert-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  font-family: var(--font-mono);
}
.cert-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem 0.6rem;
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}
.cert-dialog-title {
  font-size: 0.78rem;
  color: var(--accent2);
  letter-spacing: 0.06em;
}
.cert-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.cert-print-btn {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.2em 0.65em;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    color 0.12s,
    border-color 0.12s;
}
.cert-print-btn:hover {
  color: var(--text);
  border-color: var(--muted);
}
.cert-close-btn {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.2em;
  line-height: 1;
  transition: color 0.12s;
}
.cert-close-btn:hover {
  color: var(--text);
}
.cert-body {
  padding: 1.5rem 1.25rem 2rem;
  text-align: center;
}
.cert-course-label {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}
.cert-ascii {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre;
  text-align: left;
  display: inline-block;
  margin: 0 auto 1.25rem;
  opacity: 0.88;
}
.cert-date {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-top: 0.25rem;
}
@media print {
  .cert-overlay {
    position: static;
    background: none;
    padding: 0;
  }
  .cert-dialog {
    border: none;
    max-height: none;
  }
  .cert-dialog-header {
    display: none;
  }
  .cert-ascii {
    font-size: 0.8rem;
  }
}

/* sister-course card hover (cross-course link) */
.sister-course-card:hover {
  border-color: var(--accent) !important;
}
