/* -------- tokens -------- */
:root {
  --stage-organizational: #6b7280;
  --stage-motivation:     #f59e0b;
  --stage-prior_knowledge:#8b5cf6;
  --stage-new_knowledge:  #3b82f6;
  --stage-initial_practice:#10b981;
  --stage-independent_work:#14b8a6;
  --stage-summary:        #ef4444;

  --accent: var(--stage-new_knowledge);
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f9fafb;
  --card: #ffffff;
  --ok: #10b981;
  --bad: #ef4444;

  --radius: 12px;
  --shadow: 0 8px 28px rgba(17, 24, 39, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  /* Pin body to viewport so slides can't push the page taller. */
  height: 100vh;
  overflow: hidden;
}

/* -------- layout shell -------- */
/* Viewer fills exactly the viewport. The slide grid row (1fr) absorbs the
   remaining height; the slide itself must cap at that area (see .slide-host
   and .slide below). */
.viewer {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  grid-template-columns: 1fr;
  height: 100vh;
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px 0;
  gap: 8px;
}

.chrome {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.chrome .home {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.chrome .home:hover { background: #fff; }
.chrome .title { font-weight: 600; font-size: 15px; }
.chrome .meta { margin-left: auto; color: var(--muted); font-size: 12px; }

/* -------- stage strip -------- */
.stage-strip {
  display: flex;
  gap: 4px;
  height: 6px;
}
.stage-strip .seg {
  flex: 1;
  background: var(--line);
  border-radius: 3px;
  transition: background 0.2s;
}
.stage-strip .seg.active { background: var(--accent); }
.stage-strip .seg.past { background: color-mix(in srgb, var(--accent) 40%, var(--line)); }

/* -------- slide host -------- */
/* Host is a flex container inside the `1fr` grid row. min-height: 0 is the
   canonical fix to let a flex/grid child shrink below its content size. */
.slide-host {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 8px 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Micro label showing current lesson stage. Floats above top-right corner
   of the slide, colored by the active --accent (which is stage-specific),
   so teachers + pupils see at a glance which phase of the lesson is on
   screen. Pointer-events:none keeps the slide click targets intact. */
.stage-label {
  position: absolute;
  top: 14px;
  right: 20px;
  z-index: 5;
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--accent);
  padding: 3px 8px 3px 10px;
  border-left: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 3px;
}
.stage-label:empty { display: none; }
.slide {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-height: 100%;
  /* No min-height — let the slide collapse to fit the viewport. */
  padding: 28px 40px;
  display: flex;
  flex-direction: column;
  border-top: 6px solid var(--accent);
  position: relative;
  overflow: hidden;
}

/* stage-driven accent */
.viewer[data-stage="organizational"]  { --accent: var(--stage-organizational); }
.viewer[data-stage="motivation"]      { --accent: var(--stage-motivation); }
.viewer[data-stage="prior_knowledge"] { --accent: var(--stage-prior_knowledge); }
.viewer[data-stage="new_knowledge"]   { --accent: var(--stage-new_knowledge); }
.viewer[data-stage="initial_practice"]{ --accent: var(--stage-initial_practice); }
.viewer[data-stage="independent_work"]{ --accent: var(--stage-independent_work); }
.viewer[data-stage="summary"]         { --accent: var(--stage-summary); }

.slide h1, .slide h2, .slide h3 { margin: 0; line-height: 1.2; }
.slide h1 { font-size: 44px; }
.slide h2 { font-size: 30px; }
.slide h3 { font-size: 22px; }
.slide p  { font-size: 20px; line-height: 1.5; margin: 8px 0; }
.slide .subtle { color: var(--muted); font-size: 16px; }

/* -------- layouts -------- */
.lay-title       { align-items: center; justify-content: center; text-align: center; gap: 14px; }
.lay-title h1    { font-size: 56px; }
.lay-title .sub  { color: var(--muted); font-size: 22px; }

.lay-transition  { align-items: center; justify-content: center; text-align: center; gap: 18px; background: linear-gradient(180deg, var(--card), color-mix(in srgb, var(--accent) 6%, var(--card))); }
.lay-transition .icon-wrap { width: 96px; height: 96px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 12%, transparent); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.lay-transition svg.icon { width: 52px; height: 52px; }
.lay-transition h1 { color: var(--accent); }

.lay-concept h2   { margin-bottom: 14px; }
.lay-concept .definition { font-size: 24px; line-height: 1.5; }
.lay-concept .example    { margin-top: 20px; padding: 16px 20px; background: color-mix(in srgb, var(--accent) 7%, var(--card)); border-left: 4px solid var(--accent); border-radius: 8px; font-size: 18px; }

.lay-vocabulary h2 { margin-bottom: 20px; }
.lay-vocabulary .terms { display: grid; gap: 14px; }
.lay-vocabulary .term-item { padding: 16px 20px; border: 1px solid var(--line); border-radius: 10px; border-left: 4px solid var(--accent); }
.lay-vocabulary .term { font-weight: 700; font-size: 22px; color: var(--accent); margin-bottom: 4px; }
.lay-vocabulary .def  { font-size: 18px; color: var(--text); }

.lay-two_column h2 { margin-bottom: 20px; }
.lay-two_column .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.lay-two_column .col { padding: 20px; border-radius: 10px; border: 1px solid var(--line); }
.lay-two_column .col.left  { border-top: 4px solid var(--accent); }
.lay-two_column .col.right { border-top: 4px solid color-mix(in srgb, var(--accent) 60%, #000); }
.lay-two_column .col h3 { font-size: 22px; margin-bottom: 10px; }
.lay-two_column .col p  { font-size: 18px; }

.lay-steps h2 { margin-bottom: 20px; }
.lay-steps ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; counter-reset: step; }
.lay-steps li { counter-increment: step; display: flex; gap: 16px; align-items: flex-start; padding: 14px 18px; background: var(--bg); border-radius: 10px; }
.lay-steps li::before { content: counter(step); flex: 0 0 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.lay-steps li .step-text { font-size: 18px; line-height: 1.5; }

.lay-worked_example h2 { margin-bottom: 12px; }
.lay-worked_example .problem { padding: 16px 20px; background: color-mix(in srgb, var(--accent) 7%, var(--card)); border-radius: 10px; font-size: 20px; margin-bottom: 20px; border-left: 4px solid var(--accent); }
.lay-worked_example .step { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.lay-worked_example .step .label { background: var(--bg); padding: 10px 16px; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.lay-worked_example .step .label::after { content: "+"; color: var(--muted); font-size: 20px; }
.lay-worked_example .step.open .label::after { content: "−"; }
.lay-worked_example .step .content { padding: 14px 18px; font-size: 18px; display: none; }
.lay-worked_example .step.open .content { display: block; }

.lay-quote { align-items: center; justify-content: center; text-align: center; gap: 14px; }
.lay-quote .quote-mark { font-size: 96px; color: color-mix(in srgb, var(--accent) 30%, transparent); line-height: 0.5; }
.lay-quote .text   { font-size: 30px; line-height: 1.35; font-style: italic; max-width: 760px; }
.lay-quote .author { color: var(--muted); font-size: 18px; }

.lay-standard h2 { margin-bottom: 16px; }
.lay-standard .content { font-size: 20px; line-height: 1.5; }

.lay-quiz h2 { margin-bottom: 12px; }
.lay-quiz .question { font-size: 22px; margin-bottom: 18px; }
.lay-quiz .options { display: grid; gap: 10px; }
.lay-quiz .opt { padding: 14px 20px; border: 2px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; font-size: 18px; text-align: left; transition: all 0.15s; }
.lay-quiz .opt:hover { border-color: var(--accent); }
.lay-quiz .opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--card)); }
.lay-quiz .opt.wrong   { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--card)); }
.lay-quiz .explanation { margin-top: 16px; padding: 14px 18px; background: var(--bg); border-radius: 10px; font-size: 16px; color: var(--muted); display: none; }
.lay-quiz .explanation.shown { display: block; }

.lay-practice h2 { margin-bottom: 12px; }
.lay-practice .question { font-size: 22px; margin-bottom: 18px; }
.lay-practice .input-row { display: flex; gap: 10px; align-items: center; }
.lay-practice input { flex: 1; padding: 14px 18px; font-size: 20px; border: 2px solid var(--line); border-radius: 10px; font-family: inherit; }
.lay-practice input:focus { outline: none; border-color: var(--accent); }
.lay-practice button.check { padding: 14px 22px; border: 0; background: var(--accent); color: #fff; font-size: 18px; border-radius: 10px; cursor: pointer; }
.lay-practice .hint-btn { margin-top: 12px; background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 14px; text-decoration: underline; }
.lay-practice .hint { margin-top: 8px; padding: 12px 16px; background: var(--bg); border-radius: 8px; font-size: 15px; color: var(--muted); display: none; }
.lay-practice .hint.shown { display: block; }
.lay-practice .feedback { margin-top: 14px; font-size: 16px; }
.lay-practice .feedback.ok  { color: var(--ok); }
.lay-practice .feedback.bad { color: var(--bad); }

.lay-interactive h2 { margin-bottom: 10px; }
.lay-interactive .widget-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
  flex: 1 1 auto;
  min-height: 0;    /* allow shrinking inside flex column */
  /* Cap widget area at 65% of the slide height so title + description + nav
     are always visible above the fold. Wrap is a flex column child, so this
     works together with flex:1 to shrink when the slide is short. */
  max-height: 65%;
  overflow: hidden;
}
.lay-interactive .description { text-align: center; color: var(--muted); font-size: 15px; margin-top: 6px; }
/* SVG widgets scale to fit the wrap in BOTH dimensions. preserveAspectRatio
   already keeps the viewBox proportional, so max-width + max-height is safe. */
.lay-interactive svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}
/* Canvas or DOM-based widgets (if any) also cap to parent. */
.lay-interactive .widget-wrap canvas,
.lay-interactive .widget-wrap > div:not(.description) {
  max-width: 100%;
  max-height: 100%;
}

/* Drag handles (clock hands + number-line marker) must NOT bubble a touch
   into page scroll. Without touch-action:none, a vertical drag on mobile
   gets consumed by scroll before the widget's pointermove listener fires. */
.clock-hand,
.nl-marker {
  touch-action: none;
}

/* Check button + feedback for widgets that have a check-target in params */
.lay-interactive .widget-check {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.lay-interactive .widget-check-btn {
  padding: 10px 22px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
  min-width: 120px;
  transition: transform 0.1s, box-shadow 0.15s;
}
.lay-interactive .widget-check-btn:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.lay-interactive .widget-check-btn:active { transform: scale(0.97); }
.lay-interactive .widget-feedback {
  flex: 1;
  min-height: 32px;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
}
.lay-interactive .widget-feedback:empty { display: none; }
.lay-interactive .widget-feedback.ok    { background: color-mix(in srgb, var(--ok) 14%, var(--card)); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }
.lay-interactive .widget-feedback.retry { background: color-mix(in srgb, #f59e0b 14%, var(--card)); color: #b45309;  border: 1px solid color-mix(in srgb, #f59e0b 40%, transparent); }

@media (max-width: 767px) {
  .lay-interactive .widget-check { gap: 8px; margin-top: 6px; }
  .lay-interactive .widget-check-btn { padding: 10px 16px; font-size: 14px; min-width: 100px; }
  .lay-interactive .widget-feedback { font-size: 13px; padding: 6px 10px; }
}

.lay-platform_tasks { display: flex; flex-direction: column; }
.lay-platform_tasks .platform-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.lay-platform_tasks .platform-header h2 { margin: 0; }
.lay-platform_tasks .task-badge {
  padding: 3px 10px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.lay-platform_tasks .description { font-size: 17px; line-height: 1.5; color: var(--muted); margin-bottom: 12px; }
.lay-platform_tasks .platform-embed { flex: 1; min-height: 0; border-radius: 12px; overflow: hidden; border: 2px solid var(--border, #e2e8f0); }
.lay-platform_tasks .platform-iframe {
  width: 100%;
  height: 100%;
  min-height: 350px;
  border: none;
  display: block;
}
.lay-platform_tasks .platform-open-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.lay-platform_tasks .platform-open-link:hover { opacity: 1; }

.lay-summary h2 { margin-bottom: 20px; }
.lay-summary ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.lay-summary li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 18px; background: var(--bg); border-radius: 10px; font-size: 18px; }
.lay-summary li::before { content: "✓"; color: var(--accent); font-weight: 700; font-size: 20px; flex: 0 0 auto; }

/* -------- feedback panel (right drawer) -------- */
.feedback-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 90vw;
  background: #fff; color: #111827;
  border-left: 1px solid #e5e7eb;
  box-shadow: -8px 0 30px rgba(0,0,0,0.08);
  z-index: 20;
  display: flex; flex-direction: column;
  font-size: 14px;
}
.feedback-panel[hidden] { display: none; }
.feedback-panel header {
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between;
}
.feedback-panel header h3 {
  margin: 0; font-size: 15px; font-weight: 600;
}
.feedback-panel .fb-close {
  background: none; border: 0; font-size: 22px; color: #9ca3af;
  line-height: 1; cursor: pointer; padding: 0 4px;
}
.feedback-panel .fb-close:hover { color: #111827; }
.feedback-panel form {
  padding: 14px 18px; border-bottom: 1px solid #f3f4f6;
  display: grid; gap: 10px;
}
.feedback-panel form label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; font-weight: 600; color: #6b7280;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.feedback-panel .fb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.feedback-panel input,
.feedback-panel select,
.feedback-panel textarea {
  border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  color: #111827; background: #fff; width: 100%; box-sizing: border-box;
  text-transform: none; letter-spacing: normal; font-weight: normal;
}
.feedback-panel input:focus,
.feedback-panel select:focus,
.feedback-panel textarea:focus { outline: none; border-color: #3b82f6; }
.feedback-panel textarea { resize: vertical; min-height: 64px; }
.feedback-panel button[type=submit] {
  background: #3b82f6; color: #fff; border: 0; padding: 9px 14px;
  border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.feedback-panel button[type=submit]:disabled { opacity: 0.5; cursor: not-allowed; }
.feedback-panel .fb-msg { font-size: 12px; min-height: 14px; }
.feedback-panel .fb-msg.err { color: #991b1b; }
.feedback-panel .fb-msg.ok  { color: #065f46; }
.feedback-panel .fb-list-head {
  padding: 10px 18px;
  border-bottom: 1px solid #f3f4f6;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #6b7280;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.feedback-panel .fb-filter {
  font-size: 11px; text-transform: none; letter-spacing: normal;
  color: #6b7280; font-weight: 400;
  display: flex; gap: 4px; align-items: center; cursor: pointer;
}
.feedback-panel .fb-list { flex: 1 1 auto; overflow-y: auto; padding: 8px 18px 20px; }
.feedback-panel .fb-empty { color: #9ca3af; font-size: 13px; padding: 20px 0; text-align: center; }
.feedback-panel .fb-item {
  border: 1px solid #e5e7eb; border-left: 3px solid #3b82f6;
  border-radius: 6px; padding: 10px 12px; margin-bottom: 8px;
  background: #f9fafb;
}
.feedback-panel .fb-item.resolved { opacity: 0.55; border-left-color: #9ca3af; }
.feedback-panel .fb-item .meta1 {
  display: flex; gap: 6px; align-items: center; margin-bottom: 4px; flex-wrap: wrap;
  font-size: 11px; color: #6b7280;
}
.feedback-panel .fb-item .meta1 strong { color: #111827; font-size: 12px; }
.feedback-panel .fb-item .body { font-size: 13px; line-height: 1.5; color: #111827; white-space: pre-wrap; }
.feedback-panel .fb-item .row2 { margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.feedback-panel .fb-item button.resolve {
  background: none; border: 1px solid #e5e7eb; padding: 2px 8px;
  border-radius: 3px; font-size: 11px; color: #6b7280; cursor: pointer;
}
.feedback-panel .fb-item button.resolve:hover { border-color: #3b82f6; color: #3b82f6; }
.feedback-panel .pill { padding: 1px 6px; border-radius: 8px; font-size: 10px; font-weight: 600; }
.feedback-panel .pill.sev-low  { background: #e0e7ff; color: #3730a3; }
.feedback-panel .pill.sev-med  { background: #fef3c7; color: #92400e; }
.feedback-panel .pill.sev-high { background: #fecaca; color: #991b1b; }

.fb-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #ef4444; color: #fff;
  border-radius: 9px; font-size: 11px; font-weight: 700;
  margin-left: 6px;
}
.fb-badge[hidden] { display: none; }

@media (max-width: 520px) {
  .feedback-panel { width: 100vw; max-width: 100vw; border-left: 0; }
}

/* -------- notes -------- */
.notes-panel {
  position: fixed;
  right: 20px;
  bottom: 80px;
  width: 340px;
  max-height: 60vh;
  background: #111827;
  color: #f9fafb;
  padding: 18px 22px;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  overflow-y: auto;
  z-index: 10;
}
.notes-panel h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: #9ca3af; letter-spacing: 0.05em; }
.notes-panel #notes-body { font-size: 15px; line-height: 1.5; }

/* -------- nav footer -------- */
.nav {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0 18px;
  border-top: 1px solid var(--line);
}
.nav-btn {
  padding: 8px 16px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }
.progress { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s; }
.counter { color: var(--muted); font-size: 13px; min-width: 60px; text-align: center; }

/* ======= Responsive breakpoints =======
   desktop: default (≥1024px)
   tablet:  768-1023px — tighter paddings, smaller base fonts
   mobile:  <768px — vertical layouts, full-bleed slide, full-screen notes
============================================ */

/* tablet */
@media (max-width: 1023px) {
  .viewer { padding: 8px 14px 0; gap: 6px; max-width: 100%; }
  .slide { padding: 22px 28px; }
  .slide h1 { font-size: 36px; }
  .slide h2 { font-size: 26px; }
  .slide h3 { font-size: 20px; }
  .slide p  { font-size: 18px; }
  .lay-title h1 { font-size: 44px; }
  .lay-quote .text { font-size: 26px; }
  .lay-vocabulary .term { font-size: 20px; }
  .lay-vocabulary .def  { font-size: 16px; }
  /* Larger touch targets for nav buttons. */
  .nav-btn { padding: 10px 18px; font-size: 15px; min-height: 44px; }
  .counter { font-size: 14px; }
}

/* mobile */
@media (max-width: 767px) {
  .viewer { padding: 6px 10px 0; gap: 4px; }
  .chrome { gap: 8px; flex-wrap: wrap; padding: 2px 0 6px; }
  .chrome .title { font-size: 13px; }
  .chrome .meta { font-size: 11px; }
  .stage-strip { height: 4px; }
  .slide { padding: 16px 18px; border-top-width: 4px; }
  .slide h1 { font-size: 26px; }
  .slide h2 { font-size: 20px; }
  .slide h3 { font-size: 17px; }
  .slide p  { font-size: 16px; line-height: 1.4; }
  .lay-title h1 { font-size: 32px; }
  .lay-title .sub { font-size: 16px; }
  .lay-quote .text { font-size: 20px; }
  .lay-quote .quote-mark { font-size: 64px; }
  .lay-two_column .cols { grid-template-columns: 1fr; gap: 10px; }
  .lay-two_column .col { padding: 14px; }
  .lay-two_column .col h3 { font-size: 18px; }
  .lay-two_column .col p  { font-size: 15px; }
  .lay-steps li { padding: 10px 14px; }
  .lay-steps li .step-text { font-size: 15px; }
  .lay-vocabulary .term-item { padding: 12px 14px; }
  .lay-vocabulary .term { font-size: 17px; }
  .lay-vocabulary .def  { font-size: 14px; }
  .lay-worked_example .step .label { padding: 10px 14px; font-size: 15px; }
  .lay-worked_example .step .content { padding: 12px 14px; font-size: 15px; }
  .lay-quiz .question { font-size: 18px; }
  .lay-quiz .opt { padding: 12px 14px; font-size: 15px; min-height: 44px; }
  .lay-practice .question { font-size: 18px; }
  .lay-practice input { padding: 12px 14px; font-size: 17px; min-height: 44px; }
  .lay-practice button.check { padding: 12px 18px; font-size: 16px; min-height: 44px; }
  .lay-standard .content { font-size: 16px; }
  .lay-summary li { font-size: 15px; padding: 10px 14px; }

  /* nav: comfortable thumb reach */
  .nav { padding: 10px 0 14px; gap: 10px; }
  .nav-btn { padding: 12px 18px; font-size: 15px; min-height: 44px; min-width: 44px; }

  /* Notes become a full-screen drawer on mobile (pointer-friendly). */
  .notes-panel {
    position: fixed;
    inset: auto 0 0 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    padding: 22px 20px;
  }

  /* Keep widgets snug but legible on small screens */
  .lay-interactive .widget-wrap { padding: 4px 0; }
  .lay-interactive .description { font-size: 13px; }
}

/* very narrow mobile portrait (<=380px) — squeeze slightly more */
@media (max-width: 380px) {
  .slide { padding: 12px 12px; }
  .slide h1 { font-size: 22px; }
  .slide h2 { font-size: 18px; }
  .lay-title h1 { font-size: 26px; }
}

/* ---- design_theme — theme's palette is mapped onto the base CSS tokens
       (--bg, --card, --accent, --text, --ok, --bad, --muted, --line) via
       renderer.applyTheme(). That way every existing layout rule adopts the
       theme colours automatically without per-layout overrides. ---- */

/* Force the viewer to re-resolve --text so slide text adopts theme fg.
   (Default `color: var(--text)` is on `body` which is outside .viewer, so
   the token override on .viewer alone won't cascade without this.) */
.viewer.themed                     { color: var(--text); background: var(--bg); }
/* Slide surface uses --card (lifted 6% from --bg). This keeps in-slide
   blocks with `background: var(--bg)` (summary li, steps li, quiz
   explanation, practice hint) visually distinct as recessed/inset panels. */
.viewer.themed .slide-host         { background: var(--card); }

/* Unify heading colour across all layouts for themed decks — without this,
   `.lay-transition h1` is gold (accent) while most other layouts inherit
   plain text, creating inconsistent visual weight. */
.viewer.themed .slide h1,
.viewer.themed .slide h2           { color: var(--accent); }

/* Quiz options are <button> elements: browser UA style forces
   `color: buttontext` (black), ignoring inherited --text. Force inherit so
   options pick up theme fg. Applies to all decks, not just themed. */
.lay-quiz .opt, .lay-quiz .opt * { color: var(--text); }

/* Practice input is a bare <input>: UA defaults to white bg + black text,
   which clashes with dark theme palettes. Pull it into the theme and also
   themify the Check button's label colour. */
.viewer.themed .lay-practice input {
  background: var(--card);
  color: var(--text);
  border-color: var(--line);
}
.viewer.themed .lay-practice input::placeholder { color: var(--muted); }
.viewer.themed .lay-practice button.check { color: var(--bg); }

/* Card-like containers that are transparent by default (relying on the
   slide's --card bg to show through). Under a theme, the motif overlay
   sits behind them — give them an opaque --card background so icons don't
   bleed through onto card content. Border/border-left still provide lift. */
.viewer.themed .lay-two_column .col,
.viewer.themed .lay-vocabulary .term-item,
.viewer.themed .lay-worked_example .step {
  background: var(--card);
}

/* motif overlay: sits behind text inside each rendered slide */
.slide { position: relative; }
.slide > *:not(.motif-overlay) {
  position: relative;
  z-index: 1;
}
.motif-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
