/* =========================================
   ZNAKORA: APPLE GLASS UI (style.css)
   ========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* ЦВЕТА iOS */
    --primary: #3697ff;
    --primary-grad: linear-gradient(135deg, #236fc0, #0054ae);
    --bg-body: #F2F2F7;
    --text-main: #000000;
    --text-sec: #8A8A8E;
    
    /* СТЕКЛО И ФОНЫ */
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-heavy: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --blur: 20px;
    
    /* ЧАТ */
    --msg-in: #E9E9EB;
    --msg-out: #aed5ff;
    --text-msg-out: #ffffff;
    
    /* УТИЛИТЫ */
    --radius: 18px;
    --danger: #FF3B30;
    --success: #34C759;
    --font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
    --bg-body: #000000;
    --text-main: #FFFFFF;
    --text-sec: #98989F;
    --glass-bg: rgba(30, 30, 30, 0.65);
    --glass-heavy: rgba(40, 40, 40, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --msg-in: #2C2C2E;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

/* === СБРОС === */
* { margin: 0; padding: 0; box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh; /* Используем динамическую высоту для мобильных */
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: var(--font);
    background-color: var(--bg-body);
    color: var(--text-main);
}
.chat-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body); /* Гарантируем, что сам чат не прозрачный */
    z-index: 2000;
    display: flex;
    flex-direction: column;
    /* Оптимизация анимации для удаления артефактов */
    transform: translate3d(100%, 0, 0); 
    transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    /* Защита от мигания при анимации */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    perspective: 1000px;
}
/* === УТИЛИТЫ === */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.center { align-items: center; justify-content: center; }
.bold { font-weight: 600; }
.text-sm { font-size: 0.9rem; }
.text-xs { font-size: 0.75rem; }
.text-sec { color: var(--text-sec); }
.pointer { cursor: pointer; }
.w-full { width: 100%; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* === АНИМАЦИИ === */
@keyframes popIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* === ЭКРАН ВХОДА === */
#view-auth {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(10px);
}

.auth-card {
    width: 100%; max-width: 360px; padding: 40px;
    background: var(--glass-heavy);
    backdrop-filter: blur(40px); -webkit-backdrop-filter: blur(40px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    box-shadow: var(--glass-shadow);
    display: flex; flex-direction: column; align-items: center;
    animation: slideUp 0.4s ease-out;
}

.logo-img { height: 60px; width: auto; object-fit: contain; margin-bottom: 20px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1)); }

/* === КНОПКИ И INPUTS === */
.btn {
    border: none; padding: 0 16px; height: 44px; border-radius: 12px;
    font-weight: 600; cursor: pointer; transition: 0.2s;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-size: 0.95rem; user-select: none;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3); }
.btn-primary:active { transform: scale(0.97); }
.btn-ghost { background: transparent; color: var(--text-main); }
.btn-ghost:hover { background: rgba(0,0,0,0.05); }
.btn-danger { background: rgba(255, 59, 48, 0.1); color: var(--danger); }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; flex-shrink: 0; }

.input {
    width: 100%; height: 46px; border-radius: 12px;
    border: 1px solid transparent; 
    background: rgba(120, 120, 128, 0.12); /* Apple Gray */
    padding: 0 16px; color: var(--text-main); font-size: 1rem;
    transition: 0.2s;
}
.input:focus { background: var(--glass-heavy); border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,122,255,0.2); }

/* === ГЛАВНАЯ СЕТКА === */
#view-app { 
    display: grid; 
    grid-template-columns: 340px 1fr; /* Сайдбар шире */
    height: 100%; width: 100%; 
    overflow: hidden; 
}

/* === SIDEBAR (Стекло) === */
.sidebar { 
    background: var(--glass-bg); 
    backdrop-filter: blur(var(--blur)); -webkit-backdrop-filter: blur(var(--blur));
    border-right: 1px solid var(--glass-border); 
    display: flex; flex-direction: column; 
    height: 100%; position: relative; z-index: 20; overflow: hidden; 
}

.sidebar-header { 
    padding: 16px 16px 0 16px; /* Снизу убрали отступ (было 16px) */
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0; 
    height: 60px; /* Чуть уменьшили высоту шапки (было 70px) */
}
.tabs { display: flex; padding: 0 16px 10px; gap: 8px; flex-shrink: 0; }
.tab-btn { flex: 1; padding: 8px; text-align: center; border-radius: 10px; cursor: pointer; font-size: 0.85rem; color: var(--text-sec); font-weight: 600; transition: 0.2s; }
.tab-btn.active { background: rgba(120,120,128,0.15); color: var(--text-main); }
.search-container { padding: 0 16px 10px; flex-shrink: 0; }
.search-input { width: 100%; height: 38px; background: rgba(118, 118, 128, 0.12); border-radius: 10px; border: none; padding: 0 30px 0 12px; color: var(--text-main); }

.list-container { flex: 1; overflow-y: auto; padding: 0 10px; position: relative; }
.list-item {
    display: flex; gap: 12px; padding: 12px; border-radius: 14px;
    cursor: pointer; transition: 0.2s; margin-bottom: 4px; align-items: center;
}
.list-item:hover { background: rgba(0,0,0,0.03); }
.list-item.active { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(0,122,255,0.2); }
.list-item.active .text-sec { color: rgba(255,255,255,0.8); }

#list-search { background: var(--glass-heavy); backdrop-filter: blur(20px); position: absolute; top: 125px; bottom: 70px; left: 0; width: 100%; z-index: 25; padding: 10px; overflow-y: auto; top: 170px !important; }
.user-panel { padding: 12px 16px; border-top: 1px solid var(--glass-border); display: flex; align-items: center; justify-content: space-between; background: var(--glass-bg); backdrop-filter: blur(10px); flex-shrink: 0; height: 70px; }

/* === ЧАТ (ПРАВАЯ ЧАСТЬ) === */
.chat-area { 
    background: transparent; 
    position: relative; display: flex; flex-direction: column; 
    height: 100%; width: 100%; overflow: hidden; 
}

.chat-area { 
    background: transparent; 
    position: relative; display: flex; flex-direction: column; 
    height: 100%; width: 100%; 
    overflow-x: hidden; /* <--- ВАЖНО: Запрещаем горизонтальный скролл */
    overflow-y: hidden;
}

.messages { 
    flex: 1; 
    overflow-y: auto; 
    overflow-x: hidden; /* <--- ВАЖНО: Запрещаем скролл внутри ленты */
    padding: 20px 5%; 
    display: flex; flex-direction: column; gap: 6px; 
    width: 100%; /* Гарантируем, что ширина не превысит родителя */
    padding-bottom: 120px !important; 
    
    /* Добавляем плавность прокрутки */
    scroll-behavior: smooth;
}
.msg-row {
    display: flex;
    margin-bottom: 8px; /* Отступ между сообщениями */
    max-width: 85%;     /* На мобильных 85% экрана */
    width: fit-content; /* Ширина по содержимому */
    min-width: 0;       /* Фикс для flexbox */
}
@media (min-width: 769px) {
    .msg-row {
        max-width: 65%; 
    }
}
.msg-img, .msg-video-circle, .msg-sticker-mp4 {
    max-width: 100% !important;
    height: auto !important;
}
.swipe-reply-icon {
    position: absolute;
    right: -40px;
    top: 50%;
    transform: translateY(-50%) scale(0.8);
    width: 30px;
    height: 30px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: 0.2s;
    z-index: 5;
}
.msg-row.own {
    align-self: flex-end;
    flex-direction: row-reverse; /* Аватарки нам тут не нужны, но порядок важен */
    margin-left: auto; /* Прижимает вправо */
}
.msg-row.own .meta, 
.msg-row.own .tick-icon {
    color: rgba(255, 255, 255, 0.9) !important;
}
.msg-row:not(.own) .meta {
    color: var(--text-sec) !important;
}
.bubble {
    padding: 10px 14px !important;
    border-radius: 18px !important;
    position: relative;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.4;
    font-size: 15px; /* Комфортный размер шрифта */
    box-shadow: 0 1px 2px rgba(0,0,0,0.08); /* Легкая тень */
    
    /* Важно: пузырь не должен быть 100% ширины, он должен обтекать контент */
    width: fit-content; 
    min-width: 60px; /* Минимальная ширина для галочек */
}
.msg-row:not(.own) .avatar-container {
    align-self: flex-end; /* Аватарка внизу */
    margin-right: 8px;
    margin-bottom: 2px;
}
.group-sender-name {
    font-size: 12px;
    color: var(--text-sec);
    margin-bottom: 4px;
    margin-left: 12px; /* Отступ чтобы было над пузырем */
    font-weight: 500;
}
.bubble a[href*="/uploads/"], 
.bubble div[onclick^="window.open"] {
    max-width: 100% !important;
    box-sizing: border-box;
}
.meta {
    float: right; /* Обтекание текстом */
    margin-left: 8px;
    margin-top: 4px;
    font-size: 11px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 2px;
}
/* Хвостики iMessage */
.msg-row:not(.own) .bubble {
    background: var(--msg-in) !important; /* Светло-серый */
    color: var(--text-main) !important;
    border-bottom-left-radius: 4px !important; /* Хвостик iMessage */
    border-bottom-right-radius: 18px !important;
}
.msg-row.own .bubble {
    background: var(--primary) !important;
    /* Градиент если хочется, или просто цвет: */
    /* background: linear-gradient(135deg, #007AFF, #005ec4) !important; */
    color: white !important;
    border-bottom-right-radius: 4px !important; /* Хвостик iMessage */
    border-bottom-left-radius: 18px !important;
}
.input-area .btn-icon {
    width: 40px !important;
    height: 40px !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    transition: background 0.2s, transform 0.2s !important;
    margin-bottom: 0 !important;
    color: var(--text-sec) !important;
}

.input-area .btn-icon:hover {
    background: rgba(120, 120, 128, 0.1) !important; /* Легкий эффект наведения iOS */
    color: var(--text-main) !important;
}
.input-area {
    position: absolute !important;
    bottom: 20px !important; /* Чуть приподняли над низом */
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: calc(100% - 40px) !important; /* Отступы по бокам */
    max-width: 800px !important; /* Не растягиваем на ультра-широких мониторах */
    z-index: 100 !important;
    
    /* Эффект матового стекла Apple */
    background: var(--glass-heavy) !important;
    backdrop-filter: blur(25px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(180%) !important;
    border: 1px solid var(--glass-border) !important;
    border-radius: 30px !important; /* Форма пилюли */
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04) !important; /* Красивая сложная тень */
    
    min-height: 50px !important;
    padding: 6px 8px !important;
    
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
    transition: all 0.3s ease !important;
}
.input-wrapper {
    flex: 1 !important;
    background: transparent !important; /* Убрали серый фон */
    border-radius: 0 !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 8px !important;
    border: none !important;
}
.input-area > .btn-icon:first-child {
    width: 40px !important;
    height: 40px !important;
    margin-bottom: 0 !important;      /* Стоит ровно на одной линии с овалом */
    margin-right: 4px !important;     /* Отступ до поля ввода */
}
textarea { width: 100%; background: transparent; border: none; resize: none; max-height: 120px; color: var(--text-main); font-family: inherit; font-size: 1rem; padding: 0; margin: 0; outline: none; }

/* === МОДАЛКИ === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  opacity: 1;
  transition: opacity var(--transition-base);
}
.chat-header {
    position: absolute !important;
    top: 0;
    left: 0;
    right: 0;
    height: 70px;
    
    /* Эффект стекла */
    background: var(--glass-bg) !important;
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000; /* Самый высокий слой */
    
    display: flex !important;
    align-items: center;
    padding: 0 12px;
}
/* Левая часть (Кнопка назад, Аватар, Имя) */
.chat-header > .flex.center.gap-3 {
    flex: 1;              /* Занимает всё доступное место */
    min-width: 0;         /* ВАЖНО: Разрешает сжатие текста внутри! */
    margin-right: 8px;    /* Отступ до кнопок звонка */
    justify-content: flex-start !important; /* Прибиваем влево */
    gap: 10px !important; /* Аккуратный отступ между элементами */
}

/* Кнопки звонка (Справа) */
#header-actions {
    flex-shrink: 0;       /* Запрещаем кнопкам сжиматься */
    display: flex;
    gap: 4px;             /* Расстояние между кнопками */
    align-items: center;
}

/* Меню (Три точки) */
.chat-header > .pointer:last-child {
    flex-shrink: 0;
    margin-left: 4px;
    padding: 8px;
}
/* === КНОПКА ЗАКРЫТИЯ ДЛЯ IOS МОДАЛОК === */
.ios-close-btn {
    position: absolute !important;
    top: 15px !important;
    right: 15px !important;
    background: rgba(128,128,128,0.1) !important;
    color: var(--text-sec) !important;
    width: 32px !important;
    height: 32px !important;
    border-radius: 50% !important;
    border: none !important;
    z-index: 100 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: background 0.2s !important;
}
.ios-close-btn:active {
    background: rgba(128,128,128,0.2) !important;
}
.modal { 
    background: var(--glass-heavy); 
    backdrop-filter: blur(40px);
    padding: 24px; 
    border-radius: 28px; 
    width: 90%; 
    max-width: 380px; 
    box-shadow: var(--glass-shadow); 
    border: 1px solid var(--glass-border);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    max-height: 90vh; 
    overflow-y: auto; 
    
    /* ФИКСЫ ОТСТУПОВ И СКРОЛЛА */
    display: flex;
    flex-direction: column;
    gap: 16px;               /* Единый отступ между всеми элементами */
    overflow-x: hidden;      /* Убираем скролл влево-вправо */
    box-sizing: border-box;  /* Учитываем padding в ширине */
}

/* Принудительный перенос длинного текста (Email, ID) */
.modal h2, .modal h3, .modal p, .modal .text-sec, .modal .bold {
    word-break: break-word;       /* Ломать длинные слова */
    overflow-wrap: anywhere;      /* Переносить где угодно */
    white-space: normal;          /* Обычный перенос */
    max-width: 100%;              /* Не шире родителя */
    text-align: center;           /* Центрирование для красоты */
    margin: 0 auto;               /* Центрирование блока */
}

/* Убираем лишние margin у заголовков внутри flex-контейнера */
.modal h2 { margin-bottom: 0; margin-top: 0; }

.modal.center {
    align-items: center;
    text-align: center;
}

.modal .input {
    margin-bottom: 0; 
}
/* === АВАТАРКИ === */
.avatar { position: relative; width: 48px; height: 48px; flex-shrink: 0; border-radius: 50%; background: rgba(0,0,0,0.05); }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.dot { position: absolute; bottom: 0; right: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; z-index: 2; }
.dot.online { background: var(--success); }
.dot.offline { background: var(--text-sec); }

