.fm-peg-gallery,
.fm-peg-gallery * {
    box-sizing: border-box;
}

.fm-peg-gallery {
    --fm-peg-gallery-ratio: 1 / 1;
}

.fm-peg-orientation-portrait { --fm-peg-gallery-ratio: 3 / 4; }
.fm-peg-orientation-landscape { --fm-peg-gallery-ratio: 4 / 3; }
.fm-peg-orientation-square { --fm-peg-gallery-ratio: 1 / 1; }

.fm-peg-desktop {
    display: grid;
    gap: 16px;
    width: 100%;
    height: auto;
}

.fm-peg-layout-editorial {
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
}

.fm-peg-layout-editorial .fm-peg-primary {
    grid-row: 1 / -1;
}

.fm-peg-layout-editorial.fm-peg-count-2 { grid-template-rows: minmax(0, 1fr); }
.fm-peg-layout-editorial.fm-peg-count-3 { grid-template-rows: repeat(2, minmax(0, 1fr)); }
.fm-peg-layout-editorial.fm-peg-count-4 { grid-template-rows: repeat(3, minmax(0, 1fr)); }
.fm-peg-layout-editorial.fm-peg-count-5 { grid-template-rows: repeat(4, minmax(0, 1fr)); }
.fm-peg-layout-editorial.fm-peg-count-6 { grid-template-rows: repeat(5, minmax(0, 1fr)); }
.fm-peg-layout-editorial.fm-peg-count-7 { grid-template-rows: repeat(6, minmax(0, 1fr)); }
.fm-peg-layout-editorial.fm-peg-count-8 { grid-template-rows: repeat(7, minmax(0, 1fr)); }

.fm-peg-layout-two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
}

.fm-peg-layout-three-columns {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
}

.fm-peg-layout-hero-three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: minmax(0, 2fr) minmax(0, 1fr);
    grid-auto-rows: minmax(0, 1fr);
}

.fm-peg-layout-hero-three .fm-peg-primary {
    grid-column: 1 / -1;
}

.fm-peg-desktop.fm-peg-count-1 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}

.fm-peg-layout-three-columns.fm-peg-count-2,
.fm-peg-layout-hero-three.fm-peg-count-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fm-peg-image {
    min-width: 0;
    min-height: 0;
    width: 100%;
    height: auto;
    aspect-ratio: var(--fm-peg-gallery-ratio);
    margin: 0;
    overflow: hidden;
    background: transparent;
}

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

.fm-peg-slider-shell {
    display: none;
    position: relative;
    width: 100%;
}

.fm-peg-mobile {
    display: block;
    width: 100%;
    height: auto;
    overflow: hidden;
}

.fm-peg-gallery.is-carousel-all .fm-peg-desktop {
    display: none;
}

.fm-peg-gallery.is-carousel-all .fm-peg-slider-shell {
    display: block;
}

.fm-peg-mobile .swiper-slide,
.fm-peg-mobile .fm-peg-image {
    height: auto;
}

.fm-peg-mobile .swiper-wrapper {
    align-items: flex-start;
}

.fm-peg-arrow {
    position: absolute;
    z-index: 5;
    top: 50%;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #111;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .14);
    cursor: pointer;
    transform: translateY(-50%);
    transition: color .2s ease, background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.fm-peg-arrow::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 9px;
    height: 9px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
}

.fm-peg-prev { left: 14px; }
.fm-peg-next { right: 14px; }
.fm-peg-prev::before { transform: translate(-35%, -50%) rotate(-135deg); }
.fm-peg-next::before { transform: translate(-65%, -50%) rotate(45deg); }

.fm-peg-pagination {
    position: absolute;
    z-index: 5;
    bottom: 16px !important;
    left: 0;
    width: 100%;
    text-align: center;
}

.fm-peg-pagination .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    background: #fff;
    opacity: .55;
}

.fm-peg-pagination .swiper-pagination-bullet-active {
    opacity: 1;
}

.fm-peg-placeholder {
    padding: 28px;
    border: 1px dashed #b7b7b7;
    background: #f7f7f7;
    color: #555;
    text-align: center;
}

@media (max-width: 767px) {
    .fm-peg-desktop { display: none; }
    .fm-peg-slider-shell { display: block; }
}
