@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');

:root {
    /* Основной фон сайта (сделали чуть светлее для контраста) */
    --bg-color: #181818;
    --header-bg: rgba(24, 24, 24, 0.85);
    --card-bg: #222222;
    --card-hover: #2a2a2a;
    --text-color: #e0e0e0;
    --text-muted: #808080;
    --border-color: #333333;
    --border-dashed: #444444;
    --btn-bg: #222222;
    --btn-hover: #2a2a2a;
    --btn-text: #e0e0e0;
    
    /* Неоновый кибер-голубой акцент */
    --accent-color: #00e5ff;
    --accent-text: #000000;
    --accent-hover: #00b3cc;
    --accent-shadow: #008899;
    
    --dropzone-hover: rgba(0, 229, 255, 0.08);
    --danger-hover: #ff4d4d;
    --danger-shadow: #cc0000;
    
    /* Цвета тиров (ТЕМНАЯ ТЕМА) */
    --tier-border: #000000;    
    --tier-bg: #121212;        
    --tier-action-bg: #121212; 
}

body.light-theme {
    /* Светлая тема в стиле Twitch */
    --bg-color: #f1f5f9;
    --header-bg: rgba(241, 245, 249, 0.85);
    --card-bg: #ffffff;
    --card-hover: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --border-dashed: #94a3b8;
    --btn-bg: #ffffff;
    --btn-hover: #f1f5f9;
    --btn-text: #0f172a;
    
    --accent-color: #7c3aed;
    --accent-text: #ffffff;
    --accent-hover: #6d28d9;
    --accent-shadow: #5b21b6;
    
    --dropzone-hover: rgba(124, 58, 237, 0.05);
    --danger-hover: #ef4444;
    --danger-shadow: #b91c1c;
    
    /* Цвета тиров (СВЕТЛАЯ ТЕМА) */
    --tier-border: #ffffff;    
    --tier-bg: #e2e8f0;        
    --tier-action-bg: #f1f5f9; 
}

/* ================= БАЗОВЫЕ НАСТРОЙКИ ================= */
* { box-sizing: border-box; user-select: none; }

/* Железобетонно фиксируем ширину экрана */
html {
    overflow-y: scroll; 
}

/* 🎨 КАСТОМИЗИРУЕМ ГЛОБАЛЬНЫЙ СКРОЛЛБАР */
::-webkit-scrollbar { 
    width: 8px; /* Тонкий и аккуратный */
}
::-webkit-scrollbar-track { 
    background: transparent; /* Делаем дорожку ПОЛНОСТЬЮ ПРОЗРАЧНОЙ! Теперь пустой скролл невидим */
}
::-webkit-scrollbar-thumb { 
    background: var(--border-dashed); /* Цвет самого ползунка */
    border-radius: 4px; 
}
::-webkit-scrollbar-thumb:hover { 
    background: var(--accent-color); /* Неоновое свечение при наведении */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color); color: var(--text-color);
    margin: 0; padding: 0; min-height: 100vh;
    display: flex; flex-direction: column; align-items: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

input, button, select, textarea {
    font-family: 'Inter', system-ui, sans-serif !important;
}

body.modal-open { 
    overflow: hidden; 
    padding-right: 8px; /* Равно ширине нашего нового скроллбара */
}
body.titles-hidden .item-title-overlay { display: none !important; }

/* ================= ЛЕЙАУТ И ШАПКА ================= */
header {
    width: 100%; 
    max-width: none;
    min-height: 60px; /* Увеличили высоту (было 50px) */
    display: flex; 
    justify-content: space-between;
    align-items: center; 
    padding: 8px 26px; /* Увеличили отступы (было 6px 24px) */
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 1500; 
    background-color: var(--header-bg); 
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: none;
    transition: background-color 0.2s ease;
}

.page { 
    width: 100%; max-width: none !important; 
    padding: 0 30px 40px 30px; display: none; 
    flex-direction: column; align-items: stretch; 
}
.page.active { display: flex; }

#builder-page { max-width: 1400px !important; margin: 0 auto; }
.section-title { width: 100%; font-size: 22px; font-weight: 700; margin-bottom: 20px; text-align: left; }

.header-left, .header-right { 
    display: flex; align-items: center; gap: 10px; 
    height: 44px; /* <--- Жестко фиксируем высоту верхнего ряда */
} 

/* Минималистичные кнопки в шапке (Язык и Тема) */
header .theme-icon-btn {
    width: 36px !important; height: 36px !important; 
    font-size: 15px !important; 
    border-radius: 50% !important; /* Делаем круглыми */
    background: transparent !important; /* Убираем фон */
    border: none !important; /* Убираем рамки */
    box-shadow: none !important; /* Убираем 3D-тени */
    transition: background 0.15s ease, transform 0.1s ease !important;
}
header .theme-icon-btn:hover { 
    background: rgba(255, 255, 255, 0.06) !important; /* Мягкая подсветка как у поиска */
    transform: scale(1.05) !important; /* Легкое увеличение при наведении */
}
body.light-theme header .theme-icon-btn:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}
header .theme-icon-btn:active { 
    transform: scale(0.99) !important; /* Мягко "вдавливается" при клике */
}

/* ================= ГЛОБАЛЬНЫЙ ПОИСК В ШАПКЕ ================= */
.header-center {
    flex: 1; display: flex; justify-content: center; 
    align-items: center; 
    max-width: 580px; margin: 0 20px;
    height: 44px; /* <--- Фиксируем высоту, чтобы поиск перестал прыгать */
}

.global-search-container {
    display: flex; align-items: center; width: 100%;
    background: rgba(255, 255, 255, 0.04); 
    border: 1px solid transparent;
    border-radius: 30px; 
    padding: 4px 16px; /* Вернули комфортную высоту (было 2px 14px) */
    transition: background 0.2s ease, border-color 0.2s ease;
}

.global-search-container:focus-within {
    background: transparent;
    border-color: var(--border-color);
    box-shadow: none;
}
body.light-theme .global-search-container { background: rgba(0, 0, 0, 0.04); }
body.light-theme .global-search-container:focus-within { background: transparent; border-color: var(--border-color); box-shadow: none; }

#global-search-input {
    flex: 1; background: transparent; border: none; color: var(--text-color);
    font-size: 15px; /* Увеличили текст ввода (было 13px) */
    outline: none; 
    padding: 6px 0; /* Сделали зону клика по тексту больше */
    min-width: 0; 
}
#global-search-input::placeholder { color: var(--text-muted); font-weight: 400; }

/* Крестик очистки поиска */
.search-clear-btn {
    background: transparent; border: none; color: var(--text-muted);
    margin: 0 4px; cursor: pointer; padding: 4px; 
    display: flex; align-items: center; justify-content: center;
    transition: color 0.15s ease, background 0.15s ease;
    border-radius: 50%;
    width: 24px; height: 24px;
}
.search-clear-btn:hover { color: var(--text-color); background: rgba(255,255,255,0.08); }
body.light-theme .search-clear-btn:hover { background: rgba(0,0,0,0.06); }

.search-actions {
    display: flex; gap: 4px; margin-left: 6px; border-left: none; padding-left: 0;
}

.search-action-btn {
    background: transparent; border: none; color: var(--text-muted); 
    border-radius: 50%; 
    width: 28px; height: 28px; /* Увеличили кнопку шестеренки (было 24x24) */
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; 
    font-size: 15px; /* Увеличили иконку шестеренки (было 13px) */
    transition: color 0.15s ease, background 0.15s ease;
}
.search-action-btn:hover { color: var(--text-color); background: rgba(255,255,255,0.05); }
body.light-theme .search-action-btn:hover { background: rgba(0,0,0,0.05); }

/* ================= СЕТКА ШАБЛОНОВ (ПРЕМИАЛЬНАЯ ГАЛЕРЕЯ) ================= */
.templates-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); /* Сделали карточки чуть шире */
    gap: 24px; /* Увеличили "воздух" между карточками */
    width: 100%; 
    margin-bottom: 40px; 
    padding-top: 10px; /* ИСПРАВЛЕНИЕ БАГА: Дали место сверху, чтобы рамка не обрезалась */
    align-content: start;

    contain: layout paint;
}
.templates-grid::-webkit-scrollbar { width: 8px; }
.templates-grid::-webkit-scrollbar-track { background: transparent; }
.templates-grid::-webkit-scrollbar-thumb { background: var(--border-dashed); border-radius: 4px; }
.templates-grid::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }

.template-card {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--border-color); 
    border-radius: 14px; 
    overflow: hidden; 
    cursor: pointer;
    display: flex;
    flex-direction: column;
    padding: 0; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.15); 
    
    /* 1. Заменили прыгучий cubic-bezier на плавный ease-out и синхронизировали время (0.4s) */
    transition: transform 0.4s ease-out, box-shadow 0.4s ease-out, border-color 0.4s ease;

    content-visibility: auto; 
    contain-intrinsic-size: auto 200px; /* Подсказка браузеру о примерной высоте карточки */
}

/* Эффект парения при наведении */
.template-card:hover {
    transform: translateY(-4px); /* 2. Снизили подъем с -6px до -4px. Это более деликатно */
    border-color: rgba(255, 255, 255, 0.25); 
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    z-index: 10;
}
body.light-theme .template-card:hover { border-color: rgba(0,0,0,0.15); box-shadow: 0 15px 35px rgba(0,0,0,0.1); }

/* Обертка для картинки (задает пропорции и фоновый градиент-заглушку) */
.template-card-img-wrapper {
    position: relative; 
    width: 100%;
    aspect-ratio: 16 / 9; 
    overflow: hidden; /* Чтобы при увеличении картинка не вылезала за скругления углов карточки */
    background: linear-gradient(135deg, var(--card-hover) 0%, var(--bg-color) 100%);
}

/* Сама картинка */
.template-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Обрезает картинку по размеру окна, как background-size: cover */
    display: block;
    
    filter: saturate(0.7) brightness(0.8);
    transition: filter 0.4s ease, transform 0.4s ease-out;
}

/* При наведении картинка возвращает цвета и плавно увеличивается */
.template-card:hover .template-card-img {
    filter: saturate(1) brightness(1);
    transform: scale(1.04); 
    will-change: transform, filter; /* Аппаратное ускорение только в момент наведения */
}

/* Блок с текстом СНИЗУ (больше никаких градиентов поверх картинок) */
.template-card-content {
    position: relative;
    background: transparent;
    padding: 14px 16px;
    display: flex; flex-direction: column; z-index: 2;
    border-top: 1px solid var(--border-color); /* Тонкая линия отсекает картинку от текста */
}

.template-card-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0; 
    color: var(--text-color); /* Текст теперь цвета интерфейса, а не белый */
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    text-align: left; /* Текст слева выглядит более по-журнальному */
    text-shadow: none; /* Убрали тени за ненадобностью */
}

/* Стеклянный бейджик (Glassmorphism) */
.template-item-count {
    position: absolute;
    top: 10px; right: 10px;
    
    /* Делаем фон чуть более плотным, чтобы текст хорошо читался без размытия */
    background: rgba(0, 0, 0, 0.75); 
    
    color: #ffffff;
    font-size: 12px; font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px; 
    z-index: 5;
    border: 1px solid rgba(255,255,255,0.1);
}

/* --- Карточка "Создать шаблон" --- */
.template-card.create-new-card {
    border: 2px dashed var(--border-dashed);
    background: transparent;
    box-shadow: none;
    aspect-ratio: auto;
    height: 100%;
    min-height: 180px; 
}
.template-card.create-new-card:hover {
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: none;
    transform: translateY(-4px);
}
body.light-theme .template-card.create-new-card:hover { background: rgba(0, 0, 0, 0.02); }

