/* ==========================================
   THEME CONFIGURATION
   ========================================== */
:root {
    --card-min-width: 280px;
    --card-aspect-ratio: 0.75; /* 3:4 соотношение */
    --sidebar-width: 60px;
    --header-height: 60px;
    --drawer-width: 320px;
    --drawer-handle: 28px;
    --color-download: #3b82f6;
    --color-video: #ef4444;
    --color-book: #10b981;
    --color-service-digital: #a855f7;
    --color-service-delivery: #f97316;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-overlay: rgba(255, 255, 255, 0.92);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --accent: #6366f1;
    --scroll-track: #f1f5f9;
    --scroll-thumb: #cbd5e1;
}

:root[data-theme="dark"] {
    --bg-main: #0f0f1a;
    --bg-card: #1e293b;
    --bg-sidebar: #1e293b;
    --bg-overlay: rgba(15, 23, 42, 0.95);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    --accent: #818cf8;
    --scroll-track: #0f0f1a;
    --scroll-thumb: #334155;
}

/* ==========================================
   BASE STYLES
   ========================================== */
* {
    box-sizing: border-box;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    transition: background 0.3s, color 0.3s;
    overflow-x: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* ==========================================
   APP LAYOUT (CSS GRID)
   ========================================== */
#app {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: var(--header-height) 1fr;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* ==========================================
   HEADER
   ========================================== */
header {
    grid-column: 1 / -1;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    z-index: 1000;
    min-height: var(--header-height);
    position: sticky;
    top: 0;
}

.logo-area {
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    user-select: none;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-area img {
    width: 28px; height: 28px;
    transition: filter 0.3s ease, transform 0.3s ease;
}

.logo-area:hover img {
    filter: drop-shadow(0 0 8px var(--accent));
    transform: scale(1.1);
}

.top-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* ==========================================
   SIDEBAR
   ========================================== */
aside {
    grid-row: 2 / -1;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: var(--header-height);
    left: 0;
    height: calc(100vh - var(--header-height));
    align-items: center;
    padding: 15px 0;
    padding-bottom: calc(15px + var(--safe-bottom));
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-bottom: 12px;
    position: relative;
    text-decoration: none;
    border: none;
    background: transparent;
    flex-shrink: 0;
}

.menu-btn:hover,
.menu-btn.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent);
}

.menu-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

aside .menu-btn:last-child {
    margin-top: auto;
    margin-bottom: 0;
}

.filter-active::after {
    content: '';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

/* ==========================================
   FILTER PANEL
   ========================================== */
.filter-panel {
    position: fixed;
    top: var(--header-height);
    left: var(--sidebar-width);
    width: 280px;
    max-width: calc(100vw - var(--sidebar-width) - 20px);
    height: calc(100vh - var(--header-height));
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    z-index: 90;
    overflow-y: auto;
    box-shadow: 5px 0 15px rgba(0,0,0,0.2);
    overscroll-behavior: contain;
    
    transform: translateX(-110%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease,
                visibility 0.3s ease;
}

.filter-panel.open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.filter-group {
    margin-bottom: 18px;
}

.filter-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
}

.filter-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.filter-input:focus {
    border-color: var(--accent);
}


/* =============================================================
   ZOOM CONTROL — кнопка масштаба (правый нижний угол)
   ============================================================= */
.zoom-control {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 8px;
}

/* Кнопка-триггер — лупа с плюсом */
.zoom-control-btn {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(var(--accent-rgb, 99,102,241), 0.45);
    transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}
.zoom-control-btn:hover {
    transform: scale(1.12) rotate(5deg);
    box-shadow: 0 6px 22px rgba(var(--accent-rgb, 99,102,241), 0.6);
}
.zoom-control-btn.panel-open {
    background: var(--accent);
    transform: scale(0.92) rotate(-5deg);
}
.zoom-control-btn svg { pointer-events: none; }

/* Подсказка-тост */
.zoom-hint {
    background: var(--bg-sidebar);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 0.78rem;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    display: none;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(6px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    min-width: 280px;
}
.zoom-hint.visible {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Панель масштаба */
.zoom-panel {
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 14px 16px 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    width: 268px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(.34,1.56,.64,1);
}
.zoom-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.zoom-panel-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.zoom-panel-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-step-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.18s, border-color 0.18s, transform 0.15s;
}
.zoom-step-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: scale(1.08);
}
.zoom-step-btn:active { transform: scale(0.93); }

.zoom-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
    padding: 0;
    height: 4px;
    border-radius: 2px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
    transition: background 0.2s;
}
.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb,99,102,241),0.4);
    transition: transform 0.15s;
}
.zoom-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.zoom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb,99,102,241),0.4);
}