/* === ЗВОНОК === */
#view-call { 
    position: fixed; 
    inset: 0; 
    background: #000; 
    z-index: 9999; /* Самый высокий приоритет */
    overflow: hidden; 
    display: flex; /* Гарантирует, что дети будут позиционироваться */
}
.video-grid { 
    position: absolute;
    inset: 0;
    width: 100%; 
    height: 100%; 
    z-index: 1;
}
video { width: 100%; height: 100%; object-fit: cover; }
#local-video { 
    position: absolute; 
    top: 60px; /* Отступ сверху */
    right: 20px; /* Отступ справа */
    width: 110px; 
    height: 160px; /* Вертикальная ориентация */
    background: #2c2c2e; 
    border-radius: 18px; /* Скругление Apple */
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6); 
    z-index: 100; /* Выше собеседника */
    object-fit: cover; 
    transform: scaleX(-1); /* Зеркалим себя */
    cursor: grab;
    touch-action: none; /* Важно для перетаскивания на телефоне */
    transition: box-shadow 0.2s;
}
#local-video:active {
    cursor: grabbing;
    box-shadow: 0 25px 60px rgba(0,0,0,0.8);
    border-color: var(--primary);
}
.call-controls { 
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 20px; 
    
    padding: 12px 25px;
    border-radius: 50px; /* Полное скругление */
    z-index: 200; 
    min-width: 240px;

    /* === ЭФФЕКТ СТЕКЛА === */
    /* 1. Фон более прозрачный (чтобы было видно размытие под ним) */
    background: rgba(50, 50, 50, 0.6); 

    /* 2. Сильное размытие + насыщенность (как в iOS) */
    backdrop-filter: blur(35px) saturate(180%);
    -webkit-backdrop-filter: blur(35px) saturate(180%); /* Для Safari */

    /* 3. Тонкая светлая рамка по краям */
    border: 1px solid rgba(255, 255, 255, 0.15);
    
    /* 4. Мягкая тень под панелью */
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}
.call-btn { 
    width: 60px; height: 60px; 
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}
.call-btn svg { width: 28px; height: 28px; }
.btn-secondary {
    /* Очень прозрачный белый фон */
    background: rgba(255, 255, 255, 0.15); 
    color: white;
    
    /* Легкий блюр внутри самой кнопки */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    
    /* Тонкая рамка */
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Эффект при нажатии */
.btn-secondary:active { 
    transform: scale(0.95); 
    background: rgba(255, 255, 255, 0.25); 
}
.btn-secondary.active {
    background: white !important;
    color: black !important;
    backdrop-filter: none; /* Убираем блюр, когда активна */
    box-shadow: 0 5px 15px rgba(255,255,255,0.3);
    border: none;
}
#btn-mute.active {
    background: white;
    color: black;
}
.btn-danger-call {
    background: #FF3B30; 
    color: white;
    width: 72px; height: 72px; 
    /* box-shadow: 0 4px 15px rgba(255, 59, 48, 0.4); <-- ЭТУ СТРОКУ Я УБРАЛ */
    box-shadow: none; /* Теперь она просто красная без ореола */
}
.btn-danger-call:active { 
    transform: scale(0.9); 
}
@media (hover: hover) {
    .btn-secondary:hover { background: rgba(255, 255, 255, 0.25); }
}
.call-btn:hover { 
    background: rgba(255,255,255,0.3); 
    transform: scale(1.1); 
}
.call-btn:active { transform: scale(0.95); }
.call-btn.hangup { 
    background: #FF3B30; 
}
.call-btn.active { 
    background: white !important; 
    color: black !important; 
}

/* === ICONS & MISC === */
.icon { width: 24px; height: 24px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ctx-menu {
    position: fixed !important;
    z-index: 20050 !important;
    background: var(--glass-heavy);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    border-radius: 16px;
    padding: 6px;
    
    /* Важные ограничения размеров */
    min-width: 200px;
    max-width: 260px !important; /* Не даем стать слишком широким */
    width: auto !important;
}
.ctx-item svg, 
.ctx-item .icon {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    stroke-width: 1.8px !important; /* Тонкие линии */
    fill: none !important;
    overflow: visible !important;
    margin-right: 12px !important;
}
@media (max-width: 768px) {
    .ctx-menu {
        position: absolute !important; /* Важно */
        right: 20px !important; /* Отступ справа */
        left: auto !important;
    }
}
@keyframes menu-pop {
    to { opacity: 1; transform: scale(1); }
}
#modal-custom-alert {
    z-index: 30000 !important; /* Поверх всего, даже историй */
    background: rgba(0,0,0,0.6);
}

.custom-alert-box {
    background: var(--glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 24px;
    border-radius: 20px;
    width: 300px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.alert-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text-main); }
.alert-msg { font-size: 14px; color: var(--text-sec); margin-bottom: 20px; line-height: 1.4; }

.alert-input {
    width: 100%;
    background: rgba(120,120,128,0.1);
    border: 1px solid rgba(120,120,128,0.2);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 16px;
    color: var(--text-main);
    outline: none;
}

.alert-btns { display: flex; gap: 10px; justify-content: center; }
.alert-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    border: none;
    transition: 0.2s;
}
.alert-btn.primary { background: var(--primary); color: white; }
.alert-btn.cancel { background: rgba(120,120,128,0.15); color: var(--text-main); }
.alert-btn:active { transform: scale(0.96); }

/* Красивый список для статистики */
.stats-list { text-align: left; max-height: 200px; overflow-y: auto; margin-bottom: 20px; }
.stats-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(0,0,0,0.05); }
.stats-row:last-child { border-bottom: none; }
.stats-av { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.ctx-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px; /* Удобные отступы для пальца */
    border-radius: 12px;
    
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
    
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
    text-decoration: none;
}
.ctx-item:active {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(0.98);
}

/* Красный цвет для удаления */
.ctx-item.danger {
    color: #FF3B30;
}
.ctx-item.danger svg {
    stroke: #FF3B30;
}

.mobile-ctx-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 250px;
}
.ctx-item.danger { color: var(--danger); }
.ctx-item:hover { background: var(--primary); color: white; }
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--glass-heavy);
    backdrop-filter: blur(20px);
    padding: 14px 20px;
    border-radius: 16px;
    border-left: 4px solid var(--primary);
    
    /* ИСПРАВЛЕНИЕ: Ставим очень большой индекс */
    z-index: 40000 !important; 
    
    box-shadow: var(--glass-shadow);
    animation: slideUp 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 0.9rem;
}
#msg-input::-webkit-outer-spin-button,
#msg-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#msg-input {
    width: 100% !important;
    max-height: 120px !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    font-size: 15px !important;
    font-family: var(--font) !important;
    line-height: 1.4 !important;
    resize: none !important;
    padding: 10px 0 !important;
    color: var(--text-main) !important;
    margin: 0 !important;
    height: 40px !important;
}
#msg-input::-webkit-scrollbar {
    display: none;
}
@media (max-width: 768px) {
    /* Панель на телефонах */
    .input-area {
        bottom: 12px !important; /* Чуть ниже для телефонов */
        width: calc(100% - 24px) !important; /* Отступы по 12px с краев */
        border-radius: 26px !important;
        padding: 4px 6px !important;
    }

    /* Увеличиваем размер текста, чтобы iPhone не зумил (16px - золотое правило iOS) */
    #msg-input {
        font-size: 16px !important; 
        height: 38px !important;
        padding: 9px 0 !important;
    }

    /* Немного уменьшаем кнопки для мобилок, чтобы текст влезал лучше */
    .input-area .btn-icon,
    #btn-send,
    .action-btn-container {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
    }
}
/* =========================================
   НИЖНЕЕ МЕНЮ (BOTTOM NAVIGATION)
   ========================================= */

/* По умолчанию скрыто на ПК */
.mobile-visible { display: none; }
#btn-send {
    background: var(--primary) !important; 
    color: white !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3) !important; /* Синяя тень свечения */
    opacity: 1 !important;
    padding: 0 !important;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s !important;
}
#btn-send:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(0, 122, 255, 0.4) !important;
}

#btn-send:active {
    transform: scale(0.95) !important;
}
#btn-send svg, 
#btn-send .icon {
    stroke: white !important;
    fill: none !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
}
@media (max-width: 768px) {
    /* 1. Показываем нижнее меню */
    .mobile-visible { display: flex; }
    .hidden-desktop { display: flex; }

    /* 2. Скрываем старые элементы навигации */
    .tabs { display: none !important; } /* Старые вкладки сверху */
    
    /* Скрываем кнопку меню в хедере (справа сверху), так как она теперь внизу */
    .sidebar-header .btn-icon:last-child { display: none !important; } 

    /* 3. Стили самого меню */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 80px; /* Высота меню */
        background: var(--glass-heavy);
        backdrop-filter: blur(var(--blur));
        -webkit-backdrop-filter: blur(var(--blur));
        border-top: 1px solid var(--glass-border);
        justify-content: space-around;
        align-items: center;
        z-index: 100; /* Поверх списков, но ниже модалок */
        padding-bottom: 15px; /* Учет полоски жестов iPhone */
        box-shadow: 0 -5px 20px rgba(0,0,0,0.05);
    }

    /* 4. Кнопки меню */
    .nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 100%;
        color: var(--text-sec);
        transition: 0.2s;
        cursor: pointer;
        position: relative;
    }

    .nav-item .icon {
        width: 26px;
        height: 26px;
        margin-bottom: 4px;
        stroke-width: 2;
    }

    .nav-item span {
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.3px;
    }

    /* Активное состояние */
    .nav-item.active {
        color: var(--primary);
    }
    
    .nav-item.active .icon {
        stroke: var(--primary);
        fill: rgba(54, 151, 255, 0.1); /* Легкая заливка иконки */
    }

    /* Эффект нажатия */
    .nav-item:active {
        transform: scale(0.95);
    }

    /* 5. Коррекция списков, чтобы нижние чаты не перекрывались меню */
    .list-container {
        padding-bottom: 90px !important; /* Отступ снизу больше высоты меню */
    }
    
    /* Коррекция поиска, чтобы не перекрывался */
    #list-search {
        bottom: 80px !important;
    }

    /* Бейдж непрочитанных в нижнем меню */
    .nav-badge {
        position: absolute;
        top: -2px;
        right: -4px;
        background: var(--danger);
        width: 10px;
        height: 10px;
        border-radius: 50%;
        border: 2px solid var(--bg-body);
    }
    
    /* Темная тема для меню */
    [data-theme="dark"] .bottom-nav {
        background: rgba(30, 30, 30, 0.9);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
}
/* === MOBILE === */
@media (max-width: 768px) {
    #view-app { grid-template-columns: 1fr; }
    .sidebar { width: 100%; border-right: none; }
    .chat-area { position: absolute; inset: 0; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1); z-index: 50; background: var(--bg-body); height: 100%; }
    .chat-area.active { transform: translateX(0); }
    #btn-back { display: flex !important; }
}

/* === НОВЫЕ СТИЛИ ДЛЯ ИСПРАВЛЕНИЙ === */

/* Стиль настроек (как в iOS) */
.settings-group {
    background: rgba(120, 120, 128, 0.1);
    border-radius: 12px;
    width: 100%;
    overflow: hidden;
    margin-top: 10px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    height: 48px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.15);
}

.setting-row:last-child { border-bottom: none; }

.setting-label { font-size: 0.95rem; color: var(--text-main); }

/* Красивый Select без рамок */
.select-clean {
    appearance: none; -webkit-appearance: none;
    background: transparent;
    border: none;
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: 500;
    text-align: right;
    padding-right: 20px; /* Место под стрелочку */
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007AFF%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right center;
    background-size: 10px;
    cursor: pointer;
}

/* Ссылка приглашения */
.invite-badge {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    cursor: pointer;
    font-weight: 500;
    width: 100%;
    justify-content: center;
}

/* Экран блокировки (Философский) */
.blocked-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
    background: var(--bg-body);
}

.banned-img {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 20px;
    opacity: 0.8;
    filter: drop-shadow(0 4px 10px rgba(0,0,0,0.1));
}

.banned-title { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; color: var(--text-main); }
.banned-text { font-size: 0.95rem; color: var(--text-sec); line-height: 1.5; font-style: italic; max-width: 300px; }

/* === ИСПРАВЛЕНИЯ (SEARCH, SYSTEM MSG, DESC) === */

/* 1. Поиск: Картинка и позиция */
.no-result img {
    width: 80px !important;
    height: 80px !important;
    object-fit: contain;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Исправление перекрытия на мобильном */
@media (max-width: 768px) {
    #list-search {
        top: 170px !important; /* Отступ от верха, чтобы не закрывать поле ввода */
        bottom: 0 !important;
        height: auto !important;
        border-radius: 0 !important;
    }
}

/* 2. Системные сообщения (фото и текст) */
.msg-system {
    width: 100%;
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Общий стиль для дат и событий (вступление, смена фото и т.д.) */
.sys-badge, .date-badge {
    background: rgba(120, 120, 128, 0.15); /* Полупрозрачный серый */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-sec);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 12px;
    border-radius: 12px;
    text-align: center;
    max-width: 85%;
    line-height: 1.4;
    word-wrap: break-word;
    user-select: none;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border: 1px solid rgba(255,255,255,0.1);
}

/* Для темной темы чуть светлее текст */
[data-theme="dark"] .sys-badge, 
[data-theme="dark"] .date-badge {
    background: rgba(255, 255, 255, 0.12);
    color: #e5e5e5;
}

/* Чтобы фото обновления группы было маленьким кружочком */
.sys-avatar-prev {
    width: 50px !important;
    height: 50px !important;
    border-radius: 50%;
    object-fit: cover;
    margin-top: 8px;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* 3. Поле описания группы (стиль TextArea как текста) */
.desc-input {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    color: var(--text-sec);
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    padding: 5px;
    margin-bottom: 10px;
}
.desc-input:disabled {
    opacity: 1;
    background: transparent;
}
.desc-input:not(:disabled) {
    background: rgba(0,0,0,0.05); /* Подсветка когда можно редактировать */
    border-radius: 8px;
    color: var(--text-main);
}

.no-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding-top: 40px;
    width: 100%;
}

.no-result img {
    width: 100px !important;   /* Четко 100px */
    height: 100px !important;  /* Четко 100px */
    object-fit: contain;
    margin-bottom: 15px;
    opacity: 0.6;
}

/* 2. ПОИСК НА МОБИЛЬНОМ (Чтобы не перекрывал ввод) */
@media (max-width: 768px) {
    #list-search {
        /* Сдвигаем список результатов ВНИЗ, под поле ввода */
        top: 170px !important; 
        bottom: 0 !important;
        height: auto !important;
        background: var(--bg-body) !important; /* Фон, чтобы не было прозрачным */
        z-index: 40 !important;
    }
}

.desc-textarea {
    width: 100%;
    min-height: 60px;
    border: 1px solid transparent;
    background: transparent;
    text-align: center;
    color: var(--text-sec);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    padding: 8px;
    margin: 10px 0;
    border-radius: 12px;
    transition: 0.2s;
}
/* Когда активно (админ) - подсвечиваем */
.desc-textarea:not(:disabled) {
    background: rgba(120, 120, 128, 0.1); 
    color: var(--text-main);
}
.desc-textarea:focus {
    background: var(--bg-surface);
    border-color: var(--primary);
}
.msg-img {
    display: block;
    max-width: 100%;       /* Не шире родительского блока */
    max-height: 350px;     /* Ограничение по высоте, чтобы не было "небоскребов" */
    width: auto;           /* Сохраняем пропорции ширины */
    height: auto;          /* Сохраняем пропорции высоты */
    object-fit: contain;   /* Картинка не будет растягиваться/сплющиваться */
    border-radius: 12px;   /* Закругленные углы */
    cursor: pointer;
    background: rgba(0,0,0,0.05); /* Легкий фон, пока грузится */
}

/* Контейнер для фото, чтобы кнопка скачивания позиционировалась правильно */
.img-wrapper {
    position: relative; 
    display: inline-block; 
    max-width: 100%;       /* Важно! Контейнер тоже не должен вылезать */
    border-radius: 12px;
    overflow: hidden;      /* Обрезаем всё лишнее по краям */
}

