/*
 * Chim Cu Gáy — UI 100% từ chat-zen-26.lovable.app (Session 16)
 * Tokens: HSL shadcn-style 2 themes (light xanh lá + dark navy cyan)
 */
:root {
    --radius: 1rem;
    --green: hsl(152 82% 50%);
    --danger: hsl(0 72% 55%);
    
    /* ===== DEFAULT THEME (LIGHT) ===== */
    --background: 140 22% 92%;
    --foreground: 155 30% 12%;
    --card: 140 25% 95%;
    --card-foreground: 155 30% 12%;
    --popover: 140 25% 96%;
    --popover-foreground: 155 30% 12%;
    --primary: 158 42% 38%;
    --primary-foreground: 140 30% 97%;
    --primary-glow: 150 50% 55%;
    --secondary: 140 20% 87%;
    --secondary-foreground: 155 30% 16%;
    --muted: 140 18% 86%;
    --muted-foreground: 152 12% 38%;
    --accent: 168 40% 45%;
    --accent-foreground: 140 30% 97%;
    --destructive: 0 65% 48%;
    --destructive-foreground: 0 0% 100%;
    --border: 142 16% 80%;
    --input: 142 16% 80%;
    --ring: 158 42% 38%;

    --tg-bg-chat: 140 22% 90%;
    --tg-bg-sidebar: 142 24% 94%;
    --tg-bg-message-out: 152 35% 82%;
    --tg-bg-message-in: 140 28% 96%;
    --tg-bubble-shadow: 0 1px 3px 0 hsl(155 30% 15% / 0.08);
    --tg-online: 148 65% 38%;
    --tg-typing: 158 42% 38%;
    --tg-unread: 158 42% 38%;
    --tg-hover: 142 20% 87%;

    --gradient-primary: linear-gradient(135deg, hsl(158 42% 38%), hsl(150 50% 52%));
    --gradient-glow: radial-gradient(circle at 30% 20%, hsl(158 45% 45% / 0.15), transparent 60%),
                     radial-gradient(circle at 70% 80%, hsl(178 40% 45% / 0.12), transparent 55%);
    --gradient-mesh: linear-gradient(135deg, hsl(140 22% 92%) 0%, hsl(150 20% 89%) 100%);
    --shadow-glow: 0 0 40px hsl(158 42% 40% / 0.22);
    --shadow-elevated: 0 20px 50px -20px hsl(155 30% 15% / 0.18);

    --sidebar-background: 142 24% 94%;
    --sidebar-foreground: 155 30% 12%;
    --sidebar-border: 142 16% 82%;
    --sidebar-accent: 142 20% 88%;
    --text2: hsl(152 12% 40%);
}

/* ===== DEFAULT THEME (DARK) ===== */
.dark {
    --background: 222 47% 5%;
    --foreground: 210 40% 96%;
    --card: 222 44% 8%;
    --card-foreground: 210 40% 96%;
    --popover: 222 44% 8%;
    --popover-foreground: 210 40% 96%;
    --primary: 189 94% 55%;
    --primary-foreground: 222 47% 6%;
    --primary-glow: 199 100% 65%;
    --secondary: 222 40% 12%;
    --secondary-foreground: 210 40% 92%;
    --muted: 222 35% 13%;
    --muted-foreground: 215 20% 60%;
    --accent: 189 94% 55%;
    --accent-foreground: 222 47% 6%;
    --destructive: 0 72% 55%;
    --destructive-foreground: 0 0% 100%;
    --border: 222 35% 16%;
    --input: 222 35% 14%;
    --ring: 189 94% 55%;

    --tg-bg-chat: 222 47% 5%;
    --tg-bg-sidebar: 222 44% 7%;
    --tg-bg-message-out: 199 80% 22%;
    --tg-bg-message-in: 222 40% 12%;
    --tg-bubble-shadow: 0 2px 8px 0 hsl(0 0% 0% / 0.35);
    --tg-online: 152 82% 50%;
    --tg-typing: 189 94% 55%;
    --tg-unread: 189 94% 55%;
    --tg-hover: 222 40% 11%;

    --gradient-primary: linear-gradient(135deg, hsl(199 100% 55%), hsl(189 94% 60%));
    --gradient-glow: radial-gradient(circle at 20% 15%, hsl(199 100% 50% / 0.18), transparent 55%),
                     radial-gradient(circle at 85% 85%, hsl(263 85% 60% / 0.14), transparent 55%);
    --gradient-mesh: linear-gradient(135deg, hsl(222 47% 5%) 0%, hsl(230 45% 7%) 100%);
    --shadow-glow: 0 0 50px hsl(189 94% 55% / 0.35);
    --shadow-elevated: 0 25px 60px -20px hsl(0 0% 0% / 0.6);

    --sidebar-background: 222 44% 7%;
    --sidebar-foreground: 210 40% 96%;
    --sidebar-border: 222 35% 15%;
    --sidebar-accent: 222 40% 11%;
    --text2: hsl(215 20% 60%);
}

/* ===== FOREST THEME (LIGHT) ===== */
[data-theme-profile="forest"] {
    --background: 158 40% 92%;
    --foreground: 158 79% 5%;
    --card: 158 40% 95%;
    --card-foreground: 158 79% 5%;
    --popover: 158 40% 96%;
    --popover-foreground: 158 79% 5%;
    --primary: 158 79% 30%;
    --primary-foreground: 158 40% 98%;
    --primary-glow: 158 79% 38%;
    --secondary: 158 40% 87%;
    --secondary-foreground: 158 79% 16%;
    --muted: 158 30% 86%;
    --muted-foreground: 158 20% 38%;
    --accent: 158 79% 35%;
    --accent-foreground: 158 40% 98%;
    --border: 158 30% 80%;
    --input: 158 30% 80%;
    --ring: 158 79% 30%;

    --tg-bg-chat: 158 40% 90%;
    --tg-bg-sidebar: 158 40% 94%;
    --tg-bg-message-out: 158 79% 82%;
    --tg-bg-message-in: 158 40% 96%;
    --tg-bubble-shadow: 0 1px 3px 0 hsl(158 79% 15% / 0.08);
    --tg-online: 152 82% 38%;
    --tg-typing: 158 79% 30%;
    --tg-unread: 158 79% 30%;
    --tg-hover: 158 40% 87%;

    --gradient-primary: linear-gradient(135deg, hsl(158 79% 30%), hsl(158 79% 38%));
    --gradient-glow: radial-gradient(circle at 30% 20%, hsl(158 79% 45% / 0.15), transparent 60%),
                     radial-gradient(circle at 70% 80%, hsl(158 79% 45% / 0.12), transparent 55%);
    --gradient-mesh: linear-gradient(135deg, hsl(158 40% 92%) 0%, hsl(158 30% 89%) 100%);
    --shadow-glow: 0 0 40px hsl(158 79% 30% / 0.22);
    --shadow-elevated: 0 20px 50px -20px hsl(158 79% 15% / 0.18);

    --sidebar-background: 158 40% 94%;
    --sidebar-foreground: 158 79% 12%;
    --sidebar-border: 158 30% 82%;
    --sidebar-accent: 158 40% 88%;
    --text2: hsl(158 20% 40%);
}

/* ===== FOREST THEME (DARK) ===== */
[data-theme-profile="forest"].dark {
    --background: 158 79% 5%;
    --foreground: 158 40% 96%;
    --card: 158 79% 8%;
    --card-foreground: 158 40% 96%;
    --popover: 158 79% 8%;
    --popover-foreground: 158 40% 96%;
    --primary: 158 79% 38%;
    --primary-foreground: 158 40% 98%;
    --primary-glow: 158 79% 45%;
    --secondary: 158 60% 12%;
    --secondary-foreground: 158 40% 92%;
    --muted: 158 50% 13%;
    --muted-foreground: 158 20% 60%;
    --accent: 158 79% 45%;
    --accent-foreground: 158 40% 98%;
    --destructive: 0 72% 55%;
    --destructive-foreground: 0 0% 100%;
    --border: 158 40% 16%;
    --input: 158 40% 14%;
    --ring: 158 79% 38%;

    --tg-bg-chat: 158 79% 5%;
    --tg-bg-sidebar: 158 79% 7%;
    --tg-bg-message-out: 158 79% 22%;
    --tg-bg-message-in: 158 60% 12%;
    --tg-bubble-shadow: 0 2px 8px 0 hsl(0 0% 0% / 0.35);
    --tg-online: 152 82% 50%;
    --tg-typing: 158 79% 38%;
    --tg-unread: 158 79% 38%;
    --tg-hover: 158 60% 11%;

    --gradient-primary: linear-gradient(135deg, hsl(158 79% 38%), hsl(158 79% 45%));
    --gradient-glow: radial-gradient(circle at 20% 15%, hsl(158 79% 30% / 0.18), transparent 55%),
                     radial-gradient(circle at 85% 85%, hsl(158 79% 25% / 0.14), transparent 55%);
    --gradient-mesh: linear-gradient(135deg, hsl(158 79% 5%) 0%, hsl(158 70% 7%) 100%);
    --shadow-glow: 0 0 50px hsl(158 79% 38% / 0.35);
    --shadow-elevated: 0 25px 60px -20px hsl(0 0% 0% / 0.6);

    --sidebar-background: 158 79% 7%;
    --sidebar-foreground: 158 40% 96%;
    --sidebar-border: 158 40% 15%;
    --sidebar-accent: 158 60% 11%;
    --text2: hsl(158 20% 60%);
}

/* Thêm style cho Modal chọn Theme */
.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid hsl(var(--border) / 0.5);
    margin-bottom: 8px;
}
.theme-option:hover { background: hsl(var(--secondary) / 0.5); }
.theme-option.active { border-color: hsl(var(--primary)); background: hsl(var(--primary) / 0.1); }
.theme-preview {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
}
.theme-preview.default { background: linear-gradient(135deg, #0f172a 50%, #f1f5f9 50%); }
.theme-preview.forest { background: linear-gradient(135deg, #08442d 50%, #eefbf4 50%); }
.theme-info { flex: 1; }
.theme-name { font-weight: 600; font-size: 0.95rem; }
.theme-desc { font-size: 0.8rem; color: hsl(var(--muted-foreground)); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    /* Tăng độ nét cho text: antialiasing + kerning (fix mờ trên màn hình thường) */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'kern' 1, 'liga' 1;
    background-image: var(--gradient-glow);
    background-attachment: fixed;
    overscroll-behavior: none;
}
/* Session 125: Typography unification — Inter everywhere, no Space Grotesk/JetBrains Mono */
h1, h2, h3, h4 { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: -0.01em; }
.font-mono, code, .font-mono-label { font-family: 'Inter', ui-monospace, 'SFMono-Regular', Menlo, monospace; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
/* Dropdown/menu khi an: fade out ngan */
.dropdown.hidden { animation: none; }
a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }
/* ===== Focus ring accent (thay outline cam mac dinh cua trinh duyet) ===== */
input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
    outline: 2px solid hsl(var(--primary) / 0.7);
    outline-offset: 2px;
    border-radius: 4px;
}
button:focus-visible { outline: 2px solid hsl(var(--primary) / 0.6); outline-offset: 2px; border-radius: 8px; }
/* Khoa scroll body khi modal/lightbox mo */
body.modal-open { overflow: hidden; }
/* ===== Toast notification (thay alert() — Session 26) ===== */
#toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast-pill { pointer-events: auto; background: hsl(var(--card) / 0.95); border: 1px solid hsl(var(--border) / 0.6); color: hsl(var(--foreground)); border-radius: 999px; padding: 10px 20px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-elevated); backdrop-filter: blur(12px); animation: toastIn .22s cubic-bezier(.33,1,.68,1); display: flex; align-items: center; gap: 9px; max-width: 88vw; }
.toast-pill.success { border-color: hsl(var(--green)); }
.toast-pill.success .lucide { color: hsl(var(--green)); }
.toast-pill.error { border-color: hsl(var(--destructive)); }
.toast-pill.error .lucide { color: hsl(var(--destructive)); }
.toast-pill .lucide { width: 16px; height: 16px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(8px) scale(0.97); } }
.toast-pill.out { animation: toastOut .18s ease-in forwards; }

/* ===== Icons lucide chuẩn ===== */
.lucide { display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }
.lucide.h-4 { width: 16px; height: 16px; }
.lucide.h-5 { width: 20px; height: 20px; }
.lucide.h-6 { width: 24px; height: 24px; }

/* ===== Nền chấm bi (từ gốc index.css) ===== */
.dots-bg {
    background-image:
      radial-gradient(circle at 1px 1px, hsl(var(--primary) / 0.22) 1px, transparent 0),
      radial-gradient(circle at 12px 12px, hsl(var(--foreground) / 0.06) 1px, transparent 0);
    background-size: 24px 24px, 24px 24px;
}
.dots-bg-soft {
    background-image: radial-gradient(circle at 1px 1px, hsl(var(--foreground) / 0.10) 1px, transparent 0);
    background-size: 22px 22px;
}
.grid-bg {
    background-image:
      linear-gradient(hsl(var(--border) / 0.35) 1px, transparent 1px),
      linear-gradient(90deg, hsl(var(--border) / 0.35) 1px, transparent 1px);
    background-size: 32px 32px;
    background-position: -1px -1px;
}
.gradient-primary { background: var(--gradient-primary); }
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.glow { box-shadow: var(--shadow-glow); }
.shadow-elevated { box-shadow: var(--shadow-elevated); }
.ring-glow { box-shadow: 0 0 0 1px hsl(var(--primary) / 0.4), 0 0 24px hsl(var(--primary) / 0.35); }
.hex-avatar {
    clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
    border-radius: 6px;
}

/* ===== Scrollbar ẩn hiện thông minh (Session 39) ===== */
.scrollbar-thin {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 0.3s ease;
}
.scrollbar-thin:hover, .scrollbar-thin:active {
    scrollbar-color: hsl(var(--primary) / 0.4) transparent;
}
.scrollbar-thin::-webkit-scrollbar { width: 5px; height: 5px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 20px;
    transition: background-color 0.3s ease;
}
.scrollbar-thin:hover::-webkit-scrollbar-thumb,
.scrollbar-thin:active::-webkit-scrollbar-thumb {
    background-color: hsl(var(--primary) / 0.4);
}
.scrollbar-thin::-webkit-scrollbar-thumb:hover {
    background-color: hsl(var(--primary) / 0.6);
}

/* ===== Album Media (Telegram Style) ===== */
.msg.album {
    padding: 2px;
    max-width: 420px;
    background: transparent !important;
    box-shadow: none !important;
}
.msg-album {
    display: grid;
    gap: 3px;
    border-radius: 12px;
    overflow: hidden;
}

.msg-album img, .msg-album video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* Quay lai cover de lap day khoang trong, user muon "tranh vi tri trong" */
    background: hsl(var(--secondary) / 0.2) !important;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    display: block;
}
.msg-album img:hover, .msg-album video:hover { opacity: 0.9; transform: scale(1.02); }
.msg-album img:hover, .msg-album video:hover { opacity: 0.9; }

/* Grid layouts dựa trên số lượng file - Toi uu de khong co khoang trong */
.album-2 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 9; }
.album-3 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 1; }
.album-3 img:first-child, .album-3 video:first-child { grid-row: span 2; }
.album-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; aspect-ratio: 1; }
.album-5, .album-6 { grid-template-columns: repeat(3, 1fr); aspect-ratio: 3 / 2; }
.album-7, .album-8, .album-9 { grid-template-columns: repeat(3, 1fr); aspect-ratio: 1; }
.album-10 { grid-template-columns: repeat(4, 1fr); aspect-ratio: 1; }

