/* ===== VARIABLES ===== */
:root {
  /* LIGHT THEME VARIABLES */
  --bg: #f8fafc;
  --bg-soft: #e2e8f0;
  --panel: rgba(255, 255, 255, 0.65);
  --panel-solid: #ffffff;
  --panel-strong: rgba(255, 255, 255, 0.85);
  --panel-muted: rgba(241, 245, 249, 0.55);
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-dark: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.1);
  --teal: #0ea5e9;
  --teal-soft: rgba(14, 165, 233, 0.1);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.1);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.1);
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.1);
  --warm: #8b5cf6;
  --warm-light: rgba(139, 92, 246, 0.1);
  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(148, 163, 184, 0.4);
  --shadow-color: 15, 23, 42;
  --shadow: 0 10px 30px -5px rgba(var(--shadow-color), 0.05), 0 4px 6px -2px rgba(var(--shadow-color), 0.025);
  --shadow-soft: 0 4px 10px -2px rgba(var(--shadow-color), 0.03);
  --shadow-hover: 0 20px 40px -5px rgba(var(--shadow-color), 0.08), 0 8px 10px -4px rgba(var(--shadow-color), 0.04);
  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-display: "DM Serif Display", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --font-accent: "DM Serif Display", Georgia, serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Menlo", monospace;

  --backdrop-blur: blur(20px);
  --transition-smooth: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090b;
    --bg-soft: #18181b;
    --panel: rgba(24, 24, 27, 0.65);
    --panel-solid: #18181b;
    --panel-strong: rgba(39, 39, 42, 0.85);
    --panel-muted: rgba(9, 9, 11, 0.6);
    --ink: #f8fafc;
    --ink-soft: #cbd5e1;
    --ink-muted: #64748b;
    --accent: #60a5fa;
    --accent-dark: #3b82f6;
    --accent-light: rgba(96, 165, 250, 0.15);
    --teal: #38bdf8;
    --teal-soft: rgba(56, 189, 248, 0.15);
    --gold: #fbbf24;
    --gold-soft: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.15);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.15);
    --warm: #a78bfa;
    --warm-light: rgba(167, 139, 250, 0.15);
    --border: rgba(248, 250, 252, 0.08);
    --border-strong: rgba(248, 250, 252, 0.15);
    --shadow-color: 0, 0, 0;
  }
}

/* ===== RESET ===== */
* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 10% 10%, var(--accent-light) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, var(--teal-soft) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, var(--warm-light) 0%, transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

/* ===== SKIP LINK ===== */
.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: 16px;
}

/* ===== BACKDROP (removed from HTML, kept as no-op) ===== */
.backdrop {
  display: none;
}

/* ===== APP SHELL ===== */
.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 24px;
  width: min(1440px, calc(100% - 48px));
  margin: 24px auto 40px;
  align-items: start;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  align-self: start;
  display: flex;
  flex-direction: column;
}

.sidebar-shell {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 48px);
  gap: 0;
  padding: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--radius-xl);
  background: var(--panel);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.sidebar-shell::-webkit-scrollbar {
  width: 8px;
}

.sidebar-shell::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--border-strong);
}

/* ===== BRAND BLOCK ===== */
.brand-block,
.sidebar-card,
.hero,
.chapter-panel,
.glossary-panel,
.noscript {
  background: var(--panel);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: var(--transition-smooth);
}

.brand-block,
.sidebar-card {
  border-radius: var(--radius-lg);
  padding: 16px;
}

.brand-block {
  background: transparent;
}

.sidebar-shell .brand-block,
.sidebar-shell .sidebar-card {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.sidebar-shell .sidebar-card,
.sidebar-shell .brand-block+.sidebar-card {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.brand-block--compact .eyebrow {
  margin-bottom: 0;
}

.brand-block h1,
.brand-block h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3.5vw, 2.1rem);
  line-height: 1.1;
  color: var(--ink);
}

.brand-copy {
  margin: 10px 0 0;
  color: var(--ink-soft);
  line-height: 1.6;
  font-size: 0.92rem;
}

.brand-copy--switch {
  margin-top: 14px;
}

