/* SPDX-License-Identifier: GPL-3.0-or-later
   OpenIntraCam Portal — UI */
/* Light-Theme = Default. Dark greift entweder per OS-Einstellung (nur solange der
   Nutzer nicht explizit gewählt hat) ODER per data-theme="dark" (Umschalter). */
:root {
  --bg: #f4f6f9; --panel: #ffffff; --panel-2: #fafbfc;
  --text: #1c2530; --muted: #64748b; --border: #e3e8ef;
  --accent: #0d9488; --accent-ink: #0f766e; --accent-soft: #ccfbf1;
  --ok: #16a34a; --off: #dc2626; --warn: #d97706;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 14px;
  color-scheme: light;
}
/* gemeinsame Dark-Palette */
:root[data-theme="dark"] {
  --bg: #0e141b; --panel: #161e28; --panel-2: #1b242f;
  --text: #e6edf3; --muted: #94a3b8; --border: #263341;
  --accent: #2dd4bf; --accent-ink: #5eead4; --accent-soft: #123e3a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e141b; --panel: #161e28; --panel-2: #1b242f;
    --text: #e6edf3; --muted: #94a3b8; --border: #263341;
    --accent: #2dd4bf; --accent-ink: #5eead4; --accent-soft: #123e3a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 8px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-ink); text-decoration: none; }

/* Header */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; background: var(--panel);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.2px; }
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; }
/* Gesamt-Logo (Icon + Schriftzug + Sternenkranz), theme-abhängig getauscht. */
.brand-logo { display: inline-flex; align-items: center; }
.brand-logo img { height: 46px; width: auto; display: block; }
.brand-logo .l-dark { display: none; }
:root[data-theme="dark"] .brand-logo .l-dark { display: block; }
:root[data-theme="dark"] .brand-logo .l-light { display: none; }
.brand-name { display: inline-flex; align-items: baseline; gap: 6px; line-height: 1; }
/* Theme-Umschalter (nur noch Admin-Header) */
.theme-toggle { font-size: 15px; line-height: 1; }

/* Header-Dropdown-Menüs (Einstellungen / Benutzer) */
.menu { position: relative; }
.menu-btn { display: inline-flex; align-items: center; gap: 6px; }
.menu-btn .caret { font-size: 10px; opacity: .65; }
.menu-btn.userchip { background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; font-weight: 600; }
.menu-pop {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 210px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 50; display: none;
}
.menu-pop.menu-right { left: auto; right: 0; }
.menu.open .menu-pop { display: block; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; background: none; color: var(--text);
  font: inherit; text-align: left; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.menu-item:hover { background: var(--panel-2); }
.menu-item.danger { color: var(--off); }
.menu-label { padding: 7px 10px 3px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.theme-opt .ck { width: 14px; text-align: center; opacity: 0; color: var(--accent-ink); }
.theme-opt.on .ck { opacity: 1; }
.menu-pop form { margin: 0; }

/* Über-Dialog */
.aboutdlg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text); box-shadow: var(--shadow); padding: 26px 32px 20px; width: min(520px, 92vw); text-align: center; position: relative; }
.aboutdlg::backdrop { background: rgba(8,12,18,.55); }
.about-x { position: absolute; top: 12px; right: 12px; }
.about-logo img { width: min(220px, 62%); height: auto; }
.about-logo .l-dark { display: none; }
:root[data-theme="dark"] .about-logo .l-dark { display: inline; }
:root[data-theme="dark"] .about-logo .l-light { display: none; }
.about-name { font-weight: 700; font-size: 19px; margin-top: 6px; }
.about-ver { color: var(--muted); font-weight: 600; font-size: 14px; }
/* Der Beschreibungstext ist ein Fließtext, kein Schild.
   Zentriert gesetzt muss das Auge bei jeder Zeile den Anfang neu
   suchen — bei vier Zeilen merkt man das deutlich. Deshalb linksbündig
   im mittig sitzenden Block. text-wrap:pretty verhindert, dass am Ende
   ein einzelnes Wort allein steht. */
