:root {
  --accent: #c8a15a;
  --bg: #101014;
  --bg-elevated: #17171d;
  --border: #2a2a33;
  --text: #ecebe8;
  --text-muted: #9b9aa3;
  --radius: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #faf8f5;
  --bg-elevated: #ffffff;
  --border: #e2ddd5;
  --text: #1d1b18;
  --text-muted: #6d6862;
  --shadow: 0 10px 28px rgba(40, 32, 20, .12);
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Klassen wie .button setzen display und wuerden das hidden-Attribut sonst aushebeln. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: min(1240px, 100% - 2.5rem); margin-inline: auto; }

a { color: inherit; }

h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
h1 { font-size: 1.7rem; margin: 1.6rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.8rem 0 .8rem; }
h2:first-child { margin-top: 0; }
h3 { font-size: .95rem; margin: 1.4rem 0 .5rem; }

.muted { color: var(--text-muted); }
.small { font-size: .82rem; }
.center { text-align: center; }

/* Kopf und Fuss ----------------------------------------------------------- */

.site-header {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 62px;
}

.brand {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
}

.site-header nav { display: flex; gap: 1.1rem; }

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .88rem;
  padding: .3rem 0;
  border-bottom: 1px solid transparent;
}
.nav-link:hover { color: var(--text); border-bottom-color: var(--accent); }

.site-footer {
  margin-top: 4rem;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .85rem;
}

/* Galerie ----------------------------------------------------------------- */

.intro { margin: 2.4rem 0 1.4rem; }
.lead { font-size: 1.15rem; margin: 0; }
.intro-text { color: var(--text-muted); max-width: 62ch; white-space: pre-line; }
.count { margin: 0 0 1rem; }
.empty { color: var(--text-muted); margin: 4rem 0; text-align: center; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.tile {
  position: relative;
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.tile img, .tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease, opacity .2s ease;
}
.tile:hover img, .tile:hover video { transform: scale(1.04); }

.tile-badge {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 1;
  padding: .15rem .45rem;
  border-radius: 4px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: .7rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.loader { display: flex; justify-content: center; margin: 2rem 0; }

/* Einzelbild -------------------------------------------------------------- */

.single { margin: 2rem 0; text-align: center; }
.single img, .single video {
  max-width: 100%;
  max-height: 78vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.single-actions { display: flex; gap: .6rem; justify-content: center; margin: 1.4rem 0 .6rem; flex-wrap: wrap; }

/* Bausteine --------------------------------------------------------------- */

.button {
  display: inline-block;
  padding: .6rem 1.1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #14120e;
  font: inherit;
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { filter: brightness(1.08); }
.button:disabled { opacity: .5; cursor: not-allowed; }

.button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
.button.ghost:hover { border-color: var(--accent); }
.button.small { padding: .4rem .8rem; font-size: .82rem; }

.link-button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--text-muted);
  font: inherit;
  font-size: .8rem;
  text-decoration: underline;
  cursor: pointer;
}
.link-button:hover { color: #e06a6a; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  margin: 1.4rem 0;
}
.card.narrow { max-width: 420px; margin: 4rem auto; }

label { display: block; margin-bottom: 1rem; font-size: .88rem; color: var(--text-muted); }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); margin-bottom: .6rem; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .55rem .7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  font-size: .92rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type="color"] { width: 64px; height: 38px; padding: 2px; margin-top: .35rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; }
textarea { resize: vertical; }

.row { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.row label { flex: 1 1 160px; }

.alert { padding: .7rem 1rem; border-radius: 6px; font-size: .9rem; margin: 0 0 1.2rem; }
.alert.ok { background: color-mix(in srgb, #4caf7d 18%, transparent); border: 1px solid #4caf7d; }
.alert.error { background: color-mix(in srgb, #e06a6a 16%, transparent); border: 1px solid #e06a6a; }

pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .9rem 1rem;
  overflow-x: auto;
  font-size: .82rem;
}
code { font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace; }
.key code { display: inline-block; padding: .5rem .8rem; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; word-break: break-all; }

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 1.2rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* Gefahrenzone ------------------------------------------------------------ */

.card.danger { border-color: #e06a6a; }
.card.danger h2 { color: #e06a6a; }
.danger-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-end; }
.danger-row label { flex: 1 1 240px; margin-bottom: 0; }
.button.danger { background: #e06a6a; border-color: #e06a6a; color: #fff; }

/* Verwaltung -------------------------------------------------------------- */

.stats { display: flex; flex-wrap: wrap; gap: .8rem; margin: 1.4rem 0; }
.stat {
  flex: 1 1 120px;
  padding: 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.stat-value { font-size: 1.3rem; font-weight: 600; }
.stat-label { color: var(--text-muted); font-size: .8rem; }

.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
.admin-tile { margin: 0; }
.admin-tile img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }
.admin-tile figcaption { display: flex; flex-direction: column; gap: .15rem; margin-top: .4rem; }
.admin-tile .name { font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-tile form { margin: 0; }

/* Lightbox ---------------------------------------------------------------- */

.lightbox {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.lightbox::backdrop { background: rgba(8, 8, 10, .94); }

.lightbox figure {
  margin: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem 1.5rem;
}
.lb-stage { display: flex; align-items: center; justify-content: center; max-height: calc(100vh - 9rem); }
.lb-stage img, .lb-stage video { max-width: min(1200px, 94vw); max-height: calc(100vh - 9rem); border-radius: 6px; }

.lightbox figcaption { display: flex; align-items: center; gap: 1rem; color: var(--text-muted); font-size: .85rem; }

.lb-close, .lb-nav {
  position: absolute;
  background: rgba(255, 255, 255, .08);
  border: 0;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  line-height: 1;
}
.lb-close { top: 1rem; right: 1rem; width: 40px; height: 40px; font-size: 1.6rem; }
.lb-nav { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 2rem; }
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, .18); }

@media (max-width: 640px) {
  .wrap { width: min(1240px, 100% - 1.6rem); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
  h1 { font-size: 1.4rem; }
}
