/* Slide layout design tokens + `.slide.role-*` gold-standard layouts.
 * Now backs only the Slide Layout System reference page (/slides/layouts); the
 * Topic 5/6 slide viewer that also used it was retired 2026-07-04.
 * House form: one idea per slide, action-verb bullets, a visible Evidence line. */

:root {
  --ink: #1f2d3d;         /* navy text (the samples' #1F2D3D / #27496B) */
  --muted: #5d6b85;
  --line: #d9e0ec;
  --bg: #e9eef5;          /* soft light page behind the white slide */
  --card: #ffffff;
  --accent: #2f6db5;      /* academic blue (samples' accent1 ~#4472C4 / #2E75B6) */
  --accent2: #5b9bd5;     /* lighter blue for gradients (no cyan) */
  --accent-soft: #e6eef9;
  --sienna: #8c4a1c;      /* warm heading accent (the samples' #663300) */
  --box: #eef4fb;         /* light-blue box fill (samples' #DFEBF7 / #DAE3F3) */
  --box-line: #c9def1;    /* light-blue box border */
  --good: #1c7c4a;
  --warn: #b23b3b;
  --flash: #fff4c2;
  --slide-w: 1280px;
  --slide-h: 720px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.muted { color: var(--muted); }
.hint { font-weight: 400; font-size: .85em; }
.error { color: var(--warn); }

/* ---- Top bar ----------------------------------------------------------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.bar-left { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
#deck-title { font-size: 1.05rem; margin: 0; font-weight: 700; }
#sections { display: flex; gap: 6px; flex-wrap: wrap; }
.bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.btn {
  font: inherit; font-size: .9rem; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 7px 12px; line-height: 1;
}
.btn:hover { border-color: var(--accent); }
.btn-sm { padding: 5px 9px; font-size: .82rem; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.05); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }

/* ---- Stage ------------------------------------------------------------- */
#main { max-width: 1340px; margin: 0 auto; padding: 22px 18px 60px; }
#stage { display: flex; justify-content: center; overflow: hidden; }
.loading { padding: 60px; }

/* The 16:9 slide canvas. The samples are clean white slides with navy text, so
 * the slide is white with a thin blue top accent rule; content sits straight on
 * it. Scales down on narrow screens via transform in JS. */
.slide {
  width: var(--slide-w); height: var(--slide-h);
  /* Keep the intrinsic 1280×720 box — JS transform-scales it to fit.
     flex:0 0 auto stops #stage's flexbox from shrinking it on phones. */
  flex: 0 0 auto;
  background: #ffffff;
  border: 1px solid #dbe3ee; border-top: 6px solid var(--accent);
  border-radius: 14px; box-shadow: 0 18px 48px rgba(31, 45, 61, .16);
  padding: 48px 60px 64px; position: relative; overflow: hidden;
  display: flex; flex-direction: column;
}

/* Content sits straight on the white slide (no frosted card over a dark bg). */
.sheet {
  background: transparent; border: none; box-shadow: none; backdrop-filter: none;
  padding: 6px 4px; flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}

.sheet .kicker {
  font-size: 18px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); font-weight: 700; margin-bottom: 8px;
}

/* Section breadcrumb — the gold-standard "stage navigator". Clickable chips;
   current section highlighted. */
.sheet .breadcrumb {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px;
}
.breadcrumb .crumb {
  font-size: 15px; font-weight: 700; letter-spacing: .03em; color: var(--muted);
  background: #eef3fb; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 13px; cursor: pointer; user-select: none; line-height: 1.3;
}
.breadcrumb .crumb:hover { border-color: var(--accent); color: var(--accent); }
.breadcrumb .crumb-active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff; border-color: transparent;
}
.slide-title {
  font-size: 38px; line-height: 1.16; margin: 0; font-weight: 800;
  color: var(--ink); outline: none;
}
.slide-zh { font-size: 24px; color: #2a6bbf; margin: 6px 0 0; outline: none; font-weight: 700; }
.slide-title:empty::before, .slide-zh:empty::before, .slide-body:empty::before {
  content: attr(data-empty); color: #aab3c5; font-weight: 400;
}

.slide-body {
  margin: 22px 0 0; outline: none; flex: 1; overflow: auto;
  /* Vertically center the bullets in the free space so a sparse slide reads as
     composed rather than top-stacked with a big empty lower half. The special
     layouts below re-assert their own flow. */
  display: flex; flex-direction: column; justify-content: center; gap: 6px;
}
/* Dense plain-bullet slides flow into two columns to fill the frame's width. */
.slide-body.cols-2 {
  display: block; column-count: 2; column-gap: 48px; justify-content: initial;
}
.slide-body.cols-2 .line { break-inside: avoid; }

.slide-body .line {
  position: relative; font-size: 27px; line-height: 1.5; margin: 0 0 18px;
  padding-left: 36px; color: var(--ink);
}
.slide-body .line::before {
  content: ""; position: absolute; left: 4px; top: 11px;
  width: 13px; height: 13px; border-radius: 3px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
}

.slide-evidence {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line);
  font-size: 16px; color: var(--muted);
}
.slide-evidence b { color: var(--sienna); }
.slide-evidence a { color: var(--accent); text-decoration: none; }
.slide-evidence a:hover { text-decoration: underline; }
.slide-evidence .nolink { color: var(--ink); }

