:root {
  --bg: #f3f7f7;
  --surface: #ffffff;
  --text: #132022;
  --muted: #56686a;
  --line: #dbe5e6;
  --accent: #0a7781;          /* Türkis */
  --accent-hover: #075e66;
  --accent-soft: #e3f4f5;
  --on-accent: #ffffff;       /* Text auf Akzentflächen */
  --danger: #b91c1c;
  --ok-bg: #e7f7ef; --ok-fg: #14532d;
  --err-bg: #fef2f2; --err-fg: #991b1b;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(10 40 45 / .05), 0 4px 16px rgb(10 40 45 / .06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1516; --surface: #162022; --text: #e9f1f1; --muted: #9db0b2;
    --line: #253234; --accent: #2cc5cf; --accent-hover: #5fd6dd; --accent-soft: #10292c;
    --on-accent: #062326;
    --ok-bg: #0f2a1a; --ok-fg: #86efac; --err-bg: #2c1212; --err-fg: #fca5a5;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text); font: 16px/1.55 var(--font);
}
a { color: var(--accent); }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.15; margin: 0 0 .4rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
code { font-size: .88em; background: var(--line); padding: .1em .35em; border-radius: 5px; }
.wrap { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 28px; padding-bottom: 56px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; white-space: nowrap; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.empty { color: var(--muted); padding: 32px 0; }
.desc { white-space: pre-line; max-width: 70ch; }

/* --------------------------------------------------------------- Kopf/Fuß */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; color: var(--accent); }
.topnav { display: flex; align-items: center; gap: 14px; }
.topnav a { color: var(--text); text-decoration: none; font-size: .95rem; }
.topnav a:hover { color: var(--accent); }
.topnav form { margin: 0; }
.footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; padding-top: 18px; padding-bottom: 18px; flex-wrap: wrap; }
.footer-links, .footer-donate { display: flex; gap: 16px; flex-wrap: wrap; align-items: baseline; }
.footer-donate { gap: 12px; }
.footer-donate a { font-weight: 600; }
.footer a { color: var(--muted); }
.footer .footer-donate a { color: var(--accent); }
@media (max-width: 640px) { .footer-inner { flex-direction: column; gap: 10px; } }

/* Impressum / Datenschutz */
.legal { max-width: 820px; }
.legal h2 { margin: 1.6em 0 .4em; font-size: 1.05rem; }
.legal p, .legal ul { margin: 0 0 .9em; max-width: 72ch; overflow-wrap: anywhere; }
.legal ul { padding-left: 1.2em; }

/* ----------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: .65rem 1.1rem; border-radius: 10px; border: 1px solid transparent;
  font: 600 .95rem/1.2 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-sm { padding: .45rem .8rem; font-size: .88rem; }
.btn-accent { background: var(--accent); color: var(--on-accent); }
.btn-accent:hover { background: var(--accent-hover); }
.btn-accent:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px;
}

/* ------------------------------------------------------------ Formulare */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 24px; }
.narrow { max-width: 440px; margin: 40px auto; }
.stack { display: flex; flex-direction: column; gap: 10px; }
label { font-weight: 600; font-size: .92rem; }
input:not([type=checkbox]), textarea {
  width: 100%; padding: .7rem .8rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit;
}
textarea { resize: vertical; }
input:disabled { opacity: .6; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.form-grid h2 { margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.span-2 { grid-column: 1 / -1; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form input { max-width: 320px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.flash { padding: .75rem 1rem; border-radius: 10px; font-size: .95rem; }
.flash-success { background: var(--ok-bg); color: var(--ok-fg); }
.flash-error { background: var(--err-bg); color: var(--err-fg); }
.error-code { font-size: 3rem; font-weight: 800; color: var(--accent); margin: 0; }

/* -------------------------------------------------------------- Startseite */
.hero { display: flex; align-items: center; gap: 32px; max-width: 900px; margin-bottom: 36px; }
.hero-photo {
  flex: 0 0 auto; width: 168px; height: 168px; border-radius: 50%; object-fit: cover;
  margin: 6px; /* Platz für den Ring, damit er bündig mit dem Inhalt abschließt */
  box-shadow: 0 0 0 4px var(--surface), 0 0 0 6px var(--accent), 0 8px 24px rgb(0 0 0 / .12);
}
.hero-text { min-width: 0; }
@media (max-width: 640px) {
  /* Kompakter Profil-Kopf: kleines Foto neben der Überschrift, Text darunter */
  .hero {
    display: grid; grid-template-columns: auto 1fr; align-items: center;
    column-gap: 16px; row-gap: 14px; margin-bottom: 28px;
  }
  .hero-text { display: contents; }
  .hero-photo { width: 64px; height: 64px; margin: 4px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }
  .hero h1 { font-size: 1.45rem; margin: 0; }
  .hero .lead { grid-column: 1 / -1; font-size: 1rem; }
}
.lead { font-size: 1.1rem; color: var(--muted); margin: 0; }
/* Spenden-Banner in der Galerie */
.donate-banner {
  display: flex; align-items: center; gap: 16px; margin: 0 0 22px;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius); padding: 14px 18px;
}
.donate-icon { flex: 0 0 28px; width: 28px; height: 28px; color: var(--accent); }
.donate-body { flex: 1; min-width: 0; }
.donate-body p { margin: 2px 0 0; color: var(--muted); font-size: .94rem; max-width: 75ch; }
.donate-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .donate-banner { flex-wrap: wrap; }
  .donate-actions { width: 100%; padding-left: 44px; }
}
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 14px; }

.tiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.tile {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow); position: relative;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 10px 28px rgb(10 40 45 / .12); }
.tile-media {
  position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent) 18%, var(--accent-soft)));
}
.tile-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .35s; }
.tile:hover .tile-media img { transform: scale(1.04); }
.tile-placeholder { width: 44px; height: 44px; color: color-mix(in srgb, var(--accent) 55%, transparent); }
.tile-lock {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: rgb(0 0 0 / .45); color: #fff;
  backdrop-filter: blur(4px);
}
.tile-lock svg { width: 15px; height: 15px; }
.tile-row { display: flex; align-items: stretch; gap: 14px; padding: 14px 16px 16px; flex: 1; }
.tile-date {
  flex: 0 0 64px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--accent); color: var(--on-accent); border-radius: 10px; padding: 7px 4px; text-align: center;
}
.tile-day { font-size: 1.45rem; font-weight: 800; line-height: 1; }
.tile-month { font-size: .7rem; font-weight: 600; margin-top: 4px; opacity: .9; white-space: nowrap; }
.tile-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-name { font-weight: 700; font-size: 1.05rem; line-height: 1.3; }
.tile-meta { color: var(--muted); font-size: .9rem; }
.tile-count { color: var(--muted); font-size: .82rem; margin-top: auto; padding-top: 6px; }

