/*
 * Look: warm paper, terracotta accent, honey for brand and rehearsals, sage for correct/live,
 * crimson for destructive. System fonts only; text >= 4.5:1 and control borders >= 3:1 in
 * both schemes (ADR 0018).
 */
:root {
  color-scheme: light dark;
  --bg: #fcf8f2;
  --surface: #f4ece1;
  --surface-raised: #fffdfa;
  --fg: #211c18;
  --muted: #5e5249;
  --border: #e2d6c8; /* decorative lines */
  --border-strong: #7b6d61; /* controls */
  --accent: #9e3f1e;
  --accent-fg: #ffffff;
  --accent-soft: #fcebe4;
  --accent-on-soft: #6e270e;
  --focus: #9e3f1e;
  --warm: #994800;
  --warm-soft: #feefd6;
  --warm-fg: #6b3100;
  --ok: #1d6b42;
  --ok-bg: #e3f3e8;
  --danger: #a1153f;
  --error-bg: #fbe9ee;
  --notice-bg: var(--accent-soft);
  --qr-bg: #ffffff; /* QR codes stay white in both schemes. */
  --shadow: 0 1px 3px rgb(33 28 24 / 0.07), 0 4px 12px rgb(33 28 24 / 0.05);
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-pill: 999px;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191512;
    --surface: #231e1a;
    --surface-raised: #2e2722;
    --fg: #f7efe6;
    --muted: #c2b3a5;
    --border: #3d342d;
    --border-strong: #8c7e72;
    --accent: #ff9673;
    --accent-fg: #260c04;
    --accent-soft: #421f13;
    --accent-on-soft: #ffdbcf;
    --focus: #ff9673;
    --warm: #f7b955;
    --warm-soft: #36250d;
    --warm-fg: #ffd899;
    --ok: #81d9a2;
    --ok-bg: #193022;
    --danger: #ffb3c4;
    --error-bg: #3d1a24;
    --shadow: none;
  }
}

/*
 * Session palettes (ADR 0019): only the accent family changes. The attribute sits on <html> for
 * session pages, on #addin-view in the add-in and on each swatch in the settings, so the same
 * rules colour all of them. Contrast was computed for every pair in both schemes.
 */
[data-palette="terracotta"] {
  --accent: #9e3f1e;
  --accent-fg: #ffffff;
  --accent-soft: #fcebe4;
  --accent-on-soft: #6e270e;
  --focus: #9e3f1e;
  --notice-bg: var(--accent-soft);
}

[data-palette="petrol"] {
  --accent: #0d5963;
  --accent-fg: #ffffff;
  --accent-soft: #e2f1f3;
  --accent-on-soft: #063b42;
  --focus: #0d5963;
  --notice-bg: var(--accent-soft);
}

[data-palette="ocean"] {
  --accent: #1f4e8c;
  --accent-fg: #ffffff;
  --accent-soft: #e6eef8;
  --accent-on-soft: #12325c;
  --focus: #1f4e8c;
  --notice-bg: var(--accent-soft);
}

[data-palette="plum"] {
  --accent: #662e6b;
  --accent-fg: #ffffff;
  --accent-soft: #f3e8f5;
  --accent-on-soft: #45194a;
  --focus: #662e6b;
  --notice-bg: var(--accent-soft);
}

[data-palette="olive"] {
  --accent: #4a5712;
  --accent-fg: #ffffff;
  --accent-soft: #eef1df;
  --accent-on-soft: #313b06;
  --focus: #4a5712;
  --notice-bg: var(--accent-soft);
}

@media (prefers-color-scheme: dark) {
  [data-palette="terracotta"] {
    --accent: #ff9673;
    --accent-fg: #260c04;
    --accent-soft: #421f13;
    --accent-on-soft: #ffdbcf;
    --focus: #ff9673;
    --notice-bg: var(--accent-soft);
  }

  [data-palette="petrol"] {
    --accent: #66d1de;
    --accent-fg: #032226;
    --accent-soft: #113338;
    --accent-on-soft: #c9f2f7;
    --focus: #66d1de;
    --notice-bg: var(--accent-soft);
  }

  [data-palette="ocean"] {
    --accent: #8cbbfa;
    --accent-fg: #071c38;
    --accent-soft: #162942;
    --accent-on-soft: #d6e6ff;
    --focus: #8cbbfa;
    --notice-bg: var(--accent-soft);
  }

  [data-palette="plum"] {
    --accent: #dfa3e6;
    --accent-fg: #28092b;
    --accent-soft: #361c38;
    --accent-on-soft: #f7defa;
    --focus: #dfa3e6;
    --notice-bg: var(--accent-soft);
  }

  [data-palette="olive"] {
    --accent: #c5d66b;
    --accent-fg: #1c2103;
    --accent-soft: #2b3012;
    --accent-on-soft: #e9f2be;
    --focus: #c5d66b;
    --notice-bg: var(--accent-soft);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
}

main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.75rem 1rem 2.5rem;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2rem);
  margin: 0 0 1rem;
}

h2 {
  font-size: clamp(1.2rem, 2.2vw, 1.4rem);
  margin: 2rem 0 0.75rem;
}

h3 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.15em;
}

