:root {
  --bg: #0b0b10;
  --bg2: #15152a;
  --karte: rgba(255,255,255,0.05);
  --rand: rgba(255,255,255,0.1);
  --text: #f2f2f6;
  --grau: #9a9ab0;
  --hd: #4caf50;
  --sd: #ff9800;
  --fehler: #ff5a5a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg2) 100%) fixed;
  color: var(--text);
}
a { color: inherit; }
button, .knopf {
  font: inherit; color: var(--text); background: var(--karte); border: 1px solid var(--rand);
  border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover, .knopf:hover { background: rgba(255,255,255,0.1); }
button.primaer { background: var(--hd); border-color: var(--hd); color: #061; font-weight: 600; }
button.gefahr { color: var(--fehler); }
input[type=text], input[type=password], select {
  font: inherit; color: var(--text); background: rgba(0,0,0,0.3); border: 1px solid var(--rand);
  border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--hd); outline-offset: 0; }
.fehler { color: var(--fehler); }
.hinweis { color: var(--grau); }
[hidden] { display: none !important; }

/* ---- Anmeldung ---- */
.login-seite { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 28px; }
.login-seite .banner { width: min(520px, 90vw); filter: drop-shadow(0 0 20px rgba(187,134,252,0.25)); }
.login-karte { width: min(380px, 100%); background: var(--karte); border: 1px solid var(--rand); border-radius: 20px; padding: 28px; backdrop-filter: blur(10px); display: flex; flex-direction: column; gap: 14px; }
.login-karte h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-karte label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--grau); }
.login-karte button[type=submit] { background: var(--hd); border-color: var(--hd); color: #062; font-weight: 600; padding: 12px; }
.pass-feld { position: relative; display: block; }
.pass-feld input { padding-right: 48px; }
.auge { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 6px 10px; font-size: 1.1rem; color: var(--grau); cursor: pointer; line-height: 1; }
.auge:hover, .auge.an { color: var(--text); background: none; }
.login-karte .haken { flex-direction: row; align-items: center; gap: 10px; color: var(--text); cursor: pointer; }
.login-karte .haken input { width: 18px; height: 18px; accent-color: var(--hd); margin: 0; }

/* ---- Kopfzeile ---- */
.kopf { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; background: rgba(11,11,16,0.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--rand); flex-wrap: wrap; }
.kopf-links { display: flex; align-items: center; gap: 16px; }
.kopf .logo { height: 36px; }
.uhr { font-size: 1.6rem; font-variant-numeric: tabular-nums; color: #ddd; }
.uhr small { color: var(--grau); font-size: .95rem; margin-left: 10px; }
.kopf-rechts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; align-items: center; gap: 6px; }
.gruppen { display: flex; gap: 6px; }
.tab { font: inherit; color: var(--text); background: var(--karte); border: 1px solid var(--rand); border-radius: 10px; padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.tab .symbol { font-size: 1rem; }
.tab.aktiv { border-color: var(--hd); color: var(--hd); }
.tab.mehr, .tab.layout { display: none; }
.nur-handy { display: none; }
.schalter { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--grau); user-select: none; cursor: pointer; }
.schalter #label-hd.aktiv { color: var(--hd); }
.schalter #label-sd.aktiv { color: var(--sd); }
.schalter .slider { position: relative; width: 46px; height: 26px; display: inline-block; }
.schalter input { opacity: 0; width: 0; height: 0; position: absolute; }
.schalter i { position: absolute; inset: 0; background: var(--hd); border-radius: 26px; transition: .3s; }
.schalter i::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .3s; }
.schalter input:checked + i { background: var(--sd); }
.schalter input:checked + i::before { transform: translateX(20px); }

/* ---- Kameraraster ---- */
.raster { display: grid; gap: 10px; padding: 10px; grid-template-columns: repeat(var(--spalten, 3), 1fr); }
@media (max-width: 700px) { .raster { grid-template-columns: 1fr !important; } }
@media (min-width: 701px) and (max-width: 1100px) { .raster.auto { grid-template-columns: repeat(2, 1fr); } }
.kamera { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16/9; cursor: pointer; border: 1px solid transparent; }
.kamera video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.kamera .titel { position: absolute; left: 8px; bottom: 8px; background: rgba(0,0,0,0.55); padding: 3px 8px; border-radius: 6px; font-size: .9rem; pointer-events: none; }
.kamera .status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--grau); font-size: .95rem; pointer-events: none; background: rgba(0,0,0,0.35); }
.kamera.laeuft .status { display: none; }
.kamera .status.fehler { color: var(--fehler); }
.kamera.gross { position: fixed; inset: 0; z-index: 50; border-radius: 0; aspect-ratio: auto; width: 100vw; height: 100vh; }
body.vollbild { overflow: hidden; }
.leer { text-align: center; color: var(--grau); margin-top: 60px; }

