/* slides.css — Reusable slide deck styles for yuanhe.wiki
   Fixed 1920×1080 canvas, scaled to fit any viewport.

   ── FONT-SIZE RULE ──────────────────────────────────────
   HARD floor: 18px for any text on any slide.
   Body / labels:   ≥ 22px (comfortable for projection)
   Footnotes:       ≥ 18px
   SVG text:        ≥ 18px (effective, after viewBox scaling)
   Never use sub-18px — illegible at conference projection distance.
   ──────────────────────────────────────────────────────── */

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

:root {
  --bg: #faf9f5;
  --ink: #141413;
  --muted: #6b6b66;
  --accent: #d97757;
  --rule: rgba(20, 20, 19, 0.1);
  --code-bg: #f0efeb;
  --slide-w: 1920;
  --slide-h: 1080;
}

html,
body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #2c2c2a;
  -webkit-font-smoothing: antialiased;
}

/* ── Slide viewport ─────────────────────────────────── */

.deck {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2c2c2a;
}

.slide {
  position: absolute;
  width: 1920px;
  height: 1080px;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.slide.active {
  opacity: 1;
  pointer-events: auto;
}

.slide-inner {
  width: 100%;
  height: 100%;
  padding: 100px 240px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

/* ── Typography ─────────────────────────────────────── */

h1,
h2,
h3 {
  font-family: "Newsreader", "Source Serif 4", Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

h1 {
  font-size: 96px;
}

h2 {
  font-size: 60px;
  margin-bottom: 32px;
}

h3 {
  font-family: "Inter", sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

p,
li {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 40px;
  line-height: 1.5;
}

ul {
  padding-left: 1.3em;
}
li {
  margin-bottom: 16px;
}

strong {
  font-weight: 600;
}

a {
  color: inherit;
}

.accent {
  color: var(--accent);
  font-weight: 600;
}
.muted {
  color: var(--muted);
}
.warn {
  color: #c5524a;
  font-weight: 600;
}

code {
  font-family: "Source Code Pro", "SF Mono", monospace;
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 24px 28px;
  overflow-x: auto;
  margin: 20px 0;
}

pre code {
  background: none;
  padding: 0;
  font-size: 24px;
  line-height: 1.55;
}

/* ── Title slide ────────────────────────────────────── */

.slide--title .slide-inner {
  text-align: center;
  align-items: center;
  justify-content: center;
}

.slide--title h1 {
  margin-bottom: 20px;
}

.subtitle {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 40px;
  color: var(--muted);
  margin-bottom: 60px;
}

.divider {
  width: 100px;
  height: 3px;
  background: var(--accent);
  margin-bottom: 52px;
}

.author {
  font-family: "Inter", sans-serif;
  font-size: 28px;
  color: var(--muted);
}

.repo-links {
  font-family: "Source Code Pro", monospace;
  font-size: 22px;
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.gh-icon {
  width: 24px;
  height: 24px;
  color: var(--muted);
}

.repo-links a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition:
    color 0.2s,
    border-color 0.2s;
}

.repo-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Section divider slide ──────────────────────────── */

.slide--section .slide-inner {
  text-align: center;
  align-items: center;
  justify-content: center;
  /* optical centering — sit a touch above the true middle so it doesn't read low */
  padding-bottom: 220px;
}

.slide--section h2 {
  font-size: 104px;
}

.sect-sub {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 40px;
  font-style: normal;
  color: var(--muted);
  max-width: 1180px;
  margin-top: 36px;
  line-height: 1.4;
}

/* ── Callout box ────────────────────────────────────── */

.callout {
  background: rgba(20, 20, 19, 0.03);
  border-left: 3px solid var(--accent);
  padding: 16px 24px;
  margin: 20px 0;
  border-radius: 0 6px 6px 0;
}

.callout p {
  margin: 0;
}

/* ── Architecture tree ──────────────────────────────── */

.tree {
  font-family: "Source Code Pro", monospace;
  font-size: 20px;
  line-height: 1.8;
  background: var(--code-bg);
  padding: 28px 36px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  margin: 20px 0;
}

.tree .t-root {
  color: #b35309;
  font-weight: 600;
}
.tree .t-mid {
  color: #6d28d9;
  font-weight: 500;
}
.tree .t-leaf {
  color: var(--muted);
}

/* ── SVG diagrams ───────────────────────────────────── */

.arch-diagram {
  width: 100%;
  max-width: 1440px;
  height: auto;
  margin: 24px auto 0;
  display: block;
}

.loop-diagram {
  width: 100%;
  max-width: 1440px;
  height: auto;
  margin: 24px auto;
  display: block;
}

/* Event annotations — default terracotta, recolored on frag reveal (slide 4) */
.evt {
  fill: #d97757;
  stroke: #d97757;
  transition:
    fill 0.6s ease,
    stroke 0.6s ease;
}

/* ── Interactive contract explorer ───────────────────── */

.env-method {
  display: block;
  cursor: pointer;
  padding: 1px 0;
  border-left: 3px solid transparent;
  margin-left: -12px;
  padding-left: 9px;
  transition:
    border-color 0.25s ease,
    background 0.25s ease;
}

.env-contract code {
  line-height: 1.45;
}

.env-method:hover {
  background: rgba(217, 119, 87, 0.06);
}

.env-method.active {
  border-left-color: var(--accent);
  background: rgba(217, 119, 87, 0.08);
}

.env-examples {
  position: relative;
}

.env-ex {
  display: none;
}

.env-ex.active {
  display: block;
}

/* ── Multi-column layout ────────────────────────────── */

.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 24px 0;
}

.cols-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
  margin: 24px 0;
}

.card {
  background: rgba(20, 20, 19, 0.03);
  border-radius: 8px;
  padding: 24px 28px;
}

.card h3 {
  margin-top: 0;
}
.card ul {
  font-size: 22px;
}

/* ── Challenge grid (2×2) ───────────────────────────── */

/* ── Challenges (slide 3) — two pillars: Correctness · Efficiency ── */
.ch-thesis {
  font-size: 34px;
  color: var(--muted);
  margin: 0 0 60px;
  max-width: 1450px;
}

.ch-pillars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 100px;
}

.ch-pillar__name {
  font-family: "Newsreader", "Source Serif 4", Georgia, serif;
  font-size: 52px;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 38px;
}

.ch-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.ch-list li {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 32px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 42px;
}
.ch-list li:last-child {
  margin-bottom: 0;
}
.ch-list b {
  color: var(--ink);
  font-weight: 600;
}

/* scoped-out facet: named but deliberately below the "scope line" (kernel / RL-infra layer) */
.ch-list li.scoped {
  font-size: 27px;
  color: #aba89e;
  margin-top: 40px;
  padding-top: 26px;
  border-top: 1px solid var(--rule);
}
.ch-list li.scoped b {
  color: inherit;
  font-weight: 600;
}
.ch-list li.scoped::before {
  content: "Not elaborated here";
  display: block;
  font-family: "Inter", sans-serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Efficiency act (slides 16-18) — example-first code + takeaways ── */
.eff-lead {
  font-size: 40px;
  color: var(--muted);
  margin: 0 0 40px;
}

/* slide 16: two-beat intro — why async (muted), then the catch (ink) */
.eff-why {
  font-size: 40px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 16px;
}
.eff-but {
  font-size: 40px;
  color: var(--ink);
  line-height: 1.45;
  margin: 0 0 32px;
}

.eff-code {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 28px 34px;
  font-family: "Source Code Pro", monospace;
  font-size: 25px;
  line-height: 1.6;
  color: var(--ink);
  width: fit-content;
  max-width: 100%;
  margin: 56px auto 40px;
  overflow-x: auto;
}
.eff-code code {
  font-family: inherit;
  font-size: inherit;
  background: none;
  padding: 0;
}
.eff-cmt {
  color: #a8a69d;
}
.eff-hl {
  color: var(--accent);
}

.eff-takes {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.eff-take {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 40px;
  line-height: 1.4;
  color: var(--ink);
  position: relative;
  padding-left: 56px;
  margin-top: auto;
  margin-bottom: 170px;
}
.eff-take code {
  font-size: 0.86em;
}
.eff-mark {
  position: absolute;
  left: 0;
  top: 0;
  font-family: "Inter", sans-serif;
  font-weight: 700;
  font-size: 40px;
}
.eff-take--good .eff-mark {
  color: var(--accent);
}
.eff-take--bad {
  color: #b5453b;
}
.eff-take--bad .eff-mark {
  color: #c5524a;
}

/* slide 17: bottleneck → knob rows */
/* slide 18: tool execution — two env cards (name -> the wall -> the knob) */
.te-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 72px;
  margin-top: 64px;
}
.te-card__name {
  font-family: "Source Code Pro", monospace;
  font-size: 38px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 24px;
}
.te-card__wall {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 36px;
  color: var(--ink);
  line-height: 1.4;
  margin-bottom: 22px;
}
.te-card__knob {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 32px;
  color: var(--muted);
  line-height: 1.4;
}
.te-card__arrow {
  color: var(--accent);
  font-weight: 700;
  margin-right: 8px;
}
.te-card__knob code {
  font-size: 0.86em;
}

/* slide 18: muted forward-looking note (ties back to the challenges "scope line") */
.eff-take--note {
  color: var(--muted);
}
.eff-take--note .eff-mark {
  color: var(--accent);
}
.eff-scope {
  font-style: italic;
  color: #aba89e;
}

/* slide 18: observed-payoff callout */
.eff-stat {
  padding: 18px 28px;
  background: rgba(217, 119, 87, 0.07);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 26px;
  color: var(--ink);
  line-height: 1.45;
}
.eff-stat__nums {
  font-family: "Newsreader", "Source Serif 4", Georgia, serif;
  font-size: 34px;
  font-weight: 600;
  color: var(--accent);
}
.eff-stat__caveat {
  font-style: italic;
  color: #9b9890;
  font-size: 23px;
}

/* slide 17: "in practice" observation — muted callout, distinct from the conceptual takeaway */
.eff-note {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 30px;
  color: var(--muted);
  line-height: 1.45;
  padding: 18px 26px;
  background: rgba(20, 20, 19, 0.025);
  border-left: 3px solid var(--rule);
  border-radius: 0 8px 8px 0;
}
.eff-note b {
  color: var(--ink);
}
.eff-note__caveat {
  font-style: italic;
  color: #aba89e;
}

/* ── Slide 19: Fully Async Rollouts ─────────────────── */
.async-diagram {
  width: 100%;
  max-width: 1440px;
  height: auto;
  margin: 34px auto 0;
  display: block;
}
.async-caveats {
  margin-top: 44px;
}
.async-scope {
  font-size: 34px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 16px;
}
.async-risk {
  font-size: 38px;
  color: var(--ink);
  line-height: 1.4;
}
/* ── Hook event highlight (slide 4) ──────────────────
   Frag triggers are empty divs OUTSIDE the SVG (siblings) so
   :has() class-change detection works reliably. Inline tags live
   in the SVG and fade in via opacity. */

.evt {
  transition:
    opacity 0.4s ease,
    fill 0.4s ease,
    stroke 0.4s ease,
    font-size 0.3s ease,
    font-weight 0.3s ease;
}

.hook-trigger {
  display: block;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.hook-tag {
  opacity: 0;
  transition: opacity 0.4s ease;
}
.hook-tag-msgadd {
  fill: #5b7ea1;
}
.hook-tag-afterinv {
  fill: #5a8a6a;
}

@keyframes evt-glow-blue {
  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(91, 126, 161, 0.45));
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(91, 126, 161, 0.9));
  }
}

