:root {
  --bg: #f6f8fc;
  --panel: #ffffff;
  --panel-soft: #eef4ff;
  --ink: #14213d;
  --muted: #5b677a;
  --line: #d9e2f2;
  --visa-blue: #1434cb;
  --visa-gold: #f7b600;
  --blue-soft: rgba(20, 52, 203, 0.08);
  --gold-soft: rgba(247, 182, 0, 0.18);
  --success: #15803d;
  --danger: #b91c1c;
  --code: #111827;
  --sidebar-width: 300px;
  --toc-width: 245px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font-sans);
}

.app {
  display: flex;
  width: 100vw;
  height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #071b55;
  color: #f8fafc;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-header {
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.logo-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--visa-gold);
  color: #071b55;
  font-weight: 900;
}

.logo-text {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
}

.sidebar-close {
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 7px 10px;
  font-family: var(--font-sans);
  font-weight: 800;
  cursor: pointer;
}

.stats {
  display: grid;
  gap: 8px;
}

.stats-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #dbeafe;
  font-size: 12px;
}

.progress-track {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--visa-gold);
  transition: width 180ms ease;
}

.focus {
  color: #bfdbfe;
  font-size: 12px;
  line-height: 1.4;
}

.search-box {
  padding: 14px 18px;
}

.search-box input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 10px 11px;
  font-family: var(--font-sans);
}

.search-box input::placeholder {
  color: #b7c4dc;
}

.nav-tree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 16px;
}

.nav-category {
  margin: 12px 6px 7px;
  color: #fde68a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  color: #dbeafe;
  text-decoration: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.nav-item:hover,
.nav-item.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-checkbox {
  width: 20px;
  color: var(--visa-gold);
  font-family: var(--font-mono);
  text-align: center;
}

.nav-item.completed .title {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  color: #b6c8e7;
}

.nav-children {
  margin: 2px 0 8px 18px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.nav-item.child {
  min-height: 34px;
  padding: 7px 9px;
  font-size: 12.5px;
}

.nav-status {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 2px 6px;
  color: #071b55;
  background: #fde68a;
  font-size: 10px;
  font-weight: 800;
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}

.quiz-button,
.practice-button,
.primary-button,
.secondary-button,
.complete-button {
  border: 0;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-weight: 800;
  cursor: pointer;
}

.quiz-button {
  width: 100%;
  padding: 11px 12px;
  background: var(--visa-gold);
  color: #071b55;
}

.practice-button {
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.sidebar-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--ink);
  font-weight: 700;
}

.breadcrumb {
  color: var(--muted);
  font-size: 13px;
}

.content-layout {
  min-height: 0;
  flex: 1;
  display: flex;
  justify-content: center;
}

.markdown-body {
  flex: 1;
  max-width: 1040px;
  overflow-y: auto;
  padding: 36px 52px 80px;
}

.toc-sidebar {
  width: var(--toc-width);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 26px 18px;
  background: #fbfdff;
  border-left: 1px solid var(--line);
}

.toc-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.toc-item {
  display: block;
  color: var(--muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding: 7px 8px;
  font-size: 13px;
}

.toc-item:hover {
  color: var(--visa-blue);
  background: var(--blue-soft);
}

.toc-item.nested {
  padding-left: 18px;
  font-size: 12px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--visa-blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.page-header h1,
.markdown-body h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 2.55rem;
  line-height: 1.04;
}

.complete-button {
  flex-shrink: 0;
  padding: 10px 13px;
  background: var(--blue-soft);
  color: var(--visa-blue);
  border: 1px solid rgba(20, 52, 203, 0.2);
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.status-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-select {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 9px 10px;
  font-family: var(--font-sans);
  font-weight: 700;
}

.page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 22px;
}

.page-meta span,
.signal-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--panel);
  font-size: 12px;
  font-weight: 700;
}

.study-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 18px 0 26px;
}

.dashboard-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff, #f4f7ff);
  box-shadow: 0 12px 30px rgba(20, 52, 203, 0.07);
}

.dashboard-card strong {
  display: block;
  margin: 5px 0;
  color: var(--visa-blue);
  font-size: 2rem;
  line-height: 1;
}

.dashboard-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.markdown-body h1:first-of-type {
  display: none;
}

.markdown-body h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 34px 0 14px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1.16;
}

.markdown-body h3 {
  margin: 26px 0 11px;
  color: var(--visa-blue);
  font-size: 1.15rem;
}

.markdown-body h4 {
  margin: 20px 0 8px;
  color: var(--ink);
  font-size: 1rem;
}

.markdown-body p,
.markdown-body li {
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.72;
}

.markdown-body strong {
  color: var(--ink);
}

