.deck {
  --accent: #2f9e44;
  --accent-deep: #237534;
  --accent-soft: #e3f5e6;
  --accent-ink: #fff;
  --red: #e03131;
}

/* Title */
.title-slide { flex-direction: row; align-items: center; gap: clamp(28px, 6vw, 80px); }
.title-slide h1 { font-size: clamp(2.3rem, 4.2vw + 0.5rem, 4.4rem); max-width: 13ch; }
.title-slide .lead { font-size: clamp(1.05rem, 0.8vw + 0.8rem, 1.3rem); max-width: 46ch; }
.series { font-family: var(--mono); font-size: 0.8em; font-weight: 700; color: var(--accent-deep); }
.hero { flex: none; width: min(100%, 360px); height: auto; }
.hero .h-edges path { stroke: var(--ink); stroke-width: 3; fill: none; }
.hero circle { fill: var(--panel); stroke: var(--ink); stroke-width: 3; }
.hero circle.root, .hero rect.root { fill: var(--accent); stroke: var(--accent-deep); }
.hero rect { fill: var(--panel); stroke: var(--ink); stroke-width: 2.5; }
.hero text { font-family: var(--mono); font-weight: 700; font-size: 20px; text-anchor: middle; dominant-baseline: central; fill: var(--ink); }
.hero .h-link { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 5 5; fill: none; }
@media (max-width: 900px) {
  .title-slide { flex-direction: column-reverse; align-items: stretch; }
  .hero { width: min(100%, 300px); align-self: center; }
}

.mono { font-family: var(--mono); }
.num-in { font: inherit; font-family: var(--mono); width: 5.2em; min-height: 34px; padding: 4px 8px; border: 1.5px solid var(--ink); border-radius: 8px; background: var(--panel); color: var(--ink); }
.txt-in { font: inherit; width: 9em; min-height: 34px; padding: 4px 10px; border: 1.5px solid var(--ink); border-radius: 8px; background: var(--panel); color: var(--ink); }
.step-n { font-family: var(--mono); font-size: 0.85em; color: var(--muted); margin-right: 4px; }
.cost-track { flex: 1; height: 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; display: block; }
.cost-fill { display: block; height: 100%; background: var(--accent-deep); transition: width 0.15s; }
.cost-fill.leaf { background: var(--accent); }

