@import url('/assets/fonts/fonts.css');

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
input[type="number"], input[type="tel"], input[type="email"], input[type="url"] { direction: ltr !important; text-align: left !important; color-scheme: dark; }
input[type="date"], input[type="datetime-local"], input[type="month"], input[type="time"] { direction: rtl !important; unicode-bidi: normal !important; text-align: right !important; color-scheme: dark; }
input[type="date"]::-webkit-datetime-edit, input[type="datetime-local"]::-webkit-datetime-edit, input[type="month"]::-webkit-datetime-edit, input[type="time"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-fields-wrapper, input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper, input[type="month"]::-webkit-datetime-edit-fields-wrapper, input[type="time"]::-webkit-datetime-edit-fields-wrapper,
input[type="date"]::-webkit-datetime-edit-text, input[type="date"]::-webkit-datetime-edit-day-field, input[type="date"]::-webkit-datetime-edit-month-field, input[type="date"]::-webkit-datetime-edit-year-field,
input[type="datetime-local"]::-webkit-datetime-edit-text, input[type="datetime-local"]::-webkit-datetime-edit-day-field, input[type="datetime-local"]::-webkit-datetime-edit-month-field, input[type="datetime-local"]::-webkit-datetime-edit-year-field, input[type="datetime-local"]::-webkit-datetime-edit-hour-field, input[type="datetime-local"]::-webkit-datetime-edit-minute-field, input[type="datetime-local"]::-webkit-datetime-edit-ampm-field,
input[type="month"]::-webkit-datetime-edit-text, input[type="month"]::-webkit-datetime-edit-month-field, input[type="month"]::-webkit-datetime-edit-year-field,
input[type="time"]::-webkit-datetime-edit-text, input[type="time"]::-webkit-datetime-edit-hour-field, input[type="time"]::-webkit-datetime-edit-minute-field, input[type="time"]::-webkit-datetime-edit-ampm-field { direction: rtl !important; unicode-bidi: normal !important; }
html { height: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-height: 100%; }
html.app-page { overflow: hidden; overscroll-behavior: none; }
html.app-page body.app { overflow: hidden; overscroll-behavior: none; background: var(--bg-2); }
body {
    font-family: 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-0);
    color: var(--text-1);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}
:root {
    --bg-0: #103B47;
    --bg-1: #0E3340;
    --bg-2: #1A4F5C;
    --bg-3: #22606B;
    --bg-hover: #0C2D38;
    --primary: #103B47;
    --primary-2: #3E8E97;
    --accent: #E8C07A;
    --text-1: #F7F3EE;
    --text-2: #c4bfb7;
    --text-3: #8a9a9e;
    --danger: #ea4335;
    --warning: #E8C07A;
    --bubble-out: #22606B;
    --bubble-in: #1A4F5C;
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
    --send-bg: #E8C07A;
    --send-color: #103B47;
}
[data-theme="light"] {
    --bg-0: #F7F3EE; --bg-1: #ffffff; --bg-2: #F0EBE4; --bg-3: #E4DDD5; --bg-hover: #FAF8F5;
    --primary-2: #22606B; --text-1: #2A211B; --text-2: #5C544C; --text-3: #8a857f;
    --danger: #dc3545; --warning: #c9a045; --bubble-out: #3E8E97; --bubble-in: #ffffff;
    --send-bg: #103B47; --send-color: #E8C07A;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-0: #F7F3EE; --bg-1: #ffffff; --bg-2: #F0EBE4; --bg-3: #E4DDD5; --bg-hover: #FAF8F5;
        --primary-2: #22606B; --text-1: #2A211B; --text-2: #5C544C; --text-3: #8a857f;
        --danger: #dc3545; --warning: #c9a045; --bubble-out: #3E8E97; --bubble-in: #ffffff;
        --send-bg: #103B47; --send-color: #E8C07A;
    }
}

input, textarea, button { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary-2); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, textarea:focus-visible { outline-offset: 0; }

