@font-face { font-family: 'Vazirmatn'; src: url('fonts/Vazir.ttf') format('truetype'); font-weight: normal; font-style: normal; font-display: swap; }
* { box-sizing: border-box; font-family: 'Vazirmatn', system-ui, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

:root { 
    --bg: #f3f4f6; --sidebar: #ffffff; --chat-bg: #e5e7eb; 
    --text: #1f2937; --subtext: #6b7280;
    --my-msg: #3b82f6; --my-text: #ffffff;
    --other-msg: #ffffff; --other-text: #1f2937;
    --accent: #2563eb; --border: #e5e7eb; --accent-rgb: 37, 99, 235; 
}
[data-theme="dark"] { 
    --bg: #0f172a; --sidebar: #1e293b; --chat-bg: #0f172a; 
    --text: #f8fafc; --subtext: #94a3b8;
    --my-msg: #2563eb; --my-text: #ffffff;
    --other-msg: #334155; --other-text: #f8fafc;
    --accent: #3b82f6; --border: #334155; --accent-rgb: 59, 130, 246; 
    color-scheme: dark; 
}
/* اسکرول‌بار مدرن و یکپارچه برای تمام بخش‌ها */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 0, 0, 0.3); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

body { margin: 0; background: var(--bg); color: var(--text); height: 100vh; height: 100dvh; display: flex; overflow: hidden; width: 100vw; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
input, textarea, #msg-input, .msg-content-text, .code-block, .code-inline { -webkit-user-select: text !important; user-select: text !important; }

#splash-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg); z-index: 99999; display: flex; flex-direction: column; justify-content: center; align-items: center; transition: opacity 0.3s ease; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--border); border-top: 4px solid var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 15px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.sidebar { width: 320px; background: var(--sidebar); border-left: 1px solid var(--border); display: flex; flex-direction: column; z-index: 10; transition: 0.3s; height: 100%; overflow-x: hidden !important; position: relative; }
.sidebar-header { padding: 15px 15px; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid var(--border); background: var(--sidebar); flex-shrink: 0; gap: 10px; transition: margin-top 0.35s cubic-bezier(0.1, 0.9, 0.2, 1); }
.group-list { flex: 1; overflow-y: auto; }
.group-item { padding: 15px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; align-items: center; gap: 10px; transition: 0.2s; font-size: 15px; font-weight: 500;}
.group-item:hover { background: rgba(0,0,0,0.03); }
.group-item.active { background: var(--accent); color: #fff; }
.group-item.active .chat-preview, .group-item.active span { color: #fff !important; }

.chat-preview { font-size: 12px; color: var(--subtext); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top:4px; display:block; width: 100%; }
.unread-badge { background: var(--accent); color: white; border-radius: 12px; padding: 2px 7px; font-size: 11px; margin-right: auto; font-weight: bold; }
.group-item.active .unread-badge { background: #fff; color: var(--accent); }
.chat-avatar { border-radius: 50%; object-fit: cover; background: #cbd5e1; display:flex; align-items:center; justify-content:center; color:#fff; font-weight:bold; flex-shrink:0;}

/* تنظیمات پس‌زمینه یکپارچه برای چت */
.chat-area { 
    flex: 1; display: flex; flex-direction: column; position: relative; transition: background-image 0.3s ease-in-out, 0.3s; height: 100%; min-width: 0; 
    background-size: cover !important; 
    background-position: center center !important; 
    background-attachment: fixed !important; 
    background-repeat: no-repeat !important; 
    background-image: url('bg/pcday.webp') !important;
}
[data-theme="dark"] .chat-area { background-image: url('bg/pcdark.webp') !important; }
.chat-bg { display: none !important; }

.chat-header { height: 60px !important; padding: 0 20px !important; box-sizing: border-box !important; background: var(--sidebar); border-bottom: 1px solid var(--border); font-weight: bold; z-index: 100; display: flex; align-items: center; gap: 10px; flex-shrink: 0; font-size: 16px; transition: margin-top 0.35s cubic-bezier(0.1, 0.9, 0.2, 1);}
.back-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text); padding: 5px; }

#pinned-bar { background: var(--sidebar); padding: 12px 20px; border-bottom: 1px solid var(--border); font-size: 13px; z-index: 1; border-right: 4px solid var(--accent); display: none; color: var(--text); flex-shrink: 0; cursor: pointer; transition: 0.2s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 45px; line-height: 1.5;}

.messages { position: relative; flex: 1; overflow-y: auto; padding: 0 20px 85px 20px; display: flex; flex-direction: column; gap: 12px; z-index: 1; box-sizing: border-box; }
.unread-divider {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 20;
    align-self: stretch;
    width: calc(100% + 30px);
    margin: 0 -10px 8px -20px;
    box-sizing: border-box;
    text-align: center;
    padding: 9px 14px;
    border-radius: 14px;
    border: 1px solid rgba(59, 130, 246, 0.16);
    background: rgba(255, 255, 255, 0.92);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    transition: transform 0.24s ease, opacity 0.24s ease, background-color 0.24s ease, border-radius 0.24s ease, box-shadow 0.24s ease, color 0.24s ease;
    opacity: 1;
    animation: unread-divider-pop 0.22s ease-out both;
}
.unread-divider.unread-divider-stuck {
    border-radius: 0 0 18px 18px;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
    background: rgba(255, 255, 255, 0.95);
}
[data-theme="dark"] .unread-divider {
    background: rgba(15, 23, 42, 0.92);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text);
}
[data-theme="dark"] .unread-divider.unread-divider-stuck {
    background: rgba(15, 23, 42, 0.96);
}
.unread-divider::before {
    content: '⏳';
    display: inline-block;
    margin-right: 6px;
    opacity: 0.8;
    transform: scale(0.95);
}
.unread-divider-hidden {
    opacity: 0;
    transform: translateY(-12px);
}
@keyframes unread-divider-pop {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
body.has-custom-bg .unread-divider {
    padding: 10px 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.18);
    border-color: rgba(255,255,255,0.22);
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
[data-theme="dark"] body.has-custom-bg .unread-divider {
    background: rgba(15,23,42,0.36);
    border-color: rgba(255,255,255,0.14);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.16);
}
.message { max-width: 80%; min-width: 120px; padding: 10px 14px 6px 14px; border-radius: 16px; position: relative; line-height: 1.6; word-wrap: break-word; overflow-wrap: break-word; box-shadow: 0 2px 4px rgba(0,0,0,0.05); font-size: 14px; transition: background-color 0.5s ease; border: none; }
.msg-me { background: var(--my-msg); color: var(--my-text); align-self: flex-start; border-bottom-right-radius: 2px; }
.msg-other { background: var(--other-msg); color: var(--other-text); align-self: flex-end; border-bottom-left-radius: 2px; }

.message.has-media { padding: 6px; padding-bottom: 8px; }
.message.has-media img, .message.has-media video { border-radius: 12px; width: 100%; display: block; margin: 0 auto 4px auto; }
.message.has-media .msg-header { margin-bottom: 4px; padding: 0 4px; }

.custom-voice-player { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.05); padding: 5px 10px; border-radius: 25px; margin: 5px 0; direction: ltr; min-width: 220px;}
.msg-me .custom-voice-player { background: rgba(255,255,255,0.2); }
.voice-play-btn { background: var(--accent); color: #fff; border: none; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; cursor: pointer; transition: 0.2s; flex-shrink: 0;}
.msg-me .voice-play-btn { background: #fff; color: var(--accent); }
.voice-play-btn:hover { transform: scale(1.05); }
.voice-track { flex: 1; height: 6px; background: rgba(0,0,0,0.15); border-radius: 3px; position: relative; cursor: pointer; display: flex; align-items: center;}
.msg-me .voice-track { background: rgba(255,255,255,0.3); }
.voice-fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--accent); border-radius: 3px; width: 0%; pointer-events: none; transition: width 0.1s linear;}
.msg-me .voice-fill { background: #fff; }
.voice-time { font-size: 11px; font-family: monospace; font-weight: bold; opacity: 0.8; min-width: 35px; text-align: center;}
.voice-speed-btn { background: rgba(0,0,0,0.1); border: none; border-radius: 10px; padding: 2px 6px; font-size: 11px; font-weight: bold; cursor: pointer; color: inherit; transition: 0.2s;}
.msg-me .voice-speed-btn { background: rgba(255,255,255,0.25); }

.msg-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 5px; }
.msg-name { font-size: 13px; color: var(--accent); font-weight: 700; cursor: pointer; opacity: 0.9; display:flex; align-items:center; gap:5px;}
.msg-me .msg-name { color: #e0f2fe; }

.msg-content-text { display: block; max-width: 100%; overflow-wrap: break-word; word-break: break-word; }
.msg-content-text a { text-decoration: underline; font-weight: 600; cursor: pointer; word-break: break-word; }
.msg-me .msg-content-text a { color: #ffffff !important; }
.msg-other .msg-content-text a { color: var(--accent) !important; }

/* استایل‌های ادغام شده برای نقل قول، کد و اسپویلر */
.blockquote, div#msg-input .blockquote {
    display: block !important;
    border-right: 3px solid var(--accent) !important;
    background: rgba(var(--accent-rgb), 0.1) !important;
    margin: 8px 0 !important;
    padding: 12px 10px 8px 10px !important;
    border-radius: 8px !important;
    position: relative !important;
    font-style: italic;
    line-height: 1.6;
    word-break: break-word;
    color: inherit;
}
.blockquote::before, div#msg-input .blockquote::before {
    content: '❞ نقل قول';
    position: absolute;
    top: 2px;
    right: 10px;
    font-size: 9px;
    font-weight: bold;
    opacity: 0.5;
    font-style: normal;
    color: var(--text);
    letter-spacing: 0.5px;
}
[data-theme="dark"] .blockquote, [data-theme="dark"] div#msg-input .blockquote { background: rgba(255,255,255,0.05) !important; }

.code-inline { padding:2px 5px; border-radius:4px; font-family:monospace; cursor:pointer; transition:0.2s; font-size:13px; direction: ltr; display: inline-block; word-break: break-word; white-space: pre-wrap; max-width: 100%; vertical-align: middle;}
.msg-me .code-inline { background: rgba(255,255,255,0.25) !important; color: #ffffff !important; }
.msg-other .code-inline { background: rgba(0,0,0,0.05) !important; color: #ef4444 !important; }

.code-block, div#msg-input .code-block {
    display: block !important;
    background: rgba(0,0,0,0.1) !important;
    padding: 10px !important;
    border-radius: 8px !important;
    font-family: monospace !important;
    font-size: 13px !important;
    margin: 5px 0 !important;
    text-align: left !important;
    direction: ltr !important;
    cursor: pointer;
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: inherit;
}
[data-theme="dark"] .code-block, [data-theme="dark"] div#msg-input .code-block { background: rgba(255,255,255,0.1) !important; }
.msg-other .code-block { background:#1e293b !important; color:#38bdf8 !important; }

.spoiler, div#msg-input .spoiler {
    background: #4b5563 !important;
    color: transparent !important;
    border-radius: 4px !important;
    padding: 0 6px !important;
    cursor: pointer !important;
    display: inline-block !important;
    transition: all 0.3s ease !important;
    user-select: none;
}
.spoiler.revealed, div#msg-input .spoiler.revealed { background: rgba(0,0,0,0.1) !important; color: inherit !important; }
[data-theme="dark"] .spoiler, [data-theme="dark"] div#msg-input .spoiler { background: rgba(255,255,255,0.5) !important; color: rgba(0,0,0,0.3) !important; }
[data-theme="dark"] .spoiler.revealed, [data-theme="dark"] div#msg-input .spoiler.revealed { background: rgba(255,255,255,0.1) !important; color: inherit !important; }

.more-btn { background: none; border: none; font-size: 20px; cursor: pointer; color: inherit; opacity: 0; visibility: hidden; transition: 0.2s; padding: 0 5px; line-height: 0.8; font-weight: bold; margin-right: auto; }
.message:hover .more-btn { opacity: 0.8; visibility: visible; }

.reply-box { font-size: 12px; padding: 6px 10px; margin-bottom: 8px; border-radius: 6px; cursor: pointer; transition: 0.2s; border-right: 3px solid currentColor; background: rgba(0,0,0,0.05); }
.msg-me .reply-box { background: rgba(255,255,255,0.2); border-color: #ffffff; color: #ffffff; }
.msg-other .reply-box { border-color: var(--accent); color: var(--text); }

.edited-tag { font-size: 11px; opacity: 0.6; font-style: italic; margin-right: 5px; }
.msg-meta { font-size: 11px; opacity: 0.7; text-align: left; margin-top: 4px; display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.msg-me .msg-meta { color: #e0f2fe; }
.msg-other .msg-meta { color: var(--subtext); }
.msg-ticks { font-size: 13px; margin-right: 2px; letter-spacing: -2px; }
.tick-read { color: #38bdf8; text-shadow: 0 0 1px rgba(0,0,0,0.2); }

#menu-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); z-index: 9999; animation: fadeIn 0.2s; }
#context-menu, #editor-menu { display: none; position: fixed; background: var(--sidebar); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 25px rgba(0,0,0,0.25); z-index: 10001; flex-direction: column; min-width: 180px; overflow: hidden; animation: popInMenu 0.2s ease-out forwards; padding: 5px 0;}
#context-menu button, #editor-menu button { padding: 12px 15px; text-align: right; background: none; border: none; color: var(--text); cursor: pointer; font-family: inherit; font-size: 14px; transition: 0.2s; display:flex; align-items:center; gap:8px; outline:none; -webkit-tap-highlight-color: transparent;}
#context-menu button:hover, #editor-menu button:hover { background: var(--chat-bg); color: var(--accent); padding-right: 20px; font-weight: bold; }

@keyframes pulseRec { 0% { opacity: 1; transform: scale(1); } 50% { opacity: 0.5; transform: scale(1.3); } 100% { opacity: 1; transform: scale(1); } }
.recording-pulse { animation: pulseRec 1.2s infinite ease-in-out; }

.input-container { background: var(--sidebar); padding: 12px 20px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; z-index: 100; border-top: 1px solid var(--border); flex-shrink: 0; box-shadow: 0 -2px 10px rgba(0,0,0,0.02); transition: 0.3s; position:relative;}
#reply-indicator { display: none; font-size: 13px; margin-bottom: 10px; padding: 8px 12px; background: var(--chat-bg); border-radius: 8px; cursor: pointer; border-right: 4px solid var(--accent); overflow:hidden;}
.input-row { display: flex; gap: 10px; align-items: flex-end; width:100%;}

#msg-input { flex: 1; border-radius: 20px; padding: 12px 20px; border: 1px solid var(--border); background: var(--bg); color: var(--text); outline: none; font-size: 15px; transition: border-color 0.2s; resize: none; overflow-y: auto; max-height: 120px; min-height: 48px; line-height: 1.5; font-family: inherit; -webkit-touch-callout: none; cursor: text; word-break: break-word; }
#msg-input:focus { border-color: var(--accent); }
#msg-input:empty:before { content: attr(data-placeholder); color: var(--subtext); pointer-events: none; display: block; }
#msg-input b, #msg-input strong { font-weight: bold; color: var(--accent); }
#msg-input u { text-decoration: underline; text-underline-offset: 4px; }
#msg-input code { background: rgba(0,0,0,0.1); padding: 2px 5px; border-radius: 4px; font-family: monospace; font-size: 13px; }
[data-theme="dark"] #msg-input code { background: rgba(255,255,255,0.1); }

.btn { background: var(--accent); color: white; border: none; padding: 12px 20px; border-radius: 25px; cursor: pointer; font-weight: bold; font-size: 14px; transition: 0.2s; box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2); height: 48px;}
.btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none;}
.btn-red { background: #ef4444 !important; color: white !important; }

.icon-btn { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--subtext); padding: 5px; transition: 0.2s; height: 48px; display:flex; align-items:center; justify-content:center; -webkit-tap-highlight-color: transparent;}
.icon-btn:hover { color: var(--accent); transform: scale(1.1);}

.channel-disabled-msg { text-align: center; color: var(--subtext); font-size: 13px; padding: 10px; font-weight: bold;}
#load-older-indicator { text-align: center; padding: 10px 12px; font-size: 13px; color: var(--subtext); display: none; border-radius: 14px; background: rgba(255,255,255,0.04); backdrop-filter: blur(8px); transition: opacity 0.2s ease, transform 0.2s ease; margin: 8px 12px; flex-direction: column; gap: 8px; }
#load-older-indicator.visible { display: inline-flex; opacity: 1; transform: translateY(-3px); align-items: center; justify-content: center; gap: 8px; }
#load-older-indicator.visible::before { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; }
#load-older-indicator.error { display: flex; opacity: 1; color: #ef4444; background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.25); transform: none; }
#load-older-indicator.error::before { display: none; }
#load-older-indicator .load-error-retry { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 6px 14px; font-size: 12px; cursor: pointer; font-family: inherit; }
#load-older-indicator .load-error-details { font-size: 11px; color: var(--subtext); text-align: right; width: 100%; }
#load-older-indicator .load-error-details pre { white-space: pre-wrap; word-break: break-word; background: var(--chat-bg); padding: 8px; border-radius: 8px; margin-top: 6px; max-height: 120px; overflow-y: auto; direction: ltr; text-align: left; font-size: 10px; }
.message.msg-broken { opacity: 0.85; border: 1px dashed rgba(239,68,68,0.35); border-radius: 12px; padding: 4px; }

.jump-loading-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--sidebar); padding: 16px 24px; border-radius: 16px; box-shadow: 0 16px 30px rgba(0,0,0,0.25); z-index: 1000; display: flex; gap: 12px; align-items: center; color: var(--text); font-weight: bold; border: 1px solid rgba(255,255,255,0.08); }
.jump-loading-spinner { width: 18px; height: 18px; border: 3px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 1s linear infinite; }

#scroll-to-bottom-btn { position: fixed; bottom: 85px; left: 20px; background: var(--accent); color: white; border: none; border-radius: 50%; width: 44px; height: 44px; font-size: 20px; cursor: pointer; display: none; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,0.3); z-index: 100; transition: bottom 0.2s ease, transform 0.2s ease; }
#scroll-to-bottom-btn:hover { transform: scale(1.1); }

#lightbox { display:none; position:fixed; top:0; right:0; bottom:0; left:0; background:rgba(0,0,0,0.95); z-index:999999; flex-direction:column; justify-content:center; align-items:center; }
#lightbox .lightbox-wrapper { width:100%; height:100%; display:flex; justify-content:center; align-items:center; overflow:auto; }
#lightbox img, #lightbox video { max-width:100%; max-height:100%; object-fit:contain; transition: transform 0.2s ease; }

#drag-overlay { display:none; position:fixed; top:0; right:0; bottom:0; left:0; background:rgba(37,99,235,0.85); z-index:9999999; justify-content:center; align-items:center; color:#fff; font-size:28px; font-weight:bold; border: 8px dashed rgba(255,255,255,0.6); box-sizing:border-box; pointer-events:none; }

#toast-container { position: fixed; bottom: 85px; left: 50%; transform: translateX(-50%); z-index: 999999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; align-items: center; width:100%;}
.toast-msg { background: rgba(0,0,0,0.85); color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 13px; font-weight: bold; box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: popUp 0.3s ease-out; transition: opacity 0.3s; max-width:90%; text-align:center;}
.toast-msg.toast-error { background: rgba(185,28,28,0.95); }

#in-app-toast { position: fixed; top: -100px; left: 50%; transform: translateX(-50%); background: rgba(30, 41, 59, 0.95); color: #fff; backdrop-filter: blur(10px); padding: 12px 15px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.25); display: flex; align-items: center; gap: 12px; z-index: 9999999; transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); width: 90%; max-width: 400px; cursor: pointer; border: 1px solid rgba(255,255,255,0.1); max-height: 70px; overflow: hidden; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popUp { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal { 
    display: none; position: fixed; top:0; left:0; width:100%; height:100%; 
    background: rgba(0,0,0,0.6); 
    -webkit-backdrop-filter: blur(4px); 
    backdrop-filter: blur(4px); 
    z-index: 9999; justify-content: center; align-items: center; animation: fadeIn 0.2s ease-out; 
}
.modal-content, #auth-box { animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; background: var(--bg); padding: 30px; border-radius: 20px; width: 90%; max-width: 400px; text-align: center; position: relative; box-shadow: 0 20px 40px rgba(0,0,0,0.2);}
.modal input[type="text"], .modal textarea { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid var(--border); border-radius: 10px; background: var(--sidebar); color: var(--text); outline: none; transition: 0.2s;}
.close-x { position: absolute; top: 15px; left: 15px; font-size: 28px; color: var(--subtext); background: none; border: none; cursor: pointer; line-height: 1; transition: 0.2s; }

.hamburger-btn { background:none; border:none; padding:12px 15px; text-align:right; font-family:inherit; color:var(--text); cursor:pointer; border-radius:8px; font-size:14px; transition:0.2s; display:block; width:100%; font-weight:bold; }
.hamburger-btn:hover { background:var(--chat-bg); color:var(--accent); }

@media (max-width: 768px) { 
    .sidebar { width: 100%; } .chat-area { display: none; width: 100%; }
    body.chat-active .sidebar { display: none; } body.chat-active .chat-area { display: flex; }
    .back-btn { display: block; } .message { max-width: 90%; }
    .more-btn { opacity: 0.4; visibility: visible; font-size: 26px; padding: 5px 10px; }
    #emoji-btn { display: none !important; }
    #global-audio-bar { top: 0; }
    .chat-header { flex-direction: row-reverse !important; }
    #chat-header-avatar { margin-right: 10px !important; margin-left: 0 !important; }
    #chat-title { margin-right: auto !important; margin-left: 0 !important; text-align: left !important; }
}

@keyframes slideInDown { from { transform: translateY(-100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.multi-bar-anim { animation: slideInDown 0.25s cubic-bezier(0.1, 0.9, 0.2, 1) forwards; }
@keyframes slideOutUp { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-100%); opacity: 0; } }
.multi-bar-exit { animation: slideOutUp 0.2s cubic-bezier(0.1, 0.9, 0.2, 1) forwards; }

body.selection-mode-active .message * { pointer-events: none !important; user-select: none !important; }
body.selection-mode-active .message { pointer-events: auto !important; cursor: pointer !important; }
body.selection-mode-active .custom-voice-player button, body.selection-mode-active video { opacity: 0.5; }

.audio-bubble { border: 1px solid rgba(255,255,255,0.1); transition: transform 0.3s; }
.audio-bubble:hover { transform: translateY(-2px); }

.playing-eq { display: flex; gap: 3px; align-items: flex-end; height: 16px; margin-left: auto; }
.playing-eq span { width: 3px; background: #fff; border-radius: 2px; animation: eqAnim 0.5s infinite alternate ease-in-out; }
.playing-eq span:nth-child(2) { animation-delay: 0.2s; }
.playing-eq span:nth-child(3) { animation-delay: 0.4s; }
@keyframes eqAnim { 0% { height: 4px; } 100% { height: 16px; } }

.track-info-container { overflow: hidden; max-width: 150px; line-height: 1.3; }
.track-title { font-size: 13px; font-weight: bold; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loader-spinner { border: 3px solid rgba(255,255,255,0.3); border-top: 3px solid #fff; border-radius: 50%; width: 20px; height: 20px; animation: spin 1s linear infinite; }

#global-audio-bar { opacity: 0; transition: transform 0.35s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.3s ease; }
#global-audio-bar.player-visible { transform: translateY(0) !important; opacity: 1; }

@media (min-width: 769px) {
    #global-audio-bar { position: absolute; bottom: 0; top: auto; right: 0; left: auto; width: 320px; z-index: 100; border-top: 1px solid var(--border); border-bottom: none; background: rgba(255,255,255,0.85); backdrop-filter: blur(15px); cursor: pointer; display: none; align-items: center; padding: 10px 15px; height: 60px; direction: ltr; transform: translateY(100%); }
    [data-theme="dark"] #global-audio-bar { background: rgba(30, 41, 59, 0.85); }
    .sidebar { position: relative; padding-bottom: 0; transition: padding-bottom 0.35s; overflow: hidden; } 
    .sidebar.has-player { padding-bottom: 60px; }
}

@media (max-width: 768px) {
    #global-audio-bar { position: fixed; top: 0; bottom: auto; left: 0; width: 100%; z-index: 10000; background: rgba(255,255,255,0.95); backdrop-filter: blur(15px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); border-bottom: 1px solid var(--border); border-top: none; cursor: pointer; display: none; align-items: center; padding: 10px 15px; height: 60px; direction: ltr; transform: translateY(-100%); }
    [data-theme="dark"] #global-audio-bar { background: rgba(30, 41, 59, 0.95); }
    body.chat-active .chat-area.has-player .chat-header { margin-top: 60px; }
    .sidebar.has-player .sidebar-header { margin-top: 60px; }
}

#fs-player-modal { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    z-index: 999999; flex-direction: column; background: var(--bg); 
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1); 
    will-change: transform; overflow: hidden; 
}
#fs-player-modal.active { transform: translateY(0) !important; }
.fs-minimize-btn { width: 42px; height: 42px; background: rgba(0,0,0,0.3); border-radius: 50%; display: flex; align-items: center; justify-content: center; border: none; color: white; cursor: pointer; transition: 0.2s; backdrop-filter: blur(5px); }
.fs-minimize-btn:hover { background: rgba(0,0,0,0.5); }
.fs-minimize-btn svg { transition: transform 0.3s; width: 24px; height: 24px; }

@media (max-width: 768px) { #fs-player-modal { transform: translateY(-100%); } .fs-minimize-btn svg { transform: rotate(180deg); } }
@media (min-width: 769px) { #fs-player-modal { transform: translateY(100%); } .fs-minimize-btn svg { transform: rotate(0deg); } }

.fs-bg-blur { position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; filter: blur(60px) brightness(0.6); z-index: 0; background-size: cover; background-position: center; transition: background 0.5s; background-color: #3b82f6;}
.fs-content { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; padding: 20px; align-items: center; justify-content: center; color: white; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.fs-cover { width: 80vw; max-width: 320px; height: 80vw; max-height: 320px; border-radius: 20px; box-shadow: 0 20px 50px rgba(0,0,0,0.4); object-fit: cover; margin-bottom: 40px; transition: transform 0.3s; }
.fs-cover.playing { animation: pulseCover 3s infinite alternate ease-in-out; }
@keyframes pulseCover { 0% { transform: scale(1); box-shadow: 0 20px 50px rgba(0,0,0,0.4); } 100% { transform: scale(1.05); box-shadow: 0 30px 60px rgba(0,0,0,0.6); } }

.fs-controls { display: flex; align-items: center; gap: 25px; margin-top: 30px; direction: ltr;}
.fs-btn { background: none; border: none; color: white; font-size: 28px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; width: 50px; height: 50px; border-radius: 50%; }
.fs-btn:hover { background: rgba(255,255,255,0.1); }
.fs-play-btn { background: white; color: black; width: 70px; height: 70px; font-size: 30px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
.fs-play-btn:hover { background: white; transform: scale(1.05); }
.fs-play-btn .loader-spinner { border: 3px solid rgba(0,0,0,0.2); border-top: 3px solid #000; width: 30px; height: 30px; }

.modern-spinner { width: 35px; height: 35px; border: 3px solid rgba(59, 130, 246, 0.2); border-top-color: #3b82f6; border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 15px auto; }
.chat-loading-container { display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%; color: var(--subtext); font-size: 13px; font-weight: bold; }

#attachment-menu { position: absolute !important; bottom: calc(100% + 10px) !important; left: 20px !important; right: auto !important; transform-origin: bottom left; animation: popUpAttachment 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important; display:none; background:var(--sidebar); border:1px solid var(--border); border-radius:12px; padding:5px; box-shadow:0 5px 20px rgba(0,0,0,0.15); z-index:100; flex-direction:column; gap:5px; width:160px;}
#attachment-menu button { background:none; border:none; padding:10px; text-align:right; font-family:inherit; color:var(--text); cursor:pointer; border-radius:8px; display:flex; align-items:center; gap:10px; font-size:14px; transition:0.2s;}
#attachment-menu button:hover { background:var(--chat-bg); color:var(--accent);}

@keyframes popUpAttachment { 0% { opacity: 0; transform: scale(0.8) translateY(15px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

.modal.is-exiting .modal-content, .modal.is-exiting #auth-box { animation: popOut 0.2s ease-in forwards !important; }
.modal.is-exiting { animation: fadeOutBg 0.2s ease-in forwards !important; }
.menu-exiting { animation: popOutMenu 0.2s ease-in forwards !important; }

@keyframes popIn { 0% { opacity: 0; transform: scale(0.8) translateY(20px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes popOut { 0% { opacity: 1; transform: scale(1) translateY(0); } 100% { opacity: 0; transform: scale(0.8) translateY(20px); } }
@keyframes popInMenu { 0% { opacity: 0; transform: scale(0.9); } 100% { opacity: 1; transform: scale(1); } }
@keyframes popOutMenu { 0% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.9); } }
@keyframes fadeOutBg { 0% { background: rgba(0,0,0,0.5); } 100% { background: rgba(0,0,0,0); } }

#hamburger-overlay { transition: opacity 0.3s ease; }
#emoji-picker, .emoji-picker, .emoji-mart { left: 10px !important; right: auto !important; transform-origin: bottom left !important; animation: popInEmoji 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important; box-shadow: 0 10px 25px rgba(0,0,0,0.15) !important; z-index: 10002; }
@keyframes popInEmoji { 0% { opacity: 0; transform: scale(0.5) translateY(20px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }

#folder-tabs { position: relative !important; display: flex; overflow-x: auto; white-space: nowrap; padding: 8px 5px; gap: 4px; scrollbar-width: none; z-index: 1; justify-content: center; border-bottom: 1px solid rgba(0, 0, 0, 0.05); background: rgba(255, 255, 255, 0.55) !important; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); }
[data-theme="dark"] #folder-tabs { border-bottom: 1px solid rgba(255, 255, 255, 0.05); background: rgba(15, 23, 42, 0.55) !important; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3); }
#folder-tabs::-webkit-scrollbar { display: none; }
.folder-tab { position: relative; z-index: 2; background: transparent !important; border: none; color: var(--subtext); font-size: 13px; font-weight: bold; cursor: pointer; padding: 6px 12px; border-radius: 18px; transition: color 0.3s ease; flex-shrink: 0; }
.folder-tab.active { color: #fff !important; background: transparent !important; }
#tab-indicator { position: absolute; height: 30px; background: var(--accent); border-radius: 15px; top: 9px; transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease; z-index: 1; pointer-events: none; }

body.has-custom-bg { background-size: cover !important; background-position: center center !important; background-attachment: fixed !important; background-repeat: no-repeat !important; image-rendering: -webkit-optimize-contrast; }
#crop-container { width: 100%; height: 400px; background: #000; overflow: hidden; position: relative; border-radius: 10px; cursor: move; touch-action: none; }

body.has-custom-bg .sidebar-header { background: rgba(255, 255, 255, 0.4) !important; backdrop-filter: blur(10px) !important; -webkit-backdrop-filter: blur(10px) !important; border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important; }
[data-theme="dark"] body.has-custom-bg .sidebar-header { background: rgba(15, 23, 42, 0.4) !important; border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important; }

body.has-custom-bg .chat-area { background: transparent !important; position: relative; }
body.has-custom-bg .chat-area .chat-header { position: absolute !important; top: 0; left: 0; right: 0; height: 60px; background: rgba(255, 255, 255, 0.45) !important; backdrop-filter: blur(15px) !important; -webkit-backdrop-filter: blur(15px) !important; z-index: 100; border-bottom: 1px solid rgba(0,0,0,0.05); }
body.has-custom-bg .chat-area .input-container { position: absolute !important; bottom: 0; left: 0; right: 0; background: rgba(255, 255, 255, 0.45) !important; backdrop-filter: blur(15px) !important; -webkit-backdrop-filter: blur(15px) !important; z-index: 100; border-top: 1px solid rgba(0,0,0,0.05); }
body.has-custom-bg .chat-area .messages { position: absolute !important; top: 0; left: 0; right: 0; bottom: 0; padding-top: 75px !important; padding-bottom: 85px !important; overflow-y: auto !important; display: flex; flex-direction: column; z-index: 1; box-sizing: border-box; }
[data-theme="dark"] body.has-custom-bg .chat-area .chat-header, [data-theme="dark"] body.has-custom-bg .chat-area .input-container { background: rgba(15, 23, 42, 0.45) !important; border-color: rgba(255,255,255,0.05); }

body.has-custom-bg .message { border: none; box-shadow: 0 1px 3px rgba(0,0,0,0.15); }
body.has-custom-bg .msg-other { background: #ffffff !important; color: #111 !important; }
body.has-custom-bg .msg-me { background: #007aff !important; color: #ffffff !important; }
body.has-custom-bg .msg-me a { color: #ffffff !important; text-decoration: underline; }

body.has-custom-bg .msg-other .reply-box, body.has-custom-bg .msg-other .reply-box div, body.has-custom-bg .msg-other .reply-box span { color: #1f2937 !important; }
body.has-custom-bg .msg-other .reply-box { background: rgba(0, 0, 0, 0.06) !important; border-color: var(--accent) !important; }

body.has-custom-bg .sidebar { background: rgba(255, 255, 255, 0.90) !important; backdrop-filter: blur(15px) !important; -webkit-backdrop-filter: blur(15px) !important; }
[data-theme="dark"] body.has-custom-bg .sidebar { background: rgba(15, 23, 42, 0.90) !important; }

[data-theme="dark"] body.has-custom-bg .msg-other { background: rgba(30, 41, 59, 0.85) !important; color: #f8fafc !important; }
[data-theme="dark"] body.has-custom-bg .msg-me { background: rgba(37, 99, 235, 0.85) !important; color: #ffffff !important; }
[data-theme="dark"] body.has-custom-bg .msg-other .reply-box, [data-theme="dark"] body.has-custom-bg .msg-other .reply-box div, [data-theme="dark"] body.has-custom-bg .msg-other .reply-box span { color: #cbd5e1 !important; }
[data-theme="dark"] body.has-custom-bg .msg-other .reply-box { background: rgba(255, 255, 255, 0.1) !important; }

@keyframes popInFloat { 0% { transform: scale(0.3); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes popOutFloat { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.3); opacity: 0; } }

#global-search-container { display: none; animation: slideDownSearch 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; transform-origin: top; z-index: 999999; }
@keyframes slideDownSearch { from { opacity: 0; transform: scaleY(0); } to { opacity: 1; transform: scaleY(1); } }
#global-search-results div { animation: fadeInResult 0.3s ease forwards; opacity: 0; }
@keyframes fadeInResult { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@property --light-angle { syntax: '<angle>'; initial-value: 0deg; inherits: false; }
@keyframes messageScaleZoom { 0% { transform: scale(1); } 10% { transform: scale(1.02); } 85% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes traceBorderLight { 0% { --light-angle: 0deg; opacity: 0; } 10% { opacity: 1; } 85% { opacity: 1; } 100% { --light-angle: 720deg; opacity: 0; } }

.msg-highlight-modern { position: relative !important; z-index: 100 !important; animation: messageScaleZoom 2.5s cubic-bezier(0.25, 1, 0.5, 1) forwards !important; }
.msg-highlight-modern::after { content: ''; position: absolute; inset: -2px; border-radius: 18px; padding: 2px; background: conic-gradient(from var(--light-angle), transparent 0%, transparent 65%, var(--accent) 90%, #ffffff 100%); -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; animation: traceBorderLight 2.5s linear forwards; }

/* ========================================= */
/* استایل‌های اختصاصی پروفایل و مخاطبین */
/* ========================================= */

/* کادر ورودی بایو در تنظیمات */
.bio-textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--sidebar);
    color: var(--text);
    font-family: inherit;
    resize: none;
    height: 65px;
    outline: none;
    transition: 0.2s;
}
.bio-textarea:focus { border-color: var(--accent); }

/* مودال پروفایل تلگرامی */
.tg-modal-overlay { z-index: 9999999; display: none; }
.tg-profile-card { padding: 0 !important; overflow: hidden; max-width: 380px; width: min(92vw, 380px); border-radius: 30px; background: transparent; box-shadow: 0 30px 80px rgba(15,23,42,0.16); }
.tg-profile-cover { position: relative; height: 150px; background: linear-gradient(135deg, #4f46e5, #2563eb); overflow: visible; }
.tg-profile-cover::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 18% 25%, rgba(255,255,255,0.28), transparent 18%), radial-gradient(circle at 85% 20%, rgba(255,255,255,0.14), transparent 18%); pointer-events: none; }
.tg-profile-cover::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0) 70%); opacity: 0.6; pointer-events: none; }
.tg-profile-cover.tg-cover-animate::before { animation: coverWave 0.6s ease-out forwards; }
.tg-profile-cover.tg-cover-animate::after { animation: coverGlow 0.6s ease-out forwards; }
.tg-profile-cover::before, .tg-profile-cover::after { transition: opacity 0.25s ease; }
.tg-cover-wave-lines { position: absolute; inset: 0; background-image: radial-gradient(circle at 20% 15%, rgba(255,255,255,0.18) 0, transparent 28%), radial-gradient(circle at 80% 35%, rgba(255,255,255,0.12) 0, transparent 30%); opacity: 0.55; pointer-events: none; transform: translateY(4px); }
.tg-cover-animate .tg-cover-wave-lines { animation: waveSettle 0.8s ease-out forwards; }
.tg-close-btn { color: #fff !important; top: 16px !important; left: 16px !important; right: auto !important; z-index: 2; }
.tg-avatar-wrapper { position: absolute; left: 50%; bottom: -52px; transform: translateX(-50%); width: 110px; height: 110px; display: flex; align-items: center; justify-content: center; }
.tg-avatar-glow { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,0.5), rgba(59,130,246,0.08) 40%, transparent 60%); filter: blur(14px); animation: glowRotate 8s linear infinite; }
.tg-profile-avatar, .tg-profile-avatar-fallback { width: 96px; height: 96px; border-radius: 50%; border: 4px solid rgba(255,255,255,0.95); position: relative; z-index: 1; box-shadow: 0 18px 40px rgba(0,0,0,0.18); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 32px; color: #fff; text-transform: uppercase; }
.tg-profile-avatar { object-fit: cover; background: #111; }
.tg-profile-avatar-fallback { background: linear-gradient(135deg, #2563eb, #4f46e5); display: none; }
.tg-profile-info { text-align: center; padding: 60px 18px 18px; background: var(--sidebar); }
.tg-profile-topline { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; margin-bottom: 4px; cursor: pointer; touch-action: manipulation; user-select: none; }
.tg-profile-topline:hover .tg-profile-name, .tg-profile-topline:hover .tg-profile-username { text-decoration: underline; }
.tg-profile-name { margin: 0; font-size: 20px; font-weight: 900; color: var(--text); line-height: 1.1; }
.tg-profile-username { font-size: 11px; color: var(--accent); direction: ltr; margin-top: 2px; }
.tg-profile-story { display: flex; align-items: center; justify-content: flex-start; gap: 10px; margin: 12px auto 0; padding: 10px 14px; border-radius: 20px; background: rgba(37,99,235,0.08); box-shadow: inset 0 1px 2px rgba(37,99,235,0.08); width: fit-content; direction: ltr; }
.tg-story-label { font-size: 12px; color: var(--subtext); letter-spacing: 0.2em; text-transform: uppercase; }
.tg-story-dots { display: flex; align-items: center; justify-content: center; gap: 12px; }
.tg-story-dot { width: 16px; height: 16px; border-radius: 50%; background: rgba(37,99,235,0.18); box-shadow: 0 0 0 10px rgba(37,99,235,0.04); animation: storyPulse 1.8s ease-in-out infinite alternate; }
.tg-story-dot:nth-child(1) { animation-delay: 0s; }
.tg-story-dot:nth-child(2) { animation-delay: 0.2s; }
.tg-story-dot:nth-child(3) { animation-delay: 0.4s; }
.tg-profile-bio { font-size: 13px; color: var(--text); margin-top: 14px; line-height: 1.55; background: rgba(255,255,255,0.88); padding: 12px 14px; border-radius: 16px; border: 1px solid rgba(37,99,235,0.12); word-break: break-word; min-height: 60px; text-align: right; box-shadow: inset 0 1px 2px rgba(0,0,0,0.04); }
.tg-profile-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; justify-content: center; margin-top: 16px; }
.tg-action-btn { padding: 11px 14px; border-radius: 16px; font-weight: 700; font-size: 13px; min-height: 44px; transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease; box-shadow: 0 14px 28px rgba(0,0,0,0.1); will-change: transform, background-color; touch-action: manipulation; }
.tg-action-btn:hover { transform: translateY(-1px); }
.tg-action-btn:active { transform: translateY(1px); }
.tg-action-btn--primary { background: #2563eb; color: #fff; border: none; }
.tg-action-btn--accent { background: var(--accent); color: #fff; border: none; }
.tg-action-btn--secondary { background: rgba(255,255,255,0.12); color: var(--text); border: 1px solid rgba(255,255,255,0.16); }
.tg-action-btn--danger { background: #ef4444; color: #fff; border: none; }
@keyframes coverPulse { 0% { opacity: 0.85; transform: scale(1); } 50% { opacity: 1; transform: scale(1.03); } 100% { opacity: 0.85; transform: scale(1); } }
@keyframes coverWave { 0% { opacity: 0; transform: translateY(18px) scale(0.98); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes coverGlow { 0% { opacity: 0; transform: scale(0.96); } 100% { opacity: 0.55; transform: scale(1); } }
@keyframes waveSettle { 0% { opacity: 0; transform: translateY(18px); } 100% { opacity: 0.7; transform: translateY(0); } }
@keyframes glowRotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* استایل پایه نوار خطای اتصال */
.conn-error-bar {
    background: #ef4444;
    color: #fff;
    text-align: center;
    font-size: 11px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* کلاس انیمیشن ورود */
.conn-error-in {
    animation: slideDownError 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* کلاس انیمیشن خروج */
.conn-error-out {
    animation: slideUpError 0.25s ease-out forwards;
}

@keyframes slideDownError {
    from { opacity: 0; max-height: 0; padding: 0; }
    to { opacity: 1; max-height: 40px; padding: 6px; }
}

@keyframes slideUpError {
    from { opacity: 1; max-height: 40px; padding: 6px; }
    to { opacity: 0; max-height: 0; padding: 0; }
}

/* ==========================================
   استایل‌های مدرن مخاطبین و بخش جستجو
   ========================================== */
@keyframes instantFade { 
    from { opacity: 0; transform: translateY(5px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* کادر سرچ مخاطبین و دکمه ➕ */
.contacts-search-box { 
    display: flex !important; 
    gap: 8px !important; 
    margin-bottom: 15px !important; 
    align-items: center !important; 
}
#contact-search-input { 
    flex: 1 !important; 
    height: 42px !important; 
    border-radius: 12px !important; 
    margin: 0 !important; 
    border: 1px solid var(--border); 
    padding: 0 15px; 
    outline: none; 
    background: var(--chat-bg); 
    color: var(--text); 
}

.contacts-add-btn { 
    background: var(--accent) !important; 
    color: #fff !important; 
    border: none !important; 
    border-radius: 12px !important; 
    width: 42px !important; 
    height: 42px !important; 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    cursor: pointer !important; 
    transition: 0.2s !important; 
    padding: 0 !important; 
    font-size: 22px !important; 
    flex-shrink: 0 !important; 
    margin: 0 !important; 
}
.contacts-add-btn:hover { transform: scale(1.05) !important; opacity: 0.9 !important; }

/* آیتم‌های لیست */
.modern-contact-item { 
    display: flex; 
    align-items: center; 
    padding: 10px 12px; 
    border-bottom: 1px solid var(--border); 
    cursor: pointer; 
    transition: background 0.2s; 
    border-radius: 8px; 
    animation: instantFade 0.2s ease forwards; 
}
.modern-contact-item:hover { background: var(--chat-bg); }

/* دکمه ارسال پیام */
.modern-msg-btn { 
    background: var(--chat-bg); 
    color: var(--text); 
    border: none; 
    border-radius: 50%; 
    width: 38px; 
    height: 38px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: 0.2s; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}
.modern-msg-btn:hover { background: var(--accent); color: #fff; transform: scale(1.1); }

/* ⭐️ بخش سرچ گلوبال آکاردئونی (ثابت در صفحه بدون افتادن روی لیست) ⭐️ */
#global-add-area {
    display: none; 
    background: var(--chat-bg) !important; 
    padding: 12px !important; 
    border-radius: 12px !important; 
    margin-bottom: 15px !important; 
    border: 1px solid var(--border) !important;
}
#g-search-input {
    width: 100% !important; 
    height: 42px !important; 
    border-radius: 10px !important; 
    margin-bottom: 8px !important; 
    border: 1px solid var(--border) !important; 
    padding: 0 15px !important; 
    background: var(--sidebar) !important; 
    color: var(--text) !important; 
    outline: none !important; 
    font-family: inherit;
}
#g-search-input:focus { border-color: var(--accent) !important; }

/* باکس نمایش نتایج سرچ گلوبال */
#g-search-results {
    max-height: 200px; 
    overflow-y: auto; 
    border-radius: 8px;
}

/* ========================================= */
/* مودال تاییدیه اختصاصی (حذف پیام و مخاطب) */
/* ========================================= */
.custom-confirm-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    z-index: 99999999;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.2s;
}
.custom-confirm-overlay.closing { animation: fadeOutBg 0.2s forwards; }

.custom-confirm-box {
    background: var(--sidebar);
    padding: 25px 20px;
    border-radius: 24px;
    width: 85%; max-width: 320px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.custom-confirm-overlay.closing .custom-confirm-box { animation: popOut 0.2s forwards; }

.custom-confirm-title { margin: 0 0 10px 0; color: var(--text); font-size: 18px; font-weight: 900; }
.custom-confirm-text { font-size: 13px; color: var(--subtext); margin: 0 0 25px 0; line-height: 1.6; }

.custom-confirm-actions { display: flex; gap: 12px; justify-content: center; flex-direction: row-reverse; }
.custom-confirm-btn {
    flex: 1; height: 46px; border: none; border-radius: 23px;
    font-weight: bold; font-size: 14px; cursor: pointer; transition: 0.2s; outline: none;
}
.custom-confirm-btn.yes { background: #ef4444; color: #fff; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3); }
.custom-confirm-btn.yes:hover { transform: scale(1.05); opacity: 0.9; }
.custom-confirm-btn.no { background: var(--chat-bg); color: var(--text); }
.custom-confirm-btn.no:hover { background: var(--border); transform: scale(1.05); }


/* ========================================= */
/* انیمیشن آکاردئونی کادر افزودن مخاطب */
/* ========================================= */
#global-add-area {
    display: none; 
    background: var(--chat-bg) !important; 
    border-radius: 12px !important; 
    overflow: hidden;
    animation: accordionOpen 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
#global-add-area.closing {
    animation: accordionClose 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

@keyframes accordionOpen {
    from { max-height: 0; padding: 0 12px; margin-bottom: 0; opacity: 0; border: 0 solid transparent; }
    to { max-height: 250px; padding: 12px; margin-bottom: 15px; opacity: 1; border: 1px solid var(--border); }
}
@keyframes accordionClose {
    from { max-height: 250px; padding: 12px; margin-bottom: 15px; opacity: 1; border: 1px solid var(--border); }
    to { max-height: 0; padding: 0 12px; margin-bottom: 0; opacity: 0; border: 0 solid transparent; }
}