/* Контейнер пересланного сообщения */
.fwd-block {
    display: flex;
    gap: 10px;
    background: rgb(227, 227, 227);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 6px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border-left: 3px solid var(--primary); /* Синяя линия слева */
}

/* Аватар автора оригинала */
.fwd-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Информация (Имя, Дата) */
.fwd-meta {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.fwd-author {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary);
    line-height: 1.2;
}

.fwd-date {
    font-size: 0.7rem;
    color: var(--text-sec);
}

/* Текст пересланного сообщения */
.fwd-text-preview {
    font-size: 0.9rem;
    color: var(--text-main);
    margin-top: 2px;
    opacity: 0.9;
    /* Обрезаем, если слишком длинное */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* В темной теме фон чуть светлее */
[data-theme="dark"] .fwd-block {
    background: rgba(255, 255, 255, 0.08);
}

.type-switch {
    background: rgba(118, 118, 128, 0.12); /* Серый фон подложки */
    padding: 2px;
    border-radius: 8px;
    display: flex;
    width: 100%;
    margin-bottom: 15px;
}

.type-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px 0;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

/* Активная кнопка становится белой с тенью */
.type-btn.active {
    background: var(--bg-surface);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    font-weight: 600;
}
.info-banner {
    position: relative;
    margin: 0 16px 16px;
    padding: 16px;
    
    /* Эффект матового стекла VisionOS */
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(25px) saturate(180%);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    
    /* Тонкие границы и тени для объема */
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px; /* Более скругленные углы */
    
    /* Глубокая рассеянная тень + внутреннее свечение */
    box-shadow: 
        0 12px 30px -10px rgba(0, 0, 0, 0.08),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
        
    display: flex;
    align-items: center; /* Центрирование по вертикали */
    gap: 16px;
    
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
}

/* Эффект "живого" блика */
.info-shine {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.6) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.8s;
    pointer-events: none;
    z-index: 1;
}

.info-banner:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 
        0 20px 40px -10px rgba(0, 122, 255, 0.15),
        inset 0 0 0 1px rgba(255, 255, 255, 0.8);
}

.info-banner:hover .info-shine {
    transform: translateX(100%);
}

.info-icon-box {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    
    /* Градиент iOS Blue */
    background: linear-gradient(135deg, #007AFF, #00C6FF);
    
    /* Форма Squircle (почти квадрат с мягкими углами) */
    border-radius: 14px;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Внутренняя тень для иконки и внешняя цветная тень */
    box-shadow: 
        0 8px 16px rgba(0, 122, 255, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
        
    color: white;
    z-index: 2;
}

.info-icon-box .icon {
    width: 24px;
    height: 24px;
    stroke-width: 2.5; /* Чуть жирнее иконка */
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
}

.info-content {
    flex: 1;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.info-title {
    font-size: 15px;
    font-weight: 700; /* Жирнее заголовок */
    color: #1c1c1e; /* Apple Text Black */
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 2px;
    letter-spacing: -0.02em;
}

.version-badge {
    font-size: 9px;
    background: rgba(0, 122, 255, 0.1);
    color: #007AFF;
    padding: 4px 8px;
    border-radius: 100px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-desc {
    font-size: 13px;
    color: #8A8A8E; /* Apple Text Secondary */
    line-height: 1.35;
    font-weight: 400;
}

/* === DARK MODE ADAPTATION === */
[data-theme="dark"] .info-banner {
    background: rgba(30, 30, 30, 0.6);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .info-banner:hover {
    background: rgba(40, 40, 40, 0.7);
    border-color: rgba(255, 255, 255, 0.2);
}

[data-theme="dark"] .info-title {
    color: #FFFFFF;
}

[data-theme="dark"] .info-desc {
    color: #98989F;
}

[data-theme="dark"] .info-shine {
    background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
}

.banned-content {
    text-align: center; max-width: 400px; padding: 40px;
    color: white;
}

.banned-icon {
    width: 120px; height: 120px; object-fit: contain;
    margin-bottom: 30px; opacity: 0.9;
    filter: drop-shadow(0 0 20px rgba(255, 59, 48, 0.3));
}

.banned-title {
    font-size: 2rem; font-weight: 700; margin-bottom: 20px;
    letter-spacing: -1px;
}

.banned-quote {
    font-size: 1.1rem; line-height: 1.6; font-style: italic;
    color: rgba(255, 255, 255, 0.7); margin-bottom: 40px;
    border-left: 2px solid var(--danger); padding-left: 15px;
    text-align: left;
}

.banned-timer {
    font-family: monospace; font-size: 0.9rem; color: var(--danger);
    margin-bottom: 30px; text-transform: uppercase; letter-spacing: 2px;
}

.btn-logout {
    padding: 12px 30px; border-radius: 50px; font-size: 1rem;
    background: transparent; border: 1px solid rgba(255,255,255,0.3);
    color: white; transition: 0.3s; width: 100%;
}
.btn-logout:hover {
    background: var(--danger); border-color: var(--danger);
    box-shadow: 0 0 30px rgba(255, 59, 48, 0.4);
}
.banned-content {
    text-align: center; max-width: 400px; padding: 40px;
}

.banned-icon {
    width: 100px; height: 100px; margin-bottom: 20px;
    filter: drop-shadow(0 0 20px rgba(255, 59, 48, 0.5));
}

.banned-title { font-size: 2rem; font-weight: 800; margin-bottom: 10px; }
.banned-quote { font-style: italic; color: #aaa; margin-bottom: 30px; line-height: 1.5; }
.banned-timer { font-family: monospace; color: #ff3b30; margin-bottom: 20px; font-size: 1.2rem; }

/* === БЕЙДЖ АДМИНА (СИНЯЯ ГАЛОЧКА) === */
.admin-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #9300d2;
    color: rgb(255, 255, 255);
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 800;
    margin-left: 6px;
    border: 1px solid rgba(0, 122, 255, 0.3);
    user-select: none;
    vertical-align: middle;
    height: 18px;
}

.admin-badge::before {
    content: "✓";
    font-weight: 900;
    display: inline-block;
}

/* Для темной темы */
[data-theme="dark"] .admin-badge {
    background: rgba(10, 132, 255, 0.25);
    color: #0cd62a;
    border-color: rgba(10, 132, 255, 0.4);
}

#view-banned {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    display: flex; align-items: center; justify-content: center;
    color: white;
}
.banned-content { text-align: center; padding: 20px; }
.banned-title { font-size: 2rem; font-weight: bold; margin: 10px 0; }
.banned-timer { color: #ff3b30; font-family: monospace; font-size: 1.2rem; margin: 20px 0; }

/* === ИСПРАВЛЕНИЕ ДИЗАЙНА ВХОДА === */
.hidden {
    display: none !important;
}

.auth-card {
    transition: all 0.3s ease;
}

/* Стили для текста подтверждения */
.verify-text {
    color: #333;
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    padding: 10px;
    border-radius: 8px;
}

/* Поле для ввода кода 2FA */
.code-input {
    letter-spacing: 10px;
    font-size: 24px !important;
    text-align: center;
    font-weight: bold;
    color: #007AFF !important;
}

/* === НОВОЕ МЕНЮ И НАСТРОЙКИ (PC vs MOBILE) === */

/* НА ПК: Мини-окошко (как было, но красивее) */
@media (min-width: 769px) {
    #modal-menu .modal {
        width: 300px;
        position: absolute;
        top: 60px;
        left: 70px; /* Сдвиг от сайдбара */
        margin: 0;
        height: auto;
        border-radius: 16px;
    }
    
    /* Скрываем мобильную шапку на ПК */
    .mobile-profile-header { display: none; }
}

/* НА МОБИЛЬНОМ: Полный экран + Анимация */
@media (max-width: 768px) {
    #modal-menu .modal {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        padding: 0;
        background: var(--bg-body);
        display: flex;
        flex-direction: column;
    }
    
    /* Контейнер скролла */
    .menu-scroll-container {
    /* Обязательно для плавности на iOS */
    -webkit-overflow-scrolling: touch;
    
    /* Изолирует скролл, чтобы не тянулся фон сайта */
    overscroll-behavior: contain;
    
    /* Включает аппаратное ускорение */
    transform: translate3d(0, 0, 0);
    will-change: scroll-position;
    
    /* Если там есть position: absolute/fixed, убедись что стоят эти свойства: */
    overflow-y: auto;
    height: 100%; 
    }

    /* ШАПКА ПРОФИЛЯ (Анимированная) */
    .mobile-profile-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--glass-bg);
        backdrop-filter: blur(20px);
        transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        border-bottom: 1px solid transparent;
        overflow: hidden;
        /* Начальное состояние (Большое) */
        height: 350px; 
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        padding-bottom: 20px;
    }

    /* Аватарка (Фон) */
    .mp-avatar-bg {
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0);
    }
    
    /* Градиент поверх аватарки для читаемости текста */
    .mp-overlay {
        position: absolute;
        inset: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
        z-index: 2;
        transition: all 0.3s ease;
    }

    /* Контейнер текста */
    .mp-info {
        position: relative;
        z-index: 3;
        padding: 0 20px;
        color: white;
        transition: all 0.3s ease;
        transform-origin: left bottom;
    }

    .mp-name {
        font-size: 32px;
        font-weight: 800;
        line-height: 1.1;
        text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    }

    .mp-handle {
        font-size: 18px;
        opacity: 0.9;
        margin-top: 5px;
        font-weight: 600;
    }
    
    .mp-numeric {
        font-size: 12px;
        opacity: 0.6;
        margin-top: 2px;
        font-family: monospace;
        letter-spacing: 1px;
    }

    .mp-bio {
        margin-top: 10px;
        font-size: 14px;
        opacity: 0.8;
        line-height: 1.4;
        max-height: 60px;
        overflow: hidden;
        transition: all 0.2s;
    }

    /* === СОСТОЯНИЕ "СЖАТОЕ" (При скролле) === */
    .mobile-profile-header.shrunk {
        height: 80px; /* Маленькая высота */
        background: var(--glass-heavy);
        border-bottom: 1px solid var(--glass-border);
        justify-content: center;
        padding-bottom: 0;
    }

    .mobile-profile-header.shrunk .mp-avatar-bg {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        top: 15px;
        left: 20px;
        opacity: 1;
    }

    .mobile-profile-header.shrunk .mp-overlay { opacity: 0; }

    .mobile-profile-header.shrunk .mp-info {
        padding-left: 85px; /* Отступ под маленькую аватарку */
        color: var(--text-main);
    }

    .mobile-profile-header.shrunk .mp-name { font-size: 18px; text-shadow: none; }
    .mobile-profile-header.shrunk .mp-handle { font-size: 14px; color: var(--text-sec); }
    .mobile-profile-header.shrunk .mp-bio { opacity: 0; height: 0; margin: 0; }
    .mobile-profile-header.shrunk .mp-numeric { display: none; }
}

/* Настройки (Стилизация списков как в iOS) */
.settings-list {
    display: flex;
    flex-direction: column;
    padding: 0 16px;
    margin-top: 20px;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 0;
    border-bottom: 1px solid rgba(128,128,128, 0.1);
    cursor: pointer;
    font-size: 16px;
    color: var(--text-main);
}
.settings-item:last-child { border-bottom: none; }

.settings-icon {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
}

.arrow-right { margin-left: auto; opacity: 0.3; }

/* Формы настроек */
.settings-section-title {
    padding: 20px 16px 8px;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-sec);
    font-weight: 600;
}

.settings-input-group {
    background: var(--glass-bg);
    border-radius: 12px;
    overflow: hidden;
    margin: 0 16px;
}

.setting-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(128,128,128, 0.1);
    height: 50px;
}
.setting-row input {
    text-align: right;
    background: transparent;
    border: none;
    font-size: 16px;
    color: var(--primary);
}

/* === ИСПРАВЛЕНИЕ МОБИЛЬНОЙ ШАПКИ === */

@media (max-width: 768px) {
    /* Основное состояние (БОЛЬШОЕ) */
    .mobile-profile-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-body);
        /* Фон-картинка на весь блок */
        height: 320px;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        padding: 20px;
        overflow: hidden;
        transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
        border-bottom: 1px solid transparent;
        flex-shrink: 0; /* Важно, чтобы не сжималось само */
    }

    /* Аватарка-фон (Размытая большая) */
    /* Аватарка (Четкая) - добавляем псевдо-элемент или используем img */
    /* В данном коде у нас одна картинка .mp-avatar-bg, сделаем хитрость */
    
    .mp-overlay {
        position: absolute;
        inset: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.9) 10%, transparent);
        transition: opacity 0.3s;
    }

    .mp-info {
        position: relative;
        z-index: 5;
        transform-origin: left bottom;
        transition: all 0.4s ease;
        color: white;
    }

    .mp-name { font-size: 28px; font-weight: 800; line-height: 1.1; margin-bottom: 4px; }
    .mp-handle { font-size: 16px; opacity: 0.8; }
    .mp-numeric { font-size: 12px; opacity: 0.6; font-family: monospace; margin-bottom: 8px; }
    .mp-bio { font-size: 14px; opacity: 0.9; line-height: 1.4; max-height: 60px; overflow: hidden; }

    /* === СЖАТОЕ СОСТОЯНИЕ (МАЛЕНЬКОЕ) === */
    .mobile-profile-header.shrunk {
        height: 70px; /* Фиксированная высота */
        background: var(--glass-heavy); /* Стеклянный фон */
        backdrop-filter: blur(20px);
        padding: 0 16px;
        flex-direction: row; /* В РЯД! */
        align-items: center; /* По центру вертикально */
        justify-content: flex-start;
        border-bottom: 1px solid var(--border);
    }

    /* Превращаем фоновую картинку в маленькую аватарку */
    .mobile-profile-header.shrunk .mp-avatar-bg {
        position: relative;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        opacity: 1;
        filter: blur(0);
        transform: scale(1);
        margin-right: 12px;
        inset: auto;
        border: 1px solid rgba(0,0,0,0.1);
    }

    .mobile-profile-header.shrunk .mp-overlay { opacity: 0; }

    /* Меняем текст */
    .mobile-profile-header.shrunk .mp-info {
        color: var(--text-main);
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 0;
    }

    .mobile-profile-header.shrunk .mp-name { font-size: 16px; margin: 0; }
    .mobile-profile-header.shrunk .mp-handle { font-size: 13px; color: var(--text-sec); opacity: 1; }
    
    /* Скрываем лишнее при сжатии */
    .mobile-profile-header.shrunk .mp-numeric,
    .mobile-profile-header.shrunk .mp-bio { 
        display: none; 
    }
}

/* Превьюшки в настройках */
.wallpaper-preview {
    height: 100px;
    border-radius: 12px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.wallpaper-preview:hover {
    transform: scale(1.05);
    border-color: var(--primary);
}
.wallpaper-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 10px 0;
}
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    flex-shrink: 0; /* Чтобы не сжимался */
}

/* Прячем стандартный квадратик */
.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Фон переключателя */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(120, 120, 128, 0.3); /* Серый (выкл) */
    transition: .3s;
    border-radius: 31px;
}

/* Кругляшок */
.slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s cubic-bezier(0.3, 1.5, 0.7, 1); /* Пружинистый эффект */
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15), 0 3px 1px rgba(0,0,0,0.06);
}

/* Состояние ВКЛЮЧЕНО */
.switch-toggle input:checked + .slider {
    background-color: #34C759; /* Apple Green */
}