.create-new-content {
    width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.create-new-content .plus-icon { font-size: 32px; font-weight: 300; color: var(--text-muted); margin-bottom: 6px; transition: color 0.2s; }
.create-new-content .create-text { font-size: 14px; font-weight: 600; color: var(--text-muted); transition: color 0.2s; }
.template-card.create-new-card:hover .plus-icon, .template-card.create-new-card:hover .create-text { color: var(--accent-color); }

/* ================= ССЫЛКИ ================= */
.btn-link {
    background: transparent; border: none; color: var(--text-muted); font-size: 14px;
    font-weight: 600; cursor: pointer; padding: 4px 8px; transition: color 0.2s ease; box-shadow: none;
}
.btn-link:hover { color: var(--accent-color); transform: translateX(3px); }

/* ================= КНОПКИ И ЭЛЕМЕНТЫ УПРАВЛЕНИЯ ================= */
.btn {
    background: var(--btn-bg); color: var(--btn-text); border: 2px solid var(--border-color);
    padding: 10px 18px; border-radius: 8px; font-weight: 500; cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.1s ease;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 14px;
    box-shadow: 0 4px 0 var(--border-color); transform: translateY(0);
}
.btn:hover { background: var(--btn-hover); transform: translateY(1px); box-shadow: 0 3px 0 var(--border-color); }
.btn:active { transform: scale(0.99) !important; opacity: 0.65 !important; box-shadow: none !important; transition: all 0.25s ease !important; }

.btn-primary { background: var(--accent-color); color: var(--accent-text); border-color: var(--accent-shadow); box-shadow: 0 4px 0 var(--accent-shadow); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 3px 0 var(--accent-shadow); }
.btn-danger { color: #fff; background: var(--danger-hover); border-color: var(--danger-shadow); box-shadow: 0 4px 0 var(--danger-shadow); }
.btn-danger:hover { background: #ff3333; box-shadow: 0 3px 0 var(--danger-shadow); }
body.light-theme .btn-danger:hover { background: #dc2626; }

.builder-header { width: 100%; max-width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 10px; }

.title-input {
    flex-grow: 1; width: auto; background: transparent; border: none; border-bottom: 2px solid var(--border-color); color: var(--text-color);
    font-size: 28px; font-weight: 500; padding: 10px 0; outline: none; transition: border-color 0.2s, text-shadow 0.2s;
}
.title-input:focus { border-bottom-color: var(--accent-color); text-shadow: 0 0 10px rgba(0, 229, 255, 0.2); }
body.light-theme .title-input:focus { text-shadow: none; }
.title-input::placeholder { color: var(--text-muted); font-weight: 600; }

/* Слегка уменьшим отступ, так как у кнопок исчезли рамки */
.icon-controls { display: flex; align-items: center; gap: 4px; } 

/* Минималистичные кнопки конструктора */
.icon-btn, .theme-icon-btn {
    background: transparent; border: none; 
    border-radius: 50%; /* Строгий круглый дизайн */
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    font-size: 18px; cursor: pointer; color: var(--text-color);
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease; 
    padding: 0; outline: none; box-shadow: none; /* Убили все 3D-тени и рамки */
}

/* Эффекты наведения (мягкое свечение) */
.icon-btn:hover, .theme-icon-btn:hover { 
    background: rgba(255, 255, 255, 0.06); 
    transform: scale(1.05); 
}

.icon-btn.active {
    color: var(--accent-color) !important;
    background: rgba(0, 229, 255, 0.1) !important;
}
body.light-theme .icon-btn.active {
    background: rgba(124, 58, 237, 0.1) !important;
}

body.light-theme .icon-btn:hover, body.light-theme .theme-icon-btn:hover { 
    background: rgba(0, 0, 0, 0.06); 
}

.icon-btn:active, .theme-icon-btn:active { 
    transform: scale(0.99) !important; 
    opacity: 0.65 !important;
    transition: all 0.25s ease !important;
}

/* Цветные подсветки для специфичных кнопок (Удалить, Сохранить) */
.icon-btn.primary-hover:hover { 
    color: var(--accent-color); 
    background: rgba(0, 229, 255, 0.1); 
}
.icon-btn.danger-hover:hover { 
    color: #ff4d4d; 
    background: rgba(255, 77, 77, 0.1); 
}
body.light-theme .icon-btn.primary-hover:hover { 
    background: rgba(124, 58, 237, 0.1); 
}

/* Выпадающие меню (Игровой UI) */
.hover-dropdown { position: relative; display: inline-block; }
.hover-dropdown::after { content: ''; position: absolute; top: 100%; left: -10px; right: -10px; height: 25px; }
.dropdown-menu {
    position: absolute; top: calc(100% + 15px); right: 0; width: 240px;
    background: var(--card-bg); border: 2px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6); display: flex; flex-direction: column;
    opacity: 0; visibility: hidden; transform: translateY(-10px); transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease-out; z-index: 200; overflow: hidden;
}
.hover-dropdown:hover .dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.icon-controls:hover .hover-dropdown:not(:hover) .dropdown-menu { transition: none; opacity: 0; visibility: hidden; transform: translateY(-10px); }

.menu-item {
    background: transparent; border: none; text-align: left; padding: 14px 16px; width: 100%; display: block;
    color: var(--text-color); cursor: pointer; font-size: 14px; font-weight: 600; outline: none; transition: background 0.1s, padding-left 0.2s;
}
.menu-item:not(:last-child) { border-bottom: 2px solid var(--border-color); }
.menu-item:hover { background: var(--card-hover); color: var(--accent-color); padding-left: 20px; }


/* ================= ТИР-ЛИСТЫ И КОНТЕЙНЕРЫ (Монолитный стиль) ================= */
#capture-area, #view-capture-area { width: 100%; max-width: 100%; background-color: var(--bg-color); padding: 15px; border-radius: 12px; transition: background-color 0.2s ease; }

.tier-container { 
    display: flex; flex-direction: column; gap: 0; 
    border: 1px solid var(--tier-border); 
    background-color: var(--tier-border); 
    border-radius: 8px; overflow: hidden; 
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.tier-row {
    display: flex; min-height: 80px; height: auto;
    border-bottom: 1px solid var(--tier-border); 
    position: relative;
    transition: border-color 0.2s ease;
}
.tier-row:last-child { border-bottom: none; }

.tier-label-wrapper {
    position: relative; width: 100px; flex-shrink: 0; display: flex; align-items: center;
    justify-content: center; overflow: hidden; 
    border-right: 1px solid var(--tier-border);
    transition: border-color 0.2s ease;
}
.tier-label {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; color: #111; text-align: center; padding: 10px; word-break: break-word; outline: none; cursor: text;
}
.view-only-label { cursor: default !important; }

.color-picker-btn {
    position: absolute; top: 5px; right: 5px; opacity: 0; transition: opacity 0.2s; cursor: pointer; background: rgba(0,0,0,0.6); border-radius: 6px;
    width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 12px;
}
.tier-label-wrapper:hover .color-picker-btn { opacity: 1; }
.color-input { position: absolute; opacity: 0; width: 100%; height: 100%; top: 0; left: 0; cursor: pointer; }

.tier-actions {
    width: 38px; display: flex; flex-direction: column; 
    background: var(--tier-action-bg); 
    border-left: 1px solid var(--tier-border); 
    transition: background 0.2s ease, border-color 0.2s ease; 
    min-height: 80px;
}
.tier-action-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; padding: 0;
    color: var(--text-muted); cursor: pointer; transition: background 0.1s, color 0.1s; font-size: 15px; min-height: 26px;
}
.tier-action-btn:hover { background: rgba(255,255,255,0.08); color: var(--text-color); }
body.light-theme .tier-action-btn:hover { background: rgba(124, 58, 237, 0.08); }
.tier-drag-handle { cursor: grab; }
.tier-drag-handle:active { cursor: grabbing; }

.drag-icon-svg { stroke: currentColor; opacity: 0.6; transition: opacity 0.2s; }
.tier-action-btn:hover .drag-icon-svg { opacity: 1; color: var(--accent-color); }

.tier-dropzone {
    flex-grow: 1; display: flex; flex-wrap: wrap; align-items: flex-start; align-content: flex-start; 
    min-height: 80px; transition: background 0.2s;
}
#tier-container .tier-dropzone, #view-tier-container .tier-dropzone { 
    gap: 0; padding: 0; 
    background: var(--tier-bg); 
    transition: background 0.2s ease;
}
#pool-dropzone { 
    gap: 8px; padding: 10px 5px; border-radius: 6px; 
    justify-content: center !important; align-content: flex-start !important; align-items: flex-start !important; 
    contain: layout; 
    /* Новое свойство: */
    flex-grow: 1;
}

.add-tier-big-btn {
    width: 100%; margin-top: 0; padding: 4px; background: transparent; border: none; border-top: 1px dashed var(--border-dashed); 
    border-radius: 0 0 8px 8px; color: var(--text-muted); font-size: 12px; font-weight: 700; cursor: pointer; display: flex; 
    align-items: center; justify-content: center; transition: all 0.15s ease; min-height: 24px; opacity: 0.6;
}
.add-tier-big-btn:hover { opacity: 1; background: rgba(0, 229, 255, 0.05); color: var(--accent-color); border-top-color: var(--accent-color); }

/* ================= ПАНЕЛЬ ЭЛЕМЕНТОВ (POOL) ================= */
.pool-container {
    width: 100%; max-width: 100%; margin-top: 10px; background: var(--card-bg); border-radius: 12px;
    padding: 10px 15px; border: 2px dashed var(--border-dashed); transition: border-color 0.2s ease;
    /* Новые свойства: */
    display: flex;
    flex-wrap: wrap; /* Позволит блоку поиска занимать всю ширину при клике */
    align-items: flex-start;
    gap: 12px;
}

/* ================= ЗОНЫ УДАЛЕНИЯ ЭЛЕМЕНТОВ (КОРЗИНЫ) ================= */
.delete-dropzone, .tier-delete-dropzone {
    position: fixed; top: 0; right: 0; width: 155px; height: 100vh;
    background: rgba(255, 77, 77, 0.1); border-left: 3px dashed rgba(255, 77, 77, 0.3); color: #ff4d4d; font-weight: 700; text-align: center;
    z-index: 2000; backdrop-filter: blur(4px); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.25s, visibility 0.25s, background 0.2s, border-color 0.2s;
    display: block; 
}
.delete-dropzone.active-zone, .tier-delete-dropzone.active-zone { opacity: 1; visibility: visible; pointer-events: auto; }
.delete-dropzone.drag-over, .tier-delete-dropzone.drag-over { background: rgba(255, 77, 77, 0.2); border-left-color: #ff4d4d; }

.delete-dropzone::before, .tier-delete-dropzone::before { content: ''; display: inline-block; height: 100%; vertical-align: middle; }

.delete-text-label {
    position: absolute; top: calc(50% + 20px); left: 0; width: 100%;
    font-size: 13px !important; padding: 0 10px !important; line-height: 1.3 !important; 
    transform: translateY(-50%); pointer-events: none; z-index: 10;
    opacity: 1;
    transition: opacity 0.2s ease 0.4s; 
}

.delete-dropzone:hover .delete-text-label,
.tier-delete-dropzone:hover .delete-text-label,
.delete-dropzone:has(.sortable-ghost) .delete-text-label,
.tier-delete-dropzone:has(.sortable-ghost-tier) .delete-text-label,
.delete-dropzone:has(.strike) .delete-text-label,
.tier-delete-dropzone:has(.strike) .delete-text-label {
    opacity: 0;
    transition: opacity 0.1s ease 0s; 
}

/* ================= СТРУКТУРА КАРТОЧЕК И ИЗОБРАЖЕНИЙ ================= */
.item-wrapper, .tier-drag-handle, .tier-row { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

.item-wrapper { 
    position: relative; width: 80px; height: 80px; cursor: grab; background-color: transparent; flex-shrink: 0; 
    contain: layout style; 
}

.sortable-drag { will-change: transform; }
.item-wrapper:active { cursor: grabbing; }

#tier-container .item-wrapper, #view-tier-container .item-wrapper { margin: 0; vertical-align: top; }

.item-content {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 8px; overflow: hidden;
    transition: transform 0.15s ease-out, box-shadow 0.15s ease; background-color: transparent; border: none; box-shadow: none;
}

#tier-container .item-content, #view-tier-container .item-content { border-radius: 0; } 

.item-wrapper:not(.sortable-drag):hover .item-content { transform: scale(1.08); box-shadow: none !important; background-color: transparent !important; }

.item { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }

.add-item-card {
    width: 80px; height: 80px; border-radius: 8px; border: 2px dashed var(--border-dashed);
    background: var(--card-bg); color: var(--text-muted); font-size: 32px; font-weight: 300;
    display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
    transition: transform 0.1s, background 0.1s, color 0.1s; order: 9999;
}
.add-item-card:hover { border-color: var(--accent-color); color: var(--accent-color); background: var(--card-hover); transform: scale(1.05); }
#file-input { display: none; }

/* ================= ВСТРОЕННЫЙ ДОК ДОБАВЛЕНИЯ (INLINE) ================= */
.inline-add-dock {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed var(--border-dashed);
    border-radius: 12px;
    height: 80px; /* Высота подстраивается под дефолтные картинки */
    padding: 0 15px;
    order: 9999; /* Всегда держим в самом конце панели */
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.inline-add-dock:hover {
    border-color: var(--accent-color);
    background: rgba(0, 229, 255, 0.05);
}

body.light-theme .inline-add-dock { background: rgba(0, 0, 0, 0.02); }
body.light-theme .inline-add-dock:hover { background: rgba(124, 58, 237, 0.05); border-color: var(--accent-color); }

.inline-add-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
}

.inline-add-btn:hover {
    color: var(--accent-color);
    background: var(--card-bg);
    transform: scale(1.15);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.inline-add-btn:active {
    transform: scale(0.95) !important;
}

@media (max-width: 768px) {
    .inline-add-dock { height: 65px; padding: 0 10px; gap: 4px; }
    .inline-add-btn { width: 34px; height: 34px; }
}

.item-title-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; 
    align-items: flex-end; 
    justify-content: center; 
    padding: 6px; padding-bottom: 8px; 
    text-align: center; color: #ffffff; font-size: 11px;
    font-weight: 700; word-break: break-word; 
    
    opacity: 1; 
    transform: scale(1); 
    transition: opacity 0.15s, transform 0.15s; 
    
    background: transparent; 
    
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
         0px  3px 5px rgba(0,0,0,0.9);
}

.item-title-overlay[contenteditable="true"] { opacity: 1; transform: scale(1); background: rgba(0, 0, 0, 0.8); border: 2px solid var(--accent-color); }

/* Уведомления */
.toast {
    position: fixed; bottom: 25px; right: 25px; background: var(--card-bg); color: var(--text-color);
    border: 2px solid var(--border-color); padding: 14px 20px; border-radius: 12px; font-size: 14px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5); opacity: 0; transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s; pointer-events: none; z-index: 9999 !important; 
    display: flex; flex-direction: column; gap: 3px; font-weight: 500;
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.toast-subtitle { font-size: 12px; color: var(--accent-color); font-weight: 600; }

/* ================= АНИМАЦИИ СОРТИРОВКИ И DRAG & DROP ================= */
.sortable-ghost { opacity: 1 !important; }
.sortable-ghost .item-content { opacity: 0.3 !important; transform: scale(0.9) !important; border: none !important; filter: grayscale(1); }
.sortable-ghost-tier { opacity: 0.3 !important; background-color: var(--card-bg) !important; border: none !important; border-radius: 8px !important; }

.sortable-drag .item-content { transform: scale(1.15); box-shadow: none !important; background-color: transparent !important; transition: transform 0.1s ease-out; }
.sortable-drag-tier { opacity: 0.95 !important; background: var(--card-hover) !important; box-shadow: 0 25px 50px rgba(0,0,0,0.8), 0 0 0 2px var(--accent-color) !important; cursor: grabbing !important; z-index: 9999 !important; }

#delete-zone .sortable-ghost, #tier-delete-zone .sortable-ghost-tier { display: none !important; }
#delete-zone .item-wrapper { position: absolute !important; left: 50% !important; top: 50% !important; margin-left: -40px !important; margin-top: -40px !important; pointer-events: none !important; z-index: 100 !important; }
#tier-delete-zone .tier-row { position: absolute !important; left: 10px !important; right: 10px !important; width: auto !important; top: 50% !important; margin-top: -40px !important; pointer-events: none !important; z-index: 100 !important; }

@keyframes popIn { 0% { transform: scale(0.6) translateY(-10px); opacity: 0; } 50% { transform: scale(1.15) rotate(3deg); opacity: 1; } 100% { transform: scale(1) rotate(0deg); opacity: 1; } }
.item-pop .item-content { animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes tierPop { 0% { transform: scale(0.98); } 50% { transform: scale(1.01); } 100% { transform: scale(1); } }
.tier-pop { animation: tierPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

.drag-over-file, .sortable-dragover { background-color: var(--dropzone-hover) !important; box-shadow: inset 0 0 20px rgba(0, 229, 255, 0.1) !important; border-radius: 8px !important; transition: all 0.15s ease; }
.pool-container.drag-over-file { box-shadow: inset 0 0 20px rgba(0, 229, 255, 0.2) !important; border-color: var(--accent-color) !important; }

@keyframes slideInTier { 0% { opacity: 0; transform: scaleY(0.5) translateY(-30px); transform-origin: top; } 100% { opacity: 1; transform: scaleY(1) translateY(0); transform-origin: top; } }
.tier-row.animate-in { animation: slideInTier 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

@keyframes slideOutTier { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.95); margin-bottom: -110px; border-color: transparent; } }
.tier-row.animate-out { animation: slideOutTier 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards; pointer-events: none; }

@keyframes suckInItem { 0% { transform: scale(1) rotate(0deg); opacity: 1; } 100% { transform: scale(0) rotate(180deg); opacity: 0; } }
.sucking-in .item-content { animation: suckInItem 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards !important; }

@keyframes suckInTier { 0% { transform: scale(1); opacity: 1; filter: blur(0); } 100% { transform: scale(0) rotate(15deg); opacity: 0; filter: blur(5px); } }
.tier-row.sucking-in-tier { animation: suckInTier 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards !important; pointer-events: none; }

@keyframes fallDownItem {
    0% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
    20% { transform: translateY(-15px) scale(1.05) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) scale(0.5) rotate(var(--fall-rot, 15deg)); opacity: 0; }
}

.falling-down {
    z-index: 9999 !important;
    contain: none !important; 
}

.falling-down .item-content { 
    animation: fallDownItem 0.6s ease-in forwards !important; 
}

/* ================= АНИМАЦИЯ РАЗБИВАНИЯ НА ПИКСЕЛИ ================= */
.shatter-particle {
    opacity: 1;
    border-radius: 2px;
    box-shadow: 0 0 3px rgba(0,0,0,0.6);
    transition: transform 0.6s cubic-bezier(0.15, 0.85, 0.35, 1), opacity 0.5s ease-in-out;
}
.shatter-particle.explode {
    transform: translate(var(--rx), var(--ry)) rotate(var(--rz)) scale(0);
    opacity: 0;
}

/* ================= АНИМАЦИЯ СМЕНЫ ТЕМЫ (GPU CSS) ================= */
::view-transition-group(root) { animation: none; }
::view-transition-old(root), ::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
}

::view-transition-old(root) { z-index: 1; }
::view-transition-new(root) {
    z-index: 2;
    animation: wipe-down 0.6s cubic-bezier(0.75, 0, 0.25, 1) forwards;
}
html.theme-transition-shrinking::view-transition-new(root) {
    animation: wipe-up 0.6s cubic-bezier(0.75, 0, 0.25, 1) forwards;
}

@keyframes wipe-down {
    0% { clip-path: inset(0 0 100% 0); }
    100% { clip-path: inset(0 0 0 0); }
}
@keyframes wipe-up {
    0% { clip-path: inset(100% 0 0 0); }
    100% { clip-path: inset(0 0 0 0); }
}

/* ================= МОДАЛЬНОЕ ОКНО ПОИСКА ================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(15, 17, 21, 0.85); backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center; z-index: 3000; opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.search-modal-content {
    background: var(--card-bg); border: 2px solid var(--border-color); border-radius: 12px; width: 90%; max-width: 800px; 
    height: 750px; max-height: 85vh; display: flex; flex-direction: column; padding: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 20px rgba(0, 229, 255, 0.1); transform: scale(0.95); transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); overflow: hidden; 
}
.modal-overlay.active .search-modal-content { transform: scale(1); }
body.light-theme .search-modal-content { box-shadow: 0 10px 40px rgba(0,0,0,0.3), 0 0 20px rgba(124, 58, 237, 0.15); }

.search-modal-header, .search-tabs, .search-input-group { flex-shrink: 0; }
.search-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.search-modal-header h2 { margin: 0; font-size: 20px; font-weight: 800; color: var(--text-color); }

.search-tabs { display: flex; gap: 8px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 5px; }
.search-tabs::-webkit-scrollbar { height: 4px; }
.search-tabs::-webkit-scrollbar-thumb { background: var(--border-dashed); border-radius: 4px; }
.search-tab {
    background: var(--btn-bg); color: var(--text-muted); border: 2px solid transparent; padding: 8px 16px; border-radius: 8px; font-weight: 700; cursor: pointer; 
    transition: all 0.15s ease; white-space: nowrap; flex-shrink: 0; font-size: 14px; box-shadow: 0 4px 0 var(--border-color); transform: translateY(0);
}
.search-tab:hover { background: var(--card-hover); color: var(--text-color); transform: translateY(1px); box-shadow: 0 3px 0 var(--border-color); }
.search-tab:active { transform: scale(0.99) !important; opacity: 0.65 !important; box-shadow: none !important; transition: all 0.25s ease !important; }
.search-tab.active { background: rgba(0, 229, 255, 0.05); color: var(--accent-color); border-color: var(--accent-shadow); box-shadow: 0 4px 0 var(--accent-shadow); }
body.light-theme .search-tab.active { background: rgba(124, 58, 237, 0.05); }

.search-input-group { display: flex; gap: 10px; margin-bottom: 20px; }
.search-input-group input { flex-grow: 1; margin: 0; padding: 10px 15px; border-bottom: 2px solid var(--border-color); }

.search-results-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 15px; overflow-y: auto; 
    padding: 5px 10px 10px 5px; flex-grow: 1; align-content: start; overscroll-behavior: contain;
}
.search-results-grid::-webkit-scrollbar { width: 8px; }
.search-results-grid::-webkit-scrollbar-track { background: var(--bg-color); border-radius: 4px; }
.search-results-grid::-webkit-scrollbar-thumb { background: var(--border-dashed); border-radius: 4px; }
.search-results-grid::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }

.search-result-card {
    position: relative; border-radius: 8px; overflow: hidden; border: 2px solid var(--border-color); cursor: pointer; width: 100%;
    height: 0; padding-bottom: 100%; transition: all 0.15s ease; background: var(--btn-bg);
}
.search-result-card:hover { border-color: var(--accent-color); transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.5), 0 0 10px rgba(0, 229, 255, 0.3); }
.search-result-card img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.search-result-overlay {
    position: absolute; bottom: 0; left: 0; width: 100%; background: rgba(0,0,0,0.8); color: #fff; font-size: 13px; font-weight: 700; 
    padding: 6px; text-align: center; opacity: 0; transition: all 0.15s ease; text-shadow: 0 1px 3px #000; z-index: 10;
}
.search-result-card:hover .search-result-overlay { opacity: 1; }
.search-loading { text-align: center; padding: 40px; color: var(--accent-color); font-weight: 700; font-size: 18px; flex-shrink: 0; }

@keyframes addFlash { 0% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(0.92); filter: brightness(1.3) saturate(1.5); border-color: #00ff88; } 100% { transform: scale(1); filter: brightness(1); } }
.search-result-card.added-success { animation: addFlash 0.4s ease-out; border-color: #00ff88; }
.search-result-card.added-success .search-result-overlay { opacity: 1; background: rgba(0, 255, 136, 0.9); color: #000; text-shadow: none; }

.pagination-container { display: flex; justify-content: center; align-items: center; gap: 15px; margin-top: 15px; flex-shrink: 0; padding-top: 15px; border-top: 2px solid var(--border-color); }
.page-btn { background: var(--btn-bg); color: var(--text-color); border: 2px solid var(--border-color); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 700; transition: all 0.15s; font-size: 14px; }
.page-btn:hover:not(:disabled) { background: var(--card-hover); border-color: var(--accent-color); color: var(--accent-color); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.page-btn:active:not(:disabled) { transform: translateY(1px); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; border-color: transparent; }
.page-info { font-weight: 800; color: var(--accent-color); font-size: 15px; min-width: 60px; text-align: center; }

.search-result-title-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; 
    align-items: flex-end; 
    justify-content: center; 
    padding: 6px; padding-bottom: 25px; 
    text-align: center; color: #ffffff; 
    font-size: 11px; font-weight: 700; word-break: break-word; 
    
    pointer-events: none; opacity: 0; transition: opacity 0.15s; z-index: 5;
    
    background: transparent;
    
    text-shadow: 
        -1px -1px 0 #000,  
         1px -1px 0 #000,
        -1px  1px 0 #000,
         1px  1px 0 #000,
         0px  3px 5px rgba(0,0,0,0.9);
}
body.modal-titles-visible .search-result-title-overlay { opacity: 1; }

/* ================= РЕАЛИСТИЧНАЯ ВЕКТОРНАЯ МОЛНИЯ ================= */
.real-lightning {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0; pointer-events: none; z-index: 10;
    display: flex; justify-content: center; align-items: center; overflow: hidden;
}

.real-lightning svg {
    width: 65px; 
    height: 120%; 
}

.delete-dropzone.active-zone, .tier-delete-dropzone.active-zone {
    box-shadow: inset 0 0 15px rgba(0, 229, 255, 0.1);
}

.delete-dropzone:hover, .tier-delete-dropzone:hover,
.delete-dropzone:has(.sortable-ghost), .tier-delete-dropzone:has(.sortable-ghost-tier) {
    box-shadow: inset 0 0 40px rgba(0, 229, 255, 0.3);
    background: rgba(0, 229, 255, 0.03);
}

@keyframes real-strike {
    0%   { opacity: 0; }
    5%   { opacity: 1; filter: brightness(1.5) drop-shadow(0 0 15px #fff); } 
    10%  { opacity: 0; } 
    15%  { opacity: 0.8; transform: scaleX(-1); } 
    20%  { opacity: 0; }
    35%  { opacity: 0.4; transform: scaleX(1); filter: brightness(1.2) drop-shadow(0 0 10px #00e5ff); } 
    100% { opacity: 0; }
}

.real-lightning.strike { animation: real-strike 0.4s ease-out forwards; }

/* ================= АДАПТИВНОСТЬ (МОБИЛЬНАЯ ВЕРСИЯ) ================= */
@media (max-width: 768px) {
    header { flex-direction: column; gap: 10px; padding: 10px 15px; }
    
    /* Сбрасываем жесткую высоту на телефонах */
    .header-left, .header-right { justify-content: center; width: 100%; height: auto; }
    .header-right { flex-wrap: wrap; }
    
    /* Опускаем строку поиска под логотип и кнопки */
    .header-center { 
        height: auto; width: 100%; max-width: 100%; 
        margin: 5px 0 0 0; order: 3; 
    }
    
    .page { padding: 0 10px 40px 10px; }
    
    .builder-header { flex-direction: column; align-items: stretch; gap: 15px; margin-bottom: 15px; }
    .title-input { font-size: 20px; text-align: center; }
    .icon-controls { justify-content: center; }
    
    .dropdown-menu { right: 50%; transform: translateX(50%) translateY(-10px); }
    .hover-dropdown:hover .dropdown-menu { transform: translateX(50%) translateY(0); }
    
    .tier-label-wrapper { width: 70px; }
    .tier-label { font-size: 16px; padding: 5px; }
    
    .tier-actions { width: 34px; }
    .tier-action-btn { font-size: 14px; min-height: 28px; }

    .delete-dropzone, .tier-delete-dropzone {
        top: auto; bottom: 0; width: 100%; height: 110px; border-left: none; border-top: 3px dashed rgba(255, 77, 77, 0.5); display: flex; flex-direction: row; justify-content: center; gap: 15px; padding: 0;
    }
 
    .delete-text-label { 
        position: relative; top: auto; left: auto; transform: none; width: auto; font-size: 14px !important; padding: 0 !important; 
    }
    
    #tier-delete-zone .tier-row { top: 50% !important; margin-top: -40px !important; }
}

.delete-dropzone > div:not(.trash-icon):not(.item-wrapper):not(.sortable-ghost):not(.tier-row),
.tier-delete-dropzone > div:not(.trash-icon):not(.item-wrapper):not(.sortable-ghost):not(.tier-row) {
    font-size: 13px !important; 
    padding: 0 10px !important; 
    line-height: 1.3 !important; 
}

@media (max-width: 768px) {
    .delete-dropzone > div:not(.trash-icon):not(.item-wrapper):not(.sortable-ghost):not(.tier-row),
    .tier-delete-dropzone > div:not(.trash-icon):not(.item-wrapper):not(.sortable-ghost):not(.tier-row) {
        font-size: 14px !important; 
        padding: 0 !important; 
    }
}

/* ================= ЛОГОТИП ================= */
.logo { 
    font-size: 23px; /* Золотая середина */
    font-weight: 800; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    letter-spacing: -0.5px; 
} 
.logo span { color: var(--accent-color); text-shadow: 0 0 10px rgba(0, 229, 255, 0.3); }
body.light-theme .logo span { text-shadow: none; }

.puzzle-grid { 
    display: grid; 
    grid-template-columns: 8px 8px; /* Средний размер кубиков */
    gap: 3px; 
    transform: rotate(45deg); 
    margin: 0 5px; 
    position: relative; 
    top: -8px; /* Идеальное выравнивание под шрифт 23px */
}
.puzzle-grid div { 
    width: 8px; 
    height: 8px; 
    border-radius: 1.5px; 
}
.pg-piece { background: var(--text-color); transition: background 0.2s ease; }
.pg-accent { background: var(--accent-color); transform: translate(2px, 2px); box-shadow: 0 0 8px rgba(0, 229, 255, 0.4); }
body.light-theme .pg-accent { box-shadow: 0 0 8px rgba(124, 58, 237, 0.4); }
.logo:hover .pg-accent { transform: translate(0, 0); transition: transform 0.2s ease; }

.sortable-chosen,
.sortable-drag,
.sortable-ghost {
    box-shadow: none !important;
    border-color: var(--tier-border) !important;
    outline: none !important;
}

.tier-action-btn:active .drag-icon-svg,
.tier-drag-handle:active {
    color: var(--text-color) !important;
}

.tooltip-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%; background: var(--border-color);
    color: var(--text-muted); font-size: 13px; font-weight: 800; cursor: help; margin-left: auto;
    transition: background 0.15s, color 0.15s;
}
.tooltip-icon:hover { background: var(--accent-color); color: #000; }

/* ================= ОНБОРДИНГ ================= */
.onboarding-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 10px; }
.onboarding-card {
    background: var(--btn-bg); border: 2px solid var(--border-color); border-radius: 10px; padding: 15px 10px;
    font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.15s ease; box-shadow: 0 4px 0 var(--border-color);
}
.onboarding-card:hover { transform: translateY(-2px); border-color: var(--accent-color); }
.onboarding-card.selected { background: rgba(0, 229, 255, 0.1); border-color: var(--accent-color); color: var(--accent-color); box-shadow: 0 4px 0 var(--accent-shadow); transform: translateY(2px); }
body.light-theme .onboarding-card.selected { background: rgba(124, 58, 237, 0.1); color: var(--accent-color); }


/* ================= ПРЕМИАЛЬНАЯ ПАНЕЛЬ И ФИЛЬТРЫ ================= */
.advanced-toolbar {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 0;
    margin: 0;
    min-height: 48px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .advanced-toolbar { 
        padding: 5px 0 0 0; 
        gap: 10px; 
        min-height: 44px; /* Фиксируем для телефонов */
    }
}

/* --- Стили для выпадающего списка (Sort) --- */
.sort-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.premium-select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-color);
    border: 1px solid transparent;
    padding: 8px 40px 8px 16px; /* Оставили место справа под SVG галочку */
    font-size: 14px;
    font-weight: 500;
    border-radius: 30px; /* Форма идеальной капсулы, как у поиска */
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}
.premium-select:hover, .premium-select:focus {
    background: rgba(255, 255, 255, 0.08);
}
body.light-theme .premium-select { background: rgba(0, 0, 0, 0.04); }
body.light-theme .premium-select:hover { background: rgba(0, 0, 0, 0.08); }

.premium-select option {
    background: var(--card-bg);
    color: var(--text-color);
    font-weight: 500;
}

.select-chevron {
    position: absolute;
    right: 14px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none; /* Чтобы клик проходил сквозь иконку прямо по select */
    transition: color 0.2s ease;
}
.sort-wrapper:hover .select-chevron { color: var(--text-color); }

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}

/* --- Стили для кнопок категорий (Chips) --- */
.chip-filters-wrapper { 
    width: 100%; 
    padding: 6px 0; 
    min-height: 48px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
}

@media (max-width: 768px) { 
    .chip-filters-wrapper { 
        padding: 5px 0 0 0; 
        min-height: 44px; /* Строго равно advanced-toolbar на телефонах */
    } 
}

.chip-filters {
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    align-items: center; 
    padding: 0 !important; /* Убиваем скрытые отступы */
}

.filter-chip {
    background-color: transparent; 
    color: var(--text-muted); 
    border: 1px solid transparent; /* Добавили невидимую рамку для баланса высоты */
    padding: 8px 16px;
    border-radius: 30px; 
    font-size: 14px; 
    font-weight: 500; 
    cursor: pointer; 
    transition: all 0.2s ease; 
    flex-shrink: 0; 
}

.filter-chip:hover { 
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.06); /* Мягкое свечение при наведении */
}
body.light-theme .filter-chip:hover { background-color: rgba(0, 0, 0, 0.06); }

/* Выбранная категория */
.filter-chip.active { 
    background-color: var(--text-color); 
    color: var(--bg-color); 
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); /* Добавляет легкий объем */
}

