:root {
  --bg: #faf7f2;
  --ink: #2e2a26;
  --muted: #766f66;
  --accent: #a9765b;
  --accent-dark: #8a5e46;
  --card: #ffffff;
  --border: #e7e0d6;
  --danger: #b3392f;
  --radius: 14px;

  /* Bewusst helles Design: verhindert, dass Browser im Dunkelmodus Formularfelder
     und Hintergründe automatisch umfärben. */
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

/* WICHTIG: Eigene display-Regeln (z. B. `display: flex` für die Lightbox) überschreiben
   sonst die Browser-Voreinstellung für das hidden-Attribut. Die Lightbox läge dann
   unsichtbar, aber klickblockierend und abdunkelnd über der gesamten Seite. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

header.site {
  text-align: center;
  padding: 2.5rem 1rem 1rem;
}

header.site h1 {
  font-size: 1.9rem;
  margin: 0 0 0.35rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

header.site p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

main {
  flex: 1;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
}

/* --- Login-Seite --- */

.login-card {
  max-width: 380px;
  margin: 2rem auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(60, 45, 30, 0.06);
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 1rem 0;
  text-align: center;
  letter-spacing: 0.05em;
  font-family: inherit;
}

button {
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--border);
}

.error-text {
  color: var(--danger);
  font-size: 0.9rem;
  min-height: 1.2em;
  margin-top: 0.5rem;
}

/* --- Upload-Bereich --- */

.upload-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.name-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.name-row input {
  flex: 1;
  min-width: 160px;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  /* 1rem verhindert, dass iOS beim Antippen automatisch hineinzoomt. */
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dropzone {
  /* Ein <label> ist standardmäßig inline – ohne block würden Innenabstand und
     Rahmen aus dem Textfluss ragen und das Namensfeld überlappen. */
  display: block;
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(169, 118, 91, 0.06);
}

.dropzone input[type="file"] {
  display: none;
}

.upload-list {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.upload-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  background: #f4f0e9;
}

.upload-item.error {
  background: #fbe9e7;
  color: var(--danger);
}

.upload-item.done {
  background: #eaf3ea;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-dark);
  text-decoration: underline;
  padding: 0 0 0 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
}

.link-btn:hover {
  background: none;
  color: var(--danger);
}

.link-btn:disabled {
  opacity: 0.5;
}

/* --- Galerie --- */

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.gallery-header h2 {
  font-weight: 500;
  font-size: 1.2rem;
  margin: 0;
}

button.small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

button.danger {
  background: var(--danger);
  color: #fff;
}

button.danger:hover {
  background: #963028;
}

.select-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.9rem;
  font-size: 0.9rem;
}

.select-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tile.selectable img {
  opacity: 0.75;
}

.tile.selected img {
  opacity: 1;
}

.tile.selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.tile .check {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.tile.selected .check {
  background: var(--accent);
}

.person-group {
  margin-bottom: 1.75rem;
}

.person-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-bottom: 0.35rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.person-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}

.gallery-hint {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.grid {
  display: grid;
  /* Auf dem Handy passen so drei Spalten nebeneinander statt zwei. */
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 8px;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  background: #eee;
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
}

.tile .delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  line-height: 1;
  font-size: 0.9rem;
  padding: 0;
}

.load-more {
  display: block;
  margin: 1.5rem auto 0;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

/* --- Lightbox --- */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 16, 12, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.lightbox img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 6px;
}

.lightbox .caption {
  position: absolute;
  bottom: 1rem;
  left: 0;
  right: 0;
  text-align: center;
  color: #eee;
  font-size: 0.85rem;
}

.lightbox .close-btn,
.lightbox .nav-btn {
  position: absolute;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1.2rem;
  cursor: pointer;
}

.lightbox .close-btn {
  top: 1rem;
  right: 1rem;
}

.lightbox .nav-btn.prev {
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox .nav-btn.next {
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

footer.admin-footer {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

footer.admin-footer a {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
}

.badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}