.about-desc { color: var(--muted); font-size: 13.5px; line-height: 1.65; margin: 12px auto 18px; max-width: 440px; text-align: left; text-wrap: pretty; }
.about-facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; text-align: left; max-width: 300px; margin: 0 auto 16px; font-size: 13px; }
.about-facts dt { color: var(--muted); }
.about-facts dd { margin: 0; font-weight: 600; }
.about-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; }
.topbar .spacer { flex: 1; }
.topbar .stat { color: var(--muted); font-size: 13px; }
.topbar .stat b { color: var(--text); }

/* Layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 24px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.toolbar h1 { font-size: 20px; margin: 0; letter-spacing: -.3px; }
.toolbar .spacer { flex: 1; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 14px; font-weight: 600;
  transition: .12s ease;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 10px; }
.btn.ghost:hover { color: var(--off); background: color-mix(in srgb, var(--off) 10%, transparent); }
.btn.sm { padding: 6px 11px; font-size: 13px; }

/* Recorder cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card .head { display: flex; align-items: center; gap: 11px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.card .head .name { font-weight: 700; font-size: 15.5px; }
.card .head .host { color: var(--muted); font-size: 12.5px; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); text-transform: uppercase; letter-spacing: .4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.dot.on { background: var(--ok); color: var(--ok); }
.dot.off { background: var(--off); color: var(--off); }

.meta { display: flex; gap: 18px; padding: 12px 18px; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.meta .k { color: var(--text); font-weight: 600; }
.disk { flex: 1; }
.bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 5px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* Camera rows */
.cams { list-style: none; margin: 0; padding: 6px; }
.cams li { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; }
.cams li:hover { background: var(--panel-2); }
.cams .cam-ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-size: 16px; flex: none; }
.cams .cam-main { flex: 1; min-width: 0; }
.cams .cam-name { font-weight: 600; }
.cams .cam-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec { display: inline-flex; align-items: center; gap: 6px; color: var(--off); font-size: 12px; font-weight: 700; }
.rec .blink { width: 8px; height: 8px; border-radius: 50%; background: var(--off); animation: blink 1.4s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }
.empty-cams { padding: 16px 18px; color: var(--muted); font-size: 13px; }

.card .foot { padding: 12px 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
  border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--panel);
}
.empty .big { font-size: 42px; }

