/* Kameraarchiv — mobile first.
   Dunkel als Grundton, weil die Aufnahmen meist nachts entstehen und ein
   helles Interface um drei Uhr morgens blendet. */

:root {
  --bg: #0f1115;
  --flaeche: #171a21;
  --flaeche2: #1f232c;
  --rand: #2a2f3a;
  --text: #e8eaee;
  --leise: #9aa3b2;
  --akzent: #4c8dff;
  --gruen: #3ecf8e;
  --rot: #ff5c5c;
  --gelb: #ffc857;
  --radius: 14px;
  --sicher-oben: env(safe-area-inset-top, 0px);
  --sicher-unten: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f9; --flaeche: #fff; --flaeche2: #eef1f6; --rand: #d8dee8;
    --text: #131722; --leise: #5b6676;
  }
}

* { box-sizing: border-box; }

/* Muss vor allen display-Regeln stehen und sich durchsetzen: Klassen wie
   .mitte (display:grid) haben sonst hoehere Spezifitaet als die
   Browservorgabe [hidden]{display:none} -- versteckte Bereiche blieben dann
   unsichtbar, wuerden aber weiter ihren vollen Platz belegen. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

button, input { font: inherit; color: inherit; }
.sym { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2;
       stroke-linecap: round; stroke-linejoin: round; }
#passkeyknopf .sym, .zeile .sym { fill: currentColor; stroke: none; }

/* ---------- Grundbausteine ---------- */
.mitte { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.mitte-text { text-align: center; padding: 32px 16px; }
.leise { color: var(--leise); font-size: .9rem; }

.karte {
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--radius);
  padding: 24px; width: min(100%, 400px); display: flex; flex-direction: column; gap: 12px;
}
.karte h1 { margin: 0; font-size: 1.4rem; }

label { font-size: .85rem; color: var(--leise); margin-bottom: -6px; }

input {
  background: var(--flaeche2); border: 1px solid var(--rand); border-radius: 10px;
  padding: 13px 14px; width: 100%;
}
input:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--akzent); outline-offset: 2px;
}

.knopf {
  background: var(--akzent); color: #fff; border: 0; border-radius: 10px;
  padding: 13px 16px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px;
}
.knopf:active { transform: translateY(1px); }
.knopf[disabled] { opacity: .55; cursor: default; }
.knopf.gross { padding: 15px; font-size: 1.02rem; }
.knopf.breit { width: calc(100% - 32px); margin: 8px 16px 28px; }
.knopf.still { background: var(--flaeche2); color: var(--text); border: 1px solid var(--rand); }
.knopf.gefahr { background: var(--rot); }

.textknopf { background: none; border: 0; color: var(--akzent); cursor: pointer;
             padding: 8px; text-align: left; }
.fehler { color: var(--rot); font-size: .9rem; margin: 0; }

details summary { cursor: pointer; color: var(--leise); font-size: .9rem; padding: 6px 0; }
details[open] summary { margin-bottom: 6px; }
details > *:not(summary) { margin-top: 8px; }

/* ---------- Kopf ---------- */
.kopf {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--sicher-oben)) 12px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rand);
}
.kopf h1 { font-size: 1.1rem; margin: 0; flex: 1; }
.kopfknoepfe { display: flex; gap: 4px; }