.switch-toggle input:checked + .slider:before {
    transform: translateX(20px);
}
.call-btn.active {
    background-color: #ff3b30 !important; /* Красный цвет */
    color: white;
}

/* Слой Информации (Центр) */
.call-info-layer {
    position: absolute;
    top: 15%; /* Чуть выше центра */
    left: 0; 
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 5;
    pointer-events: none; /* Пропускаем клики сквозь текст */
    transition: opacity 0.3s;
}
.call-info-layer.hidden-ui { opacity: 0; }

.call-avatar-large {
    width: 100px; height: 100px;
    border-radius: 50%;
    margin-bottom: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.call-name {
    font-size: 28px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.call-status {
    font-size: 16px;
    color: rgba(255,255,255,0.8);
    margin-top: 5px;
}

/* Слой Таймера и Шифрования (Верх) */
.call-persistent-layer {
    position: absolute;
    top: 50px;
    width: 100%;
    text-align: center;
    z-index: 50;
    pointer-events: none;
    text-shadow: 0 1px 5px rgba(0,0,0,0.5);
}

.encryption-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.3);
    padding: 4px 10px;
    border-radius: 20px;
    margin-bottom: 5px;
    backdrop-filter: blur(5px);
}

.call-timer {
    font-size: 18px;
    font-weight: 500;
    color: white;
}

/* Видео (убедись, что оно на заднем плане) */
#remote-video { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; /* Заполняет экран без черных полос */
    position: absolute;
    inset: 0;
    z-index: 1;
    background: #1c1c1e; /* Цвет пока видео грузится */
}
.pinned-icon {
    /* Скрываем старый эмодзи 📌 */
    font-size: 0 !important;
    color: transparent !important;
    
    /* Задаем размеры новой иконки */
    width: 16px;
    height: 16px;
    
    /* Позиционируем аккуратно справа сверху */
    position: absolute;
    top: 16px;
    right: 8px;
    
    /* Рисуем векторную иконку (SVG) через код */
    /* Цвет #8A8A8E (серый) - поменяйте на %23007AFF для синего */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238A8A8E'%3E%3Cpath d='M16,12V4H17V2H7V4H8V12L6,14V16H11V22H13V16H18V14L16,12Z' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    
    /* Небольшой наклон (45 градусов) */
    transform: rotate(45deg);
    opacity: 0.8;
    z-index: 10;
}
@media (prefers-color-scheme: dark) {
    .list-item.pinned {
        background: transparent !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
}
.list-item.pinned {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1) !important;
}
.list-item.pinned .chat-item-name,
.list-item.pinned .bold {
    color: var(--text-main) !important;
}

.list-item.pinned .text-sec {
    color: var(--text-sec) !important;
}
/* === РЕАКЦИИ === */

/* 1. Панель выбора (Desktop Hover) */
.reaction-panel-desktop {
    position: absolute;
    top: -45px;
    right: 0;
    
    background: var(--glass-heavy);
    backdrop-filter: blur(20px);
    padding: 6px;
    border-radius: 50px;
    display: flex;
    gap: 6px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    
    /* Используем visibility для надежности кликов */
    opacity: 0;
    visibility: hidden; 
    transform: translateY(10px) scale(0.9);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    
    z-index: 100; /* Высокий индекс, чтобы быть выше текста */
    border: 1px solid var(--glass-border);
}

/* При наведении на сообщение */
.bubble:hover .reaction-panel-desktop {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Стили для чужих сообщений */
.msg-row:not(.own) .reaction-panel-desktop {
    right: auto;
    left: 0;
}

/* Показываем при наведении на строку сообщения */
.msg-row:hover .reaction-panel-desktop {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* Для чужих сообщений панель слева от бабла */
.msg-row:not(.own) .reaction-panel-desktop {
    right: auto;
    left: 100%;
    margin-left: 10px;
    top: 50%;
    transform: translateY(-50%) scale(0.9);
}
.msg-row:not(.own):hover .reaction-panel-desktop {
    transform: translateY(-50%) scale(1);
}

.react-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 18px;
    border-radius: 50%;
    transition: 0.2s;
}
.react-btn:hover { background: rgba(0,0,0,0.1); transform: scale(1.2); }

/* 2. Отображение поставленных реакций */
.reactions-display {
    display: flex;
    flex-wrap: wrap;       /* Перенос на новую строку */
    gap: 4px;
    margin-top: 6px;
    width: 100%;
    position: relative;
    z-index: 5;
}
.msg-row:not(.own) .reactions-display { justify-content: flex-start; }

.reaction-chip {
    background: var(--glass-heavy);
    border: 1px solid var(--glass-border);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex; align-items: center; gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: 0.2s;
}
.msg-row.own .reaction-chip {
    background: rgba(255, 255, 255, 0.2) !important; /* Полупрозрачный белый */
    border: none !important;
    color: white !important;
}
.msg-row:not(.own) .reaction-chip {
    background: #ffffff !important;
    border: 1px solid rgba(0,0,0,0.05) !important;
}
.bubble.transparent-media {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    /* Убираем хвостики */
    border-radius: 0 !important; 
}
.bubble.transparent-media .meta {
    background: rgba(0,0,0,0.4);
    padding: 2px 6px;
    border-radius: 10px;
    color: white !important;
    position: absolute;
    bottom: 10px;
    right: 10px;
    margin: 0;
    pointer-events: none;
}
.bubble.transparent-media .tick-icon {
    color: white !important;
}
.reaction-chip.active {
    background: rgba(0, 122, 255, 0.15);
    border-color: var(--primary);
    color: var(--primary);
}
.reaction-chip:hover { transform: scale(1.05); }

/* 3. Мобильное меню (Long Press) */
.mobile-react-menu {
    display: flex;
    justify-content: space-between;
    padding: 10px 10px 15px 10px;
    border-bottom: 1px solid rgba(128,128,128, 0.15);
    margin-bottom: 6px;
}
.ctx-actions-list {
    display: flex;
    flex-direction: column;
    padding: 5px;
    background: var(--glass-heavy);
    border-radius: 0 0 16px 16px; /* Закругляем низ */
}
.mobile-react-btn {
    font-size: 26px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(128, 128, 128, 0.1);
    transition: transform 0.2s;
}
.mobile-react-btn:active {
    transform: scale(1.2);
    background: rgba(128, 128, 128, 0.2);
}
.btn-clean {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: white !important;
    cursor: pointer !important;
    border-radius: 50% !important; /* Круглая зона клика */
    transition: background 0.2s;
    outline: none !important; /* Убираем синюю обводку */
}
.btn-clean:active {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(0.9);
}
#modal-forward {
    z-index: 25000 !important; /* Выше чем Viewer (20000) */
    background: rgba(0, 0, 0, 0.6) !important; /* Чуть темнее фон */
}
.btn-clean svg {
    width: 24px !important;
    height: 24px !important;
    stroke: currentColor !important;
    fill: none !important;
    stroke-width: 2px !important;
}
.share-btn-icon svg {
    width: 26px !important;
    height: 26px !important;
    stroke: #007AFF !important;
    stroke-width: 1.5px !important;
    fill: none !important;
}
.share-top-actions {
    padding-top: 10px !important;
}
/* 4. Emoji Picker Grid (Кнопка +) */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
}
.emoji-item {
    font-size: 24px;
    cursor: pointer;
    text-align: center;
    padding: 5px;
    border-radius: 8px;
}
.emoji-item:hover { background: rgba(0,0,0,0.1); }

.react-avatars {
    display: flex;
    align-items: center;
    margin-left: 4px;
}

.react-mini-av {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.8);
    margin-left: -4px; /* Наложение друг на друга */
}
.react-mini-av:first-child {
    margin-left: 0;
}

/* Обновляем Chip, чтобы вместить аватарки */
.reaction-chip {
    padding: 2px 6px;
    gap: 2px;
}
/* === ГАЛОЧКИ СТАТУСА === */
.msg-ticks {
    display: inline-flex;
    vertical-align: bottom;
    margin-left: 4px;
    opacity: 0.8;
}

.tick-icon {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* 1. ГАЛОЧКИ НА БЕЛОМ ФОНЕ (если вдруг понадобятся) */
.tick-sent { color: var(--text-sec); } /* Серые */
.tick-read { color: #34C759; }        /* Зеленые (или синие #007AFF) */

/* 2. ИСПРАВЛЕНИЕ: ГАЛОЧКИ НА СИНЕМ ФОНЕ (СВОИ СООБЩЕНИЯ) */
.msg-row.own .tick-sent {
    color: rgba(255, 255, 255, 0.5) !important;
    opacity: 0.7;
}
@media (min-width: 1024px) {
    /* Ограничиваем ширину пузырей сообщений, чтобы не читать "простыни" */
    .msg-row {
        max-width: 45%; /* Было 70%, на 4K мониторах это слишком много */
    }
    
    /* Центрируем содержимое чата, если экран очень широкий */
    .chat-area {
        max-width: 1600px; /* Ограничитель для ультра-широких мониторов */
        margin: 0 auto;
        border-left: 1px solid var(--glass-border);
        border-right: 1px solid var(--glass-border);
    }
}

.msg-row.own .tick-read {
    color: #ff00f7; /* Чисто БЕЛЫЙ (прочитано) - чтобы было видно! */
    opacity: 1 !important;
    filter: drop-shadow(0 0 2px rgba(255,255,255,0.5)); /* Легкое свечение */
}
.msg-row:not(.own) .tick-read {
    color: var(--primary) !important; /* Синий для прочитанных */
}
.msg-row:not(.own) .tick-sent {
    color: var(--text-sec) !important; /* Серый для непрочитанных */
}
/* === АНИМАЦИЯ ПЕЧАТИ (В ШАПКЕ) === */
.typing-indicator {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 2px;
    animation: fadeIn 0.3s;
}
.typing-dot {
    width: 3px; height: 3px; background: var(--primary); border-radius: 50%;
    animation: typingBounce 1s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
/* === СТИЛИЗАЦИЯ ТЕКСТА === */
.msg-content b { font-weight: 700; }
.msg-content i { font-style: italic; }

/* Цитата (-текст-) */
.fmt-quote {
    display: inline-block;
    border-left: 3px solid var(--primary);
    background: rgba(120, 120, 128, 0.1); /* Полупрозрачный фон */
    padding: 2px 8px;
    border-radius: 4px;
    font-style: italic;
    color: var(--text-sec);
    margin: 2px 0;
}

/* Внутри своих сообщений цитата чуть светлее */
.msg-row.own .fmt-quote {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: white;
    color: rgba(255, 255, 255, 0.9);
}
/* === ZNAKORA: PINNED MESSAGE (COMPACT & CLOSER) === */
#pinned-bar {
    position: absolute !important;
    top: 75px !important; 
    left: 10px !important;
    right: 10px !important;
    height: auto !important;
    min-height: 50px !important;
    z-index: 999 !important;
    
    background: var(--glass-heavy) !important;
    backdrop-filter: blur(25px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(180%) !important;
    
    border: 1px solid var(--glass-border) !important;
    border-radius: 16px !important; /* Увеличили скругление как в iOS */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05) !important;
    
    padding: 8px 12px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
}

#pinned-bar.hidden { display: none !important; }

/* Синяя полоска */
#pinned-bar .pinned-icon-area {
    width: 3px !important;
    height: 34px !important;
    background: var(--primary) !important;
    border-radius: 3px !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    display: block !important;
}

/* Скрываем иконку */
#pinned-bar .pinned-icon-area svg,
#pinned-bar .pinned-icon-area .icon { display: none !important; }

/* Текст */
#pinned-content {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    overflow: hidden !important;
    min-width: 0 !important;
}

#pinned-title, #pinned-count {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--primary) !important;
    margin-bottom: 2px !important;
    line-height: 1.2 !important;
}

#pinned-text {
    font-size: 13px !important;
    color: var(--text-main) !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    opacity: 0.8 !important;
}
/* Крестик */
#btn-unpin {
    width: 28px !important;
    height: 28px !important;
    background: transparent !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    margin-left: auto !important; /* Прижимаем вправо */
    color: var(--text-sec) !important;
    opacity: 0.6 !important;
    transition: opacity 0.2s !important;
}
#btn-unpin:hover { opacity: 1 !important; }
#btn-unpin svg { width: 20px !important; height: 20px !important; stroke-width: 1.5 !important; }
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.unread-badge {
    background-color: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    margin-left: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0, 122, 255, 0.3);
}

/* Анимация появления */
.unread-badge {
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* Стиль превью-сообщения */
#typing-preview-row .bubble {
    backdrop-filter: blur(2px);
    border-color: var(--primary) !important;
}

/* Бейдж непрочитанных сообщений */
.unread-badge {
    background-color: #007AFF; /* Синий цвет */
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px; /* Круг */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    margin-left: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 122, 255, 0.3);
    animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}
#modal-incoming {
    z-index: 9999 !important; /* Поверх всего */
    background: rgba(0,0,0,0.8) !important; /* Затемнение фона страницы */
}

#modal-incoming .modal {
    background: #121212 !important; /* Чисто черный фон карточки */
    border: 1px solid #333 !important;
    border-radius: 30px !important;
    padding: 40px 30px !important;
    width: 300px !important;
    box-shadow: 0 20px 60px rgba(0,0,0,1) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}

/* Аватарка */
#modal-incoming .avatar {
    width: 100px !important;
    height: 100px !important;
    margin-bottom: 20px !important;
    border: 2px solid #fff !important; /* Белая рамка чтобы видно было границы */
}

/* ИМЯ - БЕЛОЕ */
#inc-name {
    font-size: 24px !important;
    font-weight: 800 !important;
    color: #FFFFFF !important; /* ЯРКО БЕЛЫЙ */
    text-shadow: 0 2px 5px rgba(0,0,0,1) !important; /* Тень текста */
    margin-bottom: 10px !important;
    text-align: center !important;
}

/* ТИП ЗВОНКА - СЕРЫЙ */
#inc-type {
    font-size: 16px !important;
    color: #CCCCCC !important; /* Светло-серый */
    margin-bottom: 40px !important;
    text-align: center !important;
}

/* Кнопки */
.btn-incoming {
    width: 70px !important;
    height: 70px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 2rem !important;
    color: white !important;
    border: none !important;
}
.btn-incoming.decline { background: #FF3B30 !important; } /* Красный */
.btn-incoming.accept { background: #34C759 !important; } /* Зеленый */


/* Контейнер кнопок входящего */
.incoming-actions {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 20px;
}

.btn-incoming {
    width: 70px; 
    height: 70px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    border: none;
    cursor: pointer;
    font-size: 1.8rem;
    transition: 0.2s;
    color: white;
}

.btn-incoming.decline {
    background: #FF3B30; /* Красный */
    box-shadow: 0 5px 20px rgba(255, 59, 48, 0.3);
}

.btn-incoming.accept {
    background: #34C759; /* Зеленый */
    box-shadow: 0 5px 20px rgba(52, 199, 89, 0.3);
}

.btn-incoming:active { transform: scale(0.9); }

/* === СКРЫТИЕ ИНТЕРФЕЙСА ПРИ ВИДЕО === */
/* Когда видео включено, этот класс добавляется к панели с аватаркой */
.hidden-ui {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Таймер и шифрование остаются видны всегда, но можно их подвинуть */
.call-persistent-layer {
    z-index: 50;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8); /* Тень чтобы видно на видео */
}

/* === АКТИВНАЯ КНОПКА КАМЕРЫ (БЕЛАЯ) === */
/* Важно: перебиваем стили secondary */
.call-btn.btn-secondary.active {
    background: white !important;
    color: black !important;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

/* Кнопка записи */
#btn-record {
    transition: all 0.2s;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    overflow: hidden;
}
#btn-record.recording {
    transform: scale(1.2);
    color: var(--danger) !important;
    background: rgba(255, 59, 48, 0.1);
    border-radius: 50%;
}

/* Таймер записи */
#record-timer {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: white;
    padding: 5px 12px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 100;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}
