/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-primary: #ffffff;
    --bg-sidebar: #000000;
    --bg-sidebar-hover: #1a1a1a;
    --bg-sidebar-active: #1a1a1a;
    --bg-input: #f4f4f5;
    --bg-code: #f4f4f5;
    --bg-code-block: #1e1e2e;
    --border: #e4e4e7;
    --border-light: #f4f4f5;
    --text-primary: #18181b;
    --text-secondary: #52525b;
    --text-muted: #a1a1aa;
    --text-sidebar: #a1a1aa;
    --text-sidebar-active: #ffffff;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --accent-light: #fff7ed;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.2s ease;
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode */
[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-input: #1a1a1a;
    --bg-code: #1a1a1a;
    --border: #2a2a2a;
    --border-light: #1f1f1f;
    --text-primary: #e4e4e7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent-light: #1c1108;
}
[data-theme="dark"] .msg-bubble { color: var(--text-primary); }
[data-theme="dark"] .message.user .msg-bubble { background: #1a1a1a; }
[data-theme="dark"] .modal { background: #141414; border-color: #2a2a2a; }
[data-theme="dark"] .us-modal { background: #141414; }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: #1a1a1a; color: #e4e4e7; border-color: #2a2a2a; }
[data-theme="dark"] .chat-header { background: rgba(15,15,15,0.85); border-color: #1f1f1f; }
[data-theme="dark"] .chat-input-area { background: rgba(15,15,15,0.9); border-color: #1f1f1f; }
[data-theme="dark"] .input-wrapper { background: #1a1a1a; border-color: #2a2a2a; }
[data-theme="dark"] .suggestion-chip { background: #1a1a1a; border-color: #2a2a2a; }
[data-theme="dark"] .suggestion-chip:hover { background: #222; border-color: var(--accent); }
[data-theme="dark"] .empty-badge { background: #1a1a1a; color: #a1a1aa; }
[data-theme="dark"] .project-card { background: #141414; border-color: #2a2a2a; }
[data-theme="dark"] .project-card:hover { background: #1a1a1a; }
[data-theme="dark"] .new-card { background: #141414; border-color: #2a2a2a; }
[data-theme="dark"] .landing { background: #0f0f0f; }
[data-theme="dark"] .rag-badge { background: #1a1a1a; color: #a1a1aa; }
[data-theme="dark"] .model-dropdown { background: #1a1a1a; color: #e4e4e7; border-color: #2a2a2a; }
[data-theme="dark"] .mention-dropdown { background: #141414; border-color: #2a2a2a; }
[data-theme="dark"] .mention-item:hover, [data-theme="dark"] .mention-item.active { background: #1a1a1a; }
[data-theme="dark"] .agent-pill { background: #1a1a1a; border-color: #2a2a2a; }
[data-theme="dark"] .toast { background: #1a1a1a; color: #e4e4e7; border-color: #2a2a2a; }
[data-theme="dark"] .attached-file { background: #1a1a1a; border-color: #2a2a2a; }

html { font-size: 16.5px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* Lucide icons base sizing */
[data-lucide] { width: 1em; height: 1em; stroke-width: 2; vertical-align: -0.15em; flex-shrink: 0; }
.sidebar [data-lucide] { width: 0.85em; height: 0.85em; }
.sidebar-item [data-lucide] { width: 0.75em; height: 0.75em; }
.btn-icon-sm [data-lucide] { width: 0.7em; height: 0.7em; }
.btn-ghost [data-lucide] { width: 0.9em; height: 0.9em; }
.btn-attach [data-lucide] { width: 1em; height: 1em; }
.btn-send [data-lucide] { width: 0.85em; height: 0.85em; }
.btn-header [data-lucide] { width: 0.8em; height: 0.8em; }
.btn-icon [data-lucide] { width: 0.9em; height: 0.9em; }
.chat-header h2 [data-lucide] { width: 0.9em; height: 0.9em; }
.msg-avatar [data-lucide] { width: 0.85em; height: 0.85em; }
.folder-arrow { width: 0.6em !important; height: 0.6em !important; transition: transform 0.2s ease; color: #52525b; }
.folder.open .folder-arrow { transform: rotate(90deg); }
.us-tab [data-lucide] { width: 0.8em; height: 0.8em; }
.agent-pill-remove [data-lucide] { width: 0.55em; height: 0.55em; }
.file-item [data-lucide] { width: 0.72em; height: 0.72em; color: #52525b; }
.attached-file [data-lucide] { width: 0.72em; height: 0.72em; }
.search-box [data-lucide] { width: 0.72em; height: 0.72em; color: #52525b; }
.toast [data-lucide] { width: 0.85em; height: 0.85em; }
.toast-close [data-lucide] { width: 0.65em; height: 0.65em; }
.rag-indicator [data-lucide] { width: 0.65em; height: 0.65em; }
.btn-copy [data-lucide] { width: 0.75em; height: 0.75em; }
.code-copy-btn [data-lucide] { width: 0.7em; height: 0.7em; }
.thinking-block summary [data-lucide] { width: 0.8em; height: 0.8em; color: #a855f7; }
.file-icon-lg { width: 1.8em !important; height: 1.8em !important; }
[data-lucide].spin { animation: lucide-spin 1s linear infinite; }
@keyframes lucide-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
input, textarea, select {
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem;
    outline: none;
    transition: border var(--transition), box-shadow var(--transition);
    width: 100%;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
    backdrop-filter: blur(12px);
    transform: translateX(120%);
    animation: toastIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    max-width: 360px;
}
.toast.removing {
    animation: toastOut 0.3s ease forwards;
}
.toast [data-lucide] { flex-shrink: 0; }
.toast-text { flex: 1; }
.toast-close {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    font-size: 0.75rem;
    padding: 0.2rem;
    cursor: pointer;
    transition: opacity var(--transition);
}
.toast-close:hover { opacity: 1; }
.toast.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.toast.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast.info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.toast.warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

@keyframes toastIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--text-primary);
    color: #fff;
    border: none;
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius-xl);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
    width: 100%;
}
.btn-primary:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
    background: transparent;
    color: var(--text-sidebar);
    border: none;
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition);
    width: 100%;
}
.btn-ghost:hover { background: var(--bg-sidebar-hover); color: var(--text-sidebar-active); }
.btn-ghost.btn-danger:hover { color: var(--danger); }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0.3rem;
    transition: color var(--transition);
}
.btn-icon:hover { color: var(--text-primary); }

.btn-icon-sm {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0.2rem;
    opacity: 0;
    transition: all var(--transition);
}
.file-item:hover .btn-icon-sm,
.sidebar-item:hover .btn-icon-sm,
.sidebar-item.active .btn-icon-sm { opacity: 1; }
.btn-icon-sm:hover { color: var(--danger); }

/* ===== LANDING / INDEX ===== */
.landing {
    max-width: 900px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
}
.landing-header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
}
.logo {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.logo [data-lucide] { color: var(--accent); width: 1.2rem; height: 1.2rem; }
.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.project-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.3rem;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.project-card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border-color: #d4d4d8;
    transform: translateY(-2px);
}
.project-card h3 { font-size: 1rem; font-weight: 600; }
.card-desc { color: var(--text-secondary); font-size: 0.84rem; flex: 1; }
.card-icon { font-size: 1.3rem; }
.card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}
.card-meta [data-lucide] { margin-right: 0.2rem; }
.card-date { margin-left: auto; }

.new-card {
    border: 2px dashed var(--border);
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    box-shadow: none;
}
.new-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.new-card-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.new-card-inner [data-lucide] { width: 1.8rem; height: 1.8rem; color: var(--accent); }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity var(--transition-slow);
}
.modal-overlay.active { display: flex; opacity: 1; }
.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.8rem;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.16);
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition-slow);
}
.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 600; }
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.84rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    font-weight: 500;
}
.form-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: 1.2rem;
}
.form-actions .btn-primary { flex: 1; }
.form-actions .btn-danger {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-xl);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition);
}
.form-actions .btn-danger:hover { background: var(--danger); color: #fff; }

/* ===== APP LAYOUT ===== */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height — adjusts for mobile browser chrome */
    overflow: hidden;
    max-width: 100vw;
}

/* ===== SIDEBAR — dark, Mistral style ===== */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: width var(--transition-slow);
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1.2rem 1.1rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    transition: all var(--transition);
}
.sidebar-logo:hover { opacity: 0.85; }
.sidebar-logo [data-lucide] { color: var(--accent); width: 1.2rem; height: 1.2rem; transition: transform 0.3s ease; }
.sidebar-logo:hover [data-lucide] { transform: rotate(-10deg) scale(1.1); }
.sidebar-logo-img { width: 1.6rem; height: 1.6rem; object-fit: contain; flex-shrink: 0; }

.sidebar-section {
    padding: 0.6rem 0.8rem;
}
.sidebar-section h4 {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #52525b;
    margin-bottom: 0.4rem;
    padding: 0 0.4rem;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.4rem;
    margin-bottom: 0.4rem;
}
.section-header h4 { margin-bottom: 0; padding: 0; }
.btn-new-chat {
    background: transparent;
    border: 1px solid #333;
    color: #71717a;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-new-chat:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.1); }
.chat-list { max-height: 200px; overflow-y: auto; }

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    color: var(--text-sidebar);
    transition: all var(--transition);
    margin-bottom: 2px;
    white-space: nowrap;
}
.sidebar-item span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-item .btn-icon-sm {
    flex-shrink: 0;
    margin-left: auto;
}
.sidebar-item:hover { background: var(--bg-sidebar-hover); color: #d4d4d8; transform: translateX(2px); }
.sidebar-item.active { background: var(--bg-sidebar-active); color: var(--text-sidebar-active); }
.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* File list in sidebar */
.file-list { max-height: 180px; overflow-y: auto; }
.file-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-sidebar);
    transition: all var(--transition);
}
.file-item:hover { background: var(--bg-sidebar-hover); }
.file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-zone { margin-top: 0.5rem; padding: 0 0.2rem; }
.upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem;
    border: 1px dashed #333;
    border-radius: var(--radius-sm);
    color: #71717a;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition);
}
.upload-label:hover { border-color: var(--accent); color: var(--accent); }

.sidebar-bottom {
    margin-top: auto;
    padding: 0.8rem;
    border-top: 1px solid #1a1a1a;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* ===== CHAT MAIN ===== */
.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    position: relative;
}

/* ===== CHAT HEADER — glassmorphism ===== */
.chat-header {
    padding: 0.7rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 10;
}
.chat-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-primary);
    min-width: 0;
    flex: 1;
    overflow: hidden;
}
.chat-header h2 span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header h2 [data-lucide] { color: var(--accent); flex-shrink: 0; }
.rag-badge {
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
    animation: badgeFadeIn 0.6s ease 0.3s both;
}
@keyframes badgeFadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

/* ===== MESSAGES ===== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    scroll-behavior: smooth;
}

/* ===== EMPTY STATE with hero, typewriter, suggestions ===== */
.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}

/* Animated background squares — light version */
.empty-grid-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.esq {
    position: absolute;
    border-radius: 8px;
    opacity: 0;
    animation: esqPulse 9s ease-in-out infinite;
}
.esq1  { width:50px; height:50px; top:6%; left:8%; background: rgba(249,115,22,0.06); animation-delay:0s; animation-duration:8s; }
.esq2  { width:35px; height:35px; top:12%; right:12%; background: rgba(249,115,22,0.05); animation-delay:1.5s; animation-duration:10s; }
.esq3  { width:65px; height:65px; bottom:25%; left:5%; background: rgba(249,115,22,0.04); animation-delay:3s; animation-duration:9s; }
.esq4  { width:40px; height:40px; top:35%; right:8%; background: rgba(249,115,22,0.07); animation-delay:0.8s; animation-duration:7s; }
.esq5  { width:28px; height:28px; top:55%; left:15%; background: rgba(249,115,22,0.05); animation-delay:4s; animation-duration:11s; }
.esq6  { width:55px; height:55px; bottom:15%; right:10%; background: rgba(249,115,22,0.04); animation-delay:2s; animation-duration:8.5s; }
.esq7  { width:32px; height:32px; top:8%; left:45%; background: rgba(249,115,22,0.06); animation-delay:5s; animation-duration:7.5s; }
.esq8  { width:45px; height:45px; top:45%; left:70%; background: rgba(249,115,22,0.03); animation-delay:1s; animation-duration:10s; }
.esq9  { width:25px; height:25px; bottom:35%; left:35%; background: rgba(249,115,22,0.07); animation-delay:3.5s; animation-duration:6.5s; }
.esq10 { width:38px; height:38px; top:20%; left:65%; background: rgba(249,115,22,0.04); animation-delay:2.5s; animation-duration:9.5s; }
.esq11 { width:48px; height:48px; bottom:8%; left:55%; background: rgba(249,115,22,0.05); animation-delay:4.5s; animation-duration:8s; }
.esq12 { width:30px; height:30px; top:70%; right:25%; background: rgba(249,115,22,0.06); animation-delay:1.8s; animation-duration:7s; }

@keyframes esqPulse {
    0%   { opacity: 0; transform: scale(0.6) rotate(0deg); }
    20%  { opacity: 1; transform: scale(1) rotate(2deg); }
    50%  { opacity: 0.5; transform: scale(1.08) rotate(-1deg); }
    80%  { opacity: 1; transform: scale(1) rotate(1deg); }
    100% { opacity: 0; transform: scale(0.6) rotate(0deg); }
}

/* Hero image */
.empty-hero {
    opacity: 0;
    animation: emptyFadeUp 0.7s ease 0.1s forwards;
}
.empty-hero-img {
    width: 180px;
    height: auto;
    transition: transform 0.4s ease;
}
.empty-hero-img:hover {
    transform: scale(1.04) translateY(-4px);
}

/* Title + typewriter */
.empty-title-area {
    text-align: center;
    opacity: 0;
    animation: emptyFadeUp 0.6s ease 0.3s forwards;
}
.empty-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    letter-spacing: -0.02em;
}
.empty-typewriter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    min-height: 22px;
}
.empty-tw-text {
    font-size: 0.88rem;
    color: var(--text-secondary);
    font-weight: 400;
}
.empty-tw-cursor {
    color: var(--accent);
    font-weight: 300;
    font-size: 1rem;
    animation: emCursorBlink 0.7s step-end infinite;
}
@keyframes emCursorBlink { 0%,100%{opacity:1} 50%{opacity:0} }

