:root {
  --board: #1b222b;
  --ink: #f2efe2;
  --muted: #a8b2ba;
  --accent: #f2a37c;
  --accent2: #8fcdea;
  --paper: #f8f3e6;
  --paper-ink: #2c313a;
  --paper-line: #beb49c;
  --ok: #7dcea0;
  --btn: #d85a30;
  --btn-text: #fff;
  --panel: rgba(16, 21, 27, 0.78);
  --card: rgba(255, 255, 255, 0.06);
  --dash: rgba(242, 239, 226, 0.22);
  --border: rgba(255, 255, 255, 0.1);
  --glow: rgba(242, 163, 124, 0.12);
  --footer-h: clamp(66px, 8.5svh, 78px);
  transition: background-color 0.45s ease, color 0.35s ease;
}

/* Per-slide palettes — inspired by editorial deck systems (OD Guizang-style) */
.deck-shell[data-theme="dawn"] {
  --board: #1a1428;
  --ink: #fff6ef;
  --muted: #c9b8d4;
  --accent: #ff9a6b;
  --accent2: #ffd166;
  --paper: #fff8f2;
  --paper-ink: #3a2540;
  --paper-line: #e8c4b8;
  --ok: #8be0c2;
  --btn: #e85d4c;
  --panel: rgba(58, 28, 72, 0.55);
  --card: rgba(255, 154, 107, 0.12);
  --glow: rgba(255, 154, 107, 0.18);
}

.deck-shell[data-theme="indigo"] {
  --board: #0f1a2e;
  --ink: #eef4ff;
  --muted: #9eb3d4;
  --accent: #7eb6ff;
  --accent2: #b8a0ff;
  --paper: #f0f5ff;
  --paper-ink: #1a2a44;
  --paper-line: #a8bce0;
  --ok: #6ee7c8;
  --btn: #3b6fd9;
  --panel: rgba(20, 40, 80, 0.6);
  --card: rgba(126, 182, 255, 0.1);
  --glow: rgba(126, 182, 255, 0.16);
}

.deck-shell[data-theme="forest"] {
  --board: #0f1f18;
  --ink: #edf8f0;
  --muted: #9bc4ad;
  --accent: #7ddea0;
  --accent2: #f2d98b;
  --paper: #f4faf5;
  --paper-ink: #1f3d2e;
  --paper-line: #a8ccb4;
  --ok: #9cf0b8;
  --btn: #2d8a5e;
  --panel: rgba(24, 56, 42, 0.62);
  --card: rgba(125, 222, 160, 0.12);
  --glow: rgba(125, 222, 160, 0.18);
}

.deck-shell[data-theme="dune"] {
  --board: #2a2218;
  --ink: #faf3e8;
  --muted: #c9b89a;
  --accent: #e8a84a;
  --accent2: #e07a5f;
  --paper: #fff9ef;
  --paper-ink: #4a3728;
  --paper-line: #d4b896;
  --ok: #b8d48a;
  --btn: #c45c26;
  --panel: rgba(74, 55, 40, 0.58);
  --card: rgba(232, 168, 74, 0.14);
  --glow: rgba(232, 168, 74, 0.16);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--board); color: var(--ink); font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif; font-size: clamp(18px, 1.15vw, 24px); }
