/* ============================================================
   MMS — Design-System
   Elegant und festlich: weisse/neutrale Basis mit Gold als
   einzigem Akzent. Hell als Standard, dunkel (neutrales
   Anthrazit) über prefers-color-scheme. Alle Farben/Abstände
   laufen über CSS-Variablen — keine Zauberzahlen in Templates.
   ============================================================ */

:root {
  /* Spacing-Skala */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 40px;
  --s-7: 64px;

  /* Radien */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  /* Bedienelemente */
  --control-h: 2.5rem;
  --control-h-sm: 2rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;

  /* Helles Farbschema (Standard): weiss/neutral mit Gold als einzigem Akzent */
  --bg: #f7f6f3;
  --bg-soft: #efede8;
  --card: #ffffff;
  --fg: #22201c;
  --muted: #6d6a63;
  --line: #ebe9e3;
  --line-strong: #dbd8d0;

  --accent: #b8933f;
  --accent-hover: #9c7a2f;
  --accent-light: #ceac5b;
  --accent-soft: #f6efdc;
  /* Gold-Button traegt dunklen Text — Weiss auf Gold hat zu wenig Kontrast. */
  --fg-on-fill: #241d06;

  --danger: #a23b30;
  --danger-hover: #872f26;
  --danger-soft: #f7e6e2;

  --focus: #b8933f;

  /* Gold-Akzent fuer Zier-Trenner, Ornamente, feine Glanzpunkte */
  --gold: #b8933f;
  --gold-soft: #f6efdc;
  --gold-line: rgba(184, 147, 63, 0.35);

  --shadow-sm: 0 1px 3px rgba(40, 38, 30, 0.07);
  --shadow: 0 10px 28px rgba(40, 38, 30, 0.09);
  --shadow-accent: 0 6px 18px rgba(184, 147, 63, 0.24);

  /* Sehr dezenter Verlauf, praktisch weiss: fast weiss -> zartes Neutral */
  --bg-grad: linear-gradient(180deg, #ffffff 0%, #faf9f6 55%, #f4f2ec 100%);
}

/* Dunkelmodus haengt am data-theme-Attribut, nicht mehr an der Media-Query.
   Ein Init-Skript im <head> setzt data-theme beim Laden (gespeicherte Wahl,
   sonst Systemvorgabe), der Umschalt-Button aendert es zur Laufzeit. */
:root[data-theme="dark"] {
    /* Neutrales Anthrazit (kein Braunstich) mit Gold */
    --bg: #17171a;
    --bg-soft: #1f1f23;
    --card: #212125;
    --fg: #f0efe9;
    --muted: #a5a29b;
    --line: #303036;
    --line-strong: #43434b;

    --accent: #d8bd74;
    --accent-hover: #e6cd8a;
    --accent-light: #e6cd8a;
    --accent-soft: #2a2718;
    --fg-on-fill: #1b1707;

    --danger: #e2867a;
    --danger-hover: #ec9a8f;
    --danger-soft: #3a221c;

    --focus: #d8bd74;

    --gold: #d8bd74;
    --gold-soft: #2a2718;
    --gold-line: rgba(216, 189, 116, 0.3);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.32);
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.44);
    --shadow-accent: 0 8px 22px rgba(216, 189, 116, 0.16);

    /* Neutrales Anthrazit, ganz leichter Schimmer nach oben */
    --bg-grad: linear-gradient(180deg, #1c1c20 0%, #17171a 50%, #131315 100%);

    color-scheme: dark;
}

:root[data-theme="light"] { color-scheme: light; }

/* ---------- Hell/Dunkel-Umschalter ---------- */

.theme-toggle {
  position: fixed;
  top: var(--s-3);
  right: var(--s-3);
  z-index: 100;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Reset & Grundlagen ---------- */

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg-grad) fixed;
  color: var(--fg);
  font: 16px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

img { max-width: 100%; }

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--s-5) var(--s-4) var(--s-7);
}

