.gallery-window {
  width: 75%;
  max-width: 1800px;
}

@media (max-width: 900px) {
  .gallery-window {
    width: 96%;
  }
}

.gallery-body {
  display: block;
}

.gallery-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.gallery-grid {
  column-width: 140px;
  column-count: 4;
  column-gap: 6px;
  padding: 8px;
}

@media (min-width: 1600px) {
  .gallery-grid { column-count: 6; }
}

@media (max-width: 900px) {
  .gallery-grid { column-count: 3; }
}
@media (max-width: 600px) {
  .gallery-grid { column-count: 2; }
}

.gallery-icon {
  display: block;
  break-inside: avoid;
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid transparent;
}

.gallery-icon:hover,
.gallery-icon:focus-visible {
  border-color: navy;
  outline: none;
}

.gallery-icon img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-icon img.loaded {
  opacity: 1;
}

.empty-state {
  padding: 24px;
  text-align: center;
}

#gallery-sentinel {
  height: 1px;
}


.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 128, 128, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 900;
  padding: 20px;
}

.lightbox-overlay.open {
  display: flex;
}

.lightbox-window {
  width: 700px;
  max-width: 94vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}

.lightbox-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.lightbox-frame {
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  max-height: 65vh;
  overflow: auto;
}

.lightbox-frame img {
  max-width: 100%;
  max-height: 60vh;
  display: block;
}

.lightbox-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lightbox-counter {
  flex-grow: 1;
  text-align: center;
}

@media (max-width: 600px) {
  .lightbox-window { width: 100%; }
}