/* Suggestion chips — enhanced */
.empty-suggestions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
    width: 100%;
    max-width: 520px;
    opacity: 0;
    animation: emptyFadeUp 0.6s ease 0.5s forwards;
}
.suggestion-chip {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 0.85rem;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    text-align: left;
}
.suggestion-chip:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 4px 16px rgba(249,115,22,0.1);
    transform: translateY(-2px);
}
.chip-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.chip-icon [data-lucide] { width: 1.1rem; height: 1.1rem; }
.chip-text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.chip-text strong {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}
.chip-text small {
    font-size: 0.7rem;
    color: var(--text-muted);
    line-height: 1.3;
}
.suggestion-chip:hover .chip-text strong { color: var(--accent); }

/* Badges row */
.empty-badges {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    opacity: 0;
    animation: emptyFadeUp 0.5s ease 0.7s forwards;
}
.empty-badge {
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.badge-ico { width: 0.7rem !important; height: 0.7rem !important; color: var(--accent); }

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

.message {
    display: flex;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    opacity: 0;
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); filter: blur(2px); }
    to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* ===== USER AVATAR — colored initials ===== */
.msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    flex-shrink: 0;
    margin-top: 2px;
    transition: transform var(--transition);
}
.message:hover .msg-avatar { transform: scale(1.08); }
.message.user .msg-avatar {
    background: var(--user-avatar-bg, var(--bg-input));
    color: var(--user-avatar-color, var(--text-secondary));
    font-weight: 600;
    font-size: 0.68rem;
    letter-spacing: -0.02em;
}
.message.assistant .msg-avatar {
    background: transparent;
    color: #fff;
}

