* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #faf8f6;
  color: #2a2a2a;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid #eee;
  padding: 12px 16px;
}

.topbar h1 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  justify-content: center;
}

.tab {
  border: none;
  background: #f1efec;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  color: #555;
}

.tab.active {
  background: #2a2a2a;
  color: #fff;
}

main {
  padding: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.grid {
  columns: 2 160px;
  column-gap: 8px;
}

@media (min-width: 700px) {
  .grid { columns: 4 180px; }
}

.grid img {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 8px;
  border-radius: 6px;
  break-inside: avoid;
  cursor: pointer;
  background: #eee;
  transition: opacity .2s ease;
}

.grid img[loading="lazy"] {
  opacity: 0;
}

.grid img.loaded {
  opacity: 1;
}

.sentinel {
  height: 1px;
}

.loading-row {
  text-align: center;
  color: #999;
  padding: 16px;
  font-size: 0.85rem;
}

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

.lightbox.hidden {
  display: none;
}

.lb-img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
}

.lb-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 2rem;
  line-height: 1;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  font-size: 1.4rem;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 4px;
}

.lb-nav:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lb-prev { left: 12px; }
.lb-next { right: 12px; }

.lb-footer {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #fff;
  font-size: 0.9rem;
}

.lb-download {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 999px;
  text-decoration: none;
}

.lb-download:hover {
  background: rgba(255, 255, 255, 0.3);
}
