:root {
  color-scheme: light;
  --bg: #FAF6F0;
  --panel: #FFFDFA;
  --panel-2: #F4EDE4;
  --fg: #2E2A26;
  --muted: #6F665D;
  --line: #E7DCD0;
  --line-strong: #D8CCC0;
  --accent: #A65B43;
  --accent-dark: #8C4A35;
  --accent-soft: #F3E3DA;
  --sage: #7E9078;
  --ok: #4F7A5C;
  --warn: #8A5A1B;
  --bad: #9C3F38;
  --bad-soft: #F7E3E0;
  --video: #241F1B;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --shadow: 0 1px 2px rgba(70, 45, 25, .06), 0 10px 30px rgba(70, 45, 25, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
body { display: flex; flex-direction: column; min-height: 100vh; }

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 250, .82);
}
.brand {
  font-family: var(--serif);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.brand span { color: var(--muted); font-weight: 400; }
.head-status { display: flex; gap: 16px; align-items: baseline; min-width: 0; }
#status { color: var(--muted); font-size: .9rem; }
#status[data-kind="ok"] { color: var(--ok); }
#status[data-kind="warn"] { color: var(--warn); }
#status[data-kind="bad"] { color: var(--bad); }
#speaking { color: var(--ok); font-size: .9rem; }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 2rem; margin: 0 0 6px; }
h2 { font-size: 1.28rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 18px 0 10px; }

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.lead { color: var(--muted); margin: 0 0 16px; }
.hint { color: var(--muted); font-size: .85rem; margin: 10px 0 0; }
.error {
  background: var(--bad-soft);
  border: 1px solid #E3B9B2;
  color: var(--bad);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: .9rem;
}
.error.ok {
  background: #EDF3EA;
  border-color: #C7D3BF;
  color: #3F5F49;
}

/* --- Lobby --------------------------------------------------------------- */

#lobby {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.welcome { position: sticky; top: 18px; }
.rooms { min-width: 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.field { display: block; margin: 14px 0 0; }
.field > span {
  display: block;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 5px;
}
.field input, .dialog input {
  width: 100%;
  padding: 12px 13px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--fg);
  font: inherit;
}
.field input:focus, .dialog input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 18px 0 0;
  color: var(--fg);
  font-size: .92rem;
  cursor: pointer;
}
.check input {
  width: 19px;
  height: 19px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex: none;
}

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.tabs button { padding: 7px 11px; font-size: .85rem; }
.tabs button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.rooms-body { margin-top: 4px; }
.room-search { margin: 6px 0 4px; }
.room-group h3:first-child { margin-top: 0; }
.room-group-meta {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: .84rem;
}
.room-grid > .room-group { grid-column: 1 / -1; }

.room-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 10px;
}
.room-pager.bottom { margin: 10px 0 0; }
.room-pager .pager-meta { color: var(--muted); font-size: .84rem; }
.room-pager .pager-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.room-pager button { padding: 6px 10px; font-size: .82rem; }
.room-pager select {
  font: inherit;
  font-size: .82rem;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--fg);
}
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.room-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #FFFFFF;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.room-card:hover:not(:disabled) {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.room-card:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.room-card:disabled { opacity: .6; cursor: not-allowed; }
.room-name {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 700;
}
.room-title {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.room-note { color: var(--muted); font-size: .84rem; }
.room-action { margin-top: 3px; color: var(--accent-dark); font-size: .88rem; font-weight: 600; }
.room-state { display: block; font-size: .8rem; color: var(--muted); }
.room-state.open { color: var(--ok); }
.room-state.closed { color: var(--bad); }

/* --- Tasten -------------------------------------------------------------- */

button {
  font: inherit;
  padding: 10px 15px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}
button:hover { background: var(--panel-2); }
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
  border-color: var(--accent);
}
button.primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.quiet { background: #FFFFFF; }
button.small { padding: 7px 11px; font-size: .85rem; }
button.link {
  background: none;
  border: none;
  color: var(--accent-dark);
  text-decoration: underline;
  padding: 6px 8px;
}
button.icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}
button.icon:hover { background: var(--panel-2); }

/* --- Dialoge ------------------------------------------------------------- */

