.gallery {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.gallery--empty {
  aspect-ratio: 4 / 3;
  background-color: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--card-radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery__placeholder {
  color: var(--color-text-muted);
  font-size: var(--fs-md);
}

.gallery__main {
  position: relative;
  aspect-ratio: 4 / 3;
  background-color: var(--color-bg);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--card-radius);
  overflow: hidden;
}

.gallery__main-btn {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: zoom-in;
}

.gallery__main-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.2s ease;
}

.gallery__main-btn:hover .gallery__main-img {
  transform: scale(1.02);
}

.gallery__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background-color: rgba(0, 0, 0, 0.5);
  color: #fff;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
  z-index: 2;
}

.gallery__nav:hover {
  background-color: rgba(0, 0, 0, 0.75);
}

.gallery__nav--prev { left: var(--space-sm); }
.gallery__nav--next { right: var(--space-sm); }

.gallery__counter {
  position: absolute;
  bottom: var(--space-sm);
  right: var(--space-sm);
  padding: 4px 10px;
  background-color: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.gallery__thumbs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--space-xs);
  list-style: none;
  margin: 0;
  padding: 0;
}

.gallery__thumbs-item {
  margin: 0;
  list-style: none;
}

.gallery__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background-color: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: border-color 0.15s ease;
}

.gallery__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery__thumb:hover {
  border-color: var(--color-text-muted);
}

.gallery__thumb--active {
  border-color: var(--color-primary);
}

@media (max-width: 640px) {
  .gallery__thumbs {
    grid-template-columns: repeat(4, 1fr);
  }
}

.lightbox {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.lightbox[hidden] {
  display: none;
}

.lightbox__stage {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox__img {
  max-width: 100%;
  max-height: calc(100vh - 120px);
  object-fit: contain;
  display: block;
}

.lightbox__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 44px;
  height: 44px;
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.lightbox__close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  background-color: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 32px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.lightbox__nav:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.lightbox__nav--prev { left: var(--space-md); }
.lightbox__nav--next { right: var(--space-md); }

.lightbox__caption {
  position: absolute;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--fs-sm);
  background-color: rgba(0, 0, 0, 0.4);
  padding: 6px 16px;
  border-radius: var(--radius-md);
}

@media (max-width: 640px) {
  .lightbox__nav {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
}
