/* Неоклассический абстракционизм - CSS стили */

:root {
    --primary-color: #1a1a1a;
    --secondary-color: #f8f8f8;
    --accent-gold: #d4af37;
    --accent-bronze: #cd7f32;
    --text-light: #666;
    --background-dark: #0f0f0f;
    --transition-smooth: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --shadow-elegant: 0 20px 40px rgba(0, 0, 0, 0.1);
    --border-classic: 1px solid rgba(212, 175, 55, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 50%, #0f0f0f 100%);
    color: var(--secondary-color);    overflow: hidden;
    line-height: 1.6;
    min-height: 100dvh; /* Используем динамическую высоту для мобильных устройств */
}

body.search-mode-active .gallery-viewport {
    cursor: default;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh; /* Используем динамическую высоту */
    background: linear-gradient(45deg, var(--background-dark), var(--primary-color));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
    padding: 2rem;
    box-sizing: border-box;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--secondary-color);
    display: flex;
    z-index: 100;
    position: relative;
}

.loading-title span {
    opacity: 0;
    transform: translateY(20px);
    animation: letterFadeIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.loading-title .space {
    width: 1rem;
}

/* Анимация для каждой буквы */
@keyframes letterFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Задержки для последовательного появления букв */
.loading-title span:nth-child(1) { animation-delay: 0.1s; }
.loading-title span:nth-child(2) { animation-delay: 0.15s; }
.loading-title span:nth-child(3) { animation-delay: 0.2s; }
.loading-title span:nth-child(4) { animation-delay: 0.25s; }
.loading-title span:nth-child(5) { animation-delay: 0.3s; }
.loading-title span:nth-child(6) { animation-delay: 0.35s; }
.loading-title span:nth-child(7) { animation-delay: 0.4s; }
.loading-title span:nth-child(8) { animation-delay: 0.45s; }
.loading-title span:nth-child(10) { animation-delay: 0.5s; }
.loading-title span:nth-child(11) { animation-delay: 0.55s; }
.loading-title span:nth-child(12) { animation-delay: 0.6s; }
.loading-title span:nth-child(13) { animation-delay: 0.65s; }
.loading-title span:nth-child(14) { animation-delay: 0.7s; }
.loading-title span:nth-child(15) { animation-delay: 0.75s; }
.loading-title span:nth-child(16) { animation-delay: 0.8s; }

.loading-title span:nth-child(1),
.loading-title span:nth-child(10) {
    color: var(--accent-gold);
}

/* Анимация плавающих картин */
.floating-art-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.art-frame {
    position: absolute;
    border: 2px solid rgba(212, 175, 55, 0.6);
    border-radius: 8px;
    background: rgba(212, 175, 55, 0.1);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.2);
    animation: floating-art 8s ease-in-out infinite;
    opacity: 1; /* Изменено: все картины видны сразу */
    transform: scale(1) translateY(0); /* Изменено: нормальный размер сразу */
}

.art-frame.loaded {
    /* Убираем анимацию появления, оставляем только плавание */
    animation: floating-art 8s ease-in-out infinite;
}

/* Схематичные рисунки картин */
.art-content {
    width: 100%;
    height: 100%;
    position: relative;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Элегантная картина 1 - абстрактный пейзаж */
.art-frame:nth-child(1) .art-content::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 40%;
    background: linear-gradient(to bottom, transparent, rgba(212, 175, 55, 0.8));
    bottom: 0;
    left: 0;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.art-frame:nth-child(1) .art-content::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: #d4af37;
    border-radius: 50%;
    top: 25%;
    left: 30%;
    box-shadow: 0 0 15px #d4af37, 25px 15px 0 #cd7f32, 45px 25px 0 #d4af37;
}

/* Элегантная картина 2 - минималистичные линии */
.art-frame:nth-child(2) .art-content::before {
    content: '';
    position: absolute;
    width: 70%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #d4af37, transparent);
    top: 35%;
    left: 15%;
    box-shadow: 0 25px 0 rgba(212, 175, 55, 0.6), 0 50px 0 rgba(212, 175, 55, 0.4);
}

.art-frame:nth-child(2) .art-content::after {
    content: '';
    position: absolute;
    width: 1px;
    height: 60%;
    background: linear-gradient(180deg, transparent, #cd7f32, transparent);
    top: 20%;
    right: 30%;
}

/* Элегантная картина 3 - геометрическая композиция */
.art-frame:nth-child(3) .art-content::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 12px solid transparent;
    border-right: 12px solid transparent;
    border-bottom: 20px solid rgba(212, 175, 55, 0.9);
    top: 30%;
    left: 50%;
    transform: translateX(-50%);
}

.art-frame:nth-child(3) .art-content::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(205, 127, 50, 0.8);
    border-radius: 50%;
    top: 55%;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

/* Элегантная картина 4 - орнаментальный узор */
.art-frame:nth-child(4) .art-content::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 25% 25%, rgba(212, 175, 55, 0.6) 2px, transparent 2px),
        radial-gradient(circle at 75% 75%, rgba(205, 127, 50, 0.6) 2px, transparent 2px),
        radial-gradient(circle at 50% 50%, rgba(212, 175, 55, 0.4) 1px, transparent 1px);
    background-size: 20px 20px, 20px 20px, 10px 10px;
}

/* Элегантная картина 5 - импрессионистский стиль */
.art-frame:nth-child(5) .art-content::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 30% 40%, rgba(212, 175, 55, 0.7) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 60%, rgba(205, 127, 50, 0.6) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 20%, rgba(212, 175, 55, 0.5) 0%, transparent 40%);
}

/* Элегантная картина 6 - ар-деко узор */
.art-frame:nth-child(6) .art-content::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(45deg, transparent 40%, rgba(212, 175, 55, 0.8) 40%, rgba(212, 175, 55, 0.8) 60%, transparent 60%),
        linear-gradient(-45deg, transparent 40%, rgba(205, 127, 50, 0.6) 40%, rgba(205, 127, 50, 0.6) 60%, transparent 60%);
}

/* Элегантная картина 7 - кинетическая спираль */
.art-frame:nth-child(7) .art-content::before {
    content: '';
    position: absolute;
    width: 50px;
    height: 50px;
    border: 1.5px solid transparent;
    border-top: 1.5px solid #d4af37;
    border-right: 1.5px solid rgba(205, 127, 50, 0.6);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: spin 4s linear infinite;
}

/* Элегантная картина 8 - волнообразные формы */
.art-frame:nth-child(8) .art-content::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 50%, transparent 0%, transparent 30%, rgba(212, 175, 55, 0.7) 30%, rgba(212, 175, 55, 0.7) 40%, transparent 40%),
        radial-gradient(ellipse at 80% 50%, transparent 0%, transparent 30%, rgba(205, 127, 50, 0.6) 30%, rgba(205, 127, 50, 0.6) 40%, transparent 40%);
}

/* Элегантная картина 9 - символический знак */
.art-frame:nth-child(9) .art-content::before {
    content: '✦';
    position: absolute;
    font-size: 28px;
    color: #d4af37;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-shadow: 0 0 15px rgba(212, 175, 55, 0.6);
}

