/* ========== RESET ========== */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* ========== THEME ========== */
:root, [data-theme="light"] {
    --bg: #ffffff; --bg-soft: #f8f7ff; --bg-hover: #f3f0ff;
    --border: #e9e5f5; --border-soft: #f0edf9;
    --text: #1a1a2e; --text-soft: #6b6b80; --text-mute: #a0a0b0;
    --primary: #8b5cf6; --primary-hover: #7c3aed; --primary-soft: #f3e8ff;
    --danger: #e53935; --green: #31a24c;
    --bubble-in: #ffffff; --bubble-out: #ede9fe;
    --shadow-sm: 0 1px 2px rgba(139,92,246,0.06);
    --shadow-md: 0 4px 12px rgba(139,92,246,0.08);
    --shadow-lg: 0 10px 40px rgba(139,92,246,0.14);
    --chat-bg: #f5f3ff;
    --chat-pattern: radial-gradient(circle at 20% 80%, rgba(139,92,246,0.06), transparent 40%),
                    radial-gradient(circle at 80% 20%, rgba(167,139,250,0.05), transparent 40%);
}
[data-theme="dark"] {
    --bg: #1a1626; --bg-soft: #120f1e; --bg-hover: #241f33;
    --border: #322b47; --border-soft: #28223a;
    --text: #f0ecfa; --text-soft: #9d95b3; --text-mute: #6b6480;
    --primary: #a78bfa; --primary-hover: #c4b5fd; --primary-soft: #2e1065;
    --danger: #ef5350; --green: #4dcd6a;
    --bubble-in: #241f33; --bubble-out: #4c1d95;
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.6);
    --chat-bg: #120f1e;
    --chat-pattern: radial-gradient(circle at 20% 80%, rgba(167,139,250,0.06), transparent 40%),
                    radial-gradient(circle at 80% 20%, rgba(167,139,250,0.05), transparent 40%);
}
[data-accent="violet"] { --primary: #8b5cf6; --primary-hover: #7c3aed; --primary-soft: #f3e8ff; --bubble-out: #ede9fe; }
[data-theme="dark"][data-accent="violet"] { --primary: #a78bfa; --primary-hover: #c4b5fd; --primary-soft: #2e1065; --bubble-out: #4c1d95; }
[data-accent="blue"] { --primary: #3b82f6; --primary-hover: #2563eb; --primary-soft: #dbeafe; --bubble-out: #dbeafe; }
[data-theme="dark"][data-accent="blue"] { --primary: #60a5fa; --primary-hover: #93c5fd; --primary-soft: #1e3a8a; --bubble-out: #1e40af; }
[data-accent="teal"] { --primary: #14b8a6; --primary-hover: #0d9488; --primary-soft: #ccfbf1; --bubble-out: #ccfbf1; }
[data-theme="dark"][data-accent="teal"] { --primary: #2dd4bf; --primary-hover: #5eead4; --primary-soft: #134e4a; --bubble-out: #115e59; }
[data-accent="green"] { --primary: #22c55e; --primary-hover: #16a34a; --primary-soft: #dcfce7; --bubble-out: #dcfce7; }
[data-theme="dark"][data-accent="green"] { --primary: #4ade80; --primary-hover: #86efac; --primary-soft: #14532d; --bubble-out: #166534; }
[data-accent="orange"] { --primary: #f97316; --primary-hover: #ea580c; --primary-soft: #ffedd5; --bubble-out: #ffedd5; }
[data-theme="dark"][data-accent="orange"] { --primary: #fb923c; --primary-hover: #fdba74; --primary-soft: #7c2d12; --bubble-out: #9a3412; }
[data-accent="red"] { --primary: #ef4444; --primary-hover: #dc2626; --primary-soft: #fee2e2; --bubble-out: #fee2e2; }
[data-theme="dark"][data-accent="red"] { --primary: #f87171; --primary-hover: #fca5a5; --primary-soft: #7f1d1d; --bubble-out: #991b1b; }
[data-accent="pink"] { --primary: #ec4899; --primary-hover: #db2777; --primary-soft: #fce7f3; --bubble-out: #fce7f3; }
[data-theme="dark"][data-accent="pink"] { --primary: #f472b6; --primary-hover: #f9a8d4; --primary-soft: #831843; --bubble-out: #9d174d; }

/* ========== BASE ========== */
html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg); color: var(--text);
    -webkit-font-smoothing: antialiased;
    transition: background 0.15s, color 0.15s;
}
body.chat-page { overflow: hidden; overscroll-behavior: none; -webkit-overflow-scrolling: touch; }
body.auth-page {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #f8f7ff 0%, #ede9fe 100%);
    min-height: 100vh;
}
[data-theme="dark"] body.auth-page { background: linear-gradient(135deg, #1a1626 0%, #2e1065 100%); }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea { font-family: inherit; color: inherit; }
.muted { color: var(--text-mute); font-size: 13px; }

/* ========== AUTH ========== */
.auth-wrap { width: 100%; max-width: 420px; padding: 24px; }
.auth-card { background: var(--bg); border-radius: 16px; padding: 40px 32px; box-shadow: var(--shadow-lg); }
.auth-logo {
    width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 28px; margin: 0 auto 20px;
    box-shadow: 0 8px 24px rgba(139,92,246,0.35);
}
.auth-card h1 { font-size: 24px; font-weight: 600; margin-bottom: 6px; text-align: center; }
.auth-sub { color: var(--text-soft); margin-bottom: 28px; font-size: 14px; text-align: center; }
.auth-form label { display: block; font-size: 13px; font-weight: 500; color: var(--text-soft); margin-bottom: 6px; margin-top: 14px; }
.auth-form input {
    width: 100%; padding: 12px 14px;
    border: 1.5px solid var(--border); border-radius: 10px;
    font-size: 15px; background: var(--bg); transition: border-color 0.15s;
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.auth-form button {
    width: 100%; padding: 13px; margin-top: 22px;
    background: var(--primary); color: #fff; border-radius: 10px;
    font-size: 15px; font-weight: 600; transition: background 0.15s;
}
.auth-form button:hover { background: var(--primary-hover); }
.auth-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--text-soft); }
.flash { padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; font-size: 14px; text-align: center; }
.flash.error { background: #fef2f2; color: #991b1b; }
.flash.info { background: var(--primary-soft); color: var(--primary); border: 1px solid var(--primary); }
.code-input { font-size: 24px !important; letter-spacing: 8px; text-align: center; font-family: 'Courier New', monospace; font-weight: 600; padding: 16px 14px !important; }
.resend-form { text-align: center; margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.link-btn { background: none; color: var(--primary); font-size: 14px; font-weight: 500; padding: 6px 10px; border-radius: 8px; transition: background 0.15s; }
.link-btn:hover:not(:disabled) { background: var(--primary-soft); }
.link-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.timer-hint { font-size: 12px; color: var(--text-mute); }

/* ========== APP LAYOUT ========== */
.app { display: flex; height: 100vh; width: 100%; background: var(--bg-soft); }

/* ========== SIDEBAR ========== */
.sidebar { width: 380px; flex-shrink: 0; background: var(--bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-header { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.me { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 6px 8px; border-radius: 10px; transition: background 0.15s; text-align: left; flex: 1; }
.me:hover { background: var(--bg-hover); }
.avatar { width: 42px; height: 42px; border-radius: 50%; color: #fff; font-weight: 600; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; user-select: none; overflow: hidden; }
.avatar.img { background-size: cover; background-position: center; color: transparent; font-size: 0; }
.avatar-sm { width: 40px; height: 40px; font-size: 15px; }
.avatar-xs { width: 34px; height: 34px; font-size: 13px; }
.avatar-lg { width: 80px; height: 80px; font-size: 30px; }
.me-info { min-width: 0; }
.me-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-status { font-size: 12px; color: var(--primary); }
.sidebar-actions { display: flex; gap: 2px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; color: var(--text-soft); display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn.danger:hover { background: rgba(229,57,53,0.1); color: var(--danger); }
.icon-btn.primary { background: var(--primary); color: #fff; }
.icon-btn.primary:hover { background: var(--primary-hover); }
.sidebar-search { padding: 8px 12px; }
.sidebar-search input { width: 100%; padding: 9px 14px; background: var(--bg-soft); border: 1.5px solid transparent; border-radius: 20px; font-size: 14px; transition: all 0.15s; }
.sidebar-search input:focus { outline: none; background: var(--bg); border-color: var(--primary); }
.avatar-wrap { position: relative; display: inline-block; flex-shrink: 0; }
.status-indicator { position: absolute; bottom: 0; right: 0; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg); background: var(--green); }
.status-indicator.away { background: #f59e0b; }
.status-indicator.busy { background: #ef4444; }
.status-indicator.dnd { background: #991b1b; }
.status-indicator.offline { background: #9ca3af; }

/* ========== FOLDERS ========== */
.folder-tabs { display: flex; gap: 4px; padding: 6px 10px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); background: var(--bg); }
.folder-tabs::-webkit-scrollbar { display: none; }
.folder-tab { display: flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 10px; font-size: 13px; font-weight: 500; color: var(--text-soft); cursor: pointer; white-space: nowrap; transition: all 0.15s; border: none; background: none; flex-shrink: 0; }
.folder-tab:hover { background: var(--bg-hover); color: var(--text); }
.folder-tab.active { background: var(--primary-soft); color: var(--primary); }
.folder-tab .folder-icon { font-size: 14px; }
.folder-tab.folder-add { padding: 7px 10px; font-size: 16px; font-weight: 700; color: var(--text-mute); }
.folder-tab.folder-add:hover { color: var(--primary); }
.folder-chat-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px; margin-bottom: 12px; }
.folder-chat-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background 0.1s; font-size: 14px; }
.folder-chat-item:hover { background: var(--bg-hover); }
.folder-chat-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

/* ========== CHAT LIST ========== */
.chat-list { flex: 1; overflow-y: auto; padding: 4px; }
.chat-item { padding: 9px 10px; border-radius: 10px; display: flex; gap: 11px; align-items: center; cursor: pointer; transition: background 0.12s; margin-bottom: 1px; position: relative; }
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--primary); color: #fff; }
.chat-item.active .chat-item-preview, .chat-item.active .chat-item-time, .chat-item.active .muted { color: rgba(255,255,255,0.75); }
.chat-item.active .badge { background: #fff; color: var(--primary); }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; align-items: center; }
.chat-item-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 5px; }
.chat-item-name .pin-icon { font-size: 12px; opacity: 0.7; }
.chat-item-time { font-size: 11.5px; color: var(--text-mute); flex-shrink: 0; }
.chat-item-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.chat-item-preview { font-size: 13.5px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.chat-item-preview .msg-prefix { color: var(--primary); font-weight: 500; }
.chat-item.active .chat-item-preview .msg-prefix { color: #fff; }
.badge { background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 12px; min-width: 20px; text-align: center; line-height: 16px; }
.chat-list-archived-toggle { display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin: 4px 6px; border-radius: 10px; font-size: 13.5px; color: var(--text-soft); cursor: pointer; transition: background 0.15s; user-select: none; }
.chat-list-archived-toggle:hover { background: var(--bg-hover); }
.chat-list-archived-toggle .count { margin-left: auto; background: var(--bg-soft); padding: 2px 8px; border-radius: 10px; font-size: 12px; }

/* ========== MAIN ========== */
.main { flex: 1; display: flex; flex-direction: column; background: var(--chat-bg); background-image: var(--chat-pattern); min-width: 0; position: relative; }
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-soft); gap: 10px; background: var(--bg); }
.empty-icon { font-size: 72px; margin-bottom: 12px; opacity: 0.6; }
.empty-state h2 { font-size: 22px; color: var(--text); font-weight: 600; }
.empty-state p { font-size: 14px; }

/* ========== CHAT VIEW — FIX: position relative для якорей панелей ========== */
.chat-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}
.chat-view.hidden, .empty-state.hidden { display: none; }

.chat-top { padding: 8px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--bg); z-index: 5; }
button.chat-top-info { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 6px 10px; margin: -6px -10px; border-radius: 10px; text-align: left; cursor: pointer; transition: background 0.15s; flex: 1; }
button.chat-top-info:hover { background: var(--bg-hover); }
.chat-title { font-weight: 600; font-size: 15px; }
.chat-subtitle { font-size: 12.5px; color: var(--text-soft); }
.in-chat-search { padding: 8px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; background: var(--bg); }
.in-chat-search.hidden { display: none; }
.in-chat-search input { flex: 1; padding: 8px 14px; background: var(--bg-soft); border: 1.5px solid transparent; border-radius: 20px; font-size: 14px; }
.in-chat-search input:focus { outline: none; border-color: var(--primary); background: var(--bg); }
.search-counter { font-size: 13px; color: var(--text-soft); min-width: 40px; text-align: right; }
.pinned-bar { padding: 6px 16px; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 13px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: background 0.15s; }
.pinned-bar:hover { background: var(--bg-hover); }
.pinned-bar.hidden { display: none; }
.pinned-bar .pin-icon { color: var(--primary); }
.pinned-bar .pin-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.messages-wrap { flex: 1; position: relative; min-height: 0; }
.messages { height: 100%; overflow-y: auto; padding: 16px 4% 24px; display: flex; flex-direction: column; gap: 2px; scroll-behavior: smooth; }

/* ========== MESSAGES ========== */
.date-sep { align-self: center; padding: 6px 12px; margin: 14px 0 8px; background: rgba(139,92,246,0.85); color: #fff; border-radius: 14px; font-size: 12px; font-weight: 500; backdrop-filter: blur(6px); user-select: none; }
[data-theme="dark"] .date-sep { background: rgba(167,139,250,0.5); }
.msg-row { display: flex; gap: 8px; max-width: 100%; position: relative; align-items: flex-end; padding: 0 8px; transition: background 0.2s; }
.msg-row.own { flex-direction: row-reverse; }
.msg-row.grouped { margin-top: 0; }
.msg-row:not(.grouped) { margin-top: 8px; }
.msg-row.highlight .msg { animation: highlight 1.5s ease; }
@keyframes highlight { 0%, 100% { background-color: inherit; } 0%, 50% { box-shadow: 0 0 0 2px var(--primary); } }
.msg-row .avatar { margin-bottom: 4px; flex-shrink: 0; }
.msg-row.grouped .avatar { visibility: hidden; }
.msg { max-width: min(560px, 72%); padding: 8px 12px 6px; border-radius: 12px; font-size: 15px; line-height: 1.35; word-wrap: break-word; position: relative; background: var(--bubble-in); color: var(--text); box-shadow: 0 1px 2px rgba(139,92,246,0.08); transition: box-shadow 0.15s; animation: msgIn 0.18s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px) scale(0.98); } to { opacity: 1; transform: none; } }
.msg.own { background: var(--bubble-out); }
[data-theme="dark"] .msg.own { background: var(--bubble-out); color: #fff; }
.msg.own .msg-meta { color: rgba(76,29,149,0.6); }
[data-theme="dark"] .msg.own .msg-meta { color: rgba(255,255,255,0.7); }
.msg-row:not(.grouped):not(.own) .msg::before, .msg-row:not(.grouped).own .msg::before { content: ""; position: absolute; bottom: 0; width: 12px; height: 18px; background: inherit; }
.msg-row:not(.grouped):not(.own) .msg::before { left: -6px; border-bottom-right-radius: 12px 14px; clip-path: polygon(100% 0, 100% 100%, 0 100%); }
.msg-row:not(.grouped).own .msg::before { right: -6px; border-bottom-left-radius: 12px 14px; clip-path: polygon(0 0, 100% 100%, 0 100%); }
.msg.deleted { opacity: 0.55; font-style: italic; font-size: 13.5px; background: var(--bg-soft); }
.msg-author { font-size: 12.5px; font-weight: 600; color: var(--primary); margin-bottom: 2px; }
.msg.own .msg-author { color: #6d28d9; }
[data-theme="dark"] .msg.own .msg-author { color: #ddd6fe; }
.msg-meta { font-size: 11px; color: rgba(0,0,0,0.4); display: inline-flex; align-items: center; gap: 3px; margin-left: 8px; vertical-align: bottom; float: right; padding-top: 2px; }
[data-theme="dark"] .msg-meta { color: rgba(255,255,255,0.5); }
.msg-edited { font-style: italic; opacity: 0.75; }

/* Reply */
.msg-reply { border-left: 3px solid var(--primary); padding: 4px 8px; background: rgba(139,92,246,0.08); border-radius: 6px; margin-bottom: 5px; font-size: 13px; cursor: pointer; transition: background 0.15s; }
.msg-reply:hover { background: rgba(139,92,246,0.15); }
.msg.own .msg-reply { background: rgba(109,40,217,0.1); border-color: #7c3aed; }
[data-theme="dark"] .msg.own .msg-reply { background: rgba(255,255,255,0.1); }
.msg-reply-name { font-weight: 600; color: var(--primary); margin-bottom: 1px; }
.msg.own .msg-reply-name { color: #7c3aed; }
[data-theme="dark"] .msg.own .msg-reply-name { color: #ddd6fe; }
.msg-reply-text { opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Files */
.msg-file { display: flex; align-items: center; gap: 10px; padding: 8px 6px; text-decoration: none; color: inherit; border-radius: 8px; transition: background 0.15s; }
.msg-file:hover { background: rgba(0,0,0,0.05); }
[data-theme="dark"] .msg-file:hover { background: rgba(255,255,255,0.06); }
.file-icon { font-size: 24px; }
.file-info { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.file-size { font-size: 11.5px; opacity: 0.7; }
.msg-image { margin: -2px -6px 4px; }
.msg-image img { max-width: 340px; max-height: 340px; border-radius: 10px; display: block; cursor: zoom-in; }
.msg-voice { display: flex; align-items: center; gap: 10px; min-width: 200px; padding: 2px 4px; }
.msg-voice audio { max-width: 260px; height: 34px; }
.voice-dur { font-size: 12px; opacity: 0.75; }

/* Actions + reactions */
.msg-actions { position: absolute; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; opacity: 0; pointer-events: none; transition: opacity 0.15s; background: var(--bg); padding: 4px; border-radius: 20px; box-shadow: var(--shadow-md); z-index: 3; }
.msg-row:hover .msg-actions { opacity: 1; pointer-events: auto; }
.msg-row:not(.own) .msg-actions { right: 8px; }
.msg-row.own .msg-actions { left: 8px; }
.msg-actions .action-btn { width: 32px; height: 32px; border-radius: 50%; color: var(--text-soft); display: flex; align-items: center; justify-content: center; transition: all 0.12s; font-size: 16px; }
.msg-actions .action-btn:hover { background: var(--bg-hover); color: var(--text); transform: scale(1.1); }
.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; align-self: flex-start; }
.reaction-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; background: var(--bg-soft); border-radius: 12px; font-size: 12.5px; cursor: pointer; transition: all 0.15s; border: 1.5px solid transparent; user-select: none; }
.reaction-chip:hover { background: var(--bg-hover); }
.reaction-chip.mine { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.msg.own .reaction-chip { background: rgba(109,40,217,0.1); }
.msg.own .reaction-chip.mine { background: rgba(139,92,246,0.25); border-color: var(--primary); color: #4c1d95; }
[data-theme="dark"] .msg.own .reaction-chip.mine { color: #ddd6fe; }
.reaction-chip .r-emoji { font-size: 14px; }
.reaction-chip .r-count { font-weight: 600; font-size: 11.5px; }
.reaction-popup { position: fixed; background: var(--bg); border-radius: 24px; padding: 6px; display: flex; gap: 2px; box-shadow: var(--shadow-lg); z-index: 250; border: 1px solid var(--border); }
.reaction-popup.hidden { display: none; }
.reaction-popup .reaction-btn { width: 38px; height: 38px; border-radius: 50%; font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.reaction-popup .reaction-btn:hover { background: var(--bg-hover); transform: scale(1.2); }

/* Typing + reply preview + recording */
.typing-bar { padding: 4px 24px; height: 22px; font-size: 12.5px; color: var(--text-soft); background: transparent; }
.reply-preview { padding: 8px 16px; background: var(--bg); border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.reply-preview.hidden { display: none; }
.reply-preview-body { flex: 1; min-width: 0; border-left: 3px solid var(--primary); padding: 2px 0 2px 10px; }
.reply-preview-name { font-size: 12.5px; font-weight: 600; color: var(--primary); }
.reply-preview-text { font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recording-bar { padding: 12px 16px; background: rgba(229,57,53,0.08); border-top: 1px solid rgba(229,57,53,0.2); display: flex; align-items: center; gap: 12px; color: var(--danger); }
.recording-bar.hidden { display: none; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.channel-notice { padding: 14px 20px; text-align: center; font-size: 13.5px; color: var(--text-soft); background: var(--bg); border-top: 1px solid var(--border); }
.channel-notice.hidden { display: none; }

/* Composer */
.composer { padding: 8px 14px 12px; display: flex; gap: 8px; align-items: flex-end; background: var(--bg); border-top: 1px solid var(--border); position: relative; }
.composer textarea { flex: 1; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: 20px; resize: none; font-size: 15px; line-height: 1.4; max-height: 140px; outline: none; background: var(--bg-soft); transition: all 0.15s; }
.composer textarea:focus { border-color: var(--primary); background: var(--bg); }
.send-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; transition: all 0.15s; flex-shrink: 0; }
.send-btn:hover { background: var(--primary-hover); transform: scale(1.05); }
.jump-down { position: absolute; bottom: 16px; right: 20px; width: 48px; height: 48px; border-radius: 50%; background: var(--bg); color: var(--text-soft); box-shadow: var(--shadow-md); display: flex; align-items: center; justify-content: center; transition: all 0.15s; z-index: 4; }
.jump-down:hover { color: var(--primary); transform: scale(1.08); }
.jump-down.hidden { display: none; }
.jump-badge { position: absolute; top: -6px; right: -6px; background: var(--primary); color: #fff; font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 12px; min-width: 22px; text-align: center; }
.jump-badge.hidden { display: none; }

/* Drop overlay */
.drop-overlay { position: absolute; inset: 0; background: rgba(139,92,246,0.15); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 40; pointer-events: none; }
.drop-overlay.hidden { display: none; }
.drop-overlay-inner { background: var(--bg); padding: 32px 48px; border-radius: 20px; border: 2px dashed var(--primary); text-align: center; font-size: 16px; font-weight: 500; }
.drop-icon { font-size: 48px; margin-bottom: 10px; }

/* ========== FORMAT BAR ========== */
.format-bar { display: flex; gap: 4px; padding: 6px 12px; border-top: 1px solid var(--border); background: var(--bg); align-items: center; }
.format-bar.hidden { display: none !important; }
.format-btn { width: 34px; height: 34px; border-radius: 8px; color: var(--text-soft); display: flex; align-items: center; justify-content: center; font-size: 15px; transition: all 0.12s; border: none; background: none; cursor: pointer; }
.format-btn:hover { background: var(--bg-hover); color: var(--text); }
.format-btn.format-close { margin-left: auto; font-size: 13px; }
.msg-text b, .msg-text strong { font-weight: 700; }
.msg-text i, .msg-text em { font-style: italic; }
.msg-text s, .msg-text del { text-decoration: line-through; opacity: 0.75; }
.msg-text code { font-family: 'Courier New', monospace; background: rgba(0,0,0,0.08); padding: 1px 5px; border-radius: 5px; font-size: 0.92em; }
[data-theme="dark"] .msg-text code { background: rgba(255,255,255,0.1); }
.msg.own .msg-text code { background: rgba(255,255,255,0.2); }
.msg-text pre { display: block; font-family: 'Courier New', monospace; background: rgba(0,0,0,0.08); padding: 8px 10px; border-radius: 8px; margin: 4px 0; white-space: pre-wrap; overflow-x: auto; font-size: 13px; line-height: 1.4; }
[data-theme="dark"] .msg-text pre { background: rgba(255,255,255,0.08); }
.msg.own .msg-text pre { background: rgba(255,255,255,0.15); }
.msg-text blockquote { display: block; border-left: 3px solid var(--primary); padding: 2px 0 2px 10px; margin: 4px 0; opacity: 0.85; font-style: italic; }
.msg.own .msg-text blockquote { border-color: rgba(255,255,255,0.6); }
.spoiler { background: rgba(0,0,0,0.75); color: transparent; border-radius: 5px; padding: 0 4px; cursor: pointer; user-select: none; transition: all 0.2s; }
.spoiler.revealed { background: rgba(139,92,246,0.15); color: inherit; }
.msg.own .spoiler { background: rgba(0,0,0,0.4); }
.msg.own .spoiler.revealed { background: rgba(255,255,255,0.25); }
.msg.msg-big-emoji { background: transparent !important; box-shadow: none !important; padding: 0; }
.msg.msg-big-emoji::before { display: none !important; }
.msg.msg-big-emoji .msg-text { font-size: 48px; line-height: 1.1; display: inline-block; }
.msg.msg-big-emoji .msg-meta { display: none; }
.msg.msg-sticker { background: transparent !important; box-shadow: none !important; padding: 0; }
.msg.msg-sticker::before { display: none !important; }
.msg.msg-sticker .msg-sticker-content { font-size: 96px; line-height: 1; display: inline-block; }

/* ========== PANELS (FIX: bottom: 76px) ========== */
.emoji-panel {
    position: absolute;
    bottom: 76px;
    left: 12px;
    right: 12px;
    max-width: 480px;
    background: var(--bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 65;
    max-height: 320px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.emoji-panel.hidden { display: none !important; }
.emoji-tabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tab { padding: 6px 10px; border-radius: 8px; font-size: 18px; cursor: pointer; transition: background 0.1s; border: none; background: none; flex-shrink: 0; }
.emoji-tab:hover { background: var(--bg-hover); }
.emoji-tab.active { background: var(--primary-soft); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 8px; overflow-y: auto; }
.emoji-btn { aspect-ratio: 1; border-radius: 8px; font-size: 22px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.1s, transform 0.1s; border: none; background: none; }
.emoji-btn:hover { background: var(--bg-hover); transform: scale(1.15); }

.sticker-panel {
    position: absolute;
    bottom: 76px;
    left: 12px;
    right: 12px;
    max-width: 480px;
    background: var(--bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 66;
    max-height: 340px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sticker-panel.hidden { display: none !important; }
.sticker-header { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.3px; }
.sticker-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; padding: 8px; overflow-y: auto; }
.sticker-btn { aspect-ratio: 1; border-radius: 10px; font-size: 42px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.12s; border: none; background: none; line-height: 1; }
.sticker-btn:hover { background: var(--bg-hover); transform: scale(1.1); }

.quick-reply-popup {
    position: absolute;
    bottom: 76px;
    left: 12px;
    right: 12px;
    max-width: 480px;
    background: var(--bg);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 60;
    max-height: 340px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.quick-reply-popup.hidden { display: none !important; }
.qr-header { padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.3px; }
.qr-add-btn { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.qr-add-btn:hover { background: var(--primary-hover); }
.qr-list { overflow-y: auto; padding: 4px; }
.qr-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; transition: background 0.1s; display: flex; align-items: center; gap: 10px; }
.qr-item:hover { background: var(--bg-hover); }
.qr-shortcut { font-family: 'Courier New', monospace; background: var(--bg-soft); padding: 3px 8px; border-radius: 6px; font-size: 12.5px; color: var(--primary); font-weight: 600; flex-shrink: 0; }
.qr-text { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.qr-empty { padding: 30px 20px; text-align: center; color: var(--text-mute); font-size: 13px; }
.settings-qr-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--bg-soft); margin-bottom: 6px; cursor: pointer; transition: background 0.12s; }
.settings-qr-item:hover { background: var(--bg-hover); }
.settings-qr-item .qr-shortcut { background: var(--bg); }

/* ========== GLOBAL SEARCH ========== */
.global-search-modal .modal-card { max-width: 640px; }
.gs-input-wrap { position: relative; margin-bottom: 14px; }
.gs-input-wrap input { width: 100%; padding: 14px 18px 14px 44px; border: 1.5px solid var(--border); border-radius: 14px; font-size: 16px; background: var(--bg-soft); transition: all 0.15s; }
.gs-input-wrap input:focus { outline: none; border-color: var(--primary); background: var(--bg); }
.gs-input-wrap::before { content: "🔍"; position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 16px; opacity: 0.6; }
.gs-tabs { display: flex; gap: 4px; margin-bottom: 12px; padding: 4px; background: var(--bg-soft); border-radius: 10px; }
.gs-tab { flex: 1; padding: 8px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-soft); text-align: center; cursor: pointer; transition: all 0.15s; border: none; background: none; }
.gs-tab.active { background: var(--bg); color: var(--primary); box-shadow: var(--shadow-sm); }
.gs-tab .count { background: var(--primary-soft); color: var(--primary); padding: 1px 6px; border-radius: 10px; font-size: 11px; margin-left: 4px; }
.gs-results { max-height: 420px; overflow-y: auto; }
.gs-section { margin-bottom: 14px; }
.gs-section-title { font-size: 12px; font-weight: 600; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 4px; }
.gs-result { padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background 0.1s; display: flex; align-items: flex-start; gap: 10px; }
.gs-result:hover { background: var(--bg-hover); }
.gs-result-body { flex: 1; min-width: 0; }
.gs-result-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.gs-result-text { font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gs-result-text mark { background: rgba(139,92,246,0.3); color: inherit; border-radius: 3px; padding: 0 2px; }
.gs-empty { text-align: center; padding: 40px 20px; color: var(--text-mute); font-size: 14px; }

/* ========== LINK PREVIEW ========== */
.link-preview { display: block; margin: 6px -4px 4px; padding: 8px; border-left: 3px solid var(--primary); background: rgba(139,92,246,0.06); border-radius: 0 8px 8px 0; text-decoration: none; color: inherit; transition: background 0.15s; }
.link-preview:hover { background: rgba(139,92,246,0.12); }
.msg.own .link-preview { background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.6); }
.link-preview-inner { display: flex; gap: 10px; align-items: flex-start; }
.link-preview-img { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--bg-soft); }
.link-preview-body { flex: 1; min-width: 0; }
.link-preview-site { font-size: 11px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.link-preview-title { font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }
.link-preview-desc { font-size: 12.5px; color: var(--text-soft); }

/* ========== STATUS ========== */
.status-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.status-option { padding: 12px 8px; border-radius: 10px; background: var(--bg-soft); border: 2px solid transparent; text-align: center; cursor: pointer; transition: all 0.15s; }
.status-option:hover { background: var(--bg-hover); }
.status-option.active { border-color: var(--primary); background: var(--primary-soft); }
.status-option-emoji { font-size: 22px; margin-bottom: 4px; }
.status-option-label { font-size: 12px; font-weight: 500; }

/* ========== BOOKMARKS ========== */
.bookmark-item { padding: 12px; border-radius: 10px; background: var(--bg-soft); margin-bottom: 8px; cursor: pointer; transition: background 0.15s; display: flex; gap: 12px; align-items: flex-start; }
.bookmark-item:hover { background: var(--bg-hover); }
.bookmark-body { flex: 1; min-width: 0; }
.bookmark-chat { font-size: 11px; color: var(--primary); font-weight: 600; margin-bottom: 4px; }
.bookmark-text { font-size: 13.5px; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.bookmark-note { font-size: 12px; color: var(--text-mute); font-style: italic; margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.bookmark-remove { color: var(--text-mute); font-size: 16px; padding: 4px; }
.bookmark-remove:hover { color: var(--danger); }
.pinned-item { padding: 12px; border-radius: 10px; background: var(--bg-soft); margin-bottom: 8px; cursor: pointer; transition: background 0.15s; }
.pinned-item:hover { background: var(--bg-hover); }
.pinned-item-author { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 4px; }
.pinned-item-text { font-size: 13.5px; color: var(--text); }
.pinned-item-date { font-size: 11px; color: var(--text-mute); margin-top: 4px; }

/* ========== PIN INPUT ========== */
.pin-input-wrap { display: flex; justify-content: center; gap: 10px; margin: 20px 0; }
.pin-digit { width: 48px; height: 56px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg-soft); text-align: center; font-size: 24px; font-weight: 700; outline: none; transition: all 0.15s; }
.pin-digit:focus { border-color: var(--primary); background: var(--bg); }

/* ========== TEXT SELECTION QUOTE ========== */
.text-selection-quote { position: fixed; background: var(--text); color: var(--bg); padding: 6px 12px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg); z-index: 500; cursor: pointer; animation: fadeIn 0.15s ease; }
.text-selection-quote:hover { transform: scale(1.05); }

/* ========== MODAL ========== */
.modal { position: fixed; inset: 0; background: rgba(26,22,38,0.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal.hidden { display: none; }
.modal-card { background: var(--bg); border-radius: 14px; width: 100%; max-width: 480px; padding: 20px; box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; animation: modalIn 0.2s ease; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-card input[type="text"] { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: 10px; font-size: 14px; margin-bottom: 12px; background: var(--bg); transition: border-color 0.15s; }
.modal-card input[type="text"]:focus { outline: none; border-color: var(--primary); }
.user-search-results { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; }
.user-row { padding: 10px 12px; cursor: pointer; display: flex; align-items: center; gap: 10px; transition: background 0.1s; }
.user-row:hover { background: var(--bg-hover); }
.user-row.selected { background: var(--primary-soft); }
.selected-users { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { background: var(--primary-soft); color: var(--primary); padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.chip button { color: var(--primary); font-size: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.btn { padding: 10px 18px; border-radius: 10px; font-size: 14px; font-weight: 500; transition: all 0.15s; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.secondary { background: var(--bg-soft); color: var(--text); }
.btn.secondary:hover { background: var(--bg-hover); }
.btn.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn.danger-btn { background: var(--danger); color: #fff; width: 100%; margin-top: 8px; }
.btn.danger-btn:hover { background: #c62828; }

/* ========== SETTINGS MODAL (FIX: прокрутка) ========== */
.modal-card.modal-settings {
    max-width: 600px;
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    min-height: 500px;
    overflow: hidden;
    border-radius: 14px;
}
.modal-card.modal-settings .modal-header {
    padding: 18px 20px 14px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.settings-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(139,92,246,0.4) transparent;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
    flex: 0 0 auto;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overscroll-behavior-x: contain;
}
.settings-tabs::-webkit-scrollbar { height: 6px; display: block; }
.settings-tabs::-webkit-scrollbar-track { background: rgba(139,92,246,0.08); border-radius: 3px; }
.settings-tabs::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.4); border-radius: 3px; }
.settings-tabs::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,0.6); }
.settings-tab {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-soft);
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: all 0.15s;
    border: none;
    background: none;
}
.settings-tab:hover { background: var(--bg-hover); color: var(--text); }
.settings-tab.active { background: var(--primary-soft); color: var(--primary); }
.settings-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeIn 0.2s ease; }
.settings-section { margin-bottom: 22px; }
.settings-section:last-child { margin-bottom: 0; }
.settings-section-title { font-size: 13px; font-weight: 600; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px; }
.settings-actions { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg); flex-shrink: 0; display: flex; gap: 8px; justify-content: flex-end; }
.setting-toggle { display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; border-bottom: 1px solid var(--border-soft); user-select: none; }
.setting-toggle:last-of-type { border-bottom: none; }
.setting-toggle > span:first-child { flex: 1; font-size: 14px; color: var(--text); }
.setting-toggle > input[type="checkbox"] { display: none; }
.toggle-slider { position: relative; width: 44px; height: 24px; background: var(--border); border-radius: 12px; transition: background 0.2s; flex-shrink: 0; }
.toggle-slider::before { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
.setting-toggle input:checked + .toggle-slider { background: var(--primary); }
.setting-toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; background: var(--bg-soft); border-radius: 10px; }
.seg-btn { padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-soft); cursor: pointer; transition: all 0.15s; border: none; background: none; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--bg); color: var(--primary); box-shadow: var(--shadow-sm); }
.accent-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.accent-cell { width: 100%; aspect-ratio: 1; border-radius: 12px; cursor: pointer; border: 3px solid transparent; transition: transform 0.12s; position: relative; }
.accent-cell:hover { transform: scale(1.08); }
.accent-cell.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.accent-cell.active::after { content: "✓"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 16px; text-shadow: 0 1px 2px rgba(0,0,0,0.4); }
.profile-avatar-wrap { display: flex; align-items: center; gap: 16px; padding: 8px 0 20px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.profile-avatar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.profile-info { min-width: 0; flex: 1; }
.profile-name { font-weight: 600; font-size: 17px; margin-bottom: 3px; }
.profile-email { font-size: 13px; }
.profile-presence { margin-top: 6px; font-size: 13px; font-weight: 500; }
.profile-presence.online { color: var(--green); }
.profile-presence.offline { color: var(--text-mute); }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-soft); margin: 14px 0 8px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 8px; }
.color-cell { width: 100%; aspect-ratio: 1; border-radius: 10px; cursor: pointer; border: 2px solid transparent; transition: transform 0.1s; }
.color-cell:hover { transform: scale(1.08); }
.color-cell.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.theme-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.theme-btn { padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg); font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 10px; transition: all 0.15s; }
.theme-btn:hover { background: var(--bg-hover); }
.theme-btn.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.theme-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--border); }
.theme-dot.light { background: #ffffff; }
.theme-dot.dark { background: #1a1626; }
.user-stats { padding: 14px 0; border-top: 1px solid var(--border); margin-top: 4px; font-size: 13px; }
.forward-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; }
.forward-item { padding: 10px 12px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: background 0.1s; border-bottom: 1px solid var(--border-soft); }
.forward-item:hover { background: var(--bg-hover); }
.forward-item.selected { background: var(--primary-soft); }
.forward-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.forward-item.selected .forward-check { background: var(--primary); border-color: var(--primary); color: #fff; }
.danger-zone .btn.secondary { width: 100%; margin-bottom: 8px; }
.hotkeys-hint { padding: 14px 0; font-size: 13px; color: var(--text-soft); }
.hotkey-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
.hotkey-row:last-child { border-bottom: none; }
.hotkey-key { background: var(--bg-soft); padding: 2px 8px; border-radius: 6px; font-family: 'Courier New', monospace; font-size: 12px; border: 1px solid var(--border); }

/* ========== ROLES ========== */
.role-badge { display: inline-block; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 6px; text-transform: uppercase; letter-spacing: 0.3px; margin-left: 6px; }
.role-badge.owner { background: #fbbf24; color: #78350f; }
.role-badge.admin { background: var(--primary-soft); color: var(--primary); }
.role-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); }
.role-row-info { flex: 1; min-width: 0; }
.role-row-name { font-weight: 500; font-size: 14px; }
.role-row-username { font-size: 12px; color: var(--text-soft); }
.role-select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); font-size: 13px; cursor: pointer; }

/* ========== STATS ========== */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--bg-soft); border-radius: 10px; padding: 14px; text-align: center; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.stat-bar-chart { margin-top: 8px; }
.stat-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.stat-bar-name { flex: 0 0 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-bar { flex: 1; height: 20px; background: var(--bg-soft); border-radius: 10px; position: relative; overflow: hidden; }
.stat-bar-fill { height: 100%; background: var(--primary); border-radius: 10px; transition: width 0.3s; }
.stat-bar-count { margin-left: 8px; font-weight: 600; color: var(--text-soft); min-width: 30px; text-align: right; }
.slow-mode-badge { font-size: 11px; color: var(--text-mute); padding: 4px 10px; background: var(--bg-soft); border-radius: 12px; margin: 8px 16px; text-align: center; }

/* ========== AUTO REPLY ========== */
.auto-item { padding: 12px; background: var(--bg-soft); border-radius: 10px; margin-bottom: 8px; cursor: pointer; transition: background 0.15s; }
.auto-item:hover { background: var(--bg-hover); }
.auto-item-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.auto-item-trigger { font-family: 'Courier New', monospace; background: var(--bg); padding: 3px 8px; border-radius: 6px; font-size: 12px; color: var(--primary); font-weight: 600; }
.auto-item-match { font-size: 11px; color: var(--text-mute); text-transform: uppercase; }
.auto-item-response { font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auto-item.disabled { opacity: 0.5; }

/* ========== CONTEXT MENU ========== */
.ctx-menu { position: fixed; background: var(--bg); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; z-index: 200; border: 1px solid var(--border); animation: ctxIn 0.12s ease; }
@keyframes ctxIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: none; } }
.ctx-menu.hidden { display: none; }
.ctx-item { padding: 9px 14px; border-radius: 7px; font-size: 14px; cursor: pointer; transition: background 0.1s; display: flex; align-items: center; gap: 10px; }
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: var(--danger); }
.ctx-item.danger:hover { background: rgba(229,57,53,0.1); }

/* ========== LIGHTBOX ========== */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; z-index: 300; cursor: zoom-out; animation: fadeIn 0.15s; }
.lightbox.hidden { display: none; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 8px; }

/* ========== TICKS ========== */
.ticks { display: inline-flex; align-items: center; opacity: 0.9; }
.ticks svg { width: 16px; height: 11px; }
.ticks.read svg { color: #a78bfa; }

/* ========== POLL ========== */
.msg-poll { min-width: 280px; max-width: 420px; padding: 4px 0; }
.poll-header { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; margin-bottom: 8px; flex-wrap: wrap; }
.poll-badge { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--bg-soft); color: var(--text-soft); font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }
.msg.own .poll-badge { background: rgba(255,255,255,0.2); color: #fff; }
.poll-sub { font-size: 12px; color: var(--text-soft); margin-bottom: 10px; }
.poll-option { position: relative; padding: 10px 12px; margin-bottom: 6px; border-radius: 10px; background: var(--bg-soft); cursor: pointer; overflow: hidden; transition: background 0.15s; border: 1.5px solid transparent; }
.poll-option:hover { background: var(--bg-hover); }
.poll-option.mine { border-color: var(--primary); background: var(--primary-soft); font-weight: 500; }
.msg.own .poll-option { background: rgba(255,255,255,0.15); }
.msg.own .poll-option.mine { background: rgba(255,255,255,0.25); border-color: #fff; }
.poll-option-fill { position: absolute; inset: 0; background: rgba(139,92,246,0.15); transition: width 0.4s ease; width: 0; z-index: 0; }
.poll-option.mine .poll-option-fill { background: rgba(139,92,246,0.28); }
.poll-option-content { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 14px; }
.poll-option-text { flex: 1; }
.poll-option-stats { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.poll-option-check { color: var(--primary); }
.poll-total { margin-top: 6px; font-size: 12px; color: var(--text-soft); }

/* ========== LOCATION ========== */
.msg-location { border-radius: 10px; overflow: hidden; max-width: 320px; cursor: pointer; background: var(--bg-soft); padding: 12px; display: flex; gap: 10px; align-items: center; transition: background 0.15s; }
.msg-location:hover { background: var(--bg-hover); }
.msg.own .msg-location { background: rgba(255,255,255,0.15); }
.location-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 20px; }
.location-info { min-width: 0; }
.location-title { font-weight: 600; font-size: 14px; }
.location-coords { font-size: 12px; color: var(--text-soft); }

/* ========== MENTIONS ========== */
.mention { color: var(--primary); font-weight: 600; background: rgba(139,92,246,0.12); padding: 1px 5px; border-radius: 5px; cursor: pointer; }
.msg.own .mention { color: #4c1d95; background: rgba(255,255,255,0.25); }
[data-theme="dark"] .msg.own .mention { color: #ddd6fe; background: rgba(255,255,255,0.2); }
.mention.me { background: var(--primary); color: #fff; }
.mention-suggest { position: absolute; bottom: 100%; left: 16px; right: 16px; background: var(--bg); border-radius: 12px 12px 0 0; box-shadow: var(--shadow-lg); border: 1px solid var(--border); max-height: 220px; overflow-y: auto; z-index: 60; }
.mention-suggest.hidden { display: none; }
.mention-item { padding: 10px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: background 0.1s; }
.mention-item:hover, .mention-item.active { background: var(--bg-hover); }
.mention-item .m-name { font-weight: 500; font-size: 14px; }
.mention-item .m-username { font-size: 12px; color: var(--text-soft); }

/* ========== MEDIA PANEL ========== */
.media-panel { position: absolute; top: 0; right: 0; bottom: 0; width: 380px; background: var(--bg); border-left: 1px solid var(--border); z-index: 50; display: flex; flex-direction: column; animation: slideInRight 0.2s ease; box-shadow: -4px 0 20px rgba(0,0,0,0.05); }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: translateX(0); } }
.media-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.media-tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.media-tab { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-soft); cursor: pointer; transition: all 0.15s; }
.media-tab:hover { background: var(--bg-hover); }
.media-tab.active { background: var(--primary-soft); color: var(--primary); }
.media-content { flex: 1; overflow-y: auto; padding: 10px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.media-cell { aspect-ratio: 1; border-radius: 6px; overflow: hidden; cursor: pointer; background: var(--bg-soft); position: relative; }
.media-cell img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.media-cell:hover img { transform: scale(1.05); }
.media-files-list { display: flex; flex-direction: column; gap: 6px; }
.media-file-item { padding: 10px 12px; border-radius: 8px; background: var(--bg-soft); display: flex; gap: 10px; align-items: center; font-size: 13px; cursor: pointer; transition: background 0.15s; }
.media-file-item:hover { background: var(--bg-hover); }
.media-empty { padding: 40px 20px; text-align: center; color: var(--text-mute); font-size: 13px; }

/* ========== NOTIFICATIONS ========== */
.notif-toast { position: fixed; bottom: 20px; left: 20px; background: var(--bg); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); display: flex; gap: 12px; align-items: center; z-index: 400; max-width: 360px; animation: slideInBottom 0.25s ease; cursor: pointer; }
@keyframes slideInBottom { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.notif-toast .n-body { min-width: 0; flex: 1; }
.notif-toast .n-title { font-weight: 600; font-size: 14px; }
.notif-toast .n-text { font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-toast .n-close { color: var(--text-mute); padding: 4px; }

/* ========== FONT/DENSITY/EMOJI SIZE ========== */
[data-fontsize="small"] { --msg-font-size: 13.5px; --msg-meta-size: 10.5px; }
[data-fontsize="medium"] { --msg-font-size: 15px; --msg-meta-size: 11px; }
[data-fontsize="large"] { --msg-font-size: 16.5px; --msg-meta-size: 12px; }
.msg { font-size: var(--msg-font-size, 15px); }
.msg-meta { font-size: var(--msg-meta-size, 11px); }
[data-density="compact"] .msg-row { margin-top: 4px; }
[data-density="compact"] .msg-row.grouped { margin-top: 1px; }
[data-density="compact"] .msg { padding: 5px 10px 3px; }
[data-density="compact"] .date-sep { margin: 8px 0 4px; }
[data-emojisize="small"] .reaction-chip .r-emoji { font-size: 12px; }
[data-emojisize="medium"] .reaction-chip .r-emoji { font-size: 14px; }
[data-emojisize="large"] .reaction-chip .r-emoji { font-size: 17px; }
[data-tail="off"] .msg::before { display: none !important; }
[data-pattern="off"] .main { background-image: none !important; }

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139,92,246,0.4); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(167,139,250,0.2); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(167,139,250,0.4); }

/* ========== MOBILE ========== */
.mobile-back { display: none; }
.app, .sidebar, .main { will-change: transform; }

@media (max-width: 1024px) {
    .sidebar { width: 320px; }
    .msg { max-width: min(480px, 75%); }
}
@media (max-width: 768px) {
    .app { position: relative; overflow: hidden; }
    .sidebar { position: fixed; inset: 0; width: 100%; max-width: none; border-right: none; z-index: 20; transform: translateX(0); transition: transform 0.25s ease, opacity 0.25s ease; }
    .main { position: fixed; inset: 0; z-index: 30; transform: translateX(100%); transition: transform 0.25s ease; padding-bottom: env(safe-area-inset-bottom); }
    .app.mobile-chat-open .main { transform: translateX(0); }
    .app.mobile-chat-open .sidebar { transform: translateX(-25%); opacity: 0.5; pointer-events: none; }
    .mobile-back { display: flex; margin-right: 4px; }
    .chat-top { padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); gap: 6px; }
    .chat-top-info { flex: 1; padding: 6px 8px; margin: -6px -4px; }
    .avatar { width: 40px; height: 40px; font-size: 15px; }
    .icon-btn { width: 42px; height: 42px; }
    .folder-tabs { padding: 4px 8px; }
    .folder-tab .folder-name { display: none; }
    .folder-tab.active .folder-name { display: inline; }
    .messages { padding: 12px 8px 18px; }
    .msg { max-width: 82%; font-size: 15px; padding: 8px 11px 6px; }
    .msg-row .avatar, .msg-row > div[style*="width: 34px"] { display: none !important; }
    .msg-actions { display: none !important; }
    .composer { padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
    .composer textarea { font-size: 16px; padding: 10px 14px; max-height: 100px; }
    .composer .icon-btn, .send-btn { width: 42px; height: 42px; flex-shrink: 0; }
    .modal { align-items: flex-end; padding: 0; }
    .modal-card { max-width: 100%; width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; padding: 20px 18px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
    .modal-card.modal-settings { border-radius: 20px 20px 0 0; max-height: 92vh; min-height: 70vh; padding: 0; }
    .settings-body { padding: 16px; min-height: 0; }
    .settings-tabs { padding: 6px 8px; }
    .settings-actions { padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    .settings-actions .btn { flex: 1; }
    .ctx-menu { left: 8px !important; right: 8px !important; top: auto !important; bottom: 0 !important; width: auto !important; max-width: none !important; border-radius: 16px 16px 0 0; padding: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); min-width: 0; }
    .ctx-item { padding: 14px 16px; font-size: 15px; }
    .reaction-popup { left: 8px !important; right: 8px !important; top: auto !important; bottom: calc(80px + env(safe-area-inset-bottom)) !important; width: auto !important; display: grid; grid-template-columns: repeat(8, 1fr); }
    .reaction-popup .reaction-btn { width: 100%; height: 44px; }
    body.auth-page { align-items: flex-start; padding-top: env(safe-area-inset-top); }
    .auth-wrap { padding: 16px; max-width: 100%; }
    .auth-card { padding: 32px 22px; }
    .auth-form input { font-size: 16px; }
    .emoji-panel, .sticker-panel, .quick-reply-popup {
        left: 6px; right: 6px; max-width: none;
        bottom: calc(76px + env(safe-area-inset-bottom));
    }
    .emoji-grid { grid-template-columns: repeat(7, 1fr); }
    .emoji-btn { font-size: 20px; }
    .sticker-btn { font-size: 36px; }
    .sticker-grid { grid-template-columns: repeat(4, 1fr); }
    .msg.msg-sticker .msg-sticker-content { font-size: 72px; }
    .media-panel { width: 100%; border-left: none; }
    .notif-toast { left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: none; }
    .pin-digit { width: 42px; height: 50px; font-size: 20px; }
    .status-picker { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 400px) {
    .msg { max-width: 88%; }
    .composer .icon-btn, .send-btn { width: 38px; height: 38px; }
}
@media (hover: none) {
    .chat-item:hover { background: transparent; }
    .chat-item.active:hover { background: var(--primary); }
    .icon-btn:hover { background: transparent; color: var(--text-soft); }
    .icon-btn.primary:hover { background: var(--primary); }
    .reaction-btn:hover { transform: none; }
    .icon-btn { min-width: 42px; min-height: 42px; }
}

/* ============================================================ */
/* ========== TWEMOJI — рендер эмодзи как SVG ================= */
/* ============================================================ */
img.emoji {
    height: 1em;
    width: 1em;
    margin: 0 0.05em 0 0.1em;
    vertical-align: -0.1em;
    display: inline-block;
    object-fit: contain;
}

/* Стикеры — крупные */
.sticker-btn img.emoji {
    height: 100%;
    width: 100%;
    margin: 0;
    vertical-align: middle;
}

/* Эмодзи-панель */
.emoji-btn img.emoji {
    height: 1em;
    width: 1em;
    margin: 0;
}

/* Реакции */
.reaction-chip .r-emoji img.emoji,
.reaction-popup .reaction-btn img.emoji {
    height: 1em;
    width: 1em;
    margin: 0;
}

/* Крупные эмодзи в сообщениях */
.msg.msg-big-emoji .msg-text img.emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
}

/* Стикер-сообщение */
.msg.msg-sticker .msg-sticker-content img.emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
}

/* Иконки в чате (📌📢⭐ и т.д.) */
.chat-item-name .pin-icon img.emoji,
.pinned-bar .pin-icon img.emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
}

/* ============================================================ */
/* ========== FALLBACK для эмодзи без SVG ====================== */
/* ============================================================ */
.emoji-fallback {
    display: inline-block;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
                 "Android Emoji", "EmojiSymbols", sans-serif;
    font-size: 1em;
    line-height: 1;
    vertical-align: -0.1em;
    text-align: center;
}

.emoji-btn .emoji-fallback {
    font-size: 22px;
}

.sticker-btn .emoji-fallback {
    font-size: 36px;
}

.reaction-chip .r-emoji .emoji-fallback,
.reaction-popup .reaction-btn .emoji-fallback {
    font-size: 1em;
}

.msg.msg-big-emoji .msg-text .emoji-fallback {
    font-size: 48px;
}

.msg.msg-sticker .msg-sticker-content .emoji-fallback {
    font-size: 96px;
}

/* Мобильная версия */
@media (max-width: 768px) {
    .emoji-btn .emoji-fallback { font-size: 20px; }
    .sticker-btn .emoji-fallback { font-size: 32px; }
    .msg.msg-big-emoji .msg-text .emoji-fallback { font-size: 40px; }
    .msg.msg-sticker .msg-sticker-content .emoji-fallback { font-size: 72px; }
}

/* ============================================================ */
/* ========== OPENMOJI — второй fallback ====================== */
/* ============================================================ */
img.emoji.openmoji {
    display: inline-block;
    height: 1em;
    width: 1em;
    object-fit: contain;
    vertical-align: -0.1em;
    margin: 0;
}

.emoji-btn img.emoji.openmoji {
    height: 1em;
    width: 1em;
}

.sticker-btn img.emoji.openmoji {
    height: 100%;
    width: 100%;
}

.reaction-chip .r-emoji img.emoji.openmoji,
.reaction-popup .reaction-btn img.emoji.openmoji {
    height: 1em;
    width: 1em;
}

.msg.msg-big-emoji .msg-text img.emoji.openmoji {
    height: 1em;
    width: 1em;
}

.msg.msg-sticker .msg-sticker-content img.emoji.openmoji {
    height: 1em;
    width: 1em;
}

@media (max-width: 768px) {
    .emoji-btn img.emoji.openmoji { height: 1em; width: 1em; }
    .sticker-btn img.emoji.openmoji { height: 100%; width: 100%; }
}

/* ============================================================ */
/* ========== OPENMOJI + emoji-fallback ======================= */
/* ============================================================ */
img.emoji {
    display: inline-block;
    height: 1em;
    width: 1em;
    object-fit: contain;
    vertical-align: -0.1em;
    margin: 0 0.05em 0 0.1em;
}

img.emoji.openmoji {
    margin: 0;
}

/* Панель эмодзи */
.emoji-btn img.emoji {
    height: 1em;
    width: 1em;
    margin: 0;
}

/* Стикеры — крупные */
.sticker-btn img.emoji {
    height: 100%;
    width: 100%;
    margin: 0;
    vertical-align: middle;
}

/* Реакции */
.reaction-chip .r-emoji img.emoji,
.reaction-popup .reaction-btn img.emoji {
    height: 1em;
    width: 1em;
    margin: 0;
}

/* Крупные эмодзи в сообщениях */
.msg.msg-big-emoji .msg-text img.emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
}

/* Стикер-сообщение */
.msg.msg-sticker .msg-sticker-content img.emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
}

/* Иконки в списке чатов */
.chat-item-name .pin-icon img.emoji,
.pinned-bar .pin-icon img.emoji {
    height: 1em;
    width: 1em;
    vertical-align: middle;
}

/* Юникод-fallback (когда нет ни Twemoji, ни OpenMoji) */
.emoji-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
                 "Android Emoji", "EmojiSymbols", sans-serif;
    font-size: 1em;
    line-height: 1;
    width: 100%;
    height: 100%;
    text-align: center;
}

.emoji-btn .emoji-fallback { font-size: 22px; }
.sticker-btn .emoji-fallback { font-size: 36px; }
.reaction-chip .r-emoji .emoji-fallback,
.reaction-popup .reaction-btn .emoji-fallback { font-size: 1em; }
.msg.msg-big-emoji .msg-text .emoji-fallback { font-size: 48px; }
.msg.msg-sticker .msg-sticker-content .emoji-fallback { font-size: 96px; }

/* Мобильная версия */
@media (max-width: 768px) {
    .emoji-btn img.emoji,
    .emoji-btn .emoji-fallback { height: 1em; width: 1em; font-size: 20px; }
    .sticker-btn img.emoji,
    .sticker-btn .emoji-fallback { height: 100%; width: 100%; font-size: 32px; }
    .msg.msg-big-emoji .msg-text img.emoji,
    .msg.msg-big-emoji .msg-text .emoji-fallback { font-size: 40px; }
    .msg.msg-sticker .msg-sticker-content img.emoji,
    .msg.msg-sticker .msg-sticker-content .emoji-fallback { font-size: 72px; }
}
