/* =====================================================================
   SYNAPSE CHAT — слой оформления (theme.css)
   Подключается после style.css и переопределяет его: палитру, скругления,
   тени, пузыри сообщений, панели, модалки и анимации. Логика интерфейса
   и админ-эффекты (matrix / heaven / mecha) не затрагиваются.
   ===================================================================== */

:root {
    --bg-0: #0b0d14;
    --bg-1: #10131c;
    --bg-2: #171b27;
    --bg-3: #1f2433;
    --border: rgba(255, 255, 255, 0.065);
    --border-strong: rgba(255, 255, 255, 0.12);

    --accent: #8aa6ff;
    --accent-2: #b08cff;
    --accent-strong: #6f8dff;
    --accent-soft: rgba(138, 166, 255, 0.14);
    --accent-gradient: linear-gradient(135deg, #7c9cff 0%, #a57cff 100%);
    --own-bubble: linear-gradient(135deg, #6f8dff 0%, #9072f5 100%);

    --text-main: #e9ecf4;
    --text-dim: #8a93a8;
    --danger: #ff7286;
    --success: #5fd6a4;

    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 9px;
    --shadow-1: 0 6px 18px rgba(0, 0, 0, 0.25);
    --shadow-2: 0 24px 60px rgba(0, 0, 0, 0.45);
    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --menu-bg: rgba(22, 26, 38, 0.96);
}

/* ---------- Базовое ---------- */
body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    background: var(--bg-0);
}
::selection { background: rgba(138, 166, 255, 0.3); }
button { font-family: inherit; }

/* Иконки: по умолчанию наследуют цвет текста (см. recolorSvg в script-core.js) */
.icon-svg { width: 18px; height: 18px; flex-shrink: 0; display: block; color: inherit; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
[data-icon] .icon-svg { width: 18px; height: 18px; }

/* ---------- Кнопки ---------- */
.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    padding: 11px 16px;
    border-radius: var(--radius-md);
    border: none;
    box-shadow: 0 8px 22px rgba(124, 156, 255, 0.22);
    transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s;
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 10px 26px rgba(124, 156, 255, 0.3); }
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-secondary {
    background: var(--bg-2);
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-danger {
    background: rgba(255, 114, 134, 0.1);
    border: 1px solid rgba(255, 114, 134, 0.45);
    color: var(--danger);
    border-radius: var(--radius-md);
    padding: 11px 14px;
}
.btn-danger:hover { background: rgba(255, 114, 134, 0.18); }

/* ---------- Поля ввода (общие) ---------- */
input[type="text"], input[type="password"], textarea, select {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
input[type="text"]:focus, input[type="password"]:focus, textarea:focus, select:focus {
    border-color: rgba(138, 166, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(138, 166, 255, 0.14);
}
input[type="range"] { accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }

/* ---------- Авторизация ---------- */
.auth-body {
    background:
        radial-gradient(900px 500px at 50% -12%, rgba(124, 156, 255, 0.18), transparent 70%),
        radial-gradient(700px 450px at 100% 110%, rgba(165, 124, 255, 0.12), transparent 70%),
        var(--bg-0);
}
.auth-card {
    width: 400px;
    padding: 34px 36px;
    border-radius: 22px;
    background: rgba(16, 19, 28, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-2);
}
.logo { font-size: 20px; font-weight: 700; letter-spacing: 2.5px; }
.auth-sub { font-size: 14px; color: var(--text-dim); margin-bottom: 22px; }
.auth-form { gap: 16px; }
.auth-form label { color: var(--text-dim); font-size: 12.5px; font-weight: 500; }
.auth-form input[type="text"], .auth-form input[type="email"], .auth-form input[type="password"] { height: 44px; padding: 0 14px; font-size: 14.5px; }
.auth-form small { color: #5d667c; font-size: 11.5px; line-height: 1.4; }
.auth-error { border-radius: var(--radius-md); }
.auth-switch { margin-top: 22px; }
.auth-switch a { color: var(--accent); font-weight: 600; }

/* ---------- Аватарки / кроппер ---------- */
.avatar-crop-stage, .avatar-dropzone { border-radius: 50%; }
.avatar-placeholder { color: var(--text-dim); }
.avatar-placeholder .icon-svg { width: 24px; height: 24px; }
.zoom-label { color: var(--text-dim); }

/* =====================================================================
   ОСНОВНОЙ МАКЕТ
   ===================================================================== */
.layout { background: var(--bg-0); }

/* Левая узкая панель навигации */
.rail {
    width: 72px;
    background: var(--bg-0);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    gap: 18px;
}
.rail-avatar-btn { position: relative; }
.rail-avatar {
    width: 44px; height: 44px;
    border: 2px solid var(--bg-3);
    box-shadow: 0 0 0 2px var(--accent-soft);
}
.rail-avatar.admin-glow { border-color: var(--accent); box-shadow: 0 0 14px rgba(138, 166, 255, 0.55); }
.rail-icons { gap: 8px; margin-top: 6px; }
.rail-icon {
    width: 44px; height: 44px;
    border-radius: 14px;
    color: var(--text-dim);
    opacity: 1;
    background: transparent;
    border: none;
    cursor: pointer;
    position: relative;
    padding: 0;
}
.rail-icon .icon-svg { width: 22px; height: 22px; }
.rail-icon:hover { color: var(--text-main); background: var(--bg-2); transform: translateY(-1px); }
.rail-icon.active { color: var(--accent); background: var(--accent-soft); }
.rail-icon.active::before {
    content: '';
    position: absolute;
    left: -15px; top: 50%;
    width: 3px; height: 20px;
    transform: translateY(-50%);
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

/* Список чатов */
.chat-list {
    width: 320px;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
}
.chat-list-header {
    padding: 20px 18px 12px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0;
    color: var(--text-main);
    border-bottom: none;
}
.new-chat-btn {
    width: 36px; height: 36px;
    border-radius: 12px;
    background: var(--accent-soft);
    border: none;
    color: var(--accent);
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.2s, transform 0.15s var(--ease);
}
.new-chat-btn .icon-svg { width: 18px; height: 18px; }
.new-chat-btn:hover { background: rgba(138, 166, 255, 0.24); transform: rotate(90deg); }
.search-btn {
    margin: 0 14px 10px;
    width: calc(100% - 28px);
    height: 40px;
    padding: 0 14px;
    border-radius: var(--radius-md);
    background: var(--bg-2);
    border: 1px solid transparent;
    color: var(--text-dim);
    display: flex; align-items: center; gap: 10px;
    font-size: 13px;
    cursor: pointer;
}
.search-btn .icon-svg { width: 16px; height: 16px; }
.search-btn:hover { border-color: var(--border-strong); color: var(--text-main); }
.chat-list-body { padding: 4px 8px 12px; }
.chat-list-empty { color: var(--text-dim); text-align: center; margin-top: 48px; font-size: 13px; padding: 0 24px; line-height: 1.5; }
.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px;
    margin: 2px 0;
    border-radius: 14px;
    border-left: none;
    cursor: pointer;
    position: relative;
    transition: background 0.18s var(--ease), transform 0.12s var(--ease);
}
.chat-item:hover { background: var(--bg-2); transform: translateX(2px); }
.chat-item.active { background: rgba(138, 166, 255, 0.15); }
.chat-item.pinned:not(.active) { background: rgba(255, 255, 255, 0.025); }
.chat-item-avatar, .chat-avatar-wrap .chat-item-avatar { width: 46px; height: 46px; }
.chat-avatar-wrap { position: relative; flex-shrink: 0; }
.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name {
    display: flex; align-items: center; gap: 6px;
    font-size: 14px; font-weight: 600; color: var(--text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-item-last { color: var(--text-dim); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.has-unread .chat-item-last { color: var(--text-main); font-weight: 500; }
.chat-tag {
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 7px;
    background: var(--bg-3); color: var(--text-dim);
    text-transform: lowercase;
}
.chat-unread-dot {
    position: absolute;
    right: 14px; top: 50%;
    width: 9px; height: 9px;
    margin-top: -4.5px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px rgba(138, 166, 255, 0.18), 0 0 10px rgba(138, 166, 255, 0.6);
    animation: unreadPulse 2.4s ease-in-out infinite;
}
@keyframes unreadPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); }
}
.online-dot { border-color: var(--bg-1); }
.resize-handle { background: transparent; }
.resize-handle:hover { background: var(--accent-soft); }

/* Правая часть: фон чата */
.chat-main {
    background:
        radial-gradient(900px 500px at 75% -10%, rgba(138, 166, 255, 0.05), transparent 60%),
        var(--bg-0);
}
.chat-placeholder { color: var(--text-dim); }
.chat-placeholder h2 {
    font-size: 22px; font-weight: 700; letter-spacing: 2px;
    color: var(--text-main); margin-bottom: 8px;
}
.chat-placeholder p { font-size: 14px; line-height: 1.5; max-width: 320px; margin: 0 auto; }

/* Шапка чата */
.chat-header {
    height: 64px;
    padding: 0 18px;
    gap: 12px;
    background: rgba(16, 19, 28, 0.78);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 5;
}
.chat-header-avatar { width: 40px; height: 40px; }
.chat-header-name { font-size: 15px; font-weight: 700; color: var(--text-main); }
.chat-header-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }
.chat-header-sub.online { color: var(--success); }
.chat-header-edit-btn, .chat-header-members-btn, .chat-header-search-btn, .chat-back-btn {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.chat-header-edit-btn .icon-svg, .chat-header-members-btn .icon-svg,
.chat-header-search-btn .icon-svg, .chat-back-btn .icon-svg { width: 19px; height: 19px; }
.chat-header-search-btn { margin-left: auto; }
.chat-header-edit-btn, .chat-header-members-btn { margin-left: 0; margin-right: 0; }
.chat-header-edit-btn:hover, .chat-header-members-btn:hover, .chat-header-search-btn:hover, .chat-back-btn:hover {
    background: var(--bg-2); color: var(--accent);
}

/* Поиск по переписке */
.chat-search-bar {
    display: flex; align-items: center; gap: 6px;
    padding: 10px 14px;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
    animation: slideDown 0.22s var(--ease);
}
.chat-search-bar input {
    flex: 1; min-width: 0;
    height: 36px; padding: 0 12px;
    font-size: 14px;
    background: var(--bg-2);
    border-radius: 10px;
}
.chat-search-icon { color: var(--text-dim); margin-right: 4px; }
.chat-search-icon .icon-svg { width: 16px; height: 16px; }
.chat-search-count { font-size: 12px; color: var(--text-dim); white-space: nowrap; padding: 0 4px; }
.chat-search-nav {
    width: 32px; height: 32px; border-radius: 10px;
    background: transparent; border: none; color: var(--text-dim); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.chat-search-nav:hover { background: var(--bg-2); color: var(--text-main); }
.chat-search-nav .icon-svg { width: 17px; height: 17px; }
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Область сообщений */
.messages-area {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.admin-chat-messages {
    padding: 14px 22px 18px;
    gap: 0;
    background:
        radial-gradient(600px 300px at 50% 0%, rgba(176, 140, 255, 0.04), transparent 70%);
}

/* Разделитель дней */
.msg-day-divider {
    display: flex;
    justify-content: center;
    position: sticky;
    top: 6px;
    z-index: 4;
    margin: 14px 0 8px;
    pointer-events: none;
    animation: fadeIn 0.3s var(--ease);
}
.msg-day-divider span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    background: rgba(18, 22, 33, 0.82);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    padding: 4px 12px;
    border-radius: 999px;
    box-shadow: var(--shadow-1);
}

/* Сообщения: пузыри */
.bot-message, .self-message {
    max-width: min(74%, 620px);
    margin-top: 10px;
    gap: 10px;
}
.bot-message.msg-grouped, .self-message.msg-grouped { margin-top: 2px; }
.bot-message-avatar, .self-message-avatar {
    width: 36px; height: 36px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.msg-grouped .bot-message-avatar, .msg-grouped .self-message-avatar { visibility: hidden; }

.bot-message-bubble {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 18px 18px 18px 6px;
    padding: 8px 13px 7px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    color: var(--text-main);
}
.bot-message.msg-grouped .bot-message-bubble { border-top-left-radius: 6px; }
.bot-message .bot-name { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 1px; }
.msg-grouped .bot-name, .msg-grouped .self-message-name { display: none; }
.bot-message .bot-text, .self-message-text { font-size: 14.5px; line-height: 1.45; }

.self-message-bubble {
    background: var(--own-bubble);
    color: #fff;
    border-radius: 18px 18px 6px 18px;
    padding: 8px 13px 7px;
    box-shadow: 0 6px 18px rgba(111, 141, 255, 0.2);
}
.self-message.msg-grouped .self-message-bubble { border-top-right-radius: 6px; }
.self-message-name { font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, 0.82); opacity: 1; margin-bottom: 1px; }
.self-message-bubble .msg-time { color: rgba(255, 255, 255, 0.7); opacity: 1; }
.bot-message-bubble .msg-time { color: var(--text-dim); opacity: 0.9; }
.msg-time {
    font-size: 11px;
    margin-top: 2px;
    opacity: 1;
    cursor: default;
    letter-spacing: 0.2px;
}
.sticker-message .msg-time { color: var(--text-dim); }

/* Анимация появления новых сообщений */
.msg-appear { animation: msgIn 0.32s var(--ease) both; }
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px) scale(0.985); }
    to { opacity: 1; transform: none; }
}
@keyframes fadeIn {
    from { opacity: 0; } to { opacity: 1; }
}

/* Подсветка результатов поиска */
.msg-search-hit .bot-message-bubble,
.msg-search-hit .self-message-bubble { box-shadow: 0 0 0 1px rgba(138, 166, 255, 0.45); }
.msg-search-current .bot-message-bubble,
.msg-search-current .self-message-bubble { box-shadow: 0 0 0 2px var(--accent); }

/* Реакции */
.msg-reaction-pill {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 7px 2px 3px;
    gap: 4px;
}
.msg-reaction-pill[data-by="self"] { border-color: rgba(138, 166, 255, 0.5); }

/* Кнопка «вниз» */
.scroll-down-btn {
    position: absolute;
    right: 20px;
    bottom: 16px;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--bg-2);
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    box-shadow: var(--shadow-1);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    pointer-events: none;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s;
    z-index: 6;
}
.scroll-down-btn.visible { opacity: 1; transform: none; pointer-events: auto; }
.scroll-down-btn:hover { background: var(--bg-3); }
.scroll-down-btn .icon-svg { width: 20px; height: 20px; }
.scroll-down-count {
    position: absolute;
    top: -7px; right: -5px;
    min-width: 20px; height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--accent);
    color: #0b0d14;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 0 2px var(--bg-0);
}

/* Блок ответа */
.reply-bar {
    background: var(--bg-2);
    border: none;
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    margin-bottom: 8px;
}
.reply-bar-name { color: var(--accent); }
.reply-bar-cancel {
    width: 28px; height: 28px; border-radius: 50%;
    background: transparent; border: none; color: var(--text-dim); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.reply-bar-cancel .icon-svg { width: 14px; height: 14px; }
.reply-bar-cancel:hover { background: var(--bg-3); color: var(--danger); }
.msg-reply-ref { border-left-color: var(--accent); background: rgba(255, 255, 255, 0.04); border-radius: 8px; }
.self-message-bubble .msg-reply-ref { border-left-color: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.12); }

/* Меню сообщения и чата */
.msg-menu {
    background: var(--menu-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-2);
    padding: 6px;
    min-width: 200px;
}
.msg-menu-emojis {
    background: var(--bg-3);
    border-radius: 999px;
    padding: 4px 6px;
    margin-bottom: 4px;
    gap: 2px;
}
.msg-menu-emojis button { border-radius: 50%; transition: transform 0.15s var(--ease), background 0.15s; }
.msg-menu-btn {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 9px 11px;
    border-radius: 10px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.msg-menu-btn .icon-svg { width: 17px; height: 17px; color: var(--text-dim); }
.msg-menu-btn:hover { background: var(--bg-3); }
.msg-menu-btn:hover .icon-svg { color: var(--accent); }
.msg-menu-danger { color: var(--danger); }
.msg-menu-danger .icon-svg { color: var(--danger); }
.msg-menu-danger:hover { background: rgba(255, 114, 134, 0.12); }
.chat-ctx-menu .msg-menu-btn span { flex: 1; }

/* Панель отправки */
.admin-chat-form {
    padding: 10px 16px 14px;
    background: var(--bg-1);
    border-top: 1px solid var(--border);
}
.admin-chat-form-row { gap: 6px; }
.admin-chat-form-row #message-input,
#message-input {
    flex: 1; min-width: 0;
    height: 44px;
    padding: 0 18px;
    border-radius: 22px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    font-size: 14.5px;
}
.attach-btn, .sticker-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-dim);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.attach-btn .icon-svg, .sticker-btn .icon-svg { width: 20px; height: 20px; }
.attach-btn:hover, .sticker-btn:hover { background: var(--bg-2); color: var(--accent); }
.send-btn {
    width: 44px; height: 44px;
    padding: 0;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.send-btn .icon-svg { width: 19px; height: 19px; margin-left: -2px; }
.attach-menu, .sticker-menu {
    background: var(--menu-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    box-shadow: var(--shadow-2);
}
.attach-menu-item {
    border-radius: 10px;
    padding: 9px 12px;
    display: flex; align-items: center; gap: 10px;
    color: var(--text-main);
}
.attach-menu-item .icon-svg { width: 17px; height: 17px; color: var(--text-dim); }
.attach-menu-item:hover { background: var(--bg-3); color: var(--accent); }
.attach-menu-item:hover .icon-svg { color: var(--accent); }
.sticker-menu-tabs {
    background: var(--bg-2);
    border-radius: 12px;
    padding: 4px;
    display: flex; gap: 4px;
}
.sticker-menu-tab {
    flex: 1;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    padding: 7px 10px;
    cursor: pointer;
}
.sticker-menu-tab.active { background: var(--bg-3); color: var(--text-main); box-shadow: var(--shadow-1); }
.attachment-preview-bar { gap: 8px; }
.attach-preview { border-radius: var(--radius-sm); background: var(--bg-2); border: 1px solid var(--border); }

/* Кнопка «вниз» не должна перекрывать форму */
.scroll-down-btn { bottom: 14px; }

/* =====================================================================
   МОДАЛКИ
   ===================================================================== */
.modal-overlay {
    background: rgba(5, 7, 12, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    animation: fadeIn 0.18s var(--ease);
}
.modal-overlay.open .modal,
.modal-overlay.open .image-view-box {
    animation: modalIn 0.26s var(--ease);
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: none; }
}
.modal {
    background: var(--bg-1);
    border: 1px solid var(--border-strong);
    border-radius: 20px;
    box-shadow: var(--shadow-2);
}
.modal-header {
    padding: 16px 18px 14px 20px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
}
.modal-close {
    width: 32px; height: 32px;
    border-radius: 10px;
    color: var(--text-dim);
    background: transparent;
    border: none;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.modal-close .icon-svg { width: 16px; height: 16px; }
.modal-close:hover { background: var(--bg-2); color: var(--text-main); }
.settings-form label, .group-type-label, .new-group-body label { color: var(--text-dim); font-size: 12.5px; font-weight: 500; }
.settings-form input, .settings-form textarea,
.new-group-body input[type="text"], .chat-edit-modal input[type="text"], .chat-edit-modal textarea {
    background: var(--bg-2);
    border-radius: var(--radius-md);
}
.settings-form hr, .modal hr { border-top-color: var(--border); }
.profile-username { color: var(--text-dim); }
.profile-description { color: var(--text-dim); }
.admin-badge { border-radius: 999px; }
.logout-link { color: var(--text-dim); }
.logout-link:hover { color: var(--danger); }
.group-card-type-tag { border-radius: 999px; }
.user-search-results .user-result, .members-list > * { border-radius: 12px; }
.search-overlay { background: var(--bg-0); }
.search-overlay-header { padding: 14px 16px; border-bottom: 1px solid var(--border); gap: 10px; }
.search-overlay-header input { height: 44px; border-radius: var(--radius-md); padding: 0 14px; }
.search-section-header { font-size: 11.5px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-dim); margin: 14px 4px 6px; }

/* Просмотр текста / изображений */
.text-view-modal pre, .text-view-body pre { background: var(--bg-0); border-radius: var(--radius-md); }
.image-view-close {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(18, 22, 33, 0.8); border: 1px solid var(--border-strong);
    color: var(--text-main);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.image-view-close .icon-svg { width: 16px; height: 16px; }

/* =====================================================================
   МОБИЛЬНАЯ ВЕРСИЯ (повторяем раскладку из style.css, чтобы цвет/радиусы не ломали её)
   ===================================================================== */
@media (max-width: 800px) {
    .rail {
        width: 100%; height: 56px;
        padding: 0 12px; padding-top: env(safe-area-inset-top);
        flex-direction: row; justify-content: space-between;
        border-bottom: 1px solid var(--border);
        gap: 8px;
        background: rgba(11, 13, 20, 0.92);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
    .rail-icon.active::before { display: none; }
    .rail-icon { width: 36px; height: 36px; }
    .chat-list { width: 100% !important; background: var(--bg-0); }
    .chat-main { background: var(--bg-0); }
    .chat-header { padding: 10px 10px; height: 60px; }
    .admin-chat-messages { padding: 12px 12px 14px; }
    .bot-message, .self-message { max-width: 88%; }
    .admin-chat-form { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); }
    .auth-card { width: 92vw; padding: 28px 22px; }
    .modal { border-radius: 0; }
}

@media (max-width: 1024px) {
    .chat-list { width: 290px; }
}

/* =====================================================================
   Доступность: уважаем «меньше анимаций»
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
    .msg-appear, .msg-day-divider, .modal-overlay, .modal-overlay.open .modal,
    .chat-search-bar, .chat-unread-dot { animation: none !important; }
    .chat-item, .rail-icon, .btn-primary, .scroll-down-btn { transition: none; }
}