@keyframes evt-glow-green {
  0%,
  100% {
    filter: drop-shadow(0 0 4px rgba(90, 138, 106, 0.45));
  }
  50% {
    filter: drop-shadow(0 0 12px rgba(90, 138, 106, 0.9));
  }
}

/* ── Frag 1: msgadd highlight ── */
.slide.fragv-msgadd .evt:not(.evt-msgadd) {
  opacity: 0.25;
}
.slide.fragv-msgadd .hook-tag-msgadd {
  opacity: 1;
}
.slide.fragv-msgadd text.evt-msgadd {
  fill: #5b7ea1 !important;
  stroke: #5b7ea1 !important;
  font-size: 24px;
  font-weight: 700;
}
.slide.fragv-msgadd circle.evt-msgadd {
  r: 10;
  stroke: #5b7ea1 !important;
  fill: #5b7ea1 !important;
  animation: evt-glow-blue 1.4s ease-in-out infinite;
}
.slide.fragv-msgadd line.evt-msgadd {
  stroke: #5b7ea1 !important;
}

/* ── Frag 2: afterinv highlight — overrides frag 1 when cumulative ── */
.slide.fragv-afterinv .evt:not(.evt-afterinv) {
  opacity: 0.25;
}
/* Override msgadd's dim rule that would also dim evt-afterinv */
.slide.fragv-afterinv .evt-afterinv {
  opacity: 1 !important;
}
/* Hide msgadd inline tag */
.slide.fragv-afterinv .hook-tag-msgadd {
  opacity: 0;
}
/* Reveal afterinv inline tag */
.slide.fragv-afterinv .hook-tag-afterinv {
  opacity: 1;
}
/* Undo msgadd's highlight (back to default + dim treatment) */
.slide.fragv-afterinv text.evt-msgadd {
  fill: #d97757 !important;
  stroke: #d97757 !important;
  font-size: 20px;
  font-weight: 500;
}
.slide.fragv-afterinv circle.evt-msgadd {
  r: 6;
  stroke: #d97757 !important;
  fill: #d97757 !important;
  animation: none;
}
.slide.fragv-afterinv line.evt-msgadd {
  stroke: #d97757 !important;
}
/* Apply afterinv highlight */
.slide.fragv-afterinv text.evt-afterinv {
  fill: #5a8a6a !important;
  stroke: #5a8a6a !important;
  font-size: 24px;
  font-weight: 700;
}
.slide.fragv-afterinv circle.evt-afterinv {
  r: 10;
  stroke: #5a8a6a !important;
  fill: #5a8a6a !important;
  animation: evt-glow-green 1.4s ease-in-out infinite;
}
.slide.fragv-afterinv line.evt-afterinv {
  stroke: #5a8a6a !important;
}