button, input, textarea { font: inherit; }
button { border: 0; background: var(--btn); color: var(--btn-text); padding: .7rem 1rem; border-radius: 8px; cursor: pointer; font-weight: 700; transition: background 0.25s ease, transform 0.15s ease; }
button:hover { filter: brightness(1.08); }
button:disabled { cursor: not-allowed; opacity: .58; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--accent2); outline-offset: 3px; }
input { border: 1.5px solid var(--paper-line); background: var(--paper); color: var(--paper-ink); padding: .7rem .85rem; border-radius: 8px; width: 100%; }
textarea { border: 1.5px solid var(--paper-line); background: var(--paper); color: var(--paper-ink); padding: .7rem .85rem; border-radius: 8px; width: 100%; resize: none; }
code { font-size: .9em; color: var(--accent2); }
.deck-shell {
  width: 100vw; height: 100svh;
  display: grid; grid-template-columns: 220px 1fr; grid-template-rows: minmax(0, 1fr) var(--footer-h);
  background: radial-gradient(ellipse 120% 80% at 100% 0%, var(--glow), transparent 55%), var(--board);
}
.toc { padding: 1rem; border-right: 1px solid var(--border); overflow: auto; }
.brand { display: flex; flex-direction: column; gap: .25rem; margin-bottom: 1rem; }
.brand strong { font-size: 1.1rem; }
.builder-badge { font-size: .75rem; color: var(--ok); }
.toc nav button { display: block; width: 100%; text-align: left; background: transparent; color: var(--muted); margin-bottom: .35rem; padding: .4rem .2rem; }
.toc nav button.active { color: var(--ink); font-weight: 700; }
.stage { min-width: 0; min-height: 0; overflow: hidden; }
.slide { display: none; height: calc(100svh - var(--footer-h)); padding: clamp(1rem, 1.65vw, 2rem); overflow: hidden; gap: clamp(.7rem, 1vw, 1rem); }
.slide.active { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.title-slide.active { grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 55%) 1fr; align-items: center; }
.title-slide > div { grid-column: 1; grid-row: 1; }
.title-slide .hero-panel { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.title-slide .hero-panel span { background: var(--panel); padding: .8rem; border-radius: 8px; text-align: center; border: 1px solid var(--border); }
.slide header { border-bottom: 2px dashed var(--dash); padding-bottom: .6rem; }
.eyebrow { color: var(--accent); margin: 0 0 .25rem; }
.module-chip {
  margin: .38rem 0 0;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: .16rem .6rem;
  border-radius: 999px;
  border: 1px solid rgba(126, 182, 255, .45);
  color: #bcd6ff;
  font-size: .6rem;
  letter-spacing: .06em;
}
.module-chip[data-maturity="lab"] {
  border-color: rgba(255, 209, 102, .55);
  color: #ffd166;
}
h1, h2 { margin: 0 0 .35rem; line-height: 1.15; overflow-wrap: anywhere; line-break: anywhere; }
.subtitle, .takeaway { color: var(--muted); margin: 0; }
.soil-frame { min-width: 0; background: rgba(255,255,255,.05); padding: .75rem; border-radius: 8px; overflow-wrap: anywhere; }
.flow-steps { display: grid; gap: .6rem; height: 100%; align-content: center; }
.flow-steps.four { grid-template-columns: repeat(4, 1fr); }
.flow-steps span { background: var(--card); padding: 1rem; border-radius: 8px; text-align: center; border: 1px solid var(--border); }
.number-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; align-content: center; height: 100%; }
.number-grid article { background: var(--card); padding: 1rem; border-radius: 8px; border: 1px solid var(--border); }
.number-grid b { color: var(--accent); display: block; margin-bottom: .35rem; }
.wordcloud-stage { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: .6rem; max-width: 640px; margin: 0 auto .8rem; width: 100%; }
.word-cloud { flex: 1; min-height: 0; border: 2px dashed var(--dash); border-radius: 12px; padding: 1rem; display: flex; flex-wrap: wrap; align-content: flex-start; gap: .5rem 1rem; overflow: auto; background: var(--card); }
.word-cloud span { color: var(--accent2); line-height: 1.2; }
.poll-stage { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(320px, 1.3fr); gap: 1rem; min-height: 0; align-items: stretch; }
.poll-choices { display: grid; gap: .7rem; align-content: center; }
.poll-choices button { text-align: left; }
.poll-results { display: grid; gap: .6rem; align-content: center; min-height: 0; padding: 1rem; border: 2px dashed var(--dash); border-radius: 12px; background: var(--card); }
.poll-result { display: grid; gap: .3rem; }
.poll-result > span:first-child { color: var(--ink); }
.poll-meter { display: block; height: .7rem; border-radius: 999px; background: linear-gradient(90deg, var(--accent) var(--poll-percent), rgba(255,255,255,.12) var(--poll-percent)); }
.poll-total { margin: .25rem 0 0; color: var(--muted); }
.question-stage { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: .7rem; min-height: 0; }
.question-form { max-width: 860px; align-items: stretch; }
.question-list { min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; align-content: start; padding: .75rem; border: 2px dashed var(--dash); border-radius: 12px; background: var(--card); }
.question-list article { padding: .75rem; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); overflow-wrap: anywhere; white-space: pre-wrap; }
.question-list > p { color: var(--muted); }
.controls {
  position: relative;
  isolation: isolate;
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(.7rem, 2vw, 2rem);
  min-width: 0;
  padding: .5rem clamp(.65rem, 1.6vw, 1.5rem);
  color: #f6f8fb;
  background: linear-gradient(100deg, rgba(255,255,255,.055), transparent 44%), #0b1119;
  box-shadow: 0 -12px 34px rgba(0, 0, 0, .2);
}
.controls::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0 19%, var(--accent2) 19% 43%, rgba(255,255,255,.16) 43% 100%);
}
.deck-identity { min-width: 0; display: flex; align-items: center; gap: .72rem; }
.deck-identity-mark { width: 5px; align-self: stretch; min-height: 38px; border-radius: 999px; background: var(--accent); box-shadow: 0 0 18px var(--glow); }
.deck-identity-copy { min-width: 0; display: grid; gap: .08rem; }
.deck-identity-copy strong,
.deck-identity-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deck-identity-copy strong { font-size: clamp(.78rem, 1vw, 1rem); letter-spacing: .015em; }
.deck-identity-copy span { color: #aeb9c8; font-size: clamp(.62rem, .8vw, .78rem); }
.page-controls { display: flex; align-items: center; gap: .55rem; }
.page-controls #pageInfo { min-width: 4.4rem; color: #aeb9c8; font: 650 clamp(.68rem, .82vw, .8rem)/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; }
.controls button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .45rem .72rem;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 5px;
  color: #f6f8fb;
  background: rgba(255,255,255,.075);
}
.controls button:hover { background: rgba(255,255,255,.14); }
.sync-state { font-size: .85rem; color: var(--muted); margin-top: 1rem; }
.data-notice { color: var(--accent2); }

