/*
 * Стили FAM-галереи видео (лента Shorts, мобильный слайдер, режим просмотра).
 * Раньше жили в <style> внутри modules/video/ui/famgallery.php и отдавались
 * с каждой страницей; теперь один файл с версией статики (cms_static_version).
 * Ширина карточек по умолчанию: вертикальная 200px, горизонтальная 320px —
 * другая item_width дописывается инлайном в renderGallery().
 */

body.fam-fullview-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    background: #000 !important;  /* ← добавь это */
}

.fam-fullview-overlay .fam-fullview-video-wrap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 0;
}

.fam-fullview-overlay video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    z-index: 1;
}

.fam-fullview-video-wrap.fam-slide-out-left {
    animation: famSlideOutLeft 0.25s ease forwards;
}

.fam-fullview-video-wrap.fam-slide-out-right {
    animation: famSlideOutRight 0.25s ease forwards;
}

.fam-fullview-video-wrap.fam-slide-in-left {
    animation: famSlideInLeft 0.25s ease forwards;
}

.fam-fullview-video-wrap.fam-slide-in-right {
    animation: famSlideInRight 0.25s ease forwards;
}

@keyframes famSlideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(-100%); opacity: 0; }
}

@keyframes famSlideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

@keyframes famSlideInLeft {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

@keyframes famSlideInRight {
    from { transform: translateX(-100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

.fam-fullview-video-wrap.fam-slide-out-up {
    animation: famSlideOutUp 0.25s ease forwards;
}

.fam-fullview-video-wrap.fam-slide-out-down {
    animation: famSlideOutDown 0.25s ease forwards;
}

.fam-fullview-video-wrap.fam-slide-in-up {
    animation: famSlideInUp 0.25s ease forwards;
}

.fam-fullview-video-wrap.fam-slide-in-down {
    animation: famSlideInDown 0.25s ease forwards;
}

@keyframes famSlideOutUp {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(-100%); opacity: 0; }
}

@keyframes famSlideOutDown {
    from { transform: translateY(0); opacity: 1; }
    to   { transform: translateY(100%); opacity: 0; }
}

@keyframes famSlideInUp {
    from { transform: translateY(100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

@keyframes famSlideInDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* Увеличиваем бар при касании/hover */
.fam-fullview-progress {
    transition: height 0.15s ease;
}

.fam-fullview-progress:hover,
.fam-fullview-progress.fam-progress-active,
.fam-fullview-progress.fam-progress-active .fam-fullview-progress-played {
    height: 57px;
}

.fam-fullview-progress::before {
    transition: height 0.15s ease, bottom 0.15s ease;
}

.fam-fullview-progress-played {
    transition: height 0.15s ease;
}

/* Ползунок-кружок на конце */
.fam-fullview-progress-played::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s ease;
}

.fam-fullview-progress:hover .fam-fullview-progress-played::after,
.fam-fullview-progress.fam-progress-active .fam-fullview-progress-played::after {
    transform: translateY(-50%) scale(1);
}

.fam-fullview-mute {
    position: fixed;
    top: calc(env(safe-area-inset-top, 16px) + 8px);
    left: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99999;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.fam-fullview-mute svg {
    fill: #fff;
    width: 22px;
    height: 22px;
}

.mobile-video-player,
.mobile-video-player-horizontal {
    transition: opacity 700ms ease;
}

.fam-video-dimmed {
    opacity: 0.5 !important;
}

.mobile-video-preload {
    position: absolute;
    left: 0px;
    right: 0px;
    bottom: 0px;
    height: 4px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    overflow: hidden;
    z-index: 12;
    pointer-events: none;
}

.mobile-video-preload-buffer {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: rgba(255,255,255,0.55);
    transition: width .15s linear;
}

.mobile-video-preload-played {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: var(--background_gradient);
    transition: width .1s linear;
}

.mobile-video-loading {
    position: absolute;
    z-index: 12;
    top: 12px;
    left: 12px;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    color: #fff;
    background: rgba(0,0,0,.45);
    z-index: 13;
}

/* Стили для заблокированных кнопок (уже есть) */
.fam-gallery-control-vertical:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.fam-gallery-mobile-horizontal .mobile-video-player-horizontal {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block;
}

.fancybox-nav {
    width:25% !important;
}

.fancybox-wrap.fancybox-video .fancybox-skin {
    background: transparent !important;
}

.fancybox-wrap.fancybox-video .fancybox-inner {
    border-radius: 20px !important;
}

/* Стили для отображения времени */
.mobile-video-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.video-duration,
.video-time-remaining {
    font-family: monospace;
    font-weight: 500;
}

.fam-gallery-mobile-vertical {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.mobile-video-btn.fullscreen-btn:hover {
    transform: scale(1.1);
}

/* Стили для видео в полноэкранном режиме */
video:-webkit-full-screen {
    object-fit: contain;
    background: black;
}

video:-moz-full-screen {
    object-fit: contain;
    background: black;
}

video:-ms-fullscreen {
    object-fit: contain;
    background: black;
}

video:fullscreen {
    object-fit: contain;
    background: black;
}

/* Улучшаем touch-обработку для мобильных устройств */
@media (max-width: 768px) {
    .fam-gallery-mobile-vertical .slick-slider {
        touch-action: pan-y pinch-zoom; /* Ограничиваем действия touch */
        -webkit-tap-highlight-color: transparent; /* Убираем подсветку при тапе */
    }

    .fam-gallery-mobile-vertical .slick-slide {
        -webkit-touch-callout: none; /* Запрещаем вызов контекстного меню */
        -webkit-user-select: none; /* Запрещаем выделение текста */
        user-select: none;
    }

    .fam-gallery-mobile-vertical .fam-gallery-preview-vertical {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* Предотвращаем случайные переходы при быстрых касаниях */
    .fam-gallery-mobile-vertical .slick-list {
        touch-action: pan-y pinch-zoom;
    }

    /* Улучшаем отзывчивость кнопок */
    .fam-gallery-mobile-vertical .sound-toggle,
    .fam-gallery-mobile-vertical .mobile-video-btn {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
}

.slick-prev, .slick-next {
    top: 103% !important;
    width: 50px !important;
    height: 50px !important;
    z-index: 1000;
}

.slick-prev:before, .slick-next:before {
    font-size: 35px !important;
    font-family: inherit !important;
}

.slick-prev:before, .slick-next:before {
    color: #0000004f !important;
}

.slick-disabled {
    opacity: 0.5 !important;
}

.slick-next {
    right: 30px !important;
}

.slick-prev {
    left: 30px !important;
}

/* Индикатор паузы */
.pause-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(4px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: fadeInOut 0.3s ease;
}

.pause-indicator svg {
    width: 40px;
    height: 40px;
    fill: white;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Обновленные стили для кнопок */
.mobile-video-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(4px);
}

.mobile-video-btn svg {
    width: 24px;
    height: 24px;
    fill: white;
}

.fam-gallery-button-vertical svg {
    width: 30px;
    height: 30px;
    fill: white;
}

.fam-gallery-vertical {
    position: relative;
    overflow: hidden;
    background: #fff;
    margin-bottom: 30px;
}

/* ── Шапка ленты: название, счётчик, фильтры по тегам, соцсети ── */
.fam-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px 16px;
    flex-wrap: nowrap;              /* название, теги и соцсети — в одну строку */
    margin-bottom: 16px;
    padding: 0 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.fam-gallery-header-main {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
    min-width: 0;                   /* даёт тегам сжиматься и скроллиться, а не переносить строку */
    flex: 1 1 auto;
}

.fam-gallery-title {
    margin: 0;
    padding: 0;
    flex: 0 0 auto;
    font-size: 24px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-family: inherit;
    white-space: nowrap;
    background: linear-gradient(135deg, #ff2d95, #7b3fe4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
}

.fam-gallery-count {
    flex: 0 0 auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #8b9096;
    white-space: nowrap;
}

.fam-gallery-all-link {
    flex: 0 0 auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    color: #1a73e8;
    text-decoration: none;
    white-space: nowrap;
}

.fam-gallery-all-link:hover {
    text-decoration: underline;
}

/* Теги: одна строка, лишнее скроллится по горизонтали внутри блока (полоса прокрутки спрятана) */
.fam-gallery-filters {
    display: flex;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    padding: 2px 0;
    /* растворение у правого края — подсказка, что дальше есть ещё */
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}

.fam-gallery-filters::-webkit-scrollbar {
    display: none;
}

.fam-gallery-header .fam-gallery-filter {
    flex: 0 0 auto;
    margin: 0;
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid #d9dce0;
    background: #fff;
    color: #3c4249;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    text-transform: lowercase;      /* теги — строчными, чтобы читались как теги */
    white-space: nowrap;
    box-shadow: none;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.fam-gallery-header .fam-gallery-filter:hover {
    border-color: #b9bec5;
    color: #14161a;
}

.fam-gallery-header .fam-gallery-filter.is-active {
    background: #2b2f36;
    border-color: #2b2f36;
    color: #fff;
}

.fam-gallery-filters.is-loading {
    opacity: 0.55;
    pointer-events: none;
}

/* Соцсети: только иконки, подпись всплывает при наведении */
.fam-gallery-social {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex: 0 0 auto;
}

.fam-gallery-header .fam-gallery-social-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid #e3e6ea;
    background: #fff;
    text-decoration: none;
    transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.fam-gallery-header .fam-gallery-social-link:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
    text-decoration: none;
}

.fam-gallery-social-link img {
    width: 22px;
    height: 22px;
    display: block;
    border-radius: 50%;
}

.fam-gallery-social-link span {
    display: none;                  /* текст подписи остаётся в разметке для доступности */
}

.fam-gallery-social-link::after {
    content: attr(data-label);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    padding: 4px 8px;
    border-radius: 6px;
    background: #2b2f36;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 5;
}

.fam-gallery-social-link:hover::after,
.fam-gallery-social-link:focus-visible::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


.fam-gallery-empty {
    flex: 0 0 auto;
    padding: 40px 20px;
    color: #8b9096;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Телефон: фильтры и соцсети только на десктопе */
@media (max-width: 768px) {
    .fam-gallery-filters,
    .fam-gallery-social {
        display: none !important;
    }

    .fam-gallery-title {
        font-size: 21px;
    }
}

/* Десктопные стили */
.fam-gallery-desktop-vertical {
    cursor: grab;
}

.fam-gallery-desktop-vertical {
    height: 400px;
    max-height: 400px;
}

.fam-gallery-desktop-vertical:active {
    cursor: grabbing;
}

.fam-gallery-container-vertical {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 20px 0;
    margin: 0 -20px;
    padding-left: 20px;
    -webkit-overflow-scrolling: touch;
}

.fam-gallery-container-vertical::-webkit-scrollbar {
    display: none;
}

.fam-gallery-marquee-vertical {
    display: flex;
    gap: 15px;
    will-change: transform;
    width: max-content;
}

.fam-gallery-item-vertical {
    flex: 0 0 200px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: #1e232a; /* тёмная карточка, пока не приехало превью */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Карточка, скрытая фильтром по тегу */
.fam-gallery-item-vertical.fam-card-hidden {
    display: none !important;
}

.fam-gallery-item-vertical:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

.fam-gallery-link-vertical {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.fam-gallery-link-horizontal {
    height: 180px !important;
}

.fam-gallery-image-container-vertical {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 3px;
    /* тёмный полосатый плейсхолдер, пока превью не загрузилось */
    background-color: #1e232a;
    background-image: repeating-linear-gradient(135deg, #1e232a 0 6px, #252b33 6px 12px);
}

/* прелоадер поверх плейсхолдера */
.fam-gallery-image-container-vertical::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    box-sizing: border-box;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    animation: famThumbSpin 0.9s linear infinite;
    opacity: 1;
    transition: opacity 0.25s ease;
    pointer-events: none;
    z-index: 1;
}

.fam-gallery-image-container-vertical.fam-image-ready {
    background-image: none;
}

.fam-gallery-image-container-vertical.fam-image-ready::after {
    opacity: 0;
    animation: none;
}

@keyframes famThumbSpin {
    to { transform: rotate(360deg); }
}

@keyframes famThumbShimmer {
    0%   { background-position: 150% 0; }
    100% { background-position: -50% 0; }
}

.fam-gallery-image-vertical {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
    border-radius: 3px;
    transform: scale(1);
    position: relative;
    z-index: 2;
}

/* превью появляется плавно */
.fam-gallery-image-vertical.fam-lazy-image {
    opacity: 0;
    transition: opacity 0.45s ease, transform 0.6s ease;
}

.fam-gallery-image-vertical.fam-lazy-image.fam-image-loaded {
    opacity: 1;
}

/* Плейсхолдер под мобильным видео-плеером: пока не пришёл постер,
   вместо белого пятна — серый фон с прелоадером */
.fam-video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    background-color: #e6e7ea;
    background-image: linear-gradient(100deg,
        rgba(255, 255, 255, 0) 20%,
        rgba(255, 255, 255, 0.55) 50%,
        rgba(255, 255, 255, 0) 80%);
    background-size: 200% 100%;
    background-repeat: no-repeat;
    animation: famThumbShimmer 1.4s ease-in-out infinite;
    opacity: 1;
    transition: opacity 0.45s ease;
    pointer-events: none;
}

.fam-video-placeholder::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    box-sizing: border-box;
    border: 3px solid rgba(0, 0, 0, 0.14);
    border-top-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    animation: famThumbSpin 0.9s linear infinite;
    pointer-events: none;
}

.fam-video-placeholder.fam-placeholder-hidden {
    opacity: 0;
    animation: none;
}

.fam-video-placeholder.fam-placeholder-hidden::after {
    animation: none;
}

/* видео должно лежать поверх плейсхолдера */
.mobile-video-player {
    position: relative;
    z-index: 1;
}

.fam-gallery-image-vertical {
    height:360px !important;
}

.fam-gallery-item-vertical:hover .fam-gallery-image-vertical {
    transform: scale(1.08);
}

.fam-gallery-overlay-vertical {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: all 0.3s ease;
}

.fam-gallery-overlay-vertical button {
    border: 0px;
    background: 0px;
    cursor: pointer;
}

.fam-gallery-item-vertical:hover .fam-gallery-overlay-vertical {
    opacity: 1;
}

.fam-gallery-item-vertical:hover .fam-gallery-button-vertical {
    opacity: 1;
}

.fam-gallery-button-vertical:hover {
    transform: translateY(0) scale(1.3);
    transition: all 300ms ease-in;
}

.fam-gallery-duration-vertical {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    z-index: 2;
}

.fam-gallery-title-overlay-vertical {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 60px 16px 16px 16px;
    background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.7) 100%);
    color: white;
    z-index: 2;
}

.fam-gallery-title-vertical {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.fam-gallery-meta-vertical {
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Контролы */
.fam-gallery-controls-vertical {
    position: absolute;
    top: calc(50% + 22px);
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 2;
}

.fam-gallery-control-vertical {
    pointer-events: all;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.8;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.fam-gallery-control-vertical:hover {
    opacity: 1;
}

.fam-gallery-control-vertical svg {
    width: 20px;
    height: 20px;
    fill: #000;
}

/* Начальное состояние слайдера - невидим */
.fam-gallery-mobile-vertical .fam-gallery-slider-vertical {
    opacity: 0;
    transition: opacity 1s ease;
}

/* Когда слайдер инициализирован и готов - показываем */
.fam-gallery-mobile-vertical .fam-gallery-slider-vertical.slick-initialized {
    opacity: 1;
}

/* Также для горизонтальных слайдеров */
.fam-gallery-mobile-horizontal .fam-gallery-slider-horizontal {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fam-gallery-mobile-horizontal .fam-gallery-slider-horizontal.slick-initialized {
    opacity: 1;
}

.fam-gallery-mobile-vertical .slick-initialized .mobile-video-player {
    opacity: 1;
}

/* Мобильные стили - усиленные */
@media (max-width: 768px) {
    .fam-gallery-mobile-vertical,
    .fam-gallery-mobile-horizontal {
        display: block !important;
        width: 100% !important;
        overflow: hidden !important;
        padding: 20px 0 !important;
        position: relative !important;
    }

    .fam-gallery-mobile-vertical {
        height: 900px;
    }

    .slick-list {
        overflow: visible !important;
        padding: 10px 0 !important;
    }

    .slick-track {
        display: flex !important;
        flex-direction: row !important;
    }

    .slick-slide {
        opacity: 0.3;
        transition: opacity 0.3s ease, transform 0.3s ease;
        transform: scale(0.95);
        height: auto !important;
        float: none !important;
        margin: 0px;
        display: inline-block !important;
    }

    .slick-center {
        opacity: 1;
        transform: scale(1);
    }

    /* Вертикальные видео */
    body:not(.fam-fullview-open) .fam-gallery-mobile-vertical .slick-slide {
        width: 470px;
        max-width: 90%;
    }

    .fam-gallery-mobile-vertical .fam-gallery-preview-vertical {
        width: 100% !important;
        aspect-ratio: 9/16 !important;
        border-radius: 16px !important;
        overflow: hidden !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
        position: relative !important;
    }

    /* Горизонтальные видео */
    .fam-gallery-mobile-horizontal .slick-slide {
        width: 450px !important;
    }

    .fam-gallery-mobile-horizontal .fam-gallery-preview-horizontal {
        width: 100% !important;
        aspect-ratio: 16/9 !important;
        border-radius: 16px !important;
        overflow: hidden !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
        position: relative !important;
    }

    .fam-gallery-image-container-vertical,
    .fam-gallery-image-container-horizontal {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
    }

    .fam-gallery-image-vertical,
    .fam-gallery-image-horizontal,
    .mobile-video-player {
        width: 100% !important;
        height: 100%;
        object-fit: cover !important;
    }

    .mobile-video-controls {
        position: absolute;
        bottom: 15px;
        right: 15px;
        z-index: 10;
        display: flex;
        gap: 8px;
    }

    .mobile-video-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: none;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        backdrop-filter: blur(5px);
    }

    .mobile-video-btn svg {
        width: 20px;
        height: 20px;
        fill: #fff;
    }

    .mobile-video-info {
        position: absolute;
        bottom: 20px;
        left: 15px;
        right: 70px;
        z-index: 10;
        color: white;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    }

    .mobile-video-title {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-video-meta {
        font-size: 12px;
        opacity: 0.9;
    }

    .sound-toggle {
        position: absolute;
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.9);
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.3s ease;
        backdrop-filter: blur(5px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
        z-index: 15;
    }

    .sound-toggle svg {
        width: 20px;
        height: 20px;
        fill: #000;
    }

    .slick-dots {
        position: absolute;
        bottom: -37px;
        left: 0;
        right: 0;
        display: flex !important;
        justify-content: center;
        gap: 8px;
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .slick-dots li {
        margin: 0 5px;
        width: auto !important;
    }

    .slick-dots li button {
        width: 8px;
        height: 8px;
        padding: 0;
        border-radius: 50%;
        background: rgba(0, 0, 0, 0.3);
        border: none;
        text-indent: -9999px;
        overflow: hidden;
        transition: all 0.3s ease;
    }

    .slick-dots li.slick-active button {
        width: 20px;
        border-radius: 10px;
        background: #007AFF;
    }
}

@media (max-width: 768px) {
    /* Скрываем десктопную версию */
    .fam-gallery-desktop-vertical {
        display: none !important;
    }

    /* Показываем мобильную версию */
    .fam-gallery-mobile-vertical {
        display: block !important;
        width: 100% !important;
        overflow: hidden !important;
        padding: 20px 0 !important;
        position: relative !important;
    }
}

/* Десктоп стили */
@media (min-width: 769px) {
    .fam-gallery-desktop-vertical {
        display: block !important;
    }

    .fam-gallery-mobile-vertical {
        display: none !important;
    }
}

/* ===== Кнопка режима просмотра ===== */
.fam-view-mode-bar {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    pointer-events: all;
}

.fam-view-mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.12);
    border: 1.5px solid rgba(0, 0, 0, 0.15);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    white-space: nowrap;
}

.fam-view-mode-btn:active {
    transform: scale(0.96);
    background: rgba(0, 0, 0, 0.2);
}

/* ===== Оверлей режима просмотра ===== */
/* Chrome на Android: вертикальный свайп по галерее на самом верху
   страницы — это pull-to-refresh, то есть перезагрузка. Скролл
   остаётся, отключается только «потянуть, чтобы обновить» */
@media (max-width: 768px) {
    html {
        overscroll-behavior-y: contain;
    }
}

.fam-fullview-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: 99999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overscroll-behavior: contain;
    will-change: transform;
    isolation: isolate;
    touch-action: none;
}

.fam-fullview-overlay.fam-fullview-active {
    display: flex;
}

/* Кнопка закрытия */
.fam-fullview-close {
    position: fixed;
    top: env(safe-area-inset-top, 16px);
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 99999;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.fam-fullview-close svg {
    fill: #fff;
    width: 22px;
    height: 22px;
}

/* Навигационные стрелки режима просмотра */
.fam-fullview-nav {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom, 24px) + 16px);
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 99999;
    pointer-events: none;
}

.fam-fullview-nav-btn {
    pointer-events: all;
    width: 44px;
    height: 25px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.25);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.85;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.fam-fullview-nav-btn:active {
    transform: scale(0.93);
    opacity: 1;
}

.fam-fullview-nav-btn svg {
    width: 22px;
    height: 22px;
    fill: #1d1d1f;
}

.fam-fullview-nav-btn:disabled {
    opacity: 0.15 !important;
    pointer-events: none;
}

/* Прогресс-бар */
.fam-fullview-progress {
    position: fixed;
    bottom: 0px;
    left: 0px;
    right: 0px;
    height: 3px;
    background: rgba(255,255,255,0.25);
    border-radius: 999px;
    z-index: 99999;
    cursor: pointer;
}

.fam-fullview-progress-played {
    height: 100%;
    background: var(--background_gradient);
    border-radius: 999px;
    width: 0%;
    pointer-events: none;
    transition: width 0.1s linear;
}

/* Заголовок видео */
.fam-fullview-title {
    position: fixed;
    top: calc(env(safe-area-inset-top, 16px) + 8px);
    left: 20px;
    right: 64px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    z-index: 99999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Стили для заблокированных кнопок (уже есть) */
.fam-gallery-control-horizontal:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.fam-gallery-button-horizontal svg {
    width: 30px;
    height: 30px;
    fill: white;
}

.fam-gallery-horizontal {
    position: relative;
    overflow: hidden;
    background: #fff;
    margin-bottom: 30px;
}

/* Десктопные стили */
.fam-gallery-desktop-horizontal {
    cursor: grab;
}

.fam-gallery-desktop-horizontal:active {
    cursor: grabbing;
}

.fam-gallery-container-horizontal {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 20px 0;
    margin: 0 -20px;
    padding-left: 20px;
    -webkit-overflow-scrolling: touch;
}

.fam-gallery-container-horizontal::-webkit-scrollbar {
    display: none;
}

.fam-gallery-marquee-horizontal {
    display: flex;
    gap: 15px;
    will-change: transform;
    width: max-content;
}

.fam-gallery-item-horizontal {
    flex: 0 0 320px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: #1e232a; /* тёмная карточка, пока не приехало превью */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Карточка, скрытая фильтром по тегу */
.fam-gallery-item-horizontal.fam-card-hidden {
    display: none !important;
}

.fam-gallery-item-horizontal:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

.fam-gallery-link-horizontal {
    display: block;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

.fam-gallery-image-container-horizontal {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 3px;
    /* тёмный полосатый плейсхолдер, пока превью не загрузилось */
    background-color: #1e232a;
    background-image: repeating-linear-gradient(135deg, #1e232a 0 6px, #252b33 6px 12px);
}

/* прелоадер поверх плейсхолдера */
.fam-gallery-image-container-horizontal::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    box-sizing: border-box;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    animation: famThumbSpin 0.9s linear infinite;
    opacity: 1;
    transition: opacity 0.25s ease;
    pointer-events: none;
    z-index: 1;
}

.fam-gallery-image-container-horizontal.fam-image-ready {
    background-image: none;
}

.fam-gallery-image-container-horizontal.fam-image-ready::after {
    opacity: 0;
    animation: none;
}

.fam-gallery-image-horizontal {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
    border-radius: 3px;
    transform: scale(1);
    position: relative;
    z-index: 2;
}

/* превью появляется плавно */
.fam-gallery-image-horizontal.fam-lazy-image {
    opacity: 0;
    transition: opacity 0.45s ease, transform 0.6s ease;
}

.fam-gallery-image-horizontal.fam-lazy-image.fam-image-loaded {
    opacity: 1;
}

.fam-gallery-item-horizontal:hover .fam-gallery-image-horizontal {
    transform: scale(1.08);
}

.fam-gallery-overlay-horizontal {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: all 0.3s ease;
}

.fam-gallery-overlay-horizontal button {
    border: 0px;
    background: 0px;
    cursor: pointer;
}

.fam-gallery-item-horizontal:hover .fam-gallery-overlay-horizontal {
    opacity: 1;
}

.fam-gallery-item-horizontal:hover .fam-gallery-button-horizontal {
    opacity: 1;
}

.fam-gallery-button-horizontal:hover {
    transform: translateY(0) scale(1.3);
    transition: all 300ms ease-in;
}

.fam-gallery-duration-horizontal {
    position: absolute;
    bottom: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    z-index: 2;
}

.fam-gallery-title-overlay-horizontal {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 60px 16px 16px 16px;
    background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.7) 100%);
    color: white;
    z-index: 2;
}

.fam-gallery-title-horizontal {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.fam-gallery-meta-horizontal {
    margin-top: 4px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Контролы */
.fam-gallery-controls-horizontal {
    position: absolute;
    top: calc(50% + 22px);
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 2;
}

.fam-gallery-control-horizontal {
    pointer-events: all;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.8;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.fam-gallery-control-horizontal:hover {
    opacity: 1;
}

.fam-gallery-control-horizontal svg {
    width: 20px;
    height: 20px;
    fill: #000;
}

@media (max-width: 768px) {
    /* Скрываем десктопную версию */
    .fam-gallery-desktop-horizontal {
        display: none !important;
    }

    /* Показываем мобильную версию */
    .fam-gallery-mobile-horizontal {
        display: block !important;
        width: 100% !important;
        overflow: hidden !important;
        padding: 20px 0 !important;
        position: relative !important;
    }
}

/* Десктоп стили */
@media (min-width: 769px) {
    .fam-gallery-desktop-horizontal {
        display: block !important;
    }

    .fam-gallery-mobile-horizontal {
        display: none !important;
    }
}
