:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #5d6673;
  --border: #dde1e6;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #c62828;
  --ok: #16a34a;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --card: #181c22;
    --text: #e7eaee;
    --muted: #98a2b0;
    --border: #2a3038;
    --accent: #4f83f1;
    --danger: #ef5350;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.logo { font-weight: 700; font-size: 18px; }
.tag { color: var(--muted); font-size: 13px; }

main {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 16px;
}

h1, h2 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }

.lead { color: var(--muted); margin-top: 0; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 14px; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--danger); font-weight: 500; margin: 8px 0; }

label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: 14px; }

input {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.row { display: flex; gap: 8px; }
.row input { flex: 1; }

button {
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  white-space: nowrap;
}
button:disabled { opacity: .6; cursor: progress; }
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.danger { background: var(--danger); color: #fff; }
form > button[type="submit"] { margin-top: 8px; width: 100%; }

video {
  display: block;
  width: 100%;
  max-height: 70vh;
  background: #000;
  border-radius: 8px;
  object-fit: contain;
}

.live-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ---------- Formulare ---------- */
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 4px 14px 14px; margin: 0 0 14px; }
legend { font-weight: 700; font-size: 13px; padding: 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 12px 0 0; }
label.check input { width: auto; margin: 0; }
.ok { color: var(--ok); font-weight: 500; margin: 8px 0; }
.small { font-size: 12px; }

/* ---------- Raum ---------- */
.room-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.room-title { min-width: 0; }
.room-title h1 { margin: 0; overflow-wrap: anywhere; }
.room-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.notice { flex-basis: 100%; margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.side-col .card:last-child { margin-bottom: 0; }

.stage { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.stage[data-count="2"], .stage[data-count="3"], .stage[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stage[data-count="5"], .stage[data-count="6"], .stage[data-count="7"], .stage[data-count="8"],
.stage[data-count="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 640px) { .stage[data-count] { grid-template-columns: minmax(0, 1fr); } }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

.tile { margin: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; }
.tile video { max-height: 72vh; }
.tile.own { opacity: .9; }
.tile figcaption { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 2px 0; }
.tile-name { font-weight: 600; overflow-wrap: anywhere; }
.tile-tools { display: flex; gap: 6px; }
.tile-tools button { padding: 4px 10px; font-size: 13px; }

/* ---------- Listen ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 9px 0; border-top: 1px solid var(--border); }
.item:first-child { border-top: 0; }
.item-info { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.item-actions button { padding: 5px 10px; font-size: 13px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.badge.owner, .badge.host { color: var(--accent); border-color: var(--accent); }
.badge.live { color: var(--danger); border-color: var(--danger); }
.item .sas { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }

/* ---------- Qualität & Statistik ---------- */
select {
  width: 100%; padding: 8px 10px; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.q-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.tile-stats { margin: 6px 2px 0; font: 12px/1.45 ui-monospace, monospace; color: var(--muted); white-space: pre-line; overflow-wrap: anywhere; }
.tile-stats .warn { color: var(--danger); }

.status-line { flex-basis: 100%; margin: 0; padding: 8px 12px; border-radius: 8px; font-weight: 600;
  color: var(--danger); background: var(--bg); border: 1px solid var(--danger); }
#btn-rotate { margin-top: 12px; }