/* Session 121: msg-album-wrap now transparent — single background comes from .msg only.
   Previously this had its own bg + box-shadow, causing double-background on album bubbles. */
.msg-album-wrap {
    display: flex;
    flex-direction: column;
    border-radius: 10px;
    overflow: hidden;
    background: transparent !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
}
.out .msg-album-wrap { background: transparent !important; }

.album-caption {
    padding: 8px 12px 6px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-break: break-word;
    color: hsl(var(--foreground));
}
.out .album-caption { color: #e2f8ff; }

.msg.album .meta {
    padding: 0 8px 4px;
    margin-top: -4px;
    position: relative;
    z-index: 2;
}
.msg.album:not(:has(.album-caption)) .meta {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.4);
    padding: 2px 6px;
    border-radius: 10px;
    color: #fff;
    backdrop-filter: blur(4px);
}

/* ================== Reply Styles (Session 46) ================== */
.reply-preview {
    display: flex;
    align-items: center;
    background: rgba(var(--cyan-rgb), 0.05);
    border-left: 3px solid var(--cyan);
    padding: 8px 12px;
    margin: 0 10px;
    border-radius: 4px 4px 0 0;
    position: relative;
    animation: slideUp 0.2s ease-out;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.rp-content { flex: 1; overflow: hidden; }
.rp-name { font-size: 0.85rem; font-weight: 600; color: var(--cyan); margin-bottom: 2px; }
.rp-text { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-close { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 4px; font-size: 1.1rem; }
.rp-close:hover { color: var(--red); }

.reply-quote {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid var(--cyan);
    padding: 6px 10px;
    margin-bottom: 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    max-width: 100%;
    overflow: hidden;
}
[data-theme="dark"] .reply-quote { background: rgba(255, 255, 255, 0.05); }
.reply-quote:hover { background: rgba(var(--cyan-rgb), 0.1); }
.rq-name { font-size: 0.75rem; font-weight: 600; color: var(--cyan); margin-bottom: 2px; }
.rq-text { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.msg-highlight {
    animation: msgGlow 2s ease-out;
}
@keyframes msgGlow {
    0% { background: rgba(var(--cyan-rgb), 0.3); }
    100% { background: transparent; }
}

/* ===== Animations (thay framer-motion) ===== */
@keyframes msgEnter {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
}
.msg-row.new { animation: msgEnter .15s ease-out; }
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-5px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}
.fade-in { animation: fadeSlideIn .15s ease-out; }
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.94); }
    to   { opacity: 1; transform: scale(1); }
}
.scale-in { animation: scaleIn .18s cubic-bezier(.33,1,.68,1); }
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px hsl(var(--primary) / 0.35); }
    50%      { box-shadow: 0 0 40px hsl(var(--primary) / 0.55); }
}
.animate-pulse-glow { animation: pulseGlow 3s ease-in-out infinite; }
@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
    30%           { opacity: 1; transform: translateY(-3px); }
}
.typing-dot { animation: typingDot 1.4s ease-in-out infinite; }
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }

/* ===== Auth page (AuthPage gốc) ===== */
.auth-page { position: relative; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: hidden; }
.auth-bg-decor { position: absolute; inset: 0; opacity: .7; pointer-events: none; z-index: 0; }
.auth-blob-1 { position: absolute; top: -160px; left: -160px; width: 500px; height: 500px; border-radius: 9999px; background: hsl(var(--primary) / 0.2); filter: blur(80px); pointer-events: none; }
.auth-blob-2 { position: absolute; bottom: -160px; right: -160px; width: 500px; height: 500px; border-radius: 9999px; background: hsl(var(--accent) / 0.2); filter: blur(80px); pointer-events: none; }
.theme-toggle { position: absolute; top: 20px; right: 20px; z-index: 10; display: flex; align-items: center; gap: 8px; border-radius: 12px; border: 1px solid hsl(var(--border) / 0.6); background: hsl(var(--secondary) / 0.6); padding: 8px 12px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: hsl(var(--muted-foreground)); backdrop-filter: blur(12px); transition: all .2s; }
.theme-toggle:hover { color: hsl(var(--primary)); border-color: hsl(var(--primary) / 0.6); }
.auth-container { position: relative; z-index: 1; width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: 32px; }
.auth-logo-tile { position: relative; width: 64px; height: 64px; margin: 0 auto 16px; }
.auth-logo-tile .glow-ring { position: absolute; inset: 0; background: var(--gradient-primary); border-radius: 16px; filter: blur(16px); opacity: .6; animation: pulseGlow 3s ease-in-out infinite; }
.auth-logo-tile .tile { position: relative; width: 64px; height: 64px; background: var(--gradient-primary); border-radius: 16px; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-elevated); }
.auth-logo-tile .tile img { width: 40px; height: 40px; object-fit: contain; }
.auth-logo h1 { font-size: 30px; font-weight: 700; }
.auth-subtitle { color: hsl(var(--muted-foreground)); font-size: 14px; margin-top: 8px; }
.auth-card { background: hsl(var(--card) / 0.6); border: 1px solid hsl(var(--border) / 0.5); backdrop-filter: blur(20px) saturate(180%); border-radius: 24px; padding: 24px; box-shadow: var(--shadow-elevated); }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: hsl(var(--muted-foreground)); margin-bottom: 6px; }
.auth-input { width: 100%; background: hsl(var(--secondary) / 0.6); border: 1px solid hsl(var(--border) / 0.6); border-radius: 12px; padding: 10px 14px; font-size: 14px; color: hsl(var(--foreground)); outline: none; transition: all .2s; }
.auth-input::placeholder { color: hsl(var(--muted-foreground)); }
.auth-input:focus { border-color: hsl(var(--primary)); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2); }
.auth-input-wrap { position: relative; }
.auth-input-wrap .auth-input { padding-right: 38px; }
.auth-eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: hsl(var(--muted-foreground)); padding: 4px; }
.auth-eye:hover { color: hsl(var(--primary)); }
.btn-primary { width: 100%; background: var(--gradient-primary); color: hsl(var(--primary-foreground)); border: none; border-radius: 12px; padding: 12px; font-size: 14px; font-weight: 600; margin-top: 6px; transition: all .2s; }
.btn-primary:hover { opacity: .9; box-shadow: var(--shadow-glow); }
.btn-primary:disabled { opacity: .5; }
.auth-error { color: hsl(var(--destructive)); font-size: 13px; margin: 10px 0 4px; }
.auth-success { color: hsl(var(--green)); font-size: 13px; margin: 10px 0 4px; }
.auth-switch { text-align: center; font-size: 14px; color: hsl(var(--muted-foreground)); margin-top: 20px; }
.auth-switch a { font-weight: 500; }
.auth-fallback { text-align: center; font-size: 12.5px; margin-top: 16px; }
.auth-fallback a { color: hsl(var(--muted-foreground)); text-decoration: underline; }
.auth-fallback a:hover { color: hsl(var(--foreground)); }

/* ============ Chat layout ============ */
.app { display: flex; height: 100vh; overflow: hidden; }
/* Sidebar giong goc: nen mau deu hsl(var(--tg-bg-sidebar)) (khong gradient), khong ke thua gradient glow cua body; opacity 0.92 de hoi trong suot + giu ::before cham bi (dots-bg-soft goc) */
.sidebar { position: relative; width: 340px; background: hsl(var(--tg-bg-sidebar) / 0.92); border-right: 1px solid hsl(var(--border) / 0.5); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar::before { content: ''; position: absolute; inset: 0; background-image: radial-gradient(circle at 1px 1px, hsl(var(--foreground) / 0.10) 1px, transparent 0); background-size: 22px 22px; pointer-events: none; }
.sb-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px; }
.hamburger { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; background: none; border: 1px solid transparent; color: hsl(var(--sidebar-foreground)); border-radius: 10px; transition: all .15s; cursor: pointer; }
.hamburger:hover { background: hsl(var(--sidebar-accent)); }
.hamburger img.lucide, .hamburger .lucide { width: 18px; height: 18px; display: inline-block; }
.sb-logo { width: 26px; height: 26px; object-fit: contain; flex-shrink: 0; image-rendering: auto; }
/* Logo + hình ảnh trong app luôn render sắc nét, không tự làm mờ khi scale */
img { image-rendering: auto; -webkit-user-drag: none; }
img.sb-logo, img.owl, .auth-logo-tile .tile img { filter: brightness(0.88) saturate(0.94); }
.sb-title { font-weight: 700; font-size: 16px; flex: 1; }
.sb-search-capsule { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; background: hsl(var(--secondary) / 0.35); border: 1px solid hsl(var(--border) / 0.4); border-radius: 999px; padding: 0 14px 0 12px; transition: all .2s; }
.sb-search-capsule:hover { background: hsl(var(--secondary) / 0.5); }
.sb-search-capsule:focus-within { border-color: hsl(var(--primary)); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.18); background: hsl(var(--secondary) / 0.5); }
.sb-search-capsule .lucide { position: static; transform: none; width: 15px; height: 15px; color: hsl(var(--muted-foreground)); pointer-events: none; margin-right: 8px; }
.sb-search-capsule input { width: 100%; min-width: 0; background: none; border: none; padding: 9px 0; font-size: 14px; font-weight: 400; color: hsl(var(--foreground)); outline: none; }
.sb-search-capsule input::placeholder { color: hsl(var(--muted-foreground)); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; background: none; border: 1px solid transparent; color: hsl(var(--muted-foreground)); border-radius: 10px; transition: all .15s; cursor: pointer; }
.icon-btn:hover { background: hsl(var(--secondary) / 0.6); color: hsl(var(--foreground)); }
/* lucide SVG da duoc recolor truc tiep trong file (icons-cyan.svg / icons-red.svg)
   nen <img> hien dung mau, khong can filter. */
.icon-btn img.lucide, .icon-btn .lucide { width: 18px; height: 18px; display: inline-block; transition: filter 0.2s; }
/* Tối ưu màu icon theme sáng: Đậm nét và chuyên nghiệp hơn */
body:not(.dark) .icon-btn img.lucide, body:not(.dark) .icon-btn .lucide,
body:not(.dark) #chatMoreMenu button img.lucide,
body:not(.dark) .attach-btn img, body:not(.dark) .emoji-btn img, body:not(.dark) .mic-btn img,
body:not(.dark) .bottom-nav .bn-item img,
body:not(.dark) .chat-header .icon-btn img,
body:not(.dark) .ch-brand img,
body:not(.dark) .sb-head button img {
    filter: brightness(0.25) contrast(1.8) saturate(1.2);
}

/* Đồng bộ màu icon danh bạ và các icon khác trên mobile theo theme */
.bn-item {
    color: hsl(var(--muted-foreground));
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.bn-item.active {
    color: hsl(var(--primary));
}

/* Fix màu icon danh bạ mobile đồng nhất (Session 57) */
.bn-item[onclick*="contacts"],
.bn-item[onclick*="showContacts"] {
    color: hsl(var(--muted-foreground));
}
.bn-item[onclick*="contacts"].active,
.bn-item[onclick*="showContacts"].active {
    color: hsl(var(--primary));
}

.light .bn-item {
    color: hsl(var(--muted-foreground));
}
.light .bn-item.active {
    color: hsl(var(--primary));
}
.bn-item img {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease-out, filter 0.2s;
}
.bn-item.active img {
    transform: scale(1.1);
}

/* Đảm bảo icon SVG trong bottom nav (Danh bạ) nhận màu theo theme */
body.dark .bn-item img {
    filter: brightness(0) saturate(100%) invert(87%) sepia(23%) saturate(452%) hue-rotate(152deg) brightness(101%) contrast(92%); /* Màu cyan #7de1f5 */
}
body.dark .bn-item.active img {
    filter: brightness(0) saturate(100%) invert(58%) sepia(93%) saturate(1542%) hue-rotate(153deg) brightness(101%) contrast(96%); /* Màu primary cyan đậm hơn */
}
body:not(.dark) .bn-item.active img {
    filter: brightness(0.1) contrast(2.2); /* Màu đen đậm cho active theme sáng */
}
body:not(.dark) .bn-item:not(.active) img {
    filter: brightness(0.35) contrast(1.5); /* Màu xám đậm cho inactive theme sáng */
}
.icon-btn.danger { color: hsl(var(--destructive)); }
.icon-btn.danger:hover { background: hsl(var(--destructive) / 0.1); }
.notif-btn-wrap { position: relative; display: flex; align-items: center; }
.notif-badge { position: absolute; top: -2px; right: -4px; background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); border-radius: 999px; min-width: 16px; height: 16px; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1; box-shadow: 0 0 0 2px hsl(var(--background)); }
.notif-badge.hidden { display: none; }
.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 3px; }
/* conv row gốc: px-4 py-3 gap-3; active bg-primary/10; hover bg-tg-hover; pinned bg-primary/5 */
.conv-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px; cursor: pointer; background: transparent; border: 1px solid transparent; transition: all .18s cubic-bezier(.33,1,.68,1); }
.conv-item:hover { background: hsl(var(--tg-hover)); }
.conv-item.active { background: hsl(var(--primary) / 0.1); border-color: transparent; }
.conv-item.active:hover { background: hsl(var(--primary) / 0.14); }
.conv-item.pinned-item { background: hsl(var(--primary) / 0.05); }