.markdown-body a {
  color: var(--visa-blue);
  font-weight: 700;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 24px;
  margin-bottom: 18px;
}

.markdown-body blockquote {
  margin: 18px 0;
  padding: 14px 16px;
  border-left: 4px solid var(--visa-gold);
  border-radius: 0 10px 10px 0;
  background: var(--gold-soft);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 24px;
  background: var(--panel);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line);
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  color: var(--ink);
  background: var(--panel-soft);
}

.markdown-body code {
  border-radius: 5px;
  padding: 2px 5px;
  background: #e9eef8;
  color: #9f1239;
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.markdown-body pre {
  overflow-x: auto;
  margin: 16px 0 22px;
  padding: 16px;
  border-radius: 12px;
  background: var(--code);
  border: 1px solid #243044;
}

.markdown-body pre code {
  padding: 0;
  color: #eef2ff;
  background: transparent;
  font-size: 13px;
  line-height: 1.6;
}

.section-check {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 1px solid rgba(20, 52, 203, 0.24);
  border-radius: 999px;
  background: var(--panel);
  color: var(--visa-blue);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
}

.section-check.checked {
  background: var(--visa-blue);
  color: #ffffff;
}

.copy-say-button {
  border: 1px solid rgba(20, 52, 203, 0.22);
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--visa-blue);
  padding: 7px 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.mermaid-diagram {
  overflow-x: auto;
  margin: 18px 0 24px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.mermaid-diagram svg {
  min-width: 680px;
}

.mermaid-error {
  color: var(--danger);
  font-family: var(--font-mono);
}

.visual-demo {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 18px 0 24px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #f3f7ff);
  box-shadow: 0 18px 38px rgba(20, 52, 203, 0.08);
}

.visual-demo-title {
  color: var(--visa-blue);
  font-weight: 900;
  margin-bottom: 12px;
}

.array-demo {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  overflow-x: auto;
}

.array-cell {
  min-width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid #c7d2fe;
  border-radius: 9px;
  background: #eef4ff;
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 800;
}

.array-cell.hot {
  animation: pulseCell 1.6s ease-in-out infinite;
  background: #fff7d6;
  border-color: var(--visa-gold);
}

.pointer-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--visa-blue);
  animation: movePointer 3s ease-in-out infinite;
}

.window-demo {
  position: relative;
  display: flex;
  gap: 8px;
  padding-bottom: 18px;
}

.window-demo::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 152px;
  height: 5px;
  border-radius: 999px;
  background: var(--visa-gold);
  animation: slideWindow 3s ease-in-out infinite;
}

.grid-demo {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 7px;
}

.grid-cell {
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef4ff;
  border: 1px solid #c7d2fe;
  font-weight: 900;
}

.grid-cell.blocked {
  background: #fee2e2;
  border-color: #fecaca;
}

.grid-cell.path {
  animation: pulseCell 1.6s ease-in-out infinite;
  background: #dcfce7;
  border-color: #86efac;
}

.cache-demo {
  display: grid;
  gap: 8px;
  max-width: 360px;
}

.cache-row {
  display: flex;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  background: var(--panel);
  font-family: var(--font-mono);
}

.cache-row.evicted {
  animation: fadeEvict 2.4s ease-in-out infinite;
}

.system-flow-demo {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 18px 0 26px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(20, 52, 203, 0.08), transparent 45%),
    linear-gradient(180deg, #ffffff, #f5f8ff);
  box-shadow: 0 18px 38px rgba(20, 52, 203, 0.08);
}

.system-flow-title {
  margin-bottom: 14px;
  color: var(--visa-blue);
  font-weight: 900;
}

.flow-lane {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  align-items: center;
  gap: 12px;
  position: relative;
}

.flow-lane::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 50%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(20, 52, 203, 0.18), rgba(247, 182, 0, 0.5), rgba(20, 52, 203, 0.18));
  transform: translateY(-50%);
}

.flow-node {
  position: relative;
  z-index: 1;
  min-height: 74px;
  display: grid;
  place-items: center;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  padding: 10px;
  background: #ffffff;
  color: var(--ink);
  text-align: center;
  font-size: 13px;
  font-weight: 850;
  box-shadow: 0 10px 24px rgba(20, 52, 203, 0.06);
  animation: nodeGlow 3.5s ease-in-out infinite;
}

.flow-node:hover,
.class-card:hover {
  border-color: var(--visa-blue);
  box-shadow: 0 20px 42px rgba(20, 52, 203, 0.14);
}

.flow-node:nth-child(2) {
  animation-delay: 0.25s;
}

.flow-node:nth-child(3) {
  animation-delay: 0.5s;
}

.flow-node:nth-child(4) {
  animation-delay: 0.75s;
}