/* Элегантная картина 10 - модульная композиция */
.art-frame:nth-child(10) .art-content::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    background: rgba(212, 175, 55, 0.9);
    top: 25%;
    left: 25%;
    box-shadow: 25px 0 0 rgba(205, 127, 50, 0.8), 0 25px 0 rgba(212, 175, 55, 0.7), 25px 25px 0 rgba(205, 127, 50, 0.6);
}

/* Элегантная картина 11 - диагональная композиция */
.art-frame:nth-child(11) .art-content::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(45deg, transparent 0%, transparent 35%, rgba(212, 175, 55, 0.8) 35%, rgba(212, 175, 55, 0.8) 65%, transparent 65%);
}

.art-frame:nth-child(11) .art-content::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(-45deg, transparent 0%, transparent 35%, rgba(205, 127, 50, 0.6) 35%, rgba(205, 127, 50, 0.6) 65%, transparent 65%);
}

/* Элегантная картина 12 - точечная композиция */
.art-frame:nth-child(12) .art-content::before {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(212, 175, 55, 0.9);
    border-radius: 50%;
    top: 20%;
    left: 20%;
    box-shadow: 
        15px 0 0 rgba(205, 127, 50, 0.8), 
        30px 0 0 rgba(212, 175, 55, 0.7), 
        0 15px 0 rgba(205, 127, 50, 0.8), 
        15px 15px 0 rgba(212, 175, 55, 0.7), 
        30px 15px 0 rgba(205, 127, 50, 0.6), 
        0 30px 0 rgba(212, 175, 55, 0.6), 
        15px 30px 0 rgba(205, 127, 50, 0.7), 
        30px 30px 0 rgba(212, 175, 55, 0.8);
}

/* Элегантная картина 13 - крестообразная композиция */
.art-frame:nth-child(13) .art-content::before {
    content: '';
    position: absolute;
    width: 3px;
    height: 35px;
    background: linear-gradient(180deg, transparent, #d4af37, transparent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.art-frame:nth-child(13) .art-content::after {
    content: '';
    position: absolute;
    width: 35px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #cd7f32, transparent);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

/* Элегантная картина 14 - цветочный мотив */
.art-frame:nth-child(14) .art-content::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: rgba(212, 175, 55, 0.9);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 
        0 -18px 0 rgba(205, 127, 50, 0.8), 
        18px 0 0 rgba(212, 175, 55, 0.7), 
        0 18px 0 rgba(205, 127, 50, 0.8), 
        -18px 0 0 rgba(212, 175, 55, 0.7), 
        13px -13px 0 rgba(205, 127, 50, 0.6), 
        13px 13px 0 rgba(212, 175, 55, 0.6), 
        -13px 13px 0 rgba(205, 127, 50, 0.7), 
        -13px -13px 0 rgba(212, 175, 55, 0.8);
}

/* Элегантная картина 15 - архитектурный узор */
.art-frame:nth-child(15) .art-content::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(90deg, transparent 0%, transparent 15%, rgba(212, 175, 55, 0.8) 15%, rgba(212, 175, 55, 0.8) 20%, transparent 20%),
        linear-gradient(90deg, transparent 80%, rgba(205, 127, 50, 0.7) 80%, rgba(205, 127, 50, 0.7) 85%, transparent 85%),
        linear-gradient(0deg, transparent 0%, transparent 15%, rgba(212, 175, 55, 0.6) 15%, rgba(212, 175, 55, 0.6) 20%, transparent 20%),
        linear-gradient(0deg, transparent 80%, rgba(205, 127, 50, 0.5) 80%, rgba(205, 127, 50, 0.5) 85%, transparent 85%);
}

/* Анимация появления картин */
@keyframes artAppear {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(60px) rotate(-5deg);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1) translateY(-8px) rotate(2deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0) rotate(0deg);
    }
}

/* Анимация плавания */
@keyframes floating-art {
    0%, 100% {
        transform: translateY(0) rotate(0deg) scale(1);
        opacity: 0.6;
    }
    25% {
        transform: translateY(-20px) rotate(2deg) scale(1.05);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-40px) rotate(0deg) scale(1.1);
        opacity: 1;
    }
    75% {
        transform: translateY(-20px) rotate(-2deg) scale(1.05);
        opacity: 0.8;
    }
}

/* Анимация вращения для спирали */
@keyframes spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Разные размеры и позиции для картин */
.art-frame:nth-child(1) { 
    width: 80px; height: 100px; 
    left: 10%; top: 15%; 
    animation-delay: 0s; 
    animation-duration: 8s;
}
.art-frame:nth-child(2) { 
    width: 60px; height: 75px; 
    left: 20%; top: 25%; 
    animation-delay: 1s; 
    animation-duration: 7s;
}
.art-frame:nth-child(3) { 
    width: 70px; height: 90px; 
    left: 35%; top: 10%; 
    animation-delay: 2s; 
    animation-duration: 9s;
}
.art-frame:nth-child(4) { 
    width: 50px; height: 65px; 
    left: 50%; top: 20%; 
    animation-delay: 3s; 
    animation-duration: 6s;
}
.art-frame:nth-child(5) { 
    width: 90px; height: 110px; 
    left: 65%; top: 15%; 
    animation-delay: 4s; 
    animation-duration: 10s;
}
.art-frame:nth-child(6) { 
    width: 55px; height: 70px; 
    left: 80%; top: 25%; 
    animation-delay: 5s; 
    animation-duration: 7.5s;
}
.art-frame:nth-child(7) { 
    width: 75px; height: 95px; 
    left: 15%; top: 60%; 
    animation-delay: 6s; 
    animation-duration: 8.5s;
}
.art-frame:nth-child(8) { 
    width: 65px; height: 80px; 
    left: 30%; top: 70%; 
    animation-delay: 7s; 
    animation-duration: 7s;
}
.art-frame:nth-child(9) { 
    width: 85px; height: 105px; 
    left: 45%; top: 65%; 
    animation-delay: 8s; 
    animation-duration: 9.5s;
}
.art-frame:nth-child(10) { 
    width: 70px; height: 85px; 
    left: 60%; top: 75%; 
    animation-delay: 9s; 
    animation-duration: 8s;
}
.art-frame:nth-child(11) { 
    width: 60px; height: 75px; 
    left: 75%; top: 60%; 
    animation-delay: 10s; 
    animation-duration: 7s;
}
.art-frame:nth-child(12) { 
    width: 80px; height: 100px; 
    left: 85%; top: 70%; 
    animation-delay: 11s; 
    animation-duration: 8.5s;
}
.art-frame:nth-child(13) { 
    width: 55px; height: 70px; 
    left: 5%; top: 45%; 
    animation-delay: 12s; 
    animation-duration: 6.5s;
}
.art-frame:nth-child(14) { 
    width: 90px; height: 115px; 
    left: 25%; top: 85%; 
    animation-delay: 13s; 
    animation-duration: 10.5s;
}
.art-frame:nth-child(15) { 
    width: 65px; height: 80px; 
    left: 70%; top: 85%; 
    animation-delay: 14s; 
    animation-duration: 7.5s;
}

