:root {
  --bg: #0b0e14; --bg2: #11151d; --surface: #161b26; --surface2: #1d2431; --line: #262e3d;
  --text: #e8ecf3; --muted: #8d98ab; --accent: #4c8dff; --accent-ink: #fff;
  --alert: #ff5c6c; --warn: #ffb020; --ok: #34d399; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f4f8; --bg2: #ffffff; --surface: #ffffff; --surface2: #eef1f6; --line: #dde2ea;
    --text: #151a24; --muted: #667085; --accent: #2563eb; --shadow: 0 10px 30px rgba(20,30,50,.12);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f2f4f8; --bg2: #ffffff; --surface: #ffffff; --surface2: #eef1f6; --line: #dde2ea;
  --text: #151a24; --muted: #667085; --accent: #2563eb; --shadow: 0 10px 30px rgba(20,30,50,.12);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Kopfzeile */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand i { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff; }
.brand svg { width: 18px; height: 18px; }
nav { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
nav a { display: flex; align-items: center; gap: 7px; padding: 7px 14px; border-radius: 9px; color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap; }
nav a svg { width: 17px; height: 17px; }
nav a.on { background: var(--accent); color: var(--accent-ink); }
nav a .badge { background: var(--alert); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; line-height: 17px; }
.status { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface);
  border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.pill b { color: var(--text); font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.dot.bad { background: var(--alert); }
.dot.warn { background: var(--warn); }

main { padding: 20px; max-width: 1800px; margin: 0 auto; }
h2 { margin: 0; font-size: 20px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head .grow { flex: 1; }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn svg { width: 16px; height: 16px; }
.btn.icon { padding: 8px 10px; }
.btn:disabled { opacity: .4; cursor: default; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13.5px; }
.seg button.on { background: var(--surface2); color: var(--text); box-shadow: 0 0 0 1px var(--line) inset; }

/* Live */
.live-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.tile { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; cursor: pointer;
  border: 1px solid var(--line); box-shadow: var(--shadow); }
.tile img, .stage img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.tile .cap { position: absolute; left: 0; right: 0; top: 0; padding: 10px 12px; display: flex; align-items: center; gap: 8px;
  background: linear-gradient(#000a, transparent); color: #fff; font-weight: 600; font-size: 14px; text-shadow: 0 1px 2px #000a; }
.tile .cap small { font-weight: 500; opacity: .8; margin-left: auto; }
.tile .foot { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 12px 9px; color: #fff; font-size: 12.5px;
  background: linear-gradient(transparent, #000b); opacity: 0; transition: opacity .15s; display: flex; gap: 8px; }
.tile:hover .foot { opacity: 1; }
.tile .off { position: absolute; inset: 0; display: grid; place-items: center; color: #aab; font-size: 14px; background: #0009; }
.idle-note { display: none; position: absolute; inset: 0; z-index: 1; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: #cdd; font-size: 13px; font-weight: 600; background: #000c; gap: 4px; }
.idle-note small { font-weight: 400; opacity: .7; font-size: 11.5px; }
.is-idle .tile .idle-note, .is-idle .stage .idle-note { display: flex; }
.qbtn { position: absolute; right: 8px; bottom: 8px; z-index: 2; border: 1px solid #fff3; background: #000a; color: #fff;
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; backdrop-filter: blur(4px);
  opacity: .55; transition: opacity .15s; cursor: pointer; }
.tile:hover .qbtn, .stage .qbtn:hover, .qbtn:focus-visible { opacity: 1; }
.stage .qbtn { right: 10px; bottom: 10px; font-size: 12px; padding: 4px 9px; }
.focus-wrap { display: grid; grid-template-columns: 1fr 260px; gap: 14px; align-items: start; }
.stage { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; border: 1px solid var(--line); box-shadow: var(--shadow); }
.stage:fullscreen { border-radius: 0; }
.stage .ctl { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
.stage .ctl .btn { background: #000a; border-color: #fff3; color: #fff; backdrop-filter: blur(6px); }
.stage .cap { position: absolute; left: 14px; top: 12px; color: #fff; font-weight: 700; font-size: 16px; text-shadow: 0 1px 3px #000; display: flex; gap: 8px; align-items: center; }
.side { display: flex; flex-direction: column; gap: 10px; }
.side .tile { aspect-ratio: 16/9; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { font-size: 12.5px; color: var(--muted); }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat .s { font-size: 12.5px; color: var(--muted); }
.bar { height: 6px; border-radius: 9px; background: var(--surface2); margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 9px; }
.bar i.warn { background: var(--warn); } .bar i.bad { background: var(--alert); }

/* Filter */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px;
  display: flex; flex-direction: column; gap: 10px; }
.frow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.frow > .lbl { width: 78px; flex: none; font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface2); font-size: 13px; font-weight: 600; color: var(--muted); user-select: none; }
.chip:hover { color: var(--text); }
.chip.on { background: color-mix(in srgb, var(--c, var(--accent)) 22%, transparent); border-color: var(--c, var(--accent)); color: var(--text); }
.chip .n { font-weight: 500; opacity: .7; font-size: 12px; }
.chip .sw { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--accent)); }
input[type=date], input[type=text], select { background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; color-scheme: inherit; }

/* Ereignis-Karten */
.day { margin: 22px 0 10px; display: flex; align-items: baseline; gap: 10px; font-weight: 700; font-size: 15px; }
.day span { color: var(--muted); font-weight: 500; font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; position: relative;
  transition: transform .12s, border-color .12s; }
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.card .th { position: relative; aspect-ratio: 16/9; background: #000 center/cover; }
.card .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .badge { position: absolute; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: #000a; color: #fff; backdrop-filter: blur(4px); }
.card .dur { right: 8px; bottom: 8px; }
.card .sev { left: 8px; top: 8px; background: var(--alert); }
.card .sev.det { background: #000a; }
.card .new { position: absolute; right: 9px; top: 9px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px #0008; }
.card .pick { position: absolute; left: 8px; bottom: 8px; width: 24px; height: 24px; border-radius: 8px; border: 2px solid #fffb; background: #0006;
  display: grid; place-items: center; color: #fff; opacity: 0; transition: opacity .1s; }
.card:hover .pick, .selmode .card .pick { opacity: 1; }
.card.sel .pick { background: var(--accent); border-color: var(--accent); opacity: 1; }
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 7px; }
.card .row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.card .row .t { margin-left: auto; color: var(--muted); font-size: 13px; }
.cam { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.cam::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--text); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); }
.obj { color: var(--muted); font-size: 12.5px; }
.empty { text-align: center; padding: 60px 10px; color: var(--muted); }
.more { display: block; margin: 20px auto; }

.selbar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40; background: var(--surface); border: 1px solid var(--accent);
  border-radius: 14px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); flex-wrap: wrap; justify-content: center; max-width: 96vw; }

/* Player-Dialog */
.modal { position: fixed; inset: 0; z-index: 60; background: #000c; display: flex; align-items: center; justify-content: center; padding: 18px; }
.panel { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; width: min(1500px, 100%); max-height: 100%; overflow: auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; box-shadow: var(--shadow); }
.panel .pl { padding: 14px; min-width: 0; }
.panel .info { padding: 16px; border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 14px; }
.vid { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; }
.vid video { width: 100%; height: 100%; display: block; background: #000; }
.vid .msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: #cbd; background: #000a; }
.vid .clock { position: absolute; left: 10px; top: 10px; background: #000a; color: #fff; padding: 3px 9px; border-radius: 8px; font-size: 13px; font-variant-numeric: tabular-nums; pointer-events: none; }
.pbar { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.pbar .sp { flex: 1; }
.info h3 { margin: 0; font-size: 17px; }
.info .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; }
.info .kv dt { color: var(--muted); } .info .kv dd { margin: 0; }
.sect { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; margin-bottom: 7px; }
.tagpick { display: flex; flex-wrap: wrap; gap: 6px; }
.tagpick .chip { cursor: pointer; }
.addtag { display: flex; gap: 6px; margin-top: 8px; }
.addtag input { flex: 1; min-width: 0; }
textarea { width: 100%; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--text); font: inherit; resize: vertical; min-height: 56px; }
.others { display: flex; gap: 6px; flex-wrap: wrap; }
.kbd { font-size: 12px; color: var(--muted); }
kbd { background: var(--surface2); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font: 11.5px ui-monospace, monospace; }
.closex { position: absolute; }

/* Zeitleiste */
.tl { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.tlrow { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 10px; }
.tlrow .cam { font-size: 13.5px; }
.track { position: relative; height: 38px; background: var(--surface2); border-radius: 9px; cursor: pointer; overflow: hidden; touch-action: none; }
.track .heat { position: absolute; bottom: 0; background: var(--c); opacity: .8; }
.track .ev { position: absolute; top: 0; height: 100%; background: var(--alert); opacity: .55; min-width: 2px; }
.track .ev.det { background: var(--warn); }
.track .ph { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 6px #000; pointer-events: none; margin: 0; }
.track.cur { outline: 2px solid var(--accent); }
.tlaxis { display: grid; grid-template-columns: 96px 1fr; gap: 10px; }
.tlaxis div { position: relative; height: 16px; font-size: 11.5px; color: var(--muted); }
.tlaxis span { position: absolute; transform: translateX(-50%); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--line); padding: 9px 16px; border-radius: 12px; z-index: 80; box-shadow: var(--shadow); font-weight: 600; }

@media (max-width: 1000px) {
  .panel { grid-template-columns: 1fr; }
  .panel .info { border-left: 0; border-top: 1px solid var(--line); }
  .focus-wrap { grid-template-columns: 1fr; }
  .side { flex-direction: row; } .side .tile { flex: 1; min-width: 0; }
}
@media (max-width: 700px) {
  .top { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .status { display: none; }
  nav { order: 3; width: 100%; } nav a { flex: 1; justify-content: center; padding: 8px 6px; }
  main { padding: 12px; }
  .live-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .frow > .lbl { width: 100%; }
  .tlrow { grid-template-columns: 62px 1fr; } .tlaxis { grid-template-columns: 62px 1fr; }
  .modal { padding: 0; } .panel { border-radius: 0; height: 100%; }
}

#tp, #tbar { max-width: 1100px; }
#tp .vid { max-height: 62vh; }

.card .keep { left: 8px; bottom: 8px; padding: 3px 6px; background: var(--accent); display: inline-flex; }
.card .th .pick { left: auto; right: 8px; bottom: 36px; }
.keepbox { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface2); cursor: pointer; }
.keepbox input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); }
.keepbox small { display: block; color: var(--muted); font-size: 12.5px; }

/* Ereignis-Seite: eigene Seite (kein Popup), Regler als eigene Leiste UNTER dem Video */
.clipmeta { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clipmeta .sep { opacity: .55; font-weight: 400; margin: 0 6px; }
.clipmeta .cam { font-weight: 700; }
.clipstage { background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 16/9; box-shadow: var(--shadow); max-width: 1100px; margin: 0 auto; }
.clipstage .vid { border-radius: 0; aspect-ratio: auto; height: 100%; }
.clipbar { display: flex; align-items: center; gap: 12px; max-width: 1100px; margin: 14px auto 0; }
.cliptime { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; width: 38px; flex: none; }
.cliptime:last-child { text-align: right; }
#clipSeek { flex: 1; height: 34px; accent-color: var(--accent); cursor: pointer; }
.tags { max-width: 1100px; margin: 12px auto 0; display: flex; flex-wrap: wrap; gap: 6px; }
#clipKeep.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Klingel-Kamera liefert 4:3 - nicht auf 16:9 pressen */
.tile[data-cam="klingel"] { aspect-ratio: 4/3; }
.stage[data-cam="klingel"] { aspect-ratio: 4/3; width: min(100%, calc((100vh - 230px) * 4 / 3)); margin: 0 auto; }
