/* Foto-Sharing: mobile first, ohne Frameworks. Farben als Variablen, Hell und Dunkel. */
:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --surface-2: #eef1f3;
  --text: #1b2227;
  --muted: #55626b;
  --border: #cfd6db;
  --accent: #0b6e6e;
  --accent-text: #ffffff;
  --accent-soft: #d9efef;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --ok: #1b6e3a;
  --ok-soft: #e3f3e8;
  --focus: #0b57d0;
  --radius: 10px;
  --row: 120px;
  --gap: 6px;
  --shadow: 0 2px 10px rgba(0, 0, 0, .12);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111518;
    --surface: #1a2025;
    --surface-2: #242c32;
    --text: #e9edf0;
    --muted: #a5b1b9;
    --border: #3a444b;
    --accent: #4fb8b8;
    --accent-text: #06201f;
    --accent-soft: #163a3a;
    --danger: #ff8f86;
    --danger-soft: #3b1d1a;
    --ok: #7bd69a;
    --ok-soft: #173424;
    --focus: #8ab4ff;
    --shadow: 0 2px 10px rgba(0, 0, 0, .5);
  }
}

@media (min-width: 720px) {
  :root { --row: 170px; --gap: 8px; }
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

body.no-scroll { overflow: hidden; }

h1, h2, h3, p { margin: 0; }

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

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

.skip-link {
  position: absolute;
  left: 8px; top: -60px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  z-index: 100;
}
.skip-link:focus { top: 8px; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }

/* ---------- Kopfbereich ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.site-title { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.lang-switch { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); }
.lang-btn {
  appearance: none;
  background: none;
  border: 0;
  min-width: 44px;
  min-height: 44px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius);
}
.lang-btn[aria-pressed="true"] { color: var(--accent); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }

/* ---------- Schaltflächen und Felder ---------- */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: none; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 600; font-size: .9rem; }
select, input[type="password"], input[type="text"], input[type="date"] {
  min-height: 44px;
  padding: 8px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
}
.field-error { color: var(--danger); font-size: .9rem; font-weight: 600; }

/* ---------- Layout ---------- */
main { padding: 12px 12px 96px; max-width: 1600px; margin: 0 auto; }

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}
.toolbar-buttons { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
@media (min-width: 720px) {
  .toolbar { grid-template-columns: minmax(180px, 260px) minmax(160px, 220px) 1fr; }
  .toolbar-buttons { grid-column: auto; justify-content: flex-end; }
}

.banner {
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
}
.banner.is-error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.banner.is-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

/* ---------- Galerie ---------- */
.group { margin: 0 0 26px; }
.group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 8px; }
.group-title { font-size: 1.15rem; font-weight: 700; }
.group-meta { color: var(--muted); font-size: .9rem; }

.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  list-style: none;
  margin: 0;
  padding: 0;
}
.tiles::after { content: ""; flex-grow: 1000000; }

.tile {
  --ar: 1.333;
  position: relative;
  flex: calc(var(--ar) * 100) 1 calc(var(--ar) * var(--row));
  max-width: 100%;
  min-width: 0;
  background: var(--surface-2);
  border-radius: 8px;
  overflow: hidden;
}
.tile img { display: block; width: 100%; height: auto; }
.tile-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  color: inherit;
  font: inherit;
}
.tile.is-selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile.is-new { box-shadow: 0 0 0 3px var(--accent); }
.tile-new-badge {
  position: absolute;
  left: 6px; bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: var(--accent);
  color: var(--accent-text);
  pointer-events: none;
}

.tile-check, .tile-dl {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
}
.tile-check { left: 0; top: 0; cursor: pointer; }
.tile-check input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tile-check .box {
  width: 24px; height: 24px;
  border-radius: 6px;
  border: 2px solid #fff;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .35);
}
.tile-check input:checked + .box { background: var(--accent); border-color: #fff; color: var(--accent-text); }
.tile-check input:focus-visible + .box { outline: 3px solid var(--focus); outline-offset: 2px; }
.tile-check .box svg { width: 16px; height: 16px; opacity: 0; }
.tile-check input:checked + .box svg { opacity: 1; }
.tile-dl { right: 0; bottom: 0; color: #fff; }
.tile-dl .box {
  width: 34px; height: 34px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .5);
}
.tile-dl svg { width: 18px; height: 18px; }

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: var(--ar, 1.333);
  padding: 8px;
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  word-break: break-all;
}
.placeholder svg { width: 32px; height: 32px; }

