/* ============================================
   YSCELL AI — Stylesheet v5.1 FINAL
   Organization:
   1. Reset & Variables
   2. Base Layout  
   3. Sidebar
   4. Top Bar
   5. Chat Area
   6. Messages
   7. Input Area
   8. Modals & Overlays
   9. Sprint 1 Features
   10. Sprint 1 Features (Extra — Memory & Upload)
   11. iOS Safe Area
   12. Touch Targets
   13. Responsive (Tablet 1024px)
   14. Responsive (Mobile 768px)
   15. Responsive (Small Mobile 480px)
   16. Responsive (Tiny 360px)
   17. Landscape & Special
   18. Desktop Only
   19. Export Menu Mobile Enhancement
   20. Responsive 900px — Tablet Kecil
   21. Responsive 600px — Smartphone
   22. Responsive 400px — HP Kecil
   23. Accessibility & Reduced Motion
   ============================================ */


/* ============================================
   1. RESET & VARIABLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --sidebar-w: 290px;
    --sidebar-max: 340px;
    --bg: #05060f;
    --card: rgba(255, 255, 255, 0.04);
    --card-hover: rgba(255, 255, 255, 0.08);
    --glass: rgba(20, 25, 45, 0.55);
    --glass-hover: rgba(30, 35, 60, 0.7);
    --text: #f5f7ff;
    --text-2: #a8b0c8;
    --text-3: #6b7394;
    --border: rgba(255, 255, 255, 0.08);
    --border-bright: rgba(139, 92, 246, 0.4);
    --accent-green: #0acf83;
    --gradient-primary: linear-gradient(135deg, #7c3aed 0%, #06b6d4 50%, #ec4899 100%);
    --gradient-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(6, 182, 212, 0.1));
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    --bg: #f5f7ff;
    --card: rgba(255, 255, 255, 0.75);
    --card-hover: rgba(255, 255, 255, 0.95);
    --glass: rgba(255, 255, 255, 0.7);
    --glass-hover: rgba(255, 255, 255, 0.9);
    --text: #0a0e1f;
    --text-2: #3d4666;
    --text-3: #67709a;
    --border: rgba(0, 0, 0, 0.06);
    --border-bright: rgba(124, 58, 237, 0.35);
}

html, body {
    height: 100%;
    overflow: hidden;
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    background: var(--bg);
    color: var(--text);
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: none;
}

* { max-width: 100%; }
img, video, pre, code, table { max-width: 100%; }


/* ============================================
   2. BASE LAYOUT & BACKGROUND
   ============================================ */

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 15% 20%, rgba(124, 58, 237, 0.18) 0%, transparent 45%),
        radial-gradient(circle at 85% 80%, rgba(6, 182, 212, 0.15) 0%, transparent 45%);
    z-index: 0;
    pointer-events: none;
    animation: auroraMove 20s ease-in-out infinite;
}

@keyframes auroraMove {
    0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.9; }
    50% { transform: scale(1.15) rotate(4deg); opacity: 1; }
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(124, 58, 237, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(124, 58, 237, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
    pointer-events: none;
    mask-image: radial-gradient(circle at center, black 40%, transparent 90%);
    -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 90%);
}

.orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.5;
}
.orb-1 { width: 400px; height: 400px; background: radial-gradient(circle, #7c3aed, transparent 70%); top: -100px; left: -100px; animation: orbFloat1 18s ease-in-out infinite; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, #06b6d4, transparent 70%); bottom: -150px; right: -100px; animation: orbFloat2 22s ease-in-out infinite; }
.orb-3 { width: 300px; height: 300px; background: radial-gradient(circle, #ec4899, transparent 70%); top: 40%; left: 50%; animation: orbFloat3 20s ease-in-out infinite; }

@keyframes orbFloat1 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(80px, 60px) scale(1.15); } }
@keyframes orbFloat2 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-100px, -60px) scale(1.2); } }
@keyframes orbFloat3 { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-30%, -60%) scale(1.3); } }


/* ============================================
   3. ANNOUNCEMENT BANNER
   ============================================ */

.announcement-banner {
    display: none;
    position: relative;
    z-index: 50;
    border-bottom: 1px solid rgba(124, 58, 237, 0.4);
    backdrop-filter: blur(20px);
    animation: bannerSlideDown 0.6s var(--ease-out);
    overflow: hidden;
}
.announcement-banner.show { display: block; }

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

.announcement-content {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    max-width: 1400px;
    margin: 0 auto;
}
.announcement-icon {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.5);
}
.announcement-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.announcement-text strong { font-size: 0.88rem; font-weight: 700; color: var(--text); font-family: 'Space Grotesk', sans-serif; }
.announcement-text span { font-size: 0.78rem; color: var(--text-2); line-height: 1.4; }
.announcement-close {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.3s;
}
.announcement-close:hover { background: #ec4899; color: #fff; transform: rotate(90deg); }


/* ============================================
   4. SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-w);
    background: var(--glass);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.4s var(--ease-out);
    z-index: 200;
    position: relative;
}

.sidebar-header {
    padding: 1.3rem 1.2rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 1.05rem;
    text-decoration: none;
    color: var(--text);
}
.sidebar-logo-icon {
    width: 42px;
    height: 42px;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: #fff;
    box-shadow: 0 0 25px rgba(124, 58, 237, 0.5);
    flex-shrink: 0;
    animation: gradientShift 6s ease infinite;
}
@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
.sidebar-logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-logo-text span:first-child {
    background: var(--gradient-primary);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    font-size: 1.05rem;
    animation: gradientShift 5s ease infinite;
}
.sidebar-logo-text small { font-size: 0.62rem; color: var(--text-3); font-weight: 500; }

.new-chat-btn {
    margin: 1rem 1.2rem;
    padding: 13px 20px;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    border: none;
    border-radius: 14px;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.4s var(--ease-spring);
    font-family: inherit;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.35);
    animation: gradientShift 5s ease infinite;
}
.new-chat-btn:hover { transform: translateY(-3px) scale(1.02); }

/* Search Box */
.search-box { position: relative; margin: 0.5rem 1rem 0.5rem; }
.search-box input {
    width: 100%;
    padding: 10px 36px 10px 38px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s;
}
.search-box input:focus { border-color: var(--border-bright); background: rgba(124, 58, 237, 0.06); }
.search-box input::placeholder { color: var(--text-3); }
.search-box i.fa-search {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    font-size: 0.8rem;
    pointer-events: none;
}
.search-box .clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-size: 0.75rem;
    display: none;
}
.search-box.has-value .clear-search { display: flex; }