.wrap--narrow { max-width: 460px; }

/* ---------- Typografie ---------- */

h1, h2 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}
h1 { font-size: 1.9rem; margin: 0 0 var(--s-1); }
h2 { font-size: 1.25rem; margin: 0 0 var(--s-3); }

p { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

.sub { color: var(--muted); margin: 0 0 var(--s-5); }

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: var(--s-3);
}
.back-link:hover { color: var(--accent); }

.card-link { display: block; color: inherit; text-decoration: none; }
.card-link:hover h2 { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Festlicher Hero (Gast-Seiten: Galerie, Upload) ----------
   Volle Breite, sanfter Radialverlauf im Hintergrund, grosse Serif-
   Ueberschrift, darunter ein kleiner Zier-Trenner statt einer nackten
   Linie. Bewusst dezent gehalten -- kein Konfetti, kein Bild. */

.hero {
  position: relative;
  padding: var(--s-7) var(--s-4) var(--s-5);
  text-align: center;
  overflow: hidden;
  background: radial-gradient(ellipse 80% 100% at 50% -10%, var(--accent-soft) 0%, transparent 65%);
}
.hero::before {
  /* Sehr feines Punktraster als Textur -- kaum sichtbar, bricht nur
     die Flaeche etwas auf. */
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(currentColor 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--gold);
  opacity: 0.05;
  pointer-events: none;
}
.hero__eyebrow {
  position: relative;
  margin: 0 0 var(--s-2);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
.hero__title {
  position: relative;
  margin: 0 auto;
  max-width: 32rem;
  font-size: 2.1rem;
  line-height: 1.2;
}
.hero__sub {
  position: relative;
  max-width: 34rem;
  margin: var(--s-2) auto 0;
  color: var(--fg);
}

/* Zier-Trenner: kleine Raute/Ornament zwischen zwei feinen Linien.
   Wiederverwendbar zwischen Abschnitten (Hero -> Inhalt, Galerie -> Gaestebuch). */
.divider {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  margin: var(--s-5) 0;
  color: var(--gold);
  line-height: 1;
}
.divider::before,
.divider::after {
  content: "";
  flex: 1 1 auto;
  max-width: 5rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-line));
}
.divider::after { background: linear-gradient(90deg, var(--gold-line), transparent); }
.divider__mark { font-size: 1.05rem; }

.hero .divider { margin: var(--s-4) 0 0; }

/* Abschnittstitel mit kleinem Ornament davor statt nackter <h2> --
   fuer Gast-Seiten, wo ein Abschnittswechsel (z.B. zum Gaestebuch)
   etwas Feierliches verdient. */
.section-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}
.section-title::before {
  content: "\2766";
  color: var(--gold);
  font-size: 1rem;
}

/* ---------- Seitenkopf (Admin-Topbar) ---------- */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
  /* Platz oben rechts fuer den fixierten Hell/Dunkel-Umschalter freihalten,
     damit er den Abmelden-Button nicht ueberdeckt. */
  padding-right: calc(2.5rem + var(--s-2));
}
.page-header .sub { margin-bottom: 0; }
.page-header form { margin: 0; }

/* ---------- Buttons ---------- */

.btn, button {
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  height: var(--control-h);
  padding: 0 var(--s-4);
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: linear-gradient(180deg, var(--accent-light) 0%, var(--accent) 100%);
  color: var(--fg-on-fill);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  white-space: nowrap;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease, box-shadow .15s ease, transform .15s ease;
}
.btn:hover, button:hover {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-accent);
}
.btn:active, button:active { transform: translateY(1px); }
.btn:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; transform: none; }

.btn.ghost, button.ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--line-strong);
}
.btn.ghost:hover, button.ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: none;
}

.btn.danger, button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--fg-on-fill);
}
.btn.danger:hover, button.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); box-shadow: none; }

.btn.ghost.danger, button.ghost.danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn.ghost.danger:hover, button.ghost.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Solider Karten-Look: Hintergrund wie eine Karte (weiss bzw. dunkel je Theme),
   nicht transparent. Fuer den Diashow-Button in der Galerie. */
