/* UNLOCK CORE */
html, body { overflow: visible !important; height: auto !important; position: relative !important; }
:root { 
    --ios-bg: #f2f2f7; 
    --glass: rgba(255, 255, 255, 0.92); 
    --accent: #007aff; 
    --text-main: #000; 
    --text-gray: #6e6e73; 
    --red: #ff3b30; 
}

/* ГЛОБАЛЬНЫЙ СБРОС И ЗАЩИТА ОТ СКРОЛЛА ПО ГОРИЗОНТАЛИ */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overflow-x: hidden; width: 100%; }
a, a:hover, a:visited, a:active { text-decoration: none !important; color: inherit !important; }

body { 
    font-family: -apple-system, system-ui, sans-serif; 
    background: var(--ios-bg); margin: 0; 
    padding-top: calc(85px + env(safe-area-inset-top));
    padding-bottom: calc(95px + env(safe-area-inset-bottom));
    padding-left: 8px; padding-right: 8px;
    color: var(--text-main); -webkit-font-smoothing: antialiased;
}

/* ФОН ДО КРАЕВ (Без скруглений, 100% ширина экрана) */
.floating-island {
    position: fixed; left: 0; right: 0; width: 100%; margin: 0; max-width: 100%;
    background: var(--glass);
    backdrop-filter: blur(30px) saturate(210%); -webkit-backdrop-filter: blur(30px) saturate(210%); 
    z-index: 9999;
    border-radius: 0; /* Прямые углы для прилегания к краям */
    border-top: 1px solid rgba(0,0,0,0.1); border-bottom: 1px solid rgba(0,0,0,0.1);
}

/* Внутренний контент остается на своем месте за счет padding */
header { 
    top: 0; 
    padding-top: env(safe-area-inset-top); 
    height: calc(75px + env(safe-area-inset-top)); 
    display: flex; align-items: center; 
}
footer { 
    bottom: 0; 
    padding-bottom: env(safe-area-inset-bottom); 
    height: calc(75px + env(safe-area-inset-bottom)); 
    display: flex; justify-content: space-around; align-items: center; 
}

@media (min-width: 768px) { 
    footer { 
        max-width: 500px; margin: 0 auto; left: 0; right: 0;
        border-radius: 20px 20px 0 0; /* На ПК оставляем как "док" снизу */
        border-left: 1px solid rgba(0,0,0,0.1); border-right: 1px solid rgba(0,0,0,0.1);
    } 
    header { padding-left: 16px; padding-right: 16px; }
}

.header-container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 12px; display: flex; align-items: center; gap: 12px; }
.logo-img { height: 50px; width: auto; object-fit: contain; }

.search-form { flex-grow: 1; position: relative; height: 42px; }
.search-form input { width: 100%; height: 100%; border-radius: 12px; background: rgba(0, 0, 0, 0.05); border: none; padding-left: 36px; font-size: 16px; outline: none; }
.search-icon { position: absolute; left: 12px; top: 13px; color: var(--text-gray); width: 18px; height: 18px; }

/* СЕТКА ТОВАРОВ */
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 1120px; margin: 0 auto; }
@media (min-width: 768px) { .product-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; } }
@media (min-width: 1200px) { .product-grid { grid-template-columns: repeat(6, 1fr); gap: 16px; } }

