:root {
  --bg: #08080a;
  --side: #0b0b0e;
  --card: #0e0e11;
  --card2: #141418;
  --line: #1f1f25;
  --line2: #2a2a32;
  --text: #ececf0;
  --muted: #8c8c96;
  --dim: #5d5d66;
  --accent: #5e63e6;
  --accent2: #7176f0;
  --accent-soft: rgba(94, 99, 230, .14);
  --danger: #ef4864;
  --ok: #34d399;
  --mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --sans: 'Inter', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--line2);
  border-radius: 7px;
  padding: 7px 10px;
  width: 100%;
  min-width: 0;
}
input::placeholder, textarea::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 3px; height: 34px; }
input[type=range] { padding: 0; border: 0; accent-color: var(--accent); background: none; box-shadow: none; }
kbd { font: 500 11px var(--mono); background: var(--card2); border: 1px solid var(--line2); border-radius: 4px; padding: 0 5px; color: var(--muted); }

/* Buttons */
.btn {
  background: var(--card2);
  border: 1px solid var(--line2);
  border-radius: 7px;
  padding: 7px 13px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: #1b1b21; border-color: #35353f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: rgba(239, 72, 100, .5); background: rgba(239, 72, 100, .08); }
.btn.danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-solid:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.icon { padding: 5px 9px; min-width: 34px; }
.btn.wide { width: 100%; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: #c7c9ff; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: grid; place-items: center; }
.icon-btn:hover { color: var(--text); background: var(--card2); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin: -2px 0 14px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.pill { font: 500 11px var(--mono); color: var(--muted); border: 1px solid var(--line2); border-radius: 99px; padding: 1px 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 13px; }
.row { display: flex; gap: 8px; }
.spacer { flex: 1; }

/* Brand */
.brand { display: flex; align-items: center; gap: 8px; }
.bolt { color: var(--accent2); font-size: 14px; }
.brand-name { font: 700 13px var(--mono); letter-spacing: .14em; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 20px; }
.login-card { width: 360px; display: flex; flex-direction: column; gap: 16px; padding: 24px; }
.login-card h1 { margin: 10px 0 2px; font-size: 22px; font-weight: 600; }
.login-card .sub { margin: 0; color: var(--muted); }

/* App-Layout */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100%; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.sidebar > .brand { padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.side-status { padding: 10px 12px 0; }
.conn { display: inline-flex; align-items: center; gap: 6px; font: 500 11px var(--mono); color: var(--ok); padding: 3px 8px; border: 1px solid rgba(52, 211, 153, .25); border-radius: 99px; background: rgba(52, 211, 153, .06); }
.conn::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.conn.off { color: var(--danger); border-color: rgba(239, 72, 100, .25); background: rgba(239, 72, 100, .06); }
.nav { flex: 1; overflow: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); padding: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; text-align: left;
  background: none; border: 0; border-radius: 7px;
  padding: 8px 10px; cursor: pointer;
  color: #c9c9d1; font-weight: 500;
}
.nav-item svg { color: var(--dim); }
.nav-item:hover { background: var(--card2); color: var(--text); }
.nav-item.active { background: #15151d; color: #fff; }
.nav-item.active svg { color: var(--accent2); }
.nav-item .badge { margin-left: auto; }
.badge { background: var(--accent); color: #fff; border-radius: 99px; font: 600 11px var(--mono); padding: 1px 7px; }
.online { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.chip { display: flex; align-items: center; gap: 9px; padding: 5px 10px; font-size: 13px; color: #c9c9d1; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .12); }

.side-footer { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px; color: #c9c9d1; font-size: 13px; }
.switch-row span { display: flex; align-items: center; gap: 10px; }
.switch-row svg { color: var(--dim); }
.switch { width: 30px; height: 17px; border-radius: 99px; background: #26262e; border: 0; position: relative; cursor: pointer; transition: background .15s; padding: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #8a8a94; transition: transform .15s, background .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(13px); background: #fff; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 4px 0; }
.avatar { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, var(--accent), #9b5cf6); display: grid; place-items: center; font: 700 12px var(--mono); color: #fff; }
.me-name { flex: 1; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { overflow: auto; min-height: 0; }
.page { padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 18px; max-width: 2200px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; }
.page-head > div { flex: 1; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat { padding: 18px 20px; }
.stat-label { display: flex; justify-content: space-between; align-items: center; color: #c9c9d1; font-size: 13px; font-weight: 500; }
.stat-label svg { color: var(--dim); }
.stat-value { font: 700 34px/1.1 var(--mono); margin: 10px 0 6px; letter-spacing: -.02em; }
.stat-sub { color: var(--muted); font-size: 12px; }

/* Toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { background: none; border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; color: #c9c9d1; font-weight: 500; font-size: 13px; }
.seg button:hover { background: #1a1a21; color: #fff; }
.inline-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 500 12px var(--mono); }
.inline-label select { width: auto; font: 500 12px var(--mono); padding: 6px 8px; }

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
@media (max-width: 1250px) { .editor-grid { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.preview-card { padding: 14px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.hint { color: var(--dim); font-size: 12px; align-self: stretch; }

/* Vorschau */
.preview-wrap {
  position: relative;
  flex-shrink: 0;
  box-sizing: content-box;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background-color: #111114;
  background-image:
    linear-gradient(45deg, #17171b 25%, transparent 25%),
    linear-gradient(-45deg, #17171b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #17171b 75%),
    linear-gradient(-45deg, transparent 75%, #17171b 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
.preview-wrap .ov-stage { position: absolute; left: 0; top: 0; touch-action: none; }
.grid-layer { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; pointer-events: none; z-index: 0; }
.grid-layer .lines, .grid-layer .guides { position: absolute; inset: 0; }
.editable .ov-widget { cursor: move; outline: 2px dashed rgba(255, 255, 255, .22); }
.editable .ov-widget:hover { outline-color: rgba(113, 118, 240, .9); }
.editable .ov-widget.selected { outline: 4px solid var(--accent2); }
.editable .ov-widget.ov-off { opacity: .45; }
.editable .ov-widget.ov-off .ov-tag::after { content: ' · versteckt'; color: #ff8fa3; }
.editable .ov-widget img, .editable .ov-widget video, .editable .ov-widget iframe { pointer-events: none; }
.editable .ov-empty { background: repeating-linear-gradient(45deg, #1d1d23 0 20px, #24242b 20px 40px); }
.ov-tag { position: absolute; left: 0; top: -38px; font: 600 22px/1 var(--mono); background: var(--accent); color: #fff; padding: 6px 11px; border-radius: 6px; white-space: nowrap; pointer-events: none; display: none; }
.editable .ov-widget:hover .ov-tag, .editable .ov-widget.selected .ov-tag { display: block; }
.ov-handle { position: absolute; right: -14px; bottom: -14px; width: 28px; height: 28px; background: var(--accent2); border: 4px solid #fff; border-radius: 50%; cursor: nwse-resize; display: none; }
.editable .ov-widget.selected .ov-handle, .editable .ov-widget:hover .ov-handle { display: block; }

/* Inspector */
.inspector { padding: 14px; }
.element-list { display: flex; flex-direction: column; gap: 2px; }
.element-list:empty::before { content: 'Noch keine Elemente – füge oben eins hinzu.'; color: var(--muted); font-size: 13px; padding: 4px 6px; }
.el-row { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 7px; cursor: pointer; border: 1px solid transparent; font-size: 13px; }
.el-row:hover { background: var(--card2); }
.el-row.selected { background: #15151d; border-color: var(--line2); }
.el-row.selected .el-name { color: #fff; }
.el-row .el-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c9c9d1; }
.el-row.off .el-name { color: var(--dim); }
.el-row .eye { background: none; border: 0; cursor: pointer; font-size: 14px; padding: 2px 4px; opacity: .8; }
.editor { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 14px; }
.editor > p.muted { font-size: 13px; margin: 0; }
.editor h3 { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.editor .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.field.full { grid-column: 1 / -1; }
.field.check { flex-direction: row; align-items: center; gap: 8px; color: #c9c9d1; font-size: 13px; }
.section-title { margin: 16px 0 8px; font: 600 11px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.autohide { display: flex; gap: 6px; align-items: center; margin-top: 12px; }
.autohide input { width: 80px; }

/* Schnellsteuerung */
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; margin-bottom: 14px; }
.quick:empty::before { content: 'Noch keine Timer oder Counter angelegt.'; color: var(--muted); font-size: 13px; }
.q-item { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; }
.q-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--muted); }
.q-value { font: 700 22px/1 var(--mono); min-width: 70px; text-align: center; }
.q-item .btn { padding: 5px 10px; }
.q-item .big { font: 700 16px var(--mono); min-width: 38px; }
.alert-form { display: grid; grid-template-columns: 1fr 70px auto auto; gap: 8px; }

/* Medien */
.drop-zone { border: 1px dashed var(--line2); border-radius: 9px; padding: 22px; text-align: center; transition: border-color .15s, background .15s; }
.drop-zone p { margin: 0; color: var(--muted); }
.drop-zone.over { border-color: var(--accent); background: var(--accent-soft); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; cursor: pointer; border: 1px solid var(--line); background: var(--card); }
.media-item:hover { border-color: var(--accent); }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.media-item .del { position: absolute; top: 6px; right: 6px; background: rgba(8, 8, 10, .85); border: 1px solid var(--line2); color: #fff; border-radius: 6px; cursor: pointer; padding: 1px 7px; display: none; }
.media-item .del:hover { background: var(--danger); border-color: var(--danger); }
.media-item:hover .del { display: block; }
.media-item .vid { position: absolute; left: 6px; bottom: 6px; background: rgba(8, 8, 10, .85); font: 500 10px var(--mono); padding: 2px 6px; border-radius: 4px; }

/* Banner-Generator */
.page-full { max-width: none; height: 100%; }
.frame-card { flex: 1; padding: 0; overflow: hidden; min-height: 500px; }
.frame-card iframe { width: 100%; height: 100%; border: 0; display: block; background: var(--bg); }
body.dock #tab-banner { display: none !important; }

/* Chat */
.chat-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .chat-grid { grid-template-columns: 1fr; } }
.chat-card { display: flex; flex-direction: column; gap: 10px; height: calc(100vh - 170px); min-height: 380px; }
.chat-card .card-head { margin-bottom: 4px; }
.chat-log { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 4px; }
.msg { background: var(--card2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 11px; max-width: 85%; align-self: flex-start; word-wrap: break-word; }
.msg.mine { align-self: flex-end; background: var(--accent-soft); border-color: rgba(94, 99, 230, .35); }
.msg .meta { font: 500 11px var(--mono); color: var(--dim); margin-bottom: 3px; }
.msg .meta b { color: var(--accent2); margin-right: 8px; font-weight: 600; }
.msg.system { background: none; border: 0; color: var(--dim); font: 500 11px var(--mono); align-self: center; text-align: center; padding: 2px; }

/* Sprache */
.voice { display: flex; flex-direction: column; gap: 10px; }
.voice .card-head { margin-bottom: 2px; }
.voice .section-title { margin: 8px 0 0; }
.voice-row { display: flex; gap: 6px; align-items: center; }
.voice-row select { flex: 1; }
.ptt { width: 100%; padding: 12px; user-select: none; touch-action: none; display: flex; align-items: center; justify-content: center; gap: 10px; }
.ptt kbd { background: rgba(255, 255, 255, .15); border-color: transparent; color: #fff; }
.ptt.talking, #vOpen.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.meter { flex: 1; height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.meter div { height: 100%; width: 0; background: var(--ok); transition: width .08s; }
.speakers { display: flex; gap: 6px; flex-wrap: wrap; }
.speakers:empty { display: none; }
.speaker { font: 500 11px var(--mono); padding: 3px 9px; border-radius: 99px; background: rgba(239, 72, 100, .12); color: #ff8fa3; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* Bestätigungsfenster & Hinweise */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 1000; animation: fade .12s ease-out; }
.modal-box { width: min(420px, calc(100vw - 32px)); padding: 22px; box-shadow: 0 24px 60px rgba(0, 0, 0, .6); animation: pop .15s ease-out; }
.modal-box h3 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.modal-box p { margin: 0; color: var(--muted); }
.modal-box input { margin-top: 14px; font: 500 12px var(--mono); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line2); color: var(--text); padding: 9px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); z-index: 1001; animation: pop .15s ease-out; }

/* Dock-Modus (OBS „Benutzerdefinierte Browser-Docks“) */
body.dock .app { grid-template-columns: 1fr; }
body.dock .sidebar, body.dock .page-head, body.dock .stats, body.dock .toolbar,
body.dock .editor-grid, body.dock #tab-media { display: none !important; }
body.dock .main { display: flex; flex-direction: column; }
body.dock .page { padding: 10px; gap: 10px; }
body.dock #tab-edit { display: flex !important; }
body.dock #tab-chat { display: flex !important; flex: 1; }
body.dock .chat-grid { grid-template-columns: 1fr; }
body.dock .chat-card { height: 60vh; }
body.dock .quick { grid-template-columns: 1fr; }
body.dock .alert-form { grid-template-columns: 1fr 56px auto auto; }
