:root {
    --bg-main: #131b2e;
    --bg-panel: #1a2438;
    --bg-hover: rgba(255, 255, 255, 0.07);
    --border-color: rgba(255, 255, 255, 0.09);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.25);
    --success: #10b981;
    --danger: #ef4444;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --glass-bg: rgba(26, 36, 56, 0.92);
    --glass-border: rgba(255, 255, 255, 0.1);

    --sidebar-width: 320px;
    --inbox-width: 400px;
    --topbar-height: 64px;
    --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

body[data-theme="light"] {
    --bg-main: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-hover: rgba(15, 23, 42, 0.06);
    --border-color: rgba(15, 23, 42, 0.12);
    --text-main: #0f172a;
    --text-muted: #475569;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-glow: rgba(37, 99, 235, 0.18);
    --success: #16a34a;
    --danger: #dc2626;
    --accent-gradient: linear-gradient(135deg, #2563eb, #7c3aed);
    --glass-bg: rgba(255, 255, 255, 0.88);
    --glass-border: rgba(15, 23, 42, 0.08);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Ambient gradient overlay — tạo chiều sâu cho nền */
.app-wrapper::before {
    content: '';
    position: fixed;
    top: -30%;
    left: -30%;
    width: 160%;
    height: 160%;
    background: radial-gradient(ellipse at 15% 10%, rgba(59, 130, 246, 0.12) 0%, transparent 55%),
                radial-gradient(ellipse at 85% 85%, rgba(139, 92, 246, 0.08) 0%, transparent 55%),
                radial-gradient(ellipse at 50% 50%, rgba(59, 130, 246, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.app-wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* --- TOPBAR STYLES --- */
.topbar {
    height: var(--topbar-height);
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 50;
    box-shadow: none;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.025em;
}

.logo span {
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

body[data-theme="light"] .logo span {
    background: linear-gradient(135deg, #0f172a, #334155);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.35);
    color: var(--text-main);
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.2s var(--transition-smooth);
}

.theme-toggle-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

body[data-theme="light"] .theme-toggle-btn {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

.notification-wrapper {
    position: relative;
}

.bell-icon {
    position: relative;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s var(--transition-smooth);
    padding: 8px;
    border-radius: 50%;
}

.bell-icon:hover {
    color: var(--text-main);
    background-color: var(--bg-hover);
    transform: scale(1.1);
}

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: linear-gradient(135deg, #ef4444, #f97316);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    height: 16px;
    min-width: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-panel);
    animation: pulse 2s infinite;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.notif-dropdown {
    position: absolute;
    top: 100%;
    right: -10px;
    margin-top: 15px;
    width: 380px;
    background: rgba(26, 36, 56, 0.90);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    display: none;
    flex-direction: column;
    overflow: visible;
    z-index: 100;
    transform-origin: top right;
    animation: dropIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

body[data-theme="light"] .notif-dropdown {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(15, 23, 42, 0.05) inset;
}

body[data-theme="light"] .notif-header {
    background-color: rgba(15, 23, 42, 0.02);
}

body[data-theme="light"] .notif-item {
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: rgba(248, 250, 252, 0.95);
}

body[data-theme="light"] .notif-item.unread {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.11), rgba(124, 58, 237, 0.08));
}

body[data-theme="light"] .notif-item [style*="color: #f8fafc"] {
    color: #0f172a !important;
}

body[data-theme="light"] .notif-item [style*="color: #cbd5e1"] {
    color: #334155 !important;
}

body[data-theme="light"] .notif-item [style*="color: #94a3b8"] {
    color: #64748b !important;
}

body[data-theme="light"] .notif-item [style*="color: #60a5fa"] {
    color: #1d4ed8 !important;
}

.notif-dropdown.show {
    display: flex;
}

.notif-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.02);
}

.notifications-list {
    max-height: 520px;
    overflow-y: auto;
    padding: 0.5rem;
    scrollbar-width: thin;
}

.notif-item {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.25s var(--transition-smooth);
    border-left: 3px solid transparent;
}

.notif-item:hover {
    background-color: var(--bg-hover);
    transform: translateX(2px);
}

.notif-item.unread {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.08));
    border-left-color: var(--primary);
}

.user-mini-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.user-mini-profile img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: linear-gradient(var(--bg-panel), var(--bg-panel)) padding-box,
                linear-gradient(135deg, #3b82f6, #8b5cf6) border-box;
    transition: transform 0.2s var(--transition-smooth);
}

.user-mini-profile:hover img {
    transform: scale(1.1);
}

/* --- MAIN CONTAINER --- */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.3), rgba(139, 92, 246, 0.2));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(59, 130, 246, 0.5), rgba(139, 92, 246, 0.4));
}

/* Empty States */
.empty-state {
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.4;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Typography Helpers */
.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-muted {
    color: var(--text-muted);
}

.font-semibold {
    font-weight: 600;
}

/* 1. Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-main) 100%);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.ad-accounts-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    overscroll-behavior: contain;
    /* khóa bounce khi đến cuối */
}

.ad-account-item {
    margin-bottom: 0.5rem;
}