/* ===== AI AVATAR — logo with animated ring ===== */
.ai-avatar-wrap {
    position: relative;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    margin-top: 2px;
}
.ai-avatar-wrap .ai-avatar-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}
.ai-avatar-wrap .ai-ring-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.ai-avatar-wrap.streaming .ai-ring-svg {
    opacity: 1;
    animation: avatarSpin 1.2s linear infinite;
}
@keyframes avatarSpin {
    to { transform: rotate(360deg); }
}

.msg-bubble {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* User messages: subtle background */
.message.user .msg-bubble {
    background: var(--bg-input);
    padding: 0.7rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.92rem;
}

/* Assistant messages: no bubble, clean text */
.message.assistant .msg-bubble {
    padding: 0.2rem 0;
    font-size: 0.92rem;
    line-height: 1.7;
}

/* Markdown rendered content */
.msg-content { word-break: break-word; overflow-wrap: anywhere; min-width: 0; }
.msg-content p { margin-bottom: 0.6rem; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { font-weight: 600; }
.msg-content em { font-style: italic; }
.msg-content ul, .msg-content ol {
    margin: 0.4rem 0 0.6rem 1.4rem;
}
.msg-content li { margin-bottom: 0.25rem; }
.msg-content code {
    background: var(--bg-code);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    word-break: break-all;
}

/* ===== CODE BLOCKS with toolbar ===== */
.msg-content pre {
    position: relative;
    background: var(--bg-code-block);
    color: #cdd6f4;
    border-radius: var(--radius-sm);
    padding: 0;
    overflow: hidden;
    margin: 0.6rem 0;
    font-size: 0.84rem;
    line-height: 1.55;
    max-width: 100%;
}
.msg-content pre code {
    background: none;
    padding: 1rem;
    color: inherit;
    font-size: inherit;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
}
.code-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.3rem 0.6rem;
    background: rgba(255,255,255,0.06);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 0.7rem;
}
.code-lang {
    color: #a6adc8;
    font-family: 'SF Mono', 'Fira Code', monospace;
    text-transform: lowercase;
}
.code-copy-btn {
    background: transparent;
    border: none;
    color: #a6adc8;
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.code-copy-btn:hover { background: rgba(255,255,255,0.1); color: #cdd6f4; }
.code-copy-btn.copied { color: var(--success); }

.msg-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 0.8rem;
    margin: 0.5rem 0;
    color: var(--text-secondary);
    overflow-wrap: anywhere;
}
.msg-content h1, .msg-content h2, .msg-content h3,
.msg-content h4, .msg-content h5, .msg-content h6 {
    margin: 0.8rem 0 0.3rem;
    font-weight: 600;
}
.msg-content h1 { font-size: 1.25em; }
.msg-content h2 { font-size: 1.12em; }
.msg-content h3 { font-size: 1.02em; }
.msg-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 0.8rem 0;
}
.msg-content table {
    border-collapse: collapse;
    margin: 0.6rem 0;
    font-size: 0.86rem;
    width: 100%;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.msg-content th, .msg-content td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    text-align: left;
    white-space: nowrap;
}
.msg-content th { background: var(--bg-input); font-weight: 600; }
.msg-content a { color: var(--accent); text-decoration: underline; }
.msg-content a.user-link { text-decoration: underline; text-underline-offset: 2px; word-break: break-all; }
.msg-content a.user-link:hover { opacity: 0.8; }

.msg-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* ===== CHAT INPUT — glassmorphism ===== */
.chat-input-area {
    padding: 0.8rem 1.5rem 1.2rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 10;
}
.chat-input-area form {
    width: 100%;
    max-width: 720px;
    min-width: 0;
}
.chat-disclaimer {
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    color: #71717a;
    margin-top: 0.35rem;
    letter-spacing: 0.01em;
}

/* When chat is empty, don't absolutely position — let flex handle it */
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-xl);
    padding: 0.5rem 0.6rem 0.5rem 1rem;
    transition: all var(--transition);
}
.input-wrapper:focus-within {
    border-color: var(--border);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.08), 0 4px 16px rgba(0,0,0,0.04);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.3rem 0;
    min-height: 24px;
    max-height: 150px;
    resize: none;
    line-height: 1.5;
    font-size: 0.92rem;
}
.input-wrapper textarea:focus { border: none; box-shadow: none; }

.btn-send {
    background: var(--text-primary);
    color: #fff;
    border: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.25s ease;
    flex-shrink: 0;
}
.btn-send:hover {
    opacity: 0.85;
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(249,115,22,0.2);
}
.btn-send:active { transform: scale(0.95); }
.btn-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; box-shadow: none; }

/* ===== TYPING INDICATOR — with rotating phrases ===== */
.typing-indicator-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    min-height: 36px;
}
.typing-indicator-row .thinking-loader {
    width: 22px;
    height: 22px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}
.thinking-phrase {
    font-size: 0.84rem;
    color: var(--text-muted);
    font-weight: 400;
    transition: opacity 0.2s ease;
}

/* ===== FILE ANALYSIS STATUS ===== */
.file-status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
    min-height: 36px;
}
.file-status-row .thinking-loader {
    width: 22px;
    height: 22px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}
.file-status-text {
    font-size: 0.84rem;
    color: var(--text-muted);
    font-weight: 400;
    transition: opacity 0.2s ease;
}
.file-status-text i[data-lucide="check"] {
    width: 16px;
    height: 16px;
    color: #22c55e;
}

/* Legacy typing indicator (keep for compatibility) */
.typing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0;
    height: 40px;
    width: 40px;
}
.typing-indicator img {
    width: 36px;
    height: 36px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ===== UPLOAD PROGRESS ===== */
.upload-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: #71717a;
}
.progress-bar-container {
    flex: 1;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}
.progress-text {
    font-size: 0.72rem;
    min-width: 32px;
    text-align: right;
}

/* ===== SCROLLBAR ===== */
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #e4e4e7; border-radius: 3px; }
.chat-messages::-webkit-scrollbar-thumb:hover { background: #d4d4d8; }

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* ============================================================
   RESPONSIVE — DEDICATED MOBILE LAYOUT
   ============================================================ */

/* Sidebar toggle button — inline in chat-header */
.sidebar-toggle {
    background: transparent;
    color: var(--text-muted);
    border: none;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.sidebar-toggle [data-lucide] { width: 1.1rem; height: 1.1rem; }
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-input); }

