/* Foto-Ablage. Hell oder dunkel folgt dem Geraet. Kein Rahmenwerk.
   Grundregel fuer ueberlagerte Flaechen (Grossansicht): was darueber liegt
   und selbst nichts tut, bekommt pointer-events: none. */

:root {
  --grund: #f5f3ef;
  --flaeche: #ffffff;
  --flaeche-2: #ebe8e2;
  --tinte: #1c1b19;
  --tinte-2: #57534d;
  --tinte-3: #8b867e;
  --linie: #e0dcd4;
  --feld: #ffffff;
  --feld-rand: #cfc9bf;
  --akzent: #b4532a;
  --akzent-tinte: #ffffff;
  --akzent-weich: #f7e8df;
  --gefahr: #b42318;
  --gefahr-tinte: #ffffff;
  --gefahr-weich: #fdecea;
  --ok: #1f6f43;
  --ok-weich: #e5f3ea;
  --radius: 14px;
  --schatten: 0 1px 2px rgba(0, 0, 0, .05), 0 6px 20px rgba(0, 0, 0, .05);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #121212;
    --flaeche: #1c1c1e;
    --flaeche-2: #29292c;
    --tinte: #f2f1ee;
    --tinte-2: #b8b4ac;
    --tinte-3: #8a867f;
    --linie: #34332f;
    --feld: #121212;
    --feld-rand: #4a4843;
    --akzent: #e5845a;
    --akzent-tinte: #1b0f09;
    --akzent-weich: #3a2419;
    --gefahr: #ff7a6e;
    --gefahr-tinte: #2a0906;
    --gefahr-weich: #3b1614;
    --ok: #74d39e;
    --ok-weich: #15301f;
    --schatten: none;
  }
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--grund);
  color: var(--tinte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

img { display: block; max-width: 100%; }
a { color: inherit; }

h1 {
  margin: 0;
  font-size: 1.6rem;
  line-height: 1.2;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.symbol {
  flex: none;
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.symbol.gross { width: 48px; height: 48px; stroke-width: 1.5; }

.unsichtbar {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Kopf und Rahmen ---------- */

.kopf {
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--grund) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--linie);
}

.kopf-innen {
  max-width: 1200px;
  min-height: 56px;
  margin: 0 auto;
  padding: 6px max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 12px;
}

.kopf-luft { flex: 1; }
.kopf-form { margin: 0; }

.marke,
.kopf-zurueck {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 0;
  text-decoration: none;
  font-weight: 650;
}
.marke .symbol { color: var(--akzent); }
.kopf-zurueck { margin-left: -6px; color: var(--akzent); font-weight: 600; }
.kopf-zurueck span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.inhalt {
  flex: 1;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}

.fuss {
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--tinte-3);
}

.abschnitt.schmal { max-width: 520px; margin: 0 auto; }

.titelzeile {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  margin-bottom: 16px;
}

.leise { color: var(--tinte-2); }

.leer {
  margin: 0;
  padding: 32px 8px;
  text-align: center;
  color: var(--tinte-2);
}

/* ---------- Knoepfe, Felder, Meldungen ---------- */

.knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--akzent);
  color: var(--akzent-tinte);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.knopf:hover { filter: brightness(1.07); }
.knopf:active { transform: translateY(1px); }
.knopf.leise { background: transparent; color: var(--tinte); border-color: var(--linie); }
.knopf.leise:hover { background: var(--flaeche-2); filter: none; }
.knopf.klein { min-height: 36px; padding: 0 14px; font-size: 14px; }
.knopf.gefahr { background: var(--gefahr); color: var(--gefahr-tinte); }
.knopf.breit { width: 100%; }

.knopfreihe { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
.knopf:focus-visible,
input.unsichtbar:focus-visible + .knopf {
  outline: 3px solid color-mix(in srgb, var(--akzent) 65%, transparent);
  outline-offset: 2px;
}

input[type="text"],
input[type="password"],
input:not([type]) {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--feld-rand);
  border-radius: 12px;
  background: var(--feld);
  color: var(--tinte);
  font: inherit;
}
input::placeholder { color: var(--tinte-3); }

.karte {
  padding: 20px;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche);
  box-shadow: var(--schatten);
}

.formular label { display: block; margin: 14px 0 6px; font-size: 14px; font-weight: 600; }
.formular label:first-child { margin-top: 0; }
.formular .knopf { margin-top: 20px; }

.meldung { margin: 0 0 16px; padding: 12px 14px; border-radius: 10px; }
.meldung ul { margin: 0; padding-left: 18px; }
.meldung.fehler { background: var(--gefahr-weich); color: var(--gefahr); }
.meldung.ok { background: var(--ok-weich); color: var(--ok); }

/* ---------- Anmelden ---------- */

.seite-anmelden .inhalt { display: flex; align-items: center; justify-content: center; }
.anmelden { width: 100%; max-width: 380px; }
.anmelden-marke {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  color: var(--akzent);
}
.anmelden-marke h1 { color: var(--tinte); }