/* Адаптивность для экрана загрузки */
@media (max-width: 768px) {
    .loading-title {
        font-size: 2rem;
    }
    
    .loading-title .space {
        width: 0.8rem;
    }
    
    .art-frame:nth-child(1) { width: 60px; height: 75px; }
    .art-frame:nth-child(2) { width: 45px; height: 55px; }
    .art-frame:nth-child(3) { width: 55px; height: 70px; }
    .art-frame:nth-child(4) { width: 40px; height: 50px; }
    .art-frame:nth-child(5) { width: 70px; height: 85px; }
    .art-frame:nth-child(6) { width: 40px; height: 50px; }
    .art-frame:nth-child(7) { width: 60px; height: 75px; }
    .art-frame:nth-child(8) { width: 50px; height: 65px; }
    .art-frame:nth-child(9) { width: 65px; height: 80px; }
    .art-frame:nth-child(10) { width: 55px; height: 70px; }
    .art-frame:nth-child(11) { width: 45px; height: 55px; }
    .art-frame:nth-child(12) { width: 60px; height: 75px; }
    .art-frame:nth-child(13) { width: 40px; height: 50px; }
    .art-frame:nth-child(14) { width: 70px; height: 85px; }
    .art-frame:nth-child(15) { width: 50px; height: 65px; }
}

@media (max-width: 480px) {
    .loading-title {
        font-size: 1.5rem;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
        gap: 0.2rem;
    }
    
    .loading-title .space {
        width: 0.3rem;
    }
    
    .art-frame:nth-child(1) { width: 50px; height: 65px; }
    .art-frame:nth-child(2) { width: 40px; height: 50px; }
    .art-frame:nth-child(3) { width: 45px; height: 60px; }
    .art-frame:nth-child(4) { width: 35px; height: 45px; }
    .art-frame:nth-child(5) { width: 60px; height: 75px; }
    .art-frame:nth-child(6) { width: 40px; height: 50px; }
    .art-frame:nth-child(7) { width: 50px; height: 65px; }
    .art-frame:nth-child(8) { width: 45px; height: 55px; }
    .art-frame:nth-child(9) { width: 55px; height: 70px; }
    .art-frame:nth-child(10) { width: 45px; height: 60px; }
    .art-frame:nth-child(11) { width: 40px; height: 50px; }
    .art-frame:nth-child(12) { width: 50px; height: 65px; }
    .art-frame:nth-child(13) { width: 35px; height: 45px; }
    .art-frame:nth-child(14) { width: 60px; height: 75px; }
    .art-frame:nth-child(15) { width: 45px; height: 55px; }
}

/* Search Container */
.search-container {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 500;
    display: flex;
    align-items: center;
    background: rgba(26, 26, 26, 0.8);
    backdrop-filter: blur(15px);
    border-radius: 50px;
    padding: 0.5rem 1.5rem;
    border: var(--border-classic);
    box-shadow: var(--shadow-elegant);
    transition: all 0.3s ease-out;
}

.search-container.suggestions-active {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(26, 26, 26, 0.98);
    backdrop-filter: blur(20px);
    border: var(--border-classic);
    border-top: none;
    border-radius: 0 0 24px 24px;
    margin-top: -1px;
    padding: 0.5rem;
    z-index: -1;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.98);
    transition: all 0.3s ease-out;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.search-container.suggestions-active .search-suggestions {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.suggestion-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: var(--secondary-color);
}

.suggestion-item:hover {
    background-color: rgba(212, 175, 55, 0.1);
}

.suggestion-item .icon {
    color: var(--accent-gold);
    margin-right: 1rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.search-container:focus-within {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3), 0 0 0 1px var(--accent-gold);
    border-color: var(--accent-gold);
}

.search-icon {
    color: var(--text-light);
    margin-right: 1rem;
}

.search-input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--secondary-color);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    width: 300px;
    transition: width 0.3s ease-out;
}

.search-input::placeholder {
    color: var(--text-light);
}

.search-input:focus {
    width: 400px;
}

/* Скрываем стандартный крестик очистки в Chrome/Safari */
.search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    display: none;
}

.clear-search-button {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 0 0.5rem;
    line-height: 1;
}

.clear-search-button:hover {
    color: var(--secondary-color);
}

/* Favorites Button */
.favorites-button {
    position: relative; /* Для позиционирования счетчика */
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.favorites-button:hover {
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
    transform: scale(1.1);
}

/* Добавляем стиль для активной кнопки "Популярное" */
.popular-button.active {
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
}

.popular-button.active svg {
    fill: var(--accent-gold);
}

.favorites-button.active {
    color: var(--accent-gold);
}

.favorites-button.active .favorites-icon {
    fill: var(--accent-gold);
    stroke: var(--accent-gold);
}

.favorites-icon {
    transition: all 0.3s ease-out;
}

.favorites-counter {
    position: absolute;
    top: -2px;
    right: -5px;
    background-color: var(--accent-gold);
    color: var(--primary-color);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--background-dark);
}

/* Кнопка смены вида сетки */
.layout-toggle-button {
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layout-toggle-button:hover {
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
    transform: scale(1.1);
}

/* Новый переключатель сортировки */
.popular-sort-toggle {
    display: none; /* Показывается через JS */
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 1px solid var(--text-light);
    color: var(--secondary-color);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease-out;
    margin-left: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.popular-sort-toggle:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.1);
}

body.search-mode-active .layout-toggle-button,
body.secret-mode-active .layout-toggle-button,
body.favorites-mode-active .layout-toggle-button,
body.stats-mode-active .layout-toggle-button {
    display: none;
}

body.popular-mode-active .layout-toggle-button,
body.favorites-mode-active .layout-toggle-button {
    display: none;
}

/* No Results Message */
.no-results-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 400;
    color: var(--secondary-color);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.no-results-message h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--accent-gold);
}

.no-results-message p {
    font-size: 1rem;
    color: var(--text-light);
}
/* Gallery Container */
.gallery-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    position: relative;
    height: 100dvh; /* Используем динамическую высоту */
}

.gallery-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    cursor: grab;

}

.gallery-viewport:active {
    cursor: grabbing;
}
.gallery-grid {
    position: relative;
    width: 1px;
    height: 1px;
    transform-origin: top left;
}

/* Анимации для элементов галереи */
@keyframes itemFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes itemSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.gallery-item {
    position: absolute;
    background: rgba(255, 255, 255, 0.02);
    border: var(--border-classic);
    border-radius: 12px; /* Увеличиваем радиус для более современного вида */
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition-smooth);
    backdrop-filter: blur(10px);
    /* Размеры будут устанавливаться динамически через JavaScript */
    /* Плавное изменение размеров и позиции */
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                width 0.4s ease, 
                height 0.4s ease,
                left 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                top 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    /* Анимация появления */
    animation: itemSlideIn 0.8s ease-out;
    /* Оптимизация производительности */
    will-change: transform, width, height, left, top;
    transform: translateZ(0);
    /* Улучшенные тени для лучшего разделения картин */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
    /* Базовый z-index для предотвращения наложений */
    z-index: 1;
    /* Улучшенные границы */
    border: 1px solid rgba(212, 175, 55, 0.15);
    /* Предотвращаем выделение текста или изображения при перетаскивании */
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* Standard syntax */
}

.gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1) 0%, transparent 50%, rgba(205, 127, 50, 0.1) 100%);
    opacity: 0;
    transition: var(--transition-smooth);
    z-index: 1;
}

.gallery-item.current-image-highlight {
    z-index: 20; /* Выносим на передний план, чтобы подсветка была видна */
    /* Эта анимация заменяет стандартную itemSlideIn и добавляет эффект "подпрыгивания" и свечения */
    animation: highlight-jiggle 1.5s ease-out;
}

@keyframes highlight-jiggle {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 0 0px rgba(212, 175, 55, 0.0);
    }
    30% {
        transform: scale(1.03);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25), 0 0 0 8px rgba(212, 175, 55, 0.6);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 0 0 0px rgba(212, 175, 55, 0);
    }
}

.gallery-item:hover {
    transform: translateY(-12px) scale(1.03); /* Увеличиваем эффект подъема */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 0 2px var(--accent-gold);
    border-color: var(--accent-gold);
    /* При наведении поднимаем элемент выше остальных */
    z-index: 10;
}

.gallery-item:hover::before {
    opacity: 1;
}

/* Индикатор просмотренной картины (глаз) */
.viewed-indicator {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3; /* Выше оверлея */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* Не мешает кликам */
}

.gallery-item.viewed .viewed-indicator {
    opacity: 1;
}

/* Кнопка избранного в элементах галереи */
.favorite-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    opacity: 0;
    transition: all 0.3s ease;
    color: var(--secondary-color);
}

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

.favorite-button:hover {
    background: rgba(212, 175, 55, 0.2);
    color: var(--accent-gold);
    transform: scale(1.1);
}

.favorite-button.active {
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.3);
}

.favorite-button.active .favorite-icon {
    fill: var(--accent-gold);
    stroke: var(--accent-gold);
}

.favorite-icon {
    transition: all 0.3s ease;
}

.viewed-indicator svg {
    width: 14px;
    height: 14px;
    color: white;
    opacity: 0.8;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Показываем картины полностью, не обрезаем */
    transition: var(--transition-smooth);
    filter: grayscale(0.1) contrast(1.05) brightness(0.95); /* Улучшаем фильтры */
    /* Обеспечиваем правильное отображение изображений с любыми пропорциями */
    object-position: center;
    /* Плавное изменение размеров */
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                filter 0.3s ease;
    position: relative; /* Чтобы z-index работал */
    z-index: 2; /* Основное изображение всегда выше */
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05); /* Увеличиваем масштаб для лучшего эффекта */
    filter: grayscale(0) contrast(1.1) brightness(1.05);
}

/* Размытый фон для изображений */
.gallery-image-bg {
    display: none; /* Скрыт по умолчанию */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(20px) brightness(0.8);
    transform: scale(1.1); /* Чтобы размытые края не были видны */
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* В режиме строгой сетки убираем фон и границы, показываем только изображение */
body.strict-grid-mode .gallery-item {
    background: transparent;
    border: none;
    backdrop-filter: none;
}

/* В режиме строгой сетки вписываем изображение, а не обрезаем */
body.strict-grid-mode .gallery-item .gallery-image {
    object-fit: contain;
    filter: none; /* Убираем фильтры для чистого вида */
    width: 100%;
    height: 100%;
}

/* Скрываем фон в режиме строгой сетки */
body.strict-grid-mode .gallery-item .gallery-image-bg {
    display: none;
}

/* Отключаем увеличение изображения при наведении в режиме строгой сетки */
body.strict-grid-mode .gallery-item:hover .gallery-image {
    transform: scale(1);
    filter: none; /* Убедимся, что фильтр не применяется при наведении */
}

/* Убираем градиентный фон при наведении в режиме сетки */
body.strict-grid-mode .gallery-item::before {
    display: none;
}

/* Упрощаем эффект наведения в режиме сетки - только легкое поднятие */
body.strict-grid-mode .gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    border: none;
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9)); /* Увеличиваем непрозрачность */
    padding: 1.5rem;
    transform: translateY(100%);
    transition: var(--transition-smooth);
    z-index: 2;
    /* Адаптивность для элементов с разными пропорциями */
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    /* Плавное изменение размеров */
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                transform 0.3s ease;
    /* Добавляем размытие фона для лучшей читаемости */
    backdrop-filter: blur(4px);
}

.gallery-item:hover .gallery-overlay {
    transform: translateY(0);
}

.overlay-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin-bottom: 0.3rem;
    /* Адаптивность для элементов с разными пропорциями */
    line-height: 1.2;
    word-wrap: break-word;
    /* Плавное изменение размеров */
    transition: all 0.3s ease;
}

.overlay-number {
    font-size: 0.8rem;
    color: var(--accent-gold);
    letter-spacing: 0.1em;
    /* Адаптивность для элементов с разными пропорциями */
    line-height: 1.2;
    /* Плавное изменение размеров */
    transition: all 0.3s ease;
}

/* Loading Indicator */
.loading-indicator {
    opacity: 0;
    transition: opacity 0.3s ease;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 500;
    pointer-events: none;
}

.loading-indicator.visible {
    opacity: 1;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(212, 175, 55, 0.2);
    border-top: 2px solid var(--accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.image-modal.active {
    display: flex;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.95) 100%);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
}

.modal-content {
    position: relative;
    width: 95vw;
    max-width: 1400px;
    height: 90vh;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.98) 0%, rgba(15, 15, 15, 0.98) 100%);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 20px;
    overflow: hidden;
    animation: modalSlideIn 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 100px rgba(212, 175, 55, 0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Скрытие инфо-панели */
.modal-content.info-hidden .modal-info {
    transform: translateX(100%); /* Сдвигаем панель за пределы экрана */
    opacity: 0;
    pointer-events: none;
    /* Коллапсируем панель, чтобы контейнер с изображением мог занять всё место */
    width: 0;
    min-width: 0;
    padding: 0;
    border: none;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(30px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Левая часть - изображение */
.modal-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.02) 0%, transparent 70%);
    padding: 1rem; /* Уменьшаем отступы, чтобы изображение было больше */
    position: relative;
    overflow: hidden;
}

/* Убеждаемся, что прогресс-бар корректно позиционируется */
.modal-image-container .loading-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 10;
}