.auth-page {
    background: linear-gradient(180deg, #103B47 0%, #0E3340 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 24px; padding-top: max(24px, var(--safe-top));
    position: relative;
}
.auth-arcs { position: fixed; bottom: -280px; left: 50%; transform: translateX(-50%); width: 680px; height: 680px; pointer-events: none; }
.auth-arcs .a1 { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(247,243,238,0.06); }
.auth-arcs .a2 { position: absolute; inset: 80px; border-radius: 50%; border: 1.5px solid rgba(62,142,151,0.3); }
.auth-arcs .a3 { position: absolute; inset: 160px; border-radius: 50%; border: 1.5px solid rgba(62,142,151,0.55); }
.auth-arcs .a4 { position: absolute; inset: 240px; border-radius: 50%; border: 1.5px solid rgba(232,192,122,0.7); }
.auth-shell { width: 100%; max-width: 420px; position: relative; z-index: 1; margin: auto; }
.auth-top { width: 100%; max-width: 420px; margin: 0 auto 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; z-index: 2; }
.auth-top-logo { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: #F7F3EE; font-family: 'El Messiri', sans-serif; font-size: 19px; font-weight: 700; }
.auth-top-logo svg { flex-shrink: 0; }
.auth-top-home { display: inline-flex; align-items: center; padding: 8px 16px; border-radius: 10px; background: rgba(247,243,238,0.08); border: 1px solid rgba(247,243,238,0.28); color: #F7F3EE; text-decoration: none; font-size: 13px; font-weight: 600; white-space: nowrap; transition: background 0.15s, border-color 0.15s; }
.auth-top-home:hover { background: rgba(247,243,238,0.15); border-color: #E8C07A; }
@media (max-width: 420px) { .auth-top-logo { font-size: 17px; gap: 7px; } .auth-top-home { padding: 7px 12px; font-size: 12.5px; } }
.auth-card { background: var(--bg-1); padding: 32px 24px; border-radius: 16px; border: 1px solid var(--bg-3); }
.auth-brand { text-align: center; margin-bottom: 24px; }
.brand-mark {
    width: 64px; height: 64px; margin: 0 auto 12px;
    background: transparent; border-radius: 0;
    display: flex; align-items: center; justify-content: center;
}
.auth-brand h1 { font-family: 'El Messiri', sans-serif; font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.auth-brand p { color: var(--text-3); font-size: 14px; }

.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 12px 14px; background: var(--bg-2);
    border: 1px solid var(--bg-3); border-radius: 10px;
    color: var(--text-1); font-size: 15px; transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary-2); }
.field input[type="checkbox"], .field input[type="radio"] {
    width: 17px; height: 17px; padding: 0; flex: 0 0 auto;
    accent-color: var(--primary-2); border-radius: 4px;
}
.field label span { display: inline; margin-bottom: 0; }
.field .phone-row { display: flex; gap: 8px; }
.field .phone-row select { flex: 0 0 auto; width: auto; max-width: 52%; }
.field .phone-row input { flex: 1; min-width: 0; }
.otp-input { font-size: 24px !important; letter-spacing: 12px; text-align: center; font-weight: 600; }

.check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13px; color: var(--text-2); }
.check input { width: 18px; height: 18px; accent-color: var(--primary-2); }

.btn {
    width: 100%; padding: 13px; border-radius: 10px;
    font-size: 15px; font-weight: 600; cursor: pointer;
    transition: opacity 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--primary-2); color: #F7F3EE; }
.btn.primary:hover { background: #22606B; }
.btn.ghost { background: transparent; color: var(--text-2); }

.alert { padding: 12px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert.error { background: rgba(234, 67, 53, 0.15); color: #ff8a80; border: 1px solid rgba(234, 67, 53, 0.3); }
.alert.success { background: rgba(62, 142, 151, 0.15); color: #6FB3B0; border: 1px solid rgba(62, 142, 151, 0.3); }
.link-secondary { display: block; text-align: center; color: var(--text-3); font-size: 13px; margin-top: 16px; }

.app { background: var(--bg-0); }
.app-shell { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

.sidebar {
    width: 100%; max-width: 380px;
    background: var(--bg-1); border-inline-start: 1px solid var(--bg-2);
    display: flex; flex-direction: column;
    padding-top: var(--safe-top);
}

.sidebar-header {
    background: var(--bg-2); padding: 10px 14px;
    display: flex; align-items: center; gap: 10px;
    min-height: 60px;
}

.account-switcher {
    flex: 1; display: flex; align-items: center; gap: 10px;
    padding: 6px; border-radius: 8px; cursor: pointer;
    transition: background 0.15s;
}
.account-switcher:active { background: rgba(255,255,255,0.05); }

.account-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, #1C6470, #3E8E97);
    color: #F7F3EE; font-weight: 600; font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.account-info { flex: 1; min-width: 0; }
.account-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-tenant { font-family: 'Spectral', serif; font-style: italic; font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.caret { width: 0; height: 0; border-top: 5px solid var(--text-3); border-left: 4px solid transparent; border-right: 4px solid transparent; }

.icon-btn {
    width: 40px; height: 40px; border-radius: 50%;
    color: var(--text-2); display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.icon-btn:active { background: rgba(255,255,255,0.08); }

.search-bar { padding: 8px 12px; display: flex; gap: 6px; align-items: center; }
.search-bar input {
    flex: 1; padding: 9px 14px;
    background: var(--bg-2); border: none; border-radius: 8px;
    color: var(--text-1); font-size: 14px;
}
.search-mode-btn {
    width: 36px; height: 36px; border-radius: 8px;
    background: var(--bg-2); color: var(--text-3);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background 0.15s, color 0.15s;
}
.search-mode-btn.active { background: var(--primary-2); color: #F7F3EE; }
.search-mode-btn:active { transform: scale(0.95); }

.convo-list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.convo-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; cursor: pointer; transition: background 0.1s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.convo-item:active, .convo-item.active { background: var(--bg-3); }

.convo-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(135deg, #1C6470, #3E8E97);
    color: #F7F3EE; font-size: 18px; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; position: relative;
}
.convo-avatar .acct-dot {
    position: absolute; bottom: 0; right: -2px;
    width: 14px; height: 14px; border-radius: 50%;
    border: 2px solid var(--bg-1);
}
.convo-meta { flex: 1; min-width: 0; }
.convo-line1 { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.convo-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-time { font-family: 'Spectral', serif; font-style: italic; font-size: 12px; color: var(--text-3); flex-shrink: 0; margin-right: 8px; direction: ltr; unicode-bidi: embed; }
.convo-line2 { display: flex; justify-content: space-between; align-items: center; }
.convo-preview {
    font-size: 13px; color: var(--text-3);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    flex: 1; min-width: 0;
}
.unread-badge {
    background: var(--accent); color: #103B47;
    font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 10px;
    flex-shrink: 0; margin-right: 6px;
}

.bottom-nav {
    display: flex; justify-content: space-around;
    background: var(--bg-2); border-top: 1px solid var(--bg-3);
    padding: 0;
    margin-top: auto; flex-shrink: 0;
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 6px 0 10px; color: var(--text-2); font-size: 11px; line-height: 1;
    transition: color 0.15s;
}
.nav-item.active { color: var(--primary-2); }

.chat-area {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-0);
    padding-top: var(--safe-top);
}

.empty-chat {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-3); text-align: center; padding: 40px;
    position: relative; overflow: hidden;
}
.empty-arcs { position: absolute; bottom: -200px; left: 50%; transform: translateX(-50%); width: 520px; height: 520px; pointer-events: none; }
.empty-arcs .a1 { position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid rgba(247,243,238,0.06); }
.empty-arcs .a2 { position: absolute; inset: 60px; border-radius: 50%; border: 1.5px solid rgba(62,142,151,0.2); }
.empty-arcs .a3 { position: absolute; inset: 120px; border-radius: 50%; border: 1.5px solid rgba(62,142,151,0.4); }
.empty-arcs .a4 { position: absolute; inset: 180px; border-radius: 50%; border: 1.5px solid rgba(232,192,122,0.5); }
.empty-illustration {
    width: 120px; height: 120px; margin-bottom: 24px;
    background: var(--bg-2); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    position: relative; z-index: 1;
}
.empty-illustration::before {
    content: ''; width: 60px; height: 60px;
    background: var(--primary-2); border-radius: 50%; opacity: 0.4;
}
.empty-chat h2 { font-family: 'El Messiri', sans-serif; color: var(--text-1); font-size: 22px; margin-bottom: 8px; }
.empty-chat p { font-size: 14px; }

.chat-header {
    background: var(--bg-2); padding: 8px 12px;
    display: flex; align-items: center; gap: 10px;
    min-height: 60px;
}
.back-btn { display: none; }
.contact-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: linear-gradient(135deg, #1C6470, #3E8E97);
    color: #F7F3EE; font-weight: 600;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.contact-info { flex: 1; min-width: 0; }
.contact-info h3 { font-size: 15px; font-weight: 500; }
.muted { font-family: 'Spectral', serif; font-style: italic; font-size: 12px; color: var(--text-3); }
#chatContactStatus { direction: ltr; unicode-bidi: embed; }

.chat-messages {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    padding: 12px 14px; -webkit-overflow-scrolling: touch;
    display: flex; flex-direction: column; gap: 4px;
}
.msg { max-width: 80%; display: flex; flex-direction: column; }
.msg.in { align-self: flex-start; }
.msg.out { align-self: flex-end; }
.msg.consec { margin-top: -4px; }
.msg-bubble {
    padding: 6px 10px 6px 12px; border-radius: 8px;
    line-height: 1.4; word-wrap: break-word;
    position: relative; min-height: 32px;
}
.msg.in .msg-bubble {
    background: var(--bubble-in);
    border-top-right-radius: 0;
}
.msg.out .msg-bubble {
    background: var(--bubble-out);
    color: #F7F3EE;
    border-top-left-radius: 0;
}
.msg.consec .msg-bubble {
    border-top-right-radius: 8px;
    border-top-left-radius: 8px;
}
.msg-meta { font-family: 'Spectral', serif; font-style: italic; font-size: 11px; color: rgba(247,243,238,0.55); margin-top: 2px; display: flex; gap: 4px; align-items: center; direction: ltr; unicode-bidi: embed; }
.msg.out .msg-meta { justify-content: flex-end; }
.msg-status { font-size: 12px; color: var(--text-3); }
.msg-status.read { color: #6FB3B0; }
.msg-status.failed { color: var(--danger); }
.msg-image { max-width: 280px; max-height: 280px; border-radius: 6px; margin-bottom: 4px; cursor: pointer; }
.msg-doc { background: var(--bg-3); padding: 8px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; }

.date-divider { align-self: center; padding: 4px 12px; background: var(--bg-2); border-radius: 8px; font-family: 'Spectral', serif; font-style: italic; font-size: 12px; color: var(--text-3); margin: 16px 0 8px; }

.window-warning {
    background: rgba(232, 192, 122, 0.15);
    color: var(--warning);
    padding: 8px 14px; font-size: 12px; text-align: center;
    border-top: 1px solid rgba(232, 192, 122, 0.3);
}
.window-warning.window-soon {
    background: rgba(232, 192, 122, 0.25);
    animation: windowPulse 2s ease-in-out infinite;
}
@keyframes windowPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.composer {
    background: var(--bg-2); padding: 8px 10px calc(8px + var(--safe-bottom));
    display: flex; gap: 6px; align-items: flex-end;
}
.composer[hidden] { display: none; }
.composer textarea {
    flex: 1; min-height: 44px; max-height: 120px;
    padding: 11px 16px; background: var(--bg-3);
    border: none; border-radius: 20px;
    color: var(--text-1); font-size: 15px; resize: none;
    line-height: 1.4;
}
.composer textarea:focus { outline: none; }
.send-btn {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--send-bg); color: var(--send-color);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: opacity 0.15s, transform 0.05s;
}
.send-btn:disabled { background: var(--bg-3); color: var(--text-3); }
.send-btn:active:not(:disabled) { transform: scale(0.95); }

.modal[hidden] { display: none; }
.empty-chat[hidden] { display: none; }
.chat-header[hidden] { display: none; }
.chat-messages[hidden] { display: none; }
.composer[hidden] { display: none; }
.window-warning[hidden] { display: none; }
.assignment-bar[hidden] { display: none; }
.tag-bar[hidden] { display: none; }
.bulk-bar[hidden] { display: none; }
.modal {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); z-index: 100;
    display: flex; align-items: flex-end; justify-content: center;
    animation: fadeIn 0.2s;
}
.modal-card {
    background: var(--bg-1); width: 100%; max-width: 420px;
    border-radius: 16px 16px 0 0; padding: 20px 16px calc(20px + var(--safe-bottom));
    animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 70vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
    position: relative;
}
.modal-card h3 { font-family: 'El Messiri', sans-serif; font-size: 18px; margin-bottom: 8px; }
.modal-card p { color: var(--text-3); font-size: 14px; margin-bottom: 12px; }
.menu-item {
    display: block; padding: 12px 14px; border-radius: 8px;
    margin-bottom: 2px; transition: background 0.15s;
    min-height: 44px;
}
.menu-item:active { background: var(--bg-3); }
.menu-item.danger { color: var(--danger); }

.account-list { max-height: 60vh; overflow-y: auto; margin-bottom: 12px; }
.account-list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border-radius: 10px; cursor: pointer;
    transition: background 0.15s;
}
.account-list-item:active, .account-list-item.active { background: var(--bg-3); }
.account-list-add { color: var(--text-1); text-decoration: none; border-top: 1px solid var(--bg-3); margin-top: 8px; padding-top: 16px; }
.account-avatar-add { background: var(--bg-3) !important; color: var(--primary-2); font-size: 22px; font-weight: 600; }
.account-list-empty { padding: 24px 12px; text-align: center; color: var(--text-3); font-size: 14px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.toast {
    position: fixed; bottom: calc(80px + var(--safe-bottom)); left: 50%;
    transform: translateX(-50%);
    background: var(--bg-3); color: var(--text-1);
    padding: 10px 18px; border-radius: 24px; font-size: 14px;
    z-index: 200; max-width: 90%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: toastIn 0.3s;
}
.toast.error { background: var(--danger); color: #F7F3EE; }
.toast.success { background: var(--primary-2); color: #F7F3EE; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }

.empty-loading { display: flex; justify-content: center; gap: 4px; padding: 30px; }
.empty-loading .dot { width: 8px; height: 8px; background: var(--primary-2); border-radius: 50%; animation: bounce 1.2s infinite; }
.empty-loading .dot:nth-child(2) { animation-delay: 0.15s; }
.empty-loading .dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: scale(0.6); opacity: 0.5; } 30% { transform: scale(1); opacity: 1; } }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 2px; }
::-webkit-scrollbar-track { background: transparent; }

.assignment-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 14px; font-size: 12px;
    border-bottom: 1px solid var(--bg-3);
}
.assignment-bar.unassigned { background: rgba(232, 192, 122, 0.12); color: var(--warning); }
.assignment-bar.mine       { background: rgba(62, 142, 151, 0.12); color: var(--primary-2); }
.assignment-bar.other      { background: var(--bg-2); color: var(--text-2); }
.assignment-actions { display: flex; gap: 6px; }
.btn-mini {
    padding: 4px 12px; border-radius: 14px;
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.btn-mini.primary { background: var(--primary-2); color: #F7F3EE; }

.tag-bar {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding: 6px 14px; background: var(--bg-2);
    border-bottom: 1px solid var(--bg-3);
}
.tag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600; color: #F7F3EE;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}
.tag-chip.removable, .tag-chip.clickable { cursor: pointer; transition: opacity 0.15s; }
.tag-chip.removable:hover, .tag-chip.clickable:hover { opacity: 0.85; }
.tag-x { font-weight: 700; }
.tag-mini {
    display: inline-block; padding: 2px 7px; border-radius: 8px;
    font-size: 11px; font-weight: 600; color: #F7F3EE;
    margin-inline-end: 4px; text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}
.convo-tags { display: block; margin-top: 4px; }

.convo-item.assign-mine { box-shadow: inset 3px 0 0 var(--primary-2); }
.convo-item.assign-other { box-shadow: inset 3px 0 0 #6FB3B0; opacity: 0.85; }
.convo-item.assign-unassigned { box-shadow: inset 3px 0 0 var(--warning); }

.team-list { max-height: 60vh; overflow-y: auto; margin-bottom: 12px; }
.team-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px; border-radius: 10px; cursor: pointer;
    transition: background 0.15s;
}
.team-item:active { background: var(--bg-3); }

.notes-card { max-height: 80vh; display: flex; flex-direction: column; }
.notes-list { flex: 1; overflow-y: auto; max-height: 50vh; margin-bottom: 12px; }
.note-item {
    background: var(--bg-2); padding: 10px 12px;
    border-radius: 10px; margin-bottom: 8px;
    border-right: 3px solid var(--primary-2);
}
.note-meta {
    display: flex; align-items: center; gap: 8px;
    font-family: 'Spectral', serif; font-style: italic;
    font-size: 11px; color: var(--text-3); margin-bottom: 4px;
}
.note-author { font-weight: 600; color: var(--text-2); }
.note-time { flex: 1; }
.note-del {
    background: var(--bg-3); color: var(--text-2);
    width: 22px; height: 22px; border-radius: 50%;
    font-size: 14px; line-height: 1;
}
.note-body { font-size: 14px; color: var(--text-1); word-wrap: break-word; }
.notes-composer { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.notes-composer textarea {
    flex: 1; padding: 8px 12px; background: var(--bg-2);
    border: 1px solid var(--bg-3); border-radius: 8px;
    color: var(--text-1); font-size: 14px; resize: none;
}
.notes-composer textarea:focus { outline: none; border-color: var(--primary-2); }
.notes-composer .btn { width: auto; padding: 8px 16px; }

.tags-current, .tags-pool {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 8px 0; min-height: 32px;
}
.tags-section-title { font-size: 13px; color: var(--text-3); margin: 12px 0 4px; font-weight: 500; }
.tags-create {
    display: flex; gap: 8px; margin: 12px 0;
    padding-top: 12px; border-top: 1px solid var(--bg-3);
}
.tags-create input[type="text"] {
    flex: 1; padding: 8px 12px; background: var(--bg-2);
    border: 1px solid var(--bg-3); border-radius: 8px;
    color: var(--text-1); font-size: 14px;
}
.tags-create input[type="text"]:focus { outline: none; border-color: var(--primary-2); }
.tags-create input[type="color"] {
    width: 40px; height: 40px; border: none;
    background: transparent; padding: 0; cursor: pointer;
}
.tags-create .btn { width: auto; padding: 8px 16px; }

@media (max-width: 768px) {
    .sidebar { position: fixed; inset: 0; max-width: 100%; z-index: 10; transition: transform 0.25s ease; overflow: hidden; }
    .bottom-nav { position: fixed; inset-inline: 0; bottom: 0; z-index: 11; }
    .convo-list { padding-bottom: 56px; }
    [dir="rtl"] .sidebar.hidden { transform: translateX(100%); }
    [dir="ltr"] .sidebar.hidden { transform: translateX(-100%); }
    .chat-area { position: fixed; inset: 0; z-index: 9; transition: transform 0.25s ease; }
    [dir="rtl"] .chat-area.hidden { transform: translateX(-100%); pointer-events: none; }
    [dir="ltr"] .chat-area.hidden { transform: translateX(100%); pointer-events: none; }
    .back-btn { display: flex; }
    .msg { max-width: 90%; }
    .msg-image { max-width: 240px; max-height: 240px; }
    .modal-card { max-width: 100% !important; border-radius: 16px 16px 0 0; padding: 16px 14px calc(16px + var(--safe-bottom)); max-height: 65vh; }
    .modal-card h3 { font-size: 16px; }
    .cp-card { max-width: 100%; max-height: 80vh; }
    .composer { gap: 4px; padding: 6px 8px calc(6px + var(--safe-bottom)); }
    .composer .icon-btn { min-width: 38px; min-height: 38px; width: 38px; height: 38px; }
    .composer-row { gap: 3px; }
    .composer-row textarea { min-height: 38px; padding: 9px 12px; }
    .send-btn { width: 40px; height: 40px; }
    .convo-item { padding: 10px 12px; gap: 10px; }
    .convo-avatar { width: 44px; height: 44px; font-size: 16px; }
    .chat-header { gap: 6px; padding: 8px 8px; }
    .chat-header .icon-btn { width: 36px; height: 36px; }
    .contact-avatar { width: 34px; height: 34px; font-size: 14px; }
    .contact-info h3 { font-size: 14px; }
    .msg-react-btn { top: -10px; inset-inline-end: 2px; width: 24px; height: 24px; font-size: 12px; }
}
@media (max-width: 380px) {
    .chat-header #chatSearchBtn { display: none; }
    .chat-header { gap: 4px; padding: 6px 6px; }
    .contact-info h3 { font-size: 13px; }
    .composer .icon-btn { min-width: 34px; min-height: 34px; width: 34px; height: 34px; }
    .send-btn { width: 38px; height: 38px; }
    .composer-row textarea { padding: 8px 10px; font-size: 14px; }
}
@media (min-width: 769px) {
    .chat-area.idle .empty-chat { display: flex; }
    .chat-area.idle .chat-header,
    .chat-area.idle .chat-messages,
    .chat-area.idle .window-warning,
    .chat-area.idle .composer { display: none; }
    .modal { align-items: center; }
    .modal-card { border-radius: 16px; max-height: 80vh; }
}

.filter-bar { display: flex; gap: 4px; padding: 8px 12px; overflow-x: auto; }
.filter-btn { padding: 6px 14px; border-radius: 16px; border: 1px solid var(--bg-3); background: transparent; color: var(--text-3); font-size: 13px; font-family: inherit; cursor: pointer; white-space: nowrap; transition: all 0.15s; }
.filter-btn.active { background: var(--primary-2); color: #F7F3EE; border-color: var(--primary-2); }

.qr-suggestions { position: absolute; bottom: 100%; left: 0; right: 0; background: var(--bg-1); border: 1px solid var(--bg-3); border-radius: 12px 12px 0 0; max-height: 240px; overflow-y: auto; z-index: 50; box-shadow: 0 -4px 20px rgba(0,0,0,0.3); }
.qr-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--bg-2); transition: background 0.1s; }
.qr-item:hover { background: var(--bg-2); }
.qr-item:last-child { border-bottom: none; }
.qr-shortcut { color: var(--primary-2); font-weight: 600; font-size: 14px; white-space: nowrap; direction: ltr; }
.qr-title { color: var(--text-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-cat { padding: 6px 16px; font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; background: var(--bg-2); }
.sla-badge { font-size: 12px; flex-shrink: 0; }
.sla-warn { opacity: 0.8; }
.sla-over { animation: slaPulse 1s ease-in-out infinite; }
@keyframes slaPulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.chat-area.drag-over { outline: 3px dashed var(--primary-2); outline-offset: -6px; background: rgba(16,59,71,0.08); }
.msg-retry { background: none; border: 1px solid var(--danger); color: var(--danger); border-radius: 4px; font-size: 11px; cursor: pointer; padding: 1px 6px; margin-inline-start: 4px; }

.msg-location { max-width: 280px; }
.msg-map { width: 260px; height: 160px; border-radius: 8px; overflow: hidden; cursor: default; }
.msg-map-pin { font-size: 24px; line-height: 1; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.msg-loc-label { font-size: 13px; margin-top: 4px; color: var(--text-2); line-height: 1.4; }
.msg-loc-link { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--primary-2); text-decoration: none; }
.msg-loc-link:hover { text-decoration: underline; }

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.msg-reaction { display: inline-flex; align-items: center; gap: 2px; background: var(--bg-2); border: 1px solid var(--bg-3); border-radius: 12px; padding: 2px 6px; font-size: 14px; line-height: 1; }

.msg-template { max-width: 320px; }
.tpl-badge { display: inline-block; font-size: 11px; color: var(--primary-2); font-weight: 600; margin-bottom: 4px; }
.tpl-header { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 4px; }
.tpl-body { font-size: 14px; line-height: 1.5; }
.tpl-footer { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.tpl-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; border-top: 1px solid var(--bg-3); padding-top: 8px; }
.tpl-btn { border: 1px solid var(--primary-2); color: var(--primary-2); padding: 4px 12px; border-radius: 12px; font-size: 13px; text-align: center; }

.msg-forwarded { font-size: 11px; color: var(--text-3); font-style: italic; margin-bottom: 2px; }
.msg-quote { background: var(--bg-2); border-inline-start: 3px solid var(--primary-2); border-radius: 4px; padding: 4px 8px; margin-bottom: 4px; cursor: pointer; }
.msg-quote-text { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.msg-highlight { animation: msgHL 1.5s ease; }
@keyframes msgHL { 0%,50% { background: rgba(16,59,71,0.15); } 100% { background: transparent; } }

.msg-vcard { display: flex; align-items: center; gap: 10px; padding: 8px; background: var(--bg-2); border-radius: 8px; min-width: 180px; }
.vcard-icon { font-size: 28px; }
.vcard-name { font-weight: 600; font-size: 14px; }
.vcard-phone { font-size: 12px; color: var(--text-3); direction: ltr; }

.ctx-menu { position: fixed; z-index: 999; background: var(--bg-1); border: 1px solid var(--bg-3); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.25); min-width: 140px; padding: 4px 0; }
.ctx-item { display: block; width: 100%; padding: 8px 14px; border: none; background: none; color: var(--text-1); font-size: 13px; cursor: pointer; text-align: start; font-family: inherit; }
.ctx-item:hover { background: var(--bg-hover); }

.reply-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--bg-2); border-radius: 8px 8px 0 0; border-bottom: 1px solid var(--bg-3); }
.reply-bar[hidden] { display: none; }
.reply-preview { flex: 1; min-width: 0; border-inline-start: 3px solid var(--primary-2); padding-inline-start: 8px; }
.reply-preview-text { font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-close { background: none; border: none; font-size: 18px; color: var(--text-3); cursor: pointer; padding: 0 4px; }

.composer-row { display: flex; align-items: flex-end; gap: 4px; flex: 1; }
.composer-row textarea { flex: 1; }

.emoji-card { max-width: 340px; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: 4px; max-height: 200px; overflow-y: auto; }
.emoji-item { font-size: 22px; cursor: pointer; padding: 4px; border-radius: 6px; line-height: 1; }
.emoji-item:hover { background: var(--bg-hover); }

.reaction-picker { position: fixed; z-index: 998; background: var(--bg-1); border: 1px solid var(--bg-3); border-radius: 20px; padding: 4px 8px; display: flex; gap: 2px; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.reaction-picker[hidden] { display: none; }
.reaction-picker .emoji-item { font-size: 20px; padding: 2px 4px; }

.msg-react-btn { position: absolute; top: -12px; inset-inline-end: 4px; background: var(--bg-2); border: 1px solid var(--bg-3); border-radius: 50%; width: 26px; height: 26px; font-size: 14px; cursor: pointer; opacity: 0; transition: opacity 0.15s; display: flex; align-items: center; justify-content: center; padding: 0; z-index: 2; }
.msg:hover .msg-react-btn { opacity: 1; }
.msg { position: relative; }

.voice-preview { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--bg-2); border-radius: 8px; margin-bottom: 4px; }
.voice-preview[hidden] { display: none; }
.btn-sm { padding: 4px 12px; font-size: 13px; }

.record-btn.recording { color: #ef4444; animation: recPulse 1s infinite; }
@keyframes recPulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.record-timer { font-size: 12px; color: #ef4444; font-variant-numeric: tabular-nums; min-width: 40px; }

.chat-search-bar { display: flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--bg-1); border-bottom: 1px solid var(--bg-3); }
.chat-search-bar[hidden] { display: none; }

.request-phone-bar { padding: 8px 16px; background: var(--bg-2); border-bottom: 1px solid var(--bg-3); display: flex; align-items: center; gap: 10px; }
.request-phone-bar[hidden] { display: none; }
.request-phone-bar span { font-size: 13px; color: var(--text-2); }
.request-phone-bar .btn { width: auto; padding: 8px 16px; }
.chat-search-bar input { flex: 1; padding: 8px 12px; border: 1px solid var(--bg-3); border-radius: 8px; background: var(--bg-2); color: var(--text-1); font-size: 14px; font-family: inherit; }
.msg-search-hl { background: rgba(255,213,79,0.15); }
.pin-icon { font-size: 11px; }
.ch-qr { display: inline-block; color: #E8C07A; font-size: 11px; vertical-align: middle; line-height: 1; }
.msg-system { text-align: center; color: var(--text-3); font-size: 12px; padding: 6px 16px; margin: 4px auto; background: var(--bg-2); border-radius: 12px; max-width: 80%; }
.msg-link { color: var(--primary-2); word-break: break-all; }

.cp-card { max-width: 420px; max-height: 80vh; overflow-y: auto; }
.cp-header { text-align: center; padding: 16px 0; }
.cp-avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--primary-2); color: #fff; font-size: 28px; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; }
.cp-phone { font-size: 14px; color: var(--text-2); }
.cp-copy { background: none; border: none; cursor: pointer; font-size: 14px; }
.cp-section { border-top: 1px solid var(--bg-3); padding: 12px 0; }
.cp-section h4 { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.cp-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.cp-field { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.cp-field-name { color: var(--text-3); }
.cp-field-val { color: var(--text-1); }
.cp-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 4px; }
.cp-media-thumb { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 4px; cursor: pointer; }
.cp-media-file { padding: 8px; background: var(--bg-2); border-radius: 4px; font-size: 11px; text-align: center; }
.cp-activity { font-size: 12px; padding: 3px 0; color: var(--text-2); }
.cp-act-time { color: var(--text-3); }
.cp-conv { padding: 6px 0; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--bg-3); }
.cp-conv:hover { color: var(--primary-2); }

.bulk-bar { position: sticky; bottom: 0; background: var(--bg-1); border-top: 1px solid var(--bg-3); padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; z-index: 40; }
.bulk-bar[hidden] { display: none; }
.bulk-bar span { color: var(--primary-2); font-weight: 600; font-size: 13px; white-space: nowrap; }
.bulk-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bulk-btn { padding: 6px 12px; border: 1px solid var(--bg-3); background: var(--bg-2); color: var(--text-1); border-radius: 8px; font-size: 12px; cursor: pointer; font-family: inherit; transition: background 0.15s; }
.bulk-btn:active { background: var(--bg-3); }
.bulk-cancel { color: var(--danger); border-color: var(--danger); }
.convo-item.bulk-selected { background: rgba(62,142,151,0.15); }
.convo-check { width: 18px; height: 18px; border: 2px solid var(--text-3); border-radius: 4px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; margin-left: 8px; transition: all 0.15s; }
.bulk-selected .convo-check { background: var(--primary-2); border-color: var(--primary-2); }
.bulk-selected .convo-check::after { content: ''; width: 5px; height: 9px; border: solid #F7F3EE; border-width: 0 2px 2px 0; transform: rotate(45deg); margin-top: -2px; }

.attach-wrap { position: relative; }
.attach-menu { position: absolute; bottom: 100%; right: 0; background: var(--bg-1); border: 1px solid var(--bg-3); border-radius: 10px; padding: 4px; min-width: 160px; z-index: 20; box-shadow: 0 4px 16px rgba(0,0,0,0.3); margin-bottom: 6px; }
.attach-opt { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; background: none; border: none; color: var(--text-1); font-size: 14px; font-family: inherit; cursor: pointer; border-radius: 8px; transition: background 0.15s; }
.attach-opt:hover { background: var(--bg-2); }
.attach-opt svg { opacity: 0.7; flex-shrink: 0; }

.ml-card { max-width: 680px; width: 95vw; max-height: 85vh; display: flex; flex-direction: column; }
.ml-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ml-header h3 { margin: 0; }
.ml-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.ml-search { flex: 1; min-width: 140px; padding: 8px 12px; background: var(--bg-2); border: 1px solid var(--bg-3); border-radius: 8px; color: var(--text-1); font-family: inherit; font-size: 13px; }
.ml-search:focus { outline: none; border-color: var(--primary-2); }
.ml-filters { display: flex; gap: 4px; }
.ml-filter { padding: 6px 12px; border: 1px solid var(--bg-3); background: var(--bg-2); color: var(--text-2); border-radius: 20px; font-size: 12px; cursor: pointer; font-family: inherit; transition: all 0.15s; }
.ml-filter.active { background: var(--primary-2); color: #F7F3EE; border-color: var(--primary-2); }
.ml-upload-btn { font-size: 13px; padding: 8px 14px; cursor: pointer; }
.ml-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 12px; overflow-y: auto; flex: 1; min-height: 0; padding: 4px; align-content: start; }
.ml-item { border-radius: 12px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--bg-3); cursor: pointer; transition: border-color 0.15s, transform 0.15s; display: flex; flex-direction: column; }
.ml-item:hover { border-color: var(--primary-2); transform: translateY(-2px); }
.ml-thumb { position: relative; aspect-ratio: 4 / 3; background: var(--bg-3); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ml-item img { width: 100%; height: 100%; object-fit: cover; }
.ml-item .ml-icon { font-size: 34px; opacity: 0.55; }
.ml-info { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ml-item .ml-name { font-size: 12.5px; font-weight: 600; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ml-item .ml-meta { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ml-item .ml-del { position: absolute; top: 6px; inset-inline-start: 6px; width: 28px; height: 28px; border-radius: 50%; background: rgba(15,20,25,0.72); color: #F7F3EE; border: none; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; opacity: 0; transition: opacity 0.15s, background 0.15s; }
.ml-item:hover .ml-del, .ml-item:focus-within .ml-del { opacity: 1; }
.ml-item .ml-del:hover { background: rgba(248,81,73,0.95); }
.ml-scope-hint { margin: 0 0 10px; font-size: 12px; color: var(--text-3); line-height: 1.6; }
.ml-shared-badge { position: absolute; bottom: 6px; inset-inline-start: 6px; background: rgba(0,168,132,0.9); color: #fff; font-size: 10.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.ml-item .ml-share { position: absolute; top: 6px; inset-inline-end: 6px; width: 28px; height: 28px; border-radius: 50%; background: rgba(15,20,25,0.72); color: #F7F3EE; border: none; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.15s, background 0.15s; }
.ml-item:hover .ml-share, .ml-item:focus-within .ml-share { opacity: 1; }
.ml-item .ml-share.on { background: rgba(0,168,132,0.9); opacity: 1; }
.qrnc-card { max-width: 440px; width: 95vw; max-height: 86vh; overflow-y: auto; }
.qrnc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.qrnc-head h3 { margin: 0; }
.qrnc-sec { background: var(--bg-2); border: 1px solid var(--bg-3); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; }
.qrnc-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.qrnc-sec select, .qrnc-sec input, .qrnc-sec textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--bg-3); border-radius: 9px; background: var(--bg-1); color: var(--text-1); font-family: inherit; font-size: 13.5px; box-sizing: border-box; }
.qrnc-sec textarea { resize: vertical; }
.qrnc-sec input:focus, .qrnc-sec select:focus, .qrnc-sec textarea:focus { outline: none; border-color: var(--primary-2); }
.qrnc-contacts { max-height: 150px; overflow: auto; margin-top: 8px; border-radius: 9px; }
.qrnc-contacts:empty { display: none; }
.qrnc-divider { display: flex; align-items: center; gap: 10px; margin: 10px 0; color: var(--text-3); font-size: 11.5px; }
.qrnc-divider::before, .qrnc-divider::after { content: ""; flex: 1; height: 1px; background: var(--bg-3); }
.qrnc-pair { display: grid; grid-template-columns: 1.2fr 1fr; gap: 8px; }
@media (max-width: 480px) { .qrnc-pair { grid-template-columns: 1fr; } }
.qrnc-hint { font-size: 12px; margin: 8px 0 0; }
.qrnc-hint:empty { display: none; }
.qrnc-send { width: 100%; padding: 12px; }
.qrnc-launch { width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 14px; border-radius: 11px; font-size: 13.5px; font-weight: 600; letter-spacing: 0.1px; box-shadow: 0 1px 6px rgba(0,168,132,0.25); }
.modal-close-btn { background: var(--bg-2); border: 1px solid var(--bg-3); border-radius: 9px; color: var(--text-1); font-family: inherit; font-size: 13px; font-weight: 600; padding: 8px 18px; cursor: pointer; transition: background 0.15s, border-color 0.15s; flex-shrink: 0; }
.modal-close-btn:hover { background: var(--bg-3); border-color: var(--primary-2); }
@media (hover: none) { .ml-item .ml-del { opacity: 1; } }
.ml-empty { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 46px 20px; color: var(--text-3); text-align: center; }
.ml-empty span { font-size: 40px; opacity: 0.5; }
.ml-empty b { font-size: 14.5px; color: var(--text-2); }
.ml-empty small { font-size: 12.5px; max-width: 300px; line-height: 1.7; }
.ml-pager { display: flex; justify-content: center; gap: 6px; padding-top: 10px; }
.ml-pager button { padding: 5px 12px; border: 1px solid var(--bg-3); background: var(--bg-2); color: var(--text-2); border-radius: 6px; font-size: 13px; cursor: pointer; font-family: inherit; }
.ml-pager button.active { background: var(--primary-2); color: #F7F3EE; border-color: var(--primary-2); }
.ml-status { text-align: center; color: var(--text-3); font-size: 13px; padding: 8px 0; }
@media (max-width: 600px) { .ml-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); } .ml-filters { overflow-x: auto; flex-wrap: nowrap; } }

.onboard-card { max-width: 460px; text-align: center; position: relative; }
.onboard-close { position: absolute; top: 12px; inset-inline-end: 12px; width: 32px; height: 32px; border: none; background: transparent; color: var(--text-3); font-size: 26px; line-height: 1; cursor: pointer; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: background 0.15s, color 0.15s; }
.onboard-close:hover { background: var(--bg-3); color: var(--text-1); }
.onboard-actions { display: flex; gap: 10px; margin-top: 16px; }
.onboard-actions .btn { flex: 1; }
.onboard-header { margin-bottom: 20px; }
.onboard-logo { width: 64px; height: 64px; margin: 0 auto 14px; background: transparent; border-radius: 0; display: flex; align-items: center; justify-content: center; }
.onboard-logo::before { display: none; }
.onboard-header h2 { font-family: 'El Messiri', sans-serif; font-size: 22px; color: var(--text-1); margin-bottom: 4px; }
.onboard-header p { font-size: 14px; color: var(--text-3); }
.onboard-steps { display: flex; flex-direction: column; gap: 8px; text-align: right; }
.onboard-step { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--bg-2); border-radius: 12px; border: 1px solid var(--bg-3); transition: background 0.15s, border-color 0.15s; text-decoration: none; color: inherit; cursor: pointer; }
.onboard-step:hover { background: var(--bg-hover); border-color: var(--primary-2); }
.onboard-num { width: 36px; height: 36px; background: var(--primary-2); color: #F7F3EE; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex-shrink: 0; }
.onboard-info { flex: 1; min-width: 0; }
.onboard-info h4 { font-size: 15px; font-weight: 600; color: var(--text-1); margin-bottom: 2px; }
.onboard-info p { font-size: 13px; color: var(--text-3); line-height: 1.5; margin: 0; }
.onboard-arrow { color: var(--text-3); flex-shrink: 0; }

.empty-welcome { text-align: center; max-width: 400px; position: relative; z-index: 1; }
.empty-welcome-icon { width: 88px; height: 88px; margin: 0 auto 20px; background: var(--bg-2); border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.empty-welcome h2 { font-family: 'El Messiri', sans-serif; color: var(--text-1); font-size: 22px; margin-bottom: 8px; }
.empty-welcome > p { font-size: 15px; color: var(--text-3); }
.empty-features { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.empty-feat { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg-2); border-radius: 10px; font-size: 13px; color: var(--text-2); }

.cp-name-input { width: 100%; padding: 6px 10px; background: var(--bg-2); border: 1px solid var(--bg-3); border-radius: 6px; color: var(--text-1); font-size: 16px; font-weight: 600; text-align: center; }
.cp-name-input:focus { border-color: var(--primary-2); outline: none; }
.cp-editable { width: 100%; margin-top: 8px; }
.cp-link-item { border-bottom: 1px solid var(--bg-3); }
.cp-link-item:last-child { border-bottom: none; }

.msg-link-preview { margin-top: 6px; background: var(--bg-2); border-radius: 8px; overflow: hidden; border: 1px solid var(--bg-3); max-width: 280px; }
.lp-img { width: 100%; max-height: 140px; object-fit: cover; display: block; }
.lp-title { padding: 6px 10px 2px; font-size: 13px; font-weight: 600; color: var(--text-1); }
.lp-desc { padding: 0 10px 6px; font-size: 12px; color: var(--text-3); line-height: 1.4; }

.typing-anim { color: var(--primary-2) !important; font-style: italic; }
@keyframes typingPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.typing-anim { animation: typingPulse 1.5s ease-in-out infinite; }
.collision-bar { padding: 4px 12px; font-size: 12px; color: var(--primary-2); font-style: italic; animation: typingPulse 1.5s ease-in-out infinite; }

body { touch-action: manipulation; }
.filter-btn:active { transform: scale(0.95); opacity: 0.8; }
.convo-item:active { background: var(--bg-hover); }
.menu-item:active { background: var(--bg-3); transform: scale(0.98); }
.nav-item:active { opacity: 0.7; }
.msg:active .msg-react-btn { opacity: 1; }
.msg-truncated { max-height: 200px; overflow: hidden; position: relative; }
.msg-read-more { display: inline-block; color: var(--primary-2); font-size: 13px; cursor: pointer; margin-top: 4px; font-weight: 600; }

.offline-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 999; background: var(--danger); color: #fff; text-align: center; padding: 8px 14px; font-size: 13px; font-weight: 600; animation: slideDown 0.3s; }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

.lightbox { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,0.92); display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s; touch-action: pinch-zoom; }
.lightbox img { max-width: 95vw; max-height: 90vh; object-fit: contain; border-radius: 4px; }
.lightbox-close { position: absolute; top: max(12px, var(--safe-top)); right: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.15); color: #fff; font-size: 22px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.lightbox-dl { position: absolute; top: max(12px, var(--safe-top)); left: 12px; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.15); color: #fff; font-size: 18px; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; }

.upload-progress { position: fixed; bottom: calc(120px + var(--safe-bottom)); left: 50%; transform: translateX(-50%); z-index: 200; background: var(--bg-1); border: 1px solid var(--bg-3); border-radius: 12px; padding: 10px 16px; min-width: 200px; box-shadow: 0 4px 20px rgba(0,0,0,0.4); display: flex; align-items: center; gap: 10px; font-size: 13px; }
.upload-progress-bar { flex: 1; height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--primary-2); border-radius: 2px; transition: width 0.2s; }

.file-preview-modal { max-width: 380px; text-align: center; }
.file-preview-thumb { max-width: 200px; max-height: 200px; border-radius: 8px; margin: 12px auto; display: block; object-fit: contain; }
.file-preview-icon { font-size: 48px; margin: 16px 0; }
.file-preview-name { font-size: 14px; font-weight: 600; word-break: break-all; margin-bottom: 4px; }
.file-preview-meta { font-size: 12px; color: var(--text-3); margin-bottom: 16px; }
.file-preview-actions { display: flex; gap: 8px; }
.file-preview-actions .btn { flex: 1; }

.msg-link-suspect { color: var(--warning) !important; text-decoration: underline wavy var(--warning) !important; }

.flow-mobile-warn { display: none; background: rgba(232,192,122,0.15); color: var(--warning); padding: 12px 16px; border-radius: 8px; margin: 12px; font-size: 13px; text-align: center; border: 1px solid rgba(232,192,122,0.3); }
@media (max-width: 768px) { .flow-mobile-warn { display: block; } }

.btn-mini { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.tag-x { min-width: 22px; min-height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.note-del { min-width: 44px; min-height: 44px; }

input, textarea, select { font-size: 16px !important; }

.composer-row { gap: 6px; }

.scroll-anchor { position: absolute; bottom: 80px; left: 50%; transform: translateX(-50%); z-index: 30; background: var(--bg-1); border: 1px solid var(--bg-3); border-radius: 20px; padding: 6px 16px; font-size: 13px; color: var(--primary-2); cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,0.3); animation: fadeIn 0.2s; display: none; }
.scroll-anchor.visible { display: block; }

.dup-tab-overlay { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; }
.dup-tab-card { background: var(--bg-1); padding: 32px; border-radius: 16px; text-align: center; max-width: 380px; }
.dup-tab-card h2 { font-family: 'El Messiri', sans-serif; margin-bottom: 12px; font-size: 20px; }
.dup-tab-card p { color: var(--text-3); margin-bottom: 20px; font-size: 14px; line-height: 1.7; }

.install-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg-2); border-bottom: 1px solid var(--bg-3); }
.install-banner[hidden] { display: none; }
.install-banner .btn { width: auto; padding: 8px 16px; }

body { font-size: 1rem; }
@supports (font-size: clamp(14px, 1rem, 20px)) { body { font-size: clamp(14px, 1rem, 20px); } }

@media (hover: none) and (pointer: coarse) {
    .msg-react-btn { opacity: 0; }
    .msg:active .msg-react-btn { opacity: 1; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar { max-width: 300px; }
    .msg { max-width: 80%; }
    .modal-card { max-width: 480px; }
    .sidebar-header { padding: 8px 12px; min-height: 52px; }
    .convo-item { padding: 10px 12px; }
}
@media (min-width: 1025px) and (max-width: 1199px) {
    .sidebar { max-width: 340px; }
}
@media (min-width: 1200px) {
    .sidebar { max-width: 380px; }
    .msg { max-width: 70%; }
}
@media (min-width: 1400px) {
    .sidebar { max-width: 420px; }
}

@media (max-width: 480px) {
    .auth-card { padding: 24px 18px; border-radius: 14px; }
    .auth-brand h1 { font-size: 24px; }
    .brand-mark { width: 56px; height: 56px; }
    .auth-page { padding: 16px; padding-top: max(16px, var(--safe-top)); }
}

@media (max-width: 768px) and (orientation: landscape) {
    .bottom-nav { padding: 4px 0; }
    .nav-item span { font-size: 10px; }
}

@media (max-height: 500px) {
    .sidebar-header { min-height: 48px; padding: 6px 14px; }
    .chat-header { min-height: 48px; padding: 6px 12px; }
    .composer { padding: 6px 10px; }
    .bottom-nav { padding: 4px 0; }
    .nav-item span { display: none; }
}

@media (max-height: 700px) {
    .auth-page { align-items: flex-start; }
    .auth-brand { margin-bottom: 14px; }
    .field { margin-bottom: 10px; }
}
@media (max-height: 600px) and (orientation: landscape) {
    .auth-page { align-items: flex-start; padding-top: 12px; }
    .auth-arcs { display: none; }
    .auth-brand { margin-bottom: 12px; }
    .field { margin-bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

@media print {
    body, .app-shell { overflow: visible !important; height: auto !important; }
    .sidebar, .bottom-nav, .composer, .chat-header .icon-btn, .assignment-bar, .tag-bar, .window-warning, .modal, .toast, .offline-banner, .upload-progress, .msg-react-btn, .msg-retry, .qr-suggestions, .attach-menu, .ctx-menu, .reaction-picker, .back-btn, .bulk-bar, .chat-search-bar { display: none !important; }
    .chat-area { position: static !important; flex: none !important; }
    .chat-messages { overflow: visible !important; height: auto !important; max-height: none !important; }
    .chat-header { background: none !important; border-bottom: 2px solid #333; padding: 8px 0; }
    .chat-header { display: flex !important; }
    .msg-bubble { break-inside: avoid; }
    .msg-image { max-width: 200px !important; }
    @page { margin: 1.5cm; }
}

.msg-carousel{display:flex;overflow-x:auto;gap:8px;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;padding:4px 0;max-width:320px}
.msg-carousel::-webkit-scrollbar{height:4px}
.msg-carousel::-webkit-scrollbar-thumb{background:rgba(255,255,255,.2);border-radius:2px}
.msg-carousel-card{scroll-snap-align:start;flex:0 0 200px;background:var(--bg-2);border-radius:10px;overflow:hidden;border:1px solid var(--bg-3)}
.msg-carousel-card img{width:100%;height:110px;object-fit:cover}
.msg-carousel-card .cc-body{padding:8px 10px;font-size:13px;line-height:1.4;word-break:break-word}
.msg-carousel-card .cc-btns{display:flex;flex-direction:column;gap:4px;padding:4px 10px 8px}
.msg-carousel-card .cc-btn{text-align:center;padding:6px;border:1px solid var(--primary-2);border-radius:8px;color:var(--primary-2);font-size:12px;cursor:default}

/* شبكة مكتبة الوسائط: بديل onmouseover/onmouseout المحجوبَين بـCSP */
.cpml-item:hover { border-color: var(--primary-2) !important; }
