/* Неоклассический абстракционизм - 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; /* Используем динамическую высоту для мобильных устройств */
}

/* 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;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
}

.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;
}

.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);
}

/* 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);
}

/* 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.9) translateY(30px);
    }
    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: 8px;
    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 4px 16px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
    /* Базовый z-index для предотвращения наложений */
    z-index: 1;
    /* Улучшенные границы */
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.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:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--accent-gold);
    border-color: var(--accent-gold);
    /* При наведении поднимаем элемент выше остальных */
    z-index: 10;
}

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

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition-smooth);
    filter: grayscale(0.2) contrast(1.1);
    /* Обеспечиваем правильное отображение изображений с любыми пропорциями */
    object-position: center;
    /* Плавное изменение размеров */
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), 
                filter 0.3s ease;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05);
    filter: grayscale(0) contrast(1.2);
}

.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    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;
}

.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); }
}

/* 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 {
    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: opacity 0.3s ease-out, 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; /* Позволяет панорамировать увеличенное изображение */
}

/* Новая панель инструментов */
.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;
}

.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: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 {
    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,
.modal-image-container:hover .modal-toolbar {
    opacity: 1;
    transform: translateY(-50%) scale(1); /* для стрелок */
}

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

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

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

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

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

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

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

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

/* Правая часть - информация */
.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-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;
}

/* Визуальное описание */
.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;
}

/* Кураторский комментарий */
.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);
    }
}

/* 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: 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 {
        display: none; /* Скрываем стрелки на мобильных, используем свайпы */
    }

    /* Делаем панель инструментов всегда видимой на мобильных устройствах */
    .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%);
    }
}

@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;
    }
}

@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;
    }
}