/* Desktop sidebar collapse */
@media (min-width: 769px) {
    .sidebar {
        transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .sidebar.collapsed {
        width: 0;
        min-width: 0;
        overflow: hidden;
        transform: translateX(-20px);
        pointer-events: none;
    }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===== TABLET (769px – 1024px) ===== */
@media (max-width: 1024px) and (min-width: 769px) {
    .sidebar { width: 220px; min-width: 220px; }
    .sidebar-logo { font-size: 0.92rem; padding: 1rem 0.9rem; }
    .sidebar-item { font-size: 0.82rem; padding: 0.4rem 0.5rem; }
    .folder-header { font-size: 0.8rem; }
    .chat-header { padding: 0.6rem 1.2rem; }
    .message { max-width: 680px; }
    .chat-input-area { padding: 0.7rem 1rem 1rem; }
}

/* ===== MOBILE (≤768px) ===== */
@media (max-width: 768px) {
    html { font-size: 16px; }

    /* --- APP LAYOUT — full viewport, no overflow --- */
    .app-layout {
        height: 100vh;
        height: 100dvh;
        position: fixed;
        inset: 0;
        overflow: hidden;
    }

    .sidebar-toggle {
        position: fixed;
        top: 0.6rem;
        left: 0.6rem;
        background: var(--bg-sidebar);
        color: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        border-radius: var(--radius-sm);
    }
    .sidebar-toggle:hover { color: #fff; background: rgba(255,255,255,0.1); }

    /* --- SIDEBAR --- */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 270px;
        min-width: 270px;
        z-index: 1000;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .sidebar.open { left: 0; }

    .sidebar-top { padding: 0.7rem 0.8rem 0.3rem; }
    .sidebar-section { padding: 0.4rem 0.6rem; }
    .sidebar-tree { padding-bottom: 0.8rem; }
    .sidebar-item { font-size: 0.9rem; padding: 0.55rem 0.6rem; -webkit-tap-highlight-color: transparent; }
    .folder-header { font-size: 0.9rem; -webkit-tap-highlight-color: transparent; }
    .folder-children .sidebar-item { font-size: 0.88rem; }
    .sidebar-bottom {
        padding: 0.6rem;
        gap: 1px;
    }
    .btn-ghost { font-size: 0.9rem; padding: 0.55rem 0.8rem; }

    /* --- CHAT MAIN — flex column, fills remaining space --- */
    .chat-main {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    /* --- CHAT HEADER — fixed height, never shrinks --- */
    .chat-header {
        padding: 0.5rem 0.5rem 0.5rem 3rem;
        gap: 0.3rem;
        min-height: 46px;
        flex-shrink: 0;
        position: relative; /* not sticky — flex handles it */
    }
    .chat-header h2 {
        font-size: 0.9rem;
        gap: 0.2rem;
    }
    .chat-header h2 [data-lucide] { width: 0.75rem; height: 0.75rem; }
    .chat-header h2 span {
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .header-agent-badge {
        font-size: 0.62rem;
        padding: 0.1rem 0.35rem;
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .chat-header-actions {
        gap: 0.25rem;
        flex-shrink: 0;
    }
    .chat-header-actions .model-dropdown {
        font-size: 0.72rem;
        padding: 0.2rem 0.35rem;
        max-width: 68px;
        border-radius: 12px;
    }
    .btn-header {
        width: 30px;
        height: 30px;
        border-radius: 6px;
    }
    /* Hide share on mobile — accessible from desktop */
    .btn-header-share { display: none; }

    /* --- MESSAGES — flex: 1 with min-height: 0 for proper overflow --- */
    .chat-messages {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 0.4rem 0;
    }
    .message {
        max-width: 100%;
        padding: 0.5rem 0.7rem;
        gap: 0.5rem;
    }
    .msg-avatar {
        width: 26px;
        height: 26px;
        font-size: 0.65rem;
    }
    .ai-avatar-wrap { width: 32px; height: 32px; }
    .ai-avatar-wrap .ai-avatar-img { width: 24px; height: 24px; }
    .message.user .msg-bubble {
        padding: 0.6rem 0.8rem;
        font-size: 0.95rem;
        border-radius: var(--radius);
    }
    .message.assistant .msg-bubble {
        font-size: 0.95rem;
        line-height: 1.65;
    }
    .msg-content p { margin-bottom: 0.5rem; font-size: 0.95rem; }
    .msg-content ul, .msg-content ol { margin-left: 1.1rem; }
    .msg-content li { margin-bottom: 0.2rem; font-size: 0.95rem; }

    /* Code blocks: full-bleed horizontal scroll */
    .msg-content pre {
        font-size: 0.8rem;
        margin: 0.4rem -0.7rem;
        border-radius: 0;
    }
    .msg-content pre code {
        padding: 0.65rem 0.8rem;
        font-size: 0.8rem;
    }
    .code-toolbar { padding: 0.25rem 0.5rem; font-size: 0.68rem; }

    /* Tables: horizontal scroll */
    .msg-content table {
        font-size: 0.8rem;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0.4rem -0.7rem;
        width: calc(100% + 1.4rem);
    }
    .msg-content th, .msg-content td {
        padding: 0.3rem 0.5rem;
        white-space: nowrap;
        font-size: 0.8rem;
    }

    .msg-content h1 { font-size: 1.1em; }
    .msg-content h2 { font-size: 1.02em; }
    .msg-content h3 { font-size: 0.96em; }

    .msg-content img {
        max-width: 100%;
        border-radius: var(--radius-sm);
    }

    .msg-time { font-size: 0.65rem; margin-top: 0.25rem; }
    .btn-copy { width: 26px; height: 26px; top: 0.1rem; right: 0.1rem; }

    /* --- INPUT AREA — flex-shrink: 0, always at bottom --- */
    .chat-input-area {
        padding: 0.45rem 0.6rem;
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem));
        flex-shrink: 0;
        flex-grow: 0;
        position: relative;
        z-index: 20;
        /* Prevent any transform/translate from hiding it */
        will-change: auto;
    }
    .chat-input-area form {
        max-width: 100%;
    }
    .input-wrapper {
        padding: 0.35rem 0.45rem 0.35rem 0.65rem;
        gap: 0.2rem;
        border-radius: var(--radius-lg);
    }
    .input-wrapper textarea {
        font-size: 1rem; /* 16px prevents iOS zoom on focus */
        min-height: 24px;
        padding: 0.3rem 0;
    }
    .btn-attach {
        padding: 0.25rem;
        min-width: 30px;
        min-height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }
    .btn-attach [data-lucide] { width: 0.9em; height: 0.9em; }
    .btn-plus {
        width: 30px;
        height: 30px;
        -webkit-tap-highlight-color: transparent;
    }
    .btn-send {
        width: 34px;
        height: 34px;
        -webkit-tap-highlight-color: transparent;
    }
    .attached-file {
        font-size: 0.78rem;
        max-width: 100%;
        margin: 0.2rem 0 0;
    }

    /* --- KEYBOARD OPEN STATE (set by JS) --- */
    /* When keyboard is open, reduce safe-area padding since keyboard covers it */
    body.keyboard-open .chat-input-area {
        padding-bottom: 0.35rem;
    }
    body.keyboard-open .scroll-to-bottom {
        display: none;
    }

    /* --- MENTION DROPDOWN --- */
    .mention-dropdown {
        left: 0;
        right: 0;
        max-width: none;
        margin: 0 0.3rem 0.3rem;
        max-height: 200px;
        overflow-y: auto;
    }
    .mention-item { padding: 0.45rem 0.55rem; font-size: 0.88rem; }
    .mention-icon { width: 26px; }
    .mention-icon [data-lucide] { width: 0.9rem; height: 0.9rem; }

    /* --- AGENT PILL --- */
    .agent-pill { margin-bottom: 0.25rem; padding: 0.2rem 0.4rem 0.2rem 0.5rem; }
    .agent-pill-name { font-size: 0.78rem; }
    .agent-pill-icon [data-lucide] { width: 0.75rem; height: 0.75rem; }

    /* --- AGENT GRID (empty state) --- */
    .agent-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.35rem;
        max-width: 100%;
    }
    .agent-card { padding: 0.55rem 0.35rem; -webkit-tap-highlight-color: transparent; }
    .agent-icon { font-size: 1.2rem; }
    .agent-name { font-size: 0.65rem; }

    /* --- SHARE MODAL (bottom sheet) --- */
    .share-modal {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        margin: 0;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 1.2rem;
        padding-bottom: max(1.2rem, env(safe-area-inset-bottom, 1.2rem));
        box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
        z-index: 1001;
    }

    /* --- MODALS (bottom sheet style) --- */
    .modal-overlay { align-items: flex-end; }
    .modal {
        width: 100%;
        max-width: none;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        padding: 1.2rem;
        padding-bottom: max(1.2rem, env(safe-area-inset-bottom, 1.2rem));
        max-height: 88vh;
        max-height: 88dvh;
        overflow-y: auto;
    }
    .modal-overlay.active .modal {
        transform: scale(1) translateY(0);
    }

    /* User settings modal */
    .us-modal {
        max-width: none;
        width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 85vh;
        max-height: 85dvh;
    }
    .us-tabs {
        padding: 0 0.6rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .us-tabs::-webkit-scrollbar { display: none; }
    .us-tab {
        padding: 0.55rem 0.6rem;
        font-size: 0.82rem;
        white-space: nowrap;
        flex-shrink: 0;
    }
    .us-tab-content { padding: 1rem; }
    .us-body { max-height: 55vh; max-height: 55dvh; }
    .us-color-presets { gap: 0.3rem; }
    .us-color-dot { width: 26px; height: 26px; }
    .us-color-input { width: 38px; height: 38px; }
    .us-label { font-size: 0.9rem; }
    .us-hint { font-size: 0.78rem; }
    .us-select { font-size: 0.92rem; }
    .us-textarea { font-size: 0.92rem; }

    /* --- EMPTY STATE --- */
    .empty-chat {
        padding: 0 0.6rem 0.8rem;
        gap: 0.7rem;
    }
    .empty-hero-img {
        width: 100px;
    }
    .empty-title { font-size: 1.05rem; }
    .empty-subtitle { font-size: 0.88rem !important; }
    .empty-typewriter { min-height: 20px; }
    .empty-tw-text { font-size: 0.84rem; }
    .empty-suggestions {
        grid-template-columns: 1fr;
        max-width: 100%;
        gap: 0.4rem;
        padding: 0 0.2rem;
    }
    .suggestion-chip {
        padding: 0.55rem 0.7rem;
        gap: 0.5rem;
    }
    .chip-icon [data-lucide] { width: 0.95rem; height: 0.95rem; }
    .chip-text strong { font-size: 0.84rem; }
    .chip-text small { font-size: 0.72rem; }
    .empty-badges { gap: 0.3rem; }
    .empty-badge { font-size: 0.65rem; padding: 0.15rem 0.45rem; }

    /* --- THINKING BLOCK --- */
    .thinking-content {
        max-height: 160px;
        font-size: 0.82rem;
        padding: 0.3rem 0.5rem 0.4rem;
    }
    .thinking-live .thinking-content { max-height: 120px; }
    .thinking-block summary { font-size: 0.78rem; padding: 0.4rem 0.55rem; }

    /* --- SCROLL TO BOTTOM --- */
    .scroll-to-bottom {
        bottom: 70px;
        width: 34px;
        height: 34px;
    }

    /* --- FILE PREVIEW --- */
    .file-preview-card { max-width: 100%; }
    .file-preview-card.image { max-width: 100%; }
    .file-preview-card.audio { max-width: 100%; }

    /* --- SKELETON --- */
    .skeleton-msg { padding: 0.5rem 0.7rem; gap: 0.5rem; }
    .skeleton-avatar { width: 26px; height: 26px; }

    /* --- TYPING INDICATOR --- */
    .typing-indicator-row { padding: 0.2rem 0; min-height: 32px; }
    .thinking-phrase { font-size: 0.84rem; }
    .file-status-row { padding: 0.2rem 0; min-height: 32px; }
    .file-status-text { font-size: 0.84rem; }

    /* --- FREE CHAT SECTION --- */
    .free-chat-divider { margin-top: 0.3rem; padding-top: 0.4rem; }

    /* --- PREVENT BODY SCROLL (only on chat app pages) --- */
    body:has(.app-layout) { overflow: hidden; position: fixed; width: 100%; }
}

/* ===== VERY SMALL SCREENS (≤380px) ===== */
@media (max-width: 380px) {
    .chat-header {
        padding-left: 2.8rem;
        padding-right: 0.3rem;
    }
    .chat-header h2 { font-size: 0.85rem; }
    .chat-header h2 span { max-width: 110px; }
    .chat-header-actions .model-dropdown { display: none; }
    .btn-header-logout { display: none; }

    .message { padding: 0.4rem 0.5rem; gap: 0.4rem; }
    .msg-avatar { width: 24px; height: 24px; font-size: 0.6rem; }
    .ai-avatar-wrap { width: 30px; height: 30px; }
    .ai-avatar-wrap .ai-avatar-img { width: 22px; height: 22px; }
    .message.user .msg-bubble { padding: 0.5rem 0.7rem; font-size: 0.92rem; }
    .message.assistant .msg-bubble { font-size: 0.92rem; }
    .msg-content p { font-size: 0.92rem; }

    .chat-input-area { padding: 0.35rem 0.4rem; }
    .input-wrapper { padding: 0.3rem 0.35rem 0.3rem 0.5rem; }
    .btn-send { width: 32px; height: 32px; }
    .btn-attach { min-width: 28px; min-height: 28px; }
    .btn-plus { width: 28px; height: 28px; }

    .empty-hero-img { width: 80px; }
    .empty-title { font-size: 0.95rem; }
    .empty-suggestions { padding: 0; }
    .suggestion-chip { padding: 0.5rem 0.6rem; }
    .chip-text strong { font-size: 0.82rem; }
    .chip-text small { font-size: 0.7rem; }

    .agent-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== SAFE AREA — iPhone notch, Dynamic Island, home indicator ===== */
@supports (padding: env(safe-area-inset-bottom)) {
    .chat-input-area {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
    .sidebar {
        padding-top: env(safe-area-inset-top, 0);
    }
    .modal {
        padding-bottom: max(1.2rem, env(safe-area-inset-bottom));
    }
    .sidebar-bottom {
        padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
    }
}

/* ===== LANDSCAPE MOBILE ===== */
@media (max-height: 500px) and (max-width: 900px) {
    .empty-hero-img { width: 60px; }
    .empty-chat { gap: 0.4rem; padding-bottom: 0.3rem; }
    .empty-suggestions { grid-template-columns: 1fr 1fr; }
    .empty-title { font-size: 0.85rem; }
    .empty-badges { display: none; }
    .chat-messages { padding: 0.2rem 0; }
    .us-body { max-height: 45vh; }
    .modal { max-height: 95vh; }
}

/* ===== DRAG & DROP OVERLAY ===== */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(249, 115, 22, 0.08);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.drop-overlay.active { display: flex; }
.drop-overlay-inner {
    background: var(--bg-primary);
    border: 2px dashed var(--accent);
    border-radius: var(--radius-lg);
    padding: 2.5rem 3rem;
    text-align: center;
    box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}
.drop-overlay-inner [data-lucide] {
    width: 2.5rem;
    height: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.8rem;
    display: block;
}
.drop-overlay-inner p {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== AUTH PAGES ===== */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 1rem;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.auth-card .logo {
    margin-bottom: 0.3rem;
}
.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-bottom: 1.5rem;
}
.auth-card form {
    text-align: left;
}
.auth-card .btn-primary {
    margin-top: 0.5rem;
}
.auth-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.5rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}
.auth-link {
    margin-top: 1.2rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
}
.auth-link a {
    color: var(--accent);
    font-weight: 500;
}

/* ===== SEARCH ===== */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.4rem;
    background: var(--bg-sidebar-hover);
    border-radius: var(--radius-sm);
}
.search-box input {
    background: transparent;
    border: none;
    color: var(--text-sidebar-active);
    font-size: 0.8rem;
    padding: 0.2rem 0;
    width: 100%;
}
.search-box input:focus { border: none; box-shadow: none; }
.search-box input::placeholder { color: #52525b; }

.search-results {
    max-height: 250px;
    overflow-y: auto;
}
.search-result-item {
    display: block;
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    margin-bottom: 2px;
}
.search-result-item:hover { background: var(--bg-sidebar-hover); }
.search-result-title {
    font-size: 0.8rem;
    color: var(--text-sidebar-active);
    font-weight: 500;
}
.search-result-snippet {
    font-size: 0.72rem;
    color: #71717a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result-date {
    font-size: 0.65rem;
    color: #52525b;
}
.search-empty {
    padding: 0.5rem;
    font-size: 0.8rem;
    color: #52525b;
    text-align: center;
}

/* ===== RAG INDICATOR ===== */
.rag-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    margin-top: 0.3rem;
    cursor: default;
}

/* ===== CHAT HEADER ACTIONS ===== */
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.btn-header {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all var(--transition);
}
.btn-header:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.btn-header-logout:hover {
    border-color: var(--danger, #ef4444);
    color: var(--danger, #ef4444);
}

/* ===== MODEL DROPDOWN ===== */
.model-dropdown {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    width: auto;
    transition: border var(--transition);
}
.model-dropdown:focus { border-color: var(--accent); }

/* ===== ATTACH & IMAGE BUTTONS ===== */
.btn-attach {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 0.3rem;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
    border-radius: 50%;
}
.btn-attach:hover { color: var(--accent); transform: scale(1.1); }

/* ===== PLUS MENU ===== */
.plus-menu-wrap {
    position: relative;
    flex-shrink: 0;
}
.btn-plus {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s ease;
    padding: 0;
}
.btn-plus [data-lucide] { width: 1rem; height: 1rem; }
.btn-plus:hover { color: var(--accent); border-color: var(--accent); }
.btn-plus.open {
    color: var(--accent);
    border-color: var(--accent);
    transform: rotate(45deg);
}
.plus-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.35rem;
    display: none;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 170px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    z-index: 100;
    animation: plusMenuIn 0.18s ease;
}
[data-theme="dark"] .plus-menu {
    background: #1a1a1a;
    border-color: #2a2a2a;
    box-shadow: 0 8px 32px rgba(0,0,0,0.45);
}
@keyframes plusMenuIn {
    from { opacity: 0; transform: translateY(6px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.plus-menu.open { display: flex; }
.plus-menu-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.7rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.plus-menu-item [data-lucide] { width: 0.95rem; height: 0.95rem; flex-shrink: 0; }
.plus-menu-item:hover { background: var(--accent-light); color: var(--accent); }
.plus-menu-item.active { background: var(--accent-light); color: var(--accent); }
.plus-menu-item.active [data-lucide] { color: var(--accent); }

.attached-file {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    margin-top: 0.3rem;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--accent);
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    animation: fadeIn 0.3s ease;
}
.attached-file i:first-child { font-size: 0.72rem; }
.attached-file span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attached-file button {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.72rem;
    padding: 0.1rem;
}
.attached-file button:hover { color: var(--danger); }

/* Generated images in chat */
.msg-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0;
    display: block;
    min-height: 40px;
}
/* Hide broken images */
.msg-content img[src=""],
.msg-content img:not([src]) {
    display: none !important;
    min-height: 0;
}
/* Charts container — rendered once, never re-rendered */
.charts-content {
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.charts-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 0.5rem 0;
    display: block;
}

.btn-img-gen.active {
    color: var(--accent);
    background: var(--accent-light);
    border-radius: 50%;
}

/* Web search button active state */
.btn-web-search.active {
    color: #3b82f6;
    background: #eff6ff;
    border-radius: 50%;
}

/* Reasoning button active state */
.btn-reasoning.active {
    color: #a855f7;
    background: #faf5ff;
    border-radius: 50%;
}

/* ===== THINKING BLOCK (reasoning mode) ===== */
.thinking-block {
    border: 1px solid #e9d5ff;
    border-radius: var(--radius-sm);
    margin-bottom: 0.6rem;
    background: #faf5ff;
    overflow: hidden;
    transition: all var(--transition);
}
.thinking-block.thinking-live {
    border-left: 3px solid #a855f7;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}
.thinking-block summary {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: #7c3aed;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: all var(--transition);
}
.thinking-block summary::-webkit-details-marker { display: none; }
.thinking-block summary::before {
    content: '▶';
    font-size: 0.55rem;
    transition: transform 0.2s ease;
    color: #a78bfa;
}
.thinking-block[open] summary::before {
    transform: rotate(90deg);
}
.thinking-block summary.thinking-active::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #a855f7;
    animation: thinkDot 1.4s ease infinite;
    flex-shrink: 0;
}
.thinking-loader {
    width: 22px;
    height: 22px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}
.thinking-block summary.thinking-active {
    color: #7c3aed;
    font-weight: 600;
}
.thinking-content {
    padding: 0.4rem 0.7rem 0.6rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    border-top: 1px solid #e9d5ff;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}
.thinking-live .thinking-content {
    max-height: 200px;
}
.thinking-content p { margin-bottom: 0.4rem; }
.thinking-content p:last-child { margin-bottom: 0; }
.answer-content { margin-top: 0.2rem; }

/* Streaming reveal: vertical mask that chases content top-to-bottom.
   --reveal-h is animated by JS to follow the content height. */
.answer-content.streaming {
    -webkit-mask-image: linear-gradient(
        to bottom,
        #000 0px,
        #000 var(--reveal-h, 9999px),
        rgba(0,0,0,0.15) calc(var(--reveal-h, 9999px) + 20px),
        transparent calc(var(--reveal-h, 9999px) + 50px)
    );
    mask-image: linear-gradient(
        to bottom,
        #000 0px,
        #000 var(--reveal-h, 9999px),
        rgba(0,0,0,0.15) calc(var(--reveal-h, 9999px) + 20px),
        transparent calc(var(--reveal-h, 9999px) + 50px)
    );
}
.answer-content:not(.streaming) {
    -webkit-mask-image: none;
    mask-image: none;
}

@keyframes thinkPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
@keyframes thinkDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.7); }
}
.thinking-block summary.thinking-active .thinking-label {
    animation: thinkPulse 2s ease infinite;
}

/* Code execution indicator */
.code-exec-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    margin-top: 0.8rem;
    background: linear-gradient(135deg, rgba(249,115,22,0.08) 0%, rgba(249,115,22,0.03) 100%);
    border: 1px solid rgba(249,115,22,0.2);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: #f97316;
    font-weight: 500;
}
.code-exec-indicator [data-lucide] { width: 0.85rem; height: 0.85rem; color: #f97316; }

/* Thinking status in typing indicator */
.thinking-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    color: #7c3aed;
    font-size: 0.85rem;
    font-weight: 500;
    animation: thinkPulse 2s ease infinite;
}

/* ===== COPY BUTTON ===== */
.msg-bubble { position: relative; }
.btn-copy {
    position: absolute;
    top: 0.2rem;
    right: 0.2rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition);
}
.message.assistant:hover .btn-copy { opacity: 1; }
.btn-copy:hover { color: var(--accent); border-color: var(--accent); }
.btn-copy.copied { color: var(--success); border-color: var(--success); }

/* ===== SKELETON LOADING ===== */
.skeleton-msg {
    display: flex;
    gap: 0.75rem;
    padding: 0.8rem 0;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
}
.skeleton-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    animation: shimmer 1.5s infinite;
}
.skeleton-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.skeleton-line {
    height: 14px;
    border-radius: 6px;
    background: var(--bg-input);
    animation: shimmer 1.5s infinite;
}
.skeleton-line:nth-child(1) { width: 80%; }
.skeleton-line:nth-child(2) { width: 60%; animation-delay: 0.15s; }
.skeleton-line:nth-child(3) { width: 40%; animation-delay: 0.3s; }

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

/* ===== SYNTAX HIGHLIGHTING (highlight.js overrides) ===== */
.hljs { background: transparent !important; padding: 0 !important; }

/* ===== SIDEBAR FOLDER TREE ===== */
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem 0.4rem;
}
.sidebar-top .sidebar-logo {
    padding: 0;
    font-size: 1rem;
}
.sidebar-top .btn-new-chat {
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

.sidebar-tree {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 0.5rem;
}

.folder {
    margin-bottom: 2px;
}

.folder-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-sidebar);
    font-size: 0.84rem;
    user-select: none;
}
.folder-header:hover {
    background: var(--bg-sidebar-hover);
    color: #d4d4d8;
}