/* --- СТИЛИ ДЛЯ АУДИО И ВИДЕО --- */
.msg-audio-custom {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-sidebar);
    border-radius: 18px;
    min-width: 220px;
    user-select: none; /* Чтобы не выделялось при кликах */
}
.own .msg-audio-custom {
    background: rgba(255,255,255, 0.2);
    color: white;
}

.audio-control-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    color: white;
    transition: 0.2s;
    z-index: 10; /* Поверх bubble */
}
.own .audio-control-btn {
    background: white;
    color: var(--primary);
}

.audio-track {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.audio-wave {
    height: 4px;
    width: 100%;
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    margin-bottom: 4px;
}
.own .audio-wave { background: rgba(255,255,255,0.3); }

.audio-progress {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.1s linear;
}
.own .audio-progress { background: white; }

.msg-video-circle {
    width: 195px !important;       /* Фиксированный размер */
    height: 190px !important;
    position: relative !important;
    border-radius: 50% !important;
    background: #000;
    cursor: pointer;
    flex-shrink: 0;
    margin: 2px; /* Небольшой отступ, чтобы кольцо не обрезалось */
}

.progress-ring {
    position: absolute !important;
    inset: -3px !important; /* Выступает на 3px за пределы видео */
    width: calc(100% + 6px) !important;
    height: calc(100% + 6px) !important;
    z-index: 10 !important;
    pointer-events: none;
    transform: rotate(-90deg);
}
.msg-content {
    word-break: break-word; /* Перенос длинных слов */
    overflow-wrap: break-word;
    white-space: pre-wrap;  /* Сохраняем переносы строк */
    max-width: 100%;
    display: block;
}
/* Стили для ссылок внутри сообщений */
.msg-content a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    font-weight: 500;
}
.msg-content a:hover {
    border-bottom-color: var(--primary);
}

/* Стили для форматирования */
.msg-content b { font-weight: 700; }
.msg-content i { font-style: italic; }
.msg-content s { text-decoration: line-through; opacity: 0.7; }
.msg-content code {
    background: rgba(0,0,0,0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}
/* Темная тема для кода */
[data-theme="dark"] .msg-content code {
    background: rgba(255,255,255,0.15);
}
.msg-quote {
    border-left: 3px solid var(--primary);
    background: rgba(128, 128, 128, 0.1); /* Легкий фон */
    padding: 6px 10px;
    border-radius: 0 4px 4px 0;
    margin: 4px 0;
    color: var(--text-sec);
    font-size: 0.95em;
}
/* Стили для кнопок внутри сообщений */
.msg-buttons button:hover {
    background: rgba(255,255,255,0.2) !important;
}
.msg-row.own .msg-buttons button {
    background: rgba(0,0,0,0.1) !important;
    border-color: rgba(0,0,0,0.1) !important;
}
.msg-row:not(.own) .msg-buttons button {
    background: var(--bg-secondary) !important;
    border-color: var(--border) !important;
    color: var(--text-main) !important;
}
.admin-badge {
            background: var(--primary);
            color: white;
            font-size: 9px;
            padding: 2px 6px;
            border-radius: 4px;
            margin-left: 6px;
            font-weight: 700;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            flex-shrink: 0;
            vertical-align: middle;
        }
code.copyable {
        background: rgba(0, 122, 255, 0.1);
        color: var(--primary);
        padding: 4px 8px;
        border-radius: 6px;
        font-family: monospace;
        cursor: pointer;
        transition: 0.2s;
        border: 1px dashed rgba(0, 122, 255, 0.3);
    }
    code.copyable:hover {
        background: rgba(0, 122, 255, 0.2);
        transform: scale(1.02);
    }
    code.copyable:active {
        transform: scale(0.98);
    }
.msg-buttons {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 8px;
}
.btn-row {
    display: flex;
    gap: 5px;
    width: 100%;
}
.bot-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.15); /* Прозрачный фон */
    color: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.1);
}
.bot-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}
.bot-btn:active {
    transform: scale(0.98);
}
/* Если кнопка-ссылка */
.bot-btn.link::after {
    content: ' ↗';
    font-size: 10px;
    opacity: 0.7;
}

/* Стили документации */
.badge-tech {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.code-block {
    background: #1c1c1e;
    color: #e5e5e7;
    padding: 16px;
    border-radius: 12px;
    position: relative;
    font-family: 'SF Mono', 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    overflow-x: auto;
    border: 1px solid rgba(255,255,255,0.1);
}

.code-block.small {
    padding: 12px;
    font-size: 12px;
}

.copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: 0.2s;
}
.copy-btn:hover { background: rgba(255,255,255,0.2); }

.api-method {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    background: var(--bg-secondary);
}

.method-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.method-verb {
    font-size: 11px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.method-verb.post { background: #34C759; color: white; }
.method-verb.get { background: #007AFF; color: white; }

.method-url {
    font-family: monospace;
    font-weight: 600;
    color: var(--text-main);
}

.method-desc {
    font-size: 13px;
    color: var(--text-sec);
    margin-bottom: 12px;
}

.params-table {
    font-size: 13px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 10px;
    border-left: 2px solid var(--border);
}

.param-name { font-family: monospace; color: var(--primary); font-weight: 600; }
.param-type { font-size: 11px; color: var(--text-sec); background: rgba(0,0,0,0.05); padding: 1px 4px; border-radius: 4px; margin-right: 6px; }
.cmd-link {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
}
.cmd-link:hover {
    text-decoration: underline;
}

/* Экран приветствия бота */
.bot-start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 30px;
    text-align: center;
    background: var(--bg-body);
}
.bot-start-img {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    margin-bottom: 20px;
    object-fit: cover;
    box-shadow: var(--glass-shadow);
}
.bot-start-title {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 10px;
}
.bot-start-desc {
    color: var(--text-sec);
    font-size: 15px;
    line-height: 1.5;
    max-width: 400px;
    margin-bottom: 30px;
    
    /* ЭТИ СТРОКИ ВАЖНЫ: */
    white-space: pre-wrap;       /* Сохраняет переносы строк */
    word-wrap: break-word;       /* Ломает длинные слова */
    overflow-wrap: break-word;   /* Современный аналог */
    word-break: break-word;
}
.btn-start-big {
    background: var(--primary);
    color: white;
    font-size: 16px;
    padding: 14px 40px;
    border-radius: 12px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}
.btn-start-big:hover { transform: scale(1.05); box-shadow: 0 5px 15px rgba(0,122,255,0.4); }

/* --- Sticky Date Dividers (Как в Telegram) --- */
.date-divider {
    position: sticky;
    top: 10px;
    z-index: 5;
    text-align: center;
    margin: 15px 0;
    pointer-events: none; /* Чтобы клик сквозь пустоту проходил */
}

.date-badge:active {
    transform: scale(0.95);
}

/* --- Исправленный Календарь (Apple Style) --- */
.calendar-container {
    width: 100%;
    padding: 10px;
}

.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.cal-title {
    font-weight: 600;
    font-size: 17px;
    text-transform: capitalize; /* Первая буква заглавная */
}

/* СЕТКА ДНЕЙ */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr); /* Ровно 7 колонок */
    gap: 8px; /* Расстояние между кружочками */
    justify-items: center; /* Центрирование в ячейке */
}

.cal-day-name {
    font-size: 13px;
    color: var(--text-sec);
    font-weight: 500;
    margin-bottom: 10px;
}

.cal-day {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s;
    color: var(--text-main);
}

.cal-day:hover {
    background: var(--bg-secondary);
}

.cal-day.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.cal-day.empty {
    cursor: default;
    background: transparent;
}

/* === СТИЛИ ДЛЯ КНОПОК БОТА (Вставь в <style>) === */

/* 1. Инлайн кнопки (внутри сообщения) */
.msg-buttons {
    display: flex; flex-direction: column; gap: 8px; margin-top: 10px; width: 100%;
}
.btn-row {
    display: flex; gap: 8px; width: 100%;
}
.bot-btn {
    flex: 1;
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary);
    border: 1px solid rgba(0, 122, 255, 0.2);
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.bot-btn:active { background: rgba(0, 122, 255, 0.2); transform: scale(0.98); }
.bot-btn.link { text-decoration: none; } /* Для ссылок */

/* 2. Нижнее меню (Reply Keyboard) */
#reply-keyboard-area {
    position: absolute; /* Фиксируем позицию */
    bottom: 85px;       /* Поднимаем НАД полем ввода (высота поля ~60px + отступ) */
    left: 0; 
    width: 100%;
    
    background: transparent; /* Прозрачный фон */
    padding: 0 10px;         /* Отступы по бокам */
    
    display: none;           /* Скрыто по умолчанию */
    flex-direction: column;
    gap: 6px;                /* Расстояние между рядами кнопок */
    
    z-index: 80;             /* Под полем ввода (z=100), но над сообщениями */
    
    /* Анимация выезда */
    transform-origin: bottom;
    animation: slideUpKey 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;    /* Чтобы клики сквозь пустые места проходили */
}

/* Когда меню активно */
#reply-keyboard-area.visible {
    display: flex;
}

/* Ряды кнопок */
.reply-row {
    display: flex;
    gap: 6px;
    width: 100%;
    pointer-events: auto; /* Включаем клики на кнопках */
}

/* Сами кнопки */
.reply-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.9); /* Более плотный белый */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    
    color: #000000;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    
    padding: 12px 10px;
    border: none;
    border-radius: 12px;
    
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Тень чтобы отделить от фона */
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-btn:active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 1);
}

/* Темная тема */
[data-theme="dark"] .reply-btn {
    background: rgba(50, 50, 50, 0.9);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* =========================================
   ONBOARDING 2.0 (Glass & Custom Icons)
   ========================================= */

#view-onboarding {
    position: fixed; inset: 0;
    background: #FFFFFF;
    z-index: 5000;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s ease;
}

@media (min-width: 768px) {
    #view-onboarding {
        background: rgba(242, 242, 247, 0.8);
        backdrop-filter: blur(20px);
    }
}

.onb-card {
    width: 100%; max-width: 440px;
    height: 100%;
    background: #fff;
    display: flex; flex-direction: column;
    padding: 40px 30px;
    overflow-y: auto;
    position: relative;
}

@media (min-width: 768px) {
    .onb-card {
        height: auto; min-height: 600px;
        border-radius: 32px;
        box-shadow: 0 40px 80px rgba(0,0,0,0.1), 0 10px 30px rgba(0,0,0,0.05);
        border: 1px solid rgba(0,0,0,0.05);
    }
}

/* Анимация шагов */
.onb-step {
    flex: 1;
    display: flex; flex-direction: column; align-items: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
    width: 100%;
}

