/* ============================================
   ЧАТ — стили поверх style.css
   ============================================ */

.chat-app {
    display: grid;
    grid-template-columns: 320px 1fr;
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    height: calc(100vh - 48px);
    min-height: 480px;
    overflow: hidden;
}

/* ========== СПИСОК ЧАТОВ ========== */

.chat-sidebar {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid rgba(154, 156, 146, 0.25);
    background: var(--color-white);
}

.chat-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
    flex-shrink: 0;
}

.chat-sidebar-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-dark);
}

.chat-new-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: var(--color-accent);
    color: var(--color-white);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-new-btn:hover { background: var(--color-dark); }

.chat-search {
    padding: 0 20px 12px;
    flex-shrink: 0;
}

.chat-search-input {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    font-size: 0.88rem;
    font-family: inherit;
    background: var(--color-white);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-search-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(127, 149, 118, 0.15);
}

.chat-list {
    list-style: none;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 8px 8px;
    margin: 0;
}

.chat-list::-webkit-scrollbar { width: 6px; }
.chat-list::-webkit-scrollbar-track { background: transparent; }
.chat-list::-webkit-scrollbar-thumb {
    background: rgba(154, 156, 146, 0.4);
    border-radius: 3px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-item:hover { background: rgba(127, 149, 118, 0.08); }
.chat-item.active { background: rgba(127, 149, 118, 0.16); }

.chat-avatar {
    position: relative;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    letter-spacing: 0.3px;
    user-select: none;
}

.chat-avatar.online::after {
    content: '';
    position: absolute;
    right: 0;
    bottom: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #6fbf73;
    border: 2px solid var(--color-white);
}

.chat-item-body { flex: 1; min-width: 0; }

.chat-item-name-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}

.chat-item-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 0.72rem;
    color: var(--color-text-light);
    flex-shrink: 0;
}

.chat-item-preview {
    font-size: 0.82rem;
    color: var(--color-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item.unread .chat-item-preview {
    font-weight: 600;
    color: var(--color-text);
}

.chat-unread-badge {
    background: var(--color-accent);
    color: var(--color-white);
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 10px;
    padding: 2px 7px;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.chat-list-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.85rem;
}

/* ========== ОКНО ЧАТА ========== */

.chat-window {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    background:
        radial-gradient(circle at 100% 0%, rgba(127, 149, 118, 0.06), transparent 40%),
        var(--color-white);
}

.chat-window-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    border-bottom: 1px solid rgba(154, 156, 146, 0.25);
    background: var(--color-white);
    flex-shrink: 0;
}

.chat-peer {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chat-peer .chat-avatar {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
}

.chat-peer-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-peer-name {
    font-weight: 700;
    font-size: 0.98rem;
    color: var(--color-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-peer-status {
    font-size: 0.76rem;
    color: var(--color-text-light);
}

.chat-peer-status.online { color: var(--color-accent); font-weight: 500; }

.chat-window-actions { display: flex; gap: 2px; flex-shrink: 0; }

.chat-icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--color-text-light);
    font-size: 1.05rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    flex-shrink: 0;
}

.chat-icon-btn:hover {
    background: rgba(127, 149, 118, 0.12);
    color: var(--color-accent);
}

.chat-icon-btn img { width: 20px; height: 20px; }

#calendarBtn img { width: 26px; height: 26px; }

.chat-back-btn { display: none; font-size: 1.2rem; }

/* ========== СООБЩЕНИЯ ========== */

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(154, 156, 146, 0.35);
    border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(154, 156, 146, 0.55);
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-text-light);
    gap: 14px;
    text-align: center;
}

.chat-empty-icon {
    font-size: 3rem;
    opacity: 0.45;
}

.chat-date-sep {
    text-align: center;
    margin: 6px 0;
    display: flex;
    justify-content: center;
}

.chat-date-sep span {
    background: rgba(154, 156, 146, 0.18);
    color: var(--color-text-light);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    letter-spacing: 0.3px;
}

/* ---------- Группа сообщений ---------- */