.btn.btn--card, button.btn--card {
  background: var(--card);
  color: var(--fg);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.btn.btn--card:hover, button.btn--card:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Voll ueber die Breite der Box — z.B. der Haupt-Button "Fotos hinzufuegen". */
.btn--block { display: flex; width: 100%; }

.btn-sm, button.btn-sm {
  height: var(--control-h-sm);
  padding: 0 var(--s-3);
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Button-Gruppen: egal ob <a>, <button> oder <form><button></form> —
   alles landet in einer Reihe, gleich hoch, sauber ausgerichtet. */
.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-3);
}
.actions form { display: flex; margin: 0; }
.mb-5 { margin-bottom: var(--s-5); }

/* Variante, bei der die Buttons die verfügbare Breite gleichmäßig
   ausfüllen sollen (z.B. Verstecken/Löschen im Asset-Grid). */
.actions--fill form,
.actions--fill > .btn,
.actions--fill > button {
  flex: 1 1 0;
}
.actions--fill form .btn,
.actions--fill form button {
  width: 100%;
}

/* Foto-Challenge-Chips: eigener Umbruch, da der Prompt-Text
   mehrzeilig sein darf (im Gegensatz zu normalen Buttons). */
.chip-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.challenge-chip {
  height: auto;
  min-height: var(--control-h);
  white-space: normal;
  text-align: center;
  padding: var(--s-2) var(--s-4);
}

/* ---------- Formulare ---------- */

.field { margin-bottom: var(--s-4); }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  margin: 0 0 var(--s-1);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
  font: inherit;
  width: 100%;
  min-height: var(--control-h);
  padding: 0 var(--s-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--fg);
}
textarea { min-height: 6rem; padding: var(--s-3); line-height: 1.5; resize: vertical; }

input[readonly] { background: var(--bg-soft); color: var(--muted); }

input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }

/* Input + Kopieren-Button nebeneinander, exakt gleich hoch */
.field-copy { display: flex; gap: var(--s-2); }
.field-copy input { flex: 1; min-width: 0; }

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s-4) var(--s-5);
  margin-bottom: var(--s-4);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease;
}
.card > *:last-child { margin-bottom: 0; }
.card > h2:first-child { margin-top: 0; }

/* Anklickbare Event-Karten (Admin-Uebersicht) heben sich beim Hover
   sanft an -- eine kleine, freundliche Reaktion statt eines starren Blocks. */
.card-link:hover { color: inherit; }
.card:has(> .card-link:hover) {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--gold-line);
}

.card--danger {
  border-color: var(--danger);
  background: var(--danger-soft);
}

/* Abgesetzte Aktionsreihe am Boden einer Card */
.card-foot {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
}

.error { color: var(--danger); font-weight: 600; margin: 0 0 var(--s-3); }

/* QR-Code braucht in jedem Theme einen hellen Rahmen mit Ruhezone,
   damit er scanbar bleibt. */
.qr-wrap {
  display: inline-block;
  background: #fff;
  padding: var(--s-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  line-height: 0;
}
.qr-wrap img { display: block; border-radius: var(--radius-sm); }

/* ---------- Foto-/Video-Grid (Gast-Galerie) ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--s-2);
}
.grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  display: block;
  transition: transform .25s ease;
}

.gallery-item {
  position: relative;
  display: block;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.gallery-item:hover img { transform: scale(1.05); }

.play-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.play-badge__icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: rgba(20, 15, 10, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.play-badge__icon::after {
  content: "";
  border-top: 0.5rem solid transparent;
  border-bottom: 0.5rem solid transparent;
  border-left: 0.8rem solid #fff;
  margin-left: 0.15rem;
}

/* ---------- Asset-Grid (Admin) ---------- */

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--s-3);
}