.chip-divider { width: 1px; height: 24px; background-color: var(--border-color); margin: 0 4px; flex-shrink: 0; }

/* ================= ФОРМАТЫ КАРТИНОК (Монолит) ================= */
body.ratio-1-1 .item-wrapper, body.ratio-1-1 .add-item-card { width: 80px; height: 80px; }
body.ratio-16-9 .item-wrapper, body.ratio-16-9 .add-item-card { width: 142px; height: 80px; }
body.ratio-9-16 .item-wrapper, body.ratio-9-16 .add-item-card { width: 80px; height: 142px; }

body:not(.ratio-16-9):not(.ratio-9-16):not(.ratio-1-1) .item-wrapper, 
body:not(.ratio-16-9):not(.ratio-9-16):not(.ratio-1-1) .add-item-card { width: 80px; height: 80px; }

@media (max-width: 768px) {
    body.ratio-1-1 .item-wrapper, body.ratio-1-1 .add-item-card { width: 65px; height: 65px; }
    body.ratio-16-9 .item-wrapper, body.ratio-16-9 .add-item-card { width: 116px; height: 65px; }
    body.ratio-9-16 .item-wrapper, body.ratio-9-16 .add-item-card { width: 65px; height: 116px; }
    
    body:not(.ratio-16-9):not(.ratio-9-16):not(.ratio-1-1) .item-wrapper, 
    body:not(.ratio-16-9):not(.ratio-9-16):not(.ratio-1-1) .add-item-card { width: 65px; height: 65px; }
}

