/* Decklight — structural stylesheet. Themes supply the tokens (SPEC §5);
   this file supplies layout, builds, motion, chrome, code, terminal
   structure, and print. */

/* ---------- viewport & stage --------------------------------------------- */
.decklight {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg, #111);
  color: var(--fg, #eee);
  font-family: var(--font-body, system-ui, sans-serif);
  --build-duration: 300ms;
  --transition-duration: 350ms;
  --auto-animate-duration: 500ms;
  --dim-opacity: 0.35;
}
.decklight[data-embed] { position: relative; width: 100%; aspect-ratio: 16 / 9; }

/* Accent overlay: --bg is the canvas (color OR gradient — the shorthand takes
   either); --bg-accent overlays it ONLY when it is an image value. Using
   background-image makes CSS type-branch for us: gradient accents paint,
   color-valued accents are invalid here and no-op (themes use those as a
   secondary surface token instead). */
.decklight::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--bg-accent, none);
  pointer-events: none;
}
.decklight-stage { z-index: 1; }

.decklight-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center;
  /* The slide base lives on the STAGE so a per-section adaptation like
     style="font-size:0.85em" (the dense-slide idiom) resolves against 30px,
     not the page-default 16px the stage would otherwise inherit — an inline
     font-size on the section overrides the section rule below, and em on
     one's own font-size property reads the parent. */
  font-size: 30px;
}

/* ---------- slides -------------------------------------------------------- */
/* Pre-init FOUC guard: before init() creates .decklight-stage and moves the
   sections into it, they sit as direct children of .decklight and would paint
   stacked in document flow (a raw-content flash on every load — worst in the
   picker's preview iframes, which reload the deck per swap). Hide them in
   their pre-init location; init relocates them, after which this rule matches
   nothing and the stage rules below govern (print included — init runs there
   too). The root keeps painting the themed --bg, so boot is a clean canvas. */
.decklight > section { display: none; }

.decklight-stage > section {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: 3.5% 5%;
  box-sizing: border-box;
  font-size: 30px;
  line-height: 1.5;
  text-align: center;
  overflow: hidden;
}
.decklight-stage > section.active,
.decklight-stage > section.leaving { display: flex; }
.decklight-stage > section.leaving { z-index: 1; }
.decklight-stage > section.active { z-index: 2; }

.decklight aside.notes, .decklight aside.rehearse { display: none; }

/* ---------- pinned titles (SPEC §8) ---------------------------------------
   The engine marks pinnable sections with data-pinned + inline --pin-y /
   --pin-space (pin Y + measured title height + gap). The leading heading is
   lifted out of flow to sit at --pin-y; padding-top reserves its space so the
   remaining content centers below and can never slide under the title. */
.decklight-stage > section[data-pinned] { padding-top: var(--pin-space, 172px); }
.decklight-stage > section[data-pinned] > .pin-title {
  position: absolute;
  top: var(--pin-y, 99px);
  left: 5%;
  right: 5%;
  margin: 0;
}
/* the subtitle rides in the pinned header block, directly under the title */
.decklight-stage > section[data-pinned] > .pin-subtitle {
  position: absolute;
  top: var(--pin-sub-y, 160px);
  left: 5%;
  right: 5%;
  margin: 0;
  max-width: none; /* the generic section > p 32em cap would hug the box left */
}
/* momentary measurement state: laid out, never painted (same-task add/remove) */
.decklight-stage > section.pin-measure { display: flex; visibility: hidden; }

/* ---------- subtitle (SPEC §1) ---------------------------------------------
   The <p> directly after a slide's leading heading. One canonical look
   everywhere — markdown or HTML authored, pinned or centered. Absolute size
   (0.72 × the 30px slide base) so per-section font-size adaptations on dense
   slides can't shrink it: the design space is fixed 1280×720, px is stable. */