.onb-logo-anim {
    margin-top: 60px;
    margin-bottom: 40px;
    animation: float 3s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.onb-logo-img { width: 120px; height: auto; }

.onb-title {
    font-size: 32px; font-weight: 800; color: #1c1c1e;
    text-align: center; margin-bottom: 15px; letter-spacing: -0.5px;
}

.onb-desc {
    font-size: 17px; color: #86868b; text-align: center;
    line-height: 1.5; max-width: 320px; margin-bottom: 40px;
}

/* Аватар */
.onb-avatar-preview {
    position: relative; width: 140px; height: 140px;
    margin-bottom: 30px;
}
#onb-user-avatar {
    width: 100%; height: 100%; border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: 4px solid #fff;
}
.onb-cam-icon {
    position: absolute; bottom: 5px; right: 5px;
    width: 44px; height: 44px;
    background: var(--primary);
    color: white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 3px solid #fff; cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.onb-cam-icon:active { transform: scale(0.9); }
.onb-cam-icon .icon { width: 20px; height: 20px; stroke-width: 2.5; stroke: white; fill: none; }

/* Пресеты */
.onb-presets-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 15px;
    margin-bottom: 30px; padding: 5px;
}
.onb-preset {
    width: 56px; height: 56px; border-radius: 50%;
    cursor: pointer; transition: all 0.2s;
    border: 2px solid transparent;
}
.onb-preset:hover { transform: scale(1.1); }
.onb-preset.selected {
    border-color: var(--primary);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

/* Формы */
.onb-input-group { width: 100%; margin-bottom: 15px; }
.onb-label {
    display: block; font-size: 13px; font-weight: 600; color: #86868b;
    margin-bottom: 6px; margin-left: 12px; text-transform: uppercase; letter-spacing: 0.5px;
}
.onb-input {
    background: #F2F2F7; border: none; border-radius: 16px;
    height: 56px; font-size: 17px; padding: 0 20px; color: #000;
    transition: all 0.2s;
}
.onb-input:focus { background: #e5e5ea; transform: translateY(-1px); }

/* Настройки (Apple List) */
.onb-settings {
    background: #F2F2F7; border-radius: 20px; overflow: hidden;
    margin: 0 10px; width: 100%;
}
.onb-settings .setting-row {
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 16px 20px; height: auto;
}
.onb-settings span { font-size: 16px; font-weight: 500; color: #1c1c1e; }

/* Иконка щита */
.onb-shield-icon {
    width: 100px; height: 100px;
    background: rgba(52, 199, 89, 0.1);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin-top: 40px; margin-bottom: 20px;
    color: #34C759;
}
.onb-shield-icon .icon { width: 50px; height: 50px; stroke-width: 1.5; }

/* Кнопки */
.onb-bottom { margin-top: auto; width: 100%; padding-top: 30px; display: flex; flex-direction: column; gap: 12px; }
.onb-btn {
    height: 56px; border-radius: 18px; font-size: 17px; font-weight: 600;
    box-shadow: 0 10px 20px rgba(0, 122, 255, 0.25);
    transition: transform 0.2s, box-shadow 0.2s;
}
.onb-btn:active { transform: scale(0.98); box-shadow: 0 5px 10px rgba(0, 122, 255, 0.2); }
.onb-btn-sec { color: var(--primary); font-size: 17px; height: 50px; }

/* Светлая тема принудительно */
#view-onboarding { color: #000; --text-main: #000; }

/* === АНИМАЦИЯ КНОПКИ ОТПРАВКИ (ACTION BUTTONS) === */

/* Контейнер, где кнопки лежат друг на друге */
.action-btn-container {
    width: 40px !important;
    height: 40px !important;
    margin-bottom: 0 !important;      /* Стоит ровно на одной линии с овалом */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px; /* Отступ от поля ввода */
}

/* Общий класс для анимируемых кнопок */
.btn-anim {
    position: absolute;
    inset: 0; /* Растянуть на весь контейнер */
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); /* Эффект пружины Apple */
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Состояние: ВИДИМО */
.btn-anim.visible {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    pointer-events: auto;
}

/* Состояние: СКРЫТО (Улетает и уменьшается) */
.btn-anim.hidden-state {
    opacity: 0;
    transform: scale(0.01) rotate(90deg);
    pointer-events: none;
}

/* Анимация иконок внутри кнопки записи (Микрофон <-> Видео) */
.icon-anim {
    transition: all 0.3s ease;
    position: absolute;
}

.icon-anim.hidden-icon {
    opacity: 0;
    transform: translateY(10px) scale(0.5);
}

.icon-anim.visible-icon {
    opacity: 1;
    transform: translateY(0) scale(1);
}
/* =========================================
   ZNAKORA STICKERS: CLEAN UI (FIXED)
   ========================================= */

/* 1. Окно выбора */
#sticker-picker {
    position: absolute;
    bottom: 80px; /* Чуть выше панели ввода */
    left: 10px;
    width: 350px; /* Оптимальная ширина */
    height: 420px;
    
    background: var(--glass-heavy); /* Эффект стекла */
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    
    display: flex;
    flex-direction: column;
    z-index: 2000;
    overflow: hidden;
    
    /* Анимация появления */
    transform-origin: bottom left;
    animation: stickerPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes stickerPop {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* 2. Поиск (Верхняя часть) */
.sticker-header {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
    flex-shrink: 0;
}

.sticker-search {
    width: 100%;
    height: 36px;
    background: rgba(120, 120, 128, 0.15); /* Apple Gray */
    border: none;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    color: var(--text-main);
    text-align: left;
    transition: 0.2s;
}
.sticker-search::placeholder { text-align: center; transition: 0.2s; }
.sticker-search:focus { background: rgba(120, 120, 128, 0.25); }
.sticker-search:focus::placeholder { opacity: 0; }

/* 3. Сетка стикеров (ИСПРАВЛЕНИЕ НАЛОЖЕНИЯ) */
.sticker-grid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px; /* Внутренний отступ от краев окна */
    
    display: grid;
    /* Умная сетка: минимум 75px на стикер */
    grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
    
    /* ГЛАВНОЕ: Отступы между стикерами */
    gap: 12px; 
    align-content: start;
}

/* Карточка стикера */
.sticker-item {
    aspect-ratio: 1 / 1; /* Всегда квадрат */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 12px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Убираем серый фон, чтобы стикеры выглядели "чище" */
    background: transparent; 
}

.sticker-item:hover {
    transform: scale(1.15); /* Увеличение при наведении */
    z-index: 10;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

.sticker-item:active { transform: scale(0.95); }

/* Картинка внутри стикера */
.sticker-item img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Картинка никогда не обрежется */
    pointer-events: none;
    padding: 2px; /* Небольшой отступ внутри, чтобы не прилипало к краям */
}

/* 4. Нижние вкладки (Категории) */
.sticker-tabs {
    height: 50px;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 0 10px;
    background: rgba(240, 240, 245, 0.6); /* Полупрозрачный фон */
    border-top: 1px solid rgba(128, 128, 128, 0.1);
    overflow-x: auto;
    flex-shrink: 0;
}
[data-theme="dark"] .sticker-tabs { background: rgba(30, 30, 30, 0.8); }

/* Скроллбар для вкладок (скрыть) */
.sticker-tabs::-webkit-scrollbar { display: none; }

.pack-tab {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    opacity: 0.5;
    transition: 0.2s;
    flex-shrink: 0;
}
.pack-tab:hover { opacity: 0.8; background: rgba(0,0,0,0.05); }
.pack-tab.active {
    opacity: 1;
    background: rgba(0, 122, 255, 0.15); /* Подсветка активного */
}
.pack-tab img, .pack-tab video {
    width: 24px; height: 24px; object-fit: contain;
}
.sticker-msg {
    /* Делаем стикеры меньше и фиксированного размера */
    width: 80px;
    height: 80px;
    
    /* Делаем их идеально круглыми */
    border-radius: 50%;
    
    /* Чтобы картинка заполнила круг и не исказилась */
    object-fit: cover; 
    
    display: block;
    
    /* Опционально: можно добавить легкую тень для объема */
    box-shadow: var(--shadow-sm);
}
.msg-sticker-mp4 {
    width: 125px !important;        /* Размер (сделайте меньше/больше по вкусу) */
    height: 125px !important;       /* Такой же как ширина */
    
    border-radius: 50% !important; /* Превращает квадрат в идеальный круг */
    
    object-fit: cover !important;  /* Картинка заполняет круг без искажений */
    display: block !important;
    
    /* Убираем любые черные рамки */
    background: transparent !important; 
    box-shadow: none !important;
}
/* Полоска-индикатор сверху меню (как в iOS) */
#sticker-picker::after {
    content: "";
    position: absolute;
    top: 8px; /* Отступ сверху */
    left: 50%;
    transform: translateX(-50%);
    width: 40px; /* Ширина полоски */
    height: 5px; /* Толщина */
    background: rgba(128, 128, 128, 0.4); /* Серый цвет */
    border-radius: 5px; /* Закругление */
    z-index: 2001;
    pointer-events: none; /* Чтобы сквозь неё можно было кликать */
}
/* Дополнительно: убираем фон у пузыря вокруг стикера */
.bubble.is-sticker {
    background: transparent !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
}
.msg-video-round {
    position: relative;
    width: 240px;       /* Размер кружочка */
    height: 240px;
    border-radius: 50%;
    overflow: hidden;   /* Обрезаем под круг */
    background: #000;
    cursor: pointer;
    flex-shrink: 0;
    transform: translateZ(0); /* Фикс для Safari */
}

/* Само видео */
.msg-video-round video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* SVG Кольцо прогресса */
.progress-ring-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg); /* Чтобы начиналось сверху */
    pointer-events: none;
    z-index: 10;
}

.ring-circle {
    fill: none;
    stroke: #34C759; /* Зеленый (или var(--primary) для синего) */
    stroke-width: 4;
    stroke-linecap: round;
    /* Длина окружности для R=118 (240/2 - 2px рамки): 2 * pi * 118 ≈ 741 */
    stroke-dasharray: 741;
    stroke-dashoffset: 741; /* Скрыто в начале */
    transition: stroke-dashoffset 0.1s linear;
}

/* Кнопка Play/Replay по центру */
.vid-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.2s;
}

/* Показываем кнопку, когда видео на паузе или закончилось */
.msg-video-round.paused .vid-overlay {
    opacity: 1;
}

.vid-play-icon {
    width: 50px;
    height: 50px;
    fill: white;
    filter: drop-shadow(0 2px 5px rgba(0,0,0,0.5));
}
.sticker-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-sec); /* Серый цвет текста */
    margin-top: 8px;        /* Отступ от поиска */
    margin-left: 4px;       /* Небольшой отступ слева */
    text-transform: uppercase; /* Делаем заглавными (как в iOS) */
    letter-spacing: 0.5px;
    opacity: 0.8;
}
#msg-input:focus {
    outline: none !important;
    box-shadow: none !important;
}
/* === АДАПТАЦИЯ ПОД МОБИЛЬНЫЕ (ФИКС) === */
@media (max-width: 768px) {
    #sticker-picker {
        width: 100%; /* На всю ширину */
        left: 0;
        bottom: 65px; 
        height: 45vh; /* Пол-экрана */
        border-radius: 24px; /* Закруглить только верх */
        border: none;
        border-top: 1px solid var(--glass-border);
        box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
    }
    
    /* Увеличиваем размер стикеров для пальцев */
    .sticker-grid {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 8px;
    }
    
    /* Сдвигаем поиск чуть ниже, чтобы было удобнее тянуться */
    .sticker-header { padding: 16px; }
}
/* =========================================
   FIX FULL SCREEN MENU (MOBILE) - FINAL
   ========================================= */

@media (max-width: 768px) {
    /* 1. Настройки подложки */
    #modal-menu.modal-overlay {
        padding: 0 !important;
        align-items: flex-start !important; /* Прижимаем к верху */
        background: var(--bg-body) !important;
        z-index: 9999 !important;
    }

    /* 2. Настройки самого окна */
    /* Мы используем селектор #modal-menu .modal, чтобы сработало наверняка */
    #modal-menu .modal,
    #modal-menu .modal-fs {
        width: 100vw !important;        /* 100% ширины вьюпорта */
        height: 100vh !important;       /* 100% высоты вьюпорта */
        min-height: 100vh !important;
        max-width: none !important;
        max-height: none !important;    /* Снимаем любые ограничения */
        
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        
        background: var(--bg-body) !important;
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;     /* Фиксируем, чтобы не убегало */
        top: 0 !important;
        left: 0 !important;
    }

    /* 3. Исправление контейнера скролла (убираем дырку снизу) */
    #profile-scroll {
        flex: 1 !important;
        height: auto !important;
        overflow-y: auto !important;
        padding-bottom: 0 !important;   /* Убираем отступ снизу */
        margin-bottom: 0 !important;
    }
}
/* =========================================
   PC MENU FIX (BEAUTIFUL ROUNDED UI)
   ========================================= */

@media (min-width: 769px) {
    /* 1. Настраиваем подложку (затемнение) */
    #modal-menu.modal-overlay {
        background: rgba(0, 0, 0, 0.4) !important; /* Затемнение фона */
        align-items: center !important; /* Центрирование по вертикали */
        justify-content: center !important; /* Центрирование по горизонтали */
        padding: 0 !important;
        backdrop-filter: blur(5px) !important;
    }

    /* 2. Превращаем окно в красивую карточку */
    #modal-menu .modal,
    #modal-menu .modal-fs {
        width: 360px !important;        /* Фиксированная ширина */
        height: auto !important;        /* Высота по содержимому */
        min-height: auto !important;
        max-height: 85vh !important;    /* Не выше 85% экрана */
        
        position: relative !important;  /* Сбрасываем fixed */
        top: auto !important;
        left: auto !important;
        margin: 0 !important;
        
        border-radius: 24px !important; /* СИЛЬНОЕ СКРУГЛЕНИЕ */
        overflow: hidden !important;    /* Обрезаем контент по краям */
        
        box-shadow: 0 20px 60px rgba(0,0,0,0.3) !important; /* Глубокая тень */
        border: 1px solid rgba(255,255,255,0.2) !important; /* Тонкая рамка */
        background: var(--glass-heavy) !important;
        
        display: flex !important;
        flex-direction: column !important;
    }

    /* 3. Убираем видимый скроллбар (он портит скругление), но скролл работает */
    #profile-scroll::-webkit-scrollbar {
        width: 0 !important;
        background: transparent !important;
    }
    
    /* 4. Отступ снизу внутри списка, чтобы было красиво */
    #modal-menu .settings-list {
        padding-bottom: 20px !important;
    }
    
    /* Коррекция высоты шапки */
    #modal-menu .modal > div:first-child {
        flex-shrink: 0;
    }
}

/* === СТИЛИ НОВОГО ДИЗАЙНА (iOS Style) === */
.settings-modal-bg {
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Шапка меню */
.menu-header-card {
    position: relative;
    padding: 30px 20px 20px 20px;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.menu-avatar-large {
    width: 80px; height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border: 2px solid var(--surface);
}

.menu-name-text {
    font-size: 20px; font-weight: 700;
    color: var(--text-main); margin-bottom: 2px;
}

.menu-handle-text {
    font-size: 14px; font-weight: 500;
    color: var(--primary);
    background: rgba(0, 122, 255, 0.1);
    padding: 4px 10px; border-radius: 12px;
}

/* Группы настроек */
.settings-group-ios {
    background: var(--surface);
    border-radius: 12px;
    margin: 0 16px 24px 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.settings-row-ios {
    display: flex; align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer; text-decoration: none;
    color: var(--text-main); transition: background 0.2s;
}
.settings-row-ios:last-child { border-bottom: none; }
.settings-row-ios:active { background: var(--bg-secondary); }

/* Иконки в квадратиках */
.ios-icon-box {
    width: 30px; height: 30px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    margin-right: 12px;
    color: white; font-size: 16px;
}

/* Заголовки секций */
.ios-section-header {
    margin: 0 16px 8px 32px;
    font-size: 12px; text-transform: uppercase;
    color: var(--text-sec); font-weight: 600;
    letter-spacing: 0.5px;
}

/* Кнопка назад */
.ios-nav-header {
    padding: 12px 16px;
    display: flex; align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

/* Поля ввода (iOS стиль) */
.ios-input-group {
    background: var(--surface);
    margin: 0 16px 24px 16px;
    border-radius: 12px; overflow: hidden;
}
.ios-input-row {
    display: flex; align-items: center;
    padding: 0 16px; height: 50px;
    border-bottom: 1px solid var(--border);
}
.ios-input-row:last-child { border-bottom: none; }
.ios-input-label { width: 130px; font-weight: 500; color: var(--text-main); }
.ios-input {
    flex: 1; border: none; background: transparent;
    text-align: right; outline: none;
    color: var(--primary); font-size: 15px;
}

/* Контейнер клавиатуры (теперь сидит НАД полем ввода, а не перекрывает его) */

@keyframes slideUpKey {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Показываем, только когда есть класс visible */
#reply-keyboard-area.visible {
    display: flex;
}

/* Ряд кнопок */
.reply-row {
    display: flex;
    gap: 6px; /* Расстояние между кнопками */
    width: 100%;
}

/* Сами кнопки (Дизайн Telegram) */
.reply-btn {
    flex: 1; /* Растягиваются равномерно */
    background: rgba(255, 255, 255, 0.85); /* Полупрозрачный белый */
    backdrop-filter: blur(10px); /* Блюр фона */
    -webkit-backdrop-filter: blur(10px);
    
    color: #000000;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    
    padding: 10px 12px; /* Высота кнопки */
    border: none;
    border-radius: 8px; /* Скругление как в ТГ */
    
    /* Легкая тень */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    
    cursor: pointer;
    transition: all 0.1s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Темная тема для кнопок */
[data-theme="dark"] .reply-btn {
    background: rgba(44, 44, 46, 0.85);
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Эффект нажатия */
.reply-btn:active {
    opacity: 0.7;
    transform: scale(0.98);
}

/* Иконка переключения клавиатуры (четыре квадратика) */
/* Гарантированное скрытие для кнопки клавиатуры */
#btn-toggle-kb.hidden {
    display: none !important;
}

/* Стили самой кнопки (чтобы было красиво, как просил) */
#btn-toggle-kb {
    width: 38px !important;
    height: 38px !important;
    border-radius: 10px !important; /* Скругленные края как в ТГ */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    color: var(--text-sec);
    margin-left: 4px !important;
}

#btn-toggle-kb:active {
    transform: scale(0.9);
}

#btn-toggle-kb.active {
    color: var(--primary) !important;
    background: rgba(0, 122, 255, 0.1);
}
/* Панель ответа/пересылки над полем ввода */
#fwd-indicator {
    position: absolute;
    /* Поле ввода .input-area имеет bottom: 12px и высоту ~50px. Ставим 62px, чтобы прилипло сверху */
    bottom: 75px; 
    left: 20px;
    right: 20px;
    
    background: var(--glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    
    border: 1px solid var(--glass-border);
    border-bottom: none; 
    border-radius: 15px; /* Закругляем только верх */
    
    display: flex;
    align-items: center;
    padding: 8px 15px;
    gap: 12px;
    z-index: 90; /* Должно быть чуть меньше, чем у .input-area (100), но выше сообщений */
    animation: slideUp 0.2s ease-out;
}

#fwd-indicator.hidden {
    display: none !important;
}

/* Вертикальная синяя линия (дизайн Telegram) */
.fwd-line {
    width: 3px;
    height: 32px;
    background: var(--primary);
    border-radius: 2px;
    flex-shrink: 0;
}

.fwd-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.fwd-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1px;
}

