:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1b1d22;
  --muted: #6b7280;
  --border: #e3e5ea;
  --accent: #5b5bd6;
  --accent-text: #ffffff;
  --danger: #d93f3f;
  --ok: #1f9d55;
  --live: #e5484d;
  --input: #ffffff;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111215;
    --card: #1a1c21;
    --text: #eceef2;
    --muted: #9aa1ad;
    --border: #2c2f36;
    --accent: #7c7cf0;
    --input: #121317;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 500; }
.small { font-size: .85rem; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.narrow { width: 100%; max-width: 380px; display: grid; gap: 14px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar form { margin: 0; }

label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); }
input, select {
  font: inherit; color: var(--text); background: var(--input);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.code-input { font-size: 1.4rem; letter-spacing: .15em; text-align: center; font-family: ui-monospace, monospace; }

button, .button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.danger { color: var(--danger); }
button.ghost, .ghost { background: transparent; border-color: transparent; color: var(--muted); text-decoration: none; }
button:disabled { opacity: .5; cursor: default; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.grow { flex: 1 1 200px; }

.stream-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.stream-head h2 { margin: 0; }
.stream-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  background: var(--border); color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.badge.live { background: var(--live); color: #fff; }
.badge.warn { background: #f5a524; color: #1b1d22; }
.badge.public { background: #1f9d55; color: #fff; }
.stream-head h2 .badge { vertical-align: middle; margin-left: 6px; text-transform: none; }

.kv { display: grid; grid-template-columns: 140px 1fr auto; gap: 6px 10px; align-items: center; }
.kv code {
  font-family: ui-monospace, Menlo, monospace; font-size: .82rem; background: var(--input);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; overflow-wrap: anywhere;
}
.kv .secret { filter: blur(4px); transition: filter .15s; cursor: pointer; }
.kv .secret.shown { filter: none; }

.modes { display: flex; flex-wrap: wrap; gap: 8px; }
.modes label, .checks label {
  display: flex; gap: 8px; align-items: center; color: var(--text); font-size: .9rem;
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; cursor: pointer;
}
.checks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.checks.disabled { opacity: .45; pointer-events: none; }
.hint { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; }
td.code { font-family: ui-monospace, Menlo, monospace; font-weight: 600; letter-spacing: .05em; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { padding: 4px 8px; font-size: .82rem; }
tr.inactive td { opacity: .5; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 20;
  max-width: calc(100% - 32px);
}

@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr auto; }
  .kv > span { grid-column: 1 / -1; margin-top: 6px; }
  th.hide-sm, td.hide-sm { display: none; }
}

/* ---------- Dashboard ---------- */
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; }
.crumbs a { color: var(--text); text-decoration: none; }
.crumbs .sep { color: var(--muted); }
.crumbs > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.stream-link { display: grid; color: var(--text); text-decoration: none; }
.stream-link small { color: var(--muted); font-size: .78rem; }
.stream-link:hover strong { color: var(--accent); }
.stream-table td.actions .button { padding: 5px 10px; font-size: .85rem; }
.stream-hero { padding-bottom: 0; }
.stream-hero h1 { font-size: 1.4rem; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stream-hero h1 .badge { text-transform: none; }
.primary-link { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.tabs { display: flex; gap: 4px; margin: 16px -20px 0; padding: 0 14px; border-top: 1px solid var(--border); overflow-x: auto; }
.tabs a {
  padding: 12px 12px 10px; color: var(--muted); text-decoration: none; font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.section-head h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.count { font-size: .8rem; background: var(--accent); color: var(--accent-text); border-radius: 99px; padding: 1px 9px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .85rem; }
.stats b { color: var(--text); }
td.mono { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }
.flag { font-size: 1.1rem; }
.code-chip { font-family: ui-monospace, Menlo, monospace; font-size: .78rem; background: var(--input); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; }
tr.is-live td:first-child { box-shadow: inset 3px 0 0 var(--live); }
.switch-row { display: flex; align-items: flex-start; gap: 10px; color: var(--text); font-size: .92rem; cursor: pointer; max-width: 560px; }
.switch-row input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }
.switch-row small { display: block; color: var(--muted); font-size: .82rem; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
form[data-form=settings] h3:first-of-type { margin-top: 1.25rem; }

/* ---------- Player-Seite ---------- */
body.watch-body {
  --w-bg: #0e0e10;
  --w-surface: #18181b;
  --w-text: #efeff1;
  --w-muted: #adadb8;
  --w-accent: #9147ff;
  --w-live: #eb0400;
  background: var(--w-bg);
  color: var(--w-text);
  min-height: 100vh;
}
.watch-nav {
  height: 50px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; background: var(--w-surface); box-shadow: 0 1px 0 rgba(255,255,255,.06);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .01em; }
.brand-dot {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--w-accent), #ff4f8b);
  box-shadow: 0 0 16px rgba(145,71,255,.5);
}
.nav-link { color: var(--w-muted); text-decoration: none; font-size: .9rem; }
.nav-link:hover { color: var(--w-text); }

.watch { max-width: 1400px; margin: 0 auto; padding: 20px 16px 40px; }

/* ---------- Video-Player ---------- */
.vp {
  position: relative; background: #000; aspect-ratio: 16 / 9; width: 100%;
  border-radius: 12px; overflow: hidden; outline: none; user-select: none; -webkit-user-select: none;
  max-height: calc(100vh - 170px); margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.vp:fullscreen, .vp:-webkit-full-screen { border-radius: 0; max-height: none; aspect-ratio: auto; width: 100%; height: 100%; }
.vp video { width: 100%; height: 100%; display: block; background: #000; object-fit: contain; }
.ic { width: 24px; height: 24px; fill: currentColor; display: block; }
.ic-xl { width: 56px; height: 56px; fill: none; color: var(--w-muted); }

/* Steuerleiste */
.vp-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; align-items: center; gap: 4px; padding: 36px 10px 8px;
  background: linear-gradient(to top, rgba(0,0,0,.85), rgba(0,0,0,.45) 55%, transparent);
  transition: opacity .25s, transform .25s;
}
.vp-spacer { flex: 1; }
.vp-btn {
  position: relative; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: #fff; display: grid; place-items: center; cursor: pointer;
  transition: background .15s, transform .1s;
}
.vp-btn:hover { background: rgba(255,255,255,.14); border: 0; }
.vp-btn:active { transform: scale(.92); }
.vp-btn .ic { width: 26px; height: 26px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
#settings .ic { transition: transform .3s; }
.vp.menu-open #settings .ic { transform: rotate(60deg); }
.vp-hd {
  position: absolute; top: 5px; right: 2px; background: var(--w-live); color: #fff;
  font-size: 9px; font-weight: 800; line-height: 1; padding: 2px 3px; border-radius: 3px;
}

.vp-vol { display: flex; align-items: center; }
.vp-vol input[type=range] {
  -webkit-appearance: none; appearance: none; width: 0; opacity: 0; height: 4px; padding: 0; margin: 0;
  border: 0; border-radius: 4px; cursor: pointer; transition: width .2s, opacity .2s, margin .2s;
  background: linear-gradient(to right, #fff var(--vol, 100%), rgba(255,255,255,.3) var(--vol, 100%));
}
.vp-vol:hover input[type=range], .vp-vol:focus-within input[type=range] { width: 84px; opacity: 1; margin: 0 8px 0 2px; }
.vp-vol input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 0;
}
.vp-vol input[type=range]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: #fff; border: 0; }

.vp-live {
  display: flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px; margin-left: 6px;
  border: 0; border-radius: 6px; background: rgba(255,255,255,.12); color: #fff;
  font-size: .78rem; font-weight: 700; letter-spacing: .06em; cursor: pointer;
}
.vp-live:hover { background: rgba(255,255,255,.22); border: 0; }
.vp-live .dot { width: 8px; height: 8px; border-radius: 50%; background: #9a9a9a; }
.vp.at-live .vp-live .dot { background: var(--w-live); box-shadow: 0 0 0 0 rgba(235,4,0,.7); animation: pulse 2s infinite; }
.vp.at-live .vp-live { cursor: default; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(235,4,0,.6); } 70% { box-shadow: 0 0 0 7px rgba(235,4,0,0); } 100% { box-shadow: 0 0 0 0 rgba(235,4,0,0); } }

/* Großer Play-Button */
.vp-bigplay {
  position: absolute; left: 50%; top: 50%; z-index: 2; transform: translate(-50%, -50%);
  width: 76px; height: 76px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #fff; display: none; place-items: center; cursor: pointer; transition: transform .15s, background .15s;
}
.vp-bigplay:hover { background: var(--w-accent); transform: translate(-50%, -50%) scale(1.06); border: 0; }
.vp-bigplay .ic { width: 36px; height: 36px; margin-left: 4px; }
.vp[data-state=paused] .vp-bigplay { display: grid; }

/* Puffern */
.vp-spinner { position: absolute; inset: 0; display: none; place-items: center; pointer-events: none; z-index: 1; }
.vp[data-state=loading] .vp-spinner { display: grid; }
.ring {
  width: 54px; height: 54px; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.18); border-top-color: var(--w-accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Offline */
.vp-offline {
  position: absolute; inset: 0; z-index: 4; display: none; place-items: center; text-align: center; padding: 16px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(145,71,255,.22), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(255,79,139,.14), transparent 55%),
    #0b0b0d;
}
.vp[data-state=offline] .vp-offline { display: grid; }
.vp[data-state=offline] .vp-bar, .vp[data-state=offline] .vp-unmute { display: none; }
.vp-offline-box { display: grid; gap: 8px; justify-items: center; max-width: 340px; color: var(--w-muted); }
.vp-offline-box strong { color: var(--w-text); font-size: 1.25rem; }

/* Stummschaltungs-Hinweis */
.vp-unmute {
  position: absolute; top: 14px; left: 14px; z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 10px; border: 0; border-radius: 8px; cursor: pointer;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #fff; font-weight: 600; font-size: .9rem; animation: nudge 2.4s ease-in-out infinite;
}
.vp-unmute:hover { background: var(--w-accent); border: 0; }
@keyframes nudge { 0%, 85%, 100% { transform: none; } 90% { transform: translateX(3px); } 95% { transform: translateX(-3px); } }

/* Einblendung (Lautstärke etc.) */
.vp-toast {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%); z-index: 3; pointer-events: none;
  background: rgba(0,0,0,.65); color: #fff; padding: 8px 16px; border-radius: 8px; font-weight: 600;
}

/* Einstellungsmenü */
.vp-menu {
  position: absolute; right: 12px; bottom: 60px; z-index: 5; min-width: 200px; padding: 6px;
  background: rgba(24,24,27,.96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.6);
  max-height: calc(100% - 80px); overflow-y: auto;
}
.vp-menu-title { padding: 6px 12px 8px; font-size: .75rem; font-weight: 700; color: var(--w-muted); text-transform: uppercase; letter-spacing: .08em; }
.vp-menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%;
  padding: 9px 12px; border: 0; border-radius: 6px; background: transparent; color: #fff;
  font-size: .92rem; cursor: pointer; text-align: left;
}
.vp-menu-item:hover { background: rgba(255,255,255,.1); border: 0; }
.vp-menu-item .ic { width: 18px; height: 18px; fill: none; opacity: 0; color: var(--w-accent); }
.vp-menu-item.active .ic { opacity: 1; }
.vp-menu-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-top: 4px; padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: .92rem;
}
.vp-menu-toggle small { display: block; color: var(--w-muted); font-size: .74rem; margin-top: 1px; }
.vp-switch {
  flex: none; position: relative; width: 40px; height: 22px; padding: 0; border: 0; border-radius: 11px;
  background: #4a4a50; cursor: pointer; transition: background .2s;
}
.vp-switch::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.vp-switch[aria-checked=true] { background: var(--w-accent); }
.vp-switch[aria-checked=true]::after { transform: translateX(18px); }
.vp-switch:hover { border: 0; filter: brightness(1.1); }
.vp-menu-stat {
  display: flex; justify-content: space-between; margin-top: 4px; padding: 9px 12px 5px;
  border-top: 1px solid rgba(255,255,255,.08); color: var(--w-muted); font-size: .82rem;
}
.vp-menu-stat span { color: #fff; font-variant-numeric: tabular-nums; }
.vp-menu-item small { color: var(--w-muted); font-size: .78rem; margin-left: 6px; }
.vp-menu-item .tag { font-size: .68rem; font-weight: 800; color: #fff; background: var(--w-live); padding: 1px 4px; border-radius: 3px; margin-left: 6px; }

/* Ausblenden bei Inaktivität */
.vp.idle { cursor: none; }
.vp.idle .vp-bar { opacity: 0; transform: translateY(8px); pointer-events: none; }

/* ---------- Infos unter dem Player ---------- */
.watch-info { display: flex; gap: 14px; align-items: center; padding: 18px 4px 6px; }
.avatar {
  flex: none; width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--w-accent), #ff4f8b);
}
.avatar.live { box-shadow: 0 0 0 3px var(--w-bg), 0 0 0 5px var(--w-live); }
.watch-meta h1 { font-size: 1.3rem; margin: 0 0 4px; line-height: 1.25; }
.watch-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; color: var(--w-muted); font-size: .9rem; }
.watch-stats > span { display: inline-flex; align-items: center; gap: 5px; }
.watch-stats .ic { width: 18px; height: 18px; }
#viewers { color: #ff8280; }
#viewers b { font-weight: 700; }
.pill {
  font-size: .72rem; font-weight: 800; letter-spacing: .06em; padding: 2px 7px; border-radius: 4px;
  background: #3a3a3d; color: var(--w-muted);
}
.pill.live { background: var(--w-live); color: #fff; }
.watch-keys { color: #6f6f78; font-size: .8rem; margin: 18px 4px 0; }
.watch-keys kbd {
  font: inherit; font-size: .75rem; background: #26262c; border: 1px solid #3a3a40; border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; color: var(--w-muted);
}

@media (hover: none) {
  .watch-keys { display: none; }
  .vp-vol input[type=range] { display: none; }
}
@media (max-width: 640px) {
  .watch { padding: 0 0 24px; }
  .vp { border-radius: 0; max-height: none; box-shadow: none; }
  .watch-info { padding: 14px 16px 0; }
  .avatar { width: 44px; height: 44px; font-size: 1.15rem; }
  .watch-meta h1 { font-size: 1.1rem; }
  .vp-bar { padding: 28px 4px 4px; gap: 0; }
  .vp-bigplay { width: 64px; height: 64px; }
  .vp-menu { right: 6px; bottom: 52px; }
}

/* ---------- Startseite ---------- */
.home-title { font-size: 1.4rem; margin: 6px 4px 18px; }
.home-hint { color: var(--w-muted); font-size: .9rem; margin: 28px 4px 0; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.stream-tile { color: var(--w-text); text-decoration: none; display: grid; gap: 10px; }
.stream-tile strong { padding: 0 2px; }
.tile-thumb {
  position: relative; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(145,71,255,.35), transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(255,79,139,.25), transparent 55%),
    #1a1a1f;
  transition: transform .15s, box-shadow .15s;
}
.stream-tile:hover .tile-thumb { transform: translateY(-3px); box-shadow: -6px 6px 0 var(--w-accent); }
.tile-initial { font-size: 3rem; font-weight: 800; color: rgba(255,255,255,.85); }
.tile-thumb .pill { position: absolute; top: 10px; left: 10px; }
.tile-viewers { position: absolute; bottom: 10px; left: 10px; font-size: .8rem; background: rgba(0,0,0,.6); padding: 2px 6px; border-radius: 4px; }
.stream-tile:not(.is-live) .tile-thumb { filter: grayscale(.6); opacity: .8; }
@media (max-width: 640px) { .home-title, .home-hint, .tile-grid { margin-left: 16px; margin-right: 16px; } }