/* ===== Avatar (gốc: màu hash tên, hex cho nhóm, dot online) ===== */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; color: #fff; flex-shrink: 0; position: relative; background: hsl(215 25% 27%); filter: brightness(0.92); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar.small { width: 32px; height: 32px; font-size: 12px; }
.avatar.md { width: 44px; height: 44px; font-size: 16px; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
/* Dot online/offline — gốc ChatAvatar: dot bottom-0 right-0 border-card (avatar nhỏ); dot to hơn cho avatar md/lg */
.avatar.online-dot::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid hsl(var(--background));
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.1);
    animation: pulse-online 2s infinite;
    z-index: 2;
    transform: translate(25%, -25%);
}
.avatar.offline-dot::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: hsl(var(--muted-foreground));
    border: 2px solid hsl(var(--background));
    opacity: 0.8;
    z-index: 2;
    transform: translate(25%, -25%);
}
.avatar.md.online-dot::after, .avatar.lg.online-dot::after { width: 14px; height: 14px; top: 0; right: 0; transform: translate(25%, -25%); }
.avatar.md.offline-dot::after, .avatar.lg.offline-dot::after { width: 11px; height: 11px; top: 0; right: 0; transform: translate(25%, -25%); }

@keyframes pulse-online {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.bot-badge-mark { position: absolute; bottom: -2px; right: -2px; width: 16px; height: 16px; border-radius: 4px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid hsl(var(--background)); }
/* Session 133: conv-meta — truncate name to not push time off screen */
.conv-meta { flex: 1; min-width: 0; overflow: hidden; }
.conv-name { font-weight: 600; font-size: 15px; line-height: 1.3; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.conv-name > * { flex-shrink: 0; }
.bot-badge { font-size: 9px; background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); padding: 1px 5px; border-radius: 5px; font-weight: 700; letter-spacing: .04em; }
.conv-last { font-size: 13px; font-weight: 400; line-height: 1.35; color: hsl(var(--muted-foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-time { font-size: 11px; font-weight: 400; color: hsl(var(--muted-foreground)); flex-shrink: 0; }
/* Session 133: conv-unread — smaller badge, positioned after time (last item) */
.conv-unread { flex-shrink: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: hsl(var(--tg-unread)); color: hsl(var(--tg-bg-chat)); font-size: 9px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.conv-item:not(.active) .conv-unread { background: hsl(var(--tg-online)); }
.sb-profile { display: none; /* Session 34: profile chuyen vao menu hamburger */ }

/* ============ Chat main ============ */
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: hsl(var(--tg-bg-chat)); }
.chat-main.dots-bg {
    background-image:
      radial-gradient(circle at 1px 1px, hsl(var(--primary) / 0.22) 1px, transparent 0),
      radial-gradient(circle at 12px 12px, hsl(var(--foreground) / 0.06) 1px, transparent 0);
    background-size: 24px 24px, 24px 24px;
}
.chat-header { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--card) / 0.4); position: relative; }
.chat-more-wrap { margin-left: auto; }
.chat-header .name { font-weight: 600; font-size: 16px; font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; cursor: pointer; }
.chat-header .avatar.small { cursor: pointer; }
.chat-header .sub { font-size: 12px; color: hsl(var(--muted-foreground)); }
.chat-header .sub.online-sub { color: hsl(var(--tg-online)); }
.ch-brand { display: none !important; }

/* Session 40: Dropdown menu 3 cham header chat */
.dd-wrap { position: relative; }
#chatMoreMenu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 8px;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border) / 0.6);
    border-radius: 12px;
    padding: 8px;
    min-width: 180px;
    width: max-content !important;
    white-space: nowrap;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    z-index: 9999;
    animation: scaleIn 0.15s ease-out;
    overflow: visible !important;
    /* Session 59: Position menu exactly below the 3-dot trigger */
    right: 12px;
    left: auto;
    top: 42px; /* Anchor closer to header */
    transform: none;
    transform-origin: top right;
}
#chatMoreMenu button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    border-radius: 8px;
    color: hsl(var(--foreground));
    font-size: 14.5px;
    background: transparent;
    border: none;
    transition: all 0.2s;
    white-space: nowrap;
    cursor: pointer;
}
#chatMoreMenu button:hover {
    background: hsl(var(--accent) / 0.15);
}
#chatMoreMenu .ic {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    opacity: 0.85;
}
#chatMoreMenu button.hidden { display: none !important; }
.chat-header .actions { display: flex; gap: 8px; margin-left: auto; align-items: center; }
.chat-header .actions .icon-btn { 
    width: 38px; 
    height: 38px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-radius: 50%;
    transition: background 0.2s;
}
.chat-header .actions .icon-btn:hover { background: hsl(var(--accent) / 0.15); }
.chat-header .chat-more-wrap { margin-left: 0; }
.chat-header .actions .icon-btn { width: 34px; height: 34px; }

.msg-area { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: none; -ms-overflow-style: none; }
.msg-area::-webkit-scrollbar { width: 0; height: 0; display: none; }
.msg-row { display: flex; flex-direction: column; align-items: flex-start; width: 100%; }
.msg-row.out { align-items: flex-end; }
.msg-row > div { display: flex; flex-direction: column; align-items: flex-start; }
.msg-row.out > div { align-items: flex-end; }
.msg-row.group .sender-label { font-size: 11px; color: hsl(var(--primary)); font-weight: 600; margin-bottom: 2px; padding-left: 4px; }

/* ===== Hover action buttons trên bubble (gốc: Trả lời / Thả cảm xúc — fade + trượt) ===== */
.msg-group-actions { position: absolute; top: 50%; margin-top: -16px; display: flex; gap: 4px; opacity: 0; transform: translateX(-6px); transition: opacity .15s ease-out, transform .15s ease-out; pointer-events: none; z-index: 20; }
.msg-row.out .msg-group-actions { right: 100%; transform: translateX(6px); padding-right: 4px; }
.msg-row.in .msg-group-actions { left: 100%; padding-left: 4px; }
.msg-row:hover .msg-group-actions { opacity: 1; transform: translateX(0); pointer-events: auto; }
.msg-row.out:hover .msg-group-actions { transform: translateX(0); }
.mga-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: hsl(var(--secondary) / 0.92); border: 1px solid hsl(var(--border) / 0.5); color: hsl(var(--muted-foreground)); transition: all .12s; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.mga-btn:hover { background: hsl(var(--tg-hover)); color: hsl(var(--primary)); }
.mga-btn .lucide { width: 15px; height: 15px; }
.msg .meta .tick { color: hsl(var(--primary)); }
.msg.out .meta .tick { color: hsl(var(--foreground) / 0.9); }
.msg { max-width: 92%; min-width: 40px; width: fit-content; padding: 8px 12px; border-radius: 16px; font-size: 15px; font-weight: 400; line-height: 1.5; position: relative; word-break: break-word; overflow-wrap: anywhere; hyphens: auto; text-align: left; transition: transform .12s, box-shadow .12s, background-color .15s; background: hsl(var(--tg-bg-message-in) / 0.30); backdrop-filter: blur(12px) saturate(150%); -webkit-backdrop-filter: blur(12px) saturate(150%); border: 1px solid hsl(var(--foreground) / 0.10); box-shadow: var(--tg-bubble-shadow), inset 0 1px 0 hsl(var(--foreground) / 0.04); white-space: pre-wrap; display: inline-block; vertical-align: top; height: auto; min-height: unset; margin: 0; }
.msg.out { text-align: left; }
.msg-content-wrap { display: flex; flex-direction: column; max-width: 100%; width: 100%; }
.msg-row.out .msg-content-wrap { align-items: flex-end; }
.msg-row.in .msg-content-wrap { align-items: flex-start; }
.msg-row:hover .msg { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.msg.new { animation: msgEnter .15s ease-out; }
.msg.in { border-radius: 18px 18px 6px 18px; }
.msg.in + .reactions { margin-left: 4px; }
.msg.out { background: hsl(var(--tg-bg-message-out) / 0.45); color: hsl(var(--foreground)); border: 1px solid hsl(var(--primary) / 0.40); border-radius: 18px 18px 18px 6px; }
.msg.out + .reactions { margin-right: 4px; justify-content: flex-end; }
.msg.out .meta { color: hsl(var(--foreground) / 0.75); }
/* Session 122: Bỏ override group-self về màu incoming — outgoing luôn là cyan
toàn bộ (kể cả trong group) để phân biệt rõ với tin nhắn của friend. */
.msg-row.out.group .msg.out { background: hsl(var(--tg-bg-message-out) / 0.45); color: hsl(var(--foreground)); }
.msg-row.out.group .msg.out .meta { color: hsl(var(--foreground) / 0.75); }
.msg-row.out.group .msg.out .meta .tick { color: hsl(var(--primary)); }
.msg-row.out.group .msg.out .reply-quote { background: hsl(var(--background) / 0.3); }
/* Media bubble: đồng bộ màu với text bubble — incoming navy, outgoing cyan.
   Trước đây outgoing file dùng --primary/0.18 (cyan nhạt khác text) gây không đồng bộ. */
.msg-row.in .msg.file { background: hsl(var(--tg-bg-message-in) / 0.40) !important; border: 1px solid hsl(var(--border) / 0.7); border-radius: 16px 16px 6px 16px; padding: 6px !important; }
.msg-row.out .msg.file, .msg-row.out.group .msg.out.file { background: hsl(var(--tg-bg-message-out) / 0.45) !important; border: 1px solid hsl(var(--primary) / 0.40); border-radius: 16px 16px 16px 6px; padding: 6px !important; }
.msg-row.out .msg.file .meta, .msg-row.out.group .msg.out.file .meta { color: hsl(var(--foreground) / 0.85); padding: 0 5px 2px; }
.msg-row.in .msg.file .meta { color: hsl(var(--muted-foreground)); padding: 0 5px 2px; }
.msg-row.out.group .av-slot { margin-right: 6px; margin-top: 16px; }
.msg-row.out.group .reactions.has-reaction { margin-left: 4px; margin-right: auto; justify-content: flex-start; }
.msg .meta .tick.read { color: hsl(var(--primary)); }
.msg.system { background: transparent; color: hsl(var(--muted-foreground)); font-size: 12px; align-self: center; max-width: 100%; text-align: center; box-shadow: none; }
.msg .meta { font-size: 11px; font-weight: 400; opacity: .7; margin-top: 4px; text-align: right; display: block; line-height: 1.2; clear: both; }
.msg .meta .edit-tag { font-style: italic; margin-right: 4px; }
.msg.file { 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    background: transparent !important; 
    box-shadow: none !important; 
    padding: 0 !important;
}
.msg .file-img { display: block; max-width: 280px; max-height: 320px; width: 100%; height: auto; border-radius: 14px; object-fit: cover; cursor: zoom-in; background: hsl(var(--muted) / 0.2); box-shadow: var(--tg-bubble-shadow); }
.msg .file-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.msg .file-link:hover { text-decoration-thickness: 2px; }
.msg.file a { color: inherit; }
.msg.pinned { border: 1px dashed hsl(var(--primary)); }

/* Session 125: Markdown rendering inside message bubble (for bot /help responses).
   Hierarchy: <strong> for headings (font-weight 600), <em> for descriptions (regular + italic).
   Inline code `/cmd` gets subtle pill background. */
.msg strong, .msg b { font-weight: 600; color: hsl(var(--foreground)); }
.msg em, .msg i { font-style: italic; font-weight: 400; color: hsl(var(--muted-foreground)); }
.msg code { font-family: 'Inter', ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 13px; background: hsl(var(--secondary) / 0.6); padding: 1px 6px; border-radius: 5px; color: hsl(var(--primary)); font-weight: 500; }
.msg a { color: hsl(var(--primary)); text-decoration: underline; text-underline-offset: 2px; }
.msg a:hover { text-decoration-thickness: 2px; }
/* Bot help message — first line is bot name (heading), make it slightly more prominent */
.msg.bot-msg strong:first-child { font-size: 16px; }
.reply-quote { background: hsl(var(--background) / 0.3); border-left: 2px solid hsl(var(--primary)); padding: 5px 9px; border-radius: 6px; font-size: 12px; color: hsl(var(--muted-foreground)); margin-bottom: 5px; }
.msg.out .reply-quote { background: rgba(255,255,255,.15); }

/* Emoji picker nhanh trên bubble (8 emoji — gốc: bottom-full mb-2 bg-popover/95 backdrop-blur rounded-xl shadow-lg) */
.bubble-emoji-picker { position: absolute; bottom: 100%; margin-bottom: 8px; background: hsl(var(--card) / 0.95); border: 1px solid hsl(var(--border) / 0.5); border-radius: 20px; padding: 4px 6px; display: flex; gap: 2px; box-shadow: 0 8px 24px rgba(0,0,0,.3); z-index: 100; backdrop-filter: blur(14px); opacity: 0; transform: scale(0.8); pointer-events: none; transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
        /* Session 54: Cau noi vo hinh giua trigger va picker de khong bi mat hover */
        .bubble-emoji-picker::after { content: ""; position: absolute; top: 100%; left: 0; width: 100%; height: 30px; background: transparent; }
        .msg-row.in .bubble-emoji-picker { left: 0; transform-origin: bottom left; }
        .msg-row.out .bubble-emoji-picker { right: 0; transform-origin: bottom right; }
        /* Session 53: Hien thi picker khi hover vao vung mga-btn reaction */
        .mga-btn.reaction-trigger:hover + .bubble-emoji-picker,
        .bubble-emoji-picker:hover { opacity: 1 !important; transform: scale(1) !important; pointer-events: auto !important; }
.bubble-emoji-picker button { background: none; border: none; padding: 4px; border-radius: 8px; transition: all 0.2s; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; }
.bubble-emoji-picker button:hover { background: hsl(var(--secondary) / 0.65); transform: scale(1.1); }
.bubble-emoji-picker button img { width: 32px; height: 32px; object-fit: contain; }

.reactions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 5; }
.msg-row:hover .reactions, .msg-row .reactions.has-reaction { opacity: 1; pointer-events: auto; }
.reaction { background: hsl(var(--secondary) / 0.6); border: 1px solid hsl(var(--border) / 0.6); border-radius: 12px; padding: 2px 7px; font-size: 12px; cursor: pointer; transition: border-color .15s; display: flex; align-items: center; gap: 4px; min-height: 24px; }
.reaction img { width: 20px; height: 20px; object-fit: contain; }
.reaction:hover { border-color: hsl(var(--primary)); }
.reaction .r-count { margin-left: 3px; font-size: 10px; color: hsl(var(--muted-foreground)); }

/* Emoji picker grid cho input bar (gốc: grid-cols-8, bottom-full mb-1.5, min-w-[220px]) */
.emoji-picker-grid { position: absolute; bottom: calc(100% + 10px); right: 4px; background: hsl(var(--card)); border: 1px solid hsl(var(--border) / 0.6); border-radius: 16px; padding: 12px; min-width: 300px; box-shadow: 0 14px 40px rgba(0,0,0,.5); z-index: 60; animation: scaleIn .15s ease-out; }
.emoji-picker-grid .ep-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; max-height: 280px; overflow-y: auto; padding-right: 4px; }
.emoji-picker-grid .ep-grid::-webkit-scrollbar { width: 4px; }
.emoji-picker-grid .ep-grid::-webkit-scrollbar-thumb { background: hsl(var(--primary) / 0.3); border-radius: 4px; }
.emoji-picker-grid button { background: none; border: none; padding: 6px; border-radius: 8px; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
.emoji-picker-grid button:hover { background: hsl(var(--secondary) / 0.6); transform: scale(1.1); }
.emoji-picker-grid button img { width: 32px; height: 32px; object-fit: contain; }

/* compose — gốc: px-4 py-3 border-t bg-sidebar; textarea rounded-xl focus:ring-2 ring-primary/30; mic + emoji + paperclip + send (gradient) */
.compose { position: relative; padding: 12px 16px 16px; background: hsl(var(--tg-bg-sidebar)); border-top: 1px solid hsl(var(--border)); display: flex; gap: 6px; align-items: flex-end; }
/* Session 35: bo tron deu (22px), cao toi da 3 dong (~64px), text dai hon thi cuon trong — bo scrollbar mac dinh (thanh trang len/xuong) */
.compose textarea { flex: 1; min-width: 0; resize: none; height: 40px; min-height: 40px; max-height: calc(1.5em * 3 + 20px); padding: 10px 14px; border-radius: 22px; border: 1px solid hsl(var(--border) / 0.25); background: hsl(var(--secondary) / 0.7); color: hsl(var(--foreground)); font-size: 15px; font-weight: 400; line-height: 1.5; overflow-y: auto; overscroll-behavior: contain; outline: none; transition: box-shadow .2s, border-color .2s; }
.compose textarea:focus { border-color: hsl(var(--primary) / 0.6); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.3); }
.compose textarea::-webkit-scrollbar { width: 0; height: 0; }
.compose textarea { scrollbar-width: none; }
.send-btn { width: 40px; height: 40px; border-radius: 10px; border: none; background: none; color: hsl(var(--primary)); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: background .15s, transform .15s; }
.send-btn:hover { background: hsl(var(--secondary) / 0.6); }
.send-btn:active { transform: scale(0.92); }
.send-btn .lucide { width: 42px; height: 42px; }
.mic-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: none; border: none; color: hsl(var(--muted-foreground)); flex-shrink: 0; transition: background .15s, color .15s; }
.mic-btn:hover { background: hsl(var(--secondary) / 0.6); color: hsl(var(--foreground)); }
.mic-btn .lucide { width: 20px; height: 20px; }
.emoji-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: none; border: none; color: hsl(var(--muted-foreground)); flex-shrink: 0; transition: background .15s, color .15s; }
.emoji-btn:hover { background: hsl(var(--secondary) / 0.6); color: hsl(var(--primary-glow)); }
.emoji-btn .lucide { width: 20px; height: 20px; }
.emoji-toggle-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: none; border: none; color: hsl(var(--muted-foreground)); flex-shrink: 0; transition: background .15s, color .15s; }
.emoji-toggle-btn:hover { background: hsl(var(--secondary) / 0.6); color: hsl(var(--foreground)); }
.emoji-toggle-btn .lucide { width: 20px; height: 20px; }
.attach-btn { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: none; border: none; color: hsl(var(--muted-foreground)); flex-shrink: 0; transition: background .15s, color .15s; }
.attach-btn:hover { background: hsl(var(--secondary) / 0.6); color: hsl(var(--foreground)); }
.attach-btn .lucide { width: 20px; height: 20px; }