.slide-foot {
  position: absolute; left: 60px; right: 60px; bottom: 24px;
  display: flex; justify-content: space-between; font-size: 15px;
  color: var(--muted); letter-spacing: .02em;
}

.just-changed { background: var(--flash); border-radius: 6px; transition: background 1.4s; }

/* ---- Role-specific layouts -------------------------------------------- */
/* Divider / cover: the light "airy wave" backdrop (the gold standard's divider
   image) with a warm-sienna top edge and kicker, to set section breaks apart
   from the plain white content slides. */
.slide.role-divider {
  background: #eaf3fb url("/slides-divider-bg.jpg") center/cover no-repeat;
  border-color: #cfe0f3; border-top-color: var(--sienna);
}
.slide.role-divider .sheet {
  background: transparent; border: none; box-shadow: none; backdrop-filter: none;
  justify-content: center; align-items: flex-start; text-align: left;
  padding: 36px 8px;
}
.slide.role-divider .sheet .kicker { color: var(--sienna); }
.slide.role-divider .slide-title { font-size: 58px; color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6); }
.slide.role-divider .slide-zh { color: var(--accent); font-size: 30px; }
.slide.role-divider .slide-body { flex: 0; margin-top: 22px; justify-content: flex-start; }
.slide.role-divider .slide-body .line { padding-left: 0; font-size: 24px; color: #23344f; }
.slide.role-divider .slide-body .line::before { display: none; }
.slide.role-divider .slide-evidence { border-color: rgba(20, 35, 63, .2); color: var(--muted); }
.slide.role-divider .slide-evidence b { color: var(--ink); }
.slide.role-divider .slide-evidence a { color: var(--accent); }
.slide.role-divider .slide-foot { color: rgba(20, 35, 63, .55); }

/* Takeaway strip: bullets become a row of chips. */
.slide.role-takeaway-strip .slide-body { display: flex; flex-direction: row; flex-wrap: wrap; gap: 14px; justify-content: flex-start; align-content: center; }
.slide.role-takeaway-strip .slide-body .line {
  background: var(--accent-soft); border: 1px solid var(--box-line); border-radius: 12px;
  padding: 14px 18px 14px 40px; margin: 0; flex: 1 1 260px; font-size: 22px;
}
.slide.role-takeaway-strip .slide-body .line::before { left: 16px; top: 21px; }

/* Card grid: bullets become cards. */
.slide.role-card-grid .slide-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-content: center; }
.slide.role-card-grid .slide-body .line {
  background: var(--box); border: 1px solid var(--box-line); border-radius: 12px;
  padding: 18px 18px 18px 44px; margin: 0; font-size: 23px;
}
.slide.role-card-grid .slide-body .line::before { left: 18px; top: 24px; }

/* Flowchart & timeline: real boxes connected by arrows (the gold-standard
   box+arrow flow diagram), not a numbered list. Boxes flow left→right and fill
   the frame's width; an accent arrow sits in the gap before each next box. */
.slide.role-flowchart .slide-body, .slide.role-timeline .slide-body {
  counter-reset: step; flex-direction: row; flex-wrap: wrap;
  align-items: center; justify-content: center; gap: 24px 48px;
}
.slide.role-flowchart .slide-body .line, .slide.role-timeline .slide-body .line {
  position: relative; flex: 1 1 0; min-width: 170px; max-width: 340px; margin: 0;
  background: var(--box); border: 2px solid var(--box-line); border-radius: 14px;
  padding: 18px 16px; font-size: 21px; line-height: 1.32;
  display: flex; align-items: center; justify-content: center; text-align: center;
}
/* Connector arrow to the next box (suppressed on the last box). */
.slide.role-flowchart .slide-body .line::after, .slide.role-timeline .slide-body .line::after {
  content: "\2192"; position: absolute; right: -40px; top: 50%;
  transform: translateY(-50%); color: var(--accent);
  font-size: 30px; font-weight: 700; line-height: 1; pointer-events: none;
}
.slide.role-flowchart .slide-body .line:last-child::after,
.slide.role-timeline .slide-body .line:last-child::after { content: none; }
/* Flowchart boxes carry no marker; timeline boxes get a numbered badge. */
.slide.role-flowchart .slide-body .line::before { content: none; }
.slide.role-timeline .slide-body .line { padding: 30px 16px 16px; }
.slide.role-timeline .slide-body .line::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 12px; top: 10px;
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Comparison: bullets become side-by-side boxes (one column per option) with an
   accent top edge — a real compare layout instead of a plain stacked list. */