code,
.lobby-code,
.addin-code {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Presenter pages ------------------------------------------------------------------- */

main.narrow {
  max-width: 28rem;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  align-items: center;
  max-width: 44rem;
  margin: 0 auto;
}

.topbar a {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
}

.topbar a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* The app name with a honey dot; text, so it needs no image. */
.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand::before {
  content: "" / "";
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.4em;
  border-radius: 50%;
  background: var(--warm);
  vertical-align: 0.05em;
}

.topbar form {
  margin-left: auto;
}

form.inline {
  display: inline;
}

.field {
  margin: 0 0 1rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.field-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.5rem;
  align-items: start;
}

.field-check label {
  min-width: 0;
  font-weight: 600;
  margin: 0;
}

.field-check input {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input:not([type]),
textarea {
  width: 100%;
  font: inherit;
  padding: 0.6rem 0.75rem;
  min-height: 2.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--fg);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  border-color: var(--focus);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

/* Settings switches keep checkbox semantics; the thumb is painted on the input itself. */
input.switch {
  appearance: none;
  width: 2.75rem;
  height: 1.6rem;
  flex-shrink: 0;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background-color: var(--surface);
  background-image: radial-gradient(circle, var(--fg) 0 0.5rem, transparent calc(0.5rem + 1px));
  background-size: 1.35rem 100%;
  background-repeat: no-repeat;
  background-position: left 0.1rem center;
  cursor: pointer;
}

input.switch:checked {
  background-color: var(--accent);
  background-image: radial-gradient(
    circle,
    var(--accent-fg) 0 0.5rem,
    transparent calc(0.5rem + 1px)
  );
  background-position: right 0.1rem center;
  border-color: var(--accent);
}

input.switch:disabled {
  opacity: 0.45;
  border-style: dashed;
  cursor: not-allowed;
}

.hint {
  color: var(--muted);
  font-size: 0.925rem;
  margin: 0 0 0.25rem;
}

.field-check .hint {
  grid-column: 2;
}

.error {
  color: var(--danger);
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.field-error input,
.field-error textarea {
  border: 2px solid var(--danger);
}

.error-summary {
  border: 2px solid var(--danger);
  background: var(--error-bg);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.notice {
  background: var(--notice-bg);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  margin: 0 0 1rem;
}

/* Capsule actions: filled primary, tonal secondary, outlined destructive. */
button,
a.button,
.actions > a:not(.button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  max-width: 100%;
  min-width: 0;
  font: inherit;
  font-weight: 500;
  min-height: 2.75rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-on-soft);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-decoration: none;
  /* Long German compounds ("Beitrittsbildschirm") break at syllables; without a hyphenation
     dictionary they still break rather than widen the grid. */
  hyphens: auto;
  overflow-wrap: break-word;
}

/* Disabled controls look disabled everywhere (the phone remote, voted Q&A, locked forms). */
button:disabled,
button.primary:disabled {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--border-strong); /* A shape cue, not only a paler colour. */
  cursor: not-allowed;
  box-shadow: none;
}

button:hover:not(:disabled),
button:active:not(:disabled),
a.button:hover,
a.button:active,
.actions > a:not(.button):hover,
.actions > a:not(.button):active {
  background: color-mix(in srgb, var(--accent-soft) 88%, var(--accent));
}

button.primary,
a.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

button.primary:hover:not(:disabled),
a.button.primary:hover,
button.primary:active:not(:disabled),
a.button.primary:active {
  background: var(--accent);
  border-color: var(--fg);
}

button.danger,
a.button.danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: none;
}

button.danger:hover:not(:disabled),
button.danger:active:not(:disabled),
a.button.danger:hover,
a.button.danger:active {
  background: var(--error-bg);
  border-color: var(--danger);
}

/* Only the press moves; colours change instantly, so no half-blended state is ever shown. */
@media (prefers-reduced-motion: no-preference) {
  button,
  a.button,
  .actions > a:not(.button),
  .answer .option {
    transition: transform 80ms ease;
  }

  button:active:not(:disabled),
  a.button:active,
  .actions > a:not(.button):active,
  .answer label.option:active {
    transform: translateY(1px);
  }
}

button.link {
  background: none;
  border: 0;
  box-shadow: none;
  padding: 0;
  min-height: 1.5rem;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

button.link:hover:not(:disabled) {
  background: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.5rem;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

thead th {
  color: var(--muted);
  font-size: 0.875em; /* em: scales with the projector's larger type */
  font-weight: 600;
  white-space: nowrap;
}

td code {
  white-space: nowrap;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Badges carry their meaning in words; colour only adds emphasis. */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.05rem 0.6rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-on-soft);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-live,
.badge-open {
  color: var(--ok);
  background: var(--ok-bg);
  font-weight: 600;
}

.badge-practice,
.badge-expiring {
  color: var(--warm-fg);
  background: var(--warm-soft);
  font-weight: 600;
}

code.joincode {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

/* Dashboard questions stay cards; the remote uses grouped rows. */
.run-of-show:where(:not(.compact)) {
  padding-left: 0;
  list-style: none;
  counter-reset: question;
}

.run-of-show:where(:not(.compact)) > li {
  counter-increment: question;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
  margin: 0 0 0.75rem;
}

.run-of-show:where(:not(.compact)) .q-head::before {
  content: counter(question) "." / "";
  font-weight: 700;
  color: var(--muted);
}

/* Only questions are numbered (as in the results); slides say "Folie n" themselves. */
.run-of-show:where(:not(.compact)) > li.ros-slide {
  counter-increment: none;
}

.run-of-show .ros-slide .q-head::before {
  content: none;
}

.q-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.q-type {
  color: var(--muted);
  font-size: 0.925rem;
}

.q-prompt {
  margin: 0.25rem 0;
  font-weight: 600;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* "Add question" types: chips. */
.type-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  list-style: none;
}

.type-links a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0.45rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-on-soft);
  font-weight: 600;
  text-decoration: none;
}

.type-links a::before {
  content: "+" / ""; /* decorative: not part of the link name */
  margin-right: 0.4rem;
  color: var(--accent);
  font-weight: 700;
}

.type-links a:hover {
  background: color-mix(in srgb, var(--accent-soft) 88%, var(--accent));
  border-color: var(--accent);
}

details {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: 0.5rem 1rem;
}

details[open] {
  padding-bottom: 1rem;
}

summary {
  cursor: pointer;
  min-height: 2.25rem;
  display: flex;
  align-items: center;
  font-weight: 600;
}

summary::-webkit-details-marker {
  display: none;
}

summary::before {
  content: "▸" / "";
  margin-right: 0.5rem;
  color: var(--muted);
}

details[open] > summary::before {
  content: "▾" / "";
}

figure.qr {
  margin: 1rem 0;
  text-align: center;
}

figure.qr img {
  display: block;
  margin: 0 auto 0.75rem;
  background: var(--qr-bg);
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 100%;
  height: auto;
}

figure.qr code {
  word-break: break-all;
  font-size: 0.85rem;
  color: var(--muted);
}

.remotes li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
}

/* ---- Participants ---------------------------------------------------------------------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.muted {
  color: var(--muted);
}

.ok {
  color: var(--ok);
  font-weight: 600;
}

button.big {
  width: 100%;
  min-height: 3.5rem;
  font-size: 1.125rem;
}

input.code-input {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.75rem;
  border-radius: var(--radius-lg);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-align: center;
}

/* The join form sits on a card under the app name. */
.join h1 {
  margin-top: 1.5rem;
}

.join h1,
.stage .prompt {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
}

.join form,
.login form {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin: 1rem 0 1.5rem;
}

.session-title {
  font-size: 1.125rem;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.joined-session {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.15rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 0.875rem;
  font-weight: 600;
}

.connection-lost {
  background: var(--error-bg);
  border: 2px solid var(--danger);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-weight: 600;
}

/*
 * Waiting, saved, closed (phones, projector, remote): a calm raised card. Tonal fills are kept
 * for things you can press, so passive states never look like buttons.
 */
.state {
  font-size: 1.15rem;
  text-align: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1rem;
  color: var(--fg);
}

/* Rehearsals say so in words on every surface; honey keeps them apart from real events. */
.practice-notice {
  background: var(--warm-soft);
  color: var(--warm-fg);
  border: 1px solid var(--warm);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin: 0 0 1rem;
}

.practice-notice p {
  margin: 0.25rem 0;
}

.practice-notice a {
  color: var(--warm-fg);
  font-weight: 600;
}

.practice-notice details {
  background: transparent;
  border-color: var(--warm);
  margin: 0.5rem 0 0.25rem;
}

.answer fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
}

.answer legend {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.answer .option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.85rem;
  width: 100%;
  min-height: 3.5rem;
  margin: 0 0 0.75rem;
  padding: 1rem 1.1rem;
  font-size: 1.125rem;
  text-align: left;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--fg);
  box-shadow: var(--shadow);
}