/* Flex-Spalte mit margin-top:auto auf die Aktionsreihe, damit die
   Buttons unabhängig von der Länge des Statustexts am Boden bündig sitzen. */
.asset-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-2);
}

.asset-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.asset-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-thumb--pending {
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
  padding: var(--s-2);
}

.asset-status { margin: 0; font-size: 0.78rem; color: var(--muted); }

.asset-card .actions { margin-top: auto; }

/* ---------- Uppy-Einbettung ----------
   uppy.min.css bleibt unangetastet; der Uploader wird als eigene
   "Insel" mit fester heller Fläche eingerahmt, damit sein
   Standard-Theme (nur hell) in beiden Farbschemata ruhig wirkt. */

#uppy {
  margin: var(--s-4) 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #fff;
}

/* Uppy setzt dem Dashboard eine feste Breite (750px) als Inline-Style. In der
   vollbreiten Insel bleibt dadurch rechts ein leerer weisser Streifen. Wir
   ueberschreiben nur die Breite (Hoehe bleibt), damit der Uploader die Box
   fuellt. uppy.min.css selbst bleibt unangetastet. */
#uppy .uppy-Root,
#uppy .uppy-Dashboard,
#uppy .uppy-Dashboard-inner {
  width: 100% !important;
  max-width: 100% !important;
}

/* Grosses, dezentes Kamera-Icon im Hintergrund des Drop-Feldes, der Text
   mittig und lesbar darueber (mit kleiner Bueroklammer = Anhaengen). */
#uppy .uppy-Dashboard-AddFiles {
  position: relative;
}
#uppy .uppy-Dashboard-AddFiles::before {
  content: "";
  position: absolute;
  inset: 0;
  background: center / 92px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b8933f' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z'/%3E%3Ccircle cx='12' cy='13' r='4'/%3E%3C/svg%3E");
  opacity: 0.14;
  pointer-events: none;
}
#uppy .uppy-Dashboard-AddFiles-title {
  position: relative;
  z-index: 1;
  text-align: center;
}
#uppy .uppy-Dashboard-AddFiles-title::before {
  content: "📎 ";
}

/* ---------- Responsive ---------- */

@media (max-width: 600px) {
  .wrap { padding: var(--s-4) var(--s-3) var(--s-6); }
  h1 { font-size: 1.5rem; }
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .hero { padding: var(--s-6) var(--s-3) var(--s-4); }
  .hero__title { font-size: 1.7rem; }
}

/* ---------- Gästebuch ---------- */

.guestbook-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

/* Feiner Gold-Akzent am Rand, damit Gaestebuch-Eintraege sich wie kleine
   handgeschriebene Karten anfuehlen statt wie generische Listeneintraege. */
.guestbook-entry {
  border-left: 3px solid var(--gold-line);
}

.guestbook-entry__meta {
  margin: 0 0 var(--s-2);
  font-size: 0.85rem;
  color: var(--muted);
}

/* pre-wrap statt <br>: Zeilenumbrüche des Gastes bleiben erhalten, ohne
   dass wir dafuer HTML in eine Fremdeingabe einschleusen muessten. */
