:root {
  --rot: #b5231f;
  --rot-hell: #ff6b62;
  --grund: #fbf8f7;
  --karte: #ffffff;
  --text: #241a19;
  --grau: #6d6361;
  --linie: #e6dedc;
  --sicher-oben: env(safe-area-inset-top, 0px);
  --sicher-unten: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #1a1514;
    --karte: #241d1c;
    --text: #f4ecea;
    --grau: #a99d9a;
    --linie: #3a2f2d;
  }
}

* { box-sizing: border-box; }

/* Die Huelle ist genau so hoch wie der sichtbare Ausschnitt und scrollt selbst nicht.
   Hoehe und Safe-Area gehoeren zusammen auf dieses eine Element: mit border-box liegt
   das obere Padding INNEN, sonst waere die Seite genau um die Safe-Area zu hoch und
   der Ausloeser rutschte unter den Rand. Unten kein Padding, das traegt die Leiste
   selbst. --hoehe misst lib/hoehe.js, 100dvh gilt nur bis zur ersten Messung. */
body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: var(--sicher-oben) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
  height: var(--hoehe, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
}

/* Regel fuer alles hier: nach oben verankern und die Hoehe angeben, niemals nach
   unten (siehe Kommentar bei body). */
#app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--linie);
  background: var(--karte);
}

header h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -0.01em; }

main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; padding: 16px; overflow: auto; }

.hinweis { color: var(--grau); font-size: 15px; margin: 0; }

button {
  font: inherit;
  border: 1px solid var(--linie);
  background: var(--karte);
  color: var(--text);
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:active { transform: scale(0.99); }

button.gross { width: 100%; padding: 22px 18px; font-size: 19px; font-weight: 600; }

button.primaer {
  background: var(--rot);
  border-color: var(--rot);
  color: #fff;
  font-weight: 600;
}

button.rund {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

button[disabled] { opacity: 0.5; }

.kameraseite { gap: 12px; overflow: hidden; }

/* Der Ausloeser darf nie gequetscht werden, der Sucher gibt nach. */
.leiste { flex: 0 0 auto; }

.sucher {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
}

/* Absolut im Rahmen statt height:100%: eine Prozenthoehe gegen eine Flex-Hoehe
   lassen die Browser gern aus, dann haengt das Bild oben und darunter ist Schwarz. */
.sucher video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.blitz {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.66);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.leiste {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  justify-items: center;
  /* Die untere Safe-Area haengt hier, nicht am body: sonst zaehlt sie doppelt. */
  padding: 4px 0 calc(8px + var(--sicher-unten));
}

.platzhalter { width: 44px; height: 44px; }

.ausloeser {
  width: 74px;
  height: 74px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid var(--rot);
  background: transparent;
  display: grid;
  place-items: center;
}

.ausloeser span {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--rot);
  display: block;
}

.ausloeser[disabled] span { background: var(--grau); }

.licht.an {
  background: #f6c344;
  border-color: #f6c344;
  color: #3a2c05;
}

.wartet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--rot) 8%, var(--karte));
  border: 1px solid color-mix(in srgb, var(--rot) 22%, var(--linie));
  font-size: 15px;
}

.wartet button { padding: 8px 12px; border-radius: 10px; font-size: 15px; }

form { display: flex; flex-direction: column; gap: 18px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--grau); }

input {
  font: inherit;
  color: var(--text);
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 12px;
  padding: 12px 14px;
}

input:focus-visible, button:focus-visible { outline: 2px solid var(--rot-hell); outline-offset: 2px; }

.meldung {
  padding: 12px 14px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--rot) 10%, var(--karte));
  border: 1px solid color-mix(in srgb, var(--rot) 30%, var(--linie));
  font-size: 15px;
}

.versteckt { display: none !important; }