#delete-zone .item-wrapper {
    position: absolute !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important;
    margin: 0 !important; pointer-events: none !important; z-index: 100 !important;
}
@media (max-width: 768px) { #delete-zone .item-wrapper { left: 50% !important; } }

/* ================= АВТОРИЗАЦИЯ И ПЕРЕКЛЮЧАТЕЛЬ ЛЕНТЫ ================= */
.search-feed-selector { position: relative; z-index: 1000; margin-right: 0; }
.feed-selector-btn {
    display: flex; align-items: center; gap: 6px; 
    background: transparent; 
    border: none; color: var(--text-color); 
    padding: 8px 16px; border-radius: 30px; 
    font-size: 14px; font-weight: 600; cursor: pointer; 
    /* Убрали transform из transition, увеличили время для плавности */
    transition: background 0.3s ease, color 0.3s ease; 
    outline: none;
    /* Убрали старые transform: translateY и scale, если они где-то наследовались */
    transform: none !important; 
    box-shadow: none !important;
}
.feed-selector-btn:hover { 
    background: rgba(255,255,255,0.08); 
    transform: none !important; 
}
body.light-theme .feed-selector-btn { color: #0f172a; }
body.light-theme .feed-selector-btn:hover { background: rgba(0,0,0,0.06); transform: none !important; }

/* Очень легкое "вдавливание" при клике (scale 0.98), без сдвигов по вертикали */
.feed-selector-btn:active { 
    transform: scale(0.98) !important; 
    transition: transform 0.05s ease !important;
}

/* Жестко фиксируем иконку стрелочки, чтобы она не дергалась внутри кнопки */
.feed-selector-btn svg {
    transform: none !important;
    transition: none !important; 
    margin: 0 !important; 
    padding: 0 !important;
    vertical-align: middle;
}

/* На всякий случай блокируем любые трансформации для span с текстом тоже */
.feed-selector-btn span {
    transform: none !important;
    transition: none !important;
}

.feed-dropdown-menu {
    position: absolute; top: calc(100% + 12px); right: 0; width: 160px;
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: flex; flex-direction: column;
    opacity: 0; visibility: hidden; 
    /* Сделали смещение чуть меньше (-4px вместо -10px) и увеличили время анимации */
    transform: translateY(-4px); 
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); 
    padding: 6px;
}
body.light-theme .feed-dropdown-menu { box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.search-feed-selector.active .feed-dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.feed-dropdown-item {
    background: transparent; border: none; text-align: left; padding: 10px 12px; border-radius: 8px;
    color: var(--text-color); cursor: pointer; font-size: 13px; font-weight: 600; transition: background 0.15s, color 0.15s; outline: none;
}
.feed-dropdown-item:hover { background: var(--card-hover); color: var(--accent-color); }
.feed-dropdown-item.active { background: rgba(0, 229, 255, 0.1); color: var(--accent-color); }
body.light-theme .feed-dropdown-item.active { background: rgba(124, 58, 237, 0.1); }

/* Auth Modal Styles */
.auth-tabs { display: flex; gap: 15px; margin-bottom: 20px; }
.auth-tab { background: none; border: none; color: var(--text-muted); font-size: 18px; font-weight: 800; cursor: pointer; padding: 0 0 5px 0; transition: 0.2s; position: relative; outline: none; }
.auth-tab::after { content: ''; position: absolute; bottom: 0; left: 0; width: 0; height: 3px; background: var(--accent-color); transition: width 0.2s ease; border-radius: 3px; }
.auth-tab.active { color: var(--text-color); }
.auth-tab.active::after { width: 100%; }

.auth-form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; text-align: left; }
.auth-input { 
    background: rgba(255,255,255,0.03); border: 2px solid var(--border-color); color: var(--text-color); 
    padding: 14px; border-radius: 10px; outline: none; font-size: 15px; transition: border-color 0.2s, background 0.2s; 
}
.auth-input:focus { border-color: var(--accent-color); background: rgba(0, 229, 255, 0.03); }
body.light-theme .auth-input { background: rgba(0,0,0,0.02); }
body.light-theme .auth-input:focus { background: rgba(124, 58, 237, 0.03); }

/* ================= ПРЕМИАЛЬНЫЙ КАПСУЛЬНЫЙ МИНИМАЛИЗМ ================= */

/* 1. Строка поиска (уменьшаем правый отступ, чтобы кнопка встала в край) */
.global-search-container {
    display: flex; align-items: center; width: 100%;
    background: #222222; 
    border: 1px solid #333333;
    border-radius: 40px; 
    padding: 5px 6px 5px 20px; /* Правый отступ 6px (вместо 10), чтобы облегать кнопку */
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
body.light-theme .global-search-container { background: #f1f5f9; border-color: #cbd5e1; }

.global-search-container:focus-within {
    background: #2a2a2a; border-color: #444444;
    box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.15); 
}
body.light-theme .global-search-container:focus-within { background: #ffffff; box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15); }

#global-search-input {
    flex: 1; background: transparent; border: none; color: var(--text-color);
    font-size: 15px; outline: none; padding: 4px 0; min-width: 0;
}

/* 2. Иконка лупы */
.search-icon-btn {
    background: transparent; border: none; color: var(--text-muted);
    font-size: 18px; margin: 0 4px; cursor: pointer; padding: 4px; 
    display: flex; align-items: center; justify-content: center;
    transition: color 0.15s ease;
}
.search-icon-btn:hover { color: var(--text-color); }

/* 3. Вертикальный разделитель (Pinterest style) */
.search-divider {
    width: 1px;
    height: 22px;
    background-color: var(--border-color);
    margin: 0 8px; /* Отступы слева и справа от линии */
}

/* 4. Кнопка переключателя лент (В самом краю) */
.search-feed-selector { position: relative; z-index: 1000; margin-right: 0; }
.feed-selector-btn {
    display: flex; align-items: center; gap: 6px; 
    background: transparent; /* Делаем фон прозрачным, как в Pinterest */
    border: none; color: var(--text-color); 
    padding: 8px 16px; border-radius: 30px; 
    font-size: 14px; font-weight: 600; cursor: pointer; 
    transition: background 0.2s, color 0.2s; outline: none;
}
.feed-selector-btn:hover { background: rgba(255,255,255,0.08); }
body.light-theme .feed-selector-btn { color: #0f172a; }
body.light-theme .feed-selector-btn:hover { background: rgba(0,0,0,0.06); }

/* Выпадающее меню под кнопкой */
.feed-dropdown-menu {
    position: absolute; top: calc(100% + 12px); right: 0; width: 160px;
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: flex; flex-direction: column;
    opacity: 0; visibility: hidden; transform: translateY(-5px); transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); padding: 6px;
}
body.light-theme .feed-dropdown-menu { box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.search-feed-selector.active .feed-dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }

.feed-dropdown-item {
    background: transparent; border: none; text-align: left; padding: 10px 12px; border-radius: 8px;
    color: var(--text-color); cursor: pointer; font-size: 13px; font-weight: 600; transition: background 0.15s, color 0.15s; outline: none;
}
.feed-dropdown-item:hover { background: var(--card-hover); color: var(--accent-color); }
.feed-dropdown-item.active { background: rgba(0, 229, 255, 0.1); color: var(--accent-color); }
body.light-theme .feed-dropdown-item.active { background: rgba(124, 58, 237, 0.1); }

/* ================= ПРЕМИАЛЬНАЯ МЯГКАЯ АНИМАЦИЯ КЛИКА ================= */

/* Отключаем физическое "проваливание" для абсолютно всех кнопок */
.btn:active, 
.icon-btn:active, 
.theme-icon-btn:active, 
.search-tab:active, 
.feed-selector-btn:active,
.page-btn:active,
.onboarding-card:active,
.search-action-btn:active,
.search-icon-btn:active,
.search-clear-btn:active {
    /* 1. Блокируем любые изменения размера и прыжки */
    transform: scale(0.99) !important; /* Едва уловимое дыхание (1% вместо старых 3-5%) */
    
    /* 2. Применяем оптическое затухание (эффект мягкого касания) */
    opacity: 0.65 !important; 
    
    /* 3. Замедляем анимацию, делаем её плавной и "шелковой" */
    transition: opacity 0.25s ease-out, transform 0.25s ease-out, background-color 0.25s ease !important;
}

/* Для главных кнопок (Синих/Красных) заставляем неоновое свечение нежно приглушаться, а не резко исчезать */
.btn-primary:active, 
.btn-danger:active {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important; 
}

/* ================= АБСОЛЮТНО ВСЕ КНОПКИ: МЯГКАЯ АНИМАЦИЯ КЛИКА ================= */

/* Отключаем старые дергания и сжатия (перебиваем старые !important) */
button:active, 
a.btn:active,
.btn:active, 
.icon-btn:active, 
.theme-icon-btn:active, 
.search-tab:active, 
.feed-selector-btn:active,
.page-btn:active,
.onboarding-card:active,
.search-action-btn:active,
.search-icon-btn:active,
.search-clear-btn:active,
.menu-item:active,
.feed-dropdown-item:active {
    /* 1. Блокируем сильное сжатие (оставляем микро-отклик 1%) */
    transform: scale(0.99) !important; 
    
    /* 2. Применяем мягкое оптическое затухание */
    opacity: 0.65 !important; 
    
    /* 3. Устанавливаем шелковую плавность (перебиваем старые transition: none) */
    transition: opacity 0.25s ease-out, transform 0.25s ease-out, background-color 0.25s ease !important;
}

/* Выключаем старые тени при клике на основные кнопки */
.btn-primary:active, 
.btn-danger:active {
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2) !important; 
}

/* Убираем рамку фокуса, чтобы не было синих или серых обводок при клике */
button:focus, input:focus, select:focus, textarea:focus {
    outline: none !important;
}

/* ================= БОКОВАЯ ПАНЕЛЬ ФИЛЬТРОВ (Pinterest Style) ================= */
.layout-with-sidebar {
    display: flex;
    width: 100%;
    align-items: flex-start;
}

.filters-sidebar {
    width: 0;
    opacity: 0;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.4s ease-out;
    display: flex;
    flex-direction: column;
    gap: 28px;
    
    position: sticky;
    top: 130px; /* <-- Опустили точку фиксации ниже двойной шапки */
    max-height: calc(100vh - 150px); /* <-- Пересчитали высоту, чтобы низ не обрезался */
}

/* Замораживаем ширину внутренностей, чтобы текст не ломался при открытии панели */
.sidebar-section {
    width: 226px;
    min-width: 226px;
}

.filters-sidebar.open {
    width: 250px;
    opacity: 1;
    padding-right: 24px;
    overflow-y: auto;
}

.main-content-wrapper {
    flex-grow: 1;
    width: 100%;
    min-width: 0; 
    /* Синхронизируем обертку тоже на 0.6s */
    transition: width 0.6s ease;
}

.filters-sidebar::-webkit-scrollbar { width: 4px; }
.filters-sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* Состояние открытой панели */
.filters-sidebar.open {
    width: 250px;
    opacity: 1;
    padding-right: 24px;
    overflow-y: auto;
}

.main-content-wrapper {
    flex-grow: 1;
    width: 100%;
    min-width: 0; /* Обязательно, чтобы сетка сжималась, а не ломала верстку */
    transition: width 0.4s ease;
}

.sidebar-section h4 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-color);
    margin: 0 0 14px 0;
    opacity: 0.6;
}

/* Кастомные премиальные радиокнопки */
.sidebar-radio {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.2s, transform 0.2s;
}
.sidebar-radio:active { transform: scale(0.98); }
.sidebar-radio:hover { color: var(--text-color); }

.sidebar-radio input {
    appearance: none;
    width: 22px;
    height: 22px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    outline: none;
    position: relative;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
}
.sidebar-radio input:checked { border-color: var(--text-color); transform: scale(1.05); }
.sidebar-radio input:checked::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 12px; height: 12px;
    background: var(--text-color);
    border-radius: 50%;
}
body.light-theme .sidebar-radio input:checked,
body.light-theme .sidebar-radio input:checked::after {
    border-color: var(--text-color); background-color: var(--text-color);
}

.sidebar-chips.wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* ================= СКРОЛЛ ДЛЯ ТЕГОВ В САЙДБАРЕ ================= */

.filters-sidebar {
    gap: 0 !important; /* Убираем глобальный отступ, контролируем его внутри */
}

.sidebar-scrollable-content {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 15px; /* Отступ от ползунка скролла */
    margin-right: -15px; /* Компенсация, чтобы скроллбар был прижат к краю панели */
    padding-bottom: 20px;
}

/* Делаем внутренний ползунок панели тоньше и изящнее */
.sidebar-scrollable-content::-webkit-scrollbar { width: 4px; }
.sidebar-scrollable-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-scrollable-content::-webkit-scrollbar-thumb { background: var(--border-dashed); border-radius: 4px; }
.sidebar-scrollable-content::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ================= ФИКС ТРЯСКИ ПУЛА И СМЕЩЕНИЯ ВЛЕВО ================= */
#pool-dropzone {
    justify-content: center !important; /* Возвращаем красивое центрирование сетки! */
    align-content: flex-start !important;
    align-items: flex-start !important; 
}

/* === КЛАССИЧЕСКИЙ МАРКЕР ПОСАДКИ (ВИДИМАЯ КАРТИНКА, БЕЗ РАМОК И ТРЯСКИ) === */
#pool-dropzone > .sortable-ghost {
    display: inline-block !important;
    width: 80px !important; 
    height: 80px !important; 
    margin: 0 !important; 
    padding: 0 !important;
    flex-shrink: 0 !important;
    
    /* Делаем сам контейнер прозрачным, без рамок и фонов */
    background: transparent !important;
    border: none !important;
    opacity: 1 !important; 
}

/* Адаптация квадрата под форматы 16:9 и 9:16 */
body.ratio-16-9 #pool-dropzone > .sortable-ghost { width: 142px !important; height: 80px !important; }
body.ratio-9-16 #pool-dropzone > .sortable-ghost { width: 80px !important; height: 142px !important; }

/* Настраиваем саму картинку внутри призрака */
#pool-dropzone > .sortable-ghost .item-content {
    transform: scale(1) !important; /* Убираем сжатие (которое создавало ложную рамку) */
    opacity: 0.3 !important; /* Делаем картинку полупрозрачной */
    filter: grayscale(1) !important; /* Обесцвечиваем, как в тирах */
    border: none !important;
    background: transparent !important;
}

/* ================= ФИКС МЕРЦАНИЯ РЯДОМ С ПОИСКОМ ================= */
#ea-wrapper.search-active + .sortable-ghost,
#pool-dropzone > .sortable-ghost:first-child {
    display: none !important;
}

/* ================= ДИНАМИЧЕСКАЯ КАПСУЛА (БРОНЕБОЙНАЯ + FLIP) ================= */
#ea-wrapper {
    position: relative;
    flex-shrink: 0;
    z-index: 50; 
    order: -999 !important; 
    width: 80px; 
    height: 80px; 
    /* Отключаем CSS-растягивание обертки, чтобы FLIP-скрипт сразу знал финальные координаты сетки */
    transition: none !important;
}

.ea-inner {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex; flex-direction: column;
    background: var(--card-bg);
    border: 2px dashed var(--border-dashed);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

/* Пока капсула закрыта, клики и наведение ловит только сам квадрат 80x80 */
#ea-wrapper:not(.ea-hovered):not(.search-active) .ea-inner {
    pointer-events: none;
}

/* Стартовые размеры для форматов */
body.ratio-16-9 #ea-wrapper { width: 142px; height: 80px; }
body.ratio-9-16 #ea-wrapper { width: 80px; height: 142px; }

/* РАСКРЫТИЕ ВНИЗ (.ea-hovered) */
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) { 
    width: 80px !important; 
    height: 310px !important; 
    z-index: 1000 !important; 
}
body.ratio-16-9:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) { 
    width: 142px !important; height: 310px !important; 
}
body.ratio-9-16:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) { 
    width: 80px !important; height: 370px !important; 
}

/* Перестраиваем элементы в колонку */
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-top-row {
    flex-direction: column !important;
    height: 100% !important;
    padding-top: 10px !important;
}
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-main-btn {
    margin-bottom: 5px !important;
}
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-actions {
    opacity: 1 !important; visibility: visible !important; 
    transform: none !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
}

/* АКТИВНЫЙ РЕЖИМ ПОИСКА (Физически сдвигает все картинки пула вниз) */
#ea-wrapper.search-active {
    width: 100% !important;
    height: 450px !important;
    margin-bottom: 10px !important;
    z-index: 1000 !important; 
}
#ea-wrapper.search-active .ea-inner {
    border-radius: 12px;
    border-style: solid;
    background: rgba(0,0,0,0.15);
    box-shadow: inset 0 4px 20px rgba(0,0,0,0.2);
}
body.light-theme #ea-wrapper.search-active .ea-inner { 
    background: rgba(255,255,255,0.5); 
    box-shadow: inset 0 4px 20px rgba(0,0,0,0.05); 
}

/* ВЕРХНЯЯ СТРОКА */
.ea-top-row {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    height: 80px; 
    flex-shrink: 0;
    transition: height 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
body.ratio-9-16 .ea-top-row { height: 142px; }
#ea-wrapper.search-active .ea-top-row { height: 60px; padding: 0 10px; border-bottom: 1px solid rgba(255,255,255,0.05); }

/* ГЛАВНАЯ КНОПКА (Плюс <-> Крестик) */
.ea-main-btn {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    width: 80px; height: 80px; 
    flex-shrink: 0; color: var(--text-muted);
    border-radius: 8px;
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
body.ratio-16-9 .ea-main-btn { width: 142px; height: 80px; }
body.ratio-9-16 .ea-main-btn { width: 80px; height: 142px; }

/* При наведении аккуратно поджимаем зону плюса, чтобы все 4 иконки идеально вошли в 256px */
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-main-btn { 
    width: 60px;
    color: var(--accent-color); 
}
body.ratio-16-9:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-main-btn {
    width: 80px;
}

#ea-wrapper.search-active .ea-main-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--danger-hover); color: #fff; cursor: pointer; }
#ea-wrapper.search-active .ea-main-btn:hover { background: #ff3333; transform: scale(1.1); }

#icon-plus, #icon-cross { position: absolute; transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
#icon-cross { opacity: 0; transform: scale(0) rotate(-90deg); pointer-events: none; }
#ea-wrapper.search-active #icon-plus { opacity: 0; transform: scale(0) rotate(90deg); pointer-events: none; }
#ea-wrapper.search-active #icon-cross { opacity: 1; transform: scale(1) rotate(0deg); pointer-events: auto; }

/* КОНТЕЙНЕР ПЕРЕКЛЮЧЕНИЯ КОНТЕНТА */
.ea-content-switcher {
    position: relative;
    flex: 1;
    height: 100%;
    margin-left: 2px;
}

.ea-actions, .ea-search-controls {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.4s;
}

.ea-actions { opacity: 0; visibility: hidden; transform: translateX(-15px); gap: 6px; }
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-actions { opacity: 1; visibility: visible; transform: translateX(0); }

.ea-search-controls { opacity: 0; visibility: hidden; transform: translateY(10px); gap: 10px; }
#ea-wrapper.search-active .ea-search-controls { opacity: 1; visibility: visible; transform: translateY(0); }

/* Элементы внутри кнопок */
.ea-icon-btn {
    width: 40px; height: 40px; border-radius: 8px; background: var(--btn-bg);
    border: 1px solid var(--border-color); color: var(--text-color);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; position: relative;
}
.ea-icon-btn:hover { transform: scale(1.15); color: var(--accent-color); border-color: var(--accent-color); }
body.light-theme .ea-icon-btn:hover { box-shadow: 0 4px 12px rgba(124, 58, 237, 0.2); }

.capsule-input {
    flex-grow: 1; background: rgba(255,255,255,0.04); border: 1px solid var(--border-color);
    border-radius: 8px; padding: 10px 15px; color: var(--text-color); font-size: 15px;
    outline: none; transition: all 0.2s; min-width: 0;
}
.capsule-input:focus { border-color: var(--accent-color); background: rgba(0, 229, 255, 0.05); }

.capsule-tabs {
    display: flex; gap: 4px; background: rgba(255,255,255,0.03);
    padding: 5px; border-radius: 8px; border: 1px solid var(--border-color);
    overflow-x: auto; flex-shrink: 0;
}
.capsule-tabs::-webkit-scrollbar { display: none; }
.c-tab {
    background: transparent; color: var(--text-muted); border: none;
    padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.c-tab:hover { color: var(--text-color); }
.c-tab.active { background: var(--card-bg); color: var(--accent-color); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }

/* СЕТКА ПОИСКА (Плавно проявляется на готовом месте) */
.ea-search-body {
    width: 100%; 
    height: calc(100% - 60px); 
    padding: 10px 15px;
    opacity: 0; visibility: hidden;
    transition: opacity 0.4s ease 0.1s, visibility 0.5s;
    display: flex; flex-direction: column;
}
#ea-wrapper.search-active .ea-search-body { opacity: 1; visibility: visible; }

.premium-search-grid {
    display: flex; flex-wrap: wrap; gap: 8px;
    flex-grow: 1; overflow-y: auto; align-content: flex-start;
    padding-right: 5px;
}
.premium-search-grid::-webkit-scrollbar { width: 6px; }
.premium-search-grid::-webkit-scrollbar-thumb { background: var(--border-dashed); border-radius: 4px; }

/* Форсируем полет */
.sortable-drag.search-item, .sortable-fallback.search-item {
    transition: none !important; pointer-events: none !important;
    z-index: 999999 !important; margin: 0 !important;
}
.premium-search-grid .search-item.sortable-chosen:not(.sortable-drag) { opacity: 0 !important; }

/* Мобильная адаптация */
@media (max-width: 768px) {
    body:not(.is-dragging-item) #ea-wrapper:not(.search-active):hover { width: 180px; }
    .ea-content-switcher { margin-left: 5px; }
    .ea-search-controls { flex-wrap: wrap; }
    .capsule-input { width: 100%; order: 1; }
    .capsule-tabs { width: 100%; order: 2; justify-content: flex-start; }
}

/* === УЛЬТРА-ОПТИМИЗАЦИЯ ПУЛА ДЛЯ 100+ КАРТИНОК === */
#pool-dropzone {
    contain: layout; /* Изолируем пул: изменения внутри него больше не заставляют браузер пересчитывать всю страницу */
}

/* ================= ТУЛТИПЫ ДЛЯ КНОПОК ЗАГРУЗКИ В КАПСУЛЕ ================= */
.ea-icon-btn::after {
    right: calc(100% + 12px) !important;
    top: 50% !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) scale(0.85) translateX(10px) !important; 
}

.ea-icon-btn::before {
    right: calc(100% + 6px) !important;
    top: 50% !important;
    left: auto !important;
    bottom: auto !important;
    transform: translateY(-50%) scale(0.85) translateX(10px) !important;
    border-color: transparent transparent transparent #151515 !important;
}
.ea-icon-btn:hover::after, .ea-icon-btn:hover::before { 
    transform: translateY(-50%) scale(0.87) translateX(0) !important; 
}

#ea-wrapper:not(.search-active) .ea-inner {
    overflow: visible !important;
}