.ad-account-header {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.25s var(--transition-smooth);
}

.ad-account-header:hover {
    background-color: var(--bg-hover);
    transform: translateX(2px);
}

.ad-account-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ad-account-icon {
    color: var(--primary);
    width: 20px;
    text-align: center;
}

.campaigns-list {
    margin-left: 1rem;
    border-left: 1px solid var(--border-color);
    padding-left: 0.5rem;
    margin-top: 0.25rem;
    display: none;
}

.ad-account-item.expanded .campaigns-list {
    display: block;
    animation: slideDown 0.3s ease;
}

.ad-account-item.expanded .ad-account-header .toggle-icon {
    transform: rotate(90deg);
}

.campaign-item {
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.25s var(--transition-smooth);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.campaign-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
    transform: translateX(3px);
}

.campaign-item.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(139, 92, 246, 0.1));
    color: var(--primary);
    font-weight: 500;
    box-shadow: 0 0 12px var(--primary-glow);
}

body[data-theme="light"] .campaign-item {
    color: #334155;
}

body[data-theme="light"] .campaign-item.active {
    color: #1d4ed8;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.active {
    background-color: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.status-dot.paused {
    background-color: var(--text-muted);
}

/* 2. Inbox Panel */
.inbox-panel {
    width: var(--inbox-width);
    background-color: var(--bg-main);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    min-height: 90px;
}

.panel-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    line-height: 1.3;
}

.campaign-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.conversation-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.conversation-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    display: flex;
    gap: 1rem;
    transition: all 0.25s var(--transition-smooth);
}

.conversation-item:hover {
    background-color: var(--bg-hover);
    transform: translateX(3px);
}

.conversation-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.12) 0%, transparent 100%);
    border-left: 3px solid var(--primary);
    box-shadow: inset 4px 0 12px var(--primary-glow);
}

.conv-avatar {
    position: relative;
}

.conv-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--glass-border);
    transition: transform 0.2s var(--transition-smooth);
}

.conversation-item:hover .conv-avatar img {
    transform: scale(1.05);
}

.unread-badge {
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 50%;
    border: 2px solid var(--bg-main);
    box-shadow: 0 0 6px var(--primary-glow);
}

.conv-content {
    flex: 1;
    min-width: 0;
}

.conv-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

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

.conv-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.conv-message {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body[data-theme="light"] .conv-message {
    color: #334155;
}

.conversation-item.unread .conv-message {
    color: var(--text-main);
    font-weight: 500;
}

body[data-theme="light"] .conversation-item .text-xs[style*="color:#94a3b8"],
body[data-theme="light"] .conversation-item .text-xs[style*="color: #94a3b8"] {
    color: #64748b !important;
}

body[data-theme="light"] .conversation-item .text-xs [style*="color:#e2e8f0"],
body[data-theme="light"] .conversation-item .text-xs [style*="color: #e2e8f0"] {
    color: #334155 !important;
    font-weight: 600;
}

body[data-theme="light"] .conversation-item .text-xs i.fa-facebook {
    color: #1d4ed8;
}

body[data-theme="light"] .conv-time,
body[data-theme="light"] .message-time {
    color: #475569;
    font-weight: 500;
}

/* 3. Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    position: relative;
}

.chat-header {
    height: 90px;
    padding: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-header img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--glass-border);
}

body[data-theme="light"] .chat-header .text-xs {
    color: #64748b !important;
}

body[data-theme="light"] .chat-header .text-xs .text-slate-100,
body[data-theme="light"] .chat-header .text-xs code,
body[data-theme="light"] .chat-header .text-xs span[style*="opacity:.9"] {
    color: #334155 !important;
    font-weight: 600;
}

body[data-theme="light"] .chat-header .text-xs i.fa-facebook {
    color: #1d4ed8 !important;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overscroll-behavior: contain;
    /* khóa bounce khi đến cuối */
}

.message-date-divider {
    align-self: stretch;
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 0.35rem 0 0.15rem;
    flex-shrink: 0;
}

.message-date-divider span {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-panel);
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
}

.message-wrapper {
    display: flex;
    max-width: 70%;
}

.message-wrapper.page {
    align-self: flex-end;
}

.message-wrapper.customer {
    align-self: flex-start;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    transition: transform 0.15s var(--transition-smooth);
}

.message-wrapper:hover .message-bubble {
    transform: scale(1.01);
}

.message-wrapper.customer .message-bubble {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 4px;
}

body[data-theme="light"] .message-wrapper.customer .message-bubble {
    background: #e2e8f0;
    border: 1px solid rgba(15, 23, 42, 0.1);
    color: #0f172a;
}

.message-wrapper.page .message-bubble {
    background: var(--accent-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 14px var(--primary-glow);
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    opacity: 0.8;
}

.message-wrapper.page .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.6);
}

body[data-theme="light"] .message-wrapper.page .message-time {
    color: #475569;
}

.chat-input-area {
    padding: 1.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--glass-border);
    display: flex;
    gap: 1rem;
}

.chat-input-area input {
    flex: 1;
    background-color: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 24px;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.3s var(--transition-smooth);
}