.folder-arrow {
    font-size: 0.55rem;
    transition: transform 0.2s ease;
    color: #52525b;
    flex-shrink: 0;
    width: 12px;
    text-align: center;
}
.folder.open .folder-arrow {
    transform: rotate(90deg);
}

.folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.folder-count {
    font-size: 0.65rem;
    color: #52525b;
    background: #1a1a1a;
    padding: 0.05rem 0.35rem;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

.folder-add {
    opacity: 0;
    font-size: 0.65rem;
    color: #71717a;
    padding: 0.15rem;
    transition: all var(--transition);
}
.folder-header:hover .folder-add {
    opacity: 1;
}
.folder-add:hover {
    color: var(--accent) !important;
}

.folder-children {
    display: none;
    padding-left: 0.9rem;
}
.folder.open .folder-children {
    display: block;
}

.folder-children .sidebar-item {
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
    gap: 0.4rem;
}
.folder-children .sidebar-item [data-lucide] {
    color: #52525b;
}
.folder-children .sidebar-item.active [data-lucide] {
    color: var(--accent);
}

/* ===== GENERAL CHATS & SIDEBAR DIVIDER ===== */
.general-chats-section {
    margin-bottom: 0.3rem;
}

.sidebar-divider {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem 0.25rem;
    margin-top: 0.2rem;
}
.sidebar-divider span {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #52525b;
    flex: 1;
}
.sidebar-divider .folder-add {
    opacity: 0.6;
    font-size: 0.7rem;
    color: #71717a;
}
.sidebar-divider .folder-add:hover {
    opacity: 1;
    color: var(--accent);
}

/* Free chat section */
.free-chat-divider {
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
}
.free-chat-divider span {
    color: #3b82f6;
}
.free-chats-section {
    padding: 0 0.3rem;
}
.sidebar-item-free i[data-lucide] {
    color: #3b82f6;
}
.sidebar-item-free.active {
    background: rgba(59, 130, 246, 0.12);
}
.empty-badge.free-badge {
    border-color: #3b82f6;
    color: #3b82f6;
}
.empty-badge.free-badge .badge-ico {
    color: #3b82f6;
}

/* ===== FILE PREVIEW CARDS (in-chat attachments) ===== */
.file-preview-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.7rem;
    margin-bottom: 0.4rem;
    max-width: 320px;
    overflow: hidden;
}
.file-preview-card.image {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    max-width: 280px;
}
.file-preview-card.image .file-preview-info {
    padding: 0.4rem 0.7rem 0.5rem;
}
.file-preview-img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    display: block;
}
.file-preview-audio {
    width: 100%;
    max-width: 260px;
    height: 36px;
    border-radius: 4px;
}
.file-preview-card.audio {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
    padding: 0.6rem 0.7rem;
    max-width: 300px;
}
.file-preview-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    flex-shrink: 0;
}
.file-preview-icon.audio {
    background: #7c3aed;
}
.file-preview-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.file-preview-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-preview-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.file-preview-prompt {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-top: 0.15rem;
    line-height: 1.5;
}