.decklight .subtitle {
  font-size: 21.6px;
  color: var(--muted, #9aa);
  line-height: 1.4;
  /* inline margins stay auto: the shorthand would wipe the generic
     `section > p` centering and the capped box would hug left (visible on
     non-pinned title cards, where the subtitle is in normal flow) */
  margin: -0.4em auto 1em;
}

/* typography on tokens */
.decklight h1, .decklight h2, .decklight h3, .decklight h4 {
  font-family: var(--font-heading, var(--font-body, system-ui, sans-serif));
  color: var(--heading-color, var(--fg, #eee));
  font-weight: var(--heading-weight, 700);
  line-height: 1.15;
  margin: 0 0 0.6em;
}
.decklight h1 { font-size: 2.2em; }
.decklight h2 { font-size: 1.6em; }
.decklight h3 { font-size: 1.2em; }
.decklight a { color: var(--link, var(--accent, #6af)); }
.decklight strong { color: var(--heading-color, inherit); }
.decklight .muted, .decklight small { color: var(--muted, #999); }

.decklight section > p, .decklight section > blockquote { margin: 0.4em auto; max-width: 32em; }
.decklight ul, .decklight ol, .decklight dl {
  text-align: left;
  display: inline-block;
  margin: 0.4em auto;
  max-width: 34em;
}
.decklight li { margin: 0.35em 0; }
.decklight blockquote {
  text-align: left;
  border-left: 4px solid var(--accent, #6af);
  background: var(--block-bg, rgba(128,128,128,.12));
  padding: 0.5em 1em;
  border-radius: var(--block-radius, 8px);
  font-style: italic;
}
.decklight table {
  margin: 0.6em auto;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.82em;
}
.decklight th, .decklight td {
  padding: 0.35em 0.9em;
  /* --block-border is a full border shorthand ("1px solid #…", themes may
     use dashed) — wrapping it in `1px solid var(…)` is invalid at
     computed-value time and kills the border entirely */
  border-bottom: var(--block-border, 1px solid rgba(128,128,128,.35));
}
.decklight th { color: var(--accent, #6af); }
.decklight img, .decklight svg { max-width: 100%; }
.decklight section > svg, .decklight section > img { margin: 0.3em auto; display: block; }

/* ---------- builds (SPEC §2) ---------------------------------------------- */
.decklight .build-step {
  visibility: hidden;
  opacity: 0;
  transition:
    opacity var(--build-duration) ease,
    transform var(--build-duration) ease,
    visibility 0s linear var(--build-duration);
}
.decklight .build-step[data-build-state="current"],
.decklight .build-step[data-build-state="done"] {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition:
    opacity var(--build-duration) ease,
    transform var(--build-duration) ease,
    visibility 0s;
}

/* entrance style offsets while pending */
.decklight .build-step[data-build-style="fade-up"][data-build-state="pending"]   { transform: translateY(16px); }
.decklight .build-step[data-build-style="fade-down"][data-build-state="pending"] { transform: translateY(-16px); }
.decklight .build-step[data-build-style="zoom"][data-build-state="pending"]      { transform: scale(0.55); }
.decklight .build-step[data-build-style="none"] { transition: none !important; }
.decklight .build-step[data-build-style="pop"][data-build-state="current"] {
  animation: dl-pop var(--build-duration) cubic-bezier(.34,1.56,.64,1);
}
@keyframes dl-pop { 0% { transform: scale(.4); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }

/* highlight style: always visible; current gets emphasis, siblings dim */
.decklight .build-step[data-build-style="highlight"] { visibility: visible; opacity: 1; }
.decklight .build-step[data-build-style="highlight"][data-build-state="current"] {
  outline: 3px solid var(--accent, #6af);
  outline-offset: 4px;
  border-radius: var(--block-radius, 8px);
}
.decklight .has-current-highlight .build-step[data-build-style="highlight"]:not([data-build-state="current"]) {
  opacity: var(--dim-opacity);
}

/* theme picker: list + live minified preview */
.decklight-theme-picker {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.decklight-theme-picker .tp-panel {
  display: flex;
  gap: 18px;
  width: min(880px, 86vw);
  height: min(520px, 78vh);
  background: #16181d;
  color: #e8eaee;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
  font: 15px/1.4 system-ui, sans-serif;
}
.decklight-theme-picker .tp-side {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  border-right: 1px solid rgba(255, 255, 255, .08);
  padding-right: 10px;
}
.decklight-theme-picker .tp-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.decklight-theme-picker .tp-filter {
  flex: none;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
  color: #8d93a0;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.decklight-theme-picker .tp-filter.tp-active { color: #fff; }
.decklight-theme-picker .tp-filter.tp-active::after { content: '▏'; opacity: .6; }
.decklight-theme-picker .tp-none {
  padding: 7px 12px;
  opacity: .55;
}
/* pack navigation rows */
.decklight-theme-picker .tp-row.tp-pack { font-weight: 600; }
.decklight-theme-picker .tp-row.tp-back,
.decklight-theme-picker .tp-row.tp-all {
  text-transform: none;
  color: #b9bec8;
  border-top: 1px solid rgba(255, 255, 255, .08);
  margin-top: 6px;
  padding-top: 9px;
}
.decklight-theme-picker .tp-row.tp-back {
  border-top: 0;
  margin-top: 0;
  padding-top: 7px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  margin-bottom: 6px;
  padding-bottom: 9px;
}
.decklight-theme-picker .tp-row {
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-transform: capitalize;
}
.decklight-theme-picker .tp-row.tp-selected { background: rgba(255, 255, 255, .14); }
.decklight-theme-picker .tp-row.tp-current::after { content: ' ✓'; opacity: .7; }
.decklight-theme-picker .tp-row.tp-gen {
  text-transform: none;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
  margin-bottom: 6px;
  padding-bottom: 9px;
}
.decklight-theme-picker .tp-tag {
  float: right;
  font-size: 11px;
  opacity: .65;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 999px;
  padding: 0 8px;
  margin-left: 8px;
}
.decklight-theme-picker .tp-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.decklight-theme-picker .tp-preview iframe {
  flex: 1;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: #000;
}
.decklight-theme-picker .tp-caption {
  text-align: center;
  text-transform: capitalize;
  opacity: .8;
  font-size: 14px;
}
/* the slide finder shares the picker's anatomy; titles keep their casing
   (these overrides must come after the capitalize rules above) */
.decklight-finder .tp-side { flex-basis: 300px; }
.decklight-finder .tp-row,
.decklight-finder .tp-caption { text-transform: none; }
.decklight-finder .tp-row {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- brand logo (SPEC §8) -------------------------------------------
   Chrome-level mark on every slide. The engine sets data-canvas="dark|light"
   on the root from the applied theme's real background luminance; the
   on-light/on-dark variants toggle accordingly (on-any always shows). */
.decklight-logo {
  position: absolute;
  z-index: 30;
  height: var(--logo-h, 38px);
  pointer-events: none;
  opacity: 0.9;
}
.decklight-logo[data-pos="bottom-left"] { left: 22px; bottom: 16px; }
.decklight-logo[data-pos="top-left"] { left: 22px; top: 16px; }
.decklight-logo[data-pos="top-right"] { right: 22px; top: 16px; }
.decklight-logo[data-pos="bottom-right"] { right: 22px; bottom: 16px; }
.decklight-logo span { display: block; height: 100%; }
.decklight-logo img, .decklight-logo svg { height: 100%; width: auto; display: block; }
/* hero variant: a larger in-flow mark above a slide's content (data-logo) */
.decklight-hero-logo {
  height: var(--hero-logo-h, 96px);
  margin: 0 auto 30px;
  flex: none;
}
.decklight-hero-logo span { display: block; height: 100%; }
.decklight-hero-logo img, .decklight-hero-logo svg { height: 100%; width: auto; display: block; margin: 0 auto; }
.decklight[data-canvas="dark"] .decklight-logo .on-light,
.decklight[data-canvas="dark"] .decklight-hero-logo .on-light { display: none; }
.decklight[data-canvas="light"] .decklight-logo .on-dark,
.decklight[data-canvas="light"] .decklight-hero-logo .on-dark { display: none; }
/* a hero slide carries its own mark — the corner chrome yields */
.decklight.has-hero-logo > .decklight-logo { display: none; }

/* theme-switch toast */
.decklight-toast {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font: 14px var(--font-mono, monospace);
  padding: 6px 14px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
  z-index: 40;
}
.decklight-toast.show { opacity: 1; }

/* draw style: strokes animate dash-offset; text/fills fade */
.decklight .build-step[data-build-style="draw"] { visibility: visible; opacity: 1; }
.decklight .build-step[data-build-style="draw"] .draw-stroke {
  stroke-dasharray: var(--draw-len);
  stroke-dashoffset: var(--draw-len);
  transition: stroke-dashoffset calc(var(--build-duration) * 2.2) ease;
}
.decklight .build-step[data-build-style="draw"][data-build-state="current"] .draw-stroke,
.decklight .build-step[data-build-style="draw"][data-build-state="done"] .draw-stroke {
  stroke-dashoffset: 0;
}
.decklight .build-step[data-build-style="draw"] .draw-fade {
  opacity: 0;
  transition: opacity var(--build-duration) ease calc(var(--build-duration) * 1.2);
}
.decklight .build-step[data-build-style="draw"][data-build-state="current"] .draw-fade,
.decklight .build-step[data-build-style="draw"][data-build-state="done"] .draw-fade {
  opacity: 1;
}
.decklight .build-step[data-build-style="draw"][data-build-state="pending"] .draw-fade { opacity: 0; }
.decklight .build-step[data-build-style="draw"][data-build-state="pending"] {
  /* strokes hidden by full dash offset; keep element itself visible */
  opacity: 1;
}

/* instant application (slide entry, deep links, back-nav restore) */
.decklight.decklight-no-anim .build-step,
.decklight.decklight-no-anim .build-step .draw-stroke,
.decklight.decklight-no-anim .build-step .draw-fade {
  transition: none !important;
  animation: none !important;
}

/* ---------- element animations (SPEC §4.3) -------------------------------- */
.decklight section.active [data-animate="pulse"] { animation: dl-pulse 1.6s ease-in-out infinite; }
.decklight section.active [data-animate="float"] { animation: dl-float 3s ease-in-out infinite; }
.decklight section.active [data-animate="shake"] { animation: dl-shake .8s ease-in-out infinite; }
.decklight section.active [data-animate="spin"]  { animation: dl-spin 2.4s linear infinite; }
.decklight section.active [data-animate="blink"] { animation: dl-blink 1.2s steps(2) infinite; }
.decklight section.active [data-animate="bounce"]  { animation: dl-bounce 1.4s cubic-bezier(.28, .84, .42, 1) infinite; }
.decklight section.active [data-animate="swing"]   { animation: dl-swing 2s ease-in-out infinite; transform-origin: top center; }
.decklight section.active [data-animate="glow"]    { animation: dl-glow 2.2s ease-in-out infinite; }
.decklight section.active [data-animate="breathe"] { animation: dl-breathe 3.4s ease-in-out infinite; }
@keyframes dl-pulse { 50% { transform: scale(1.06); } }
@keyframes dl-float { 50% { transform: translateY(-8px); } }
@keyframes dl-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes dl-spin  { to { transform: rotate(360deg); } }
@keyframes dl-blink { 50% { opacity: .25; } }
@keyframes dl-bounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px); } 60% { transform: translateY(-6px); } }
@keyframes dl-swing { 0%, 100% { transform: rotate(4deg); } 50% { transform: rotate(-4deg); } }
@keyframes dl-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(128, 160, 255, 0); }
  50% { box-shadow: 0 0 18px 4px color-mix(in srgb, var(--accent, #6af) 55%, transparent); }
}
@keyframes dl-breathe { 50% { transform: scale(1.04); opacity: .82; } }

/* ---------- slide transitions (SPEC §4.1) --------------------------------- */
.decklight section.tr-fade.entering { animation: dl-fade-in var(--transition-duration) ease both; }
.decklight section.tr-fade.leaving  { animation: dl-fade-out var(--transition-duration) ease both; }
@keyframes dl-fade-in  { from { opacity: 0; } }
@keyframes dl-fade-out { to   { opacity: 0; } }

.decklight section.tr-slide.entering.dir-fwd  { animation: dl-in-right var(--transition-duration) ease both; }
.decklight section.tr-slide.leaving.dir-fwd   { animation: dl-out-left var(--transition-duration) ease both; }
.decklight section.tr-slide.entering.dir-back { animation: dl-in-left var(--transition-duration) ease both; }
.decklight section.tr-slide.leaving.dir-back  { animation: dl-out-right var(--transition-duration) ease both; }
@keyframes dl-in-right  { from { transform: translateX(60px); opacity: 0; } }
@keyframes dl-out-left  { to   { transform: translateX(-60px); opacity: 0; } }
@keyframes dl-in-left   { from { transform: translateX(-60px); opacity: 0; } }
@keyframes dl-out-right { to   { transform: translateX(60px); opacity: 0; } }

.decklight section.tr-scale.entering { animation: dl-scale-in var(--transition-duration) ease both; }
.decklight section.tr-scale.leaving  { animation: dl-scale-out var(--transition-duration) ease both; }
@keyframes dl-scale-in  { from { transform: scale(.88); opacity: 0; } }
@keyframes dl-scale-out { to   { transform: scale(1.08); opacity: 0; } }

.decklight-stage { perspective: 1400px; }
.decklight section.tr-flip.entering.dir-fwd  { animation: dl-flip-in var(--transition-duration) ease both; }
.decklight section.tr-flip.leaving.dir-fwd   { animation: dl-flip-out var(--transition-duration) ease both; }
.decklight section.tr-flip.entering.dir-back { animation: dl-flip-out-rev var(--transition-duration) ease both; }
.decklight section.tr-flip.leaving.dir-back  { animation: dl-flip-in-rev var(--transition-duration) ease both; }
@keyframes dl-flip-in      { from { transform: rotateY(24deg); opacity: 0; } }
@keyframes dl-flip-out     { to   { transform: rotateY(-24deg); opacity: 0; } }
@keyframes dl-flip-in-rev  { to   { transform: rotateY(24deg); opacity: 0; } }
@keyframes dl-flip-out-rev { from { transform: rotateY(-24deg); opacity: 0; } }

/* auto-animate fresh content */
.decklight .aa-fresh { opacity: 0; }
.decklight .aa-fresh.aa-in { opacity: 1; transition: opacity var(--auto-animate-duration) ease; }

/* ---------- code (SPEC §6) ------------------------------------------------- */
.decklight pre {
  text-align: left;
  margin: 0.5em auto;
  max-width: 95%;
  background: var(--code-bg, #1d1f27);
  border-radius: var(--block-radius, 10px);
  box-shadow: var(--shadow, 0 6px 24px rgba(0,0,0,.25));
  padding: 0.7em 1em;
  overflow: auto;
}
.decklight pre code {
  display: block;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.62em;
  line-height: 1.55;
  color: var(--code-fg, #e6e6e6);
  background: none;
  white-space: pre;
}
.decklight :not(pre) > code {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.9em;
  background: var(--block-bg, rgba(128,128,128,.15));
  padding: 0.1em 0.35em;
  border-radius: 5px;
}
.decklight .code-line { display: block; min-height: 1.55em; transition: opacity var(--build-duration) ease; }
.decklight pre.line-numbers { counter-reset: dl-line; }
.decklight pre.line-numbers .code-line { counter-increment: dl-line; }
.decklight pre.line-numbers .code-line::before {
  content: counter(dl-line);
  display: inline-block;
  width: 2.2em;
  margin-right: 0.8em;
  text-align: right;
  color: var(--muted, #888);
  user-select: none;
}
.decklight .code-line.line-dim { opacity: var(--dim-opacity); }
.decklight .code-line.line-hl { opacity: 1; }

/* hljs token → theme token mapping (no separate hljs theme files) */
.decklight .hljs-keyword, .decklight .hljs-literal, .decklight .hljs-selector-tag { color: var(--hl-keyword, #c792ea); }
.decklight .hljs-string, .decklight .hljs-regexp, .decklight .hljs-addition { color: var(--hl-string, #a5d6a7); }
.decklight .hljs-number, .decklight .hljs-symbol { color: var(--hl-number, #f78c6c); }
.decklight .hljs-comment, .decklight .hljs-quote, .decklight .hljs-deletion { color: var(--hl-comment, #7d8799); font-style: italic; }
.decklight .hljs-title, .decklight .hljs-title.function_, .decklight .hljs-function, .decklight .hljs-section { color: var(--hl-function, #82aaff); }
.decklight .hljs-type, .decklight .hljs-built_in, .decklight .hljs-class, .decklight .hljs-attr, .decklight .hljs-attribute, .decklight .hljs-variable, .decklight .hljs-template-variable { color: var(--hl-type, #ffcb6b); }
.decklight .hljs-punctuation, .decklight .hljs-operator, .decklight .hljs-meta { color: var(--hl-punct, #89ddff); }

/* ---------- terminal placement (visuals live in src/terminal/terminal.css,
   concatenated into dist by the build) ------------------------------------- */
.decklight .terminal {
  text-align: left;
  margin: 0.5em auto;
  /* Stable footprint: a fixed width (not max-width) — in a flex column the
     auto side margins would otherwise shrink the box to its content, making
     the terminal grow as output streams in. */
  width: 95%;
}
.decklight .terminal ::selection { background: var(--term-selection, rgba(120,150,255,.35)); }

/* ---------- chrome --------------------------------------------------------- */
.decklight-controls { position: absolute; right: 18px; bottom: 14px; z-index: 40; display: flex; gap: 6px; }
.decklight-arrow {
  background: transparent;
  border: 0;
  color: var(--muted, #888);
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 10px;
}
.decklight-arrow:hover { color: var(--accent, #6af); }
.decklight-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; z-index: 40; background: rgba(128,128,128,.2); }
.decklight-progress .bar { height: 100%; width: 0; background: var(--accent, #6af); transition: width 200ms ease; }
.decklight-slide-number {
  position: absolute;
  right: 20px;
  top: 16px;
  z-index: 40;
  color: var(--muted, #888);
  font-size: 14px;
  font-family: var(--font-mono, monospace);
}
.decklight-slide-number .mod {
  opacity: .75;
  margin-right: 12px;
  font-family: var(--font-body, system-ui, sans-serif);
}

/* module menu (playlist): list overlay, same pattern as the theme picker */
.decklight-module-menu {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.decklight-module-menu .mm-panel {
  width: min(460px, 80vw);
  max-height: min(560px, 80vh);
  display: flex;
  flex-direction: column;
  background: #16181d;
  color: #e8eaee;
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
  font: 15px/1.4 system-ui, sans-serif;
}
.decklight-module-menu .mm-title {
  font-weight: 600;
  opacity: .7;
  padding: 0 12px 10px;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: .08em;
}
.decklight-module-menu .mm-list { overflow-y: auto; }
.decklight-module-menu .mm-row {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.decklight-module-menu .mm-row.mm-selected { background: rgba(255, 255, 255, .14); }
.decklight-module-menu .mm-row.mm-current::after { content: ' ✓'; opacity: .7; }

/* overview */
.decklight-overview-grid {
  position: absolute;
  inset: 0;
  z-index: 60;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 20px;
  /* theme-independent scrim: color-mix(var(--bg)…) breaks when --bg is a
     gradient (invalid <color>, declaration dropped, stage bleeds through) */
  background: rgba(9, 10, 13, 0.93);
}
/* 16:9 cells: the row height is set explicitly by layoutOverview() from the
   resolved column width — intrinsic tricks (aspect-ratio, %-padding spacers)
   contribute nothing to auto row sizing here and the rows collapse. */
.decklight-overview-grid .ov-cell {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid transparent;
  background: var(--bg, #111);
}
/* the grid replaces the stage; kill any bleed-through under the scrim */
.decklight-overview > .decklight-stage { visibility: hidden; }
.decklight-overview-grid .ov-cell.ov-current { border-color: var(--accent, #6af); }
.decklight-overview-grid .ov-cell.ov-selected { outline: 3px solid var(--accent, #6af); outline-offset: 2px; }
.decklight-overview-grid .ov-frame { transform-origin: top left; position: absolute; top: 0; left: 0; pointer-events: none; }
.decklight-overview-grid .ov-clone *, .decklight-overview-grid .ov-clone { animation: none !important; transition: none !important; }
/* clones live outside .decklight-stage, so the slide base styles must be
   restated here — without them thumbnails render as unstyled 16px fragments */
.decklight-overview-grid .ov-clone {
  display: flex !important;
  position: relative !important;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  flex-direction: column;
  justify-content: center;
  padding: 3.5% 5%;
  font-size: 30px;
  line-height: 1.5;
  text-align: center;
  overflow: hidden;
}
.decklight-overview-grid .ov-clone[data-pinned] { padding-top: var(--pin-space, 172px); }
.decklight-overview-grid .ov-clone[data-pinned] > .pin-title {
  position: absolute;
  top: var(--pin-y, 99px);
  left: 5%;
  right: 5%;
  margin: 0;
}
.decklight-overview-grid .ov-clone[data-pinned] > .pin-subtitle {
  position: absolute;
  top: var(--pin-sub-y, 160px);
  left: 5%;
  right: 5%;
  margin: 0;
  max-width: none;
}
.decklight-overview-grid .ov-num {
  position: absolute; left: 8px; top: 6px; z-index: 2;
  font-size: 12px; color: var(--fg, #eee); background: rgba(0,0,0,.5); border-radius: 4px; padding: 0 7px;
}
.decklight-overview .build-step { visibility: visible !important; opacity: 1 !important; transform: none !important; }
.decklight-overview .draw-stroke { stroke-dashoffset: 0 !important; }
.decklight-overview .draw-fade { opacity: 1 !important; }

/* narration picker (N) */
.decklight-narr {
  position: absolute;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.decklight-narr .narr-card {
  background: #16181d;
  color: #e8eaee;
  border-radius: 12px;
  padding: 14px;
  width: min(440px, 82vw);
  max-height: 70vh;
  overflow-y: auto;
  font: 14px/1.5 system-ui, sans-serif;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .55);
}
.decklight-narr .narr-head {
  opacity: .55;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 10px 12px 2px;
}
.decklight-narr .narr-row { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.decklight-narr .narr-row-label { flex: 1 1 auto; min-width: 0; }
.decklight-narr .narr-prev-btn {
  flex: none;
  background: none;
  border: 1px solid rgba(255, 255, 255, .18);
  color: inherit;
  opacity: .65;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 6px;
  cursor: pointer;
}
.decklight-narr .narr-prev-btn:hover { opacity: 1; border-color: rgba(255, 255, 255, .4); }
.decklight-narr .narr-preview-row { display: flex; align-items: center; gap: 6px; }
.decklight-narr .narr-preview-row .narr-input { flex: 1 1 auto; width: auto; }
.decklight-narr .narr-reset-btn { margin: 8px 0 4px; padding: 7px 9px; }
.decklight-narr .narr-row.narr-sel { background: rgba(255, 255, 255, .14); }
.decklight-narr .narr-row.narr-cur::after { content: ' ✓'; opacity: .7; }
.decklight-narr .narr-flavor { opacity: .5; font-size: .85em; margin-left: 6px; }
.decklight-narr .narr-input {
  width: 100%;
  box-sizing: border-box;
  margin: 8px 0 4px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .07);
  color: inherit;
  font: inherit;
  outline: none;
}

/* offline recording (⇧V) — shares .decklight-narr's card chrome */
.decklight-record .narr-card { width: min(400px, 82vw); }
.decklight-record .rec-line { padding: 4px 12px; opacity: .85; }
.decklight-record .rec-hint { padding: 10px 12px 2px; opacity: .5; font-size: 12px; }
.decklight-record .rec-bar {
  height: 6px;
  margin: 10px 12px 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
  overflow: hidden;
}
.decklight-record .rec-bar-fill {
  height: 100%;
  background: var(--accent, #6af);
  transition: width 200ms ease;
}

/* command palette (/) */
.decklight-palette .narr-card { width: min(520px, 86vw); }
.decklight-palette .pal-input {
  padding: 8px 12px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
  color: #8d93a0;
  font-size: 13px;
}
.decklight-palette .pal-input.tp-active { color: #fff; }
.decklight-palette .pal-input.tp-active::after { content: '▏'; opacity: .6; }
.decklight-palette .pal-row { display: flex; justify-content: space-between; gap: 18px; }
.decklight-palette .pal-kbd {
  opacity: .55;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  white-space: nowrap;
}

/* blackout / help */
.decklight-blackout { position: absolute; inset: 0; background: #000; z-index: 90; }
.decklight-help { position: absolute; inset: 0; z-index: 95; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; }
.decklight-help .help-card { background: var(--bg, #222); color: var(--fg, #eee); border-radius: 12px; padding: 24px 34px; font-size: 16px; box-shadow: var(--shadow, 0 10px 40px rgba(0,0,0,.5)); }
.decklight-help td { padding: 3px 14px 3px 0; }
.decklight-help td:first-child { font-family: var(--font-mono, monospace); color: var(--accent, #6af); }

/* debug log window (D) — passive chrome: keys keep driving the deck.
   Hardcoded dark like the picker/narr cards: readable over every theme. */
.decklight-debug {
  position: absolute;
  right: 14px;
  bottom: 46px;
  width: min(430px, 44vw);
  max-height: 46vh;
  z-index: 85;
  display: flex;
  flex-direction: column;
  background: rgba(11, 13, 18, .93);
  color: #dce2ec;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
  font: 11px/1.55 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}
.decklight-debug .dbg-head {
  padding: 8px 12px 2px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .55;
}
.decklight-debug .dbg-state {
  padding: 0 12px 7px;
  color: #9ecbff;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.decklight-debug .dbg-log { overflow-y: auto; padding: 6px 12px 9px; }
.decklight-debug .dbg-row { display: flex; gap: 9px; }
.decklight-debug .dbg-t { opacity: .4; flex: none; }
.decklight-debug .dbg-k { flex: none; width: 42px; opacity: .75; }
.decklight-debug .dbg-m { white-space: pre-wrap; word-break: break-word; }
.decklight-debug .dbg-error .dbg-k, .decklight-debug .dbg-error .dbg-m { color: #ff8f8f; }
.decklight-debug .dbg-theme .dbg-k { color: #b7a3ff; }
.decklight-debug .dbg-narr .dbg-k { color: #8fd6a8; }
.decklight-debug .dbg-tts .dbg-k { color: #7fb8ff; }

/* closed captions (C) — the current notes segment, youtube-style */
.decklight-captions {
  position: absolute;
  left: 50%;
  bottom: 7%;
  transform: translateX(-50%);
  max-width: 72%;
  padding: 10px 18px;
  border-radius: 8px;
  background: rgba(8, 9, 12, .8);
  color: #fff;
  font-size: 21px;
  line-height: 1.45;
  text-align: center;
  z-index: 45;
  pointer-events: none;
  display: none;
}
.decklight-captions.show { display: block; }

/* notes editor (E, served by `decklight edit`) */
.decklight-editor .narr-card { width: min(640px, 88vw); }
.decklight-editor .edit-notes {
  min-height: 240px;
  resize: vertical;
  line-height: 1.6;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
}

/* transcript overlay (palette → Transcript…) */
.decklight-transcript .narr-card { width: min(680px, 88vw); }
.decklight-transcript .tr-actions { display: flex; gap: 8px; padding: 4px 12px 10px; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.decklight-transcript .tr-slide { padding: 4px 12px; }
.decklight-transcript .tr-title { font-weight: 700; margin: 10px 0 4px; cursor: pointer; }
.decklight-transcript .tr-title:hover { color: #9ecbff; }
.decklight-transcript .tr-seg { margin: 0 0 8px; opacity: .85; font-size: 13px; line-height: 1.55; }

/* ---------- print (SPEC §8) ------------------------------------------------ */
.decklight.decklight-print { position: static; overflow: visible; }
.decklight.decklight-print .decklight-stage {
  position: static;
  transform: none !important;
  width: auto !important;
  height: auto !important;
}
.decklight.decklight-print .decklight-stage > section {
  display: flex;
  position: relative;
  width: 1280px;
  height: 720px;
  page-break-after: always;
  break-after: page;
  border-bottom: 1px dashed rgba(128,128,128,.4);
}
.decklight.decklight-print .build-step { visibility: visible !important; opacity: 1 !important; transform: none !important; }
.decklight.decklight-print .draw-stroke { stroke-dashoffset: 0 !important; }
.decklight.decklight-print .draw-fade { opacity: 1 !important; }
@media print {
  @page { size: 1280px 720px; margin: 0; }
  .decklight.decklight-print .decklight-stage > section { border-bottom: 0; }
  .decklight-controls, .decklight-progress { display: none !important; }
}

/* ---------- reduced motion ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .decklight section.entering, .decklight section.leaving,
  .decklight .build-step, .decklight [data-animate],
  .decklight .draw-stroke, .decklight .draw-fade, .decklight .aa-fresh {
    animation: none !important;
    transition: none !important;
  }
}


/* Decklight terminal player chrome (SPEC §7.3).
 * Shipped from src/terminal/ so the terminal subsystem is self-contained;
 * the core build concatenates this into dist/decklight.css.
 * All colors come from theme tokens (--term-*, --ansi-*). */

.terminal-window {
  background: var(--term-bg, #101418);
  color: var(--term-fg, #e6e6e6);
  border-radius: var(--block-radius, 10px);
  box-shadow: var(--shadow, 0 8px 30px rgba(0, 0, 0, .35));
  overflow: hidden;
  font-family: var(--font-mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 0.62em;
  text-align: left;
}

.terminal-titlebar {
  display: var(--term-chrome, flex);
  align-items: center;
  gap: 7px;
  padding: 9px 12px;
  background: color-mix(in srgb, var(--term-bg, #101418) 82%, var(--term-fg, #fff) 18%);
}

.terminal-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: #ff5f57;
}
.terminal-dot:nth-child(2) { background: #febc2e; }
.terminal-dot:nth-child(3) { background: #28c840; }

.terminal-title {
  margin-left: 8px;
  opacity: .65;
  font-size: .9em;
  flex: 1;
  text-align: center;
  padding-right: 60px; /* visually center vs the dots */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.terminal-controls { display: flex; gap: 6px; }
.terminal-btn {
  background: transparent;
  color: var(--term-fg, #e6e6e6);
  border: 1px solid color-mix(in srgb, var(--term-fg, #fff) 35%, transparent);
  border-radius: 6px;
  font: inherit;
  font-size: .85em;
  padding: 1px 8px;
  cursor: pointer;
}
.terminal-btn:hover { background: color-mix(in srgb, var(--term-fg, #fff) 12%, transparent); }

.terminal-screen {
  overflow-y: auto;
  padding: 12px 14px;
  scrollbar-width: thin;
  /* Stable footprint: the screen arrives at its full size before anything
     plays and never resizes as steps stream in. aspect-ratio sets the
     preferred height from the width (the 16:9 floor); min-height: 0 disables
     the content-based automatic minimum so content CANNOT grow the box —
     it scrolls instead; the inline rows cap (max-height) wins as the max.
     width + box-sizing keep the inline axis definite: without them, a capped
     height would TRANSFER through the ratio and narrow the box. */
  aspect-ratio: 16 / 9;
  min-height: 0;
  width: 100%;
  box-sizing: border-box;
}

/* .decklight prefix: the deck's generic `pre` styling (code-panel background,
   shadow, radius, padding) must not leak into the terminal's line buffer —
   invisible when term-bg ≈ code-bg, glaring on a light terminal screen. */
.terminal-lines,
.decklight .terminal-lines {
  margin: 0;
  padding: 0;
  font: inherit;
  line-height: var(--term-line-height, 1.45em);
  white-space: pre-wrap;
  word-break: break-word;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.terminal-lines ::selection { background: var(--term-selection, rgba(120, 160, 255, .35)); }

.terminal-prompt { color: var(--term-prompt, #7ee787); font-weight: 600; }
.terminal-cmd { color: var(--term-fg, #e6e6e6); font-weight: 600; }

.terminal-cursor {
  display: inline-block;
  width: .6em; height: 1.05em;
  vertical-align: text-bottom;
  background: var(--term-cursor, #aeb8c2);
  animation: terminal-blink 1.1s steps(1) infinite;
}
@keyframes terminal-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .terminal-cursor { animation: none; } }

.terminal-broken .terminal-lines { color: #ffb0b0; }

/* --- ANSI 16-color classes -> theme tokens ------------------------------- */
.ansi-fg-0  { color: var(--ansi-black,          #3b4252); }
.ansi-fg-1  { color: var(--ansi-red,            #e06c75); }
.ansi-fg-2  { color: var(--ansi-green,          #98c379); }
.ansi-fg-3  { color: var(--ansi-yellow,         #e5c07b); }
.ansi-fg-4  { color: var(--ansi-blue,           #61afef); }
.ansi-fg-5  { color: var(--ansi-magenta,        #c678dd); }
.ansi-fg-6  { color: var(--ansi-cyan,           #56b6c2); }
.ansi-fg-7  { color: var(--ansi-white,          #d8dee9); }
.ansi-fg-8  { color: var(--ansi-bright-black,   #6b7386); }
.ansi-fg-9  { color: var(--ansi-bright-red,     #ff7b86); }
.ansi-fg-10 { color: var(--ansi-bright-green,   #b5e890); }
.ansi-fg-11 { color: var(--ansi-bright-yellow,  #ffd68a); }
.ansi-fg-12 { color: var(--ansi-bright-blue,    #82c4ff); }
.ansi-fg-13 { color: var(--ansi-bright-magenta, #dd93ee); }
.ansi-fg-14 { color: var(--ansi-bright-cyan,    #6fd7e4); }
.ansi-fg-15 { color: var(--ansi-bright-white,   #f2f4f8); }

.ansi-bg-0  { background-color: var(--ansi-black,          #3b4252); }
.ansi-bg-1  { background-color: var(--ansi-red,            #e06c75); }
.ansi-bg-2  { background-color: var(--ansi-green,          #98c379); }
.ansi-bg-3  { background-color: var(--ansi-yellow,         #e5c07b); }
.ansi-bg-4  { background-color: var(--ansi-blue,           #61afef); }
.ansi-bg-5  { background-color: var(--ansi-magenta,        #c678dd); }
.ansi-bg-6  { background-color: var(--ansi-cyan,           #56b6c2); }
.ansi-bg-7  { background-color: var(--ansi-white,          #d8dee9); }
.ansi-bg-8  { background-color: var(--ansi-bright-black,   #6b7386); }
.ansi-bg-9  { background-color: var(--ansi-bright-red,     #ff7b86); }
.ansi-bg-10 { background-color: var(--ansi-bright-green,   #b5e890); }
.ansi-bg-11 { background-color: var(--ansi-bright-yellow,  #ffd68a); }
.ansi-bg-12 { background-color: var(--ansi-bright-blue,    #82c4ff); }
.ansi-bg-13 { background-color: var(--ansi-bright-magenta, #dd93ee); }
.ansi-bg-14 { background-color: var(--ansi-bright-cyan,    #6fd7e4); }
.ansi-bg-15 { background-color: var(--ansi-bright-white,   #f2f4f8); }

.ansi-bold { font-weight: 700; }
.ansi-dim { opacity: var(--dim-opacity, .55); }
.ansi-italic { font-style: italic; }
.ansi-underline { text-decoration: underline; }
.ansi-inv-fg { color: var(--term-bg, #101418); }
.ansi-inv-bg { background-color: var(--term-fg, #e6e6e6); }

/* Print: casts fully expanded, no scroll clipping (SPEC §8). The 16:9 floor
   is released so the box grows with the full output. */
@media print {
  .terminal-screen { max-height: none !important; overflow: visible; aspect-ratio: auto; min-height: auto; }
  .terminal-controls { display: none; }
}
