/* Classrun styles.
   Sections: fonts · tokens · base · buttons & forms · menus & modals · top bar · dashboard · code ·
   stage (the projected slide) · results on the stage · editor · notebook import · presenter · student · Parsons ·
   votes & feedback · code cells · results page · account & auth · landing · themes · small screens */

/* ---------- Fonts (served from node_modules, so they work without internet) ---------- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("/vendor/inter/inter-latin-wght-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url("/vendor/jbmono/jetbrains-mono-latin-wght-normal.woff2") format("woff2"); }

/* ---------- Tokens ---------- */
/* "Run blue" on warm paper neutrals. Yellow (--marker) only means "live": the play icon, the live dot,
   the line under a join code; never in results, where it would be confused with orange "wrong". */
:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-2: #f0f0eb;
  --border: #e3e3dc;
  --border-strong: #b8b8ae;
  --text: #16171d;
  --muted: #5d5f6a;
  --placeholder: #9a9ca5;
  --accent: #2350e6;
  --accent-hover: #1a3fc2;
  --accent-soft: #e8eeff;
  --accent-ink: #15318f;
  --on-accent: #ffffff;
  --marker: #ffd43b;
  /* Outcomes: colour-blind friendly (bluish green / orange / reddish purple), always with an icon;
     "wrong" is also hatched in bars. */
  --ok: #0f8a6c;
  --ok-soft: #d9f3ec;
  --ok-ink: #0b5e4a;
  --warn: #e08a00;
  --warn-soft: #fff1d6;
  --warn-ink: #7a4a00;
  --bad: #c2366f;
  --bad-soft: #fbe3ed;
  --bad-ink: #8f1f4e;
  --neutral: #a3a49c;
  --code-bg: #15161e;
  --code-border: transparent;
  --code-text: #e9e9ee;
  --code-comment: #8d90a3;
  --field: #3a64ff;               /* the editable part of the code */
  /* presenter chrome (always dark) */
  --dk-bg: #0b0c10;
  --dk-1: #131419;
  --dk-2: #1b1c23;
  --dk-3: #25262f;
  --dk-border: #2b2c36;
  --dk-text: #ececef;
  --dk-muted: #a2a4ae;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(22, 23, 29, .05), 0 4px 16px rgba(22, 23, 29, .06);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .35);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --wrong-hatch: repeating-linear-gradient(135deg, var(--warn) 0 10px, #f2b443 10px 20px);
}

/* Dark mode: set by /js/theme.js from the system setting or the toggle in the top bar. */
:root[data-scheme="dark"] {
  color-scheme: dark;
  --bg: #0e0f13;
  --surface: #16171d;
  --surface-2: #1f2028;
  --border: #2b2c36;
  --border-strong: #4a4c58;
  --text: #ececef;
  --muted: #a2a4ae;
  --placeholder: #6c6e7a;
  --accent: #7a9bff;
  --accent-hover: #93afff;
  --accent-soft: #1c2647;
  --accent-ink: #c3d2ff;
  --on-accent: #0b1020;          /* white on this light blue would fail contrast */
  --ok: #2fbf95;
  --ok-soft: #12332b;
  --ok-ink: #8de6c9;
  --warn: #f0a12a;
  --warn-soft: #3a2b10;
  --warn-ink: #ffd18a;
  --bad: #e2558e;
  --bad-soft: #3b1626;
  --bad-ink: #ffadcb;
  --code-bg: #0a0b0f;
  --code-border: #2b2c36;        /* otherwise code disappears into the dark cards */
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
::placeholder { color: var(--placeholder); opacity: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden, [hidden] { display: none !important; }
.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ok-ink { color: var(--ok-ink); }
kbd { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; }
/* counts and percentages don't jump around while they change */
.big-count, .res-n, .counter, .stat b, .result-stats b, .q-timer, .res-timer, .choice-n, .vote-bar-row b, .num { font-variant-numeric: tabular-nums; }
/* code shows == and != as typed, not as ligatures */
code, pre, kbd, .mono, textarea, .field, .p-code, .wordmark, .jc, .join-panel .code { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }

.ico { display: inline-flex; width: 1.1em; height: 1.1em; flex-shrink: 0; vertical-align: -.18em; }
.ico svg { width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Brand ---------- */
.logo { display: inline-flex; align-items: center; gap: 9px; color: var(--text); }
.logo:hover { text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; display: block; }
.logo-mark.lg { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto; }
.wordmark { font-family: var(--mono); font-weight: 600; font-size: 18px; letter-spacing: -.02em; color: var(--text); }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: var(--r-md); cursor: pointer; font-weight: 560; font-size: 14px; line-height: 1.3; transition: background .12s, border-color .12s, transform .05s; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger:hover { color: var(--bad-ink); border-color: var(--bad-soft); background: var(--bad-soft); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; gap: 5px; }
.btn-lg { padding: 11px 20px; font-size: 16px; border-radius: 12px; }
.btn-xl { padding: 14px 26px; font-size: 20px; border-radius: 14px; margin-top: 22px; }
.btn-block { width: 100%; }
.btn.icon-only { padding: 8px 10px; }
.btn > span:not(.ico):not(.spinner) { display: inline-flex; align-items: center; gap: 6px; }

.input, .textarea, select.input { width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md); padding: 9px 11px; outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; min-height: 80px; }
.mono, .textarea.mono { font-family: var(--mono); font-size: 13.5px; }
/* code fields look like the code they produce */
.textarea.mono { background: var(--code-bg); color: var(--code-text); border-color: var(--code-border); caret-color: #fff; }
.textarea.mono:focus { border-color: var(--accent); }
.textarea.mono::placeholder { color: var(--code-comment); }
label.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 16px 0 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.field-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }

.seg { display: inline-flex; flex-wrap: wrap; background: var(--surface-2); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 560; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1); }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 6px 0; font-size: 14px; }
.switch.small { font-size: 13px; padding: 0; gap: 6px; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; flex-shrink: 0; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { left: 16px; }

/* soft badges use the dark "ink" colour for the text: readable (WCAG AA), not just pretty */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.correct { background: var(--ok-soft); color: var(--ok-ink); }
.badge.wrong, .badge.warn-badge { background: var(--warn-soft); color: var(--warn-ink); }
.badge.error { background: var(--bad-soft); color: var(--bad-ink); }
.badge.accent, .badge.submitted, .badge.ungraded { background: var(--accent-soft); color: var(--accent-ink); }
.badge.live { background: var(--ok-soft); color: var(--ok-ink); }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }

.alert { padding: 9px 12px; border-radius: var(--r-md); font-size: 13.5px; margin-top: 8px; }
.alert.warn { background: var(--warn-soft); color: var(--warn-ink); }
.alert.err { background: var(--bad-soft); color: var(--bad-ink); }
.alert.ok { background: var(--ok-soft); color: var(--ok-ink); }
.alert.info { background: var(--accent-soft); color: var(--accent-ink); }