/* Tree view */
.tv-host { display: flex; justify-content: center; min-height: 60px; overflow: hidden; }
.tv { display: block; max-width: 100%; height: auto; overflow: visible; }
.tv-edge { stroke: #b4c2ce; stroke-width: 2; }
.tv-node circle { fill: var(--panel); stroke: var(--ink); stroke-width: 1.8; transition: fill 0.2s, stroke 0.2s; }
.tv-node text { font-family: var(--mono); font-weight: 700; fill: var(--ink); pointer-events: none; }
.tv-node .tv-note { font-size: 10px; font-weight: 400; fill: var(--muted); }
.tv-node.click { cursor: pointer; }
.tv-node.click:hover circle { fill: var(--accent-soft); }
.tv-node.path circle { fill: var(--accent-soft); stroke: var(--accent-deep); stroke-width: 2.5; }
.tv-node.onstack circle { fill: var(--accent-soft); stroke: var(--accent); stroke-dasharray: 4 3; stroke-width: 2.2; }
.tv-node.cur circle { fill: var(--value); stroke: var(--ink); stroke-width: 2.5; }
.tv-node.done circle { fill: var(--accent); stroke: var(--accent-deep); }
.tv-node.done text:not(.tv-note) { fill: #fff; }
.tv-node.new circle { fill: var(--value); }
.tv-node.found circle { fill: var(--ok); stroke: #007a75; }
.tv-node.found text:not(.tv-note) { fill: #fff; }
.tv-node.target circle { stroke: var(--ok); stroke-width: 3; }
.tv-node.bad circle { fill: var(--block-soft); stroke: var(--block); stroke-width: 2.5; }
.tv-node.bad .tv-note { fill: var(--block); font-weight: 700; }
.tv-node.red circle { fill: var(--red); stroke: #a51d1d; }
.tv-node.black circle { fill: var(--ink); stroke: var(--ink); }
.tv-node.red text, .tv-node.black text { fill: #fff; }
.tv-node.term circle { stroke-width: 3.5; }

/* Trees everywhere */
.ew-tree { font-family: var(--mono); font-size: 0.82em; line-height: 1.75; background: var(--paper); border-radius: 10px; padding: 8px 12px; overflow-x: auto; }
.ew-row { display: flex; align-items: center; white-space: pre; }
.ew-line { color: #9aaab8; }
.ew-lab { padding: 0 6px; border-radius: 4px; transition: background 0.2s; }
.ew-row.on .ew-lab { background: var(--accent-soft); }
.ew-row.cur .ew-lab { background: var(--value); }
.ew-ord { margin-left: 6px; min-width: 1.6em; height: 1.6em; display: inline-grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 0.78em; font-weight: 700; }

/* Traversal / stacks */
.tr-row { display: flex; gap: 10px; align-items: center; min-height: 2em; }
.tr-l { min-width: 7.2em; flex: none; }
.queue .arr { color: var(--muted); font-size: 0.8em; }
.val.dim { opacity: 0.35; }
.val.cur { background: var(--value); }
.val.top { background: var(--accent-soft); border-color: var(--accent-deep); box-shadow: 0 0 0 2px var(--accent); }
@media (max-width: 520px) { .tr-row { flex-direction: column; align-items: flex-start; gap: 4px; } .tr-l { min-width: 0; } }

/* Balance panels */
.bal-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bal-p { border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-width: 0; display: flex; flex-direction: column; gap: 6px; min-height: 140px; }
.bal-h { font-size: 0.8em; font-weight: 600; color: var(--muted); }
.bal-h b { color: var(--ink); font-size: 1.15em; }
@media (max-width: 520px) { .bal-panels { grid-template-columns: 1fr; } }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.card p { font-size: 0.9em; }
@media (max-width: 1000px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }

/* Quiz question inside the quiz block */
.quiz .q { font-size: 1.02em; margin-bottom: 4px; }

/* Fan-out calculator */
.fo-l { min-width: 5.5em; }
.slider output { min-width: 8.6em; font-size: 0.85em; }
.demo .queue .val { background: var(--panel); }
.demo .queue .val.cur { background: var(--value); }
.demo .queue .val.done { background: var(--ok-soft); }
.bal-l { min-width: 4.5em; }
.fo-levels { display: grid; gap: 4px; }
.fo-lv { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) 6.5em; gap: 10px; align-items: center; font-size: 0.85em; }
.fo-lv b { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 0.9em; }
.stats .stat span { line-height: 1.3; }

/* B+tree */
.bt { display: flex; flex-direction: column; gap: 10px; align-items: center; min-height: 80px; padding: 6px 0; }
.bt-level { display: flex; flex-wrap: wrap; gap: 6px 4px; justify-content: center; align-items: center; }
.bt-node { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 6px; overflow: hidden; background: var(--panel); font-family: var(--mono); font-size: 0.78em; font-weight: 700; transition: background 0.2s; }
.bt-node span { padding: 3px 6px; min-width: 2.2em; text-align: center; }
.bt-node span + span { border-left: 1px solid var(--line); }
.bt-node.leaf { background: var(--accent-soft); }
.bt-node.path { border-color: var(--accent-deep); box-shadow: 0 0 0 2px var(--accent); }
.bt-node.split { animation: bt-flash 1.2s; }
.bt-node .hit { background: var(--value); }
.bt-node .e { color: var(--muted); font-weight: 400; }
.bt-link { color: var(--muted); font-size: 0.8em; }
@keyframes bt-flash { 0%, 40% { background: var(--value); } }

/* Heap array */
.hp-arr { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.hp-cell { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.85em; border: 1.5px solid var(--ink); border-radius: 5px; background: var(--panel); font-family: var(--mono); transition: background 0.2s; }
.hp-cell b { font-size: 0.82em; padding: 1px 3px; }
.hp-cell i { font-style: normal; font-size: 0.62em; color: var(--muted); border-top: 1px solid var(--line); width: 100%; text-align: center; }
.hp-cell.top { background: var(--accent-soft); }
.hp-cell.cur { background: var(--value); }

/* Streams */
.sm-body { display: flex; flex-direction: column; gap: 8px; min-height: 9.5em; }
.md-halves { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: start; }
.md-halves > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.md-med { align-items: center; text-align: center; }
.md-med b { font-size: 1.8em; color: var(--accent-deep); font-variant-numeric: tabular-nums; }
@media (max-width: 520px) { .md-halves { grid-template-columns: 1fr; } .md-med { flex-direction: row !important; gap: 10px; } }

/* Trie */
.sug { font-family: var(--mono); font-size: 0.82em; padding: 2px 8px; border-radius: 6px; background: var(--paper); border: 1px solid var(--line); }
.sug b { color: var(--accent-deep); }

/* Longest prefix match */
.lp-bits { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; }
.lp-oct { display: grid; grid-template-columns: repeat(8, 0.78em); font-family: var(--mono); }
.lp-oct em { font-style: normal; font-size: 0.75em; color: var(--muted); font-weight: 700; }
.lp-oct > span { display: block; text-align: center; font-size: 0.85em; border-bottom: 3px solid transparent; color: var(--muted); }
.lp-oct > span.walk { color: var(--ink); font-weight: 700; border-bottom-color: #b4c2ce; }
.lp-oct > span.bestb { border-bottom-color: var(--accent); }
.lp-oct em { grid-column: 1 / -1; text-align: center; }
.lp-table { display: grid; gap: 4px; }
.lp-row { display: grid; grid-template-columns: 8.5em minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 4px 10px; border-radius: 6px; background: var(--paper); font-size: 0.86em; border-left: 4px solid var(--line); transition: background 0.2s, opacity 0.2s; }
.lp-row code { background: none; padding: 0; }
.lp-row b { font-size: 0.85em; }
.lp-row.ok { border-left-color: var(--accent); }
.lp-row.no { opacity: 0.45; }
.lp-row.best { background: var(--accent-soft); border-left-color: var(--accent-deep); }
.lp-row.best b { color: var(--accent-deep); }
@media (max-width: 520px) { .lp-row { grid-template-columns: 7.5em minmax(0, 1fr); } .lp-row b { display: none; } .lp-row.best b { display: inline; grid-column: 1 / -1; } }

/* Interview signals */
.sig { display: grid; gap: 6px; max-width: 1000px; }
.sig-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 9px 14px; background: var(--panel); border-radius: 8px; border-left: 4px solid var(--accent); font-size: 0.95em; }
.sig-row span { color: var(--muted); }
.sig-row b { font-weight: 600; }
@media (max-width: 700px) { .sig-row { grid-template-columns: 1fr; gap: 2px; } }
.limits { border-left: 3px solid var(--line); padding-left: 12px; margin-bottom: 6px; }
@media (max-width: 520px) { .lp-bits { display: grid; grid-template-columns: auto auto; justify-content: center; } }