.sidebar-course-switch {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

/* HIDE CLUTTER */
.site-footer,
.sidebar-note,
.sidebar-shell .brand-block,
.sidebar-shell .sidebar-card:first-of-type .sidebar-card__row {
  display: none !important;
}

/* ===== SIDEBAR OVERRIDES (light theme) ===== */
.sidebar-shell .eyebrow {
  color: var(--accent);
}

.sidebar-shell .brand-copy,
.sidebar-shell .helper-text,
.sidebar-shell .sidebar-card__row span,
.sidebar-shell .field-label,
.sidebar-shell .sidebar-note {
  color: var(--ink-soft);
}

.sidebar-shell .sidebar-card__row strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.sidebar-shell .progress-track {
  margin-bottom: 0;
  background: var(--border);
}

.sidebar-shell .search-input {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: var(--backdrop-blur);
  border-color: var(--border);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  transition: var(--transition-smooth);
}

@media (prefers-color-scheme: dark) {
  .sidebar-shell .search-input {
    background: rgba(0, 0, 0, 0.2);
  }
}

.sidebar-shell .search-input::placeholder {
  color: var(--ink-muted);
}

.sidebar-shell .search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.sidebar-shell .ghost-button,
.sidebar-shell .filter-chip {
  background: var(--panel-solid);
  border-color: var(--border);
  color: var(--ink);
}

.sidebar-shell .ghost-button:hover,
.sidebar-shell .filter-chip:hover {
  background: var(--bg-soft);
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.sidebar-shell .filter-chip.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sidebar-shell .chapter-nav {
  margin-top: 12px;
  gap: 8px;
  max-height: none;
  overflow: visible;
}

.sidebar-shell .chapter-nav__item {
  background: rgba(148, 163, 184, 0.05); /* Extremely subtle glass base */
  border: none;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  box-shadow: none;
  transition: all 0.2s ease;
}

.sidebar-shell .chapter-nav__item:hover {
  background: rgba(148, 163, 184, 0.12); /* Slightly more prominent on hover */
  transform: none;
  box-shadow: none;
}

.sidebar-shell .chapter-nav__item.is-active {
  background: var(--bg-soft); /* Distinguishes active item clearly */
  border: none;
  box-shadow: none;
  font-weight: 700; /* Makes active item text pop natively without blue bar */
}

.sidebar-shell .chapter-nav__item.is-complete {
  border-color: var(--accent);
}

.sidebar-shell .chapter-card__number,
.sidebar-shell .meta-chip,
.sidebar-shell .chapter-nav__time {
  background: var(--bg-soft);
  color: var(--ink-soft);
}

.sidebar-shell .meta-chip--teal {
  background: var(--accent-light);
  color: var(--accent);
}

.sidebar-shell .meta-chip--accent {
  background: var(--warm-light);
  color: var(--warm);
}

.sidebar-shell .meta-chip--gold {
  background: var(--gold-soft);
  color: var(--gold);
}

.sidebar-shell .meta-chip--success {
  background: var(--accent-light);
  color: var(--accent);
}

.sidebar-shell .chapter-nav__title {
  font-size: 0.95rem;
  color: var(--ink);
}

.sidebar-shell .chapter-nav__footer {
  gap: 6px;
  margin-top: 10px;
}

.sidebar-shell .empty-state {
  background: var(--bg-soft);
  border-color: var(--border);
}

/* ===== SHARED LAYOUT ROWS ===== */
.sidebar-card__row,
.sidebar-card__head,
.hero__meta,
.chapter-head__meta,
.glossary-topbar,
.course-tabbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-card__row span,
.hero__meta span,
.chapter-head__meta span {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.sidebar-card__head {
  align-items: flex-start;
}

/* ===== ENERGY LINE TRACK ===== */
.progress-track {
  height: 2px;
  width: 100%;
  border-radius: 999px;
  background: transparent;
  overflow: visible;
  margin: 0;
  position: relative;
}

.progress-track::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 999px;
}

.progress-track__fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  box-shadow: 0 0 10px var(--accent), 0 0 25px var(--warm);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 2;
  animation: pulseGlow 3s infinite alternate ease-in-out;
}

@keyframes pulseGlow {
  0% { filter: brightness(1) drop-shadow(0 0 8px var(--accent)); }
  100% { filter: brightness(1.3) drop-shadow(0 0 15px var(--warm)); }
}

/* ===== INTERACTIVE ELEMENTS ===== */
.ghost-button,
.filter-chip,
.chapter-nav__item,
.tab-button,
.quiz-option,
.action-button,
.exercise-chip,
.glossary-tag {
  border: 1px solid var(--border);
  background: var(--panel-solid);
  color: var(--ink);
  transition: var(--transition-smooth);
}

.ghost-button,
.action-button,
.tab-button,
.filter-chip,
.exercise-chip {
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.ghost-button,
.action-button,
.tab-button {
  padding: 10px 14px;
}

.ghost-button--compact {
  padding: 8px 11px;
  font-size: 0.9rem;
}

.ghost-button:hover,
.filter-chip:hover,
.chapter-nav__item:hover,
.tab-button:hover,
.quiz-option:hover,
.action-button:hover,
.exercise-chip:hover,
.glossary-tag:hover {
  border-color: var(--border-strong);
  background: var(--bg-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}

.ghost-button:active,
.filter-chip:active,
.action-button:active,
.tab-button:active {
  transform: translateY(0);
}

/* ===== FORM ELEMENTS ===== */
.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.field-label--inline {
  flex-basis: 100%;
  margin-bottom: 0;
}

.helper-text {
  margin: 8px 0 0;
  color: var(--ink-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.search-input,
.glossary-search {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--ink);
  outline: none;
}

.search-input:focus,
.glossary-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

/* ===== FILTER ROW ===== */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.filter-chip {
  padding: 7px 12px;
  font-size: 0.88rem;
}

.filter-chip.is-active,
.tab-button.is-active,
.action-button--primary,
.exercise-chip--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 10px -2px rgba(var(--shadow-color), 0.15);
}

/* ===== CHAPTER NAV ===== */
.chapter-nav {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: min(58vh, 900px);
  overflow-y: auto;
  padding-right: 4px;
}

.chapter-nav::-webkit-scrollbar {
  width: 6px;
}

.chapter-nav::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--border-strong);
}

.chapter-nav__item {
  width: 100%;
  text-align: left;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: none;
}

.chapter-nav__item.is-active {
  background: var(--accent-light);
  border-color: var(--accent);
  border-left: 3px solid var(--accent);
}

.chapter-nav__item.is-complete {
  border-color: var(--accent);
}

.chapter-nav__topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.chapter-nav__title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.chapter-nav__footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

/* ===== CONTENT TEXT ===== */
.lesson-section p,
.exercise-card__prompt,
.glossary-card__text,
.empty-state p {
  margin: 0;
  line-height: 1.7;
  color: var(--ink-soft);
}

/* ===== TAGS ===== */
.chapter-head__badges,
.glossary-card__tags,
.exercise-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.glossary-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* ===== WORKSPACE ===== */
.workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== HOME PAGE ===== */
body[data-page="home"] {
  --accent: #14b8a6;
  --accent-dark: #0d9488;
  --accent-light: rgba(20, 184, 166, 0.12);
  min-height: 100vh;
  padding: 0;
  overflow-x: hidden;
  background-image:
    linear-gradient(115deg, rgba(20, 184, 166, 0.12), transparent 26%, rgba(245, 158, 11, 0.1) 54%, transparent 72%),
    repeating-linear-gradient(90deg, rgba(15, 23, 42, 0.045) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(15, 23, 42, 0.035) 0 1px, transparent 1px 72px),
    linear-gradient(135deg, #f8fafc, #f0fdfa 46%, #eff6ff);
  background-size: 140% 140%, 72px 72px, 72px 72px, 100% 100%;
  animation: home-background-shift 18s ease-in-out infinite alternate;
}

@media (prefers-color-scheme: dark) {
  body[data-page="home"] {
    background-image:
      linear-gradient(115deg, rgba(45, 212, 191, 0.12), transparent 26%, rgba(245, 158, 11, 0.08) 54%, transparent 72%),
      repeating-linear-gradient(90deg, rgba(248, 250, 252, 0.05) 0 1px, transparent 1px 72px),
      repeating-linear-gradient(0deg, rgba(248, 250, 252, 0.04) 0 1px, transparent 1px 72px),
      linear-gradient(135deg, #09090b, #111111 46%, #042f2e);
  }
}

.home-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 48px 24px;
  overflow: hidden;
}

.home-stage::before,
.home-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.home-stage::before {
  background:
    linear-gradient(105deg, transparent 0 36%, rgba(255, 255, 255, 0.42) 44%, transparent 52%),
    linear-gradient(74deg, transparent 0 62%, rgba(20, 184, 166, 0.14) 68%, transparent 74%);
  mix-blend-mode: screen;
  transform: translateX(-18%);
  animation: home-light-sweep 10s ease-in-out infinite alternate;
}

.home-stage::after {
  background-image:
    linear-gradient(120deg, transparent 0 14%, rgba(20, 184, 166, 0.22) 14.2%, transparent 14.6%),
    linear-gradient(120deg, transparent 0 72%, rgba(245, 158, 11, 0.2) 72.2%, transparent 72.6%),
    linear-gradient(120deg, transparent 0 86%, rgba(37, 99, 235, 0.18) 86.2%, transparent 86.6%);
  opacity: 0.7;
}

@media (prefers-color-scheme: dark) {
  .home-stage::before {
    background:
      linear-gradient(105deg, transparent 0 36%, rgba(45, 212, 191, 0.16) 44%, transparent 52%),
      linear-gradient(74deg, transparent 0 62%, rgba(245, 158, 11, 0.1) 68%, transparent 74%);
  }
}

.home-scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.home-scene__trace {
  position: absolute;
  height: 2px;
  width: min(520px, 44vw);
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.34;
  transform: rotate(-18deg);
  animation: home-trace-drift 9s ease-in-out infinite;
}

.home-scene__trace--one {
  top: 18%;
  left: -8%;
}

.home-scene__trace--two {
  top: 64%;
  right: -12%;
  animation-delay: -2.4s;
}

.home-scene__trace--three {
  top: 82%;
  left: 16%;
  animation-delay: -5s;
}

.home-scene__chip {
  position: absolute;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink-soft);
  box-shadow: var(--shadow-soft);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  animation: home-chip-float 7s ease-in-out infinite;
}

@media (prefers-color-scheme: dark) {
  .home-scene__chip {
    background: rgba(24, 24, 27, 0.62);
  }
}

.home-scene__chip--cpp {
  top: 14%;
  right: 10%;
}

.home-scene__chip--ia {
  bottom: 18%;
  left: 7%;
  animation-delay: -2s;
}

.home-scene__chip--train {
  top: 25%;
  left: 9%;
  animation-delay: -3.8s;
}

.home-scene__chip--raii {
  right: 12%;
  bottom: 14%;
  animation-delay: -5.4s;
}

.home-hero {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  display: grid;
  gap: 34px;
  animation: home-content-enter 0.8s ease both;
}

.home-hero__copy {
  max-width: 820px;
}

.home-hero h1 {
  margin: 0;
  max-width: 820px;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 8vw, 6.6rem);
  line-height: 0.98;
}