.zoom-panel-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-muted);
}
#zoom-label-text { font-weight: 600; color: var(--text-main); }
#zoom-percent-text { font-size: 0.72rem; opacity: 0.65; }

.zoom-reset-btn {
    width: 100%;
    padding: 6px;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
}
.zoom-reset-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb,99,102,241),0.06);
}

/* =============================================================
   FILTER PANEL — улучшенная панель фильтров
   ============================================================= */
.filter-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.filter-reset-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    font-weight: 600;
}
.filter-reset-btn:hover {
    background: var(--accent);
    color: #fff;
}

.filter-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.filter-search-wrap {
    position: relative;
}
.filter-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.filter-search-clear:hover { background: var(--accent); color: #fff; }

.filter-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding: 12px 36px 12px 14px !important;
    min-height: 48px;
    font-size: 1rem;
    cursor: pointer;
}

/* Кнопки-теги типов материалов */
.type-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.type-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    border-radius: 20px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(.34,1.56,.64,1);
    white-space: nowrap;
    line-height: 1;
}
.type-tag svg {
    flex-shrink: 0;
    transition: transform 0.2s;
}
.type-tag:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb,99,102,241),0.06);
    transform: translateY(-1px);
}
.type-tag:hover svg { transform: rotate(-8deg) scale(1.1); }
.type-tag.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 3px 10px rgba(var(--accent-rgb,99,102,241),0.35);
    transform: translateY(-1px);
}
.type-tag.active svg { transform: scale(1.1); }
.type-tag:active { transform: scale(0.94); }

/* badge активных фильтров на сайдбаре */
.sidebar-filter-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    pointer-events: none;
    animation: badge-pop 0.25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* Кнопка скрыть фильтры */
.filter-hide-btn {
    width: 100%;
    margin-top: 12px;
    padding: 14px;
    min-height: 48px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.filter-hide-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ==========================================
   INFO DRAWER - ПАНЕЛЬ "СМОТРИ"
   ========================================== */
.info-drawer {
    position: fixed;
    top: 80px;
    left: calc(var(--sidebar-width) + 20px);
    width: 340px;
    height: 480px;
    min-width: 250px;
    min-height: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: visible;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    visibility: hidden;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.25s, transform 0.25s, visibility 0s linear 0.25s;
}
.info-drawer.state-open {
    visibility: visible;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.25s, transform 0.25s;
    display: flex !important;
}
.info-drawer.state-hidden {
    display: none !important;
}
.info-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.05);
    border-bottom: 1px solid var(--border-color);
    border-radius: 12px 12px 0 0;
    cursor: grab;
    user-select: none;
    touch-action: none;
}
.info-drawer-header:active { cursor: grabbing; }
.info-drawer-header .drag-icon { color: var(--text-muted); margin-right: 10px; }
.resizer { position: absolute; z-index: 10; touch-action: none; width: 10px; height: 10px; }
.resizer-n { top: -5px; left: 10px; right: 10px; height: 10px; width: auto; cursor: n-resize; }
.resizer-s { bottom: -5px; left: 10px; right: 10px; height: 10px; width: auto; cursor: s-resize; }
.resizer-e { top: 10px; bottom: 10px; right: -5px; width: 10px; height: auto; cursor: e-resize; }
.resizer-w { top: 10px; bottom: 10px; left: -5px; width: 10px; height: auto; cursor: w-resize; }
.resizer-nw { top: -5px; left: -5px; width: 15px; height: 15px; cursor: nw-resize; z-index: 11; }
.resizer-ne { top: -5px; right: -5px; width: 15px; height: 15px; cursor: ne-resize; z-index: 11; }
.resizer-sw { bottom: -5px; left: -5px; width: 15px; height: 15px; cursor: sw-resize; z-index: 11; }
.resizer-se { bottom: -5px; right: -5px; width: 15px; height: 15px; cursor: se-resize; z-index: 11; }