.slide.role-compare-table .slide-body {
  display: flex; flex-direction: row; flex-wrap: wrap; gap: 20px;
  align-items: center; justify-content: center;
}
.slide.role-compare-table .slide-body .line {
  position: relative; flex: 1 1 0; min-width: 220px; margin: 0;
  background: var(--box); border: 1px solid var(--box-line); border-top: 4px solid var(--accent);
  border-radius: 12px; padding: 24px; font-size: 22px; line-height: 1.4;
  display: flex; flex-direction: column; justify-content: center;
}
.slide.role-compare-table .slide-body .line::before { content: none; }

/* Single statement: one large, centered claim — no list feel. The first line
   reads as the headline; any follow-up sits below it, smaller. */
.slide.role-single-statement .slide-body {
  justify-content: center; align-items: center; text-align: center; gap: 22px;
}
.slide.role-single-statement .slide-body .line {
  padding-left: 0; max-width: 1000px; font-size: 33px; line-height: 1.45;
  font-weight: 600; margin: 0; color: var(--ink);
}
.slide.role-single-statement .slide-body .line::before { content: none; }
.slide.role-single-statement .slide-body .line:first-child {
  font-size: 41px; font-weight: 800; color: var(--accent);
}

/* Myth vs reality: a warm "reality check" panel (sienna) with check markers,
   contrasting with the blue concept slides. */
.slide.role-myth-vs-reality .slide-body {
  justify-content: center; gap: 0; background: #fbf3ec;
  border: 1px solid #e7cdb6; border-left: 6px solid var(--sienna);
  border-radius: 14px; padding: 32px 36px;
}
.slide.role-myth-vs-reality .slide-body .line {
  padding-left: 44px; font-size: 26px; line-height: 1.45; margin: 0 0 18px;
}
.slide.role-myth-vs-reality .slide-body .line:last-child { margin-bottom: 0; }
.slide.role-myth-vs-reality .slide-body .line::before {
  content: "\2714"; background: none; width: auto; height: auto; border-radius: 0;
  left: 4px; top: 1px; color: var(--sienna); font-size: 24px; font-weight: 700;
}

/* Rule box: a highlighted "rule" panel with a tag — the do-this guardrail. */
.slide.role-rule-box .slide-body {
  justify-content: center; gap: 0; position: relative; background: var(--box);
  border: 1px solid var(--box-line); border-left: 6px solid var(--accent);
  border-radius: 14px; padding: 36px 36px 30px;
}
.slide.role-rule-box .slide-body:not(:empty)::before {
  content: "RULE / \89c4\5219"; position: absolute; top: -13px; left: 24px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 700;
  letter-spacing: .08em; padding: 4px 12px; border-radius: 999px;
}
.slide.role-rule-box .slide-body .line { font-size: 26px; line-height: 1.45; margin: 0 0 16px; }
.slide.role-rule-box .slide-body .line:last-child { margin-bottom: 0; }

/* Pyramid: stacked tiers, widest at the top (priority-first ordering). */
.slide.role-pyramid .slide-body { align-items: center; justify-content: center; gap: 14px; }
.slide.role-pyramid .slide-body .line {
  padding: 18px 22px; margin: 0; text-align: center; color: #fff; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  font-size: 24px; font-weight: 600;
}
.slide.role-pyramid .slide-body .line::before { content: none; }
.slide.role-pyramid .slide-body .line:nth-child(1) { width: 88%; }
.slide.role-pyramid .slide-body .line:nth-child(2) { width: 64%; opacity: .92; }
.slide.role-pyramid .slide-body .line:nth-child(3) { width: 44%; opacity: .84; }
.slide.role-pyramid .slide-body .line:nth-child(n+4) { width: 36%; opacity: .78; }

