/* REX Gallery – Basistyle */
.rex-gallery { width: 100%; }
.rex-gallery-grid {
  display: grid;
  grid-template-columns: repeat(var(--rex-cols-desktop,4), 1fr);
  gap: var(--rex-gap,12px);
}
@media (max-width: 1024px) {
  .rex-gallery-grid { grid-template-columns: repeat(var(--rex-cols-tablet,3), 1fr); }
}
@media (max-width: 640px) {
  .rex-gallery-grid { grid-template-columns: repeat(var(--rex-cols-mobile,2), 1fr); }
}

/* Quadratische Thumbnails */
.rex-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f2f2f2;
}
.rex-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: .88;
  transform: scale(1.0);
  transition: opacity .25s ease, transform .25s ease;
}
.rex-gallery-item:hover .rex-thumb img,
.rex-gallery-item:focus .rex-thumb img {
  opacity: 1;
  transform: scale(1.02);
}

/* Lightbox */
.rex-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999999;
}
.rex-lightbox--open { display: flex !important; }
.rex-lightbox__content {
  position: relative;
  max-width: 95vw;
  max-height: 90vh;
  width: 100%;
  padding: 0;
}
.rex-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.rex-lightbox__caption {
  color: #fff;
  text-align: center;
  margin-top: 10px;
  line-height: 1.4;
}
.rex-lightbox__title {
  font-size: 18px;
  font-weight: 600;
}
.rex-lightbox__desc {
  font-size: 14px;
  opacity: .9;
  margin-top: 4px;
}
.rex-lightbox__close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
}
.rex-lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,.12);
  border: 0;
  color: #fff;
  font-size: 28px;
  width: 46px;
  height: 46px;
  cursor: pointer;
  transition: background .2s ease;
}
.rex-lightbox__nav:hover { background: rgba(255,255,255,.22); }
.rex-lightbox__prev { left: 16px; }
.rex-lightbox__next { right: 16px; }

/* Accessibility helpers */
.rex-gallery-item { outline: none; }
.rex-gallery-item:focus .rex-thumb { box-shadow: 0 0 0 3px rgba(100,150,250,.6); }
