:root {
  --bg: #0e1116; --bg2: #151a21; --bg3: #1d242d; --line: #2a333e;
  --fg: #e6eaef; --fg2: #9aa6b2; --acc: #2dd4bf; --acc2: #14b8a6;
  --red: #f43f5e; --yellow: #f59e0b; --green: #22c55e;
  --r: 10px; --tabh: 56px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* iOS-Web-App (black-translucent): ohne den Zuschlag landen fixierte Elemente um die Statusleisten-Höhe zu hoch */
html { height: 100%; min-height: calc(100% + env(safe-area-inset-top)); background: var(--bg); }
/* kein Doppeltipp-Zoom (iOS), Tippen reagiert ohne Verzögerung */
html, body, button, a, input, select, label, .tile, .gal-item, .ov-pic, .cal-day { touch-action: manipulation; }
html, body { margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
h2 { font-size: 15px; font-weight: 600; margin: 24px 0 10px; color: var(--fg2); text-transform: uppercase; letter-spacing: .06em; }
a { color: var(--acc); }
input, select, textarea { background: var(--bg3); color: var(--fg); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font: inherit; min-height: 36px; }
input:focus, select:focus { outline: 2px solid var(--acc2); outline-offset: -1px; }
input[type=checkbox] { min-height: 0; width: 18px; height: 18px; accent-color: var(--acc); }
.btn { background: var(--bg3); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px;
  font: inherit; cursor: pointer; min-height: 36px; white-space: nowrap; }
.btn:hover { border-color: var(--fg2); }
.btn.primary { background: var(--acc2); border-color: var(--acc2); color: #04201c; font-weight: 600; }
.btn.danger { color: var(--red); }
.btn.icon { padding: 4px 12px; font-size: 18px; }
.btn.small { min-height: 28px; padding: 3px 10px; font-size: 13px; }
.err { color: var(--red); min-height: 1em; margin: 6px 0 0; }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: var(--bg3); color: var(--fg2); }
.badge.on { background: #0f3d2e; color: var(--green); }
.badge.off { background: #3d1220; color: var(--red); }
.badge.warn { background: #3d2c0b; color: var(--yellow); }
.empty { color: var(--fg2); text-align: center; padding: 40px; }

/* Login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); }
.login-card { width: min(360px, 100%); background: var(--bg2); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0 0 6px; text-align: center; font-size: 22px; }
.login-logo { width: 56px; height: 56px; margin: 0 auto; }
.login-card label { display: flex; flex-direction: column; gap: 4px; color: var(--fg2); font-size: 13px; }
.device-login summary { color: var(--fg2); cursor: pointer; font-size: 13px; }
.device-login { display: flex; flex-direction: column; gap: 8px; }
.device-login[open] > * + * { margin-top: 8px; }

/* Layout */
body { min-height: 100%; }
#app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; height: calc(56px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); background: var(--bg2);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.brand img { width: 26px; height: 26px; }
.brand .ver { font-size: 11px; font-weight: 500; color: var(--fg2); }
.version { color: var(--fg2); font-size: 12px; text-align: center; margin: 0; }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tabs a { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 8px; color: var(--fg2);
  text-decoration: none; font-weight: 500; }
.tabs a svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.active { color: var(--fg); background: var(--bg3); }
.tabs a.active svg { stroke: var(--acc); }
/* Bewegung irgendwo: Kamera-Symbol der Live-Navigation leuchtet orange (auch aus anderen Bereichen sichtbar) */
.tabs a.motion, .tabs a.motion.active { color: #f59e0b; }
.tabs a.motion svg, .tabs a.motion.active svg { stroke: #f59e0b; filter: drop-shadow(0 0 4px rgba(245, 158, 11, .85)); animation: motion-glow 1.4s ease-in-out infinite; }
@keyframes motion-glow { 50% { filter: drop-shadow(0 0 1px rgba(245, 158, 11, .3)); } }
.user { display: flex; gap: 8px; align-items: center; color: var(--fg2); }
main { flex: 1; padding: 14px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.view { display: none; }
.view.active { display: block; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--bg3); color: var(--fg2); border: 0; padding: 7px 12px; cursor: pointer; font: inherit; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--acc2); color: #04201c; font-weight: 600; }
.pager { display: inline-flex; align-items: center; gap: 6px; color: var(--fg2); }

/* Live-Raster */
.grid { display: grid; gap: 6px; grid-template-columns: repeat(var(--cols, 2), 1fr); }
.tile { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: var(--ar, 16/9); cursor: pointer;
  border: 1px solid var(--line); }
/* Bild immer vollständig und im Seitenverhältnis des Haupt-Streams: Kachel hat dieses Verhältnis,
   das Video wird hineingestreckt (verzerrte Sub-Streams wie 640×480 bei 16:9 werden so korrigiert). */
.tile video { width: 100%; height: 100%; object-fit: fill; display: block; background: #000; }
.grid { align-items: center; }
.tile-label { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: linear-gradient(#000a, #0000); font-size: 13px; font-weight: 500; pointer-events: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fg2); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.off { background: var(--red); }
.rec-dot { margin-left: auto; color: var(--red); font-size: 11px; font-weight: 700; }
.tile-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 28px 10px 8px; text-align: center; color: var(--fg2); font-size: 13px; pointer-events: none; }

/* Vollbild */
.focus { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.focus-bar { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  background: #000c; }
.focus-bar .spacer { flex: 1; }
.focus-video { position: relative; flex: 1; min-height: 0; padding-bottom: env(safe-area-inset-bottom);
  container-type: size; display: grid; place-items: center; }
/* größtmögliche Fläche im Seitenverhältnis der Kamera, ohne Beschnitt */
.focus-video video { width: min(100cqw, calc(100cqh * var(--ar, 1.7778))); height: min(100cqh, calc(100cqw / var(--ar, 1.7778)));
  object-fit: fill; display: block; }

/* Aufnahmen */
.player-wrap { background: #000; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.player-wrap { display: flex; flex-direction: column; align-items: center; }
.player-wrap .rec-info { align-self: stretch; }
.player-wrap video { width: min(100%, calc(62vh * var(--ar, 1.7778))); display: block; background: #000; aspect-ratio: var(--ar, 16/9); object-fit: fill; }
.rec-info { padding: 8px 12px; color: var(--fg2); font-size: 13px; background: var(--bg2); }
.timeline { position: relative; margin: 14px 0 6px; height: 54px; user-select: none; touch-action: none; }
.tl-track { position: absolute; left: 0; right: 0; top: 0; height: 30px; background: var(--bg3); border-radius: 6px; cursor: pointer; overflow: hidden; }
.tl-seg { position: absolute; top: 0; bottom: 0; background: var(--acc2); opacity: .75; }
.tl-seg.open { background: var(--red); }
/* Aufnahmen: zwei Spalten (Desktop) */
.rec-layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 16px; align-items: start; }
.rec-side { position: sticky; top: 70px; display: flex; flex-direction: column; gap: 12px; }
.side-box { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.side-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--fg2);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.link-btn { background: none; border: 0; color: var(--acc); cursor: pointer; font-size: 12px; text-transform: none; letter-spacing: 0; padding: 0; }
.cal-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.cal-title { flex: 1; text-align: center; font-weight: 600; background: none; border: 0; color: var(--fg); font: inherit; font-weight: 600; padding: 6px 4px; }
.cal-title .chev { display: none; margin-left: 6px; color: var(--fg2); font-size: 12px; transition: transform .2s; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 11px; color: var(--fg2); padding-bottom: 2px; }
.cal-day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 1px;
  min-height: 40px; padding: 4px 0 3px; border-radius: 7px; border: 1px solid transparent; background: var(--bg3); color: var(--fg);
  cursor: pointer; font: inherit; font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-day:hover { border-color: var(--line); }
.cal-day.other { opacity: .35; }
.cal-day.today .d { color: var(--acc); font-weight: 700; }
.cal-day.sel { border-color: var(--acc); background: color-mix(in srgb, var(--acc) 18%, var(--bg3)); }
.cal-day.future { opacity: .35; cursor: default; }
.cal-day .n { font-size: 10px; color: var(--fg2); line-height: 1; }
.cal-day .n:empty { visibility: hidden; }
.evt-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; vertical-align: middle; }
.cal-sort { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.cal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.cal-legend { font-size: 11px; color: var(--fg2); }
.cal-legend b { font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.cam-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cam-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg3); color: var(--fg2); cursor: pointer; font: inherit; font-size: 13px; }
.cam-chip .sw { width: 9px; height: 9px; border-radius: 50%; background: var(--cc); opacity: .35; }
.cam-chip.on { color: var(--fg); border-color: var(--cc); background: color-mix(in srgb, var(--cc) 16%, var(--bg3)); }
.cam-chip.on .sw { opacity: 1; }
.cam-chip.all { --cc: var(--acc); font-weight: 600; }
.seg-btns { display: flex; flex-direction: column; gap: 4px; }
.seg-btns button { text-align: left; padding: 6px 10px; border-radius: 7px; border: 1px solid transparent; background: none; color: var(--fg2);
  cursor: pointer; font: inherit; font-size: 13px; }
.seg-btns button:hover { background: var(--bg3); }
.seg-btns button.active { background: var(--bg3); border-color: var(--line); color: var(--fg); font-weight: 600; }
.rec-day-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.rec-day-head h3 { margin: 0; font-size: 17px; min-width: 0; }
/* Zeitleiste: eine Spur je Kamera */
.tl-multi { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px 6px; }
.tl-lane { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; align-items: center; margin-bottom: 5px; }
.tl-lane .lbl { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.tl-lane .lbl .sw { width: 8px; height: 8px; border-radius: 50%; background: var(--cc); flex: none; }
.tl-lane .tl-track { position: relative; height: 22px; }
.tl-lane .tl-seg { background: var(--cc); opacity: .55; }
.tl-lane .tl-seg.open { background: var(--cc); opacity: .9; }
.tl-axis { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px; }
.tl-axis .tl-hours { position: relative; top: 0; }
.tl-lane .tl-cursor { top: -3px; height: 28px; }
.tl-multi .empty { margin: 6px 0; }
/* Galerie der Bewegungen */
.sec-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; }
.sec-head h3 { margin: 0; font-size: 15px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.gallery .empty { grid-column: 1 / -1; }
.gal-item { position: relative; border-radius: 8px; overflow: hidden; background: var(--bg2); cursor: pointer;
  border: 1px solid var(--line); display: flex; flex-direction: column; }
.gal-item:hover { border-color: #f59e0b; }
.gal-img { position: relative; aspect-ratio: var(--ar, 16/9); background: #000; }
.gal-item img { width: 100%; height: 100%; object-fit: fill; display: block; }
.gal-item .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--fg2); font-size: 12px; }
/* Beschriftung als fester Balken unter dem Bild – gut lesbar, unabhängig vom Bildinhalt */
.gal-cap { display: flex; gap: 8px; align-items: center; padding: 7px 10px; background: var(--bg2); border-top: 3px solid var(--cc, var(--line));
  font-size: 14px; color: var(--fg); font-variant-numeric: tabular-nums; }
.gal-cap .time { color: var(--fg2); }
/* Auswahl */
.gal-item .chk { position: absolute; top: 8px; left: 8px; width: 24px; height: 24px; border-radius: 6px; border: 2px solid #fff;
  background: #0007; display: none; place-items: center; color: #fff; font-weight: 700; font-size: 15px; }
.gallery.selecting .gal-item .chk { display: grid; }
.gallery.selecting .gal-item.picked { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.gallery.selecting .gal-item.picked .chk { background: var(--red); border-color: var(--red); }
.gallery.selecting .gal-item.picked .chk::after { content: '✓'; }
.sel-bar { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg2); }
.sec-head .spacer { flex: 1; }
.btn.small.danger { color: var(--red); }
.check-row { display: flex; flex-direction: row; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.check-row input { width: 22px; height: 22px; }
.sound-list { display: flex; flex-direction: column; background: var(--bg3); border: 1px solid var(--line); border-radius: 8px; }
.sound-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; }
.sound-row + .sound-row { border-top: 1px solid var(--line); }
.sound-row label { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 400; cursor: pointer; }
.sound-row input[type=radio] { width: 20px; height: 20px; min-height: 0; accent-color: var(--acc); }
.hint { margin: -6px 0 2px; font-size: 13px; color: var(--fg2); }
.vol-row { display: flex; align-items: center; gap: 10px; }
.vol-row input[type=range] { flex: 1; min-height: 0; padding: 0; accent-color: var(--acc); }
.list-tools { display: flex; align-items: center; gap: 12px; margin: 8px 0 4px; font-size: 13px; color: var(--fg2); }
.list-tools label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.rec-item input[type=checkbox] { margin: 0; }
.gal-cap .cam { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.gal-cap .cam .sw { width: 9px; height: 9px; border-radius: 50%; background: var(--cc); flex: none; }
.gal-cap .dur { margin-left: auto; color: #ddd; white-space: nowrap; }
.gal-item .norec.live { color: #fff; background: var(--red); }
.gal-item .norec { position: absolute; top: 6px; right: 6px; font-size: 11px; background: #000c; color: #ddd;
  padding: 1px 6px; border-radius: 4px; }
.rec-segs { margin-top: 14px; }
.rec-segs summary { cursor: pointer; color: var(--fg2); font-size: 14px; padding: 4px 0; }
/* Wiedergabe-Overlay */
.player-ov { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; }
.pl-title { font-weight: 600; font-variant-numeric: tabular-nums; }
.pl-stage { position: relative; flex: 1; min-height: 0; container-type: size; display: grid; place-items: center; }
.pl-frame { position: relative; width: min(100cqw, calc(100cqh * var(--ar, 1.7778))); height: min(100cqh, calc(100cqw / var(--ar, 1.7778))); }
.pl-frame video, .pl-frame img { width: 100%; height: 100%; object-fit: fill; display: block; background: #000; }
.pl-frame video { cursor: pointer; }
/* Vorschau beim Ziehen: liegt über dem Video, bis dieses an der neuen Stelle ein Bild hat */
.pl-frame .pl-scrubimg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; background: #000; }
/* Player im Stil der iOS-Wiedergabe: Datum groß oben, eine Tages-Zeitleiste, große Tasten */
.player-ov { background: #000; }
.pl-top { display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  background: #14161d; }
.pl-top .pl-title { flex: 1; text-align: center; font-size: 18px; font-weight: 600; color: #ddd; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-round { width: 44px; height: 44px; border-radius: 50%; border: 0; background: #2a2e3a; color: #fff; display: grid; place-items: center;
  cursor: pointer; flex: none; text-decoration: none; }
.pl-round svg, .pl-main svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pl-round.hidden { visibility: hidden; display: grid !important; }
.pl-date { text-align: center; color: #fff; font-weight: 600; font-size: clamp(14px, 4.2vw, 19px); padding: 8px 10px; font-variant-numeric: tabular-nums; }
.pl-ctrl { background: #1a1a1c; padding: 14px max(18px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
.pl-scrub { position: relative; height: 34px; cursor: pointer; user-select: none; touch-action: none; }
.pl-track { position: absolute; left: 0; right: 0; top: 13px; height: 8px; border-radius: 4px; background: #2c2c3a; overflow: hidden; }
.pl-track .seg { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--cc, #6366f1) 70%, #2c2c3a); }
.pl-track .seg.alt { background: color-mix(in srgb, var(--cc, #6366f1) 50%, #2c2c3a); }
.pl-track .cut { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #1a1a1c; }
.pl-track .evt { position: absolute; top: 0; height: 3px; min-width: 2px; background: #f59e0b; }
.pl-knob { position: absolute; top: 5px; width: 40px; height: 24px; margin-left: -20px; border-radius: 12px; background: #fff;
  box-shadow: 0 1px 4px #0008; pointer-events: none; }
.pl-hover { position: absolute; top: -26px; transform: translateX(-50%); background: #000d; color: #fff; font-size: 12px; padding: 2px 7px;
  border-radius: 5px; pointer-events: none; display: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pl-scrub.drag .pl-hover, .pl-scrub:hover .pl-hover { display: block; }
.pl-times { display: flex; justify-content: space-between; gap: 10px; color: #eee; font-size: 17px; font-variant-numeric: tabular-nums; margin: 6px 2px 4px; }
.pl-main { display: flex; align-items: center; justify-content: center; gap: clamp(14px, 6vw, 34px); margin: 6px 0 12px; }
.pl-main button { background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; display: grid; place-items: center; }
.pl-main button svg { width: 30px; height: 30px; }
.pl-main .pl-big { width: 76px; height: 76px; border-radius: 50%; border: 3px solid #fff; }
.pl-main .pl-big::before { content: ''; width: 0; height: 0; border-style: solid; border-width: 13px 0 13px 22px; border-color: transparent transparent transparent #fff; margin-left: 6px; }
.pl-main .pl-big.playing::before { width: 22px; height: 28px; border: 0; margin: 0; background: linear-gradient(90deg, #fff 0 8px, transparent 8px 14px, #fff 14px 22px); }
.pl-sub { display: flex; align-items: center; gap: 10px; background: #252527; border-radius: 12px; padding: 8px 14px; }
.pl-sub .spacer { flex: 1; }
.pl-sub .pl-info { color: #aaa; font-size: 12px; padding: 0; background: none; }
.pl-rate { background: none; border: 0; color: #fff; font-size: 18px; font-weight: 600; cursor: pointer; padding: 4px 6px; }
.pl-info { padding: 8px max(12px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)); color: var(--fg2); font-size: 13px; background: #000c; }
a.btn.icon { display: inline-grid; place-items: center; text-decoration: none; }
/* Bewegungsereignisse: orange Markierungen im oberen Drittel der Zeitleiste */
.tl-evt { position: absolute; top: 0; height: 10px; min-width: 2px; background: #f59e0b; pointer-events: none; }
.rec-events { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.rec-events:empty { display: none; }
.rec-events button { background: var(--bg2); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 3px 8px;
  font-size: 12px; font-variant-numeric: tabular-nums; cursor: pointer; }
.rec-events button:hover { border-color: #f59e0b; }
.rec-events .lbl { color: var(--fg2); font-size: 12px; align-self: center; margin-right: 4px; }
/* Live: Bewegung */
.tile.motion { border-color: #f59e0b; }
.mot-dot { display: none; color: #f59e0b; font-size: 11px; font-weight: 700; }
.tile.motion .mot-dot { display: inline; }
#focus-name.mot::after { content: '  ⚑ Bewegung'; color: #f59e0b; font-size: 12px; font-weight: 700; }
.tl-cursor { position: absolute; top: -3px; height: 36px; width: 2px; background: #fff; pointer-events: none; display: none; }
.tl-hours { position: absolute; top: 34px; left: 0; right: 0; height: 16px; font-size: 11px; color: var(--fg2); }
.tl-hours span { position: absolute; transform: translateX(-50%); }
.tl-hours span:first-child { transform: none; } .tl-hours span:last-child { transform: translateX(-100%); }
.rec-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 6px; margin-top: 12px; }
.rec-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; }
.rec-item.active { border-color: var(--acc); }
.rec-item .t { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.rec-item .s { white-space: nowrap; }
.rec-item .s { color: var(--fg2); font-size: 12px; margin-left: auto; }
.rec-item .c { color: var(--cc, var(--fg2)); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rec-item a { color: var(--fg2); text-decoration: none; padding: 0 4px; }

/* Status */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card .k { color: var(--fg2); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.card .v { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card .sub { color: var(--fg2); font-size: 12px; }
.bar { height: 6px; background: var(--bg3); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--acc2); }
.bar i.warn { background: var(--yellow); } .bar i.crit { background: var(--red); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
.tbl { width: 100%; border-collapse: collapse; background: var(--bg2); }
.tbl th, .tbl td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { color: var(--fg2); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: var(--bg3); }
.tbl tr:last-child td { border-bottom: 0; }
.status-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 24px 0 10px; }
.status-head h2 { margin: 0; flex: 1; }
.status-head .btn { text-decoration: none; display: inline-flex; align-items: center; }
.tbl td.err-cell.old { color: var(--fg2); }
.tbl td.err-cell { white-space: normal; color: var(--red); font-size: 12px; max-width: 320px; }
.tbl .actions { text-align: right; }
.tbl .actions .btn + .btn { margin-left: 4px; }

/* Einstellungen */
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.subtabs button { background: none; border: 0; color: var(--fg2); padding: 10px 14px; font: inherit; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs button.active { color: var(--fg); border-bottom-color: var(--acc); }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.panel-head h3 { margin: 0; font-size: 16px; }
.panel-head .spacer { flex: 1; }
.form { max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { color: var(--fg2); font-size: 13px; }
.field small { color: var(--fg2); font-size: 12px; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check > span { color: var(--fg); font-size: 14px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 10px; background: var(--bg3); border: 1px solid var(--line);
  border-radius: 8px; max-height: 180px; overflow-y: auto; }
.checks label { display: flex; align-items: center; gap: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.probe { font-size: 13px; background: var(--bg3); border-radius: 8px; padding: 8px 10px; }
.probe .ok { color: var(--green); } .probe .no { color: var(--yellow); }
.code { font-family: ui-monospace, Menlo, monospace; background: var(--bg3); padding: 8px 10px; border-radius: 8px; word-break: break-all; user-select: all; }

dialog { background: var(--bg2); color: var(--fg); border: 1px solid var(--line); border-radius: 14px; padding: 0;
  width: min(600px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: #000a; }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
dialog h3 { margin: 0 0 4px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dlg-actions .left { margin-right: auto; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: var(--bg3); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; transition: transform .25s; z-index: 100; max-width: calc(100vw - 32px); }
.toast.show { transform: translate(-50%, 0); }
.toast.error { border-color: var(--red); }

/* Mobil */
/* ── Übersicht (Handy) ── */
.mobile-only { display: none; }
.live-mode { margin-bottom: 10px; }
.ov-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.ov-chips button { flex: none; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2);
  color: var(--fg); font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.ov-chips button.on { background: color-mix(in srgb, var(--acc) 22%, var(--bg2)); border-color: color-mix(in srgb, var(--acc) 50%, var(--line)); color: var(--acc); }
.ov-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.ov-group { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; }
.ov-group.on { border-color: var(--acc); }
.ov-mosaic { display: grid; aspect-ratio: 16/9; background: #000; }
.ov-mosaic.n2, .ov-mosaic.n3, .ov-mosaic.n4 { grid-template-columns: 1fr 1fr; }
.ov-mosaic img { width: 100%; height: 100%; object-fit: fill; display: block; min-height: 0; }
.ov-group .nm { text-align: center; padding: 6px; font-weight: 700; font-size: 14px; }
.ov-sec { font-size: 18px; font-weight: 700; color: var(--acc); margin: 4px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.ov-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.ov-card { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 6px; }
.ov-pic { border-radius: 9px; overflow: hidden; background: #000; border: 1px solid var(--line); cursor: pointer; position: relative; }
.ov-pic .im { aspect-ratio: var(--ar, 16/9); background: #111; position: relative; }
.ov-pic img, .ov-pic video { width: 100%; height: 100%; object-fit: fill; display: block; }
.ov-pic .tile-msg { font-size: 11px; padding: 4px; }
/* orangener Rahmen: Bewegung erkannt bzw. Bewegungsaufnahme läuft */
.ov-pic.motion { border-color: #f59e0b; }
.ov-pic .cap.stale { color: var(--red); }
.ov-pic .cap { text-align: center; font-size: 12px; padding: 3px 4px; color: var(--fg2); background: var(--bg3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-none { border: 1px dashed var(--line); border-radius: 9px; display: grid; place-items: center; text-align: center; color: var(--fg2);
  font-size: 12px; aspect-ratio: 16/11; padding: 4px; }
.ov-info { text-align: center; min-width: 92px; font-size: 13px; color: var(--fg2); line-height: 1.55; font-variant-numeric: tabular-nums; }
.ov-info .nm { color: var(--fg); font-weight: 700; font-size: 15px; line-height: 1.25; margin-bottom: 3px; word-break: break-word; }
.ov-info .bad { color: var(--red); }

@media (max-width: 1000px) {
  .rec-layout { grid-template-columns: 1fr; }
  .rec-side { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
  .seg-btns { flex-direction: row; flex-wrap: wrap; }
}
@media (max-width: 760px) {
  .mobile-only { display: flex; }
  /* iOS zoomt bei Eingabefeldern unter 16 px automatisch hinein */
  input, select, textarea { font-size: 16px; }
  .tl-lane, .tl-axis { grid-template-columns: 72px minmax(0, 1fr); }
  .tile-msg { font-size: 11px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 6px; }
  .card { padding: 10px; } .card .v { font-size: 18px; }
  .topbar { height: calc(48px + env(safe-area-inset-top)); }
  /* Tab-Leiste: Home-Indikator-Bereich nur teilweise nutzen, damit die Leiste nicht zu hoch wird */
  .tabs { position: fixed; bottom: 0; left: 0; right: 0; margin: 0; background: var(--bg2); border-top: 1px solid var(--line);
    justify-content: space-around; z-index: 20;
    box-shadow: 0 60px 0 var(--bg2); /* falls iOS doch eine Lücke lässt: gleiche Farbe darunter */
    padding: 2px max(4px, env(safe-area-inset-right)) max(4px, calc(env(safe-area-inset-bottom) - 14px)) max(4px, env(safe-area-inset-left)); }
  .tabs a { flex-direction: column; gap: 1px; font-size: 10px; line-height: 1.2; padding: 4px 6px; flex: 1; }
  .tabs a svg { width: 22px; height: 22px; }
  .tabs a.active { background: none; color: var(--acc); }
  main { padding: 10px max(8px, env(safe-area-inset-right)) calc(var(--tabh) + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .user #user-name { display: none; }
  .grid { gap: 4px; }
  .row2 { grid-template-columns: 1fr; }
  .toast { bottom: calc(var(--tabh) + env(safe-area-inset-bottom)); }
  #live-fs { display: none; }
  /* Aufnahmen am iPhone: zwei Galeriebilder nebeneinander */
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .gal-cap { font-size: 12px; padding: 5px 7px; gap: 5px; flex-wrap: wrap; row-gap: 0; }
  .gal-cap > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Kalender: Monat/Jahr antippen klappt ihn ein und aus */
  .cal-title { cursor: pointer; }
  .cal-title .chev { display: inline-block; }
  .cal-box.collapsed .cal-head { margin-bottom: 0; }
  .cal-box.collapsed .cal-grid, .cal-box.collapsed .cal-foot, .cal-box.collapsed .cal-sort, .cal-box.collapsed #cal-prev, .cal-box.collapsed #cal-next { display: none; }
  .cal-box.collapsed .cal-title .chev { transform: rotate(-90deg); }
}