.home-hero p {
  max-width: 56ch;
  margin: 18px 0 0;
  color: var(--ink-soft);
  line-height: 1.75;
  font-size: 1.08rem;
}

.home-course-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.home-course-button {
  position: relative;
  min-height: 170px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.36)),
    var(--panel);
  box-shadow: var(--shadow);
  transition: var(--transition-smooth);
  overflow: hidden;
}

.home-course-button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0 36%, rgba(255, 255, 255, 0.46) 48%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.7s ease;
}

.home-course-button--ia {
  border-color: rgba(20, 184, 166, 0.36);
}

.home-course-button--cpp {
  border-color: rgba(37, 99, 235, 0.28);
}

@media (prefers-color-scheme: dark) {
  .home-course-button {
    background:
      linear-gradient(135deg, rgba(39, 39, 42, 0.78), rgba(24, 24, 27, 0.38)),
      var(--panel);
  }
}

.home-course-button:hover,
.home-course-button:focus-visible {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.home-course-button:hover::before,
.home-course-button:focus-visible::before {
  transform: translateX(120%);
}

.home-course-button__code {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  box-shadow: 0 16px 34px -20px rgba(15, 23, 42, 0.8);
}

.home-course-button--ia .home-course-button__code {
  background: linear-gradient(135deg, #14b8a6, #f59e0b);
}

.home-course-button--cpp .home-course-button__code {
  background: linear-gradient(135deg, #2563eb, #10b981);
}

.home-course-button strong,
.home-course-button small {
  display: block;
}

.home-course-button strong {
  font-size: 1.35rem;
}

.home-course-button small {
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 0.96rem;
}

.home-course-button__arrow {
  position: relative;
  margin-left: auto;
  color: var(--accent);
  font-size: 1.65rem;
  transition: transform 0.3s ease;
}

.home-course-button:hover .home-course-button__arrow,
.home-course-button:focus-visible .home-course-button__arrow {
  transform: translateX(6px);
}

.home-syllabus-rail {
  width: 100%;
  overflow: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 14%, #000 86%, transparent);
}

.home-syllabus-rail__track {
  display: flex;
  width: max-content;
  gap: 10px;
  padding: 13px 0;
  animation: home-rail-scroll 26s linear infinite;
}

.home-syllabus-rail span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.42);
  font-size: 0.88rem;
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .home-syllabus-rail span {
    background: rgba(24, 24, 27, 0.52);
  }
}

@keyframes home-background-shift {
  from {
    background-position: 0% 50%, 0 0, 0 0, 0 0;
  }

  to {
    background-position: 100% 50%, 72px 0, 0 72px, 0 0;
  }
}

@keyframes home-light-sweep {
  from {
    transform: translateX(-18%);
  }

  to {
    transform: translateX(18%);
  }
}

@keyframes home-trace-drift {
  0%,
  100% {
    transform: translateX(-18px) rotate(-18deg);
  }

  50% {
    transform: translateX(80px) rotate(-18deg);
  }
}

@keyframes home-chip-float {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.58;
  }

  50% {
    transform: translateY(-18px);
    opacity: 0.92;
  }
}

@keyframes home-content-enter {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes home-rail-scroll {
  to {
    transform: translateX(-50%);
  }
}

/* ===== HERO ===== */
.hero,
.chapter-panel,
.glossary-panel,
.noscript {
  border-radius: var(--radius-xl);
  padding: 28px;
}

/* ===== GLOBAL DASHBOARD / ENERGY LINE WRAPPER ===== */
.global-dashboard {
  background: transparent;
  border: none;
  padding: 0 12px;
  margin: 32px auto 48px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  box-shadow: none;
}

.dashboard-progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  width: 100%;
}

.progress-text {
  font-weight: 500;
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: -4px; /* Optically align with edge */
}

.progress-text strong {
  margin-left: 8px;
  color: #fff;
  font-size: 1.2rem;
  text-shadow: 0 0 12px var(--accent);
  letter-spacing: 0;
}

/* HIDE REDUNDANT ELEMENTS */
.dashboard-search,
.dashboard-clear-btn,
.elegant-filters {
  display: none !important;
}

.hero {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero::before {
  display: none;
}

.hero::after {
  display: none;
}

.hero__layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 1.2fr);
  gap: 40px;
  align-items: center;
}

.hero__copy {
  display: flex;
  flex-direction: column;
}

.hero__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.hero__lead {
  max-width: 60ch;
  margin: 14px 0 0;
  color: var(--ink-soft);
  line-height: 1.75;
  font-size: 1rem;
}

.hero__intro-visual {
  width: min(540px, 100%);
  margin-top: 18px;
}

.hero-neural-network {
  width: 100%;
  min-height: 190px;
}

.hero-neural-network svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.hero-nn__connection {
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
  opacity: 0.24;
}

.hero-nn__connection--input,
.hero-nn__connection--hidden,
.hero-nn__connection--output {
  stroke-dasharray: 5 12;
  animation: hero-nn-flow 2.4s linear infinite;
}

.hero-nn__connection--hidden {
  animation-delay: 0.35s;
}

.hero-nn__connection--output {
  animation-delay: 0.7s;
}

.hero-nn__node {
  transform-box: fill-box;
  transform-origin: center;
  fill: var(--panel-solid);
  stroke: var(--accent);
  stroke-width: 1.8;
  animation: hero-nn-node-pulse 3.6s ease-in-out infinite;
}

.hero-nn__node--input {
  animation-delay: 0s;
}

.hero-nn__node--hidden-one {
  animation-delay: 0.45s;
}

.hero-nn__node--hidden-two {
  animation-delay: 0.9s;
}

.hero-nn__node--output {
  fill: var(--accent-light);
  animation-delay: 1.35s;
}

.hero-nn__signal {
  transform-box: view-box;
  transform-origin: 0 0;
  fill: var(--accent);
  opacity: 0;
  filter: drop-shadow(0 0 8px var(--accent));
  animation: hero-nn-signal 3.6s ease-in-out infinite;
}

.hero-nn__signal--a {
  --signal-from-x: 46px;
  --signal-from-y: 58px;
  --signal-to-x: 165px;
  --signal-to-y: 88px;
  animation-delay: 0s;
}

.hero-nn__signal--b {
  --signal-from-x: 46px;
  --signal-from-y: 172px;
  --signal-to-x: 165px;
  --signal-to-y: 142px;
  animation-delay: 0.2s;
}

