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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fafafa;
  color: #333;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 4rem 1rem 2rem;
  background: #fff;
  border-bottom: 1px solid #eee;
}
header h1 {
  font-size: 2.5rem;
  font-weight: 300;
  letter-spacing: 0.1em;
}
.subtitle {
  margin-top: 0.5rem;
  color: #888;
  font-size: 1rem;
  letter-spacing: 0.05em;
}

/* Categories */
.categories {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid #eee;
  justify-content: center;
  flex-wrap: wrap;
}
.cat-btn {
  padding: 0.5rem 1.2rem;
  border: 1px solid #ddd;
  border-radius: 2rem;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
  transition: all 0.2s;
}
.cat-btn:hover { border-color: #999; }
.cat-btn.active { background: #333; color: #fff; border-color: #333; }

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  max-width: 1400px;
  margin: 0 auto;
}
.toolbar-actions { display: flex; gap: 0.5rem; }
.photo-count { color: #888; font-size: 0.9rem; }
.btn {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.btn:hover { background: #f0f0f0; }
.hidden { display: none !important; }

/* Masonry Grid */
.gallery {
  columns: 4;
  column-gap: 8px;
  padding: 0 1rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}
@media (max-width: 1200px) { .gallery { columns: 3; } }
@media (max-width: 800px) { .gallery { columns: 2; } }
@media (max-width: 500px) { .gallery { columns: 2; column-gap: 4px; } }

.gallery-item {
  break-inside: avoid;
  margin-bottom: 4px;
  position: relative;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
}
.gallery-item img {
  opacity: 0;
  transition: opacity 0.4s ease-in;
}
.gallery-item img[src] {
  /* Images that have loaded get faded in via JS event */
}
.gallery-item img.loaded {
  opacity: 1;
}
@media (min-width: 501px) {
  .gallery-item { margin-bottom: 8px; }
}
.gallery-item img {
  width: 100%;
  display: block;
  transition: transform 0.3s;
  image-orientation: from-image;
}
@media (hover: hover) {
  .gallery-item:hover img { transform: scale(1.02); }
}

/* Selection */
.gallery-item .checkbox {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0,0,0,0.4);
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  z-index: 2;
  pointer-events: none;
  transition: background-color 0.15s, border-color 0.15s;
}
.selecting .gallery-item .checkbox { display: flex; }
.gallery-item.selected .checkbox {
  background: #22c55e;
  border-color: #fff;
}
.gallery-item.selected .checkbox::after { content: '✓'; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  flex-direction: column;
}
.lb-img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  image-orientation: from-image;
}
.lb-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-size: 2rem;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
}
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
  padding: 1rem;
}
.lb-prev { left: 1rem; }
.lb-next { right: 1rem; }
.lb-footer {
  position: absolute;
  bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #fff;
}
.lb-download { background: #fff; color: #333; }
.lb-counter { font-size: 0.9rem; opacity: 0.8; }