/* Slide-scoped media modules */
.media-stage { min-height: 0; height: 100%; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: .45rem; }
.video-frame {
  min-height: 0;
  height: 100%;
  aspect-ratio: 16 / 9;
  max-width: min(100%, 980px);
  justify-self: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #080d14;
  box-shadow: 0 22px 60px rgba(0,0,0,.3);
}
.video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.media-placeholder { width: 100%; height: 100%; display: grid; place-content: center; justify-items: center; gap: .65rem; padding: 1.2rem; text-align: center; background: radial-gradient(circle at 50% 20%, rgba(126,182,255,.2), transparent 48%), repeating-linear-gradient(135deg, rgba(255,255,255,.025) 0 1px, transparent 1px 14px); }
.media-placeholder h3, .camera-panel h3 { margin: 0; font-size: clamp(1.2rem, 2.1vw, 2rem); }
.media-placeholder p, .camera-panel p { max-width: 54ch; margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.55; }
.media-signal { color: var(--accent2); font: 700 .66rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.module-status { min-height: 1.25em; margin: 0; color: var(--muted); font-size: .74rem; }

.camera-stage { min-height: 0; height: 100%; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr); gap: 1rem; }
.camera-viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: radial-gradient(circle at 50% 42%, rgba(125,222,160,.17), transparent 34%), #07110d; }
.camera-viewport video { position: relative; z-index: 1; width: 100%; height: 100%; display: block; object-fit: cover; transform: scaleX(-1); opacity: .16; transition: opacity .3s ease; }
[data-camera-state="active"] .camera-viewport video { opacity: .9; }
.camera-effects { position: absolute; z-index: 2; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.camera-reticle { position: absolute; z-index: 3; inset: 50% auto auto 50%; width: min(32vw, 210px); aspect-ratio: 1; transform: translate(-50%, -50%); border: 1px solid rgba(255,255,255,.38); border-radius: 50%; box-shadow: 0 0 0 28px rgba(255,255,255,.025), 0 0 0 74px rgba(255,255,255,.018); pointer-events: none; }
.camera-reticle::before, .camera-reticle::after, .camera-reticle span::before, .camera-reticle span::after { content: ""; position: absolute; width: 18px; height: 18px; border-color: var(--accent); }
.camera-reticle::before { left: 10%; top: 10%; border-left: 2px solid var(--accent); border-top: 2px solid var(--accent); }
.camera-reticle::after { right: 10%; top: 10%; border-right: 2px solid var(--accent); border-top: 2px solid var(--accent); }
.camera-reticle span::before { left: 10%; bottom: 10%; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
.camera-reticle span::after { right: 10%; bottom: 10%; border-right: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
.camera-local-badge { position: absolute; z-index: 4; left: .75rem; top: .75rem; padding: .3rem .48rem; border: 1px solid rgba(255,255,255,.24); border-radius: 4px; color: #dcffea; background: rgba(5,16,11,.72); font: 700 .58rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; }
.camera-panel { min-width: 0; align-self: stretch; display: flex; flex-direction: column; justify-content: center; gap: .72rem; padding: clamp(.8rem, 1.6vw, 1.4rem); border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
.module-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .25rem; }
.button-secondary { color: var(--ink); background: transparent; border: 1px solid var(--border); }

.canvas-stage { position: relative; min-width: 0; min-height: 0; height: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: radial-gradient(circle at 50% 50%, rgba(126,182,255,.16), transparent 40%), #081222; cursor: crosshair; touch-action: none; }
.canvas-stage canvas { position: absolute; inset: 0; display: block; }
.canvas-caption { position: absolute; left: .85rem; bottom: .75rem; display: grid; gap: .18rem; pointer-events: none; }
.canvas-caption span { color: #ffd166; font: 700 .58rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
.canvas-caption strong { color: rgba(255,255,255,.82); font-size: .72rem; font-weight: 600; }
@media (max-width: 900px) {
  .deck-shell { grid-template-columns: 1fr; }
  .toc { display: none; }
  .title-slide.active { grid-template-columns: 1fr; }
  .flow-steps.four, .number-grid, .poll-stage, .question-list, .camera-stage { grid-template-columns: 1fr; }
  .camera-stage { grid-template-rows: minmax(180px, 1fr) auto; }
  .camera-panel { padding: .7rem; gap: .42rem; }
  .camera-panel p { font-size: .7rem; }
}
@media (max-width: 640px) {
  :root { --footer-h: 72px; }
  html, body { font-size: 16px; }
  .slide { padding: .72rem; gap: .52rem; }
  .slide h1, .slide h2 { font-size: clamp(1.3rem, 6vw, 1.65rem); }
  .slide header { min-width: 0; }
  .soil-frame { padding: .58rem; font-size: .88rem; }
  .controls { display: block; width: 100%; min-width: 0; overflow: hidden; padding: .45rem .5rem; }
  .deck-identity { gap: .45rem; }
  .deck-identity { width: calc(100% - 136px); height: 100%; }
  .deck-identity-mark { width: 3px; min-height: 34px; }
  .deck-identity-copy strong { font-size: .72rem; }
  .deck-identity-copy span { font-size: .56rem; }
  .page-controls { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); gap: .3rem; }
  .page-controls #pageInfo { min-width: 3.3rem; font-size: .6rem; }
  .controls button { width: 38px; min-height: 38px; padding: 0; }
  .nav-label { display: none; }
  .media-placeholder { gap: .42rem; padding: .7rem; }
  .media-placeholder p { font-size: .68rem; }
  .camera-panel .media-signal, .camera-panel p { display: none; }
  .camera-panel h3 { font-size: .95rem; }
  .module-actions { margin: 0; }
  .module-status { font-size: .62rem; }
}
@media (prefers-reduced-motion: reduce) {
  :root, button, .camera-viewport video { transition: none; }
}

.event-meta {
  margin-top: .8rem;
  font-size: .85rem;
  letter-spacing: .06em;
  opacity: .82;
}
.deck-shell[data-run-mode="preview"] button:disabled,
.deck-shell[data-run-mode="preview"] input:disabled {
  opacity: .55;
  cursor: not-allowed;
}