.hero-nn__signal--c {
  --signal-from-x: 165px;
  --signal-from-y: 88px;
  --signal-to-x: 292px;
  --signal-to-y: 66px;
  animation-delay: 0.75s;
}

.hero-nn__signal--d {
  --signal-from-x: 165px;
  --signal-from-y: 142px;
  --signal-to-x: 292px;
  --signal-to-y: 166px;
  animation-delay: 0.95s;
}

.hero-nn__signal--e {
  --signal-from-x: 292px;
  --signal-from-y: 66px;
  --signal-to-x: 410px;
  --signal-to-y: 116px;
  animation-delay: 1.55s;
}

.hero-nn__signal--f {
  --signal-from-x: 292px;
  --signal-from-y: 166px;
  --signal-to-x: 410px;
  --signal-to-y: 116px;
  animation-delay: 1.75s;
}

.hero-nn__label {
  fill: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  text-anchor: middle;
}

.hero-cpp-journey {
  width: 100%;
  min-height: 190px;
}

.hero-cpp-journey svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.hero-cpp__card {
  animation: hero-cpp-card-float 5.2s ease-in-out infinite;
}

.hero-cpp__card--run {
  animation-delay: -2.6s;
}

.hero-cpp__card-panel {
  fill: var(--panel-solid);
  stroke-width: 1.4;
}

.hero-cpp__card-panel--source {
  stroke: rgba(59, 130, 246, 0.36);
}

.hero-cpp__card-panel--run {
  stroke: rgba(16, 185, 129, 0.34);
}

.hero-cpp__card-title,
.hero-cpp__core-text {
  fill: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
}

.hero-cpp__card-title {
  font-size: 13px;
}

.hero-cpp__card-subtitle,
.hero-cpp__core-subtext,
.hero-cpp__token-label {
  fill: var(--ink-soft);
  font-family: var(--font-body);
  font-size: 11px;
}

.hero-cpp__code-line,
.hero-cpp__output-line {
  fill: rgba(59, 130, 246, 0.14);
}

.hero-cpp__output-line {
  animation: hero-cpp-output-pulse 2.8s ease-in-out infinite;
}

.hero-cpp__output-line--mid {
  animation-delay: 0.2s;
}

.hero-cpp__output-line--short {
  animation-delay: 0.4s;
}

.hero-cpp__code-line--short,
.hero-cpp__output-line--short {
  opacity: 0.7;
}

.hero-cpp__stream {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-dasharray: 6 10;
  opacity: 0.24;
  animation: hero-cpp-stream-flow 1.6s linear infinite;
}

.hero-cpp__stream--b,
.hero-cpp__stream--d {
  animation-delay: 0.22s;
}

.hero-cpp__halo {
  fill: rgba(59, 130, 246, 0.08);
  animation: hero-cpp-core-breathe 3.8s ease-in-out infinite;
}

.hero-cpp__orbit {
  fill: none;
  stroke: rgba(59, 130, 246, 0.28);
  stroke-width: 1.3;
}

.hero-cpp__orbit--inner {
  stroke: rgba(16, 185, 129, 0.24);
}

.hero-cpp__core-node {
  fill: var(--panel-solid);
  stroke: var(--accent);
  stroke-width: 1.7;
  animation: hero-cpp-core-breathe 3.8s ease-in-out infinite;
}

.hero-cpp__core-text,
.hero-cpp__core-subtext,
.hero-cpp__token-label {
  text-anchor: middle;
}

.hero-cpp__core-text {
  font-size: 22px;
}

.hero-cpp__rotor {
  transform-box: view-box;
  transform-origin: 260px 122px;
  opacity: 0.84;
}

.hero-cpp__rotor--outer {
  animation: hero-cpp-rotate 16s linear infinite;
}

.hero-cpp__rotor--inner {
  animation: hero-cpp-rotate-reverse 11s linear infinite;
}

.hero-cpp__token-pill {
  fill: rgba(15, 23, 42, 0.78);
  stroke: rgba(59, 130, 246, 0.34);
  stroke-width: 1.1;
}

.hero-cpp__token-pill--small {
  fill: rgba(15, 23, 42, 0.72);
  stroke: rgba(16, 185, 129, 0.34);
}

.hero-cpp__token-label {
  fill: rgba(226, 232, 240, 0.92);
  font-family: var(--font-mono);
  font-weight: 700;
  dominant-baseline: central;
}

.hero-cpp__token-label--small {
  font-size: 10px;
}

@media (prefers-color-scheme: light) {
  .hero-cpp__token-pill {
    fill: rgba(226, 232, 240, 0.72);
    stroke: rgba(59, 130, 246, 0.3);
  }

  .hero-cpp__token-pill--small {
    fill: rgba(219, 234, 254, 0.78);
    stroke: rgba(16, 185, 129, 0.28);
  }

  .hero-cpp__token-label {
    fill: rgba(15, 23, 42, 0.82);
  }
}

.hero-cpp__particle {
  fill: var(--accent);
  opacity: 0;
  filter: drop-shadow(0 0 8px var(--accent));
  animation: hero-cpp-particle 2.8s ease-in-out infinite;
}

.hero-cpp__particle--a {
  --from-x: 148px;
  --from-y: 94px;
  --to-x: 222px;
  --to-y: 94px;
  animation-delay: 0s;
}

.hero-cpp__particle--b {
  --from-x: 148px;
  --from-y: 150px;
  --to-x: 222px;
  --to-y: 150px;
  animation-delay: 0.34s;
}

.hero-cpp__particle--c {
  --from-x: 298px;
  --from-y: 94px;
  --to-x: 372px;
  --to-y: 94px;
  animation-delay: 1.02s;
}

.hero-cpp__particle--d {
  --from-x: 298px;
  --from-y: 150px;
  --to-x: 372px;
  --to-y: 150px;
  animation-delay: 1.36s;
}

@keyframes hero-nn-flow {
  to {
    stroke-dashoffset: -34;
  }
}

@keyframes hero-cpp-stream-flow {
  to {
    stroke-dashoffset: -32;
  }
}

@keyframes hero-cpp-card-float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

@keyframes hero-nn-node-pulse {
  0%,
  100% {
    opacity: 0.78;
    transform: scale(1);
  }

  45%,
  58% {
    opacity: 1;
    transform: scale(1.12);
    filter: drop-shadow(0 0 9px var(--accent));
  }
}

@keyframes hero-nn-signal {
  0%,
  8% {
    opacity: 0;
    transform: translate(var(--signal-from-x), var(--signal-from-y)) scale(0.65);
  }

  18%,
  52% {
    opacity: 1;
  }

  62% {
    opacity: 1;
    transform: translate(var(--signal-to-x), var(--signal-to-y)) scale(1);
  }

  72%,
  100% {
    opacity: 0;
    transform: translate(var(--signal-to-x), var(--signal-to-y)) scale(0.65);
  }
}