.fwd-preview {
    font-size: 12px;
    color: var(--text-sec);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fwd-close-btn {
    background: transparent !important;
    border: none !important;
    padding: 4px !important;
    cursor: pointer;
    color: var(--text-sec);
    opacity: 0.6;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fwd-close-btn:hover {
    opacity: 1;
}

.fwd-close-btn .icon {
    width: 20px !important;
    height: 20px !important;
}
#pinned-list-dropdown {
    position: absolute !important;
    top: 132px !important; /* Отступ под плашкой */
    left: 10px !important;
    right: 10px !important;
    z-index: 2000 !important;

    background: var(--glass-heavy) !important;
    backdrop-filter: blur(25px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(25px) saturate(180%) !important;
    
    border: 1px solid var(--glass-border) !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1) !important;
    
    max-height: 50vh !important;
    overflow-y: auto !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
}

/* Красивые пункты внутри списка */
#pinned-list-dropdown .list-item {
    background: transparent !important;
    border-radius: 0 !important;
    margin: 0 !important;
    border-bottom: 1px solid rgba(128, 128, 128, 0.15) !important; 
    padding: 12px 16px !important;
    transition: background 0.2s;
    align-items: flex-start !important; /* Выравнивание по верху */
}

#pinned-list-dropdown .list-item:first-child {
    border-top-left-radius: 20px !important;
    border-top-right-radius: 20px !important;
}

#pinned-list-dropdown .list-item:last-child {
    border-bottom: none !important;
}

#pinned-list-dropdown .list-item:active {
    background: rgba(0, 0, 0, 0.05) !important;
}

/* Скрываем полосу прокрутки для красоты */
#pinned-list-dropdown::-webkit-scrollbar {
    display: none;
}

/* Анимация выпадания */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
/* --- СТИЛИ ДЛЯ МИНИ-МЕДИА В ЗАКРЕПЕ --- */
.pin-media-preview {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    margin-right: 10px;
    background: #000;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.1);
}

.pin-media-preview.circle {
    border-radius: 50%; /* Для кружочков */
}

.pin-text-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.pin-msg-title {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text-main) !important; /* Черный текст вместо синего, как на Скрине 2 */
    margin-bottom: 4px !important;
    line-height: 1.3 !important;
}

.pin-msg-body {
    font-size: 12px !important;
    color: var(--text-sec) !important; /* Серый текст снизу */
    opacity: 0.8 !important;
}

.btn-unpin-list {
    opacity: 0.6;
    transition: opacity 0.2s;
}
.btn-unpin-list:hover { opacity: 1; }
@media (max-width: 768px) {
    /* 1. По умолчанию скрываем строку поиска на мобильных (вкладка Чаты) */
    .sidebar .search-container {
        display: none;
    }

    /* 2. Когда активна вкладка "Поиск" (добавляем класс search-active на sidebar) */
    .sidebar.search-active .search-container {
        display: block !important;
        margin-top: 10px;
    }

    /* Скрываем списки чатов и контактов, когда включен поиск */
    .sidebar.search-active #list-chats,
    .sidebar.search-active #list-contacts {
        display: none !important;
    }

    /* Показываем результаты поиска принудительно */
    .sidebar.search-active #list-search {
        display: block !important;
        padding-top: 10px;
    }
    
    /* Если результатов нет, показываем пустой блок, чтобы не было пустоты */
    .sidebar.search-active #list-search:empty::before {
        content: 'Введите запрос для поиска...';
        display: block;
        text-align: center;
        color: var(--text-sec);
        margin-top: 40px;
        font-size: 14px;
    }
}

/* === STORY CREATOR (FIXED) === */
.story-screen {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    background: #000; overflow: hidden; z-index: 5001;
}

#story-video-preview {
    width: 100%; height: 100%; object-fit: cover;
}

/* Камера (Низ) */
.story-cam-controls {
    position: absolute; bottom: 40px; left: 0; right: 0;
    display: flex; justify-content: space-around; align-items: center;
    padding: 0 20px; z-index: 10;
}

.shutter-outer {
    width: 72px; height: 72px; 
    border: 4px solid white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; transition: transform 0.1s;
}
.shutter-outer:active { transform: scale(0.95); }

.shutter-inner {
    width: 60px; height: 60px; background: white; border-radius: 50%;
}

.btn-cam-icon {
    width: 44px; height: 44px; border-radius: 50%;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    color: white; cursor: pointer; transition: 0.2s;
}
.btn-cam-icon:active { transform: scale(0.9); background: rgba(255,255,255,0.2); }
.btn-cam-icon svg { width: 24px; height: 24px; stroke-width: 2; }

/* Редактор (Верх) */
.story-editor-tools.header {
    position: absolute; top: 0; left: 0; right: 0;
    padding: 20px; display: flex; justify-content: space-between;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
    z-index: 20;
}

/* Редактор (Низ) */
.story-editor-tools.footer {
    position: absolute; bottom: 0; left: 0; right: 0;
    padding: 20px; display: flex; flex-direction: column; gap: 15px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    z-index: 20;
}

/* Поле ввода описания */
.story-desc-row {
    display: flex; gap: 10px; align-items: center; width: 100%;
}
.story-desc-input {
    flex: 1; background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px; padding: 12px 15px; color: white; 
    backdrop-filter: blur(10px); outline: none;
}
.story-desc-input::placeholder { color: rgba(255,255,255,0.7); }

.btn-publish {
    background: #007AFF; color: white; border: none; 
    width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(0,122,255,0.4);
}

/* Ползунок размера */
.size-slider-container {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 0 20px; opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.size-slider-container.active { opacity: 1; pointer-events: auto; }

input[type=range].story-slider {
    -webkit-appearance: none; width: 100%; background: transparent;
}
input[type=range].story-slider::-webkit-slider-thumb {
    -webkit-appearance: none; height: 20px; width: 20px;
    border-radius: 50%; background: #ffffff; cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5); margin-top: -8px;
}
input[type=range].story-slider::-webkit-slider-runnable-track {
    width: 100%; height: 4px; background: rgba(255,255,255,0.3); border-radius: 2px;
}

/* КОРЗИНА ДЛЯ УДАЛЕНИЯ */
.story-trash-zone {
    position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(20px);
    width: 60px; height: 60px; border-radius: 50%;
    background: rgba(255, 59, 48, 0.8); display: flex; align-items: center; justify-content: center;
    color: white; opacity: 0; transition: 0.2s; pointer-events: none; z-index: 15;
}
.story-trash-zone.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.story-trash-zone.hovered { transform: translateX(-50%) scale(1.2); background: #FF3B30; }

/* Элементы на холсте */
.story-overlay-item {
    position: absolute; cursor: grab; user-select: none;
    color: white; font-weight: bold; text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    padding: 5px; text-align: center; white-space: nowrap;
    touch-action: none; /* Важно для мобильных */
}
.story-overlay-item:active { cursor: grabbing; opacity: 0.8; }

/* === STORIES UI === */
.stories-rail {
    display: flex;
    gap: 12px;
    /* Было padding: 15px. Меняем на: Верх 5px, Право 15px, Низ 15px, Лево 15px */
    padding: 5px 15px 15px 15px; 
    overflow-x: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    scrollbar-width: none; 
}
.stories-rail::-webkit-scrollbar { display: none; } /* Chrome */

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    min-width: 70px;
}

.story-ring {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    padding: 2px;
    position: relative;
    /* Градиент для новых историй (Znakora Blue + Purple) */
    background: linear-gradient(45deg, #007AFF, #5856D6, #AF52DE);
    transition: transform 0.2s;
}

.story-ring.seen {
    background: #E5E5EA; /* Серый для просмотренных */
}
/* Моя история (создать) */
.story-ring.create {
    background: transparent;
    border: 2px dashed #C7C7CC;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid var(--surface); /* Отступ от кольца */
    object-fit: cover;
    background: white;
}

.story-plus {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--primary);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid var(--surface);
}

.story-name {
    font-size: 11px;
    margin-top: 4px;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-main);
}

/* === STORY VIEWER (Полноэкранный плеер) === */
.story-viewer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important; /* fallback */
    height: 100dvh !important; /* dynamic viewport height для мобилок */
    background: #000 !important;
    z-index: 20000 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.story-progress-bar {
    display: flex;
    gap: 4px;
    padding: 10px 5px;
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 20002;
}

.progress-segment {
    flex: 1;
    height: 2px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: white;
    width: 0%;
}

.story-header {
    position: absolute;
    top: 25px; left: 15px; right: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20002;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.story-media-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.story-media {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Чтобы картинка целиком влезала */
}
.story-desc-view {
    position: absolute;
    bottom: 80px; /* Чуть выше кнопок лайка */
    left: 0;
    right: 0;
    text-align: center;
    color: white;
    padding: 10px 20px;
    font-size: 16px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8); /* Тень чтобы читать на белом */
    z-index: 20003;
    pointer-events: none; /* Чтобы сквозь текст можно было тыкать */
    white-space: pre-wrap; /* Сохранять переносы строк */
}
/* Зоны клика для навигации */
.story-nav {
    position: absolute;
    top: 0; bottom: 0;
    z-index: 20001;
}
.nav-left { left: 0; width: 30%; }
.nav-right { right: 0; width: 70%; } /* Основная зона - вперед */

/* === UI ИСТОРИЙ (КНОПКИ И МЕНЮ) === */

/* Кнопки действий в просмотре истории (Лайк, Шер) */
.story-actions-container {
    position: absolute;
    bottom: 20px;
    right: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 20005; /* Поверх медиа */
}

.story-btn-round {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important; /* Чтобы не сжимало */
    border-radius: 50% !important;
    
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    
    color: white;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    padding: 0 !important; /* Убираем отступы */
    margin: 0 !important;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transition: transform 0.2s, background 0.2s;
}
.story-btn-round:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.4);
}
.story-btn-round svg, 
.story-btn-round .icon {
    width: 24px !important;
    height: 24px !important;
    display: block !important;
    stroke-width: 2px !important;
    fill: none !important; /* Важно для SVG */
}
.story-btn-round.liked svg {
    fill: #FF3B30 !important;
    stroke: none !important;
}

.story-btn-round:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.4);
}
/* Активный лайк (Красное сердце) */
.story-btn-round.liked {
    background: rgba(255, 255, 255, 0.9);
    color: #FF3B30;
    border-color: white;
    box-shadow: 0 0 15px rgba(255, 59, 48, 0.4);
}

.story-btn-round svg {
    width: 24px;
    height: 24px;
    stroke-width: 2;
}

/* Статистика просмотров (Глазик) для своих историй */
.story-viewer-stats {
    position: absolute;
    bottom: 25px;
    left: 20px;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 20005;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
}

/* === КАРТОЧКА ИСТОРИИ В ЧАТЕ === */
.shared-story-card {
    display: flex;
    align-items: center;
    background: rgba(0, 122, 255, 0.08); /* Легкий синий фон */
    border: 1px solid rgba(0, 122, 255, 0.15);
    border-radius: 14px;
    padding: 10px 12px;
    margin-top: 6px;
    cursor: pointer;
    max-width: 280px;
    transition: background 0.2s;
    user-select: none;
}

.shared-story-card:active {
    background: rgba(0, 122, 255, 0.15);
}

.shared-story-icon {
    width: 42px; 
    height: 42px;
    border-radius: 50%;
    /* Градиент как у сторис */
    background: linear-gradient(45deg, #007AFF, #AF52DE); 
    padding: 2px;
    margin-right: 12px;
    flex-shrink: 0;
}

.shared-story-inner {
    width: 100%; 
    height: 100%;
    border-radius: 50%;
    background: var(--bg-body); /* Цвет фона подстраивается под тему */
    display: flex; 
    align-items: center; 
    justify-content: center;
}

.story-card-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
    margin-bottom: 2px;
}

.story-card-sub {
    font-size: 11px;
    color: var(--text-sec);
}
/* === МЕНЮ ПОДЕЛИТЬСЯ (SHARE SHEET) === */
.share-top-actions {
    display: flex;
    gap: 12px;
    padding: 0 16px 15px;
    border-bottom: 1px solid rgba(128,128,128,0.1);
    margin-bottom: 10px;
}

.share-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(120, 120, 128, 0.08); /* Легкий серый фон */
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
    color: var(--primary);
}

.share-action-btn:active {
    transform: scale(0.96);
    background: rgba(120, 120, 128, 0.15);
}