.chat-group {
    display: flex;
    gap: 10px;
    width: 100%;
    align-items: flex-start;
    animation: msgIn 0.2s ease-out;
}

.chat-group.own {
    flex-direction: row-reverse;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-group-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-white);
    flex-shrink: 0;
    letter-spacing: 0.3px;
    user-select: none;
    box-shadow: 0 1px 2px rgba(69, 82, 64, 0.1);
    overflow: hidden;
}

.chat-group-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.chat-group-avatar.avatar-hidden {
    visibility: hidden;
}

.chat-group-messages {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    max-width: 78%;
}

.chat-sender-name {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--color-accent);
    padding: 0 4px 2px;
    line-height: 1.2;
}

.chat-group.own .chat-sender-name {
    color: var(--color-dark);
    text-align: right;
}

/* ---------- Пузырь сообщения ---------- */

.chat-bubble {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 16px;
    background: var(--color-white);
    border: 1px solid rgba(154, 156, 146, 0.25);
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--color-text);
    box-shadow: 0 1px 2px rgba(69, 82, 64, 0.04);
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
    width: fit-content;
    max-width: 100%;
    transition: border-radius 0.15s;
}

.chat-group.own .chat-bubble {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-white);
    align-self: flex-end;
}

.chat-group:not(.own) .chat-bubble.tail {
    border-bottom-left-radius: 4px;
}

.chat-group.own .chat-bubble.tail {
    border-bottom-right-radius: 4px;
}

.chat-text { flex: 1; min-width: 0; }

.chat-bubble-time {
    font-size: 0.68rem;
    opacity: 0.6;
    white-space: nowrap;
    flex-shrink: 0;
    padding-left: 6px;
    align-self: flex-end;
    transform: translateY(2px);
}

.chat-group.own .chat-bubble-time { opacity: 0.8; }

/* Индикатор "печатает" */

.chat-typing-group {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    align-self: flex-start;
    max-width: 78%;
    animation: msgIn 0.2s ease-out;
}

.chat-typing-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-white);
    flex-shrink: 0;
    user-select: none;
    box-shadow: 0 1px 2px rgba(69, 82, 64, 0.1);
}

.chat-typing {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--color-white);
    border: 1px solid rgba(154, 156, 146, 0.25);
    border-radius: 16px 16px 16px 4px;
    box-shadow: 0 1px 2px rgba(69, 82, 64, 0.04);
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--color-border);
    border-radius: 50%;
    animation: typingAnim 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingAnim {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* ========== ПОЛЕ ВВОДА ========== */

.chat-composer {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px 16px;
    border-top: 1px solid rgba(154, 156, 146, 0.25);
    background: var(--color-white);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    min-width: 0;
    padding: 11px 18px;
    border: 1px solid var(--color-border);
    border-radius: 22px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--color-white);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(127, 149, 118, 0.15);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--color-accent);
    color: var(--color-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--color-dark); }
.chat-send-btn:active { transform: scale(0.94); }
.chat-send-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Клавизм: поле ввода + кнопка смены раскладки */
.chat-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.chat-input-wrap .chat-input {
    width: 100%;
    box-sizing: border-box;
    padding-right: 48px;
}

.klavizm-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid var(--color-dark);
    background: transparent;
    color: var(--color-text-light);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 9px;
    cursor: pointer;
    display: none;
    line-height: 1;
}

.klavizm-btn.show { display: block; }

/* Меню скрепки (VK-стиль) */
.chat-attach { position: relative; }

.chat-attach-menu {
    position: absolute;
    bottom: 46px;
    left: 0;
    background: var(--color-white);
    border: 1px solid rgba(154, 156, 146, 0.25);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    padding: 6px;
    min-width: 190px;
    display: none;
    z-index: 60;
}

.chat-attach-menu.open { display: block; }

.chat-attach-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-text);
    text-align: left;
}

.chat-attach-item:hover { background: rgba(127, 149, 118, 0.12); }