dialog.dialog {
  width: min(560px, 94vw);
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--fg);
  box-shadow: 0 24px 70px rgba(46, 42, 38, .22);
}
dialog.dialog::backdrop { background: rgba(46, 42, 38, .42); }
dialog.dialog.small { width: min(420px, 94vw); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; }
.invite-link {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .8rem;
  background: #F7F0E8;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}
.leader-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.leader-person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.leader-name { flex: 1 1 140px; font-weight: 600; overflow-wrap: anywhere; }
.leader-person .leader-self { color: var(--muted); font-size: .8rem; }
.leader-person button { padding: 6px 9px; font-size: .8rem; }
.leader-person .breakout-group {
  max-width: 110px;
  padding: 5px 7px;
  font-size: .8rem;
}
.leader-empty { margin: 0; color: var(--muted); font-size: .9rem; }

.preview-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: var(--video);
  display: flex;
  align-items: center;
  justify-content: center;
}
#preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.preview-empty { color: #C9BBAD; font-size: .95rem; }
.preview-subtitle { margin: -8px 0 0; color: var(--muted); font-size: .95rem; }
.preview-status { margin: 12px 0 0; color: var(--muted); }

.devices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.device { display: block; font-size: .82rem; color: var(--muted); }
.device > span { display: block; margin-bottom: 4px; }
.device select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--fg);
  font: inherit;
}
.device select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.help { margin-top: 12px; color: var(--muted); font-size: .9rem; }
.help summary { cursor: pointer; color: var(--accent-dark); font-weight: 600; }
.help ol { margin: 10px 0 0; padding-left: 22px; }
.help li { margin: 5px 0; }

/* --- Sitzung ------------------------------------------------------------- */

#session {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 22px 104px;
}
#session.fill-stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 20px;
}
.intro { max-width: 580px; margin: 20px auto; }

