:root {
  --bg: #0e0d14;
  --panel: #17151f;
  --panel-2: #1f1c2a;
  --line: #2c2839;
  --text: #ecebf3;
  --muted: #9893ab;
  --accent: #8b6cff;
  --accent-2: #b39dff;
  --ok: #3ddc97;
  --warn: #ffb547;
  --bad: #ff5d73;
  --cam: #5cc8ff;
  --match: #ffb547;
  --radius: 12px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
h2 { font-size: 15px; margin: 0; font-weight: 600; letter-spacing: .01em; }
a { color: var(--accent-2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Kopfzeile ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px 24px; background: rgba(14, 13, 20, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.pulse.live { background: var(--bad); box-shadow: 0 0 0 0 rgba(255, 93, 115, .7); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(255, 93, 115, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 93, 115, 0); } }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button {
  background: none; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 8px;
  font: inherit; font-weight: 500; cursor: pointer;
}
nav button:hover { color: var(--text); background: var(--panel); }
nav button.active { color: var(--text); background: var(--panel-2); }

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

/* ---------- Karten ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.empty { color: var(--muted); padding: 28px 12px; text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 16px; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #3c3650; background: #262236; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #7a58ff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: rgba(255, 93, 115, .4); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; }
.btn.active { border-color: var(--accent); color: var(--accent-2); }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 14px; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }
input, select {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=color] { padding: 2px; width: 42px; height: 36px; cursor: pointer; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row input[type=text] { flex: 1; min-width: 160px; }
.stack { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.switch { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }

/* ---------- Live ---------- */
.statusbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 13px;
}
.pill b { font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.live-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.side .card { margin-bottom: 16px; }
.frame-wrap { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; }
.frame-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; }
.frame-wrap .empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
#frameInfo { margin-top: 8px; }
.now-item {
  display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.now-item:last-child { border-bottom: 0; }
.now-item .bar { width: 6px; height: 36px; border-radius: 3px; }
.now-item .name { font-weight: 600; font-size: 15px; }
.now-item .pos { color: var(--muted); font-size: 12.5px; }
.now-item .dur { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.now-item .since { color: var(--muted); font-size: 12px; text-align: right; }
.score-row { display: grid; grid-template-columns: 1fr 120px 44px; gap: 10px; align-items: center; padding: 4px 0; font-size: 13px; }
.score-row .track { height: 6px; background: var(--panel-2); border-radius: 3px; position: relative; overflow: hidden; }
.score-row .fill { position: absolute; inset: 0 auto 0 0; background: var(--muted); border-radius: 3px; }
.score-row.best .fill { background: var(--ok); }
.score-row .thr { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--warn); }
.score-row .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.hint {
  background: linear-gradient(135deg, rgba(139, 108, 255, .16), rgba(92, 200, 255, .08));
  border: 1px solid rgba(139, 108, 255, .35); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
}
.hint ol { margin: 6px 0 0; padding-left: 20px; }
.hint li.done { color: var(--muted); text-decoration: line-through; }

/* ---------- Auswertung ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 11px; border-radius: 7px; font: inherit; cursor: pointer; }
.seg button.active { background: var(--panel-2); color: var(--text); }
.custom-range { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#rangeLabel { margin-bottom: 16px; }
.total-row { display: grid; grid-template-columns: 130px 1fr 92px; gap: 12px; align-items: center; padding: 7px 0; }
.total-row .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.total-row .track { height: 22px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.total-row .fill { height: 100%; border-radius: 6px; min-width: 2px; }
.total-row .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.total-row .val small { display: block; color: var(--muted); font-weight: 400; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:hover td { background: rgba(255, 255, 255, .02); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; background: var(--panel-2); color: var(--muted); }
.tag.live { background: rgba(255, 93, 115, .15); color: var(--bad); }

/* Zeitleiste */
.tl { position: relative; }
.tl-axis { position: relative; height: 22px; margin-left: 130px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); }
.tl-axis span { position: absolute; transform: translateX(-50%); top: 2px; white-space: nowrap; }
.tl-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; height: 34px; }
.tl-row .nm { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 8px; }
.tl-lane { position: relative; height: 22px; background: var(--panel-2); border-radius: 5px; }
.tl-seg { position: absolute; top: 0; bottom: 0; border-radius: 4px; cursor: pointer; min-width: 2px; opacity: .9; }
.tl-seg:hover { opacity: 1; outline: 2px solid #fff; z-index: 2; }
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .05); pointer-events: none; }