/* Индикатор "Просмотрено" в модальном окне */
.modal-viewed-indicator {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    background: rgba(15, 15, 15, 0.7);
    backdrop-filter: blur(10px);
    color: var(--secondary-color);
    padding: 0.4rem 0.8rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 15;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-viewed-indicator.visible {
    opacity: 1;
}

.modal-image {
    display: block; /* Улучшает поведение изображения внутри flex-контейнера */
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease-out;
    cursor: zoom-in;
}

.modal-image-container.zoomed .modal-image {
    /* Убираем ограничения, чтобы показать в натуральную величину */
    max-width: none;
    max-height: none;
    cursor: grab;
}

.modal-image-container.zoomed {
    overflow: auto; /* Включаем скролл для панорамирования */
    cursor: grab; /* Курсор для перетаскивания */
    align-items: flex-start; /* Выравниваем по верху для корректного скролла */
    justify-content: flex-start; /* Выравниваем по левому краю для корректного скролла */
    position: relative;
    touch-action: none; /* Отключаем стандартные жесты на мобильных, чтобы работал наш pan */
    /* Скрываем полосы прокрутки, так как у нас есть панорамирование и масштабирование */
    -ms-overflow-style: none;  /* IE и Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Скрываем полосы прокрутки для Webkit-браузеров (Chrome, Safari) */
.modal-image-container.zoomed::-webkit-scrollbar {
    display: none;
}

/* Новая панель инструментов */
.modal-toolbar {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(15, 15, 15, 0.7);
    backdrop-filter: blur(10px);
    padding: 0.5rem;
    border-radius: 2rem;
    border: 1px solid rgba(212, 175, 55, 0.2);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease-out;
    z-index: 15;
}

/* Сдвигаем панель, когда информация скрыта, чтобы не перекрывалась кнопкой закрытия */
.modal-content.info-hidden .modal-toolbar {
    right: 5rem;
    transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease-out, transform 0.3s ease-out;
}

.toolbar-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--secondary-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.toolbar-btn svg {
    pointer-events: none; /* Предотвращаем перехват событий иконкой, чтобы клик всегда был на кнопке */
}

/* Стили для иконки избранного в модальном окне */
.favorites-icon-modal {
    transition: all 0.3s ease-out;
}

.toolbar-btn.favorite-active .favorites-icon-modal {
    fill: var(--accent-gold);
    stroke: var(--accent-gold);
}

.toolbar-btn.favorite-active {
    color: var(--accent-gold);
    background: rgba(212, 175, 55, 0.2);
}

.toolbar-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    color: var(--accent-gold);
}

.lang-btn {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1rem; /* Сделаем текст чуть крупнее для лучшей читаемости */
    letter-spacing: 0.05em;
}

.toolbar-counter {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: var(--secondary-color);
    background: rgba(0, 0, 0, 0.3);
    padding: 0.3rem 0.8rem;
    border-radius: 1rem;
    margin: 0 0.5rem;
    display: none; /* Скрываем по умолчанию, чтобы не занимать место */
    transition: all 0.3s ease;
}

/* Навигационные стрелки */
.modal-nav.sub-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%) scale(0.9);
    width: 50px;
    height: 50px;
    background: rgba(15, 15, 15, 0.7);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    opacity: 0;
    z-index: 15;
}

.modal-image-container:hover .modal-nav.sub-nav,
.modal-image-container:hover .modal-toolbar {
    opacity: 1;
    transform: translateY(-50%) scale(1); /* для стрелок */
}

.modal-image-container:hover .modal-toolbar {
    transform: translateY(0); /* для тулбара */
}

.modal-nav.sub-nav[style*="display: none"] {
    /* Предотвращаем мерцание при скрытии */
    pointer-events: none;
}

.modal-nav.sub-nav:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: var(--accent-gold);
}

.modal-nav.sub-nav.prev {
    left: 2rem;
}

.modal-nav.sub-nav.next {
    right: 2rem;
}

.modal-nav.sub-nav::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid var(--secondary-color);
    border-bottom: none;
    border-right: none;
}

.modal-nav.sub-nav.prev::before {
    transform: rotate(-45deg) translateX(3px);
}

.modal-nav.sub-nav.next::before {
    transform: rotate(135deg) translateX(-3px);
}

/* Внешние кнопки навигации */
.modal-nav-external {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(15, 15, 15, 0.3);
    border: 1px solid rgba(212, 175, 55, 0.1);
    backdrop-filter: blur(5px);
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001; /* Выше модального окна */
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Скрываем внешние кнопки навигации на мобильных устройствах */
@media (max-width: 768px) {
    .modal-nav-external {
        display: none !important;
    }
}

.modal-nav-external:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: var(--accent-gold);
    transform: translateY(-50%) scale(1.1);
}

.modal-nav-external.prev { left: 2vw; }
.modal-nav-external.next { right: 2vw; }

.modal-nav-external::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 3px solid var(--secondary-color);
    border-bottom: none;
    border-right: none;
    opacity: 0.8;
}

.modal-nav-external.prev::before { transform: rotate(-45deg) translateX(4px); }
.modal-nav-external.next::before { transform: rotate(135deg) translateX(-4px); }

/* Правая часть - информация */
.modal-info {
    width: 420px;
    padding: 3rem;
    overflow-y: auto;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.5) 100%);
    border-left: 1px solid rgba(212, 175, 55, 0.2);
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Кастомная полоса прокрутки для информационной панели */
.modal-info::-webkit-scrollbar {
    width: 6px;
}

.modal-info::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.modal-info::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
    transition: background 0.3s ease;
}

.modal-info::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.5);
}

/* Firefox */
.modal-info {
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.3) rgba(0, 0, 0, 0.2);
}

/* Кнопка закрытия */
.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--secondary-color);
    font-size: 1.5rem;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--accent-gold);
    color: var(--primary-color);
    transform: rotate(90deg);
}

/* Заголовок и автор */
.modal-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.modal-title-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-light);
    margin-top: -0.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.8;
    display: none; /* Скрываем по умолчанию, показываем через JS */
    transition: opacity 0.3s ease-out;
}

.modal-author {
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    font-weight: 300;
    color: var(--accent-gold);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* Детали произведения */
.modal-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.detail-section {
    /* Убрали фон для более чистого вида */
}

.detail-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent-bronze);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.5rem;
}

.detail-content {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: var(--secondary-color);
    line-height: 1.6;
}

/* Стили для кликабельных тегов поиска */
.search-tag {
    display: inline-block;
    background: rgba(212, 175, 55, 0.1);
    color: var(--accent-gold);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-size: 0.95rem; /* Соответствует размеру шрифта .detail-content */
}

.search-tag:hover, .search-tag:focus {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--accent-gold);
    color: var(--secondary-color);
    outline: none;
}

.modal-author > .search-tag {
    font-size: 1.1rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: 0;
    background: transparent;
    border-radius: 0;
    border-bottom: 1px dashed rgba(212, 175, 55, 0.5);
}

.modal-author > .search-tag:hover, .modal-author > .search-tag:focus {
    background: transparent;
    color: var(--secondary-color);
    border-bottom-style: solid;
    border-bottom-color: var(--accent-gold);
}

/* Визуальное описание */
.modal-description {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    color: rgba(248, 248, 248, 0.9);
    line-height: 1.8;
    padding-left: 1rem;
    border-left: 2px solid var(--accent-gold);
    opacity: 0.8;
}

.detail-content#modalStyle {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* Кураторский комментарий */
.curator-comment {
    font-style: italic;
    position: relative;
    padding-left: 1rem;
}

.curator-comment::before {
    content: '"';
    position: absolute;
    left: -5px;
    top: -10px;
    font-size: 3rem;
    color: var(--accent-gold);
    opacity: 0.3;
    font-family: 'Playfair Display', serif;
}

/* Анимация уведомления */
@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    85% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* Подсказка о свайпах для мобильных устройств */
.swipe-hint {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 15, 0.9);
    backdrop-filter: blur(15px);
    color: var(--secondary-color);
    padding: 1rem 1.5rem;
    border-radius: 2rem;
    border: 1px solid rgba(212, 175, 55, 0.3);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1002;
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    transition: all 0.4s ease-out;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.swipe-hint.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.swipe-hint .swipe-icon {
    width: 20px;
    height: 20px;
    color: var(--accent-gold);
}