/* Вложения: видео и документ */
.chat-video {
    max-width: 260px;
    max-height: 220px;
    border-radius: 10px;
    display: block;
}

.chat-document {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 1px solid currentColor;
    padding-bottom: 1px;
}

.chat-document-icon { font-size: 1rem; }
.chat-document-name { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Пересылка и ответы */
.chat-group { position: relative; }

.chat-forwarded-label {
    font-size: 0.72rem;
    color: var(--color-accent);
    font-weight: 600;
    margin-bottom: 2px;
}

/* Выделение сообщений */
.chat-app.selecting .chat-group { cursor: pointer; }
.chat-app.selecting .chat-bubble { pointer-events: none; }

.chat-group.selected {
    background: rgba(127, 149, 118, 0.12);
    border-radius: 10px;
}

.chat-group.selected::before {
    content: '✓';
    position: absolute;
    top: 8px;
    left: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    z-index: 6;
}

.chat-group.own.selected::before {
    left: auto;
    right: -6px;
}

/* Панель выделения */
.chat-window { position: relative; }

.chat-selection-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--color-white);
    border-bottom: 1px solid rgba(154, 156, 146, 0.25);
    display: none;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    z-index: 40;
}

.chat-selection-bar.active { display: flex; }

.chat-selection-count {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-dark);
    margin: 0 auto 0 4px;
}

.chat-selection-btn {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--color-accent);
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
}

.chat-selection-btn:hover { background: rgba(127, 149, 118, 0.12); }

.chat-selection-btn:disabled { opacity: 0.4; cursor: default; }

.chat-selection-forward {
    background: var(--color-accent);
    color: #fff;
}

.chat-selection-forward:hover { background: var(--color-dark); }

.chat-selection-delete {
    color: #e53935;
    border: 1px solid #e53935;
}

.chat-selection-delete:hover { background: rgba(229, 57, 53, 0.1); }

/* Панель ответа */
.chat-reply-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(127, 149, 118, 0.1);
    border-top: 1px solid rgba(154, 156, 146, 0.25);
}

.chat-reply-bar.active { display: flex; }

.chat-reply-bar-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-reply-bar-title {
    font-size: 0.72rem;
    color: var(--color-accent);
    font-weight: 700;
}

.chat-reply-bar-text {
    font-size: 0.85rem;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-reply-bar-close {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--color-text-light);
    padding: 4px;
}

.chat-reply-bar-close:hover { color: var(--color-dark); }

/* Цитата в сообщении */
.chat-reply-quote {
    font-size: 0.78rem;
    border-left: 3px solid currentColor;
    border-radius: 4px;
    padding: 4px 8px;
    margin-bottom: 4px;
    max-width: 240px;
    overflow: hidden;
    opacity: 0.85;
}

.chat-reply-quote-author {
    font-weight: 700;
    margin-right: 4px;
}

.chat-reply-quote-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Модалка пересылки */
.forward-chat-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.forward-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.forward-chat-item:hover { background: rgba(127, 149, 118, 0.12); }

.forward-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: #fff;
    background: var(--color-accent);
    overflow: hidden;
}