.guestbook-entry__body {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.guestbook-entry--hidden { opacity: 0.6; }

/* ---------- Foto-Challenges (Admin-Verwaltung) ---------- */

.challenge-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.challenge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.challenge-row form { margin: 0; }
.challenge-row span { overflow-wrap: anywhere; }

/* Erledigte Challenge-Chips (Gast hat dafuer schon ein Foto hochgeladen):
   dezent statt entfernt, denn ein zweites, besseres Foto darf jederzeit
   nachgereicht werden. */
.challenge-chip.done { opacity: 0.65; }
.challenge-chip__check {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Foto-Challenges (Gast: Checkbox-Liste) ---------- */

.section-title--sm { margin-top: 0; font-size: 1.15rem; }

/* Fortschritt "X von Y geschafft" — der Gast sieht per Cookie seinen Stand. */
.challenge-progress {
  margin: 0 0 var(--s-2);
  font-weight: 600;
  color: var(--accent);
}
.challenge-progress #challenge-done-count { font-size: 1.05em; }

/* Jede Aufgabe ist ein grosser, gut tippbarer Button (Handy: >=48px).
   Die generischen Button-Stile werden hier bewusst ueberschrieben. */
.challenge-item {
  width: 100%;
  min-height: 48px;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--s-3);
  padding: var(--s-3);
  text-align: left;
  white-space: normal;
  font-weight: 500;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
}
.challenge-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.challenge-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

/* Die Checkbox links: leer, bis fuer die Aufgabe ein Foto hochgeladen wurde. */
.challenge-check {
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg);
  position: relative;
}
.challenge-item.is-done .challenge-check {
  background: var(--accent);
  border-color: var(--accent);
}
.challenge-item.is-done .challenge-check::after {
  content: "";
  position: absolute;
  left: 0.42rem;
  top: 0.14rem;
  width: 0.32rem;
  height: 0.62rem;
  border: solid var(--fg-on-fill);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.challenge-text { flex: 1; line-height: 1.3; }
.challenge-item.is-done .challenge-text { color: var(--muted); }

/* Datei-Inputs unsichtbar, aber im Layout praesent (nicht display:none) —
   sonst blockieren manche Android-Browser den per JS ausgeloesten Dialog. */
.file-offscreen {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  left: -9999px;
}

/* Knoepfe pro Aufgabe: Kamera direkt oeffnen bzw. Datei auswaehlen (mit Tag). */
.challenge-cam,
.challenge-upload {
  flex: 0 0 auto;
  width: 2.3rem;
  height: 2.3rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.challenge-cam:hover,
.challenge-upload:hover { background: var(--accent); color: var(--fg-on-fill); }
.challenge-cam .ic,
.challenge-upload .ic { width: 1.2rem; height: 1.2rem; }
.challenge-item.is-done .challenge-cam,
.challenge-item.is-done .challenge-upload { background: transparent; color: var(--muted); }

/* Kurze Status-/Erfolgsmeldung: fixiert unten mittig, verschiebt das Layout
   nicht und erzwingt kein Scrollen. Folgt dem Farbthema. */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-5);
  transform: translateX(-50%);
  z-index: 300;
  max-width: 92vw;
  padding: var(--s-3) var(--s-4);
  border-radius: 999px;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
}
.toast[hidden] { display: none; }

/* Kategorie/Trenner in der Gaeste-Liste (keine Checkbox, nur Ueberschrift). */
.challenge-category {
  list-style: none;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent);
  margin: var(--s-4) 0 var(--s-1);
  padding-bottom: var(--s-1);
  border-bottom: 1px solid var(--gold-line);
}
.challenge-list > .challenge-category:first-child { margin-top: 0; }

/* Admin: Drag-and-Drop-Sortierung. */
.challenge-row__text { flex: 1; overflow-wrap: anywhere; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 1.1rem; user-select: none; flex: 0 0 auto; }
.challenge-row.dragging { opacity: 0.45; }
.challenge-row--cat { background: var(--accent-soft); border-radius: var(--radius-sm); padding: var(--s-2) var(--s-3); }
.challenge-row--cat .challenge-row__text { font-weight: 700; }
.cat-tag {
  display: inline-block; font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  color: var(--accent); background: var(--card); border: 1px solid var(--gold-line);
  border-radius: 999px; padding: 1px 6px; margin-right: 4px;
}

/* ---------- Galerie-Gruppen nach Name ---------- */

.gallery-group {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  margin: var(--s-5) 0 var(--s-3);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--gold-line);
  color: var(--fg);
}
/* 'Allgemein' soll exakt wie die Challenge-Ueberschriften aussehen
   (gleiche Schrift, kein Kursiv, keine gedaempfte Farbe). */
.gallery-group--muted { color: var(--fg); font-style: normal; }