/* ── Gym interface flow (slide 5) ───────────────────── */

.gym-flow {
  display: grid;
  grid-template-columns: 1fr auto 1.4fr auto 1fr;
  align-items: stretch;
  gap: 24px;
  margin-top: 60px;
}

.gym-flow__box {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.gym-flow__step {
  background: rgba(217, 119, 87, 0.08);
  border-color: rgba(217, 119, 87, 0.4);
}

.gym-flow__tag {
  font-family: "Inter", sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
}

.gym-flow__name {
  margin-bottom: 16px;
}

.gym-flow__name code {
  font-family: "Source Code Pro", monospace;
  font-size: 28px;
  font-weight: 600;
  background: rgba(20, 20, 19, 0.05);
  padding: 4px 12px;
  border-radius: 4px;
  color: var(--ink);
}

.gym-flow__fields {
  list-style: none;
  padding: 0;
  margin: 0;
}

.gym-flow__fields li {
  font-family: "Source Code Pro", monospace;
  font-size: 24px;
  color: var(--muted);
  margin-bottom: 6px;
}

.gym-flow__fields li code {
  background: transparent;
  padding: 0;
  font-size: 1em;
  color: var(--muted);
}

/* Invisible placeholder line for vertical alignment */
.gym-flow__ph {
  visibility: hidden;
}

/* Step verbs styled differently from variable names: italic serif */
.gym-flow__fields--steps li {
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-size: 26px;
  color: var(--accent);
}

.gym-flow__hero {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 30px;
  font-style: italic;
  color: var(--accent);
  line-height: 1.3;
  margin-bottom: 6px;
}

.gym-flow__sub {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 22px;
  color: var(--muted);
}

.gym-flow__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Inter", sans-serif;
  font-size: 56px;
  font-weight: 300;
  color: var(--muted);
}