/* ----------------------------------------------------------- Entsperren */
.back { display: inline-block; margin-bottom: 18px; color: var(--muted); text-decoration: none; font-size: .92rem; }
.back:hover { color: var(--accent); }
.unlock { max-width: 460px; margin: 0 auto; }
.unlock-card { text-align: center; padding: 32px 28px; }
.unlock-card form { text-align: left; margin-top: 18px; }
.unlock-icon { width: 44px; height: 44px; color: var(--accent); margin-bottom: 8px; }
.unlock-card h1 { font-size: 1.6rem; }
.unlock-card.has-cover { padding-top: 0; overflow: hidden; }
.unlock-cover { display: block; width: calc(100% + 56px); max-width: none; height: auto; aspect-ratio: 16 / 9; object-fit: cover; margin: 0 -28px 20px; }
.unlock-card.has-cover .unlock-icon { width: 32px; height: 32px; }

/* Vorschaubild-Auswahl im Admin */
.cover-box { display: flex; gap: 16px; align-items: center; padding: 14px; margin-bottom: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.cover-box p { margin: 4px 0 8px; }
.cover-box form { margin: 0; }
.cover-current { width: 192px; height: 108px; object-fit: cover; border-radius: 8px; flex: 0 0 auto; }
.cover-empty { width: 192px; height: 108px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; border: 2px dashed var(--line); color: var(--muted); font-size: 1.8rem; }
@media (max-width: 640px) { .cover-box { flex-direction: column; align-items: flex-start; } .cover-current, .cover-empty { width: 100%; height: auto; aspect-ratio: 16 / 9; } }
.cover-btn {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; font-size: 16px; line-height: 1;
  background: rgb(0 0 0 / .45); color: rgb(255 255 255 / .85); transition: background .15s, color .15s;
}
.cover-btn:hover, .cover-btn:focus-visible { background: rgb(0 0 0 / .7); color: #ffd54a; }
.photo.is-cover { outline: 3px solid var(--accent); outline-offset: 2px; }
.photo.is-cover .cover-btn { background: var(--accent); color: #ffd54a; }

/* --------------------------------------------------------------- Galerie */
.gallery-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.gallery-head p { margin: 0; }
.gallery-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.photo { position: relative; aspect-ratio: 3 / 2; overflow: hidden; border-radius: 8px; background: var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s; }
.photo-open { display: block; width: 100%; height: 100%; }
.photo:hover img { transform: scale(1.03); }
.photo-dl {
  position: absolute; right: 8px; bottom: 8px; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: rgb(0 0 0 / .55); color: #fff; opacity: 0; transition: opacity .15s;
}
.photo-dl svg { width: 18px; height: 18px; }
.photo:hover .photo-dl, .photo-dl:focus-visible { opacity: 1; }
@media (hover: none) { .photo-dl { opacity: 1; } }

.photo-pick { position: absolute; top: 8px; left: 8px; display: none; cursor: pointer; }
.photo-pick input { position: absolute; opacity: 0; width: 26px; height: 26px; margin: 0; cursor: pointer; }
.photo-pick span[aria-hidden] {
  display: block; width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff;
  background: rgb(0 0 0 / .35); box-shadow: 0 1px 4px rgb(0 0 0 / .4);
}
.photo-pick input:checked + span { background: var(--accent); border-color: var(--accent); }
.photo-pick input:checked + span::after { content: ""; display: block; width: 7px; height: 12px; margin: 3px 0 0 7px; border: solid var(--on-accent); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.photo-pick input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.selecting .photo-pick, .photo-pick.always { display: block; }
.selecting .photo-dl { display: none; }
.selecting .photo:has(input:checked) img { opacity: .75; transform: scale(.94); }

.selection-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 150%); z-index: 30;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 14px; box-shadow: 0 8px 30px rgb(0 0 0 / .18); transition: transform .2s;
  width: max-content; max-width: calc(100% - 32px);
}
.selection-bar { visibility: hidden; }
.selecting .selection-bar { transform: translate(-50%, 0); visibility: visible; }
.selecting .main { padding-bottom: 120px; }
.selection-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------------------------------------------------- Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgb(8 8 8 / .94); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lb-open { overflow: hidden; }
.lb-img { max-width: calc(100vw - 32px); max-height: calc(100vh - 120px); object-fit: contain; user-select: none; }
.lb-btn { position: absolute; background: rgb(255 255 255 / .1); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; font-size: 1.6rem; cursor: pointer; display: grid; place-items: center; }
.lb-btn:hover { background: rgb(255 255 255 / .22); }
.lb-close { top: 16px; right: 16px; font-size: 1.1rem; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-bar { position: absolute; bottom: 18px; left: 0; right: 0; display: flex; justify-content: center; align-items: center; gap: 16px; color: #ddd; font-size: .9rem; }
@media (max-width: 640px) { .lb-prev, .lb-next { top: auto; bottom: 70px; transform: none; } }

/* ----------------------------------------------------------------- Admin */
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.row-between h1, .row-between h2 { margin: 0; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
@media (max-width: 720px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  .table td { border: 0; padding: 4px 14px; text-align: left; }
}
.notice { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.folder-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.folder-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; text-align: center; margin-bottom: 20px; transition: border-color .15s, background .15s; }
.dropzone p { margin: .3rem 0; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.busy { opacity: .85; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 14px auto 0; max-width: 420px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.grid-admin { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-bottom: 14px; }
.grid-admin .photo { aspect-ratio: 1; }
.photo-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 4px; font-size: .7rem; color: #fff; background: linear-gradient(transparent, rgb(0 0 0 / .7)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
fieldset.donate-field { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.field[hidden] { display: none; }
.warn { color: var(--err-fg); font-weight: 600; }
.row-between.tight { margin-bottom: 0; }
textarea.mono { font: .9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
details summary { cursor: pointer; color: var(--muted); }
.form-grid.inner { margin-top: 14px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }

/* ---------------------------------------------------------- Mobil-Feinschliff */
.only-narrow { display: none; }
@media (max-width: 640px) {
  .only-wide { display: none; }
  .only-narrow { display: inline; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .gallery-head { margin-bottom: 16px; }
  .gallery-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .gallery-actions .btn { padding: .6rem .5rem; font-size: .88rem; white-space: normal; text-align: center; }
  .photo-dl { width: 32px; height: 32px; right: 6px; bottom: 6px; }
  .photo-pick { top: 6px; left: 6px; }
  /* Auswahl-Leiste: oben Zähler + Alle/Keine, darunter breiter Download-Button */
  .selection-bar {
    left: 12px; right: 12px; width: auto; max-width: none; bottom: 12px;
    transform: translateY(150%); display: grid; grid-template-columns: 1fr auto auto;
    align-items: center; gap: 8px; padding: 10px 12px;
  }
  .selecting .selection-bar { transform: translateY(0); }
  .selection-actions { display: contents; }
  #selection-submit { grid-column: 1 / -1; width: 100%; padding: .7rem; }
  /* Spenden-Banner kompakter */
  .donate-banner { padding: 14px 16px; gap: 10px; }
  .donate-icon { display: none; }
  .donate-actions { padding-left: 0; }
  .unlock-card { padding: 24px 18px; }
  .unlock-cover { width: calc(100% + 36px); margin: 0 -18px 18px; }
  .grid-admin { grid-template-columns: repeat(3, 1fr); }
  .tile-media.is-empty { aspect-ratio: 3 / 1; }  /* Platzhalter auf dem Handy flacher */
}