/* Zelle um Kachel + eigene Badges/Loeschknopf (Loeschform darf nicht im <a> liegen). */
.gallery-cell { position: relative; }

/* Loeschsymbol NUR an eigenen Kacheln, oben rechts, rot, transparenter
   Hintergrund. Dezenter Schatten, damit das Rot auf hellen wie dunklen
   Fotos sichtbar bleibt. */
.tile-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: none;
  background: transparent;
  color: #e53935;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}
.tile-delete svg { width: 20px; height: 20px; display: block; }
.tile-delete:hover { color: #ff4136; }

/* Kennzeichnet die eigenen Uploads des Gastes (nur an diesen gibt es Loeschen). */
.mine-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--accent);
  color: var(--fg-on-fill);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  pointer-events: none;
}

/* CTA-Reihe ueber der Galerie (Hochladen + Diashow) */
.cta-stack { display: flex; flex-direction: column; gap: var(--s-2); }

/* ---------- Galerie-Lightbox (mobiler Betrachter + Video-Player) ---------- */

.lightbox {
  /* Folgt dem Farbthema: hell = weiss mit dunklen Bedienelementen,
     dunkel = schwarz mit hellen. */
  --lb-bg: rgba(255, 255, 255, 0.97);
  --lb-fg: #22201c;
  --lb-ctl: rgba(0, 0, 0, 0.07);
  --lb-ctl-hover: rgba(0, 0, 0, 0.15);
  --lb-ctl-border: rgba(0, 0, 0, 0.22);
  --lb-danger: #c0392b;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--lb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
:root[data-theme="dark"] .lightbox {
  --lb-bg: rgba(0, 0, 0, 0.94);
  --lb-fg: #ffffff;
  --lb-ctl: rgba(255, 255, 255, 0.16);
  --lb-ctl-hover: rgba(255, 255, 255, 0.3);
  --lb-ctl-border: rgba(255, 255, 255, 0.4);
  --lb-danger: #f0b6ae;
}
.lightbox[hidden] { display: none; }

.lb-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
}
.lb-stage img,
.lb-stage video {
  max-width: 96vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: var(--radius);
  background: var(--lb-ctl);
}

.lb-btn {
  position: fixed;
  z-index: 210;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--lb-ctl);
  color: var(--lb-fg);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-btn:hover { background: var(--lb-ctl-hover); }
.lb-close { top: var(--s-3); right: var(--s-3); }
.lb-prev { left: var(--s-2); top: 50%; transform: translateY(-50%); }
.lb-next { right: var(--s-2); top: 50%; transform: translateY(-50%); }

/* Zwei Reihen: Aktionen oben, Zaehler darunter (kein schlechter Umbruch). */
.lb-bar {
  position: fixed;
  bottom: var(--s-4);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  max-width: 96vw;
}
.lb-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
}

/* Play und Download: runde Icon-Knoepfe OHNE Text (Text bricht schlecht um). */
.lb-play, .lb-download {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--lb-ctl-border);
  background: var(--lb-ctl);
  color: var(--lb-fg);
  font-size: 1.15rem;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lb-play:hover, .lb-download:hover { background: var(--lb-ctl-hover); }

/* Admin-Aktionen mit Text (Verstecken/Loeschen) als Pillen. */
.lb-hide, .lb-delete {
  height: auto;
  padding: var(--s-2) var(--s-4);
  border-radius: 999px;
  border: 1px solid var(--lb-ctl-border);
  background: var(--lb-ctl);
  color: var(--lb-fg);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.lb-hide:hover { background: var(--lb-ctl-hover); }
.lb-delete { border-color: var(--lb-danger); color: var(--lb-danger); }
.lb-delete:hover { background: rgba(192, 57, 43, 0.14); }
.lb-count { color: var(--lb-fg); opacity: 0.72; font-size: 0.9rem; }

/* Solange die Lightbox offen ist, stoert der Theme-Umschalter oben rechts. */
body.lb-open .theme-toggle { display: none; }

/* ---------- Inline-Icons ---------- */
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: 0 0 auto; }
.btn .ic, button .ic { width: 1.1em; height: 1.1em; margin-right: 0.15em; }