.card {
    background: var(--bg-card);
    border-radius: var(--card-radius);
    border-top: 4px solid var(--visor-color, gray);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(.34,1.56,.64,1), box-shadow 0.2s cubic-bezier(.34,1.56,.64,1);
    position: relative;
    content-visibility: auto;
    contain-intrinsic-size: auto 300px;
    will-change: transform;
}

/* --- Кнопка закрытия ("<") --- */
.info-drawer-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.info-drawer-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.info-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
    overscroll-behavior: contain;
    background: var(--bg-card);
    border-radius: 0 0 12px 12px;
}

/* Карточки внутри панели "Смотри" */
.info-card {
    background: var(--bg-main);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border-color);
}

.info-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.info-card:active {
    transform: scale(0.98);
}

.stream-card {
    background: transparent; /* <--- ПРОЗРАЧНЫЙ ФОН */
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    position: relative;
    border: 1px solid var(--accent);
    cursor: pointer;
}

.stream-card video {
    width: 100%;
    display: block;
    pointer-events: none;
}

.live-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #ef4444;
    color: white;
    padding: 2px 8px;
    font-size: 0.65rem;
    font-weight: bold;
    border-radius: 4px;
    animation: pulse 2s infinite;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

#btn-info-toggle.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent);
}

/* ==========================================
   INFO CARD OVERLAY (Развернутые карточки)
   ========================================== */
.info-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    backdrop-filter: blur(10px);
    overscroll-behavior: contain;
}

.info-overlay.active {
    opacity: 1;
    visibility: visible;
}

.info-overlay-content {
    background: var(--bg-card);
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    animation: infoZoomIn 0.3s ease-out;
}

@keyframes infoZoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.info-overlay-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 10;
    transition: background 0.2s;
}

.info-overlay-close:hover {
    background: var(--accent);
}

.info-overlay-media {
    width: 100%;
    background: transparent; /* <--- ПРОЗРАЧНЫЙ ФОН */
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    max-height: 60vh;
}

.info-overlay-media video,
.info-overlay-media img {
    width: 100%;
    max-height: 60vh;
    object-fit: contain;
}

.info-overlay-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    overscroll-behavior: contain;
}

/* ==========================================
   MAIN CONTENT AREA
   ========================================== */
main {
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
    overscroll-behavior: contain;
}

/* ==========================================
   VITRINE GRID (GRID STABILITY FIX)
   ========================================== */
#vitrine-grid {
    display: grid;
    /* auto-fill заполняет строку максимально возможным кол-вом колонок */
    grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
    gap: 15px;
    padding-bottom: 80px;
    width: 100%;
    /* Важно: предотвращает горизонтальный скролл на мобильном, если сетка чуть шире */
    box-sizing: border-box; 
}

/* КАРТОЧКА */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--border-color);
    border-top: 4px solid var(--visor-color, var(--border-color));
    transition: transform 0.1s linear, box-shadow 0.2s ease;
    cursor: pointer;
    
    /* === КРИТИЧЕСКИЕ ИСПРАВЛЕНИЯ РАЗМЕРОВ === */
    width: 100%;       /* Занимать всю ширину ячейки грида */
    min-width: 0;      /* РАЗРЕШАЕТ карточке сжиматься меньше контента (Fix для Grid) */
    aspect-ratio: 3 / 4; /* Фиксированная пропорция */
    
    display: flex;
    flex-direction: column;
}

