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

.jffg-gallery {
    position: relative;
    z-index: 1 !important;
    width: 100%;
    max-width: 1220px;
    margin: 0 auto;
    isolation: isolate;
}

.jffg-title {
    margin: 0 0 18px;
    color: #111;
    font-size: clamp(28px, 3vw, 42px);
    line-height: 1.08;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.jffg-stage-wrap {
    position: relative;
    z-index: 1;
}

.jffg-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #ececec;
    border-radius: 18px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .12);
}

.jffg-slide {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    transform: scale(1.015);
    transition: opacity .55s ease, transform 1.2s ease;
}

.jffg-slide.is-active {
    opacity: 1;
    transform: scale(1);
    z-index: 1;
}

.jffg-slide[hidden] {
    display: block !important;
    visibility: hidden;
    pointer-events: none;
}

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

.jffg-arrow {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 56px;
    height: 56px;
    margin: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    color: transparent;
    font-size: 0;
    background: linear-gradient(180deg, rgba(18, 43, 78, .95) 0%, rgba(10, 29, 53, .95) 100%);
    border: 1px solid rgba(255, 255, 255, .48);
    border-radius: 999px;
    box-shadow: 0 16px 36px rgba(10, 26, 45, .22), inset 0 1px 0 rgba(255, 255, 255, .18), 0 0 0 5px rgba(255, 255, 255, .08);
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform .24s ease, box-shadow .24s ease, background .24s ease, opacity .24s ease;
    opacity: .96;
    animation: jffg-arrow-breathe 4.8s ease-in-out infinite;
}

.jffg-arrow::before {
    content: '';
    width: 12px;
    height: 12px;
    border-top: 3px solid #fff;
    border-right: 3px solid #fff;
    display: block;
}

.jffg-prev::before {
    transform: translateX(2px) rotate(-135deg);
}

.jffg-next::before {
    transform: translateX(-2px) rotate(45deg);
}

.jffg-arrow:hover,
.jffg-arrow:focus-visible {
    background: linear-gradient(180deg, rgba(22, 52, 92, .98) 0%, rgba(12, 36, 66, .98) 100%);
    transform: translateY(calc(-50% - 1px)) scale(1.07);
    box-shadow: 0 18px 42px rgba(10, 26, 45, .28), inset 0 1px 0 rgba(255, 255, 255, .2), 0 0 0 7px rgba(7, 149, 223, .12);
    outline: none;
    opacity: 1;
}

.jffg-arrow:active {
    transform: translateY(-50%) scale(.98);
}

.jffg-prev { left: 22px; }
.jffg-next { right: 22px; }

.jffg-thumb-strip-wrap {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.jffg-thumbs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 2px 8px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #b9b9b9 transparent;
}

.jffg-thumbs::-webkit-scrollbar { height: 6px; }
.jffg-thumbs::-webkit-scrollbar-track { background: transparent; }
.jffg-thumbs::-webkit-scrollbar-thumb { background: #b9b9b9; border-radius: 999px; }

.jffg-thumb {
    flex: 0 0 clamp(90px, 11vw, 145px);
    aspect-ratio: 4 / 3;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: #eee;
    border: 3px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    opacity: .72;
    transition: opacity .2s ease, transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.jffg-thumb:hover,
.jffg-thumb:focus-visible {
    opacity: 1;
    transform: translateY(-2px);
    outline: none;
}

.jffg-thumb.is-active {
    opacity: 1;
    border-color: #0874cf;
    box-shadow: 0 0 0 2px rgba(8, 116, 207, .13);
}

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

.jffg-thumb-scroll {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    color: transparent;
    font-size: 0;
    background: linear-gradient(180deg, #ffffff 0%, #f4f7fb 100%);
    border: 1px solid rgba(16, 43, 78, .12);
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(13, 28, 45, .08), inset 0 1px 0 rgba(255, 255, 255, .9);
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease, background .2s ease;
}

.jffg-thumb-scroll::before {
    content: '';
    width: 10px;
    height: 10px;
    border-top: 2.5px solid #102b4e;
    border-right: 2.5px solid #102b4e;
    display: block;
}

.jffg-thumb-scroll-left::before {
    transform: translateX(2px) rotate(-135deg);
}

.jffg-thumb-scroll-right::before {
    transform: translateX(-2px) rotate(45deg);
}

.jffg-thumb-scroll:hover,
.jffg-thumb-scroll:focus-visible {
    border-color: rgba(7, 149, 223, .42);
    background: linear-gradient(180deg, #ffffff 0%, #eef6fd 100%);
    box-shadow: 0 12px 22px rgba(13, 28, 45, .11), 0 0 0 5px rgba(7, 149, 223, .08);
    transform: translateY(-1px) scale(1.04);
    outline: none;
}

.jffg-thumb-scroll:active {
    transform: scale(.98);
}

.jffg-empty-frontend {
    padding: 18px 20px;
    background: #fff7e8;
    border: 1px solid #e8c783;
    border-radius: 8px;
}


@keyframes jffg-arrow-breathe {
    0%, 100% {
        box-shadow: 0 16px 36px rgba(10, 26, 45, .22), inset 0 1px 0 rgba(255, 255, 255, .18), 0 0 0 5px rgba(255, 255, 255, .08);
    }
    50% {
        box-shadow: 0 18px 40px rgba(10, 26, 45, .26), inset 0 1px 0 rgba(255, 255, 255, .18), 0 0 0 7px rgba(255, 255, 255, .05);
    }
}

/* Keep third-party chat widgets and launchers above the gallery. */
[id*="chatway"],
[class*="chatway"],
iframe[src*="chatway"],
iframe[title*="Chatway" i] {
    z-index: 2147483000 !important;
}

@media (max-width: 760px) {
    .jffg-title {
        margin-bottom: 12px;
        font-size: 30px;
    }

    .jffg-stage {
        aspect-ratio: 4 / 3;
        border-radius: 12px;
        box-shadow: 0 10px 28px rgba(0, 0, 0, .11);
    }

    .jffg-arrow {
        width: 46px;
        height: 46px;
    }

    .jffg-arrow::before {
        width: 10px;
        height: 10px;
        border-top-width: 2.5px;
        border-right-width: 2.5px;
    }

    .jffg-prev { left: 12px; }
    .jffg-next { right: 12px; }

    .jffg-thumb-strip-wrap {
        grid-template-columns: 30px minmax(0, 1fr) 30px;
        gap: 5px;
        margin-top: 10px;
    }

    .jffg-thumb-scroll {
        width: 34px;
        height: 34px;
    }

    .jffg-thumb-scroll::before {
        width: 8px;
        height: 8px;
        border-top-width: 2px;
        border-right-width: 2px;
    }

    .jffg-thumb {
        flex-basis: 82px;
        border-width: 2px;
        border-radius: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .jffg-slide,
    .jffg-thumb,
    .jffg-thumbs,
    .jffg-arrow,
    .jffg-thumb-scroll {
        transition: none !important;
        animation: none !important;
        scroll-behavior: auto !important;
    }
}