/* Network: a centered cluster of pill nodes (shared / connected competence). */
.slide.role-network .slide-body {
  flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; gap: 20px;
}
.slide.role-network .slide-body .line {
  padding: 20px 26px; margin: 0; max-width: 330px; text-align: center;
  font-size: 21px; line-height: 1.35; background: var(--accent-soft);
  border: 2px solid var(--accent); border-radius: 999px; color: var(--ink);
}
.slide.role-network .slide-body .line::before {
  content: ""; position: static; display: inline-block; width: 10px; height: 10px;
  margin-right: 9px; border-radius: 50%; background: var(--accent); vertical-align: middle;
}

/* Before -> after: boxes flowing left→right with an accent arrow between. Boxes
   size to content (not full height) so the arrow sits in the gap, not the text. */
.slide.role-before-after .slide-body {
  flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: center; gap: 24px 54px;
}
.slide.role-before-after .slide-body .line {
  position: relative; flex: 1 1 0; min-width: 200px; max-width: 360px; min-height: 150px; margin: 0;
  padding: 24px 22px; font-size: 22px; line-height: 1.4; background: var(--box);
  border: 1px solid var(--box-line); border-top: 4px solid var(--accent);
  border-radius: 12px; display: flex; align-items: center; justify-content: center; text-align: center;
}
.slide.role-before-after .slide-body .line::before {
  content: "\2192"; position: absolute; right: -44px; top: 50%; transform: translateY(-50%);
  background: none; width: auto; height: auto; border-radius: 0;
  color: var(--accent); font-size: 32px; font-weight: 700;
}
.slide.role-before-after .slide-body .line:last-child::before { content: none; }

/* Big-stat callout: the headline finding large in an accent panel. */
.slide.role-big-stat-callout .slide-body { justify-content: center; gap: 18px; }
.slide.role-big-stat-callout .slide-body .line:first-child {
  font-size: 33px; font-weight: 800; color: #fff; padding: 26px 30px;
  border-radius: 14px; background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
}
.slide.role-big-stat-callout .slide-body .line:first-child::before { content: none; }