.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .3; } }
.toast { position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: #16171d; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px); }
.toast-action { border: 0; background: transparent; color: #a8bcff; font-weight: 700; cursor: pointer; padding: 2px 4px; }

/* ---------- Menus & modals ---------- */
.menu-wrap { position: relative; display: inline-flex; }
.menu-btn { padding: 6px 9px; }
.menu { position: absolute; top: calc(100% + 6px); min-width: 230px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; padding: 6px; z-index: 60; box-shadow: var(--shadow-lg); }
.menu.align-right { right: 0; }
.menu.align-left { left: 0; }
.menu.up { top: auto; bottom: calc(100% + 6px); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent; color: inherit; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item .ico { color: var(--muted); }
.menu-item.danger, .menu-item.danger .ico { color: var(--bad-ink); }
.menu-item.phone-only { display: none; }
@media (max-width: 600px) { .menu-item.phone-only { display: flex; } }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.menu-user { display: flex; flex-direction: column; line-height: 1.3; }
.menu-user span { font-size: 12.5px; color: var(--muted); }
.menu.dark { background: var(--dk-1); border-color: var(--dk-border); color: var(--dk-text); }
.menu.dark .menu-item:hover, .menu.dark .menu-item:focus-visible { background: var(--dk-3); }
.menu.dark .menu-item .ico { color: var(--dk-muted); }
.menu.dark .menu-sep { background: var(--dk-border); }

.modal-overlay { position: fixed; inset: 0; background: rgba(8, 9, 14, .55); display: grid; place-items: center; z-index: 80; padding: 20px; }
.modal { width: min(560px, 100%); padding: 22px 24px; color: var(--text); background: var(--surface); }
.modal h2 { margin: 0 0 6px; font-size: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.problem-list { margin: 10px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
table.keys { border-collapse: collapse; width: 100%; font-size: 14px; }
table.keys td { padding: 5px 8px; border-top: 1px solid var(--border); }

/* ---------- Top bar ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
/* the pages with a content column: the bar lines up with it */
.topbar-inner, .topbar:not(:has(.topbar-inner)) { height: 60px; display: flex; align-items: center; gap: 12px; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.topbar:not(:has(.topbar-inner)) { padding: 0 20px; }
.topnav { display: flex; gap: 2px; margin-left: 14px; }
.topnav a { color: var(--muted); font-weight: 560; font-size: 14px; padding: 7px 11px; border-radius: 8px; }
.topnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topnav a.on { color: var(--text); background: var(--surface-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.topbar .menu-btn { border-radius: 99px; padding: 3px; border-color: transparent; background: transparent; }
.theme-btn { padding: 8px; color: var(--muted); }
.theme-btn:hover { color: var(--text); }
.theme-btn .ico { width: 18px; height: 18px; }

/* ---------- Dashboard ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 32px 20px; }
.hero { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.hero h1 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.hero p { margin: 4px 0 0; }
.hero-actions { display: flex; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.section-title { font-size: 13px; font-weight: 650; color: var(--muted); margin: 0 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.pres-card { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.pres-card-body { padding: 0 4px; }
.pres-card h3 { margin: 0 0 2px; font-size: 16.5px; }
.pres-card .thumb { position: relative; display: block; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.pres-card .thumb .stage { pointer-events: none; border-radius: 0; }
.pres-card .actions { display: flex; gap: 6px; align-items: center; padding: 0 4px 4px; }
.pres-card.broken { border-color: var(--bad); padding: 16px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h2 { color: var(--text); margin: 22px 0 6px; }
.empty p { max-width: 460px; margin: 0 auto 18px; }
/* an empty, dashed slide with a bit of code: what a deck looks like before it exists */
.ghost-slide { position: relative; width: 300px; max-width: 100%; aspect-ratio: 16 / 9; margin: 0 auto; border: 2px dashed var(--border-strong); border-radius: 14px; display: grid; place-items: center; padding: 18px; }
.ghost-slide pre.code { font-size: 13px; text-align: left; width: 100%; }
.ghost-play { position: absolute; right: -12px; bottom: -12px; width: 40px; height: 40px; border-radius: 12px; background: var(--code-bg); color: var(--marker); display: grid; place-items: center; box-shadow: var(--shadow); }
#sessions { margin-bottom: 28px; }
.session-list { display: flex; flex-direction: column; }
.session-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.session-row:first-child { border-top: 0; }
.session-title { min-width: 0; }
.section-head { margin-bottom: 10px; }
.section-head .section-title { margin: 0; }
.session-day { margin-bottom: 24px; }
.session-search { width: 260px; max-width: 100%; }

/* ---------- Code ---------- */
pre.code, .md pre { background: var(--code-bg); color: var(--code-text); border: 1px solid var(--code-border); border-radius: var(--r-md); padding: 14px 16px; margin: 0; overflow: auto; font-family: var(--mono); font-size: 14px; line-height: 1.55; tab-size: 4; }
pre.code code, .md pre code { font-family: inherit; background: none; padding: 0; white-space: pre; }
.md :not(pre) > code { font-family: var(--mono); background: var(--surface-2); padding: .1em .35em; border-radius: 5px; font-size: .9em; }
.md img { max-width: 100%; height: auto; border-radius: var(--r-md); }
.hljs-keyword, .hljs-built_in, .hljs-literal { color: #c4a0ff; }
.hljs-string { color: #b5e08a; }
.hljs-number { color: #ffa36b; }
.hljs-comment { color: var(--code-comment); font-style: italic; }
.hljs-title, .hljs-title.function_ { color: #7fb0ff; }
.hljs-title.class_ { color: #ffcf6b; }
.hljs-params, .hljs-subst { color: inherit; }
.hljs-meta { color: #85d8ff; }

/* the blank students fill in, as the room sees it */
.blank { display: inline-block; min-width: var(--w, 6ch); text-align: center; background: rgba(58, 100, 255, .2); border: 2px dashed #6f8dff; border-radius: 6px; color: #a8bcff; line-height: 1.25; padding: 0 4px; vertical-align: baseline; }
.blank-block { display: block; min-width: 0; text-align: left; padding: 6px 10px; height: calc(var(--lines) * 1.55em + 12px); margin: 2px 0; }
mark.answer-mark { background: rgba(58, 100, 255, .26); color: inherit; border-radius: 4px; outline: 1px solid rgba(111, 141, 255, .75); padding: 0 1px; }
mark.answer-mark.block { display: inline-block; min-width: 60%; }

/* editable code (student view) */
.code-edit { display: flex; flex-direction: column; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--r-md); overflow: hidden; }
.code-edit pre.code { border-radius: 0; border: 0; }
.code-edit pre.part { padding-bottom: 4px; }
.code-edit .field { font-family: var(--mono); font-size: 14px; color: #fff; background: rgba(58, 100, 255, .2); border: 2px solid #6f8dff; border-radius: 6px; outline: none; }
.code-edit .field:focus { background: rgba(58, 100, 255, .32); box-shadow: 0 0 0 3px rgba(111, 141, 255, .3); }
.code-edit .field:disabled { opacity: .8; border-style: dashed; }
.code-edit input.field { padding: 1px 4px; min-width: 6ch; max-width: 100%; line-height: 1.3; vertical-align: baseline; }
.code-edit textarea.field { margin: 2px 10px; padding: 6px 8px; resize: none; line-height: 1.55; tab-size: 4; overflow: hidden; }
.code-edit textarea.field-block { min-height: 70px; white-space: pre; overflow-x: auto; }
.code-edit textarea.field-line { white-space: pre-wrap; word-break: break-word; min-height: 0; }
.code-edit > :last-child.field { margin-bottom: 12px; }
.code-edit > :first-child.field { margin-top: 12px; }

/* keys that are missing on a phone keyboard */
.code-keys { display: flex; gap: 4px; overflow-x: auto; padding: 6px 2px 2px; scrollbar-width: none; }
.code-keys button { flex: 0 0 auto; min-width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; font: 600 16px var(--mono); color: var(--text); }
.code-keys button:active { background: var(--accent-soft); }

.output { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.output pre { margin: 0; padding: 10px 14px; font-family: var(--mono); font-size: 13.5px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; background: none; color: var(--text); border: 0; border-radius: 0; }
.output .stderr { color: var(--bad-ink); background: var(--bad-soft); }
.output .stderr.test-failed { color: var(--warn-ink); background: var(--warn-soft); }
.output > .muted { padding: 10px 14px; }
.output.ok { border-color: var(--ok); }
.output.bad { border-color: var(--bad); }
.mini-out { margin: 0; padding: 8px 10px; background: rgba(0, 0, 0, .06); border-radius: 8px; font: 13px/1.45 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: auto; }
.output-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.output-diff pre.diff { margin: 0; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font: 13px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; }
.diff-line { display: block; min-height: 1.5em; padding-left: 4px; }
.diff-line.bad { background: var(--warn-soft); color: var(--warn-ink); box-shadow: inset 3px 0 var(--warn); }

/* ---------- Stage: the 1280×720 slide the room sees ---------- */
.stage-host { position: relative; overflow: hidden; }
/* Slides always use the light projector colours, whatever the lecturer's own theme is. */
.stage {
  color-scheme: light;
  --surface: #fff; --surface-2: #f0f0eb; --border: #e3e3dc; --border-strong: #b8b8ae; --text: #16171d; --muted: #5d5f6a;
  --accent: #2350e6; --accent-soft: #e8eeff; --accent-ink: #15318f; --on-accent: #fff;
  --ok: #0f8a6c; --ok-soft: #d9f3ec; --ok-ink: #0b5e4a; --warn: #e08a00; --warn-soft: #fff1d6; --warn-ink: #7a4a00;
  --bad: #c2366f; --bad-soft: #fbe3ed; --bad-ink: #8f1f4e; --code-bg: #15161e; --code-border: transparent;
  --safe-x: 64px; --safe-top: 56px; --safe-bottom: 52px; --strip: 64px; --fs: 1;
  color: var(--text); position: absolute; left: 50%; top: 50%; width: 1280px; height: 720px; transform-origin: center; transform: translate(-50%, -50%) scale(.5);
  background: var(--surface); border-radius: 6px; padding: var(--safe-top) var(--safe-x) var(--safe-bottom); display: flex; flex-direction: column; overflow: hidden; font-size: calc(30px * var(--fs)); line-height: 1.45;
}
.stage.has-join-strip { padding-bottom: calc(var(--strip) + 20px); }
.stage h1 { font-size: calc(54px * var(--fs)); line-height: 1.1; margin: 0 0 26px; letter-spacing: -.035em; }
.stage .md p { margin: 0 0 .6em; }
.stage .md ul, .stage .md ol { margin: 0 0 .6em; padding-left: 1.2em; }
.stage .md li { margin-bottom: .25em; }
.stage .md pre { font-size: calc(24px * var(--fs)); margin: .4em 0; }
.stage .md img { max-height: 420px; }
.q-label { font-size: 15px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 10px; }

/* the join strip: reserved space at the bottom, so it never covers the slide */
.join-strip { position: absolute; left: 0; right: 0; bottom: 0; height: var(--strip); display: flex; align-items: center; gap: 22px; padding: 0 var(--safe-x); background: #f0f0eb; border-top: 1px solid #e3e3dc; font-size: 22px; color: #5d5f6a; }
.join-strip b { color: #16171d; font-weight: 650; }
.join-strip .jc { font-family: var(--mono); font-weight: 700; font-size: 28px; color: #16171d; letter-spacing: .04em; box-shadow: inset 0 -6px 0 var(--marker); padding: 0 2px; }
.join-strip .qr { margin-left: auto; width: 52px; height: 52px; }
.join-strip .qr svg { width: 100%; height: 100%; display: block; }

/* title slide: big title on the left, how to join on the right */
.stage.layout-title { display: grid; grid-template-columns: 1fr auto; grid-template-rows: 1fr auto; column-gap: 56px; padding-bottom: 40px; }
.stage.layout-title .title-main { align-self: center; min-width: 0; }
.stage.layout-title h1 { font-size: calc(88px * var(--fs)); font-weight: 750; letter-spacing: -.045em; margin-bottom: 18px; }
.stage.layout-title .subtitle { font-size: calc(34px * var(--fs)); color: var(--muted); }
.stage.layout-title .subtitle p { margin: 0; }
.title-join { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 26px 30px; border: 1px solid var(--border); border-radius: 22px; background: #fff; box-shadow: 0 8px 30px rgba(22, 23, 29, .08); }
.title-join .qr { width: 240px; height: 240px; }
.title-join .qr svg { width: 100%; height: 100%; display: block; }
.title-join .jt { font-size: 20px; color: var(--muted); }
.title-join .jt b { color: var(--text); }
.title-join .jc { font-family: var(--mono); font-size: 72px; font-weight: 800; letter-spacing: .02em; line-height: 1; box-shadow: inset 0 -12px 0 var(--marker); padding: 0 6px; }
.title-join.placeholder .qr { display: grid; place-items: center; border: 2px dashed var(--border-strong); border-radius: 12px; color: var(--muted); font-size: 22px; }
.title-footer { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-size: 22px; color: var(--muted); }
.title-footer .wordmark { font-size: 24px; opacity: .5; }

/* question slides */
.stage-question { flex-direction: row; gap: 40px; }
.stage-question .q-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stage-question h1 { font-size: calc(42px * var(--fs)); margin-bottom: 14px; }
.stage-question .md { font-size: calc(25px * var(--fs)); margin-bottom: 18px; }
.stage-question pre.code { font-size: calc(23px * var(--fs)); padding: 20px 24px; flex-shrink: 1; min-height: 0; }
.stage-question .q-aside { width: 400px; flex-shrink: 0; display: flex; flex-direction: column; }
/* a short question: bigger code, centred, instead of an empty bottom half */
.stage.q-short .q-main { justify-content: center; }
.stage.q-short .q-main pre.code { font-size: calc(27px * var(--fs)); padding: 24px 28px; }
.answer-label { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 750; color: var(--ok-ink); text-transform: uppercase; letter-spacing: .08em; margin: 2px 0 8px; }
pre.stage-output { margin-top: 0; white-space: pre-wrap; }

/* ---------- Results on the stage: readable from the back of a lecture hall ---------- */
.results { display: flex; flex-direction: column; gap: 20px; height: 100%; min-height: 0; }
.res-head { display: flex; align-items: flex-start; gap: 12px; }
.res-head > div:first-child { flex: 1; }
.results .big-count { font-size: 84px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.results .big-count span { font-size: 30px; color: var(--muted); font-weight: 650; letter-spacing: 0; }
.results .label { font-size: 20px; color: var(--muted); font-weight: 650; margin-bottom: 6px; }
.res-timer { display: inline-flex; align-items: center; gap: 8px; font: 750 34px var(--mono); color: var(--accent-ink); background: var(--accent-soft); padding: 6px 14px; border-radius: 14px; }
.res-bars { display: flex; flex-direction: column; gap: 14px; }
.res-bar { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: end; row-gap: 6px; }
.res-bar::after { content: ""; grid-column: 1 / -1; height: 26px; border-radius: 99px; background: #e2e2da; grid-row: 2; }
.res-bar .fill { grid-column: 1 / -1; grid-row: 2; height: 26px; border-radius: 99px; z-index: 1; transition: width .5s ease; min-width: 0; }
.res-label { display: inline-flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 650; }
.res-n { font-size: 40px; font-weight: 800; line-height: 1; }
.res-n small { font-size: 22px; color: var(--muted); font-weight: 650; }
.c-correct .fill, .stackbar .c-correct, .swatch.c-correct { background: var(--ok); }
.c-wrong .fill, .stackbar .c-wrong, .swatch.c-wrong { background: var(--wrong-hatch); }
.c-error .fill, .stackbar .c-error, .swatch.c-error { background: var(--bad); }
.c-ungraded .fill, .stackbar .c-ungraded, .swatch.c-ungraded { background: var(--neutral); }
.c-correct .res-label .ico { color: var(--ok); }
.c-wrong .res-label .ico { color: var(--warn); }
.c-error .res-label .ico { color: var(--bad); }
.stackbar { display: flex; height: 22px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.stackbar > div { transition: width .4s ease; }
.err-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.err-chips .chip { font-family: var(--mono); font-size: 22px; background: var(--bad-soft); color: var(--bad-ink); padding: 4px 12px; border-radius: 10px; }
.test-rows { display: flex; flex-direction: column; gap: 6px; }
.test-row { display: flex; align-items: center; gap: 10px; background: var(--warn-soft); border-radius: 10px; padding: 6px 12px; font-size: 20px; }
.test-row code { font-family: var(--mono); color: var(--warn-ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-row b { color: var(--warn-ink); }
.results-hidden { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 28px; font-weight: 650; border: 3px dashed var(--border-strong); border-radius: 20px; }
.results-hidden .ico { width: 44px; height: 44px; margin-bottom: 8px; }
.results-hidden .small { font-size: 20px; font-weight: 500; }
.callout { background: var(--warn-soft); border-radius: 14px; padding: 12px 14px; min-height: 0; overflow: hidden; }
.callout .label { color: var(--warn-ink); }
.callout pre.snippet { font-size: 18px; max-height: 150px; }

/* multiple choice on the stage */
.choice-preview { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.choice-opt { position: relative; display: flex; align-items: center; gap: 16px; padding: 14px 18px; border: 2px solid var(--border); border-radius: 16px; font-size: calc(28px * var(--fs)); overflow: hidden; }
.choice-opt > :not(.choice-bar) { position: relative; z-index: 1; }
.choice-opt .choice-text { flex: 1; }
.choice-opt .choice-bar { position: absolute; inset: 0 auto 0 0; width: var(--pct); background: var(--accent-soft); transition: width .5s ease; }
.choice-opt .choice-n { font-size: 34px; font-weight: 800; }
.choice-opt.correct { border-color: var(--ok); }
.choice-opt.correct .choice-bar { background: var(--ok-soft); }
.choice-opt.correct > .ico { color: var(--ok); width: 34px; height: 34px; }
.choice-letter { width: 36px; height: 36px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 800; font-size: .8em; }
.choice-opt .choice-letter { width: 48px; height: 48px; font-size: 24px; }

/* Parsons blocks on the stage */
.parsons-preview { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.parsons-preview .p-block { background: var(--code-bg); color: var(--code-text); border-radius: 8px; padding: 7px 16px; font-size: calc(21px * var(--fs)); break-inside: avoid; }
.parsons-preview .p-code { font-size: inherit; }
.parsons-preview.several { display: block; columns: 2; column-gap: 12px; }
.parsons-preview.several .p-block { margin-bottom: 8px; font-size: calc(18px * var(--fs)); }
.parsons-preview.many { display: block; columns: 2; column-gap: 10px; }
.parsons-preview.many .p-block { margin-bottom: 6px; font-size: calc(15px * var(--fs)); padding: 5px 12px; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: 250px minmax(380px, 1fr) minmax(360px, 44%); height: calc(100vh - 60px); }
.slide-list { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
/* only the slides scroll: "New slide" stays in view */
.slide-items { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.slide-item { position: relative; display: flex; gap: 9px; align-items: center; padding: 8px 8px 8px 10px; border-radius: var(--r-md); cursor: pointer; border: 1px solid transparent; }
.slide-item:hover { background: var(--surface-2); }
.slide-item.dragging { opacity: .45; }
.slide-item.is-hidden .t, .slide-item.is-hidden .slide-ico, .slide-item.is-hidden .num { opacity: .5; }
.slide-item .hidden-mark { color: var(--muted); display: inline-flex; }
/* the grip only shows on touch screens, which can't drag and drop */
.slide-item .grip { display: none; color: var(--muted); padding: 6px 0; margin-left: -4px; touch-action: none; cursor: grab; }
@media (pointer: coarse) { .slide-item .grip { display: inline-flex; } }
/* without hover, the actions menu is always visible */
@media (hover: none) { .slide-item .ops { opacity: 1; } }
.slide-item.drop-before::before, .slide-item.drop-after::after { content: ""; position: absolute; left: 4px; right: 4px; height: 3px; border-radius: 2px; background: var(--accent); pointer-events: none; }
.slide-item.drop-before::before { top: -4px; }
.slide-item.drop-after::after { bottom: -4px; }
.slide-item.active { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.slide-item .num { font-size: 12px; color: var(--muted); width: 16px; text-align: right; }
.slide-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex-shrink: 0; }
.slide-item.q .slide-ico { background: var(--accent); color: var(--on-accent); }
.slide-item .warn-dot { color: var(--warn); display: inline-flex; }
.slide-item .t { font-size: 13.5px; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
/* the actions menu only takes room when you point at the row */
.slide-item .ops { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); opacity: 0; }
.slide-item:hover .ops, .slide-item:focus-within .ops, .slide-item .ops:has([aria-expanded="true"]) { opacity: 1; }
.slide-item .ops .menu-btn { padding: 3px 6px; background: var(--surface); }
.add-slide { padding: 10px 12px; border-top: 1px solid var(--border); }
.add-slide .menu-wrap { display: flex; }
.add-slide .menu-btn { flex: 1; }
.menu-kind { display: flex; flex-direction: column; line-height: 1.3; flex: 1; position: relative; padding-right: 22px; }
.menu-kind > span:not(.ico) { font-size: 12.5px; color: var(--muted); }
.menu-kind .menu-check { position: absolute; right: 0; top: 50%; transform: translateY(-50%); color: var(--accent); }
.type-picker { margin-bottom: 6px; }
.type-picker .menu-btn { font-size: 16px; font-weight: 650; padding: 6px 10px 6px 8px; }
.type-picker .menu-btn .ico:first-child { color: var(--accent); }
.type-picker .chev { color: var(--muted); }
.fold { margin-top: 18px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.fold > summary { display: flex; align-items: baseline; gap: 10px; padding: 10px 12px; cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::before { content: "▸"; color: var(--muted); font-size: 12px; transition: transform .12s; }
.fold[open] > summary::before { transform: rotate(90deg); }
.fold-title { font-size: 14px; font-weight: 600; white-space: nowrap; }
.fold-sum { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fold[open] .fold-sum { display: none; }
.fold-body { padding: 0 12px 12px; }
.fold-body > .field-label:first-child { margin-top: 0; }
.form-pane { overflow: auto; padding: 20px 24px 60px; }
.form-pane h2 { margin: 0 0 4px; font-size: 18px; }
.form-pane > p { margin: 0 0 4px; }
.preview-pane { background: var(--surface-2); border-left: 1px solid var(--border); padding: 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.preview-pane > * { flex-shrink: 0; }
.preview-pane .stage-host { aspect-ratio: 16 / 9; width: 100%; border-radius: 8px; box-shadow: var(--shadow); background: #fff; }
.preview-pane h4 { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.preview-pane .alert.row { gap: 8px; }
.preview-bar .seg button { display: inline-flex; align-items: center; gap: 6px; }
.phone-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.phone-frame { width: 390px; max-width: 100%; height: min(760px, calc(100vh - 190px)); min-height: 480px; border: 10px solid #16171d; border-radius: 34px; overflow: hidden; background: var(--bg); box-shadow: var(--shadow); }
.phone-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
/* Python's status only shows while it loads or when it failed */
.topbar .py-status.idle, .topbar .py-status.ready { display: none; }
.student-preview { background: var(--surface); border-radius: var(--r-lg); padding: 14px; box-shadow: var(--shadow); }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.settings-grid .opt { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; }
.settings-grid .opt > span { font-size: 14px; }
.title-input { font-size: 16px; font-weight: 650; border: 1px solid transparent; background: transparent; padding: 6px 8px; border-radius: 8px; min-width: 160px; max-width: 420px; flex: 0 1 420px; }
.title-input:hover { border-color: var(--border); }
.topbar .more-menu .menu-btn { padding: 8px 10px; border-radius: var(--r-md); }
#design-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 8px 10px; border: 2px solid var(--border); border-radius: var(--r-lg); background: var(--surface); color: var(--text); cursor: pointer; text-align: left; font: inherit; }
.theme-card:hover { border-color: var(--border-strong); }
.theme-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-card b { font-size: 14px; margin-top: 6px; }
.theme-card > span { font-size: 12.5px; color: var(--muted); }
.theme-thumb { width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; border: 1px solid var(--border); }
.color-row { gap: 16px; flex-wrap: wrap; }
.color-field { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.color-field input[type="color"] { width: 40px; height: 32px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; }
.logo-preview { height: 36px; max-width: 120px; object-fit: contain; padding: 3px; border: 1px solid var(--border); border-radius: var(--r-sm); background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 12px 12px; }
.topbar .more-menu .menu-btn:hover { background: var(--surface-2); }
.title-input:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.save-state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.save-state.ok::before { content: "✓ "; color: var(--ok); }
.save-state.err { color: var(--bad-ink); font-weight: 600; }
.options-edit { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.option-row { display: flex; align-items: center; gap: 8px; width: 100%; }
.option-row .input { flex: 1; }
.history-list { display: flex; flex-direction: column; gap: 6px; max-height: 50vh; overflow: auto; }
.history-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-md); }
.conflict-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: var(--bad-soft); color: var(--bad-ink); border: 1px solid var(--bad); padding: 10px 14px; border-radius: 12px; z-index: 60; box-shadow: var(--shadow); max-width: calc(100vw - 32px); flex-wrap: wrap; }
/* code input with the editable region highlighted behind the text */
.code-input { position: relative; }
.code-input .backdrop, .code-input textarea { font-family: var(--mono); font-size: 13.5px; line-height: 1.5; padding: 9px 11px; border-width: 1px; white-space: pre-wrap; overflow-wrap: break-word; tab-size: 4; letter-spacing: normal; }
.code-input .backdrop { position: absolute; inset: 0; margin: 0; border: 1px solid transparent; color: transparent; overflow: hidden; pointer-events: none; background: var(--code-bg); border-radius: var(--r-md); }
.code-input textarea { position: relative; background: transparent !important; display: block; }
.code-input mark { background: rgba(58, 100, 255, .3); color: transparent; border-radius: 3px; box-shadow: 0 0 0 1px rgba(111, 141, 255, .6); }
.code-input mark.m { background: #6f8dff; box-shadow: none; }

/* ---------- Notebook import ---------- */
body.nb-open { overflow: hidden; }
.nb-tool { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: grid; grid-template-rows: auto minmax(0, 1fr); }
.nb-head { display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.nb-head-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 20px; flex-shrink: 0; }
.nb-head-title { display: flex; flex-direction: column; min-width: 200px; }
.nb-head-title .title-input { margin-left: -8px; flex: none; width: min(420px, 40vw); }
.nb-kicker { font-size: 12px; color: var(--muted); font-weight: 560; }
.nb-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-left: 8px; }
.nb-control { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); font-weight: 560; }
.nb-select { padding: 5px 8px; font-size: 13.5px; width: auto; color: var(--text); }
.nb-summary { display: flex; gap: 6px 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.nb-over-count { color: var(--warn-ink); font-weight: 650; display: inline-flex; gap: 4px; align-items: center; }
.nb-main { display: grid; grid-template-columns: minmax(520px, 1fr) minmax(360px, 42%); min-height: 0; }
.nb-outline { overflow: auto; padding: 16px 20px 80px; display: flex; flex-direction: column; }
.nb-outline > .alert { margin: 0 0 10px; }
.nb-tips { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.nb-keys { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 18px; }

.nb-slide { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 12px 12px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.nb-slide:hover { border-color: var(--border-strong); }
.nb-slide.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.nb-slide.over { border-left: 4px solid var(--warn); }
.nb-slide.q .nb-num { background: var(--accent); color: var(--on-accent); }
.nb-slide.drop-into { box-shadow: 0 0 0 3px var(--accent); }
.nb-slide-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.nb-num { min-width: 26px; height: 26px; padding: 0 6px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 700; flex-shrink: 0; }
.nb-kind { padding: 2px; flex-shrink: 0; }
.nb-kind button { padding: 3px 9px; font-size: 12.5px; }
.nb-slide-title { flex: 1; min-width: 0; font-weight: 620; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.nb-slide-head .menu-btn { padding: 3px 7px; }
.nb-fill { display: inline-flex; align-items: center; flex-shrink: 0; }
.nb-fill-bar { width: 54px; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; display: block; }
.nb-fill-bar span { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.nb-slide-body { display: grid; grid-template-columns: 192px 1fr; gap: 12px; align-items: start; }
.nb-thumb { width: 192px; height: 108px; border-radius: 6px; border: 1px solid var(--border); background: #fff; }
.nb-thumb .stage { transform: translate(-50%, -50%) scale(.15); pointer-events: none; border-radius: 0; }
.nb-cells { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nb-notes-label { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 6px 0 0 4px; }

.nb-cell { position: relative; display: flex; align-items: center; gap: 7px; padding: 4px 6px; border-radius: 8px; border: 1px solid transparent; min-width: 0; cursor: pointer; }
.nb-cell:hover { background: var(--surface-2); }
.nb-cell.selected { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.nb-cell.dragging { opacity: .4; }
.nb-cell.drop-before::before, .nb-cell.drop-after::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; border-radius: 3px; background: var(--accent); }
.nb-cell.drop-before::before { top: -3px; }
.nb-cell.drop-after::after { bottom: -3px; }
.nb-grip { color: var(--placeholder); cursor: grab; display: inline-flex; }
.nb-tag { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; flex-shrink: 0; min-width: 34px; text-align: center; background: var(--surface-2); color: var(--muted); }
.nb-tag.code { background: var(--code-bg); color: var(--code-text); border: 1px solid var(--code-border); }
.nb-tag.head { background: var(--accent-soft); color: var(--accent-ink); }
.nb-tag.note { background: var(--warn-soft); color: var(--warn-ink); }
.nb-src { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.nb-src.mono { font-family: var(--mono); font-size: 12.5px; }
.nb-more { color: var(--muted); font-size: 12px; font-family: var(--font); }
.nb-ops { display: flex; gap: 1px; opacity: 0; flex-shrink: 0; }
.nb-cell:hover .nb-ops, .nb-cell.selected .nb-ops, .nb-cell:focus-within .nb-ops { opacity: 1; }
.nb-op { border: 0; background: transparent; color: var(--muted); width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.nb-op:hover { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.nb-op.on { color: var(--warn-ink); }

/* between two slides: merge them */
.nb-join { height: 14px; position: relative; display: grid; place-items: center; }
.nb-join-btn { opacity: 0; display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; border-radius: 99px; padding: 1px 10px; cursor: pointer; position: relative; z-index: 1; }
.nb-join:hover .nb-join-btn, .nb-join-btn:focus-visible { opacity: 1; }
.nb-join-btn:hover { color: var(--accent-ink); border-color: var(--accent); }

.nb-excluded { margin-top: 18px; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.nb-excluded.drop-into { border-color: var(--accent); background: var(--accent-soft); }
.nb-excluded-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; color: var(--muted); }
.nb-excluded-head b { color: var(--text); font-size: 14px; }
.nb-excluded .nb-ops { opacity: 1; }

.nb-preview { background: var(--surface-2); border-left: 1px solid var(--border); padding: 20px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.nb-preview .stage-host { aspect-ratio: 16 / 9; width: 100%; flex-shrink: 0; border-radius: 8px; box-shadow: var(--shadow); background: #fff; }
.nb-preview-info { display: flex; flex-direction: column; gap: 4px; }
.nb-preview-info .alert { margin-top: 4px; }
.nb-preview-notes h4 { margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.nb-preview-notes .small { white-space: pre-wrap; }
/* slides are measured on a full-size stage that nobody sees */
.nb-measure { position: fixed; left: -20000px; top: 0; width: 1280px; height: 720px; visibility: hidden; pointer-events: none; }

@media (max-width: 1000px) {
  .nb-main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .nb-preview { order: -1; border-left: 0; border-bottom: 1px solid var(--border); max-height: 42vh; }
}
@media (max-width: 640px) {
  .nb-slide-body { grid-template-columns: 1fr; }
  .nb-thumb { display: none; }
}

/* ---------- Presenter ---------- */
body.presenter { background: var(--dk-bg); color: var(--dk-text); overflow: hidden; }
.pres { display: grid; grid-template-rows: 1fr auto; grid-template-columns: minmax(0, 1fr); height: 100vh; height: 100dvh; transition: margin-right .22s ease; }
/* the answers panel makes room instead of covering the slide */
body.drawer-open:not(.screen-mode) .pres { margin-right: min(480px, 92vw); }
body.nav-open:not(.screen-mode) .pres { margin-left: min(300px, 85vw); }
.pres-main { display: grid; grid-template-columns: 1fr; min-height: 0; }
body.side-open .pres-main { grid-template-columns: 1fr minmax(300px, 27vw); }
.pres .stage-host { margin: 18px 18px 0; }
.pres .stage { border-radius: 10px; box-shadow: var(--shadow-lg); }
.pres-bar { display: flex; align-items: center; gap: 8px; padding: 12px 18px; flex-wrap: wrap; }
.pres-bar .btn, .drawer .btn, .console-side .btn { background: var(--dk-2); border-color: var(--dk-border); color: var(--dk-text); }
.pres-bar .btn:hover, .drawer .btn:hover { background: var(--dk-3); }
.pres-bar .btn.on { background: var(--dk-3); border-color: #4a4c58; }
.pres-bar .btn.btn-primary, .drawer .btn.btn-primary { background: #2350e6; border-color: #2350e6; color: #fff; }
.pres-bar .btn.btn-primary:hover { background: #1a3fc2; }
.pres-bar .counter { color: var(--dk-muted); font-size: 14px; min-width: 60px; text-align: center; background: none; border: 1px solid transparent; border-radius: var(--r-md); padding: 7px 8px; cursor: pointer; font-family: inherit; }
.pres-bar .counter:hover, .pres-bar .counter.on { background: var(--dk-2); border-color: var(--dk-border); color: var(--dk-text); }
.pres-bar .pill { display: inline-flex; align-items: center; gap: 8px; background: var(--dk-2); border: 1px solid var(--dk-border); padding: 7px 12px; border-radius: var(--r-md); font-size: 14px; color: #c9cad3; }
button.pill { cursor: pointer; }
.pres-bar .pill b { color: #fff; font-family: var(--mono); letter-spacing: .04em; }
.bar-actions { display: contents; }
.pres-bar .chip-contrast { color: var(--marker); border-color: #5a4a10; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--marker); box-shadow: 0 0 0 3px rgba(255, 212, 59, .25); flex-shrink: 0; }
.live-dot.off { background: var(--bad); box-shadow: 0 0 0 3px rgba(194, 54, 111, .25); }

.console-side { background: var(--dk-1); border: 1px solid var(--dk-border); margin: 18px 18px 0 0; border-radius: 12px; padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.side-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 4px; }
.side-clock { display: flex; flex-direction: column; line-height: 1.2; }
.side-clock b { font: 700 28px var(--mono); }
.side-clock .muted { color: var(--dk-muted); font-size: 13px; }
.side-label { font-size: 12px; font-weight: 700; color: var(--dk-muted); margin-top: 12px; text-transform: uppercase; letter-spacing: .06em; }
.console-side .notes { font-size: 20px; line-height: 1.5; white-space: pre-wrap; }
.console-side .muted { color: var(--dk-muted); }
.console-side .mini-out { background: var(--dk-2); color: var(--dk-text); }
.console-side .next-thumb { aspect-ratio: 16 / 9; width: 100%; margin: 0; border-radius: 8px; flex-shrink: 0; }
.next-thumb .stage { border-radius: 0; }

/* centred, but a panel taller than the screen scrolls instead of losing its top */
.overlay { position: fixed; inset: 0; background: rgba(8, 9, 14, .78); backdrop-filter: blur(6px); display: flex; overflow: auto; z-index: 50; padding: 30px; }
.overlay > * { margin: auto; }
.overlay > .modal { width: min(560px, 100%); }
.blackout { position: fixed; inset: 0; background: #000; z-index: 70; display: grid; place-items: end center; padding-bottom: 20px; color: #444; font-size: 13px; cursor: pointer; }
/* the join screen is seen by the room: always the light projector colours */
.join-panel { --accent: #2350e6; --on-accent: #fff; background: #fff; color: #16171d; border-radius: 24px; padding: 44px 56px; display: flex; gap: 52px; align-items: center; box-shadow: var(--shadow-lg); max-width: 1100px; }
.join-panel .qr { width: 340px; height: 340px; flex-shrink: 0; }
.join-panel .qr svg { width: 100%; height: 100%; }
.join-panel h2 { font-size: 32px; margin: 0 0 8px; }
.join-panel .jp-text { font-size: 22px; color: #5d5f6a; }
.join-panel .url { font-size: 32px; font-weight: 700; color: #16171d; word-break: break-all; }
.join-panel .code { font-family: var(--mono); font-size: 88px; font-weight: 800; letter-spacing: .02em; line-height: 1.05; display: inline-block; box-shadow: inset 0 -14px 0 var(--marker); padding: 0 6px; }
.jp-joined { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-size: 20px; color: #5d5f6a; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(480px, 92vw); background: var(--dk-1); border-left: 1px solid var(--dk-3); z-index: 40; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .22s ease; color: var(--dk-text); }
.drawer.open { transform: none; }
.drawer header { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--dk-3); }
.drawer header h3 { margin: 0; font-size: 17px; }
.drawer .muted { color: var(--dk-muted); }
.drawer .seg { background: var(--dk-2); }
.drawer .seg button { color: var(--dk-muted); }
.drawer .seg button.on { background: var(--dk-3); color: #fff; }
/* the slide list while presenting: the editor's rows on the dark console */
.slide-nav { position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 85vw); background: var(--dk-1); border-right: 1px solid var(--dk-3); z-index: 40; display: flex; flex-direction: column; transform: translateX(-100%); visibility: hidden; transition: transform .22s ease, visibility .22s; color: var(--dk-text); }
.slide-nav.open { transform: none; visibility: visible; }
.slide-nav header { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--dk-3); }
.slide-nav header h3 { margin: 0; font-size: 17px; }
.slide-nav .btn { background: var(--dk-2); border-color: var(--dk-border); color: var(--dk-text); }
.slide-nav .slide-item:hover { background: var(--dk-2); }
.slide-nav .slide-item.active { background: var(--dk-3); border-color: #4a4c58; }
.slide-nav .slide-item .num { color: var(--dk-muted); width: 20px; }
.slide-nav .slide-ico { background: var(--dk-2); color: var(--dk-muted); }
.slide-nav .slide-item.q .slide-ico { background: #2350e6; color: #fff; }
.drawer .list { overflow: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.drawer-tools { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--dk-3); color: var(--dk-muted); flex-wrap: wrap; }
.ans-item { background: var(--dk-2); border: 1px solid var(--dk-border); border-radius: var(--r-md); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.ans-item:hover { border-color: #4a4c58; }
.ans-item.is-hidden pre { filter: blur(4px); opacity: .6; }
.ans-item pre { margin: 0; font-family: var(--mono); font-size: 14px; color: var(--dk-text); white-space: pre-wrap; word-break: break-word; max-height: 96px; overflow: hidden; }
.ans-item pre.behaviour { color: #ffcf8a; }
.ans-item .meta { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--dk-muted); flex-wrap: wrap; }
.btn.vote-pick { padding: 2px 8px; font-size: 12px; }
.btn.vote-pick.on { background: #2350e6; border-color: #2350e6; color: #fff; }
.fb-indicator { color: #a8bcff; display: inline-flex; align-items: center; gap: 4px; }

.review { background: var(--surface); color: var(--text); border-radius: 18px; width: min(1180px, 96vw); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); }
.review header { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.review header h3 { margin: 0; font-size: 20px; }
.review header .badge { font-size: 14px; }
.review .body { padding: 22px 24px; overflow: auto; display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; }
.review pre.code, .review .code-edit .field { font-size: 19px; }
.review .output pre { font-size: 17px; max-height: 50vh; }
.review h4 { margin: 0 0 8px; font-size: 13px; font-weight: 650; color: var(--muted); }
/* the spotlight is seen by the room, like the slides: always the light projector colours */
.review.spotlight {
  --surface: #fff; --surface-2: #f0f0eb; --border: #e3e3dc; --text: #16171d; --muted: #5d5f6a;
  --ok: #0f8a6c; --ok-soft: #d9f3ec; --ok-ink: #0b5e4a; --warn: #e08a00; --warn-soft: #fff1d6; --warn-ink: #7a4a00;
  --bad: #c2366f; --bad-soft: #fbe3ed; --bad-ink: #8f1f4e; --accent-soft: #e8eeff; --accent-ink: #15318f; --code-border: transparent;
  width: min(1400px, 96vw);
}
.review.spotlight header h3 { font-size: 30px; }
.review.spotlight header .badge { font-size: 20px; padding: 4px 12px; }
.review.spotlight pre.code { font-size: 26px; }
.review.spotlight .output pre { font-size: 24px; }
.variant-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.variant-tabs .btn.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.review-feedback { display: flex; flex-direction: column; gap: 8px; }
.fb-rule { display: flex; align-items: center; gap: 10px; background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--r-md); padding: 8px 10px; font-size: 14px; }
.fb-rule > div { flex: 1; white-space: pre-wrap; }

/* the audience screen: only the slide */
body.screen-mode .pres { grid-template-rows: 1fr; }
body.screen-mode .pres-bar, body.screen-mode .console-side { display: none; }
body.screen-mode .pres .stage-host { margin: 0; }
body.screen-mode .pres .stage { border-radius: 0; box-shadow: none; }

/* ---------- Student ---------- */
body.student { background: var(--bg); }
.s-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.s-top .logo-mark { width: 26px; height: 26px; }
.s-top .title { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.slides-btn { position: relative; padding: 5px 8px; }
.count-dot { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.s-livebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; background: var(--accent-soft); color: var(--accent-ink); font-size: 14px; position: sticky; top: 49px; z-index: 4; flex-wrap: wrap; }
.s-main { max-width: 760px; margin: 0 auto; padding: 18px 16px calc(90px + env(safe-area-inset-bottom)); }
.s-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); }
.s-card h1 { font-size: 24px; margin: 0 0 10px; letter-spacing: -.02em; line-height: 1.2; }
.s-card.layout-title { text-align: center; padding: 48px 20px; }
.s-card.layout-title h1 { font-size: 30px; }
.title-meta { margin: 14px 0 0; font-size: 14px; }
.s-card .md { font-size: 16px; }
.s-card .md p:first-child { margin-top: 0; }
.s-card .code-edit { margin: 14px 0 4px; }
.s-card.waiting { text-align: center; padding: 48px 20px; }
.pulse-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--marker); margin: 0 auto 16px; animation: pulse 1.4s infinite; }
.q-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.q-head .q-label { margin-bottom: 0; }
.q-timer { display: inline-flex; align-items: center; gap: 6px; font: 700 15px var(--mono); color: var(--accent-ink); background: var(--accent-soft); border-radius: 99px; padding: 3px 10px; }
.q-timer.urgent { color: var(--bad-ink); background: var(--bad-soft); }
.s-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.s-actions .btn { flex: 1; min-width: 120px; padding: 12px 16px; font-size: 15px; }
.feedback { margin-top: 14px; padding: 14px 16px; border-radius: 12px; display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.feedback .fb-icon { width: 22px; height: 22px; margin-top: 1px; }
.feedback.correct { background: var(--ok-soft); color: var(--ok-ink); }
.feedback.wrong { background: var(--warn-soft); color: var(--warn-ink); }
.feedback.error { background: var(--bad-soft); color: var(--bad-ink); }
.feedback.submitted, .feedback.ungraded { background: var(--accent-soft); color: var(--accent-ink); }
.feedback.locked { background: var(--surface-2); color: var(--muted); }
.feedback .mini-out { color: inherit; }
.s-section-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; color: var(--muted); margin: 16px 0 6px; }
.solution { margin-top: 16px; padding: 12px 14px; border: 2px solid var(--ok); border-radius: 12px; }
.solution .s-section-label { color: var(--ok-ink); margin-top: 0; }
.privacy { margin: 16px 0 0; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.join-card { width: 100%; max-width: 400px; text-align: center; padding: 32px 26px; color: var(--text); }
.join-card h1 { font-size: 24px; margin: 16px 0 4px; }
.join-card > p { margin: 0; }
.join-card .input { text-align: center; font-size: 28px; letter-spacing: .2em; font-family: var(--mono); padding: 12px; margin: 20px 0 12px; }
.py-status { font-size: 12px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.py-status .d { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); flex-shrink: 0; }
.py-status.ready .d { background: var(--ok); }
.py-status.loading .d { background: var(--warn); animation: pulse 1s infinite; }
.py-status.failed .d { background: var(--bad); }
.choice-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.choice-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--border); border-radius: 12px; cursor: pointer; font-size: 16px; }
.choice-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-item input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex-shrink: 0; }
/* earlier slides, as a sheet from the bottom */
.sheet-overlay { position: fixed; inset: 0; background: rgba(8, 9, 14, .5); z-index: 90; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: min(560px, 100%); max-height: 80vh; overflow: auto; background: var(--surface); color: var(--text); border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-lg); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 8px; }
.sheet-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.sheet-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; font-size: 15px; }
.sheet-item:hover, .sheet-item:focus-visible { background: var(--surface-2); }
.sheet-item .num { width: 22px; color: var(--muted); font-size: 13px; text-align: right; }
.sheet-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Parsons problems ---------- */
.parsons { display: flex; flex-direction: column; gap: 4px; margin: 10px 0 12px; }
.p-program { list-style: none; margin: 0; padding: 8px; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--r-md); min-height: 56px; display: flex; flex-direction: column; gap: 4px; counter-reset: pline; }
.p-program.drop-end::after { content: ""; height: 3px; border-radius: 3px; background: #6f8dff; }
.p-line { display: flex; align-items: center; gap: 6px; background: rgba(58, 100, 255, .16); border: 1px solid rgba(111, 141, 255, .5); border-radius: 8px; padding: 4px 6px 4px 4px; color: var(--code-text); touch-action: none; }
.p-line.dragging { opacity: .5; }
.p-line.drop-before { box-shadow: 0 -3px 0 #6f8dff; }
.p-line::before { counter-increment: pline; content: counter(pline); font-family: var(--mono); font-size: 11px; color: var(--code-comment); width: 14px; text-align: right; flex-shrink: 0; }
.p-grip { color: var(--code-comment); cursor: grab; display: inline-flex; padding: 6px 2px; touch-action: none; }
.p-grip .ico { width: 16px; height: 16px; }
/* indentation as guides instead of leading spaces: lines stay readable on a narrow screen */
.p-code { font-family: var(--mono); font-size: 14px; white-space: pre-wrap; word-break: break-word; flex: 1; min-width: 0; padding-left: calc(var(--indent, 0) * 2.2ch); background-image: repeating-linear-gradient(to right, rgba(111, 141, 255, .45) 0 1px, transparent 1px 2.2ch); background-size: calc(var(--indent, 0) * 2.2ch) 100%; background-repeat: no-repeat; line-height: 1.5; }
.p-ops { display: flex; gap: 2px; flex-shrink: 0; }
.p-ops button { border: 0; background: rgba(255, 255, 255, .08); color: #c9cad3; width: 34px; height: 34px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.p-ops button:hover:not(:disabled) { background: rgba(255, 255, 255, .18); }
.p-ops button:disabled { opacity: .3; cursor: default; }
.p-empty { color: var(--code-comment); font-size: 14px; padding: 12px; text-align: center; }
/* the blocks to choose from use the code look as well, so a block doesn't change when it moves */
.p-pool { display: flex; flex-direction: column; gap: 6px; }
.p-pool .p-block { display: flex; text-align: left; background: var(--code-bg); border: 1px dashed #4a4c58; border-radius: 8px; padding: 9px 12px; cursor: pointer; color: var(--code-text); min-height: 44px; align-items: center; }
.p-pool .p-block:hover:not(:disabled) { border-style: solid; border-color: #6f8dff; }
.p-pool .p-block:disabled { opacity: .6; cursor: default; }

/* ---------- Fix the bug ---------- */
/* code with line numbers (slides, snippets) */
pre.bug-code .bl { display: flex; gap: 14px; padding: 0 6px; border-radius: 4px; }
pre.bug-code .ln, .bug-edit .ln { color: var(--code-comment); min-width: 2ch; text-align: right; flex-shrink: 0; user-select: none; }
pre.bug-code .lc { white-space: pre-wrap; word-break: break-word; min-width: 0; }
pre.bug-code .bl.picked { background: rgba(255, 99, 99, .2); box-shadow: inset 3px 0 #ff6b6b; }
pre.bug-code .bl.picked .lc { text-decoration: line-through; text-decoration-color: rgba(255, 140, 140, .7); }
pre.bug-code .bl.picked:not(:has(+ .fix)) .lc { text-decoration: none; }
pre.bug-code .bl.fix { background: rgba(47, 191, 149, .2); box-shadow: inset 3px 0 #2fbf95; }
/* the student's input: every line is a toggle */
.bug-edit { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 12px; padding: 8px; background: var(--code-bg); border: 1px solid var(--code-border); border-radius: var(--r-md); }
.bug-line { display: flex; gap: 12px; align-items: baseline; width: 100%; text-align: left; border: 0; background: transparent; color: var(--code-text); font: inherit; padding: 6px 8px; border-radius: 6px; cursor: pointer; min-height: 36px; }
.bug-line .lc { font-family: var(--mono); font-size: 14px; white-space: pre-wrap; word-break: break-word; background: none; padding: 0; }
.bug-line:hover:not(:disabled) { background: rgba(255, 255, 255, .06); }
.bug-line.picked { background: rgba(255, 99, 99, .2); box-shadow: inset 3px 0 #ff6b6b; }
.bug-line:disabled { cursor: default; }
.bug-line:focus-visible { outline: 2px solid #6f8dff; outline-offset: -2px; }
.bug-fix-row { display: flex; gap: 12px; align-items: center; padding: 2px 8px 6px; }
.bug-fix-row .ln { color: #2fbf95; }
.bug-fix { flex: 1; min-width: 0; font-family: var(--mono); font-size: 14px; white-space: pre; }

/* ---------- Predict the output, snippets, votes ---------- */
.prediction-field { font-family: var(--mono) !important; font-size: 15px; min-height: 90px; }
pre.prediction { color: var(--code-text); white-space: pre-wrap; }
pre.snippet { font-size: 14px; max-height: 220px; }
.vote-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.vote-card { display: flex; flex-direction: column; gap: 8px; text-align: left; border: 2px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px; cursor: pointer; transition: border-color .12s; color: var(--text); }
.vote-card:hover:not(:disabled) { border-color: var(--accent); }
.vote-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.vote-card:disabled { cursor: default; }
.vote-card.correct, .vote-cand.correct { border-color: var(--ok); }
.vote-card.incorrect, .vote-cand.incorrect { opacity: .78; }
.vote-card pre.snippet.in-context { font-size: 13px; }
.vote-head { display: flex; align-items: center; gap: 8px; }
.vote-letter { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 800; }
.stage-vote h1 { font-size: 40px; margin-bottom: 6px; }
.vote-sub { color: var(--muted); font-size: 20px; margin-bottom: 20px; }
.vote-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; flex: 1; min-height: 0; }
.vote-grid.n2 { grid-template-rows: 1fr; }
.vote-cand { border: 3px solid var(--border); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }
.vote-cand .vote-letter { width: 44px; height: 44px; font-size: 24px; border-radius: 10px; }
.vote-cand .badge { font-size: 18px; padding: 4px 12px; }
.vote-cand pre.snippet { font-size: 20px; line-height: 1.4; flex: 1; min-height: 0; max-height: none; overflow: hidden; }
.vote-cand pre.snippet.in-context { font-size: 18px; line-height: 1.35; }
.vote-grid.n3 .vote-cand pre.snippet.in-context, .vote-grid.n4 .vote-cand pre.snippet.in-context { font-size: 14px; line-height: 1.3; }
.vote-grid.n3 .vote-cand pre.snippet, .vote-grid.n4 .vote-cand pre.snippet { font-size: 16px; padding: 10px 14px; }
.vote-grid.n3 .vote-cand, .vote-grid.n4 .vote-cand { gap: 8px; padding: 12px; }
.vote-grid.n3 .vote-bars, .vote-grid.n4 .vote-bars { gap: 3px; }
.vote-bars { display: flex; flex-direction: column; gap: 6px; }
.vote-bar-row { display: flex; align-items: center; gap: 10px; font-size: 20px; }
.vote-round { color: var(--muted); font-size: 15px; width: 26px; }
.vote-bar { flex: 1; height: 16px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.vote-bar > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.vote-cand.correct .vote-bar > div { background: var(--ok); }
.vote-bar-row b { width: 56px; text-align: right; }
.lecturer-feedback { margin-top: 14px; }
.lf-item { background: var(--accent-soft); color: var(--accent-ink); border-radius: 12px; padding: 12px 14px; margin-top: 6px; white-space: pre-wrap; border-left: 4px solid var(--accent); }

/* ---------- Code cells on normal slides ---------- */
.cell { margin: .5em 0; }
.cell-body { display: flex; flex-direction: column; }
.cell-code-wrap { position: relative; display: flex; min-height: 0; }
.cell-code-wrap pre.cell-code { margin: 0; flex: 1; min-width: 0; min-height: 0; overflow: auto; }
.cell-code-wrap pre.cell-code:focus-within { box-shadow: 0 0 0 2px #6f8dff; }
.cell-code code[contenteditable] { display: block; outline: none; min-height: 1.5em; caret-color: #fff; cursor: text; padding-right: 150px; }
.cell-bar { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.cell-btn { border: 1px solid var(--dk-border); background: var(--dk-2); color: var(--dk-text); border-radius: 7px; padding: 4px 10px; font: 600 13px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.cell-btn:hover:not(:disabled) { background: var(--dk-3); }
.cell-btn.primary { background: #2350e6; border-color: #2350e6; color: #fff; }
.cell-btn.primary:hover:not(:disabled) { background: #1a3fc2; }
.cell-btn.primary .ico { color: var(--marker); }
.cell-btn .spinner { width: 12px; height: 12px; }
.cell-out { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.cell-out[hidden] { display: none !important; }
.cell-out-head { display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 12px; background: var(--surface-2); font-size: 12px; font-weight: 700; color: var(--muted); }
.cell-out-head .spacer { flex: 1; }
.cell-out-head .cell-btn { background: var(--surface); color: var(--text); border-color: var(--border); }
.cell-out-head .cell-btn:hover { background: var(--surface-2); }
.cell-out-head .cell-btn.on { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.cell-layouts { display: flex; gap: 4px; }
.cell-out .output { border: 0; border-radius: 0; }
/* output inside Markdown: one light output card, not a dark code block inside it */
.md .cell-out pre { background: none; color: var(--text); border: 0; border-radius: 0; margin: 0; }
.md .cell-out .stderr { background: var(--bad-soft); color: var(--bad-ink); }
.s-card .cell-out .output pre { max-height: 50vh; }
.stage .cell-btn { font-size: 16px; padding: 6px 12px; border-radius: 8px; }
.stage .cell-out-head { font-size: 15px; padding: 6px 8px 6px 14px; }
.stage .cell-out .output pre { font-size: calc(20px * var(--fs)); max-height: 230px; padding: 12px 16px; }
.stage .cell-code code[contenteditable] { padding-right: 200px; }
/* layouts for long output: the active cell takes over the slide */
.stage.cell-mode { padding-top: 34px; }
.stage.cell-mode > h1 { font-size: 30px; margin-bottom: 14px; }
.stage.cell-mode .md { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage.cell-mode .md > :not(.cell.active) { display: none; }
.stage.cell-mode .cell.active { flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0; }
.stage.cell-mode .cell.active .cell-body { flex: 1; min-height: 0; }
.stage.cell-mode .cell-out { flex: 1; min-height: 0; }
.stage.cell-mode .cell-out .output { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.stage.cell-mode .cell-out .output pre { max-height: none; min-height: 0; }
.stage.cell-mode .cell-out .output pre.stdout { flex: 1; overflow: auto; }
.stage.cell-focus .cell-code-wrap { max-height: 42%; flex-shrink: 0; }
.stage.cell-side .cell.active .cell-body { flex-direction: row; gap: 16px; }
.stage.cell-side .cell-code-wrap { flex: 1; min-width: 0; }
.stage.cell-side .cell-out { margin-top: 0; min-width: 0; }
.stage.cell-output .cell.active .cell-code-wrap { display: none; }
.stage.cell-output .cell-out { margin-top: 0; }
.stage.cell-output .cell-out .output pre { font-size: calc(24px * var(--fs)); }

/* ---------- Results page ---------- */
.result-card { padding: 18px 20px; margin-bottom: 14px; }
.result-card h2 { margin: 0 0 8px; font-size: 20px; }
.result-stats { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.result-stats b { font-size: 26px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.result-card details { margin-top: 12px; }
.result-card summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.result-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-top: 10px; }
.result-group .meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; }

/* ---------- Account & login ---------- */
.admin-card { padding: 18px 20px; margin-bottom: 16px; }
.admin-card h2 { font-size: 18px; margin: 0 0 12px; }
.admin-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.admin-form > div { flex: 1 1 220px; }
.admin-form .field-label { margin-top: 0; }
.stats-row { display: flex; flex-wrap: wrap; gap: 26px; }
.stats-row .stat { display: flex; flex-direction: column; }
.stats-row .stat b { font-size: 20px; }
.table-wrap { overflow-x: auto; }
table.users { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
table.users th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; }
table.users th, table.users td { padding: 9px 8px; border-top: 1px solid var(--border); }
table.users .num { text-align: right; }
table.users .actions-cell { text-align: right; }
table.users tr.disabled td { color: var(--muted); }
table.users tr.disabled td:first-child, table.users tr.disabled td:nth-child(2) { text-decoration: line-through; }

body.auth { background: var(--bg); }
.auth-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 22px; }
.auth-logo .logo-mark { width: 36px; height: 36px; border-radius: 10px; }
.auth-logo .wordmark { font-size: 22px; }
.auth-card { width: 100%; max-width: 420px; padding: 28px; }
.auth-card h1 { font-size: 24px; margin: 0 0 6px; }
.auth-card > p { margin: 0 0 6px; }
.auth-card .btn-block { margin-top: 18px; }
.auth-card .alert { margin-top: 12px; }

/* ---------- Landing page ---------- */
body.landing { background: var(--bg); }
.landing .topbar { background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.l-construction { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; text-align: center; }
.l-construction h1 { font-size: 32px; letter-spacing: -.03em; margin: 0; }
.l-construction .btn { padding: 11px 26px; font-size: 16px; }
.l-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 48px; align-items: center; padding-top: 56px; padding-bottom: 40px; }
.l-hero h1 { font-size: 52px; line-height: 1.05; letter-spacing: -.045em; margin: 0 0 18px; }
.l-lead { font-size: 19px; color: var(--muted); margin: 0 0 26px; max-width: 520px; }
.l-join { padding: 16px; max-width: 420px; margin-bottom: 14px; }
.l-join label { display: block; font-weight: 650; margin-bottom: 8px; }
.l-join .input { font-family: var(--mono); font-size: 22px; letter-spacing: .12em; }
.l-join .btn { padding: 11px 22px; font-size: 16px; }
.l-visual { position: relative; padding: 0 0 90px 70px; }
.l-stage { aspect-ratio: 16 / 9; width: 100%; border-radius: 12px; box-shadow: var(--shadow-lg); background: #fff; }
.l-phone { position: absolute; left: 0; bottom: 0; width: 190px; border-radius: 30px; background: #16171d; padding: 9px; box-shadow: var(--shadow-lg); }
.l-phone-screen { border-radius: 22px; overflow: hidden; background: var(--bg); padding: 10px; font-size: 12px; }
.l-phone .s-card { padding: 12px; border-radius: 12px; }
.l-phone .s-card h1 { font-size: 15px; margin-bottom: 8px; }
.l-phone .q-label { font-size: 10px; margin-bottom: 4px; }
.l-phone .code-edit { margin: 6px 0; }
.l-phone pre.code { font-size: 9px; padding: 8px; white-space: pre-wrap; }
.l-phone .code-edit .field { font-size: 9px; }
.l-phone .feedback { font-size: 11px; padding: 8px; margin-top: 8px; gap: 6px; }
.l-phone .feedback .fb-icon { width: 14px; height: 14px; }
.l-section { padding-top: 40px; padding-bottom: 20px; }
.l-section h2 { font-size: 28px; margin: 0 0 18px; }
.l-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; counter-reset: step; }
.l-steps li { display: flex; flex-direction: column; gap: 6px; padding: 18px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.l-steps li::before { counter-increment: step; content: counter(step); width: 30px; height: 30px; border-radius: 9px; background: var(--code-bg); color: var(--marker); font: 700 15px var(--mono); display: grid; place-items: center; margin-bottom: 4px; }
.l-steps span { color: var(--muted); }
.l-types { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.l-type { padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.l-type h3 { margin: 4px 0 0; font-size: 17px; }
.l-type p { margin: 0; flex: 1; }
.l-type pre.code { font-size: 12.5px; }
.l-type-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); }
.l-type-icon .ico { width: 20px; height: 20px; }
.l-split { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.l-split h2 { font-size: 22px; margin-bottom: 8px; }
.l-split p { color: var(--muted); margin: 0; font-size: 16px; }
.l-alpha { margin-top: 40px; padding: 26px 28px; }
.l-alpha h2 { font-size: 22px; margin-bottom: 6px; }
.l-alpha p { margin: 0; color: var(--muted); }
.l-footer { display: flex; align-items: center; gap: 16px; padding-top: 40px; padding-bottom: 40px; font-size: 14px; flex-wrap: wrap; }
.prose { max-width: 720px; }
.prose h1 { font-size: 32px; letter-spacing: -.03em; }
.prose h2 { font-size: 20px; margin-top: 28px; }
.prose li { margin-bottom: 6px; }

/* ---------- Slide design: the presentation's theme and text size (set in the editor's Design panel) ---------- */
[data-stage-size="large"] .stage { --fs: 1.12; }
[data-stage-size="larger"] .stage { --fs: 1.25; }

/* Paper: warm off-white with serif titles */
[data-stage-theme="paper"] .stage {
  --surface: #fbf8f1; --surface-2: #f1ebdd; --border: #e2d9c6; --border-strong: #b9ad95; --text: #2b2620; --muted: #6a6256;
  --accent: #b0441b; --accent-soft: #f8e3d8; --accent-ink: #7a2a0d;
}
[data-stage-theme="paper"] .stage h1 { font-family: Georgia, "Iowan Old Style", "Times New Roman", serif; font-weight: 700; letter-spacing: -.01em; }
[data-stage-theme="paper"] .join-strip { background: var(--surface-2); border-color: var(--border); }

/* Midnight: dark slides, for dim rooms */
[data-stage-theme="midnight"] .stage {
  --surface: #12141c; --surface-2: #1c1f2a; --border: #2c3040; --border-strong: #4a4f63; --text: #eef0f6; --muted: #a3a8b8;
  --accent: #8aa6ff; --accent-soft: #1f2a4d; --accent-ink: #c7d4ff; --on-accent: #0b1020;
}
/* Dark slides: Midnight, and Custom with a dark background */
:is([data-stage-theme="midnight"], [data-stage-dark]) .stage {
  color-scheme: dark;
  --ok: #3ccf9f; --ok-soft: #123329; --ok-ink: #8de6c9; --warn: #f0a12a; --warn-soft: #3a2b10; --warn-ink: #ffd18a;
  --bad: #e8609a; --bad-soft: #3b1626; --bad-ink: #ffadcb; --code-bg: #090a0f; --code-border: var(--border);
}
:is([data-stage-theme="midnight"], [data-stage-dark]) .join-strip { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
:is([data-stage-theme="midnight"], [data-stage-dark]) .join-strip :is(b, .jc) { color: var(--text); }
:is([data-stage-theme="midnight"], [data-stage-dark]) .join-strip .qr { background: #fff; padding: 3px; border-radius: 4px; }
/* QR codes need a light background: the join card stays light */
:is([data-stage-theme="midnight"], [data-stage-dark]) .title-join { --text: #16171d; --muted: #5d5f6a; --border: #e3e3dc; --border-strong: #b8b8ae; color: var(--text); box-shadow: none; }
:is([data-stage-theme="midnight"], [data-stage-dark]) .res-bar::after { background: var(--border); }

/* Custom: the lecturer's text, band and background colours (set by applyDesign() in render.js), and a logo in the top-right corner.
   The other colours are mixed from those three, so they suit any choice. */
[data-stage-theme="custom"] .stage {
  --surface: var(--custom-bg); --text: var(--custom-text);
  --surface-2: color-mix(in srgb, var(--custom-text) 7%, var(--custom-bg));
  --border: color-mix(in srgb, var(--custom-text) 14%, var(--custom-bg));
  --border-strong: color-mix(in srgb, var(--custom-text) 35%, var(--custom-bg));
  --muted: color-mix(in srgb, var(--custom-text) 68%, var(--custom-bg));
  --accent: var(--custom-band); --on-accent: var(--custom-on-band);
  --accent-soft: color-mix(in srgb, var(--custom-band) 16%, var(--custom-bg));
  --accent-ink: color-mix(in srgb, var(--custom-band) 65%, var(--custom-text));
}
[data-stage-theme="custom"] .stage::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 14px; background: var(--custom-band); }
[data-stage-theme="custom"] .stage::after {
  content: ""; position: absolute; top: 22px; right: 24px; width: 180px; height: 52px; pointer-events: none;
  background: var(--custom-logo) no-repeat right top / contain;
}

/* ---------- High-contrast projector theme (C in the presenter) ---------- */
:root[data-theme="contrast"] .stage, :root[data-theme="contrast"] .review.spotlight {
  --text: #000; --muted: #24252c; --border: #7d7f8a; --border-strong: #3d3f48; --surface-2: #d9dbe2; --accent: #1638c4; --accent-ink: #0c227d;
  --ok: #0a6e55; --warn: #b86e00; --bad: #a3205a;
}
:root[data-theme="contrast"] .stage { font-weight: 500; }
:root[data-theme="contrast"] .stage .q-label { color: #0c227d; }
:root[data-theme="contrast"] .stage pre.code, :root[data-theme="contrast"] .stage .md pre, :root[data-theme="contrast"] .parsons-preview .p-block { background: #000; font-size: 110%; }
:root[data-theme="contrast"] .stage .blank { background: #000; border: 0; outline: 3px solid var(--marker); color: var(--marker); }
:root[data-theme="contrast"] .res-bar::after { background: #c9ccd6; }
:root[data-theme="contrast"] .vote-cand, :root[data-theme="contrast"] .choice-opt, :root[data-theme="contrast"] .title-join { border-width: 3px; border-color: #3d3f48; }
:root[data-theme="contrast"] .join-strip { background: #fff; border-top: 3px solid #000; color: #000; }

/* ---------- Narrow screens ---------- */
@media (max-width: 1000px) {
  .editor { grid-template-columns: 200px 1fr; height: auto; }
  .preview-pane { grid-column: 1 / -1; border-left: 0; }
  .review .body { grid-template-columns: 1fr; }
  .join-panel { flex-direction: column; padding: 30px; gap: 24px; }
  body.side-open .pres-main { grid-template-columns: 1fr; }
  body.side-open .console-side { display: none; }
  .l-hero { grid-template-columns: 1fr; }
  .l-types { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .topbar-inner, .topbar:not(:has(.topbar-inner)) { padding: 0 12px; gap: 8px; }
  .topnav { margin-left: 0; }
  .topnav a { padding: 7px 8px; white-space: nowrap; }
  /* the logo alone; "Account" is also in the avatar menu; page actions keep only their icon */
  .topbar-inner .logo .wordmark, .topnav a[href="/admin"], .topbar .btn > span.lbl { display: none; }
  .admin-card .row { flex-wrap: wrap; }
  .topbar-inner theme-toggle { display: none; }
  /* editor: the title gets the room, saving shows only when it fails */
  .title-input { min-width: 0; flex: 1 1 auto; padding: 6px 4px; }
  .save-state:not(.err), .topbar:not(:has(.topbar-inner)) theme-toggle { display: none; }
  #design-btn { padding-left: 10px; padding-right: 10px; }
  /* editor: one column, with the slide list on top */
  .editor { grid-template-columns: minmax(0, 1fr); }
  .slide-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 38vh; }
  .form-pane { padding: 16px 14px 40px; }
  .preview-pane { padding: 14px; }
  .wordmark { font-size: 16px; }
  .hero h1 { font-size: 24px; }
  .field-grid { grid-template-columns: 1fr; }
  .s-main { padding-left: 10px; padding-right: 10px; }
  .s-card { padding: 16px 14px; }
  pre.code, .md pre { font-size: 13px; padding: 12px; }
  /* the Run button goes below the code instead of covering it */
  .cell-bar { position: static; justify-content: flex-end; padding: 6px 0 0; }
  .cell-code-wrap { flex-direction: column; }
  .cell-code code[contenteditable] { padding-right: 0; }
  .output-diff { grid-template-columns: 1fr; }
  /* Submit stays within reach of the thumb */
  .s-actions { position: sticky; bottom: 0; background: var(--surface); margin: 14px -14px -16px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); border-radius: 0 0 var(--r-lg) var(--r-lg); z-index: 3; }
  .settings-grid { grid-template-columns: 1fr; }
  .l-hero h1 { font-size: 38px; }
  .l-steps, .l-types, .l-split { grid-template-columns: 1fr; }
  .l-visual { padding-left: 40px; }
  .l-phone { width: 150px; }
}

@media (max-width: 480px) {
  /* drag the handle to reorder; only "remove" stays, so the line itself gets the width */
  .p-ops button[aria-label="Move up"], .p-ops button[aria-label="Move down"] { display: none; }
  /* Python's state is shown by the dot alone; the presentation title gets the room */
  .s-top .py-status:not(.loading) .t { display: none; }
  /* the join page fills the phone instead of a card in a card */
  .center-screen .join-card { border: 0; box-shadow: none; background: transparent; }
  .auth-card { border: 0; box-shadow: none; background: transparent; padding: 8px; }
}

/* ---------- Presenter on a phone ---------- */
/* the slide gets every pixel; the panels cover it instead of squeezing it */
@media (max-width: 700px), (max-height: 500px) {
  .pres .stage-host { margin: 8px 8px 0; }
  .pres .stage { border-radius: 6px; }
  .pres-bar { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .pres-bar .btn { padding: 7px 10px; }
  .pres-bar .pill { padding: 6px 10px; }
  .pres-bar .pill-code { display: none; }
  .pres-bar .counter { min-width: 0; }
  /* the question's actions scroll sideways instead of wrapping onto more rows */
  .bar-actions { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .bar-actions::-webkit-scrollbar { display: none; }
  .bar-actions > * { flex-shrink: 0; }
  body.drawer-open:not(.screen-mode) .pres, body.nav-open:not(.screen-mode) .pres { margin: 0; }
  .drawer { width: min(480px, 100vw); box-shadow: var(--shadow-lg); }
  .slide-nav { box-shadow: var(--shadow-lg); }
  /* the bar's menus open as a sheet at the bottom: a scrolling row would cut them off */
  .pres-bar .menu.up { position: fixed; left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); min-width: 0; max-height: calc(100dvh - 16px); overflow: auto; }
  .pres-bar .menu-item { padding: 11px 12px; font-size: 15px; }
  .overlay { padding: 10px; }
  .join-panel { padding: 22px; gap: 18px; border-radius: 18px; }
  .join-panel h2 { font-size: 22px; }
  .join-panel .jp-text, .jp-joined { font-size: 15px; }
  .join-panel .url { font-size: 18px; }
  .join-panel .code { font-size: 52px; box-shadow: inset 0 -9px 0 var(--marker); }
  .join-panel .btn-xl { margin-top: 14px; padding: 10px 20px; font-size: 17px; }
  .review { width: 100%; max-height: none; border-radius: 14px; }
  .review header { padding: 12px 14px; gap: 8px; }
  .review header h3 { font-size: 17px; }
  /* the buttons get a row of their own below the title */
  .review header .spacer { flex-basis: 100%; }
  .review .body { padding: 14px; gap: 16px; }
  .review pre.code, .review .code-edit .field, .review .output pre { font-size: 14px; }
}
/* portrait: the slide controls on top, the question's actions in a row below */
@media (max-width: 700px) {
  .pres-bar { flex-wrap: wrap; }
  .bar-actions { order: 1; flex-basis: 100%; }
  .join-panel .qr { width: min(230px, 62vw); height: min(230px, 62vw); }
}
/* landscape: one row, and the join info next to the QR code */
@media (max-height: 500px) {
  .pres-bar { flex-wrap: nowrap; }
  .pres-bar .spacer { display: none; }
  .pres-bar .menu.up { left: auto; width: min(320px, calc(100vw - 16px)); }
  .bar-actions { flex: 1; }
  .join-panel { flex-direction: row; }
  .join-panel .qr { width: min(240px, calc(100dvh - 90px)); height: min(240px, calc(100dvh - 90px)); }
  .join-panel .jp-text[style] { margin-top: 8px !important; }
}

/* Inputs below 16px make iOS zoom in when they get the focus. */
@media (pointer: coarse) {
  .input, .textarea, .code-edit .field, .prediction-field, select { font-size: 16px !important; }
  .p-ops button { width: 40px; height: 40px; }
}

/* small print under the main button */
.join-card .privacy, .auth-card .btn-block + p { margin-top: 16px; }
