/* ═══════════════════════════════════════════════════════════════════
   RUNACY — МЕССЕНДЖЕР
   Двухпанельный интерфейс: список чатов слева, переписка справа.
   Стилистика — как у остального сайта: переменные темы, тонкие
   разделители, скругления 10–12 px, акцент — --accent.
   ═══════════════════════════════════════════════════════════════════ */

#section-chat.active {
    flex-direction: row;
    align-items: stretch;
}

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

.chat-sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border-right: 1px solid var(--border);
    background: var(--bg);
}

.chat-sidebar-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-search {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.chat-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.chat-search-icon {
    display: inline-flex;
    color: var(--fg-dim);
    flex-shrink: 0;
}

.chat-search-icon .ico { width: 16px; height: 16px; }

.chat-search input {
    flex: 1;
    min-width: 0;
    background: none;
    border: none;
    outline: none;
    color: var(--fg);
    font: inherit;
    font-size: 14px;
}

.chat-search input::placeholder { color: var(--fg-dim); }

.chat-search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--fg-dim);
}

.chat-search-clear .ico { width: 14px; height: 14px; }
.chat-search-clear:hover { color: var(--fg); }

.chat-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 6px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 12px;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s;
}

.chat-item:hover { background: var(--bg-2); }

.chat-item.active { background: var(--accent-soft); }

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

.chat-item-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.chat-item-title {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-time {
    font-size: 11px;
    color: var(--fg-dim);
    flex-shrink: 0;
}

.chat-item-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.chat-item-preview {
    flex: 1;
    min-width: 0;
    font-size: 12.5px;
    color: var(--fg-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-badge {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item-check {
    flex-shrink: 0;
    display: inline-flex;
    color: var(--fg-dim);
}

.chat-item-check.read { color: var(--accent); }
.chat-item-check .ico { width: 15px; height: 15px; }

/* ─────────────────────────── АВАТАРЫ ─────────────────────────── */

.chat-avatar {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: var(--accent);
    letter-spacing: 0.5px;
    overflow: visible;
}

.chat-avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.chat-avatar.xs { width: 26px; height: 26px; font-size: 11px; }

.chat-avatar .chat-online-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid var(--bg);
}

.chat-avatar.sm .chat-online-dot { width: 10px; height: 10px; }
.chat-avatar.xs .chat-online-dot { width: 9px; height: 9px; border-width: 1.5px; }

/* ─────────────────────────── ОБЛАСТЬ ПЕРЕПИСКИ ─────────────────────────── */

.chat-main {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.chat-placeholder,
.chat-side-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--fg-dim);
    font-size: 14px;
    padding: 30px;
    text-align: center;
}

.chat-side-empty { flex: 1; }

.chat-empty-icon {
    display: inline-flex;
    color: var(--border);
}

.chat-empty-icon .ico { width: 56px; height: 56px; }

.chat-conversation {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.chat-conv-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 56px;
}

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

.chat-conv-peer {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.chat-conv-peer-text { min-width: 0; }

.chat-conv-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conv-status {
    font-size: 12px;
    color: var(--fg-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conv-status.online { color: var(--success); }

/* ─────────────────────────── ЛЕНТА СООБЩЕНИЙ ─────────────────────────── */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 14px 16px 6px;
    display: flex;
    flex-direction: column;
}

.chat-messages-inner {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
}

.chat-load-more {
    display: flex;
    justify-content: center;
    padding-bottom: 12px;
}

.chat-load-more .ghost {
    font-size: 12.5px;
    padding: 6px 14px;
}

.chat-messages-empty {
    text-align: center;
    color: var(--fg-dim);
    font-size: 13px;
    padding: 40px 20px;
}

.chat-date-sep {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 14px 0 8px;
}

.chat-date-sep span {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--fg-dim);
    background: var(--bg-2);
    border: 1px solid var(--border);
    padding: 3px 12px;
    border-radius: 999px;
}

.msg-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 2px;
    max-width: 100%;
}

.msg-row.group-start { margin-top: 10px; }

.msg-row.mine { flex-direction: row-reverse; }

.msg-av {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: var(--accent);
    visibility: hidden;
}

.msg-row.group-start .msg-av { visibility: visible; }

.msg-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: min(640px, 76%);
}

.msg-row.mine .msg-col { align-items: flex-end; }

.msg-sender {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--fg-dim);
    margin: 0 4px 3px;
}

.msg-bubble {
    position: relative;
    padding: 7px 11px 8px;
    border-radius: 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.42;
    color: var(--fg);
    white-space: normal;
}

/* Переносы строк сохраняем только в самом тексте сообщения, а не в
   разметке вложения/кнопок внутри пузыря. */
.msg-text {
    display: block;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.msg-row.mine .msg-bubble {
    background: var(--accent-soft);
    border-color: var(--accent-soft-2);
}

.msg-bubble.deleted {
    font-style: italic;
    color: var(--fg-dim);
    background: transparent;
    border-style: dashed;
}

.msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    color: var(--fg-dim);
    margin: 3px 4px 0;
}

.msg-meta .ico { width: 13px; height: 13px; }

