*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
  background: #fff;
  color: #1d1d1f;
}

header {
  padding: 3rem 2rem 2rem;
  text-align: center;
}

header h1 {
  font-size: 1.1rem;
  font-weight: 300;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

#filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

#filters button {
  background: #f5f5f7;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 400;
  color: #1d1d1f;
  cursor: pointer;
  padding: 0.4rem 1rem;
  border-radius: 980px;
  transition: background 0.15s, color 0.15s;
}

#filters button:hover { background: #e8e8ed; }
#filters button.active { background: #1d1d1f; color: #fff; }

#filters button .count {
  opacity: 0.45;
  margin-left: 0.3em;
  font-size: 0.75em;
}

#filters button.active .count { opacity: 0.6; }


.photo.hidden { display: none; }

#gallery {
  columns: 3;
  column-gap: 8px;
  padding: 0 8px 8px;
}

@media (max-width: 900px) { #gallery { columns: 2; } }
@media (max-width: 500px) { #gallery { columns: 1; padding: 0 8px 8px; } }

.photo {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.4s;
}

.photo.loaded { opacity: 1; }
.photo.loaded:hover { opacity: 0.8; }

#empty {
  padding: 6rem 2rem;
  text-align: center;
  color: #aaa;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.lightbox[hidden] { display: none; }

#lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.2s;
}

#lightbox-img.ready { opacity: 1; }

#spinner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

#spinner.active { opacity: 1; }

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

#close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  padding: 0.75rem;
  min-width: 44px;
  min-height: 44px;
}

#prev, #next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 3rem;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  padding: 1rem;
  min-width: 44px;
  min-height: 44px;
  opacity: 0.7;
  transition: opacity 0.15s;
  user-select: none;
}

#prev { left: 1rem; }
#next { right: 1rem; }
#prev:hover, #next:hover { opacity: 1; }



#top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1d1d1f;
  border: none;
  border-radius: 980px;
  color: #fff;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 400;
  padding: 0.4rem 1rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.15s;
  z-index: 50;
}

#top:hover { background: #3a3a3c; }
#top.visible { opacity: 1; }

@media (max-width: 500px) {
  header { padding: 2rem 1rem 1.5rem; }
  .photo { margin-bottom: 0; }
  #prev { left: 0.25rem; }
  #next { right: 0.25rem; }
  #top { bottom: 1rem; right: 1rem; }
}