.card:hover {
    z-index: 10;
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

/* Медиа-область (60% высоты) */
.card-media {
    width: 100%;
    /* flex-grow/shrink предотвращают сплющивание картинки */
    flex: 0 0 60%; 
    height: 60%; 
    background: transparent;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-media img,
.card-media video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Заполнять область без искажений */
    transition: transform 0.3s;
    display: block;
}

.card:hover .card-media img {
    transform: scale(1.05);
}

/* Контент (40% высоты) */
.card-content {
    padding: 10px; /* Чуть меньше паддинг для мобильных */
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Скрываем лишнее, если текст не влезает */
    justify-content: space-between;
}

.card-title {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.25;
    
    /* === ИСПРАВЛЕНИЕ ТЕКСТА === */
    word-wrap: break-word;      /* Переносить длинные слова */
    word-break: break-word;     /* Жесткий перенос, если слово шире карточки */
    hyphens: auto;              /* Переносы (дефисы) */
    
    /* Ограничение в 3 строки */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* Прижимаем к низу */
    white-space: nowrap; /* Мета-данные в одну строку */
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-price {
    font-weight: 700;
    color: var(--accent);
    font-size: 0.9rem;
}

/* Адаптив для очень маленького зума (компактный вид) */
.compact-view .card-content {
    display: none; /* Скрываем текст, оставляем только картинку */
}
.compact-view .card {
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    border-top-width: 2px;
}

/* scale-icon: <=120px — микро-квадрат без полей (иконки) */
#vitrine-grid.scale-icon { gap: 8px !important; }
#vitrine-grid.scale-icon .card { aspect-ratio: 1 / 1; border-radius: 4px; border-top-width: 1px; }
#vitrine-grid.scale-icon .card-media { flex: 1; height: 100%; transition: none; }
#vitrine-grid.scale-icon .card-content, #vitrine-grid.scale-icon .card-desc, #vitrine-grid.scale-icon .card-meta, #vitrine-grid.scale-icon .card-title, #vitrine-grid.scale-icon .card-price { display: none !important; }
.compact-view .card-media {
    flex: 1;
    height: 100%;
}

/* ==========================================
   EXPANDED CARD OVERLAY (WITH CONTROLS)
   ========================================== */
#overlay-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    z-index: 2000;
    
    display: flex;
    align-items: flex-start; 
    justify-content: center;
    
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch;
    padding: 30px 15px; 
}

#overlay-layer.active {
    opacity: 1;
    visibility: visible;
}

.expanded-card {
    background: transparent;
    width: 100%;
    max-width: 1100px;
    border-radius: 12px;
    margin: auto; 
    
    display: flex;
    flex-direction: row;
    
    position: relative;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;

    height: 85vh; 
    max-height: 800px;
    min-height: 400px;
}

/* --- Левая часть (Медиа) --- */
.exp-media {
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    overflow: hidden;
    width: 60%;
    min-width: 200px;
    max-width: calc(100% - 200px);
    flex-shrink: 0;
}

.exp-media video, 
.exp-media img {
    width: 100%;
    flex: 1;
    object-fit: contain;
    display: block;
    background: transparent;
    min-height: 0;
}

