/* =========================================
   YAZME | GOOGLE HABITAT 2026 (UI/UX)
   МЕССЕНДЖЕР: DASHBOARD LAYOUT (ПК) + ПАРЯЩАЯ КАПСУЛА + МОБИЛЬНАЯ АДАПТАЦИЯ
   ВЕРСИЯ: 8.3 | ФИКС ПРОЗРАЧНОСТИ + CORE MEMORY (ЯДРО ПАМЯТИ 🧠) 
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* Глобальные переменные ДНК */
:root {
    --critter-main: #6b48ff;
    --critter-accent: #00e5ff;
    --critter-glow: rgba(107, 72, 255, 0.4);
    --memory-color: #b388ff;
}

/* 1. Глобальный сброс для точных размеров */
*, *::before, *::after {
    box-sizing: border-box;
}

/* 2. ЖЕЛЕЗОБЕТОННАЯ ФИКСАЦИЯ */
html, body.google-habitat {
    margin: 0;
    padding: 0;
    background-color: #050505;
    font-family: 'Inter', sans-serif;
    color: #e3e3e8;
    
    position: fixed; 
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    overflow: hidden; 
}

/* Кнопка "Назад" - минимализм */
.gh-back-btn {
    position: fixed;
    top: 20px; left: 20px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff; font-size: 18px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 9999;
    backdrop-filter: blur(10px);
    transition: background 0.2s, transform 0.2s;
}
.gh-back-btn:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.15); }

/* =========================================
   ГЛАВНАЯ СЕТКА (DASHBOARD LAYOUT)
   ========================================= */
.gh-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex; 
    justify-content: center; 
    align-items: center;
    overflow: hidden;
}

/* Новый контейнер для десктопа */
.gh-desktop-layout {
    display: flex;
    width: 100%; 
    max-width: 1600px;
    height: 100%; 
    background: #0f0f13; 
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    position: relative;
    overflow: hidden;
}

/* =========================================
   БОКОВАЯ ПАНЕЛЬ (САЙДБАР)
   ========================================= */
.gh-sidebar {
    width: 320px;
    flex-shrink: 0;
    background: #141419;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    z-index: 20;
}

.gh-header {
    padding: 30px 20px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
}
.gh-header::-webkit-scrollbar { display: none; }

/* =========================================
   ОСНОВНАЯ ДОСКА (ЧАТ)
   ========================================= */
.gh-main-area {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #0f0f13;
    overflow: hidden;
}

.gh-chat-zone {
    flex: 1 1 0; 
    display: flex; flex-direction: column;
    min-height: 0; 
    overflow: hidden; 
    position: relative;
}

.gh-chat-history {
    position: relative; 
    z-index: 1; 
    flex: 1;
    overflow-y: auto;
    padding: 40px 60px 250px; 
    display: flex; flex-direction: column; gap: 20px;
    
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
    
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 10%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 10%);
}

.gh-chat-history::-webkit-scrollbar { width: 6px; }
.gh-chat-history::-webkit-scrollbar-track { background: transparent; }
.gh-chat-history::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 6px; }
.gh-chat-history::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

/* =========================================
   НОВЫЙ КРИТТЕР И АНИМАЦИЯ УХОДА
   ========================================= */
.gh-intro-critter {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: auto;      
    margin-bottom: auto;   
    padding: 20px 0;
    animation: ghIntroFloat 4s ease-in-out infinite;
    z-index: 2;
}

.gh-intro-critter svg, .gh-intro-critter img {
    width: 140px;
    height: 140px;
    filter: drop-shadow(0 10px 25px var(--critter-glow)); 
}

@keyframes ghIntroFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes ghWalkAway {
    0% { transform: scale(1) translateY(0) rotate(0deg); opacity: 1; }
    20% { transform: scale(0.9) translateY(-10px) rotate(-15deg); opacity: 1; }
    40% { transform: scale(0.8) translateY(0) rotate(15deg); opacity: 0.8; }
    60% { transform: scale(0.6) translateY(-10px) rotate(-15deg); opacity: 0.5; }
    80% { transform: scale(0.4) translateY(0) rotate(15deg); opacity: 0.2; }
    100% { transform: scale(0) translateY(-30px) rotate(0deg); opacity: 0; }
}