/* ===== AUTH BADGES (Fundraising Expert) ===== */
.auth-badges {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 1.5rem;
    align-items: center;
}
.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    background: var(--bg-input);
}
.auth-badge [data-lucide] {
    width: 0.7rem;
    height: 0.7rem;
    color: var(--accent);
}

/* ===== AGENT CARDS ===== */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    width: 100%;
    max-width: 520px;
    opacity: 0;
    animation: emptyFadeUp 0.6s ease 0.45s forwards;
}
.agent-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.8rem 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}
.agent-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, rgba(249,115,22,0.06) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.agent-card:hover::before { opacity: 1; }
.agent-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(249,115,22,0.1);
}
.agent-card.active {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 4px 16px rgba(249,115,22,0.12);
}
.agent-card.active::before { opacity: 1; }

.agent-icon {
    font-size: 1.6rem;
    line-height: 1;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}
.agent-card:hover .agent-icon {
    transform: scale(1.15);
}

.agent-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
    position: relative;
    z-index: 1;
}
.agent-card:hover .agent-name { color: var(--accent); }
.agent-card.active .agent-name { color: var(--accent); }

/* Header agent badge */
.header-agent-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    margin-right: 0.3rem;
    animation: badgeFadeIn 0.4s ease both;
}

/* ===== @ MENTION DROPDOWN ===== */
.mention-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    max-width: 720px;
    margin: 0 auto 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.1), 0 -2px 8px rgba(0,0,0,0.06);
    padding: 0.4rem;
    display: none;
    z-index: 100;
    animation: mentionSlideUp 0.2s ease;
}
.mention-dropdown.open {
    display: block;
}
@keyframes mentionSlideUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.mention-header {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 0.25rem 0.5rem 0.35rem;
    font-weight: 600;
}
.mention-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    width: 100%;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.88rem;
    color: var(--text-primary);
}
.mention-item:hover,
.mention-item.active {
    background: var(--accent-light);
    color: var(--accent);
}
.mention-item.active {
    box-shadow: inset 0 0 0 1px rgba(249,115,22,0.2);
}
.mention-icon {
    flex-shrink: 0;
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
}
.mention-icon [data-lucide] { width: 1rem; height: 1rem; }
.mention-name {
    font-weight: 500;
    font-size: 0.85rem;
}