/* --- Панель управления видео --- */
.video-controls-panel {
    width: 100%;
    padding: 8px;
    background: transparent;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap; /* Перенос на новую строку */
    gap: 6px;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.video-ctrl-btn {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-main);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    transition: 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.video-ctrl-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.video-ctrl-btn:active {
    transform: scale(0.95);
}

.video-ctrl-btn .ctrl-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.video-ctrl-btn .ctrl-key {
    font-size: 0.6rem;
    opacity: 0.6;
    font-family: monospace;
    white-space: nowrap;
}

/* Индикатор скорости */
.speed-indicator {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 45px;
    text-align: center;
    cursor: pointer;
    transition: 0.2s;
}

.speed-indicator:hover {
    background: var(--bg-card);
    border-color: var(--accent);
}

/* Скрываем горячие клавиши на мобильных */
@media (max-width: 600px) {
    .video-ctrl-btn .ctrl-key {
        display: none;
    }
    
    .video-ctrl-btn {
        padding: 8px 10px;
    }
}

/* --- Разделитель (только визуальный, ресайз отключён) --- */
.exp-resizer {
    width: 10px;
    background: transparent;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

/* Точки-индикатор */
.exp-resizer::after {
    content: '⋮⋮';
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: -2px;
    opacity: 0.3;
}

/* --- Правая часть (Текст) --- */
.exp-info {
    display: flex;
    flex-direction: column;
    background: transparent;
    flex: 1;
    min-width: 200px;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.exp-info-scroll {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.exp-info-scroll h2 {
    margin: 0 0 10px 0;
    line-height: 1.2;
    font-size: 1.4rem;
    color: var(--text-main);
}

.exp-info-scroll .exp-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.exp-info-scroll .exp-desc {
    line-height: 1.5;
    font-size: 0.95rem;
    white-space: pre-wrap;
    color: var(--text-main);
}

/* --- Крестик закрытия --- */
.exp-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    opacity: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: 0.2s;
    stroke: currentColor;
}

.exp-close:hover { 
    opacity: 1;
    background: rgba(239,68,68,0.12);
    border-color: #ef4444;
    color: #ef4444;
    transform: scale(1.1);
}

/* Кнопка в развернутой карточке */
.exp-btn {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    display: block;
    text-decoration: none;
    font-size: 1rem;
}

/* Блокировка выделения текста при ресайзе */
.resizing {
    user-select: none;
    -webkit-user-select: none;
}

.resizing * {
    cursor: col-resize !important;
}

/* ==========================================
   МОБИЛЬНАЯ И СТЕСНЁННАЯ ВЕРСИЯ (< 900px)
   ========================================== */
@media (max-width: 900px) {
    #overlay-layer {
        padding: 10px;
        display: block;
        overflow-y: auto; 
    }

    .expanded-card {
        display: flex;
        flex-direction: column;
        height: auto !important;
        max-height: none !important;
        min-height: auto;
        border-radius: 8px;
        margin-bottom: 30px;
        background: transparent;
    }

    .exp-media {
        width: 100% !important;
        min-width: 100%;
        max-width: 100%;
        height: 40vh;
        min-height: 100px; /* Минимум для видимости */
        flex: none;
        background: transparent;
    }
    
    /* Разделитель на мобильном — только визуальный, ресайз отключён */
    .exp-resizer {
        width: 100%;
        height: 16px;
        cursor: default;
    }
    
    .exp-resizer::after {
        content: '⋯⋯';
        letter-spacing: 2px;
        opacity: 0.3;
    }
    
    .resizing * {
        cursor: default !important;
    }
    
    .exp-info {
        width: 100%;
        height: auto;
        min-width: auto;
        display: block;
        background: transparent;
    }

    .exp-info-scroll {
        padding: 15px;
        overflow: visible;
        height: auto;
    }

    .exp-close {
        position: fixed;
        top: 15px;
        right: 15px;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(5px);
        color: #ef4444;
        border: 1px solid rgba(239,68,68,0.3);
        opacity: 1;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }
    
    .exp-close:hover {
        background: rgba(239,68,68,0.2);
        border-color: #ef4444;
    }
    
    /* Панель управления на мобильных — компактнее */
    .video-controls-panel {
        padding: 6px;
        gap: 4px;
    }
    
    .video-ctrl-btn {
        padding: 5px 8px;
        min-width: 50px;
        font-size: 0.7rem;
    }
    
    .video-ctrl-btn .ctrl-icon {
        font-size: 1rem;
    }
    
    .video-ctrl-btn .ctrl-key {
        display: none; /* Скрываем комбинации клавиш на мобильных */
    }
}

/* Ещё более узкие экраны */
@media (max-width: 500px) {
    .video-controls-panel {
        gap: 3px;
    }
    
    .video-ctrl-btn {
        padding: 4px 6px;
        min-width: 40px;
    }
    
    .video-ctrl-btn .ctrl-label {
        display: none; /* Только иконки */
    }
    
    .video-ctrl-btn .ctrl-icon {
        font-size: 1.2rem;
    }
}

/* ==========================================
   LOAD MORE BUTTON
   ========================================== */
.load-more-container {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: 25px 0;
}

.load-more-btn {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
    width: 55px;
    height: 55px;
    border-radius: 50%;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.load-more-btn:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1) rotate(90deg);
}

/* ==========================================
   SCROLLBARS
   ========================================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scroll-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* ==========================================
   BUTTONS & UTILITIES
   ========================================== */
.btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    transition: filter 0.2s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    filter: brightness(1.1);
}