/* ================= КАПСУЛЬНЫЙ РЕДИЗАЙН ПОИСКА (БЕЗ ПУСТОТ И БАГОВ) ================= */
/* ЭТИ СТИЛИ ПРИМЕНЯЮТСЯ ТОЛЬКО К КОНСТРУКТОРУ И НИКАК НЕ ТРОГАЮТ ШАПКУ */

/* 1. Убиваем 450px пустоты и делаем контейнер растяжимым */
#ea-wrapper.search-active {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin-bottom: 25px !important;
    z-index: 1000 !important;
}

/* 2. ВАЖНЫЙ ФИКС: position: relative, чтобы картинки больше не выпадали */
#ea-wrapper.search-active .ea-inner {
    position: relative !important;
    height: auto !important;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
body.light-theme #ea-wrapper.search-active .ea-inner {
    background: transparent !important; box-shadow: none !important;
}

/* 3. Верхняя панель (Плавающая прозрачная капсула) */
#ea-wrapper.search-active .ea-top-row {
    height: auto !important;
    padding: 8px 12px !important;
    background: rgba(30, 30, 30, 0.65) !important;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-radius: 100px !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4) !important;
    width: fit-content !important;
    margin: 0 auto;
    border-bottom: none !important;
}
body.light-theme #ea-wrapper.search-active .ea-top-row {
    background: rgba(255, 255, 255, 0.8) !important; border-color: rgba(0,0,0,0.05) !important;
}

/* Кнопка крестика */
#ea-wrapper.search-active .ea-main-btn {
    width: 36px !important; height: 36px !important; border-radius: 50% !important; background: rgba(255, 70, 70, 0.15) !important; color: #ff5555 !important; cursor: pointer; margin: 0 12px 0 0 !important; transition: 0.2s ease !important;
}
#ea-wrapper.search-active .ea-main-btn:hover { background: #ff5555 !important; color: #fff !important; transform: scale(1.05) !important; }

/* Вкладки поиска */
#ea-wrapper.search-active .capsule-tabs {
    display: flex; gap: 4px; background: transparent !important; padding: 0 !important; border-radius: 0 !important; border: none !important; overflow-x: auto; flex-shrink: 0;
}
#ea-wrapper.search-active .c-tab {
    background: transparent !important; color: rgba(255, 255, 255, 0.5) !important; border: none !important; padding: 8px 16px !important; border-radius: 100px !important; font-size: 13px; font-weight: 600 !important; cursor: pointer; transition: all 0.2s !important; white-space: nowrap; box-shadow: none !important;
}
#ea-wrapper.search-active .c-tab:hover { color: #fff !important; }
#ea-wrapper.search-active .c-tab.active { background: rgba(255, 255, 255, 0.12) !important; color: #fff !important; }
body.light-theme #ea-wrapper.search-active .c-tab { color: rgba(0,0,0,0.5) !important; }
body.light-theme #ea-wrapper.search-active .c-tab:hover { color: #000 !important; }
body.light-theme #ea-wrapper.search-active .c-tab.active { background: rgba(0,0,0,0.1) !important; color: #000 !important; }

/* Поле ввода в капсуле */
#ea-wrapper.search-active .capsule-input {
    flex-grow: 1; background: rgba(0, 0, 0, 0.3) !important; border: 1px solid rgba(255, 255, 255, 0.05) !important; border-radius: 100px !important; padding: 8px 20px !important; color: #fff !important; font-size: 15px !important; outline: none !important; transition: all 0.2s !important; min-width: 200px; box-shadow: inset 0 2px 5px rgba(0,0,0,0.2) !important; margin: 0 !important;
}
#ea-wrapper.search-active .capsule-input:focus { border-color: rgba(255, 255, 255, 0.15) !important; }
body.light-theme #ea-wrapper.search-active .capsule-input { background: rgba(0,0,0,0.05) !important; border-color: transparent !important; color: #000 !important; box-shadow: none !important; }

/* Кнопка "Найти" — неоновый акцент (строго изолировано, не трогая Вики) */
#ea-wrapper.search-active .ea-search-controls > button:last-child {
    background: #00e5ff !important; color: #000 !important; border: none !important; border-radius: 100px !important; padding: 8px 22px !important; font-weight: 700 !important; margin: 0 !important; cursor: pointer; transition: 0.2s ease !important;
}
#ea-wrapper.search-active .ea-search-controls > button:last-child:hover { 
    background: #00c4d9 !important; transform: scale(1.05) !important; 
}
#ea-wrapper.search-active .ea-search-controls button:last-child:hover { background: #00c4d9 !important; transform: scale(1.05) !important; }

/* 4. Мягкая сетка картинок */
#ea-wrapper.search-active .ea-search-body {
    width: 100% !important; height: auto !important; min-height: 0 !important; padding: 15px !important; opacity: 1; visibility: visible; display: flex; flex-direction: column; background: rgba(25, 25, 25, 0.5) !important; border: 1px solid rgba(255, 255, 255, 0.03) !important; border-radius: 20px !important; margin-top: 5px !important;
}
body.light-theme #ea-wrapper.search-active .ea-search-body { background: rgba(255, 255, 255, 0.5) !important; border-color: rgba(0,0,0,0.05) !important; }

#ea-wrapper.search-active .premium-search-grid {
    display: grid !important; grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)) !important; gap: 10px !important; justify-content: center !important; width: 100% !important; overflow: visible !important; padding: 0 !important;
}
#ea-wrapper.search-active .premium-search-grid .search-item, 
#ea-wrapper.search-active .premium-search-grid .item-wrapper {
    width: 100% !important; height: auto !important; aspect-ratio: 1 / 1 !important; margin: 0 !important; border-radius: 10px !important; background: rgba(255, 255, 255, 0.02) !important;
}
#ea-wrapper.search-active .ea-search-body hr { display: none !important; }

/* Пагинация (Стр 1, Назад, Вперед) */
#ea-wrapper.search-active .pagination-container {
    display: inline-flex !important; justify-content: center !important; align-items: center !important; gap: 15px !important; background: rgba(30, 30, 30, 0.65) !important; backdrop-filter: blur(12px) !important; padding: 6px 18px !important; border-radius: 100px !important; border: 1px solid rgba(255, 255, 255, 0.05) !important; margin: 15px auto 0 auto !important; width: fit-content !important; border-top: none !important;
}
body.light-theme #ea-wrapper.search-active .pagination-container { background: rgba(255, 255, 255, 0.8) !important; border-color: rgba(0,0,0,0.05) !important; }

#ea-wrapper.search-active .page-btn {
    background: transparent !important; border: none !important; color: rgba(255, 255, 255, 0.6) !important; box-shadow: none !important; padding: 4px 12px !important; cursor: pointer !important; transition: all 0.15s;
}
#ea-wrapper.search-active .page-btn:hover:not(:disabled) { color: #fff !important; background: rgba(255, 255, 255, 0.1) !important; }
body.light-theme #ea-wrapper.search-active .page-btn { color: rgba(0,0,0,0.6) !important; }
body.light-theme #ea-wrapper.search-active .page-btn:hover:not(:disabled) { color: #000 !important; background: rgba(0,0,0,0.05) !important; }
#ea-wrapper.search-active .page-info { color: #00e5ff !important; font-weight: 700 !important; }

/* Мобильная адаптация капсулы */
@media (max-width: 768px) {
    #ea-wrapper.search-active .ea-search-controls { flex-wrap: wrap; justify-content: center; }
    #ea-wrapper.search-active .capsule-input { width: 100% !important; order: 1; }
    #ea-wrapper.search-active .capsule-tabs { width: 100% !important; order: 2; justify-content: center; }
    /* Добавлен знак > для изоляции кнопки Найти от вкладок */
    #ea-wrapper.search-active .ea-search-controls > button:last-child { order: 3; width: 100% !important; }
    #ea-wrapper.search-active .ea-top-row { border-radius: 20px !important; flex-direction: column; padding: 15px !important; }
    #ea-wrapper.search-active .ea-main-btn { margin: 0 0 10px 0 !important; }
}

/* ================= ФИКС ЦЕНТРИРОВАНИЯ ВЕРХНЕЙ КАПСУЛЫ ПОИСКА ================= */
/* Возвращаем вкладки, инпут и кнопку "Найти" в физический поток капсулы */
#ea-wrapper.search-active .ea-content-switcher {
    position: relative !important;
    width: auto !important;
    height: auto !important;
    flex: 0 1 auto !important;
    margin-left: 0 !important;
    display: flex !important;
    align-items: center !important;
}

#ea-wrapper.search-active .ea-search-controls {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    transform: none !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

/* Задаем комфортную ширину полю ввода внутри центрированной капсулы */
#ea-wrapper.search-active .capsule-input {
    width: 260px !important;
    flex-grow: 0 !important;
}

/* ================= ФИКС: КНОПКА ПЛЮС СТРОГО СПРАВА ================= */

/* 1. Делаем общий контейнер гибкой строкой, запрещаем перенос вниз */
.pool-container {
    display: flex !important;
    flex-direction: row !important; 
    align-items: flex-start !important;
    flex-wrap: nowrap !important; /* Жесткий запрет падать вниз */
    gap: 15px !important;
    border: none !important; 
    background: transparent !important; 
    padding: 0 !important;
}

/* 2. Рамка и фон теперь только у зоны с картинками */
#pool-dropzone {
    flex: 1 1 0% !important; /* Занимает всё свободное место слева */
    width: auto !important;
    background: var(--card-bg) !important;
    border: 2px dashed var(--border-dashed) !important;
    border-radius: 12px !important;
    padding: 10px 15px !important;
    min-height: 104px !important;
}

/* 3. Кнопка жестко фиксируется справа */
#ea-wrapper {
    flex: 0 0 auto !important; 
    order: 2 !important; 
}

/* 4. Анимация раскрытия строго ВНИЗ */
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) { 
    width: 80px !important; 
    height: 310px !important; 
}
body.ratio-16-9:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) { width: 142px !important; height: 310px !important; }
body.ratio-9-16:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) { width: 80px !important; height: 370px !important; }

body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-top-row {
    flex-direction: column !important;
    height: 100% !important;
    padding-top: 10px !important;
}
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-main-btn { margin-bottom: 5px !important; }
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-actions {
    opacity: 1 !important; visibility: visible !important; transform: none !important;
    flex-direction: column !important; align-items: center !important;
}

/* 5. Тултипы всплывают ВЛЕВО (чтобы не улетать за экран) */
.ea-icon-btn::after { right: calc(100% + 12px) !important; left: auto !important; transform: translateY(-50%) translateX(10px) !important; }
.ea-icon-btn::before { right: calc(100% + 6px) !important; left: auto !important; transform: translateY(-50%) translateX(10px) !important; border-color: transparent transparent transparent #151515 !important; }
.ea-icon-btn:hover::after, .ea-icon-btn:hover::before { transform: translateY(-50%) translateX(0) !important; }

/* 6. Адаптация для телефонов (кнопка падает вниз) */
@media (max-width: 768px) {
    .pool-container { flex-direction: column !important; }
    #ea-wrapper { width: 100% !important; }
}

/* ================= ФИКС ГЛИТЧА ПРИ СВОРАЧИВАНИИ ================= */
/* Намертво фиксируем вертикальный каркас, чтобы он не ломался при отведении мышки */

#ea-wrapper:not(.search-active) .ea-top-row {
    flex-direction: column !important;
    padding-top: 10px !important;
}

#ea-wrapper:not(.search-active) .ea-main-btn {
    margin: 0 0 5px 0 !important; /* Убиваем боковые отступы старого дизайна */
    width: 60px !important;
    height: 60px !important;
}

#ea-wrapper:not(.search-active) .ea-content-switcher {
    margin-left: 0 !important;
    width: 100% !important;
}

#ea-wrapper:not(.search-active) .ea-actions {
    flex-direction: column !important;
    align-items: center !important;
}

/* Заставляем иконки прятаться вверх (translateY), а не вправо */
#ea-wrapper:not(.ea-hovered):not(.search-active) .ea-actions {
    transform: translateY(-15px) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s !important;
}

#ea-wrapper.ea-hovered:not(.search-active) .ea-actions {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* ================= НИЖНЯЯ ФИКСИРОВАННАЯ ПАНЕЛЬ ПОИСКА ================= */
.bottom-search-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 250px;
    max-height: 50vh;
    background-color: var(--header-bg); 
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    z-index: 2500;
    display: flex;
    flex-direction: column;
    
    /* Анимация выезда снизу */
    transform: translateY(100%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease, visibility 0.4s;
}

.bottom-search-panel.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.bsp-header {
    display: flex;
    align-items: center;
    padding: 15px 30px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
body.light-theme .bsp-header { border-bottom-color: rgba(0,0,0,0.05); }

.bottom-search-panel .ea-search-body {
    padding: 15px 30px;
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: transparent !important;
    border: none !important;
}

.bottom-search-panel .premium-search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.bottom-search-panel .capsule-input {
    background: rgba(0,0,0,0.2) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 100px !important;
    padding: 8px 20px !important;
    color: var(--text-color) !important;
}
body.light-theme .bottom-search-panel .capsule-input { background: rgba(255,255,255,0.5) !important; }

/* Адаптация нижней панели под телефоны */
@media (max-width: 768px) {
    .bsp-header { flex-direction: column; gap: 10px; padding: 15px; }
    .bsp-header .capsule-tabs { margin: 0 !important; width: 100%; justify-content: center; }
    .bsp-header > div:last-child { margin-left: 0 !important; width: 100%; max-width: none !important; }
    .bottom-search-panel .ea-search-body { padding: 15px; }
}

/* ================= ФИКС ПЕРЕКРЫТИЯ КОНТЕНТА ПАНЕЛЬЮ ================= */
/* Добавляем плавную анимацию для body, чтобы контент отъезжал вверх мягко */
body {
    transition: background-color 0.2s ease, color 0.2s ease, padding-bottom 0.4s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* Когда панель открыта, добавляем пустое место снизу */
body.search-panel-active {
    padding-bottom: 250px !important; /* 250px (высота панели) + 20px для комфортного скролла */
}

/* ================= ФИКС МОБИЛЬНОЙ ШАПКИ ПОИСКА ================= */
@media (max-width: 768px) {
    .bsp-header { 
        flex-direction: row !important; 
        flex-wrap: wrap !important; 
        justify-content: space-between !important; 
        padding: 12px !important;
    }
    .bsp-center-bar { 
        order: 3; 
        width: 100% !important; 
        max-width: none !important; 
        margin: 10px 0 0 0 !important; 
    }
}

/* ================= ФИКС: МЕНЮ ПОИСКА ОТКРЫВАЕТСЯ ВВЕРХ ================= */
#search-category-dropdown {
    top: auto !important; /* Отменяем открытие вниз */
    bottom: calc(100% + 12px) !important; /* Заставляем выпадать вверх от кнопки */
    transform: translateY(10px) !important; /* Подготовка для красивой анимации */
}

/* Состояние, когда мы кликнули на кнопку */
.search-feed-selector.active #search-category-dropdown {
    transform: translateY(0) !important; /* Плавный выезд снизу-вверх */
}

/* ================= НОВЫЙ ДИЗАЙН: КОМПАКТНАЯ БОКОВАЯ КНОПКА (РАСКРЫТИЕ ВПРАВО) ================= */

/* 1. Убираем громоздкий пунктир и делаем кнопку прозрачной в покое */
#ea-wrapper .ea-inner {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 30px !important; /* Закругленная форма капсулы */
}

/* 2. Стартовые размеры малютки-кнопки */
body:not(.is-dragging-item) #ea-wrapper:not(.search-active) {
    width: 44px !important;
    height: 44px !important;
    margin-top: 10px !important; /* Выравниваем по верхнему краю пула */
}

/* 3. Оформление самой иконки плюса (круглый бейдж) */
body:not(.is-dragging-item) #ea-wrapper:not(.search-active) .ea-main-btn {
    width: 44px !important;
    height: 44px !important;
    margin: 0 !important;
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 50% !important; /* Идеальный круг */
    color: var(--text-muted) !important;
    flex-shrink: 0 !important;
    transition: all 0.3s ease !important;
    cursor: pointer;
}
/* Делаем сам плюсик изящнее */
#icon-plus { width: 22px !important; height: 22px !important; }

/* 4. Раскрытие ВПРАВО при наведении (высота остается 44px, растет только ширина) */
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) {
    width: 220px !important; 
    height: 44px !important;
}

/* При наведении капсула обретает плотный фон и тень */
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-inner {
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
}
body.light-theme:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-inner {
    background: #ffffff !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
}