/* Drag & drop overlay (gốc: bg-background/80 backdrop-blur border-2 dashed primary rounded-xl) */
.drag-overlay { position: absolute; inset: 6px; z-index: 70; background: hsl(var(--background) / 0.82); backdrop-filter: blur(4px); border: 2px dashed hsl(var(--primary)); border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; pointer-events: none; animation: fadeSlideIn .15s ease-out; }
.drag-overlay .big { font-size: 42px; }
.drag-overlay .drag-title { font-size: 16px; font-weight: 600; color: hsl(var(--primary)); }
.drag-overlay .drag-sub { font-size: 13px; color: hsl(var(--muted-foreground)); }

/* FAB cuộn xuống đáy (gốc: bottom-20 right-4 h-9 w-9 rounded-full hover:bg-primary/10) */
.scroll-fab { position: absolute; right: 16px; bottom: 76px; width: 38px; height: 38px; border-radius: 50%; background: hsl(var(--card) / 0.95); border: 1px solid hsl(var(--border) / 0.6); color: hsl(var(--muted-foreground)); display: flex; align-items: center; justify-content: center; z-index: 20; box-shadow: 0 4px 14px rgba(0,0,0,.4); opacity: 0; visibility: hidden; pointer-events: none; transform: translateY(6px) scale(.92); transition: opacity .18s ease, visibility .18s ease, transform .18s ease, background .15s, color .15s; backdrop-filter: blur(8px); }
.scroll-fab.visible { opacity: 1; visibility: visible; pointer-events: auto; transform: translateY(0) scale(1); }
.scroll-fab:hover { background: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.scroll-fab .lucide { width: 18px; height: 18px; }
.scroll-fab.unread { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }

/* Session 126: load-more indicator khi cuộn lên history */
.load-more-indicator {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 8px 12px; margin: 6px auto; width: fit-content;
    font-size: 12px; color: hsl(var(--muted-foreground));
    background: hsl(var(--secondary) / 0.5); border: 1px solid hsl(var(--border) / 0.4);
    border-radius: 14px;
}
.lm-spinner {
    width: 14px; height: 14px;
    border: 2px solid hsl(var(--border));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: lm-spin 0.8s linear infinite;
}
@keyframes lm-spin { to { transform: rotate(360deg); } }

/* ================== Session 127: Pre-upload overlay (spinner / tick / error) ================== */
.pu-overlay {
    position: absolute; inset: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; z-index: 5;
    background: hsl(var(--background) / 0.55);
    backdrop-filter: blur(2px);
    border-radius: inherit;
    pointer-events: none; /* click xuyên qua overlay để nút ✕ vẫn dùng được */
}
.pu-overlay.pu-error { pointer-events: auto; }
.pu-spinner {
    width: 28px; height: 28px;
    border: 3px solid hsl(var(--border) / 0.5);
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: lm-spin 0.8s linear infinite;
}
.pu-progress {
    font-size: 11px; font-weight: 600;
    color: hsl(var(--primary));
    background: hsl(var(--card) / 0.85);
    padding: 1px 6px; border-radius: 8px;
    min-width: 32px; text-align: center;
}
.pu-overlay.pu-done {
    background: hsla(140, 70%, 45%, 0.18);
    backdrop-filter: blur(1px);
}
.pu-tick {
    width: 36px; height: 36px;
    color: hsl(140, 70%, 50%);
    filter: drop-shadow(0 0 4px hsla(140, 70%, 50%, 0.5));
    animation: pu-pop 0.3s ease-out;
}
@keyframes pu-pop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}
.pu-overlay.pu-error {
    background: hsla(0, 70%, 50%, 0.18);
}
.pu-err-icon {
    font-size: 22px; color: hsl(0, 70%, 55%);
    line-height: 1;
}
.pu-retry {
    pointer-events: auto;
    margin-top: 4px;
    background: hsl(var(--card) / 0.95);
    color: hsl(var(--primary));
    border: 1px solid hsl(var(--primary) / 0.5);
    border-radius: 50%;
    width: 24px; height: 24px;
    font-size: 14px; font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s, background 0.15s;
}
.pu-retry:hover { transform: rotate(90deg); background: hsl(var(--primary) / 0.15); }

/* Inline tile (compose area) — đảm bảo relative cho overlay absolute */
.inline-tile { position: relative; }

/* ATP dialog tiles — đảm bảo relative cho overlay absolute */
.atp-tile { position: relative; }
.atp-tile .atp-x { z-index: 6; /* trên overlay */ }

/* Nút Send disabled khi đang có file upload */
.send-btn.disabled-by-upload {
    opacity: 0.5; cursor: not-allowed; pointer-events: none;
}

/* Thanh tìm tin trong chat (gốc: border-b bg-sidebar flex gap-2 items-center) */
.chat-search-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid hsl(var(--border)); background: hsl(var(--tg-bg-sidebar)); animation: fadeSlideIn .15s ease-out; }
.chat-search-bar input { flex: 1; min-width: 0; background: hsl(var(--secondary) / 0.7); border: 1px solid hsl(var(--border) / 0.4); border-radius: 10px; padding: 7px 12px; font-size: 13px; color: hsl(var(--foreground)); outline: none; transition: border-color .2s, box-shadow .2s; }
.chat-search-bar input:focus { border-color: hsl(var(--primary) / 0.6); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.25); }
.chat-search-bar .match-info { font-size: 11px; color: hsl(var(--muted-foreground)); flex-shrink: 0; }
.chat-search-bar .highlight-hit { outline: 2px solid hsl(var(--primary)); outline-offset: 2px; border-radius: 4px; }
.chat-search-bar .icon-btn { width: 32px; height: 32px; }

/* preview file chưa gửi — Session 36: nhieu file cuon trong, khong keo dai composer lam mat icon trai/phai
   Quy tac: cao toi da ~3 hang (148px), overflow-y auto, an scrollbar; moi card hang doc 44px (text + thumb) */