/* ---------- Alben ---------- */

.neues-album { display: flex; gap: 10px; margin-bottom: 24px; }
.neues-album input { flex: 1; min-width: 0; }

.alben {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 16px 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.album-karte { display: flex; flex-direction: column; min-width: 0; text-decoration: none; }

.album-bild {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--flaeche-2);
  color: var(--tinte-3);
}
.album-bild img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.album-karte:hover .album-bild img { transform: scale(1.03); }

.album-name {
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}
.album-anzahl { font-size: 14px; color: var(--tinte-2); }

/* ---------- Hochladen ---------- */

.hochladen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-bottom: 20px;
  padding: 16px;
  border: 2px dashed var(--linie);
  border-radius: var(--radius);
  background: var(--flaeche);
  transition: border-color .15s, background-color .15s;
}
.hochladen.ziehen { border-color: var(--akzent); background: var(--akzent-weich); }
.hochladen-ziehen { color: var(--tinte-2); }
.hochladen .leer { padding: 0; text-align: left; }

.hochladen-stand { flex-basis: 100%; }
.hochladen-stand progress { display: block; width: 100%; height: 8px; accent-color: var(--akzent); }
.hochladen-text { margin: 6px 0 0; font-size: 14px; color: var(--tinte-2); overflow-wrap: anywhere; }

.probleme { margin: 8px 0 0; padding-left: 18px; font-size: 14px; color: var(--gefahr); overflow-wrap: anywhere; }
.probleme .hinweis { color: var(--tinte-2); }

/* ---------- Raster ---------- */

.raster {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
}

.kachel {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  background: var(--flaeche-2);
}
.kachel img { width: 100%; height: 100%; object-fit: cover; }
.kachel.neu { animation: auftauchen .35s ease-out; }

.kachel-ohne {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  color: var(--tinte-3);
  font-size: 12px;
  font-weight: 600;
}

@keyframes auftauchen { from { opacity: 0; transform: scale(.96); } }

/* ---------- Loeschen ---------- */

.loeschen-vorschau {
  display: grid;
  place-items: center;
  width: 160px;
  aspect-ratio: 1;
  margin: 16px 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--flaeche-2);
  color: var(--tinte-3);
}
.loeschen-vorschau img { width: 100%; height: 100%; object-fit: cover; }
.warnung { color: var(--gefahr); }

/* ---------- Grossansicht ---------- */

html.lk-offen { overflow: hidden; }

.leuchtkasten {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: #000;
  color: #fff;
  overscroll-behavior: contain;
}

.lk-leiste {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
  background: linear-gradient(rgba(0, 0, 0, .6), transparent);
}
.lk-zaehler { padding-left: 8px; font-size: 14px; opacity: .8; font-variant-numeric: tabular-nums; }
.lk-luft { flex: 1; }

.lk-knopf,
.lk-pfeil {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}
.lk-knopf:hover,
.lk-pfeil:hover { background: rgba(255, 255, 255, .16); }

/* Flex, nicht Grid: in einem Grid mit automatischer Zeilenhoehe laeuft
   max-height: 100% am Bild ins Leere, und ein Hochkantfoto ragte ueber den
   Bildschirm hinaus. Die Buehne hat durch inset: 0 eine feste Hoehe, darauf
   bezieht sich das Bild hier. */
.lk-buehne {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Aufziehen mit zwei Fingern bleibt erlaubt; gewischt wird nur, solange
     nicht vergroessert ist (siehe public/app.js). */
  touch-action: manipulation;
}

.lk-bild {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  transition: opacity .15s;
}
.lk-bild.wechsel { opacity: .35; }

/* Ueber dem Bild statt daneben: "Laedt ..." erscheint, waehrend das vorige
   Foto noch gedimmt zu sehen ist. */
.lk-hinweis { position: absolute; padding: 24px; text-align: center; opacity: .85; pointer-events: none; }
.lk-hinweis .symbol { margin: 0 auto 8px; }

.lk-pfeil {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 52px;
  height: 52px;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, .35);
}
.lk-zurueck { left: max(10px, env(safe-area-inset-left)); }
.lk-weiter { right: max(10px, env(safe-area-inset-right)); }
.lk-pfeil:disabled { visibility: hidden; }

.lk-unterschrift {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  padding: 24px 16px max(14px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, .6));
  text-align: center;
  font-size: 14px;
  overflow-wrap: anywhere;
  pointer-events: none;
}

/* ---------- Breite und Bedienung ---------- */

@media (min-width: 700px) {
  .alben { gap: 24px 20px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .raster { gap: 6px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .kachel { border-radius: 8px; }
}

/* Touchgeraete: niemand zieht dort Dateien, und geblaettert wird mit dem Finger. */
@media (hover: none) {
  .hochladen { border-style: solid; }
  .hochladen-ziehen { display: none; }
  .lk-pfeil { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