@keyframes hero-cpp-core-breathe {
  0%,
  100% {
    opacity: 0.82;
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

@keyframes hero-cpp-rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes hero-cpp-rotate-reverse {
  to {
    transform: rotate(-360deg);
  }
}

@keyframes hero-cpp-output-pulse {
  0%,
  100% {
    opacity: 0.48;
  }

  50% {
    opacity: 1;
  }
}

@keyframes hero-cpp-particle {
  0%,
  12% {
    opacity: 0;
    transform: translate(var(--from-x), var(--from-y)) scale(0.65);
  }

  28%,
  58% {
    opacity: 1;
  }

  68% {
    opacity: 1;
    transform: translate(var(--to-x), var(--to-y)) scale(1);
  }

  80%,
  100% {
    opacity: 0;
    transform: translate(var(--to-x), var(--to-y)) scale(0.65);
  }
}

.hero__meta {
  margin-top: 16px;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.action-button--outline {
  background: transparent;
}

.hero__spotlight {
  margin-top: 20px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.hero__spotlight-label {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.hero__spotlight strong {
  display: block;
  font-size: 1.3rem;
  line-height: 1.2;
}

.hero__spotlight p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

/* ===== HERO FOCUS (TERMINAL) ===== */
.hero-focus--terminal {
  background: #0f111a;
  color: #a6accd;
  border-radius: var(--radius-lg);
  padding: 0;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
}

.terminal-header {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  /* slightly lighter header */
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.term-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.term-dot--red {
  background: #ff5f56;
}

.term-dot--yellow {
  background: #ffbd2e;
}

.term-dot--green {
  background: #27c93f;
}

.terminal-body {
  margin: 0;
  padding: 20px;
  overflow-x: auto;
}

.terminal-body code {
  color: #a6accd;
  font-family: inherit;
}

.token-keyword {
  color: #c792ea;
  font-style: italic;
}

/* Purple */
.token-string {
  color: #c3e88d;
}

/* Green */
.token-function {
  color: #82aaff;
}

/* Blue */
.token-comment {
  color: #676e95;
  font-style: italic;
}

/* Grey */
.token-number {
  color: #f78c6c;
}

/* Orange */

.terminal-actions {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.term-command {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-prompt {
  color: #c3e88d;
  /* Green prompt */
  font-weight: bold;
}

.terminal-btn {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #a6accd;
  cursor: pointer;
  padding: 0;
  text-align: left;
  transition: var(--transition-smooth);
}

.terminal-btn--primary {
  color: #82aaff;
}

.terminal-btn:hover {
  color: #ffffff;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

/* ===== CHAPTER / GLOSSARY HEADS ===== */
.chapter-head,
.glossary-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.chapter-head h2,
.glossary-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
}

/* ===== CONTENT CARDS ===== */
.lesson-section,
.exercise-card,
.glossary-card,
.quiz-card,
.callout,
.empty-state {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: var(--backdrop-blur);
  -webkit-backdrop-filter: var(--backdrop-blur);
  box-shadow: var(--shadow-soft);
  transition: var(--transition-smooth);
}

.exercise-card:hover,
.glossary-card:hover,
.quiz-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
}

.glossary-card {
  padding: 16px;
}

.lesson-section h3,
.exercise-card h3,
.glossary-card h3,
.quiz-card h3 {
  margin: 12px 0 6px;
  font-size: 1.05rem;
}

.exercise-card__prompt,
.glossary-card__text,
.quiz-card p {
  color: var(--ink-soft);
}

/* ===== LISTS ===== */
.bullet-list,
.check-list,
.exercise-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.75;
}

.bullet-list li+li,
.check-list li+li,
.exercise-list li+li {
  margin-top: 4px;
}

/* ===== VIDEO GRID ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.video-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.video-card:hover,
.video-card:focus-visible {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.video-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.video-card__media {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #1a1a1a;
}

.video-card__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.15s ease;
}

.video-card:hover .video-card__thumb,
.video-card:focus-visible .video-card__thumb {
  opacity: 0.9;
}

.video-card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0, 0, 0, 0.3));
}

.video-card__badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.video-card__play {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.65);
}

.video-card__play::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-36%, -50%);
  width: 0;
  height: 0;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  border-left: 16px solid #fff;
}

.video-card__body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
}

.video-card__title {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
}

.video-card__note {
  color: var(--ink-soft);
  line-height: 1.6;
  font-size: 0.9rem;
}

.video-card__cta {
  margin-top: auto;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ===== META CHIPS ===== */
.chapter-card__number,
.meta-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.meta-chip--teal {
  background: var(--accent-light);
  color: var(--accent);
}

.meta-chip--gold {
  background: var(--gold-soft);
  color: var(--gold);
}

.meta-chip--accent {
  background: var(--warm-light);
  color: var(--warm);
}

.meta-chip--success {
  background: var(--success-soft);
  color: var(--success);
}

/* ===== CHAPTER PANEL ===== */
.chapter-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.chapter-head {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.75fr);
  align-items: start;
  gap: 20px;
}

.chapter-head__aside {
  display: grid;
  gap: 12px;
}

.chapter-head__status {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.chapter-head__status strong,
.chapter-head__status span {
  display: block;
}

.chapter-head__status span {
  margin-top: 6px;
  color: var(--ink-soft);
  line-height: 1.6;
}

/* ===== CHAPTER TOOLBAR (dark) ===== */
.chapter-head__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 0;
  background: #1a1a1a;
  color: #f0eeea;
  box-shadow: var(--shadow);
}

.chapter-head__progress,
.chapter-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chapter-head__summary {
  max-width: 74ch;
  color: var(--ink-soft);
  line-height: 1.7;
}

.chapter-head__progress {
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
}

.chapter-head__toolbar .ghost-button {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.chapter-head__toolbar .ghost-button:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ===== GOAL GRID ===== */
.goal-grid,
.tab-panel__grid,
.exercise-grid,
.quiz-grid,
.glossary-grid {
  display: grid;
  gap: 12px;
}

.goal-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.goal-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.goal-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.goal-card span {
  color: var(--ink-soft);
  line-height: 1.6;
  font-size: 0.92rem;
}

/* ===== TAB BAR ===== */
.course-tabbar {
  flex-wrap: wrap;
  position: sticky;
  top: 12px;
  z-index: 4;
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  box-shadow: var(--shadow-soft);
}

.course-tabpanel,
.glossary-mode-panel {
  margin-top: 16px;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tab-button {
  flex: 1 1 0;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
}

.tab-button.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 10px -2px rgba(var(--shadow-color), 0.15);
}

/* ===== LESSON SECTIONS ===== */
.lesson-section {
  padding: 20px;
}

.lesson-section h3 {
  font-family: var(--font-body);
  font-weight: 700;
}

.lesson-section p+p {
  margin-top: 10px;
}

.review-question {
  font-weight: 600;
  color: var(--ink);
}

.glossary-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  line-height: inherit;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.16em;
  cursor: pointer;
}

.glossary-link:hover {
  color: var(--accent);
}

.glossary-link:focus-visible {
  border-radius: 999px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-light);
}

/* ===== DEEP DIVE ===== */
.lesson-deep-dive {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
}

.lesson-deep-dive__intro,
.lesson-deep-dive__check {
  margin: 0;
  line-height: 1.7;
}

.lesson-deep-dive__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.lesson-deep-dive__panel {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
}

.lesson-deep-dive__panel--wide {
  grid-column: 1 / -1;
}

.lesson-deep-dive__panel h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  color: var(--accent-dark);
}

.lesson-deep-dive__panel ul,
.lesson-deep-dive__panel ol {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

.lesson-deep-dive__panel li+li {
  margin-top: 4px;
}

.lesson-deep-dive__check {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink-soft);
}

/* ===== CODE BLOCKS ===== */
.code-block {
  margin: 14px 0 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-left: 3px solid var(--accent);
  background: #1e1e1e;
  color: #d4d4d4;
}

.code-block__head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.code-block pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  tab-size: 2;
}

.code-block code,
.code-block__code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
  white-space: pre;
}

.code-block .token {
  color: inherit;
}

.code-block .token-comment {
  color: #6a9955;
  font-style: italic;
}

.code-block .token-string {
  color: #ce9178;
}

.code-block .token-keyword,
.code-block .token-preprocessor {
  color: #569cd6;
  font-weight: 700;
}

.code-block .token-type,
.code-block .token-command {
  color: #4ec9b0;
}

.code-block .token-number,
.code-block .token-constant {
  color: #b5cea8;
}

.code-block .token-function {
  color: #dcdcaa;
}

.code-block .token-variable {
  color: #9cdcfe;
}

.code-block .token-operator,
.code-block .token-punctuation {
  color: #d4d4d4;
}

/* ===== CALLOUTS ===== */
.callout {
  padding: 16px;
  margin-top: 14px;
}

.callout__label {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.callout__title {
  margin: 12px 0 6px;
  font-size: 1rem;
}

.callout p {
  margin: 0;
}

.callout--info {
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
}

.callout--info .callout__label {
  background: rgba(45, 90, 39, 0.12);
  color: var(--accent);
}

.callout--warn {
  background: var(--gold-soft);
  border-left: 3px solid var(--gold);
}

.callout--warn .callout__label {
  background: rgba(166, 124, 0, 0.12);
  color: var(--gold);
}

.callout--danger {
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
}

.callout--danger .callout__label {
  background: rgba(157, 51, 51, 0.12);
  color: var(--danger);
}

.callout--success {
  background: var(--success-soft);
  border-left: 3px solid var(--success);
}

.callout--success .callout__label {
  background: rgba(45, 90, 39, 0.12);
  color: var(--success);
}

/* ===== DATA TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.data-table th,
.data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table thead th {
  background: var(--bg-soft);
  font-weight: 700;
  font-size: 0.9rem;
}

.data-table tbody tr:nth-child(even) td {
  background: var(--bg-soft);
}

/* ===== QUIZ & EXERCISE GRIDS ===== */
.quiz-grid,
.exercise-grid,
.glossary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quiz-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.quiz-card,
.exercise-card {
  padding: 20px;
}

.quiz-option-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.quiz-option {
  padding: 10px 14px;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.quiz-option.is-correct {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.quiz-option.is-wrong {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.quiz-feedback {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--ink-soft);
  line-height: 1.6;
}

.exercise-card__chips {
  margin-top: 12px;
}

.exercise-chip {
  padding: 6px 10px;
  cursor: default;
  font-size: 0.85rem;
}

.exercise-chip--primary {
  cursor: pointer;
}

/* ===== GLOSSARY ===== */
.glossary-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.glossary-head p {
  max-width: 58ch;
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.glossary-topbar {
  flex-wrap: wrap;
}

.glossary-grid {
  margin-top: 16px;
}

.glossary-card {
  min-height: 100%;
}

.glossary-card h3 {
  margin-top: 0;
}

.glossary-card__text {
  margin-top: 6px;
}

/* ===== GLOSSARY STUDY / FLASHCARDS ===== */
.glossary-topbar__meta,
.glossary-card__head,
.glossary-card__actions,
.glossary-study__head,
.glossary-study__actions,
.glossary-mode-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.glossary-topbar__meta,
.glossary-card__head,
.glossary-study__head {
  justify-content: space-between;
}

.glossary-mode-switch {
  margin-top: 16px;
}

.glossary-grid--study {
  align-items: start;
}

.glossary-card--study {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.glossary-card--study.is-known {
  border-color: var(--success);
}

.glossary-card--study.is-targeted {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light), var(--shadow-hover);
}

.glossary-card__head h3 {
  margin: 0;
}

.glossary-card__example {
  margin: 0;
  color: var(--ink-soft);
  line-height: 1.7;
}

.glossary-card__visual {
  display: flex;
  justify-content: center;
}

.glossary-card__visual .figure {
  margin: 8px 0 4px;
  width: 100%;
}

.glossary-card__actions {
  margin-top: auto;
}

.glossary-card__actions .ghost-button,
.glossary-card__actions .action-button {
  min-width: 120px;
  justify-content: center;
}

.glossary-study {
  margin-top: 16px;
  padding: 22px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  box-shadow: var(--shadow-soft);
}

.glossary-study__actions,
.glossary-study .glossary-card__actions {
  margin-top: 16px;
}

.glossary-study__actions .ghost-button,
.glossary-study__actions .action-button {
  min-width: 140px;
  justify-content: center;
}

.flashcard {
  position: relative;
  margin-top: 16px;
  cursor: pointer;
}

.flashcard__face {
  min-height: 300px;
  padding: 24px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.flashcard__face h3 {
  margin: 8px 0 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-family: var(--font-display);
}

.flashcard__face--back {
  display: none;
}

.flashcard.is-flipped .flashcard__face--front {
  display: none;
}

.flashcard.is-flipped .flashcard__face--back {
  display: block;
}

/* ===== GLOSSARY QUIZ ===== */
.quiz-card--glossary {
  padding: 22px;
}

.glossary-quiz__prompt {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.glossary-quiz__lead,
.glossary-quiz__hint,
.glossary-quiz__term {
  margin: 0;
}

.glossary-quiz__lead {
  color: var(--ink);
  line-height: 1.7;
}

.glossary-quiz__hint {
  color: var(--ink-soft);
  line-height: 1.6;
}

.glossary-quiz__term {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--accent-dark);
}

.quiz-option-list--glossary {
  margin-top: 18px;
}

.quiz-option--long {
  white-space: normal;
  line-height: 1.6;
}

.glossary-quiz-feedback {
  display: grid;
  gap: 12px;
}

.glossary-quiz-feedback__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.glossary-quiz-feedback p {
  margin: 0;
}

/* ===== ASSISTANT PANEL ===== */
.assistant-panel {
  border-radius: var(--radius-xl);
  padding: 22px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: var(--accent-light);
  box-shadow: var(--shadow);
}

.assistant-panel__head,
.assistant-panel__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.assistant-panel__head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 1.8rem);
}

.assistant-panel__head p:last-child {
  margin: 8px 0 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.assistant-panel__hint {
  margin: 16px 0 0;
  color: var(--ink-soft);
  line-height: 1.6;
}

.assistant-panel__prompt {
  margin: 16px 0 0;
  padding: 16px;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-left: 3px solid var(--accent);
  background: #1e1e1e;
  color: #d4d4d4;
  white-space: pre-wrap;
}

.assistant-panel__prompt code {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.7;
}

.assistant-panel__actions {
  margin-top: 16px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 20px;
}

.empty-state h3 {
  margin: 0 0 6px;
}

/* ===== UTILITIES ===== */
.is-hidden {
  display: none;
}

.sidebar-note {
  margin: 10px 0 0;
  line-height: 1.6;
  font-size: 0.88rem;
}

.chapter-nav__time {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 700;
}

/* ===== NOSCRIPT ===== */
.noscript {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto 30px;
  text-align: center;
  background: var(--panel);
}

/* ===== FOOTER ===== */
.site-footer {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto 36px;
  padding: 0 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  font-weight: 700;
  color: var(--accent);
}

/* ===== RESPONSIVE: 1260px ===== */
@media (max-width: 1260px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .goal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chapter-head {
    grid-template-columns: 1fr;
  }
}

/* ===== RESPONSIVE: 1080px ===== */
@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    max-height: none;
  }

  .sidebar-shell {
    max-height: none;
    overflow: visible;
    padding: 20px;
  }

  .chapter-nav {
    max-height: none;
  }

  .hero__layout,
  .chapter-head,
  .lesson-deep-dive__grid,
  .quiz-grid,
  .exercise-grid,
  .glossary-grid {
    grid-template-columns: 1fr;
  }

  .hero-focus {
    order: -1;
  }

  .chapter-head__toolbar,
  .assistant-panel__head,
  .assistant-panel__actions,
  .site-footer {
    align-items: flex-start;
  }
}

/* ===== RESPONSIVE: 760px ===== */
@media (max-width: 760px) {
  .app-shell {
    width: min(100%, calc(100% - 16px));
    margin: 10px auto 20px;
    gap: 14px;
  }

  .site-footer {
    width: min(100%, calc(100% - 16px));
    padding: 0;
  }

  body[data-page="home"] {
    padding: 0;
  }

  .home-stage {
    min-height: 100svh;
    place-items: start center;
    padding: 34px 18px;
  }

  .home-scene__chip {
    display: none;
  }

  .home-hero {
    gap: 24px;
  }

  .home-course-actions {
    grid-template-columns: 1fr;
  }

  .home-course-button {
    min-height: 124px;
    padding: 18px;
  }

  .home-course-button__code {
    width: 56px;
    height: 56px;
  }

  .sidebar {
    max-height: none;
  }

  .sidebar-shell {
    max-height: none;
    overflow: visible;
    padding: 16px;
    border-radius: var(--radius-lg);
  }

  .hero,
  .chapter-panel,
  .glossary-panel,
  .assistant-panel {
    border-radius: var(--radius-lg);
    padding: 18px;
  }

  .hero__title {
    font-size: clamp(1.8rem, 8vw, 2.6rem);
  }

  .hero__spotlight,
  .chapter-head__toolbar,
  .chapter-head__status {
    padding: 16px;
    border-radius: var(--radius-md);
  }

  .goal-grid,
  .hero-facts {
    grid-template-columns: 1fr;
  }

  .chapter-nav__item,
  .lesson-section,
  .exercise-card,
  .quiz-card,
  .glossary-card {
    border-radius: var(--radius-sm);
  }

  .course-tabbar {
    justify-content: flex-start;
    position: static;
  }

  .tab-button,
  .ghost-button,
  .action-button {
    width: 100%;
    justify-content: center;
  }

  .chapter-head__actions,
  .hero-actions {
    width: 100%;
  }

  .hero-actions .action-button,
  .chapter-head__actions .ghost-button,
  .chapter-head__actions .action-button,
  .glossary-card__actions .ghost-button,
  .glossary-card__actions .action-button,
  .glossary-study__actions .ghost-button,
  .glossary-study__actions .action-button {
    width: 100%;
    justify-content: center;
  }

  .tab-button {
    flex-basis: 100%;
  }

  .glossary-mode-switch,
  .glossary-topbar__meta,
  .glossary-card__actions,
  .glossary-study__actions {
    width: 100%;
  }

  .flashcard__face,
  .glossary-study,
  .quiz-card--glossary {
    padding: 18px;
    border-radius: var(--radius-md);
  }
}

/* ===== FORMULAS ===== */
.formula {
  font-family: "DM Serif Display", "Times New Roman", Georgia, serif;
  font-feature-settings: "lnum" 1, "tnum" 0;
  color: var(--ink);
}

.formula var {
  font-style: italic;
  font-family: inherit;
}

.formula--block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 20px auto;
  padding: 18px 24px;
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md, 10px);
  max-width: 100%;
  overflow-x: auto;
}

.formula--block .formula__body {
  font-size: 1.35rem;
  line-height: 1.9;
  text-align: center;
  white-space: nowrap;
}

.formula--block .formula__caption {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--ink);
  opacity: 0.7;
  font-style: italic;
}

