/**
 * Удобная сетка фото в постах форума (вместо полноэкранной карусели).
 * Кликом по миниатюре открывается FoF PhotoSwipe.
 */

.Post-body .swiper {
  --libro-gallery-gap: 8px;
  --libro-gallery-radius: 10px;
  margin: 0.85em 0 0.35em;
  padding: 0;
  overflow: visible !important;
  height: auto !important;
  background: transparent;
}

.Post-body .swiper-wrapper {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: var(--libro-gallery-gap);
  transform: none !important;
  width: 100% !important;
  height: auto !important;
  box-sizing: border-box;
}

.Post-body .swiper-slide {
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  flex-shrink: 1 !important;
}

.Post-body .swiper-slide a[data-pswp],
.Post-body .swiper-slide > img {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none !important;
  border: 0 !important;
}

.Post-body .swiper-slide img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  border-radius: var(--libro-gallery-radius);
  background: #e8eef4;
  box-shadow: 0 1px 2px rgba(20, 40, 70, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  cursor: zoom-in;
}

.Post-body .swiper-slide a[data-pswp]:hover img,
.Post-body .swiper-slide a[data-pswp]:focus-visible img {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(20, 40, 70, 0.16);
}

/* Стрелки и счётчик карусели не нужны в режиме сетки */
.Post-body .swiper-button-next,
.Post-body .swiper-button-prev,
.Post-body .swiper-pagination {
  display: none !important;
}

/* Одиночные фото вне галереи — не растягивать на всю ширину */
.Post-body > p > a[data-pswp]:only-child > img,
.Post-body > p > img:only-child {
  display: block;
  max-width: min(100%, 520px);
  width: auto;
  height: auto;
  max-height: 420px;
  object-fit: contain;
  border-radius: var(--libro-gallery-radius, 10px);
  background: #e8eef4;
}

@media (max-width: 560px) {
  .Post-body .swiper-wrapper {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .Post-body .swiper-slide img {
    aspect-ratio: 1 / 1;
  }
}