/* ---- Rich line content (keyword — gloss split + semantic colour) ------- */
.slide-body .line .lead { font-weight: 800; }
.slide-body .line .note, .slide-body .line .rest { font-weight: 400; color: var(--muted); }
.slide.role-single-statement .slide-body .line .lead { color: var(--accent); }
/* keyword + caption boxes read better left-aligned than centred */
.slide.role-flowchart .slide-body .line:has(.note),
.slide.role-timeline .slide-body .line:has(.note),
.slide.role-before-after .slide-body .line:has(.note),
.slide.role-compare-table .slide-body .line { text-align: left; }
.slide.role-flowchart .slide-body .line, .slide.role-timeline .slide-body .line { min-height: 92px; }
/* semantic do (green) / don't (red) / rule (amber); marker stays in the text */
.slide-body .line.sem-do::before { background: var(--good) !important; }
.slide-body .line.sem-dont::before { background: var(--warn) !important; }
.slide-body .line.sem-rule::before { background: #cf9b1a !important; }
.role-card-grid .line.sem-do, .role-compare-table .line.sem-do, .role-before-after .line.sem-do { border-color: var(--good); background: #ecf6f0; }
.role-card-grid .line.sem-dont, .role-compare-table .line.sem-dont, .role-before-after .line.sem-dont { border-color: var(--warn); background: #fbeeee; }
.role-card-grid .line.sem-rule, .role-compare-table .line.sem-rule, .role-before-after .line.sem-rule { border-color: #cf9b1a; background: #fbf4dd; }

/* ---- Controls ---------------------------------------------------------- */
#controls { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 20px; }
#counter { min-width: 150px; text-align: center; }

/* ---- Transcript (notes) ------------------------------------------------ */
#notes { max-width: var(--slide-w); margin: 22px auto 0; background: var(--card);
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.panel-label { font-weight: 700; margin-bottom: 8px; }
#script-box {
  width: 100%; min-height: 120px; resize: vertical; font: inherit; font-size: 1rem;
  line-height: 1.5; border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  color: var(--ink); background: #fbfcfe;
}

/* ---- Overview / map ---------------------------------------------------- */
#overview {
  position: fixed; inset: 0; z-index: 40; background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
#ov-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line);
}
#ov-title { font-size: 1.1rem; font-weight: 800; }
#ov-body { flex: 1; overflow: auto; padding: 22px 26px 60px; max-width: 1340px;
  margin: 0 auto; width: 100%; }

.ov-section-head {
  display: flex; align-items: baseline; gap: 12px; margin: 22px 0 12px;
  padding-bottom: 8px; border-bottom: 2px solid var(--accent);
}
.ov-section-head:first-child { margin-top: 0; }
.ov-sec-id { font-size: 1.05rem; font-weight: 800; color: var(--accent); }
.ov-sec-count { font-size: .85rem; color: var(--muted); }

.ov-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.ov-card {
  text-align: left; cursor: pointer; font: inherit;
  background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--accent);
  border-radius: 12px; padding: 14px 14px 12px; min-height: 116px;
  display: flex; flex-direction: column; gap: 5px;
  box-shadow: 0 4px 14px rgba(31, 45, 61, .06);
  transition: transform .08s ease, border-color .08s ease, box-shadow .08s ease;
}
.ov-card:hover {
  border-color: var(--accent); transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(31, 45, 61, .14);
}
.ov-card.ov-current { border-color: var(--sienna); border-top-color: var(--sienna); background: #fff8f1; }
.ov-num { font-size: .8rem; font-weight: 700; color: var(--muted); }
.ov-card-title { font-size: .98rem; font-weight: 700; line-height: 1.3; color: var(--ink); }
.ov-card-zh { font-size: .85rem; color: #2a6bbf; line-height: 1.3; }
.ov-role {
  margin-top: auto; align-self: flex-start; font-size: .68rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent); background: var(--accent-soft);
  border: 1px solid var(--box-line); border-radius: 999px; padding: 3px 9px;
}

@media (max-width: 640px) {
  #ov-body { padding: 14px 12px 48px; }
  .ov-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .ov-card { min-height: 100px; padding: 11px; }
}

/* ---- AI panel ---------------------------------------------------------- */
#ai-backdrop { position: fixed; inset: 0; background: rgba(20,35,59,.35); z-index: 30; }
#ai-panel {
  position: fixed; top: 0; right: 0; width: min(440px, 92vw); height: 100vh;
  background: var(--card); border-left: 1px solid var(--line); z-index: 31;
  display: flex; flex-direction: column; padding: 16px; gap: 10px;
  box-shadow: -10px 0 30px rgba(20,35,59,.18);
}
#ai-header { display: flex; align-items: center; justify-content: space-between; font-weight: 700; }
.ai-header-btns { display: flex; align-items: center; gap: 8px; }
#ai-context { margin: 0; font-size: .85rem; }
.chat-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.chat-msg { padding: 9px 12px; border-radius: 10px; font-size: .92rem; line-height: 1.45; white-space: pre-wrap; }
.chat-user { background: var(--accent); color: #fff; align-self: flex-end; max-width: 88%; }
.chat-assistant { background: #f0f3f9; align-self: flex-start; max-width: 92%; }
.chat-error { background: #fdecec; color: var(--warn); align-self: flex-start; }
.chat-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chat-hint { font-size: .8rem; }
/* Preview of a proposed edit, shown in the log so the new content is visible
   before the teacher clicks Apply. */
.chat-edit-preview {
  align-self: flex-start; max-width: 92%; border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 10px;
  background: #fafbfe; padding: 8px 11px; font-size: .9rem;
  display: flex; flex-direction: column; gap: 6px;
}
.chat-edit-preview .pv-field { display: flex; flex-direction: column; gap: 2px; }
.chat-edit-preview .pv-label {
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  text-transform: uppercase; color: var(--muted);
}
.chat-edit-preview .pv-val { white-space: pre-wrap; line-height: 1.45; }
.chat-edit-preview ul { margin: 0; padding-left: 18px; }
.chat-edit-preview li { line-height: 1.4; }
#ai-row { display: flex; gap: 8px; }
#ai-input { flex: 1; font: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }

/* ---- Mobile / phone (chrome only — the slide itself auto-scales in JS) -- */
@media (max-width: 820px) {
  #deck-title { width: 100%; }
}

@media (max-width: 640px) {
  #topbar {
    padding: 8px 10px; gap: 8px; flex-direction: column; align-items: stretch;
  }
  .bar-left { gap: 6px; }
  #deck-title { font-size: .98rem; }
  /* Section tabs scroll sideways instead of stacking into many rows. */
  #sections {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 2px; scrollbar-width: thin;
  }
  #sections .btn { flex: 0 0 auto; }
  .bar-right { justify-content: space-between; }
  .bar-right .btn { flex: 1 1 auto; text-align: center; padding: 9px 8px; }
  #save-state { flex-basis: 100%; text-align: center; }

  #main { padding: 12px 8px 48px; }

  #controls { gap: 10px; margin-top: 14px; }
  #controls .btn { flex: 1 1 0; padding: 11px 8px; }
  #counter { min-width: 0; font-size: .85rem; }

  #notes { padding: 12px 12px; border-radius: 10px; }
  /* 16px inputs stop iOS Safari from auto-zooming on focus. */
  #script-box, #ai-input { font-size: 16px; }

  #ai-panel { width: 100vw; padding: 14px; }
}