/* Search Tabs */
.search-tabs {
    display: flex;
    gap: 4px;
    padding: 0 1rem 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.search-tabs::-webkit-scrollbar { display: none; }
.search-tab {
    padding: 5px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text-3);
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.search-tab:hover { border-color: var(--border-bright); color: var(--text-2); }
.search-tab.active { background: var(--gradient-soft); color: #a78bfa; border-color: var(--border-bright); }

.search-result-info { padding: 4px 1.2rem 8px; font-size: 0.68rem; color: var(--text-3); display: none; }
.search-result-info.show { display: block; }
.search-result-info strong { color: #a78bfa; }

.no-result { padding: 20px 1rem; text-align: center; color: var(--text-3); font-size: 0.78rem; display: none; }
.no-result.show { display: block; }
.no-result i { font-size: 2rem; opacity: 0.3; display: block; margin-bottom: 8px; }

.sidebar-section-title {
    padding: 0.5rem 1.2rem 0.4rem;
    font-size: 0.65rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-section-title button {
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 8px;
}

/* Chat History */
.chat-history { flex: 1; overflow-y: auto; padding: 0 0.8rem 1rem; }
.chat-history::-webkit-scrollbar { width: 5px; }
.chat-history::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.35); border-radius: 5px; }

.history-item {
    padding: 11px 13px;
    border-radius: 12px;
    color: var(--text-2);
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 4px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    border: 1px solid transparent;
    transition: background 0.2s, border-color 0.2s;
}
.history-item:hover { background: var(--card-hover); color: var(--text); border-color: var(--border); }
.history-item.active { background: var(--gradient-soft); color: #a78bfa; border: 1px solid var(--border-bright); }
.history-item.pinned { background: linear-gradient(135deg, rgba(251, 191, 36, 0.08), transparent); border-color: rgba(251, 191, 36, 0.25); }
.history-item i { font-size: 0.88rem; flex-shrink: 0; color: var(--text-3); }
.history-item i.pin-badge { color: #fbbf24; }
.history-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.history-item mark { background: rgba(236, 72, 153, 0.3); color: #f472b6; padding: 0 2px; border-radius: 3px; font-weight: 700; }
.history-item .del-btn,
.history-item .pin-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    padding: 4px;
    font-size: 0.75rem;
    border-radius: 6px;
    flex-shrink: 0;
    transition: all 0.2s;
}
.history-item:hover .del-btn,
.history-item:hover .pin-btn { opacity: 1; }
.history-item .del-btn:hover { background: rgba(236, 72, 153, 0.15); color: #f472b6; }
.history-item .pin-btn:hover { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }

/* User Area */
.sidebar-user-area { padding: 0 0.8rem 0.8rem; border-top: 1px solid var(--border); padding-top: 0.8rem; }
.sidebar-user-card {
    display: flex;
    gap: 10px;
    padding: 11px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s;
    align-items: center;
}
.sidebar-user-card:hover { border-color: var(--border-bright); background: var(--glass-hover); transform: translateY(-2px); }
.user-avatar-mini { width: 42px; height: 42px; border-radius: 50%; border: 2px solid #7c3aed; object-fit: cover; flex-shrink: 0; background: #0f172a; }
.user-card-info { flex: 1; min-width: 0; }
.user-card-name-row { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; flex-wrap: wrap; }
.user-card-name { font-size: 0.82rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.user-plan-badge { font-size: 0.55rem; padding: 2px 7px; border-radius: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; flex-shrink: 0; }
.user-plan-badge.free { background: rgba(113, 128, 150, 0.25); color: #a0aec0; }
.user-plan-badge.pro { background: rgba(59, 130, 246, 0.25); color: #60a5fa; }
.user-plan-badge.premium { background: linear-gradient(135deg, rgba(236, 72, 153, 0.3), rgba(245, 158, 11, 0.3)); color: #fbbf24; }
.user-quota-row { display: flex; align-items: center; gap: 6px; }
.user-quota-bar { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.1); border-radius: 4px; overflow: hidden; min-width: 50px; }
.user-quota-fill { height: 100%; background: linear-gradient(90deg, #0acf83, #3b82f6); border-radius: 4px; transition: width 0.5s; width: 0%; }
.user-quota-fill.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.user-quota-fill.danger { background: linear-gradient(90deg, #ff0040, #ff6b81); }
.user-quota-text { font-size: 0.62rem; color: var(--text-3); font-weight: 600; min-width: 32px; text-align: right; white-space: nowrap; }

.sidebar-guest-card {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(236, 72, 153, 0.05));
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 14px;
    align-items: center;
}
.sidebar-guest-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.sidebar-guest-info { flex: 1; min-width: 0; }
.sidebar-guest-title { font-size: 0.78rem; font-weight: 700; color: #fbbf24; margin-bottom: 2px; }
.sidebar-guest-desc { font-size: 0.62rem; color: var(--text-3); line-height: 1.3; }
.sidebar-login-btn {
    padding: 7px 12px;
    background: linear-gradient(135deg, #0acf83, #3b82f6);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 0.7rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: space-between;
}
.sidebar-footer-actions { display: flex; gap: 6px; flex: 1; justify-content: flex-end; }
.sidebar-footer-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.3s;
}
.sidebar-footer-btn:hover { background: rgba(124, 58, 237, 0.18); color: #a78bfa; border-color: var(--border-bright); transform: translateY(-2px); }
.sidebar-footer-btn.upgrade-btn {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(245, 158, 11, 0.15));
    border-color: rgba(236, 72, 153, 0.3);
    color: #fbbf24;
}
.sidebar-footer-btn.upgrade-btn:hover { background: linear-gradient(135deg, rgba(236, 72, 153, 0.3), rgba(245, 158, 11, 0.3)); color: #fff; }


/* ============================================
   5. TOP BAR
   ============================================ */

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 10;
    min-width: 0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1.3rem;
    background: var(--glass);
    backdrop-filter: blur(30px) saturate(180%);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    flex-shrink: 0;
    gap: 8px;
    position: relative;
    min-height: 58px;
}

.top-bar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-2);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: all 0.3s;
}
.mobile-menu-btn:hover { background: rgba(124, 58, 237, 0.15); color: #a78bfa; }

.chat-title-wrap { min-width: 0; flex: 1; display: flex; align-items: center; gap: 8px; }
.chat-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
    padding: 2px 6px;
}
.chat-title:hover { background: rgba(124, 58, 237, 0.08); }

.chat-status-mini { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.chat-status-mini .dot { width: 8px; height: 8px; background: #0acf83; border-radius: 50%; box-shadow: 0 0 8px #0acf83; animation: statusPulse 2s ease-in-out infinite; }
.chat-status-mini .dot.offline { background: #6b7394; box-shadow: none; animation: none; }
@keyframes statusPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.top-bar-right { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

/* AI / Persona Selector */
.ai-selector, .persona-selector { position: relative; flex-shrink: 0; }
.ai-selector-btn, .persona-selector-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-2);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    transition: all 0.3s var(--ease-spring);
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
}
.ai-selector-btn:hover, .persona-selector-btn:hover { background: rgba(124, 58, 237, 0.15); color: #a78bfa; border-color: var(--border-bright); }
.persona-selector-btn {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.1), rgba(124, 58, 237, 0.1));
    border-color: rgba(236, 72, 153, 0.3);
    color: #f472b6;
    max-width: 140px;
}
.persona-selector-btn:hover { background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(124, 58, 237, 0.2)); color: #f472b6; }
.ai-selector-btn i:first-child, .persona-emoji { font-size: 0.9rem; flex-shrink: 0; }
.ai-selector-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; min-width: 0; overflow: hidden; }
.ai-selector-label { font-weight: 700; color: var(--text); font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.ai-selector-model { font-size: 0.56rem; color: var(--text-3); font-weight: 500; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.persona-name { overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-size: 0.72rem; max-width: 80px; }
.ai-selector-arrow, .persona-arrow { font-size: 0.6rem; color: var(--text-3); transition: transform 0.3s; flex-shrink: 0; }
.ai-selector.open .ai-selector-arrow, .persona-selector.open .persona-arrow { transform: rotate(180deg); }

/* Dropdown menus (desktop) */
.ai-selector-menu, .persona-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    min-width: 200px;
    max-width: min(260px, calc(100vw - 16px));
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid var(--border-bright);
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    z-index: 9999;
    max-height: 340px;
    overflow-y: auto;
    animation: selectorMenuIn 0.25s var(--ease-spring);
    overscroll-behavior: contain;
}
.ai-selector-menu { left: 0; right: auto; }
.persona-menu { left: 0 !important; right: auto !important; max-width: calc(100vw - 20px) !important; border-color: rgba(236, 72, 153, 0.4); }
.ai-selector.open .ai-selector-menu,
.persona-selector.open .persona-menu { display: block; }
@keyframes selectorMenuIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-selector-header, .persona-menu-header {
    padding: 6px 8px;
    font-size: 0.6rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.ai-selector-header i, .persona-menu-header i { color: #a78bfa; font-size: 0.65rem; }
.persona-menu-header i { color: #f472b6; }

.ai-provider-item, .persona-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    margin-bottom: 2px;
}
.ai-provider-item:hover, .persona-item:hover { background: rgba(124, 58, 237, 0.08); border-color: rgba(124, 58, 237, 0.2); }
.ai-provider-item.active, .persona-item.active { background: var(--gradient-soft); border-color: var(--border-bright); }
.persona-item.active { background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(124, 58, 237, 0.1)); border-color: rgba(236, 72, 153, 0.4); }
.ai-provider-item.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.ai-provider-icon, .persona-item-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #fff;
    flex-shrink: 0;
    font-weight: 700;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
.ai-provider-icon.groq { background: linear-gradient(135deg, #f97316, #ea580c); }
.ai-provider-icon.deepseek { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.ai-provider-icon.gemini { background: linear-gradient(135deg, #4285f4, #34a853); }
.ai-provider-icon.openai { background: linear-gradient(135deg, #10a37f, #0d8f6f); }
.ai-provider-icon.custom { background: linear-gradient(135deg, #71717a, #3f3f46); }
.ai-provider-icon.auto { background: var(--gradient-primary); background-size: 200% 200%; animation: gradientShift 4s ease infinite; }
.ai-provider-icon.claude { background: linear-gradient(135deg, #d97757, #c15f3c); }
.ai-provider-icon.router9 { background: linear-gradient(135deg, #3b82f6, #7c3aed); }
.persona-item-icon { background: linear-gradient(135deg, #ec4899, #8b5cf6); }

.ai-provider-info, .persona-item-info { flex: 1; min-width: 0; }
.ai-provider-name, .persona-item-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-provider-model, .persona-item-desc {
    font-size: 0.56rem;
    color: var(--text-3);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ai-provider-status { font-size: 0.52rem; font-weight: 700; padding: 2px 6px; border-radius: 8px; white-space: nowrap; flex-shrink: 0; }
.ai-provider-status.ok { background: rgba(10, 207, 131, 0.15); color: #0acf83; }
.ai-provider-status.busy { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* Quota Badge */
.quota-badge {
    padding: 6px 12px;
    background: rgba(10, 207, 131, 0.12);
    border: 1px solid rgba(10, 207, 131, 0.3);
    color: var(--accent-green);
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}
.quota-badge.warn { background: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.35); color: #fbbf24; }
.quota-badge.danger { background: rgba(236, 72, 153, 0.15); border-color: rgba(236, 72, 153, 0.35); color: #f472b6; }

/* Top Bar Buttons */
.top-bar-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
    transition: all 0.3s;
}
.top-bar-btn:hover { background: rgba(124, 58, 237, 0.18); color: #a78bfa; border-color: var(--border-bright); transform: translateY(-2px); }


/* ============================================
   6. CHAT AREA
   ============================================ */

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.6rem 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scroll-behavior: smooth;
    position: relative;
    z-index: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}
.chat-scroll::-webkit-scrollbar { width: 6px; }
.chat-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(124, 58, 237, 0.5), rgba(6, 182, 212, 0.5));
    border-radius: 6px;
}

/* Scroll FAB */
.scroll-bottom-fab {
    position: absolute;
    bottom: 140px;
    right: 24px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.5);
    opacity: 0;
    transform: translateY(20px) scale(0.8);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
}
.scroll-bottom-fab.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.scroll-bottom-fab:hover { transform: translateY(-3px) scale(1.08); }
.scroll-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ec4899;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    display: none;
    border: 2px solid var(--bg);
}

/* Welcome */
.welcome { text-align: center; padding: 2rem 1rem; margin: auto; max-width: 720px; }
.welcome-icon {
    width: 110px;
    height: 110px;
    margin: 0 auto 1.6rem;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #fff;
    box-shadow: 0 25px 70px rgba(124, 58, 237, 0.5);
    animation: floatIcon 4s ease-in-out infinite, gradientShift 6s ease infinite;
}
@keyframes floatIcon {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-12px) rotate(3deg); }
}
.welcome h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(1.6rem, 4vw, 2.3rem);
    margin-bottom: 0.8rem;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
    animation: gradientShift 6s ease infinite;
}
.welcome p {
    color: var(--text-2);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1.8rem;
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.8rem; max-width: 720px; margin: 0 auto; }
.suggestion-btn {
    padding: 16px 20px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text-2);
    font-size: 0.83rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.4s var(--ease-spring);
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: inherit;
    line-height: 1.5;
}
.suggestion-btn:hover { background: var(--glass-hover); border-color: var(--border-bright); color: var(--text); transform: translateY(-4px); }
.suggestion-btn i { color: #a78bfa; font-size: 1.05rem; flex-shrink: 0; width: 22px; text-align: center; }


/* ============================================
   7. MESSAGES
   ============================================ */

.message {
    display: flex;
    gap: 13px;
    max-width: 920px;
    width: 100%;
    margin: 0 auto;
    animation: msgIn 0.5s var(--ease-out);
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(15px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.message.user { flex-direction: row-reverse; }

.message-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    color: #fff;
    flex-shrink: 0;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.message.user .message-avatar { background: linear-gradient(135deg, #06b6d4, #3b82f6); }
.message.ai .message-avatar {
    background: var(--gradient-primary);
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
}

/* Body width behavior */
.message-body {
    max-width: calc(100% - 65px);
    min-width: 0;
    flex: none;
}
.message.user .message-body { flex: 0 1 auto; }
.message.ai .message-body { flex: 1 1 auto; }

.message-bubble {
    padding: 15px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    position: relative;
}
.message.user .message-bubble {
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: #fff;
    border-top-right-radius: 6px;
    white-space: pre-wrap;
    display: inline-block;
    max-width: 100%;
}
.message.ai .message-bubble {
    background: var(--glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    color: var(--text);
    border-top-left-radius: 6px;
    display: block;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.35);
    padding: 3px 7px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.2);
    word-break: break-word;
}
.message-bubble strong { color: #06b6d4; font-weight: 700; }
.message.user .message-bubble strong { color: #fff; }
.message-time {
    font-size: 0.65rem;
    color: var(--text-3);
    margin-top: 7px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.message.user .message-time { justify-content: flex-end; }
.message-model {
    font-size: 0.62rem;
    color: var(--text-3);
    opacity: 0.75;
    padding: 0 10px;
    margin-top: 3px;
    font-style: italic;
}

/* Markdown inside bubble */
.message-bubble h1.md-h1,
.message-bubble h2.md-h2,
.message-bubble h3.md-h3 {
    color: #a78bfa;
    margin: 16px 0 10px;
    font-weight: 700;
    line-height: 1.4;
    border-left: 3px solid #7c3aed;
    padding-left: 12px;
    font-family: 'Space Grotesk', sans-serif;
}
.message-bubble h1.md-h1 { font-size: 1.18rem; }
.message-bubble h2.md-h2 { font-size: 1.06rem; }
.message-bubble h3.md-h3 { font-size: 0.96rem; }
.message-bubble hr.md-hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-bright), transparent);
    margin: 16px 0;
}

.md-table-wrapper {
    overflow-x: auto;
    margin: 14px 0;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.25);
    -webkit-overflow-scrolling: touch;
}
.md-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 400px; }
.md-table thead { background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(6, 182, 212, 0.15)); }
.md-table th {
    padding: 11px 14px;
    text-align: left;
    font-weight: 700;
    color: #a78bfa;
    border-bottom: 2px solid rgba(124, 58, 237, 0.35);
    white-space: nowrap;
}
.md-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text-2); }

.md-ul, .md-ol { padding-left: 22px; margin: 10px 0; }
.md-ul { list-style: none; }
.md-ul .md-li { position: relative; padding-left: 18px; margin-bottom: 6px; line-height: 1.7; }
.md-ul .md-li::before { content: '▸'; position: absolute; left: 0; color: #a78bfa; font-weight: 700; }
.md-ol { list-style: none; counter-reset: md-ol-counter; }
.md-ol .md-li { position: relative; padding-left: 22px; margin-bottom: 6px; counter-increment: md-ol-counter; line-height: 1.7; }
.md-ol .md-li::before { content: counter(md-ol-counter) '.'; position: absolute; left: 0; color: #a78bfa; font-weight: 700; font-size: 0.85em; }

.message-bubble.streaming::after {
    content: '▋';
    color: #a78bfa;
    font-weight: 700;
    animation: blink 0.7s step-end infinite;
    margin-left: 2px;
    font-size: 1.1em;
}
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* Code Blocks */
.code-block-wrapper {
    margin: 14px 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid rgba(124, 58, 237, 0.3);
    background: rgba(0, 0, 0, 0.55);
}
.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(6, 182, 212, 0.15));
    border-bottom: 1px solid rgba(124, 58, 237, 0.25);
    gap: 10px;
    flex-wrap: wrap;
}
.code-block-lang {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #a78bfa;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Space Grotesk', monospace;
}
.code-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    color: #e2e8f0;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}
.code-copy-btn:hover { background: rgba(124, 58, 237, 0.25); color: #fff; }
.code-copy-btn.copied { background: linear-gradient(135deg, rgba(10, 207, 131, 0.3), rgba(5, 150, 105, 0.2)); color: #0acf83; }
.code-block-wrapper pre {
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    padding: 16px 18px !important;
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.65;
    color: #e2e8f0;
    font-family: 'Courier New', monospace;
    max-height: 500px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.code-block-wrapper pre code {
    background: none !important;
    padding: 0 !important;
    color: #e2e8f0 !important;
    border: none !important;
    font-size: inherit;
    white-space: pre;
    display: block;
}

/* Typing */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 16px 20px;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: 20px;
    border-top-left-radius: 6px;
    width: fit-content;
}
.typing-dot {
    width: 9px;
    height: 9px;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-10px) scale(1.15); opacity: 1; }
}

/* Message Actions */
.msg-actions {
    display: flex;
    gap: 5px;
    margin-top: 6px;
    padding: 0 8px;
    flex-wrap: wrap;
    opacity: 0;
    transition: opacity 0.3s;
}
.message:hover .msg-actions { opacity: 1; }
@media (hover: none), (max-width: 768px) {
    .message.ai .msg-actions { opacity: 1; }
}
.msg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-3);
    font-size: 0.62rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.msg-action-btn:hover { background: rgba(124, 58, 237, 0.2); color: #a78bfa; border-color: rgba(124, 58, 237, 0.4); }
.msg-action-btn i { font-size: 0.68rem; }
.msg-action-btn.feedback-btn.up.active {
    background: linear-gradient(135deg, rgba(10, 207, 131, 0.25), rgba(5, 150, 105, 0.15));
    color: #0acf83;
    border-color: rgba(10, 207, 131, 0.5);
    box-shadow: 0 0 15px rgba(10, 207, 131, 0.3);
}
.msg-action-btn.feedback-btn.down.active {
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.25), rgba(244, 114, 182, 0.15));
    color: #f472b6;
    border-color: rgba(236, 72, 153, 0.5);
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.3);
}
.msg-action-btn.feedback-btn:hover { transform: translateY(-2px); }
.message.user .msg-actions { justify-content: flex-end; }

/* Sources */
.sources-box {
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(59, 130, 246, 0.06);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 12px;
}
.sources-box-title {
    font-size: 0.66rem;
    color: #60a5fa;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.sources-list { display: flex; flex-direction: column; gap: 4px; }
.source-item {
    display: flex;
    gap: 8px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-2);
    font-size: 0.72rem;
    transition: all 0.2s;
    align-items: flex-start;
}
.source-item:hover { background: rgba(59, 130, 246, 0.1); color: var(--text); }
.source-num {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    font-weight: 700;
    font-size: 0.62rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.source-title {
    flex: 1;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.search-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 12px;
    font-size: 0.75rem;
    color: #60a5fa;
    margin-bottom: 8px;
    animation: msgIn 0.4s;
}

/* TTS */
.tts-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 12px;
    font-size: 0.7rem;
}
.tts-bar.playing { background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(6, 182, 212, 0.15)); border-color: rgba(124, 58, 237, 0.4); }
.tts-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.tts-btn:hover { background: rgba(124, 58, 237, 0.2); color: #a78bfa; }
.tts-btn.active { background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; border-color: transparent; }

/* Attachments in bubble */
.message-bubble .chat-image {
    max-width: 100%;
    max-height: 320px;
    border-radius: 12px;
    margin: 8px 0;
    cursor: pointer;
    display: block;
    border: 1px solid var(--border);
}
.message-bubble .chat-video {
    max-width: 100%;
    max-height: 320px;
    border-radius: 12px;
    margin: 8px 0;
    display: block;
    background: #000;
}
.message-bubble .chat-pdf {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(236, 72, 153, 0.1);
    border: 1px solid rgba(236, 72, 153, 0.3);
    border-radius: 12px;
    margin: 8px 0;
    text-decoration: none;
    color: inherit;
}
.message-bubble .chat-pdf i { color: #f472b6; font-size: 1.4rem; }
.message-bubble .chat-pdf-info { flex: 1; min-width: 0; }
.message-bubble .chat-pdf-name { font-size: 0.83rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-bubble .chat-pdf-size { font-size: 0.66rem; color: var(--text-3); }

/* Generated images */
.message-bubble .chat-generated-image {
    max-width: 100%;
    max-height: 500px;
    border-radius: 14px;
    margin: 8px 0;
    display: block;
    border: 1px solid rgba(124, 58, 237, 0.3);
    cursor: pointer;
}
.img-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.68rem;
    color: var(--text-3);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.img-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: rgba(124, 58, 237, 0.1);
    border-radius: 10px;
}
.img-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.img-action-btn {
    padding: 7px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    color: var(--text-2);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.img-action-btn.primary { background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; border-color: transparent; }
.img-loading {
    padding: 30px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 14px;
    border: 1px dashed rgba(124, 58, 237, 0.3);
}
.img-loading-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.5rem;
    animation: imgPulse 1.5s ease-in-out infinite;
}
@keyframes imgPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
.img-loading-text { font-size: 0.85rem; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.img-loading-sub { font-size: 0.72rem; color: var(--text-3); }

/* Disabled banner */
.disabled-banner {
    display: none;
    padding: 14px 22px;
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(244, 114, 182, 0.05));
    border: 1px solid rgba(236, 72, 153, 0.35);
    border-radius: 14px;
    color: #f472b6;
    font-size: 0.83rem;
    font-weight: 600;
    text-align: center;
    margin: 1rem auto;
    max-width: 720px;
}
.disabled-banner.show { display: block; }


/* ============================================
   8. INPUT AREA
   ============================================ */

.input-area {
    padding: 1rem 1.3rem 1.2rem;
    background: var(--glass);
    backdrop-filter: blur(30px);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}
.input-wrapper {
    max-width: 920px;
    margin: 0 auto;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 8px;
    transition: all 0.4s;
}
.input-wrapper:focus-within { border-color: var(--border-bright); box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1); }
.input-wrapper.disabled { opacity: 0.5; pointer-events: none; }

#aiInput {
    flex: 1;
    min-height: 28px;
    max-height: 170px;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    resize: none;
    padding: 10px 6px;
    line-height: 1.55;
}
#aiInput::placeholder { color: var(--text-3); }

.attach-btn, .voice-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s;
}
.attach-btn:hover { background: rgba(124, 58, 237, 0.18); color: #a78bfa; }
.voice-btn:hover { background: rgba(236, 72, 153, 0.18); color: #f472b6; }
.voice-btn.recording {
    background: linear-gradient(135deg, #ec4899, #f472b6);
    color: #fff;
    animation: pulseRecord 1s ease infinite;
}
@keyframes pulseRecord {
    0%, 100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.6); }
    50% { box-shadow: 0 0 0 12px rgba(236, 72, 153, 0); }
}
.image-btn {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(6, 182, 212, 0.1)) !important;
    border-color: rgba(124, 58, 237, 0.3) !important;
    color: #a78bfa !important;
}
.image-btn:hover { background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(6, 182, 212, 0.2)) !important; }

.web-search-btn, .memory-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s;
    position: relative;
}
.web-search-btn:hover { background: rgba(59, 130, 246, 0.18); color: #60a5fa; }
.web-search-btn.active { background: linear-gradient(135deg, #3b82f6, #06b6d4); color: #fff; border-color: transparent; box-shadow: 0 0 15px rgba(59, 130, 246, 0.5); }
.memory-btn:hover { background: rgba(124, 58, 237, 0.18); color: #a78bfa; }
.memory-btn.active { background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; border-color: transparent; box-shadow: 0 0 15px rgba(124, 58, 237, 0.6); }
.memory-btn.locked { opacity: 0.45; cursor: not-allowed; }
.memory-btn.locked::after {
    content: '\f023';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    bottom: -1px;
    right: -1px;
    font-size: 0.5rem;
    background: #f59e0b;
    color: #000;
    padding: 2px;
    border-radius: 50%;
    width: 15px;
    height: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg);
}

.send-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    border: none;
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4);
    animation: gradientShift 5s ease infinite;
    transition: all 0.3s;
}
.send-btn:hover:not(:disabled) { transform: scale(1.1) rotate(8deg); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; background: var(--card); box-shadow: none; animation: none; }
.send-btn.stop-mode {
    background: linear-gradient(135deg, #ec4899, #f472b6);
    animation: pulseStop 1.5s ease-in-out infinite;
}
@keyframes pulseStop {
    0%, 100% { box-shadow: 0 8px 25px rgba(236, 72, 153, 0.4); }
    50% { box-shadow: 0 8px 35px rgba(236, 72, 153, 0.8), 0 0 0 8px rgba(236, 72, 153, 0.1); }
}

.input-hint {
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-3);
    margin-top: 10px;
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.input-hint kbd {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 6px;
    font-family: 'Space Grotesk', monospace;
    font-size: 0.65rem;
    color: var(--text-2);
    font-weight: 600;
}

/* Attachment Preview */
.attachment-preview {
    display: none;
    max-width: 920px;
    margin: 0 auto 10px;
    padding: 12px 14px;
    background: var(--glass);
    border: 1px solid var(--border-bright);
    border-radius: 16px;
}
.attachment-preview.show { display: flex; gap: 14px; align-items: center; }
.attachment-preview-thumb {
    width: 62px;
    height: 62px;
    border-radius: 12px;
    overflow: hidden;
    flex-shrink: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.attachment-preview-thumb img,
.attachment-preview-thumb video { width: 100%; height: 100%; object-fit: cover; }
.attachment-preview-thumb .video-icon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #fff; font-size: 1.4rem; }
.attachment-preview-thumb .pdf-icon { font-size: 2rem; color: #f472b6; }
.attachment-preview-info { flex: 1; min-width: 0; }
.attachment-preview-info .name { font-size: 0.83rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.attachment-preview-info .size { font-size: 0.68rem; color: var(--text-3); }
.attachment-preview-remove {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(236, 72, 153, 0.15);
    border: 1px solid rgba(236, 72, 153, 0.35);
    color: #f472b6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

/* Voice Status */
.voice-status {
    display: none;
    max-width: 920px;
    margin: 0 auto 10px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.15), rgba(244, 114, 182, 0.05));
    border: 1px solid rgba(236, 72, 153, 0.35);
    border-radius: 16px;
    align-items: center;
    gap: 14px;
}
.voice-status.show { display: flex; }
.voice-pulse { width: 14px; height: 14px; background: #ec4899; border-radius: 50%; animation: pulseVoice 1s ease-in-out infinite; flex-shrink: 0; }
@keyframes pulseVoice { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.3); opacity: 0.8; } }
.voice-text { flex: 1; font-size: 0.86rem; font-weight: 600; color: #f472b6; }
.voice-timer { font-size: 0.86rem; font-weight: 700; color: #ec4899; font-variant-numeric: tabular-nums; font-family: 'Space Grotesk', monospace; }
.voice-stop-btn {
    padding: 9px 18px;
    background: linear-gradient(135deg, #ec4899, #f472b6);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}


/* ============================================
   9. MODALS & OVERLAYS
   ============================================ */

/* Toast */
.ai-toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%) translateY(30px) scale(0.9);
    background: var(--glass);
    backdrop-filter: blur(30px);
    color: #fff;
    padding: 14px 26px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: all 0.5s var(--ease-spring);
    border: 1px solid var(--border-bright);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    max-width: calc(100vw - 30px);
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
.ai-toast.error { border-color: rgba(236, 72, 153, 0.5); color: #f472b6; }
.ai-toast.success { border-color: rgba(10, 207, 131, 0.5); color: #0acf83; }

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 150;
}
.sidebar-overlay.active { display: block; }

/* Confirm Dialog */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(15px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.confirm-overlay.active { display: flex; }
.confirm-box {
    background: var(--glass);
    border: 1px solid var(--border-bright);
    border-radius: 22px;
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
}
.confirm-box i { font-size: 2.5rem; color: #ec4899; margin-bottom: 1rem; display: block; }
.confirm-box h3 { font-size: 1.1rem; margin-bottom: 0.6rem; font-family: 'Space Grotesk', sans-serif; }
.confirm-box p { color: var(--text-2); font-size: 0.86rem; margin-bottom: 1.5rem; line-height: 1.6; }
.confirm-actions { display: flex; gap: 0.7rem; }
.confirm-btn { flex: 1; padding: 12px; border-radius: 12px; border: none; font-weight: 700; font-size: 0.85rem; cursor: pointer; font-family: inherit; }
.confirm-btn.cancel { background: var(--card); color: var(--text-2); border: 1px solid var(--border); }
.confirm-btn.danger { background: linear-gradient(135deg, #ec4899, #f472b6); color: #fff; }

/* Lightbox */
.image-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.97);
    backdrop-filter: blur(15px);
    z-index: 3000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.image-lightbox.active { display: flex; }
.image-lightbox img { max-width: 100%; max-height: 100%; border-radius: 14px; }
.image-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

/* Image Gen Modal */
.img-gen-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    z-index: 4000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
}
.img-gen-modal.active { display: flex; }
.img-gen-content {
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 24px;
    padding: 1.8rem;
    max-width: 520px;
    width: 100%;
    position: relative;
    max-height: 92vh;
    overflow-y: auto;
}
.img-gen-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-2);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: inherit;
}
.img-gen-close:hover { background: #ec4899; color: #fff; transform: rotate(90deg); }
.img-gen-header { display: flex; gap: 14px; align-items: center; margin-bottom: 1.5rem; padding-right: 2.5rem; }
.img-gen-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
}
.img-gen-header h2 { font-family: 'Space Grotesk', sans-serif; font-size: 1.15rem; font-weight: 700; margin-bottom: 3px; color: var(--text); }
.img-gen-header p { font-size: 0.78rem; color: var(--text-3); }
.img-gen-body { display: flex; flex-direction: column; gap: 1rem; }
.img-gen-field label { display: block; font-size: 0.75rem; color: var(--text-2); margin-bottom: 6px; font-weight: 600; }
.img-gen-field textarea,
.img-gen-field select {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: var(--text);
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
}
.img-gen-field textarea:focus,
.img-gen-field select:focus { border-color: #8b5cf6; }
.img-gen-charcount { text-align: right; font-size: 0.68rem; color: var(--text-3); margin-top: 4px; }
.img-gen-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.img-gen-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}
.img-gen-preset-label { font-size: 0.68rem; color: var(--text-3); font-weight: 700; text-transform: uppercase; margin-right: 4px; }
.img-preset-btn {
    padding: 6px 12px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 20px;
    color: #a78bfa;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.img-preset-btn:hover { background: rgba(124, 58, 237, 0.25); }
.img-gen-footer { display: flex; gap: 0.6rem; margin-top: 1.5rem; }
.img-gen-btn {
    flex: 1;
    padding: 13px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.img-gen-btn.ghost { background: rgba(255, 255, 255, 0.04); color: var(--text-2); border: 1px solid rgba(255, 255, 255, 0.08); }
.img-gen-btn.primary { background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; }

/* Edit Modal */
.edit-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    z-index: 4500;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.edit-modal.active { display: flex; }
.edit-modal-content {
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 22px;
    padding: 1.6rem;
    max-width: 600px;
    width: 100%;
    position: relative;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.edit-modal-header { display: flex; align-items: center; gap: 12px; margin-bottom: 1.2rem; padding-right: 2rem; }
.edit-modal-header i {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.edit-modal-header h3 { font-family: 'Space Grotesk', sans-serif; font-size: 1.05rem; font-weight: 700; }
.edit-modal-header p { font-size: 0.75rem; color: var(--text-3); margin-top: 2px; }
.edit-modal textarea {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    outline: none;
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}
.edit-modal textarea:focus { border-color: #8b5cf6; }
.edit-modal-footer { display: flex; gap: 0.6rem; margin-top: 1.2rem; }
.edit-modal-btn {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.edit-modal-btn.cancel { background: rgba(255, 255, 255, 0.05); color: var(--text-2); border: 1px solid rgba(255, 255, 255, 0.1); }
.edit-modal-btn.save { background: linear-gradient(135deg, #7c3aed, #06b6d4); color: #fff; }
.edit-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-2);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: inherit;
}
.edit-modal-close:hover { background: #ec4899; color: #fff; transform: rotate(90deg); }

/* Export Menu */
.export-wrapper { position: relative; }
.export-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 180px;
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    backdrop-filter: blur(30px);
    border: 1px solid var(--border-bright);
    border-radius: 12px;
    padding: 5px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
    z-index: 9999;
}
.export-menu.active { display: block; }
.export-menu-header {
    padding: 6px 8px;
    font-size: 0.6rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.export-menu-header i { color: #a78bfa; font-size: 0.65rem; }
.export-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
}
.export-item:hover { background: rgba(124, 58, 237, 0.15); color: #a78bfa; }
.export-item i { width: 16px; text-align: center; font-size: 0.8rem; flex-shrink: 0; }
.export-item.json i { color: #f59e0b; }
.export-item.markdown i { color: #3b82f6; }
.export-item.txt i { color: #a78bfa; }
.export-item.pdf i { color: #dc2626; }
.export-item.img i { color: #ec4899; }

/* Prompt Drawer */
.prompt-drawer { display: none; position: fixed; inset: 0; z-index: 4000; }
.prompt-drawer.open { display: block; }
.prompt-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    animation: drawerFadeIn 0.3s ease;
}
@keyframes drawerFadeIn { from { opacity: 0; } to { opacity: 1; } }
.prompt-drawer-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    border-left: 1px solid var(--border-bright);
    display: flex;
    flex-direction: column;
    animation: drawerSlideIn 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.7);
}
@keyframes drawerSlideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.prompt-drawer-header {
    padding: 1.2rem 1.4rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.prompt-drawer-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}
.prompt-drawer-title i { color: #0acf83; }
.prompt-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    line-height: 1;
    transition: all 0.3s;
}
.prompt-drawer-close:hover { background: #ec4899; color: #fff; transform: rotate(90deg); }
.prompt-drawer-body { flex: 1; overflow-y: auto; padding: 1.2rem 1.4rem; }
.prompt-drawer-body::-webkit-scrollbar { width: 5px; }
.prompt-drawer-body::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.4); border-radius: 5px; }
.prompt-form {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1.2rem;
}
.prompt-form h4 {
    font-size: 0.82rem;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #0acf83;
    font-family: 'Space Grotesk', sans-serif;
}
.prompt-input {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    transition: all 0.3s;
    resize: vertical;
}
.prompt-input:focus { border-color: #0acf83; background: rgba(10, 207, 131, 0.04); }
.prompt-input::placeholder { color: var(--text-3); }
.prompt-add-btn {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    background: linear-gradient(135deg, #0acf83, #3b82f6);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}
.prompt-add-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(10, 207, 131, 0.4); }
.prompt-list { display: flex; flex-direction: column; gap: 8px; }
.prompt-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    transition: all 0.3s;
}
.prompt-item:hover { border-color: rgba(10, 207, 131, 0.3); background: rgba(10, 207, 131, 0.04); }
.prompt-item-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 6px; }
.prompt-item-title { font-size: 0.82rem; font-weight: 700; color: var(--text); flex: 1; word-break: break-word; }
.prompt-item-delete {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(236, 72, 153, 0.1);
    border: none;
    color: #f472b6;
    cursor: pointer;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s;
}
.prompt-item-delete:hover { background: #ec4899; color: #fff; transform: scale(1.1); }
.prompt-item-content {
    font-size: 0.74rem;
    color: var(--text-2);
    line-height: 1.5;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.prompt-item-use {
    padding: 6px 12px;
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    color: #a78bfa;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.prompt-item-use:hover { background: rgba(124, 58, 237, 0.3); color: #fff; }
.prompt-empty { text-align: center; padding: 2rem 1rem; color: var(--text-3); font-size: 0.8rem; }
.prompt-empty i { font-size: 2.5rem; opacity: 0.3; display: block; margin-bottom: 0.8rem; color: #0acf83; }

/* Upgrade Modal */
.upgrade-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
}
.upgrade-modal.open { display: flex; }
.upgrade-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
    animation: drawerFadeIn 0.3s ease;
}
.upgrade-modal-content {
    position: relative;
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 24px;
    padding: 2rem;
    max-width: 700px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    animation: upgradeModalIn 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
    box-shadow: 0 30px 80px rgba(124, 58, 237, 0.4);
}
@keyframes upgradeModalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.upgrade-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    line-height: 1;
    transition: all 0.3s;
}
.upgrade-modal-close:hover { background: #ec4899; color: #fff; transform: rotate(90deg); }
.upgrade-modal-title {
    text-align: center;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.4rem;
    animation: gradientShift 5s ease infinite;
    padding-right: 2rem;
}
.upgrade-modal-subtitle { text-align: center; color: var(--text-2); font-size: 0.85rem; margin-bottom: 1.5rem; }
.upgrade-plans-grid { display: grid; grid-template-columns: 1fr; gap: 0.8rem; }
@media (min-width: 600px) { .upgrade-plans-grid { grid-template-columns: repeat(3, 1fr); } }
.upgrade-plan-card {
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem;
    text-align: center;
    transition: all 0.3s;
    position: relative;
}
.upgrade-plan-card.featured { border-color: rgba(124, 58, 237, 0.5); background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(236, 72, 153, 0.05)); }
.upgrade-plan-card.current { border-color: rgba(10, 207, 131, 0.6); background: rgba(10, 207, 131, 0.08); }
.upgrade-plan-card:hover:not(.current) { transform: translateY(-4px); box-shadow: 0 15px 40px rgba(124, 58, 237, 0.3); }
.upgrade-plan-name { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 800; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 1px; }
.upgrade-plan-card.free .upgrade-plan-name { color: #a0aec0; }
.upgrade-plan-card.pro .upgrade-plan-name { color: #60a5fa; }
.upgrade-plan-card.premium .upgrade-plan-name { color: #fbbf24; }
.upgrade-plan-price { font-size: 1.4rem; font-weight: 900; color: var(--text); margin-bottom: 4px; }
.upgrade-plan-price small { font-size: 0.65rem; color: var(--text-3); font-weight: 500; }
.upgrade-plan-features { list-style: none; text-align: left; margin: 1rem 0; padding: 0; font-size: 0.72rem; color: var(--text-2); line-height: 1.8; }
.upgrade-plan-features li { display: flex; align-items: flex-start; gap: 6px; }
.upgrade-plan-features i { color: #0acf83; font-size: 0.7rem; margin-top: 4px; flex-shrink: 0; }
.upgrade-plan-features li.disabled { color: var(--text-3); text-decoration: line-through; opacity: 0.6; }
.upgrade-plan-features li.disabled i { color: #718096; }
.upgrade-plan-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #0acf83, #3b82f6);
    border: none;
    border-radius: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
}
.upgrade-plan-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(10, 207, 131, 0.4); }
.upgrade-plan-btn:disabled { background: rgba(255, 255, 255, 0.06); color: var(--text-3); cursor: not-allowed; }
.upgrade-plan-btn.premium-btn { background: linear-gradient(135deg, #ec4899, #f59e0b); }
.upgrade-plan-btn.pro-btn { background: linear-gradient(135deg, #3b82f6, #7c3aed); }

/* PWA Banner */
.pwa-banner {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    backdrop-filter: blur(30px);
    border: 1px solid var(--border-bright);
    border-radius: 20px;
    padding: 16px 20px;
    z-index: 9000;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
    max-width: min(420px, calc(100vw - 30px));
    transition: transform 0.6s var(--ease-spring), opacity 0.4s;
}
.pwa-banner.show { display: flex; gap: 14px; align-items: center; transform: translateX(-50%) translateY(0); }
.pwa-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 14px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    box-shadow: 0 8px 25px rgba(124, 58, 237, 0.5);
}
.pwa-info { flex: 1; min-width: 0; }
.pwa-info strong { display: block; font-size: 0.88rem; color: var(--text); font-weight: 700; margin-bottom: 3px; font-family: 'Space Grotesk', sans-serif; }
.pwa-info span { display: block; font-size: 0.72rem; color: var(--text-2); line-height: 1.4; }
.pwa-actions { display: flex; gap: 6px; flex-shrink: 0; }
.pwa-btn { padding: 8px 14px; border-radius: 10px; border: none; font-weight: 700; font-size: 0.75rem; cursor: pointer; font-family: inherit; }
.pwa-btn.install { background: var(--gradient-primary); color: #fff; box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4); }
.pwa-btn.later { background: rgba(255, 255, 255, 0.05); color: var(--text-3); border: 1px solid rgba(255, 255, 255, 0.1); }

/* Shortcuts Modal */
.shortcuts-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.shortcuts-modal.active { display: flex; }
.shortcuts-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(15px);
}
.shortcuts-modal-content {
    position: relative;
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    border: 1px solid var(--border-bright);
    border-radius: 24px;
    padding: 2rem;
    max-width: 560px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    animation: shortcutsIn 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
    box-shadow: 0 30px 80px rgba(124, 58, 237, 0.4);
}
@keyframes shortcutsIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.shortcuts-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    line-height: 1;
    transition: all 0.3s;
}
.shortcuts-modal-close:hover { background: #ec4899; color: #fff; transform: rotate(90deg); }
.shortcuts-modal-content h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 5s ease infinite;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 2rem;
}
.shortcut-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.shortcut-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.82rem;
    gap: 10px;
}
.shortcut-item span { color: var(--text-2); }
.shortcut-item kbd {
    background: rgba(124, 58, 237, 0.15);
    border: 1px solid rgba(124, 58, 237, 0.3);
    color: #a78bfa;
    padding: 3px 9px;
    border-radius: 6px;
    font-family: 'Space Grotesk', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    margin: 0 2px;
}

/* Drop Overlay */
.drop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(124, 58, 237, 0.15);
    backdrop-filter: blur(20px);
    z-index: 9998;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.drop-overlay.active { display: flex; animation: dropFadeIn 0.2s ease; }
@keyframes dropFadeIn { from { opacity: 0; } to { opacity: 1; } }
.drop-overlay-content {
    text-align: center;
    color: #fff;
    padding: 3rem 4rem;
    border: 3px dashed rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    background: rgba(124, 58, 237, 0.2);
}
.drop-overlay-content i {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
    color: #a78bfa;
    animation: dropBounce 1.5s ease-in-out infinite;
}
@keyframes dropBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.drop-overlay-content h3 { font-size: 1.3rem; font-family: 'Space Grotesk', sans-serif; margin-bottom: 0.4rem; }
.drop-overlay-content p { color: rgba(255, 255, 255, 0.7); font-size: 0.9rem; }

/* Model Context Menu */
.model-context-menu button { font-family: inherit; }


/* ============================================
   10. SPRINT 1 FEATURES
   ============================================ */

/* Camera Button */
.camera-btn {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(6, 182, 212, 0.1)) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
    color: #60a5fa !important;
}
.camera-btn:hover { background: linear-gradient(135deg, rgba(59, 130, 246, 0.3), rgba(6, 182, 212, 0.2)) !important; }

/* Camera Modal */
.camera-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 5000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.25s ease;
}
.camera-modal.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.camera-modal-content {
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 22px;
    padding: 1.2rem;
    max-width: 720px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9);
    animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalSlideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.camera-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
}
.camera-modal-header i {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.camera-modal-header h3 { flex: 1; font-family: 'Space Grotesk', sans-serif; font-size: 1.05rem; font-weight: 700; }
.camera-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: all 0.3s;
}
.camera-close:hover { background: #ec4899; color: #fff; transform: rotate(90deg); }
#cameraVideo {
    width: 100%;
    max-height: 65vh;
    border-radius: 14px;
    background: #000;
    object-fit: cover;
    display: block;
}
.camera-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
}
.camera-cancel {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: inherit;
}
.camera-capture {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    border: 4px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.5);
    transition: all 0.2s;
}
.camera-capture:active { transform: scale(0.92); }
.camera-switch {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}
.camera-switch:hover { background: rgba(124, 58, 237, 0.3); }

/* Chat Search Bar */
.chat-search-bar {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 1.3rem;
    background: var(--glass);
    backdrop-filter: blur(30px);
    border-bottom: 1px solid var(--border);
    animation: searchBarSlideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 50;
    flex-shrink: 0;
}
.chat-search-bar.active { display: flex; }
@keyframes searchBarSlideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-search-bar > i.fa-search { color: var(--text-3); font-size: 0.85rem; flex-shrink: 0; }
.chat-search-bar input {
    flex: 1;
    padding: 8px 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
    min-width: 0;
}
.chat-search-bar input:focus { border-color: var(--border-bright); background: rgba(124, 58, 237, 0.06); }
.chat-search-count {
    font-size: 0.7rem;
    color: var(--text-3);
    font-weight: 600;
    min-width: 40px;
    text-align: center;
    font-family: 'Space Grotesk', monospace;
}
.chat-search-nav {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-family: inherit;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-search-nav:hover { background: rgba(124, 58, 237, 0.2); color: #a78bfa; border-color: var(--border-bright); }
.chat-search-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(236, 72, 153, 0.1);
    border: 1px solid rgba(236, 72, 153, 0.25);
    color: #f472b6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-family: inherit;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-search-close:hover { background: #ec4899; color: #fff; }
.chat-search-highlight {
    background: rgba(251, 191, 36, 0.35);
    color: #fbbf24;
    padding: 1px 3px;
    border-radius: 3px;
    font-weight: 700;
    border: 1px solid rgba(251, 191, 36, 0.4);
}
.message.search-active {
    background: rgba(251, 191, 36, 0.06);
    border-radius: 20px;
    padding: 4px;
    margin: -4px 0;
    transition: background 0.3s;
}
.message.search-active .message-bubble {
    border-color: rgba(251, 191, 36, 0.5) !important;
    box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.15);
}

/* Undo Toast */
.undo-toast {
    position: fixed;
    bottom: calc(110px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(30px) scale(0.9);
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    backdrop-filter: blur(30px);
    color: #fff;
    padding: 12px 14px 12px 20px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 10000;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid rgba(236, 72, 153, 0.4);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    max-width: calc(100vw - 30px);
    display: flex;
    align-items: center;
    gap: 10px;
}
.undo-toast.show { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); pointer-events: auto; }
.undo-toast > i { color: #f472b6; font-size: 1rem; flex-shrink: 0; }
.undo-toast > span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.undo-btn {
    padding: 6px 14px;
    background: linear-gradient(135deg, #0acf83, #3b82f6);
    border: none;
    border-radius: 20px;
    color: #fff;
    font-weight: 700;
    font-size: 0.78rem;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    transition: transform 0.2s;
}
.undo-btn:hover { transform: scale(1.05); }
.undo-btn:active { transform: scale(0.95); }


/* ============================================
   10.1 MEMORY VIEWER MODAL (Extra Fix)
   ============================================ */

.memory-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 4600;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
}
.memory-modal.active { display: flex; }

.memory-modal-content {
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 22px;
    padding: 1.6rem;
    max-width: 640px;
    width: 100%;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 30px 80px rgba(124, 58, 237, 0.35);
    animation: memoryModalIn 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
}
@keyframes memoryModalIn {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.memory-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.memory-modal-header h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}
.memory-modal-header h3 i { color: #a78bfa; }
.memory-count {
    font-size: 0.75rem;
    color: var(--text-3);
    font-weight: 500;
    margin-left: 4px;
}
.memory-modal-close {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-2);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: inherit;
    transition: all 0.3s var(--ease-spring);
}
.memory-modal-close:hover {
    background: #ec4899;
    color: #fff;
    transform: rotate(90deg) scale(1.05);
}

.memory-modal-info {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(139, 92, 246, 0.08);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 12px;
    color: #c4b5fd;
    font-size: 0.76rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    flex-shrink: 0;
}
.memory-modal-info i { color: #a78bfa; margin-top: 2px; flex-shrink: 0; }

.memory-modal-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 6px;
    margin-bottom: 1rem;
}
.memory-modal-list::-webkit-scrollbar { width: 5px; }
.memory-modal-list::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.4);
    border-radius: 5px;
}

.memory-modal-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
}
.memory-btn-danger {
    padding: 10px 18px;
    background: rgba(236, 72, 153, 0.15);
    border: 1px solid rgba(236, 72, 153, 0.35);
    color: #f472b6;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}
.memory-btn-danger:hover {
    background: #ec4899;
    color: #fff;
    transform: translateY(-2px);
}

.memory-loading {
    padding: 2rem;
    text-align: center;
    color: var(--text-3);
    font-size: 0.85rem;
}
.memory-loading i { color: #a78bfa; margin-right: 8px; }

.memory-empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-3);
    font-size: 0.85rem;
}
.memory-empty i {
    font-size: 2.5rem;
    opacity: 0.3;
    display: block;
    margin-bottom: 0.8rem;
    color: #a78bfa;
}
.memory-empty p { margin-bottom: 4px; font-weight: 600; color: var(--text-2); }
.memory-empty small { font-size: 0.72rem; color: var(--text-3); }

.memory-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    transition: all 0.2s;
}
.memory-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(139, 92, 246, 0.35);
}
.memory-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.memory-item-rank {
    font-size: 0.65rem;
    font-weight: 800;
    color: #a78bfa;
    background: rgba(139, 92, 246, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}
.memory-item-time {
    font-size: 0.68rem;
    color: var(--text-3);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.memory-item-delete {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(236, 72, 153, 0.1);
    border: none;
    color: #f472b6;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    font-family: inherit;
}
.memory-item-delete:hover {
    background: #ec4899;
    color: #fff;
    transform: scale(1.1);
}
.memory-item-q,
.memory-item-a {
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-2);
    word-break: break-word;
    margin-bottom: 4px;
}
.memory-item-q strong { color: #06b6d4; margin-right: 4px; }
.memory-item-a strong { color: #a78bfa; margin-right: 4px; }


/* ============================================
   10.2 UPLOAD PROGRESS OVERLAY (Extra Fix)
   ============================================ */

.upload-progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 5500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.25s ease;
}

.upload-progress-box {
    background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98));
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 20px;
    padding: 2rem 2rem 1.6rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8);
    animation: uploadBoxIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes uploadBoxIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.upload-progress-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.6rem;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.5);
    animation: gradientShift 4s ease infinite, uploadPulse 2s ease-in-out infinite;
}
@keyframes uploadPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

.upload-progress-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    word-break: break-all;
    line-height: 1.4;
    padding: 0 4px;
}

.upload-progress-bar-wrap {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 10px;
}
.upload-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--gradient-primary);
    background-size: 200% 100%;
    border-radius: 8px;
    transition: width 0.3s ease;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.5);
    animation: gradientShift 3s ease infinite;
}

.upload-progress-text {
    font-size: 0.78rem;
    color: var(--text-2);
    font-weight: 600;
}
.upload-progress-percent {
    color: #a78bfa;
    font-weight: 800;
    font-family: 'Space Grotesk', monospace;
    font-size: 0.85rem;
    margin-left: 4px;
}


/* ============================================
   11. iOS SAFE AREA
   ============================================ */

@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    .top-bar { padding-top: calc(0.9rem + env(safe-area-inset-top)); }
    .input-area { padding-bottom: calc(1.2rem + env(safe-area-inset-bottom)); }
    .ai-toast { bottom: calc(110px + env(safe-area-inset-bottom)); }
    .scroll-bottom-fab { bottom: calc(140px + env(safe-area-inset-bottom)); }
    .pwa-banner { bottom: calc(20px + env(safe-area-inset-bottom)); }
}


/* ============================================
   12. TOUCH TARGETS
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    .top-bar-btn,
    .sidebar-footer-btn,
    .attach-btn,
    .voice-btn,
    .web-search-btn,
    .memory-btn,
    .send-btn,
    .mobile-menu-btn,
    .img-preset-btn,
    .search-tab,
    .export-item,
    .ai-provider-item,
    .persona-item,
    .history-item,
    .suggestion-btn,
    .upgrade-plan-btn,
    .prompt-item-use,
    .prompt-item-delete,
    .prompt-add-btn,
    .pwa-btn,
    .confirm-btn,
    .edit-modal-btn,
    .img-gen-btn {
        touch-action: manipulation;
    }
    .top-bar-btn:active,
    .sidebar-footer-btn:active,
    .attach-btn:active,
    .voice-btn:active,
    .send-btn:active {
        transform: scale(0.92);
        transition: transform 0.1s;
    }
}


/* ============================================
   13. RESPONSIVE — TABLET (max 1024px)
   ============================================ */

@media (max-width: 1024px) {
    :root { --sidebar-w: 260px; }
    .chat-scroll { padding: 1.3rem 1rem; }
    .message { max-width: 100%; }
}


/* ============================================
   14. RESPONSIVE — MOBILE (max 768px)
   ============================================ */

@media (max-width: 768px) {
    :root {
        --sidebar-w: 88vw;
        --sidebar-max: 340px;
    }

    /* ----- SIDEBAR (slide from left) ----- */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: min(var(--sidebar-w), var(--sidebar-max));
        transform: translateX(-100%);
        box-shadow: 15px 0 50px rgba(0, 0, 0, 0.7);
        will-change: transform;
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-header { padding-top: calc(1.3rem + env(safe-area-inset-top)); }
    .sidebar-footer { padding-bottom: calc(0.8rem + env(safe-area-inset-bottom)); }

    /* ----- MOBILE MENU BTN ----- */
    .mobile-menu-btn {
        display: flex;
        width: 42px;
        height: 42px;
        border-radius: 12px;
        font-size: 1.05rem;
    }

    /* ----- TOP BAR ----- */
    .top-bar {
        padding: 0.65rem 0.75rem;
        gap: 5px;
        min-height: 58px;
    }
    .top-bar-left { gap: 8px; flex: 1; min-width: 0; }
    .chat-title-wrap { min-width: 0; flex: 1; gap: 4px; }
    .chat-title {
        font-size: 0.88rem;
        max-width: calc(100vw - 260px);
        font-weight: 700;
    }
    .chat-status-mini { display: none; }
    .top-bar-right { gap: 4px; flex-shrink: 0; }
    .top-bar-btn {
        width: 38px;
        height: 38px;
        font-size: 0.88rem;
        border-radius: 10px;
    }
    /* Sembunyikan tombol non-esensial di mobile */
    .top-bar-btn-home,
    #copyFullChatBtn { display: none !important; }

    /* Persona + AI selector compact */
    .persona-selector-btn,
    .ai-selector-btn {
        padding: 6px 8px;
        font-size: 0.66rem;
        max-width: 90px;
        border-radius: 9px;
        gap: 4px;
    }
    .persona-selector-btn { max-width: 80px; }
    .persona-name {
        max-width: 44px;
        font-size: 0.66rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .ai-selector-label {
        max-width: 52px;
        font-size: 0.66rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .ai-selector-model { display: none; }
    .ai-selector-arrow, .persona-arrow { font-size: 0.55rem; }

    .quota-badge {
        padding: 6px 8px;
        font-size: 0.6rem;
        gap: 3px;
        border-radius: 12px;
    }
    .quota-badge i { font-size: 0.65rem; }

    /* ----- BOTTOM SHEET (reparent by JS) ----- */
    .ai-selector-menu,
    .persona-menu {
        display: none;
    }
    .ai-selector-menu.mobile-menu,
    .persona-menu.mobile-menu {
        display: none;
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
        padding: 12px 12px calc(20px + env(safe-area-inset-bottom)) !important;
        background: linear-gradient(135deg, rgba(25, 30, 50, 0.98), rgba(15, 20, 35, 0.98)) !important;
        backdrop-filter: blur(30px) !important;
        -webkit-backdrop-filter: blur(30px) !important;
        box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.85) !important;
        border: none !important;
        border-top: 1px solid rgba(139, 92, 246, 0.4) !important;
        z-index: 99999 !important;
        transform: translateY(0) !important;
        animation: sheetSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
        overscroll-behavior: contain;
    }
    .ai-selector-menu.mobile-menu.open,
    .persona-menu.mobile-menu.open { display: block !important; }
    @keyframes sheetSlideUp {
        from { transform: translateY(100%); opacity: 0.5; }
        to { transform: translateY(0); opacity: 1; }
    }
    .ai-selector-menu.mobile-menu::before,
    .persona-menu.mobile-menu::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.35);
        border-radius: 2px;
        margin: 0 auto 14px;
    }
    body.menu-open { overflow: hidden !important; }
    body.menu-open::after {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.75);
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        z-index: 99998;
        animation: fadeIn 0.25s ease;
    }
    .ai-selector-menu.mobile-menu .ai-provider-item,
    .persona-menu.mobile-menu .persona-item {
        padding: 12px 14px !important;
        border-radius: 12px !important;
        margin-bottom: 4px;
        min-height: 52px;
    }
    .ai-selector-menu.mobile-menu .ai-selector-header,
    .persona-menu.mobile-menu .persona-menu-header {
        padding: 8px 10px;
        font-size: 0.68rem;
    }

    /* ----- CHAT SCROLL ----- */
    .chat-scroll {
        padding: 1rem 0.85rem 0.5rem;
        gap: 0.8rem;
    }

    /* ----- WELCOME ----- */
    .welcome { padding: 1.2rem 0.5rem; margin: auto; max-width: 100%; }
    .welcome-icon { width: 84px; height: 84px; font-size: 2.2rem; margin-bottom: 1rem; }
    .welcome h1 { font-size: 1.35rem; margin-bottom: 0.5rem; line-height: 1.3; }
    .welcome p { font-size: 0.88rem; line-height: 1.6; margin-bottom: 1.3rem; padding: 0 0.5rem; }
    .suggestions { grid-template-columns: 1fr; gap: 0.5rem; padding: 0 0.25rem; }
    .suggestion-btn {
        padding: 14px 16px;
        font-size: 0.82rem;
        border-radius: 14px;
        gap: 12px;
        line-height: 1.4;
    }
    .suggestion-btn i { font-size: 1rem; width: 22px; }

    /* ----- MESSAGES ----- */
    .message { gap: 10px; max-width: 100%; width: 100%; }
    .message-avatar { width: 36px; height: 36px; font-size: 0.9rem; }
    .message-body { max-width: calc(100% - 46px); min-width: 0; flex: none; }
    .message.user .message-body { flex: 0 1 auto; }
    .message.ai .message-body { flex: 1 1 auto; }
    .message-bubble {
        padding: 12px 15px;
        font-size: 0.86rem;
        line-height: 1.65;
        border-radius: 18px;
    }
    .message.user .message-bubble { border-top-right-radius: 5px; display: inline-block; max-width: 100%; }
    .message.ai .message-bubble { border-top-left-radius: 5px; display: block; }
    .message-time { font-size: 0.62rem; margin-top: 6px; padding: 0 6px; }
    .message-model { font-size: 0.6rem; padding: 0 6px; }

    /* Actions compact */
    .message.ai .msg-actions {
        opacity: 1;
        gap: 6px;
        padding: 0 4px;
        margin-top: 8px;
        flex-wrap: wrap;
    }
    .msg-action-btn {
        min-height: 32px !important;
        padding: 6px 12px !important;
        font-size: 0.68rem !important;
        border-radius: 16px !important;
        gap: 5px !important;
        font-weight: 600;
    }
    .msg-action-btn i { font-size: 0.72rem !important; }
    .msg-action-btn.feedback-btn {
        min-width: 38px !important;
        padding: 6px 10px !important;
        justify-content: center;
    }
    .tts-btn { min-height: 30px !important; padding: 5px 10px !important; font-size: 0.65rem !important; }
    .tts-bar { padding: 5px 8px !important; margin-top: 6px; border-radius: 10px; }

    /* Code blocks */
    .code-block-wrapper { margin: 12px 0; border-radius: 12px; max-width: 100%; }
    .code-block-header { padding: 8px 12px; flex-wrap: wrap; gap: 8px; }
    .code-block-lang { font-size: 0.68rem; }
    .code-copy-btn { padding: 5px 11px; font-size: 0.68rem; }
    .code-block-wrapper pre {
        padding: 12px 14px !important;
        font-size: 0.76rem;
        line-height: 1.6;
        -webkit-overflow-scrolling: touch;
    }

    /* Markdown tables */
    .md-table-wrapper { margin: 12px 0; border-radius: 10px; -webkit-overflow-scrolling: touch; max-width: 100%; }
    .md-table { font-size: 0.74rem; min-width: 100%; }
    .md-table th, .md-table td { padding: 8px 10px; white-space: nowrap; }

    .message-bubble h1.md-h1 { font-size: 1.05rem; margin: 12px 0 8px; }
    .message-bubble h2.md-h2 { font-size: 0.98rem; margin: 10px 0 6px; }
    .message-bubble h3.md-h3 { font-size: 0.9rem; margin: 8px 0 5px; }
    .md-ul, .md-ol { padding-left: 18px; margin: 8px 0; }
    .md-ul .md-li, .md-ol .md-li { margin-bottom: 5px; line-height: 1.6; }
    .message-bubble code { padding: 2px 5px; font-size: 0.82em; word-break: break-word; }

    /* Sources */
    .sources-box { margin-top: 10px; padding: 10px; border-radius: 10px; }
    .sources-box-title { font-size: 0.65rem; margin-bottom: 6px; }
    .source-item { padding: 8px 10px; font-size: 0.72rem; border-radius: 8px; }

    /* Typing */
    .typing-indicator { padding: 12px 16px; border-radius: 18px; }
    .typing-dot { width: 8px; height: 8px; }

    /* ----- INPUT AREA ----- */
    .input-area {
        padding: 0.65rem 0.7rem calc(0.8rem + env(safe-area-inset-bottom)) !important;
        position: sticky;
        bottom: 0;
    }
    .input-wrapper {
        padding: 5px 6px !important;
        border-radius: 22px !important;
        gap: 4px !important;
        align-items: flex-end;
    }
    #aiInput {
        font-size: 0.9rem !important;
        padding: 9px 4px !important;
        line-height: 1.5;
        min-height: 28px;
        max-height: 120px;
    }
    .attach-btn,
    .voice-btn,
    .web-search-btn,
    .memory-btn {
        width: 38px;
        height: 38px;
        font-size: 0.88rem;
        flex-shrink: 0;
    }
    .image-btn { width: 38px; height: 38px; }
    .camera-btn { width: 38px; height: 38px; }
    .send-btn { width: 42px; height: 42px; font-size: 0.95rem; }

    /* Sembunyikan tombol kurang penting di HP */
    .web-search-btn,
    .memory-btn { display: none; }

    .input-hint {
        font-size: 0.6rem;
        margin-top: 6px;
        gap: 6px;
        padding: 0 4px;
        flex-wrap: wrap;
    }
    .input-hint span:nth-child(2) { display: none; }
    .input-hint kbd { font-size: 0.58rem; padding: 2px 6px; }

    /* Attachment Preview */
    .attachment-preview { padding: 10px 12px; border-radius: 14px; margin-bottom: 8px; gap: 10px; }
    .attachment-preview-thumb { width: 50px; height: 50px; border-radius: 10px; }
    .attachment-preview-info .name { font-size: 0.76rem; }
    .attachment-preview-info .size { font-size: 0.62rem; }
    .attachment-preview-remove { width: 32px; height: 32px; font-size: 0.8rem; }

    /* Voice Status */
    .voice-status { padding: 12px 14px; border-radius: 14px; gap: 10px; margin-bottom: 8px; }
    .voice-text { font-size: 0.82rem; }
    .voice-timer { font-size: 0.82rem; }
    .voice-stop-btn { padding: 8px 14px; font-size: 0.74rem; border-radius: 20px; }

    /* Sidebar User */
    .sidebar-user-card { padding: 10px; gap: 10px; border-radius: 14px; }
    .user-avatar-mini { width: 40px; height: 40px; }
    .user-card-name { font-size: 0.8rem; }
    .user-plan-badge { font-size: 0.54rem; padding: 2px 7px; }
    .user-quota-text { font-size: 0.62rem; }

    /* History items - always show buttons */
    .history-item { padding: 12px 13px; font-size: 0.82rem; border-radius: 12px; gap: 10px; }
    .history-item .pin-btn,
    .history-item .del-btn { opacity: 1 !important; padding: 6px; }

    /* Search */
    .search-box { margin: 0.5rem 0.9rem 0.4rem !important; }
    .search-box input { padding: 11px 34px 11px 36px !important; font-size: 0.82rem; }
    .search-tabs { padding: 0 1rem 0.6rem; gap: 5px; }
    .search-tab { padding: 6px 13px; font-size: 0.7rem; border-radius: 14px; }

    /* ----- MODALS — FULL SCREEN BOTTOM SHEET ----- */
    .img-gen-modal,
    .edit-modal,
    .upgrade-modal,
    .shortcuts-modal {
        padding: 0;
        align-items: flex-end;
    }
    .img-gen-content,
    .edit-modal-content,
    .upgrade-modal-content,
    .shortcuts-modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 95vh;
        max-height: 95dvh;
        border-radius: 24px 24px 0 0;
        margin: 0;
        animation: modalBottomSheet 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
    @keyframes modalBottomSheet {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }
    .img-gen-close,
    .edit-modal-close,
    .upgrade-modal-close,
    .shortcuts-modal-close {
        width: 40px;
        height: 40px;
        font-size: 1.4rem;
    }

    .img-gen-header { margin-bottom: 1.2rem; gap: 12px; }
    .img-gen-icon { width: 48px; height: 48px; font-size: 1.3rem; }
    .img-gen-header h2 { font-size: 1.05rem; }
    .img-gen-header p { font-size: 0.72rem; }
    .img-gen-row { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
    .img-gen-presets { padding: 10px; gap: 5px; }
    .img-gen-preset-label { font-size: 0.64rem; }
    .img-preset-btn { padding: 8px 12px; font-size: 0.72rem; }
    .img-gen-footer { gap: 0.5rem; margin-top: 1.2rem; }
    .img-gen-btn { padding: 14px; font-size: 0.88rem; }

    .edit-modal textarea { font-size: 0.9rem; min-height: 140px; }

    .upgrade-plans-grid { grid-template-columns: 1fr; gap: 0.7rem; }
    .upgrade-plan-card { padding: 1.2rem; }
    .upgrade-plan-price { font-size: 1.3rem; }

    .shortcut-grid { grid-template-columns: 1fr; }
    .shortcut-item { padding: 12px 14px; font-size: 0.8rem; flex-wrap: wrap; gap: 6px; }

    /* Confirm */
    .confirm-overlay { padding: 1rem; }
    .confirm-box { padding: 1.6rem; border-radius: 20px; max-width: 100%; }

    /* Lightbox */
    .image-lightbox { padding: 0.5rem; }
    .image-lightbox-close {
        width: 42px;
        height: 42px;
        top: calc(12px + env(safe-area-inset-top));
        right: 12px;
        font-size: 1.4rem;
    }
    .image-lightbox img { border-radius: 10px; }

    /* Prompt drawer */
    .prompt-drawer-panel { max-width: 100%; width: 100%; border-radius: 0; }
    .prompt-drawer-body { padding: 1rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom)); }

    /* Export menu */
    .export-menu {
        position: fixed;
        top: auto;
        bottom: calc(70px + env(safe-area-inset-bottom));
        right: 8px;
        left: 8px;
        min-width: auto;
        max-width: none;
        border-radius: 16px;
    }
    .export-item { padding: 12px 14px; font-size: 0.82rem; border-radius: 10px; }

    /* Toast */
    .ai-toast {
        bottom: calc(100px + env(safe-area-inset-bottom));
        left: 12px;
        right: 12px;
        transform: translateY(30px) scale(0.9);
        padding: 13px 18px;
        font-size: 0.82rem;
        border-radius: 16px;
        max-width: none;
    }
    .ai-toast.show { transform: translateY(0) scale(1); }

    /* Scroll FAB */
    .scroll-bottom-fab {
        width: 44px;
        height: 44px;
        right: 12px;
        bottom: calc(130px + env(safe-area-inset-bottom));
        font-size: 0.95rem;
    }
    .scroll-badge { font-size: 0.58rem; padding: 2px 6px; }

    /* Drop overlay */
    .drop-overlay-content { padding: 2rem 1.5rem; border-radius: 18px; }
    .drop-overlay-content i { font-size: 3rem; }
    .drop-overlay-content h3 { font-size: 1rem; }
    .drop-overlay-content p { font-size: 0.78rem; }

    /* PWA banner */
    .pwa-banner {
        bottom: calc(12px + env(safe-area-inset-bottom));
        left: 8px;
        right: 8px;
        max-width: none;
        padding: 14px 16px;
        border-radius: 18px;
        transform: translateY(120%);
    }
    .pwa-banner.show { transform: translateY(0); }
    .pwa-icon { width: 46px; height: 46px; font-size: 1.2rem; }

    /* Announcement */
    .announcement-content { padding: 10px 14px; gap: 10px; }
    .announcement-icon { width: 34px; height: 34px; font-size: 0.95rem; }
    .announcement-text strong { font-size: 0.8rem; }
    .announcement-text span { font-size: 0.72rem; }

    /* Chat search mobile */
    .chat-search-bar { padding: 8px 0.7rem; gap: 6px; }
    .chat-search-bar input { font-size: 0.82rem; padding: 7px 10px; }
    .chat-search-count { font-size: 0.64rem; min-width: 34px; }
    .chat-search-nav, .chat-search-close { width: 30px; height: 30px; font-size: 0.7rem; }

    /* Undo toast mobile */
    .undo-toast {
        bottom: calc(100px + env(safe-area-inset-bottom));
        left: 12px;
        right: 12px;
        transform: translateY(30px) scale(0.9);
        max-width: none;
        padding: 11px 12px 11px 16px;
        font-size: 0.8rem;
    }
    .undo-toast.show { transform: translateY(0) scale(1); }

    /* Camera modal mobile */
    .camera-modal-content { padding: 1rem; border-radius: 18px; max-width: 100%; }
    .camera-capture { width: 60px; height: 60px; font-size: 1.4rem; }
    .camera-actions { gap: 0.8rem; }

    /* Memory modal mobile */
    .memory-modal { padding: 0; align-items: flex-end; }
    .memory-modal-content {
        max-width: 100%;
        border-radius: 22px 22px 0 0;
        max-height: 90vh;
        padding: 1.2rem 1rem;
        padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
    }
    .memory-modal-header h3 { font-size: 0.95rem; }
    .memory-item { padding: 10px 12px; }
    .memory-item-q, .memory-item-a { font-size: 0.74rem; }
    .memory-modal-footer .memory-btn-danger {
        width: 100%;
        justify-content: center;
    }

    /* Upload progress mobile */
    .upload-progress-box {
        padding: 1.5rem 1.2rem 1.2rem;
        border-radius: 18px;
        max-width: 92%;
    }
    .upload-progress-icon { width: 56px; height: 56px; font-size: 1.4rem; }
    .upload-progress-name { font-size: 0.82rem; }
}


/* ============================================
   15. RESPONSIVE — SMALL MOBILE (max 480px)
   ============================================ */

@media (max-width: 480px) {
    .top-bar { padding: 0.6rem 0.6rem; min-height: 54px; }
    .chat-title { font-size: 0.82rem; max-width: calc(100vw - 220px); }
    .top-bar-btn { width: 34px; height: 34px; font-size: 0.8rem; border-radius: 9px; }
    #exportBtn { display: none; }
    .mobile-menu-btn { width: 38px; height: 38px; font-size: 0.95rem; }

    .persona-selector-btn,
    .ai-selector-btn {
        padding: 5px 7px;
        font-size: 0.6rem;
        max-width: 75px;
    }
    .persona-selector-btn { max-width: 60px; }
    .persona-emoji { font-size: 0.85rem; }
    .persona-name { display: none; }
    .ai-selector-label { max-width: 44px; font-size: 0.6rem; }

    .quota-badge { padding: 5px 7px; font-size: 0.58rem; border-radius: 10px; }
    .quota-badge i { display: none; }

    .chat-scroll { padding: 0.85rem 0.7rem 0.4rem; gap: 0.7rem; }
    .welcome-icon { width: 72px; height: 72px; font-size: 1.9rem; margin-bottom: 0.9rem; }
    .welcome h1 { font-size: 1.2rem; margin-bottom: 0.4rem; }
    .welcome p { font-size: 0.82rem; line-height: 1.55; margin-bottom: 1.1rem; }
    .suggestion-btn { padding: 12px 14px; font-size: 0.78rem; gap: 10px; }

    .message-avatar { width: 32px; height: 32px; font-size: 0.82rem; }
    .message-body { max-width: calc(100% - 42px); }
    .message-bubble { padding: 11px 13px; font-size: 0.84rem; line-height: 1.6; border-radius: 16px; }

    .msg-action-btn { padding: 6px 10px; font-size: 0.65rem; gap: 4px; min-height: 30px !important; }
    .msg-action-btn i { font-size: 0.68rem !important; }
    .msg-action-btn.feedback-btn { min-width: 34px !important; padding: 6px 8px !important; }
    .tts-btn { padding: 4px 8px; font-size: 0.6rem; }

    .md-table th, .md-table td { padding: 6px 8px; font-size: 0.72rem; }
    .message-model { font-size: 0.56rem; opacity: 0.6; }

    .input-area { padding: 0.6rem 0.65rem calc(0.75rem + env(safe-area-inset-bottom)) !important; }
    .input-wrapper { padding: 4px 5px; border-radius: 22px; gap: 3px; }
    #aiInput { font-size: 0.86rem; padding: 8px 4px; max-height: 100px; }
    .attach-btn,
    .voice-btn,
    .image-btn,
    .camera-btn { width: 34px; height: 34px; font-size: 0.82rem; }
    .send-btn { width: 38px; height: 38px; font-size: 0.88rem; }
    .input-hint { font-size: 0.58rem; margin-top: 5px; }

    :root { --sidebar-w: 92vw; --sidebar-max: 320px; }
    .sidebar-header { padding: 1rem; }
    .sidebar-logo-icon { width: 38px; height: 38px; font-size: 1rem; }
    .sidebar-logo-text span:first-child { font-size: 0.95rem; }
    .sidebar-logo-text small { font-size: 0.58rem; }
    .new-chat-btn { padding: 12px 16px; font-size: 0.82rem; margin: 0.85rem 1rem; }
    .sidebar-user-card,
    .sidebar-guest-card { padding: 9px; }
    .user-avatar-mini,
    .sidebar-guest-icon { width: 36px; height: 36px; }
    .user-card-name { font-size: 0.76rem; max-width: 100px; }
    .history-item { padding: 11px 12px; font-size: 0.8rem; }
    .sidebar-footer { padding: 0.7rem 1rem; gap: 5px; }
    .sidebar-footer-btn { width: 36px; height: 36px; font-size: 0.82rem; border-radius: 9px; }

    .upgrade-plan-card { padding: 1.1rem; }
    .upgrade-plan-name { font-size: 0.92rem; }
    .upgrade-plan-price { font-size: 1.2rem; }
    .upgrade-plan-features { font-size: 0.72rem; line-height: 1.7; }

    .shortcut-item { padding: 10px 12px; font-size: 0.76rem; }
    .prompt-drawer-title { font-size: 0.92rem; }
    .prompt-form h4 { font-size: 0.8rem; }

    .chat-search-bar input { font-size: 0.78rem; padding: 6px 9px; }
    .chat-search-count { display: none; }
}


/* ============================================
   16. RESPONSIVE — TINY (max 360px)
   ============================================ */

@media (max-width: 360px) {
    .top-bar { padding: 0.5rem; min-height: 50px; }
    .mobile-menu-btn { width: 34px; height: 34px; }
    .chat-title { font-size: 0.76rem; max-width: calc(100vw - 180px); }
    .top-bar-btn { width: 32px; height: 32px; font-size: 0.75rem; }
    #soundBtn, #shareChatBtn { display: none !important; }
    .persona-selector-btn { max-width: 40px; padding: 5px; gap: 0; }
    .persona-arrow { display: none; }
    .ai-selector-btn { max-width: 60px; padding: 5px 6px; }
    .quota-badge { min-width: 40px; justify-content: center; }

    .welcome h1 { font-size: 1.1rem; }
    .welcome p { font-size: 0.78rem; }
    .message-bubble { font-size: 0.82rem; padding: 10px 12px; }

    .attach-btn,
    .voice-btn,
    .image-btn,
    .camera-btn { width: 32px; height: 32px; font-size: 0.78rem; }
    .send-btn { width: 36px; height: 36px; font-size: 0.82rem; }
}


/* ============================================
   17. LANDSCAPE (short height)
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
    .welcome { padding: 0.5rem; }
    .welcome-icon { width: 60px; height: 60px; font-size: 1.6rem; margin-bottom: 0.6rem; }
    .welcome h1 { font-size: 1.05rem; }
    .welcome p { font-size: 0.78rem; margin-bottom: 0.8rem; }
    .suggestions { grid-template-columns: repeat(2, 1fr); }
    .ai-selector-menu.mobile-menu,
    .persona-menu.mobile-menu { max-height: 80vh !important; }
}


/* ============================================
   18. DESKTOP - HIDE MOBILE-ONLY ELEMENTS
   ============================================ */

@media (min-width: 769px) {
    .mobile-menu {
        display: none !important;
    }
    body.menu-open::after {
        display: none;
    }
}


/* ============================================
   19. EXPORT MENU — MOBILE ENHANCEMENT
   ============================================ */

/* Export item PDF — warna merah (extra safety) */
.export-item.pdf i { color: #dc2626; }

/* Export menu mobile — bottom sheet penuh */
@media (max-width: 768px) {
    .export-menu {
        position: fixed;
        top: auto;
        bottom: calc(70px + env(safe-area-inset-bottom, 0px));
        right: 8px;
        left: 8px;
        min-width: auto;
        max-width: none;
        width: auto;
        border-radius: 16px;
        padding: 8px;
        max-height: 70vh;
        overflow-y: auto;
        animation: exportSheetIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        overscroll-behavior: contain;
    }

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

    .export-menu-header {
        padding: 8px 10px;
        font-size: 0.65rem;
        margin-bottom: 6px;
    }

    .export-item {
        padding: 12px 14px;
        font-size: 0.82rem;
        border-radius: 10px;
        gap: 10px;
        min-height: 44px;
        margin-bottom: 2px;
    }

    .export-item i {
        width: 18px;
        font-size: 0.9rem;
    }

    .export-item:active {
        background: rgba(124, 58, 237, 0.25);
        transform: scale(0.98);
    }
}


/* ============================================
   20. RESPONSIVE 900px — Tablet Kecil
   ============================================ */

@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        box-shadow: 15px 0 50px rgba(0, 0, 0, 0.7);
        z-index: 250;
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-menu-btn { display: flex; }
    .suggestions { grid-template-columns: 1fr; }
}


/* ============================================
   21. RESPONSIVE 600px — Smartphone
   ============================================ */

@media (max-width: 600px) {
    /* TOP BAR */
    .top-bar {
        padding: 0.55rem 0.65rem;
        gap: 4px;
        min-height: 54px;
    }
    .top-bar-left { gap: 8px; }
    .mobile-menu-btn {
        width: 34px;
        height: 34px;
        border-radius: 9px;
        font-size: 0.9rem;
    }
    .chat-title {
        font-size: 0.82rem;
        font-weight: 700;
        max-width: calc(100vw - 200px);
    }
    .top-bar-right { gap: 4px; }

    /* Persona & AI Selector */
    .ai-selector-btn,
    .persona-selector-btn {
        padding: 6px 8px;
        border-radius: 9px;
        font-size: 0.62rem;
        gap: 4px;
        max-width: 95px;
    }
    .ai-selector-btn i:first-child { font-size: 0.8rem; }
    .ai-selector-label {
        max-width: 55px;
        font-size: 0.62rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .ai-selector-model {
        max-width: 55px;
        font-size: 0.48rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .persona-selector-btn {
        max-width: 85px;
        padding: 6px 8px;
    }
    .persona-emoji { font-size: 0.85rem; }
    .persona-name {
        max-width: 48px;
        font-size: 0.62rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .ai-selector-arrow,
    .persona-arrow { font-size: 0.55rem; }

    /* Quota */
    .quota-badge {
        padding: 5px 8px;
        font-size: 0.58rem;
        gap: 3px;
        min-width: 44px;
        justify-content: center;
        border-radius: 12px;
    }
    .quota-badge i { font-size: 0.65rem; }

    /* Top Bar Buttons */
    .top-bar-btn {
        width: 34px;
        height: 34px;
        border-radius: 9px;
        font-size: 0.8rem;
    }
    .top-bar-btn-home { display: none !important; }

    /* Dropdown menu — fixed dari top */
    .ai-selector-menu,
    .persona-menu {
        position: fixed;
        top: 60px;
        left: 8px;
        right: 8px;
        max-width: none;
        width: auto;
        border-radius: 14px;
        max-height: 60vh;
        z-index: 9999;
    }
    .ai-provider-item,
    .persona-item {
        padding: 8px 10px;
        gap: 8px;
    }
    .ai-provider-icon,
    .persona-item-icon {
        width: 28px;
        height: 28px;
        font-size: 0.7rem;
    }
    .ai-provider-name,
    .persona-item-name { font-size: 0.72rem; }
    .ai-provider-model,
    .persona-item-desc { font-size: 0.58rem; }

    /* CHAT SCROLL */
    .chat-scroll {
        padding: 1rem 0.75rem;
        gap: 0.75rem;
    }

    /* WELCOME */
    .welcome-icon {
        width: 80px;
        height: 80px;
        font-size: 2rem;
        margin-bottom: 1rem;
    }
    .welcome h1 { font-size: 1.3rem; margin-bottom: 0.5rem; }
    .welcome p { font-size: 0.85rem; margin-bottom: 1.2rem; }
    .suggestions { gap: 0.6rem; }
    .suggestion-btn {
        padding: 12px 14px;
        font-size: 0.78rem;
        gap: 10px;
        border-radius: 14px;
    }
    .suggestion-btn i { font-size: 0.95rem; }

    /* MESSAGES */
    .message { gap: 8px; }
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }
    .message-body { max-width: calc(100% - 46px); }
    .message-bubble {
        padding: 10px 13px;
        font-size: 0.82rem;
        line-height: 1.6;
        border-radius: 16px;
    }
    .message.user .message-bubble { border-top-right-radius: 4px; }
    .message.ai .message-bubble { border-top-left-radius: 4px; }
    .message-time { font-size: 0.62rem; }
    .message-model { font-size: 0.6rem; }

    /* INPUT AREA */
    .input-area { padding: 0.6rem 0.7rem 0.75rem; }
    .input-wrapper {
        padding: 4px 6px;
        border-radius: 22px;
        gap: 4px;
    }
    .attach-btn,
    .voice-btn,
    .web-search-btn,
    .memory-btn {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }
    #aiInput {
        font-size: 0.85rem;
        padding: 8px 4px;
        min-height: 26px;
    }
    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
    }
    .input-hint {
        font-size: 0.6rem;
        gap: 6px;
        margin-top: 6px;
        padding: 0 4px;
    }
    .input-hint span:nth-child(2) { display: none; }

    /* ATTACHMENT */
    .attachment-preview {
        padding: 8px 10px;
        border-radius: 12px;
        margin-bottom: 6px;
    }
    .attachment-preview-thumb {
        width: 44px;
        height: 44px;
        border-radius: 8px;
    }
    .attachment-preview-info .name { font-size: 0.72rem; }
    .attachment-preview-info .size { font-size: 0.6rem; }
    .attachment-preview-remove {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    /* VOICE */
    .voice-status {
        padding: 10px 12px;
        gap: 10px;
        border-radius: 14px;
    }
    .voice-text { font-size: 0.78rem; }
    .voice-timer { font-size: 0.78rem; }
    .voice-stop-btn { padding: 7px 14px; font-size: 0.72rem; }

    /* SIDEBAR */
    .sidebar { max-width: 280px; }
    .sidebar-user-card { padding: 9px; gap: 8px; border-radius: 12px; }
    .user-avatar-mini { width: 36px; height: 36px; }
    .user-card-name { font-size: 0.76rem; }
    .user-plan-badge { font-size: 0.5rem; padding: 2px 6px; }
    .user-quota-text { font-size: 0.58rem; }
    .sidebar-guest-card { padding: 9px; gap: 8px; border-radius: 12px; }
    .sidebar-guest-icon { width: 36px; height: 36px; font-size: 0.95rem; }
    .sidebar-guest-title { font-size: 0.72rem; }
    .sidebar-guest-desc { font-size: 0.58rem; }
    .sidebar-login-btn { padding: 6px 10px; font-size: 0.65rem; }

    /* MODALS */
    .prompt-drawer-panel { max-width: 100%; }
    .upgrade-modal-content {
        padding: 1.2rem 1rem;
        border-radius: 18px;
        margin: 0.5rem;
    }
    .upgrade-modal-title { font-size: 1.1rem; }
    .upgrade-modal-subtitle { font-size: 0.75rem; }
    .upgrade-plans-grid { grid-template-columns: 1fr; gap: 0.6rem; }
    .upgrade-plan-card { padding: 1rem; }
}


/* ============================================
   22. RESPONSIVE 400px — HP Kecil
   ============================================ */

@media (max-width: 400px) {
    .chat-title { font-size: 0.78rem; max-width: 90px; }
    .ai-selector-model { display: none; }
    .persona-name { display: none; }
    .persona-selector-btn { max-width: 42px; padding: 6px; gap: 0; }
    .ai-selector-btn { max-width: 70px; padding: 5px 7px; }
    .quota-badge i { display: none; }
    .quota-badge { min-width: 38px; padding: 5px 6px; }
    .top-bar-btn { width: 32px; height: 32px; font-size: 0.75rem; }

    .input-wrapper { padding: 3px 5px; gap: 3px; }
    .attach-btn,
    .voice-btn,
    .web-search-btn,
    .memory-btn { width: 30px; height: 30px; font-size: 0.75rem; }
    .send-btn { width: 36px; height: 36px; font-size: 0.85rem; }
    #aiInput { font-size: 0.82rem; padding: 7px 3px; }

    .suggestions { grid-template-columns: 1fr; gap: 0.5rem; }
    .suggestion-btn { padding: 10px 12px; font-size: 0.75rem; }

    .message-bubble { padding: 9px 12px; font-size: 0.8rem; }
    .message-avatar { width: 30px; height: 30px; font-size: 0.78rem; }
    .message-body { max-width: calc(100% - 42px); }

    /* Export menu di HP kecil — full width bottom */
    .export-menu {
        left: 6px;
        right: 6px;
        bottom: calc(64px + env(safe-area-inset-bottom, 0px));
        border-radius: 14px;
        padding: 6px;
    }
    .export-item {
        padding: 11px 12px;
        font-size: 0.78rem;
        min-height: 42px;
    }
}


/* ============================================
   23. ACCESSIBILITY & REDUCED MOTION
   ============================================ */

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