.formula--inline {
  display: inline;
  font-size: 1.05em;
  padding: 0 2px;
}

.formula .op {
  font-style: normal;
  padding: 0 0.15em;
}

.formula .sum {
  font-style: normal;
  font-size: 1.5em;
  line-height: 0.8;
  display: inline-block;
  vertical-align: middle;
  position: relative;
  padding: 0 0.1em;
}

.formula .sum-limits {
  display: inline-flex;
  flex-direction: column;
  font-size: 0.55em;
  line-height: 1;
  vertical-align: middle;
  font-style: normal;
  padding: 0 0.3em 0 0.1em;
  text-align: center;
  font-family: "DM Sans", system-ui, sans-serif;
}

.formula .sum-limits .top {
  margin-bottom: 0.15em;
}

.formula .sum-limits .bot {
  margin-top: 0.15em;
}

.formula .fn {
  font-style: normal;
  font-family: "DM Sans", system-ui, sans-serif;
  font-weight: 500;
  padding-right: 0.1em;
}

.formula .fraction {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  vertical-align: middle;
  margin: 0 0.18em;
  line-height: 1.05;
}

.formula .fraction .num,
.formula .fraction .den {
  display: block;
  padding: 0 0.28em;
  white-space: nowrap;
}

.formula .fraction .num {
  border-bottom: 1.5px solid currentColor;
  padding-bottom: 0.12em;
}