.btn:active {
    transform: scale(0.98);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

/* Анимация свечения для кнопки оплаты */
@keyframes glowing {
  0% { box-shadow: 0 0 5px #6366f1; }
  50% { box-shadow: 0 0 20px #6366f1, 0 0 10px #6366f1 inset; }
  100% { box-shadow: 0 0 5px #6366f1; }
}

.pay-btn-glow {
  background: linear-gradient(45deg, #4f46e5, #ec4899);
  color: white; 
  padding: 6px 15px; 
  border-radius: 6px; 
  text-decoration: none;
  font-weight: bold; 
  animation: glowing 1.5s infinite; /* Пульсация */
  border: none; 
  cursor: pointer;
  display: inline-block; 
  transition: transform 0.2s;
}
.pay-btn-glow:hover { transform: scale(1.05); }

/* ==========================================
   FOOTER
   ========================================== */
.app-footer {
    padding: 15px;
    padding-bottom: calc(15px + var(--safe-bottom));
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    flex-shrink: 0;
}

.app-footer a {
    color: inherit;
    text-decoration: none;
}

.app-footer a:hover {
    color: var(--accent);
}

/* ==========================================
   ADMIN TABLES
   ========================================== */
.admin-table-container {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.admin-table th {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
}

/* ==========================================
   AUTH PAGES STYLES
   ========================================== */
.auth-card {
    width: 95%;
    max-width: 600px;
    margin: 40px auto;
    padding: 30px;
}

.legal-scroll-box {
    height: 150px;
    overflow-y: auto;
    background: rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.fade-in-form {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.5s ease-in-out;
}

.fade-in-form.visible {
    opacity: 1;
    max-height: 1000px;
    margin-top: 20px;
}

/* ==========================================
   FORMS
   ========================================== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--accent);
}

/* ==========================================
   ALERTS
   ========================================== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid #10b981;
    color: #10b981;
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid #ef4444;
    color: #ef4444;
}

/* ==========================================
   RESPONSIVE - TABLET
   ========================================== */
@media (max-width: 900px) {
    .expanded-card {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .exp-media {
        max-height: 40vh;
    }
}

/* ==========================================
   RESPONSIVE - MOBILE
   ========================================== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 50px;
        --header-height: 50px;
        --card-min-width: 150px;
        --drawer-width: calc(100vw - var(--sidebar-width));
        --drawer-handle: 24px;
    }
    
    .logo-area span {
        display: none;
    }
    
    .menu-btn {
        width: 36px;
        height: 36px;
        margin-bottom: 10px;
    }
    
    .menu-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .filter-panel {
        width: calc(100vw - var(--sidebar-width) - 15px);
    }
    
    main {
        padding: 10px;
    }
    
    #vitrine-grid {
        gap: 10px;
    }
    
    .expanded-card {
        width: 98%;
        height: 95%;
    }
    
    .exp-info {
        padding: 15px;
    }
}

/* Горизонтальная прокрутка для мобильных отключена. 
   Сетка #vitrine-grid теперь вертикальная по умолчанию. */

/* ==========================================
   RESPONSIVE - SMALL MOBILE (portrait)
   ========================================== */
@media (max-width: 480px) {
    :root {
        --sidebar-width: 45px;
        --card-min-width: 130px;
        --drawer-width: calc(100vw - var(--sidebar-width));
    }
    
    .top-controls {
        gap: 8px;
    }
    
    .card-content {
        padding: 10px;
    }
    
    .card-title {
        font-size: 0.85rem;
    }
    
    .card-price {
        font-size: 0.9rem;
    }
}

/* ==========================================
   LANDSCAPE MOBILE
   ========================================== */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --header-height: 45px;
    }
    
    aside {
        padding: 8px 0;
    }
    
    .menu-btn {
        margin-bottom: 6px;
    }
}

@media (max-width: 768px), (max-height: 700px) {

    /* Карточки сохраняют строгий aspect-ratio 3/4 на всех экранах.
       Контент, который не влезает, обрезается — полный текст доступен при раскрытии карточки. */

    /* Отключаем перехват pointer-событий у video, чтобы свайп работал на мобильных */
    .card-media video {
        pointer-events: none;
    }
}

@media (max-width: 900px), (max-height: 700px) {

    /* 1) Открытая карточка становится единым scroll-контейнером */
    .expanded-card {
        overflow-y: auto;                 /* было: overflow: hidden; */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* 2) Убираем отдельный скролл у правой части, чтобы не было "скролл только текста" */
    .exp-info {
        overflow: visible;                /* было: overflow-y: auto; */
        max-height: none;
    }

    /* 3) На всякий случай: медиа не делает отдельную зону прокрутки */
    .exp-media {
        overflow: visible;                /* было: overflow: hidden; */
    }
}
/* --- CAROUSEL STYLES (New) --- */
.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: background 0.2s, transform 0.1s;
    user-select: none;
}
.carousel-nav:hover { background: var(--accent); }
.carousel-nav:active { transform: translateY(-50%) scale(0.9); }
.carousel-prev { left: 10px; }
.carousel-next { right: 10px; }

.carousel-counter {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.5);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 20;
}
/* Гарантирует, что контент внутри медиа-зоны всегда по центру и вписан */
.exp-media-content {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ключевое требование: показывать целиком */
    display: block;
}
/* ==========================================
   RESPONSIVE - MOBILE
   ========================================== */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 50px;
        --header-height: 50px;
        --card-min-width: 150px;
        
        /* ИЗМЕНЕНИЕ: Уменьшаем ширину панели до 85% экрана */
        --drawer-width: 85vw; 
        
        --drawer-handle: 24px;
    }

    /* Removed mobile overrides for floating info-drawer */
    
    .logo-area span {
        display: none;
    }
    
    .menu-btn {
        width: 36px;
        height: 36px;
        margin-bottom: 10px;
    }
    
    .menu-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .filter-panel {
        width: 100%;
        left: 0;
        z-index: 140;
    }
    
    main {
        padding: 10px;
    }
    
    #vitrine-grid {
        gap: 10px;
    }
    
    .expanded-card {
        width: 98%;
        height: 95%;
    }
    
    .exp-info {
        padding: 15px;
    }
}

/* ==========================================
   ZOOM SCALE LEVELS — Уровни детализации карточек
   Управляются из JS через классы на #vitrine-grid
   
   Пороги (280px = 100%):
     scale-xs: <240px (<86%)  — только квадратное изображение
     scale-sm: 240-280px      — фото + название (без цены)
     scale-md: 280-350px      — фото + название + цена (стандарт)
     scale-lg: 350-450px      — полная карточка
     scale-xl: >450px         — полная + описание
   ========================================== */

/* --- БАЗОВЫЕ ПЕРЕХОДЫ (ПЛАВНЫЕ) --- */
.card-content,
.card-media,
.card-desc,
.card-meta,
.card-price,
.card-views,
.card-author,
.card-title {
    transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease, font-size 0.3s ease;
    overflow: hidden;
}

.card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    max-height: 200px;
}