.product-card { background: #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,0.04); position: relative; cursor: pointer; }
.img-wrap { width: 100%; aspect-ratio: 1/1; background: #eee; }
.img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.card-info { padding: 8px; }
.p-price { font-size: 12px; font-weight: 800; color: var(--accent); margin: 0 0 2px; }
.p-title { font-size: 10px; color: #333; margin: 0; height: 26px; overflow: hidden; line-height: 1.2; }

.fav-btn { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; background: rgba(255,255,255,0.9); border-radius: 50%; display: flex; align-items: center; justify-content: center; z-index: 10; border: none; cursor: pointer; }
.fav-btn svg { width: 14px; height: 14px; color: var(--text-gray); }
.fav-btn.active svg { fill: var(--red); color: var(--red); stroke: var(--red); }

/* МОДАЛЬНОЕ ОКНО (Строго между шапкой и подвалом) */
.modal { 
    position: fixed !important; 
    top: calc(75px + env(safe-area-inset-top)) !important;
    bottom: calc(75px + env(safe-area-inset-bottom)) !important; 
    left: 8px !important; right: 8px !important; margin: 0 auto !important; max-width: 1120px !important; 
    background: #fff !important; border-radius: 20px 20px 0 0 !important; z-index: 1002 !important;
    display: flex !important; flex-direction: column !important; 
    transform: translateY(150%) !important; transition: 0.4s cubic-bezier(0.2, 1, 0.2, 1) !important; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.15) !important; overflow: visible !important;
}
.modal.active { transform: translateY(0) !important; }
.modal-header { padding: 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #f2f2f7; flex-shrink: 0; background: #fff; }
.modal-body { flex: 1; overflow-y: auto; padding: 15px; -webkit-overflow-scrolling: touch; }
.cart-footer { padding: 15px; border-top: 1px solid #f2f2f7; background: #fff; flex-shrink: 0; }

.sheet-img-big { width: 100%; height: 220px; object-fit: cover; border-radius: 12px; margin-bottom: 10px; background: #eee; }
.back-btn { background: rgba(0,0,0,0.05); border: none; font-size: 14px; color: var(--accent); padding: 8px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.modal-title { font-size: 16px; font-weight: 700; position: absolute; left: 50%; transform: translateX(-50%); margin: 0; }

.list-item { background: #fff; padding: 10px; border-radius: 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; border: 1px solid #f2f2f7; }
.cart-item-img { width: 50px; height: 50px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.list-item-info { flex: 1; min-width: 0; overflow: hidden; }
.list-item-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.cart-controls { background: #f2f2f7; border-radius: 8px; display: inline-flex; align-items: center; padding: 2px; gap: 4px; }
.cart-controls button { background: #fff; border: none; width: 28px; height: 28px; border-radius: 6px; font-size: 18px; color: var(--accent); font-weight: bold; cursor: pointer; }

/* ФОРМА И ДАТЫ */
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 10px; width: 100%; }
.input-wrapper { display: flex; flex-direction: column; min-width: 0; }
.input-wrapper label { font-size: 9px; color: var(--text-gray); margin-bottom: 4px; padding-left: 4px; font-weight: bold; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.form-grid input { width: 100%; padding: 10px 8px; border-radius: 10px; border: 1px solid #eee; outline: none; font-size: 13px; background: #fafafa; box-sizing: border-box; min-width: 0; text-align: center; -webkit-appearance: none; }
.form-grid input[type="text"], .form-grid input[type="tel"] { text-align: left; padding: 12px 10px; font-size: 14px; }
.form-grid input:focus { border-color: var(--accent); background: #fff; }

.add-btn { background: var(--accent); color: white; border: none; width: 100%; padding: 14px; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; transition: 0.2s; }
.add-btn:active { transform: scale(0.98); }

/* СОЦСЕТИ */
.social-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.social-btn { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 12px; font-weight: 700; font-size: 15px; color: white !important; }
.bg-wa { background: #25D366; } .bg-tg { background: #2AABEE; } .bg-vk { background: #0077FF; } .bg-phone { background: #34c759; }

.tab { display: flex; flex-direction: column; align-items: center; color: var(--text-gray); width: 20%; position: relative; cursor: pointer; }
.tab svg { width: 22px; height: 22px; margin-bottom: 2px; }
.tab span { font-size: 9px; font-weight: 600; }
.tab.active { color: var(--accent); }

.badge { position: absolute; top: -3px; left: calc(50% + 2px); background: var(--red); color: white; font-size: 10px; font-weight: 900; border-radius: 10px; padding: 0 4px; min-width: 16px; height: 16px; display: none; align-items: center; justify-content: center; border: 1.5px solid #fff; z-index: 10; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); opacity: 0; visibility: hidden; transition: 0.3s; z-index: 1001; }
.overlay.active { opacity: 1; visibility: visible; }

/* БЛОК "НИЧЕГО НЕ НАЙДЕНО" */
.empty-search-state {
    grid-column: 1 / -1; /* Растягиваем на всю ширину сетки */
    background: #fff;
    border-radius: 16px;
    padding: 40px 20px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    margin: 20px auto;
    max-width: 600px;
}
.empty-icon { color: #ccc; margin-bottom: 15px; display: flex; justify-content: center; }
.empty-icon svg { width: 50px; height: 50px; }
.empty-search-state h3 { margin: 0 0 10px; font-size: 19px; color: var(--text-main); font-weight: 800; }
.empty-search-state p { margin: 0 0 25px; font-size: 14px; color: var(--text-gray); line-height: 1.5; }
.tg-btn { 
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; 
    background: #2AABEE; color: #fff !important; text-decoration: none; 
    padding: 14px 24px; border-radius: 12px; font-weight: 700; font-size: 15px; 
}

/* ФИКС: Подвал на ПК в стиле macOS Dock */
@media (min-width: 768px) { 
    footer.floating-island { 
        max-width: 450px !important; /* Аккуратная ширина */
        margin: 0 auto !important; 
        left: 0 !important; 
        right: 0 !important;
        bottom: 24px !important; /* Парит над нижним краем */
        border-radius: 30px !important; /* Круглый со всех сторон, как в Mac */
        border: 1px solid rgba(0,0,0,0.1) !important;
        box-shadow: 0 15px 40px rgba(0,0,0,0.12) !important; /* Мягкая тень для объема */
        padding-bottom: 0 !important; /* Убираем отступы телефона */
        height: 70px !important;
    } 
}

/* --- ПРАВКИ ДЛЯ ПК: СЕТКА НА 5, МАРКЕТПЛЕЙС-СТАЙЛ, ПОДВАЛ ВНИЗУ --- */
@media (min-width: 1200px) { 
    .product-grid { 
        grid-template-columns: repeat(5, 1fr) !important; /* 5 товаров в ряд */
    }
}

@media (min-width: 768px) { 
    .product-grid, .header-container {
        max-width: 1150px !important; /* Сужаем контент, даем много пустого места по бокам */
    }
    
    footer.floating-island { 
        max-width: 1150px !important; /* Подвал ровно по ширине ассортимента */
        width: 100% !important;
        margin: 0 auto !important; 
        left: 0 !important; 
        right: 0 !important;
        bottom: 0 !important; /* Без промежутка снизу */
        border-radius: 24px 24px 0 0 !important; /* Скругление только верхних углов */
        box-shadow: 0 -4px 20px rgba(0,0,0,0.05) !important; /* Мягкая тень сверху */
    } 
}

/* =========================================
   ПРАВКИ ИСКЛЮЧИТЕЛЬНО ДЛЯ ПК (DESKTOP)
========================================= */
@media (min-width: 768px) { 
    /* 1. Скрываем подвал и мобильные иконки на компьютере */
    .mobile-only { display: none !important; } 
    
    /* 2. Настраиваем шапку: расталкиваем элементы по краям */
    .header-container { justify-content: space-between; }
    
    /* 3. Увеличиваем Логотип на 15% (было 50px, стало 58px) */
    .logo-img { height: 58px !important; } 
    
    /* 4. Сокращаем строку поиска в 2 раза и центрируем */
    .search-wrapper { max-width: 45%; flex: 1; margin: 0 auto; } 
    
    /* 5. Показываем меню из подвала в шапке */
    .desktop-menu-wrap { display: flex !important; align-items: center; gap: 24px; }
    .desktop-tab { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-main); font-weight: 600; font-size: 15px; text-decoration: none; position: relative; }
    .desktop-tab svg { width: 22px; height: 22px; color: var(--text-gray); transition: 0.2s; }
    .desktop-tab:hover svg { color: var(--accent); }

    /* 6. МОДАЛЬНОЕ ОКНО ДЛЯ ПК: Аккуратное, по центру, не на всю высоту */
    .modal { 
        top: 50% !important; bottom: auto !important; left: 50% !important; right: auto !important; 
        width: 90% !important; max-width: 600px !important; height: auto !important; max-height: 85vh !important; 
        transform: translate(-50%, -40%) scale(0.95) !important; 
        opacity: 0; transition: all 0.3s cubic-bezier(0.2, 1, 0.2, 1) !important; 
        border-radius: 24px !important; margin: 0 !important;
        box-shadow: 0 20px 60px rgba(0,0,0,0.15) !important;
    }
    .modal.active { 
        transform: translate(-50%, -50%) scale(1) !important; 
        opacity: 1; 
    }
}

/* =========================================
   ЖИВОЙ ПОИСК И СТРУКТУРА (ОБЩЕЕ)
========================================= */
.desktop-menu-wrap { display: none; } /* Скрыто на телефоне */
.search-wrapper { flex-grow: 1; position: relative; }

/* Выпадающее меню поиска */
.search-dropdown { display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: #fff; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.12); z-index: 10000; max-height: 350px; overflow-y: auto; border: 1px solid #eee; }
.search-dropdown-item { padding: 12px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #f2f2f7; cursor: pointer; transition: 0.2s; }
.search-dropdown-item:hover { background: #fafafa; }
.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-img { width: 45px; height: 45px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.search-dropdown-info { flex: 1; min-width: 0; overflow: hidden; }
.search-dropdown-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }
.search-dropdown-price { font-size: 12px; color: var(--accent); font-weight: bold; }

/* --- КНОПКА "КАТАЛОГ" ДЛЯ ПК --- */
.desktop-catalog-btn { 
    display: none; /* Прячем на мобилках */
}

@media (min-width: 768px) {
    .desktop-catalog-btn {
        display: flex !important;
        align-items: center;
        gap: 8px;
        background: var(--text-main); /* Черная заливка */
        color: #fff;
        border: none;
        padding: 0 16px;
        height: 42px;
        border-radius: 12px;
        font-weight: 600;
        font-size: 15px;
        cursor: pointer;
        transition: 0.2s;
        flex-shrink: 0;
    }
    .desktop-catalog-btn:hover { background: #333; }
    .desktop-catalog-btn:active { transform: scale(0.96); }
}

/* =========================================
   ПОЛНОЦЕННАЯ СТРАНИЦА ТОВАРА (OZON STYLE)
========================================= */
.detail-container { max-width: 1040px; margin: 0 auto; padding: 20px 12px; }
.detail-breadcrumb { margin-bottom: 25px; }
.back-link { display: inline-flex; align-items: center; gap: 8px; color: var(--text-gray); font-weight: 600; font-size: 15px; text-decoration: none; transition: 0.2s; }
.back-link:hover { color: var(--accent); }

.detail-grid { display: grid; gap: 20px; }
.detail-image img { width: 100%; border-radius: 20px; object-fit: cover; aspect-ratio: 1/1; background: #eee; box-shadow: 0 4px 15px rgba(0,0,0,0.03); }
.detail-info { padding: 10px 0; }
.detail-title { font-size: 26px; margin: 0 0 15px; font-weight: 800; color: var(--text-main); }
.detail-desc { font-size: 16px; color: var(--text-gray); line-height: 1.6; white-space: pre-wrap; }

.detail-action-card { background: #fff; padding: 24px; border-radius: 20px; border: 1px solid #f2f2f7; box-shadow: 0 10px 40px rgba(0,0,0,0.04); }
.detail-price { font-size: 32px; font-weight: 800; color: var(--accent); margin: 0 0 5px; }
.detail-note { font-size: 12px; color: #8e8e93; margin: 0 0 25px; }

.fav-action-btn { margin-top: 15px; width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; background: #f2f2f7; border: none; padding: 16px; border-radius: 12px; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--text-main); transition: 0.2s; }
.fav-action-btn.active { color: var(--red); background: rgba(255,59,48,0.1); }

/* ПЛАНШЕТ И ПК (Разбиваем на колонки) */
@media(min-width: 768px) {
    .detail-grid { grid-template-columns: 1fr 1fr; align-items: start; gap: 30px; }
}
/* БОЛЬШИЕ ЭКРАНЫ ПК (3 колонки: Фото - Описание - Корзина) */
@media(min-width: 1024px) {
    .detail-container { padding: 40px 20px; }
    .detail-grid { grid-template-columns: 1.5fr 2fr 1.2fr; gap: 40px; }
    .detail-action-card { position: sticky; top: 120px; /* Липкая карточка справа */ }
}

/* ФИКС "НЕВИДИМЫХ" КЛИКОВ: Скрытые модальные окна больше не перехватывают нажатия */
.modal { 
    pointer-events: none !important; 
}
.modal.active {
    pointer-events: auto !important;
}

/* =========================================
   ХЛЕБНЫЕ КРОШКИ И ПОХОЖИЕ ТОВАРЫ
========================================= */
.detail-breadcrumb { margin-bottom: 25px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.breadcrumb-link { color: var(--text-gray); font-size: 13px; text-decoration: none; transition: 0.2s; display: flex; align-items: center; gap: 4px; }
.breadcrumb-link:hover { color: var(--accent); }
.breadcrumb-separator { color: #ccc; width: 14px; height: 14px; }
.breadcrumb-current { color: var(--text-main); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }

.related-section { margin-top: 60px; padding-top: 40px; border-top: 1px solid #f2f2f7; }
.related-title { font-size: 24px; font-weight: 800; margin-bottom: 20px; color: var(--text-main); }

/* =========================================
   КНОПКА "НАЙТИ" (ТОЛЬКО ДЛЯ ПК)
========================================= */
.search-btn { display: none; } /* Скрыто на телефоне */

@media (min-width: 768px) {
    /* Делаем отступ внутри строки, чтобы текст не залезал под кнопку */
    .search-form input { padding-right: 95px !important; }
    
    .search-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: absolute;
        right: 4px;
        top: 4px;
        bottom: 4px;
        background: var(--accent);
        color: #fff;
        border: none;
        border-radius: 8px;
        padding: 0 18px;
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
        transition: 0.2s;
    }
    .search-btn:hover { opacity: 0.9; }
    .search-btn:active { transform: scale(0.95); }
}

/* =========================================
   РУЧНОЙ ВВОД В КОРЗИНЕ И КНОПКИ УДАЛЕНИЯ
========================================= */
.cart-qty-input {
    width: 36px; text-align: center; font-weight: bold; font-size: 16px;
    border: none; background: transparent; outline: none; padding: 0; color: var(--text-main);
    -moz-appearance: textfield; font-family: inherit;
}
/* Убираем системные стрелочки вверх/вниз у инпута */
.cart-qty-input::-webkit-outer-spin-button,
.cart-qty-input::-webkit-inner-spin-button { 
    -webkit-appearance: none; margin: 0; 
}

/* =========================================
   ВСПЛЫВАЮЩИЕ УВЕДОМЛЕНИЯ (ТОАСТЫ)
========================================= */
#toast-container { 
    position: fixed; bottom: 120px; left: 50%; transform: translateX(-50%); 
    z-index: 10000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; 
}
.toast { 
    background: rgba(0,0,0,0.85); color: #fff; padding: 12px 24px; 
    border-radius: 30px; font-size: 14px; font-weight: 600; text-align: center; 
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: fadeToast 0.3s cubic-bezier(0.2, 1, 0.2, 1), fadeToastOut 0.3s ease 2.7s forwards; 
}
@keyframes fadeToast { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeToastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-20px); } }

@media (min-width: 768px) { #toast-container { bottom: 50px; } }

/* УВЕЛИЧИВАЕМ ИКОНКИ ИЗБРАННОГО НА КАРТОЧКАХ ТОВАРОВ */
.fav-btn { 
    width: 32px !important; 
    height: 32px !important; 
    top: 8px !important; 
    right: 8px !important; 
}
.fav-btn svg { 
    width: 18px !important; 
    height: 18px !important; 
}

/* Фикс для мобильных браузеров (Safari, Chrome) */
header.floating-island, footer {
    position: fixed !important;
    width: 100%;
    z-index: 9999;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}
header.floating-island { top: 0; padding-top: env(safe-area-inset-top); }
footer { bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
body {
    padding-top: 80px;
    padding-bottom: 80px;
    overscroll-behavior-y: none;
}

/* Фикс для пропорций картинок (чтобы не растягивались) */
.product-img {
    width: 100% !important;
    height: 200px !important;
    object-fit: cover !important; /* Заставляет картинку заполнить квадрат, обрезая лишнее */
    border-radius: 8px 8px 0 0 !important;
}

/* Настройки специально для мобильных телефонов */
@media (max-width: 768px) {
    .product-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important; /* Ровно 2 товара в ряд */
        gap: 10px !important;
        padding: 10px !important;
        align-items: start !important;
    }
    .product-card {
        margin: 0 !important;
        width: 100% !important;
        height: auto !important;
    }
    .product-img {
        height: 140px !important; /* Делаем картинки чуть меньше для телефонов */
    }
}

/* СЕТКА: ПК (6 колонок по умолчанию) */
.product-grid {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 15px !important;
    padding: 15px !important;
    align-items: start !important;
}

/* СЕТКА: Планшеты (4 колонки при ширине экрана до 1024px) */
@media (max-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        padding: 10px !important;
    }
}

/* СЕТКА: Телефоны (3 колонки при ширине экрана до 768px) */
@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5px !important;
        padding: 5px !important;
    }
    .product-card {
        margin: 0 !important;
        width: 100% !important;
    }
    /* Уменьшаем картинки и текст, чтобы влезло в 3 колонки */
    .product-img {
        height: 100px !important; 
    }
    .p-price {
        font-size: 11px !important;
        margin-bottom: 2px !important;
    }
    .p-title {
        font-size: 10px !important;
        line-height: 1.1 !important;
    }
}

/* --- СТИЛИ ЖИВОГО ПОИСКА --- */
.search-wrapper { position: relative !important; }
.live-search-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000; margin-top: 5px; display: none;
    max-height: 350px; overflow-y: auto;
}
.live-search-item {
    display: flex; align-items: center; padding: 10px;
    border-bottom: 1px solid #eee; text-decoration: none; color: #333;
}
.live-search-item:last-child { border-bottom: none; }
.live-search-item:hover { background: #f9f9f9; }
.live-search-img {
    width: 40px; height: 40px; border-radius: 4px; object-fit: cover; margin-right: 10px; background: #eee;
}
.live-search-info { display: flex; flex-direction: column; }
.live-search-title { font-size: 14px; font-weight: 500; }
.live-search-price { font-size: 12px; color: #666; margin-top: 2px; }

/* --- СТИЛИ СКЕЛЕТНОЙ ЗАГРУЗКИ --- */
@keyframes skeleton-pulse {
    0% { background-color: #e0e0e0; }
    50% { background-color: #f0f0f0; }
    100% { background-color: #e0e0e0; }
}
.skeleton-card {
    width: 100%; height: 200px; border-radius: 8px;
    animation: skeleton-pulse 1.5s infinite ease-in-out;
    margin-bottom: 10px; background-color: #e0e0e0; cursor: default;
}
@media (max-width: 768px) { .skeleton-card { height: 140px; } }

/* --- СТИЛИ ЖИВОГО ПОИСКА --- */
.search-wrapper { position: relative !important; }
.live-search-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000; margin-top: 5px; display: none;
    max-height: 350px; overflow-y: auto;
}
.live-search-item {
    display: flex; align-items: center; padding: 10px;
    border-bottom: 1px solid #eee; text-decoration: none; color: #333;
}
.live-search-item:last-child { border-bottom: none; }
.live-search-item:hover { background: #f9f9f9; }
.live-search-img {
    width: 40px; height: 40px; border-radius: 4px; object-fit: cover; margin-right: 10px; background: #eee;
}
.live-search-info { display: flex; flex-direction: column; }
.live-search-title { font-size: 14px; font-weight: 500; }
.live-search-price { font-size: 12px; color: #666; margin-top: 2px; }

/* --- СТИЛИ СКЕЛЕТНОЙ ЗАГРУЗКИ --- */
@keyframes skeleton-pulse {
    0% { background-color: #e0e0e0; }
    50% { background-color: #f0f0f0; }
    100% { background-color: #e0e0e0; }
}
.skeleton-card {
    width: 100%; height: 200px; border-radius: 8px;
    animation: skeleton-pulse 1.5s infinite ease-in-out;
    margin-bottom: 10px; background-color: #e0e0e0; cursor: default;
}
@media (max-width: 768px) { .skeleton-card { height: 140px; } }

/* --- ИЗБРАННОЕ И ЗУМ --- */
.product-card .img-wrap { position: relative; }
.fav-btn { position: absolute; top: 10px; right: 10px; z-index: 10; background: rgba(255,255,255,0.85); border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,0.15); transition: all 0.2s ease; }
.fav-btn:hover { background: #fff; transform: scale(1.1); }
.fav-btn.active i, .fav-btn.active svg { fill: #ff3b30; color: #ff3b30; stroke: #ff3b30; }
.detail-image img { transition: transform 0.3s ease; }
.detail-image img:hover { transform: scale(1.02); }


/* --- ИЗБРАННОЕ НА ФОТО И ЗУМ --- */
.product-card { position: relative; }
.fav-btn {
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    cursor: pointer; transition: all 0.2s ease;
}
.fav-btn:hover { transform: scale(1.1); background: #fff; }
.fav-btn.active i, .fav-btn.active svg { color: #ff3b30; fill: #ff3b30; stroke: #ff3b30; }
.detail-image img { cursor: zoom-in; transition: transform 0.3s; }
.detail-image img:hover { transform: scale(1.02); }

/* --- РАЗБЛОКИРОВКА ЭКРАНА --- */
html { overflow-x: hidden; height: auto; }






.modal { 
}


body { 
}
/* Блокируем скролл ТОЛЬКО когда реально открыта модалка */
body.stop-scroll { 
}

/* --- СТАНДАРТ СВОБОДНОГО СКРОЛЛА --- */
html, body {
}
/* Только этот класс будет временно стопорить фон, если мы его включим */
body.modal-open-fix { 
}

body.modal-open-fix #overlay { pointer-events: auto !important; }

/* FIX MODAL CLICK THROUGH */
.modal.active { pointer-events: auto !important; }

/* =========================================
   OZON / WILDBERRIES CATALOG STYLE
========================================= */
@media (min-width: 768px) {
    #modal-catalog { max-width: 950px !important; height: 75vh !important; }
}

.wb-catalog-container { display: flex; flex: 1; height: 100%; position: relative; overflow: hidden; background: #fff; }
.wb-catalog-sidebar { width: 35%; background: #f2f2f7; overflow-y: auto; padding: 10px 0; -webkit-overflow-scrolling: touch; }
.wb-catalog-content { width: 65%; overflow-y: auto; padding: 30px 40px; background: #fff; -webkit-overflow-scrolling: touch; }

.wb-root-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; cursor: pointer; color: #333; font-size: 15px; font-weight: 500; transition: 0.2s; text-decoration: none; }
.wb-root-item:hover { background: #e5e5ea; }
.wb-root-item.active { background: #fff; color: var(--accent); font-weight: 800; border-radius: 16px 0 0 16px; box-shadow: -4px 0 15px rgba(0,0,0,0.02); }
.wb-root-item.active .wb-root-arrow { color: var(--accent); }
.wb-root-arrow { width: 18px; height: 18px; color: #aaa; }

.wb-pane { display: none; animation: fadeIn 0.3s; }
.wb-pane.active { display: block; }
.wb-pane-header { display: inline-block; font-size: 20px; font-weight: 800; color: #000; margin-bottom: 24px; text-decoration: none; transition: 0.2s; }
.wb-pane-header:hover { color: var(--accent); }

.wb-pane-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 30px; }
.wb-sub-group { display: flex; flex-direction: column; gap: 8px; }
.wb-sub-title { font-size: 15px; font-weight: 800; color: #000; margin-bottom: 8px; text-decoration: none; transition: 0.2s; }
.wb-sub-title:hover { color: var(--accent); }
.wb-sub-item { font-size: 14px; color: #6e6e73; text-decoration: none; transition: 0.2s; }
.wb-sub-item:hover { color: var(--accent); }

.wb-mobile-back { display: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* МОБИЛЬНАЯ ВЕРСИЯ (Слайд-меню) */
@media (max-width: 768px) {
    .wb-catalog-sidebar { width: 100%; position: absolute; inset: 0; background: #fff; z-index: 1; transition: transform 0.3s cubic-bezier(0.2, 1, 0.2, 1); padding: 0; }
    .wb-catalog-sidebar.hidden { transform: translateX(-100%); }
    
    .wb-catalog-content { width: 100%; position: absolute; inset: 0; background: #fff; z-index: 2; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.2, 1, 0.2, 1); padding: 20px 15px; }
    .wb-catalog-content.active { transform: translateX(0); }
    
    .wb-root-item { border-bottom: 1px solid #f2f2f7; padding: 18px 16px; background: #fff; border-radius: 0; margin: 0; font-size: 16px; }
    .wb-root-item.active { box-shadow: none; color: #333; font-weight: 500; }
    .wb-root-item:hover { background: #fafafa; }
    
    .wb-pane-grid { grid-template-columns: 1fr; gap: 25px; }
    .wb-mobile-back { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 700; color: var(--accent); padding-bottom: 15px; margin-bottom: 20px; border-bottom: 1px solid #f2f2f7; cursor: pointer; }
}

/* =========================================
   OZON / WILDBERRIES CATALOG STYLE
========================================= */
@media (min-width: 768px) {
    #modal-catalog { max-width: 950px !important; height: 75vh !important; }
}

.wb-catalog-container { display: flex; flex: 1; height: 100%; position: relative; overflow: hidden; background: #fff; }
.wb-catalog-sidebar { width: 35%; background: #f2f2f7; overflow-y: auto; padding: 10px 0; -webkit-overflow-scrolling: touch; }
.wb-catalog-content { width: 65%; overflow-y: auto; padding: 30px 40px; background: #fff; -webkit-overflow-scrolling: touch; }

.wb-root-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; cursor: pointer; color: #333; font-size: 15px; font-weight: 500; transition: 0.2s; text-decoration: none; }
.wb-root-item:hover { background: #e5e5ea; }
.wb-root-item.active { background: #fff; color: var(--accent); font-weight: 800; border-radius: 16px 0 0 16px; box-shadow: -4px 0 15px rgba(0,0,0,0.02); }
.wb-root-item.active .wb-root-arrow { color: var(--accent); }
.wb-root-arrow { width: 18px; height: 18px; color: #aaa; }

.wb-pane { display: none; animation: fadeIn 0.3s; }
.wb-pane.active { display: block; }
.wb-pane-header { display: inline-block; font-size: 20px; font-weight: 800; color: #000; margin-bottom: 24px; text-decoration: none; transition: 0.2s; }
.wb-pane-header:hover { color: var(--accent); }

.wb-pane-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 30px; }
.wb-sub-group { display: flex; flex-direction: column; gap: 8px; }
.wb-sub-title { font-size: 15px; font-weight: 800; color: #000; margin-bottom: 8px; text-decoration: none; transition: 0.2s; }
.wb-sub-title:hover { color: var(--accent); }
.wb-sub-item { font-size: 14px; color: #6e6e73; text-decoration: none; transition: 0.2s; }
.wb-sub-item:hover { color: var(--accent); }

.wb-mobile-back { display: none; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* МОБИЛЬНАЯ ВЕРСИЯ (Слайд-меню) */
@media (max-width: 768px) {
    .wb-catalog-sidebar { width: 100%; position: absolute; inset: 0; background: #fff; z-index: 1; transition: transform 0.3s cubic-bezier(0.2, 1, 0.2, 1); padding: 0; }
    .wb-catalog-sidebar.hidden { transform: translateX(-100%); }
    
    .wb-catalog-content { width: 100%; position: absolute; inset: 0; background: #fff; z-index: 2; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.2, 1, 0.2, 1); padding: 20px 15px; }
    .wb-catalog-content.active { transform: translateX(0); }
    
    .wb-root-item { border-bottom: 1px solid #f2f2f7; padding: 18px 16px; background: #fff; border-radius: 0; margin: 0; font-size: 16px; }
    .wb-root-item.active { box-shadow: none; color: #333; font-weight: 500; }
    .wb-root-item:hover { background: #fafafa; }
    
    .wb-pane-grid { grid-template-columns: 1fr; gap: 25px; }
    .wb-mobile-back { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 700; color: var(--accent); padding-bottom: 15px; margin-bottom: 20px; border-bottom: 1px solid #f2f2f7; cursor: pointer; }
}

/* =========================================
   КРАСИВЫЕ МОДАЛЬНЫЕ ОКНА (BOTTOM SHEET) НА МОБИЛКАХ
========================================= */
@media (max-width: 768px) {
    .modal {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 90vh !important; /* Окно занимает 90% экрана снизу */
        max-height: none !important;
        border-radius: 28px 28px 0 0 !important; /* Сильные закругления в стиле iOS */
        transform: translateY(100%);
        transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1); /* Плавный прыжок */
        margin: 0 !important;
        padding-top: 15px !important;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.15) !important;
    }
    
    /* Та самая серая черточка сверху (индикатор свайпа) */
    .modal::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 45px;
        height: 5px;
        background: #e0e0e0;
        border-radius: 10px;
        z-index: 100;
    }

    .modal.active {
        transform: translateY(0);
    }

    .modal-header {
        border-radius: 28px 28px 0 0;
        padding: 15px 20px 20px 20px !important;
        border-bottom: 1px solid #f2f2f7 !important;
    }

    .modal-title {
        font-size: 19px !important;
        font-weight: 800 !important;
        letter-spacing: -0.5px;
    }
    
    .back-btn {
        font-weight: 600 !important;
        color: var(--accent) !important;
    }
}

/* --- УЛУЧШЕННАЯ КНОПКА НАЗАД (МОБИЛЬНЫЙ КАТАЛОГ) --- */
@media (max-width: 768px) {
    .wb-mobile-back {
        display: flex !important;
        align-items: center;
        gap: 8px;
        font-size: 17px;
        font-weight: 600;
        color: #000;
        padding: 16px 15px;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        position: sticky;
        top: 0;
        z-index: 100;
        margin: -20px -15px 20px -15px; /* Растягиваем на всю ширину */
        border-bottom: 1px solid #f2f2f7;
        box-shadow: 0 4px 15px rgba(0,0,0,0.03);
        cursor: pointer;
    }
    .wb-mobile-back i {
        color: var(--accent);
        width: 24px;
        height: 24px;
        margin-left: -5px; /* Сдвигаем иконку чуть левее для баланса */
    }
}

/* =========================================
   ПРЕМИУМ ДИЗАЙН МОБИЛЬНОГО КАТАЛОГА (iOS / OZON STYLE)
========================================= */
@media (max-width: 768px) {
    /* Само модальное окно */
    #modal-catalog {
        height: 92vh !important;
        border-radius: 24px 24px 0 0 !important;
        padding: 0 !important;
        background: #fff !important;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.15) !important;
    }
    
    /* Индикатор свайпа (маленькая серая полоска сверху) */
    #modal-catalog::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 5px;
        background: #e0e0e0;
        border-radius: 10px;
        z-index: 1000;
    }

    /* Главная шапка модалки */
    #modal-catalog .modal-header {
        padding: 30px 20px 15px 20px !important;
        border-bottom: 1px solid #f2f2f7 !important;
        border-radius: 24px 24px 0 0;
        background: #fff;
    }

    .wb-catalog-container {
        display: flex;
        position: relative;
        height: 100%;
        width: 100%;
        overflow: hidden;
        background: #fff;
    }

    /* Первая страница (Список главных разделов) */
    .wb-catalog-sidebar {
        width: 100%;
        height: 100%;
        overflow-y: auto;
        position: absolute;
        left: 0;
        background: #fff;
        transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.35s ease;
        padding-bottom: 50px;
        z-index: 1;
    }

    .wb-catalog-sidebar.hidden {
        transform: translateX(-30%); /* Уезжает влево с эффектом параллакса */
        opacity: 0;
        pointer-events: none;
    }

    /* Вторая страница (Подкатегории) */
    .wb-catalog-content {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
        background: #f2f2f7 !important; /* Приятный светло-серый фон для контраста белых карточек */
        transform: translateX(100%);
        transition: transform 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
        overflow-y: auto;
        z-index: 2;
        padding: 0 !important;
        box-shadow: -5px 0 25px rgba(0,0,0,0.05); /* Тень на границе страниц */
    }

    .wb-catalog-content.active {
        transform: translateX(0);
    }

    /* Дизайн пунктов главного меню */
    .wb-root-item {
        padding: 18px 20px !important;
        font-size: 17px !important;
        font-weight: 600 !important;
        color: #1c1c1e !important;
        border-bottom: 1px solid #f2f2f7 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        background: #fff !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }
    
    .wb-root-item.active {
        box-shadow: none !important;
        background: #fff !important;
    }
    
    .wb-root-arrow {
        color: #c7c7cc !important;
        width: 20px;
        height: 20px;
    }

    /* Кнопка НАЗАД внутри подкатегории */
    .wb-mobile-back {
        position: sticky !important;
        top: 0 !important;
        background: rgba(242, 242, 247, 0.95) !important; /* Цвет серого фона с прозрачностью */
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        padding: 25px 20px 15px 20px !important;
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        font-size: 17px !important;
        font-weight: 600 !important;
        color: var(--accent) !important;
        z-index: 100 !important;
        margin: 0 !important;
        border-bottom: none !important;
        box-shadow: none !important;
        cursor: pointer;
    }

    /* Большой заголовок выбранной категории */
    .wb-pane-header {
        display: block !important;
        margin: 10px 20px 20px 20px !important;
        font-size: 26px !important;
        font-weight: 800 !important;
        color: #000 !important;
        text-decoration: none !important;
        line-height: 1.2 !important;
    }

    /* Белые карточки с подкатегориями (Стиль Apple/iOS) */
    .wb-sub-group {
        background: #fff !important;
        margin: 0 15px 20px 15px !important;
        border-radius: 16px !important;
        padding: 16px 20px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.03) !important;
    }

    .wb-sub-title {
        font-size: 17px !important;
        font-weight: 700 !important;
        color: #000 !important;
        margin-bottom: 8px !important;
        display: block !important;
        text-decoration: none !important;
    }

    .wb-sub-item {
        font-size: 15px !important;
        font-weight: 500 !important;
        color: #6e6e73 !important;
        padding: 12px 0 !important;
        display: block !important;
        border-top: 1px solid #f2f2f7 !important;
        text-decoration: none !important;
    }
    
    .wb-sub-item:first-of-type {
        border-top: none !important;
        margin-top: 5px !important;
    }
}

/* =========================================
   ВЫТАСКИВАЕМ КНОПКУ "НАЗАД" ИЗ-ПОД КРАЕВ
========================================= */
@media (max-width: 768px) {
    .wb-mobile-back {
        display: flex !important;
        position: sticky !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        background: rgba(242, 242, 247, 0.95) !important;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        
        /* ГЛАВНОЕ: огромный отступ сверху (35px), чтобы кнопка не уходила под закругления модалки */
        padding: 35px 20px 15px 20px !important; 
        
        z-index: 9999 !important;
        color: #007aff !important; /* Синий цвет кликабельных элементов iOS */
        font-size: 17px !important;
        font-weight: 600 !important;
        box-sizing: border-box !important;
        border-bottom: 1px solid #e5e5ea !important;
        align-items: center !important;
    }

    .wb-mobile-back i, 
    .wb-mobile-back svg {
        color: #007aff !important;
        margin-right: 6px !important;
        width: 24px !important;
        height: 24px !important;
    }
}

/* =========================================
   ФИНАЛЬНЫЙ ФИКС ГЕОМЕТРИИ (ЧТОБЫ НИЧЕГО НЕ ПРЯТАЛОСЬ)
========================================= */
@media (max-width: 768px) {
    /* 1. Заставляем тело модалки строго соблюдать границы */
    #modal-catalog .modal-body {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        padding: 0 !important;
    }
    
    .wb-catalog-container {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        position: relative !important;
    }

    /* 2. Жестко привязываем списки к верху и низу контейнера */
    .wb-catalog-sidebar, .wb-catalog-content {
        position: absolute !important;
        top: 0 !important;
        bottom: 0 !important; /* Упирается в низ, а не улетает */
        left: 0 !important;
        right: 0 !important;
        height: auto !important;
        overflow-y: auto !important;
        padding-bottom: 80px !important; /* Место для скролла внизу */
    }

    /* 3. Спасаем пункт "Все товары" */
    .wb-catalog-sidebar {
        padding-top: 15px !important; /* Отодвигаем от шапки вниз */
    }

    /* 4. Спасаем кнопку "Назад" */
    .wb-mobile-back {
        position: sticky !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        
        /* КЛЮЧЕВОЕ: Огромный отступ сверху (45px), чтобы пройти сквозь закругления экрана */
        padding: 45px 20px 15px 20px !important; 
        
        background: rgba(242, 242, 247, 0.95) !important;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 9999 !important;
        box-sizing: border-box !important;
        border-bottom: 1px solid #e5e5ea !important;
        display: flex !important;
        align-items: center !important;
    }
}

/* =========================================
   ИДЕАЛЬНАЯ ГЕОМЕТРИЯ И NATIVE-НАВИГАЦИЯ
========================================= */
@media (max-width: 768px) {
    /* Прячем нашу старую дублирующуюся кнопку, она больше не нужна! */
    .wb-mobile-back { display: none !important; }

    /* Жесткий каркас модалки, чтобы ничего не вываливалось */
    #modal-catalog {
        display: flex !important;
        flex-direction: column !important;
        height: 90vh !important;
        max-height: 90vh !important;
        overflow: hidden !important;
    }

    /* Шапку теперь НИКОГДА не прячем */
    #modal-catalog .modal-header {
        display: flex !important; 
        flex-shrink: 0 !important;
        z-index: 10 !important;
        background: #fff !important;
    }

    /* Тело каталога: занимает строго оставшееся место */
    #modal-catalog .modal-body {
        flex: 1 1 auto !important;
        position: relative !important;
        overflow: hidden !important; /* Сам блок не скроллится... */
        padding: 0 !important;
    }

    .wb-catalog-container {
        position: absolute !important;
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        display: flex !important;
        width: 100% !important;
        height: 100% !important;
        overflow: hidden !important;
    }

    /* ...скроллятся только сами списки внутри него! */
    .wb-catalog-sidebar, .wb-catalog-content {
        position: absolute !important;
        top: 0 !important; left: 0 !important; right: 0 !important; bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important; /* Плавный скролл как в iOS */
        padding-bottom: 120px !important; /* Огромный запас снизу, чтобы панель Safari ничего не перекрывала */
        background: #fff;
    }

    .wb-catalog-content {
        background: #f2f2f7 !important;
        z-index: 5 !important;
    }
}

/* =========================================
   ФИНАЛЬНЫЙ ФИКС: СПАСАЕМ ШАПКУ ОТ ПЕРЕКРЫТИЯ
========================================= */
@media (max-width: 768px) {
    /* 1. Жестко привязываем Тело окна. Теперь всё, что внутри, не может вылезти выше него */
    #modal-catalog .modal-body {
        position: relative !important; /* КРИТИЧЕСКИ ВАЖНО */
        flex: 1 1 auto !important;
        height: 100% !important;
        z-index: 1 !important;
    }

    /* 2. Шапка теперь гарантированно лежит ПОВЕРХ списков */
    #modal-catalog .modal-header {
        position: relative !important;
        z-index: 9999 !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.03) !important; /* Легкая тень, чтобы визуально отделить шапку от скролла */
        background: #fff !important;
    }

    /* 3. Контейнер каталога больше не улетает наверх */
    .wb-catalog-container {
        position: absolute !important;
        top: 0 !important; 
        left: 0 !important; 
        right: 0 !important; 
        bottom: 0 !important;
    }
}

/* Восстановление структуры списка в модалке */
#modal-catalog a, 
#modal-catalog .category-item,
#modal-catalog .subcategory-item {
    display: block !important;
    padding: 12px 0 !important;
    border-bottom: 1px solid #f0f0f0 !important;
    text-decoration: none !important;
    color: #1c1c1e !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
}

#modal-catalog a:last-child {
    border-bottom: none !important;
}


/* =========================================
   ДЕСКТОПНЫЙ КАТАЛОГ В СТИЛЕ OZON (ИДЕАЛЬНЫЙ ЦЕНТР FLEXBOX)
========================================= */
@media (min-width: 769px) {
    /* 1. ГЛАВНЫЙ ЭКРАН КАТАЛОГА (ФЛЕКС-КОНТЕЙНЕР НА ВЕСЬ ЭКРАН) */
    div#modal-catalog.active,
    div#modal-catalog.show {
        display: flex !important;
        justify-content: center !important; /* АБСОЛЮТНЫЙ ЦЕНТР ПО ГОРИЗОНТАЛИ */
        align-items: flex-start !important; /* ПРИЖИМАЕМ К ВЕРХУ (ПОД ШАПКУ) */
        position: fixed !important;
        top: 85px !important; /* Отступ под высоту твоей шапки сайта */
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: calc(100vh - 85px) !important;
        z-index: 999999 !important;
        background: transparent !important; /* Фон затемнения дает твой #overlay */
        padding-top: 30px !important; /* Эстетичный отступ каталога от шапки */
        margin: 0 !important;
        transform: none !important;
        box-sizing: border-box !important;
    }

    #modal-catalog .modal-header { display: none !important; }

    /* 2. БЕЛАЯ КОРОБКА КАТАЛОГА */
    div#modal-catalog .modal-body {
        display: flex !important;
        flex-direction: row !important;
        width: 95vw !important; /* Занимает 95% ширины экрана... */
        max-width: 1040px !important; /* ...но не больше 1040px (как на Озоне) */
        height: 75vh !important; /* Высота 75% от экрана */
        min-height: 500px !important;
        max-height: 800px !important;
        background: #fff !important;
        border-radius: 16px !important;
        box-shadow: 0 20px 60px rgba(0,0,0,0.4) !important; /* Глубокая тень */
        padding: 0 !important;
        margin: 0 !important; /* Flex родителя сам поставит эту коробку по центру */
        overflow: hidden !important;
        position: relative !important; /* ОТМЕНЯЕМ МОБИЛЬНЫЙ ABSOLUTE */
        top: auto !important; left: auto !important; transform: none !important;
    }

    /* 3. КОНТЕЙНЕР И КОЛОНКИ (Жестко отменяем мобильные выезды) */
    .wb-catalog-container {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
        height: 100% !important;
        position: static !important;
    }

    .wb-catalog-sidebar {
        display: block !important;
        position: static !important; /* СБРАСЫВАЕМ МОБИЛЬНЫЙ ABSOLUTE */
        width: 280px !important;
        min-width: 280px !important;
        height: 100% !important;
        background: #f9f9f9 !important;
        border-right: 1px solid #eee !important;
        padding: 20px 0 !important;
        overflow-y: auto !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .wb-catalog-content {
        display: block !important;
        position: static !important; /* СБРАСЫВАЕМ МОБИЛЬНЫЙ ABSOLUTE */
        flex: 1 !important;
        height: 100% !important;
        background: #fff !important;
        padding: 40px 50px !important;
        overflow-y: auto !important;
        transform: none !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* ДИЗАЙН ЭЛЕМЕНТОВ МЕНЮ */
    .wb-root-item { display: block !important; padding: 10px 20px !important; margin: 2px 10px !important; border-radius: 8px !important; font-size: 15px !important; font-weight: 500 !important; color: #111 !important; text-decoration: none !important; cursor: pointer !important; background: transparent !important; border: none !important; transition: 0.15s !important; }
    .wb-root-item:hover { background: #fff !important; box-shadow: 0 2px 5px rgba(0,0,0,0.04) !important; }
    .wb-root-item.active { background: #fff !important; color: #005bff !important; font-weight: 600 !important; box-shadow: 0 2px 5px rgba(0,0,0,0.04) !important; }
    .wb-root-arrow { display: none !important; }

    .wb-pane { display: none !important; }
    .wb-pane.active { display: block !important; animation: fadeIn 0.2s ease; }

    .wb-pane-header { display: block !important; font-size: 28px !important; font-weight: 800 !important; color: #111 !important; margin-bottom: 30px !important; text-decoration: none !important; }
    .wb-pane-grid { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 30px !important; align-items: start !important; }
    @media (max-width: 1200px) { .wb-pane-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 20px !important; } }

    .wb-sub-group { margin: 0 !important; padding: 0 !important; display: block !important; }
    .wb-sub-title { font-size: 15px !important; font-weight: 700 !important; color: #111 !important; margin-bottom: 12px !important; display: block !important; text-decoration: none !important; }
    .wb-sub-item { font-size: 14px !important; font-weight: 400 !important; color: #555 !important; padding: 6px 0 !important; display: block !important; text-decoration: none !important; line-height: 1.3 !important; }
    .wb-sub-item:hover { color: #005bff !important; }
    .wb-mobile-back { display: none !important; }
}


/* --- ФИКС КНОПКИ КАТАЛОГА (СИНИЙ OZON) --- */
.desktop-catalog-btn {
    background-color: #005bff !important;
    color: #fff !important;
    border: none !important;
    border-radius: 8px !important;
    padding: 10px 24px !important;
    font-weight: 700 !important;
    font-size: 16px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    transition: background-color 0.2s !important;
}
.desktop-catalog-btn:hover { background-color: #004ad0 !important; }
.desktop-catalog-btn svg, .desktop-catalog-btn i { stroke: #fff !important; width: 20px !important; height: 20px !important; }

/* --- ФИКС ИКОНОК СЕРДЕЧЕК --- */
.fav-btn svg, .fav-btn i { stroke: #8e8e93 !important; fill: transparent !important; transition: 0.2s; }
.fav-btn.active svg, .fav-btn.active i { stroke: #ff3b30 !important; fill: #ff3b30 !important; }

/* Гарантия, что старый каталог никого не перекроет */
#modal-catalog { display: none !important; pointer-events: none !important; }

/* --- STYLES FOR CATALOG PAGE --- */

    .catalog-page-wrapper { max-width: 1120px; margin: 30px auto; padding: 0 20px; min-height: 60vh; }
    .back-link { display: inline-flex; align-items: center; gap: 4px; color: #8e8e93; text-decoration: none; font-weight: 600; font-size: 15px; margin-bottom: 20px; transition: color 0.2s; }
    .back-link i { width: 18px; height: 18px; }
    .back-link:hover { color: var(--accent); }
    .catalog-page-title { font-size: 32px; font-weight: 800; margin-bottom: 30px; color: #111; letter-spacing: -0.5px; }
    .catalog-page-subtitle { font-size: 26px; font-weight: 800; margin: 60px 0 25px 0; color: #111; letter-spacing: -0.5px; }
    
    .ozon-cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 15px; }
    .ozon-cat-card { background: #f7f8fa; border-radius: 14px; padding: 15px; display: flex; flex-direction: column; align-items: center; text-decoration: none; transition: all 0.2s ease; border: 1px solid transparent; cursor: pointer; }
    .ozon-cat-card:hover { background: #fff; border-color: #eee; transform: translateY(-3px); box-shadow: 0 10px 25px rgba(0,0,0,0.06); }
    
    .ozon-cat-img-wrap { width: 100%; height: 110px; margin-bottom: 12px; display: flex; align-items: center; justify-content: center; }
    .ozon-cat-img-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; mix-blend-mode: multiply; }
    
    .ozon-cat-title { font-size: 14px; font-weight: 600; color: #111; text-align: center; line-height: 1.3; }
    
    @media (max-width: 768px) {
        .catalog-page-wrapper { margin: 15px auto; }
        .catalog-page-title { font-size: 24px; margin-bottom: 20px; }
        .catalog-page-subtitle { font-size: 22px; margin: 40px 0 20px 0; }
        .ozon-cat-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
        .ozon-cat-card { padding: 10px; border-radius: 12px; }
        .ozon-cat-img-wrap { height: 80px; margin-bottom: 8px; }
        .ozon-cat-title { font-size: 12px; }
    }
    @media (max-width: 480px) {
        .ozon-cat-grid { grid-template-columns: repeat(2, 1fr); }
    }


/* === ГЛОБАЛЬНАЯ СЕТКА И ВЫРАВНИВАНИЕ === */
/* 1. Жестко связываем шапку, крошки, заголовки и сетку товаров в одну ровную колонку */
.header-container,
.breadcrumbs,
.category-main-title,
.catalog-page-wrapper,
.product-grid {
    max-width: 1120px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

/* 2. Убиваем двойные отступы внутри страницы каталога (чтобы карточки не сужались) */
.catalog-page-wrapper .product-grid,
.catalog-page-wrapper .ozon-cat-grid {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
}

/* 3. Дизайн заголовка H1 */
.category-main-title {
    font-size: 32px !important;
    font-weight: 800 !important;
    color: #111 !important;
    margin-top: 10px !important;
    margin-bottom: 25px !important;
    letter-spacing: -0.5px !important;
    display: block !important;
}


/* =========================================================================
   👑 PREMIUM MOBILE EXPERIENCE (App-Like Design for max-width: 768px) 👑
   ========================================================================= */
@media (max-width: 768px) {
    /* --- 1. ШАПКА И ПОИСК --- */
    header { height: calc(65px + env(safe-area-inset-top)) !important; }
    body { padding-top: calc(75px + env(safe-area-inset-top)) !important; }
    
    .header-container { padding: 0 16px !important; gap: 16px !important; }
    .logo-img { height: 38px !important; }
    
    .search-form { height: 44px !important; }
    .search-form input { 
        border-radius: 22px !important; /* Сильное скругление, как в Apple */
        background: #eef0f4 !important; 
        font-size: 15px !important; 
        padding-left: 42px !important;
    }
    .search-icon { top: 13px !important; left: 16px !important; width: 18px !important; height: 18px !important; color: #8e8e93 !important; }
    .icon-btn { width: 44px !important; height: 44px !important; border-radius: 22px !important; background: #eef0f4 !important; display: flex; align-items: center; justify-content: center; border: none; }
    .icon-btn i, .icon-btn svg { width: 20px !important; height: 20px !important; color: #111 !important; }

    /* --- 2. КАРТОЧКА ТОВАРА (КАТАЛОГ) --- */
    .product-grid { padding: 12px 16px !important; gap: 12px !important; }
    .product-card { 
        border-radius: 16px !important; 
        box-shadow: 0 4px 12px rgba(0,0,0,0.03) !important; 
        border: 1px solid #f5f5f5 !important;
    }
    .product-img, .img-wrap { 
        height: 160px !important; 
        border-radius: 16px 16px 0 0 !important; 
        background: #f7f8fa !important;
    }
    .card-info { padding: 12px !important; }
    .p-price { font-size: 15px !important; margin-bottom: 4px !important; letter-spacing: -0.3px !important; }
    .p-title { font-size: 13px !important; color: #111 !important; height: 34px !important; line-height: 1.3 !important; font-weight: 500 !important; }
    
    .fav-btn { width: 34px !important; height: 34px !important; top: 10px !important; right: 10px !important; box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important; }
    .fav-btn svg { width: 18px !important; height: 18px !important; }

    /* --- 3. СТРАНИЦА ТОВАРА (ВНУТРИ) --- */
    .product-page-wrapper { padding: 0 !important; margin-top: 0 !important; }
    .breadcrumbs-wrapper { padding: 0 16px !important; margin-bottom: 15px !important; }
    
    .product-detail-card { 
        border-radius: 0 !important; 
        background: transparent !important; 
        padding: 0 16px 120px 16px !important; /* Огромный отступ снизу под липкую кнопку */
        gap: 16px !important; 
    }
    
    .product-detail-image { 
        border-radius: 24px !important; 
        box-shadow: 0 8px 24px rgba(0,0,0,0.04) !important;
    }
    
    .product-detail-title { font-size: 26px !important; line-height: 1.15 !important; margin-bottom: 10px !important; margin-top: 10px !important; }
    .product-detail-price { font-size: 28px !important; margin-bottom: 15px !important; }
    
    .product-detail-description h3 { font-size: 20px !important; margin-top: 20px !important; }
    .product-detail-description p { font-size: 15px !important; line-height: 1.5 !important; }

    /* ЛИПКАЯ ПАНЕЛЬ С КНОПКОЙ ПОКУПКИ (КАК В WILDBERRIES/OZON) */
    .detail-actions-wrapper {
        position: fixed !important;
        bottom: calc(75px + env(safe-area-inset-bottom)) !important; /* Над нижним меню */
        left: 0 !important;
        right: 0 !important;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        padding: 12px 16px !important;
        margin: 0 !important;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.08) !important;
        z-index: 100 !important;
        display: flex !important;
        gap: 12px !important;
        align-items: center !important;
        border-top: 1px solid #eee !important;
    }
    
    .detail-add-btn { 
        flex: 1 !important; 
        height: 52px !important; 
        font-size: 17px !important; 
        border-radius: 14px !important; 
    }
    
    .qty-controller { 
        flex: 1 !important; 
        height: 52px !important; 
        border-radius: 14px !important; 
        padding: 4px !important;
    }
    .qty-btn { width: 44px !important; height: 44px !important; font-size: 22px !important; border-radius: 10px !important; }
    #detail-qty-input { font-size: 18px !important; }
    
    .fav-detail-btn { 
        width: 52px !important; 
        height: 52px !important; 
        border-radius: 14px !important; 
        background: #f2f2f7 !important;
    }

    /* --- 4. ИЗБРАННОЕ И КОРЗИНА (СПИСКИ) --- */
    .catalog-page-wrapper h1 { font-size: 28px !important; padding-left: 0 !important; }
    
    #fav-content-area, #cart-body { display: flex !important; flex-direction: column !important; gap: 12px !important; padding: 0 16px !important; }
    
    .list-item, .product-card[style*="flex-direction: column; height: 100%"] { 
        flex-direction: row !important; /* Строим в линию */
        align-items: center !important;
        height: auto !important;
        padding: 12px !important;
        border-radius: 16px !important;
        box-shadow: 0 4px 15px rgba(0,0,0,0.03) !important;
        border: 1px solid #f2f2f7 !important;
        gap: 16px !important;
    }
    
    /* Картинка слева */
    .list-item .img-wrap, .product-card[style*="flex-direction: column"] .img-wrap { 
        width: 80px !important; 
        height: 80px !important; 
        flex-shrink: 0 !important;
        border-radius: 12px !important;
    }
    
    /* Инфо по центру */
    .list-item .card-info, .product-card[style*="flex-direction: column"] .card-info { 
        padding: 0 !important; 
        flex: 1 !important; 
        display: flex !important; 
        flex-direction: column !important; 
        justify-content: center !important;
    }
    
    .list-item .p-title, .product-card[style*="flex-direction: column"] .p-title { 
        font-size: 14px !important; 
        height: auto !important; 
        margin-bottom: 6px !important;
        color: #111 !important;
    }
    
    .list-item .p-price, .product-card[style*="flex-direction: column"] .p-price { 
        font-size: 15px !important; 
        margin-bottom: 0 !important;
    }
    
    /* Контролы справа (Умный счетчик на 2 строки: счетчик сверху, мусорка снизу) */
    .smart-cart-wrap, .product-card[style*="flex-direction: column"] > div[style*="flex-direction:column; gap:8px"] {
        flex-direction: column !important;
        width: 90px !important;
        margin: 0 !important;
        gap: 8px !important;
        align-items: flex-end !important;
    }
    
    /* Увеличиваем сами счетчики */
    .unified-counter, .cart-controls {
        height: 40px !important;
        width: 90px !important;
        border-radius: 10px !important;
        padding: 4px !important;
    }
    .unified-counter button, .cart-controls button {
        width: 32px !important;
        height: 32px !important;
        font-size: 18px !important;
        border-radius: 8px !important;
    }
    
    /* Кнопка "В заявку" в Избранном */
    .fav-add-to-cart-btn {
        width: 90px !important;
        height: 40px !important;
        padding: 0 !important;
        font-size: 12px !important;
        border-radius: 10px !important;
        margin: 0 !important;
    }

    /* Мусорка в Избранном */
    .product-card[style*="flex-direction: column"] button[onclick*="toggleFav"] {
        padding: 0 !important;
        width: 36px !important;
        height: 36px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: rgba(255,59,48,0.1) !important;
        color: var(--red) !important;
        border-radius: 10px !important;
        font-size: 0 !important; /* Убираем текст "Удалить" */
    }
    .product-card[style*="flex-direction: column"] button[onclick*="toggleFav"]::before {
        content: '';
        display: block;
        width: 16px;
        height: 16px;
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23ff3b30" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/></svg>');
        background-size: cover;
    }
    
    /* Скрываем сердечко в углу картинки (оно теперь не нужно, есть кнопка корзины/мусорки справа) */
    .product-card[style*="flex-direction: column"] .fav-btn { display: none !important; }

    /* --- 5. НИЖНЕЕ МЕНЮ (ПОДВАЛ) --- */
    footer.floating-island {
        height: calc(65px + env(safe-area-inset-bottom)) !important;
        background: rgba(255, 255, 255, 0.98) !important;
        border-top: 1px solid rgba(0,0,0,0.05) !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.02) !important;
    }
    
    .tab { width: 25% !important; gap: 4px !important; } /* 4 таба вместо 5 (убрали дубль Контактов/Главной по желанию, или просто дали больше места) */
    .tab svg { width: 24px !important; height: 24px !important; stroke-width: 1.5px !important; }
    .tab span { font-size: 10px !important; font-weight: 500 !important; }
    
    .tab.active { color: #111 !important; }
    .tab.active svg { stroke-width: 2.5px !important; color: var(--accent) !important; }
    .tab.active span { font-weight: 700 !important; }
    
    .badge {
        top: -4px !important;
        left: calc(50% + 4px) !important;
        font-size: 11px !important;
        min-width: 18px !important;
        height: 18px !important;
        border-width: 2px !important;
    }
}

/* === ПРАВКИ ПО СПИСКУ (ТОЛЬКО МОБИЛКИ) === */
@media (max-width: 768px) {
    
    
    /* 2. Убираем кнопки каталога из шапки */
    header .catalog-btn, header .desktop-catalog-btn {
        display: none !important;
    }
    
    /* 3. Липкая кнопка в товаре (прижимаем к подвалу) */
    .detail-actions-wrapper {
        bottom: calc(65px + env(safe-area-inset-bottom)) !important; /* 65px - высота подвала */
        padding-bottom: 12px !important;
        border-radius: 0 !important; /* Прямые углы внизу для плотного прилегания */
    }
    
    /* 4. Одинаковый размер кнопок в Избранном */
    .fav-add-to-cart-btn, 
    .smart-cart-wrap .unified-counter, 
    .product-card[style*="flex-direction: column"] .unified-counter {
        width: 105px !important;
        height: 40px !important;
        margin: 0 !important;
    }
    
    /* 6. Аккуратная корзина (Заявка): мелкое фото, перенос текста */
    #cart-body .list-item {
        align-items: center !important;
        padding: 12px !important;
    }
    #cart-body .cart-item-img {
        width: 60px !important;
        height: 60px !important;
        border-radius: 8px !important;
    }
    #cart-body .list-item-title {
        white-space: normal !important; /* Разрешаем перенос текста */
        font-size: 13px !important;
        line-height: 1.3 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important; /* Максимум 2 строки */
        -webkit-box-orient: vertical !important;
        margin-bottom: 4px !important;
    }
    .cart-qty-input { width: 30px !important; font-size: 14px !important; }
}

/* === АБСОЛЮТНОЕ ВЫРАВНИВАНИЕ ПЛИТОК (МОБИЛКИ) === */
@media (max-width: 768px) {
    /* Ограничиваем только Главную страницу и Каталог, не трогаем Избранное */
    main > .product-grid .product-card,
    .catalog-page-wrapper > .product-grid .product-card,
    .related-section .product-grid .product-card {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important; /* Заставляет карточки в одном ряду быть одной высоты */
        justify-content: flex-start !important;
    }
    
    main > .product-grid .product-card .img-wrap,
    .catalog-page-wrapper > .product-grid .product-card .img-wrap,
    .related-section .product-grid .product-card .img-wrap {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important; /* Идеальный квадрат для фото */
        flex-shrink: 0 !important;
    }
    
    main > .product-grid .product-card .card-info,
    .catalog-page-wrapper > .product-grid .product-card .card-info,
    .related-section .product-grid .product-card .card-info {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 1 !important; /* Текстовый блок занимает все оставшееся место до низа */
        justify-content: space-between !important;
        padding: 8px !important;
    }
    
    main > .product-grid .product-card .p-title,
    .catalog-page-wrapper > .product-grid .product-card .p-title,
    .related-section .product-grid .product-card .p-title {
        height: 32px !important; /* Строго выделяем место под 2 строки текста */
        overflow: hidden !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        white-space: normal !important;
        margin-bottom: 4px !important;
        font-size: 11px !important; /* Делаем шрифт чуть аккуратнее, чтобы влезал */
    }
}

/* === ИДЕАЛЬНО РОВНЫЕ КНОПКИ В ИЗБРАННОМ (МОБИЛКА) === */
@media (max-width: 768px) {
    /* Выбираем и кнопку, и обертку счетчика */
    #fav-content-area .card-info > .fav-add-to-cart-btn,
    #fav-content-area .card-info > div[style*="justify-content:space-between"] {
        width: 120px !important;     /* Жесткая ширина */
        height: 40px !important;     /* Жесткая высота */
        min-height: 40px !important;
        max-height: 40px !important;
        box-sizing: border-box !important;
        margin: auto 0 0 0 !important; /* Прижимаем к низу */
        border-radius: 10px !important;
    }
    
    /* Сбрасываем лишние отступы у кнопки, чтобы она не раздувалась */
    #fav-content-area .card-info > .fav-add-to-cart-btn {
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 13px !important;
    }
    
    /* Сохраняем аккуратные отступы внутри счетчика */
    #fav-content-area .card-info > div[style*="justify-content:space-between"] {
        padding: 4px !important;
    }
    
    /* Кнопки плюс и минус внутри счетчика */
    #fav-content-area .card-info > div[style*="justify-content:space-between"] button {
        width: 32px !important;
        height: 32px !important;
        font-size: 18px !important;
        border-radius: 8px !important;
    }
}

/* === МИНИ-ФОТО БЕЗ РАМКИ В ИЗБРАННОМ (МОБИЛКА) === */
@media (max-width: 768px) {
    #fav-content-area .product-card .img-wrap {
        width: 55px !important;      /* Значительно уменьшили размер */
        height: 55px !important; 
        min-width: 55px !important;
        border-radius: 12px !important; /* Закругленные края */
        background: transparent !important; /* Убираем серый фон, который выглядит как рамка */
        border: none !important;     /* Убираем любые линии */
        padding: 0 !important;
        box-shadow: none !important;
    }
    
    #fav-content-area .product-card .img-wrap img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border-radius: 12px !important; /* Закругляем саму картинку */
    }
}

/* === ИЗБРАННОЕ: ВСЕ В ОДНУ СТРОКУ (МОБИЛКА) === */
@media (max-width: 768px) {
    /* 1. Сама карточка становится флекс-строкой */
    #fav-content-area .product-card {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        padding: 10px 12px !important;
        height: auto !important;
        gap: 10px !important;
    }
    
    /* 2. Фото слева (Порядок 1) */
    #fav-content-area .product-card .img-wrap {
        order: 1 !important;
        width: 55px !important;
        height: 55px !important;
        min-width: 55px !important;
        margin: 0 !important;
        border-radius: 12px !important;
    }
    
    /* 3. Центральный блок с Инфо и Кнопкой Заявки (Порядок 2) */
    #fav-content-area .product-card .card-info {
        order: 2 !important;
        display: grid !important;
        grid-template-columns: 1fr auto !important; /* Текст занимает всё место, кнопка - справа */
        grid-template-rows: auto auto !important;
        gap: 4px 10px !important;
        padding: 0 !important;
        width: 100% !important;
        align-items: center !important;
    }
    
    #fav-content-area .product-card .p-title {
        grid-column: 1 !important;
        grid-row: 1 !important;
        margin: 0 !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important; /* Название в 2 строки, если длинное */
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        white-space: normal !important;
    }
    
    #fav-content-area .product-card .p-price {
        grid-column: 1 !important;
        grid-row: 2 !important;
        margin: 0 !important;
        font-size: 13px !important;
        color: #005bff !important;
    }
    
    /* Кнопка заявки и счетчик внутри Инфо-блока */
    #fav-content-area .product-card .fav-add-to-cart-btn,
    #fav-content-area .product-card > .card-info > div[style*="justify-content:space-between"] {
        grid-column: 2 !important;
        grid-row: 1 / span 2 !important;
        margin: 0 !important;
        width: 95px !important; /* Компактный размер для вместимости */
        height: 38px !important;
        min-width: 95px !important;
    }

    /* 4. Кнопка удаления (Сердечко) справа (Порядок 3) */
    #fav-content-area .product-card .fav-btn {
        order: 3 !important;
        position: static !important; /* Возвращаем в общий поток */
        display: flex !important;    /* Отменяем скрытие из старых скриптов */
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        margin: 0 !important;
        box-shadow: none !important;
        background: rgba(255, 59, 48, 0.1) !important; /* Красный фончик */
        border-radius: 8px !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #fav-content-area .product-card .fav-btn svg,
    #fav-content-area .product-card .fav-btn i {
        width: 16px !important;
        height: 16px !important;
        color: #ff3b30 !important;
        stroke: #ff3b30 !important;
        fill: #ff3b30 !important;
    }
}

/* === КОРЗИНА (ЗАЯВКА): МИНИ-ФОТО И АККУРАТНЫЙ СПИСОК (МОБИЛКА) === */
@media (max-width: 768px) {
    #cart-body .list-item {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        padding: 10px !important;
        gap: 10px !important;
        border-radius: 12px !important;
    }
    
    /* 1. Делаем фото крошечным и аккуратным */
    #cart-body .cart-item-img {
        width: 40px !important; 
        height: 40px !important;
        min-width: 40px !important;
        border-radius: 8px !important;
        object-fit: cover !important;
        margin: 0 !important;
    }
    
    /* 2. Блок с названием и ценой */
    #cart-body .list-item-info {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        min-width: 0 !important; /* Защита от разъезжания верстки */
    }
    
    /* 3. Название товара (разрешаем 2 строки, делаем компактнее) */
    #cart-body .list-item-title {
        font-size: 12px !important;
        font-weight: 600 !important;
        line-height: 1.2 !important;
        margin-bottom: 2px !important;
        white-space: normal !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
    
    /* 4. Правый блок с кнопками (чуть уменьшаем, чтобы всё влезло) */
    #cart-body .list-item > div[style*="display:flex"] {
        flex-shrink: 0 !important;
        gap: 6px !important;
    }
    
    .cart-controls {
        height: 32px !important;
        padding: 2px !important;
    }
    .cart-controls button {
        width: 26px !important;
        height: 26px !important;
        font-size: 16px !important;
    }
    .cart-qty-input {
        width: 24px !important;
        font-size: 13px !important;
    }
    
    /* Кнопка с мусоркой */
    #cart-body button[title="Удалить"] {
        width: 32px !important;
        height: 32px !important;
    }
}

/* === КАТЕГОРИИ И ПОДКАТЕГОРИИ: 4 В РЯД И ЧИСТОЕ ФОТО (МОБИЛКА) === */
@media (max-width: 768px) {
    /* Контейнер сетки категорий */
    .category-grid, [class*="category-container"] {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important; /* Строго 4 колонки */
        gap: 8px !important; /* Минимальный отступ между плитками */
        padding: 0 !important;
    }
    
    /* Карточка категории */
    .category-card, [class*="category-card"] {
        background: transparent !important; /* Убираем любой фон */
        border: none !important;          /* Убираем рамку */
        padding: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
    }
    
    /* Обертка картинки */
    .category-card .img-wrap, [class*="category-card"] .img-wrap {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;   /* Делаем идеальный квадрат */
        border-radius: 12px !important;    /* Закругленные углы */
        background: #f7f8fa !important;   /* Светло-серый фон для загрузки */
        overflow: hidden !important;
        border: none !important;
        padding: 0 !important;
    }
    
    /* Сама картинка */
    .category-card .img-wrap img, [class*="category-card"] .img-wrap img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;     /* Картинка заполняет квадрат */
        border-radius: 12px !important;    /* Закругляем саму картинку */
    }
    
    /* Название категории (чуть уменьшаем, чтобы вмещалось) */
    .category-card .p-title, [class*="category-card"] .p-title {
        font-size: 11px !important;
        line-height: 1.2 !important;
        margin-top: 4px !important;
        font-weight: 500 !important;
    }
}

/* === ПЛИТКИ КАТЕГОРИЙ (4 В РЯД, БЕЗ РАМОК) НА МОБИЛКАХ === */
@media (max-width: 768px) {
    /* Сетка на 4 колонки */
    .ozon-cat-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    
    /* Убираем фон и рамки у самой карточки */
    .ozon-cat-card {
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    
    /* Делаем контейнер картинки идеальным квадратом с закруглениями */
    .ozon-cat-img-wrap {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 1 !important;
        border-radius: 14px !important;
        background: #f7f8fa !important; /* Оставляем легкий фон под фото на всякий случай */
        margin-bottom: 6px !important;
        padding: 0 !important;
        overflow: hidden !important;
    }
    
    /* Сама картинка заполняет квадрат */
    .ozon-cat-img-wrap img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important; /* Заполнение без сплющивания */
        mix-blend-mode: normal !important; /* Отключаем старые эффекты наложения */
        border-radius: 14px !important;
    }
    
    /* Компактный текст под фото */
    .ozon-cat-title {
        font-size: 11px !important;
        line-height: 1.2 !important;
        font-weight: 500 !important;
    }
}

/* === КОРРЕКТИРОВКА ШАПКИ (ЭЛЕГАНТНОСТЬ И ОТСТУПЫ) === */

/* ДЛЯ КОМПЬЮТЕРОВ И ПЛАНШЕТОВ */
@media (min-width: 769px) {
    /* 1. Уменьшаем кнопку Каталога и отлипляем от логотипа */
    .desktop-catalog-btn {
        height: 38px !important;
        padding: 0 16px !important;
        font-size: 14px !important;
        margin-left: 30px !important; /* ОТОДВИГАЕМ ОТ ЛОГОТИПА */
        margin-right: 10px !important;
        border-radius: 10px !important;
    }
    .desktop-catalog-btn svg, .desktop-catalog-btn i {
        width: 16px !important;
        height: 16px !important;
    }
    
    /* 2. Уменьшаем строку поиска */
    .search-wrapper {
        max-width: 400px !important; /* Делаем поиск короче и аккуратнее */
    }
    .search-form {
        height: 38px !important; /* Делаем строку тоньше */
    }
    .search-form input {
        font-size: 14px !important;
        padding-left: 36px !important;
        border-radius: 10px !important;
    }
    .search-icon {
        top: 10px !important; /* Центруем иконку лупы */
        width: 16px !important;
        height: 16px !important;
    }
    .search-btn {
        top: 3px !important;
        bottom: 3px !important;
        padding: 0 16px !important;
        font-size: 13px !important;
        border-radius: 8px !important;
    }
}

/* ДЛЯ ТЕЛЕФОНОВ (на всякий случай тоже делаем поиск тоньше и отдаляем от лого) */
@media (max-width: 768px) {
    .header-container {
        gap: 20px !important; /* Увеличиваем расстояние между Лого и Поиском */
    }
    .search-form {
        height: 38px !important; /* Тонкая строка поиска */
    }
    .search-form input {
        font-size: 14px !important;
        padding-left: 36px !important;
    }
    .search-icon {
        top: 10px !important;
        width: 16px !important;
        height: 16px !important;
    }
    .icon-btn {
        width: 38px !important;
        height: 38px !important;
    }
}

/* === МИКРОАНИМАЦИЯ КОРЗИНЫ === */
@keyframes bounceBadge {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); background-color: #ff2d55; }
    100% { transform: scale(1); }
}
.badge-bounce { animation: bounceBadge 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* === КРЕСТИК ОЧИСТКИ ПОИСКА === */
.search-clear {
    position: absolute; right: 100px; top: 50%; transform: translateY(-50%);
    width: 20px; height: 20px; background: #c7c7cc; color: #fff;
    border-radius: 50%; display: none; align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px; font-weight: bold; line-height: 1; z-index: 10;
    transition: background 0.2s;
}
.search-clear:hover { background: #8e8e93; }
@media (max-width: 768px) { .search-clear { right: 12px; } }