.flow-node:nth-child(5) {
  animation-delay: 1s;
}

.flow-packet {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  margin-top: 14px;
  background: var(--visa-gold);
  box-shadow: 0 0 0 8px rgba(247, 182, 0, 0.16);
  will-change: margin-left;
  animation: packetMove 4s ease-in-out infinite;
}

.class-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}

.class-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(20, 52, 203, 0.07);
  transition: border-color 160ms ease, box-shadow 160ms ease;
  animation: classLift 3.2s ease-in-out infinite;
}

.class-card:nth-child(2) {
  animation-delay: 0.25s;
}

.class-card:nth-child(3) {
  animation-delay: 0.5s;
}

.class-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--visa-blue);
}

.concept-callout {
  border: 1px solid rgba(20, 52, 203, 0.18);
  border-radius: 14px;
  margin: 18px 0 24px;
  padding: 16px 18px;
  background: #ffffff;
}

.concept-callout h4 {
  margin-top: 0;
  color: var(--visa-blue);
}

/* ── Capacity callout ── */

.capacity-callout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}

.capacity-metric {
  border: 1px solid rgba(20, 52, 203, 0.15);
  border-radius: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #eef4ff 0%, #ffffff 100%);
  text-align: center;
}

.capacity-metric strong {
  display: block;
  color: var(--visa-blue);
  font-size: 1.6rem;
  font-family: var(--font-mono);
  line-height: 1.2;
  margin-bottom: 4px;
}

.capacity-metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Schema card ── */

.schema-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 18px 0 24px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(20, 52, 203, 0.07);
}

.schema-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #071b55 0%, #1434cb 100%);
  color: #ffffff;
  font-weight: 850;
  font-size: 14px;
}

.schema-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.schema-field:last-child {
  border-bottom: none;
}

.schema-field-name {
  min-width: 140px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink);
}

.schema-field-type {
  min-width: 90px;
  color: #9f1239;
  font-family: var(--font-mono);
  font-size: 12px;
}

.schema-field-note {
  color: var(--muted);
  font-size: 12px;
}

.schema-field-badge {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.schema-field-badge.pk {
  background: rgba(247, 182, 0, 0.2);
  color: #92400e;
}

.schema-field-badge.idx {
  background: rgba(20, 52, 203, 0.1);
  color: var(--visa-blue);
}

.schema-field-badge.fk {
  background: rgba(21, 128, 61, 0.1);
  color: #15803d;
}

/* ── Decision tree ── */

.decision-tree {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 18px 0 26px;
  padding: 18px;
  background: linear-gradient(180deg, #ffffff, #f8faff);
  box-shadow: 0 14px 34px rgba(20, 52, 203, 0.06);
}

.decision-tree-title {
  margin-bottom: 14px;
  color: var(--visa-blue);
  font-weight: 900;
}

.decision-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.decision-node {
  padding: 10px 14px;
  border-radius: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.decision-node.question {
  grid-column: 1 / -1;
  background: #eef4ff;
  border: 1px solid #c7d2fe;
  color: var(--ink);
  animation: nodeGlow 3.5s ease-in-out infinite;
}

.decision-node.yes {
  background: rgba(21, 128, 61, 0.1);
  border: 1px solid rgba(21, 128, 61, 0.3);
  color: #15803d;
}

.decision-node.no {
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.25);
  color: #b91c1c;
}

.decision-arrow {
  color: var(--muted);
  font-weight: 900;
  font-size: 18px;
  text-align: center;
}

/* ── Multi-row flow ── */

.flow-multi {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 18px 0 26px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(20, 52, 203, 0.06), transparent 45%),
    linear-gradient(180deg, #ffffff, #f5f8ff);
  box-shadow: 0 18px 38px rgba(20, 52, 203, 0.08);
}

.flow-multi-title {
  margin-bottom: 14px;
  color: var(--visa-blue);
  font-weight: 900;
}

.flow-multi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  align-items: center;
  gap: 10px;
  position: relative;
  margin-bottom: 12px;
}

.flow-multi-row::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 50%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(20, 52, 203, 0.14), rgba(247, 182, 0, 0.4), rgba(20, 52, 203, 0.14));
  transform: translateY(-50%);
}

.flow-multi-label {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 6px 0 2px;
}

.flow-node-success {
  position: relative;
  z-index: 1;
  min-height: 62px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(21, 128, 61, 0.3);
  border-radius: 10px;
  padding: 8px;
  background: rgba(21, 128, 61, 0.06);
  color: #15803d;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  animation: nodeGlow 3.5s ease-in-out infinite;
}