.ikon {
  background: none; border: 0; color: var(--text); cursor: pointer;
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; position: relative;
}
.ikon:active { background: var(--flaeche2); }
.ikon.hell { color: #fff; }
.punkt { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px;
         background: var(--akzent); border-radius: 50%; }

/* ---------- Filter ---------- */
.filterleiste {
  padding: 12px; border-bottom: 1px solid var(--rand); background: var(--flaeche);
  display: flex; flex-direction: column; gap: 10px;
}
.gruppe { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--flaeche2); border: 1px solid var(--rand); color: var(--text);
  border-radius: 999px; padding: 9px 14px; cursor: pointer; min-height: 40px;
}
.chip[aria-pressed="true"] { background: var(--akzent); border-color: var(--akzent); color: #fff; }
.chip .anzahl { color: var(--leise); font-size: .8rem; margin-left: 5px; }
.chip[aria-pressed="true"] .anzahl { color: #dbe7ff; }

/* ---------- Raster ---------- */
.raster {
  display: grid; gap: 10px; padding: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (min-width: 900px) { .raster { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }

.kachel {
  position: relative; background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); overflow: hidden; cursor: pointer; padding: 0;
  text-align: left; color: inherit; display: block; width: 100%;
}
.kachel img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #000; }
.kachel .platzhalter { width: 100%; aspect-ratio: 16/9; display: grid; place-items: center;
                       background: var(--flaeche2); color: var(--leise); font-size: .8rem; }
.kachelinfo { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; }
.kachelinfo .zeit { font-size: .82rem; color: var(--leise); }
.kachelinfo .name { font-size: .92rem; font-weight: 600; }

.marken { position: absolute; top: 8px; left: 8px; display: flex; gap: 5px; }
.marke {
  background: rgba(10,12,16,.82); color: #fff; font-size: .72rem; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(4px);
}
.marke.people  { background: rgba(76,141,255,.92); }
.marke.animal  { background: rgba(62,207,142,.92); }
.marke.vehicle { background: rgba(255,200,87,.92); color: #241c00; }
.dauer { position: absolute; right: 8px; bottom: 58px; background: rgba(10,12,16,.82);
         color: #fff; font-size: .72rem; padding: 2px 7px; border-radius: 6px; }
.neu { position: absolute; top: 8px; right: 8px; width: 9px; height: 9px;
       background: var(--akzent); border-radius: 50%; box-shadow: 0 0 0 2px rgba(0,0,0,.35); }

/* ---------- Vollansicht ---------- */
.voll { position: fixed; inset: 0; background: #000; z-index: 60;
        display: flex; flex-direction: column; }
.vollkopf {
  display: flex; align-items: center; gap: 10px; color: #fff;
  padding: calc(8px + var(--sicher-oben)) 8px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,.75), transparent);
  position: absolute; inset: 0 0 auto 0; z-index: 2;
}
.vollinfo { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.vollinfo strong { font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vollinfo .leise { color: #b9c2d0; font-size: .8rem; }

/* Wischen: horizontale Bahn mit Einrasten. Nativ statt nachgebauter Geste --
   folgt dem Finger exakt und braucht keine Bibliothek. */
.bahn {
  flex: 1; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.bahn::-webkit-scrollbar { display: none; }
.folie {
  flex: 0 0 100%; width: 100%; height: 100%;
  scroll-snap-align: center; scroll-snap-stop: always;
  display: grid; place-items: center; position: relative;
}
.folie video { width: 100%; height: 100%; object-fit: contain; background: #000; }

.vollfuss {
  display: flex; justify-content: space-around; align-items: center;
  padding: 10px 8px calc(10px + var(--sicher-unten));
  background: linear-gradient(to top, rgba(0,0,0,.8), transparent);
  position: absolute; inset: auto 0 0 0; z-index: 2;
}
.wischhinweis {
  position: absolute; bottom: calc(76px + var(--sicher-unten)); left: 0; right: 0;
  text-align: center; color: #cfd6e2; font-size: .8rem; pointer-events: none;
  transition: opacity .4s; text-shadow: 0 1px 3px rgba(0,0,0,.8);
}

/* ---------- Blatt von unten ---------- */
.blatt { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.5);
         display: flex; align-items: flex-end; }
.blattinhalt {
  background: var(--flaeche); width: 100%; border-radius: 18px 18px 0 0;
  padding: 10px 10px calc(14px + var(--sicher-unten));
  max-height: 85dvh; overflow-y: auto;
  animation: hoch .18s ease-out;
}
@keyframes hoch { from { transform: translateY(14px); opacity: .6; } }
@media (min-width: 700px) {
  .blatt { align-items: center; justify-content: center; }
  .blattinhalt { max-width: 520px; border-radius: var(--radius); }
}
.blattkopf { padding: 10px 12px; color: var(--leise); font-size: .85rem; margin: 0; }
.zeile {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 0; padding: 15px 12px; text-align: left;
  border-radius: 10px; cursor: pointer; min-height: 50px;
}
.zeile:active { background: var(--flaeche2); }
.zeile.gefahr { color: var(--rot); }

.blattinhalt h2 { margin: 6px 12px 12px; font-size: 1.1rem; }
.feld { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabelle th, .tabelle td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--rand); }
.tabelle th { color: var(--leise); font-weight: 600; font-size: .8rem; }

.hinweis {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(22px + var(--sicher-unten)); z-index: 90;
  background: var(--flaeche2); border: 1px solid var(--rand); color: var(--text);
  padding: 12px 18px; border-radius: 999px; box-shadow: 0 8px 28px rgba(0,0,0,.45);
  max-width: min(92vw, 460px); text-align: center; font-size: .92rem;
}
.hinweis.gut { border-color: var(--gruen); }
.hinweis.schlecht { border-color: var(--rot); }

.kopieren { display: flex; gap: 8px; align-items: center; }
.kopieren input { flex: 1; font-size: .85rem; }

/* ---------- Freigabeseite ---------- */
body.freigabe { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
body.freigabe video { width: 100%; border-radius: 10px; background: #000; margin-top: 8px; }
body.freigabe .hinweis { position: static; transform: none; margin-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