.forward-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.forward-chat-name {
    font-size: 0.92rem;
    color: var(--color-text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.forward-empty {
    padding: 16px;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.88rem;
}

/* Перетаскивание файлов */
.chat-app.dragover {
    position: relative;
}

.chat-app.dragover::after {
    content: 'Отпустите файл для отправки';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(127, 149, 118, 0.22);
    border: 2px dashed var(--color-accent);
    border-radius: 16px;
    color: var(--color-dark);
    font-weight: 700;
    font-size: 1rem;
    z-index: 100;
    pointer-events: none;
}

/* ========== АДАПТИВНОСТЬ ========== */

@media (max-width: 900px) {
    .chat-app {
        grid-template-columns: 1fr;
        height: calc(100vh - 140px);
        min-height: 420px;
        max-height: none;
    }

    .chat-sidebar { display: none; border-right: none; }
    .chat-window { display: none; }

    .chat-app.show-list .chat-sidebar { display: flex; }
    .chat-app.show-chat .chat-window { display: flex; }

    .chat-back-btn { display: flex; }
}

@media (max-width: 600px) {
    .chat-group,
    .chat-typing-group { max-width: 90%; }
    .chat-messages { padding: 16px 12px; gap: 12px; }
    .chat-window-header { padding: 10px 14px; }
    .chat-composer { padding: 10px 12px 14px; }
    .chat-sidebar-header { padding: 16px 16px 10px; }
    .chat-search { padding: 0 16px 10px; }
    .chat-group-avatar,
    .chat-typing-avatar { width: 32px; height: 32px; font-size: 0.72rem; }
    .chat-avatar { width: 42px; height: 42px; font-size: 0.95rem; }
}

/* ========== ВКЛАДКИ (Основные / Дополнительные) ========== */

.chat-tabs {
    display: flex;
    gap: 6px;
    padding: 0 20px 10px;
    flex-shrink: 0;
}

.chat-tab {
    position: relative;
    flex: 1;
    padding: 7px 0;
    border: none;
    border-radius: 8px;
    background: rgba(127, 149, 118, 0.08);
    color: var(--color-text-light);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.chat-tab.active {
    background: var(--color-accent);
    color: var(--color-white);
}

.chat-tab-badge {
    position: absolute;
    top: -6px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e53935;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-sizing: border-box;
}

.chat-tab-badge.show { display: flex; }

/* ========== КНОПКА ⋮ И МЕНЮ ========== */

.chat-item-menu {
    border: none;
    background: none;
    color: var(--color-text-light);
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 6px;
    flex-shrink: 0;
}

.chat-item-menu:hover { background: rgba(127, 149, 118, 0.15); color: var(--color-dark); }

.chat-menu {
    position: fixed;
    z-index: 100;
    min-width: 220px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(69, 82, 64, 0.15);
    padding: 6px;
    display: flex;
    flex-direction: column;
}

.chat-menu[hidden] { display: none; }

.chat-menu-item {
    text-align: left;
    border: none;
    background: none;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--color-text);
    transition: background 0.15s;
}

.chat-menu-item:hover { background: rgba(127, 149, 118, 0.12); }

.chat-mute-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.chat-avatar img { display: block; }

/* ========== ВКЛАДКИ В МОДАЛКЕ «НОВЫЙ ЧАТ» ========== */

.chat-new-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.chat-new-tab {
    flex: 1;
    padding: 7px 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: none;
    color: var(--color-text-light);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.chat-new-tab.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-white);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--color-text);
    margin-bottom: 14px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input { accent-color: var(--color-accent); width: 16px; height: 16px; }

/* ========== ОПРОС В СООБЩЕНИИ ========== */

.chat-poll {
    min-width: 220px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-poll-question { font-weight: 600; margin-bottom: 2px; }

.chat-poll-option {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid rgba(154, 156, 146, 0.35);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.chat-poll-option:hover { border-color: var(--color-accent); }

.chat-poll-option.voted {
    border-color: var(--color-accent);
    background: rgba(127, 149, 118, 0.08);
}

.chat-poll-option-text { font-size: 0.86rem; }

.chat-poll-bar {
    height: 6px;
    border-radius: 3px;
    background: rgba(154, 156, 146, 0.22);
    overflow: hidden;
}

.chat-poll-bar-fill {
    height: 100%;
    background: var(--color-accent);
    border-radius: 3px;
    transition: width 0.2s;
}

.chat-poll-meta { font-size: 0.72rem; color: var(--color-text-light); }

/* Опрос в своих сообщениях (зелёный пузырь) */
.chat-group.own .chat-poll-option { border-color: rgba(255, 255, 255, 0.4); }
.chat-group.own .chat-poll-option.voted { background: rgba(255, 255, 255, 0.14); }
.chat-group.own .chat-poll-bar { background: rgba(255, 255, 255, 0.25); }
.chat-group.own .chat-poll-bar-fill { background: rgba(255, 255, 255, 0.75); }
.chat-group.own .chat-poll-meta { color: rgba(255, 255, 255, 0.8); }

/* ========== КАРТИНКА В СООБЩЕНИИ ========== */

.chat-image {
    max-width: 260px;
    max-height: 220px;
    border-radius: 10px;
    display: block;
}

/* ========== ИНФОРМАЦИЯ О ЧАТЕ ========== */

.modal-chat-info { max-width: 400px; }

.chat-info-avatar {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    font-weight: 700;
    font-size: 1.8rem;
    letter-spacing: 0.5px;
    user-select: none;
    overflow: hidden;
    position: relative;
}

.chat-info-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.chat-info-avatar.can-change { cursor: pointer; }

.chat-info-avatar.can-change::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.35);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 15.2a3.2 3.2 0 1 0 0-6.4 3.2 3.2 0 0 0 0 6.4z'/%3E%3Cpath d='M9 3 7.2 5H4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-3.2L15 3H9z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 22px 22px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.chat-info-avatar.can-change:hover::after { opacity: 1; }

.chat-info-members-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-light);
    font-weight: 600;
    margin-bottom: 8px;
}