/* ---- Admin ---- */
.admin { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 24px; }
.admin h2 { margin: 0 0 12px; font-size: 1.1rem; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.karte { background: var(--karte); border: 1px solid var(--rand); border-radius: 16px; padding: 16px; }
.tabelle { width: 100%; border-collapse: collapse; }
.tabelle th, .tabelle td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--rand); vertical-align: middle; }
.tabelle th { color: var(--grau); font-weight: 500; font-size: .85rem; }
.tabelle tr.gesperrt td { opacity: .5; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .8rem; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--rand); background: rgba(0,0,0,.25); cursor: pointer; user-select: none; }
.chip.an { border-color: var(--hd); color: var(--hd); }
.chip.alle { border-color: var(--sd); color: var(--sd); cursor: default; }
.aktionen { display: flex; gap: 6px; flex-wrap: wrap; }
.aktionen button { padding: 5px 9px; font-size: .85rem; }
.dialog { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.dialog form { background: #1a1a2e; border: 1px solid var(--rand); border-radius: 16px; padding: 20px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 12px; }
.dialog label { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; color: var(--grau); }
.dialog .zeile { display: flex; gap: 8px; justify-content: flex-end; }
.meldung { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #222; border: 1px solid var(--rand); padding: 10px 16px; border-radius: 10px; z-index: 200; }
.sitzungen { font-size: .8rem; color: var(--grau); }
@media (max-width: 700px) {
  .tabelle thead { display: none; }
  .tabelle tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--rand); }
  .tabelle td { display: block; border: 0; padding: 4px 0; }
}

/* ---- Ansicht-Dropdown & eigene Layouts ---- */
select.knopf { appearance: auto; background: var(--karte); color: var(--text); padding: 7px 10px; width: auto; max-width: 220px; }
select.knopf option { background: #1a1a2e; color: var(--text); }
.raster.eigen { grid-template-columns: repeat(var(--spalten), 1fr); }
.zelle-leer { aspect-ratio: 16/9; border-radius: 10px; border: 1px dashed var(--rand); }
.kamera-quad { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 5px; aspect-ratio: 16/9; }
.kamera-quad .kamera { aspect-ratio: auto; }
.kamera-quad .kamera .titel { font-size: .75rem; padding: 2px 6px; }
.kamera.gross { aspect-ratio: auto; }
.kamera .status.keine { color: var(--grau); }
@media (max-width: 700px) { .raster.eigen { grid-template-columns: 1fr !important; } .kamera-quad { aspect-ratio: 16/9; } }

/* Layout-Editor */
.editor form { width: min(760px, 100%); max-height: 92vh; overflow: auto; }
.editor .kopfzeile { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.editor .kopfzeile label { flex: 1 1 160px; }
.editor .vorschau { display: grid; gap: 8px; grid-template-columns: repeat(var(--spalten, 2), 1fr); }
.editor .ez { border: 1px solid var(--rand); border-radius: 10px; padding: 8px; background: rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 6px; min-height: 90px; }
.editor .ez select { padding: 6px 8px; font-size: .85rem; }
.editor .ez .mini { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.editor .ez .leiste { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--grau); }
.editor .ez .leiste button { padding: 2px 7px; font-size: .8rem; }
.editor .fuss { display: flex; gap: 8px; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.editor .fuss .zeile { margin-left: auto; }

/* ---- Handy: Tab-Leiste unten, restliche Schalter als Blatt ---- */
@media (max-width: 700px) {
  body.ansicht { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  /* kein backdrop-filter: der würde die fixe Tab-Leiste und das Blatt am Kopf festhalten */
  .kopf { padding: 6px 12px; padding-top: calc(6px + env(safe-area-inset-top)); backdrop-filter: none; background: rgba(11,11,16,0.97); }
  .kopf .logo { height: 30px; }
  .uhr { font-size: 1.1rem; }
  .uhr small { display: none; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(11,11,16,0.92); backdrop-filter: blur(12px); border-top: 1px solid var(--rand); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 4px; }
  .tabs .gruppen { display: contents; }
  .tab { flex: 1 1 0; flex-direction: column; gap: 2px; padding: 6px 2px; background: none; border: 0; border-radius: 10px; font-size: .72rem; color: var(--grau); }
  .tab .symbol { font-size: 1.35rem; line-height: 1.2; }
  .tab.aktiv { color: var(--hd); background: rgba(76,175,80,0.12); }
  .tab.mehr, .tab.layout { display: flex; }
  .nur-handy { display: inline; }
  .kopf-rechts { display: none; position: fixed; left: 0; right: 0; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 39; background: #15152a; border-top: 1px solid var(--rand); border-radius: 18px 18px 0 0; padding: 14px 16px; flex-direction: column; align-items: stretch; gap: 12px; box-shadow: 0 -10px 30px rgba(0,0,0,.5); }
  .kopf-rechts.offen { display: flex; }
  .kopf-rechts .knopf, .kopf-rechts select.knopf { padding: 12px 14px; text-align: center; }
  .kopf-rechts .schalter { justify-content: center; padding: 6px 0; }
  .raster { padding: 8px; gap: 8px; }
  .kamera.gross { height: 100dvh; }
  .dialog { padding: 8px; align-items: flex-end; }
  .dialog form { max-height: 88vh; overflow: auto; }
  .editor .vorschau { grid-template-columns: 1fr 1fr !important; }
}