/* ---------- Bottom-Navigation (Gaeste) ---------- */
.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: var(--s-1);
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -2px 12px rgba(40, 38, 30, 0.07);
}
.bn-item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.bn-item .ic { width: 22px; height: 22px; }
.bn-item.is-active { color: var(--accent); }
.bn-item:hover { color: var(--accent); }

/* Hochladen als hervorgehobener Knopf (gold gefuellt, angehoben). */
.bn-upload { color: var(--accent); }
.bn-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.7rem;
  height: 2.7rem;
  margin-top: -1.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--fg-on-fill);
  box-shadow: var(--shadow-accent);
  border: 3px solid var(--card);
}
.bn-fab .ic { width: 24px; height: 24px; margin: 0; }

/* Platz schaffen, damit die feste Leiste nichts verdeckt. */
body:has(.bottomnav) { padding-bottom: 4.8rem; }

/* ---------- Startseite (Hub) ---------- */
.hero--sub { padding-top: 0; }
.hero--sub .hero__title { font-size: 1.5rem; }

.start-intro { margin-bottom: var(--s-5); }
.start-intro__title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin: 0 0 var(--s-3);
  color: var(--fg);
}
/* pre-wrap: Absatz-Umbrueche des Admins bleiben erhalten, ohne HTML einzuschleusen. */
.start-intro__body { white-space: pre-wrap; overflow-wrap: break-word; color: var(--fg); }

/* Vier schoene Buttons im 2x2-Raster: Rahmen, sanfter Verlauf, Tiefe. */
.start-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}
.start-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  min-height: 9.5rem;
  padding: var(--s-4);
  text-align: center;
  text-decoration: none;
  color: var(--fg);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--card) 0%, var(--bg-soft) 100%);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.start-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  color: var(--fg);
}
.start-btn:active { transform: translateY(0); }
.start-btn__icon {
  width: 3.2rem;
  height: 3.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--gold-line);
}
.start-btn__icon .ic { width: 1.7rem; height: 1.7rem; }
.start-btn__title { font-family: var(--font-serif); font-size: 1.05rem; font-weight: 600; line-height: 1.2; }

@media (prefers-color-scheme: dark) {
  .start-btn { box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.06); }
}
:root[data-theme="dark"] .start-btn { box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.06); }

/* Zurueck-Button oben auf den Unterseiten: fest positioniert (oben links,
   analog zum Theme-Umschalter oben rechts), damit er beim Scrollen immer
   sichtbar bleibt. */
.back-to-start {
  position: fixed;
  top: var(--s-3);
  left: var(--s-3);
  z-index: 100;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.75rem 0.4rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--fg);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.back-to-start:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.back-to-start .ic { width: 1.05rem; height: 1.05rem; }
/* Solange die Lightbox offen ist, stoert der Button (wie der Theme-Umschalter). */
body.lb-open .back-to-start { display: none; }

.upload-hint { margin-top: var(--s-4); text-align: center; font-size: 0.85rem; }

.check-row { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-3); font-weight: 500; cursor: pointer; }
.check-row input[type="checkbox"] { width: 1.15rem; height: 1.15rem; flex: 0 0 auto; accent-color: var(--accent); }
input[type="file"] { font: inherit; color: var(--muted); max-width: 100%; }

/* Optionales Vollbild-Hintergrundbild (hinter allem, mit Lesbarkeits-Schleier). */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(250, 249, 246, 0.45);
}
body:has(.page-bg) { background: transparent; }
:root[data-theme="dark"] .page-bg::after { background: rgba(18, 18, 20, 0.6); }
:root[data-theme="light"] .page-bg::after { background: rgba(250, 249, 246, 0.45); }

.qr-wrap--lg { display: inline-block; padding: var(--s-3); }
.qr-wrap--lg img { border-radius: var(--radius); display: block; }