.answer .option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.answer label.option input {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  flex-shrink: 0;
}

.answer > button.primary,
.qa > form > button.primary {
  width: 100%;
}

.answer label.option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: 2px solid var(--accent);
}

/* Shape + letter in a small pill: options never rely on colour alone. */
.marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  font-weight: 700;
  font-size: 0.95em;
  min-width: 2.9rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-on-soft);
  border: 1px solid transparent;
}

.answer .option:hover .marker,
.answer label.option:has(input:checked) .marker {
  background: var(--surface-raised);
  border-color: var(--border-strong);
}

.scale-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(3.5rem, 1fr));
  gap: 0.5rem;
}

.scale-buttons .option {
  justify-content: center;
  margin: 0;
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
}

.me {
  border: 1px solid var(--border);
  background: var(--surface-raised);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin: 0 0 1rem;
}

.me-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.925rem;
}

.me-value {
  margin: 0;
  font-weight: 600;
}

.nickname {
  margin-top: 2rem;
}

.legal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0.75rem 1rem 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.925rem;
}

.legal-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.125rem 0;
}

/* ---- Results (screen, participants after reveal) --------------------------------------- */

.results-table th[scope="row"] {
  font-weight: 400;
  width: 70%;
}

.results-table .num {
  white-space: nowrap;
}