/* scale-xs: <240px — только квадратное изображение */
#vitrine-grid.scale-xs .card {
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    border-top-width: 2px;
}
#vitrine-grid.scale-xs .card-content {
    opacity: 0; max-height: 0; margin: 0; padding: 0; pointer-events: none;
}
#vitrine-grid.scale-xs .card-media { flex: 1; height: 100%; max-height: 100%; transition: height 0.3s; }

/* scale-sm: 240-280px — фото + название */
#vitrine-grid.scale-sm .card { aspect-ratio: 3 / 4; }
#vitrine-grid.scale-sm .card-media { flex: 0 0 65%; height: 65%; transition: height 0.3s; }
#vitrine-grid.scale-sm .card-desc  { opacity: 0; max-height: 0; margin: 0; pointer-events: none; }
#vitrine-grid.scale-sm .card-meta  { opacity: 0; max-height: 0; margin: 0; padding: 0; pointer-events: none; }
#vitrine-grid.scale-sm .card-price { opacity: 0; max-height: 0; margin: 0; padding: 0; pointer-events: none; }
#vitrine-grid.scale-sm .card-title { font-size: 0.82rem; opacity: 1; max-height: 45px; }

/* scale-md: 280-350px — фото + название + цена (стандарт 100%) */
#vitrine-grid.scale-md .card { aspect-ratio: 3 / 4; }
#vitrine-grid.scale-md .card-media { flex: 0 0 62%; height: 62%; transition: height 0.3s; }
#vitrine-grid.scale-md .card-desc  { opacity: 0; max-height: 0; margin: 0; pointer-events: none; }
#vitrine-grid.scale-md .card-meta  { opacity: 0; max-height: 0; margin: 0; padding: 0; pointer-events: none; }
#vitrine-grid.scale-md .card-title { font-size: 0.9rem; opacity: 1; max-height: 45px; }
#vitrine-grid.scale-md .card-price { opacity: 1; max-height: 60px; margin-top: auto; }