.help-card {
  background: #FBF0E6;
  border: 1px solid #E9CFC0;
  border-radius: 16px;
  padding: 18px 20px;
  margin: 0 0 16px;
}
.help-card h2 { font-size: 1.2rem; margin-bottom: 6px; }
.help-card p { margin: 6px 0 0; }
.help-card .help { color: #6E5A4D; }

.tiles {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
  align-content: start;
}
.tiles.fill {
  display: block;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
.tiles.fill figure {
  position: absolute;
  max-width: none;
  margin: 0;
  aspect-ratio: auto;
}
.tiles.fill figure video { width: 100%; height: 100%; }
figure {
  margin: 0 auto;
  width: 100%;
  max-width: 820px;
  position: relative;
  background: var(--video);
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
video { width: 100%; height: 100%; object-fit: contain; display: block; }
figure.self { border: 1px solid var(--sage); }
/* Nur die eigene Kamera ist Selfie-gespiegelt — der eigene Bildschirm nicht. */
figure.self:not(.screen-share) video { transform: scaleX(-1); }
figure.speaking { outline: 2px solid var(--sage); outline-offset: -2px; }

.tiles.speaker { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tiles.speaker figure { max-width: 100%; }
.tiles.speaker figure.spotlight {
  grid-column: 1 / -1;
  order: -1;
  max-width: 100%;
  aspect-ratio: auto;
  height: min(58vh, 620px);
}
.tiles.speaker figure:not(.spotlight) { cursor: pointer; }
.tiles.speaker figure:not(.spotlight) .tile-camera-off { display: none; }
.tiles.speaker figure:not(.spotlight) .tile-avatar { width: 42%; }

figure .pin {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(36, 31, 27, .72);
  color: #F2EAE0;
  font: inherit;
  font-size: .75rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease;
}
figure:hover .pin, figure:focus-within .pin { opacity: 1; }
figure .pin:hover { background: rgba(36, 31, 27, .92); }
@media (hover: none) { figure .pin { opacity: 1; } }
figcaption {
  position: absolute;
  left: 10px;
  bottom: 8px;
  font-size: .8rem;
  color: #E8DED2;
  background: rgba(36, 31, 27, .72);
  padding: 2px 7px;
  border-radius: 5px;
}

.tile-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: radial-gradient(circle at 50% 35%, #3A332D, var(--video) 70%);
  pointer-events: none;
}
.tile-avatar {
  width: clamp(52px, 18%, 108px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid rgba(255, 255, 255, .18);
  font-family: var(--serif);
  font-size: clamp(1.15rem, 3.2vw, 2.15rem);
  font-weight: 700;
}
.tile-camera-off {
  color: #C9BBAD;
  font-size: .78rem;
  letter-spacing: .01em;
}
.tile-name { max-width: calc(100% - 76px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-mic {
  position: absolute;
  right: 10px;
  bottom: 8px;
  z-index: 2;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(36, 31, 27, .72);
  color: #E8DED2;
  font-size: .78rem;
  line-height: 1.25;
}
.tile-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
figure.participant .tile-placeholder[hidden],
figure.participant .tile-video[hidden] { display: none !important; }
figure.screen-share { background: #151210; }
figure.screen-share .tile-video { object-fit: contain; }
figure.screen-share .tile-placeholder { background: #151210; }
#screen[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}
#screen:disabled {
  opacity: .5;
  cursor: not-allowed;
}
body.stage-full #controls #screen[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.waiting {
  max-width: 520px;
  margin: 28px auto;
  padding: 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: rgba(255, 253, 250, .7);
  color: var(--muted);
  text-align: center;
}

/* --- Fußleiste ----------------------------------------------------------- */

footer#controls {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  padding: 12px 22px calc(12px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.room-label {
  margin-right: auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .9rem;
}
.layout-field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .85rem;
  white-space: nowrap;
}
.layout-field select {
  font: inherit;
  padding: 7px 9px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--fg);
}
.more { position: relative; }
.more-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  min-width: 270px;
  max-height: 70vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 10;
}
.more-menu button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
}
.more-menu button:hover { background: var(--panel-2); }
.menu-devices { display: grid; gap: 8px; padding: 6px; }
.menu-devices .device { font-size: .78rem; }
.more-menu .audio-filter,
.more-menu .video-filter { padding: 6px; font-size: .78rem; }
.breakout-count { max-width: 90px; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 0 6px; }

#audio {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.video-filter-source {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* --- Chat ---------------------------------------------------------------- */

.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;
}
.chat-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #FFFFFF;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
}
.chat {
  position: fixed;
  z-index: 40;
  right: 16px;
  bottom: 96px;
  width: min(360px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid var(--line);
}
.chat-head h2 { margin: 0; font-size: 1.15rem; }
.chat-head .icon { width: 32px; height: 32px; font-size: 1.3rem; }
.chat-log {
  flex: 1;
  min-height: 160px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FFFDFA;
}
.chat-empty { margin: auto; color: var(--muted); font-size: .9rem; text-align: center; }
.chat-message { max-width: 92%; display: flex; flex-direction: column; gap: 3px; }
.chat-message.own { align-self: flex-end; align-items: flex-end; }
.chat-meta { display: flex; gap: 6px; color: var(--muted); font-size: .72rem; }
.chat-name { font-weight: 600; }
.chat-text {
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-message.own .chat-text { background: var(--accent-soft); }
.chat-form {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-top: 1px solid var(--line);
}
.chat-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: #FFFFFF;
  color: var(--fg);
}
.chat-form button { padding: 9px 13px; }
body.stage-full .chat { bottom: 90px; }

/* --- Vollbild / Fokusmodus ------------------------------------------------ */

.stage-top { display: none; }

body.stage-full {
  overflow: hidden;
  background: var(--video);
}
body.stage-full header.top { display: none; }
body.stage-full #session {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  padding:
    var(--stage-top-h, 56px)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}
body.stage-full #session.fill-stage {
  height: 100vh;
  height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}
