/*
  Live-Folien interface.

  Order rules (the system, so nothing is decided per element):
  - Colours come only from Radix Colors (vendor/radix-colors.css), each step in its documented role:
    1-2 backgrounds, 3-5 fills (rest, hover, pressed), 6-8 borders, 9-10 solid, 11-12 text.
    Neutral = slate. Meaning colours: amber = released to students, grass = live/on, red = ending.
    The main action is solid slate-12 (graphite). There is no other accent.
  - Glass follows Apple's rule: only the floating navigation layer (top bar, slide strip, toasts) is glass.
    Content (cards, lists, inputs, slides) is solid.
  - Spacing only from the 4/8 scale below. Radii: 12 controls, 20 cards (outer = inner + padding), pills for buttons.
  - Type: one family, two weights (400, 600), seven sizes.
  - Motion explains, never decorates: press feedback, direction of slide changes, the rubber band at the
    release limit, the yellow bar when a slide is released, switches. "Reduce motion" turns it all off.
*/
:root {
  --bg: var(--slate-2);
  --surface: #fff;
  --fill: var(--slate-3);
  --fill-hover: var(--slate-4);
  --fill-press: var(--slate-5);
  --line: var(--slate-6);
  --line-strong: var(--slate-7);
  --focus: var(--slate-8);
  --solid: var(--slate-12);
  --solid-hover: #2c3238;
  --text: var(--slate-12);
  --text-2: var(--slate-11);
  --marker: var(--amber-9);
  --on: var(--grass-9);
  --danger: var(--red-11);
  --danger-fill: var(--red-3);
  --danger-fill-hover: var(--red-4);

  --glass-bg: rgba(252, 252, 253, .72);
  --glass-blur: saturate(180%) blur(20px);
  --glass-line: rgba(0, 0, 45, .07);

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px;
  --r-control: 12px;
  --r-card: 20px;
  --pill: 999px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --t-display: clamp(38px, 4.6vw, 56px);
  --t-title1: 30px;
  --t-title2: 24px;
  --t-title3: 21px;
  --t-body: 19px;
  --t-callout: 17px;
  --t-footnote: 15px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-float: 0 1px 0 var(--glass-line), 0 8px 24px rgba(0, 0, 0, .06);
  --shadow-slide: 0 0 0 1px var(--glass-line), 0 12px 32px rgba(0, 0, 0, .08);

  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --t-press: 90ms;
  --t-quick: 180ms;
  --t-move: 300ms;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button, a, label, .thumb, .drop { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { text-wrap: balance; line-height: 1.15; font-weight: 600; }
a { color: var(--text); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }

/* glass: navigation layer only */
.home-head, .pres-bar, .strip, .toast, .beamer-code {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

/* ---------- buttons
   .btn            secondary, neutral fill (default)
   .btn-primary    the one main action per view, solid graphite
   .btn-quiet      tertiary, no fill until hover
   .btn-danger     ending things
   .btn-switch     on/off with the label staying the same
   Heights: .btn-small 44, .btn 52, .btn-big 60, remote 120. */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 52px; padding: 0 var(--s-5);
  border: 0; border-radius: var(--pill);
  background: var(--fill); color: var(--text);
  font-size: 18px; font-weight: 600; line-height: 1.2;
  text-align: center; text-decoration: none; cursor: pointer; user-select: none;
  transition: transform var(--t-move) var(--ease), background-color var(--t-quick) ease-out, opacity var(--t-quick) ease-out;
}
.btn:active { transform: scale(0.97); background: var(--fill-press); transition-duration: var(--t-press); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--solid); color: #fff; }
.btn-primary:active { background: var(--solid-hover); }
.btn-quiet { background: transparent; }
.btn-danger { background: var(--danger-fill); color: var(--danger); }
.btn-tinted { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.btn-big { min-height: 60px; padding: 0 var(--s-6); font-size: 20px; }
.btn-small { min-height: 44px; padding: 0 var(--s-4); font-size: 16px; }
.btn.is-busy:disabled { opacity: .85; }
.btn.is-busy::before {
  content: ""; width: 18px; height: 18px; flex: none; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin 800ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-switch { padding-right: 84px !important; }
.btn-switch::before, .btn-switch::after { content: ""; position: absolute; top: 50%; pointer-events: none; }
.btn-switch::before {
  right: var(--s-4); width: 51px; height: 31px; margin-top: -15.5px; border-radius: var(--pill);
  background: var(--slate-6); transition: background-color 220ms ease-out;
}
.btn-switch::after {
  right: 38px; width: 27px; height: 27px; margin-top: -13.5px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .18);
  transition: transform 260ms var(--ease);
}
.btn-switch.btn-on::before { background: var(--on); }
.btn-switch.btn-on::after { transform: translateX(20px); }

.linklike { background: none; border: 0; padding: var(--s-2) var(--s-3); border-radius: var(--pill); cursor: pointer; color: var(--text); font-size: var(--t-footnote); }

/* ---------- motion vocabulary */
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes from-right { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes from-left { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes rubber { 0% { transform: none; } 30% { transform: translateX(-14px); } 65% { transform: translateX(4px); } 100% { transform: none; } }

/* ---------- start page */
.home { max-width: 800px; margin: 0 auto; padding: 0 var(--s-5) var(--s-8); }
.home-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-4);
  margin: 0 calc(var(--s-5) * -1); padding: var(--s-3) var(--s-5);
  box-shadow: 0 1px 0 var(--glass-line);
}
.brand { font-weight: 600; font-size: var(--t-callout); display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; flex: none; }
.home-lede { font-size: var(--t-display); line-height: 1.06; letter-spacing: -0.025em; margin: var(--s-8) 0 var(--s-3); }
.home-sub { color: var(--text-2); margin: 0 0 var(--s-7); max-width: 44ch; font-size: var(--t-title3); line-height: 1.45; }
.panel { background: var(--surface); border-radius: var(--r-card); padding: var(--s-6); box-shadow: var(--shadow-card), inset 0 0 0 1px var(--line); }
.panel h2 { font-size: var(--t-title2); letter-spacing: -0.015em; margin: 0 0 var(--s-1); }
.panel > p { margin: 0 0 var(--s-6); color: var(--text-2); }
.panel + .panel, .recent + .panel { margin-top: var(--s-5); }
.panel-quiet { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.panel-quiet h2 { font-size: var(--t-title3); }
.panel-quiet > p { margin-bottom: var(--s-4); }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; display: grid; gap: var(--s-6); }
.steps > li { counter-increment: step; display: grid; grid-template-columns: 32px 1fr; gap: var(--s-4); align-items: start; }
.steps > li::before {
  content: counter(step); width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 600; font-size: var(--t-footnote);
  background: var(--fill); color: var(--text); font-variant-numeric: tabular-nums;
}
.step-body { min-width: 0; display: grid; gap: var(--s-3); padding-top: 2px; }
.step-body > label, .step-title { font-weight: 600; }

/* drag and drop works anywhere on the page; the zone shows where the file will land */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2);
  text-align: center; min-height: 240px; padding: var(--s-6);
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-control);
  background: var(--slate-1); color: var(--text-2); cursor: pointer;
  transition: background-color var(--t-quick) ease-out, border-color var(--t-quick) ease-out, transform var(--t-move) var(--ease);
}
.drop.is-over { border-color: var(--solid); border-style: solid; background: var(--slate-3); transform: scale(1.01); }
.drop-icon { color: var(--text); margin-bottom: var(--s-1); }
.drop-title { font-size: var(--t-title3); font-weight: 600; color: var(--text); }
.drop-or { font-size: var(--t-footnote); }
.drop .btn { margin: var(--s-1) 0; }
.drop .hint { margin-top: var(--s-1); }
body.is-dragging::after {
  content: ""; position: fixed; inset: var(--s-2); z-index: 50; pointer-events: none;
  border-radius: var(--r-card); box-shadow: inset 0 0 0 2px var(--solid);
  animation: fadein 120ms ease-out both;
}
.file-card {
  display: flex; align-items: center; gap: var(--s-4); padding: var(--s-4);
  border-radius: var(--r-control); background: var(--slate-2); box-shadow: inset 0 0 0 1px var(--line);
  animation: rise var(--t-move) var(--ease) both;
}
.file-icon { width: 48px; height: 48px; flex: none; border-radius: 10px; background: var(--surface); color: var(--text); display: grid; place-items: center; box-shadow: inset 0 0 0 1px var(--line); }
.file-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .btn { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

.hint { color: var(--text-2); font-size: var(--t-footnote); }
.input {
  width: 100%; min-height: 52px; padding: 0 var(--s-4);
  border: 1px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); font-size: var(--t-body);
  transition: border-color var(--t-quick) ease-out, box-shadow var(--t-quick) ease-out;
}
.input::placeholder { color: var(--slate-9); }
.input:focus, .input:focus-visible { outline: none; border-color: var(--solid); box-shadow: 0 0 0 3px var(--slate-a4); }
.code-input { font-size: 26px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; text-align: center; min-height: 60px; font-variant-numeric: tabular-nums; }
.join-row { display: flex; gap: var(--s-3); flex-wrap: wrap; }
.join-row .input { flex: 1 1 220px; width: auto; }
.join-row .btn { min-height: 60px; }
.progress { height: 4px; border-radius: var(--pill); background: var(--fill); overflow: hidden; margin: var(--s-5) 0 0; }
.progress > i { display: block; height: 100%; width: 100%; background: var(--solid); transform: scaleX(0); transform-origin: left center; transition: transform 200ms var(--ease); }
.error { color: var(--danger); font-weight: 600; margin: var(--s-4) 0 0; }
.submit-row { margin-top: var(--s-6); display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }

.recent { margin-top: var(--s-7); }
.recent h2 { font-size: var(--t-callout); color: var(--text-2); margin: 0 0 var(--s-2) var(--s-4); }
.recent ul { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-control); overflow: hidden; box-shadow: var(--shadow-card), inset 0 0 0 1px var(--line); }
.recent li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3) var(--s-2) var(--s-4); min-height: 60px; box-shadow: inset 0 -1px 0 var(--slate-4); }
.recent li:last-child { box-shadow: none; }
.recent li a { flex: 1; font-weight: 600; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.recent li time { color: var(--text-2); font-size: var(--t-footnote); font-variant-numeric: tabular-nums; }
.recent li .btn { min-height: 40px; padding: 0 var(--s-3); font-size: var(--t-footnote); }

/* ---------- status screens */
.status-screen { min-height: 100dvh; display: grid; place-items: center; text-align: center; padding: var(--s-5); }
.status-screen h1 { font-size: var(--t-title1); letter-spacing: -0.015em; margin: 0 0 var(--s-2); }
.status-screen p { margin: 0 auto var(--s-4); max-width: 42ch; }

.banner {
  position: fixed; left: 50%; top: var(--s-3); transform: translateX(-50%); z-index: 90;
  padding: var(--s-2) var(--s-4); border-radius: var(--pill); background: var(--red-9); color: #fff; font-weight: 600; font-size: var(--t-footnote);
}
.toast {
  position: fixed; left: 50%; bottom: var(--s-5); transform: translateX(-50%); z-index: 90;
  width: max-content; max-width: min(520px, calc(100vw - 32px)); padding: var(--s-3) var(--s-5); border-radius: var(--s-4); text-align: center;
  color: var(--text); font-weight: 600; font-size: var(--t-callout); box-shadow: var(--shadow-float), inset 0 0 0 1px var(--glass-line);
}
.toast.is-in { animation: toast-in 240ms var(--ease) both; }

.slide-frame { position: relative; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; min-height: 0; }
.slide-frame img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; background: #fff; border-radius: var(--s-2); user-select: none; -webkit-user-drag: none; }
.slide-frame img.is-in { animation: fadein 200ms ease-out both; }
.slide-frame img.is-in[data-dir="fwd"] { animation: from-right var(--t-move) var(--ease) both; }
.slide-frame img.is-in[data-dir="back"] { animation: from-left var(--t-move) var(--ease) both; }
.slide-frame img.is-rubber, .slide-frame img.is-in.is-rubber { animation: rubber 360ms var(--ease); }

/* ---------- lecturer view: top bar, stage | side column, strip */
.pres { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; }
.pres-bar { display: flex; align-items: center; gap: var(--s-3) var(--s-5); flex-wrap: wrap; padding: var(--s-3) var(--s-5); box-shadow: 0 1px 0 var(--glass-line); z-index: 2; }
.pres-bar .brand { margin-right: calc(var(--s-2) * -1); }
.pres-title { font-weight: 600; font-size: var(--t-callout); flex: 1 1 260px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pres-meta { display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap; }
.meta-code { display: inline-flex; align-items: center; gap: var(--s-2); }
.meta-code > span { color: var(--text-2); font-size: var(--t-footnote); }
.code-chip {
  font: inherit; font-weight: 700; font-size: 22px; letter-spacing: .12em; padding: var(--s-1) var(--s-4);
  border: 0; border-radius: var(--r-control); background: var(--surface); color: var(--text); cursor: pointer; font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background-color var(--t-quick) ease-out, transform var(--t-move) var(--ease);
}
button.code-chip:active { transform: scale(0.97); transition-duration: var(--t-press); }
.viewers { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 600; font-size: var(--t-callout); font-variant-numeric: tabular-nums; }
.viewers::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on); }
.ended-note { font-weight: 600; color: var(--danger); }