/* Галочки прочтения: одна — отправлено, две — прочитано. */
.msg-read {
    display: inline-flex;
    align-items: center;
    color: var(--fg-dim);
    opacity: 0.8;
}

.msg-read.read, .msg-meta .read { color: var(--accent); opacity: 1; }

.msg-reply {
    display: flex;
    gap: 6px;
    padding: 4px 8px;
    margin-bottom: 5px;
    border-left: 2px solid var(--accent);
    background: var(--bg-3);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    max-width: 100%;
}

.msg-reply-author { font-weight: 600; color: var(--accent); flex-shrink: 0; }

.msg-reply-text {
    color: var(--fg-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-forwarded {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-forwarded .ico { width: 13px; height: 13px; }

.msg-actions {
    position: absolute;
    top: -12px;
    display: flex;
    gap: 2px;
    padding: 2px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 8px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
    z-index: 3;
}

.msg-row.mine .msg-actions { left: 0; }
.msg-row:not(.mine) .msg-actions { right: 0; }

.msg-bubble:hover .msg-actions,
.msg-actions:focus-within {
    opacity: 1;
    pointer-events: auto;
}

.msg-actions button {
    background: none;
    border: none;
    padding: 3px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--fg-dim);
    display: flex;
    align-items: center;
}

.msg-actions button:hover { background: var(--bg-2); color: var(--fg); }
.msg-actions button .ico { width: 15px; height: 15px; }

.msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 5px 4px 0;
}

.msg-row.mine .msg-reactions { justify-content: flex-end; }

.msg-reaction {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    font-size: 12px;
    cursor: pointer;
    color: var(--fg);
}

.msg-reaction.mine {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.msg-reaction-count { font-size: 11px; color: var(--fg-dim); }
.msg-reaction.mine .msg-reaction-count { color: var(--accent); }

/* ─────────────────────────── ВЛОЖЕНИЯ ─────────────────────────── */

.msg-atts {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
}

.msg-att-image {
    display: block;
    max-width: 320px;
    max-height: 320px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: zoom-in;
    background: var(--bg-3);
}

.msg-att-image img {
    display: block;
    max-width: 100%;
    max-height: 320px;
    object-fit: cover;
}

.msg-att-video {
    max-width: 360px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #000;
    display: block;
}

.msg-att-audio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    min-width: 240px;
    max-width: 340px;
}

.msg-att-audio audio { flex: 1; height: 32px; min-width: 0; }

.msg-att-voice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    min-width: 220px;
}

.msg-att-voice audio { flex: 1; height: 30px; min-width: 0; }

.msg-att-voice-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
}

.msg-att-voice-icon .ico { width: 16px; height: 16px; }

.msg-att-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--fg);
    max-width: 320px;
}

.msg-att-file:hover { border-color: var(--accent); }

.msg-att-file-icon {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-3);
    color: var(--fg-dim);
}

.msg-att-file-icon .ico { width: 19px; height: 19px; }

.msg-att-file-info { min-width: 0; }

.msg-att-file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-att-file-size { font-size: 11px; color: var(--fg-dim); }

.msg-att-missing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px dashed var(--border);
    color: var(--fg-dim);
    font-size: 12.5px;
    font-style: italic;
    max-width: 320px;
}

.msg-forced-att {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ─────────────────────────── «ПЕЧАТАЕТ…» ─────────────────────────── */

.chat-typing {
    flex-shrink: 0;
    padding: 2px 18px 4px;
    font-size: 12px;
    color: var(--fg-dim);
    min-height: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-typing-dots { display: inline-flex; gap: 3px; }

.chat-typing-dots i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--fg-dim);
    animation: chat-typing-bounce 1.1s infinite ease-in-out;
}

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

@keyframes chat-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-3px); opacity: 1; }
}

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

.chat-composer {
    position: relative;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    padding: 8px 12px 10px;
    background: var(--bg);
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.chat-input-row textarea {
    flex: 1;
    min-width: 0;
    resize: none;
    max-height: 160px;
    padding: 9px 12px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--fg);
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    outline: none;
}

.chat-input-row textarea:focus { border-color: var(--accent); }

.chat-send-btn,
.chat-mic-btn { color: var(--accent); }

.chat-send-btn:hover,
.chat-mic-btn:hover { background: var(--accent-soft); }

.chat-input-row .icon-btn:disabled { opacity: 0.45; cursor: default; }

.chat-reply-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 6px 10px;
    border-left: 3px solid var(--accent);
    background: var(--bg-2);
    border-radius: 8px;
    font-size: 12.5px;
}

.chat-reply-bar-text {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--fg-dim);
}

.chat-reply-bar-author { font-weight: 600; color: var(--accent); }

.chat-drafts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.chat-draft {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 260px;
    padding: 6px 26px 6px 6px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 12.5px;
}

.chat-draft-thumb {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    object-fit: cover;
    background: var(--bg-3);
    flex-shrink: 0;
}