body.stage-full #tiles { flex: 1 1 auto; min-height: 0; }
body.stage-full .tiles:not(.fill) { overflow: auto; align-content: start; }
body.stage-full #waiting { display: none; }
body.stage-full #controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  justify-content: center;
  padding: 10px max(14px, env(safe-area-inset-right))
    calc(10px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(36, 31, 27, .9);
  border-top-color: rgba(255, 255, 255, .14);
  color: #F2EAE0;
  backdrop-filter: blur(10px);
  transition: opacity .18s ease, transform .18s ease;
}
body.stage-full #controls .room-label { display: none; }
body.stage-full #controls button,
body.stage-full #controls button.quiet {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .22);
  color: #F2EAE0;
}
body.stage-full #controls button:hover { background: rgba(255, 255, 255, .16); }
body.stage-full #controls button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}
body.stage-full #controls button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
body.stage-full #controls button.icon { background: transparent; color: #F2EAE0; }
body.stage-full .layout-field { color: #E8DED2; }
body.stage-full .layout-field select {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .22);
  color: #F2EAE0;
}
body.stage-full #controls .more-menu {
  background: rgba(36, 31, 27, .98);
  border-color: rgba(255, 255, 255, .18);
  color: #F2EAE0;
  color-scheme: dark;
}
body.stage-full #controls .more-menu button {
  background: none;
  color: #F2EAE0;
}
body.stage-full #controls .more-menu button:hover { background: rgba(255, 255, 255, .12); }
body.stage-full #controls .more-menu .device { color: #E8DED2; }
body.stage-full #controls .more-menu select {
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .22);
  color: #F2EAE0;
}
body.stage-full #controls .more-menu .menu-sep { background: rgba(255, 255, 255, .14); }
body.stage-full #controls.idle {
  opacity: 0;
  pointer-events: none;
}
body.stage-full #controls.idle { transform: translateY(100%); }

body.stage-full .stage-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding:
    calc(10px + env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    22px
    max(16px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(20, 17, 15, .86), rgba(20, 17, 15, 0));
  color: #F2EAE0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.stage-heading { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stage-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
.stage-layout {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #E8DED2;
  font-size: .8rem;
  pointer-events: auto;
}
.stage-layout select {
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 8px;
  background: rgba(36, 31, 27, .55);
  color: #F2EAE0;
  font: inherit;
  color-scheme: dark;
}
.stage-label {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-status {
  color: rgba(242, 234, 224, .78);
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stage-status[data-kind="ok"] { color: #B9D3BC; }
.stage-status[data-kind="warn"] { color: #E8C18A; }
.stage-status[data-kind="bad"] { color: #F0A9A3; }
.stage-exit {
  flex: none;
  pointer-events: auto;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(36, 31, 27, .55);
  color: #F2EAE0;
  font-size: .82rem;
  white-space: nowrap;
}
.stage-exit:hover { background: rgba(36, 31, 27, .82); }

@media (prefers-reduced-motion: reduce) {
  body.stage-full #controls,
  body.stage-full .stage-top { transition: none; }
}

/* --- Schmal -------------------------------------------------------------- */

@media (max-width: 820px) {
  #lobby { grid-template-columns: 1fr; padding: 16px; }
  .welcome { position: static; }
  #session { padding: 16px 16px 180px; }
  .room-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  header.top { padding: 12px 16px; }
  .panel, dialog.dialog { padding: 18px; }
  h1 { font-size: 1.7rem; }
  .dialog-actions { flex-direction: column; align-items: stretch; }
  .dialog-actions button { width: 100%; }
  .devices { grid-template-columns: 1fr; }
  footer#controls { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .room-label { flex-basis: 100%; margin: 0 0 4px; }
  #session { padding-bottom: 214px; }
  .tiles.speaker figure.spotlight { height: min(45vh, 380px); }
  .room-pager { align-items: flex-start; }
  .room-pager .pager-meta { flex-basis: 100%; }
  .room-pager .pager-controls { width: 100%; justify-content: space-between; }
  .chat {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 62vh;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.stage-full .chat { bottom: 0; }
  .chat-log { min-height: 120px; }
  .tile-avatar { width: clamp(48px, 18%, 84px); }
  body.stage-full .stage-top {
    gap: 8px;
    padding:
      calc(8px + env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      16px
      max(10px, env(safe-area-inset-left));
  }
  .stage-heading { flex: 1 1 auto; }
  .stage-label { font-size: .92rem; }
  .stage-status { display: none; }
  .stage-actions { gap: 6px; }
  .stage-layout-label { display: none; }
  .stage-layout select { padding: 5px 6px; font-size: .78rem; max-width: 100px; }
  .stage-exit { padding: 6px 8px; font-size: .78rem; }
  body.stage-full #controls { gap: 6px; }
  body.stage-full #controls button { padding: 9px 11px; }
  body.stage-full .layout-field { font-size: .8rem; }
  body.stage-full .layout-field select { padding: 6px 7px; }
}