/* ===== AGENT PILL (above input) ===== */
.agent-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.5rem 0.3rem 0.6rem;
    background: var(--accent-light);
    border: 1px solid rgba(249,115,22,0.2);
    border-radius: 20px;
    margin-bottom: 0.4rem;
    width: fit-content;
    animation: pillFadeIn 0.25s ease;
}
@keyframes pillFadeIn {
    from { opacity: 0; transform: scale(0.9) translateX(-8px); }
    to   { opacity: 1; transform: scale(1) translateX(0); }
}
.agent-pill-icon {
    display: flex;
    align-items: center;
    color: var(--accent);
}
.agent-pill-icon [data-lucide] { width: 0.85rem; height: 0.85rem; }
.agent-pill-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
}
.agent-pill-remove {
    background: transparent;
    border: none;
    color: var(--accent);
    font-size: 0.6rem;
    cursor: pointer;
    padding: 0.15rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    opacity: 0.6;
}
.agent-pill-remove:hover {
    opacity: 1;
    background: rgba(249,115,22,0.15);
}

/* ===== USER SETTINGS MODAL ===== */
.us-modal {
    max-width: 520px;
    padding: 0;
    overflow: hidden;
}
.us-modal .modal-header {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 0;
}
.us-modal .modal-header h2 {
    display: flex;
    align-items: center;
}

/* Tabs */
.us-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    padding: 0 1.4rem;
}
.us-tab {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.65rem 0.9rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}
.us-tab:hover { color: var(--text-primary); }
.us-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.us-tab [data-lucide] { width: 0.78rem; height: 0.78rem; }

/* Body */
.us-body {
    max-height: 60vh;
    overflow-y: auto;
}
.us-tab-content {
    display: none;
    padding: 1.2rem 1.4rem 1.4rem;
    animation: usFadeIn 0.25s ease;
}
.us-tab-content.active { display: block; }
@keyframes usFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Form groups */
.us-group {
    margin-bottom: 1.2rem;
}
.us-label {
    display: block;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}
.us-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
    line-height: 1.35;
}
.us-select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    font-size: 0.86rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: border 0.2s ease;
}
.us-select:focus { border-color: var(--accent); outline: none; }
.us-textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    font-size: 0.86rem;
    color: var(--text-primary);
    resize: vertical;
    min-height: 80px;
    transition: border 0.2s ease;
    font-family: inherit;
    line-height: 1.5;
}
.us-textarea:focus { border-color: var(--accent); outline: none; }

/* Slider */
.us-slider-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.us-slider-edge {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.us-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 5px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    border: none;
    padding: 0;
}
.us-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 1px 6px rgba(249,115,22,0.3);
    transition: transform 0.15s ease;
}
.us-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.us-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}
.us-slider-val {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 30px;
    text-align: center;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* Save */
.us-save { margin-top: 0.2rem; }

/* Color picker */
.us-color-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.us-color-input {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-light);
    border-radius: 10px;
    padding: 2px;
    cursor: pointer;
    background: var(--bg-input);
    flex-shrink: 0;
}
.us-color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.us-color-input::-webkit-color-swatch { border-radius: 6px; border: none; }
.us-color-presets {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.us-color-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}
.us-color-dot:hover {
    transform: scale(1.2);
    border-color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* Account tab */
.us-account-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem;
    background: var(--bg-input);
    border-radius: var(--radius);
    margin-bottom: 1.2rem;
}
.us-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}
.us-account-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}
.us-account-info strong { font-size: 0.95rem; }
.us-account-info span { font-size: 0.72rem; color: var(--text-muted); }