/* Modal / dialog */
dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(460px, 92vw);
  background: var(--panel); color: var(--text); box-shadow: 0 20px 50px rgba(0,0,0,.28);
}
dialog::backdrop { background: rgba(8,12,18,.5); backdrop-filter: blur(2px); }
dialog .dhead { padding: 18px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
dialog form { padding: 20px; display: grid; gap: 14px; }
label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea {
  font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); resize: vertical; min-height: 40px;
}
textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
dialog.wide { width: min(620px, 94vw); }
.ok { color: var(--accent); font-size: 13px; font-weight: 600; margin-top: 2px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dact { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.hint { font-size: 12px; color: var(--muted); font-weight: 500; }
.warn { color: var(--warn); font-weight: 600; }
.htmx-request .spin { display: inline-block; }
.spin { display: none; }

/* ---- Sidebar-Layout ---- */
.app { display: flex; align-items: stretch; min-height: calc(100vh - 61px); }
.sidebar { width: 252px; flex: none; padding: 14px 12px; background: var(--panel); border-right: 1px solid var(--border); overflow-y: auto; }
.navitem { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 9px; color: var(--text); font-size: 14px; cursor: pointer; }
.navitem:hover { background: var(--panel-2); }
.navitem.all { font-weight: 600; margin-bottom: 8px; }
.count { margin-left: auto; font-size: 11px; color: var(--muted); background: var(--panel-2); padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.sidebar .count { background: var(--bg); }
details.site { margin-top: 2px; }
details.site > summary { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-radius: 9px; cursor: pointer; font-weight: 650; font-size: 14px; list-style: none; user-select: none; }
details.site > summary::-webkit-details-marker { display: none; }
details.site > summary::before { content: '▸'; color: var(--muted); font-size: 10px; transition: transform .15s ease; }
details.site[open] > summary::before { transform: rotate(90deg); }
details.site > summary:hover { background: var(--panel-2); }
details.site .navitem.sub { margin-left: 16px; font-size: 13.5px; color: var(--muted); }
details.site .navitem.sub:hover { color: var(--text); }
details.site > summary .site-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-edit { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; border-radius: 6px; opacity: 0; transition: opacity .12s, color .12s, background .12s; }
details.site > summary:hover .site-edit { opacity: 1; }
.site-edit:hover { color: var(--accent); background: var(--panel); }

/* ---- Hauptbereich ---- */
#main { flex: 1; min-width: 0; padding: 22px 26px; }
.scope-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.crumb { font-size: 19px; font-weight: 700; letter-spacing: -.3px; display: flex; align-items: center; gap: 9px; }
.crumb .sep { color: var(--muted); font-weight: 400; }
.crumb-count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 2px 9px; border-radius: 999px; }
.rec-strip { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.rec-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); background: var(--panel); border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px; cursor: pointer; font-family: inherit; transition: border-color .12s, color .12s; }
.rec-chip:hover { border-color: var(--accent); color: var(--text); }

/* ---- Recorder-Detail-Dialog ---- */
.recdlg { width: min(460px, 94vw); }
.recdlg-head { display: flex; align-items: center; justify-content: space-between; }
.recdetail { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 16px; }
.rec-status { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.rec-status.on { color: var(--ok); } .rec-status.off { color: var(--off); }
.rec-status .badge { margin-left: auto; }
.rec-rename label { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.rec-rename .row { display: flex; gap: 8px; }
.rec-rename input { flex: 1; }
.rec-title { font-size: 17px; font-weight: 700; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; word-break: break-all; }
dl.kv dd .fp { font-size: 10.5px; letter-spacing: .3px; }

/* ---- Kamera-Tabelle ---- */
table.cams { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.cams th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
table.cams td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
table.cams tr:last-child td { border-bottom: none; }
table.cams tbody tr:hover td { background: var(--panel-2); }
td.cam-name { font-weight: 600; }
.cam-id { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.w1 { width: 1%; white-space: nowrap; }
.tag { font-size: 12px; background: var(--accent-soft); color: var(--accent-ink); padding: 2px 9px; border-radius: 6px; }
.muted { color: var(--muted); font-size: 13px; }
.err, .ferr { color: var(--off); font-size: 13px; font-weight: 600; margin-top: 2px; }

/* ---- Aktionen + Live ---- */
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn + .btn { margin-left: 6px; }
.live-btn { color: var(--accent-ink); border-color: var(--accent-soft); font-weight: 700; }
.live-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.livedlg { width: min(1040px, 96vw); }
.livehead { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.liveplayer { display: flex; align-items: stretch; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.livebody { flex: 1; min-width: 0; position: relative; background: #000; display: grid; place-items: center; }
/* Format der Vorschau folgt dem echten Videoformat (aspect-ratio wird per JS gesetzt). */
#liveVideo { width: 100%; height: auto; aspect-ratio: 16 / 9; max-height: 74vh; object-fit: contain; display: block; background: #000; }
.livestatus { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 14px; pointer-events: none; text-shadow: 0 1px 3px rgba(0,0,0,.7); }

/* PTZ-Panel rechts neben dem Bild — Joystick-Look, nicht überlagert */
.ptz { width: 190px; flex: none; padding: 16px 14px; border-left: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; gap: 16px; align-items: center; }
.ptz-title { align-self: flex-start; font-weight: 700; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.ptzctrls { display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* Joystick-Kreis: Pfeile um einen Mittel-Ring */
.dpad { position: relative; width: 138px; height: 138px; flex: none; border-radius: 50%; border: 2px solid var(--border); background: var(--panel-2); }
.dpad .pad { position: absolute; border: none; background: none; padding: 6px; min-height: 0; font-size: 14px; line-height: 1; color: var(--muted); cursor: pointer; user-select: none; }
.dpad .pad:disabled { cursor: not-allowed; }
.dpad .pad:not(:disabled):hover { filter: brightness(1.25); }
.pad.up    { top: 5px;    left: 50%; transform: translateX(-50%); }
.pad.down  { bottom: 5px; left: 50%; transform: translateX(-50%); }
.pad.left  { left: 8px;   top: 50%;  transform: translateY(-50%); }
.pad.right { right: 8px;  top: 50%;  transform: translateY(-50%); }
.pad.home  { top: 50%; left: 50%; transform: translate(-50%, -50%); width: 58px; height: 58px; padding: 0; border-radius: 50%; border: 5px solid var(--border); background: transparent; }
.pad.home:not(:disabled):active { transform: translate(-50%, -50%) scale(.95); }

/* Zoom horizontal (Pille) */
.zoompill { display: flex; align-items: center; gap: 12px; padding: 6px 16px; border: 2px solid var(--border); border-radius: 999px; background: var(--panel-2); }
.zoompill .zbtn { border: none; background: none; padding: 2px 4px; min-height: 0; width: auto; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; }
.zoompill .zbtn:not(:disabled):hover { filter: brightness(1.25); }
.zoomlbl { font-size: 12px; color: var(--muted); }
.ptz-note { font-size: 12px; text-align: center; font-weight: 600; }

/* Fähigkeit per Farbe: grün = steuerbar, orange = nicht steuerbar */
/* Schwenken/Neigen (D-Pad) und Zoom (Pille) sind unabhängige Fähigkeiten:
   grün umrandet = kann das, orange = kann das nicht. */
.dpad.cap-on  { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.dpad.cap-on  .pad { color: var(--ok); }
.dpad.cap-on  .pad.home { border-color: var(--ok); }
.dpad.cap-off { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.dpad.cap-off .pad { color: var(--warn); opacity: .8; }
.dpad.cap-off .pad.home { border-color: var(--warn); }

.zoompill.cap-on  { border-color: color-mix(in srgb, var(--ok) 55%, var(--border)); }
.zoompill.cap-on  .zbtn, .zoompill.cap-on  .zoomlbl { color: var(--ok); }
.zoompill.cap-off { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.zoompill.cap-off .zbtn, .zoompill.cap-off .zoomlbl { color: var(--warn); opacity: .8; }

/* Hinweistext grün, sobald irgendeine Fähigkeit vorhanden ist. */
.ptz:has(.cap-on) .ptz-note { color: var(--ok); }
.ptz:not(:has(.cap-on)) .ptz-note { color: var(--warn); }


/* ---- Login ---- */
.loginbg { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.loginbox { width: min(360px, 94vw); background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 26px; display: grid; gap: 14px; }
.loginbrand { display: grid; justify-items: center; gap: 4px; }
.loginbrand img { width: min(230px, 70%); height: auto; display: block; }
.loginbrand .l-dark { display: none; }
:root[data-theme="dark"] .loginbrand .l-dark { display: block; }
:root[data-theme="dark"] .loginbrand .l-light { display: none; }
.loginsub { margin: -8px 0 6px; color: var(--muted); font-size: 13px; }
.loginerr { background: color-mix(in srgb, var(--off) 12%, transparent); color: var(--off); border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 600; }
.loginbox label { color: var(--muted); }
.loginbtn { width: 100%; justify-content: center; margin-top: 6px; }

/* ---- Topbar-Benutzer ---- */
.userchip { font-size: 13px; font-weight: 600; color: var(--text); background: var(--panel-2); border: 1px solid var(--border); padding: 5px 11px; border-radius: 999px; }

/* ---- Admin ---- */
.admincols { display: grid; grid-template-columns: 1fr; gap: 26px; }
@media (min-width: 920px) { .admincols { grid-template-columns: 1fr 1fr; } }
.adminhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.adminhead h2 { font-size: 15px; margin: 0; }
.field { display: grid; gap: 6px; }
.flabel { font-size: 13px; font-weight: 600; color: var(--muted); }
.chks { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text); }
.chk input { width: auto; }

/* ---- Viewer: Umschalter Live/Aufnahme + Playback-Leiste ---- */
.modeswitch { display: inline-flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.modebtn { display: inline-flex; align-items: center; gap: 6px; border: none; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 6px; cursor: pointer; }
.modebtn.on { background: var(--accent); color: #fff; }
.modebtn:not(.on):hover { color: var(--text); }

.pbbar { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--panel); display: flex; flex-direction: column; gap: 10px; }
.pbbar[hidden] { display: none; }   /* sonst überschreibt display:flex das hidden-Attribut (nur in Aufnahme zeigen) */
.pbrow { display: flex; align-items: center; gap: 10px; }
.pbtime { font-variant-numeric: tabular-nums; font-size: 13px; font-weight: 600; min-width: 92px; }
.pbtime.muted { font-weight: 500; min-width: 0; }
.pbseek { flex: 1; height: 6px; accent-color: var(--accent); cursor: pointer; }
.mark { font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--muted); min-width: 62px; }
.mark.set { color: var(--accent-ink); background: var(--accent-soft); padding: 2px 8px; border-radius: 6px; font-weight: 600; }

/* ---- Gebäude-Vorschau-Raster ---- */
.gridcols { display: inline-flex; gap: 2px; margin-left: 14px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.gridcols .gc { border: none; background: none; color: var(--muted); font: inherit; font-weight: 600; font-size: 12.5px; width: 26px; height: 24px; border-radius: 6px; cursor: pointer; }
.gridcols .gc:hover { color: var(--text); }
/* Aktiver Spalten-Button rein aus :root[data-grid-cols] — überlebt htmx-Swaps. */
:root[data-grid-cols="2"] .gridcols .gc[data-c="2"],
:root[data-grid-cols="4"] .gridcols .gc[data-c="4"],
:root:not([data-grid-cols]) .gridcols .gc[data-c="3"],
:root[data-grid-cols="3"] .gridcols .gc[data-c="3"] { background: var(--accent); color: #fff; }

/* Spaltenzahl aus :root[data-grid-cols] (überlebt Gebäudewechsel/htmx-Swaps). Default 3. */
.camgrid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; padding: 4px 2px; }
:root[data-grid-cols="2"] .camgrid { grid-template-columns: repeat(2, minmax(0,1fr)); }
:root[data-grid-cols="4"] .camgrid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.camtile { margin: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--panel); box-shadow: var(--shadow); cursor: pointer; transition: border-color .12s, transform .06s; }
.camtile:hover { border-color: var(--accent); }
.camtile:active { transform: scale(.997); }
.camtile.off { cursor: default; opacity: .8; }
.thumbwrap { position: relative; aspect-ratio: 16 / 9; background: #0b0f14; display: grid; place-items: center; overflow: hidden; }
.camthumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumboff { color: var(--muted); font-size: 13px; font-weight: 600; }
.rec.ontile { position: absolute; top: 8px; left: 8px; background: rgba(8,12,18,.55); padding: 2px 8px; border-radius: 999px; color: #fff; backdrop-filter: blur(2px); }
.camtile figcaption { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-weight: 600; font-size: 13.5px; }
.camtile .tname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-edit { padding: 3px 6px; }

/* Wirkungsvorschau in der Gruppenmaske.
   Sagt in Klartext, was die Gruppe wirklich freigibt — und faerbt
   deutlich, sobald sie ueber alle Standorte reicht. Ein leeres Feld
   bedeutet hier "alles", und das hat schon einmal jemanden ueberrascht. */
.wirkung {
  font-size: 13px; line-height: 1.45; margin: 4px 0 2px;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card, transparent);
  color: var(--text);
}
.wirkung:empty { display: none; }
.wirkung b { font-weight: 650; }
.wirkung.weit {
  border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.wirkung.leer { color: var(--muted); }
