:root {
  --grund: #f4f5f7;
  --flaeche: #ffffff;
  --text: #1b1f24;
  --leise: #5d6672;
  --linie: #dde1e6;
  --akzent: #1f6feb;
  --akzent-text: #ffffff;
  --gut: #1a7f37;
  --gefahr: #c62828;
  --warnung: #9a6700;
  --raum-grund: #111418;
  --raum-flaeche: #1b2026;
  --raum-linie: #2c333b;
  --raum-text: #e8ebef;
  --raum-leise: #9aa4af;
  --radius: 10px;
  --schrift: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --grund: #111418;
    --flaeche: #1b2026;
    --text: #e8ebef;
    --leise: #9aa4af;
    --linie: #2c333b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--schrift);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background: var(--grund);
}
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0.2rem 0 0.4rem; }
.leise { color: var(--leise); }
.klein { font-size: 0.85rem; }

/* ---- Knöpfe ---- */
.knopf {
  font: inherit;
  font-size: 0.95rem;
  border: 1px solid var(--raum-linie);
  background: var(--raum-flaeche);
  color: var(--raum-text);
  border-radius: var(--radius);
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  min-height: 44px;
}
.knopf:hover { filter: brightness(1.15); }
.knopf:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--akzent); outline-offset: 2px; }
.knopf:disabled { opacity: 0.5; cursor: default; }
.knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf.gefahr { background: var(--gefahr); border-color: var(--gefahr); color: #fff; }
.knopf.gefahr-leise { color: #ff8a80; }
.knopf.warnung { background: var(--warnung); border-color: var(--warnung); color: #fff; }
.knopf.an { background: #23415f; border-color: var(--akzent); }
.knopf.gross { width: 100%; font-size: 1.1rem; padding: 0.8rem; min-height: 52px; }
.knopf.klein { font-size: 0.8rem; min-height: 32px; padding: 0.25rem 0.6rem; }

/* ---- Eintritt, Warten, Ende ---- */
.karte-seite { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.karte {
  width: 100%;
  max-width: 440px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 14px;
  padding: 28px 24px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 0.06);
}
.karte .knopf { border-color: var(--linie); background: var(--flaeche); color: var(--text); }
.karte .knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.marke { margin: 0; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--leise); }
label { display: block; font-weight: 600; margin: 1.2rem 0 0.35rem; }
input, textarea {
  font: inherit;
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--grund);
  color: var(--text);
}
#eintritt-name { font-size: 1.15rem; }
.fehler { color: var(--gefahr); font-weight: 600; margin: 0.5rem 0 0; }
.hinweis-referent { background: #e8f0fe; color: #174ea6; padding: 0.5rem 0.7rem; border-radius: var(--radius); font-size: 0.9rem; }
@media (prefers-color-scheme: dark) { .hinweis-referent { background: #1d2b44; color: #a8c7fa; } }
.karte .knopf.gross { margin-top: 0.6rem; }
.puls { width: 14px; height: 14px; border-radius: 50%; background: var(--akzent); margin: 1rem auto 0; animation: puls 1.6s ease-in-out infinite; }
@keyframes puls { 50% { transform: scale(1.6); opacity: 0.4; } }

/* ---- Meldung ---- */
.meldung {
  position: fixed; z-index: 50; left: 50%; top: 16px; transform: translateX(-50%);
  max-width: min(560px, calc(100% - 32px));
  background: #24292f; color: #fff; padding: 0.7rem 1rem; border-radius: var(--radius);
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.3); font-size: 0.95rem;
}

/* ---- Raum ---- */
.raum {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 340px;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: 'kopf kopf' 'ref ref' 'buehne seite' 'fuss fuss';
  background: var(--raum-grund);
  color: var(--raum-text);
}
.kopf { grid-area: kopf; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--raum-linie); min-width: 0; }
.raum-titel { font-size: 1.05rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { background: var(--warnung); color: #fff; border-radius: 999px; padding: 0.15rem 0.7rem; font-size: 0.85rem; }
.anzahl { color: var(--raum-leise); font-size: 0.9rem; white-space: nowrap; }

.referent-leiste { grid-area: ref; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 16px; background: #161b21; border-bottom: 1px solid var(--raum-linie); }
.start-hinweis { color: #ffd479; font-weight: 600; }
.schalter { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; font-size: 0.9rem; cursor: pointer; }
.schalter input { width: 18px; height: 18px; }

.buehne-bereich { grid-area: buehne; position: relative; display: flex; flex-direction: column; min-height: 0; min-width: 0; padding: 12px; gap: 10px; }
.buehne { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; background: #000; border-radius: var(--radius); overflow: hidden; }
.buehne video { width: 100%; height: 100%; object-fit: contain; }
.buehne-leer { color: var(--raum-leise); text-align: center; padding: 16px; }
.buehne-unterschrift { position: absolute; left: 24px; top: 20px; margin: 0; background: rgb(0 0 0 / 0.55); color: #fff; font-size: 0.8rem; padding: 0.15rem 0.55rem; border-radius: 6px; }
.bild-im-bild { position: absolute; right: 24px; bottom: 24px; width: min(22%, 240px); aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; border: 2px solid rgb(255 255 255 / 0.25); background: #000; box-shadow: 0 4px 16px rgb(0 0 0 / 0.5); }
.buehne-bereich:has(.kamera-leiste:not([hidden])) .bild-im-bild { bottom: 150px; }
.bild-im-bild video { width: 100%; height: 100%; object-fit: cover; }
.kamera-leiste { display: flex; gap: 8px; overflow-x: auto; flex: 0 0 auto; }
.kachel { position: relative; flex: 0 0 auto; width: 200px; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; border: 2px solid transparent; }
.kachel.spricht { border-color: var(--gut); }
.kachel video { width: 100%; height: 100%; object-fit: cover; }
.kachel-name { position: absolute; left: 6px; bottom: 6px; background: rgb(0 0 0 / 0.6); color: #fff; font-size: 0.75rem; padding: 0.05rem 0.4rem; border-radius: 4px; }

.seitenleiste { grid-area: seite; display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--raum-linie); background: var(--raum-flaeche); }
.reiter { display: flex; border-bottom: 1px solid var(--raum-linie); }
.reiter-knopf { flex: 1; font: inherit; font-size: 0.95rem; background: none; border: 0; color: var(--raum-leise); padding: 0.75rem; cursor: pointer; border-bottom: 2px solid transparent; position: relative; }
.reiter-knopf.aktiv { color: var(--raum-text); border-bottom-color: var(--akzent); }
.punkt { display: inline-block; width: 8px; height: 8px; background: var(--akzent); border-radius: 50%; margin-left: 6px; vertical-align: middle; }
.tafel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.chat-liste { list-style: none; margin: 0; padding: 12px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.chat-leer { color: var(--raum-leise); font-size: 0.9rem; }
.chat-zeile { background: #222831; border-radius: 8px; padding: 0.45rem 0.65rem; }
.chat-zeile.von-referent { background: #1d2b44; border-left: 3px solid var(--akzent); }
.chat-zeile.eigene { background: #23302a; }
.chat-kopf { display: flex; justify-content: space-between; gap: 8px; font-size: 0.8rem; color: var(--raum-leise); }
.chat-kopf strong { color: var(--raum-text); font-weight: 600; }
.chat-text { margin: 0.15rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.95rem; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--raum-linie); }
.chat-form textarea { resize: none; background: var(--raum-grund); color: var(--raum-text); border-color: var(--raum-linie); font-size: 0.95rem; }
.personen-liste { list-style: none; margin: 0; padding: 8px 12px; overflow-y: auto; }
.person { padding: 8px 0; border-bottom: 1px solid var(--raum-linie); }
.person-kopf { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.person.spricht .person-name { color: #7ee2a8; }
.mic-punkt { width: 10px; height: 10px; border-radius: 50%; background: #4b535c; flex: 0 0 auto; }
.mic-punkt.an { background: var(--gut); }
.abzeichen { font-size: 0.72rem; background: #1d2b44; color: #a8c7fa; padding: 0.05rem 0.45rem; border-radius: 999px; }
.person-aktionen { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

.fuss { grid-area: fuss; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--raum-linie); }
.knopf.mic { display: inline-flex; align-items: center; gap: 10px; padding: 0.5rem 1.2rem; min-height: 56px; min-width: 230px; background: #2a3038; }
.knopf.mic.an { background: var(--gut); border-color: var(--gut); }
.mic-text { display: flex; flex-direction: column; text-align: left; line-height: 1.2; }
.mic-text small { color: rgb(255 255 255 / 0.75); font-size: 0.78rem; }
.mic-symbol { width: 22px; height: 22px; flex: 0 0 auto; background: currentColor; mask: url('/mic.svg') center / contain no-repeat; }
.knopf.mic:not(.an) .mic-symbol { mask-image: url('/mic-aus.svg'); }

/* ---- Schmal: Handy ---- */
/* Handy: Bühne oben in 16:9, Chat direkt darunter (Prämisse 2) */
@media (max-width: 820px) {
  .raum { grid-template-columns: 1fr; grid-template-rows: auto auto auto minmax(0, 1fr) auto; grid-template-areas: 'kopf' 'ref' 'buehne' 'seite' 'fuss'; }
  .seitenleiste { border-left: 0; border-top: 1px solid var(--raum-linie); }
  .buehne-bereich { padding: 8px; }
  .buehne { flex: 0 0 auto; aspect-ratio: 16 / 9; }
  .bild-im-bild { width: 28%; right: 14px; bottom: 14px; }
  .buehne-unterschrift { left: 14px; top: 12px; }
  .kachel { width: 120px; }
  .knopf.mic { min-width: 0; flex: 1 1 auto; justify-content: center; }
  .referent-leiste { font-size: 0.85rem; }
  .chat-form textarea { font-size: 16px; } /* verhindert Zoom beim Tippen auf iOS */
}
@media (orientation: landscape) and (max-height: 500px) {
  .raum { grid-template-columns: 1fr 260px; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-areas: 'kopf kopf' 'ref ref' 'buehne seite' 'fuss fuss'; }
  .buehne { aspect-ratio: auto; flex: 1; }
}

/* ---- Marke: Organisationslogo (z. B. GST) und dezente kappa1-Signatur ---- */
.org-logo-karte { display: block; max-height: 56px; max-width: 220px; margin: 0 0 14px; object-fit: contain; }
@media (prefers-color-scheme: dark) {
  .org-logo-karte { background: #fff; padding: 6px 10px; border-radius: 8px; }
}
.signatur {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--linie);
  font-size: 0.78rem; letter-spacing: 0.04em; color: var(--leise);
}
.signatur img { height: 18px; width: auto; display: block; opacity: 0.9; }
.signatur b { font-weight: 600; color: #2f7fc0; }
@media (prefers-color-scheme: dark) { .signatur b { color: #58b6ea; } }
.hinweis-aufnahme { margin: 0.6rem 0 0; }

.org-chip { height: 30px; max-width: 140px; object-fit: contain; background: #fff; padding: 3px 8px; border-radius: 6px; flex: 0 0 auto; }
.signatur-raum { display: inline-flex; align-items: center; gap: 4px; padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--raum-linie); color: var(--raum-leise); font-size: 0.75rem; letter-spacing: 0.06em; opacity: 0.75; }
.signatur-raum img { height: 18px; width: auto; display: block; }
.aufnahme-zeichen { display: inline-flex; align-items: center; gap: 6px; color: #ff6b6b; font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.aufnahme-zeichen::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: #ff4d4d; animation: puls 1.6s ease-in-out infinite; }
/* Zeitmarken (Prämisse 40): Knopf mit kleinem Menü, Pause-Hinweis im Kopf */
.marken { position: relative; display: inline-block; }
.marken-menue { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; min-width: 200px; display: flex; flex-direction: column; background: #1d2530; border: 1px solid var(--raum-linie); border-radius: 10px; padding: 4px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.marken-eintrag { font: inherit; font-size: 0.9rem; text-align: left; background: none; border: 0; color: inherit; padding: 0.55rem 0.8rem; border-radius: 7px; cursor: pointer; }
.marken-eintrag:hover, .marken-eintrag:focus-visible { background: #2a3a52; outline: none; }
.marken-eintrag.an { color: #ffd166; }
.pause-zeichen { background: #5a4a12; white-space: nowrap; }
.knopf.aufnahme { color: #ff8a80; }
.knopf.aufnahme.an { background: #4a1f1f; border-color: #ff4d4d; color: #fff; }
@media (max-width: 820px) {
  .signatur-raum span { display: none; }
  .org-chip { height: 24px; max-width: 90px; }
  .anzahl { display: none; }
}

/* ---- Umfragen (Prämissen 20–23) ---- */
.umfrage-ebene { position: absolute; inset: 12px; z-index: 5; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.umfrage-ebene > * { pointer-events: auto; }
.umfrage-karte {
  width: min(640px, 100%); max-height: 100%; overflow-y: auto;
  background: rgb(22 27 34 / 0.97); color: var(--raum-text);
  border: 1px solid #2f7fc0; border-radius: 14px; padding: 16px 18px;
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.55);
}
.umfrage-kopf { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.umfrage-marke { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: #58b6ea; font-weight: 700; }
.umfrage-anzahl { font-size: 0.85rem; color: var(--raum-leise); }
.umfrage-einklappen { margin-left: auto; font: inherit; font-size: 0.8rem; background: none; border: 1px solid var(--raum-linie); color: var(--raum-leise); border-radius: 8px; padding: 0.2rem 0.6rem; cursor: pointer; }
.umfrage-text { font-size: 1.2rem; line-height: 1.35; margin: 0 0 12px; }
.umfrage-optionen { display: flex; flex-direction: column; gap: 8px; }
.umfrage-optionen.typ-ja-nein { flex-direction: row; }
.umfrage-optionen.typ-ja-nein .umfrage-option { flex: 1; justify-content: center; font-size: 1.1rem; }
.umfrage-option {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px;
  font: inherit; text-align: left; color: var(--raum-text); background: #232a33;
  border: 2px solid #343d48; border-radius: 10px; padding: 0.7rem 0.9rem; min-height: 50px; cursor: pointer;
}
.umfrage-option:hover:not(:disabled) { border-color: #58b6ea; }
.umfrage-option:disabled { cursor: default; opacity: 1; }
.umfrage-option.gewaehlt { border-color: var(--akzent); background: #1d2b44; }
.umfrage-option.richtig { border-color: var(--gut); }
.umfrage-option > *:not(.umfrage-balken) { position: relative; }
.umfrage-balken { position: absolute; inset: 0 auto 0 0; background: rgb(47 127 192 / 0.35); transition: width 0.5s ease; }
.umfrage-option.richtig .umfrage-balken { background: rgb(26 127 55 / 0.45); }
.umfrage-buchstabe { flex: 0 0 auto; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #343d48; font-weight: 700; font-size: 0.9rem; }
.umfrage-option.gewaehlt .umfrage-buchstabe { background: var(--akzent); }
.umfrage-optionstext { flex: 1; }
.umfrage-prozent { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.umfrage-haken { color: #7ee2a8; font-weight: 700; font-size: 1.1rem; }
.umfrage-bild { position: relative; width: 100%; background: #000; border-radius: 10px; overflow: hidden; user-select: none; }
.umfrage-bild img { display: block; width: 100%; height: 100%; object-fit: contain; }
.umfrage-bild.klickbar { cursor: crosshair; }
.umfrage-punkt, .umfrage-eigener-punkt { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: rgb(255 196 0 / 0.85); border: 1px solid #000; pointer-events: none; }
.umfrage-eigener-punkt { width: 18px; height: 18px; margin: -9px 0 0 -9px; background: var(--akzent); border: 3px solid #fff; box-shadow: 0 0 0 2px #000; }
.umfrage-zone { position: absolute; transform: translate(-50%, -50%); border: 3px solid #7ee2a8; border-radius: 50%; box-shadow: 0 0 0 2px #000; pointer-events: none; }
.umfrage-fuss { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.umfrage-hinweis { font-size: 0.88rem; color: var(--raum-leise); }
strong.umfrage-hinweis { color: #7ee2a8; font-size: 1.05rem; }
.umfrage-pille { align-self: flex-end; margin-right: auto; font: inherit; font-size: 0.9rem; background: var(--akzent); color: #fff; border: 0; border-radius: 999px; padding: 0.5rem 1rem; cursor: pointer; box-shadow: 0 4px 16px rgb(0 0 0 / 0.4); }

/* Reiter „Umfragen“ für Referierende */
.umfragen-suche { padding: 10px; border-bottom: 1px solid var(--raum-linie); }
.umfragen-suche input { background: var(--raum-grund); color: var(--raum-text); border-color: var(--raum-linie); font-size: 0.9rem; padding: 0.5rem 0.7rem; }
.fragen-liste { list-style: none; margin: 0; padding: 8px 12px; overflow-y: auto; flex: 1; }
.frage-zeile { padding: 8px 0; border-bottom: 1px solid var(--raum-linie); }
.frage-kopf { display: flex; gap: 8px; align-items: center; }
.frage-code { font-family: ui-monospace, Menlo, monospace; font-size: 0.78rem; background: #1d2b44; color: #a8c7fa; padding: 0.05rem 0.4rem; border-radius: 4px; }
.frage-text { margin: 4px 0 6px; font-size: 0.9rem; }
.spontan-form { padding: 10px 12px; border-top: 1px solid var(--raum-linie); display: flex; flex-direction: column; gap: 6px; }
.spontan-form strong { font-size: 0.85rem; }
.spontan-form input { background: var(--raum-grund); color: var(--raum-text); border-color: var(--raum-linie); font-size: 0.9rem; padding: 0.45rem 0.6rem; }
.spontan-knoepfe { display: flex; flex-wrap: wrap; gap: 6px; }

@media (max-width: 820px) {
  /* Blatt endet über der Fusszeile, damit Mikrofon und „Verlassen“ erreichbar bleiben */
  .umfrage-ebene { position: fixed; inset: auto 0 calc(76px + env(safe-area-inset-bottom)) 0; z-index: 30; padding: 8px; max-height: 70vh; align-items: flex-end; }
  body.folienlink .umfrage-ebene, .folienlink-umfrage { position: static; }
  .umfrage-karte { max-height: calc(70vh - 16px); }
  .umfrage-text { font-size: 1.05rem; }
}

/* Folienlink-Seite (/f/CODE) */
body.folienlink { background: var(--raum-grund); color: var(--raum-text); }
.folienlink-seite { max-width: 760px; margin: 0 auto; padding: 16px; }
.folienlink-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.folienlink-meldung { background: var(--raum-flaeche); border: 1px solid var(--raum-linie); border-radius: 12px; padding: 16px; line-height: 1.5; }
.folienlink-umfrage .umfrage-karte { width: 100%; }
.folienlink-zurueck { margin-top: 12px; }
.kalender-link { display: inline-block; margin: -0.2rem 0 0.4rem; color: var(--akzent); }

/* ---- Besprechungen (Schritt 4) ---- */
.buehne.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-content: center; gap: 10px; padding: 10px; background: transparent; }
.buehne.kacheln .kachel { width: auto; }
.kachel.ohne-video { display: grid; place-items: center; background: #222a33; }
.kachel-initialen { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: #2f7fc0; color: #fff; font-size: 1.4rem; font-weight: 700; }
.e2ee-zeichen { font-size: 0.85rem; color: #7ee2a8; white-space: nowrap; cursor: help; }
.wartende { flex: 1 1 100%; display: flex; flex-direction: column; gap: 6px; }
.wartend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #1d2b44; border: 1px solid var(--akzent); border-radius: 10px; padding: 6px 10px; }
.wartend span { font-weight: 600; margin-right: auto; }
@media (max-width: 820px) {
  .buehne.kacheln { grid-template-columns: repeat(2, 1fr); aspect-ratio: auto; }
  .e2ee-zeichen { font-size: 0.75rem; }
}

/* Sprachwahl DE · FR · IT · EN (Prämisse 30) */
.sprachen { display: flex; gap: 4px; justify-content: flex-end; margin: -4px 0 4px; }
.sprache-knopf { background: none; border: 1px solid transparent; border-radius: 6px; padding: 2px 7px; font: inherit; font-size: 0.8rem; color: inherit; opacity: 0.65; cursor: pointer; }
.sprache-knopf:hover { opacity: 1; }
.sprache-knopf.an { opacity: 1; font-weight: 600; border-color: currentColor; }