#filePreview { width: 100%; margin-bottom: 8px; }
.fp-box { display: flex; flex-direction: column; gap: 6px; background: hsl(var(--secondary) / 0.4); border: 1px solid hsl(var(--border) / 0.5); border-radius: 12px; padding: 8px 12px; max-height: 148px; overflow-y: auto; overscroll-behavior: contain; }
.fp-box::-webkit-scrollbar { width: 0; height: 0; display: none; }
.fp-box { scrollbar-width: none; }
.fp-card { display: flex; align-items: center; gap: 8px; background: hsl(var(--card)); border-radius: 10px; padding: 6px 8px; flex-shrink: 0; min-width: 0; height: 44px; }
.fp-card-thumb { flex-shrink: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.fp-card-thumb img, .fp-card-thumb video { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.fp-card-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.fp-size { font-size: 11px; color: hsl(var(--muted-foreground)); }
.fp-cancel { flex-shrink: 0; background: none; border: none; color: hsl(var(--destructive)); opacity: .8; }
.fp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-cancel:hover { color: hsl(var(--destructive)); }
.fp-cancel .lucide { width: 14px; height: 14px; }

/* ============ Attachment preview dialog (Telegram Desktop style — Session 37) ============ */
.atp { max-height: 90vh; padding: 0; gap: 0; }
.atp-head { display: flex; align-items: center; padding: 14px 16px 10px; border: none; }
.atp-title { flex: 1; font-size: 15px; font-weight: 600; color: hsl(var(--primary)); }
.atp-close { background: none; border: none; display: inline-flex; align-items: center; justify-content: center; padding: 4px; }
.atp-grid { margin: 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: start; max-height: 46vh; overflow-y: auto; overscroll-behavior: contain; }
.atp-grid::-webkit-scrollbar { width: 0; height: 0; display: none; }
.atp-grid { scrollbar-width: none; }
/* tile chung: vi tri relative cho nut X */
.atp-tile { position: relative; border-radius: 12px; overflow: hidden; border: 1px solid hsl(var(--border) / 0.5); background: hsl(var(--secondary) / 0.4); }
.atp-tile img, .atp-tile video { width: 100%; height: 100%; display: block; }
.atp-tile .atp-x { position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; border-radius: 50%; background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); border: none; font-size: 12px; font-weight: 700; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.4); display: inline-flex; align-items: center; justify-content: center; }
/* 1 file: preview lon top, 2 cot */
.atp-main { grid-column: 1 / span 2; min-height: 150px; max-height: 38vh; display: flex; align-items: center; justify-content: center; }
.atp-main img, .atp-main video { width: 100%; height: 100%; object-fit: contain; }
.atp-main .atp-doc { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px; width: 100%; }
.atp-main .atp-doc .big { font-size: 34px; }
.atp-main .atp-doc .dn { font-size: 13px; font-weight: 500; text-align: center; word-break: break-word; padding: 0 8px; }
.atp-main .atp-doc .ds { font-size: 11px; color: hsl(var(--muted-foreground)); }
/* 2+ files: anh chinh lon trai */
.atp-big { grid-column: 1; grid-row: 1 / span 2; min-height: 180px; max-height: 46vh; }
.atp-big img, .atp-big video { width: 100%; height: 100%; object-fit: cover; }
.atp-sm { min-height: 88px; aspect-ratio: 4 / 3; }
.atp-sm img, .atp-sm video { width: 100%; height: 100%; object-fit: cover; }
.atp-sm .vid-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.atp-sm .vid-play::after { content: ""; width: 0; height: 0; border-left: 11px solid rgba(255,255,255,.9); border-top: 7px solid transparent; border-bottom: 7px solid transparent; margin-left: 3px; }
/* tile file tai lieu khi 2+ files: icon + ten + size */
.atp-doc-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 4px; padding: 6px; }
.atp-doc-tile .big { font-size: 26px; }
.atp-doc-tile .dn { font-size: 10px; color: hsl(var(--muted-foreground)); text-align: center; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.atp-hint { margin: 10px 16px 4px; font-size: 11px; color: hsl(var(--muted-foreground)); }
.atp-cbx { display: flex; align-items: center; gap: 8px; margin: 8px 16px 0; font-size: 13px; color: hsl(var(--foreground)); }
.atp-cbx input { accent-color: hsl(var(--primary)); width: 15px; height: 15px; }
.atp-cap { display: flex; align-items: center; gap: 8px; margin: 10px 16px 0; border: 1px solid hsl(var(--border) / 0.6); border-radius: 22px; background: hsl(var(--secondary) / 0.5); padding: 6px 8px 6px 14px; }
.atp-cap input { flex: 1; background: transparent; border: none; color: hsl(var(--foreground)); font-size: 14px; outline: none; padding: 2px 0; }
.atp-cap input::placeholder { color: hsl(var(--muted-foreground)); }
.atp-cap-emoji { background: none; border: none; display: inline-flex; align-items: center; justify-content: center; padding: 2px; }
.atp-foot { display: flex; align-items: center; gap: 10px; padding: 12px 16px 14px; }
.atp-btn { flex: 1; padding: 10px 0; border-radius: 14px; border: none; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .18s cubic-bezier(.33,1,.68,1); background: transparent; }
.atp-add { color: hsl(var(--primary)); }
.atp-add:hover { background: hsl(var(--secondary) / 0.5); }
.atp-cancel { color: hsl(var(--muted-foreground)); }
.atp-cancel:hover { color: hsl(var(--foreground)); }
.atp-send { background: linear-gradient(135deg, hsl(var(--primary) / 0.92), hsl(var(--primary))); color: hsl(var(--primary-foreground)); }
.atp-send:hover { filter: brightness(1.12); transform: translateY(-1px); }
.atp-send:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }

.empty-chat { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: hsl(var(--muted-foreground)); gap: 12px; }
.empty-chat .big { font-size: 72px; }
.empty-chat img.owl { width: 84px; height: 84px; opacity: .85; }
.empty-chat h2 { font-size: 20px; color: hsl(var(--foreground)); }
.empty-chat p { font-size: 13px; }

/* ============ Context menu tin nhắn ============ */
.ctx-menu { position: fixed; background: hsl(var(--popover)); border: 1px solid hsl(var(--border) / 0.6); border-radius: 12px; padding: 5px; min-width: 170px; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 1000; animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; transform-origin: top left; }
.ctx-menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 8px 12px; background: none; border: none; color: hsl(var(--popover-foreground)); border-radius: 9px; font-size: 13px; transition: background .12s; }
.ctx-menu button:hover { background: hsl(var(--secondary) / 0.6); }
.ctx-menu button.danger { color: hsl(var(--destructive)); }
.ctx-menu button .lucide { width: 15px; height: 15px; color: hsl(var(--muted-foreground)); }

/* ============ Modal ============ */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 50; backdrop-filter: blur(4px); animation: modalBgFade 0.25s cubic-bezier(0.33, 1, 0.68, 1) forwards; }
.modal-bg .modal { animation: modalContentIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
/* Mo app smooth: fade-in toan trang khi vao (body chat page, khong phai trang auth) */
@keyframes appFadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }
body:not(.auth-page) { animation: appFadeIn .3s ease-out both; }
.modal { background: hsl(var(--card)); border: 1px solid hsl(var(--border) / 0.5); border-radius: 20px; width: 92%; max-width: 480px; max-height: 86vh; display: flex; flex-direction: column; box-shadow: var(--shadow-elevated); animation: modalContentIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.modal.wide { max-width: 820px; }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid hsl(var(--border) / 0.5); }
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-head button { background: none; border: none; color: hsl(var(--muted-foreground)); display: inline-flex; align-items: center; justify-content: center; }
.modal-head button:hover { color: hsl(var(--foreground)); }
.modal-head .lucide { width: 18px; height: 18px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal .form-group { margin-bottom: 13px; }
.modal .form-group label { display: block; font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: hsl(var(--muted-foreground)); margin-bottom: 6px; }
.modal input, .modal textarea, .modal select { width: 100%; padding: 10px 13px; border-radius: 12px; border: 1px solid hsl(var(--border) / 0.6); background: hsl(var(--secondary) / 0.5); color: hsl(var(--foreground)); font-size: 14px; outline: none; transition: border-color .2s; }
.modal input:focus, .modal textarea:focus { border-color: hsl(var(--primary)); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2); }
.modal textarea { min-height: 70px; resize: vertical; }
.modal .btn-row { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }
.btn { padding: 9px 18px; border-radius: 12px; border: 1px solid hsl(var(--border) / 0.6); background: hsl(var(--secondary) / 0.6); color: hsl(var(--foreground)); font-size: 13px; font-weight: 600; transition: all .18s cubic-bezier(.33,1,.68,1); }
.btn:hover { background: hsl(var(--secondary)); transform: translateY(-1px); filter: brightness(1.15); }
.btn:active { transform: translateY(0); filter: none; }
.hamburger:hover, .icon-btn:hover { background: hsl(var(--secondary) / 0.5); }
.send-btn:hover { transform: scale(1.05); }
.send-btn:active { transform: scale(0.95); }
.btn.primary { background: var(--gradient-primary); border-color: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn.primary:hover { box-shadow: var(--shadow-glow); }
.btn.danger { background: transparent; border-color: hsl(var(--destructive)); color: hsl(var(--destructive)); }
.btn.small { padding: 5px 12px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* menu dropdown (hamburger) */
.dd-wrap { position: relative; display: inline-flex; align-items: center; }
.dropdown { position: absolute; top: calc(100% + 8px); left: 0; background: hsl(var(--popover)); border: 1px solid hsl(var(--border) / 0.6); border-radius: 12px; padding: 6px; min-width: 240px; box-shadow: 0 12px 32px rgba(0,0,0,.5); z-index: 50; animation: dropdownBounce 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; transform-origin: top left; }
.dropdown.anchor-left { transform-origin: top right; }
.dropdown.anchor-left { left: auto; right: 0; }
.dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; background: none; border: none; color: hsl(var(--popover-foreground)); border-radius: 9px; font-size: 13.5px; transition: background .12s; }
.dropdown button:hover { background: hsl(var(--secondary) / 0.6); }
.dropdown button .ic { display: inline-flex; color: hsl(var(--muted-foreground)); }
.dropdown button .ic .lucide { width: 16px; height: 16px; }
.dropdown .dd-divider { height: 1px; background: hsl(var(--border) / 0.5); margin: 4px 0; }
/* Profile header trong menu hamburger (goc Telegram Desktop: profile hien thi tren cung) */
.mm-profile { display: flex; align-items: center; gap: 12px; padding: 14px 12px 12px; border-radius: 9px; cursor: pointer; transition: background .15s; }
.mm-profile:hover { background: hsl(var(--secondary) / 0.5); }
.mm-avatar { width: 42px; height: 42px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 600; color: hsl(var(--primary-foreground)); flex-shrink: 0; filter: brightness(0.92); }
.mm-info { flex: 1; min-width: 0; }
.mm-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-user { font-size: 11.5px; color: hsl(var(--muted-foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.mm-chevron { color: hsl(var(--muted-foreground)); }
.mm-version { font-size: 11px; color: hsl(var(--muted-foreground) / 0.7); padding: 8px 12px 4px; font-weight: 500; }
.mm-profile .mm-avatar { background: var(--gradient-primary); }
.badge { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); font-size: 10px; padding: 1px 7px; border-radius: 10px; margin-left: auto; font-weight: 700; }

/* dropdown header chat (more-vertical) */
.header-dropdown { position: absolute; background: hsl(var(--popover)); border: 1px solid hsl(var(--border) / 0.6); border-radius: 12px; padding: 5px; min-width: 180px; box-shadow: 0 12px 32px rgba(0,0,0,.5); z-index: 40; animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; transform-origin: top right; }
.header-dropdown button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 9px 12px; background: none; border: none; color: hsl(var(--popover-foreground)); border-radius: 9px; font-size: 13px; }
.header-dropdown button:hover { background: hsl(var(--secondary) / 0.6); }
.header-dropdown button .lucide { width: 15px; height: 15px; color: hsl(var(--muted-foreground)); }
.header-dropdown button.danger { color: hsl(var(--destructive)); }

/* danh sách trong modal */
/* Session 30: modal Danh ba — cac icon can deu, khong sat vao canh */
.list-item { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    padding: 10px 14px; 
    margin: 2px 6px; 
    border-radius: 12px; 
    transition: background 0.2s ease;
}
.list-item:hover {
    background: hsl(var(--secondary) / 0.4);
}
.list-item:not(:last-child) { 
    border-bottom: 1px solid hsl(var(--border) / 0.2); 
}
/* Session 30: nut icon chat Danh ba can deu tay phai, khong sat vao vien modal */
.list-item > .btn.small { 
    margin-left: auto; 
    margin-right: 3px; 
    flex-shrink: 0; 
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: hsl(var(--secondary) / 0.3);
    border: 1px solid hsl(var(--border) / 0.4);
}
.list-item > .btn.small:hover {
    background: hsl(var(--primary) / 0.15);
    border-color: hsl(var(--primary) / 0.4);
}
.list-item > .btn.small + .btn.small { margin-left: 8px; }
.list-item .li-info { flex: 1; min-width: 0; }
.list-item .li-name { font-size: 14px; font-weight: 600; color: hsl(var(--foreground)); }
.list-item .li-sub { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 1px; }

/* Custom Search Input for Contacts */
.contacts-search-wrap {
    position: relative;
    margin: 12px 6px;
}
.contacts-search-wrap input {
    width: 100%;
    background: hsl(var(--secondary) / 0.3);
    border: 1px solid hsl(var(--border) / 0.5);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13.5px;
    color: hsl(var(--foreground));
    outline: none;
    transition: all 0.2s;
}
.contacts-search-wrap input:focus {
    border-color: hsl(var(--primary));
    background: hsl(var(--secondary) / 0.5);
    box-shadow: 0 0 0 2px hsl(var(--primary) / 0.1);
}
.contacts-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--primary));
    margin: 16px 12px 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.contacts-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: hsl(var(--border) / 0.3);
}
.user-avatars { display: flex; flex-wrap: wrap; gap: 10px; max-height: 240px; overflow-y: auto; }
.user-pick { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; border: 2px solid transparent; border-radius: 12px; padding: 6px; transition: border-color .15s, background .15s; }
.user-pick:hover { background: hsl(var(--primary) / 0.08); }
.user-pick.sel { border-color: hsl(var(--primary)); background: hsl(var(--primary) / 0.12); }
.user-pick .check { font-size: 13px; color: hsl(var(--primary)); font-weight: 700; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; }
.user-pick.sel .check { opacity: 1; transform: scale(1); }
.new-owner-pick { border: 2px solid transparent; border-radius: 12px; transition: border-color .15s, background .15s; }
.new-owner-pick:hover { background: hsl(var(--primary) / 0.08); }
.new-owner-pick.sel { border-color: hsl(var(--primary)); background: hsl(var(--primary) / 0.12); }
.new-owner-pick .nop-check { font-size: 15px; color: hsl(var(--primary)); font-weight: 700; opacity: 0; transform: scale(.6); transition: opacity .15s, transform .15s; }
.new-owner-pick.sel .nop-check { opacity: 1; transform: scale(1); }
#nopConfirm:disabled { opacity: .45; cursor: not-allowed; }