.flow-node-danger {
  position: relative;
  z-index: 1;
  min-height: 62px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(185, 28, 28, 0.25);
  border-radius: 10px;
  padding: 8px;
  background: rgba(185, 28, 28, 0.05);
  color: #b91c1c;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.flow-node-warn {
  position: relative;
  z-index: 1;
  min-height: 62px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(247, 182, 0, 0.4);
  border-radius: 10px;
  padding: 8px;
  background: rgba(247, 182, 0, 0.08);
  color: #92400e;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

/* ── Comparison table ── */

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 18px 0 24px;
}

.compare-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(20, 52, 203, 0.05);
}

.compare-card h4 {
  margin: 0 0 8px;
  color: var(--visa-blue);
  font-size: 14px;
}

.compare-card ul {
  margin: 0;
  padding-left: 18px;
}

.compare-card li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}

/* ── Sequence steps ── */

.sequence-steps {
  border: 1px solid var(--line);
  border-radius: 16px;
  margin: 18px 0 26px;
  padding: 18px;
  background: #ffffff;
  counter-reset: seq-step;
}

.sequence-steps-title {
  margin-bottom: 14px;
  color: var(--visa-blue);
  font-weight: 900;
}

.seq-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  counter-increment: seq-step;
}

.seq-step:last-child {
  border-bottom: none;
}

.seq-step::before {
  content: counter(seq-step);
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--visa-blue);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}

.seq-step-content {
  flex: 1;
}

.seq-step-content strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  margin-bottom: 2px;
}

.seq-step-content span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.seq-step-fail {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(185, 28, 28, 0.08);
  color: #b91c1c;
  font-size: 11px;
  font-weight: 800;
  margin-left: 6px;
}

@keyframes pulseCell {
  0%, 100% {
    transform: translateY(0);
    box-shadow: none;
  }
  50% {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(20, 52, 203, 0.12);
  }
}

@keyframes movePointer {
  0%, 100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(240px);
  }
}

@keyframes slideWindow {
  0%, 100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(116px);
  }
}

@keyframes fadeEvict {
  0%, 100% {
    opacity: 1;
    transform: translateX(0);
  }
  50% {
    opacity: 0.35;
    transform: translateX(18px);
  }
}

@keyframes nodeGlow {
  0%, 100% {
    transform: translateY(0);
    border-color: #c7d2fe;
  }
  50% {
    transform: translateY(-4px);
    border-color: var(--visa-blue);
    box-shadow: 0 18px 30px rgba(20, 52, 203, 0.14);
  }
}

@keyframes packetMove {
  0%, 100% {
    margin-left: 0;
  }
  50% {
    margin-left: calc(100% - 18px);
  }
}

@keyframes classLift {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .array-cell.hot,
  .pointer-dot,
  .window-demo::after,
  .grid-cell.path,
  .cache-row.evicted,
  .flow-node,
  .flow-packet,
  .class-card,
  .decision-node.question,
  .flow-node-success {
    animation: none;
  }
}

.learning-card,
.board-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--panel);
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 18px 0 24px;
}

.loading,
.error {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal.open {
  display: block;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-panel {
  position: relative;
  width: min(640px, calc(100vw - 28px));
  margin: 7vh auto;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
}

.icon-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 7px 10px;
  cursor: pointer;
}

.quiz-card {
  padding: 20px;
}

.quiz-meta {
  color: var(--visa-blue);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.quiz-question {
  color: var(--ink);
  font-weight: 800;
  margin-bottom: 14px;
}

.practice-prompt {
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1.5;
  margin-bottom: 14px;
}

.quiz-options {
  display: grid;
  gap: 9px;
}

.quiz-option {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  text-align: left;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.quiz-option.correct {
  border-color: rgba(21, 128, 61, 0.4);
  background: rgba(21, 128, 61, 0.1);
}

.quiz-option.wrong {
  border-color: rgba(185, 28, 28, 0.4);
  background: rgba(185, 28, 28, 0.08);
}

.quiz-explanation {
  display: none;
  margin-top: 14px;
  padding: 13px;
  border-radius: 10px;
  color: var(--muted);
  background: var(--panel-soft);
}

.quiz-explanation.visible {
  display: block;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
}

.primary-button {
  padding: 10px 14px;
  color: #ffffff;
  background: var(--visa-blue);
}

.secondary-button {
  padding: 10px 14px;
  color: var(--visa-blue);
  background: var(--blue-soft);
}

@media (max-width: 1100px) {
  .toc-sidebar {
    display: none !important;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    z-index: 50;
  }

  .sidebar.collapsed {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .content {
    width: 100%;
  }

  .content-layout {
    display: block;
  }

  .markdown-body {
    height: calc(100vh - 54px);
    padding: 24px 20px 70px;
  }

  .page-header {
    display: grid;
  }

  .page-header h1,
  .markdown-body h1 {
    font-size: 2rem;
  }
}