/* Плюс становится цветным и сливается с капсулой при наведении */
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-main-btn {
    background: transparent !important;
    border-color: transparent !important;
    color: var(--accent-color) !important;
}

/* 5. Перестраиваем внутренности в ГОРИЗОНТАЛЬНУЮ строку */
body:not(.is-dragging-item) #ea-wrapper:not(.search-active) .ea-top-row {
    flex-direction: row !important;
    padding: 0 !important;
    height: 100% !important;
}
body:not(.is-dragging-item) #ea-wrapper:not(.search-active) .ea-content-switcher {
    width: auto !important;
    margin-left: 2px !important;
    display: flex !important;
}

/* Кнопки действий (файлы, камера и т.д.) теперь стоят в ряд */
body:not(.is-dragging-item) #ea-wrapper:not(.search-active) .ea-actions {
    flex-direction: row !important;
    gap: 6px !important;
    padding-right: 10px !important;
}

/* 6. Плавная анимация выезда кнопок СЛЕВА НАПРАВО */
#ea-wrapper:not(.ea-hovered):not(.search-active) .ea-actions {
    transform: translateX(-15px) !important;
    opacity: 0 !important;
    visibility: hidden !important;
}
#ea-wrapper.ea-hovered:not(.search-active) .ea-actions {
    transform: translateX(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Делаем мелкие иконки действий круглыми и аккуратными */
.ea-icon-btn {
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    border: none !important;
    background: rgba(255,255,255,0.05) !important;
}
body.light-theme .ea-icon-btn { background: rgba(0,0,0,0.05) !important; }
.ea-icon-btn svg { width: 16px !important; height: 16px !important; }

/* 7. Тултипы переносим НАВЕРХ (иначе они будут перекрывать друг друга) */
.ea-icon-btn::after {
    right: auto !important; left: 50% !important;
    bottom: calc(100% + 8px) !important; top: auto !important;
    transform: translateX(-50%) translateY(10px) !important; 
}
.ea-icon-btn::before {
    right: auto !important; left: 50% !important;
    bottom: calc(100% + 2px) !important; top: auto !important;
    transform: translateX(-50%) translateY(10px) !important;
    border-color: #151515 transparent transparent transparent !important;
}
.ea-icon-btn:hover::after, .ea-icon-btn:hover::before { 
    transform: translateX(-50%) translateY(0) !important; 
}

/* ================= ФИКС: КНОПКА ПРИКРЕПЛЕНА К ПАНЕЛИ ================= */

/* 1. Убираем дыру между пулом и кнопкой */
.pool-container {
    gap: 0 !important;
}

/* 2. Надвигаем кнопку ровно на границу пула (компенсируем толщину рамки) */
#ea-wrapper {
    margin-left: -2px !important; 
    z-index: 100 !important; /* Чтобы кнопка была поверх рамки */
}

/* 3. Делаем левый край кнопки плоским, чтобы она сливалась с рамкой как родная деталь */
body:not(.is-dragging-item) #ea-wrapper:not(.search-active) .ea-inner,
body:not(.is-dragging-item) #ea-wrapper:not(.search-active) .ea-main-btn {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: none !important; /* Убираем стык рамок */
}

/* 4. При раскрытии вправо капсула тоже остается приклеенной плоским краем */
body:not(.is-dragging-item) #ea-wrapper.ea-hovered:not(.search-active) .ea-inner {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: none !important;
}

/* ================= ЖЕСТКИЙ ФИКС: РАСКРЫТИЕ СТРОГО ВПРАВО ================= */
/* Добавление 'html' делает этот код абсолютным приоритетом */

/* 1. Блокируем рост вниз, разрешаем только в ширину */
html body:not(.is-dragging-item) #ea-wrapper.ea-hovered {
    width: 220px !important; 
    height: 44px !important; 
}

/* 2. Заставляем каркас всегда быть горизонтальной строкой */
html body:not(.is-dragging-item) #ea-wrapper .ea-top-row {
    flex-direction: row !important;
    padding: 0 !important;
    align-items: center !important;
    height: 100% !important;
}

/* 3. Убиваем нижний отступ у плюса, оставшийся от вертикального дизайна */
html body:not(.is-dragging-item) #ea-wrapper .ea-main-btn {
    margin: 0 !important; 
    width: 44px !important;
    height: 44px !important;
}

/* 4. Выстраиваем внутренние кнопки строго в ряд */
html body:not(.is-dragging-item) #ea-wrapper .ea-actions {
    flex-direction: row !important; 
    align-items: center !important;
    justify-content: flex-start !important;
    width: auto !important;
    gap: 6px !important;
    padding-right: 10px !important;
}

/* 5. Анимация выезда слева направо */
html body:not(.is-dragging-item) #ea-wrapper:not(.ea-hovered) .ea-actions {
    transform: translateX(-20px) !important;
    opacity: 0 !important;
    visibility: hidden !important;
}
html body:not(.is-dragging-item) #ea-wrapper.ea-hovered .ea-actions {
    transform: translateX(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* ================= АБСОЛЮТНЫЙ ПРИОРИТЕТ: РАСКРЫТИЕ СТРОГО ВПРАВО ================= */
/* Использование #builder-page делает этот код математически сильнее любых старых стилей */

/* 1. Блокируем старую высоту 310px, разрешаем расти только в ширину */
body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered:not(.search-active) {
    width: 220px !important; 
    height: 44px !important; 
}

/* 2. Стартовый размер кнопки в покое (защита от растягивания) */
body:not(.is-dragging-item) #builder-page #ea-wrapper:not(.ea-hovered):not(.search-active) {
    width: 44px !important;
    height: 44px !important;
}

/* 3. Жестко переводим весь каркас капсулы в ГОРИЗОНТАЛЬНУЮ строку */
body:not(.is-dragging-item) #builder-page #ea-wrapper:not(.search-active) .ea-top-row {
    flex-direction: row !important;
    align-items: center !important;
    height: 100% !important;
    padding: 0 !important;
}

/* 4. Выстраиваем внутренние кнопки в один ряд */
body:not(.is-dragging-item) #builder-page #ea-wrapper:not(.search-active) .ea-actions {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    width: 100% !important;
    padding-left: 2px !important;
}

/* 5. Плавный выезд иконок СЛЕВА НАПРАВО */
body:not(.is-dragging-item) #builder-page #ea-wrapper:not(.ea-hovered):not(.search-active) .ea-actions {
    transform: translateX(-20px) !important;
    opacity: 0 !important;
    visibility: hidden !important;
}
body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered:not(.search-active) .ea-actions {
    transform: translateX(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* 6. Убиваем старые отступы у круглой кнопки плюса */
body:not(.is-dragging-item) #builder-page #ea-wrapper:not(.search-active) .ea-main-btn {
    margin: 0 !important;
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0 !important;
}

/* ================= ФИКС: РАСКРЫТИЕ ПОВЕРХ (БЕЗ СДВИГА КАРТИНОК) ================= */

/* 1. Намертво фиксируем базу кнопки, чтобы она больше не давила на картинки */
html body:not(.is-dragging-item) #builder-page #ea-wrapper,
html body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    position: relative !important; /* Якорь для парящей выпадающей части */
    z-index: 100 !important;
}

/* 2. Делаем саму капсулу (ea-inner) "парящей". Теперь она не влияет на соседей. */
html body:not(.is-dragging-item) #builder-page #ea-wrapper .ea-inner {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 44px !important;
    height: 44px !important;
    overflow: hidden !important;
    /* Удерживаем плоский левый край для стыка с пунктиром */
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: none !important;
    transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s, box-shadow 0.3s !important;
}

/* 3. При наведении расширяется только "парящая" капсула, а база остается 44px */
html body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered .ea-inner {
    width: 220px !important;
}

/* ================= ФИНАЛЬНОЕ УБИЙСТВО СДВИГА КАРТИНОК ================= */

/* 1. Жестко блокируем расширение самой кнопки, перебивая старый код */
html body:not(.is-dragging-item) #builder-page #ea-wrapper,
html body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered:not(.search-active) {
    width: 44px !important;
    min-width: 44px !important;
    position: relative !important;
    overflow: visible !important; /* Обязательно, чтобы дать выехать внутренней капсуле */
}

/* 2. Делаем саму капсулу (с фоном и рамкой) парящей над страницей */
html body:not(.is-dragging-item) #builder-page #ea-wrapper .ea-inner {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 44px !important;
    height: 44px !important;
    overflow: hidden !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: none !important;
    transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s, box-shadow 0.3s !important;
    z-index: 100 !important;
}

/* 3. Разрешаем расширяться ТОЛЬКО парящей капсуле (она не сдвинет картинки) */
html body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered:not(.search-active) .ea-inner {
    width: 220px !important;
}

/* 4. Фиксируем ширину внутренней строки, чтобы иконки не сплющивало при анимации */
html body:not(.is-dragging-item) #builder-page #ea-wrapper .ea-top-row {
    width: 220px !important;
    flex-wrap: nowrap !important;
}

/* ================= ФИКС: КНОПКА НЕ ЛОМАЕТСЯ ПРИ ПЕРЕТАСКИВАНИИ ================= */
/* Жестко фиксируем дизайн маленькой кнопки на то время, пока мы тащим картинку мышкой */

html body.is-dragging-item #builder-page #ea-wrapper {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    position: relative !important;
    margin-left: -2px !important; /* Удерживаем приклеенной к рамке */
    z-index: 100 !important;
}

html body.is-dragging-item #builder-page #ea-wrapper .ea-inner {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 44px !important;
    height: 44px !important;
    overflow: hidden !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-left: none !important;
}

/* Восстанавливаем круглый бейдж плюсика во время перетаскивания */
html body.is-dragging-item #builder-page #ea-wrapper .ea-main-btn {
    width: 44px !important;
    height: 44px !important;
    margin: 0 !important;
    background: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 50% !important;
    color: var(--text-muted) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

html body.is-dragging-item #builder-page #ea-wrapper #icon-plus {
    width: 22px !important;
    height: 22px !important;
    transform: translate(-50%, -50%) scale(1) rotate(0deg) !important;
    opacity: 1 !important;
}

/* ================= ФИНАЛЬНЫЙ ФИКС КРИВОГО ПЛЮСА ПРИ ПЕРЕТАСКИВАНИИ ================= */

/* 1. Жестко бетонируем размеры всех слоев (убиваем вытягивание в овал) */
html body.is-dragging-item #builder-page #ea-wrapper,
html body.is-dragging-item #builder-page #ea-wrapper .ea-inner,
html body.is-dragging-item #builder-page #ea-wrapper .ea-top-row,
html body.is-dragging-item #builder-page #ea-wrapper .ea-main-btn {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important; 
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    padding: 0 !important;
}

/* 2. Идеально центруем плюсик и отменяем старый сдвиг */
html body.is-dragging-item #builder-page #ea-wrapper .ea-main-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

html body.is-dragging-item #builder-page #ea-wrapper #icon-plus {
    transform: none !important; /* Именно это вернет плюс ровно в центр */
    position: static !important;
    margin: 0 !important;
}

/* 3. Намертво отключаем невидимые элементы, чтобы они не распирали кнопку изнутри */
html body.is-dragging-item #builder-page #ea-wrapper .ea-content-switcher,
html body.is-dragging-item #builder-page #ea-wrapper .ea-actions {
    display: none !important;
    width: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

/* ================= ФИКС: ЯЗЫЧОК НЕ СКРУГЛЯЕТСЯ ПРИ ПЕРЕТАСКИВАНИИ ================= */
html body.is-dragging-item #builder-page #ea-wrapper .ea-main-btn {
    border-radius: 0 30px 30px 0 !important; /* Прямой левый край, круглый правый */
    border-left: none !important; /* Убираем левую границу для идеального стыка с пунктиром */
}

/* ================= ФИКС: КНОПКА НЕ ПОДПРЫГИВАЕТ ПРИ ПЕРЕТАСКИВАНИИ ================= */
html body.is-dragging-item #builder-page #ea-wrapper {
    margin-top: 10px !important; /* Возвращаем пропавший отступ */
}

/* ================= ДИЗАЙН УМНОЙ СТРОКИ ПОИСКА (КАК В ШАПКЕ) ================= */

.bsp-header-new {
    position: relative !important;
    justify-content: center !important;
    display: flex !important;
    align-items: center !important;
    padding: 15px 30px !important;
}

.unified-search-bar {
    display: flex !important;
    align-items: center !important;
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 100px !important;
    padding: 4px 4px 4px 20px !important;
    width: 100% !important;
    max-width: 600px !important;
    transition: all 0.3s ease !important;
}
body.light-theme .unified-search-bar { background: rgba(0,0,0,0.03) !important; }

/* Подсветка всей капсулы при клике */
.unified-search-bar:focus-within {
    border-color: var(--accent-color) !important;
    background: transparent !important;
}

.unified-search-bar input {
    flex-grow: 1 !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-color) !important;
    outline: none !important;
    font-size: 14px !important;
    min-width: 100px !important;
}

#search-clear-btn {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    cursor: pointer !important;
    padding: 5px !important;
    margin-right: 5px !important;
    display: none; /* Управляется скриптом JS */
    align-items: center;
    justify-content: center;
}
#search-clear-btn:hover { color: var(--text-color) !important; }

.usb-divider {
    width: 1px !important;
    height: 24px !important;
    background: var(--border-color) !important;
    margin: 0 5px !important;
}

.unified-search-bar .search-feed-selector { margin: 0 !important; position: relative !important; }

.unified-search-bar .feed-selector-btn {
    background: transparent !important;
    border: none !important;
    color: var(--text-color) !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    padding: 8px 15px !important;
    border-radius: 100px !important;
}
.unified-search-bar .feed-selector-btn:hover { background: rgba(255,255,255,0.1) !important; }
body.light-theme .unified-search-bar .feed-selector-btn:hover { background: rgba(0,0,0,0.05) !important; }

/* Меню категорий элегантно всплывает вверх */
.unified-search-bar #search-category-dropdown {
    top: auto !important;
    bottom: calc(100% + 15px) !important;
    right: 0 !important;
    left: auto !important;
    min-width: 150px !important;
}

.bsp-submit-btn { padding: 10px 22px !important; border-radius: 100px !important; margin-left: 10px !important; }
.bsp-close-btn {
    position: absolute !important; 
    right: 30px !important;
    width: 36px !important; 
    height: 36px !important; 
    background: rgba(255, 70, 70, 0.15) !important; 
    color: #ff5555 !important; 
    border-radius: 50% !important;
    margin: 0 !important;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .bsp-header-new { flex-wrap: wrap !important; padding: 15px !important; }
    .bsp-close-btn { position: static !important; margin-left: auto !important; }
    .unified-search-bar { max-width: 100% !important; order: 3 !important; margin-top: 15px !important; }
    .bsp-submit-btn { order: 4 !important; margin-top: 15px !important; flex-grow: 1 !important; margin-left: 0 !important;}
}

/* ================= ДИЗАЙН: ЛУПА В СТРОКЕ И БОКОВЫЕ СТРЕЛКИ ================= */

/* 1. Настраиваем лупу и крестик внутри строки */
#search-submit-icon, #search-clear-btn {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    cursor: pointer !important;
    padding: 5px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.2s !important;
}
#search-clear-btn { display: none; margin-right: 0 !important; }
#search-submit-icon { margin-right: 8px !important; }

#search-clear-btn:hover { color: #ff5555 !important; } /* Крестик краснеет */
#search-submit-icon:hover { color: var(--accent-color) !important; } /* Лупа светится */

/* 2. Настраиваем карусель картинок */
.search-carousel-container {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 15px !important;
    flex-grow: 1 !important;
}

.search-carousel-container .premium-search-grid {
    flex-grow: 1 !important;
    width: 100% !important;
}

/* 3. Дизайн боковых круглых стрелок */
.nav-arrow {
    flex-shrink: 0 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,0.05) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-color) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}
body.light-theme .nav-arrow { background: rgba(0,0,0,0.05) !important; }

.nav-arrow:hover:not(:disabled) {
    background: var(--accent-color) !important;
    color: white !important;
    border-color: var(--accent-color) !important;
    transform: scale(1.1) !important; /* Легкое увеличение при наведении */
}

/* Умное скрытие стрелок (отключаются прозрачностью, если неактивны) */
.nav-arrow:disabled,
.nav-arrow[style*="visibility: hidden"],
.nav-arrow[style*="display: none"] {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Скрываем стрелки, если поиск еще не дал результатов (пустая сетка) */
.search-carousel-container:has(#search-results-grid:empty) .nav-arrow {
    display: none !important;
}

/* Мобильная адаптация стрелок */
@media (max-width: 768px) {
    .nav-arrow { width: 36px !important; height: 36px !important; }
    .search-carousel-container { gap: 8px !important; }
}

/* ================= ФИКС: ВОЗВРАЩАЕМ ВИДИМОСТЬ БЛОКУ КАРТИНОК И ЗАГРУЗКИ ================= */
html body #bottom-search-panel #ea-search-body {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Делаем так, чтобы сетка картинок занимала всё доступное место */
html body #bottom-search-panel .search-carousel-container {
    height: 100% !important;
}

/* ================= 1. ЧИСТЫЕ МИНИМАЛИСТИЧНЫЕ СТРЕЛКИ ================= */
html body .nav-arrow {
    color: var(--text-color) !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
    box-shadow: none !important; /* Убрали лишние тени */
    font-size: initial !important; /* Возвращаем видимость SVG */
}

