:root {
  --bg: #1e1f22; --bg2: #2b2d31; --bg3: #313338; --border: #3f4147;
  --fg: #dbdee1; --fg2: #949ba4; --accent: #5865f2; --live: #23a559; --danger: #da373c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 15px/1.4 system-ui, "Segoe UI", sans-serif; }
.hidden { display: none !important; }
button { font: inherit; border: 0; border-radius: 6px; padding: 8px 14px; background: var(--accent); color: #fff; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button.secondary { background: var(--bg3); color: var(--fg); }
button.danger { background: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
input { font: inherit; width: 100%; padding: 9px 10px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); }
label { display: block; margin: 10px 0; font-size: 13px; color: var(--fg2); }
label input { margin-top: 4px; }
.row { display: flex; gap: 6px; margin-top: 4px; }
.row input { flex: 1; font-family: ui-monospace, monospace; font-size: 13px; }
.hint { color: var(--fg2); font-size: 13px; }
.error { color: #f38688; min-height: 1.4em; margin: 8px 0 0; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* Auth-Karten */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { width: min(400px, 100%); background: var(--bg2); border-radius: 12px; padding: 24px; box-shadow: 0 8px 30px #0006; }
.card h1 { margin: 0 0 16px; font-size: 22px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; background: var(--bg3); color: var(--fg2); }
.tabs button.active { background: var(--accent); color: #fff; }
.card form button[type=submit] { width: 100%; margin-top: 8px; }

/* Header */
header { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--bg2); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 17px; }
.status { color: var(--fg2); flex: 1; }
nav { display: flex; align-items: center; gap: 8px; }
.me { color: var(--fg2); padding: 0 6px; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 12px; line-height: 18px; text-align: center; margin-left: 4px; }

/* Raster */
main { padding: 12px; }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(var(--cols, 1), 1fr); }
.tile { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; outline: 2px solid transparent; transition: outline-color .15s; }
.tile.audio-on { outline-color: var(--live); }
.tile video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; cursor: pointer; }
.tile .bar { position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: linear-gradient(transparent, #000c); font-size: 14px; }
.tile .name { font-weight: 600; flex: 1; text-shadow: 0 1px 2px #000; }
.tile .live { color: var(--live); font-size: 12px; font-weight: 700; }
.tile .state { color: var(--fg2); font-size: 12px; }
.tile .bar button { padding: 4px 8px; background: #0008; font-size: 16px; line-height: 1; }
.tile .bar button.on { background: var(--live); }

/* Fokus-Modus */
.grid.focus { grid-template-columns: 1fr; }
.grid.focus .tile:not(.focused) { display: none; }
.grid.focus .tile.focused { aspect-ratio: auto; height: calc(100vh - 56px - 24px - 110px); }
.focus-bar { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.focus-bar .thumb { flex: 0 0 160px; aspect-ratio: 16/9; border-radius: 6px; background: var(--bg3); display: grid; place-items: center; cursor: pointer; font-size: 13px; color: var(--fg2); }
.focus-bar .thumb.back { background: var(--accent); color: #fff; }

/* Offline-Chips */
.offline { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip { padding: 3px 10px; border-radius: 12px; background: var(--bg3); color: var(--fg2); font-size: 13px; }
.empty { color: var(--fg2); text-align: center; margin-top: 60px; font-size: 17px; }

/* Dialoge */
dialog { background: var(--bg2); color: var(--fg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: min(520px, 92vw); }
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
table { width: 100%; border-collapse: collapse; }
td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
td:last-child { text-align: right; white-space: nowrap; }
td button { padding: 4px 10px; font-size: 13px; }
.st-pending { color: #f0b232; font-size: 13px; }
.st-approved { color: var(--live); font-size: 13px; }

@media (max-width: 700px) {
  header { flex-wrap: wrap; }
  .status { order: 3; width: 100%; }
}
.chip.own { background: #3a2f33; color: var(--fg); display: inline-flex; align-items: center; gap: 8px; }
.chip.own button { padding: 2px 8px; font-size: 12px; }
