.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.gallery-loading {
  color: var(--muted);
}

.gallery-card {
  position: relative;
  min-height: 240px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: zoom-in;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  min-height: 240px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 0.45s ease, filter 0.45s ease, opacity 0.25s ease;
}

.gallery-card:hover img,
.gallery-card.is-playing img {
  transform: scale(1.06);
  filter: saturate(1.08) contrast(1.04);
}

.gallery-card-title {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-weight: 800;
  text-align: left;
  backdrop-filter: blur(8px);
}

.gallery-hover-preview {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 45;
  width: min(720px, 58vw);
  aspect-ratio: 16 / 10;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  overflow: hidden;
  background: #05070a;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  transform: translateY(14px) scale(0.98);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.gallery-hover-preview.active {
  display: block;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.gallery-hover-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-hover-text,
.lightbox-caption {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  padding: 13px 15px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.68);
  color: #fff;
  font-size: 15px;
  line-height: 1.45;
  backdrop-filter: blur(10px);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.86);
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: min(1180px, 94vw);
  max-height: 84vh;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.lightbox-close,
.lightbox-nav {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.lightbox-close {
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  font-size: 24px;
}

.lightbox-nav {
  top: 50%;
  width: 48px;
  height: 48px;
  font-size: 36px;
  line-height: 1;
  transform: translateY(-50%);
}

.lightbox-prev { left: 18px; }
.lightbox-next { right: 18px; }

@media (max-width: 900px) {
  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .gallery-hover-preview {
    display: none !important;
  }
}

@media (max-width: 560px) {
  .gallery {
    grid-template-columns: 1fr;
  }

  .gallery-card,
  .gallery-card img {
    min-height: 260px;
  }

  .lightbox {
    padding: 14px;
  }

  .lightbox-nav {
    top: auto;
    bottom: 18px;
    transform: none;
  }

  .lightbox-caption {
    bottom: 78px;
  }
}