.share-btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.share-btn-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-main);
}
/* === СТИЛИ ДЛЯ ЗАКРЕПЛЕННЫХ ЧАТОВ === */
.chat-item.pinned {
    background: linear-gradient(90deg, rgba(54, 151, 255, 0.08) 0%, rgba(54, 151, 255, 0.02) 100%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

/* Исправляем цвет имени: всегда берем переменную темы, игнорируем наследование */
.chat-item.pinned .chat-item-name {
    color: var(--text-main) !important; 
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Исправляем цвет сообщения */
.chat-item.pinned .chat-item-msg {
    color: var(--text-sec) !important;
}

/* Кастомная иконка закрепа (Скрепка/Пин) */
.pin-icon-custom {
    width: 14px;
    height: 14px;
    color: var(--primary); /* Синий цвет скрепки */
    transform: rotate(45deg); /* Стильный наклон */
    filter: drop-shadow(0 2px 3px rgba(54, 151, 255, 0.4)); /* Тень для иконки */
    flex-shrink: 0;
}
/* КАСТОМНАЯ ИКОНКА ЗАКРЕПА (SVG) */
.pin-icon-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pin-icon-svg {
    width: 14px;
    height: 14px;
    fill: var(--primary); /* Синий цвет для закрепа */
    transform: rotate(45deg);
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.1));
}

/* === ФИКС ДЕФФЕКТА ВЫХОДА ИЗ ЧАТА (СКРИН 3) === */
@media (max-width: 768px) {
    .chat-area {
        position: fixed; /* На мобильных чат поверх всего */
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: var(--bg-body);
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
        z-index: 1000;
        visibility: hidden; /* Прячем, когда не активен */
    }

    .chat-area.active {
        transform: translateX(0);
        visibility: visible;
    }
    
    .sidebar {
        width: 100%;
        background: var(--bg-body); /* Важно иметь фон, чтобы не было дырок */
    }
}
/* Темная тема: корректировка фона закрепа */
@media (prefers-color-scheme: dark) {
    .chat-item.pinned {
        background: linear-gradient(90deg, rgba(54, 151, 255, 0.15) 0%, rgba(54, 151, 255, 0.05) 100%);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
}
/* ИНТЕРАКТИВНЫЕ ЭЛЕМЕНТЫ ЧАТА */
.interactive-code {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary);
    font-family: monospace;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px dashed rgba(0, 122, 255, 0.3);
    transition: background 0.2s;
}
.interactive-code:active { background: rgba(0, 122, 255, 0.2); }

.interactive-link {
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
}
.interactive-link:hover { text-decoration: underline; }
.interactive-link.cmd { color: #5856D6; } /* Фиолетовый для команд */

.safe-link {
    color: var(--primary);
    text-decoration: underline;
    word-break: break-all;
}
#story-edit-video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* важно для сторис 9:16 */
    background: #000;
}
@media (max-width: 768px) {
    
    /* 1. Сжимаем шапку с логотипом */
    .sidebar-header {
        height: 70px !important; /* Уменьшаем общую высоту (было 70px) */
        padding: 10px 16px 0 16px !important; /* Убираем отступ снизу */
        align-items: flex-start !important; /* Прижимаем логотип к верху, если нужно */
    }

    /* 2. Немного уменьшаем сам логотип, чтобы он смотрелся аккуратно */
    .sidebar-header .logo-img {
        height: 32px !important; /* Оптимальный размер для мобильных */
        margin-top: 5px; /* Чуть опускаем визуально */
    }

    /* 3. Поднимаем блок историй вверх */
    .stories-rail {
        padding-top: 0px !important; /* Полностью убираем верхний отступ */
        padding-bottom: 10px !important;
        margin-top: 0px !important;
    }
}
/* === ИКОНКИ В ПРЕВЬЮ ЧАТА (Вместо текста) === */
.prev-icon {
    /* Жесткие размеры, чтобы не растягивало */
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    
    /* Выравнивание по тексту */
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
    margin-top: -3px; /* Чуть поднять для идеального центра */
    
    /* УБИРАЕМ ЧЕРНУЮ ЗАЛИВКУ (ГЛАВНЫЙ ФИКС) */
    fill: none !important;
    
    /* Цвет линий - берем из переменной темы (Серый) */
    stroke: var(--text-sec);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    
    /* Прозрачность для мягкости */
    opacity: 0.9;
    transition: stroke 0.2s, opacity 0.2s;
}

/* 2. Стиль при наведении на чат */
.list-item:hover .prev-icon {
    opacity: 1;
    stroke: var(--primary); /* Синеют при наведении */
}

/* 3. Стиль АКТИВНОГО чата (на синем фоне) */
.list-item.active .prev-icon {
    stroke: rgba(255, 255, 255, 0.9) !important; /* Становятся белыми */
    opacity: 1;
}

/* 4. ТЕМНАЯ ТЕМА (Автоматически подхватит var(--text-sec), но можно усилить) */
[data-theme="dark"] .prev-icon {
    stroke: #98989F; /* Светло-серый для темной темы */
}

/* 5. МОБИЛЬНАЯ АДАПТАЦИЯ (Чтобы не съезжало) */
@media (max-width: 768px) {
    .prev-icon {
        width: 14px !important; /* Чуть меньше на телефоне */
        height: 14px !important;
        margin-top: -2px;
    }
}

.msg-row .bubble:has(.msg-sticker-mp4),
.msg-row .bubble:has(.msg-video-circle),
.msg-row .bubble.is-sticker {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* 2. ВРЕМЯ И ГАЛОЧКИ ПОВЕРХ КРУЖОЧКА/СТИКЕРА */
/* Делаем полупрозрачную подложку, чтобы время читалось */
.msg-row .bubble:has(.msg-sticker-mp4) .meta,
.msg-row .bubble:has(.msg-video-circle) .meta,
.msg-row .bubble.is-sticker .meta {
    position: absolute;
    bottom: 10px;
    right: 15px;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 8px;
    border-radius: 12px;
    
    /* Текст всегда белый */
    color: white !important;
    font-size: 11px;
    font-weight: 500;
    
    margin: 0;
    z-index: 20;
    pointer-events: none; /* Чтобы клики проходили сквозь время */
}

/* Галочки внутри подложки тоже белые */
.msg-row .bubble:has(.msg-sticker-mp4) .tick-icon,
.msg-row .bubble:has(.msg-video-circle) .tick-icon,
.msg-row .bubble.is-sticker .tick-icon {
    color: white !important;
    stroke: white !important;
}
.msg-row.own .interactive-link, 
.msg-row.own .msg-content span[data-action="command"],
.msg-row.own a,
.msg-row.own .safe-link {
    color: #ffffff !important;      /* Белый цвет текста */
    text-decoration: underline;
    opacity: 1;
    
    /* ГЛАВНЫЕ СВОЙСТВА ДЛЯ РАБОТЫ КЛИКА: */
    pointer-events: auto !important; /* Разрешаем клик */
    position: relative !important;   /* Включаем позиционирование */
    z-index: 10 !important;          /* Поднимаем над слоем сообщения */
    cursor: pointer !important;      /* Курсор руки */
}
.msg-row:not(.own) .safe-link,
.msg-row:not(.own) .interactive-link,
.msg-row:not(.own) .msg-content a {
    color: var(--primary) !important;
    pointer-events: auto;
    position: relative;
    z-index: 5;
}
.msg-row.own .interactive-code {
    color: #ffffff !important;
    background: rgba(255,255,255,0.2) !important;
    border-color: rgba(255,255,255,0.3) !important;
}
/* ==================================================================
   APPLE STYLE FIX ДЛЯ ОКОШКА ССЫЛОК (#smart-link-handler)
   ================================================================== */

/* 1. Фон затенения (Оверлей) - ставим твою картинку */
#smart-link-handler.modal-overlay {
    background: url('/public/images/link.png') no-repeat center center !important;
    background-size: cover !important;
    /* Добавляем размытие заднего плана для эффекта глубины */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

/* 2. Само окошко (Контент) - Эффект "Матовое стекло" (Frosted Glass) */
#smart-link-handler .modal-content {
    /* Полупрозрачный белый фон + сильное размытие */
    background: rgba(255, 255, 255, 0.75) !important;
    backdrop-filter: blur(30px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(30px) saturate(180%);

    /* Тонкая светлая граница и мягкая тень */
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;

    /* Цвет текста внутри всегда черный для контраста */
    color: #000000 !important;
    border-radius: 24px !important;
}

/* 3. Кнопка закрытия (Крестик) - в стиле iOS (серый кружок) */
#smart-link-handler .modal-close {
    width: 30px !important;
    height: 30px !important;
    background: rgba(118, 118, 128, 0.12) !important; /* Серый фон */
    border-radius: 50% !important;
    top: 12px !important;
    right: 12px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Сам крестик внутри кружка */
#smart-link-handler .modal-close::before,
#smart-link-handler .modal-close::after {
    background-color: #8E8E93 !important; /* Серый цвет линий */
    height: 2px !important;
    width: 14px !important;
    top: auto !important; /* Сброс старых стилей */
    left: auto !important;
}

/* 4. Основная кнопка действия - стиль iOS */
#smart-link-handler .primary-btn {
    background: #007AFF !important; /* Apple Blue */
    border-radius: 14px !important;
    font-weight: 600 !important;
    font-size: 17px !important;
    padding: 12px !important;
    width: 100%;
    margin-top: 15px;
    box-shadow: none !important;
}
/* ==================================================================
   ДИЗАЙН ДЛЯ ПЕРЕХОДА ПО ССЫЛКЕ (Через существующую модалку)
   ================================================================== */

/* Когда у модалки есть класс .link-mode, меняем фон на картинку */
#modal-custom-alert.link-mode {
    background: url('/public/images/link.png') no-repeat center center fixed !important;
    background-size: cover !important;
    backdrop-filter: blur(5px); /* Легкое размытие самой картинки */
}

/* Затемнение поверх картинки */
#modal-custom-alert.link-mode::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3); /* Легкая тень */
    z-index: -1;
}

/* Стилизуем само окошко внутри, когда активен режим ссылки */
#modal-custom-alert.link-mode .custom-alert-box {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.5) !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2) !important;
    color: black !important;
    border-radius: 24px !important;
}

/* Заголовки и текст внутри */
#modal-custom-alert.link-mode .alert-title { color: #000 !important; font-size: 20px !important; }
#modal-custom-alert.link-mode .alert-msg { color: #333 !important; font-size: 14px !important; }

/* Кнопки */
#modal-custom-alert.link-mode .alert-btn.primary {
    background: #007AFF !important;
    border-radius: 12px !important;
}
#modal-custom-alert.link-mode .alert-btn.cancel {
    background: rgba(0,0,0,0.05) !important;
    color: #007AFF !important;
    border-radius: 12px !important;
}

/* Темная тема */
[data-theme="dark"] #modal-custom-alert.link-mode .custom-alert-box {
    background: rgba(40, 40, 40, 0.85) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}
[data-theme="dark"] #modal-custom-alert.link-mode .alert-title { color: white !important; }
[data-theme="dark"] #modal-custom-alert.link-mode .alert-msg { color: #ccc !important; }
/* --- НОВЫЕ СТИЛИ ДЛЯ SVG --- */
.reaction-svg {
    width: 28px; /* Чуть больше для четкости */
    height: 28px;
    display: block;
    pointer-events: none;
    overflow: visible; /* ГЛАВНОЕ: Запрещаем обрезать края */
    filter: drop-shadow(0px 2px 3px rgba(0,0,0,0.15)); /* Мягкая тень для объема */
}

/* В списке выбора (пикере) */
.emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px; /* Больше места для пальца */
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.emoji-item:hover { transform: scale(1.15); }
.emoji-item .reaction-svg { width: 34px; height: 34px; }

/* Внутри чипсов (под сообщением) */
.reaction-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px; /* Чуть просторнее */
    border-radius: 16px; /* Более округлые */
    margin-right: 4px;
    margin-bottom: 4px;
    border: 1px solid transparent; /* Чтобы не скакало при активном */
}
.reaction-chip.active {
    background: rgba(0, 122, 255, 0.1);
    border-color: rgba(0, 122, 255, 0.3);
}
.reaction-chip .reaction-svg { width: 20px; height: 20px; }
/* СТИЛЬ ПОДСКАЗКИ */
.media-hint-tooltip {
    position: absolute !important;
    bottom: 85px !important;
    right: 15px !important;
    width: auto !important;
    max-width: 260px !important;
    background: rgba(33, 33, 33, 0.95) !important;
    color: #fff !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 12px 30px 12px 15px !important; /* Больше отступ справа для крестика */
    border-radius: 18px !important;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
    z-index: 2000 !important;
    animation: fadeInUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.media-hint-tooltip.hidden { display: none !important; }

.hint-content { display: flex; flex-direction: column; gap: 8px; }

.hint-row { display: flex; align-items: center; gap: 10px; font-size: 13px; line-height: 1.3; }

.hint-icon { font-size: 16px; width: 20px; text-align: center; }

.hint-text { color: rgba(255,255,255,0.9); }
.hint-text b { color: #fff; font-weight: 600; }

.hint-tail {
    position: absolute; bottom: -6px; right: 25px; width: 14px; height: 14px;
    background: rgba(33, 33, 33, 0.95);
    transform: rotate(45deg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    border-right: 1px solid rgba(255,255,255,0.1);
}

.hint-close {
    position: absolute; top: 5px; right: 5px; width: 20px; height: 20px;
    background: rgba(255,255,255,0.1); border: none; border-radius: 50%;
    color: #ccc; font-size: 16px; line-height: 18px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* --- КРАСИВЫЙ ЛОАДЕР ИСТОРИИ (FIXED/STICKY) --- */
.history-loader {
    position: sticky; /* Липкое позиционирование */
    top: 10px;        /* Отступ от самого верха видимой зоны */
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;    /* ПОВЕРХ ВСЕГО */
    opacity: 0;
    pointer-events: none; /* Чтобы сквозь него можно было кликать */
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); /* Пружинистая анимация */
    height: 0;        /* Чтобы не сдвигал контент */
    overflow: visible;
}

.history-loader.visible {
    opacity: 1;
    transform: translateY(0);
    height: 40px;     /* Занимает немного места при появлении */
}

/* Сам кружочек на красивой подложке */
.spinner-circle {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 122, 255, 0.2);
    border-top-color: var(--primary); /* Синий цвет */
    border-radius: 50%;
    animation: history-spin 0.8s linear infinite;
    
    /* Красота: Стекломорфизм + Тень */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 3px;     /* Внутренний отступ */
    box-sizing: content-box; /* Чтобы padding не сжимал спиннер */
}

/* Для темной темы (автоматически) */
[data-theme="dark"] .spinner-circle {
    background: rgba(40, 40, 40, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
}

@keyframes history-spin {
    to { transform: rotate(360deg); }
}

/* === КНОПКИ ПРОФИЛЯ В СТИЛЕ IOS (Звонки, Сообщение) === */
.ptn-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.1s;
}

.ptn-action-btn:active {
    transform: scale(0.95);
}

.ptn-action-icon {
    width: 46px;
    height: 46px;
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ptn-action-btn:hover .ptn-action-icon {
    background: rgba(0, 122, 255, 0.2);
}

.ptn-action-btn span {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
}

@media (max-width: 768px) {
    #modal-partner, #modal-group-info {
        align-items: flex-start !important; /* ВАЖНО: Прижимаем к верху, а не к низу, чтобы не съезжало в Яндексе */
        padding: 0 !important;
    }
    
    .profile-modal-ios {
        position: relative !important; /* ВАЖНО: Удерживает крестик внутри окна */
        width: 100vw !important;
        height: 100dvh !important; /* ВАЖНО: Используем dvh (dynamic viewport height) - это лечит скрытие панелей! */
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        background: var(--bg-body) !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 60px 20px 20px 20px !important; /* Спустили контент ниже, чтобы не налез на крестик */
        border: none !important;
        box-shadow: none !important;
    }

    .ios-close-btn {
        top: 20px !important; /* Отступ от верхнего края экрана (безопасная зона) */
        right: 20px !important;
    }
}

/* ПК версия: аккуратное мини-окошко по центру */
@media (min-width: 769px) {
    .profile-modal-ios {
        width: 360px !important;
        background: var(--glass-heavy) !important;
        backdrop-filter: blur(30px) saturate(180%) !important;
        -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
        border: 1px solid var(--glass-border) !important;
        border-radius: 28px !important; /* Красивые круглые углы */
        box-shadow: 0 20px 60px rgba(0,0,0,0.2) !important;
        padding: 24px !important;
    }
}

/* === СЕТКА МЕДИА В ПРОФИЛЕ === */
.media-grid-ios {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px; /* Расстояние между плитками (как в iOS Photos) */
    width: 100%;
    padding: 0 16px 20px 16px;
}

.media-grid-item {
    aspect-ratio: 1 / 1;
    background: rgba(128, 128, 128, 0.1);
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Скругление краев для крайних элементов */
.media-grid-item:first-child { border-top-left-radius: 12px; }
.media-grid-item:nth-child(3) { border-top-right-radius: 12px; }

.media-grid-item:active { opacity: 0.7; }

/* Иконки типа файла (камера, файл, микрофон) поверх превью */
.media-type-icon {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}
.media-type-icon svg { width: 12px; height: 12px; stroke: white; fill: none; }

/* === ИСПРАВЛЕНИЕ СКРОЛЛА ОПИСАНИЯ === */
.scrollable-bio {
    max-height: 120px;
    overflow-y: auto;
    /* Скрываем скроллбар для красоты, но оставляем возможность скроллить */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE */
}
.scrollable-bio::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera, Edge */
}
/* === ПОЛНОЕ СКРЫТИЕ СИСТЕМНЫХ ПОЛЗУНКОВ (APPLE STYLE) === */
.modal, 
.profile-modal-ios, 
#grp-part-list,
.settings-group-ios,
textarea {
    scrollbar-width: none !important; /* Для Firefox */
    -ms-overflow-style: none !important; /* Для старых Edge/IE */
}

.modal::-webkit-scrollbar, 
.profile-modal-ios::-webkit-scrollbar, 
#grp-part-list::-webkit-scrollbar,
.settings-group-ios::-webkit-scrollbar,
textarea::-webkit-scrollbar {
    display: none !important; /* Для Chrome, Safari, Opera, Yandex */
    width: 0 !important;
    height: 0 !important;
    background: transparent !important;
}