/* ---------- Personen ---------- */
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 16px; }
.person-grid .card { margin: 0; }
.person-card.inactive { opacity: .55; }
.person-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.person-head input[type=text] { flex: 1; font-weight: 600; background: transparent; border-color: transparent; padding: 6px 8px; }
.person-head input[type=text]:hover { border-color: var(--line); }
.samples { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.sample { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; background: var(--panel-2); }
.sample img { width: 100%; height: 100%; object-fit: cover; }
.sample button {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0;
  background: rgba(0, 0, 0, .7); color: #fff; cursor: pointer; font-size: 12px; line-height: 20px; padding: 0; display: none;
}
.sample:hover button { display: block; }
.warn-text { color: var(--warn); }
.face-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.face { background: var(--panel-2); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.face img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.face .meta { font-size: 12px; color: var(--muted); min-height: 34px; }
.face select { width: 100%; padding: 6px; font-size: 12.5px; }

/* ---------- Ansichten ---------- */
.intro ol { margin: 8px 0; padding-left: 20px; }
.intro li { margin-bottom: 6px; }
.t-cam { color: var(--cam); } .t-match { color: var(--match); }
.scene-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.scene-item {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent;
}
.scene-item:hover { background: var(--panel-2); }
.scene-item.active { background: var(--panel-2); border-color: var(--accent); }
.scene-item img { width: 72px; aspect-ratio: 16/9; object-fit: cover; border-radius: 5px; background: #000; }
.scene-item .nm { font-weight: 600; }
.scene-item .sub { font-size: 12px; color: var(--muted); }
.canvas-wrap { position: relative; user-select: none; background: #000; border-radius: 8px; overflow: hidden; cursor: crosshair; }
.canvas-wrap img { width: 100%; display: block; pointer-events: none; }
.rgn { position: absolute; border: 2px solid var(--cam); background: rgba(92, 200, 255, .12); }
.rgn.match { border-color: var(--match); border-style: dashed; background: rgba(255, 181, 71, .1); }
.rgn.sel { box-shadow: 0 0 0 2px #fff; }
.rgn .lb {
  position: absolute; left: -2px; top: -2px; transform: translateY(-100%); background: var(--cam); color: #001520;
  font-size: 11.5px; font-weight: 600; padding: 1px 6px; border-radius: 4px 4px 4px 0; white-space: nowrap;
}
.rgn.match .lb { background: var(--match); color: #241400; }
.rgn.draft { border-style: dotted; }
.editor-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.region-list { margin-top: 12px; }
.region-row { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; }
.region-row input { padding: 6px 8px; }
.region-row .kind { width: 12px; height: 12px; border-radius: 3px; border: 2px solid var(--cam); }
.region-row .kind.match { border-color: var(--match); border-style: dashed; }
.region-row.sel input { border-color: var(--accent); }
.editor-foot { display: flex; gap: 8px; justify-content: space-between; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Einstellungen ---------- */
.settings label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-weight: 500; }
.settings label small { color: var(--muted); font-weight: 400; font-size: 12px; }
.settings .card h2 { margin-bottom: 14px; }
.settings label.check { flex-direction: row; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.actions { position: sticky; bottom: 12px; display: flex; justify-content: flex-end; margin-bottom: 16px; }
.actions .btn { box-shadow: 0 6px 24px rgba(0, 0, 0, .5); padding: 10px 22px; }
.log { background: var(--bg); border-radius: 8px; padding: 12px; max-height: 220px; overflow: auto; font-size: 12px; color: var(--muted); white-space: pre-wrap; margin: 0; }
.danger-zone { border-color: rgba(255, 93, 115, .3); }
.danger-zone h2 { margin-bottom: 12px; }

/* ---------- Dialog & Toast ---------- */
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h3 { margin: 0 0 14px; }
dialog label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; }
dialog .row { justify-content: flex-end; margin-top: 8px; }
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(120px);
  background: var(--panel-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px;
  transition: transform .25s; z-index: 50; max-width: calc(100vw - 32px);
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--bad); }

@media (max-width: 1000px) {
  .live-grid, .grid2, .scene-layout { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  main { padding: 16px; }
  .top { padding: 10px 16px; gap: 10px; }
  .total-row { grid-template-columns: 90px 1fr 80px; }
  .tl-axis { margin-left: 90px; }
  .tl-row { grid-template-columns: 90px 1fr; }
}

/* Korrekturen */
.total-row .fill { display: block; }
#toast { opacity: 0; pointer-events: none; }
#toast.show { opacity: 1; pointer-events: auto; }
.rgn.match .lb { top: auto; bottom: -2px; transform: translateY(100%); border-radius: 0 4px 4px 4px; }
.face-grid > .muted { grid-column: 1 / -1; }

/* VODs */
.vod-form { margin-top: 14px; }
.vod-form .row input[type=text] { flex: 1; }
.vod-common { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.vod-common label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; max-width: 420px; }
.vod-common label small { color: var(--muted); font-weight: 400; font-size: 12px; }
.vod-common label.check { flex-direction: row; align-items: center; gap: 8px; max-width: none; font-weight: 400; }
.vod-info { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--panel-2); font-size: 13px; }
.vod-info.bad { border: 1px solid rgba(255, 93, 115, .4); }
.vod-info.ok { border: 1px solid rgba(61, 220, 151, .35); }
.progress { width: 220px; height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.job { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.job .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job .m { color: var(--muted); font-size: 12.5px; }
.job .err { color: var(--bad); font-size: 12.5px; grid-column: 1 / -1; }
.job .acts { display: flex; gap: 6px; align-items: start; flex-wrap: wrap; justify-content: flex-end; }
.job .progress { width: 100%; grid-column: 1 / -1; }
.tag.ok { background: rgba(61, 220, 151, .15); color: var(--ok); }
.tag.bad { background: rgba(255, 93, 115, .15); color: var(--bad); }
.tag.run { background: rgba(139, 108, 255, .2); color: var(--accent-2); }

/* Login / Rollen */
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.me img, .avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--panel-2); flex: none; }
.avatar { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.me .who { line-height: 1.2; }
.me .who small { display: block; color: var(--muted); font-size: 11.5px; }
.badge { display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff;
         font-size: 11px; font-weight: 700; align-items: center; justify-content: center; margin-left: 4px; }
body.role-viewer .need-editor { display: none !important; }
.user-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row .avatar, .user-row img { width: 36px; height: 36px; }
.user-row .nm { font-weight: 600; }
.user-row .sub { color: var(--muted); font-size: 12.5px; }
.user-row .acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.user-row select { padding: 6px 8px; }
