:root {
  --bg: #faf9f6;
  --fg: #2b2a27;
  --muted: #7a766d;
  --card-bg: #ffffff;
  --border: #e6e2da;
  --accent: #4a6b5c;
  --accent-fg: #ffffff;
  --danger: #a8503f;
  --danger-fg: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b18;
    --fg: #eeece6;
    --muted: #9b968b;
    --card-bg: #26241f;
    --border: #3a3730;
    --accent: #7fa88f;
    --accent-fg: #14231b;
    --danger: #c97e6d;
    --danger-fg: #2a1310;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.24);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

p { margin: 0.5rem 0; }

.subtitle { color: var(--muted); margin-top: 0; }

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

.page {
  min-height: 100vh;
  padding: 2rem 1rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.page-home:not(.page-dashboard), .page-admin-login, .page-notfound {
  justify-content: center;
}

.card {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  position: relative;
}

.card.centered { text-align: center; }

.lang-switch {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  display: flex;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.lang-switch a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
}

.lang-switch a.active {
  color: var(--fg);
  font-weight: 600;
  background: var(--bg);
}

form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }

label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; color: var(--muted); }

input[type="text"],
input[type="password"],
input[type="file"] {
  font: inherit;
  font-size: 1rem;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  min-height: 44px;
}

input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.65rem 1.25rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  color: var(--fg);
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-link { background: transparent; border-color: transparent; color: var(--muted); font-weight: 400; text-decoration: underline; }

.error {
  color: var(--danger-fg);
  background: color-mix(in srgb, var(--danger) 15%, var(--card-bg));
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
}

.notice {
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 15%, var(--card-bg));
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
}

/* Footer */

.site-footer {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.8rem;
}

.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* Imprint */

.page-imprint .card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.25rem;
}

/* Account */

.page-home.page-dashboard .card { max-width: 520px; }

.account-sessions {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.account-sessions li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.account-session-title { font-weight: 600; }

.account-session-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.account-session-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.account-session-actions .btn {
  min-height: 36px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

/* Gallery */

body:has(.page-gallery) { background: #101114; }

.page-gallery {
  --bg: #101114;
  --fg: #f2f0ea;
  --muted: #98958d;
  --card-bg: #1b1c21;
  --border: #2c2e34;
  --accent: #9fd8c0;
  --accent-fg: #0b1c15;
  --danger: #e2897a;
  --danger-fg: #2a0f0a;
  align-items: stretch;
  max-width: 960px;
  margin: 0 auto;
  padding-top: 1.5rem;
  background: var(--bg);
}

.gallery-header { position: relative; padding-right: 4rem; margin-bottom: 1rem; }

.gallery-footer { text-align: center; margin-top: 1.5rem; }

.expiry { color: var(--muted); font-size: 0.9rem; }

.upload-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.upload-btn { align-self: flex-start; }

.hide-others-toggle {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  cursor: pointer;
}

.hide-others-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.gallery-table {
  position: relative;
  border-radius: 20px;
  padding: 0.75rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.gallery-table::before {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -25%;
  height: 55%;
  background: radial-gradient(ellipse at center, color-mix(in srgb, var(--accent) 30%, transparent), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

.upload-progress {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.upload-item .bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}

.upload-item .bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.15s ease;
}

.upload-item.error { color: var(--danger); }
.upload-item.done .bar { display: none; }

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

.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

@media (min-width: 600px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 6px; } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(5, 1fr); gap: 6px; } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(6, 1fr); gap: 8px; } }

.presenting .gallery-table { padding: 1.5rem; }
.presenting .grid { gap: 10px; }
@media (min-width: 1200px) { .presenting .grid { grid-template-columns: repeat(7, 1fr); gap: 12px; } }

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 6px;
  background: var(--border);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

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

.thumb .thumb-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Admin */

.page-admin .card, .page-admin-login .card { max-width: 460px; }
.page-admin form { margin-top: 0.75rem; }

.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.qr-wrap {
  margin: 1.25rem auto 0.75rem;
  max-width: 170px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem;
}

.qr-wrap svg { width: 100%; height: auto; display: block; }

.link-row { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; }

.link-row input {
  flex: 1;
  font-size: 0.7rem;
  color: var(--muted);
  min-height: 36px;
  padding: 0.5rem 0.65rem;
}

.link-row .btn {
  min-height: 36px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.stats { color: var(--muted); font-size: 0.9rem; margin: 1rem 0; }

/* Lightbox */

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 9, 8, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  touch-action: pan-y;
}

.lightbox[hidden] { display: none; }

.lightbox-img {
  max-width: 92vw;
  max-height: 78vh;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.75rem;
  cursor: pointer;
}

.lightbox-prev { left: 1rem; }
.lightbox-next { right: 1rem; }

@media (max-width: 480px) {
  .lightbox-nav { width: 40px; height: 40px; font-size: 1.5rem; }
}

/* Drag-and-drop upload */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(16, 17, 20, 0.9);
  border: 3px dashed var(--accent);
  margin: 12px;
  border-radius: 16px;
  color: var(--fg);
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  padding: 2rem;
  pointer-events: none;
}

.page-gallery.drag-over .drop-overlay { display: flex; }

/* Presentation mode */

body.presenting .lang-switch,
body.presenting .upload-bar,
body.presenting .gallery-footer,
body.presenting .site-footer {
  display: none;
}

body.presenting .page-gallery {
  padding-top: 0.75rem;
  max-width: none;
}

body.presenting .gallery-header { margin-bottom: 0.5rem; }

body.presenting .thumb .thumb-delete { display: none; }

.presentation-qr {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 200;
  width: 116px;
  background: #fff;
  border-radius: 10px;
  padding: 0.55rem;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.presentation-qr svg { width: 100%; height: auto; display: block; }

.presentation-qr p {
  color: #555;
  font-size: 0.6rem;
  margin: 0.35rem 0 0;
}

.presentation-link strong {
  display: block;
  font-family: monospace;
  font-size: 0.6rem;
  word-break: break-all;
  margin-top: 0.1rem;
  color: #333;
}

body:not(.presenting) .presentation-qr,
.presentation-qr[hidden] {
  display: none;
}

.presentation-controls {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  gap: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.presenting .presentation-controls.show {
  opacity: 1;
  pointer-events: auto;
}

.presentation-controls .btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

body:not(.presenting) .presentation-controls { display: none; }