/* scale-lg: 350-450px — полная карточка */
#vitrine-grid.scale-lg .card { aspect-ratio: 3 / 4; }
#vitrine-grid.scale-lg .card-media { flex: 0 0 60%; height: 60%; transition: height 0.3s; }
#vitrine-grid.scale-lg .card-desc  { opacity: 0; max-height: 0; margin: 0; pointer-events: none; }
#vitrine-grid.scale-lg .card-title { font-size: 0.95rem; opacity: 1; max-height: 45px; }
#vitrine-grid.scale-lg .card-meta  { opacity: 1; max-height: 40px; margin-top: 10px; }
#vitrine-grid.scale-lg .card-price { opacity: 1; max-height: 60px; margin-top: auto; }

/* scale-xl: >450px — полная карточка с описанием */
#vitrine-grid.scale-xl .card { aspect-ratio: auto; min-height: 480px; }
#vitrine-grid.scale-xl .card-media { flex: 0 0 55%; height: 55%; transition: height 0.3s; }
#vitrine-grid.scale-xl .card-desc  { opacity: 1; max-height: 200px; margin-top: 5px; margin-bottom: 5px; }
#vitrine-grid.scale-xl .card-title { font-size: 1.05rem; opacity: 1; max-height: 60px; }
#vitrine-grid.scale-xl .card-meta  { opacity: 1; max-height: 40px; margin-top: 10px; }
#vitrine-grid.scale-xl .card-price { font-size: 1rem; opacity: 1; max-height: 60px; margin-top: auto; }

/* Анимация перехода между уровнями */
#vitrine-grid .card {
    transition: aspect-ratio 0.4s ease, border-radius 0.3s ease, min-height 0.4s ease;
}