.chat-info-members {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.chat-info-member {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(127, 149, 118, 0.05);
    position: relative;
}

.chat-info-member-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
    overflow: hidden;
    user-select: none;
}

.chat-info-member-avatar img { display: block; }

.chat-info-member-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-info-admin-badge {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--color-accent);
    background: rgba(127, 149, 118, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.chat-info-more-btn {
    border: none;
    background: none;
    color: var(--color-text-light);
    font-size: 1.15rem;
    line-height: 1;
    padding: 2px 8px;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-info-more-btn:hover { background: rgba(127, 149, 118, 0.15); color: var(--color-text); }

.chat-info-menu {
    position: absolute;
    right: 8px;
    top: calc(100% - 2px);
    min-width: 160px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 4px;
    display: none;
    z-index: 30;
}

.chat-info-menu.open { display: block; }

.chat-info-menu-item {
    display: block;
    width: 100%;
    border: none;
    background: none;
    color: var(--color-text);
    font-size: 0.85rem;
    text-align: left;
    padding: 8px 12px;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
}

.chat-info-menu-item:hover { background: rgba(127, 149, 118, 0.12); }

.chat-info-delete-btn {
    display: block;
    width: 100%;
    margin-top: 4px;
    border: 1px solid #d9534f;
    background: none;
    color: #d9534f;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
}

.chat-info-delete-btn:hover { background: rgba(217, 83, 79, 0.12); }

.chat-info-invite-btn {
    display: block;
    width: 100%;
    margin-top: 4px;
    border: 1px solid var(--color-accent);
    background: none;
    color: var(--color-accent);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
}

.chat-info-invite-btn:hover { background: rgba(127, 149, 118, 0.12); }

.invite-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
}

.invite-item {
    border: 1px solid var(--color-border);
    background: none;
    color: var(--color-text);
    font-size: 0.85rem;
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.invite-item:hover { background: rgba(127, 149, 118, 0.1); }

.invite-item:first-child {
    border-color: var(--color-accent);
    color: var(--color-accent);
    font-weight: 600;
}

.invite-result { margin-top: 12px; }
.invite-result[hidden] { display: none; }
.invite-result-label {
    font-size: 0.82rem;
    color: var(--color-text-light);
    margin-bottom: 6px;
}
.invite-result .modal-input { margin-bottom: 10px; }

/* ========== ГАЛОЧКИ ПРОЧТЕНИЯ ========== */

.chat-ticks {
    margin-left: 6px;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.55);
    vertical-align: middle;
    transition: color 0.3s;
}

.chat-ticks.read { color: #aee7ff; }

/* Аватарки проголосовавших в опросе (VK-стиль) */
.chat-poll-voters {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
}

.chat-poll-voter-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    font-weight: 700;
    color: #fff;
    background: var(--color-accent);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
    vertical-align: middle;
}

.chat-poll-voter-fallback {
    background: var(--color-dark);
}