/* ===== Contacts tabs (gốc: pills rounded-lg text-xs) ===== */
.ct-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.ct-tab { padding: 6px 13px; border-radius: 8px; font-size: 12px; font-weight: 500; border: none; background: hsl(var(--secondary) / 0.5); color: hsl(var(--muted-foreground)); transition: all .15s; }
.ct-tab.active { background: var(--gradient-primary); color: hsl(var(--primary-foreground)); }
.ct-user-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 12px; transition: background .15s; }
.ct-user-row:hover { background: hsl(var(--tg-hover)); }
.ct-actions { display: flex; gap: 6px; margin-left: auto; }
.ct-actions button { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 9px; border: none; background: hsl(var(--secondary) / 0.6); color: hsl(var(--foreground)); transition: all .15s; }
.ct-actions button:hover { background: hsl(var(--primary) / 0.15); color: hsl(var(--primary)); }
.ct-actions button.primary-act { background: var(--gradient-primary); color: hsl(var(--primary-foreground)); }
.ct-actions button.danger-act { background: hsl(var(--destructive) / 0.12); color: hsl(var(--destructive)); }
.ct-actions button .lucide { width: 15px; height: 15px; }
.friend-req-wrap { margin-bottom: 14px; border: 1px solid hsl(var(--border) / 0.4); border-radius: 14px; padding: 8px; }
.friend-req-head { font-size: 12px; font-weight: 600; color: hsl(var(--muted-foreground)); padding: 4px 6px 8px; text-transform: uppercase; letter-spacing: .06em; }

/* settings item row (gốc SettingsView) */
.st-item { display: flex; align-items: center; gap: 12px; padding: 11px 8px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.st-item:hover { background: hsl(var(--tg-hover)); }
.st-item .st-ic { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: hsl(var(--secondary) / 0.6); color: hsl(var(--foreground)); }
.st-item .st-ic .lucide { width: 17px; height: 17px; }
.st-item .st-label { flex: 1; font-size: 13.5px; font-weight: 500; }
.st-item.danger .st-label, .st-item.danger .st-ic { color: hsl(var(--destructive)); }
.st-divider { height: 1px; background: hsl(var(--border) / 0.5); margin: 8px 0; }

/* ============ Bot Management & Admin page (light) ============ */
.page { min-height: 100vh; padding: 28px 10%; background: hsl(var(--background)); }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.page-head h2 { font-size: 22px; }
.page-head .back { color: hsl(var(--muted-foreground)); font-size: 13px; }
.tabs { display: flex; gap: 8px; margin-bottom: 18px; border-bottom: 1px solid hsl(var(--border) / 0.5); }
.tab { padding: 10px 16px; background: none; border: none; color: hsl(var(--muted-foreground)); font-size: 14px; border-bottom: 2px solid transparent; transition: all .18s; }
.tab:hover { color: hsl(var(--foreground)); }
.tab.active { color: hsl(var(--primary)); border-color: hsl(var(--primary)); font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }
.b-card { background: hsl(var(--card)); border: 1px solid hsl(var(--border) / 0.5); border-radius: 16px; padding: 16px; }
.b-card .b-head { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.b-card .b-name { font-weight: 700; font-size: 15px; }
.b-card .b-sub { font-size: 12px; color: hsl(var(--muted-foreground)); }
.status-chip { font-size: 11px; padding: 3px 9px; border-radius: 10px; font-weight: 700; margin-left: auto; }
.status-chip.active { background: hsl(var(--tg-online) / 0.16); color: hsl(var(--tg-online)); }
.status-chip.inactive { background: hsl(var(--destructive) / 0.14); color: hsl(var(--destructive)); }
.token-box { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: hsl(var(--secondary) / 0.4); border: 1px solid hsl(var(--border) / 0.5); border-radius: 8px; padding: 8px 10px; word-break: break-all; color: hsl(var(--muted-foreground)); }
.code-block { font-family: 'JetBrains Mono', monospace; font-size: 12px; background: hsl(var(--secondary) / 0.4); border: 1px solid hsl(var(--border) / 0.5); border-radius: 8px; padding: 10px; margin-top: 8px; white-space: pre-wrap; color: hsl(var(--muted-foreground)); }
.b-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid hsl(var(--border) / 0.5); }
table.data th { color: hsl(var(--muted-foreground)); font-weight: 600; font-size: 12px; }
table.data tbody tr { transition: background .15s; }
table.data tbody tr:hover { background: hsl(var(--secondary) / 0.35); }
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px) { .stat-cards { grid-template-columns: repeat(2, 1fr); } }
.stat { background: hsl(var(--card)); border: 1px solid hsl(var(--border) / 0.5); border-radius: 16px; padding: 16px; }
.stat .v { font-size: 26px; font-weight: 800; }
.stat .l { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 2px; }

/* Nút tìm tin trong header (mở chat-search-bar) */
.chat-header .actions { display: flex; gap: 4px; position: relative; }
.chat-header .actions .icon-btn { width: 34px; height: 34px; }

/* ============ Info panel (slide-in bên phải chat — gốc InfoPanel width 0→320 0.2s) ============ */
/* Session 132: Info panel — centered modal (was right-side panel) */
.info-panel-wrap {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 40;
    width: 380px;
    max-width: 92vw;
    max-height: 85vh;
    animation: ipModalPop 0.25s cubic-bezier(0.33, 1, 0.68, 1) forwards;
}
@keyframes ipModalPop {
    from { opacity: 0; transform: translate(-50%, -48%) scale(0.96); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.info-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 38; animation: modalBgFade .15s ease-out; backdrop-filter: blur(2px); }
.info-panel { width: 100%; background: hsl(var(--tg-bg-sidebar)); border: 1px solid hsl(var(--border) / 0.6); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.info-panel.open { width: 100%; animation: none; }
.info-panel-inner { width: 100%; max-height: 85vh; overflow-y: auto; display: flex; flex-direction: column; }
.info-panel-inner::-webkit-scrollbar { width: 5px; }
.ip-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid hsl(var(--border) / 0.5); }
.ip-head h4 { font-size: 14px; font-weight: 600; }
.ip-hero { display: flex; flex-direction: column; align-items: center; padding: 24px 16px 20px; }
.ip-hero .avatar { width: 72px; height: 72px; font-size: 26px; }
.ip-hero h5 { margin-top: 12px; font-size: 17px; font-weight: 600; }
.ip-hero p { font-size: 12.5px; color: hsl(var(--muted-foreground)); margin-top: 4px; }
.ip-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 16px; background: none; border: none; color: hsl(var(--foreground)); text-align: left; font-size: 13.5px; transition: background .12s; }
.ip-row:hover { background: hsl(var(--tg-hover)); }
.ip-row .ip-ic { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex-shrink: 0; }
.ip-row .ip-ic .lucide { width: 16px; height: 16px; color: hsl(var(--muted-foreground)); }
.ip-row .ip-label { flex: 1; min-width: 0; }
.ip-row .ip-detail { font-size: 11px; color: hsl(var(--muted-foreground)); flex-shrink: 0; }
.ip-sec { margin-top: 14px; padding: 0 16px; }
.ip-sec-head { display: flex; align-items: center; gap: 6px; }
.ip-sec-head h6 { font-size: 11px; font-weight: 600; color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: .06em; }
.ip-add-btn { margin-left: auto; font-size: 11px; font-weight: 500; padding: 4px 10px; border-radius: 10px; background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); border: none; transition: background .12s; }
.ip-add-btn:hover { background: hsl(var(--primary) / 0.2); }
.ip-add-box { margin-top: 8px; margin-bottom: 8px; animation: fadeSlideIn .15s ease-out; }
.ip-add-box input { width: 100%; background: hsl(var(--secondary)); border: 1px solid transparent; border-radius: 12px; padding: 8px 12px; font-size: 12px; color: hsl(var(--foreground)); outline: none; }
.ip-add-box input:focus { border-color: hsl(var(--primary) / 0.6); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.25); }
.ip-add-list { max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.ip-add-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; border-radius: 10px; background: none; border: none; color: hsl(var(--foreground)); text-align: left; transition: background .12s; }
.ip-add-item:hover { background: hsl(var(--tg-hover)); }
.ip-add-item .aip-info { flex: 1; min-width: 0; }
.ip-add-item .aip-name { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ip-add-item .aip-sub { font-size: 10px; color: hsl(var(--muted-foreground)); }
.ip-add-item .aip-ic .lucide { width: 14px; height: 14px; color: hsl(var(--primary)); }
.ip-member { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; transition: background .12s; }
.ip-member:hover { background: hsl(var(--tg-hover)); }
.ip-member .im-info { flex: 1; min-width: 0; }
.ip-member .im-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ip-member .im-sub { font-size: 11px; color: hsl(var(--muted-foreground)); }
.ip-member .im-role { font-size: 11px; color: hsl(var(--muted-foreground)); text-transform: capitalize; flex-shrink: 0; }
.ip-actions { margin-top: auto; padding: 14px 10px 16px; display: flex; flex-direction: column; gap: 3px; }
.ip-action { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 14px; border-radius: 10px; background: none; border: none; color: hsl(var(--foreground)); text-align: left; font-size: 13px; transition: background .12s, color .12s; }
.ip-action .lucide { width: 16px; height: 16px; }
.ip-action.primary-act { color: hsl(var(--primary)); }
.ip-action.primary-act:hover { background: hsl(var(--primary) / 0.1); }
.ip-action.neutral-act { color: hsl(var(--muted-foreground)); }
.ip-action.neutral-act:hover { background: hsl(var(--muted)); }
.ip-action.danger-act { color: hsl(var(--destructive)); }
.ip-action.danger-act:hover { background: hsl(var(--destructive) / 0.1); }

/* ================== Thong bao (panel gốc: centered card) ================== */
.notif-btn { position: relative; }
.notif-item { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; background: none; border: none; color: hsl(var(--popover-foreground)); border-radius: 10px; cursor: pointer; transition: background .12s; }
.notif-item:hover { background: hsl(var(--secondary) / 0.6); }
.notif-item.unread { background: hsl(var(--primary) / 0.08); }
.notif-item .ni-icon { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; background: hsl(var(--secondary) / 0.6); color: hsl(var(--primary)); flex-shrink: 0; }
.notif-item .ni-icon .lucide { width: 15px; height: 15px; }
.notif-item .ni-lead { position: relative; display: inline-flex; flex-shrink: 0; }
.notif-item .ni-badge { position: absolute; right: -3px; bottom: -3px; width: 16px; height: 16px; border-radius: 50%; background: hsl(var(--popover)); border: 2px solid hsl(var(--popover)); display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 1px hsl(var(--border) / 0.5); }
.notif-item .ni-badge img { width: 9px; height: 9px; }
.notif-item .ni-title { font-size: 13px; font-weight: 600; line-height: 1.3; }
.notif-item .ni-desc { font-size: 12px; color: hsl(var(--muted-foreground)); line-height: 1.35; margin-top: 1px; }
.notif-item .ni-time { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.notif-item.unread .ni-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: hsl(var(--primary)); margin-left: 6px; vertical-align: middle; }
.notif-item .ni-dot { display: none; }
.notif-empty { padding: 26px 14px; text-align: center; color: hsl(var(--muted-foreground)); font-size: 12.5px; }
/* panel centered (gốc NotificationPanel: overlay pt-16) */
/* Session 124: Notification dropdown — xổ xuống từ icon chuông (giống hamburger menu),
   thay vì overlay full-screen modal cũ. Toggle: click chuông = mở, click lại = đóng. */
/* Session 146: anchored from the bell's right edge, not its left — the bell sits near the right end of the
   sidebar's top bar (search field takes the space to its left), so a ~380px-wide panel anchored to "left: 0"
   had nowhere to grow but further right, off the edge of whatever it is rendered inside. On the full desktop
   page that edge is just the browser window (so it went unnoticed, quietly overlapping the chat pane), but
   inside the Dashboard's floating widget it is the iframe's own boundary — content past it is not just
   covered, it is genuinely not rendered at all. Growing left from the bell instead keeps it inside either one. */
.notif-overlay { position: absolute; top: calc(100% + 8px); right: 0; z-index: 55; background: hsl(var(--popover)); border: 1px solid hsl(var(--border) / 0.6); border-radius: 14px; width: min(380px, calc(100vw - 16px)); max-height: 70vh; box-shadow: 0 14px 40px rgba(0,0,0,.55); animation: dropdownBounce 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; transform-origin: top right; display: flex; flex-direction: column; overflow: hidden; }
.notif-overlay.hidden { animation: none; }
.notif-panel { display: flex; flex-direction: column; overflow: hidden; flex: 1; min-height: 0; }
.notif-panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid hsl(var(--border) / 0.5); flex-shrink: 0; }
.notif-panel-head h4 { flex: 1; font-size: 14px; font-weight: 600; }
.notif-panel-head button { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 8px; background: none; border: none; color: hsl(var(--muted-foreground)); cursor: pointer; transition: background .12s; }
.notif-panel-head button:hover { background: hsl(var(--secondary) / 0.6); color: hsl(var(--foreground)); }
/* Session 133: notif-panel-body — themed scrollbar (was default white on mobile) */
.notif-panel-body { overflow-y: auto; padding: 6px; flex: 1; min-height: 0; scrollbar-width: thin; scrollbar-color: hsl(var(--primary) / 0.3) transparent; }
.notif-panel-body::-webkit-scrollbar { width: 4px; }
.notif-panel-body::-webkit-scrollbar-track { background: transparent; }
.notif-panel-body::-webkit-scrollbar-thumb { background: hsl(var(--primary) / 0.25); border-radius: 4px; }
.notif-panel-body::-webkit-scrollbar-thumb:hover { background: hsl(var(--primary) / 0.4); }