.swipe-hint .swipe-text {
    white-space: nowrap;
}

/* Адаптивность для подсказки */
@media (max-width: 480px) {
    .swipe-hint {
        bottom: 1.5rem;
        padding: 0.8rem 1.2rem;
        font-size: 0.8rem;
    }
    
    .swipe-hint .swipe-icon {
        width: 18px;
        height: 18px;
    }
}

/* Secret Mode Theme */
body.secret-mode-active {
    background: linear-gradient(135deg, #2c0b0e 0%, #1a0000 50%, #2c0b0e 100%);
    /* Меняем основной акцентный цвет на зловещий красный */
    --accent-gold: #c7374e;
    --accent-bronze: #a12f40;
    --border-classic: 1px solid rgba(199, 55, 78, 0.3);
}

body.secret-mode-active .loading-title span:nth-child(1),
body.secret-mode-active .loading-title span:nth-child(10) {
    color: var(--accent-gold);
}

body.secret-mode-active .search-container {
    background: rgba(44, 11, 14, 0.8);
}

body.secret-mode-active .search-suggestions {
    background: rgba(44, 11, 14, 0.98);
}

body.secret-mode-active .suggestion-item:hover {
    background-color: rgba(199, 55, 78, 0.1);
}

body.secret-mode-active .gallery-item:hover {
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--accent-gold);
}

body.secret-mode-active .gallery-item::before {
    background: linear-gradient(135deg, rgba(199, 55, 78, 0.1) 0%, transparent 50%, rgba(161, 47, 64, 0.1) 100%);
}

body.secret-mode-active .spinner {
    border-top-color: var(--accent-gold);
}

body.secret-mode-active .modal-backdrop {
    background: linear-gradient(to bottom, rgba(26, 0, 0, 0.9) 0%, rgba(44, 11, 14, 0.95) 100%);
}

body.secret-mode-active .modal-content {
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 100px rgba(199, 55, 78, 0.1);
}

body.secret-mode-active .modal-description {
    border-left-color: var(--accent-gold);
}

body.secret-mode-active .curator-comment::before {
    color: var(--accent-gold);
}


/* Responsive Design */
@media (max-width: 1200px) {
    .modal-info {
        width: 350px;
        padding: 2rem;
    }
    
    .modal-title {
        font-size: 1.8rem;
    }
}

/* Исправление экрана загрузки для мобильных устройств */
@media (max-width: 768px) {
    .loading-screen {
        padding: 2rem;
    }
    
    .loading-title {
        font-size: 2rem;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
    }
    
    .loading-title .space {
        width: 0.5rem;
    }
}

@media (max-width: 480px) {
    .loading-screen {
        padding: 1rem;
    }
    
    .loading-title {
        font-size: 1.5rem;
        flex-wrap: wrap;
        justify-content: center;
        text-align: center;
        gap: 0.2rem;
    }
    
    .loading-title .space {
        width: 0.3rem;
    }
}