html body.light-theme .nav-arrow {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.08) !important;
    color: var(--text-color) !important;
}

html body .nav-arrow:hover:not(:disabled) {
    background: var(--accent-color) !important;
    border-color: var(--accent-color) !important;
    color: #fff !important;
    transform: scale(1.1) !important;
}

/* УБИВАЕМ СТАРЫЕ CSS-ГАЛОЧКИ, ЧТОБЫ ОНИ НЕ НАКЛАДЫВАЛИСЬ НА SVG */
html body #page-prev-btn::after,
html body #page-next-btn::after {
    display: none !important;
}


/* ================= 2. УМНЫЙ КРЕСТИК В СТРОКЕ ПОИСКА ================= */

/* Используем чистую CSS-магию: если плейсхолдер виден (строка пустая), крестика нет */
html body #search-query-input:placeholder-shown + #search-clear-btn {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Если плейсхолдер скрыт (мы начали вводить текст), крестик плавно появляется */
html body #search-query-input:not(:placeholder-shown) + #search-clear-btn {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ================= ДИЗАЙН ИКОНОК В ВЕРХНЕЙ ШАПКЕ ================= */

/* Базовый стиль для аккуратных иконок шапки */
html body .header-icon-btn {
    background: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    cursor: pointer !important;
    padding: 5px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: color 0.2s !important;
    margin-right: 4px !important; /* Небольшой отступ между иконками */
}

/* Цвета при наведении */
html body #top-search-clear-btn:hover { color: #ff5555 !important; }
html body #top-search-submit-btn:hover { color: var(--accent-color) !important; }

/* Чистая CSS-магия: прячем крестик, если виден плейсхолдер (строка пустая) */
html body #top-search-input:placeholder-shown + #top-search-clear-btn {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Показываем крестик, когда ввели текст */
html body #top-search-input:not(:placeholder-shown) + #top-search-clear-btn {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ================= ФИКС: УМНЫЙ КРЕСТИК ДЛЯ РЕАЛЬНОГО ID ИНПУТА ================= */

/* Прячем крестик, если строка global-search-input пустая */
html body #global-search-input:placeholder-shown + #top-search-clear-btn {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Показываем крестик, когда ввели текст */
html body #global-search-input:not(:placeholder-shown) + #top-search-clear-btn {
    display: flex !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* ================= ДИЗАЙН: КАРУСЕЛЬ СТРОГО В ОДИН РЯД ================= */

/* 1. Делаем сетку гибкой строкой БЕЗ ПЕРЕНОСОВ (nowrap) */
html body #bottom-search-panel #search-results-grid {
    display: flex !important;
    flex-wrap: nowrap !important; /* ЗАПРЕЩАЕМ ПЕРЕНОС НА НОВУЮ СТРОКУ */
    gap: 15px !important; 
    justify-content: flex-start !important; /* Выравниваем по левому краю */
    align-items: center !important; /* Центрируем по вертикали */
    padding: 10px 5px !important;
    
    /* Разрешаем горизонтальный скролл ВНУТРИ сетки (если картинок больше, чем влезает на экран) */
    overflow-x: auto !important; 
    overflow-y: hidden !important; 
    
    /* Скрываем стандартный страшный ползунок скролла (если нужно) */
    scrollbar-width: none; 
}
html body #bottom-search-panel #search-results-grid::-webkit-scrollbar {
    display: none;
}

/* 2. Жестко фиксируем размеры картинок, чтобы они не сплющивались */
html body #bottom-search-panel #search-results-grid > * {
    margin: 0 !important; 
    flex-shrink: 0 !important; /* Ключевое правило: запрещаем сжатие! */
    position: relative !important; 
}

/* 3. Карусель теперь всегда одной фиксированной высоты */
html body #bottom-search-panel .search-carousel-container {
    height: auto !important; 
    align-items: center !important;
    padding-top: 15px !important;
}

/* ================= ФИКС: ЖЕСТКАЯ БЛОКИРОВКА ВЫСОТЫ ПАНЕЛИ ================= */
html body #bottom-search-panel {
    height: 200px !important; /* Уменьшили высоту панели, чтобы не было пустоты снизу */
    min-height: 200px !important; 
    max-height: 200px !important;
    padding-bottom: 10px !important;
}
html body #bottom-search-panel .ea-search-body {
    overflow-y: hidden !important; 
}

/* ================= ФИКС: УБИВАЕМ ВЕРТИКАЛЬНЫЙ СКРОЛЛ ПАНЕЛИ ================= */
html body #bottom-search-panel .ea-search-body {
    overflow-y: hidden !important; /* Намертво блокируем появление полосы прокрутки */
}

/* Выравниваем карусель строго по верхнему краю, чтобы не было скачков */
html body #bottom-search-panel .search-carousel-container {
    align-items: flex-start !important;
    padding-top: 5px !important;
}

/* ================= ДИНАМИЧЕСКАЯ ВЫСОТА ПАНЕЛИ ПОД ФОРМАТ ================= */

/* 1. Панель автоматически подстраивается под высоту картинок (80px или 142px) */
html body #bottom-search-panel {
    height: auto !important; 
    min-height: 0 !important; 
    max-height: none !important;
    padding-bottom: 15px !important; /* Оставляем место для горизонтального ползунка */
}

/* 2. Отступ страницы для низких картинок (Квадрат и 16:9) */
html body:not(.ratio-9-16).search-panel-active {
    padding-bottom: 175px !important; 
}

/* 3. Увеличенный отступ страницы для высоких картинок (9:16) */
html body.ratio-9-16.search-panel-active {
    padding-bottom: 235px !important; 
}

/* 4. Снимаем жесткий лимит высоты сетки, из-за которого обрезался низ вертикальных картинок */
html body #bottom-search-panel #search-results-grid {
    max-height: none !important; 
}

/* 3. Убираем лишние отступы внутри панели */
html body .bsp-header-new {
    padding-top: 15px !important;
    padding-bottom: 0px !important;
}

html body #bottom-search-panel .search-carousel-container {
    padding-top: 10px !important;
    margin-top: 0 !important;
}

html body #bottom-search-panel #search-results-grid {
    padding: 0 5px !important; 
}

/* ================= ФИКС: ЖЕСТКАЯ БЛОКИРОВКА 3-ГО РЯДА ================= */
html body #bottom-search-panel #search-results-grid {
    max-height: 195px !important; /* Физически ограничиваем высоту ровно под 2 ряда */
    overflow: hidden !important;  /* Безжалостно обрезаем всё, что попытается упасть вниз */
}

/* ================= ПОДСКАЗКА ДЛЯ СКРОЛЛА И ФИКСЫ СЕТКИ ================= */
.scroll-hint-overlay {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    padding: 8px 16px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

body.light-theme .scroll-hint-overlay {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0f172a;
}

.scroll-hint-overlay.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Делаем скролл внутри сетки абсолютно плавным */
html body #bottom-search-panel #search-results-grid {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Идеально плавный свайп на iOS */
}

/* Умное скрытие стрелок */
.nav-arrow.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ================= ПРЕМИАЛЬНАЯ МИНИМАЛИСТИЧНАЯ КНОПКА ПЛЮС (КАПСУЛА) ================= */

/* 1. Отсоединяем кнопку и используем margin-top для выравнивания */
html body #builder-page #ea-wrapper {
    margin-left: 15px !important; /* Больше воздуха от рамки */
    margin-top: 20px !important;  /* Спускаем кнопку вниз, чтобы она была по центру первого ряда картинок */
    align-self: flex-start !important; /* Жестко привязываем к верху, а спускаем через margin-top */
}

/* Фикс для разных форматов (разная высота картинок = разный сдвиг кнопки) */
html body.ratio-16-9 #builder-page #ea-wrapper { margin-top: 20px !important; }
html body.ratio-9-16 #builder-page #ea-wrapper { margin-top: 51px !important; }

/* 2. Делаем саму капсулу идеальным "стеклом" (Glassmorphism) */
html body #builder-page #ea-wrapper .ea-inner {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 100px !important; /* Идеальный круг при 44x44 и капсула при раскрытии */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s, box-shadow 0.3s, border-color 0.3s !important;
}

/* Светлая тема для капсулы */
html body.light-theme #builder-page #ea-wrapper .ea-inner {
    background: rgba(0, 0, 0, 0.02) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03) !important;
}

/* 3. Очищаем саму кнопку внутри (фон теперь дает капсула, убираем старые плоские края) */
html body #builder-page #ea-wrapper .ea-main-btn {
    background: transparent !important;
    border: none !important;
    border-radius: 50% !important; 
    color: var(--text-muted) !important;
    box-shadow: none !important;
}

/* 4. Иконка плюса: делаем ее тонкой и изящной */
html body #builder-page #ea-wrapper #icon-plus {
    width: 22px !important;
    height: 22px !important;
    stroke-width: 1.5px !important; /* Тонкие, "дорогие" линии */
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), color 0.3s !important;
}

/* 5. Эффект наведения (Ховер раскрытия) */
html body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered .ea-inner {
    background: rgba(255, 255, 255, 0.07) !important; /* Мягко высветляем */
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2) !important;
}

html body.light-theme:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered .ea-inner {
    background: rgba(255, 255, 255, 0.9) !important; /* В светлой теме делаем почти белой */
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08) !important;
}

/* 6. Анимация плюсика при наведении */
html body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered .ea-main-btn {
    color: var(--accent-color) !important; /* Загорается цветом скроллбара (голубым/фиолетовым) */
}

html body:not(.is-dragging-item) #builder-page #ea-wrapper.ea-hovered #icon-plus {
    transform: scale(1.1) rotate(90deg) !important; /* Плавный проворот на 90 градусов */
}

/* ================= ФИНАЛЬНЫЙ ФИКС: ИДЕАЛЬНО КРУГЛАЯ КАПСУЛА ================= */

/* 1. Намертво отрываем капсулу от пунктирной рамки пула */
html body #builder-page #ea-wrapper {
    margin-left: 15px !important; 
}

/* 2. Заставляем внешний контейнер быть идеальным кругом (или овалом при наведении),
      убивая все старые прямые углы и прозрачные левые рамки */
html body #builder-page #ea-wrapper:not(.search-active) .ea-inner {
    border-radius: 100px !important; 
    border: 1px solid rgba(255, 255, 255, 0.08) !important; /* Полная рамка со всех 4 сторон */
}

/* Рамка для светлой темы */
html body.light-theme #builder-page #ea-wrapper:not(.search-active) .ea-inner {
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

/* 3. Очищаем саму кнопку внутри, чтобы она не рисовала "двойной" фон поверх контейнера */
html body #builder-page #ea-wrapper:not(.search-active) .ea-main-btn {
    border-radius: 100px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* ================= ФИНАЛЬНЫЙ ФИКС: ИДЕАЛЬНО КРУГЛАЯ КАПСУЛА + ТУЛТИПЫ ================= */

/* 1. Отрываем капсулу от рамки */
html body #builder-page #ea-wrapper {
    margin-left: 15px !important; 
    overflow: visible !important; /* Разрешаем тултипам выходить за пределы! */
}

/* 2. Капсула становится круглой, но не обрезает всплывающие подсказки */
html body #builder-page #ea-wrapper:not(.search-active) .ea-inner {
    border-radius: 100px !important; 
    border: 1px solid rgba(255, 255, 255, 0.08) !important; 
    overflow: visible !important; /* ВАЖНО: снимаем старый hidden, который обрезал тултипы! */
}

/* Рамка для светлой темы */
html body.light-theme #builder-page #ea-wrapper:not(.search-active) .ea-inner {
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
}

/* 3. Кнопка внутри */
html body #builder-page #ea-wrapper:not(.search-active) .ea-main-btn {
    border-radius: 100px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}


/* ================= ТУЛТИПЫ ДЛЯ КНОПОК КАПСУЛЫ (ВСПЛЫВАЮТ ВВЕРХ) ================= */

html body #builder-page .ea-icon-btn {
    position: relative !important; /* Якорь для тултипов */
}

/* Текст подсказки */
html body #builder-page .ea-icon-btn::after {
    content: attr(data-title) !important;
    position: absolute !important;
    bottom: calc(100% + 10px) !important;
    left: 50% !important;
    top: auto !important;
    right: auto !important;
    transform: translateX(-50%) translateY(10px) !important;
    
    background: #111111 !important;
    color: #ffffff !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    pointer-events: none !important;
    
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3) !important;
    z-index: 9999 !important; /* Выносим поверх всего */
}

/* Стрелочка вниз */
html body #builder-page .ea-icon-btn::before {
    content: '' !important;
    position: absolute !important;
    bottom: calc(100% + 2px) !important;
    left: 50% !important;
    top: auto !important;
    right: auto !important;
    transform: translateX(-50%) translateY(10px) !important;
    
    border-width: 5px !important;
    border-style: solid !important;
    border-color: #111111 transparent transparent transparent !important;
    
    pointer-events: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    z-index: 9999 !important;
}

/* Светлая тема */
html body.light-theme #builder-page .ea-icon-btn::after {
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1) !important;
    border: 1px solid rgba(0,0,0,0.05) !important;
}
html body.light-theme #builder-page .ea-icon-btn::before {
    border-color: #ffffff transparent transparent transparent !important;
}

/* Появление при наведении */
html body #builder-page .ea-icon-btn:hover::after,
html body #builder-page .ea-icon-btn:hover::before {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) !important;
}

/* ================= ФИКС: КОЛОНКА ИЗ 3-Х КАПСУЛ СПРАВА ================= */

/* Создаем колонку для кнопок справа от пула картинок */
html body #builder-page .capsules-column {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    justify-content: flex-start;
    margin-left: 15px;
    margin-top: 18px; /* Выравниваем по центру первой картинки */
    z-index: 100;
}

/* Снимаем старые отступы с капсул, так как их теперь двигает колонка */
html body #builder-page #ea-wrapper,
html body #builder-page #settings-wrapper,
html body #builder-page #save-wrapper {
    margin-left: 0 !important;
    margin-top: 0 !important;
}

/* Базовый размер 44x44 для Настроек и Сохранения */
html body #builder-page #settings-wrapper,
html body #builder-page #save-wrapper {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    position: relative !important;
    overflow: visible !important; 
}

/* Внутренняя стеклянная капсула (Круг в покое) */
html body #builder-page #settings-wrapper .ea-inner,
html body #builder-page #save-wrapper .ea-inner {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 100px !important; 
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    overflow: visible !important; 
    transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s, box-shadow 0.3s, border-color 0.3s !important;
    z-index: 100 !important;
}

/* Светлая тема */
html body.light-theme #builder-page #settings-wrapper .ea-inner,
html body.light-theme #builder-page #save-wrapper .ea-inner {
    background: rgba(0, 0, 0, 0.02) !important;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03) !important;
}

/* Сама иконка (Шестеренка / Дискета) */
html body #builder-page #settings-wrapper .ea-main-btn,
html body #builder-page #save-wrapper .ea-main-btn {
    width: 44px !important;
    height: 44px !important;
    border-radius: 100px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--text-muted) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

/* Строка с кнопками */
html body #builder-page #settings-wrapper .ea-top-row,
html body #builder-page #save-wrapper .ea-top-row {
    flex-direction: row !important;
    align-items: center !important;
    height: 100% !important;
    padding: 0 !important;
    width: 220px !important; /* В обеих капсулах по 4 доп. кнопки, поэтому ширина одинаковая */
    flex-wrap: nowrap !important;
}

html body #builder-page #settings-wrapper .ea-content-switcher,
html body #builder-page #save-wrapper .ea-content-switcher {
    width: auto !important;
    margin-left: 2px !important;
    display: flex !important;
}

html body #builder-page #settings-wrapper .ea-actions,
html body #builder-page #save-wrapper .ea-actions {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    padding-left: 2px !important;
    
    transform: translateX(-20px) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s !important;
}

/* ================= ХОВЕР ЭФФЕКТЫ (РАСКРЫТИЕ) ================= */
html body:not(.is-dragging-item) #builder-page #settings-wrapper.ea-hovered .ea-inner,
html body:not(.is-dragging-item) #builder-page #save-wrapper.ea-hovered .ea-inner {
    width: 220px !important;
    background: rgba(255, 255, 255, 0.07) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2) !important;
}
html body.light-theme:not(.is-dragging-item) #builder-page #settings-wrapper.ea-hovered .ea-inner,
html body.light-theme:not(.is-dragging-item) #builder-page #save-wrapper.ea-hovered .ea-inner {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08) !important;
}

/* Подсветка главной иконки при наведении */
html body:not(.is-dragging-item) #builder-page #settings-wrapper.ea-hovered .ea-main-btn,
html body:not(.is-dragging-item) #builder-page #save-wrapper.ea-hovered .ea-main-btn {
    color: var(--accent-color) !important;
}
/* Анимации иконок: шестеренка крутится, дискета чуть увеличивается */
html body:not(.is-dragging-item) #builder-page #settings-wrapper.ea-hovered .ea-main-btn svg {
    transform: rotate(90deg) !important; 
}
html body:not(.is-dragging-item) #builder-page #save-wrapper.ea-hovered .ea-main-btn svg {
    transform: scale(1.1) !important; 
}

/* Появление скрытых кнопок */
html body:not(.is-dragging-item) #builder-page #settings-wrapper.ea-hovered .ea-actions,
html body:not(.is-dragging-item) #builder-page #save-wrapper.ea-hovered .ea-actions {
    transform: translateX(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Блокировка при перетаскивании картинок */
html body.is-dragging-item #builder-page #settings-wrapper,
html body.is-dragging-item #builder-page #save-wrapper {
    z-index: 100 !important;
}
html body.is-dragging-item #builder-page #settings-wrapper .ea-actions,
html body.is-dragging-item #builder-page #save-wrapper .ea-actions {
    display: none !important;
}

