:root {
  --gallery-primary: #E60000;
  --gallery-secondary: #0D0D0D;
}

* { box-sizing: border-box; }

body.gallery-body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #fafafa;
  color: #1a1a1a;
}

/* Optional page background image (branding setting): a fixed full-page
   image layer plus a near-opaque white overlay for readability, both
   sitting behind the real content. Real content elements get a small
   z-index so they stack above these layers regardless of source order. */
.bg-image-layer, .bg-overlay-layer {
  position: fixed;
  inset: 0;
  /* Explicit width/height as a fallback alongside inset: 0 - some mobile
     browsers (address bar show/hide changing the viewport) don't always
     reflow a fixed element sized purely via inset, leaving a gap at the
     bottom. 100dvh (dynamic viewport height) tracks the real visible
     area on browsers that support it; 100vh is the fallback. */
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
}
.bg-image-layer {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.bg-overlay-layer {
  background: rgba(255, 255, 255, .87);
}

.gallery-header, .gallery-main, .gallery-footer, .preview-banner, .register-card {
  position: relative;
  z-index: 1;
}

.gallery-header {
  background: var(--gallery-secondary);
  padding: 22px 16px;
  text-align: center;
}
.gallery-logo { max-height: 48px; }
.gallery-logo-text { color: #fff; font-weight: 700; font-size: 1.3rem; letter-spacing: .02em; }

.gallery-main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 16px 60px;
}

.gallery-welcome {
  text-align: center;
  color: #444;
  font-size: 1rem;
  max-width: 640px;
  margin: 0 auto 24px;
  line-height: 1.5;
}

.gallery-actions { text-align: center; margin-bottom: 30px; }
.btn-download-all {
  display: inline-block;
  background: var(--gallery-primary);
  color: #fff;
  text-decoration: none;
  padding: 12px 26px;
  border-radius: 30px;
  font-weight: 600;
  font-size: .95rem;
}
.btn-download-all:hover { opacity: .9; }

.gallery-empty { text-align: center; color: #777; padding: 40px 0; }

.gallery-moment { margin-bottom: 40px; }
.gallery-moment-title {
  font-size: 1.1rem;
  border-left: 4px solid var(--gallery-primary);
  padding-left: 12px;
  margin-bottom: 16px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  align-items: start;
}

.gallery-item {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
}
.gallery-item img {
  /* No forced aspect-ratio/cropping: each photo keeps its own shape
     (a square photo shows square, portrait stays portrait, etc.) - it
     just scales to the column width. align-items:start on the grid
     above stops shorter items being stretched to match a taller
     neighbour in the same row. */
  width: 100%;
  height: auto;
  display: block;
  background: #eee;
}
.btn-download {
  display: block;
  text-align: center;
  padding: 10px;
  color: #fff;
  background: var(--gallery-secondary);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
}
.btn-download:hover { background: var(--gallery-primary); }

.gallery-footer {
  text-align: center;
  color: #999;
  font-size: .78rem;
  padding: 20px 0 40px;
}

.gallery-error {
  max-width: 480px;
  margin: 80px auto;
  text-align: center;
  padding: 0 20px;
}

@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