.formula .fraction .den {
  padding-top: 0.12em;
  font-size: 0.9em;
}

.formula .pipeline {
  font-family: "DM Sans", system-ui, sans-serif;
  font-style: normal;
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.formula .pipeline .arrow {
  padding: 0 0.4em;
  color: var(--accent);
}

.formula .pipeline .group {
  display: inline-block;
  padding: 0.1em 0.5em;
  margin: 0 0.1em;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 6px;
}

@media (prefers-color-scheme: dark) {
  .formula .pipeline .group {
    background: rgba(255, 255, 255, 0.05);
  }
}

/* ===== FIGURES (SVG, schemas, diagrams) ===== */
.figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 22px auto;
  padding: 18px 22px;
  background: var(--accent-light);
  border: 1px solid rgba(20, 184, 166, 0.18);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md, 10px);
  max-width: 100%;
  overflow-x: auto;
}

.figure__body {
  display: flex;
  justify-content: center;
  width: 100%;
}

.figure__body svg {
  max-width: 100%;
  height: auto;
  display: block;
}

.figure__caption {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.82rem;
  color: var(--ink);
  opacity: 0.75;
  font-style: italic;
  text-align: center;
  max-width: 54ch;
}

.figure--tight {
  padding: 10px 14px;
  gap: 6px;
  margin: 14px auto;
}

.figure--wide .figure__caption {
  max-width: 72ch;
}

/* SVG semantic colors — inherit the course accent variables */
.figure svg .svg-grid {
  stroke: rgba(15, 23, 42, 0.35);
  fill: none;
  stroke-width: 1;
}