/* ===== Media viewer (lightbox anh/video trong tin nhan — Session 25) ===== */
/* Session 123: Media viewer — toolbar moved to TOP, stage fills rest, zoom transform support */
.media-viewer { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 2000; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; backdrop-filter: blur(25px); animation: modalBgFade .22s cubic-bezier(.33,1,.68,1); }
.mv-wrap { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 16px 20px 20px; box-sizing: border-box; overflow: hidden; }
/* Toolbar docked at top, full width pill */
.mv-toolbar { position: relative; display: flex; align-items: center; gap: 10px; background: hsl(var(--card) / 0.92); border: 1px solid hsl(var(--border) / 0.6); border-radius: 999px; padding: 8px 16px; box-shadow: 0 10px 30px rgba(0,0,0,.5); backdrop-filter: blur(15px); z-index: 2001; margin-bottom: 16px; flex-shrink: 0; max-width: 92vw; }
.mv-name { font-size: 13px; font-weight: 600; color: hsl(var(--foreground)); max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mv-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; border: 1px solid hsl(var(--border) / 0.5); background: hsl(var(--secondary) / 0.4); cursor: pointer; transition: all .18s cubic-bezier(.33,1,.68,1); flex-shrink: 0; }
.mv-btn:hover { background: hsl(var(--primary) / 0.25); border-color: hsl(var(--primary)); }
.mv-btn:active { transform: scale(0.94); }
.mv-btn .lucide { width: 18px; height: 18px; }
.mv-btn.primary { background: linear-gradient(135deg, hsl(var(--primary) / 0.35), hsl(var(--accent) / 0.25)); border-color: hsl(var(--primary) / 0.6); }
.mv-btn.active { background: hsl(var(--primary) / 0.35); border-color: hsl(var(--primary)); }
/* Stage fills remaining vertical space; image zoom transform applied here */
.mv-stage { position: relative; display: flex; align-items: center; justify-content: center; flex: 1; width: 100%; height: 100%; overflow: hidden; margin-bottom: 0; }
.mv-stage img, .mv-stage video { max-width: 95%; max-height: 95%; width: auto; height: auto; border-radius: 12px; object-fit: contain; box-shadow: 0 20px 60px rgba(0,0,0,.8); outline: none; animation: scaleIn .25s cubic-bezier(.33,1,.68,1); transition: transform .15s cubic-bezier(.33,1,.68,1); transform-origin: center center; will-change: transform; }
.mv-stage img.zoomable { cursor: zoom-in; }
.mv-stage img.zoomable.zoomed { cursor: grab; }
.mv-stage img.zoomable.dragging { cursor: grabbing; transition: none; }
.mv-stage video { transition: none; }
/* Zoom level badge */
.mv-zoom-badge { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); background: hsl(var(--card) / 0.92); border: 1px solid hsl(var(--border) / 0.6); border-radius: 999px; padding: 4px 12px; font-size: 11px; font-weight: 600; color: hsl(var(--foreground)); backdrop-filter: blur(12px); z-index: 2002; pointer-events: none; opacity: 0; transition: opacity .25s; }
.mv-zoom-badge.visible { opacity: 1; }
.mv-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.mv-nav.prev { left: 14px; }
.mv-nav.next { right: 14px; }
.mv-nav { z-index: 3; background: hsl(var(--card) / 0.88); border-color: hsl(var(--primary) / 0.65); box-shadow: 0 6px 20px rgba(0,0,0,.45); }
.mv-nav:hover { transform: translateY(-50%) scale(1.08); }
@media (max-width: 900px) {
    .mv-nav { display: inline-flex; width: 42px; height: 42px; }
    .mv-nav.prev { left: 8px; }
    .mv-nav.next { right: 8px; }
}
/* Video thumbnail in chat (Telegram style) */
.video-thumb-wrap { position: relative; max-width: 260px; max-height: 240px; border-radius: 10px; overflow: hidden; background: #000; cursor: pointer; }
.video-thumb { display: block; width: 100%; height: auto; aspect-ratio: 16/9; object-fit: cover; opacity: 0.8; transition: opacity 0.2s; }
.video-thumb-wrap:hover .video-thumb { opacity: 0.95; }
.play-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 2; pointer-events: none; }
.play-icon { width: 48px; height: 48px; background: rgba(0,0,0,0.5); border-radius: 50%; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.2); }
.play-icon::after { content: ''; display: block; width: 0; height: 0; border-style: solid; border-width: 10px 0 10px 18px; border-color: transparent transparent transparent #fff; margin-left: 4px; }
.video-duration { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,0.6); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; backdrop-filter: blur(4px); }

/* ============ Reply Feature (Session 46) ============ */
.reply-preview { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: hsl(var(--secondary) / 0.4); border-top: 1px solid hsl(var(--border) / 0.5); border-left: 4px solid hsl(var(--primary)); animation: slideUp .2s ease-out; }
.reply-preview.hidden { display: none; }
.rp-content { flex: 1; min-width: 0; }
.rp-name { font-size: 13px; font-weight: 600; color: hsl(var(--primary)); margin-bottom: 2px; }
.rp-text { font-size: 12px; color: hsl(var(--muted-foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-close { background: none; border: none; color: hsl(var(--muted-foreground)); cursor: pointer; padding: 4px; font-size: 16px; }
.rp-close:hover { color: hsl(var(--foreground)); }

.reply-quote { background: hsl(var(--secondary) / 0.3); border-left: 3px solid hsl(var(--primary) / 0.7); padding: 6px 10px; border-radius: 6px; margin-bottom: 6px; cursor: pointer; transition: background .2s; }
.reply-quote:hover { background: hsl(var(--secondary) / 0.5); }
.rq-name { font-size: 12px; font-weight: 600; color: hsl(var(--primary)); margin-bottom: 2px; }
.rq-text { font-size: 11px; color: hsl(var(--muted-foreground)); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; opacity: 0.8; }

.msg-row[id] { scroll-margin-top: 80px; }
.msg-highlight { animation: highlightFlash 2s ease-out; }
@keyframes highlightFlash {
    0% { background: hsl(var(--primary) / 0.3); }
    100% { background: transparent; }
}
@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ================== Mobile Optimization (Session 57) ================== */
.bottom-nav {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: hsl(var(--card) / 0.95);
    border-top: 1px solid hsl(var(--border) / 0.6);
    backdrop-filter: blur(12px);
    z-index: 50;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.bn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    gap: 4px;
    transition: all 0.2s;
    flex: 1;
}

.bn-item .lucide {
    width: 22px;
    height: 22px;
}

.bn-item span {
    font-size: 10px;
    font-weight: 500;
}

.bn-item.active {
    color: hsl(var(--primary));
}

/* Fix màu icon danh bạ mobile đồng nhất (Session 57) */
.bn-item[onclick*="contacts"],
.bn-item[onclick*="showContacts"] {
    color: hsl(var(--muted-foreground));
}
.bn-item[onclick*="contacts"].active,
.bn-item[onclick*="showContacts"].active {
    color: hsl(var(--primary));
}

.light .bn-item {
    color: hsl(var(--muted-foreground));
}
.light .bn-item.active {
    color: hsl(var(--primary));
}

.back-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    margin-right: 8px;
    border-radius: 50%;
    transition: background 0.2s;
}

.back-btn:hover {
    background: hsl(var(--secondary) / 0.6);
}

@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }

    .sidebar {
        width: 100% !important;
        height: 100vh;
        border-right: none;
        padding-bottom: 60px; /* Cho bottom nav */
    }

    .bottom-nav {
        display: flex;
    }

    .chat-main {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 100;
        background: hsl(var(--background));
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.33, 1, 0.68, 1);
    }

    .chat-main.open {
        transform: translateX(0);
    }

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

    .empty-chat {
        display: none;
    }

    .chat-header {
        padding: 8px 12px;
    }

    .compose {
        padding: 8px 12px 12px;
    }
}

/* ================== Call UI (Session 61) ================== */
.call-modal {
    width: 100%;
    max-width: 400px;
    background: hsl(var(--card));
    border-radius: 1.5rem;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.call-header {
    margin-bottom: 2rem;
}

.call-header .avatar.large {
    width: 100px;
    height: 100px;
    margin: 0 auto 1rem;
    font-size: 2.5rem;
}

#callStatus {
    color: hsl(var(--muted-foreground));
    font-size: 0.875rem;
    margin-top: 0.5rem;
    animation: pulse 2s infinite;
}

.call-video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 3/4;
    background: #000;
    border-radius: 1rem;
    margin-bottom: 2rem;
    overflow: hidden;
}

#remoteVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#localVideo {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    width: 100px;
    aspect-ratio: 3/4;
    background: #222;
    border-radius: 0.5rem;
    object-fit: cover;
    border: 2px solid hsl(var(--border));
}