.gh-intro-critter.walking-away {
    animation: ghWalkAway 1.5s ease-in-out forwards !important;
}

/* =========================================
   СТИЛИ СООБЩЕНИЙ И АВАТАРОК
   ========================================= */
.ch-msg { 
    display: flex; 
    width: 100%; 
    flex-wrap: wrap; /* Позволяет панели действий падать под баббл */
}

.ch-msg.critter { 
    justify-content: flex-start; 
    align-items: flex-start; 
    margin-top: 25px; 
}

.ch-msg.user { 
    justify-content: flex-start; 
    align-items: flex-end; 
    flex-direction: row-reverse; 
    margin-top: 15px; 
}

.ch-msg.critter .ch-avatar-container {
    position: relative;
    float: left;
    margin: 0 15px 5px 0;
}

.ch-msg.user .ch-avatar-container {
    position: relative;
    margin: 0 10px;
    flex-shrink: 0;
    float: none;
}

.ch-msg-avatar-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: #0f0f13;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255,255,255,0.05);
}

.ch-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ch-msg-avatar-wrapper.static-svg svg {
    width: 100%;
    height: 100%;
    filter: none;
}

.ch-msg-avatar-wrapper.static-svg svg * {
    animation: none !important;
    transition: none !important;
}

.ch-persona-badge {
    position: absolute;
    top: -28px; 
    left: 50%;
    transform: translateX(-50%); 
    width: 24px; 
    height: 24px; 
    background: #1a1a22;
    border: 1.5px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px; 
    z-index: 5;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
    animation: badgePop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgePop {
    0% { transform: translateX(-50%) scale(0); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.glass-bubble, .gh-bubble {
    padding: 16px 20px; 
    font-size: 15px; 
    line-height: 1.5; 
    word-break: break-word;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.ch-msg.critter .glass-bubble, .ch-msg.critter .gh-bubble {
    max-width: 85%;
    display: flow-root; 
    border-bottom-left-radius: 4px; 
    background: var(--critter-main, #6b48ff); 
    color: #fff;
}

.ch-msg.user .glass-bubble, .ch-msg.user .gh-bubble {
    max-width: 70%;
    display: block;
    border-bottom-right-radius: 4px; 
    background: #2a2a35; 
    color: #fff;
}

/* =========================================
   ЯДРО ПАМЯТИ (CORE MEMORY) - СТИЛИ
   ========================================= */
.ch-msg.user .ch-action-bar {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-right: 56px; 
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateY(5px);
}

.ch-msg.user:hover .ch-action-bar {
    opacity: 1;
    transform: translateY(0);
}

/* Кнопка мозга (Memory Core) */
.ch-action-bar-btn.brain-btn {
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.ch-action-bar-btn.brain-active {
    color: var(--memory-color) !important;
    filter: drop-shadow(0 0 8px rgba(179, 136, 255, 0.8));
    transform: scale(1.15);
}

/* Всплывающее окно (Toast) при сохранении */
.ch-toast-notification {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(30, 30, 40, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(179, 136, 255, 0.4);
    color: #fff;
    padding: 14px 24px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6), 0 0 25px rgba(179, 136, 255, 0.2);
    z-index: 2147483660;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ch-toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.ch-toast-icon {
    font-size: 20px;
    color: var(--memory-color);
    animation: brainPulse 1.5s infinite;
}

@keyframes brainPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px var(--memory-color)); }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 15px var(--memory-color)); }
}

/* Модальное окно управления памятью (Лимит превышен) */
#ch-memory-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100dvh;
    background: rgba(0,0,0,0.7);
    z-index: 2147483650;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ch-memory-modal-card {
    background: rgba(20, 20, 25, 0.95);
    border: 1px solid rgba(179, 136, 255, 0.3);
    width: 90%;
    max-width: 480px;
    border-radius: 28px;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7), inset 0 0 40px rgba(179, 136, 255, 0.05);
    transform: scale(0.95) translateY(20px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.ch-memory-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
    overflow-y: auto;
    max-height: 45vh;
    padding-right: 5px;
    scrollbar-width: thin;
    scrollbar-color: rgba(179, 136, 255, 0.3) transparent;
}
.ch-memory-list::-webkit-scrollbar { width: 6px; }
.ch-memory-list::-webkit-scrollbar-thumb { background: rgba(179, 136, 255, 0.3); border-radius: 6px; }

.ch-memory-item {
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s ease;
}

.ch-memory-item:hover {
    border-color: rgba(179, 136, 255, 0.5);
    background: rgba(179, 136, 255, 0.08);
    transform: translateX(4px);
}

.ch-memory-item-role {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--memory-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ch-memory-item-text {
    color: #e3e3e8;
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    font-style: italic;
}

.ch-memory-remove-btn {
    background: rgba(255, 82, 82, 0.1);
    color: #FF5252;
    border: 1px solid rgba(255, 82, 82, 0.2);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    align-self: flex-end;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ch-memory-remove-btn:hover { 
    background: #FF5252; color: #fff; transform: scale(1.05); box-shadow: 0 4px 15px rgba(255, 82, 82, 0.4);
}
.ch-memory-remove-btn:active { transform: scale(0.95); }

/* Анимации набора и раздумий */
.ch-typing { display: flex; gap: 4px; padding: 4px; margin-top: 8px; }
.ch-typing span {
    width: 6px; height: 6px; background: rgba(255,255,255,0.7);
    border-radius: 50%; animation: ghBounce 1.4s infinite both;
}
.ch-typing span:nth-child(1) { animation-delay: -0.32s; }
.ch-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ghBounce { 0%, 80%, 100% { transform: scale(0); opacity: 0.3; } 40% { transform: scale(1); opacity: 1; } }

.ch-thinking-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 6px;
    font-weight: 500;
    font-style: italic;
    transition: opacity 0.4s ease;
    min-height: 16px;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

/* =========================================
   3. ПОДВАЛ (Поле ввода - ПАРЯЩАЯ КАПСУЛА)
   ========================================= */
.gh-input-zone {
    position: absolute; 
    bottom: 0; left: 0; right: 0;
    z-index: 50; 
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(15,15,19,0) 0%, rgba(15,15,19,0.8) 40%, #0f0f13 90%);
    padding: 40px 60px calc(100px + env(safe-area-inset-bottom, 0px)); 
    border-top: none;
    transition: padding 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
}

/* Файловое превью */
.ch-file-preview-container {
    max-width: 900px;
    margin: 0 auto 12px auto;
    padding: 0 15px;
    animation: fadeIn 0.3s ease;
    pointer-events: auto;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.ch-file-preview-card {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: rgba(40, 40, 50, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 8px 12px 8px 8px;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.4);
}
.ch-file-preview-icon {
    width: 38px; height: 38px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: var(--critter-accent, #00e5ff);
    font-size: 18px;
}
.ch-file-preview-info {
    display: flex; flex-direction: column;
    max-width: 160px;
}
.ch-file-name {
    font-size: 13px; font-weight: 600; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ch-file-size {
    font-size: 11px; color: #8e8e99;
    margin-top: 2px;
}
.ch-file-remove-btn {
    background: rgba(255, 82, 82, 0.15); color: #FF5252;
    border: 1px solid rgba(255, 82, 82, 0.3);
    border-radius: 50%;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
    margin-left: 8px;
}
.ch-file-remove-btn:hover { background: #FF5252; color: #fff; transform: scale(1.1); }
.ch-file-remove-btn:active { transform: scale(0.9); }

.gh-input-wrapper {
    display: flex; gap: 12px; align-items: flex-end; 
    pointer-events: auto;
    
    max-width: 900px;
    margin: 0 auto;

    background: #1e1e28;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 30px;
    padding: 8px 8px 8px 8px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
}

/* === КНОПКИ ВВОДА (МИКРОФОН, СТОП, ОТПРАВИТЬ) === */
#ch-attach-btn {
    width: 44px; height: 44px; border-radius: 50%; 
    background: rgba(255, 255, 255, 0.05); color: #8e8e99; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; font-size: 18px;
    transition: all 0.2s ease;
    margin-bottom: 0;
}
#ch-attach-btn:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
#ch-attach-btn:active { transform: scale(0.9); }

#ch-mic-btn {
    width: 44px; height: 44px; border-radius: 50%; 
    background: linear-gradient(135deg, rgba(107, 72, 255, 0.15), rgba(255, 43, 84, 0.15)); 
    border: 1px solid rgba(255, 43, 84, 0.3); 
    box-shadow: inset 0 0 10px rgba(107, 72, 255, 0.1), 0 0 10px rgba(255, 43, 84, 0.2);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; font-size: 18px;
    transition: all 0.3s ease;
    margin-bottom: 0;
    outline: none;
    position: relative; overflow: hidden;
}
#ch-mic-btn i { 
    background: linear-gradient(135deg, #a78bfa, #ff7eb3); -webkit-background-clip: text; -webkit-text-fill-color: transparent; 
    position: relative; z-index: 2; transition: all 0.3s ease; 
}
#ch-mic-btn::before { 
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; 
    background: linear-gradient(135deg, #6b48ff, #ff2b54); opacity: 0; transition: opacity 0.3s ease; z-index: 1; 
}
#ch-mic-btn:hover { 
    border-color: transparent; box-shadow: 0 6px 20px rgba(255, 43, 84, 0.5); transform: translateY(-2px) scale(1.05); 
}
#ch-mic-btn:hover::before { opacity: 1; }
#ch-mic-btn:hover i { background: none; -webkit-text-fill-color: #fff; color: #fff; }
#ch-mic-btn:active { transform: scale(0.9); }

#ch-stop-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 43, 84, 0.2), rgba(255, 82, 82, 0.1)); 
    border: 1px solid rgba(255, 43, 84, 0.4); 
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; font-size: 16px;
    transition: all 0.3s ease;
    margin-bottom: 0;
    animation: chPulseStop 1.5s infinite;
    outline: none;
    position: relative; overflow: hidden;
}
#ch-stop-btn i { 
    color: #ff2b54; position: relative; z-index: 2; transition: all 0.3s ease; 
}
#ch-stop-btn::before { 
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; 
    background: linear-gradient(135deg, #ff2b54, #ff5252); opacity: 0; transition: opacity 0.3s ease; z-index: 1; 
}
#ch-stop-btn:hover { 
    border-color: transparent; transform: translateY(-2px) scale(1.05); box-shadow: 0 6px 20px rgba(255, 43, 84, 0.6); animation: none; 
}
#ch-stop-btn:hover::before { opacity: 1; }
#ch-stop-btn:hover i { color: #fff; }
#ch-stop-btn:active { transform: scale(0.9); }

#ch-send-btn {
    width: 44px; height: 44px; border-radius: 50%; 
    background: linear-gradient(135deg, #6b48ff, #ff2b54); color: #fff; border: none;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0; font-size: 16px;
    box-shadow: 0 4px 15px rgba(107, 72, 255, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 0;
}
#ch-send-btn:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 6px 20px rgba(255, 43, 84, 0.5); }
#ch-send-btn:active { transform: scale(0.9); box-shadow: 0 4px 10px rgba(107, 72, 255, 0.4); }

/* === ВОЛНА ЗАПИСИ (ЭКВАЛАЙЗЕР) === */
@keyframes chWaveAnim { 0%, 100% { transform: scaleY(0.4); } 50% { transform: scaleY(1); } }
@keyframes chPulseOpacity { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

.ch-recording-wave { display: flex; flex: 1; align-items: center; padding: 0 10px; gap: 12px; }
.ch-wave-bars { display: flex; align-items: center; gap: 4px; height: 24px; }
.ch-bar { width: 4px; background: linear-gradient(to top, #6b48ff, #ff2b54); border-radius: 2px; animation: chWaveAnim 1s ease-in-out infinite; box-shadow: 0 0 6px rgba(255, 43, 84, 0.5); }
.ch-bar:nth-child(1) { height: 40%; animation-delay: 0.0s; }
.ch-bar:nth-child(2) { height: 80%; animation-delay: 0.1s; }
.ch-bar:nth-child(3) { height: 100%; animation-delay: 0.2s; }
.ch-bar:nth-child(4) { height: 80%; animation-delay: 0.3s; }
.ch-bar:nth-child(5) { height: 40%; animation-delay: 0.4s; }

.ch-record-timer { background: linear-gradient(135deg, #a78bfa, #ff7eb3); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-size: 15px; font-weight: 800; font-family: 'Inter', sans-serif; font-variant-numeric: tabular-nums; }
.ch-record-status { color: #8e8e9e; font-size: 13px; font-weight: 500; animation: chPulseOpacity 1.5s infinite; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

#ch-message-input {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 0; 
    padding: 10px 0; 
    color: #fff; font-size: 15px; outline: none; font-family: 'Inter', sans-serif;
    resize: none; 
    min-height: 40px;
    max-height: 200px; 
    line-height: 1.4;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

#ch-message-input::-webkit-scrollbar { width: 4px; }
#ch-message-input::-webkit-scrollbar-track { background: transparent; margin: 10px 0; }
#ch-message-input::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }
#ch-message-input::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

#ch-message-input:focus { background: transparent; border-color: transparent; }
#ch-message-input::placeholder { color: #8e8e99; }

/* =========================================
   4. СТИЛИ ДЛЯ БЛОКОВ КОДА
   ========================================= */
.ch-msg .glass-bubble pre, 
.ch-msg .gh-bubble pre {
    background: #0f0f13 !important;
    border-radius: 10px;
    padding: 14px;
    margin: 12px 0;
    overflow-x: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.5);
    text-align: left;
    clear: both;
}

.ch-msg .glass-bubble pre::-webkit-scrollbar,
.ch-msg .gh-bubble pre::-webkit-scrollbar { height: 6px; }
.ch-msg .glass-bubble pre::-webkit-scrollbar-thumb,
.ch-msg .gh-bubble pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.ch-msg .glass-bubble code, 
.ch-msg .gh-bubble code {
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 6px;
    border-radius: 6px;
}

.ch-msg .glass-bubble pre code, 
.ch-msg .gh-bubble pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    white-space: pre;
    color: #e3e3e8;
}

.ch-msg.critter .gh-bubble pre code * { text-shadow: none !important; }

/* =========================================
   МОБИЛЬНАЯ АДАПТАЦИЯ (До 800px)
   ========================================= */
@media (max-width: 800px) {
    .gh-desktop-layout {
        flex-direction: column;
    }
    
    .gh-sidebar {
        width: 100%;
        flex-shrink: 0;
        border: none;
        background: transparent;
        z-index: 100;
        position: absolute;
        top: 0; left: 0;
        pointer-events: none;
    }

    .gh-header {
        padding: 0;
        overflow: visible;
        pointer-events: none;
    }

    .gh-stats-toggle-btn {
        display: flex !important;
        pointer-events: auto;
    }
    
    .gh-stats-panel {
        max-height: 0 !important;
        opacity: 0 !important;
        overflow: hidden !important;
        transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease !important;
    }
    .gh-stats-panel.active {
        max-height: 500px !important;
        opacity: 1 !important;
        margin-top: 10px !important;
        pointer-events: auto;
    }

    .gh-chat-history {
        padding: 80px 15px calc(220px + env(safe-area-inset-bottom, 0px)); 
        gap: 16px;
        -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%);
        mask-image: linear-gradient(to bottom, transparent 0%, black 15%);
        transition: padding 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
    }

    .gh-input-zone {
        padding: 20px 15px calc(100px + env(safe-area-inset-bottom, 0px));
        background: linear-gradient(to bottom, rgba(15,15,19,0) 0%, rgba(15,15,19,0.9) 35%, #0f0f13 80%);
    }

    body.dock-is-hidden .gh-chat-history {
        padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px)); 
    }

    body.dock-is-hidden .gh-input-zone {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); 
    }

    .gh-input-wrapper {
        max-width: 100%;
        padding: 6px;
        border-radius: 24px;
    }
    
    #ch-send-btn, #ch-attach-btn, #ch-mic-btn, #ch-stop-btn {
        width: 40px; height: 40px;
    }
    
    .ch-msg.critter .glass-bubble, .ch-msg.critter .gh-bubble { max-width: 93%; }
    .ch-msg.user .glass-bubble, .ch-msg.user .gh-bubble { max-width: 85%; }
    
    .ch-msg.user .ch-action-bar { padding-right: 48px; }
}

/* ========================================= */
/* ГЛОБАЛЬНЫЙ ИИ ОВЕРЛЕЙ БЁРЧИ               */
/* ========================================= */
.ai-overlay-modal {
    position: fixed;
    top: 100%;
    left: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 2147483640 !important;
    background: rgba(8, 9, 13, 0.45) !important;
    backdrop-filter: blur(40px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(40px) saturate(200%) !important;
    transition: top 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top-left-radius: 28px;
    border-top-right-radius: 28px;
    box-shadow: 0 -10px 40px rgba(107, 72, 255, 0.2), 
                inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.ai-overlay-modal.active { top: 0; }

.ai-overlay-close-btn {
    position: absolute;
    top: calc(env(safe-area-inset-top, 10px) + 15px);
    left: 15px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    z-index: 10000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.ai-overlay-close-btn:hover { background: rgba(255, 255, 255, 0.2); transform: scale(1.05); }
.ai-overlay-close-btn:active { transform: scale(0.9); background: rgba(255, 255, 255, 0.3); }

/* ХИРУРГИЧЕСКАЯ ОТМЕНА ФОНОВ */
.ai-overlay-modal .google-habitat,
.ai-overlay-modal .gh-wrapper,
.ai-overlay-modal .gh-desktop-layout,
.ai-overlay-modal .gh-main-area,
.ai-overlay-modal .gh-chat-zone,
.ai-overlay-modal .gh-input-zone,
.ai-overlay-modal .gh-chat-history {
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

.ai-overlay-modal .gh-input-wrapper {
    background: #1e1e28 !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
}

/* ========================================= */
/* ВОССТАНОВЛЕННЫЕ ГЛОБАЛЬНЫЕ СТИЛИ ЧАТА ИИ  */
/* ========================================= */
.gh-stats-wrapper { position: relative !important; width: 100% !important; z-index: 100 !important; }
.gh-top-actions { display: flex !important; gap: 10px !important; width: 100% !important; }
.gh-stats-toggle-btn { background: #141419 !important; border: 1px solid rgba(255, 255, 255, 0.1) !important; color: #fff !important; padding: 10px 10px !important; border-radius: 20px !important; font-family: 'Inter', sans-serif !important; font-size: 13px !important; font-weight: 600 !important; display: flex !important; align-items: center !important; justify-content: center !important; gap: 8px !important; flex: 1 !important; cursor: pointer !important; transition: background 0.2s, transform 0.2s !important; }
.gh-stats-toggle-btn:active { transform: scale(0.98) !important; background: rgba(40, 40, 50, 0.8) !important; }
.gh-stats-panel { max-height: 0 !important; opacity: 0 !important; overflow: hidden !important; transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease !important; }
.gh-stats-panel.active { max-height: 500px !important; opacity: 1 !important; margin-top: 10px !important; }
.gh-stats { display: flex !important; flex-direction: column !important; gap: 12px !important; background: #141419 !important; padding: 16px !important; border-radius: 16px !important; border: 1px solid rgba(255, 255, 255, 0.05) !important; width: 100% !important; box-sizing: border-box !important; }

.gh-stats::-webkit-scrollbar { width: 4px; }
.gh-stats::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }
.gh-stat-wrapper { display: flex !important; flex-direction: column !important; gap: 8px !important; width: 100% !important; background: rgba(0,0,0,0.2) !important; padding: 10px !important; border-radius: 12px !important; transition: all 0.2s ease !important; box-sizing: border-box !important; }
.gh-stat-label-container { display: flex !important; justify-content: space-between !important; align-items: center !important; width: 100% !important; margin-bottom: 4px !important; }
.gh-stat-label { font-size: 12px !important; font-weight: 800 !important; color: #E8EAED !important; text-transform: uppercase !important; letter-spacing: 1px !important; cursor: help !important; }
.stat-val-text { font-size: 14px !important; font-weight: 900 !important; width: 40px !important; text-align: right !important; }

.trait-slider { -webkit-appearance: none; width: 100%; height: 14px; background: #111; border-radius: 10px; outline: none; box-shadow: inset 0 2px 4px rgba(0,0,0,0.8); cursor: pointer; overflow: hidden; }
.trait-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #fff; cursor: ew-resize; box-shadow: 0 0 5px rgba(0,0,0,0.5); box-shadow: -400px 0 0 392px var(--slider-color); }
.trait-slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #fff; cursor: ew-resize; border: none; }
.trait-slider::-moz-range-progress { height: 14px; border-radius: 10px; background: var(--slider-color); }
#slider-vibe { --slider-color: #FF5252; }
#slider-delivery { --slider-color: #40C4FF; }
#slider-creative { --slider-color: #b388ff; }

.gh-switch { position: relative; display: inline-block; width: 42px; height: 22px; margin: 0; }
.gh-switch input { opacity: 0; width: 0; height: 0; }
.gh-slider-toggle { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 22px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.8); }
.gh-slider-toggle:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
input:checked + .gh-slider-toggle { background-color: #F48FB1; }
input:checked + .gh-slider-toggle:before { transform: translateX(20px); }

.ch-msg-badges { display: flex !important; gap: 6px !important; margin-top: 10px !important; flex-wrap: wrap !important; }
.trait-badge { display: inline-flex !important; align-items: center !important; gap: 6px !important; padding: 4px 10px !important; border-radius: 12px !important; font-size: 11px !important; font-weight: 700 !important; background: rgba(0, 0, 0, 0.3) !important; border: 1px solid rgba(255, 255, 255, 0.1) !important; cursor: pointer !important; transition: all 0.2s ease !important; backdrop-filter: blur(5px) !important; }
.trait-badge:hover { transform: translateY(-2px) !important; background: rgba(255, 255, 255, 0.1) !important; }
.trait-badge.vibe { color: #FF5252 !important; border-color: rgba(255, 82, 82, 0.3) !important; }
.trait-badge.delivery { color: #40C4FF !important; border-color: rgba(64, 196, 255, 0.3) !important; }
.trait-badge.creative { color: #b388ff !important; border-color: rgba(179, 136, 255, 0.3) !important; }
.trait-badge .delta.pos { color: #00E676 !important; }
.trait-badge .delta.neg { color: #FF5252 !important; }
.trait-badge .delta.zero { color: #aaa !important; font-weight: normal !important; }

.ch-msg.bot .ch-msg-avatar-wrapper { background: linear-gradient(145deg, #2A2D3A, #1A1C24) !important; border: 2px solid var(--bot-color, #fff) !important; box-shadow: 0 0 12px var(--bot-color-glow, rgba(255,255,255,0.2)) !important; display: flex; align-items: center; justify-content: center; }
.ch-msg.bot .ch-avatar { font-size: 24px !important; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.bot-name-label { font-size: 11px !important; font-weight: 800 !important; text-transform: uppercase !important; color: var(--bot-color, #a8c7fa) !important; margin-bottom: 6px !important; display: inline-block !important; letter-spacing: 0.5px !important; border-bottom: 1px dashed var(--bot-color, #a8c7fa) !important; padding-bottom: 2px !important; }

.gh-bubble a[href^="messenger.php?u="] { display: inline-flex !important; align-items: center !important; gap: 4px !important; padding: 2px 8px !important; border-radius: 12px !important; font-size: 12px !important; font-weight: 700 !important; color: #fff !important; background: linear-gradient(145deg, rgba(107, 72, 255, 0.4), rgba(0, 229, 255, 0.4)) !important; border: 1px solid rgba(255, 255, 255, 0.2) !important; text-decoration: none !important; transition: all 0.2s ease !important; box-shadow: 0 2px 5px rgba(0,0,0,0.3) !important; margin: 0 2px; }
.gh-bubble a[href^="messenger.php?u="]:hover { transform: translateY(-1px) !important; background: linear-gradient(145deg, rgba(107, 72, 255, 0.6), rgba(0, 229, 255, 0.6)) !important; box-shadow: 0 4px 10px rgba(0,229,255,0.4) !important; border-color: rgba(255, 255, 255, 0.5) !important; }
.gh-bubble a[href^="messenger.php?u="]::before { content: '\f544'; font-family: 'Font Awesome 6 Free'; font-weight: 900; font-size: 10px; }

.history-item { background: rgba(0,0,0,0.2) !important; padding: 12px !important; border-radius: 12px !important; display: flex !important; flex-direction: column !important; gap: 6px !important; cursor: pointer !important; transition: background 0.2s ease !important; border: 1px solid transparent !important; }
.history-item:hover { background: rgba(255,255,255,0.05) !important; }
.history-item.active-session { background: rgba(255,255,255,0.08) !important; border-color: rgba(255,255,255,0.2) !important; }
.history-item-date { font-size: 10px !important; color: #888 !important; font-weight: 600 !important; text-transform: uppercase !important; }
.history-item-text { font-size: 13px !important; color: #E8EAED !important; line-height: 1.4 !important; font-weight: 600 !important; }

.ch-art-container { margin-top: 12px; position: relative; max-width: 280px; border-radius: 16px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.ch-art-img { width: 100%; display: block; border-radius: 16px; transition: transform 0.3s ease; cursor: zoom-in; }
.ch-art-overlay { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%); padding: 15px 10px 10px 10px; display: flex; gap: 8px; justify-content: flex-end; opacity: 0; transition: opacity 0.2s ease; }
.ch-art-container:hover .ch-art-overlay { opacity: 1; }
.ch-art-btn { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.2); color: #fff; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(10px); transition: all 0.2s ease; font-size: 14px; }
.ch-art-btn:hover { background: rgba(255,255,255,0.3); transform: translateY(-2px); color: #d4af37; }
.ch-art-loading { display: flex; align-items: center; gap: 10px; padding: 10px 15px; background: rgba(212, 175, 55, 0.1); border: 1px dashed rgba(212, 175, 55, 0.4); border-radius: 12px; color: #d4af37; font-size: 13px; font-weight: 600; margin-top: 10px; width: fit-content; }

#ch-lightbox-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0, 0, 0, 0.95); z-index: 2147483645 !important; justify-content: center; align-items: center; backdrop-filter: blur(10px); }
#ch-lightbox-img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.8); transition: transform 0.2s ease; }
.ch-lightbox-close { position: absolute; top: 20px; right: 20px; background: rgba(255,255,255,0.3); border: 1px solid rgba(255,255,255,0.5); color: #fff; width: 44px; height: 44px; border-radius: 50%; font-size: 20px; display: flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(5px); z-index: 2147483646 !important; transition: all 0.2s ease; }
.ch-lightbox-close:hover { background: rgba(255,255,255,0.5); transform: scale(1.1); color: #FF5252; }

.ch-avatar-container { position: relative; display: flex; justify-content: center; }
.ch-persona-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: #1E222D; border: 2px solid #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 13px; z-index: 100; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.5); pointer-events: auto; }

/* === ОПТИМИЗАЦИЯ ПОД МОБИЛЬНЫЕ УСТРОЙСТВА === */
@media (max-width: 800px) {
    .ai-overlay-modal {
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
    }
    
    .ai-overlay-modal .gh-wrapper,
    .ai-overlay-modal .gh-desktop-layout,
    .ai-overlay-modal .gh-main-area {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }
    .ai-overlay-modal .gh-input-zone {
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 15px) !important;
        margin-bottom: 0 !important;
    }

    .gh-stats-wrapper { position: absolute !important; top: 15px !important; left: 0 !important; right: 0 !important; z-index: 1000 !important; pointer-events: none !important; }
    .gh-top-actions { justify-content: flex-end !important; padding: 0 15px !important; pointer-events: auto !important; width: auto !important; gap: 8px !important; }
    .gh-stats-toggle-btn { flex: none !important; background: #1e1e28 !important; border: 1px solid rgba(255, 255, 255, 0.08) !important; padding: 8px 14px !important; font-size: 12px !important; border-radius: 20px !important; box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important; }
    .gh-stats-panel { position: absolute !important; top: 45px !important; left: 15px !important; right: 15px !important; pointer-events: none !important; z-index: 1001 !important; margin-top: 0 !important; }
    .gh-stats-panel.active { pointer-events: auto !important; margin-top: 0 !important; }
    .gh-stats { background: #141419 !important; box-shadow: 0 15px 40px rgba(0,0,0,0.7) !important; border-radius: 20px !important; border: 1px solid rgba(255, 255, 255, 0.1) !important; }
}