.figure svg .svg-cell {
  fill: rgba(255, 255, 255, 0.7);
  stroke: rgba(15, 23, 42, 0.35);
  stroke-width: 1;
}

.figure svg .svg-cell-text {
  fill: var(--ink, #0f172a);
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  text-anchor: middle;
  dominant-baseline: central;
}

.figure svg .svg-label {
  fill: var(--ink, #0f172a);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 13px;
  text-anchor: middle;
}

.figure svg .svg-label-small {
  fill: var(--ink, #0f172a);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 11px;
  text-anchor: middle;
  opacity: 0.75;
}

.figure svg .svg-filter-cell {
  fill: rgba(20, 184, 166, 0.18);
  stroke: var(--accent);
  stroke-width: 1.2;
}

.figure svg .svg-highlight {
  fill: rgba(20, 184, 166, 0.28);
  stroke: var(--accent);
  stroke-width: 2;
}

.figure svg .svg-arrow {
  stroke: var(--accent);
  stroke-width: 1.6;
  fill: none;
  marker-end: url(#arrowHead);
}

.figure svg .svg-pipeline-block {
  fill: rgba(255, 255, 255, 0.7);
  stroke: var(--accent);
  stroke-width: 1.4;
}

.figure svg .svg-pipeline-block-text {
  fill: var(--ink, #0f172a);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: central;
}

.figure svg .svg-neuron {
  fill: rgba(255, 255, 255, 0.85);
  stroke: var(--accent);
  stroke-width: 1.4;
}

.figure svg .svg-neuron-dropped {
  fill: rgba(148, 163, 184, 0.25);
  stroke: rgba(148, 163, 184, 0.6);
  stroke-dasharray: 3 3;
}

.figure svg .svg-connection {
  stroke: rgba(20, 184, 166, 0.45);
  stroke-width: 1;
  fill: none;
}

@media (prefers-color-scheme: dark) {
  .figure {
    background: rgba(20, 184, 166, 0.12);
    border-color: rgba(45, 212, 191, 0.22);
  }
  .figure svg .svg-grid,
  .figure svg .svg-cell {
    stroke: rgba(226, 232, 240, 0.4);
  }
  .figure svg .svg-cell {
    fill: rgba(15, 23, 42, 0.5);
  }
  .figure svg .svg-cell-text,
  .figure svg .svg-label,
  .figure svg .svg-label-small,
  .figure svg .svg-pipeline-block-text {
    fill: #e2e8f0;
  }
  .figure svg .svg-pipeline-block {
    fill: rgba(15, 23, 42, 0.55);
  }
  .figure svg .svg-neuron {
    fill: rgba(15, 23, 42, 0.55);
  }
}

/* --- Animations used inside figures --- */

@keyframes anim-slide-window {
  0%, 8%    { transform: translate(0, 0); }
  11%, 19%  { transform: translate(40px, 0); }
  22%, 30%  { transform: translate(80px, 0); }
  33%, 41%  { transform: translate(0, 40px); }
  44%, 52%  { transform: translate(40px, 40px); }
  55%, 63%  { transform: translate(80px, 40px); }
  66%, 74%  { transform: translate(0, 80px); }
  77%, 85%  { transform: translate(40px, 80px); }
  88%, 100% { transform: translate(80px, 80px); }
}

.figure svg .anim-slide-window {
  animation: anim-slide-window 6s ease-in-out infinite;
}

@keyframes anim-slide-output {
  0%, 10%    { opacity: 0; }
  11%, 21%   { opacity: 1; }
  22%, 32%   { opacity: 1; }
  33%, 100%  { opacity: 1; }
}

.figure svg .anim-output-appear-0 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 0s; opacity: 0; }
.figure svg .anim-output-appear-1 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 0.66s; opacity: 0; }
.figure svg .anim-output-appear-2 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 1.32s; opacity: 0; }
.figure svg .anim-output-appear-3 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 2.00s; opacity: 0; }
.figure svg .anim-output-appear-4 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 2.66s; opacity: 0; }
.figure svg .anim-output-appear-5 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 3.32s; opacity: 0; }
.figure svg .anim-output-appear-6 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 4.00s; opacity: 0; }
.figure svg .anim-output-appear-7 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 4.66s; opacity: 0; }
.figure svg .anim-output-appear-8 { animation: anim-output-appear 6s ease-in-out infinite; animation-delay: 5.32s; opacity: 0; }

@keyframes anim-output-appear {
  0%, 5%   { opacity: 0; transform: scale(0.6); }
  10%, 95% { opacity: 1; transform: scale(1); }
  100%     { opacity: 1; transform: scale(1); }
}

@keyframes anim-pulse-highlight {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

.figure svg .anim-pulse {
  animation: anim-pulse-highlight 1.6s ease-in-out infinite;
}

@keyframes anim-dropout-flicker {
  0%, 24%  { opacity: 1; }
  25%, 49% { opacity: 0.2; }
  50%, 74% { opacity: 1; }
  75%, 99% { opacity: 0.2; }
  100%     { opacity: 1; }
}

.figure svg .anim-dropout-a { animation: anim-dropout-flicker 3.2s steps(1, end) infinite; animation-delay: 0s; }
.figure svg .anim-dropout-b { animation: anim-dropout-flicker 3.2s steps(1, end) infinite; animation-delay: 0.8s; }
.figure svg .anim-dropout-c { animation: anim-dropout-flicker 3.2s steps(1, end) infinite; animation-delay: 1.6s; }
.figure svg .anim-dropout-d { animation: anim-dropout-flicker 3.2s steps(1, end) infinite; animation-delay: 2.4s; }

@keyframes anim-ball-descend {
  0%   { transform: translate(0, 0); }
  15%  { transform: translate(30px, 20px); }
  30%  { transform: translate(55px, 38px); }
  45%  { transform: translate(75px, 52px); }
  60%  { transform: translate(90px, 62px); }
  75%  { transform: translate(100px, 68px); }
  90%, 100% { transform: translate(105px, 70px); }
}

.figure svg .anim-ball {
  animation: anim-ball-descend 4s ease-in-out infinite alternate;
}

@keyframes anim-pipeline-flow {
  0%   { stroke-dashoffset: 24; }
  100% { stroke-dashoffset: 0; }
}

.figure svg .anim-pipeline-arrow {
  stroke-dasharray: 6 6;
  animation: anim-pipeline-flow 1.2s linear infinite;
}

/* ===== COURSE THEMES ===== */
body[data-course="ia"] {
  --accent: #14b8a6;
  --accent-dark: #0d9488;
  --accent-light: rgba(20, 184, 166, 0.12);
  --teal: #06b6d4;
  --teal-soft: rgba(6, 182, 212, 0.12);
}

@media (prefers-color-scheme: dark) {
  body[data-course="ia"] {
    --accent: #2dd4bf;
    --accent-dark: #14b8a6;
    --accent-light: rgba(45, 212, 191, 0.18);
    --teal: #22d3ee;
    --teal-soft: rgba(34, 211, 238, 0.18);
  }
}

.course-switch-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 4px 10px -2px rgba(var(--shadow-color), 0.15);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  font-size: 0.92rem;
  transition: var(--transition-smooth);
}

.course-switch-link--sidebar {
  min-height: 46px;
}

.course-switch-link:hover,
.course-switch-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  filter: brightness(1.05);
  text-decoration: none;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