/* Extension points (below the flow) */

.env-extend {
  margin-top: 56px;
}

.env-extend__label {
  font-family: "Inter", sans-serif;
  font-size: 28px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 24px;
}

.env-extend__label code {
  font-size: 0.95em;
  background: rgba(20, 20, 19, 0.06);
  color: var(--ink);
}

.env-extend__grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 32px;
  align-items: start;
}

.env-extend__group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.env-extend__group-label {
  grid-column: 1 / -1;
  font-family: "Inter", sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  margin-bottom: 6px;
}

.env-extend__method {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.env-extend__method code {
  font-family: "Source Code Pro", monospace;
  font-size: 28px;
  font-weight: 600;
  background: transparent;
  padding: 0;
  color: var(--ink);
}

.env-extend__method span {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 24px;
  color: var(--muted);
  line-height: 1.35;
}

.env-extend__divider {
  width: 1px;
  background: var(--rule);
  align-self: stretch;
  margin-top: 40px;
}

/* ── Algorithm block ────────────────────────────────── */

.algo {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 24px 32px;
}

.algo__title {
  font-family: "Inter", sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.algo__title code {
  font-size: 0.95em;
  background: transparent;
  padding: 0;
  color: var(--accent);
  text-transform: none;
}

.algo__steps {
  margin: 0;
  padding-left: 28px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 28px;
  line-height: 1.7;
  color: var(--ink);
}

.algo__steps li {
  margin-bottom: 6px;
}

.algo__steps li::marker {
  color: var(--muted);
  font-family: "Source Code Pro", monospace;
  font-size: 0.82em;
}

.algo__steps strong {
  color: var(--accent);
  font-weight: 600;
}

.algo__steps .var {
  font-family: "Source Code Pro", monospace;
  font-size: 0.88em;
  color: var(--ink);
}

.algo__steps code {
  font-family: "Source Code Pro", monospace;
  font-size: 0.88em;
  background: rgba(20, 20, 19, 0.05);
  color: var(--ink);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ── Table ──────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 22px;
  margin: 20px 0;
}

th {
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 20px;
  text-align: left;
  border-bottom: 2px solid var(--accent);
  padding: 10px 16px;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--rule);
}

tr:last-child td {
  border-bottom: none;
}

/* ── Fragments (animated reveals) ───────────────────── */

.frag {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.4s ease,
    transform 0.4s ease;
}

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

/* ── Footnote ───────────────────────────────────────── */

.footnote {
  position: absolute;
  bottom: 36px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "Inter", sans-serif;
  font-size: 20px;
  color: var(--muted);
}

.footnote a {
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition:
    color 0.2s,
    border-color 0.2s;
}

.footnote a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Progress bar ───────────────────────────────────── */

.progress {
  position: fixed;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  transition: width 0.35s ease;
  z-index: 100;
}

/* ── Keyboard hint ──────────────────────────────────── */

.hint {
  position: fixed;
  bottom: 16px;
  right: 20px;
  font-family: "Inter", sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  opacity: 1;
  transition: opacity 1s ease;
  z-index: 101;
}

.hint.hidden {
  opacity: 0;
}

/* ── Flow diagram ──────────────────────────────────── */

.flow-diagram {
  width: 100%;
  max-width: 1440px;
  height: auto;
  margin: 24px auto 0;
  display: block;
}

/* ── Chat Template (slide 9) ──────────────────────────── */

/* Whole appended message, templated on its own. The leading boundary is wrong:
   a [BOS] is injected and the "\n" turn-separator is dropped. Rendered as the
   raw template string (slide 7 .tito-txt family), defects flagged inline and
   echoed in the caption with the same red treatment. */
.tmpl-wrap {
  text-align: center;
  margin: 48px 0 36px;
}

.tmpl-msg {
  display: inline-block;
  text-align: left;
  font-family: "Source Code Pro", monospace;
  font-size: 27px;
  line-height: 1.7;
  color: #55534d;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  white-space: pre;
}
.tmpl-msg .imk {
  color: #a8a69d;
} /* special tokens, de-emphasized */
.tmpl-ctx {
  color: #b8b6ad;
} /* previous turn — already in the buffer */

/* Two defects, shared between the message and the caption */
.tmpl-drop {
  font-family: "Source Code Pro", monospace;
  color: #c5524a;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  opacity: 0.8;
  margin: 0 3px;
}
.tmpl-inject {
  font-family: "Source Code Pro", monospace;
  color: #c5524a;
  background: rgba(197, 82, 74, 0.15);
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 4px;
  margin: 0 3px;
}

/* the Solution reveals as a second beat (.frag), pushed down from the figure */
.tmpl-solution {
  margin-top: 40px;
}

/* ── Strict Tool Parsing (slide 13) ───────────────────── */

.ctr-section {
  margin-top: 52px;
}

.ctr-fixes {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.ctr-fix {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 28px;
  align-items: start;
  background: rgba(20, 20, 19, 0.03);
  border-radius: 12px;
  padding: 34px 42px;
}

.ctr-fix__num {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #faf9f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Source Code Pro", monospace;
  font-size: 30px;
  font-weight: 700;
}

.ctr-fix__name {
  font-family: "Inter", sans-serif;
  font-size: 34px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 12px;
}

.ctr-fix__detail {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 30px;
  color: var(--muted);
  line-height: 1.5;
}

.ctr-fix__detail code {
  font-size: 0.88em;
  background: rgba(20, 20, 19, 0.06);
  color: var(--ink);
}

/* ── Termination Reasons (slide 13) ─────────────────────── */

/* a list: each enum reason → how we treat the rollout, with the treatment
   (bold sans) and why (serif, muted) merged on one line. env chips gray,
   model terracotta (the deck's env/model palette). task_complete sits last,
   below a heavier divider, as the normal-completion baseline that hands the
   output to the reward function. */
.term-list {
  margin-top: 44px;
}

.term-item {
  display: grid;
  grid-template-columns: 360px 48px 1fr;
  align-items: center;
  gap: 18px;
  padding: 28px 0;
}
.term-item + .term-item {
  border-top: 1px solid var(--rule);
}
.term-item--note {
  margin-top: 6px;
}
.term-item + .term-item--note {
  border-top: 2px solid #cfcdc4;
}

.term-reason {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.term-chip {
  font-family: "Source Code Pro", monospace;
  font-size: 23px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.term-chip--env {
  background: #e7e5de;
  color: #4a4a46;
  border-color: #cfcdc4;
}
.term-chip--model {
  background: rgba(217, 119, 87, 0.16);
  color: #a64f2c;
  border-color: rgba(217, 119, 87, 0.42);
}

.term-arrow {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 34px;
  color: var(--accent);
  text-align: center;
}

.term-out {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 25px;
  line-height: 1.4;
}
.term-treat__name {
  font-family: "Inter", sans-serif;
  font-size: 25px;
  font-weight: 600;
  color: var(--ink);
}
.term-why {
  color: var(--muted);
}

/* ── Tool Parsing (slide 11) ──────────────────────────── */

.tp-case {
  margin-bottom: 44px;
}

.tp-examples {
  margin-top: 50px;
}

.tp-case__cols {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: stretch;
}

.tp-col {
  padding: 18px 0;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.tp-col__label {
  font-family: "Inter", sans-serif;
  font-size: 19px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.tp-col--server .tp-col__label {
  color: var(--accent);
}

.tp-col--server {
  background: rgba(217, 119, 87, 0.06);
  border-radius: 10px;
  padding: 18px 24px;
}

.tp-case__arrow {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 44px;
  font-weight: 400;
  color: var(--accent);
  padding: 0 18px;
  user-select: none;
  align-self: center;
}

.tp-col__code {
  font-family: "Source Code Pro", monospace;
  font-size: 26px;
  color: var(--ink);
  line-height: 1.45;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.tp-code {
  font-family: "Source Code Pro", monospace;
  font-size: 22px;
  line-height: 1.5;
  color: var(--ink);
  background: rgba(217, 119, 87, 0.06);
  border: 1px solid rgba(217, 119, 87, 0.18);
  border-radius: 6px;
  padding: 14px 18px;
  margin: 10px 0 14px;
  white-space: pre;
  overflow-x: auto;
}

.tp-comment {
  color: var(--muted);
  font-style: italic;
}

.tp-tag {
  color: var(--accent);
  font-weight: 600;
}
.tp-str {
  color: #5a8a6a;
}
.tp-rogue {
  color: #c5524a;
  text-decoration: line-through;
  text-decoration-color: rgba(197, 82, 74, 0.6);
}
.tp-invented {
  background: rgba(217, 119, 87, 0.22);
  border-radius: 2px;
  padding: 0 2px;
}

.tp-case__consequence {
  padding: 16px 0 0;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 27px;
  line-height: 1.4;
  color: var(--ink);
}

.tp-case__consequence::before {
  content: "\2192  ";
  color: var(--accent);
  font-weight: 600;
}

.tp-case__consequence code {
  font-size: 0.92em;
  background: rgba(20, 20, 19, 0.06);
  padding: 1px 6px;
}

/* ── Click-to-reveal info popover (used inline in code/text) ── */

.popinfo {
  position: relative;
  cursor: pointer;
  border-bottom: 1.5px dotted var(--accent);
  outline: none;
}

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

.popinfo__tip {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 14px);
  transform: translateX(-50%);
  background: var(--ink);
  color: #faf9f5;
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.45;
  padding: 14px 20px;
  border-radius: 8px;
  white-space: normal;
  width: max-content;
  max-width: 560px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 50;
}

.popinfo__tip code {
  font-family: "Source Code Pro", monospace;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.12);
  color: #faf9f5;
  padding: 1px 6px;
  border-radius: 3px;
  border: none;
}

/* Arrow pointing down to the trigger */
.popinfo__tip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: var(--ink);
}

.popinfo.open .popinfo__tip,
.popinfo:focus .popinfo__tip {
  display: block;
}

/* ── Token Metadata (slide 11) ─────────────────────────── */

/* "A token is a record": columns = model tokens, rows = per-token fields.
   token_id reuses slide 7's terracotta model-token chip; logprob and
   routed_experts are annotated with why each is kept. */
.tmeta {
  display: flex;
  justify-content: center;
  margin: 52px 0 64px;
}

.tmeta-grid {
  display: grid;
  grid-template-columns: auto repeat(4, 104px) auto;
  column-gap: 16px;
  row-gap: 16px;
  align-items: center;
}

.tmeta-key {
  font-family: "Source Code Pro", monospace;
  font-size: 24px;
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  padding-right: 14px;
}

.tmeta-chip {
  font-family: "Source Code Pro", monospace;
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  padding: 7px 0;
  border-radius: 7px;
  background: rgba(217, 119, 87, 0.16);
  color: #a64f2c;
  border: 1px solid rgba(217, 119, 87, 0.42);
}

.tmeta-val {
  font-family: "Source Code Pro", monospace;
  font-size: 24px;
  color: #4a4a46;
  text-align: center;
}

.tmeta-anno {
  font-family: "Inter", sans-serif;
  font-size: 22px;
  color: var(--muted);
  white-space: nowrap;
  text-align: left;
}
.tmeta-anno:not(:empty)::before {
  content: "\2192  ";
  color: var(--accent);
  font-weight: 600;
}

/* loss_mask = 0 → prompt/tool token, shown in slide 7's gray env-chip */
.tmeta-chip--ctx {
  background: #e7e5de;
  color: #4a4a46;
  border-color: #cfcdc4;
}

/* divider between the per-token scalars and the routed_experts matrix */
.tmeta-rule {
  grid-column: 1 / -1;
  border-top: 1px solid var(--rule);
  margin: 4px 0;
}

/* routed_experts: layers (rows) × top_k (cell) under the same token columns */
.tmeta-rexp-hdr {
  grid-column: 2 / 6;
  font-family: "Source Serif 4", Georgia, serif;
  font-style: italic;
  font-size: 20px;
  color: var(--muted);
  text-align: center;
}
.tmeta-layer {
  font-size: 20px;
}

/* routed_experts cells: abstract "top_k experts" as small blocks, not fake indices */
.tmeta-experts {
  display: flex;
  justify-content: center;
  gap: 5px;
}
.tmeta-experts i {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: rgba(217, 119, 87, 0.65);
}

/* ── TITO sub-label verb highlight (slide 7) ────────── */

.hl-preserve,
.hl-tokenize {
  transition:
    fill 0.35s ease,
    font-weight 0.35s ease,
    font-size 0.35s ease;
}

.slide.fragv-preserve .hl-preserve {
  fill: #d97757;
  font-weight: 700;
  font-size: 20px;
}

.slide.fragv-tokenize .hl-tokenize {
  fill: #5a8a6a;
  font-weight: 700;
  font-size: 20px;
}

/* ── Example table ─────────────────────────────────── */

.example-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.example-table td {
  padding: 7px 12px;
  font-size: 20px;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
}

.example-table tr:last-child td {
  border-bottom: none;
}

.ex-key {
  font-family: "Source Code Pro", monospace;
  font-size: 17px;
  color: var(--muted);
  white-space: nowrap;
  width: 1%;
}

/* ── Conversation trace ────────────────────────────── */

.trace {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trace-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 20px;
  line-height: 1.5;
}

.trace-role {
  font-family: "Source Code Pro", monospace;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 72px;
  flex-shrink: 0;
}

.trace-env .trace-role {
  color: #6b6b66;
}
.trace-model .trace-role {
  color: #d97757;
}

.trace-content {
  flex: 1;
}

.trace-tool {
  font-family: "Source Code Pro", monospace;
  font-size: 18px;
  color: #6639ba;
  background: rgba(102, 57, 186, 0.06);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ── Inline syntax highlighting ─────────────────────── */

.kw {
  color: #cf222e;
}
.fn {
  color: #6639ba;
}
.cl {
  color: #0550ae;
}
.cm {
  color: #6b6b66;
  font-style: italic;
}
.st {
  color: #0a3069;
}
.op {
  color: #141413;
}

/* ── Slide: Token-in / Token-out (stage walk) ─────────── */

.tito-rows {
  position: relative;
  margin-top: 6px;
}

.tito-row {
  display: grid;
  grid-template-columns: 160px 440px 1fr 180px;
  column-gap: 22px;
  align-items: start;
  padding: 18px 0;
}
/* row container steps via .frag but stays laid out as a skeleton; cells reveal */
.tito-row.frag {
  opacity: 1;
  transform: none;
}

.tito-stage {
  font-family: "Inter", sans-serif;
  font-size: 27px;
  font-weight: 600;
  padding-left: 38px;
  position: relative;
}
.tito-row--env .tito-stage {
  color: #8a887e;
}
.tito-row--model .tito-stage {
  color: var(--accent);
}
.tito-sub {
  display: block;
  font-size: 17px;
  font-weight: 500;
  color: #b4b2a8;
  margin-top: 2px;
}
.tito-arrow {
  position: absolute;
  left: 0;
  top: 3px;
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.tito-toks,
.tito-txt,
.tito-anno {
  opacity: 0;
  transition: opacity 0.45s ease;
}
.tito-row.visible .tito-toks,
.tito-row.visible .tito-txt,
.tito-row.visible .tito-anno {
  opacity: 1;
}

.tito-toks {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-content: flex-start;
}
.tito-chip {
  font-family: "Source Code Pro", monospace;
  font-size: 21px;
  padding: 3px 9px;
  border-radius: 6px;
  background: #e7e5de;
  color: #4a4a46;
  border: 1px solid #cfcdc4;
}
.tito-row--model .tito-chip {
  background: rgba(217, 119, 87, 0.16);
  color: #a64f2c;
  border-color: rgba(217, 119, 87, 0.42);
}
.tito-chip.sp {
  font-weight: 600;
}
.tito-row--env .tito-chip.sp {
  background: #d3d1ca;
}
.tito-row--model .tito-chip.sp {
  background: rgba(217, 119, 87, 0.3);
}
.tito-chip.fold {
  background: #fff;
  border-style: dashed;
  font-style: italic;
  color: var(--muted);
}
.tito-el {
  color: #b8b6ad;
  font-family: "Source Code Pro", monospace;
  font-size: 21px;
  align-self: center;
}

.tito-txt {
  font-family: "Source Code Pro", monospace;
  font-size: 22px;
  line-height: 1.4;
  color: #55534d;
}
.tito-txt .imk {
  color: #a8a69d;
}

.tito-anno .tito-dir {
  font-family: "Inter", sans-serif;
  font-size: 23px;
  font-weight: 600;
}
.tito-row--env .tito-anno .tito-dir {
  color: #8a887e;
}
.tito-row--model .tito-anno .tito-dir {
  color: var(--accent);
}
.tito-anno .tito-msk {
  font-family: "Inter", sans-serif;
  font-size: 18px;
  color: var(--muted);
  margin-top: 5px;
}
.tito-row--model .tito-anno .tito-msk {
  color: #c0764f;
}

/* single walking arrow — cascade shows it only on the latest revealed row */
.slide.fragv-tito1 .frag-tito1 .tito-arrow {
  opacity: 1;
}
.slide.fragv-tito2 .frag-tito1 .tito-arrow {
  opacity: 0;
}
.slide.fragv-tito2 .frag-tito2 .tito-arrow {
  opacity: 1;
}
.slide.fragv-tito3 .frag-tito2 .tito-arrow {
  opacity: 0;
}
.slide.fragv-tito3 .frag-tito3 .tito-arrow {
  opacity: 1;
}
.slide.fragv-tito4 .frag-tito3 .tito-arrow {
  opacity: 0;
}
.slide.fragv-tito4 .frag-tito4 .tito-arrow {
  opacity: 1;
}

/* ── Slide: Retokenization Drift (real example → reason → what breaks) ── */

/* Equation as the formal restatement under the opening sentence */
.why-eq {
  font-family: "Source Code Pro", monospace;
  font-size: 44px;
  color: var(--accent);
  text-align: center;
  margin: 56px 0 72px;
}
.why-eq code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Token-chip demo */
.drift-demo {
  margin: 0;
}
.drift-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-bottom: 14px;
}
.drift-row:last-child {
  margin-bottom: 0;
}
.drift-label {
  width: 280px;
  text-align: right;
  line-height: 1.2;
  font-family: "Inter", sans-serif;
  font-size: 26px;
  font-weight: 600;
}
.drift-row--gen .drift-label {
  color: var(--accent);
}
.drift-row--re .drift-label {
  color: var(--muted);
}

.drift-toks {
  display: flex;
  gap: 10px;
}
.dchip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #eceae5;
  border: 1px solid #d6d4cd;
}
.dtxt {
  font-family: "Source Code Pro", monospace;
  font-size: 32px;
  color: #4a4a46;
  white-space: pre;
}
.did {
  font-family: "Source Code Pro", monospace;
  font-size: 18px;
  color: #aaa89e;
  margin-top: 4px;
}
.drift-row--gen .dchip--hot {
  background: rgba(217, 119, 87, 0.16);
  border-color: rgba(217, 119, 87, 0.55);
}
.drift-row--gen .dchip--hot .dtxt {
  color: #a64f2c;
  font-weight: 600;
}
.dchip--bad {
  background: #f5e0d9;
  border-color: #dca48f;
}
.dchip--bad .dtxt {
  color: #c5524a;
  font-weight: 600;
}

/* Caption above the demo: small muted Inter, attribution tone */
.drift-caption {
  font-family: "Inter", sans-serif;
  font-size: 22px;
  font-weight: 500;
  color: #b4b2a8;
  text-align: center;
  letter-spacing: 0.06em;
  margin: 0 0 22px;
}

/* ── Overview / TOC overlay (press 'o') — UI chrome, not a scaled slide ── */
.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 19, 0.88);
}
.toc-overlay.open {
  display: flex;
}
.toc-panel {
  background: var(--bg);
  color: var(--ink);
  border-radius: 1.4vh;
  padding: 3vh 4vh;
  min-width: 30vw;
  max-width: 80vw;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
}
.toc-title {
  font-family: "Newsreader", Georgia, serif;
  font-size: 3vh;
  font-weight: 500;
  margin-bottom: 1.6vh;
  flex: none;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
  min-height: 0;
  flex: 1 1 auto;
}
.toc-item {
  display: flex;
  align-items: center;
  gap: 1.4vh;
  padding: 0.9vh 1.3vh;
  border-radius: 0.8vh;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 2vh;
  color: var(--ink);
}
.toc-item:hover {
  background: var(--code-bg);
}
.toc-item.current {
  color: var(--accent);
  font-weight: 600;
}
.toc-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3vh;
  height: 3vh;
  border-radius: 50%;
  flex: none;
  background: var(--code-bg);
  color: var(--muted);
  font-size: 1.5vh;
}
.toc-item.current .toc-num {
  background: var(--accent);
  color: #fff;
}

/* ── Slide: When the reward won't move (diagnostic) ──── */
.wm-list { display: flex; flex-direction: column; margin: 34px 0 64px; }
.wm-row {
  display: grid;
  grid-template-columns: 210px 1fr;
  column-gap: 40px;
  align-items: baseline;
  padding: 20px 0;
  border-top: 1px solid var(--rule);
}
.wm-row:last-child { border-bottom: 1px solid var(--rule); }
.wm-key {
  font-family: "Newsreader", "Source Serif 4", Georgia, serif;
  font-size: 33px;
  font-weight: 500;
  color: var(--accent);
}
.wm-tag {
  display: block;
  margin-top: 6px;
  font-family: "Inter", sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.wm-desc {
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 30px;
  line-height: 1.4;
  color: var(--ink);
}
.wm-ret { display: inline-block; transform: scaleX(-1); color: var(--accent); font-weight: 600; margin-right: 14px; }

/* ── Slide: Finally (closer) ─────────────────────────── */
.slide--finally p { margin-bottom: 48px; max-width: 1480px; }
/* code-pointer pill — rounded, accent-outlined CTA, floating in the lower space */
.fin-callout {
  margin: 80px 0 auto;
  background: rgba(217, 119, 87, 0.06);
  border: 2px solid var(--accent);
  border-radius: 18px;
  padding: 26px 36px;
  max-width: 1480px;
}
.fin-callout p { font-size: 30px; line-height: 1.45; margin: 0; max-width: none; }
.fin-callout .fc-label {
  font-family: "Inter", sans-serif; font-size: 18px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent);
  margin-bottom: 12px;
}
.fin-callout a { color: var(--accent); font-weight: 600; text-decoration: none; }