svg.bar {
  display: block;
  width: 100%;
  height: 0.9rem;
  margin-top: 0.35rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.bar-track {
  fill: var(--surface);
}

.bar-fill {
  fill: var(--accent);
}

/* After reveal the correct options' bars turn green (the row also says "correct" in words). */
.results-table tr.correct .bar-fill {
  fill: var(--ok);
}

.results-detail {
  color: var(--muted);
  font-size: 0.925rem;
  margin: -0.25rem 0 0.75rem;
}

@media (prefers-reduced-motion: no-preference) {
  .bar-fill {
    transition: width 300ms ease-out;
  }
}

.scale-stats {
  font-size: 1.125rem;
}

.cloud {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  align-items: baseline;
  justify-content: center;
}

.cloud .count {
  font-size: 0.75rem;
  color: var(--muted);
}

.cloud .w1 {
  font-size: 1rem;
}

.cloud .w2 {
  font-size: 1.35rem;
}

.cloud .w3 {
  font-size: 1.8rem;
}

.cloud .w4 {
  font-size: 2.4rem;
  font-weight: 600;
}

.cloud .w5 {
  font-size: 3.2rem;
  font-weight: 700;
}

.wall {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr));
  gap: 0.75rem;
}

.wall li {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- Beamer ---------------------------------------------------------------------------- */

body.screen-body,
body.show-body {
  font-size: clamp(1rem, 1.6vw, 2rem);
}

main.screen {
  max-width: none;
  min-height: 100vh;
  padding: 2vh 4vw;
}

.screen-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
  padding-bottom: 1.5vh;
  border-bottom: 1px solid var(--border);
}

.screen-head h1 {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--muted);
  margin: 0;
}

.screen-head .status {
  margin: 0;
  color: var(--muted);
}

.screen .prompt {
  font-size: 2.2em;
  line-height: 1.2;
  margin: 3vh 0;
}

.screen svg.bar {
  height: 1.4em;
}

.screen .cloud {
  min-height: 50vh;
  align-content: center;
}

.lobby {
  display: flex;
  flex-wrap: wrap;
  gap: 4vw;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

.lobby-qr {
  width: min(60vh, 40vw);
  height: auto;
  background: var(--qr-bg);
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
}

/* Join callouts stay readable on washed-out projectors. */
.lobby-text,
.addin-text {
  min-width: 0;
  max-width: 100%;
  padding: 1em;
  background: var(--surface-raised);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.lobby-text p {
  margin: 0.25em 0;
  font-size: 1.5em;
}

.lobby-host {
  font-weight: 700;
}

.lobby-code {
  font-size: clamp(1.5rem, 8vw, 4em) !important;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--accent-on-soft);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  display: inline-block;
  padding: 0.1em 0.4em 0.1em 0.55em; /* letter spacing adds room on the right only */
}

.screen-join {
  margin-top: 3vh;
  color: var(--muted);
}

.screen-join strong {
  font-family: var(--font-mono);
  color: var(--fg);
  letter-spacing: 0.1em;
}

/* Wide tables scroll inside their box instead of widening the page on phones. */
.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.5rem;
}

.table-wrap table {
  margin: 0;
}

/* On phones the table scrolls sideways instead of breaking titles letter by letter. */
.table-wrap td {
  overflow-wrap: normal;
  hyphens: auto;
}

.table-wrap td:first-child {
  min-width: 9rem;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

main {
  overflow-wrap: anywhere;
}

/* ---- Remote (phone) and live controls ------------------------------------------------- */

body.remote-body main.remote {
  max-width: 32rem;
  padding: 0.5rem 1rem 2rem;
}

.remote-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.remote-top a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.remote-code strong {
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}

.remote-title {
  font-size: 1.25rem;
  margin: 0.5rem 0;
}

.remote-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.85rem;
  font-weight: 600;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  margin: 0 0 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface);
  border-radius: var(--radius);
}

/* What is on stage now: a card the presenter finds at a glance. */
.now {
  background: var(--surface-raised);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.now p:last-child {
  margin-bottom: 0;
}

.feedback {
  min-height: 1.5rem;
  margin: 0 0 0.5rem;
  color: var(--ok);
  font-weight: 600;
}

.now-prompt {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0.25rem 0;
}

.badge-mode {
  display: inline-block;
  margin: 0.25rem 0;
}

.control-grid > * {
  min-width: 0;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

form.control {
  margin: 0;
}

form.control button.big {
  font-size: 1.2rem;
  font-weight: 600;
}

form.control.htmx-request button {
  outline: 3px solid var(--accent);
  opacity: 0.7;
}

form.control.control-failed button {
  border-color: var(--danger);
}

.run-of-show:where(.compact) > li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  min-width: 0;
}

.ros-text {
  min-width: 0;
  flex: 1 1 8rem;
}

.run-of-show.compact form {
  min-width: 0;
  max-width: 100%;
}

.run-of-show:where(.compact) > li:where(.current) {
  font-weight: 700;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  padding-left: calc(1rem - 4px);
}

.run-of-show:where(.compact) > li:where(.current) .badge {
  background: var(--surface-raised);
  border-color: var(--border-strong);
}

.run-of-show:where(.compact) > li:where(.current) .ros-text::before {
  content: "▶ " / "";
}

.end-session {
  margin-top: 1.5rem;
}

.modqueue ul {
  list-style: none;
  padding: 0;
}

.mod-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.9rem;
  margin: 0 0 0.75rem;
}

.mod-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.live-controls {
  margin: 0 0 1rem;
}