.chat-input-area input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow), 0 0 20px rgba(59, 130, 246, 0.1);
}

body[data-theme="light"] .chat-input-area input {
    background-color: #ffffff;
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.14);
}

body[data-theme="light"] .chat-input-area input::placeholder {
    color: #64748b;
}

body[data-theme="light"] .chat-input-area input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2), 0 0 16px rgba(37, 99, 235, 0.12);
}

.chat-input-area button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s var(--transition-smooth);
    box-shadow: 0 4px 14px var(--primary-glow);
}

.chat-input-area button:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.chat-input-area button:active {
    transform: scale(0.95);
}

body[data-theme="light"] #conversationSearchInput {
    background: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid rgba(15, 23, 42, 0.14) !important;
}

body[data-theme="light"] #conversationSearchInput::placeholder {
    color: #64748b !important;
}

body[data-theme="light"] #globalSearchBtn {
    color: #ffffff !important;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* ===== MOBILE BACK BUTTON (ẩn trên desktop) ===== */
.mobile-back-btn {
    display: none;
}

/* ===== RESPONSIVE MOBILE (≤ 768px) ===== */
@media (max-width: 768px) {

    /* --- Viewport & body --- */
    html,
    body {
        height: 100%;
        overflow: hidden;
        overscroll-behavior: none;
    }

    .app-wrapper {
        height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* Topbar: chiều cao tường minh, tính safe-area notch */
    .topbar {
        flex-shrink: 0;
        height: auto;
        min-height: var(--topbar-height);
        padding: max(0px, env(safe-area-inset-top)) 10px 0;
        gap: 6px;
        box-sizing: border-box;
    }

    /* App-container: chiều cao rõ ràng = toàn bộ phần còn lại */
    .app-container {
        flex: 1;
        position: relative;
        overflow: hidden;
        /* không dùng height:0 — để flex tự tính, position:relative giúp children absolute fill đúng */
    }

    /* Panels: absolute fill 100% container — hoạt động vì container có computed height từ flex */
    .sidebar,
    .inbox-panel,
    .chat-panel {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        border: none !important;
        overflow: hidden;
    }

    /* Default: chỉ sidebar hiện */
    .sidebar {
        transform: translateX(0);
        z-index: 3;
    }

    .inbox-panel {
        transform: translateX(100%);
        z-index: 2;
    }

    .chat-panel {
        transform: translateX(100%);
        z-index: 1;
    }

    /* Inbox active */
    .app-container[data-panel="inbox"] .sidebar {
        transform: translateX(-100%);
    }

    .app-container[data-panel="inbox"] .inbox-panel {
        transform: translateX(0);
        z-index: 3;
    }

    .app-container[data-panel="inbox"] .chat-panel {
        transform: translateX(100%);
    }

    /* Chat active */
    .app-container[data-panel="chat"] .sidebar {
        transform: translateX(-100%);
    }

    .app-container[data-panel="chat"] .inbox-panel {
        transform: translateX(-100%);
    }

    .app-container[data-panel="chat"] .chat-panel {
        transform: translateX(0);
        z-index: 4;
    }

    /* --- Topbar compact --- */
    .logo span {
        display: none;
    }

    .logo {
        flex-shrink: 0;
    }

    #topName {
        display: none;
    }

    .topbar-right {
        gap: 8px;
        flex-shrink: 0;
    }

    .theme-toggle-btn span {
        display: none;
    }

    .theme-toggle-btn {
        padding: 8px 10px;
    }

    /* Override inline styles trên search form */
    #globalSearchForm {
        flex: 1 !important;
        max-width: none !important;
        margin: 0 6px !important;
        gap: 6px !important;
    }

    #globalSearchBtn {
        padding: 0 12px !important;
        flex-shrink: 0;
    }

    /* --- Panel header --- */
    .mobile-back-btn {
        display: flex;
        align-items: center;
        background: none;
        border: none;
        color: var(--primary);
        cursor: pointer;
        font-size: 1.1rem;
        padding: 8px 10px 8px 0;
        flex-shrink: 0;
    }

    .panel-header {
        height: auto;
        min-height: 56px;
        padding: 8px 16px;
        display: flex;
        align-items: center;
    }

    .panel-header h2 {
        font-size: 0.95rem;
    }

    /* --- Chat header --- */
    .chat-header {
        height: auto;
        min-height: 56px;
        padding: 8px 16px;
    }

    .chat-mobile-back {
        background: none;
        border: none;
        color: var(--primary);
        cursor: pointer;
        font-size: 1.1rem;
        padding: 8px 10px 8px 0;
        flex-shrink: 0;
    }

    /* --- Chat input safe area --- */
    .chat-input-area {
        padding: 10px 12px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        flex-shrink: 0;
    }

    /* --- Notification dropdown --- */
    .notif-dropdown {
        width: calc(100vw - 80px);
        /* Ngắn hơn trước (trước là 20px) */
        right: -150px;
        /* Dịch sang phải nhiều hơn (trước là -4px) */
        left: -300px;
        margin-top: 10px;
    }

    /* --- Message bubbles --- */
    .message-wrapper {
        max-width: 88%;
    }
}