@media (max-width: 968px) {
    .modal-content {
        flex-direction: column;
        height: 95vh;
        width: 95vw;
    }
    
    .modal-image-container {
        height: 50%;
        padding: 1.5rem;
    }
    
    .modal-info {
        width: 100%;
        height: 50%;
        padding: 2rem;
        border-left: none;
        overflow-y: auto; /* Включаем скролл информации на мобильных */
        border-top: 1px solid rgba(212, 175, 55, 0.2);
    }
    
    .modal-nav {
        width: 40px;
        height: 40px;
    }
    
    /* Исправление для скрытия инфо-панели на мобильных */
    .modal-content.info-hidden .modal-info {
        transform: translateY(100%); /* Сдвигаем вниз, а не вбок */
        width: 100%; /* Сбрасываем изменение ширины с десктопа */
        min-width: 100%;
        height: 0;
        min-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-top: none;
        overflow: hidden;
    }
    .modal-content.info-hidden .modal-image-container {
        height: 100%; /* Контейнер с изображением занимает всю высоту */
    }
}
@media (max-width: 768px) {
    .search-container {
        width: 90vw;
        top: 1rem;
    }
    .search-input {
        width: 100%;
        flex: 1;
    }
    .search-input:focus {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .modal-content {
        border-radius: 12px;
        width: 100vw;
        height: 100dvh; /* Используем динамическую высоту */
    }
    
    .modal-image-container {
        height: 45%;
        padding: 1rem;
    }
    
    .modal-info {
        height: 55%;
        padding: 1.5rem;
    }
    
    .modal-header {
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
    
    .modal-title {
        font-size: 1.6rem;
    }
    
    .modal-author {
        font-size: 0.95rem;
    }
    
    .modal-details {
        gap: 1rem;
    }
    
    .detail-section {
        gap: 1.5rem;
    }
    
    .detail-content {
        font-size: 0.9rem;
    }
    
    .modal-description {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }
    
    .modal-close {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        top: 1rem;
        right: 1rem;
    }
    
    .modal-nav.sub-nav {
        display: none; /* Скрываем стрелки на мобильных, используем свайпы */
    }

    /* Улучшения для индикатора загрузки на мобильных */
    .loading-progress {
        height: 4px; /* Сделаем полоску чуть толще */
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
        position: absolute;
        top: 0;
        z-index: 10;
    }

    .progress-fill {
        width: 0% !important;
        height: 100% !important;
        border-radius: 0;
        transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .progress-fill::after {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
        animation: shimmer 1.5s infinite;
    }


    /* Делаем панель инструментов всегда видимой на мобильных устройствах */
    .modal-toolbar {
        opacity: 1;
        transform: none; /* Сбрасываем анимацию появления */
        bottom: 1.5rem; /* Перемещаем вниз для удобства */
        top: auto;
        left: 50%;
        transform: translateX(-50%);
        width: max-content; /* Ширина по содержимому */
        background: rgba(15, 15, 15, 0.85);
        backdrop-filter: blur(12px);
        padding: 0.6rem 1rem;
    }

    /* Отключаем эффект наведения, который остался от десктопных стилей */
    .modal-image-container:hover .modal-toolbar {
        transform: translateX(-50%);
    }
    
    /* Улучшения для прогресс-бара на мобильных */
    .modal-image-container .loading-progress {
        height: 4px;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
    }
    
    .modal-image-container .progress-fill {
        height: 100% !important;
        border-radius: 0;
        transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@media (max-width: 480px) {
    .loading-title {
        font-size: 1.8rem;
    }
    
    .modal-content {
        animation: modalSlideInMobile 0.4s ease-out;
    }
    
    @keyframes modalSlideInMobile {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    .modal-image-container {
        height: 40%;
        padding: 0.5rem;
    }
    
    .modal-info {
        height: 60%;
        padding: 1rem;
        padding-bottom: 2rem;
    }
    
    .modal-header {
        margin-bottom: 1rem;
        padding-bottom: 0.8rem;
    }
    
    .modal-title {
        font-size: 1.4rem;
    }
    
    .modal-author {
        font-size: 0.85rem;
    }
    
    .modal-description {
        font-size: 0.9rem;
        margin-bottom: 0.8rem;
        line-height: 1.6;
    }
    
    .detail-label {
        font-size: 0.75rem;
        margin-bottom: 0.3rem;
    }
    
    .detail-content {
        font-size: 0.85rem;
        line-height: 1.5;
    }
    
    .curator-comment::before {
        font-size: 2rem;
        top: -5px;
    }
    
    /* Улучшения для прогресс-бара на очень маленьких экранах */
    .modal-image-container .loading-progress {
        height: 3px;
        width: 100% !important;
        left: 0 !important;
        right: 0 !important;
        border-radius: 0;
    }
    
    .modal-image-container .progress-fill {
        height: 100% !important;
        border-radius: 0;
        transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

@media (max-width: 380px) {
    .modal-title {
        font-size: 1.2rem;
    }
    
    .modal-description {
        font-size: 0.85rem;
    }
    
    .detail-content {
        font-size: 0.8rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus states for keyboard navigation */
.gallery-item:focus,
.modal-close:focus {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Оптимизация для устройств с высоким DPI */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .gallery-image {
        /* Улучшенное качество изображений на устройствах с высоким DPI */
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
    
    .gallery-item {
        /* Улучшенное качество границ на устройствах с высоким DPI */
        border-width: 0.5px;
    }
}

/* Оптимизация для устройств с низким DPI */
@media (-webkit-max-device-pixel-ratio: 1), (max-resolution: 96dpi) {
    .gallery-image {
        /* Упрощенное рендеринг для устройств с низким DPI */
        image-rendering: auto;
    }
}

/* Поддержка устройств с ограниченными возможностями */
@media (prefers-reduced-motion: reduce) {
    .gallery-item {
        /* Отключаем анимации для пользователей с ограниченными возможностями */
        animation: none;
        transition: opacity 0.1s ease;
    }
    
    .gallery-image {
        /* Упрощенные переходы для экономии ресурсов */
        transition: opacity 0.1s ease;
    }
    
    .gallery-overlay {
        /* Упрощенные переходы для экономии ресурсов */
        transition: opacity 0.1s ease;
    }
}

/* Поддержка устройств с ограниченными ресурсами */
@media (max-width: 320px) {
    .gallery-item {
        /* Минимальные размеры для очень старых устройств */
        min-width: 150px;
        min-height: 150px;
        max-width: 250px;
        max-height: 250px;
        /* Отключаем сложные эффекты */
        backdrop-filter: none;
        box-shadow: none;
    }
    
    .gallery-image {
        /* Упрощенное отображение */
        filter: none;
    }
}

/* Индикатор прогресса загрузки */
.loading-progress {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 3px; /* Тонкая полоска */
    z-index: 10;
    overflow: hidden;
    background-color: rgba(212, 175, 55, 0.2); /* Фон для трека */
    transition: opacity 0.5s ease-out;
    opacity: 1;
    border-radius: 0;
    box-sizing: border-box;
}

.loading-progress.hiding {
    opacity: 0;
}

.loading-progress .progress-fill {
    height: 100%;
    background: var(--accent-gold);
    transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
    box-shadow: 0 0 8px var(--accent-gold);
    position: relative;
    overflow: hidden;
    border-radius: 0;
}

@keyframes progressSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) translateY(0);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 480px) {
    .loading-progress {
        width: 100% !important;
        min-width: auto;
        max-width: none;
        padding: 0;
        height: 4px;
        left: 0 !important;
        right: 0 !important;
        position: absolute;
        top: 0;
        z-index: 10;
    }
    
    .progress-fill {
        width: 0% !important;
        height: 100% !important;
        border-radius: 0;
        transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* Подсказки для кнопок */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    z-index: 10001;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}

/* Базовые стили для кнопок в модальном окне */
.modal-toolbar button {
    position: relative;
    cursor: pointer;
    z-index: 1;
}

.tooltip.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .tooltip {
        font-size: 0.75rem;
        padding: 0.4rem 0.6rem;
        max-width: 120px;
        white-space: normal;
        text-align: center;
    }
    
    .tooltip::after {
        border-width: 4px;
    }
}

/* Улучшения для увеличенного изображения */
.modal-image-container.zoomed:active {
    cursor: grabbing;
}

.modal-image-container.zoomed img {
    transition: transform 0.1s ease-out;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.modal-image-container.zoomed img:active {
    cursor: grabbing;
}

/* Убираем курсор-лупу для обычного изображения */
.modal-image-container:not(.zoomed) img {
    cursor: default !important;
}

.modal-image-container:not(.zoomed) {
    cursor: default !important;
}

/* Дополнительная защита от нежелательных курсоров */
.modal-image-container img {
    cursor: default !important;
}

.modal-image-container.zoomed img {
    cursor: grab !important;
}

.modal-image-container.zoomed img:active {
    cursor: grabbing !important;
}

/* Анимация для плавного перехода в режим зума */
.modal-image-container img {
    transition: width 0.3s ease-out, height 0.3s ease-out;
}

/* Улучшенные курсоры для разных состояний */
.modal-image-container.zoomed .zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
}

.zoom-controls button {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.zoom-controls button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.zoom-controls button:active {
    transform: scale(0.95);
}

/* Индикатор масштаба */
.zoom-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.zoom-indicator.visible {
    opacity: 1;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .zoom-indicator {
        top: 10px;
        right: 10px;
        padding: 0.4rem 0.8rem;
        font-size: 0.75rem;
    }
    
    .zoom-controls button {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
    
    .modal-image-container.zoomed {
    }
}

/* Дополнительные улучшения для очень маленьких экранов */
@media (max-width: 480px) {
    .zoom-controls button {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }
    
    .tooltip {
        max-width: 100px;
        font-size: 0.7rem;
        padding: 0.3rem 0.5rem;
    }
}

/* Индикатор прогресса загрузки */
.loading-progress-indicator {
    position: relative;
    z-index: 100;
    margin-top: 2rem;
    text-align: center;
    opacity: 1; /* Показываем прогресс-бар сразу */
    transition: opacity 0.5s ease-out; /* Для плавности */
}

.progress-bar {
    width: 300px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
    border: 1px solid rgba(212, 175, 55, 0.3);
    position: relative;
}

.loading-progress-indicator .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), var(--accent-bronze));
    width: 0%;
    transition: width 0.2s ease-out;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

/* Адаптивность для индикатора прогресса */
@media (max-width: 768px) {
    .progress-bar {
        width: 250px;
    }
}

@media (max-width: 480px) {
    .progress-bar {
        width: 200px;
    }
}

/* Stats Mode Theme */
body.stats-mode-active {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: #ffffff;
    --accent-gold: #00d4ff;
    --accent-bronze: #0099cc;
    --border-classic: 1px solid rgba(0, 212, 255, 0.3);
    --primary-color: rgba(255, 255, 255, 0.1);
    --secondary-color: #ffffff;
    --text-light: rgba(255, 255, 255, 0.7);
}

/* Разрешаем скролл в режиме статистики */
body.stats-mode-active,
body.stats-mode-active .gallery-container,
body.stats-mode-active .gallery-viewport {
    overflow: visible !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

body.stats-mode-active .search-container {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
}

body.stats-mode-active .search-input,
body.stats-mode-active .search-icon,
body.stats-mode-active .clear-search-button,
body.stats-mode-active .favorites-button,
body.stats-mode-active .layout-toggle-button {
    color: var(--secondary-color);
}

body.stats-mode-active .search-input::placeholder {
    color: var(--text-light);
}

body.stats-mode-active .favorites-button:hover,
body.stats-mode-active .layout-toggle-button:hover {
    color: var(--accent-gold);
    background: rgba(0, 119, 204, 0.1);
}

/* Hide gallery items in stats mode */
body.stats-mode-active .gallery-item {
    display: none;
}

/* Style for the stats grid layout */
.gallery-grid.stats-layout {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 2rem;
    padding: 8rem 2rem 2rem; /* Padding to clear search bar */
    width: 100%;
    height: auto;
    position: static; /* Override absolute positioning */
    transform: none !important; /* Override pan/zoom transform */
    align-items: flex-start;
}

/* Старая галерея статистики (удалить или переименовать) */
/*.gallery-grid.stats-gallery-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    padding: 8rem 2rem 2rem;
    width: 100%;
    height: auto;
    position: static;
    transform: none !important;
}*/

.stats-column {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.stats-column-left {
    flex: 1 1 400px;
    max-width: 500px;
}

.stats-column-right {
    flex: 2 1 600px;
}

.stats-artworks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

body.stats-mode-active .gallery-item {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 3 / 4;
    transform: none !important;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 212, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
}

.stats-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 10px;
    padding: 0.8rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    cursor: pointer;
    min-height: 100px;
}

body.stats-mode-active .gallery-item:hover {
    transform: translateY(-5px) scale(1.03) !important;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--accent-gold) !important;
    border-color: var(--accent-gold) !important;
    z-index: 10;
}

.stats-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(0, 212, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

body.stats-mode-active .gallery-item .gallery-image {
    object-fit: cover;
}

.stats-content {
    color: #ffffff;
}

.stats-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: var(--accent-gold);
    margin-bottom: 0.8rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
    display: flex;
    justify-content: space-between;
}

.stats-body {
    font-size: 0.9rem;
}

.stats-title-item {
    grid-column: 1 / -1;
    text-align: center;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: default;
}

.stats-title-item:hover {
    background: transparent;
    transform: none;
    box-shadow: none;
}

.stats-section-title h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    color: var(--accent-gold);
    margin: 0;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}


/* Счетчик избранного на картинах */
.stats-favorite-count {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 212, 255, 0.9);
    color: #ffffff;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

.stats-favorite-count svg {
    width: 16px;
    height: 16px;
    fill: #ffffff;
}

.stat-block {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 212, 255, 0.2);
    border-radius: 16px;
    padding: 1.5rem 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.stat-block.large {
    flex-basis: 500px;
}

.stat-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.8rem;
    color: var(--accent-gold);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid rgba(0, 119, 204, 0.1);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: var(--text-light);
}

.stat-value {
    font-weight: 600;
    font-size: 1rem;
    color: var(--secondary-color);
}

.stat-error {
    color: #c7374e;
    font-size: 1.2rem;
    padding: 1rem;
}

/* Popular list styles */
.stat-block .popular-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-block .popular-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-radius: 12px;
    transition: background-color 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.popular-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.stat-block .popular-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.popular-thumbnail {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border-classic);
    background-color: #eee;
}
.stat-block .popular-info {
.popular-info {
    flex-grow: 1;
    min-width: 0; /* Fix for flexbox text overflow */
}

.popular-title {
    font-weight: 500;
    color: var(--secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-block .popular-info small {
    color: var(--text-light);
    margin-left: 0.5rem;
}

.popular-author {
    font-size: 0.9rem;
    color: var(--text-light);
}

.popular-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.stat-block .popular-count {
    font-weight: 600;
    color: var(--accent-gold);
    background: rgba(0, 212, 255, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.9rem;
}
.popular-count svg {
    fill: currentColor;
}

@media (max-width: 768px) {
    .gallery-grid.stats-layout {
        padding-top: 6rem;
        flex-direction: column;
        align-items: stretch;
    }
    .stats-column-left, .stats-column-right {
        max-width: 100%;
        flex-basis: auto;
    }
    .stats-artworks-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    .stat-title {
        font-size: 1.5rem;
    }
    .stat-block {
        padding: 1rem 1.5rem;
    }
}

.stats-favorite-count svg {
    width: 16px !important;
    height: 16px !important;
    fill: currentColor !important;
}

/* Стили для круговой диаграммы времени */
.time-chart {
    width: 120px;
    height: 120px;
    margin: 1rem auto;
    position: relative;
}

.time-chart svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.time-chart .time-segment {
    transition: all 0.3s ease;
}

.time-chart .time-segment:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.time-chart .time-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.time-chart .time-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

/* Tooltip for stats */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-gold);
    font-weight: bold;
    cursor: help;
    user-select: none;
    transition: background-color 0.2s ease;
}

.tooltip-trigger:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tooltip-container .tooltip {
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%);
    visibility: hidden;
}

.tooltip-container:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* Стили для популярных картин */
.popular-stats {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem; /* Немного увеличим отступ */
    margin-top: 8px;
}

.stat-favorites, .stat-views {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--secondary-color);
    backdrop-filter: blur(5px);
    cursor: default; /* Убираем курсор-указатель */
    transition: all 0.3s ease; /* Добавляем плавный переход */
}

.stat-favorites svg, .stat-views svg {
    width: 14px;
    height: 14px;
    opacity: 0.8;
}

/* --- НОВЫЕ СТИЛИ ДЛЯ РЕЖИМА "ПОПУЛЯРНОЕ" --- */

/* 1. Показываем кнопки сортировки в режиме "Популярное" */
body.popular-mode-active .popular-sort-options {
    display: flex;
}

/* 2. Делаем оверлей с информацией видимым по умолчанию */
body.popular-mode-active .gallery-item .gallery-overlay {
    transform: translateY(0);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0.7) 50%, transparent 100%);
}

/* 3. Делаем видимой кнопку "избранное" по умолчанию */
body.popular-mode-active .gallery-item .favorite-button {
    opacity: 1;
}

/* 4. Убираем эффект увеличения при наведении, так как информация уже видна */
body.popular-mode-active .gallery-item {
    cursor: pointer;
}

body.popular-mode-active .gallery-item:hover {
    transform: translateY(-5px) scale(1.02); /* Оставляем небольшой эффект */
    box-shadow: 0 12px 24px rgba(0,0,0,0.2), 0 0 0 1px var(--accent-gold);
    border-color: var(--accent-gold);
}

/* 5. Убираем лишний hover-эффект для оверлея */
body.popular-mode-active .gallery-item:hover .gallery-overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.75) 50%, transparent 100%);
}

@media (max-width: 768px) {
    .popular-stats {
        flex-direction: column;
        gap: 4px;
    }
}

@media (max-width: 480px) {
    .popular-button {
        width: 40px;
        height: 40px;
    }
    
    .popular-stats {
        font-size: 0.7rem;
    }
    
    .stat-favorites, .stat-views {
        padding: 1px 4px;
    }
}
