:root {
  --bg: #0e0e10; --card: #18181b; --line: #2f2f35; --text: #efeff1; --muted: #adadb8;
  --accent: #9147ff; --ok: #00c853; --bad: #eb0400;
  --nav-h: 0px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
a { color: #bf94ff; }
code { background: #000; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- Header / Nav ---------- */
header { display: flex; align-items: center; gap: 14px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 10; }
header h1 { font-size: 18px; margin: 0; white-space: nowrap; }
header h1 small { color: var(--muted); font-size: 11px; font-weight: 400; }
nav { display: flex; gap: 4px; flex: 1; }
nav button { background: transparent; color: var(--muted); display: flex; align-items: center; gap: 6px; }
nav button i { font-style: normal; }
nav button.active { background: var(--accent); color: #fff; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.tab { display: none; } .tab.active { display: block; }

/* ---------- Bausteine ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card h3 { margin: 18px 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; } .grid2 { margin-bottom: 16px; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; } .between { justify-content: space-between; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 9px 14px; font: inherit; cursor: pointer; min-height: 40px; }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .35; cursor: default; }
button.ghost { background: #2f2f35; }
button.danger { background: #5c1616; }
button.sm { padding: 4px 10px; font-size: 13px; min-height: 32px; }
input, select { background: #0e0e10; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: inherit; min-height: 40px; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
input[type=file] { padding: 7px; max-width: 100%; }
#addName { flex: 1; min-width: 0; }
.form label { display: block; margin-bottom: 12px; color: var(--muted); }
.form label input:not([type=checkbox]), .form select { display: block; width: 100%; max-width: 420px; margin-top: 4px; }
label.inline { display: flex !important; align-items: center; gap: 10px; color: var(--text) !important; margin-bottom: 10px; cursor: pointer; }
.hint { color: var(--muted); font-size: 13px; }
.pill { padding: 2px 10px; border-radius: 99px; background: #2f2f35; font-weight: 600; }
.pill.ok { background: #0b3d1f; color: #6fffa6; } .pill.bad { background: #4a1010; color: #ff8a80; }
.banner { background: #3a2a00; border: 1px solid #8a6500; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; }
.code { display: inline-block; font-size: 22px; letter-spacing: 3px; background: #000; padding: 2px 12px; border-radius: 6px; margin-top: 4px; user-select: all; }
.hidden { display: none !important; }

/* ---------- Kanalliste ---------- */
.list { list-style: none; padding: 0; margin: 10px 0 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.list .info { flex: 1; min-width: 0; display: flex; gap: 10px; align-items: baseline; }
.list .meta { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .actions { display: flex; gap: 4px; flex: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #555; flex: none; }
.dot.on { background: var(--bad); box-shadow: 0 0 6px var(--bad); }

pre { background: #000; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font: 12px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; margin: 0; }
#logs { height: 70vh; }
pre.small { max-height: 240px; }

/* ---------- Statistik ---------- */
.seg { display: inline-flex; background: #0e0e10; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg button { background: transparent; color: var(--muted); min-height: 34px; padding: 4px 12px; }
.seg button.active { background: var(--accent); color: #fff; }
#statSel { min-width: 160px; }
#chartWrap { position: relative; margin-top: 14px; touch-action: pan-y; }
#chart { display: block; }
#tip { position: absolute; pointer-events: none; background: #000; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.stat-list { display: flex; flex-direction: column; gap: 6px; }
.stat-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 14px; align-items: center; text-align: left; background: #0e0e10; border: 1px solid var(--line); }
.stat-row.active { border-color: var(--accent); }
.stat-row .num { font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-row .gain { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.stat-row .gain.up { color: #6fffa6; }

/* ---------- Multi-View ---------- */
.chip { display: inline-flex; gap: 6px; align-items: center; background: #2f2f35; padding: 6px 12px; border-radius: 99px; cursor: pointer; margin-bottom: 8px; }
.chip.live { box-shadow: inset 0 0 0 1px var(--bad); }
#mvGrid { display: grid; grid-template-columns: repeat(var(--cols, 2), 1fr); gap: 10px; }
.mv-cell { display: flex; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; }
.mv-cell.with-chat { aspect-ratio: 21/9; }
.mv-cell iframe { border: 0; flex: 1; height: 100%; min-width: 0; }
.mv-cell iframe.chat { flex: 0 0 300px; }

/* ---------- Toast / Login ---------- */
#toast { position: fixed; bottom: calc(20px + var(--nav-h)); left: 50%; transform: translateX(-50%) translateY(100px); background: #2f2f35; padding: 10px 18px; border-radius: 10px; transition: .25s; opacity: 0; z-index: 30; max-width: 90vw; text-align: center; }
#toast.show { transform: translateX(-50%); opacity: 1; } #toast.bad { background: #5c1616; }
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { margin: 0; }
.err { color: #ff8a80; margin: 0; min-height: 1em; }

/* ---------- Tablet ---------- */
@media (max-width: 1000px) {
  nav button span { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}

/* ---------- Handy ---------- */
@media (max-width: 720px) {
  :root { --nav-h: calc(62px + env(safe-area-inset-bottom)); }
  body { font-size: 16px; padding-bottom: var(--nav-h); }
  header { padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); justify-content: space-between; }
  header h1 { font-size: 17px; }
  .who #who { display: none; }
  nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; gap: 0; z-index: 20; }
  nav button { flex: 1; flex-direction: column; gap: 2px; padding: 4px 2px; min-height: 50px; font-size: 10px; border-radius: 10px; }
  nav button i { font-size: 20px; }
  nav button span { display: block; }
  nav button.active { background: rgba(145,71,255,.2); color: #fff; }
  main { padding: 12px; }
  .card { padding: 14px; border-radius: 14px; margin-bottom: 12px; }
  .grid2 { gap: 12px; margin-bottom: 12px; }
  input, select { font-size: 16px; } /* verhindert Auto-Zoom auf iOS */
  .btns button { flex: 1 1 calc(50% - 8px); }
  .list .info { flex-direction: column; gap: 0; }
  .list .actions button { min-width: 36px; min-height: 36px; }
  .seg { width: 100%; } .seg button { flex: 1; padding: 4px 6px; }
  #statSel { width: 100%; }
  .stat-row { grid-template-columns: 1fr auto; gap: 2px 10px; }
  .stat-row .gain { grid-column: span 1; }
  #mvGrid { grid-template-columns: 1fr !important; }
  .mv-cell.with-chat { flex-direction: column; aspect-ratio: auto; }
  .mv-cell.with-chat iframe:first-child { aspect-ratio: 16/9; flex: none; width: 100%; height: auto; }
  .mv-cell iframe.chat { flex: none; height: 320px; width: 100%; }
  #logs { height: calc(100vh - 260px); }
  .form label input:not([type=checkbox]), .form select { max-width: none; }
  #updForm button { width: 100%; }
}
