:root {
  --grund: #f6f2ec;
  --flaeche: #fffdfa;
  --tinte: #2a2521;
  --leise: #857a70;
  --linie: #e4dcd1;
  --akzent: #a3835a;
  --akzent-dunkel: #86683f;
  --gewaehlt: #4f7358;
  --warnung: #a4483c;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--grund);
  color: var(--tinte);
  font: 16px/1.55 var(--sans);
}
[hidden] { display: none !important; }
img { display: block; max-width: 100%; }
a { color: var(--akzent-dunkel); }

h1, h2 { font-family: var(--serif); font-weight: 400; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); letter-spacing: 0.01em; line-height: 1.1; }
h2 { font-size: 1.6rem; }
.ueberzeile {
  font-size: 0.74rem; letter-spacing: 0.28em; text-transform: uppercase; color: var(--akzent-dunkel);
  margin: 0 0 0.6rem;
}
.leise { color: var(--leise); }
.klein { font-size: 0.875rem; }

/* ---------- Knöpfe und Felder ---------- */
button, .knopf {
  font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 44px; padding: 0.55rem 1.2rem;
  border-radius: 999px; border: 1px solid var(--tinte);
  background: var(--tinte); color: #fff; text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}
button:hover, .knopf:hover { background: #000; }
button:disabled { opacity: 0.45; cursor: default; }
button.zweit, .knopf.zweit { background: transparent; color: var(--tinte); border-color: var(--linie); }
button.zweit:hover, .knopf.zweit:hover { border-color: var(--tinte); background: transparent; }
button.gefahr { background: transparent; color: var(--warnung); border-color: transparent; padding-inline: 0.7rem; }
button.gefahr:hover { background: #f4e4e1; }
:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

input[type='password'], input[type='text'], textarea {
  font: inherit; width: 100%; padding: 0.75rem 1rem;
  border: 1px solid var(--linie); border-radius: var(--radius);
  background: var(--flaeche); color: var(--tinte);
}
textarea { resize: vertical; min-height: 6rem; }

/* ---------- Seitenkopf ---------- */
.kopf {
  text-align: center; padding: 3.2rem 1rem 2rem; position: relative;
}
.kopf p.einleitung { max-width: 36rem; margin: 1rem auto 0; color: var(--leise); }
.nav {
  position: absolute; top: 0.8rem; right: 1rem; left: 1rem;
  display: flex; justify-content: flex-end; gap: 0.3rem; flex-wrap: wrap;
}
.nav a, .nav button {
  min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.85rem; font-weight: 400;
  background: transparent; color: var(--leise); border: 0; text-decoration: none; border-radius: 999px;
}
.nav a:hover, .nav button:hover { color: var(--tinte); background: transparent; }
.zierlinie { width: 3rem; height: 1px; background: var(--akzent); margin: 1.3rem auto 0; }

main { max-width: 1500px; margin: 0 auto; padding: 0 0.75rem 5rem; }
.schmal { max-width: 860px; }

/* ---------- Anmeldung ---------- */
.anmeldung {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; text-align: center;
}
.anmeldung form { width: min(22rem, 100%); margin: 2.2rem auto 0; display: grid; gap: 0.8rem; }
.anmeldung input { text-align: center; }
.fehler { color: var(--warnung); min-height: 1.5em; margin: 0; font-size: 0.9rem; }

/* ---------- Leiste über dem Raster ---------- */
.leiste {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 0.6rem 1rem; flex-wrap: wrap;
  padding: 0.6rem 0.75rem; margin: 0 -0.75rem 0.9rem;
  background: color-mix(in srgb, var(--grund) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--linie);
}
.zaehler { font-family: var(--serif); font-size: 1.25rem; white-space: nowrap; }
.zaehler small { font-family: var(--sans); font-size: 0.8rem; color: var(--leise); margin-left: 0.4rem; }
.filter { display: flex; gap: 0.25rem; margin-right: auto; }
.filter button {
  min-height: 36px; padding: 0.25rem 0.85rem; font-size: 0.85rem; font-weight: 400;
  background: transparent; color: var(--leise); border-color: transparent;
}
.filter button[aria-pressed='true'] { color: var(--tinte); border-color: var(--tinte); }

.hinweis {
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius);
  padding: 1rem 1.2rem; margin: 0 auto 1.2rem; max-width: 46rem; text-align: center;
}
.hinweis.erfolg { border-color: var(--gewaehlt); }
.leer { text-align: center; color: var(--leise); padding: 4rem 1rem; }

/* ---------- Bildraster: Zeilen gleicher Höhe, nichts wird beschnitten ---------- */
.raster { display: flex; flex-wrap: wrap; gap: 6px; }
.raster::after { content: ''; flex-grow: 1000000; }
.kachel {
  position: relative; overflow: hidden; border-radius: 4px; background: #e9e2d8;
  flex-grow: calc(var(--verh) * 100); flex-basis: calc(var(--verh) * var(--zeile, 300px));
}
.kachel > i { display: block; padding-bottom: calc(100% / var(--verh)); }
.kachel img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; cursor: zoom-in;
  transition: opacity 0.2s, transform 0.3s;
}
.kachel:hover img { transform: scale(1.015); }
.kachel .nr {
  position: absolute; left: 6px; bottom: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 0.72rem; color: #fff; background: rgba(0, 0, 0, 0.45); pointer-events: none;
}
.kachel .notizmarke {
  position: absolute; right: 6px; bottom: 6px; padding: 1px 7px; border-radius: 999px;
  font-size: 0.72rem; color: #fff; background: rgba(0, 0, 0, 0.45); pointer-events: none;
}
.haken {
  position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; min-height: 0; padding: 0;
  border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, 0.28); color: transparent;
}
.haken:hover { background: rgba(0, 0, 0, 0.5); color: #fff; }
.haken svg { width: 22px; height: 22px; }
.kachel.gewaehlt .haken { background: var(--gewaehlt); border-color: var(--gewaehlt); color: #fff; }
.kachel.gewaehlt { outline: 3px solid var(--gewaehlt); outline-offset: -3px; }
.kachel.gewaehlt img { opacity: 0.88; }
.gesperrt .haken { pointer-events: none; }
.gesperrt .kachel:not(.gewaehlt) .haken { display: none; }
@media (max-width: 640px) {
  .raster { --zeile: 170px; gap: 4px; }
  .haken { width: 36px; height: 36px; top: 4px; right: 4px; }
  .haken svg { width: 18px; height: 18px; }
  .kopf { padding-top: 3.8rem; }
}

/* ---------- Videos ---------- */
.abschnitt { text-align: center; margin: 0.5rem 0 1rem; }
.raster.videos { --zeile: 260px; margin-bottom: 2.5rem; }
.kachel.video { display: block; min-height: 0; padding: 0; border: 0; border-radius: 4px; background: #e9e2d8; cursor: pointer; }
.kachel.video img { cursor: pointer; }
.kachel .start {
  position: absolute; inset: 0; margin: auto; width: 60px; height: 60px; border-radius: 50%;
  display: grid; place-items: center; padding-left: 4px;
  background: rgba(0, 0, 0, 0.5); color: #fff; font-size: 1.3rem; border: 2px solid #fff; pointer-events: none;
}
.kachel.video:hover .start { background: rgba(0, 0, 0, 0.75); }
.gross .buehne video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.liste input[type='text'] { padding: 0.35rem 0.6rem; font-size: 0.9rem; margin-top: 0.2rem; }

/* ---------- Großansicht ---------- */
dialog { border: 0; padding: 0; color: inherit; }
dialog::backdrop { background: rgba(20, 17, 14, 0.6); }
.gross {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0;
  background: #14110e; color: #f3eee7;
}
.gross[open] { display: grid; grid-template-rows: auto 1fr auto; }
.gross .oben { display: flex; align-items: center; justify-content: space-between; padding: 0.4rem 0.6rem; }
.gross .oben span { font-size: 0.85rem; color: #b9aea2; padding-left: 0.5rem; }
.gross .buehne { position: relative; min-height: 0; display: grid; place-items: center; overflow: hidden; }
.gross .buehne img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; position: absolute; inset: 0; margin: auto; }
.gross button.rund {
  width: 44px; height: 44px; min-height: 0; padding: 0; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 1.4rem; line-height: 1;
}
.gross button.rund:hover { background: rgba(255, 255, 255, 0.25); }
.gross .pfeil { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.gross .pfeil.links { left: 0.6rem; }
.gross .pfeil.rechts { right: 0.6rem; }
.gross .unten {
  display: flex; align-items: center; justify-content: center; gap: 0.7rem; flex-wrap: wrap;
  padding: 0.7rem 0.8rem calc(0.7rem + env(safe-area-inset-bottom));
}
.gross .unten input { max-width: 26rem; background: rgba(255, 255, 255, 0.08); border-color: transparent; color: #fff; }
.gross .unten input::placeholder { color: #a99e92; }
.gross .unten button, .gross .unten .knopf { background: #fff; color: var(--tinte); border-color: #fff; }
.gross .unten button.an { background: var(--gewaehlt); border-color: var(--gewaehlt); color: #fff; }
@media (max-width: 640px) { .gross .pfeil { display: none; } }

.fenster { width: min(34rem, calc(100vw - 2rem)); border-radius: 14px; background: var(--flaeche); padding: 1.6rem; }
.fenster h2 { margin-bottom: 0.6rem; }
.fenster .zeile { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.2rem; flex-wrap: wrap; }

/* ---------- Verwaltung ---------- */
.karte {
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px;
  padding: 1.4rem; margin-bottom: 1.2rem;
}
.karte h2 { margin-bottom: 0.3rem; }
.karte .zeile { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.status { display: inline-block; padding: 0.15rem 0.7rem; border-radius: 999px; font-size: 0.8rem; background: #efe8dd; color: var(--akzent-dunkel); }
.status.gruen { background: #e2ecdf; color: #3c5a44; }
.liste { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--linie); }
.liste li { display: flex; align-items: center; gap: 0.8rem; padding: 0.45rem 0; border-bottom: 1px solid var(--linie); }
.liste img { width: 46px; height: 46px; object-fit: cover; border-radius: 4px; flex: none; }
.liste .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.liste .name small { display: block; color: var(--leise); }
.ablage {
  margin-top: 1rem; border: 1.5px dashed var(--akzent); border-radius: var(--radius);
  padding: 1.6rem 1rem; text-align: center; color: var(--leise); cursor: pointer;
}
.ablage.aktiv { background: #f1e9dc; color: var(--tinte); }
progress { width: 100%; height: 6px; margin-top: 0.8rem; accent-color: var(--akzent); }
.feld { display: grid; gap: 0.35rem; margin-top: 1rem; }
.feld label { font-weight: 500; }
.feld label span { font-weight: 400; }
.fehler.gut { color: var(--gewaehlt); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
.unterabschnitt { font-size: 1.25rem; margin-top: 1.8rem; }
.zitat { border-left: 2px solid var(--akzent); padding-left: 0.9rem; margin: 0.8rem 0 0; white-space: pre-wrap; }

footer { text-align: center; color: var(--leise); font-size: 0.8rem; padding: 0 1rem 2.5rem; }

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