.call-actions {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.call-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.call-btn:hover {
    transform: scale(1.1);
}

.call-btn.hangup {
    background: #ef4444;
}

.call-btn.answer {
    background: #22c55e;
    width: auto;
    border-radius: 2rem;
    padding: 0 1.5rem;
    color: #fff;
    font-weight: 600;
    gap: 0.5rem;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Session 77: View-only Badge (Chim mat do) */
.view-only-badge {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 9999;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--card) / 0.85);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    border: 2px solid hsl(var(--destructive) / 0.8);
    box-shadow: 0 0 15px hsl(var(--destructive) / 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}
.view-only-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px hsl(var(--destructive) / 0.5);
    background: hsl(var(--card));
}
.vo-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.vo-bird {
    width: 34px;
    height: 34px;
    filter: brightness(0.9) contrast(1.1);
    transition: filter 0.3s;
}
/* Session 78: Hieu ung mat do (Red-eye) overlay */
.vo-eyes {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 34px;
    height: 34px;
    pointer-events: none;
    background: radial-gradient(circle at 38% 44%, #ff0000 2px, transparent 4px),
                radial-gradient(circle at 62% 44%, #ff0000 2px, transparent 4px);
    filter: blur(0.5px) drop-shadow(0 0 3px #ff0000);
    opacity: 0.9;
    animation: eyePulse 2s infinite ease-in-out;
}
@keyframes eyePulse {
    0%, 100% { opacity: 0.8; filter: blur(0.5px) drop-shadow(0 0 2px #ff0000); }
    50% { opacity: 1; filter: blur(0.4px) drop-shadow(0 0 5px #ff0000); }
}

@media (max-width: 768px) {
    .view-only-badge {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    .vo-bird, .vo-eyes {
        width: 30px;
        height: 30px;
    }
}

/* Session 85: Inline file preview in compose bar */
.inline-file-preview {
    position: absolute;
    bottom: 100%;
    left: 16px;
    right: 16px;
    background: hsl(var(--card) / 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid hsl(var(--border) / 0.5);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    z-index: 10;
    animation: slideUp 0.2s ease-out;
}
.inline-tile {
    display: flex;
    align-items: center;
    gap: 8px;
    background: hsl(var(--secondary) / 0.5);
    padding: 4px 8px;
    border-radius: 8px;
    max-width: 100%;
}
.inline-tile img, .inline-tile video {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
}
.inline-name {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.inline-x {
    background: none;
    border: none;
    color: hsl(var(--destructive));
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
}
.doc-icon { font-size: 20px; }

/* ============ Gallery Panel (Media/Files — Session 97) ============ */
/* Session 137: Gallery panel — centered modal (was right-side panel, same fix as info panel) */
.gallery-panel-wrap {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 40;
    width: 420px;
    max-width: 92vw;
    max-height: 85vh;
    animation: ipModalPop 0.25s cubic-bezier(0.33, 1, 0.68, 1) forwards;
}
.gallery-panel {
    width: 100%;
    background: hsl(var(--tg-bg-sidebar));
    border: 1px solid hsl(var(--border) / 0.6);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
    max-height: 85vh;
}
.gallery-panel.open { width: 100%; animation: none; }
.gp-inner { width: 100%; max-height: 85vh; overflow-y: auto; display: flex; flex-direction: column; }
.gp-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid hsl(var(--border) / 0.5); position: sticky; top: 0; background: hsl(var(--tg-bg-sidebar)); z-index: 10; }
.gp-head h4 { font-size: 14px; font-weight: 600; flex: 1; }
.gp-head .back-btn { padding: 6px; border-radius: 50%; transition: background 0.2s; }
.gp-head .back-btn:hover { background: hsl(var(--tg-hover)); }

.gp-content { padding: 12px; flex: 1; }
.gp-day-group { margin-bottom: 18px; }
.gp-day-title { margin: 0 2px 8px; color: hsl(var(--muted-foreground)); font-size: 11px; font-weight: 700; text-transform: capitalize; letter-spacing: .02em; }
.gp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.gp-item { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; cursor: pointer; background: hsl(var(--muted) / 0.3); }
.gp-item img, .gp-item video { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.gp-source-btn { position: absolute; right: 5px; bottom: 5px; width: 27px; height: 27px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid hsl(var(--primary) / .7); border-radius: 50%; background: hsl(var(--card) / .88); cursor: pointer; opacity: 0; transform: translateY(4px); transition: opacity .18s, transform .18s, background .18s; z-index: 2; }
.gp-item:hover .gp-source-btn, .gp-source-btn:focus-visible { opacity: 1; transform: translateY(0); }
.gp-source-btn:hover { background: hsl(var(--primary) / .22); }
.gp-source-btn .lucide { width: 14px; height: 14px; }
.gp-item:hover img, .gp-item:hover video { transform: scale(1.05); }

.gp-list { display: flex; flex-direction: column; gap: 8px; }
.gp-file-item { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px; background: hsl(var(--secondary) / 0.4); border: 1px solid hsl(var(--border) / 0.3); text-decoration: none; color: inherit; transition: all 0.2s; }
.gp-file-item:hover { background: hsl(var(--tg-hover)); transform: translateY(-1px); border-color: hsl(var(--primary) / 0.5); }
.gp-file-icon { width: 40px; height: 40px; border-radius: 10px; background: hsl(var(--primary) / 0.1); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.gp-file-info { flex: 1; min-width: 0; }
.gp-file-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.gp-file-meta { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.gp-empty { text-align: center; padding: 40px 20px; color: hsl(var(--muted-foreground)); font-size: 13px; }

/* ============ Professional UI Animations (Session 99) ============ */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideInUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes dropdownBounce {
    0% { transform: scale(0.9) translateY(-10px); opacity: 0; }
    70% { transform: scale(1.02) translateY(2px); opacity: 1; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

@keyframes modalBgFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalContentIn {
    from { transform: scale(0.9) translateY(20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.ani-fade-in { animation: fadeIn 0.3s ease-out forwards; }
.ani-slide-right { animation: slideInRight 0.3s cubic-bezier(0.33, 1, 0.68, 1) forwards; }
.ani-slide-left { animation: slideInLeft 0.3s cubic-bezier(0.33, 1, 0.68, 1) forwards; }
.ani-slide-up { animation: slideInUp 0.3s ease-out forwards; }
.ani-scale-in { animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.ani-dropdown { animation: dropdownBounce 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

/* ================== Session 134: @mention autocomplete + highlight ================== */
.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: hsl(var(--popover));
    border: 1px solid hsl(var(--border) / 0.6);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,.4);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    animation: mentionDrop 0.15s ease-out;
}
@keyframes mentionDrop {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.mention-dropdown::-webkit-scrollbar { width: 4px; }
.mention-dropdown::-webkit-scrollbar-thumb { background: hsl(var(--primary) / 0.25); border-radius: 4px; }
.mention-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .12s;
}
.mention-item.active, .mention-item:hover {
    background: hsl(var(--primary) / 0.15);
}
.mention-item .mi-info { flex: 1; min-width: 0; }
.mention-item .mi-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-item .mi-sub { font-size: 11px; color: hsl(var(--muted-foreground)); }
.mention-item .mi-all-tag { font-size: 10px; font-weight: 600; color: hsl(var(--primary)); background: hsl(var(--primary) / 0.12); padding: 2px 8px; border-radius: 6px; }

/* Mention highlight trong message bubble */
.mention-tag {
    color: hsl(var(--primary));
    font-weight: 600;
    background: hsl(var(--primary) / 0.12);
    padding: 0 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .12s;
}
.mention-tag:hover {
    background: hsl(var(--primary) / 0.25);
}

/* Mention notification icon trong notif panel */
.notif-item.mention-notif .ni-icon { background: hsl(var(--primary) / 0.15); border-radius: 8px; }
.notif-item.mention-notif .ni-title { color: hsl(var(--primary)); }

/* ===== DENTOR THEME: same palette as the Dentor Dashboard (light + dark) ===== */
[data-theme-profile="dentor"] {
    --background: 210 40% 98%;
    --foreground: 222 47% 11%;
    --card: 0 0% 100%;
    --card-foreground: 222 47% 11%;
    --popover: 0 0% 100%;
    --popover-foreground: 222 47% 11%;
    --primary: 0 66% 64%;
    --primary-foreground: 0 0% 100%;
    --primary-glow: 0 66% 72%;
    --secondary: 210 40% 96%;
    --secondary-foreground: 222 47% 11%;
    --muted: 210 40% 96%;
    --muted-foreground: 215 19% 35%;
    --accent: 0 66% 64%;
    --accent-foreground: 0 0% 100%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 0 0% 100%;
    --border: 214 32% 89%;
    --input: 214 32% 89%;
    --ring: 0 66% 64%;

    --tg-bg-chat: 210 40% 96%;
    --tg-bg-sidebar: 0 0% 100%;
    --tg-bg-message-out: 0 80% 95%;
    --tg-bg-message-in: 0 0% 100%;
    --tg-bubble-shadow: 0 1px 2px 0 hsl(222 47% 11% / 0.08);
    --tg-online: 152 60% 38%;
    --tg-typing: 0 66% 64%;
    --tg-unread: 0 66% 64%;
    --tg-hover: 210 40% 96%;

    --gradient-primary: linear-gradient(135deg, hsl(0 66% 64%), hsl(0 66% 58%));
    --gradient-glow: none;
    --gradient-mesh: linear-gradient(135deg, hsl(210 40% 98%) 0%, hsl(210 40% 96%) 100%);
    --shadow-glow: 0 0 30px hsl(0 66% 64% / 0.2);
    --shadow-elevated: 0 20px 50px -20px hsl(222 47% 11% / 0.18);

    --sidebar-background: 0 0% 100%;
    --sidebar-foreground: 222 47% 11%;
    --sidebar-border: 214 32% 91%;
    --sidebar-accent: 210 40% 96%;
    --text2: hsl(215 19% 35%);
}

[data-theme-profile="dentor"].dark {
    --background: 218 49% 8%;
    --foreground: 220 13% 91%;
    --card: 221 39% 11%;
    --card-foreground: 220 13% 91%;
    --popover: 221 39% 11%;
    --popover-foreground: 220 13% 91%;
    --primary: 0 67% 72%;
    --primary-foreground: 218 49% 8%;
    --primary-glow: 0 67% 78%;
    --secondary: 219 32% 16%;
    --secondary-foreground: 220 13% 91%;
    --muted: 219 32% 16%;
    --muted-foreground: 215 20% 65%;
    --accent: 0 67% 72%;
    --accent-foreground: 218 49% 8%;
    --destructive: 0 91% 71%;
    --destructive-foreground: 0 0% 100%;
    --border: 217 19% 27%;
    --input: 217 19% 27%;
    --ring: 0 67% 72%;

    --tg-bg-chat: 218 49% 8%;
    --tg-bg-sidebar: 221 39% 11%;
    --tg-bg-message-out: 0 35% 27%;
    --tg-bg-message-in: 219 32% 16%;
    --tg-bubble-shadow: 0 2px 8px 0 hsl(0 0% 0% / 0.35);
    --tg-online: 152 60% 50%;
    --tg-typing: 0 67% 72%;
    --tg-unread: 0 67% 72%;
    --tg-hover: 219 32% 16%;

    --gradient-primary: linear-gradient(135deg, hsl(0 67% 72%), hsl(0 67% 66%));
    --gradient-glow: none;
    --gradient-mesh: linear-gradient(135deg, hsl(218 49% 8%) 0%, hsl(221 39% 11%) 100%);
    --shadow-glow: 0 0 40px hsl(0 67% 72% / 0.25);
    --shadow-elevated: 0 25px 60px -20px hsl(0 0% 0% / 0.6);

    --sidebar-background: 221 39% 11%;
    --sidebar-foreground: 220 13% 91%;
    --sidebar-border: 217 19% 22%;
    --sidebar-accent: 219 32% 16%;
    --text2: hsl(215 20% 65%);
}

.theme-preview.dentor { background: linear-gradient(135deg, #f8fafc 0 50%, #e06666 50% 100%); }
/* Dentor logo replaces the old owl in the empty state */
[data-theme-profile="dentor"] .empty-chat .owl { width: 96px; height: 96px; border-radius: 9999px; object-fit: cover; opacity: 1; filter: none; }
/* Icons follow the Dashboard line style: slate strokes at 1.8px (baked into the SVG files), light strokes in dark mode. */
[data-theme-profile="dentor"].dark img.lucide[src*="-cyan"] { filter: brightness(0) invert(0.82); }
[data-theme-profile="dentor"].dark img.lucide[src*="-red"] { filter: none; }

/* ===== Call controls (mute / camera) ===== */
.call-controls { display: flex; justify-content: center; gap: .75rem; margin-bottom: 1.25rem; }
.call-ctl {
    border: 1px solid hsl(var(--border)); background: hsl(var(--secondary)); color: hsl(var(--foreground));
    border-radius: 9999px; padding: .55rem 1.1rem; font-size: .875rem; font-weight: 600; cursor: pointer;
}
.call-ctl:hover { background: hsl(var(--muted)); }
.call-ctl.off { background: hsl(var(--destructive)); border-color: transparent; color: #fff; }
.call-btn.hangup.wide { width: auto; border-radius: 2rem; padding: 0 1.5rem; color: #fff; font-weight: 600; gap: .5rem; }
/* the bundled call icons are drawn for a dark button: keep them white on the coloured call buttons in every theme */
.call-btn img { filter: brightness(0) invert(1) !important; }
/* Icons without a colour suffix draw in black: soften in light mode, light in dark mode. */
[data-theme-profile="dentor"] img.lucide:not([src*="-cyan"]):not([src*="-red"]) { filter: brightness(0) opacity(0.7); }
[data-theme-profile="dentor"].dark img.lucide:not([src*="-cyan"]):not([src*="-red"]) { filter: brightness(0) invert(0.82); }

/* ===== Embedded (Dashboard widget) ===== */
body.embed #mmLogout, body.embed .mm-version { display: none; }
body.embed { overscroll-behavior: contain; }

/* ===== "Tin nhắn mới" divider ===== */
.new-divider { display: flex; align-items: center; gap: .75rem; margin: 10px 4px; color: hsl(var(--primary)); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.new-divider::before, .new-divider::after { content: ""; flex: 1; height: 1px; background: hsl(var(--primary) / .45); }

/* ===== Profile modal (Dashboard-style form) ===== */
.modal.prof-modal { max-width: 32rem; border-radius: 1rem; }
.modal.prof-modal .modal-head { padding: 14px 20px; }
.modal.prof-modal .modal-head h3 { font-size: 1rem; font-weight: 600; }
.modal.prof-modal .modal-body { padding: 0; }
.prof { display: flex; flex-direction: column; }
.prof-hero { display: flex; align-items: center; gap: 16px; padding: 18px 20px; background: hsl(var(--muted) / .6); border-bottom: 1px solid hsl(var(--border)); }
.prof-avatar { width: 72px; height: 72px; border-radius: 9999px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; color: #fff; font-size: 26px; font-weight: 600; border: 3px solid hsl(var(--card)); box-shadow: 0 0 0 1px hsl(var(--border)); }
.prof-avatar img { width: 100%; height: 100%; object-fit: cover; }
.prof-who { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.prof-name { font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prof-sub { font-size: 12px; color: hsl(var(--muted-foreground)); }
.prof-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.prof-upload { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.prof .btn.small .lucide { width: 14px; height: 14px; }
.prof-sec { padding: 16px 20px; border-bottom: 1px solid hsl(var(--border)); }
.prof-sec h4 { margin: 0 0 12px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: hsl(var(--muted-foreground)); }
.prof .form-group label { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: hsl(var(--foreground)); }
.prof .form-group:last-child { margin-bottom: 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: hsl(var(--muted)); border: 1px solid hsl(var(--border)); }
.seg button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border: 0; border-radius: 8px; background: transparent; color: hsl(var(--muted-foreground)); font-size: 13px; font-weight: 600; cursor: pointer; }
.seg button.on { background: hsl(var(--card)); color: hsl(var(--foreground)); box-shadow: 0 1px 2px hsl(222 47% 11% / .12); }
.seg .lucide { width: 15px; height: 15px; }
.prof-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; cursor: pointer; }
.prof-row + .prof-row { border-top: 1px solid hsl(var(--border) / .6); }
.prof-row span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.prof-row b { font-size: 13px; font-weight: 600; }
.prof-row small { font-size: 12px; color: hsl(var(--muted-foreground)); line-height: 1.4; }
.prof-row input.sw, .modal input.sw { appearance: none; -webkit-appearance: none; flex-shrink: 0; width: 38px; height: 22px; padding: 0; border-radius: 9999px; border: 0; background: hsl(var(--border)); position: relative; cursor: pointer; transition: background .15s; }
.modal input.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 9999px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.modal input.sw:checked { background: hsl(var(--primary)); }
.modal input.sw:checked::after { transform: translateX(16px); }
.modal input.sw:focus-visible { outline: 2px solid hsl(var(--ring)); outline-offset: 2px; box-shadow: none; }
.prof-push { margin-top: 10px; padding: 12px; border-radius: 10px; background: hsl(var(--muted) / .6); border: 1px solid hsl(var(--border)); }
.prof-note { font-size: 12px; line-height: 1.45; color: hsl(var(--muted-foreground)); }
.prof-push .prof-actions { margin-top: 10px; }
.prof-links { display: flex; flex-direction: column; gap: 2px; }
.prof-links a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; color: hsl(var(--foreground)); font-size: 13px; text-decoration: none; }
.prof-links a:hover { background: hsl(var(--muted)); }
.prof-crosslink { padding-top: 4px; padding-bottom: 4px; }
.prof-crosslink a { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: hsl(var(--primary)); text-decoration: none; }
.prof-crosslink a:hover { text-decoration: underline; }
.prof-crosslink .lucide { width: 15px; height: 15px; }
.prof-links .lucide { width: 16px; height: 16px; }
.prof-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; position: sticky; bottom: 0; background: hsl(var(--card)); border-top: 1px solid hsl(var(--border)); }
.prof .btn.primary { width: auto; margin: 0; }

.modal.prof-modal .modal-head button img { filter: brightness(0) opacity(.55) !important; }
.modal.prof-modal .modal-head button:hover img { filter: brightness(0) opacity(.9) !important; }
[data-theme-profile="dentor"].dark .modal.prof-modal .modal-head button img { filter: brightness(0) invert(.8) !important; }

/* ===== "Có bản cập nhật mới" bar ===== */
.app-update-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 24px); padding: 10px 10px 10px 16px; border-radius: 14px; background: hsl(var(--card)); border: 1px solid hsl(var(--border)); box-shadow: var(--shadow-elevated); font-size: 13px; color: hsl(var(--foreground)); animation: modalContentIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.app-update-bar span { white-space: nowrap; }
.app-update-bar .aub-close { background: none; border: none; color: hsl(var(--muted-foreground)); font-size: 15px; line-height: 1; padding: 4px 2px; cursor: pointer; }
.app-update-bar .aub-close:hover { color: hsl(var(--foreground)); }
@media (max-width: 640px) {
    .app-update-bar { bottom: 76px; font-size: 12.5px; }
    .app-update-bar span { white-space: normal; }
}
