/* Galerie — mobil zuerst. Simon teilt und schaut ueberwiegend am iPhone. */

:root {
  --bg: #0b0b0c;
  --flaeche: #17181a;
  --rand: #2a2c30;
  --text: #f2f3f5;
  --leise: #9aa0a6;
  --akzent: #4a9eff;
  --gruen: #35c07a;
  --rot: #ff5f6d;
  /* Ausschnitte am iPhone (Notch, Home-Indikator) */
  --oben: env(safe-area-inset-top, 0px);
  --unten: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Muss ganz oben stehen und muss !important sein: Das hidden-Attribut setzt
   display:none nur ueber das Browser-Standardblatt, und jede eigene Regel mit
   display (z. B. .overlay { display:flex }) gewinnt dagegen. Ohne das hier lag
   die Einzelbildansicht beim Laden offen ueber der Galerie. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  /* Verhindert, dass iOS beim Doppeltippen hineinzoomt */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
body.fixiert { overflow: hidden; }

button {
  font: inherit;
  color: var(--text);
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 10px 14px;
  /* 44px ist Apples Mindestgroesse fuer sicher treffbare Flaechen */
  min-height: 44px;
  cursor: pointer;
}
button:disabled { opacity: .4; cursor: default; }
button.an { border-color: var(--akzent); background: #16304d; }

input {
  font: inherit;
  color: var(--text);
  background: #0f1012;
  border: 1px solid var(--rand);
  border-radius: 10px;
  padding: 12px;
  width: 100%;
  /* 16px verhindert den Auto-Zoom von Safari beim Antippen */
  font-size: 16px;
}

/* ---------- Kopf ---------- */
#kopf {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(var(--oben) + 12px) 12px 8px;
  background: rgba(11, 11, 12, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rand);
}
.kopfzeile { display: flex; align-items: center; gap: 10px; }
#titel { margin: 0; font-size: 19px; flex: 1; }
.leise {
  background: none;
  border: none;
  color: var(--leise);
  font-size: 14px;
  padding: 6px 8px;
  min-height: 36px;
}

#filter {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
#filter::-webkit-scrollbar { display: none; }
#filter button {
  white-space: nowrap;
  font-size: 14px;
  padding: 8px 12px;
  min-height: 38px;
}
#filter button.aktiv { border-color: var(--akzent); color: var(--akzent); }
#filter span { color: var(--leise); margin-left: 4px; }

/* ---------- Raster ---------- */
#raster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 4px;
  padding: 4px;
  padding-bottom: 96px; /* Platz fuer die Leiste unten */
}
@media (min-width: 900px) {
  #raster { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; padding: 8px; }
}

.kachel {
  position: relative;
  margin: 0;
  background: var(--flaeche);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
/* Quadratisch und beschnitten. Gemischte Hoch-/Querformate haben sonst in
   derselben Rasterzeile unterschiedliche Hoehen und reissen schwarze Loecher
   in die Kacheln - genau das war beim ersten Sichttest zu sehen. */
.kachel img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.zeichen {
  position: absolute;
  left: 6px;
  bottom: 6px;
  display: flex;
  gap: 4px;
}
.zeichen span {
  font-size: 12px;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(6px);
}
.zeichen .gewaehlt { color: var(--gruen); }
.zeichen .geliked { color: var(--rot); }
.leer { grid-column: 1 / -1; text-align: center; color: var(--leise); padding: 48px 0; }

/* ---------- Leiste unten ---------- */
#leiste {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px calc(10px + var(--unten));
  background: rgba(11, 11, 12, .94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--rand);
}
#auswahlinfo { flex: 1; color: var(--leise); font-size: 14px; }
#zipknopf { border-color: var(--akzent); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .96);
  display: flex;
  align-items: center;
  justify-content: center;
}
.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 16px;
  padding: 24px;
  width: min(420px, calc(100% - 32px));
}
.karte h1 { margin: 0 0 8px; font-size: 20px; }
.karte p { color: var(--leise); font-size: 14px; margin: 0 0 16px; }
.karte button { width: 100%; margin-top: 12px; border-color: var(--akzent); }

/* ---------- Einzelbild ---------- */
#lupe { flex-direction: column; }
#grossbild {
  max-width: 100%;
  max-height: calc(100vh - 260px - var(--oben) - var(--unten));
  object-fit: contain;
}
.rund {
  position: absolute;
  border-radius: 999px;
  width: 44px;
  padding: 0;
  background: rgba(30, 30, 32, .8);
  z-index: 2;
}
#zu { top: calc(var(--oben) + 12px); right: 12px; }
.seite { top: 50%; transform: translateY(-50%); font-size: 26px; }
.links { left: 10px; }
.rechts { right: 10px; }

#werkzeuge {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 12px 12px calc(12px + var(--unten));
  background: rgba(11, 11, 12, .95);
  border-top: 1px solid var(--rand);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
#btn-auswahl, #btn-like { flex: 1; min-width: 130px; }
#kommentarbereich { width: 100%; }
#kommentarliste { max-height: 96px; overflow-y: auto; margin-bottom: 8px; }
.kommentar { font-size: 14px; padding: 3px 0; }
.kommentar strong { color: var(--akzent); margin-right: 6px; }
#kommentarform { display: flex; gap: 8px; }
#kommentarform input { flex: 1; }

#meldung {
  position: fixed;
  left: 50%;
  bottom: calc(84px + var(--unten));
  transform: translateX(-50%);
  z-index: 100;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
}

/* ---------- Anmeldeseite ---------- */
body.mitte {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;   /* dvh: iOS-Adressleiste faehrt ein und aus */
  padding: 16px;
}
body.mitte .karte { margin: 0 auto; }
.fehler { color: var(--rot); font-size: 14px; margin: 12px 0 0; }
