:root {
  --bg: #0f1116;
  --card: #181b23;
  --line: #262a35;
  --text: #e8eaf0;
  --muted: #8f97ab;
  --accent: #9146ff;
  --accent-2: #a970ff;
  --ok: #2fbf71;
  --danger: #e5484d;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent-2); }

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
p { margin: 0.4rem 0; }
small, .muted { color: var(--muted); }
small { font-size: 0.85em; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

.wrap { max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.center { justify-content: center; text-align: center; }

.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding-bottom: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.who { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; color: var(--muted); }

button, .btn {
  font: inherit; color: var(--text); background: #232735; border: 1px solid var(--line);
  border-radius: 9px; padding: 0.5rem 0.9rem; cursor: pointer;
}
button:hover { background: #2a2f3f; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: transparent; font-weight: 600; }
button.primary:hover { background: var(--accent-2); }
button.danger { color: #ff8a8e; }
button.danger:hover { background: #3a1e21; }
button.big { padding: 0.9rem 1.4rem; font-size: 1.05rem; width: 100%; }

input, select {
  font: inherit; color: var(--text); background: #0c0e13; border: 1px solid var(--line);
  border-radius: 9px; padding: 0.5rem 0.7rem; width: 100%;
}
input[readonly] { color: var(--muted); }
label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
label small { font-weight: 400; margin-left: 0.3rem; }

.row { display: flex; gap: 0.5rem; }
.row input { flex: 1; min-width: 0; }
.field { margin-top: 0.9rem; }
.field:first-child { margin-top: 0; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.card footer { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); align-items: start; }
@media (max-width: 480px) { .cards { grid-template-columns: 1fr; } }
.danger-card { border-color: #4a2326; }

.card header { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.card header h2 { margin: 0; }
.card header .meta { margin-left: auto; color: var(--muted); font-size: 0.9rem; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: #555c6e; flex: none; }
.dot.online { background: var(--ok); box-shadow: 0 0 0 4px rgba(47, 191, 113, 0.18); }

.switch { float: right; font-weight: 400; display: inline-flex; align-items: center; gap: 0.35rem; }
.switch input { width: auto; }

.preview { margin-top: 0.9rem; aspect-ratio: 16 / 9; background: #000; border-radius: 9px; overflow: hidden; }
.preview iframe { width: 100%; height: 100%; border: 0; display: block; }

/* Reiter */
.tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.tabs button { background: transparent; border-color: transparent; color: var(--muted); }
.tabs button:hover { background: #232735; color: var(--text); }
.tabs button.active { background: #232735; border-color: var(--line); color: var(--text); font-weight: 600; }

/* Anmelden / Registrieren */
.auth { max-width: 460px; padding-top: 8vh; }
.auth .brand { margin-bottom: 0.5rem; }
.auth > .card { margin-top: 1.5rem; }
.auth-form { margin-top: 1.2rem; }
.auth-form .big { margin-top: 1.2rem; }
.error { color: #ff8a8e; min-height: 1.4em; margin-top: 0.6rem; }
.notice {
  background: #1f2430; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  padding: 0.6rem 0.8rem; border-radius: 8px; color: var(--muted); margin-bottom: 1rem;
}

.code-box {
  background: #0c0e13; border: 1px solid var(--line); border-radius: 9px;
  padding: 1rem; margin: 1rem 0; text-align: center;
}
.code-box code { font-size: 1.3rem; letter-spacing: 0.08em; word-break: break-all; }

/* Kontenliste */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 1rem; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
th, td { text-align: left; padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 0.85rem; font-weight: 600; background: #14171e; }
tr:last-child td { border-bottom: 0; }
td.actions { display: flex; gap: 0.4rem; }
td.actions button { padding: 0.3rem 0.6rem; font-size: 0.9rem; }
.tag { background: var(--accent); color: #fff; border-radius: 5px; padding: 0 0.35rem; font-size: 0.75rem; }

.help { margin-top: 2rem; }
.help ol, .help ul { padding-left: 1.2rem; }
.help li { margin: 0.4rem 0; }
details summary { cursor: pointer; font-weight: 600; }
details[open] summary { margin-bottom: 0.5rem; }

#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 20px);
  background: #262a35; color: var(--text); padding: 0.6rem 1rem; border-radius: 9px;
  opacity: 0; transition: all 0.2s; pointer-events: none; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: #4a2326; }

/* Gast-Seite */
.guest .stage {
  background: #000; border-radius: var(--radius); aspect-ratio: 16 / 9; overflow: hidden;
  display: grid; place-items: center; color: var(--muted); border: 1px solid var(--line);
}
.guest video { width: 100%; height: 100%; object-fit: contain; display: block; transform: scaleX(-1); }
.guest .controls { display: grid; gap: 0.9rem; grid-template-columns: 1fr 1fr; margin-top: 1rem; }
@media (max-width: 600px) { .guest .controls { grid-template-columns: 1fr; } }
.guest .status { margin-top: 1rem; padding: 0.7rem 0.9rem; border-radius: 9px; background: var(--card); border: 1px solid var(--line); }
.guest .status.error { border-color: var(--danger); color: #ff8a8e; }
.guest .viewers { color: var(--muted); }
.guest .viewers.ok { color: var(--ok); }
.guest .actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 1rem; }
.guest .actions button { flex: 1; }
.guest button.muted { border-color: var(--danger); color: #ff8a8e; }
.guest .fatal { background: #4a2326; border: 1px solid var(--danger); padding: 1rem; border-radius: var(--radius); margin-top: 1rem; }