/* ================= ФИКС: УБИВАЕМ "ПРИЗРАЧНОЕ ПОЛЕ" (ЛОЖНЫЕ СРАБАТЫВАНИЯ) ================= */

/* 1. Если капсула закрыта, делаем весь ее невидимый длинный "хвост" абсолютно прозрачным для мышки */
html body #builder-page .expandable-add-wrapper:not(.ea-hovered):not(.search-active) {
    pointer-events: none !important;
}

/* 2. Разрешаем реагировать на мышку ИСКЛЮЧИТЕЛЬНО самой круглой иконке */
html body #builder-page .expandable-add-wrapper:not(.ea-hovered):not(.search-active) .ea-main-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* ================= ФИКС: ПРАВИЛЬНЫЙ ПОРЯДОК КАПСУЛ (ПЛЮС -> СОХРАНЕНИЕ -> НАСТРОЙКИ) ================= */

/* Жестко задаем порядок кнопок в колонке, перебивая старые стили */
html body #builder-page #ea-wrapper {
    order: 1 !important; /* Плюс всегда первый (сверху) */
}

html body #builder-page #save-wrapper {
    order: 2 !important; /* Сохранение всегда второе (посередине) */
}

html body #builder-page #settings-wrapper {
    order: 3 !important; /* Настройки всегда третьи (снизу) */
}

/* ================= ФИКС: ЖЕСТКАЯ БЛОКИРОВКА ПРЫЖКОВ ПРИ ПЕРЕТАСКИВАНИИ ================= */

/* 1. Намертво фиксируем саму колонку на ее законном месте (18px сверху) во время драга */
html body.is-dragging-item #builder-page .capsules-column {
    margin-top: 18px !important;
    padding-top: 0 !important;
    transform: none !important;
}

/* 2. Убиваем ЛЮБЫЕ старые отступы у кнопок, которые могли активироваться при перетаскивании */
html body.is-dragging-item #builder-page #ea-wrapper,
html body.is-dragging-item #builder-page #save-wrapper,
html body.is-dragging-item #builder-page #settings-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    top: 0 !important;
    transform: none !important;
}

/* 3. Гарантируем, что стеклянная форма и рамки кнопок не ломаются во время драга */
html body.is-dragging-item #builder-page .capsules-column .ea-inner {
    border-radius: 100px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    width: 44px !important;
    height: 44px !important;
}

/* 4. Защита для светлой темы при перетаскивании */
html body.light-theme.is-dragging-item #builder-page .capsules-column .ea-inner {
    border-color: rgba(0, 0, 0, 0.06) !important;
    background: rgba(0, 0, 0, 0.02) !important;
}

/* ================= ФИКС: ПРОЗРАЧНОСТЬ ПРИ ДРАГЕ И ПРАВИЛЬНЫЙ КУРСОР ================= */

/* 1. Убираем курсор-руку у главных кнопок (они открываются по наведению, кликать на них не нужно) */
html body #builder-page .capsules-column .ea-main-btn {
    cursor: default !important; 
}

/* 2. Жестко убиваем темный фон и старые рамки у кнопок во время перетаскивания картинок */
html body.is-dragging-item #builder-page .capsules-column .ea-main-btn {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--text-muted) !important;
}

/* 3. Убеждаемся, что иконка плюса тоже не имеет никаких фонов */
html body.is-dragging-item #builder-page .capsules-column #icon-plus {
    background: transparent !important;
}

/* ================= ФИКС: ВЫРАВНИВАНИЕ КОЛОНКИ ПО ФОРМАТУ И ОЧИСТКА ПЛЮСА ================= */

/* 1. Отключаем привязку колонки к верхнему краю, теперь она будет плавать */
html body #builder-page .capsules-column {
    margin-top: 0 !important;
}

/* 2. Жестко позиционируем колонку по центру ПЕРВОГО ряда для каждого формата */
/* Для Квадратов (1:1) высота картинки 80px, кнопка 44px -> (80-44)/2 = 18px */
html body #builder-page .capsules-column {
    margin-top: 18px !important;
}

/* Для Прямоугольников (16:9) высота тоже 80px */
html body.ratio-16-9 #builder-page .capsules-column {
    margin-top: 18px !important;
}

/* Для Вертикальных (9:16) высота картинки 142px -> (142-44)/2 = 49px */
html body.ratio-9-16 #builder-page .capsules-column {
    margin-top: 49px !important;
}

/* 3. ЖЕСТКО блокируем прыжки при перетаскивании (отменяем все старые трансформации) */
html body.is-dragging-item #builder-page .capsules-column {
    transform: none !important;
    padding-top: 0 !important;
}

/* 4. ОЧИЩАЕМ ПЛЮСИК ПРИ ПЕРЕТАСКИВАНИИ (Убиваем старый темный фон) */
html body.is-dragging-item #builder-page #ea-wrapper .ea-main-btn {
    background: transparent !important;
    border: none !important;
    border-radius: 100px !important; /* Убираем плоский левый край */
}

/* Очищаем иконку плюса */
html body.is-dragging-item #builder-page #ea-wrapper #icon-plus {
    background: transparent !important;
    transform: none !important;
}

/* ================= АБСОЛЮТНЫЙ ФИКС: ТЕМНЫЙ ФОН И ПРЫЖКИ КОЛОНКИ ================= */

/* 1. ЖЕСТКО УБИВАЕМ ТЕМНЫЙ ФОН ПЛЮСА ПРИ ПЕРЕТАСКИВАНИИ */
/* Длинный селектор перебивает любые старые правила в коде */
html body.is-dragging-item #builder-page #pool-container #ea-wrapper .ea-main-btn,
html body.is-dragging-item #builder-page #pool-container #ea-wrapper:not(.search-active) .ea-main-btn {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Защищаем стеклянную капсулу Плюса от искажений при драге */
html body.is-dragging-item #builder-page #pool-container #ea-wrapper .ea-inner,
html body.is-dragging-item #builder-page #pool-container #ea-wrapper:not(.search-active) .ea-inner {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 100px !important;
}

/* 2. НАМЕРТВО ФИКСИРУЕМ КОЛОНКУ СВЕРХУ (БЕЗ ПРЫЖКОВ ПРИ СМЕНЕ ФОРМАТА) */
html body #builder-page .capsules-column {
    align-self: flex-start !important; /* Прибиваем колонку к самому верху пула */
    margin-top: 20px !important; /* Задаем единый отступ сверху для всех форматов */
    transform: none !important;
}

/* Отменяем любые изменения отступов для других форматов, чтобы колонка стояла на месте */
html body.ratio-9-16 #builder-page .capsules-column,
html body.ratio-16-9 #builder-page .capsules-column,
html body.is-dragging-item #builder-page .capsules-column {
    margin-top: 20px !important;
    transform: none !important;
}

/* ================= ФИНАЛЬНЫЙ ФИКС: АБСОЛЮТНАЯ ФИКСАЦИЯ КОЛОНКИ ================= */

/* 1. Делаем родительский контейнер пула опорной точкой */
html body #builder-page #pool-container {
    position: relative !important;
}

/* 2. Отрываем колонку от картинок и фиксируем абсолютно */
html body #builder-page .capsules-column {
    position: absolute !important;
    top: 20px !important; /* Жестко фиксируем отступ сверху для ВСЕХ форматов */
    right: -60px !important; /* Выносим за правую границу пунктирной рамки */
    margin-top: 0 !important;
    align-self: flex-start !important;
    height: auto !important;
}

/* Убиваем все старые отступы форматов, так как теперь позиция абсолютная */
html body.ratio-16-9 #builder-page .capsules-column,
html body.ratio-9-16 #builder-page .capsules-column,
html body.is-dragging-item #builder-page .capsules-column {
    margin-top: 0 !important;
    top: 20px !important; 
    transform: none !important;
}

/* 3. ФИКС ИКОНКИ ПЛЮСА ПРИ ПЕРЕТАСКИВАНИИ */
/* Отменяем старые правила transform, которые сдвигали крестик */
html body.is-dragging-item #builder-page #ea-wrapper #icon-plus {
    transform: none !important;
    margin: 0 !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
}

/* Жестко центрируем иконку плюса внутри прозрачной кнопки */
html body.is-dragging-item #builder-page #ea-wrapper .ea-main-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ================= АБСОЛЮТНОЕ УДАЛЕНИЕ ПРЫЖКОВ И СДВИГОВ ================= */

/* 1. Убиваем старые индивидуальные отступы у капсулы Плюса для ВСЕХ форматов */
html body #builder-page #ea-wrapper,
html body.ratio-9-16 #builder-page #ea-wrapper,
html body.ratio-16-9 #builder-page #ea-wrapper {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* 2. Намертво прибиваем саму колонку к верху (как на квадратном формате) */
html body #builder-page .capsules-column {
    margin-top: 18px !important;
}

/* 3. Центрируем иконку Плюса при перетаскивании (Flexbox вместо устаревшего Absolute) */
html body.is-dragging-item #builder-page #ea-wrapper .ea-main-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important; /* Защита от темного фона */
    border: none !important;
}

/* Очищаем старые координаты иконки, чтобы Flexbox поставил ее ровно по центру */
html body.is-dragging-item #builder-page #ea-wrapper #icon-plus {
    position: static !important; /* Убиваем top: 50% и left: 50% */
    transform: none !important;  /* Убиваем translate(-50%, -50%) */
    margin: 0 !important;
}

/* ================= ФИКС: ЖЕСТКАЯ ЗАМОРОЗКА ПОЗИЦИИ КОЛОНКИ ДЛЯ ВСЕХ ФОРМАТОВ ================= */

html body #builder-page .capsules-column,
html body.ratio-1-1 #builder-page .capsules-column,
html body.ratio-16-9 #builder-page .capsules-column,
html body.ratio-9-16 #builder-page .capsules-column,
html body.is-dragging-item #builder-page .capsules-column {
    position: absolute !important;
    top: 18px !important; /* Единый и неизменный отступ сверху */
    margin-top: 0 !important; /* Безжалостно убиваем все старые margin-top */
    transform: none !important;
}

/* ================= ФИКС: АНИМАЦИЯ ИКОНКИ СОХРАНЕНИЯ (ВРАЩЕНИЕ ВПРАВО) ================= */

/* 1. Задаем иконке дискеты такую же плавность, как у шестеренки */
html body #builder-page #save-wrapper .ea-main-btn svg {
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), color 0.3s ease !important;
}

/* 2. При раскрытии капсулы крутим дискету ровно на 90 градусов по часовой стрелке */
html body:not(.is-dragging-item) #builder-page #save-wrapper.ea-hovered .ea-main-btn svg {
    transform: rotate(90deg) !important; 
}

/* ================= ФИКС СКАЧКА ПЛЮСИКА (СИНХРОНИЗАЦИЯ .ea-top-row) ================= */

/* 1. Фиксируем внешнюю обертку одинаково в покое и при перетаскивании */
html body main#builder-page #pool-container #ea-wrapper,
html body.is-dragging-item main#builder-page #pool-container #ea-wrapper {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
}

/* 2. Фиксируем капсулу .ea-inner без смены рамок */
html body main#builder-page #pool-container #ea-wrapper .ea-inner,
html body.is-dragging-item main#builder-page #pool-container #ea-wrapper .ea-inner {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    border-radius: 100px !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.03) !important;
    box-sizing: border-box !important;
}

html body.light-theme main#builder-page #pool-container #ea-wrapper .ea-inner,
html body.light-theme.is-dragging-item main#builder-page #pool-container #ea-wrapper .ea-inner {
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    background: rgba(0, 0, 0, 0.02) !important;
}

/* 3. ГЛАВНОЕ ИСПРАВЛЕНИЕ: запрещаем .ea-top-row менять высоту с 100% (42px) на 44px при драге */
html body main#builder-page #pool-container #ea-wrapper .ea-top-row,
html body.is-dragging-item main#builder-page #pool-container #ea-wrapper .ea-top-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    width: 220px !important;
    min-width: 220px !important;
    max-width: 220px !important;
    height: 100% !important;
    min-height: 100% !important;
    max-height: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 4. Делаем .ea-main-btn идентичной кнопкам сохранения и настроек */
html body main#builder-page #pool-container #ea-wrapper .ea-main-btn,
html body.is-dragging-item main#builder-page #pool-container #ea-wrapper .ea-main-btn {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

/* 5. Центрируем сам SVG-плюсик через Flexbox без переключения position */
html body main#builder-page #pool-container #ea-wrapper #icon-plus,
html body.is-dragging-item main#builder-page #pool-container #ea-wrapper #icon-plus {
    position: static !important;
    width: 22px !important;
    height: 22px !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: rotate(0deg) scale(1) !important;
}

/* 6. Сохраняем раскрытие капсулы и поворот плюсика при наведении */
html body:not(.is-dragging-item) main#builder-page #pool-container #ea-wrapper.ea-hovered .ea-inner {
    width: 220px !important;
    max-width: 220px !important;
    background: rgba(255, 255, 255, 0.07) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}

html body.light-theme:not(.is-dragging-item) main#builder-page #pool-container #ea-wrapper.ea-hovered .ea-inner {
    background: rgba(255, 255, 255, 0.9) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

html body:not(.is-dragging-item) main#builder-page #pool-container #ea-wrapper.ea-hovered #icon-plus {
    transform: rotate(90deg) scale(1.1) !important;
}

/* ================= ПРЕМИАЛЬНАЯ КНОПКА "СОЗДАТЬ" В ШАПКЕ ================= */

.header-create-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 16px;
    background: #ffffff; /* Максимальный контраст */
    color: #000000;
    font-size: 13px;
    font-weight: 700;
    border: none;
    border-radius: 100px; /* Идеальная капсула */
    margin-right: 10px; /* Отступ от блока авторизации */
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1) !important; /* Перебиваем старые глобальные транзишены */
    flex-shrink: 0;
    opacity: 1 !important; /* Защита от глобального прозрачного клика */
}

/* Плавный поворот плюса */
.header-create-btn svg {
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Мягкий ховер (парение) */
.header-create-btn:hover {
    transform: translateY(-2px) !important;
    background: #f5f5f5;
    box-shadow: 0 6px 15px rgba(255, 255, 255, 0.15);
}
.header-create-btn:hover svg {
    transform: rotate(90deg);
}

/* Оптический отклик при клике (микро-сжатие) */
.header-create-btn:active {
    transform: scale(0.97) translateY(0) !important;
    box-shadow: 0 2px 5px rgba(255, 255, 255, 0.1) !important;
}

/* Инверсия для светлой темы */
html body.light-theme .header-create-btn {
    background: #0f172a;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
html body.light-theme .header-create-btn:hover {
    background: #000000;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}
html body.light-theme .header-create-btn:active {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
}

/* Скрываем текст на телефонах, оставляя только плюсик в кружке */
@media (max-width: 768px) {
    .header-create-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        margin-right: 5px;
    }
    .header-create-btn span {
        display: none;
    }
}

/* ================= ФИКС БОКОВОЙ ПАНЕЛИ И ТЕГОВ ================= */

/* 1. Убиваем горизонтальный скролл на корню */
html body .filters-sidebar {
    overflow-x: hidden !important;
}

html body .sidebar-scrollable-content {
    overflow-x: hidden !important;
    width: 100% !important;
    padding-right: 12px !important;
    margin-right: -12px !important;
}

/* 2. Разрешаем секциям быть гибкими (убиваем старые жесткие 226px) */
html body .sidebar-section {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

/* 3. Делаем теги в сайдбаре видимыми кнопками и разрешаем перенос текста */
html body .filters-sidebar .filter-chip {
    background: rgba(255, 255, 255, 0.04) !important; /* Легкий фон */
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    padding: 6px 12px !important;
    font-size: 13px !important;
    white-space: normal !important; /* Разрешаем перенос длинных слов */
    line-height: 1.3 !important;
    max-width: 100% !important; /* Защита от распирания панели */
    text-align: left !important;
    height: auto !important;
}

/* Оформление тегов для светлой темы */
html body.light-theme .filters-sidebar .filter-chip {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.06) !important;
}

/* Ховер эффекты (подсветка при наведении) */
html body .filters-sidebar .filter-chip:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
}
html body.light-theme .filters-sidebar .filter-chip:hover {
    background: rgba(0, 0, 0, 0.06) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

/* Активный выбранный тег */
html body .filters-sidebar .filter-chip.active {
    background: var(--text-color) !important;
    color: var(--bg-color) !important;
    border-color: transparent !important;
}

/* ================= ФИКС: УБИВАЕМ "ДЕРГАНЬЕ" ТЕГОВ ПРИ ОТКРЫТИИ ПАНЕЛИ ================= */

/* Замораживаем ширину контейнера со скроллом, чтобы контент внутри не сжимался */
html body .sidebar-scrollable-content {
    width: 226px !important;
    min-width: 226px !important;
    max-width: 226px !important;
    flex-shrink: 0 !important;
}

/* Также жестко фиксируем секции, чтобы они не пытались перестраиваться на лету */
html body .sidebar-section {
    width: 226px !important;
    min-width: 226px !important;
    max-width: 226px !important;
    flex-shrink: 0 !important;
}

/* Гарантируем, что сама панель не будет обрезать текст по словам при сужении */
html body .filters-sidebar {
    white-space: nowrap !important;
}