.pres-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: 0; }
@media (max-width: 1000px) { .pres-main { grid-template-columns: 1fr; } .pres-side { display: none; } }
.pres-stage { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; padding: var(--s-5); min-height: 0; }
.pres-stage > .ink-bar { grid-row: 1; margin-bottom: var(--s-4); }
.pres-stage > .slide-frame, .pres-stage > .start-card { grid-row: 2; }
.pres-stage > .pres-nav { grid-row: 3; margin-top: var(--s-5); position: relative; z-index: 2; }
.pres-stage .slide-frame { min-height: 0; height: 100%; }
.pres-stage .slide-frame img { max-height: 100%; border-radius: var(--r-control); box-shadow: var(--shadow-slide); }
.pres-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--s-4); }
.pres-nav .btn { min-height: 60px; font-size: 20px; }
.pres-nav .btn:not(.btn-primary) { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.pres-nav #btn-prev { justify-self: end; min-width: 160px; }
.pres-nav #btn-next { justify-self: start; min-width: 220px; }
.pres-pos { text-align: center; font-variant-numeric: tabular-nums; min-width: 180px; }
.pres-pos #pos { font-weight: 600; font-size: var(--t-title3); }
.pres-pos #released { color: var(--text-2); font-size: var(--t-footnote); }

.start-card { margin: auto; max-width: 560px; width: 100%; background: var(--surface); border-radius: var(--r-card); padding: var(--s-6); box-shadow: var(--shadow-card), inset 0 0 0 1px var(--line); }
.start-card h1 { font-size: var(--t-title1); letter-spacing: -0.015em; margin: 0 0 var(--s-1); }
.start-card > p { color: var(--text-2); margin: 0 0 var(--s-6); }
.start-card .steps .btn { justify-self: start; }

/* side column: grouped lists, one surface per group */
.pres-side { padding: var(--s-5) var(--s-5) var(--s-5) 0; overflow: auto; display: grid; align-content: start; gap: var(--s-5); }
.side-menu { display: grid; gap: var(--s-5); }
.side-group { display: grid; gap: 0; }
.side-group h2 { font-size: var(--t-footnote); color: var(--text-2); font-weight: 600; margin: 0 0 var(--s-2) var(--s-4); }
.side-group .btn {
  width: 100%; justify-content: flex-start; text-align: left;
  min-height: 52px; padding: var(--s-3) var(--s-4); border-radius: 0;
  background: var(--surface); color: var(--text); font-size: var(--t-callout); font-weight: 400;
  box-shadow: inset 1px 0 0 var(--line), inset -1px 0 0 var(--line), inset 0 -1px 0 var(--slate-4);
}
.side-group .btn:first-of-type { border-top-left-radius: var(--r-control); border-top-right-radius: var(--r-control); box-shadow: inset 0 1px 0 var(--line), inset 1px 0 0 var(--line), inset -1px 0 0 var(--line), inset 0 -1px 0 var(--slate-4); }
.side-group .btn:last-of-type { border-bottom-left-radius: var(--r-control); border-bottom-right-radius: var(--r-control); box-shadow: inset 1px 0 0 var(--line), inset -1px 0 0 var(--line), inset 0 -1px 0 var(--line); }
.side-group .btn:only-of-type { box-shadow: inset 0 0 0 1px var(--line); }
.side-group .btn:active { transform: none; background: var(--fill); }
.side-group .btn:focus-visible { outline-offset: -2px; z-index: 1; }
.side-group .btn-danger { color: var(--danger); }
.next-preview img { width: 100%; display: block; background: #fff; border-radius: var(--r-control); box-shadow: inset 0 0 0 1px var(--line), 0 0 0 1px var(--line); }
.next-empty { padding: var(--s-5); border: 1.5px dashed var(--line-strong); border-radius: var(--r-control); text-align: center; color: var(--text-2); }
.keys { font-size: 13px; color: var(--text-2); margin: 0 0 0 var(--s-4); }

/* slide strip: the yellow bar grows in when a slide is released to students */
.strip { display: flex; gap: var(--s-3); overflow-x: auto; padding: var(--s-3) var(--s-5) var(--s-4); box-shadow: 0 -1px 0 var(--glass-line); scrollbar-width: thin; }
.thumb {
  position: relative; flex: none; width: 112px; padding: 0; border: 0; border-radius: var(--s-2); background: none; cursor: pointer;
  box-shadow: 0 0 0 1px var(--line);
  transition: transform var(--t-move) var(--ease), box-shadow var(--t-quick) ease-out;
}
.thumb img { width: 100%; display: block; aspect-ratio: 16 / 10; object-fit: contain; background: #fff; border-radius: var(--s-2); opacity: .45; transition: opacity 240ms ease-out; }
.thumb::after {
  content: ""; position: absolute; left: var(--s-2); right: var(--s-2); bottom: -8px; height: 3px; border-radius: var(--pill);
  background: var(--marker); transform: scaleX(0); transform-origin: left center; transition: transform 420ms var(--ease);
}
.thumb.is-released img { opacity: 1; }
.thumb.is-released::after { transform: scaleX(1); }
.thumb:active { transform: scale(0.96); transition-duration: var(--t-press); }
.thumb.is-current { box-shadow: 0 0 0 2px var(--solid); }
.thumb span { position: absolute; left: var(--s-1); top: var(--s-1); font-size: 12px; font-weight: 600; padding: 0 6px; border-radius: var(--s-1); background: var(--solid); color: #fff; font-variant-numeric: tabular-nums; }

/* overlays for the hall stay plain white: maximum contrast on any projector */
.overlay { overscroll-behavior: contain; position: fixed; inset: 0; z-index: 80; background: #fff; color: var(--text); display: grid; place-items: center; padding: var(--s-6); animation: fadein 160ms ease-out both; }
.overlay-inner { display: grid; grid-template-columns: auto 1fr; gap: var(--s-7); align-items: center; max-width: 1200px; }
@media (max-width: 820px) { .overlay-inner { grid-template-columns: 1fr; text-align: center; gap: var(--s-5); } }
.qr { width: min(52vh, 80vw); aspect-ratio: 1; background: #fff; padding: var(--s-3); border-radius: var(--r-card); box-shadow: inset 0 0 0 1px var(--line); }
.qr svg { width: 100%; height: 100%; display: block; }
.overlay h1 { font-size: clamp(28px, 3.6vw, 44px); letter-spacing: -0.02em; margin: 0 0 var(--s-3); }
.qr-url { font-size: clamp(22px, 2.6vw, 32px); font-weight: 600; margin: 0 0 var(--s-4); overflow-wrap: anywhere; }
.big-code { font-size: clamp(64px, 11vw, 140px); font-weight: 700; letter-spacing: .08em; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.overlay p { margin: 0 0 var(--s-3); }
.overlay-close { position: absolute; top: var(--s-5); right: var(--s-5); }

.beamer { position: fixed; inset: 0; z-index: 70; background: #000; display: grid; place-items: center; }
.beamer img { max-width: 100vw; max-height: 100vh; object-fit: contain; display: block; }
.beamer img.is-in { animation: fadein 160ms ease-out both; }
.beamer-code { position: absolute; right: var(--s-5); bottom: var(--s-4); padding: var(--s-2) var(--s-4); border-radius: var(--pill); color: var(--text); font-weight: 600; font-size: 22px; }
.beamer-code b { letter-spacing: .1em; }
.beamer .overlay { position: absolute; }

/* ---------- phone remote (lecturer) */
.remote { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "head" "stage" "panel"; height: 100dvh; padding-bottom: env(safe-area-inset-bottom); font-size: var(--t-callout); }
.remote-head { grid-area: head; }
.remote-stage { grid-area: stage; padding: var(--s-2) var(--s-4) 0; min-height: 0; touch-action: pan-y; }
.remote-stage img { max-height: 100%; border-radius: var(--r-control); box-shadow: var(--shadow-slide); }
.remote-panel { grid-area: panel; display: grid; gap: var(--s-4); padding-top: var(--s-4); }
.remote-panel > .remote-next, .remote-panel > .ink-bar { margin: 0 var(--s-4); }
.remote-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: calc(var(--s-3) + env(safe-area-inset-top)) var(--s-4) var(--s-3); }
.remote-head .code-chip { font-size: 20px; cursor: default; }
.remote-next { display: flex; gap: var(--s-4); align-items: center; font-variant-numeric: tabular-nums; }
.remote-next img { width: 36%; background: #fff; border-radius: var(--s-2); box-shadow: 0 0 0 1px var(--line); }
.remote-next #pos { font-weight: 600; }
.remote-controls { display: grid; grid-template-columns: 1fr 2fr; gap: var(--s-3); padding: 0 var(--s-4); }
.remote-controls .btn { min-height: 120px; border-radius: 28px; font-size: 22px; }
.remote-controls .btn:not(.btn-primary) { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.remote-controls .btn-primary { font-size: 26px; }
.remote-row { display: flex; gap: var(--s-3); padding: 0 var(--s-4) var(--s-4); }
.remote-row .btn { flex: 1; justify-content: flex-start; text-align: left; min-height: 60px; border-radius: var(--r-control); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: var(--t-callout); font-weight: 400; }
.remote-row .btn:active { transform: none; background: var(--fill); }

/* iPad and other wide screens: big slide to write on, controls in a column on the right */
@media (min-width: 700px) {
  .remote { grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "head head" "stage panel"; }
  .remote-stage { padding: var(--s-2) var(--s-4) var(--s-5) var(--s-5); }
  .remote-panel { align-content: end; padding: var(--s-2) var(--s-5) var(--s-5) 0; gap: var(--s-4); }
  .remote-panel > .remote-next, .remote-panel > .ink-bar { margin: 0; }
  .remote-panel .remote-controls, .remote-panel .remote-row { padding: 0; }
  .remote-panel .remote-controls { grid-template-columns: 1fr; }
  .remote-panel .remote-controls .btn { min-height: 88px; }
  .remote-panel .remote-controls .btn-primary { order: -1; min-height: 120px; }
  .remote-panel .ink-bar { display: grid; grid-template-columns: 1fr 1fr; justify-self: stretch; border-radius: var(--r-card); padding: var(--s-3); gap: var(--s-2); }
  .remote-panel .ink-colors { grid-column: 1 / -1; justify-content: center; padding: 0 0 var(--s-1); gap: var(--s-3); }
  .remote-panel .swatch { width: 44px; height: 44px; }
  .remote-panel .ink-hint { grid-column: 1 / -1; text-align: center; padding-top: var(--s-1); }
}

/* ---------- pen notes */
.ink-layer { position: absolute; pointer-events: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.ink-input { pointer-events: auto; touch-action: none; }
.beamer .ink-layer { z-index: 1; }
.beamer .beamer-code, .beamer .overlay { z-index: 2; }
.slide-frame img.is-in ~ .ink-layer { animation: fadein 200ms ease-out both; }
.slide-frame img.is-in[data-dir="fwd"] ~ .ink-layer { animation: from-right var(--t-move) var(--ease) both; }
.slide-frame img.is-in[data-dir="back"] ~ .ink-layer { animation: from-left var(--t-move) var(--ease) both; }
.ink-bar {
  display: flex; align-items: center; gap: var(--s-3); justify-self: center;
  padding: var(--s-2) var(--s-3); border-radius: var(--pill);
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line), var(--shadow-card);
}
.ink-colors { display: flex; gap: var(--s-2); padding-right: var(--s-2); }
.swatch {
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
  transition: transform var(--t-move) var(--ease), box-shadow var(--t-quick) ease-out;
}
.swatch[data-ink-color="k"] { background: #1c2024; }
.swatch[data-ink-color="r"] { background: #e5484d; }
.swatch[data-ink-color="b"] { background: #0b68cb; }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--solid); }
.swatch:active { transform: scale(0.92); transition-duration: var(--t-press); }
.ink-hint { color: var(--text-2); font-size: var(--t-footnote); padding: 0 var(--s-2); }
.ink-bar .btn-small { min-height: 40px; }
.ink-bar .btn:disabled { opacity: .35; }
@media (max-width: 1180px) { .pres-stage .ink-hint { display: none; } }

/* ---------- end of the lecture */
.end-overlay { place-items: center; overflow: auto; }
.end-box { width: min(600px, 100%); }
.end-step { display: grid; gap: var(--s-5); animation: rise var(--t-move) var(--ease) both; }
.end-step h1 { font-size: var(--t-title1); letter-spacing: -0.015em; margin: 0; }
.end-lead { margin: 0; font-size: var(--t-title3); color: var(--text-2); }
.end-lead strong { color: var(--text); font-weight: 600; }
.end-actions { display: grid; gap: var(--s-3); }
.end-step > .btn-quiet { justify-self: start; }
.choices { display: grid; gap: var(--s-3); }
.choice {
  display: grid; gap: 2px; text-align: left; width: 100%; min-height: 80px; padding: var(--s-4) var(--s-5);
  border: 0; border-radius: var(--r-card); background: var(--surface); color: var(--text); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  transition: transform var(--t-move) var(--ease), background-color var(--t-quick) ease-out, box-shadow var(--t-quick) ease-out;
}
.choice b { font-size: var(--t-title3); font-weight: 600; }
.choice span { color: var(--text-2); font-size: var(--t-callout); }
.choice:active { transform: scale(0.985); background: var(--fill); transition-duration: var(--t-press); }
.pickup { text-align: center; display: grid; gap: var(--s-4); justify-items: center; }
.pickup h1 { margin: 0; }
.pickup p { color: var(--text-2); font-size: clamp(20px, 2.4vw, 30px); margin: 0; }
.pickup .big-code { font-size: clamp(96px, 18vw, 220px); letter-spacing: .12em; }

/* student phone after the end */
.end-sheet { margin: 0 var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom)); padding: var(--s-5); border-radius: var(--r-card); background: var(--slate-2); box-shadow: inset 0 0 0 1px var(--slate-5); display: grid; gap: var(--s-3); animation: rise var(--t-move) var(--ease) both; }
.end-sheet h2 { margin: 0; font-size: var(--t-title3); }
.end-sheet p { margin: 0; color: var(--text-2); font-size: var(--t-footnote); }
.end-sheet .end-dl { width: 100%; min-height: 56px; }
.end-code { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-3); }
.pickup-input::placeholder { letter-spacing: 0; font-size: var(--t-callout); font-weight: 400; }
.pickup-input { font-size: 26px; font-weight: 600; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; min-height: 56px; }
.end-code .btn { min-height: 56px; }
.end-sheet .error { margin: 0; font-size: var(--t-footnote); }

/* ---------- student view (dark, Radix slate-dark via body.dark) */
.board { --bg: #000; --fill: var(--slate-3); --fill-hover: var(--slate-4); --fill-press: var(--slate-5); --text: var(--slate-12); --text-2: var(--slate-11); --line: var(--slate-6); --line-strong: var(--slate-7); --focus: var(--slate-9); --on: var(--grass-9); --danger: var(--red-11);
  background: #000; color: var(--text); min-height: 100dvh; font-size: var(--t-callout); color-scheme: dark; }
.board .btn-marker, .board .btn-primary { background: var(--slate-12); color: #000; }
.board .error { color: var(--danger); }
.board .input { background: var(--slate-2); color: var(--text); border-color: var(--slate-7); }
.board .input:focus { border-color: var(--slate-11); box-shadow: 0 0 0 3px rgba(255, 255, 255, .12); }
.board .toast { background: rgba(33, 34, 37, .78); color: var(--text); bottom: calc(108px + env(safe-area-inset-bottom)); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 8px 24px rgba(0, 0, 0, .4); }
.live {
  display: inline-flex; flex: none; white-space: nowrap; align-items: center; gap: var(--s-2);
  min-height: 32px; padding: 0 var(--s-3); border: 0; border-radius: var(--pill); font-weight: 600; font-size: var(--t-footnote);
  background: var(--grass-3); color: var(--grass-11); cursor: pointer;
  transition: background-color var(--t-quick) ease-out, color var(--t-quick) ease-out, transform var(--t-move) var(--ease);
}
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 2.4s ease-in-out infinite; }
.live.is-off { background: var(--slate-12); color: #000; }
.live.is-off::before { display: none; }
.live.is-off:active { transform: scale(0.96); transition-duration: var(--t-press); }
.live:disabled { cursor: default; }
.live.is-off:disabled { background: var(--slate-3); color: var(--text-2); }
.view { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; height: 100dvh; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: calc(var(--s-3) + env(safe-area-inset-top)) var(--s-4) var(--s-3); }
.view-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.view-stage { padding: 0 var(--s-3); min-height: 0; touch-action: pan-y pinch-zoom; }
.view-stage img { max-height: calc(100dvh - 150px); border-radius: var(--s-2); }
.view-foot { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom)); }
.btn-round { width: 56px; height: 56px; min-height: 56px; padding: 0; border-radius: 50%; }
.view-pos { text-align: center; font-size: var(--t-footnote); font-weight: 600; font-variant-numeric: tabular-nums; min-width: 0; display: grid; gap: var(--s-2); justify-items: center; }
.back-live { min-height: 44px; font-size: var(--t-footnote); padding: 0 var(--s-4); }
.pause-cover { position: fixed; inset: 0; background: #000; color: var(--text); display: grid; place-items: center; text-align: center; z-index: 40; padding: var(--s-5); animation: fadein 300ms ease-out both; }
.join-form { width: min(420px, 100%); text-align: left; }
.join-form h1 { font-size: var(--t-title1); letter-spacing: -0.015em; }
.join-form .btn { margin-top: var(--s-3); width: 100%; min-height: 56px; }

/* legal links and the lecturer's numbers */
.legal-links { font-size: var(--t-footnote); color: var(--text-2); margin: var(--s-4) 0 0; }
.legal-links a { color: var(--text-2); }
.site-foot { margin-top: var(--s-7); text-align: center; }
.keys + .legal-links { margin: 0 0 0 var(--s-4); }
.end-sheet .legal-links { margin: 0; text-align: center; }
.stats .stat { margin: 0 0 var(--s-1) var(--s-4); font-size: var(--t-callout); color: var(--text-2); }
.stats .stat b { color: var(--text); font-size: var(--t-title3); font-variant-numeric: tabular-nums; margin-right: var(--s-1); }
.legal h1 { font-size: var(--t-title1); margin: var(--s-7) 0 var(--s-4); }
.legal h2 { font-size: var(--t-title3); margin: var(--s-6) 0 var(--s-2); }
.legal p { max-width: 68ch; }

/* hover only with a real pointer, so a tap never leaves a button looking pressed */
@media (hover: hover) {
  .btn:hover { background: var(--fill-hover); }
  .btn:disabled:hover { background: var(--fill); }
  .btn-primary:hover { background: var(--solid-hover); }
  .btn-primary:disabled:hover { background: var(--solid); }
  .btn-quiet:hover { background: var(--fill); }
  .btn-danger:hover { background: var(--danger-fill-hover); }
  .btn-tinted:hover, .pres-nav .btn:not(.btn-primary):hover, .remote-controls .btn:not(.btn-primary):hover, .file-card .btn:hover { background: var(--slate-2); }
  .linklike:hover { background: var(--fill); }
  .drop:hover { border-color: var(--slate-8); background: var(--slate-2); }
  .drop.is-over:hover { border-color: var(--solid); background: var(--slate-3); }
  .recent li:hover { background: var(--slate-2); }
  button.code-chip:hover { background: var(--slate-2); }
  .side-group .btn:hover { background: var(--slate-2); }
  .side-group .btn:disabled:hover { background: var(--surface); }
  .side-group .btn-danger:hover { background: var(--danger-fill); }
  .side-group .btn.btn:active { background: var(--fill); }
  .remote-row .btn:hover { background: var(--slate-2); }
  .choice:hover { background: var(--slate-2); box-shadow: inset 0 0 0 1px var(--slate-8); }
  .swatch:hover { transform: scale(1.06); }
  .thumb:hover { box-shadow: 0 0 0 1px var(--slate-8); }
  .thumb.is-current:hover { box-shadow: 0 0 0 2px var(--solid); }
  .board .btn-marker:hover, .board .btn-primary:hover { background: var(--slate-11); }
}

@media (prefers-reduced-transparency: reduce) {
  :root { --glass-bg: var(--slate-1); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:active, .thumb:active { transform: none; }
}