.us-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}
.us-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.7rem;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
}
.us-stat-val {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}
.us-stat-lbl {
    font-size: 0.62rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.us-info-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1.4rem;
}
.us-info-chip {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
}

.us-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.us-logout:hover { background: var(--danger); color: #fff; }

/* ===== 2FA SETTINGS ===== */
.us-2fa-section { border-top:1px solid var(--border-light); padding-top:1.2rem; margin-top:0.5rem; }
.tfa-badge {
    display:inline-flex; align-items:center; gap:0.35rem; font-size:0.78rem; font-weight:600;
    padding:0.3rem 0.7rem; border-radius:20px; margin-bottom:0.8rem;
}
.tfa-badge [data-lucide] { width:0.75rem; height:0.75rem; }
.tfa-on { background:rgba(34,197,94,0.1); color:#22c55e; border:1px solid rgba(34,197,94,0.25); }
.tfa-off { background:rgba(255,255,255,0.05); color:var(--text-muted); border:1px solid var(--border-light); }
.us-btn-accent {
    display:inline-flex; align-items:center; gap:0.3rem; background:var(--accent,#f97316); color:#fff;
    font-size:0.82rem; font-weight:600; padding:0.5rem 1.2rem; border-radius:50px; border:none; cursor:pointer;
    transition:all 0.2s;
}
.us-btn-accent:hover { filter:brightness(0.9); transform:translateY(-1px); }
.us-btn-outline {
    display:inline-flex; align-items:center; gap:0.3rem; background:none;
    border:1px solid var(--border-light); color:var(--text-secondary);
    font-size:0.82rem; font-weight:500; padding:0.45rem 1rem; border-radius:50px; cursor:pointer;
    transition:all 0.2s;
}
.us-btn-outline:hover { border-color:var(--danger,#ef4444); color:var(--danger,#ef4444); }
.tfa-qr-wrap {
    display:flex; justify-content:center; margin-top:0.8rem;
    background:white; border-radius:12px; padding:0.8rem; width:fit-content; margin-left:auto; margin-right:auto;
}
.tfa-qr-img { width:180px; height:180px; image-rendering:pixelated; }
.tfa-code-input {
    width:140px; padding:0.5rem 0.7rem; font-size:1.1rem; font-weight:600; text-align:center;
    letter-spacing:0.3em; border-radius:10px; border:1px solid var(--border-light);
    background:var(--bg-input); color:var(--text-primary); outline:none; font-family:monospace;
}
.tfa-code-input:focus { border-color:var(--accent,#f97316); box-shadow:0 0 0 3px rgba(249,115,22,0.1); }
.tfa-verify-row, .tfa-disable-row {
    display:flex; align-items:center; gap:0.6rem; margin-top:0.8rem;
}
.btn-sm-danger {
    background:rgba(239,68,68,0.1); color:#ef4444; border:1px solid rgba(239,68,68,0.3);
    font-size:0.82rem; font-weight:600; padding:0.5rem 1rem; border-radius:50px; cursor:pointer;
    transition:all 0.2s;
}
.btn-sm-danger:hover { background:#ef4444; color:#fff; }

/* ===== KB PERSONALE TAB ===== */
.kb-upload-area {
    margin-bottom: 1rem;
}
.kb-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    border: 2px dashed var(--border-light);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}
.kb-upload-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(249,115,22,0.05);
}
.kb-upload-btn [data-lucide] { width: 1rem; height: 1rem; }
.kb-upload-progress {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 0.6rem;
}
.kb-progress-bar {
    flex: 1;
    height: 4px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}
.kb-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.4s ease;
    width: 0%;
}
.kb-progress-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.kb-file-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.kb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}
.kb-empty p { font-size: 0.88rem; margin: 0; }
.kb-empty small { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }
.kb-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.8rem;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    transition: border-color 0.2s;
}
.kb-file-item:hover { border-color: var(--accent); }
.kb-file-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}
.kb-file-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.kb-file-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kb-file-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}
.kb-file-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.3rem;
    border-radius: 6px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.kb-file-delete:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

/* ===== SCROLL TO BOTTOM BUTTON ===== */
.scroll-to-bottom {
    position: absolute;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    opacity: 0;
}
.scroll-to-bottom.visible {
    transform: translateX(-50%) scale(1);
    opacity: 1;
}
.scroll-to-bottom:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(249,115,22,0.3);
}

/* ===== INLINE RENAME INPUT ===== */
.sidebar-item .rename-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-sidebar-hover);
    border: 1px solid var(--accent);
    color: #fff;
    font-size: 0.82rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    outline: none;
    font-family: inherit;
}

/* ===== PAGE TRANSITION SKELETON ===== */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: pageLoadSlide 1.2s ease infinite;
    z-index: 9999;
}
@keyframes pageLoadSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== DARK MODE TOGGLE ===== */
.dark-mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.6rem;
    background: none;
    border: none;
    color: var(--text-sidebar);
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.dark-mode-toggle:hover { background: var(--bg-sidebar-hover); color: #d4d4d8; }

/* ===== EMPTY STATE (index.html) ===== */
.empty-projects {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
    gap: 1rem;
}
.empty-projects-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.empty-projects h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}
.empty-projects p {
    font-size: 0.9rem;
    max-width: 320px;
    line-height: 1.5;
}
/* ===== SMOOTH STREAMING ===== */
/* No cursor — the reveal mask is the visual indicator */

/* ===== SHARED CHAT PAGE ===== */
.shared-page {
    max-width: 780px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.shared-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}
.shared-error h2 { font-size: 1.3rem; margin-bottom: 0.5rem; }
.shared-error p { color: var(--text-secondary); font-size: 0.95rem; }
.shared-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(12px);
    z-index: 10;
}
[data-theme="dark"] .shared-header { background: rgba(15,15,15,0.9); }
.shared-header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1rem;
}
.shared-header-right {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.8rem;
}
.shared-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 500;
    font-size: 0.72rem;
}
.shared-author { color: var(--text-muted); }
.shared-messages {
    flex: 1;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.shared-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 1.2rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ===== SHARE BUTTON & MODAL ===== */
.btn-header-share {
    position: relative;
}
.share-modal {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    width: 320px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 100;
    display: none;
}
.share-modal.open { display: block; }
[data-theme="dark"] .share-modal { background: #141414; border-color: #2a2a2a; }
.share-modal-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.share-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.8rem;
}
.share-toggle-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
/* Toggle switch */
.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
    cursor: pointer;
}
.toggle-switch input { display: none; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 22px;
    transition: background var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.share-url-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.4rem;
}
.share-url-input {
    flex: 1;
    font-size: 0.78rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text-primary);
    min-width: 0;
}
.share-url-copy {
    background: var(--text-primary);
    color: #fff;
    border: none;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: opacity var(--transition);
}
.share-url-copy:hover { opacity: 0.85; }

/* ===== SIDEBAR LOAD MORE ===== */
.load-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    margin: 0.2rem 0.4rem;
    border: none;
    background: transparent;
    color: var(--text-sidebar);
    font-size: 0.78rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    width: calc(100% - 0.8rem);
}
.load-more-btn:hover { background: var(--bg-sidebar-hover); color: var(--accent); }
.load-more-btn [data-lucide] { width: 0.7rem; height: 0.7rem; }

/* ===== BETA POPUP ===== */
.beta-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    transition: opacity 0.3s ease;
    animation: fadeIn 0.3s ease;
}
.beta-popup {
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem 1.8rem 1.5rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
[data-theme="dark"] .beta-popup {
    background: #1a1a1a;
    border-color: #2a2a2a;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.beta-popup-emoji {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    line-height: 1;
}
.beta-popup h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 0.6rem;
    color: var(--text-primary);
}
.beta-popup p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 1rem;
}
.beta-popup-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
    padding: 0.6rem 0.8rem;
    background: var(--accent-light);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--accent);
}
.beta-popup-hint strong { font-weight: 600; }
