:root {
  color-scheme: dark;
  --bg: #111;
  --fg: #eee;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, sans-serif;
}

html.lightbox-open,
body.lightbox-open {
  overflow: hidden;
  height: 100%;
  touch-action: none;
}

#grid {
  column-count: 2;
  column-gap: 8px;
  padding: var(--nav-clearance, 64px) 8px 8px;
}

@media (min-width: 600px) { #grid { column-count: 3; } }
@media (min-width: 1000px) { #grid { column-count: 4; } }

#grid img {
  width: 100%;
  display: block;
  margin-bottom: 8px;
  border-radius: 6px;
  break-inside: avoid;
  background: #222;
  cursor: pointer;
}

#sentinel { height: 1px; }

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 10;
}

#lightbox.open { display: flex; }


#lightbox-caption {
  margin-top: 12px;
  color: #ccc;
  font-size: 0.9rem;
}

.lightbox-controls {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.lightbox-controls button {
  pointer-events: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.5rem;
  padding: 0 16px;
  cursor: pointer;
}

#lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 1.5rem;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
}

#lightbox-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#lightbox-strip {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  transform: translateX(-100vw);
  will-change: transform;
}

#lightbox-strip.animating {
  transition: transform 150ms ease-out;
}

.lb-slot {
  position: absolute;
  top: 0;
  height: 100%;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.lb-spinner {
  position: absolute;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lb-spin 0.75s linear infinite;
  display: none;
}

.lb-spinner.visible {
  display: block;
}

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