:root {
  --bg: #fff6ee;          /* warmes Creme */
  --surface: #ffffff;
  --surface-2: #ffe9d5;   /* helles Orange */
  --border: #f2d3ba;
  --text: #2a1c12;        /* dunkles Braun-Schwarz */
  --muted: #96826f;
  --accent: #ee7621;      /* „Maus"-Orange */
  --accent-hover: #d9631a;
  --danger: #e5484d;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI Rounded", "SF Pro Rounded", "Nunito", "Quicksand",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Verspielte, runde Überschriften im Stil der Vorlage */
#app-title, #login-title {
  font-weight: 800;
  letter-spacing: .3px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); }

/* --- Login --- */
.screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
/* Login-Screen im Marken-Orange der Vorlage */
#login.screen { background: var(--accent); }
.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}
.login-card h1 { margin: 0; font-size: 1.6rem; }
#login-title::before { content: "🐭 "; }

input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}
input:focus { outline: 2px solid var(--accent); border-color: transparent; }

button, .lb-btn {
  cursor: pointer;
  font-size: 1rem;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: background .15s ease;
}
button:hover { background: var(--accent-hover); }
button.ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
  font-weight: 500;
}
button.ghost:hover { background: var(--surface-2); }
button.danger, .lb-btn.danger { background: var(--danger); }
button.danger:hover, .lb-btn.danger:hover { background: #cf3b40; }

/* --- Topbar --- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.topbar h1 { margin: 0; font-size: 1.25rem; color: #fff; }
.topbar .ghost { color: #fff; border-color: rgba(255, 255, 255, .65); }
.topbar .ghost:hover { background: rgba(255, 255, 255, .18); }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

/* --- Dropzone --- */
#dropzone {
  display: block;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
#dropzone:hover, #dropzone:focus, #dropzone.dragover {
  border-color: var(--accent);
  background: var(--surface);
  outline: none;
}
.dz-inner { display: flex; flex-direction: column; gap: 6px; }
.dz-inner .small { font-size: .8rem; opacity: .8; }

.upload-actions {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
.upload-actions button { font-size: .95rem; }

.upload-status {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .95rem;
}

.gallery-meta { margin: 24px 4px 12px; font-size: .9rem; }

/* --- Galerie --- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: zoom-in;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .2s ease;
}
.tile:hover img { transform: scale(1.05); }
.tile .tile-del {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  border: none;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .tile-del { opacity: 1; }
.tile .tile-del:hover { background: var(--danger); }
.tile .tile-dl {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-size: 1rem;
  opacity: 0;
  transition: opacity .15s;
}
.tile:hover .tile-dl { opacity: 1; }
.tile .tile-dl:hover { background: var(--accent); }
@media (hover: none) { .tile .tile-dl { opacity: 1; } }

/* --- Mehrfachauswahl --- */
.gallery.select-mode .tile-dl,
.gallery.select-mode .tile-del { display: none; }
.tile-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  border: 2px solid var(--accent);
  display: none;
  align-items: center;
  justify-content: center;
}
.gallery.select-mode .tile-check { display: flex; }
.tile-check::after { content: ""; color: #fff; font-weight: 800; line-height: 1; }
.tile.selected .tile-check { background: var(--accent); }
.tile.selected .tile-check::after { content: "✓"; }
.tile.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile.selected img { filter: brightness(.9); }

.selectbar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, .22);
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
#select-count { font-weight: 700; }
.selectbar-actions { display: flex; gap: 8px; }
.selectbar button { padding: 8px 14px; }

/* --- Galerie-Leiste (Meta + Diashow) --- */
.gallery-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 4px 12px;
}
.gallery-bar .gallery-meta { margin: 0; }

/* --- Diashow --- */
.slideshow {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, .94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}
.slideshow img, .slideshow video {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 8px;
  background: #000;
}
.ss-bar { display: flex; align-items: center; gap: 12px; }
.ss-bar .lb-btn { min-width: 46px; font-size: 1.15rem; }
#ss-counter { color: #fff; min-width: 64px; text-align: center; }

/* --- Medienschutz (Kontextmenü/Speichern erschweren) --- */
.tile img, .lightbox img, .lightbox video,
.slideshow img, .slideshow video {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.empty { text-align: center; padding: 48px; color: var(--muted); }

/* --- Lightbox --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0,0,0,.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}
.lightbox img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
}
.lb-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.lb-bar span { color: var(--text); max-width: 50vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-btn { background: var(--surface-2); border: 1px solid var(--border); text-decoration: none; }
.lb-btn:hover { background: var(--border); }
.lb-close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.6rem;
  border-radius: 50%;
}
.lightbox video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
  background: #000;
}

/* --- Video-Play-Badge auf Kacheln --- */
.play-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  padding-left: 3px;
  pointer-events: none;
}

/* --- Fußzeile --- */
#site-footer {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 20px;
  color: var(--muted);
  font-size: .85rem;
}
#site-footer a { color: var(--muted); text-decoration: none; }
#site-footer a:hover { color: var(--text); text-decoration: underline; }

/* --- Inhalts-Modal (Info/Impressum/Datenschutz) --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 620px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 38px;
  height: 38px;
  padding: 0;
  font-size: 1.4rem;
  border-radius: 50%;
}
.doc { line-height: 1.55; }
.doc h2 { margin: 0 26px 12px 0; }
.doc h3 { margin: 20px 0 6px; font-size: 1.02rem; }
.doc p, .doc ul { margin: 8px 0; }
.doc ul { padding-left: 20px; }
.doc li { margin: 6px 0; }
.doc .small { font-size: .82rem; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 20px; }

/* --- Topbar-Aktionen + Konfig-Formulare --- */
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.pw-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.pw-form h3 { margin: 0 0 4px; }
.pw-form button { align-self: flex-start; }
.form-msg { font-size: .85rem; margin: 2px 0 0; min-height: 1em; }
.form-msg.ok { color: #46b483; }
.form-msg.error { color: var(--danger); }

/* --- Download-Protokoll --- */
.doc h4 { margin: 16px 0 4px; font-size: .95rem; }
.dl-scroll { overflow-x: auto; margin: 8px 0; }
.dl-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.dl-table th, .dl-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.dl-table th { color: var(--muted); font-weight: 600; }
.dl-table td.num, .dl-table th.num { text-align: right; }