.chat-draft-icon {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    background: var(--bg-3);
    color: var(--fg-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-draft-icon .ico { width: 18px; height: 18px; }

.chat-draft-info { min-width: 0; }

.chat-draft-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

.chat-draft-size { font-size: 11px; color: var(--fg-dim); }

.chat-draft-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--bg-3);
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-draft-remove:hover { background: var(--danger); color: #fff; }

.chat-draft-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 0 0 10px 10px;
    transition: width 0.15s;
}

/* ─────────────────────────── ЗАПИСЬ ГОЛОСА ─────────────────────────── */

.chat-recording {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px 2px;
    font-size: 13px;
}

.chat-rec-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    animation: chat-rec-pulse 1s infinite;
}

@keyframes chat-rec-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.25; }
}

.chat-rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.chat-rec-hint { flex: 1; color: var(--fg-dim); font-size: 12.5px; }

/* ─────────────────────────── ЭМОДЗИ ─────────────────────────── */

.emoji-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 12px;
    right: 12px;
    max-width: 360px;
    height: 280px;
    overflow-y: auto;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 30px var(--shadow);
    padding: 8px;
    z-index: 30;
}

.emoji-cat-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--fg-dim);
    padding: 8px 4px 4px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}

.emoji-grid button {
    background: none;
    border: none;
    padding: 4px 0;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.emoji-grid button:hover { background: var(--bg-3); }

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

.chat-new-search { margin-bottom: 12px; }

.chat-new-list {
    max-height: 340px;
    overflow-y: auto;
    margin: 0 -4px;
}

.chat-new-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
}

.chat-new-item:hover { background: var(--bg-2); }

.chat-new-item.selected { background: var(--accent-soft); }

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

.chat-new-item-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-new-item-sub { font-size: 11.5px; color: var(--fg-dim); }

.chat-new-item-mark {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
}

.chat-new-item.selected .chat-new-item-mark {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.chat-new-item-mark .ico { width: 13px; height: 13px; }

.chat-group-title-row { margin-bottom: 12px; }

.chat-picker-hint {
    font-size: 12.5px;
    color: var(--fg-dim);
    margin-bottom: 6px;
}

/* ─────────────────────────── ПИКЕР БИБЛИОТЕКИ ─────────────────────────── */

.chat-lib-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.chat-lib-tabs .tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--fg-dim);
    cursor: pointer;
}

.chat-lib-tabs .tab.active { border-color: var(--accent); color: var(--accent); }
.chat-lib-tabs .tab .ico { width: 17px; height: 17px; }

.chat-lib-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 6px;
    max-height: 380px;
    overflow-y: auto;
}

.chat-lib-cell {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-3);
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-lib-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }

.chat-lib-cell.selected { outline: 2px solid var(--accent); outline-offset: -2px; }

.chat-lib-cell-mark {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid #fff;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
}

.chat-lib-cell.selected .chat-lib-cell-mark {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.chat-lib-cell-mark .ico { width: 13px; height: 13px; }

.chat-lib-dur {
    position: absolute;
    top: 5px;
    left: 5px;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 10.5px;
    font-variant-numeric: tabular-nums;
}

.chat-lib-name {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 5px 4px;
    font-size: 10.5px;
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Скрытый input для выбора файлов. Именно уводим за край экрана, а не
   display:none — так диалог выбора гарантированно открывается во всех
   браузерах (в части движков клик по display:none-инпуту игнорируется). */
.chat-file-input {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* ─────────────────────────── МЕНЮ «СКРЕПКИ» ─────────────────────────── */

.chat-attach-menu {
    position: fixed;
    z-index: 400;
    display: flex;
    flex-direction: column;
    min-width: 210px;
    padding: 5px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow);
}

.chat-attach-menu button {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 8px;
    color: var(--fg);
    font: inherit;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}

.chat-attach-menu button:hover { background: var(--bg-3); }

.chat-attach-menu button .ico {
    width: 17px;
    height: 17px;
    color: var(--fg-dim);
    flex-shrink: 0;
}

/* ─────────────────────────── ЛАЙТБОКС ─────────────────────────── */

.chat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: var(--overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.chat-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.chat-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-lightbox-close .ico { width: 20px; height: 20px; }

/* ─────────────────────────── АДАПТИВ ─────────────────────────── */

@media (max-width: 900px) {
    .chat-sidebar { width: 100%; border-right: none; }

    .chat-main { display: none; }

    #section-chat.mobile-chat-open .chat-sidebar { display: none; }
    #section-chat.mobile-chat-open .chat-main { display: flex; }

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

    .chat-conv-head { min-height: 52px; }

    .chat-messages { padding: 12px 10px 4px; }

    .msg-col { max-width: 84%; }

    .msg-att-image { max-width: 240px; }
    .msg-att-video { max-width: 260px; }
    .msg-att-image img { max-height: 240px; }

    .emoji-picker { left: 8px; right: 8px; max-width: none; height: 240px; }

    .chat-input-row textarea { font-size: 15px; }
}

/* Гостю доступен только мессенджер */
body.guest-mode #search-box,
body.guest-mode #nav-gallery,
body.guest-mode #nav-albums,
body.guest-mode #nav-files,
body.guest-mode #nav-music { display: none !important; }