.empty { text-align: center; padding: 48px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-title { font-size: 1.2rem; font-weight: 700; }
.load-more { display: flex; justify-content: center; padding: 8px 0 24px; }

.selection-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.selection-count { font-weight: 700; }

.site-footer { max-width: 900px; margin: 0 auto; padding: 8px 16px 120px; display: flex; flex-direction: column; gap: 10px; color: var(--muted); font-size: .9rem; }
.info summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }

/* ---------- Dialoge ---------- */
dialog { color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }

.dialog {
  width: min(640px, 100vw);
  max-height: 100dvh;
  max-height: 100vh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.dialog[open] { display: flex; flex-direction: column; max-height: min(92dvh, 900px); }
@media (max-width: 640px) {
  .dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .dialog[open] { max-height: 100dvh; }
}
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dialog-head h2 { font-size: 1.15rem; }
.dialog-foot { border-bottom: 0; border-top: 1px solid var(--border); justify-content: flex-end; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.dialog-body { padding: 16px; overflow: auto; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.pick-row { display: flex; flex-wrap: wrap; gap: 10px; }

.upload-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.upload-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.upload-item.is-error { border-color: var(--danger); background: var(--danger-soft); }
.upload-item.is-done { border-color: var(--ok); background: var(--ok-soft); }
.upload-thumb { width: 56px; height: 56px; border-radius: 6px; background: var(--surface-2); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.upload-thumb canvas, .upload-thumb svg { width: 100%; height: 100%; object-fit: cover; }
.upload-thumb svg { width: 28px; height: 28px; }
.upload-meta { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.upload-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-state { font-size: .875rem; color: var(--muted); }
.is-error .upload-state { color: var(--danger); font-weight: 600; }
.is-done .upload-state { color: var(--ok); font-weight: 600; }

progress { width: 100%; height: 10px; accent-color: var(--accent); }
.summary { font-weight: 700; }
.summary.is-error { color: var(--danger); }
.summary.is-ok { color: var(--ok); }

/* ---------- Lightbox ---------- */
.lightbox {
  width: 100vw; height: 100dvh;
  max-width: 100vw; max-height: 100dvh;
  margin: 0; padding: 0; border: 0;
  background: #0b0e10;
  color: #f2f5f7;
}
.lightbox[open] { display: flex; flex-direction: column; }
.lb-top, .lb-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; background: #11171a; }
.lb-top { padding-top: calc(8px + env(safe-area-inset-top)); }
.lb-bar { padding-bottom: calc(8px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.lb-title { font-size: 1rem; }
.lb-top .btn, .lb-bar .btn { background: #232b30; color: #f2f5f7; border-color: #3a444b; }
.lb-bar .btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.lb-stage { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lb-figure { margin: 0; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }
.lb-figure img { max-width: 100%; max-height: calc(100% - 64px); width: auto; height: auto; object-fit: contain; }
.lb-placeholder { color: #c3ccd2; min-width: 260px; }
.lb-caption { padding: 8px 56px 0; text-align: center; font-size: .9rem; color: #d4dbe0; max-height: 64px; overflow: auto; }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 72px;
  border: 0;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 2.4rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.lb-nav:hover { background: rgba(255, 255, 255, .22); }
.lb-prev { left: 0; border-radius: 0 10px 10px 0; }
.lb-next { right: 0; border-radius: 10px 0 0 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- Zugangscode ---------- */
.gate { max-width: 420px; margin: 48px auto; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; display: flex; flex-direction: column; gap: 14px; }
.gate form { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Administration ---------- */
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 12px 12px 48px; display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.card h2 { font-size: 1.1rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.stat-value { font-size: 1.3rem; font-weight: 700; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.admin-thumb { width: 64px; height: 48px; object-fit: contain; background: var(--surface-2); border-radius: 4px; display: block; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--accent-soft); color: var(--text); }
.badge.is-bad { background: var(--danger-soft); color: var(--danger); }
.report-list { margin: 0; padding-left: 1.2rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.1); }

@media (prefers-reduced-motion: no-preference) {
  .tile { transition: outline-color .15s ease; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
