: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;
}

#grid {
  column-count: 2;
  column-gap: 8px;
  padding: 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-img {
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
}

#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;
}