a.button.big {
  display: flex;
  min-height: 3.5rem;
  margin: 0 0 0.75rem;
}

/* ---- Quiz ---------------------------------------------------------------------------- */

.badge-quiz {
  font-weight: 600;
}

.countdown {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.countdown.cd-urgent {
  color: var(--danger);
}

.screen .countdown {
  font-size: 2em;
}

.results-table tr.correct th[scope="row"] {
  font-weight: 700;
}

.correct-mark {
  color: var(--ok);
  font-weight: 700;
}

.quiz-result {
  background: var(--surface-raised);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.quiz-result.quiz-correct {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.quiz-result.quiz-wrong {
  border-color: var(--danger);
  background: var(--error-bg);
}

.quiz-verdict {
  font-size: 1.25rem;
  font-weight: 700;
}

.compare-note {
  color: var(--muted);
}

.quiz-fields {
  margin: 0 0 1rem;
}

.quiz-fields fieldset,
.advanced-fields fieldset {
  border: 0;
  padding: 0;
  margin: 0.75rem 0;
  min-width: 0;
}

.quiz-fields legend,
.advanced-fields legend {
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.podium {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2vw;
  justify-content: center;
  align-items: flex-end;
  margin: 2vh 0;
}

.podium-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 1rem 1rem 0 0;
  padding: 1rem 2rem;
  text-align: center;
  flex: 0 1 14rem;
  min-width: 0;
}

.podium .podium-1 {
  background: var(--warm-soft);
  color: var(--warm-fg);
  border: 2px solid var(--warm);
  order: 2;
  min-height: 14rem;
  font-size: 1.4em;
}

.podium .podium-2 {
  order: 1;
  min-height: 10rem;
}

.podium .podium-3 {
  order: 3;
  min-height: 8rem;
}

.podium-rank,
.podium-points {
  display: block;
  font-weight: 800;
}

.lb-table {
  max-width: 48rem;
  margin: 0 auto;
}

/* Rank changes animate with same-document View Transitions where supported. */
.lb-row,
.podium-item {
  view-transition-name: match-element;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

/* ---- Q&A ------------------------------------------------------------------------------- */

.qa {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.qa-list {
  list-style: none;
  padding: 0;
}

.qa-item {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.9rem;
  margin: 0 0 0.75rem;
}

.qa-text {
  margin: 0 0 0.25rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.qa-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.qa-meta :where(button) {
  min-height: 2rem;
  padding: 0.25rem 0.75rem;
  box-shadow: none;
}

.qa-answered {
  background: var(--surface);
  color: var(--muted);
}

.qa-pending {
  border-style: dashed;
}

.qa-wall .qa-list {
  max-width: 60rem;
  margin: 0 auto;
}

.qa-wall .qa-item {
  font-size: 1.4em;
  display: flex;
  justify-content: space-between;
  gap: 2rem;
}

.qa-votes {
  font-weight: 700;
  white-space: nowrap;
}

/* ---- PowerPoint add-in (display only) ------------------------------------------------- */

body.addin-body main.addin {
  max-width: none;
  padding: 0.75rem;
}

/* Slide show view is passive: nothing focusable, no pointer interaction, large type. */
body.addin-show {
  cursor: none;
  user-select: none;
}

body.addin-show * {
  pointer-events: none;
}

.addin-view {
  display: flex;
  gap: 4vw;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  min-height: 90vh;
  font-size: clamp(1rem, 4vw, 3rem);
}

.addin-qr {
  width: min(70vh, 40vw);
  height: auto;
  background: var(--qr-bg);
  padding: 0.5rem;
  border-radius: var(--radius);
}

.addin-text p {
  margin: 0.2em 0;
}

.addin-host {
  font-weight: 700;
}

.addin-code {
  display: inline-block;
  font-size: 2em;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-on-soft);
  background: var(--accent-soft);
  border-radius: var(--radius-pill);
  padding: 0.05em 0.35em 0.05em 0.47em;
}

.addin-current {
  font-size: 0.6em;
  color: var(--muted);
}

/* Presenter task navigation (one segmented bar) and read-only previews. */
.session-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  width: fit-content;
  max-width: 100%;
  padding: 0.25rem;
  margin: 0.25rem 0 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.session-nav a {
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-pill);
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
}
.session-nav a:hover {
  color: var(--accent);
}
.session-nav a[aria-current="page"] {
  background: var(--surface-raised);
  color: var(--accent-on-soft);
  font-weight: 700;
  /* The raised segment alone is too faint in dark mode; the border keeps it visible and leaves
     the outline to keyboard focus. */
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.sharing-qr {
  display: block;
  background: var(--qr-bg);
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
  height: auto;
}
select {
  font: inherit;
  max-width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface-raised);
  color: var(--fg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.correct-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.4rem;
}
.correct-option > input[name="correct_choice"] {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}
.question-preview {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin: 1rem 0 2rem;
}
.question-preview .screen-head {
  flex-wrap: wrap;
  gap: 0.5rem;
}
.question-summary {
  margin: 1.25rem 0;
  padding: 0.25rem 1.25rem 0.75rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

/* Export downloads: a button and what the file is for. */
.export-links {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
}

.export-links li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  align-items: center;
  margin: 0 0 0.6rem;
}

.report-qa {
  padding-left: 1.25rem;
}

.report-qa li {
  margin: 0 0 0.4rem;
}
.question-options {
  list-style: none;
  padding: 0;
}
.results-hidden .question-options li {
  padding: 0.4rem 0;
}
/*
 * The optional small join QR sits top right beside the question only; results and the join line
 * below use the full width. The server sets .with-qr, so no :has() is needed.
 */
.screen-question.with-qr {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 2.5vw;
  align-items: start;
}
.screen-question.with-qr > * {
  grid-column: 1 / -1;
}
.screen-question.with-qr > .prompt {
  grid-column: 1;
}
.screen-question.with-qr > .question-qr {
  grid-column: 2;
  grid-row: 1;
  width: clamp(6rem, 10vw, 10rem);
  height: auto;
  background: var(--qr-bg);
  padding: 0.4rem;
  margin-top: 3vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Hidden results on the projector still list the options, as quiet cards. */
.screen .results-hidden .question-options li {
  background: var(--surface-raised);
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 0.5rem 1rem;
  margin: 0 0 0.5rem;
}

/* Keep server-disabled buttons disabled when the request's temporary lock is released. */
.control-fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

/* Remote grid: buttons in a row share one height; only grid buttons are rounded rectangles. */
.control-grid form.control,
.control-grid .control-fieldset {
  display: grid; /* grid items stretch in both directions */
  height: 100%;
}

.control-grid form.control button.big {
  border-radius: var(--radius-lg);
}

/* Inset groups: one container, hairline row separators, no per-row boxes. */
.run-of-show.compact,
.remotes,
.session-buttons,
.settings-group {
  list-style: none;
  padding: 0;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.run-of-show.compact > li:first-child,
.session-buttons > li:first-child > a {
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
}

.run-of-show.compact > li:last-child,
.session-buttons > li:last-child > a {
  border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px);
}

.run-of-show.compact > li:only-child,
.session-buttons > li:only-child > a {
  border-radius: calc(var(--radius-lg) - 1px);
}

.settings-group {
  margin: 0 0 1rem;
  padding-bottom: 1rem;
}

.settings-group > .field {
  margin: 0;
  padding: 1rem;
}

.settings-group > :where(button) {
  margin: 0 1rem;
  max-width: calc(100% - 2rem);
}

.session-buttons :where(a).button.big {
  justify-content: flex-start;
  flex-wrap: nowrap;
  text-align: left;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--accent-on-soft);
  box-shadow: none;
}

.session-buttons :where(a).button.big:hover {
  background: var(--accent-soft);
}

/* Rows of a list that lead somewhere end in a chevron, as on phones. */
.session-buttons :where(a).button.big::after {
  content: "›" / "";
  margin-left: auto;
  padding-left: 0.5rem;
  font-size: 1.4em;
  line-height: 1;
}

.session-buttons :where(a) > span {
  flex: 1 1 auto;
  min-width: 0;
}

.session-buttons a code {
  color: var(--muted);
}

.remotes > :where(li) + :where(li),
.session-buttons > :where(li) + :where(li),
.run-of-show.compact > :where(li) + :where(li),
.settings-group > .field + .field {
  border-top: 1px solid var(--border);
}

/* System colours preserve outlines, disabled cues, native switches and keyboard focus. */
@media (forced-colors: active) {
  button,
  a.button,
  .actions > a:not(.button),
  .type-links a,
  .answer .option,
  .session-buttons :where(a).button.big {
    border: 1px solid ButtonText;
  }

  button:disabled,
  .answer button.option:disabled {
    opacity: 1;
    color: GrayText;
    border: 1px dashed GrayText;
  }

  input.switch,
  input.switch:checked {
    appearance: auto;
    width: 1.5rem;
    height: 1.5rem;
    border: 0;
    border-radius: 0;
    background: none;
  }

  input.switch:disabled {
    opacity: 1;
  }

  :focus-visible {
    outline: 3px solid Highlight;
  }

  .session-nav a[aria-current="page"] {
    border-color: CanvasText;
  }
}

/* Palette choice in the settings: one swatch per palette, the name always written next to it. */
.palette-field {
  border: 0;
  padding: 1rem;
  margin: 0;
  min-width: 0;
}

/* Floated, so the legend sits inside the group instead of on the separator line above it. */
.palette-field legend {
  float: left;
  width: 100%;
  font-weight: 600;
  padding: 0;
  margin: 0 0 0.25rem;
}

.palette-field > .hint {
  clear: both;
}

.palette-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Two classes: the general ".field label" rule must not turn the options into blocks. */
.palette-options .palette-option {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.35rem 0.9rem 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  cursor: pointer;
  font-weight: 500;
}

.palette-options .palette-option:has(input:checked) {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  font-weight: 700;
}

.palette-option .swatch {
  display: inline-block;
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  border: 2px solid var(--accent-soft);
}

/* Nickname suggestions: one tap saves one; the own-name field follows. */
.nickname-suggestions {
  margin: 0 0 1.25rem;
}

.suggestions-label {
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

/* Learning progress (ADR 0019) */
.learning-chart {
  display: block;
  width: 100%;
  height: auto;
}
.learning-grid {
  stroke: var(--border);
  stroke-width: 1;
}
.learning-line {
  stroke: var(--accent);
  stroke-width: 2;
}
.learning-point {
  fill: var(--accent);
}
.learning-label {
  fill: var(--muted);
  font-size: 18px; /* viewBox units: readable once the chart shrinks on phones */
}
.learning-progress caption {
  text-align: left;
  font-weight: 600;
  margin-block: 0.5rem;
}

/* Key figures first: the change in percentage points, large, with the two values beside it. */
.learning-figure {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: 28rem;
  margin: 0.75rem 0 1rem;
  padding: 0.9rem 1rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.learning-figure-label {
  color: var(--muted);
  font-size: 0.925rem;
}

.learning-figure-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.learning-figure-detail {
  font-variant-numeric: tabular-nums;
}

/* Six columns fit the dashboard width when headers may wrap; row headers break at syllables. */
.learning-progress thead th {
  white-space: normal;
  overflow-wrap: normal;
  hyphens: auto;
}

/* On phones the table scrolls sideways (it takes focus), so headers stay on one line. */
@media (max-width: 40rem) {
  .learning-progress thead th {
    white-space: nowrap;
  }
}

.learning-progress tbody th {
  overflow-wrap: normal;
  hyphens: auto;
}

.learning-progress td.learning-prompt {
  min-width: 10rem;
}

/* A short radio group inside a form (e.g. learning phase): one choice per line, 24 px targets. */
.choice-field {
  border: 0;
  padding: 0;
  margin: 0 0 1rem;
  min-width: 0;
}

.choice-field legend {
  font-weight: 600;
  padding: 0;
}

.choice-field .choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  font-weight: 400;
}

.choice-field label.choice input {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
}

/* Learning progress on the beamer (ADR 0020): one large number, then bars like the results. */
.learning-screen-headline {
  display: flex;
  flex-direction: column;
  gap: 0.1em;
  margin: 0.25em 0 0.75em;
}

.learning-screen-value {
  font-size: 2.6em;
  font-weight: 800;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.learning-screen-label {
  color: var(--muted);
}

/* Scaled with the beamer's type (em), so the rows and the group-data note read from the back. */
.learning-screen .results-table tbody {
  font-size: 1.25em;
}

.learning-screen .results-table .num {
  font-weight: 700;
}

.learning-screen .hint {
  font-size: 0.9em;
}

/* ---- Slides (ADR 0021, 0022) ------------------------------------------------------------ */

/* The beamer gives a slide the whole screen; the header stays for screen readers only. */
main.screen:has(.with-slide) {
  padding: 0;
}

.screen-stage.with-slide .screen-head {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.screen-slide {
  position: relative;
  display: grid;
  place-items: center;
  height: 100vh;
  overflow: hidden;
  background: #000;
}

.screen-slide:has(.md-slide) {
  background: var(--bg);
}

.slide-image {
  display: block;
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.slide-join {
  position: absolute;
  right: 1.5vw;
  bottom: 1.5vh;
  margin: 0;
  padding: 0.2em 0.8em;
  font-size: 0.75em;
  color: var(--fg);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}

/* Markdown slides: fixed 16:9, every size scales with the slide's width (container units). */
.md-slide {
  container-type: inline-size;
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  color: var(--fg);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.screen-slide .md-slide {
  width: min(100vw, calc(100vh * 16 / 9));
  border: 0;
  border-radius: 0;
}

.md-body {
  position: relative;
  box-sizing: border-box;
  height: 100%;
  padding: 5cqw 6cqw;
  font-size: 2.6cqw;
  line-height: 1.35;
  overflow: hidden;
}

.md-body > :first-child {
  margin-top: 0;
}

.md-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 4cqw;
  align-content: start;
}

.md-column {
  min-width: 0;
}

.md-layout-choice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-block: 0.4rem;
}

.md-body h2 {
  font-size: 5cqw;
  line-height: 1.15;
  margin: 0 0 2cqw;
}

.md-body h3 {
  font-size: 4cqw;
  line-height: 1.2;
  margin: 0 0 1.6cqw;
  color: var(--accent);
}

.md-body h4 {
  font-size: 3.2cqw;
  margin: 0 0 1.2cqw;
}

.md-body p,
.md-body ul,
.md-body ol,
.md-body blockquote,
.md-body table,
.md-body pre {
  margin: 0 0 1.4cqw;
}

.md-body ul,
.md-body ol {
  padding-left: 1.4em;
}

/* Task lists: the checkbox replaces the bullet. */
.md-body li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.2em;
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.md-body li + li {
  margin-top: 0.3em;
}

.md-body li input[type="checkbox"] {
  width: 0.85em;
  height: 0.85em;
  accent-color: var(--accent);
  margin: 0 0.4em 0 0;
  vertical-align: -0.05em;
}

.md-body blockquote {
  padding-left: 1em;
  border-left: 0.3cqw solid var(--accent);
  color: var(--muted);
}

.md-code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.md-body code {
  font-family: var(--font-mono);
  font-size: 0.85em;
}

.md-code {
  padding: 1cqw 1.4cqw;
  background: var(--surface);
  border-radius: var(--radius);
  white-space: pre-wrap;
}

.md-table {
  border-collapse: collapse;
  font-size: 0.9em;
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.md-table th,
.md-table td {
  padding: 0.3em 0.8em;
  border-bottom: 1px solid var(--border-strong);
  text-align: left;
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.md-table th {
  background: var(--surface);
}

.md-table .md-align-center {
  text-align: center;
}

.md-table .md-align-right {
  text-align: right;
}

.md-img {
  display: block;
  max-width: 100%;
  max-height: 32cqw;
  object-fit: contain;
}

.md-missing-image {
  display: inline-block;
  padding: 0.2em 0.6em;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}

.md-link {
  text-decoration: underline;
}

/* Title slide: centred. */
.md-title .md-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.md-title .md-body h2 {
  font-size: 6.4cqw;
}

/* Background image (Marp ![bg]): the text sits on a solid panel so it stays readable. */
.md-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.md-bg .md-body:not(:empty) {
  height: auto;
  max-height: calc(100% - 6cqw);
  margin: 3cqw;
  padding: 3cqw 4cqw;
  background: var(--surface-raised);
  border-radius: var(--radius);
}

/* Remote: the current slide, the next one and the notes. */
.nav-grid {
  grid-template-columns: 2fr 1fr;
}

.slide-thumb {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.slide-thumb img,
.slide-thumb-img {
  width: 160px;
  height: auto;
  border: 1px solid var(--border-strong);
  border-radius: 0.375rem;
  background: var(--surface);
}

.slide-thumb.small img {
  width: 96px;
}

.up-next {
  margin-top: 0.5rem;
}

.slide-notes {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.75rem;
  white-space: pre-wrap;
  background: var(--surface-raised);
  border-left: 3px solid var(--accent);
  border-radius: 0.25rem;
}

/* Prepare: slides in the run of show. */
.slides-section {
  margin-bottom: 2rem;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.upload-form .field {
  margin: 0;
}

.ros-slide .slide-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.ros-slide .slide-row p {
  margin: 0;
}

/* Notes and "+ Frage hier einfügen" as two small links side by side, not two full bars. */
.slide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.5rem;
  margin-top: 0.25rem;
}

.slide-actions > details {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
}

.slide-actions > details[open] {
  flex-basis: 100%;
  padding-bottom: 0.5rem;
}

.slide-actions summary {
  color: var(--accent-on-soft);
  font-weight: 600;
  min-height: 2rem;
}

.slide-notes-edit textarea {
  width: 100%;
  margin-bottom: 0.5rem;
}

/* New version: what changes (label in text, colour only as an extra). */
.replace-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  padding: 0;
  list-style: none;
}

.change-table td {
  padding: 0.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.change-new td:nth-child(2),
.change-changed td:nth-child(2) {
  font-weight: 600;
  color: var(--accent-on-soft);
}

.change-remove td:nth-child(2) {
  font-weight: 600;
  color: var(--danger);
}

/* Markdown editor: text and preview side by side on wide screens. */
.md-editor {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 64rem) {
  .md-editor {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
}

.md-text {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.md-preview-list {
  display: grid;
  gap: 1rem;
  padding: 0;
  list-style: none;
}

.md-warnings {
  padding-left: 1.25rem;
  color: var(--warm-fg);
}

.md-images {
  display: grid;
  gap: 0.75rem;
  padding: 0;
  list-style: none;
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.md-images li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.md-images img {
  height: auto;
  border: 1px solid var(--border);
  border-radius: 0.25rem;
}

.md-template {
  white-space: pre-wrap;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

/* The presenter's slide show (clicker page): a small tool bar that disappears in full screen. */
.present-tools {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  z-index: 1;
  max-width: 28rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* biome-ignore lint/style/noDescendingSpecificity: a different component than the earlier rule */
.present-tools p {
  margin: 0.5rem 0 0;
}

:fullscreen .present-tools {
  display: none;
}

/* "Position im Ablauf": many slides, so the choices scroll inside the form. */
.position-options {
  max-height: 16rem;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Selected Markdown slide editor (ADR 0023 stage 1). */
main:has(.md-slide-editor) {
  max-width: 100rem;
}
.md-slide-editor {
  display: grid;
  grid-template-columns: minmax(10rem, 0.6fr) minmax(16rem, 1fr) minmax(20rem, 1.5fr);
  gap: 1.5rem;
  align-items: start;
  margin-block: 1.5rem;
}
.md-slide-field,
.md-slide-preview,
.md-slide-outline {
  min-width: 0;
}
.md-slide-outline > summary {
  display: none;
}
.md-slide-outline ol {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}
/* biome-ignore lint/style/noDescendingSpecificity: separate editor component */
.md-slide-outline button {
  width: 100%;
  text-align: start;
  display: grid;
  white-space: normal;
  overflow-wrap: anywhere;
  border-radius: var(--radius);
}
.md-slide-outline [aria-current] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-on-soft);
}
/* biome-ignore lint/style/noDescendingSpecificity: separate editor component */
.md-slide-field h2 {
  margin-top: 0;
}
.md-slide-preview {
  padding: 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
}
.md-whole-document {
  margin-block: 1.5rem;
}
@media (max-width: 900px) {
  .md-slide-editor {
    grid-template-columns: minmax(0, 1fr);
  }
  .md-slide-outline > summary {
    display: list-item;
  }
}
