* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

/* CRITICAL: Enable text selection everywhere */
* {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    -webkit-user-drag: text !important;
}

/* But disable text selection on interactive elements so clicks work */
button, .btn, .suggestion-chip, .action-btn, .theme-option, .font-option,
.ai-mode-option, .chat-item, .chat-item-delete, .toggle-slider,
input[type="checkbox"], label, .sidebar-toggle-btn, .close-sidebar-btn {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

html, body, div, span, p, button, input, textarea, label, h1, h2, h3, h4, h5, h6, a, li, ul, ol, table, tr, td, th {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

:root {
    --primary-gradient: #ffffff;
    --glow-color: rgba(247, 249, 255, 0.5);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --background: transparent;
    --foreground: #fff;
    --sidebar-bg: rgba(15, 15, 25, 0.8);
    --header-bg: rgba(15, 15, 25, 0.7);
    --main-bg: transparent;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.3);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --primary-color: #667eea;
    --accent-cyan: #00d4ff;
    --accent-purple: #a855f7;
    --accent-pink: #ec4899;
    --neon-glow: 0 0 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    --neon-glow-cyan: 0 0 20px rgba(0, 212, 255, 0.5);
}

body {
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-family);
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: text;
    -webkit-user-select: text;
}

body[data-font="cyber"] {
    --font-family: 'Orbitron', sans-serif;
}

body[data-font="tech"] {
    --font-family: 'Rajdhani', sans-serif;
}

body[data-font="modern"] {
    --font-family: 'Outfit', sans-serif;
}

body[data-font="elegant"] {
    --font-family: 'Cormorant Garamond', serif;
}

body[data-font="code"] {
    --font-family: 'JetBrains Mono', monospace;
}

body[data-font="futuristic"] {
    --font-family: 'Exo 2', sans-serif;
}

body[data-font="bold"] {
    --font-family: 'Bebas Neue', sans-serif;
}

body[data-font="inter"] {
    --font-family: 'Inter', sans-serif;
}

body[data-font="poppins"] {
    --font-family: 'Poppins', sans-serif;
}

body[data-font="space"] {
    --font-family: 'Space Grotesk', sans-serif;
}

body[data-font="sora"] {
    --font-family: 'Sora', sans-serif;
}

body[data-font="dmsans"] {
    --font-family: 'DM Sans', sans-serif;
}

body[data-font="nunito"] {
    --font-family: 'Nunito', sans-serif;
}

body[data-font="quicksand"] {
    --font-family: 'Quicksand', sans-serif;
}

body[data-font="firacode"] {
    --font-family: 'Fira Code', monospace;
}

body[data-font="comic"] {
    --font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif;
}

/* Light mode variables and element rules */
body.light-mode {
    --background: #f8fafc;
    --foreground: #1a1a2e;
    --sidebar-bg: rgba(255, 255, 255, 0.92);
    --header-bg: rgba(255, 255, 255, 0.85);
    --main-bg: #ffffff;
    --primary-gradient: #4f46e5;
    --glow-color: rgba(79, 70, 229, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
}

body.light-mode .btn,
body.light-mode .btn i {
    color: #1a1a2e;
}
body.light-mode .btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Personality Overlay & Card Light Mode Styles */
body.light-mode .personality-overlay-content,
body.light-mode .personality-card,
body.light-mode .personality-card-header h3,
body.light-mode .personality-description,
body.light-mode .feature-tag {
    color: inherit;
}

body.light-mode .personality-overlay-content {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(16,24,40,0.06);
    padding: 32px 24px;
    border: 1px solid var(--glass-border);
    max-width: 420px;
    margin: 40px auto;
}

body.light-mode .overlay-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-gradient);
    margin-bottom: 24px;
    letter-spacing: -0.5px;
}

body.light-mode .personality-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

body.light-mode .personality-card {
    background: #f8fafc;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 8px rgba(16,24,40,0.04);
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
    transition: box-shadow 0.18s, border-color 0.18s, background 0.18s;
    color: #111;
}

body.light-mode .personality-card.active {
    background: #dfefff;
    color: #000;
    border: 2px solid #4a90e2;
    box-shadow: 0 6px 18px rgba(74,144,226,0.12);
}

body.light-mode .personality-card:hover {
    background: #eef6ff;
    border-color: var(--primary-gradient);
    box-shadow: 0 6px 24px rgba(var(--primary-color-rgb, 102, 126, 234), 0.12);
}

body.light-mode .personality-card-header i {
    font-size: 32px;
    margin-right: 12px;
    color: var(--primary-gradient);
}

body.light-mode .personality-card-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #154ea0;
}

body.light-mode .personality-description {
    font-size: 14px;
    color: #333;
}

body.light-mode .feature-tag {
    font-size: 14px;
    color: #2b3f8f;
    background: #e9efff;
    border-radius: 8px;
    padding: 4px 10px;
    margin-right: 6px;
    opacity: 0.95;
}

body.light-mode .apply-personality-btn {
    background: var(--primary-gradient);
    color: #fff;
    border-radius: 12px;
    font-weight: 600;
    font-size: 16px;
    padding: 12px 24px;
    border: none;
    box-shadow: 0 4px 16px rgba(74,144,226,0.12);
    transition: background 0.16s;
}

body.light-mode .apply-personality-btn:hover {
    background: #4a90e2;
}

body.light-mode .personality-panel {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(16,24,40,0.06);
    padding: 32px 24px;
    border: 1px solid var(--glass-border);
    max-width: 420px;
    margin: 40px auto;
}

body.light-mode .personality-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary-gradient);
    margin-bottom: 24px;
    letter-spacing: -0.5px;
}

body.light-mode .personality-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

body.light-mode .personality-option {
    background: #f8fafc;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 2px 8px rgba(16,24,40,0.04);
    padding: 18px 16px;
    display: flex;
    align-items: center;
    gap: 18px;
    cursor: pointer;
    transition: box-shadow 0.18s, border-color 0.18s, background 0.18s;
}

body.light-mode .personality-option.selected {
    background: #eef3ff;
    border-color: var(--primary-gradient);
    box-shadow: 0 6px 24px rgba(var(--primary-color-rgb, 102, 126, 234), 0.12);
}

body.light-mode .personality-option:hover {
    background: #eef3ff;
    border-color: var(--primary-gradient);
    box-shadow: 0 6px 24px rgba(var(--primary-color-rgb, 102, 126, 234), 0.12);
}

body.light-mode .personality-icon {
    font-size: 32px;
    margin-right: 12px;
}

body.light-mode .personality-label {
    font-size: 18px;
    font-weight: 600;
    color: #222;
}

body.light-mode .personality-desc {
    font-size: 14px;
    color: #5b6ca8;
    opacity: 0.9;
}

body.light-mode .card, body.light-mode .main-content, body.light-mode .sidebar, body.light-mode .header {
    background: var(--main-bg);
    color: var(--foreground);
    border-color: var(--glass-border);
}

body.light-mode .sidebar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.06);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

body.light-mode .header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

body.light-mode .app {
    background: #f8fafc;
}

body.light-mode #messageInput {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a1a2e;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

body.light-mode #messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

body.light-mode #messageInput::placeholder {
    color: rgba(0, 0, 0, 0.35);
}

body.light-mode .input-container {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.04);
}

body.light-mode .recent-chats-header h3 {
    color: rgba(0, 0, 0, 0.5);
}

body.light-mode .loading-screen {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #f8fafc 100%);
}

body.light-mode .loading-brand {
    color: #1a1a2e;
}

body.light-mode .loading-ring {
    border-top-color: var(--primary-color);
}

body.light-mode .loading-bar {
    background: rgba(0, 0, 0, 0.06);
}

body.light-mode .brand-name {
    color: var(--primary-color);
}

body.light-mode .current-chat-title {
    color: rgba(0, 0, 0, 0.45);
}

body.light-mode .input-footer small {
    color: rgba(0, 0, 0, 0.35);
}

body.light-mode .chat-item {
    color: var(--foreground);
}
body.light-mode .chat-item:hover {
    background: #f0f4ff;
    color: var(--primary-gradient);
}
body.light-mode .chat-item.active {
    background: #e3eaff;
    color: var(--primary-gradient);
    border-left: 3px solid var(--primary-gradient);
}
    body.light-mode .btn.primary {
    background: var(--primary-color);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}
body.light-mode .btn.secondary {
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a2e;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
body.light-mode .btn.secondary:hover {
    background: #f1f5f9;
    border-color: rgba(79, 70, 229, 0.3);
}
body.light-mode .btn.danger {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.15);
}
body.light-mode .message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color, #4f46e5) 0%, var(--primary-dark, #764ba2) 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}
body.light-mode .message.ai .message-content {
    background: #ffffff;
    color: #1a1a2e;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
body.light-mode .suggestion-chip {
    background: rgba(255, 255, 255, 0.95);
    color: #1a1a2e;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
body.light-mode .suggestion-chip:hover {
    background: #f1f5f9;
    color: var(--primary-color);
    border-color: rgba(79, 70, 229, 0.3);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}
body.light-mode .suggestion-chip i {
    color: var(--primary-color);
    border-color: rgba(79, 70, 229, 0.3);
    background: rgba(79, 70, 229, 0.06);
}
body.light-mode .suggestion-chip:hover i {
    background: var(--primary-color);
    color: #fff;
}
body.light-mode .welcome-greeting {
    color: rgba(0, 0, 0, 0.35);
}
body.light-mode .feature-item {
    background: #e3eaff;
    border: 1px solid #c7d2fe;
}
body.light-mode .feature-item span {
    color: #222;
}
body.light-mode .feature-item strong {
    color: var(--primary-gradient);
}

body.light-mode .message-actions {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-mode .action-btn {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: rgba(0, 0, 0, 0.7);
}

body.light-mode .action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #222;
}

body.light-mode .action-btn.speaking {
    background: rgba(0, 119, 255, 0.15);
    color: #0077ff;
    border-color: rgba(0, 119, 255, 0.4);
}

body.light-mode .action-copy:hover {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.4);
    color: #2ecc71;
}

body.light-mode .action-speak:hover {
    background: rgba(0, 119, 255, 0.15);
    border-color: rgba(0, 119, 255, 0.4);
    color: #0077ff;
}


/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    border-radius: 10px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.8);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5) rgba(255, 255, 255, 0.05);
}

/* Floating Particles */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.8);
    border-radius: 50%;
    animation: floatParticle linear infinite;
    box-shadow: 0 0 10px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

@keyframes floatParticle {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a0a0f 0%, #12121f 50%, #0a0a0f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
}

.loading-ring {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--primary-color, #667eea);
    border-right-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    animation: ringRotate 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    top: -20px;
}

.loading-ring::after {
    content: '';
    position: absolute;
    inset: 6px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-bottom-color: rgba(var(--primary-dark-rgb, 118, 75, 162), 0.6);
    border-left-color: rgba(var(--primary-dark-rgb, 118, 75, 162), 0.2);
    animation: ringRotate 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite reverse;
}

@keyframes ringRotate {
    to { transform: rotate(360deg); }
}

.loading-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 20px;
    animation: loadingFloat 2s ease-in-out infinite;
    filter: drop-shadow(0 0 24px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5));
}

@keyframes loadingFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.loading-brand {
    font-size: 20px;
    font-weight: 700;
    color: rgba(255,255,255,0.85);
    letter-spacing: 2px;
    text-transform: uppercase;
    animation: loadingFadeIn 1s ease-out 0.3s both;
}

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

.loading-bar {
    width: 140px;
    height: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 4px;
}

.loading-bar-fill {
    height: 100%;
    width: 40%;
    background: linear-gradient(90deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2));
    border-radius: 4px;
    animation: loadingProgress 1.5s ease-in-out infinite;
}

@keyframes loadingProgress {
    0% { transform: translateX(-100%); width: 40%; }
    50% { width: 70%; }
    100% { transform: translateX(350%); width: 40%; }
}

/* Animated background */
.app::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: none;
    pointer-events: none !important;
    z-index: 0;
}

@keyframes bgPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.02); }
}

.app {
    display: flex;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #0f0f1a;
    position: relative;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
    overflow: hidden;
}

/* focus rules for message input intentionally removed to prevent strong colored halos */

/* Sidebar Styles */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 100;
    overflow: hidden;
    box-shadow: 2px 0 40px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
}

.sidebar-header-top {
    display: flex;
    gap: 10px;
    align-items: center;
    pointer-events: auto;
}

.sidebar-header-top .sidebar-new-chat {
    flex: 1;
}

.sidebar-new-chat {
    width: 100%;
    justify-content: center;
    font-weight: 600;
    letter-spacing: 0.3px;
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure the New Chat button follows the active theme's primary color */
.sidebar-new-chat,
.sidebar-new-chat.btn.primary {
    background: var(--primary-color, #667eea);
    color: #fff !important;
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.sidebar-new-chat:hover:not(:disabled),
.sidebar-new-chat.btn.primary:hover:not(:disabled) {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.sidebar-toggle {
    display: none;
}

.recent-chats {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    pointer-events: auto;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.recent-chats-header {
    padding: 0 20px 15px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 15px;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.recent-chats-header h3 {
    color: var(--foreground);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.recent-chats-list {
    padding: 0 10px;
    pointer-events: auto;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 4px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--foreground);
    position: relative;
    pointer-events: auto !important;
    user-select: text !important;
}

.chat-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--foreground);
    transform: translateX(4px);
}

.chat-item.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    color: var(--primary-color, #667eea);
    border-left: 3px solid var(--primary-color, #667eea);
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
}

.chat-item-content {
    flex: 1;
    overflow: hidden;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.chat-item-title {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.chat-item-preview {
    font-size: 12px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.chat-item-time {
    font-size: 11px;
    opacity: 0.5;
    margin-left: 8px;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.chat-item-delete {
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-left: 8px;
    padding: 4px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: var(--foreground);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

.chat-item-delete:hover {
    background: rgba(255, 0, 0, 0.2);
    color: #ff4757;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--glass-border);
    pointer-events: auto;
    user-select: text !important;
    -webkit-user-select: text !important;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--main-bg);
    min-width: 0;
    min-height: 0;
    position: relative;
    z-index: 1;
    pointer-events: auto;
    overflow: hidden;
}

.header {
    background: var(--header-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
    color: var(--foreground);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mobile-only {
    display: none;
}

.sidebar-toggle-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 10px;
}

/* Show toggle button when sidebar is collapsed */
.sidebar.collapsed ~ .main-content .sidebar-toggle-btn {
    display: flex;
}

.current-chat-title {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    margin-right: 15px;
    font-style: italic;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Interactive Logo Styles */
.logo-container {
    position: relative;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 12px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    object-fit: contain;
    position: relative;
    z-index: 2;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 2px 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4));
}

.logo-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    border-radius: 12px;
    background: var(--primary-color, #667eea);
    opacity: 0;
    z-index: 1;
    transition: all 0.3s ease;
    filter: blur(12px);
}

.logo-container:hover {
    transform: scale(1.1);
}

.logo-container:hover .header-logo {
    filter: drop-shadow(0 4px 16px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6));
    transform: rotate(5deg);
}

.logo-container:hover .logo-glow {
    opacity: 0.6;
    width: 120%;
    height: 120%;
}

.logo-container:active {
    transform: scale(0.95);
}

.logo-container:active .header-logo {
    transform: rotate(-5deg);
}

/* Logo click animation */
.logo-container.clicked .header-logo {
    animation: logoSpin 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes logoSpin {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(15deg) scale(1.1); }
    50% { transform: rotate(-10deg) scale(1.05); }
    75% { transform: rotate(5deg) scale(1.1); }
    100% { transform: rotate(0deg) scale(1); }
}

/* Logo pulse animation on idle */
.logo-container .header-logo {
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { 
        filter: drop-shadow(0 2px 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4));
    }
    50% { 
        filter: drop-shadow(0 4px 16px rgba(var(--primary-color-rgb, 102, 126, 234), 0.7));
    }
}

.brand-name {
    color: var(--primary-color, #667eea);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-controls {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-normal);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.btn:active::before {
    width: 200px;
    height: 200px;
}

.btn.primary {
    background: var(--primary-color, #667eea);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    filter: brightness(1.1);
}

.btn.primary:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: var(--shadow-sm);
}

.btn.secondary {
    background: var(--sidebar-bg);
    color: var(--foreground);
    border: 1.5px solid var(--glass-border);
}

.btn.secondary:hover, .theme-btn:hover {
    background: var(--main-bg);
    color: var(--foreground);
    border-color: var(--primary-gradient, #667eea);
}

.btn.secondary i, .theme-btn i {
    color: var(--foreground);
}

/* Danger button */
.btn.danger {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn.danger:hover {
    background: rgba(255, 71, 87, 0.3);
    border-color: rgba(255, 71, 87, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
}

.btn.danger:active {
    transform: translateY(0) scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Button icon animation */
.btn i {
    transition: transform 0.3s ease;
}

.btn:hover:not(:disabled) i {
    transform: scale(1.1);
}

.btn.primary:hover:not(:disabled) i {
    animation: pulse-icon 0.6s ease;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.3); }
}

/* Only apply in light mode */
body.light-mode .chat-container {
    background: #ffffff;
    color: #0b1220;
    border-radius: 14px;
    border: none;
    box-shadow: none;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: transparent;
    color: inherit;
    border-radius: 0;
    border: none;
    box-shadow: none;
    min-height: 0;
    scroll-behavior: smooth;
}

.welcome-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    animation: welcomeFadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.welcome-content {
    max-width: 520px;
    padding: 0 20px;
    background: none;
    border-radius: 0;
    border: none;
    backdrop-filter: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.welcome-logo {
    width: 64px;
    height: 64px;
}

.welcome-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-lg);
    opacity: 0.8;
}

.welcome-greeting {
    font-size: 32px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: -0.5px;
    animation: welcomeTextSlide 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

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

.welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 100%;
    margin-top: 8px;
    animation: suggestionsSlideUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) 0.4s both;
}

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

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: var(--foreground);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}

.suggestion-chip::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb, 102, 126, 234), 0.08) 0%, rgba(var(--primary-dark-rgb, 118, 75, 162), 0.05) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.suggestion-chip:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    color: rgba(255, 255, 255, 0.95);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.suggestion-chip:hover::before {
    opacity: 1;
}

.suggestion-chip:active {
    transform: translateY(-1px) scale(0.98);
}

.suggestion-chip i {
    font-size: 14px;
    color: var(--primary-color, #667eea);
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
    border: 1.5px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
    border-radius: 10px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.suggestion-chip:hover i {
    background: var(--primary-color, #667eea);
    color: #fff;
    border-color: var(--primary-color, #667eea);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.welcome-icon {
    font-size: 64px;
    color: var(--primary-color, #667eea);
    margin-bottom: 25px;
    opacity: 0.8;
}

.welcome-content h2 {
    color: var(--primary-color, #667eea);
    margin-bottom: 15px;
    font-size: 36px;
    font-weight: 600;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.welcome-content p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    line-height: 1.7;
    margin-bottom: 10px;
}

/* Feature Highlights in Welcome Screen */
.feature-highlights {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 20px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.08);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 16px;
    text-align: left;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.feature-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
    transition: left 0.5s ease;
}

.feature-item:hover::before {
    left: 100%;
}

.feature-item:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    transform: translateX(8px) scale(1.02);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.feature-item i {
    font-size: 24px;
    color: var(--primary-color, #667eea);
    width: 40px;
    flex-shrink: 0;
}

.feature-item span {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1.5;
}

.feature-item strong {
    color: rgba(255, 255, 255, 0.95);
}

.message {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
    animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

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

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--foreground);
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary-color, #667eea);
    margin-left: 12px;
}

/* Enhanced AI Response/Answer Display */
.message.ai .message-avatar {
    background: linear-gradient(135deg, var(--primary-color, #667eea) 0%, var(--primary-dark, #764ba2) 100%);
    margin-right: 12px;
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    animation: avatarPulse 3s ease-in-out infinite;
}

@keyframes avatarPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4); }
    50% { box-shadow: 0 4px 20px rgba(var(--primary-dark-rgb, 118, 75, 162), 0.6); }
}

.ai-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message-content {
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    max-width: 70%;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: box-shadow var(--transition-normal);
    cursor: default;
    position: relative;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    font-family: var(--font-family);
    pointer-events: auto;
    z-index: 10;
}

.message-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message:hover::before {
    opacity: 1;
}

.message-content:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color, #667eea) 0%, var(--primary-dark, #764ba2) 100%);
    color: var(--foreground);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.message.ai .message-content {
    background: linear-gradient(180deg, rgba(30, 30, 50, 0.7) 0%, rgba(20, 20, 40, 0.8) 100%);
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* Enhanced streaming cursor with gradient */
.message.streaming .cursor {
    display: inline-block;
    width: 10px;
    height: 20px;
    background: linear-gradient(180deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2));
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s infinite;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
}

@keyframes blink {
    0%, 45% {
        opacity: 1;
        transform: scaleX(1);
    }
    50%, 100% {
        opacity: 0;
        transform: scaleX(0.5);
    }
}

.message.streaming .streaming-text {
    min-height: 24px;
}

.message.streaming .message-content {
    animation: streamingGlow 2s ease-in-out infinite;
}

@keyframes streamingGlow {
    0%, 100% { box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.2); }
    50% { box-shadow: 0 4px 30px rgba(var(--primary-dark-rgb, 118, 75, 162), 0.4); }
}

.message-content p {
    margin: 0;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* KaTeX Math/Fraction Styling */
.message-content .katex {
    font-size: 1.1em;
    color: inherit;
}

.message-content .katex-display {
    margin: 1em 0;
    text-align: center;
}

.message-content .katex-display > .katex {
    font-size: 1.2em;
}

/* Enhanced message actions layout */
.message-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 5;
    pointer-events: auto;
    flex-wrap: wrap;
}

.actions-left, .actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-timestamp {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-tokens {
    font-size: 11px;
    color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.8);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
    border-radius: 12px;
    margin-right: 8px;
    user-select: none;
}

/* Enhanced action buttons with tooltips */
.action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 38px;
    height: 38px;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.action-btn:hover::before {
    left: 100%;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-tooltip {
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.2s ease;
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.8);
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
}

.action-btn:hover .btn-tooltip {
    opacity: 1;
}

.action-btn.speaking {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    color: #009dff;
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    animation: speakingPulse 1s ease-in-out infinite;
}

@keyframes speakingPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 102, 126, 234), 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0); }
}

/* Streaming indicator dots */
.streaming-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.streaming-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.streaming-indicator .dot {
    width: 6px;
    height: 6px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.streaming-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.streaming-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.input-container {
    padding: 16px 20px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 5;
}

.image-preview-container {
    margin-bottom: 12px;
}

.image-preview-container.hidden {
    display: none;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 200px;
}

.image-preview-wrapper img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 12px;
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    object-fit: cover;
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff4757;
    color: var(--foreground);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

.remove-image-btn:hover {
    background: #ff3344;
    transform: scale(1.1);
}

/* Hidden file input */
.hidden-file-input {
    display: none;
}

/* Unified input button styles */
.input-wrapper .btn {
    padding: 14px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.input-wrapper .btn i {
    font-size: 16px;
}

/* Upload button */
.upload-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.upload-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    transform: scale(1.05);
}

/* Message image display */
.message-image {
    margin-bottom: 10px;
}

.message-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    object-fit: contain;
}

/* Drag over state */
#messageInput.drag-over {
    border-color: #ffffff;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    border: 2px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    padding: 14px 18px;
    font-size: 15px;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 48px;
    line-height: 1.5;
    transition: all var(--transition-normal);
    background: rgba(20, 20, 35, 0.5);
    color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    font-family: inherit;
}

#messageInput:focus {
    border-color: var(--primary-color, #667eea);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    background: rgba(25, 25, 45, 0.7);
}

#messageInput::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

#sendButton {
    padding: 14px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color, #667eea);
    border: none;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

#sendButton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.12);
    transition: left 0.4s ease;
}

#sendButton:hover:not(:disabled)::before {
    left: 100%;
}

#sendButton:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
    filter: brightness(1.1);
}

#sendButton:active:not(:disabled) {
    transform: scale(0.95);
}

#sendButton:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

#sendButton i {
    color: var(--foreground);
    font-size: 16px;
    transition: transform 0.3s ease;
}

#sendButton:hover:not(:disabled) i {
    transform: translateX(2px);
}

.input-footer {
    margin-top: 12px;
    text-align: center;
}

.input-footer small {
    color: var(--foreground);
    font-size: 12px;
    letter-spacing: 0.3px;
}

.loading-indicator {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-xl);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: var(--shadow-lg);
    animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { box-shadow: var(--shadow-lg); }
    50% { box-shadow: 0 8px 48px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5); }
}

.loading-indicator.show {
    display: flex;
    animation: loadingSlideIn 0.25s ease-out, loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.typing-indicator {
    display: flex;
    gap: 5px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    animation: typing 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-container::-webkit-scrollbar,
.recent-chats::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track,
.recent-chats::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb,
.recent-chats::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.recent-chats::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
    }
    
    .chat-container {
        padding: 25px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        background: rgba(26, 26, 26, 0.95);
        backdrop-filter: blur(20px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .mobile-only {
        display: flex;
    }
    
    .main-content {
        width: 100%;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .current-chat-title {
        display: none;
    }
    
    .chat-container {
        padding: 20px 15px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 15px 18px;
    }
    
    .input-container {
        padding: 20px 15px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .welcome-content h2 {
        font-size: 28px;
    }
    
    .welcome-content p {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }
    
    .chat-container {
        padding: 15px 10px;
    }
    
    .input-container {
        padding: 15px 10px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 12px 15px;
    }
    
    #messageInput {
        font-size: 14px;
        padding: 12px 15px;
    }
    
    .welcome-content h2 {
        font-size: 24px;
    }
    
    .welcome-content p {
        font-size: 14px;
    }
    
    .sidebar {
        width: 260px;
    }
}

/* Dark mode overlay for mobile sidebar */
@media (max-width: 768px) {
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Always show toggle button on mobile */
    .sidebar-toggle-btn {
        display: flex !important;
    }
}

/* ==================== THEME SYSTEM ==================== */

/* Theme Selector Styles */
.theme-selector {
    position: relative;
    width: 100%;
}

.theme-btn {
    width: 100%;
    justify-content: center;
}

.theme-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 8px;
    display: none;
    z-index: 1001;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: dropdownFadeIn 0.2s ease;
}

.theme-dropdown.show {
    display: block;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.8);
}

.theme-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 1);
    transform: translateX(4px);
}

.theme-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-left: 3px solid var(--primary-color, #667eea);
}

.theme-preview {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid var(--glass-border);
    background: var(--main-bg);
    color: var(--foreground);
}

.theme-option:hover .theme-preview {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Theme preview colors */
.light-blue-preview {
    background: #4facfe;
}

.dark-blue-preview {
    background: #0f1419;
}

.ocean-preview {
    background: #2193b0;
}

.sunset-preview {
    background: #ff7e5f;
}

.forest-preview {
    background: #11998e;
}

.purple-preview {
    background: #0088ff;
}

/* Connection Status Styles */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    transition: all 0.3s ease;
}

.connection-status:hover {
    background: rgba(74, 222, 128, 0.15);
    transform: scale(1.02);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
}

.status-indicator.online {
    background: #4ade80;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.8);
    animation: statusGlow 2s ease-in-out infinite;
}

.status-indicator.online::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 2px solid rgba(74, 222, 128, 0.4);
    animation: statusRing 2s ease-in-out infinite;
}

@keyframes statusGlow {
    0%, 100% { box-shadow: 0 0 12px rgba(74, 222, 128, 0.8); }
    50% { box-shadow: 0 0 20px rgba(74, 222, 128, 1); }
}

@keyframes statusRing {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0; }
}

.status-indicator.offline {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    animation: none;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.status-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Message Counter Styles */
.message-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    font-weight: 500;
}

#messageCount {
    background: var(--primary-color, #667eea);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    font-weight: 600;
}

/* ==================== THEME DEFINITIONS ==================== */

/* Default/Purple Theme (already applied) */
:root {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-color-rgb: 102, 126, 234;
    --primary-dark-rgb: 118, 75, 162;

    --bg-gradient-1: #0f1419;
    --bg-gradient-2: #1a1f2e;
    --ai-gradient-1: #00d2ff;
    --ai-gradient-2: #3a7bd5;
}

/* Light Blue Theme */
[data-theme="light-blue"] {
    --primary-color: #4facfe;
    --primary-dark: #00f2fe;
    --primary-color-rgb: 79, 172, 254;
    --primary-dark-rgb: 0, 242, 254;

    --bg-gradient-1: #1a2a3a;
    --bg-gradient-2: #0d1b2a;
    --ai-gradient-1: #4facfe;
    --ai-gradient-2: #00f2fe;
}

[data-theme="light-blue"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="light-blue"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

[data-theme="light-blue"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.5);
}

[data-theme="light-blue"] .message.user .message-content,
[data-theme="light-blue"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="light-blue"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="light-blue"] .welcome-icon,
[data-theme="light-blue"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="light-blue"] .chat-item.active {
    background: rgba(79, 172, 254, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="light-blue"] #messageInput:focus {
}

[data-theme="light-blue"] .loading-indicator {
    background: rgba(79, 172, 254, 0.9);
}

/* Dark Blue Theme */
[data-theme="dark-blue"] {
    --primary-color: #3b82f6;
    --primary-dark: #1e40af;
    --primary-color-rgb: 59, 130, 246;
    --primary-dark-rgb: 30, 64, 175;

    --bg-gradient-1: #0a0f1a;
    --bg-gradient-2: #111827;
    --ai-gradient-1: #3b82f6;
    --ai-gradient-2: #1e40af;
}

[data-theme="dark-blue"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="dark-blue"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

[data-theme="dark-blue"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

[data-theme="dark-blue"] .message.user .message-content,
[data-theme="dark-blue"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="dark-blue"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="dark-blue"] .welcome-icon,
[data-theme="dark-blue"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="dark-blue"] .chat-item.active {
    background: rgba(59, 130, 246, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="dark-blue"] #messageInput:focus {
}

[data-theme="dark-blue"] .loading-indicator {
    background: rgba(59, 130, 246, 0.9);
}

/* Ocean Theme */
[data-theme="ocean"] {
    --primary-color: #2193b0;
    --primary-dark: #6dd5ed;
    --primary-color-rgb: 33, 147, 176;
    --primary-dark-rgb: 109, 213, 237;

    --bg-gradient-1: #0c1821;
    --bg-gradient-2: #1b3a4b;
    --ai-gradient-1: #2193b0;
    --ai-gradient-2: #6dd5ed;
}

[data-theme="ocean"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="ocean"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(33, 147, 176, 0.3);
}

[data-theme="ocean"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(33, 147, 176, 0.5);
}

[data-theme="ocean"] .message.user .message-content,
[data-theme="ocean"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="ocean"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="ocean"] .welcome-icon,
[data-theme="ocean"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="ocean"] .chat-item.active {
    background: rgba(33, 147, 176, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="ocean"] #messageInput:focus {
}

[data-theme="ocean"] .loading-indicator {
    background: rgba(33, 147, 176, 0.9);
}

/* Sunset Theme */
[data-theme="sunset"] {
    --primary-color: #ff7e5f;
    --primary-dark: #feb47b;
    --primary-color-rgb: 255, 126, 95;
    --primary-dark-rgb: 254, 180, 123;

    --bg-gradient-1: #1a1012;
    --bg-gradient-2: #2d1f1f;
    --ai-gradient-1: #ff7e5f;
    --ai-gradient-2: #feb47b;
}

[data-theme="sunset"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="sunset"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(255, 126, 95, 0.3);
}

[data-theme="sunset"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(255, 126, 95, 0.5);
}

[data-theme="sunset"] .message.user .message-content,
[data-theme="sunset"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="sunset"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="sunset"] .welcome-icon,
[data-theme="sunset"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="sunset"] .chat-item.active {
    background: rgba(255, 126, 95, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="sunset"] #messageInput:focus {
}

[data-theme="sunset"] .loading-indicator {
    background: rgba(255, 126, 95, 0.9);
}

/* Forest Theme */
[data-theme="forest"] {
    --primary-color: #11998e;
    --primary-dark: #38ef7d;
    --primary-color-rgb: 17, 153, 142;
    --primary-dark-rgb: 56, 239, 125;

    --bg-gradient-1: #0a1510;
    --bg-gradient-2: #1a2f23;
    --ai-gradient-1: #11998e;
    --ai-gradient-2: #38ef7d;
}

[data-theme="forest"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="forest"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(17, 153, 142, 0.3);
}

[data-theme="forest"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(17, 153, 142, 0.5);
}

[data-theme="forest"] .message.user .message-content,
[data-theme="forest"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="forest"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="forest"] .welcome-icon,
[data-theme="forest"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="forest"] .chat-item.active {
    background: rgba(17, 153, 142, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="forest"] #messageInput:focus {
}

[data-theme="forest"] .loading-indicator {
    background: rgba(17, 153, 142, 0.9);
}

/* Purple Theme (default values, explicit declaration) */
[data-theme="purple"] {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-color-rgb: 102, 126, 234;
    --primary-dark-rgb: 118, 75, 162;

    --bg-gradient-1: #0f1419;
    --bg-gradient-2: #1a1f2e;
    --ai-gradient-1: #00d2ff;
    --ai-gradient-2: #3a7bd5;
}

[data-theme="purple"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="purple"] .btn.primary {
    background: var(--primary-color);
}

[data-theme="purple"] .message.user .message-content,
[data-theme="purple"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="purple"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

/* Mobile responsive updates for theme elements */
@media (max-width: 768px) {
    .connection-status {
        display: none;
    }
    
    .message-counter {
        display: none;
    }
    
    .theme-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 280px;
        max-width: 90vw;
    }
    
    .theme-dropdown.show {
        animation: mobileDropdownFadeIn 0.3s ease;
    }
    
    @keyframes mobileDropdownFadeIn {
        from {
            opacity: 0;
            transform: translate(-50%, -50%) scale(0.9);
        }
        to {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
    }
}

/* ============================================
   AI PERSONALITY MODE SELECTOR
   ============================================ */

.personality-selector {
    position: relative;
}

.personality-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.personality-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.personality-btn i {
    color: var(--primary-color, #667eea);
}

.personality-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: rgba(30, 30, 40, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.personality-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.personality-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 6px;
}

.personality-option:last-child {
    margin-bottom: 0;
}

.personality-option:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
}

.personality-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

.personality-option i {
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 10px;
    color: var(--primary-color, #667eea);
}

.personality-option.active i {
    background: var(--primary-color, #667eea);
    color: white;
}

.personality-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.personality-name {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
}

.personality-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   FLOATING PERSONALITY OVERLAY
   ============================================ */

.personality-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.personality-overlay.show {
    display: flex;
    animation: overlayFadeIn 0.25s ease;
}

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

.personality-overlay-content {
    background: rgba(18, 18, 28, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 28px;
    width: 420px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    animation: panelSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.personality-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    position: relative;
}

.overlay-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.overlay-title i {
    color: var(--primary-color, #667eea);
    font-size: 20px;
}

.overlay-subtitle {
    position: absolute;
    bottom: -4px;
    left: 0;
    font-size: 12px;
    color: var(--foreground);
    margin: 0;
}

.overlay-close {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.overlay-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.personality-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.personality-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.personality-card:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
}

.personality-card.active {
    background: #d1e7ff; /* Light blue background for active card */
    color: #000; /* Black text for better contrast */
    border: 2px solid #4a90e2; /* Highlighted border */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Subtle shadow for emphasis */
}

.personality-card.active .personality-card-header h3 {
    color: #4a90e2; /* Highlighted header text */
}

.personality-card.active .personality-description {
    color: #333; /* Darker text for description */
}

.personality-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.personality-card-icon i {
    font-size: 18px;
    color: var(--primary-color, #667eea);
    transition: all 0.2s ease;
}

.personality-card.active .personality-card-icon {
    background: var(--primary-color, #667eea);
}

.personality-card.active .personality-card-icon i {
    color: white;
}

.personality-card-info {
    flex: 1;
    min-width: 0;
}

.personality-card-info h3 {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 2px 0;
}

.personality-card-info p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
}

.personality-check {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.personality-check i {
    font-size: 10px;
    color: transparent;
    transition: all 0.2s ease;
}

.personality-card.active .personality-check {
    background: var(--primary-color, #667eea);
    border-color: var(--primary-color, #667eea);
}

.personality-card.active .personality-check i {
    color: white;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile responsiveness for personality overlay */
@media (max-width: 768px) {
    .personality-overlay-content {
        margin: 12px;
        padding: 20px;
        max-height: 90vh;
    }
    
    .overlay-title {
        font-size: 16px;
    }
}

/* ============================================
   VOICE INPUT STYLES
   ============================================ */

.voice-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    position: relative;
    overflow: hidden;
}

.voice-btn::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--primary-color, #667eea);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 50%;
}

.voice-btn:hover {
    transform: scale(1.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.8);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.voice-btn:hover::before {
    opacity: 0.2;
}

.voice-btn i {
    font-size: 18px;
    color: var(--primary-color, #667eea);
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

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

.voice-btn.listening {
    background: #ff4757;
    border-color: transparent;
    animation: voicePulse 1.5s infinite;
    transform: scale(1.1);
}

.voice-btn.listening::before {
    opacity: 0;
}

.voice-btn.listening i {
    color: white;
    animation: micBounce 0.5s ease infinite;
}

@keyframes micBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Auto-Read Button Styles */
.auto-read-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

.auto-read-btn i {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
}

.auto-read-btn:hover {
    transform: scale(1.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.auto-read-btn:hover i {
    color: var(--primary-color, #667eea);
}

.auto-read-btn.active {
    background: var(--primary-color, #667eea);
    border-color: transparent;
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.auto-read-btn.active i {
    color: white;
}

.auto-read-btn.active.speaking {
    animation: speakingGlow 1.5s infinite;
}

@keyframes speakingGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 102, 126, 234), 0.6), 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(var(--primary-color-rgb, 102, 126, 234), 0), 0 4px 30px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    }
}

.voice-status {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(255, 71, 87, 0.9);
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(255, 71, 87, 0.4);
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
}

.voice-status.hidden {
    display: none;
}

.voice-pulse {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: voiceDot 1s infinite;
}

@keyframes voiceDot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

/* Voice wave animation for status */
.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.voice-wave span {
    width: 3px;
    height: 100%;
    background: white;
    border-radius: 2px;
    animation: voiceWave 0.5s infinite ease-in-out;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes voiceWave {
    0%, 100% {
        transform: scaleY(0.3);
    }
    50% {
        transform: scaleY(1);
    }
}

/* ============================================
   PERSONALITY INDICATOR IN MESSAGES
   ============================================ */

.personality-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
}

.personality-badge i {
    font-size: 10px;
    color: var(--primary-color, #667eea);
}

/* ============================================
RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .personality-btn span {
        display: none;
    }
    
    .personality-btn {
        padding: 8px 12px;
    }
    
    .personality-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 320px;
    }
    
    .personality-dropdown.show {
        transform: translate(-50%, -50%);
    }
    
    .voice-status {
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* ============================================
   THEME VARIATIONS FOR PERSONALITY
   ============================================ */

[data-theme="ocean"] .personality-btn {
    background: rgba(0, 180, 219, 0.2);
    border-color: rgba(0, 180, 219, 0.4);
}

[data-theme="ocean"] .personality-btn i,
[data-theme="ocean"] .personality-option i {
    color: #00b4db;
}

[data-theme="sunset"] .personality-btn {
    background: rgba(255, 94, 98, 0.2);
    border-color: rgba(255, 94, 98, 0.4);
}

[data-theme="sunset"] .personality-btn i,
[data-theme="sunset"] .personality-option i {
    color: #ff5e62;
}

[data-theme="forest"] .personality-btn {
    background: rgba(17, 153, 142, 0.2);
    border-color: rgba(17, 153, 142, 0.4);
}

[data-theme="forest"] .personality-btn i,
[data-theme="forest"] .personality-option i {
    color: #11998e;
}

/* Image Generation Styles */
.generate-image-btn {
    background: rgba(147, 51, 234, 0.2);
    border: 2px solid rgba(147, 51, 234, 0.4);
    color: #c084fc;
}

.generate-image-btn:hover {
    background: rgba(147, 51, 234, 0.4);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.4);
}

.generate-image-btn i {
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.generating-image .message-avatar {
    background: #9333ea;
}

.generating-image .message-avatar i {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.image-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    text-align: center;
}

.image-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(147, 51, 234, 0.2);
    border-top: 3px solid #9333ea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.image-prompt-preview {
    font-style: italic;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 10px;
    font-size: 0.9em;
}

.generated-image-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 100%;
}

.generated-image-caption {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

.generated-image-prompt {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9em;
    margin: 0;
}

.generated-image-wrapper {
    position: relative;
    max-width: 512px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.generated-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.generated-image.loaded {
    opacity: 1;
}

.image-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(147, 51, 234, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    min-height: 200px;
    transition: opacity 0.3s ease;
}

.image-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.image-loading-overlay.error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    font-size: 0.9em;
}

.generated-image-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.image-action-btn {
    padding: 8px 16px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.image-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.regenerate-btn {
    background: rgba(147, 51, 234, 0.2);
    border-color: rgba(147, 51, 234, 0.4);
}

.regenerate-btn:hover {
    background: rgba(147, 51, 234, 0.4);
}

/* Light theme adjustments for image generation */
[data-theme="light-blue"] .generate-image-btn {
    background: rgba(147, 51, 234, 0.15);
    color: #9333ea;
}

[data-theme="light-blue"] .generated-image-caption {
    color: rgba(0, 0, 0, 0.9);
}

[data-theme="light-blue"] .generated-image-prompt {
    color: rgba(0, 0, 0, 0.6);
}

[data-theme="light-blue"] .image-action-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
    color: rgba(0, 0, 0, 0.8);
}

[data-theme="light-blue"] .image-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ============================================
   DARK MODE TOGGLE BUTTON
   ============================================ */

.dark-mode-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 16px;
}

/* ============================================
   LIGHT MODE STYLES
   ============================================ */

[data-mode="light"] body {
    background: #f5f6fa;
}

[data-mode="light"] .app {
    background: #f5f6fa;
}

[data-mode="light"] .sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(0, 0, 0, 0.08);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.05);
}

[data-mode="light"] .sidebar-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .sidebar-footer {
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .recent-chats-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .recent-chats-header h3 {
    color: rgba(0, 0, 0, 0.6);
}

[data-mode="light"] .chat-item {
    color: rgba(0, 0, 0, 0.7);
}

[data-mode="light"] .chat-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.9);
}

[data-mode="light"] .chat-item.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
    color: var(--primary-color, #667eea);
    border-left: 3px solid var(--primary-color, #667eea);
}

[data-mode="light"] .header {
    background: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.05);
    color: #1a1a2e;
}

[data-mode="light"] .brand-name {
    color: var(--primary-color, #667eea);
}

[data-mode="light"] .current-chat-title {
    color: rgba(0, 0, 0, 0.5);
}

[data-mode="light"] .btn.secondary, .theme-btn {
    background: var(--sidebar-bg);
    color: var(--foreground);
    border: 1.5px solid var(--glass-border);
}

.btn.secondary:hover, .theme-btn:hover {
    background: var(--main-bg);
    color: var(--foreground);
    border-color: var(--primary-gradient, #667eea);
}

.btn.secondary i, .theme-btn i {
    color: var(--foreground);
}

/* Danger button */
.btn.danger {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn.danger:hover {
    background: rgba(255, 71, 87, 0.3);
    border-color: rgba(255, 71, 87, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
}

.btn.danger:active {
    transform: translateY(0) scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Button icon animation */
.btn i {
    transition: transform 0.3s ease;
}

.btn:hover:not(:disabled) i {
    transform: scale(1.1);
}

.btn.primary:hover:not(:disabled) i {
    animation: pulse-icon 0.6s ease;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.3); }
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    background: transparent;
}

.welcome-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    animation: welcomeFadeIn 0.8s ease-out;
}

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

.welcome-content {
    max-width: 500px;
    padding: 0;
    background: none;
    border-radius: 0;
    border: none;
    backdrop-filter: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.welcome-logo {
    width: 56px;
    height: 56px;
}

.welcome-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 14px;
    opacity: 0.7;
}

.welcome-greeting {
    font-size: 26px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: -0.3px;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--foreground);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.suggestion-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

.suggestion-chip i {
    font-size: 16px;
    color: var(--primary-gradient, #667eea);
    background: var(--main-bg, #fff);
    border: 2px solid var(--primary-gradient, #667eea);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0);
    transition: all 0.3s ease;
}

.suggestion-chip:hover i {
    background: var(--primary-gradient, #667eea);
    color: #fff;
    border-color: var(--primary-gradient, #667eea);
}

.welcome-icon {
    font-size: 64px;
    color: var(--primary-color, #667eea);
    margin-bottom: 25px;
    opacity: 0.8;
}

.welcome-content h2 {
    color: var(--primary-color, #667eea);
    margin-bottom: 15px;
    font-size: 36px;
    font-weight: 600;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.welcome-content p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    line-height: 1.7;
    margin-bottom: 10px;
}

/* Feature Highlights in Welcome Screen */
.feature-highlights {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 20px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.08);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 16px;
    text-align: left;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.feature-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
    transition: left 0.5s ease;
}

.feature-item:hover::before {
    left: 100%;
}

.feature-item:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    transform: translateX(8px) scale(1.02);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.feature-item i {
    font-size: 24px;
    color: var(--primary-color, #667eea);
    width: 40px;
    flex-shrink: 0;
}

.feature-item span {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1.5;
}

.feature-item strong {
    color: rgba(255, 255, 255, 0.95);
}

.message {
    display: flex;
    margin-bottom: 20px;
    align-items: flex-start;
    animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--foreground);
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary-color, #667eea);
    margin-left: 15px;
}

.message.ai .message-avatar {
    background: #3a7bd5;
    margin-right: 15px;
}

.ai-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message-content {
    border-radius: 20px;
    padding: 18px 22px;
    max-width: 75%;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: all 0.3s ease;
}

.message-content:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.message.user .message-content {
    background: var(--primary-color, #667eea);
    color: var(--foreground);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 30px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.message.ai .message-content {
    background: rgba(30, 30, 50, 0.6);
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Streaming message cursor animation */
.message.streaming .cursor {
    display: inline-block;
    width: 8px;
    height: 18px;
    background: rgba(255, 255, 255, 0.8);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

.message.streaming .streaming-text {
    min-height: 24px;
}

.message-content p {
    margin: 0;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* KaTeX Math/Fraction Styling */
.message-content .katex {
    font-size: 1.1em;
    color: inherit;
}

.message-content .katex-display {
    margin: 1em 0;
    text-align: center;
}

.message-content .katex-display > .katex {
    font-size: 1.2em;
}

/* Message action buttons (copy, speak) */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 36px;
    height: 36px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--foreground);
    transform: translateY(-1px);
}

.action-btn.speaking {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    color: var(--primary-color, #667eea);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

.action-copy:hover {
    background: rgba(46, 204, 113, 0.2);
    border-color: rgba(46, 204, 113, 0.4);
    color: #2ecc71;
}

.action-speak:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    color: var(--primary-color, #667eea);
}

.input-container {
    padding: 25px 30px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 5;
}

/* Image preview container */
.image-preview-container {
    margin-bottom: 15px;
}

.image-preview-container.hidden {
    display: none;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 200px;
}

.image-preview-wrapper img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 12px;
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    object-fit: cover;
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff4757;
    color: var(--foreground);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

.remove-image-btn:hover {
    background: #ff3344;
    transform: scale(1.1);
}

/* Hidden file input */
.hidden-file-input {
    display: none;
}

/* Unified input button styles */
.input-wrapper .btn {
    padding: 14px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.input-wrapper .btn i {
    font-size: 16px;
}

/* Upload button */
.upload-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.upload-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    transform: scale(1.05);
}

/* Message image display */
.message-image {
    margin-bottom: 10px;
}

.message-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    object-fit: contain;
}

/* Drag over state */
#messageInput.drag-over {
    border-color: var(--primary-color, #667eea);
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 15px 20px;
    font-size: 16px;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 52px;
    line-height: 1.5;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(20, 20, 35, 0.6);
    color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#messageInput:focus {
    border-color: var(--primary-color, #667eea);
    box-shadow: 0 0 0 4px rgba(var(--primary-color-rgb, 102, 126, 234), 0.2), 0 4px 30px rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    background: rgba(25, 25, 45, 0.8);
}

#messageInput::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

#sendButton {
    padding: 14px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color, #667eea);
    border: none;
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

#sendButton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
    transition: left 0.5s ease;
}

#sendButton:hover:not(:disabled)::before {
    left: 100%;
}

#sendButton:hover:not(:disabled) {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 25px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
}

#sendButton:active:not(:disabled) {
    transform: scale(0.95) rotate(0deg);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#sendButton i {
    color: var(--foreground);
    font-size: 16px;
    transition: transform 0.3s ease;
}

#sendButton:hover:not(:disabled) i {
    transform: translateX(2px);
}

.input-footer {
    margin-top: 12px;
    text-align: center;
}

.input-footer small {
    color: var(--foreground);
    font-size: 12px;
    letter-spacing: 0.3px;
}

.loading-indicator {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: white;
    padding: 16px 28px;
    border-radius: 30px;
    display: none;
    align-items: center;
    gap: 14px;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4); }
    50% { box-shadow: 0 8px 48px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6); }
}

.loading-indicator.show {
    display: flex;
    animation: loadingSlideIn 0.3s ease-out, loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.typing-indicator {
    display: flex;
    gap: 6px;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: white;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-container::-webkit-scrollbar,
.recent-chats::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track,
.recent-chats::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb,
.recent-chats::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.recent-chats::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
    }
    
    .chat-container {
        padding: 25px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        background: rgba(26, 26, 26, 0.95);
        backdrop-filter: blur(20px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .mobile-only {
        display: flex;
    }
    
    .main-content {
        width: 100%;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .current-chat-title {
        display: none;
    }
    
    .chat-container {
        padding: 20px 15px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 15px 18px;
    }
    
    .input-container {
        padding: 20px 15px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .welcome-content h2 {
        font-size: 28px;
    }
    
    .welcome-content p {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }
    
    .chat-container {
        padding: 15px 10px;
    }
    
    .input-container {
        padding: 15px 10px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 12px 15px;
    }
    
    #messageInput {
        font-size: 14px;
        padding: 12px 15px;
    }
    
    .welcome-content h2 {
        font-size: 24px;
    }
    
    .welcome-content p {
        font-size: 14px;
    }
    
    .sidebar {
        width: 260px;
    }
}

/* Dark mode overlay for mobile sidebar */
@media (max-width: 768px) {
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Always show toggle button on mobile */
    .sidebar-toggle-btn {
        display: flex !important;
    }
}

/* ==================== THEME SYSTEM ==================== */

/* Theme Selector Styles */
.theme-selector {
    position: relative;
    width: 100%;
}

.theme-btn {
    width: 100%;
    justify-content: center;
}

.theme-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 8px;
    display: none;
    z-index: 1001;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: dropdownFadeIn 0.2s ease;
}

.theme-dropdown.show {
    display: block;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.8);
}

.theme-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 1);
    transform: translateX(4px);
}

.theme-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-left: 3px solid var(--primary-color, #667eea);
}

.theme-preview {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid var(--glass-border);
    background: var(--main-bg);
    color: var(--foreground);
}

.theme-option:hover .theme-preview {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Theme preview colors */
.light-blue-preview {
    background: #4facfe;
}

.dark-blue-preview {
    background: #0f1419;
}

.ocean-preview {
    background: #2193b0;
}

.sunset-preview {
    background: #ff7e5f;
}

.forest-preview {
    background: #11998e;
}

.purple-preview {
    background: var(--primary-color, #667eea);
}

/* Connection Status Styles */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    transition: all 0.3s ease;
}

.connection-status:hover {
    background: rgba(74, 222, 128, 0.15);
    transform: scale(1.02);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
}

.status-indicator.online {
    background: #4ade80;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.8);
    animation: statusGlow 2s ease-in-out infinite;
}

.status-indicator.online::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 2px solid rgba(74, 222, 128, 0.4);
    animation: statusRing 2s ease-in-out infinite;
}

@keyframes statusGlow {
    0%, 100% { box-shadow: 0 0 12px rgba(74, 222, 128, 0.8); }
    50% { box-shadow: 0 0 20px rgba(74, 222, 128, 1); }
}

@keyframes statusRing {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0; }
}

.status-indicator.offline {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    animation: none;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.status-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Message Counter Styles */
.message-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    font-weight: 500;
}

#messageCount {
    background: var(--primary-color, #667eea);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    font-weight: 600;
}

/* ==================== THEME DEFINITIONS ==================== */

/* Default/Purple Theme (already applied) */
:root {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-color-rgb: 102, 126, 234;
    --primary-dark-rgb: 118, 75, 162;

    --bg-gradient-1: #0f1419;
    --bg-gradient-2: #1a1f2e;
    --ai-gradient-1: #00d2ff;
    --ai-gradient-2: #3a7bd5;
}

/* Light Blue Theme */
[data-theme="light-blue"] {
    --primary-color: #4facfe;
    --primary-dark: #00f2fe;
    --primary-color-rgb: 79, 172, 254;
    --primary-dark-rgb: 0, 242, 254;

    --bg-gradient-1: #1a2a3a;
    --bg-gradient-2: #0d1b2a;
    --ai-gradient-1: #4facfe;
    --ai-gradient-2: #00f2fe;
}

[data-theme="light-blue"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="light-blue"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

[data-theme="light-blue"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.5);
}

[data-theme="light-blue"] .message.user .message-content,
[data-theme="light-blue"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="light-blue"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="light-blue"] .welcome-icon,
[data-theme="light-blue"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="light-blue"] .chat-item.active {
    background: rgba(79, 172, 254, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="light-blue"] .loading-indicator {
    background: rgba(79, 172, 254, 0.9);
}

/* Dark Blue Theme */
[data-theme="dark-blue"] {
    --primary-color: #3b82f6;
    --primary-dark: #1e40af;
    --primary-color-rgb: 59, 130, 246;
    --primary-dark-rgb: 30, 64, 175;

    --bg-gradient-1: #0a0f1a;
    --bg-gradient-2: #111827;
    --ai-gradient-1: #3b82f6;
    --ai-gradient-2: #1e40af;
}

[data-theme="dark-blue"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="dark-blue"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

[data-theme="dark-blue"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

[data-theme="dark-blue"] .message.user .message-content,
[data-theme="dark-blue"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="dark-blue"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="dark-blue"] .welcome-icon,
[data-theme="dark-blue"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="dark-blue"] .chat-item.active {
    background: rgba(59, 130, 246, 0.2);
    border-left-color: var(--primary-color);
}
[data-theme="dark-blue"] .loading-indicator {
    background: rgba(59, 130, 246, 0.9);
}

[data-theme="dark-blue"] .loading-indicator {
    background: rgba(59, 130, 246, 0.9);
}

/* Ocean Theme */
[data-theme="ocean"] {
    --primary-color: #2193b0;
    --primary-dark: #6dd5ed;
    --primary-color-rgb: 33, 147, 176;
    --primary-dark-rgb: 109, 213, 237;

    --bg-gradient-1: #0c1821;
    --bg-gradient-2: #1b3a4b;
    --ai-gradient-1: #2193b0;
    --ai-gradient-2: #6dd5ed;
}

[data-theme="ocean"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="ocean"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(33, 147, 176, 0.3);
}

[data-theme="ocean"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(33, 147, 176, 0.5);
}

[data-theme="ocean"] .message.user .message-content,
[data-theme="ocean"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="ocean"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="ocean"] .welcome-icon,
[data-theme="ocean"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="ocean"] .chat-item.active {
    background: rgba(33, 147, 176, 0.2);
    border-left-color: var(--primary-color);
}
[data-theme="ocean"] .loading-indicator {
    background: rgba(33, 147, 176, 0.9);
}

[data-theme="ocean"] .loading-indicator {
    background: rgba(33, 147, 176, 0.9);
}

/* Sunset Theme */
[data-theme="sunset"] {
    --primary-color: #ff7e5f;
    --primary-dark: #feb47b;
    --primary-color-rgb: 255, 126, 95;
    --primary-dark-rgb: 254, 180, 123;

    --bg-gradient-1: #1a1012;
    --bg-gradient-2: #2d1f1f;
    --ai-gradient-1: #ff7e5f;
    --ai-gradient-2: #feb47b;
}

[data-theme="sunset"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="sunset"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(255, 126, 95, 0.3);
}

[data-theme="sunset"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(255, 126, 95, 0.5);
}

[data-theme="sunset"] .message.user .message-content,
[data-theme="sunset"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="sunset"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="sunset"] .welcome-icon,
[data-theme="sunset"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="sunset"] .chat-item.active {
    background: rgba(255, 126, 95, 0.2);
    border-left-color: var(--primary-color);
}
[data-theme="sunset"] .loading-indicator {
    background: rgba(255, 126, 95, 0.9);
}

[data-theme="sunset"] .loading-indicator {
    background: rgba(255, 126, 95, 0.9);
}

/* Forest Theme */
[data-theme="forest"] {
    --primary-color: #11998e;
    --primary-dark: #38ef7d;
    --primary-color-rgb: 17, 153, 142;
    --primary-dark-rgb: 56, 239, 125;

    --bg-gradient-1: #0a1510;
    --bg-gradient-2: #1a2f23;
    --ai-gradient-1: #11998e;
    --ai-gradient-2: #38ef7d;
}

[data-theme="forest"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="forest"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(17, 153, 142, 0.3);
}

[data-theme="forest"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(17, 153, 142, 0.5);
}

[data-theme="forest"] .message.user .message-content,
[data-theme="forest"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="forest"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="forest"] .welcome-icon,
[data-theme="forest"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="forest"] .chat-item.active {
    background: rgba(17, 153, 142, 0.2);
    border-left-color: var(--primary-color);
}
[data-theme="forest"] .loading-indicator {
    background: rgba(17, 153, 142, 0.9);
}

[data-theme="forest"] .loading-indicator {
    background: rgba(17, 153, 142, 0.9);
}

/* Purple Theme (default values, explicit declaration) */
[data-theme="purple"] {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-color-rgb: 102, 126, 234;
    --primary-dark-rgb: 118, 75, 162;

    --bg-gradient-1: #0f1419;
    --bg-gradient-2: #1a1f2e;
    --ai-gradient-1: #00d2ff;
    --ai-gradient-2: #3a7bd5;
}

[data-theme="purple"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="purple"] .btn.primary {
    background: var(--primary-color);
}

[data-theme="purple"] .message.user .message-content,
[data-theme="purple"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="purple"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

/* Mobile responsive updates for theme elements */
@media (max-width: 768px) {
    .connection-status {
        display: none;
    }
    
    .message-counter {
        display: none;
    }
    
    .theme-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 280px;
        max-width: 90vw;
    }
    
    .theme-dropdown.show {
        animation: mobileDropdownFadeIn 0.3s ease;
    }
    
    @keyframes mobileDropdownFadeIn {
        from {
            opacity: 0;
            transform: translate(-50%, -50%) scale(0.9);
        }
        to {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
    }
}

/* ============================================
   AI PERSONALITY MODE SELECTOR
   ============================================ */

.personality-selector {
    position: relative;
}

.personality-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.personality-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.personality-btn i {
    color: var(--primary-color, #667eea);
}

.personality-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: rgba(30, 30, 40, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.personality-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.personality-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 6px;
}

.personality-option:last-child {
    margin-bottom: 0;
}

.personality-option:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
}

.personality-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

.personality-option i {
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 10px;
    color: var(--primary-color, #667eea);
}

.personality-option.active i {
    background: var(--primary-color, #667eea);
    color: white;
}

.personality-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.personality-name {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
}

.personality-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   FLOATING PERSONALITY OVERLAY
   ============================================ */

.personality-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.personality-overlay.show {
    display: flex;
    animation: overlayFadeIn 0.25s ease;
}

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

.personality-overlay-content {
    background: rgba(18, 18, 28, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 28px;
    width: 420px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    animation: panelSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.personality-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    position: relative;
}

.overlay-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.overlay-title i {
    color: var(--primary-color, #667eea);
    font-size: 20px;
}

.overlay-subtitle {
    position: absolute;
    bottom: -4px;
    left: 0;
    font-size: 12px;
    color: var(--foreground);
    margin: 0;
}

.overlay-close {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.overlay-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.personality-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.personality-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.personality-card:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
}

.personality-card.active {
    background: #d1e7ff; /* Light blue background for active card */
    color: #000; /* Black text for better contrast */
    border: 2px solid #4a90e2; /* Highlighted border */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Subtle shadow for emphasis */
}

.personality-card.active .personality-card-header h3 {
    color: #4a90e2; /* Highlighted header text */
}

.personality-card.active .personality-description {
    color: #333; /* Darker text for description */
}

.personality-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.personality-card-icon i {
    font-size: 18px;
    color: var(--primary-color, #667eea);
    transition: all 0.2s ease;
}

.personality-card.active .personality-card-icon {
    background: var(--primary-color, #667eea);
}

.personality-card.active .personality-card-icon i {
    color: white;
}

.personality-card-info {
    flex: 1;
    min-width: 0;
}

.personality-card-info h3 {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 2px 0;
}

.personality-card-info p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
}

.personality-check {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.personality-check i {
    font-size: 10px;
    color: transparent;
    transition: all 0.2s ease;
}

.personality-card.active .personality-check {
    background: var(--primary-color, #667eea);
    border-color: var(--primary-color, #667eea);
}

.personality-card.active .personality-check i {
    color: white;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile responsiveness for personality overlay */
@media (max-width: 768px) {
    .personality-overlay-content {
        margin: 12px;
        padding: 20px;
        max-height: 90vh;
    }
    
    .overlay-title {
        font-size: 16px;
    }
}

/* ============================================
   VOICE INPUT STYLES
   ============================================ */

.voice-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    position: relative;
    overflow: hidden;
}

.voice-btn::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--primary-color, #667eea);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 50%;
}

.voice-btn:hover {
    transform: scale(1.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.8);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.voice-btn:hover::before {
    opacity: 0.2;
}

.voice-btn i {
    font-size: 18px;
    color: var(--primary-color, #667eea);
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

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

.voice-btn.listening {
    background: #ff4757;
    border-color: transparent;
    animation: voicePulse 1.5s infinite;
    transform: scale(1.1);
}

.voice-btn.listening::before {
    opacity: 0;
}

.voice-btn.listening i {
    color: white;
    animation: micBounce 0.5s ease infinite;
}

@keyframes micBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Auto-Read Button Styles */
.auto-read-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

.auto-read-btn i {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
}

.auto-read-btn:hover {
    transform: scale(1.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.auto-read-btn:hover i {
    color: var(--primary-color, #667eea);
}

.auto-read-btn.active {
    background: var(--primary-color, #667eea);
    border-color: transparent;
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.auto-read-btn.active i {
    color: white;
}

.auto-read-btn.active.speaking {
    animation: speakingGlow 1.5s infinite;
}

@keyframes speakingGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 102, 126, 234), 0.6), 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(var(--primary-color-rgb, 102, 126, 234), 0), 0 4px 30px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    }
}

.voice-status {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(255, 71, 87, 0.9);
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(255, 71, 87, 0.4);
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
}

.voice-status.hidden {
    display: none;
}

.voice-pulse {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: voiceDot 1s infinite;
}

@keyframes voiceDot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

/* Voice wave animation for status */
.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.voice-wave span {
    width: 3px;
    height: 100%;
    background: white;
    border-radius: 2px;
    animation: voiceWave 0.5s infinite ease-in-out;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes voiceWave {
    0%, 100% {
        transform: scaleY(0.3);
    }
    50% {
        transform: scaleY(1);
    }
}

/* ============================================
   PERSONALITY INDICATOR IN MESSAGES
   ============================================ */

.personality-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
}

.personality-badge i {
    font-size: 10px;
    color: var(--primary-color, #667eea);
}

/* ============================================
RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .personality-btn span {
        display: none;
    }
    
    .personality-btn {
        padding: 8px 12px;
    }
    
    .personality-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 320px;
    }
    
    .personality-dropdown.show {
        transform: translate(-50%, -50%);
    }
    
    .voice-status {
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* ============================================
   THEME VARIATIONS FOR PERSONALITY
   ============================================ */

[data-theme="ocean"] .personality-btn {
    background: rgba(0, 180, 219, 0.2);
    border-color: rgba(0, 180, 219, 0.4);
}

[data-theme="ocean"] .personality-btn i,
[data-theme="ocean"] .personality-option i {
    color: #00b4db;
}

[data-theme="sunset"] .personality-btn {
    background: rgba(255, 94, 98, 0.2);
    border-color: rgba(255, 94, 98, 0.4);
}

[data-theme="sunset"] .personality-btn i,
[data-theme="sunset"] .personality-option i {
    color: #ff5e62;
}

[data-theme="forest"] .personality-btn {
    background: rgba(17, 153, 142, 0.2);
    border-color: rgba(17, 153, 142, 0.4);
}

[data-theme="forest"] .personality-btn i,
[data-theme="forest"] .personality-option i {
    color: #11998e;
}

/* Image Generation Styles */
.generate-image-btn {
    background: rgba(147, 51, 234, 0.2);
    border: 2px solid rgba(147, 51, 234, 0.4);
    color: #c084fc;
}

.generate-image-btn:hover {
    background: rgba(147, 51, 234, 0.4);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.4);
}

.generate-image-btn i {
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.generating-image .message-avatar {
    background: #9333ea;
}

.generating-image .message-avatar i {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.image-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    text-align: center;
}

.image-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(147, 51, 234, 0.2);
    border-top: 3px solid #9333ea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.image-prompt-preview {
    font-style: italic;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 10px;
    font-size: 0.9em;
}

.generated-image-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 100%;
}

.generated-image-caption {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

.generated-image-prompt {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9em;
    margin: 0;
}

.generated-image-wrapper {
    position: relative;
    max-width: 512px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.generated-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.generated-image.loaded {
    opacity: 1;
}

.image-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(147, 51, 234, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    min-height: 200px;
    transition: opacity 0.3s ease;
}

.image-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.image-loading-overlay.error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    font-size: 0.9em;
}

.generated-image-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.image-action-btn {
    padding: 8px 16px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.image-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.regenerate-btn {
    background: rgba(147, 51, 234, 0.2);
    border-color: rgba(147, 51, 234, 0.4);
}

.regenerate-btn:hover {
    background: rgba(147, 51, 234, 0.4);
}

/* Light theme adjustments for image generation */
[data-theme="light-blue"] .generate-image-btn {
    background: rgba(147, 51, 234, 0.15);
    color: #9333ea;
}

[data-theme="light-blue"] .generated-image-caption {
    color: rgba(0, 0, 0, 0.9);
}

[data-theme="light-blue"] .generated-image-prompt {
    color: rgba(0, 0, 0, 0.6);
}

[data-theme="light-blue"] .image-action-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
    color: rgba(0, 0, 0, 0.8);
}

[data-theme="light-blue"] .image-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ============================================
   DARK MODE TOGGLE BUTTON
   ============================================ */

.dark-mode-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 16px;
}

/* ============================================
   LIGHT MODE STYLES
   ============================================ */

[data-mode="light"] body {
    background: #f5f6fa;
}

[data-mode="light"] .app {
    background: #f5f6fa;
}

[data-mode="light"] .sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(0, 0, 0, 0.08);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.05);
}

[data-mode="light"] .sidebar-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .sidebar-footer {
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .recent-chats-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .recent-chats-header h3 {
    color: rgba(0, 0, 0, 0.6);
}

[data-mode="light"] .chat-item {
    color: rgba(0, 0, 0, 0.7);
}

[data-mode="light"] .chat-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.9);
}

[data-mode="light"] .chat-item.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
    color: var(--primary-color, #667eea);
    border-left: 3px solid var(--primary-color, #667eea);
}

[data-mode="light"] .header {
    background: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.05);
    color: #1a1a2e;
}

[data-mode="light"] .brand-name {
    color: var(--primary-color, #667eea);
}

[data-mode="light"] .current-chat-title {
    color: rgba(0, 0, 0, 0.5);
}

[data-mode="light"] .btn.secondary, .theme-btn {
    background: var(--sidebar-bg);
    color: var(--foreground);
    border: 1.5px solid var(--glass-border);
}

.btn.secondary:hover, .theme-btn:hover {
    background: var(--main-bg);
    color: var(--foreground);
    border-color: var(--primary-gradient, #667eea);
}

.btn.secondary i, .theme-btn i {
    color: var(--foreground);
}

/* Danger button */
.btn.danger {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn.danger:hover {
    background: rgba(255, 71, 87, 0.3);
    border-color: rgba(255, 71, 87, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
}

.btn.danger:active {
    transform: translateY(0) scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Button icon animation */
.btn i {
    transition: transform 0.3s ease;
}

.btn:hover:not(:disabled) i {
    transform: scale(1.1);
}

.btn.primary:hover:not(:disabled) i {
    animation: pulse-icon 0.6s ease;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.3); }
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    background: transparent;
}

.welcome-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    text-align: center;
    animation: welcomeFadeIn 0.8s ease-out;
}

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

.welcome-content {
    max-width: 500px;
    padding: 0;
    background: none;
    border-radius: 0;
    border: none;
    backdrop-filter: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.welcome-logo {
    width: 56px;
    height: 56px;
}

.welcome-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 14px;
    opacity: 0.7;
}

.welcome-greeting {
    font-size: 26px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: -0.3px;
}

.welcome-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px;
}

.suggestion-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--foreground);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.suggestion-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.85);
}

.suggestion-chip i {
    font-size: 16px;
    color: var(--primary-gradient, #667eea);
    background: var(--main-bg, #fff);
    border: 2px solid var(--primary-gradient, #667eea);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    box-shadow: 0 2px 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0);
    transition: all 0.3s ease;
}

.suggestion-chip:hover i {
    background: var(--primary-gradient, #667eea);
    color: #fff;
    border-color: var(--primary-gradient, #667eea);
}

.welcome-icon {
    font-size: 64px;
    color: var(--primary-color, #667eea);
    margin-bottom: 25px;
    opacity: 0.8;
}

.welcome-content h2 {
    color: var(--primary-color, #667eea);
    margin-bottom: 15px;
    font-size: 36px;
    font-weight: 600;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.welcome-content p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 16px;
    line-height: 1.7;
    margin-bottom: 10px;
}

/* Feature Highlights in Welcome Screen */
.feature-highlights {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 20px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.08);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 16px;
    text-align: left;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.feature-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.05);
    transition: left 0.5s ease;
}

.feature-item:hover::before {
    left: 100%;
}

.feature-item:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    transform: translateX(8px) scale(1.02);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.feature-item i {
    font-size: 24px;
    color: var(--primary-color, #667eea);
    width: 40px;
    flex-shrink: 0;
}

.feature-item span {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    line-height: 1.5;
}

.feature-item strong {
    color: rgba(255, 255, 255, 0.95);
}

.message {
    display: flex;
    margin-bottom: 20px;
    align-items: flex-start;
    animation: messageSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--foreground);
    font-weight: bold;
    font-size: 16px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--primary-color, #667eea);
    margin-left: 15px;
}

.message.ai .message-avatar {
    background: #3a7bd5;
    margin-right: 15px;
}

.ai-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.message-content {
    border-radius: 20px;
    padding: 18px 22px;
    max-width: 75%;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    word-wrap: break-word;
    overflow-wrap: break-word;
    transition: all 0.3s ease;
}

.message-content:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.message.user .message-content {
    background: var(--primary-color, #667eea);
    color: var(--foreground);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 30px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.message.ai .message-content {
    background: rgba(30, 30, 50, 0.6);
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Streaming message cursor animation */
.message.streaming .cursor {
    display: inline-block;
    width: 8px;
    height: 18px;
    background: rgba(255, 255, 255, 0.8);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

.message.streaming .streaming-text {
    min-height: 24px;
}

.message-content p {
    margin: 0;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-content code {
    background: rgba(0, 0, 0, 0.3);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* KaTeX Math/Fraction Styling */
.message-content .katex {
    font-size: 1.1em;
    color: inherit;
}

.message-content .katex-display {
    margin: 1em 0;
    text-align: center;
}

.message-content .katex-display > .katex {
    font-size: 1.2em;
}

/* Message action buttons (copy, speak) */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.action-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 36px;
    height: 36px;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--foreground);
    transform: translateY(-1px);
}

.action-btn.speaking {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    color: var(--primary-color, #667eea);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

.action-copy:hover {
    background: rgba(46, 204, 113, 0.2);
    border-color: rgba(46, 204, 113, 0.4);
    color: #2ecc71;
}

.action-speak:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    color: var(--primary-color, #667eea);
}

.input-container {
    padding: 25px 30px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 5;
}

/* Image preview container */
.image-preview-container {
    margin-bottom: 15px;
}

.image-preview-container.hidden {
    display: none;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 200px;
}

.image-preview-wrapper img {
    max-width: 100%;
    max-height: 150px;
    border-radius: 12px;
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    object-fit: cover;
}

.remove-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff4757;
    color: var(--foreground);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
}

.remove-image-btn:hover {
    background: #ff3344;
    transform: scale(1.1);
}

/* Hidden file input */
.hidden-file-input {
    display: none;
}

/* Unified input button styles */
.input-wrapper .btn {
    padding: 14px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.input-wrapper .btn i {
    font-size: 16px;
}

/* Upload button */
.upload-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.upload-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    transform: scale(1.05);
}

/* Message image display */
.message-image {
    margin-bottom: 10px;
}

.message-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    object-fit: contain;
}

/* Drag over state */
#messageInput.drag-over {
    border-color: var(--primary-color, #667eea);
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 15px 20px;
    font-size: 16px;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 52px;
    line-height: 1.5;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(20, 20, 35, 0.6);
    color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

#messageInput:focus {
    border-color: var(--primary-color, #667eea);
    box-shadow: 0 0 0 4px rgba(var(--primary-color-rgb, 102, 126, 234), 0.2), 0 4px 30px rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    background: rgba(25, 25, 45, 0.8);
}

#sendButton {
    padding: 14px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color, #667eea);
    border: none;
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

#sendButton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.15);
    transition: left 0.5s ease;
}

#sendButton:hover:not(:disabled)::before {
    left: 100%;
}

#sendButton:hover:not(:disabled) {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 6px 25px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
}

#sendButton:active:not(:disabled) {
    transform: scale(0.95) rotate(0deg);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#sendButton i {
    color: var(--foreground);
    font-size: 16px;
    transition: transform 0.3s ease;
}

#sendButton:hover:not(:disabled) i {
    transform: translateX(2px);
}

.input-footer {
    margin-top: 12px;
    text-align: center;
}

.input-footer small {
    color: var(--foreground);
    font-size: 12px;
    letter-spacing: 0.3px;
}

.loading-indicator {
    position: absolute;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.95);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: white;
    padding: 16px 28px;
    border-radius: 30px;
    display: none;
    align-items: center;
    gap: 14px;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4), 0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4); }
    50% { box-shadow: 0 8px 48px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6); }
}

.loading-indicator.show {
    display: flex;
    animation: loadingSlideIn 0.3s ease-out, loadingPulse 2s ease-in-out infinite;
}

@keyframes loadingSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.typing-indicator {
    display: flex;
    gap: 6px;
}

.typing-indicator span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: white;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-container::-webkit-scrollbar,
.recent-chats::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track,
.recent-chats::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb,
.recent-chats::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover,
.recent-chats::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        width: 260px;
    }
    
    .chat-container {
        padding: 25px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px;
        z-index: 1000;
        background: rgba(26, 26, 26, 0.95);
        backdrop-filter: blur(20px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: block;
    }
    
    .mobile-only {
        display: flex;
    }
    
    .main-content {
        width: 100%;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .header h1 {
        font-size: 18px;
    }
    
    .current-chat-title {
        display: none;
    }
    
    .chat-container {
        padding: 20px 15px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 15px 18px;
    }
    
    .input-container {
        padding: 20px 15px;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .welcome-content h2 {
        font-size: 28px;
    }
    
    .welcome-content p {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 16px;
    }
    
    .chat-container {
        padding: 15px 10px;
    }
    
    .input-container {
        padding: 15px 10px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 12px 15px;
    }
    
    #messageInput {
        font-size: 14px;
        padding: 12px 15px;
    }
    
    .welcome-content h2 {
        font-size: 24px;
    }
    
    .welcome-content p {
        font-size: 14px;
    }
    
    .sidebar {
        width: 260px;
    }
}

/* Dark mode overlay for mobile sidebar */
@media (max-width: 768px) {
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* Always show toggle button on mobile */
    .sidebar-toggle-btn {
        display: flex !important;
    }
}

/* ==================== THEME SYSTEM ==================== */

/* Theme Selector Styles */
.theme-selector {
    position: relative;
    width: 100%;
}

.theme-btn {
    width: 100%;
    justify-content: center;
}

.theme-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 8px;
    display: none;
    z-index: 1001;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: dropdownFadeIn 0.2s ease;
}

.theme-dropdown.show {
    display: block;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: rgba(255, 255, 255, 0.8);
}

.theme-option:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 1);
    transform: translateX(4px);
}

.theme-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-left: 3px solid var(--primary-color, #667eea);
}

.theme-preview {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid var(--glass-border);
    background: var(--main-bg);
    color: var(--foreground);
}

.theme-option:hover .theme-preview {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Theme preview colors */
.light-blue-preview {
    background: #4facfe;
}

.dark-blue-preview {
    background: #0f1419;
}

.ocean-preview {
    background: #2193b0;
}

.sunset-preview {
    background: #ff7e5f;
}

.forest-preview {
    background: #11998e;
}

.purple-preview {
    background: var(--primary-color, #667eea);
}

/* Connection Status Styles */
.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    transition: all 0.3s ease;
}

.connection-status:hover {
    background: rgba(74, 222, 128, 0.15);
    transform: scale(1.02);
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    position: relative;
}

.status-indicator.online {
    background: #4ade80;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.8);
    animation: statusGlow 2s ease-in-out infinite;
}

.status-indicator.online::after {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    right: -3px;
    bottom: -3px;
    border-radius: 50%;
    border: 2px solid rgba(74, 222, 128, 0.4);
    animation: statusRing 2s ease-in-out infinite;
}

@keyframes statusGlow {
    0%, 100% { box-shadow: 0 0 12px rgba(74, 222, 128, 0.8); }
    50% { box-shadow: 0 0 20px rgba(74, 222, 128, 1); }
}

@keyframes statusRing {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0; }
}

.status-indicator.offline {
    background: #ef4444;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
    animation: none;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

.status-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* Message Counter Styles */
.message-counter {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    font-weight: 500;
}

#messageCount {
    background: var(--primary-color, #667eea);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    font-weight: 600;
}

/* ==================== THEME DEFINITIONS ==================== */

/* Default/Purple Theme (already applied) */
:root {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-color-rgb: 102, 126, 234;
    --primary-dark-rgb: 118, 75, 162;

    --bg-gradient-1: #0f1419;
    --bg-gradient-2: #1a1f2e;
    --ai-gradient-1: #00d2ff;
    --ai-gradient-2: #3a7bd5;
}

/* Light Blue Theme */
[data-theme="light-blue"] {
    --primary-color: #4facfe;
    --primary-dark: #00f2fe;
    --primary-color-rgb: 79, 172, 254;
    --primary-dark-rgb: 0, 242, 254;

    --bg-gradient-1: #1a2a3a;
    --bg-gradient-2: #0d1b2a;
    --ai-gradient-1: #4facfe;
    --ai-gradient-2: #00f2fe;
}

[data-theme="light-blue"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="light-blue"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

[data-theme="light-blue"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(79, 172, 254, 0.5);
}

[data-theme="light-blue"] .message.user .message-content,
[data-theme="light-blue"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="light-blue"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="light-blue"] .welcome-icon,
[data-theme="light-blue"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="light-blue"] .chat-item.active {
    background: rgba(79, 172, 254, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="light-blue"] #messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.2);
}

[data-theme="light-blue"] .loading-indicator {
    background: rgba(79, 172, 254, 0.9);
}

/* Dark Blue Theme */
[data-theme="dark-blue"] {
    --primary-color: #3b82f6;
    --primary-dark: #1e40af;
    --primary-color-rgb: 59, 130, 246;
    --primary-dark-rgb: 30, 64, 175;

    --bg-gradient-1: #0a0f1a;
    --bg-gradient-2: #111827;
    --ai-gradient-1: #3b82f6;
    --ai-gradient-2: #1e40af;
}

[data-theme="dark-blue"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="dark-blue"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

[data-theme="dark-blue"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

[data-theme="dark-blue"] .message.user .message-content,
[data-theme="dark-blue"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="dark-blue"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="dark-blue"] .welcome-icon,
[data-theme="dark-blue"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="dark-blue"] .chat-item.active {
    background: rgba(59, 130, 246, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="dark-blue"] #messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[data-theme="dark-blue"] .loading-indicator {
    background: rgba(59, 130, 246, 0.9);
}

/* Ocean Theme */
[data-theme="ocean"] {
    --primary-color: #2193b0;
    --primary-dark: #6dd5ed;
    --primary-color-rgb: 33, 147, 176;
    --primary-dark-rgb: 109, 213, 237;

    --bg-gradient-1: #0c1821;
    --bg-gradient-2: #1b3a4b;
    --ai-gradient-1: #2193b0;
    --ai-gradient-2: #6dd5ed;
}

[data-theme="ocean"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="ocean"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(33, 147, 176, 0.3);
}

[data-theme="ocean"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(33, 147, 176, 0.5);
}

[data-theme="ocean"] .message.user .message-content,
[data-theme="ocean"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="ocean"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="ocean"] .welcome-icon,
[data-theme="ocean"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="ocean"] .chat-item.active {
    background: rgba(33, 147, 176, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="ocean"] #messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 147, 176, 0.2);
}

[data-theme="ocean"] .loading-indicator {
    background: rgba(33, 147, 176, 0.9);
}

/* Sunset Theme */
[data-theme="sunset"] {
    --primary-color: #ff7e5f;
    --primary-dark: #feb47b;
    --primary-color-rgb: 255, 126, 95;
    --primary-dark-rgb: 254, 180, 123;

    --bg-gradient-1: #1a1012;
    --bg-gradient-2: #2d1f1f;
    --ai-gradient-1: #ff7e5f;
    --ai-gradient-2: #feb47b;
}

[data-theme="sunset"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="sunset"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(255, 126, 95, 0.3);
}

[data-theme="sunset"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(255, 126, 95, 0.5);
}

[data-theme="sunset"] .message.user .message-content,
[data-theme="sunset"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="sunset"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="sunset"] .welcome-icon,
[data-theme="sunset"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="sunset"] .chat-item.active {
    background: rgba(255, 126, 95, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="sunset"] #messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 126, 95, 0.2);
}

[data-theme="sunset"] .loading-indicator {
    background: rgba(255, 126, 95, 0.9);
}

/* Forest Theme */
[data-theme="forest"] {
    --primary-color: #11998e;
    --primary-dark: #38ef7d;
    --primary-color-rgb: 17, 153, 142;
    --primary-dark-rgb: 56, 239, 125;

    --bg-gradient-1: #0a1510;
    --bg-gradient-2: #1a2f23;
    --ai-gradient-1: #11998e;
    --ai-gradient-2: #38ef7d;
}

[data-theme="forest"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="forest"] .btn.primary {
    background: var(--primary-color);
    box-shadow: 0 2px 8px rgba(17, 153, 142, 0.3);
}

[data-theme="forest"] .btn.primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(17, 153, 142, 0.5);
}

[data-theme="forest"] .message.user .message-content,
[data-theme="forest"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="forest"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

[data-theme="forest"] .welcome-icon,
[data-theme="forest"] .chat-item.active {
    color: var(--primary-color);
}

[data-theme="forest"] .chat-item.active {
    background: rgba(17, 153, 142, 0.2);
    border-left-color: var(--primary-color);
}

[data-theme="forest"] #messageInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(17, 153, 142, 0.2);
}

[data-theme="forest"] .loading-indicator {
    background: rgba(17, 153, 142, 0.9);
}

/* Purple Theme (default values, explicit declaration) */
[data-theme="purple"] {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-color-rgb: 102, 126, 234;
    --primary-dark-rgb: 118, 75, 162;

    --bg-gradient-1: #0f1419;
    --bg-gradient-2: #1a1f2e;
    --ai-gradient-1: #00d2ff;
    --ai-gradient-2: #3a7bd5;
}

[data-theme="purple"] .app {
    background: var(--bg-gradient-1);
}

[data-theme="purple"] .btn.primary {
    background: var(--primary-color);
}

[data-theme="purple"] .message.user .message-content,
[data-theme="purple"] .message.user .message-avatar {
    background: var(--primary-color);
}

[data-theme="purple"] .message.ai .message-avatar {
    background: var(--ai-gradient-1);
}

/* Mobile responsive updates for theme elements */
@media (max-width: 768px) {
    .connection-status {
        display: none;
    }
    
    .message-counter {
        display: none;
    }
    
    .theme-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 280px;
        max-width: 90vw;
    }
    
    .theme-dropdown.show {
        animation: mobileDropdownFadeIn 0.3s ease;
    }
    
    @keyframes mobileDropdownFadeIn {
        from {
            opacity: 0;
            transform: translate(-50%, -50%) scale(0.9);
        }
        to {
            opacity: 1;
            transform: translate(-50%, -50%) scale(1);
        }
    }
}

/* ============================================
   AI PERSONALITY MODE SELECTOR
   ============================================ */

.personality-selector {
    position: relative;
}

.personality-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 13px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    border-radius: 20px;
    transition: all 0.3s ease;
}

.personality-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.personality-btn i {
    color: var(--primary-color, #667eea);
}

.personality-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 280px;
    background: rgba(30, 30, 40, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.personality-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.personality-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 6px;
}

.personality-option:last-child {
    margin-bottom: 0;
}

.personality-option:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
}

.personality-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

.personality-option i {
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 10px;
    color: var(--primary-color, #667eea);
}

.personality-option.active i {
    background: var(--primary-color, #667eea);
    color: white;
}

.personality-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.personality-name {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
}

.personality-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

/* ============================================
   FLOATING PERSONALITY OVERLAY
   ============================================ */

.personality-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.personality-overlay.show {
    display: flex;
    animation: overlayFadeIn 0.25s ease;
}

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

.personality-overlay-content {
    background: rgba(18, 18, 28, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 28px;
    width: 420px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    animation: panelSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.personality-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    position: relative;
}

.overlay-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.overlay-title i {
    color: var(--primary-color, #667eea);
    font-size: 20px;
}

.overlay-subtitle {
    position: absolute;
    bottom: -4px;
    left: 0;
    font-size: 12px;
    color: var(--foreground);
    margin: 0;
}

.overlay-close {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--foreground);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.overlay-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.personality-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.personality-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.personality-card:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
}

.personality-card.active {
    background: #d1e7ff; /* Light blue background for active card */
    color: #000; /* Black text for better contrast */
    border: 2px solid #4a90e2; /* Highlighted border */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Subtle shadow for emphasis */
}

.personality-card.active .personality-card-header h3 {
    color: #4a90e2; /* Highlighted header text */
}

.personality-card.active .personality-description {
    color: #333; /* Darker text for description */
}

.personality-card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.personality-card-icon i {
    font-size: 18px;
    color: var(--primary-color, #667eea);
    transition: all 0.2s ease;
}

.personality-card.active .personality-card-icon {
    background: var(--primary-color, #667eea);
}

.personality-card.active .personality-card-icon i {
    color: white;
}

.personality-card-info {
    flex: 1;
    min-width: 0;
}

.personality-card-info h3 {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    margin: 0 0 2px 0;
}

.personality-card-info p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.45);
    margin: 0;
}

.personality-check {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.personality-check i {
    font-size: 10px;
    color: transparent;
    transition: all 0.2s ease;
}

.personality-card.active .personality-check {
    background: var(--primary-color, #667eea);
    border-color: var(--primary-color, #667eea);
}

.personality-card.active .personality-check i {
    color: white;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile responsiveness for personality overlay */
@media (max-width: 768px) {
    .personality-overlay-content {
        margin: 12px;
        padding: 20px;
        max-height: 90vh;
    }
    
    .overlay-title {
        font-size: 16px;
    }
}

/* ============================================
   VOICE INPUT STYLES
   ============================================ */

.voice-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    position: relative;
    overflow: hidden;
}

.voice-btn::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--primary-color, #667eea);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 50%;
}

.voice-btn:hover {
    transform: scale(1.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.8);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.voice-btn:hover::before {
    opacity: 0.2;
}

.voice-btn i {
    font-size: 18px;
    color: var(--primary-color, #667eea);
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
}

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

.voice-btn.listening {
    background: #ff4757;
    border-color: transparent;
    animation: voicePulse 1.5s infinite;
    transform: scale(1.1);
}

.voice-btn.listening::before {
    opacity: 0;
}

.voice-btn.listening i {
    color: white;
    animation: micBounce 0.5s ease infinite;
}

@keyframes micBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Auto-Read Button Styles */
.auto-read-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

.auto-read-btn i {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.3s ease;
}

.auto-read-btn:hover {
    transform: scale(1.08);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.auto-read-btn:hover i {
    color: var(--primary-color, #667eea);
}

.auto-read-btn.active {
    background: var(--primary-color, #667eea);
    border-color: transparent;
    box-shadow: 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.auto-read-btn.active i {
    color: white;
}

.auto-read-btn.active.speaking {
    animation: speakingGlow 1.5s infinite;
}

@keyframes speakingGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 102, 126, 234), 0.6), 0 4px 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(var(--primary-color-rgb, 102, 126, 234), 0), 0 4px 30px rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    }
}

.voice-status {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(255, 71, 87, 0.9);
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(255, 71, 87, 0.4);
    color: white;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
}

.voice-status.hidden {
    display: none;
}

.voice-pulse {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    animation: voiceDot 1s infinite;
}

@keyframes voiceDot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

/* Voice wave animation for status */
.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.voice-wave span {
    width: 3px;
    height: 100%;
    background: white;
    border-radius: 2px;
    animation: voiceWave 0.5s infinite ease-in-out;
}

.voice-wave span:nth-child(1) { animation-delay: 0s; }
.voice-wave span:nth-child(2) { animation-delay: 0.1s; }
.voice-wave span:nth-child(3) { animation-delay: 0.2s; }
.voice-wave span:nth-child(4) { animation-delay: 0.3s; }
.voice-wave span:nth-child(5) { animation-delay: 0.4s; }

@keyframes voiceWave {
    0%, 100% {
        transform: scaleY(0.3);
    }
    50% {
        transform: scaleY(1);
    }
}

/* ============================================
   PERSONALITY INDICATOR IN MESSAGES
   ============================================ */

.personality-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 8px;
}

.personality-badge i {
    font-size: 10px;
    color: var(--primary-color, #667eea);
}

/* ============================================
RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 768px) {
    .personality-btn span {
        display: none;
    }
    
    .personality-btn {
        padding: 8px 12px;
    }
    
    .personality-dropdown {
        position: fixed;
        top: 50%;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        width: 90vw;
        max-width: 320px;
    }
    
    .personality-dropdown.show {
        transform: translate(-50%, -50%);
    }
    
    .voice-status {
        font-size: 12px;
        padding: 8px 16px;
    }
}

/* ============================================
   THEME VARIATIONS FOR PERSONALITY
   ============================================ */

[data-theme="ocean"] .personality-btn {
    background: rgba(0, 180, 219, 0.2);
    border-color: rgba(0, 180, 219, 0.4);
}

[data-theme="ocean"] .personality-btn i,
[data-theme="ocean"] .personality-option i {
    color: #00b4db;
}

[data-theme="sunset"] .personality-btn {
    background: rgba(255, 94, 98, 0.2);
    border-color: rgba(255, 94, 98, 0.4);
}

[data-theme="sunset"] .personality-btn i,
[data-theme="sunset"] .personality-option i {
    color: #ff5e62;
}

[data-theme="forest"] .personality-btn {
    background: rgba(17, 153, 142, 0.2);
    border-color: rgba(17, 153, 142, 0.4);
}

[data-theme="forest"] .personality-btn i,
[data-theme="forest"] .personality-option i {
    color: #11998e;
}

/* Image Generation Styles */
.generate-image-btn {
    background: rgba(147, 51, 234, 0.2);
    border: 2px solid rgba(147, 51, 234, 0.4);
    color: #c084fc;
}

.generate-image-btn:hover {
    background: rgba(147, 51, 234, 0.4);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.4);
}

.generate-image-btn i {
    animation: sparkle 2s ease-in-out infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.generating-image .message-avatar {
    background: #9333ea;
}

.generating-image .message-avatar i {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.image-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    text-align: center;
}

.image-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(147, 51, 234, 0.2);
    border-top: 3px solid #9333ea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

.image-prompt-preview {
    font-style: italic;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 10px;
    font-size: 0.9em;
}

.generated-image-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 100%;
}

.generated-image-caption {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

.generated-image-prompt {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9em;
    margin: 0;
}

.generated-image-wrapper {
    position: relative;
    max-width: 512px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.generated-image {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.generated-image.loaded {
    opacity: 1;
}

.image-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(147, 51, 234, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    min-height: 200px;
    transition: opacity 0.3s ease;
}

.image-loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.image-loading-overlay.error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    font-size: 0.9em;
}

.generated-image-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.image-action-btn {
    padding: 8px 16px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.image-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.regenerate-btn {
    background: rgba(147, 51, 234, 0.2);
    border-color: rgba(147, 51, 234, 0.4);
}

.regenerate-btn:hover {
    background: rgba(147, 51, 234, 0.4);
}

/* Light theme adjustments for image generation */
[data-theme="light-blue"] .generate-image-btn {
    background: rgba(147, 51, 234, 0.15);
    color: #9333ea;
}

[data-theme="light-blue"] .generated-image-caption {
    color: rgba(0, 0, 0, 0.9);
}

[data-theme="light-blue"] .generated-image-prompt {
    color: rgba(0, 0, 0, 0.6);
}

[data-theme="light-blue"] .image-action-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
    color: rgba(0, 0, 0, 0.8);
}

[data-theme="light-blue"] .image-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* ============================================
   DARK MODE TOGGLE BUTTON
   ============================================ */

.dark-mode-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 16px;
}

/* ============================================
   LIGHT MODE STYLES
   ============================================ */

[data-mode="light"] body {
    background: #f5f6fa;
}

[data-mode="light"] .app {
    background: #f5f6fa;
}

[data-mode="light"] .sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(0, 0, 0, 0.08);
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.05);
}

[data-mode="light"] .sidebar-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .sidebar-footer {
    border-top-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .recent-chats-header {
    border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-mode="light"] .recent-chats-header h3 {
    color: rgba(0, 0, 0, 0.6);
}

[data-mode="light"] .chat-item {
    color: rgba(0, 0, 0, 0.7);
}

[data-mode="light"] .chat-item:hover {
    background: rgba(0, 0, 0, 0.05);
    color: rgba(0, 0, 0, 0.9);
}

[data-mode="light"] .chat-item.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.1);
    color: var(--primary-color, #667eea);
    border-left: 3px solid var(--primary-color, #667eea);
}

[data-mode="light"] .header {
    background: rgba(255, 255, 255, 0.9);
    border-bottom-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.05);
    color: #1a1a2e;
}

[data-mode="light"] .brand-name {
    color: var(--primary-color, #667eea);
}

[data-mode="light"] .current-chat-title {
    color: rgba(0, 0, 0, 0.5);
}

[data-mode="light"] .btn.secondary, .theme-btn {
    background: var(--sidebar-bg);
    color: var(--foreground);
    border: 1.5px solid var(--glass-border);
}

.btn.secondary:hover, .theme-btn:hover {
    background: var(--main-bg);
    color: var(--foreground);
    border-color: var(--primary-gradient, #667eea);
}

.btn.secondary i, .theme-btn i {
    color: var(--foreground);
}

/* Danger button */
.btn.danger {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn.danger:hover {
    background: rgba(255, 71, 87, 0.3);
    border-color: rgba(255, 71, 87, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(255, 71, 87, 0.4);
}

/* ===== Overrides: remove remaining blue glows ===== */
/* Disable common blue glows and drop-shadows used across light mode UI. */
body.light-mode .btn.primary,
body.light-mode .btn.primary:hover,
body.light-mode .personality-btn,
body.light-mode .personality-btn:hover,
body.light-mode .personality-card.active,
body.light-mode .personality-card:hover,
body.light-mode .feature-item,
body.light-mode .feature-item:hover,
body.light-mode .particle,
body.light-mode .generate-image-btn,
body.light-mode .theme-dropdown,
body.light-mode .theme-btn,
body.light-mode .welcome-icon {
    box-shadow: none !important;
    filter: none !important;
    border-color: transparent !important;
}

/* Conservative global neutralizer for any remaining color glows in light mode */
body.light-mode [style*="rgba(102, 126, 234"],
body.light-mode [style*="rgba(74,144,226"],
body.light-mode [style*="rgba(66,133,244"] {
    box-shadow: none !important;
    filter: none !important;
}

/* ===== Memory Panel Styles ===== */
.memory-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.memory-panel.hidden {
    display: none;
}

.memory-panel-content {
    background: var(--sidebar-bg, rgba(15, 15, 25, 0.95));
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}

.memory-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}

.memory-panel-header h2 {
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.memory-panel-header h2 i {
    color: var(--primary-gradient, #667eea);
}

.memory-panel-body {
    padding: 20px;
}

.memory-description {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

body.light-mode .memory-description {
    color: rgba(0, 0, 0, 0.7);
}

.memory-section {
    margin-bottom: 24px;
}

.memory-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-gradient, #667eea);
}

.memory-list {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    min-height: 60px;
}

body.light-mode .memory-list {
    background: rgba(0, 0, 0, 0.05);
}

.memory-empty {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    text-align: center;
    padding: 16px;
}

body.light-mode .memory-empty {
    color: rgba(0, 0, 0, 0.5);
}

.memory-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background 0.2s ease;
}

body.light-mode .memory-item {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.memory-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

body.light-mode .memory-item:hover {
    background: rgba(255, 255, 255, 1);
}

.memory-item-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
}

.memory-item-delete {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.memory-item-delete:hover {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.1);
}

body.light-mode .memory-item-delete {
    color: rgba(0, 0, 0, 0.4);
}

body.light-mode .memory-item-delete:hover {
    color: #ff4757;
}

.memory-add-form {
    display: flex;
    gap: 8px;
}

.memory-add-form input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.2));
    background: rgba(0, 0, 0, 0.2);
    color: var(--foreground, #fff);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

body.light-mode .memory-add-form input {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.2);
    color: #222;
}

.memory-add-form input:focus {
    border-color: var(--primary-gradient, #667eea);
}

.memory-add-form input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

body.light-mode .memory-add-form input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.memory-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}

#memoryButton {
    width: 100%;
}

#clearMemoryButton {
    width: 100%;
}
/* ============================================
   MODERN AI THINKING ANIMATIONS
   ============================================ */

.thinking-message {
    animation: thinkingFadeIn 0.3s ease-out;
}

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

.thinking-content {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb, 102, 126, 234), 0.15) 0%, rgba(var(--primary-dark-rgb, 118, 75, 162), 0.1) 100%);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    min-width: 250px;
}

.thinking-animation {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 0;
}

.brain-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color, #667eea) 0%, var(--primary-dark, #764ba2) 100%);
    border-radius: 12px;
    color: white;
    animation: brainPulse 2s ease-in-out infinite;
}

.brain-icon svg {
    width: 24px;
    height: 24px;
}

@keyframes brainPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px 5px rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    }
}

.thinking-text {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.thinking-word {
    animation: thinkingWordChange 3s ease-in-out infinite;
}

@keyframes thinkingWordChange {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.thinking-dots {
    display: flex;
    gap: 3px;
}

.thinking-dots span {
    width: 4px;
    height: 4px;
    background: var(--primary-color, #667eea);
    border-radius: 50%;
    animation: thinkingDot 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingDot {
    0%, 80%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.5);
        opacity: 1;
    }
}

.thinking-particles {
    position: absolute;
    right: 20px;
    display: flex;
    gap: 4px;
}

.thinking-particles span {
    width: 6px;
    height: 6px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    border-radius: 50%;
    animation: particle 2s infinite ease-in-out;
}

.thinking-particles span:nth-child(1) { animation-delay: 0s; }
.thinking-particles span:nth-child(2) { animation-delay: 0.3s; }
.thinking-particles span:nth-child(3) { animation-delay: 0.6s; }
.thinking-particles span:nth-child(4) { animation-delay: 0.9s; }
.thinking-particles span:nth-child(5) { animation-delay: 1.2s; }

@keyframes particle {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translateY(-8px) scale(1.2);
        opacity: 1;
    }
}

.thinking-progress {
    margin-top: 12px;
    height: 3px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.thinking-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2), var(--primary-color, #667eea));
    background-size: 200% 100%;
    animation: progressMove 2s linear infinite;
    border-radius: 3px;
}

@keyframes progressMove {
    0% {
        width: 0%;
        background-position: 0% 0%;
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
        background-position: 200% 0%;
    }
}

/* Neural network animation background */
.thinking-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(var(--primary-color-rgb, 102, 126, 234), 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(var(--primary-dark-rgb, 118, 75, 162), 0.1) 0%, transparent 50%);
    animation: neuralPulse 3s ease-in-out infinite;
    pointer-events: none;
    border-radius: inherit;
}

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

/* Light mode thinking styles */
body.light-mode .thinking-content {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb, 102, 126, 234), 0.1) 0%, rgba(var(--primary-dark-rgb, 118, 75, 162), 0.05) 100%);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

body.light-mode .thinking-text {
    color: rgba(0, 0, 0, 0.8);
}

body.light-mode .thinking-progress {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
}

/* Typing indicator variant */
.typing-indicator-modern {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
}

.typing-indicator-modern span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2));
    border-radius: 50%;
    animation: modernTyping 1.4s infinite ease-in-out;
}

.typing-indicator-modern span:nth-child(1) { animation-delay: 0s; }
.typing-indicator-modern span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator-modern span:nth-child(3) { animation-delay: 0.4s; }

@keyframes modernTyping {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-10px) scale(1.2);
        opacity: 1;
    }
}

/* Glowing ring effect */
.thinking-message .message-avatar {
    position: relative;
}

.thinking-message .message-avatar::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    border-radius: 50%;
    animation: avatarRing 2s ease-in-out infinite;
}

@keyframes avatarRing {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Additional human-like response styles */
.message.ai .message-content {
    position: relative;
}

.message.ai .message-content::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid rgba(30, 30, 50, 0.6);
}

body.light-mode .message.ai .message-content::before {
    border-right-color: #fff;
}

/* ============================================
   MODERN ANIMATIONS & EFFECTS
   ============================================ */

/* Animated gradient background */
.app {
    background: linear-gradient(135deg, #0f1419 0%, #1a1f2e 25%, #0f1419 50%, #151b26 75%, #0f1419 100%);
    background-size: 400% 400%;
    animation: gradientFlow 15s ease infinite;
}

@keyframes gradientFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Glowing orbs background effect */
.app::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(var(--primary-color-rgb, 102, 126, 234), 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(var(--primary-dark-rgb, 118, 75, 162), 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 60%, rgba(0, 210, 255, 0.08) 0%, transparent 40%);
    animation: orbFloat 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(2%, -2%) scale(1.02); }
    50% { transform: translate(-1%, 2%) scale(0.98); }
    75% { transform: translate(1%, -1%) scale(1.01); }
}

/* Enhanced button hover animations */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    border-radius: 50%;
}

.btn:hover::after {
    width: 300px;
    height: 300px;
}

/* Shine effect on buttons */
.btn.primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

.btn.primary:hover::before {
    left: 100%;
}

/* Floating animation for logo */
.logo-container {
    animation: logoFloat 6s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

/* Pulsing glow effect */
.header-logo {
    animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {
    0%, 100% { 
        filter: drop-shadow(0 0 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5));
    }
    50% { 
        filter: drop-shadow(0 0 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.8));
    }
}

/* Message entrance animations */
.message {
    animation: messageEnter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes messageEnter {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Staggered message animation */
.message:nth-child(1) { animation-delay: 0s; }
.message:nth-child(2) { animation-delay: 0.05s; }
.message:nth-child(3) { animation-delay: 0.1s; }
.message:nth-child(4) { animation-delay: 0.15s; }
.message:nth-child(5) { animation-delay: 0.2s; }

/* Typing indicator enhanced */
.typing-indicator span {
    animation: typingBounce 1.4s infinite ease-in-out;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2));
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

/* Send button pulse animation */
#sendButton:not(:disabled) {
    animation: sendPulse 2s ease-in-out infinite;
}

@keyframes sendPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(var(--primary-color-rgb, 102, 126, 234), 0);
    }
}

/* Input focus glow animation */
#messageInput:focus {
    animation: inputGlow 2s ease-in-out infinite;
}

@keyframes inputGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    }
    50% {
        box-shadow: 0 0 30px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    }
}

/* Sidebar item hover animation */
.chat-item {
    position: relative;
    overflow: hidden;
}

.chat-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: linear-gradient(180deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2));
    transform: scaleY(0);
    transition: transform 0.3s ease;
}

.chat-item:hover::before,
.chat-item.active::before {
    transform: scaleY(1);
}

/* Status indicator enhanced */
.status-indicator.online {
    animation: statusPulseEnhanced 2s ease-in-out infinite;
}

@keyframes statusPulseEnhanced {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(74, 222, 128, 0);
    }
}

/* Suggestion chip animations */
.suggestion-chip {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: chipAppear 0.5s ease-out backwards;
}

.suggestion-chip:nth-child(1) { animation-delay: 0.1s; }
.suggestion-chip:nth-child(2) { animation-delay: 0.2s; }
.suggestion-chip:nth-child(3) { animation-delay: 0.3s; }
.suggestion-chip:nth-child(4) { animation-delay: 0.4s; }

@keyframes chipAppear {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.8);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.suggestion-chip:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

/* Welcome message enhanced animation */
.welcome-message {
    animation: welcomeEnhanced 1s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Particle enhanced animation */
.particle {
    animation: particleEnhanced linear infinite;
}

@keyframes particleEnhanced {
    0% {
        transform: translateY(100vh) translateX(0) rotate(0deg) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
        transform: translateY(90vh) translateX(10px) rotate(36deg) scale(1);
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-10vh) translateX(-10px) rotate(360deg) scale(0.5);
        opacity: 0;
    }
}

/* Loading indicator shimmer */
.loading-indicator {
    background: linear-gradient(90deg, 
        rgba(var(--primary-color-rgb, 102, 126, 234), 0.95) 0%, 
        rgba(var(--primary-dark-rgb, 118, 75, 162), 0.95) 50%, 
        rgba(var(--primary-color-rgb, 102, 126, 234), 0.95) 100%);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Feature item slide animation */
.feature-item {
    animation: featureSlide 0.6s ease-out backwards;
}

.feature-item:nth-child(1) { animation-delay: 0.1s; }
.feature-item:nth-child(2) { animation-delay: 0.2s; }
.feature-item:nth-child(3) { animation-delay: 0.3s; }

@keyframes featureSlide {
    0% {
        opacity: 0;
        transform: translateX(-30px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Button icon spin on hover */
.btn:hover i {
    animation: iconSpin 0.3s ease;
}

@keyframes iconSpin {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(15deg); }
    100% { transform: rotate(0deg); }
}

/* Action button ripple */
.action-btn {
    position: relative;
    overflow: hidden;
}

.action-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.action-btn:active::after {
    width: 100px;
    height: 100px;
}

/* Theme dropdown slide */
.theme-dropdown.show {
    animation: dropdownSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes dropdownSlide {
    0% {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Connection status breathing */
.connection-status {
    animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

/* Memory panel slide up */
.memory-panel-content {
    animation: panelSlideUpEnhanced 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes panelSlideUpEnhanced {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Scrollbar animated */
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2));
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary-dark, #764ba2), var(--primary-color, #667eea));
}

/* Voice button wave effect */
.voice-btn.listening {
    animation: voiceWave 0.5s ease-in-out infinite;
}

@keyframes voiceWave {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.15); }
}

/* Message content hover effect */
.message-content::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.message-content:hover::after {
    opacity: 1;
}

/* Auto-read button glow */
.auto-read-btn.active {
    animation: readGlow 1.5s ease-in-out infinite;
}

@keyframes readGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(var(--primary-color-rgb, 102, 126, 234), 0.8);
    }
}

/* Generate image button sparkle */
.generate-image-btn i {
    animation: iconSparkle 2s ease-in-out infinite;
}

@keyframes iconSparkle {
    0%, 100% {
        transform: rotate(0deg) scale(1);
        filter: brightness(1);
    }
    25% {
        transform: rotate(-5deg) scale(1.1);
        filter: brightness(1.2);
    }
    75% {
        transform: rotate(5deg) scale(1.1);
        filter: brightness(1.2);
    }
}

/* Header subtle animation */
.header {
    animation: headerFade 0.5s ease-out;
}

@keyframes headerFade {
    0% {
        opacity: 0;
        transform: translateY(-20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar slide animation */
.sidebar {
    animation: sidebarSlide 0.5s ease-out;
}

@keyframes sidebarSlide {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Input container rise animation */
.input-container {
    animation: inputRise 0.6s ease-out;
}

@keyframes inputRise {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Personality card flip effect */
.personality-card {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.personality-card:hover {
    transform: translateX(5px);
}

/* Counter pulse */
#messageCount {
    animation: counterPulse 1s ease-in-out infinite;
}

@keyframes counterPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Brand name gradient animation */
.brand-name {
    background: linear-gradient(90deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2), #00d2ff, var(--primary-color, #667eea));
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: brandGradient 4s ease-in-out infinite;
}

@keyframes brandGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Remove image button bounce */
.remove-image-btn:hover {
    animation: bounceOnce 0.3s ease;
}

@keyframes bounceOnce {
    0%, 100% { transform: scale(1.1); }
    50% { transform: scale(1.2); }
}

/* Image loading spinner enhanced */
.image-loading-spinner {
    animation: spinnerEnhanced 1s linear infinite;
}

@keyframes spinnerEnhanced {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* Light mode specific animations */
body.light-mode .app {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 25%, #f5f7fa 50%, #eef1f6 75%, #f5f7fa 100%);
    background-size: 400% 400%;
}

body.light-mode .app::before {
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(var(--primary-color-rgb, 102, 126, 234), 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(var(--primary-dark-rgb, 118, 75, 162), 0.05) 0%, transparent 50%);
}

/* ============================================
   AI MODE SELECTOR
   ============================================ */

.ai-mode-selector {
    position: relative;
    margin-right: 8px;
}

.ai-mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 13px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border-radius: 20px;
    transition: all 0.2s ease;
}

.ai-mode-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

.ai-mode-btn i:first-child {
    color: var(--primary-color, #667eea);
}

.ai-mode-btn .fa-chevron-down {
    font-size: 10px;
    opacity: 0.7;
}

.ai-mode-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: rgba(25, 25, 35, 0.98);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.ai-mode-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ai-mode-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ai-mode-option:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
}

.ai-mode-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
}

.ai-mode-option i {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-radius: 8px;
    color: var(--primary-color, #667eea);
    font-size: 14px;
}

.ai-mode-option.active i {
    background: var(--primary-color, #667eea);
    color: white;
}

.ai-mode-option.roast-mode i {
    background: rgba(255, 71, 87, 0.2);
    color: #ff4757;
}

.ai-mode-option.roast-mode.active i {
    background: #ff4757;
    color: white;
}

.ai-mode-info {
    display: flex;
    flex-direction: column;
}

.ai-mode-name {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
}

.ai-mode-desc {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

/* ============================================
   SETTINGS PANEL
   ============================================ */

.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.settings-panel.hidden {
    display: none;
}

.settings-panel-content {
    background: rgba(18, 18, 28, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 24px;
    width: 480px;
    max-width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
    animation: panelSlideUp 0.3s ease;
}

.settings-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-panel-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.settings-panel-header h2 i {
    color: var(--primary-color, #667eea);
}

.settings-section {
    margin-bottom: 20px;
}

.settings-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 8px;
}

.settings-section h3 i {
    color: var(--primary-color, #667eea);
    font-size: 14px;
}

.settings-description {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
    line-height: 1.5;
}

.font-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.font-option {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.font-option::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb, 102, 126, 234), 0.15) 0%, rgba(var(--primary-dark-rgb, 118, 75, 162), 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.font-option:hover {
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.font-option:hover::before {
    opacity: 1;
}

.font-option.active {
    background: linear-gradient(135deg, rgba(var(--primary-color-rgb, 102, 126, 234), 0.2) 0%, rgba(var(--primary-dark-rgb, 118, 75, 162), 0.15) 100%);
    border-color: var(--primary-color, #667eea);
    box-shadow: 0 0 16px rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
}

.font-option.active::after {
    content: '\2713';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 10px;
    color: var(--primary-color, #667eea);
    font-weight: 700;
}

.font-preview {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.9);
    display: block;
}

.font-option.active .font-preview {
    color: #fff;
    text-shadow: 0 0 10px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

.setting-item {
    padding: 12px 0;
}

.toggle-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    width: 100%;
}

.toggle-setting span:first-child {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

.toggle-setting input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 48px;
    height: 26px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 13px;
    transition: background 0.2s ease;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.toggle-setting input:checked + .toggle-slider {
    background: var(--primary-color, #667eea);
}

.toggle-setting input:checked + .toggle-slider::after {
    transform: translateX(22px);
}

.setting-note {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-style: italic;
    margin-top: 8px;
}

/* ============================================
   SUPER CUSTOMIZATION CONTROLS
   ============================================ */

/* Settings Divider */
.settings-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 16px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--primary-color, #667eea);
}
.settings-divider::before,
.settings-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-color, #667eea), transparent);
    opacity: 0.35;
}
.settings-divider i {
    font-size: 14px;
}

/* Accent Color Row */
.accent-color-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.accent-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.accent-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}
.accent-swatch:hover {
    transform: scale(1.18);
    box-shadow: 0 0 12px rgba(255,255,255,0.25);
}
.accent-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 16px currentColor;
    transform: scale(1.15);
}
.accent-swatch.active::after {
    content: 'âœ“';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.accent-custom {
    display: flex;
    align-items: center;
    gap: 8px;
}
.accent-picker-label {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
}
.accent-picker-input {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
    padding: 0;
}
.accent-picker-input::-webkit-color-swatch-wrapper { padding: 2px; }
.accent-picker-input::-webkit-color-swatch { border-radius: 6px; border: 2px solid rgba(255,255,255,0.2); }

/* Bubble Style Grid */
.bubble-style-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}
.bubble-style-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
}
.bubble-style-option:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.12);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    transform: translateY(-2px);
}
.bubble-style-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-color: var(--primary-color, #667eea);
    color: #fff;
    box-shadow: 0 0 16px rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
}
.bubble-style-preview {
    width: 50px;
    height: 28px;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.35);
    position: relative;
}
.bsp-default { border-radius: 12px; }
.bsp-rounded { border-radius: 28px; }
.bsp-sharp  { border-radius: 2px; }
.bsp-minimal { border-radius: 0; background: transparent; border-bottom: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.6); }
.bsp-neon {
    border-radius: 12px;
    background: transparent;
    border: 2px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.7);
    box-shadow: inset 0 0 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.25), 0 0 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
}
.bsp-glass {
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.15);
}

/* Slider Control */
.slider-control {
    display: flex;
    align-items: center;
    gap: 10px;
}
.slider-label {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    min-width: 18px;
    text-align: center;
}
.slider-label-lg {
    font-size: 20px;
    font-weight: 700;
}
.slider-value {
    font-size: 12px;
    color: var(--primary-color, #667eea);
    font-weight: 600;
    min-width: 38px;
    text-align: center;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.12);
    padding: 3px 8px;
    border-radius: 6px;
}
.custom-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: rgba(255,255,255,0.1);
    outline: none;
    transition: background 0.2s;
}
.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color, #667eea);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    transition: transform 0.15s, box-shadow 0.15s;
}
.custom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 14px rgba(var(--primary-color-rgb, 102, 126, 234), 0.7);
}
.custom-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color, #667eea);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

/* Density Selector */
.density-selector {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}
.density-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}
.density-option:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.12);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}
.density-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-color: var(--primary-color, #667eea);
    color: #fff;
    box-shadow: 0 0 12px rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
}

/* Custom CSS Textarea */
.custom-css-textarea {
    width: 100%;
    min-height: 80px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    color: #a3e635;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    padding: 12px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.6;
}
.custom-css-textarea:focus {
    border-color: var(--primary-color, #667eea);
}
.custom-css-textarea::placeholder {
    color: rgba(163,230,53,0.35);
}

/* Profile Actions */
.profile-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.profile-btn {
    flex: 1;
    min-width: 90px;
    text-align: center;
    justify-content: center;
    font-size: 12px !important;
    padding: 10px 8px !important;
    cursor: pointer;
}

/* ====== BUBBLE STYLE APPLIED CLASSES ====== */
body[data-bubble="rounded"] .message-content { border-radius: 24px !important; }
body[data-bubble="sharp"] .message-content { border-radius: 2px !important; }
body[data-bubble="minimal"] .message-content {
    border-radius: 0 !important;
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid rgba(255,255,255,0.1) !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
body[data-bubble="neon"] .message-content {
    border-radius: 14px !important;
    background: transparent !important;
    border: 1.5px solid var(--primary-color, #667eea) !important;
    box-shadow: inset 0 0 12px rgba(var(--primary-color-rgb, 102, 126, 234), 0.15), 0 0 12px rgba(var(--primary-color-rgb, 102, 126, 234), 0.15) !important;
}
body[data-bubble="glassmorphism"] .message-content {
    border-radius: 14px !important;
    background: rgba(255,255,255,0.06) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
}

/* ====== DENSITY CLASSES ====== */
body[data-density="compact"] .message { margin-bottom: 6px !important; }
body[data-density="compact"] .message-content { padding: 8px 12px !important; font-size: 13px; }
body[data-density="compact"] .chat-container { gap: 8px !important; padding: 12px !important; }

body[data-density="spacious"] .message { margin-bottom: 28px !important; }
body[data-density="spacious"] .message-content { padding: 18px 22px !important; }
body[data-density="spacious"] .chat-container { gap: 28px !important; padding: 32px !important; }

/* ====== ANIMATION SPEED CLASSES ====== */
body[data-anim-speed="off"] *,
body[data-anim-speed="off"] *::before,
body[data-anim-speed="off"] *::after {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
}
body[data-anim-speed="fast"] { --transition-fast: 0.05s; --transition-normal: 0.1s; --transition-slow: 0.15s; }
body[data-anim-speed="slow"] { --transition-fast: 0.3s; --transition-normal: 0.6s; --transition-slow: 1s; }

/* ====== SIDEBAR RIGHT POSITION ====== */
body[data-sidebar-pos="right"] .app { flex-direction: row-reverse; }
body[data-sidebar-pos="right"] .sidebar { border-right: none; border-left: 1px solid var(--glass-border); }

/* ====== Light Mode Overrides for Customization Controls ====== */
body.light-mode .settings-divider { color: var(--primary-gradient); }
body.light-mode .accent-swatch { border-color: rgba(0,0,0,0.15); }
body.light-mode .accent-swatch.active { border-color: #222; }
body.light-mode .accent-picker-label { color: rgba(0,0,0,0.5); }
body.light-mode .bubble-style-option { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.1); color: rgba(0,0,0,0.7); }
body.light-mode .bubble-style-option:hover { background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.08); }
body.light-mode .bubble-style-option.active { background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.12); color: #222; }
body.light-mode .slider-label { color: rgba(0,0,0,0.5); }
body.light-mode .custom-slider { background: rgba(0,0,0,0.1); }
body.light-mode .density-option { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.1); color: rgba(0,0,0,0.7); }
body.light-mode .density-option.active { background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.12); color: #222; }
body.light-mode .custom-css-textarea { background: rgba(0,0,0,0.04); color: #166534; border-color: rgba(0,0,0,0.1); }
body.light-mode .custom-css-textarea::placeholder { color: rgba(22,101,52,0.35); }
body.light-mode .bubble-style-preview { background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2); }
body.light-mode .slider-value { background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.08); }

/* ============================================
   CUSTOM AI MODE CREATOR â€” SPACE THEME
   ============================================ */

.persona-stars-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.persona-creator-modal {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% 50%, rgba(30, 10, 60, 0.92) 0%, rgba(2, 2, 12, 0.96) 70%);
    backdrop-filter: blur(30px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    animation: pcmOverlayIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}

.persona-creator-modal.hidden {
    display: none;
}

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

/* ---- card ---- */
.persona-creator-content {
    background: linear-gradient(160deg, rgba(8, 6, 24, 0.98) 0%, rgba(4, 2, 16, 0.99) 100%);
    border: 1px solid rgba(120, 80, 220, 0.2);
    border-radius: 24px;
    padding: 0;
    width: 580px;
    max-width: 94vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
    box-shadow:
        0 0 0 1px rgba(120, 80, 220, 0.06),
        0 40px 120px rgba(0, 0, 0, 0.8),
        0 0 120px rgba(100, 60, 200, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    animation: pcmCardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pcmCardIn {
    from { opacity: 0; transform: translateY(40px) scale(0.92); filter: blur(6px); }
    60%  { filter: blur(0); }
    to   { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

.persona-creator-content::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(140, 100, 255, 0.4), rgba(80, 200, 255, 0.3), transparent);
    z-index: 2;
}

.persona-creator-content::-webkit-scrollbar { width: 5px; }
.persona-creator-content::-webkit-scrollbar-track { background: transparent; }
.persona-creator-content::-webkit-scrollbar-thumb { background: rgba(120, 80, 220, 0.25); border-radius: 10px; }

/* ---- header ---- */
.persona-creator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px 20px;
    border-bottom: 1px solid rgba(120, 80, 220, 0.12);
    background: linear-gradient(180deg, rgba(100, 60, 200, 0.06) 0%, transparent 100%);
}

.persona-header-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.persona-header-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #4c1d95, #7c3aed, #2563eb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: #fff;
    position: relative;
    box-shadow: 0 0 30px rgba(100, 60, 220, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    animation: personaIconFloat 4s ease-in-out infinite;
}

.persona-icon-orbit {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 1px dashed rgba(140, 100, 255, 0.25);
    animation: orbitSpin1 6s linear infinite;
    pointer-events: none;
}

@keyframes personaIconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes orbitSpin1 {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.persona-creator-header h2 {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(90deg, #e0d4ff 0%, #a5b4fc 50%, #67e8f9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
    margin: 0;
}

.persona-header-sub {
    font-size: 12px;
    color: rgba(160, 140, 220, 0.5);
    margin: 2px 0 0;
}

.persona-close-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    font-size: 14px;
}
.persona-close-btn:hover {
    background: rgba(255, 60, 80, 0.12);
    color: #f87171;
    border-color: rgba(255, 60, 80, 0.2);
    transform: rotate(90deg);
}

/* ---- body ---- */
.persona-creator-body {
    padding: 24px 28px 28px;
}

.persona-step {
    margin-bottom: 24px;
}

.persona-step-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(180, 160, 240, 0.6);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.step-num {
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: linear-gradient(135deg, #4c1d95, #7c3aed);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 12px rgba(124, 58, 237, 0.3);
}

/* ---- name input ---- */
.persona-name-input {
    width: 100%;
    padding: 14px 18px;
    background: rgba(120, 80, 220, 0.06);
    border: 1px solid rgba(120, 80, 220, 0.15);
    border-radius: 14px;
    color: #e0d4ff;
    font-size: 15px;
    font-weight: 500;
    outline: none;
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    box-sizing: border-box;
}

.persona-name-input:focus {
    border-color: rgba(140, 100, 255, 0.5);
    background: rgba(120, 80, 220, 0.1);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1), 0 0 30px rgba(120, 80, 220, 0.06);
}

.persona-name-input::placeholder {
    color: rgba(160, 140, 220, 0.3);
    font-weight: 400;
}

/* ---- layout ---- */
.persona-builder-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.persona-traits-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 7px;
    flex: 1;
    min-width: 0;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}

.persona-traits-grid::-webkit-scrollbar { width: 4px; }
.persona-traits-grid::-webkit-scrollbar-track { background: transparent; }
.persona-traits-grid::-webkit-scrollbar-thumb { background: rgba(120, 80, 220, 0.2); border-radius: 10px; }

/* ---- trait chips ---- */
.persona-trait-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    cursor: grab;
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    font-weight: 500;
    position: relative;
    user-select: none;
    overflow: hidden;
}

.persona-trait-chip::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 50%, currentColor, transparent 70%);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    mix-blend-mode: soft-light;
}

.persona-trait-chip i {
    font-size: 15px;
    color: rgba(160, 140, 255, 0.7);
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    flex-shrink: 0;
}

.persona-trait-chip span {
    pointer-events: none;
}

.persona-trait-chip:hover {
    background: rgba(120, 80, 220, 0.1);
    border-color: rgba(140, 100, 255, 0.3);
    color: #e0d4ff;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(100, 60, 220, 0.15);
}
.persona-trait-chip:hover::before { opacity: 0.15; }
.persona-trait-chip:hover i { filter: drop-shadow(0 0 6px currentColor); }

.persona-trait-chip:active {
    cursor: grabbing;
}

.persona-trait-chip.dragging {
    opacity: 0.3;
    transform: scale(0.9);
    filter: blur(1px);
}

.persona-trait-chip.active {
    background: linear-gradient(135deg, rgba(120, 80, 220, 0.2) 0%, rgba(80, 40, 180, 0.15) 100%);
    border-color: rgba(140, 100, 255, 0.5);
    color: #e0d4ff;
    box-shadow:
        0 0 0 1px rgba(140, 100, 255, 0.2),
        0 0 20px rgba(120, 80, 220, 0.12);
    animation: traitPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes traitPop {
    0% { transform: scale(0.9); }
    50% { transform: scale(1.06); }
    100% { transform: scale(1); }
}

.persona-trait-chip.active i {
    color: #c4b5fd;
    filter: drop-shadow(0 0 8px rgba(196, 181, 253, 0.6));
}

.persona-trait-chip.active::before { opacity: 0.12; }

.persona-trait-chip.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 7px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #4c1d95);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pcmCheckIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.5);
}

@keyframes pcmCheckIn {
    from { transform: scale(0) rotate(-90deg); }
    to   { transform: scale(1) rotate(0deg); }
}

/* ---- cosmic bubble zone ---- */
.persona-bubble-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.persona-bubble {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.bubble-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid transparent;
    pointer-events: none;
}
.bubble-ring-1 {
    border-color: rgba(140, 100, 255, 0.18);
    animation: bubbleOrbit1 7s linear infinite;
}
.bubble-ring-2 {
    inset: -10px;
    border-color: rgba(80, 200, 255, 0.1);
    border-style: dashed;
    animation: bubbleOrbit2 11s linear infinite reverse;
}
.bubble-ring-3 {
    inset: -20px;
    border-color: rgba(140, 100, 255, 0.06);
    animation: bubbleOrbit1 18s linear infinite;
}
.bubble-ring-4 {
    inset: -32px;
    border-color: rgba(80, 200, 255, 0.04);
    border-style: dotted;
    animation: bubbleOrbit2 26s linear infinite reverse;
}

@keyframes bubbleOrbit1 {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes bubbleOrbit2 {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.bubble-core {
    width: 155px;
    height: 155px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, rgba(120, 80, 220, 0.15), transparent 55%),
        radial-gradient(circle at 70% 70%, rgba(40, 120, 220, 0.1), transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(6, 4, 18, 0.95), rgba(6, 4, 18, 0.95));
    border: 2px solid rgba(120, 80, 220, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: inset 0 0 50px rgba(100, 60, 220, 0.06), 0 0 40px rgba(100, 60, 220, 0.04);
}

.bubble-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: rgba(160, 140, 220, 0.3);
    font-size: 12px;
    pointer-events: none;
    transition: all 0.4s ease;
}
.bubble-placeholder i {
    font-size: 20px;
    animation: satellitePulse 3s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(140, 100, 255, 0.3));
}

@keyframes satellitePulse {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.5; }
    50% { transform: translateY(-4px) rotate(8deg); opacity: 1; }
}

/* drag over state */
.persona-bubble.drag-over .bubble-core {
    border-color: rgba(140, 100, 255, 0.6);
    background:
        radial-gradient(circle at 35% 30%, rgba(140, 100, 255, 0.25), transparent 55%),
        radial-gradient(circle at 70% 70%, rgba(60, 160, 255, 0.15), transparent 50%),
        rgba(8, 6, 22, 0.97);
    box-shadow: inset 0 0 60px rgba(120, 80, 220, 0.15), 0 0 50px rgba(120, 80, 220, 0.2);
    transform: scale(1.06);
}
.persona-bubble.drag-over .bubble-ring-1 { border-color: rgba(140, 100, 255, 0.4); animation-duration: 3s; }
.persona-bubble.drag-over .bubble-ring-2 { border-color: rgba(80, 200, 255, 0.25); animation-duration: 5s; }
.persona-bubble.drag-over .bubble-placeholder { color: rgba(180, 160, 255, 0.7); }

/* has traits state */
.persona-bubble.has-traits .bubble-placeholder { opacity: 0; position: absolute; }
.persona-bubble.has-traits .bubble-core {
    border-color: rgba(140, 100, 255, 0.35);
    box-shadow: inset 0 0 50px rgba(120, 80, 220, 0.08), 0 0 40px rgba(100, 60, 220, 0.1);
}
.persona-bubble.has-traits .bubble-ring-1 { border-color: rgba(140, 100, 255, 0.25); }

/* trait orbs */
.bubble-trait-orb {
    position: absolute;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4c1d95, #7c3aed);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35), 0 0 12px rgba(100, 60, 220, 0.2);
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.35s ease;
    animation: orbPopIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bubble-trait-orb:hover {
    transform: scale(1.18) !important;
    box-shadow: 0 6px 28px rgba(124, 58, 237, 0.5), 0 0 20px rgba(140, 100, 255, 0.25);
    z-index: 2;
}
.bubble-trait-orb i { font-size: 14px; margin-bottom: 1px; }
.bubble-trait-orb .orb-remove {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(6, 4, 18, 0.9);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.25s ease;
    cursor: pointer;
}
.bubble-trait-orb:hover .orb-remove { opacity: 1; }

@keyframes orbPopIn {
    from { transform: scale(0) rotate(-45deg); opacity: 0; }
    60%  { transform: scale(1.1) rotate(5deg); }
    to   { transform: scale(1) rotate(0deg); opacity: 1; }
}
@keyframes bubbleRipple {
    0% { transform: scale(0.7); opacity: 0.7; border-color: rgba(140, 100, 255, 0.6); }
    100% { transform: scale(2.5); opacity: 0; border-color: rgba(80, 200, 255, 0); }
}
.bubble-ripple {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid rgba(140, 100, 255, 0.5);
    pointer-events: none;
    animation: bubbleRipple 0.7s ease-out forwards;
}

/* trait count */
.bubble-trait-count {
    font-size: 12px;
    font-weight: 500;
    color: rgba(160, 140, 220, 0.35);
    letter-spacing: 0.04em;
}
.bubble-trait-count span {
    color: #a78bfa;
    font-weight: 700;
    filter: drop-shadow(0 0 4px rgba(167, 139, 250, 0.4));
}

/* ---- selected traits bar ---- */
.persona-selected-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 0;
    margin-bottom: 24px;
    transition: min-height 0.3s ease;
}
.persona-selected-bar:empty { margin-bottom: 0; }

.selected-trait-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, rgba(120, 80, 220, 0.15) 0%, rgba(60, 40, 140, 0.1) 100%);
    border: 1px solid rgba(140, 100, 255, 0.25);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    color: #c4b5fd;
    animation: pcmTagIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.selected-trait-tag i {
    cursor: pointer;
    color: rgba(255, 255, 255, 0.3);
    font-size: 10px;
    transition: all 0.25s ease;
}
.selected-trait-tag i:hover { color: #f87171; transform: scale(1.2); }

@keyframes pcmTagIn {
    from { transform: scale(0.4) translateY(8px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}

/* ---- action buttons ---- */
.persona-creator-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid rgba(120, 80, 220, 0.08);
}

.persona-btn-cancel {
    padding: 11px 22px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid rgba(120, 80, 220, 0.15);
    background: rgba(120, 80, 220, 0.05);
    color: rgba(180, 160, 240, 0.6);
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    align-items: center;
    gap: 6px;
}
.persona-btn-cancel:hover {
    background: rgba(120, 80, 220, 0.12);
    color: #c4b5fd;
    border-color: rgba(140, 100, 255, 0.3);
}

.persona-btn-create {
    padding: 11px 28px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    border: none;
    background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 50%, #6366f1 100%);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 4px 24px rgba(124, 58, 237, 0.3), 0 0 12px rgba(100, 60, 220, 0.15);
    letter-spacing: 0.02em;
}
.persona-btn-create::before {
    content: '';
    position: absolute;
    top: -50%; left: -70%;
    width: 40%; height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
    pointer-events: none;
}
.persona-btn-create:hover:not(:disabled)::before { left: 140%; }
.persona-btn-create:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 36px rgba(124, 58, 237, 0.45), 0 0 24px rgba(140, 100, 255, 0.2);
    filter: brightness(1.1);
}
.persona-btn-create:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    box-shadow: none;
}
.persona-btn-create i { font-size: 13px; }

/* ---- mobile ---- */
@media (max-width: 600px) {
    .persona-creator-content { border-radius: 20px; width: 100%; }
    .persona-creator-header { padding: 20px 20px 16px; }
    .persona-creator-body { padding: 20px; }
    .persona-builder-row { flex-direction: column; align-items: center; }
    .persona-traits-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; width: 100%; max-height: 200px; }
    .persona-trait-chip { flex-direction: column; padding: 10px 4px; font-size: 10px; gap: 4px; text-align: center; }
    .persona-bubble { width: 160px; height: 160px; }
    .bubble-core { width: 125px; height: 125px; }
    .bubble-trait-orb { width: 38px; height: 38px; font-size: 8px; }
    .bubble-trait-orb i { font-size: 12px; }
    .persona-header-icon { width: 40px; height: 40px; font-size: 16px; }
    .persona-creator-header h2 { font-size: 16px; }
}

/* ---- light mode ---- */
body.light-mode .persona-creator-modal { background: radial-gradient(ellipse at 20% 50%, rgba(220, 210, 255, 0.85) 0%, rgba(240, 245, 255, 0.92) 70%); }
body.light-mode .persona-creator-content { background: linear-gradient(160deg, #faf8ff 0%, #f0edff 100%); border-color: rgba(124, 58, 237, 0.2); box-shadow: 0 40px 120px rgba(80, 40, 180, 0.15); }
body.light-mode .persona-creator-content::before { background: linear-gradient(90deg, transparent, rgba(124, 58, 237, 0.3), rgba(59, 130, 246, 0.2), transparent); }
body.light-mode .persona-creator-header { border-color: rgba(124, 58, 237, 0.1); }
body.light-mode .persona-creator-header h2 { background: linear-gradient(90deg, #4c1d95, #6366f1); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
body.light-mode .persona-header-sub { color: rgba(100, 60, 180, 0.5); }
body.light-mode .persona-close-btn { border-color: rgba(0, 0, 0, 0.06); background: rgba(0, 0, 0, 0.02); color: rgba(0, 0, 0, 0.4); }
body.light-mode .persona-close-btn:hover { background: rgba(255, 60, 80, 0.08); color: #ef4444; }
body.light-mode .persona-step-label { color: rgba(100, 60, 180, 0.5); }
body.light-mode .persona-name-input { background: rgba(255, 255, 255, 0.8); border-color: rgba(124, 58, 237, 0.2); color: #1e1040; }
body.light-mode .persona-name-input:focus { border-color: rgba(124, 58, 237, 0.5); background: #fff; }
body.light-mode .persona-trait-chip { background: rgba(255, 255, 255, 0.8); border-color: rgba(124, 58, 237, 0.12); color: #3b1d8e; }
body.light-mode .persona-trait-chip i { color: #7c3aed; filter: none; }
body.light-mode .persona-trait-chip:hover { background: rgba(240, 235, 255, 0.95); border-color: rgba(124, 58, 237, 0.3); color: #4c1d95; }
body.light-mode .persona-trait-chip.active { background: rgba(124, 58, 237, 0.08); border-color: rgba(124, 58, 237, 0.5); color: #4c1d95; }
body.light-mode .selected-trait-tag { background: rgba(124, 58, 237, 0.06); border-color: rgba(124, 58, 237, 0.2); color: #5b21b6; }
body.light-mode .persona-btn-cancel { border-color: rgba(0, 0, 0, 0.08); background: rgba(0, 0, 0, 0.02); color: rgba(0, 0, 0, 0.5); }
body.light-mode .persona-btn-cancel:hover { background: rgba(0, 0, 0, 0.05); color: #111; }
body.light-mode .bubble-core { background: radial-gradient(circle at 35% 30%, rgba(124, 58, 237, 0.08), transparent 55%), #faf8ff; border-color: rgba(124, 58, 237, 0.2); }
body.light-mode .bubble-placeholder { color: rgba(100, 60, 180, 0.3); }
body.light-mode .bubble-trait-count { color: rgba(100, 60, 180, 0.4); }
body.light-mode .bubble-ring-1 { border-color: rgba(124, 58, 237, 0.12); }
body.light-mode .bubble-ring-2 { border-color: rgba(59, 130, 246, 0.08); }
body.light-mode .bubble-trait-orb .orb-remove { background: #fff; }

/* ============================================
   CODE BLOCK WITH COPY BUTTON
   ============================================ */

.code-block-wrapper {
    position: relative;
    margin: 12px 0;
    border-radius: 10px;
    overflow: hidden;
    background: #1e1e2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-language {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color, #667eea);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.copy-code-btn {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    border-radius: 6px;
    color: var(--primary-color, #667eea);
    cursor: pointer;
    transition: all 0.2s ease;
    pointer-events: auto !important;
    position: relative;
    z-index: 100;
}

.copy-code-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6);
    transform: translateY(-1px);
}

.code-block-wrapper pre {
    margin: 0;
    padding: 16px;
    background: transparent;
    border: none;
    overflow-x: auto;
}

.code-block-wrapper code {
    background: transparent;
    padding: 0;
    border: none;
    font-size: 14px;
    line-height: 1.6;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    color: #e4e4e7;
}

.inline-code {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Fira Code', 'Consolas', monospace;
    color: #a5b4fc;
}

body.light-mode .code-block-wrapper {
    background: #f5f5f5;
    border-color: #e0e0e0;
}

body.light-mode .code-block-header {
    background: #e8e8e8;
    border-color: #d0d0d0;
}

body.light-mode .code-language {
    color: var(--primary-color, #667eea);
}

body.light-mode .copy-code-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    color: var(--primary-color, #667eea);
}

body.light-mode .copy-code-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.25);
}

body.light-mode .code-block-wrapper code {
    color: #333;
}

body.light-mode .inline-code {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    color: #5563c1;
}

.copy-code-btn.copied {
    background: rgba(34, 197, 94, 0.3) !important;
    border-color: rgba(34, 197, 94, 0.6) !important;
    color: #22c55e !important;
}

body.light-mode .copy-code-btn.copied {
    background: rgba(34, 197, 94, 0.2) !important;
    color: #16a34a !important;
}

/* Light mode loading indicator */
body.light-mode .loading-indicator {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.95);
    box-shadow: 0 8px 32px rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

body.light-mode .loading-text {
    color: #fff;
}

/* Allow text selection in messages - comprehensive fix */
.message,
.message *,
.message-content,
.message-content *,
.message p,
.message pre,
.message code,
.message span,
.code-block-wrapper,
.code-block-wrapper pre,
.code-block-wrapper code,
.chat-container {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
}

.message-content {
    cursor: default;
}

/* Code Block Styles */
.code-block-wrapper {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    margin: 12px 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.code-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-language {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.copy-code-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.copy-code-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
    transform: translateY(-1px);
}

.copy-code-btn.copied {
    background: rgba(46, 204, 113, 0.3);
    border-color: rgba(46, 204, 113, 0.5);
}

.code-block-wrapper pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    background: transparent;
    border-radius: 0;
}

.code-block-wrapper code {
    background: transparent;
    padding: 0;
    border: none;
    font-size: 14px;
    line-height: 1.5;
    color: #e0e0e0;
}

.inline-code {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--primary-color, #667eea);
}

/* Loading Indicator with Spinning Favicon */
.favicon-spinning {
    animation: faviconSpin 1s linear infinite;
}

@keyframes faviconSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.loading-indicator {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.loading-indicator.show {
    display: flex;
    animation: loadingSlideIn 0.3s ease-out;
}

@keyframes loadingSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.loading-favicon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    animation: spinLoader 1s linear infinite;
    object-fit: contain;
}

@keyframes spinLoader {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 14px;
    font-weight: 500;
}

/* CRITICAL: Enable text selection everywhere - MUST be at the END of the file */
.chat-container,
.chat-container *,
.message,
.message-content,
.message-content * {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    -webkit-user-drag: text !important;
    pointer-events: auto !important;
    cursor: default !important;
}

/* Allow selection in input fields */
input, textarea {
    user-select: text !important;
    -webkit-user-select: text !important;
}

/* Force all interactive elements to be clickable */
.sidebar,
.sidebar-header,
.sidebar-footer,
.recent-chats,
.recent-chats-list,
.chat-item,
.chat-item-content,
.chat-item-title,
.chat-item-preview,
.chat-item-time,
.chat-item-delete {
    pointer-events: auto !important;
    cursor: pointer !important;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.word-select {
    display: inline;
    cursor: default;
    user-select: text !important;
    -webkit-user-select: text !important;
    padding: 1px 0;
    border-radius: 2px;
    transition: background 0.1s ease;
}

.word-select:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

.word-select::selection {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.5);
}

/* ============================================
   TEXT SELECTION UI - FLOATING COPY BUTTON
   ============================================ */
.selection-tooltip {
    position: absolute;
    z-index: 1000;
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(30, 30, 50, 0.95);
    border: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: selectionTooltipFade 0.2s ease-out;
    pointer-events: auto;
}

@keyframes selectionTooltipFade {
    from {
        opacity: 0;
        transform: translateY(5px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.selection-tooltip::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    background: rgba(30, 30, 50, 0.95);
    border-right: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    border-bottom: 1px solid rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
    transform: translateX(-50%) rotate(45deg);
}

.selection-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.selection-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    color: #fff;
}

.selection-btn.copied {
    color: #4ade80;
}

.selection-btn i {
    font-size: 12px;
}

/* Highlight selected text */
.message-content ::selection {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6) !important;
    color: #ffffff !important;
    text-shadow: 0 0 8px rgba(var(--primary-color-rgb, 102, 126, 234), 0.8);
}

.message-content::-moz-selection {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.6) !important;
    color: #ffffff !important;
}

/* ============================================
   FORCE TEXT SELECTION - ALWAYS LAST
   ============================================ */
.chat-container, 
.chat-container * {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    -webkit-user-drag: text !important;
    pointer-events: auto !important;
    cursor: default !important;
}

.message,
.message-content,
.message-content * {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    pointer-events: auto !important;
    cursor: default !important;
}

/* Visible selection highlight */
*::selection {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.7) !important;
    color: #ffffff !important;
}

*::-moz-selection {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.7) !important;
    color: #ffffff !important;
}

/* ============================================
   ENHANCED ANIMATIONS & UI POLISH
   ============================================ */

/* Smooth page-level transitions */
.app {
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.4s;
}

/* Sidebar open/close on mobile */
@media (max-width: 768px) {
    .sidebar {
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    .sidebar.open {
        transform: translateX(0) !important;
    }
}

/* Settings & Memory panel slide-in */
.settings-panel,
.memory-panel {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
}

.settings-panel:not(.hidden),
.memory-panel:not(.hidden) {
    animation: panelFadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.settings-panel-content,
.memory-panel-content {
    animation: panelSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* AI Mode dropdown animation */
.ai-mode-dropdown {
    animation: modeDropIn 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

@keyframes modeDropIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Button press micro-interaction */
.btn {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.btn:active:not(:disabled) {
    transform: scale(0.96) !important;
}

/* Sidebar footer buttons */
.sidebar-footer .btn {
    border-radius: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-footer .btn:hover {
    transform: translateY(-1px);
}

/* ============================================
   IMPROVED MOBILE RESPONSIVENESS
   ============================================ */

@media (max-width: 768px) {
    /* Sidebar overlay */
    .sidebar {
        width: 300px !important;
        max-width: 85vw;
    }

    /* Header compact */
    .header {
        padding: 10px 14px !important;
        gap: 8px;
    }

    .header h1 {
        font-size: 16px !important;
    }

    .header-left {
        gap: 8px;
        min-width: 0;
    }

    .header-controls {
        gap: 6px;
        flex-wrap: nowrap;
        align-items: center;
        overflow-x: auto;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .header-controls::-webkit-scrollbar {
        display: none;
    }

    /* AI mode button compact */
    .ai-mode-btn #aiModeLabel {
        display: none;
    }

    .ai-mode-btn .fa-chevron-down {
        display: none;
    }

    .ai-mode-btn {
        padding: 8px 10px !important;
        min-width: 38px;
    }

    /* Hide less important items */
    .current-chat-title {
        display: none !important;
    }

    .message-counter {
        display: none !important;
    }

    /* Chat area */
    .chat-container {
        padding: 16px 12px !important;
    }

    .message-content {
        max-width: 88% !important;
        padding: 12px 14px !important;
    }

    .message-avatar {
        width: 30px !important;
        height: 30px !important;
        font-size: 11px !important;
    }

    /* Input area */
    .input-container {
        padding: 12px 10px !important;
    }

    #messageInput {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 12px 14px !important;
        min-height: 44px !important;
    }

    .input-wrapper .btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        padding: 0 !important;
    }

    #sendButton {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
    }

    .input-footer {
        display: none;
    }

    /* Welcome section */
    .welcome-greeting {
        font-size: 24px !important;
    }

    .welcome-suggestions {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    .suggestion-chip {
        padding: 10px 12px !important;
        font-size: 12px !important;
        border-radius: 12px !important;
    }

    .suggestion-chip i {
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
    }

    /* AI mode dropdown fullwidth on mobile */
    .ai-mode-dropdown {
        position: fixed !important;
        top: 60px !important;
        right: 12px !important;
        left: auto !important;
        min-width: 220px !important;
        max-width: calc(100vw - 24px);
    }

    /* Panels fullscreen on mobile */
    .settings-panel-content,
    .memory-panel-content {
        margin: 0 !important;
        border-radius: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
    }

    /* Loading screen mobile */
    .loading-logo {
        width: 64px !important;
        height: 64px !important;
    }

    .loading-ring {
        width: 100px !important;
        height: 100px !important;
        top: -18px !important;
    }

    .loading-brand {
        font-size: 16px !important;
    }

    .loading-bar {
        width: 110px !important;
    }

    /* Code blocks mobile */
    .code-block-wrapper {
        max-width: 100% !important;
    }

    .code-block-wrapper pre {
        max-width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .code-block-wrapper code {
        font-size: 12px !important;
    }

    /* Font selector mobile */
    .font-selector {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Generated images */
    .generated-image-wrapper img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Loading indicator */
    .loading-indicator {
        bottom: 100px !important;
        padding: 8px 16px !important;
        font-size: 13px !important;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 8px 10px !important;
    }

    .header h1 {
        font-size: 14px !important;
    }

    .header-controls .btn {
        padding: 6px 8px !important;
        font-size: 12px !important;
    }

    .sidebar {
        width: 100% !important;
        max-width: 100vw !important;
    }

    .chat-container {
        padding: 12px 8px !important;
    }

    .message-content {
        max-width: 92% !important;
        padding: 10px 12px !important;
        font-size: 14px !important;
    }

    .welcome-greeting {
        font-size: 20px !important;
    }

    .welcome-content {
        gap: 16px !important;
    }

    .welcome-suggestions {
        grid-template-columns: 1fr !important;
    }

    .suggestion-chip {
        padding: 12px 14px !important;
        justify-content: flex-start;
    }

    /* Hide less used input buttons on tiny screens */
    .generate-image-btn,
    .auto-read-btn {
        display: none !important;
    }

    .input-wrapper .btn {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    #sendButton {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    .logo-container {
        width: 34px !important;
        height: 34px !important;
    }

    .header-logo {
        width: 30px !important;
        height: 30px !important;
    }
}

/* Touch-friendly for mobile */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .chat-item {
        padding: 14px 16px;
    }

    .suggestion-chip {
        min-height: 48px;
    }

    .action-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Remove hover-dependent effects on touch */
    .chat-item:hover {
        transform: none;
    }

    .suggestion-chip:hover {
        transform: none;
    }
}

/* Safe area on notched devices */
@supports (padding: env(safe-area-inset-bottom)) {
    .input-container {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .welcome-logo {
        display: none;
    }

    .welcome-greeting {
        font-size: 20px !important;
    }

    .welcome-content {
        gap: 12px !important;
    }

    .loading-logo {
        width: 48px !important;
        height: 48px !important;
    }

    .loading-ring {
        width: 80px !important;
        height: 80px !important;
    }
}

/* ============================================
   RIGHT-CLICK CONTEXT PANEL
   ============================================ */

.context-panel {
    position: fixed;
    z-index: 100000;
    width: 240px;
    background: rgba(22, 22, 35, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 8px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: contextPanelIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: top left;
    user-select: none;
}

.context-panel.hidden {
    display: none;
}

@keyframes contextPanelIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(-4px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.context-panel-header {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: rgba(255, 255, 255, 0.4);
    padding: 6px 8px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.context-panel-header i {
    color: var(--primary-color, #667eea);
    font-size: 12px;
}

.context-section {
    padding: 4px 0;
}

.context-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.35);
    padding: 4px 8px 6px;
}

.context-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 4px 8px;
}

/* Theme swatches */
.context-theme-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    padding: 2px 8px 4px;
}

.context-theme-swatch {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.context-theme-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.context-theme-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 0 2px var(--primary-color, #667eea);
}

.context-theme-swatch.active::after {
    content: '\2713';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Font buttons */
.context-font-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 2px 8px 4px;
}

.context-font-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.context-font-btn:hover {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
    color: #fff;
}

.context-font-btn.active {
    background: var(--primary-color, #667eea);
    border-color: var(--primary-color, #667eea);
    color: #fff;
    font-weight: 600;
}

/* Action buttons */
.context-action {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.context-action:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.context-action i {
    width: 18px;
    text-align: center;
    color: var(--primary-color, #667eea);
    font-size: 13px;
}

/* Light mode context panel */
body.light-mode .context-panel {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

body.light-mode .context-panel-header {
    color: rgba(0, 0, 0, 0.45);
}

body.light-mode .context-label {
    color: rgba(0, 0, 0, 0.4);
}

body.light-mode .context-divider {
    background: rgba(0, 0, 0, 0.06);
}

body.light-mode .context-theme-swatch.active {
    border-color: #1a1a2e;
}

body.light-mode .context-font-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
    color: #1a1a2e;
}

body.light-mode .context-font-btn:hover {
    background: rgba(79, 70, 229, 0.08);
    border-color: rgba(79, 70, 229, 0.3);
}

body.light-mode .context-font-btn.active {
    background: var(--primary-color, #4f46e5);
    color: #fff;
}

body.light-mode .context-action {
    color: #1a1a2e;
}

body.light-mode .context-action:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* ============================================
   BUTTON THEME & LIGHT MODE FIXES
   ============================================ */

/* Primary buttons always white text on colored bg */
.btn.primary,
.sidebar-new-chat,
.sidebar-new-chat.btn.primary,
#sendButton {
    color: #fff !important;
}

.btn.primary i,
.sidebar-new-chat i,
#sendButton i {
    color: #fff !important;
}

/* All themed buttons use --primary-color */
.btn.primary,
#sendButton {
    background: var(--primary-color, #667eea) !important;
}

/* User message bubbles follow theme */
.message.user .message-content {
    background: linear-gradient(135deg, var(--primary-color, #667eea) 0%, var(--primary-dark, #764ba2) 100%) !important;
}

.message.user .message-avatar {
    background: var(--primary-color, #667eea) !important;
}

/* AI avatar follows theme gradient */
.message.ai .message-avatar {
    background: linear-gradient(135deg, var(--primary-color, #667eea) 0%, var(--primary-dark, #764ba2) 100%) !important;
}

/* Suggestion chip icons follow theme */
.suggestion-chip i {
    color: var(--primary-color, #667eea);
    border-color: var(--primary-color, #667eea);
}

.suggestion-chip:hover i {
    background: var(--primary-color, #667eea);
}

/* Active chat item follows theme */
.chat-item.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.15) !important;
    border-left-color: var(--primary-color, #667eea) !important;
    color: var(--primary-color, #667eea) !important;
}

/* Loading indicator follows theme */
.loading-indicator {
    background: var(--primary-color, #667eea) !important;
}

/* Brand name follows theme */
.brand-name {
    color: var(--primary-color, #667eea) !important;
}

/* ============================================
   ALL ACCENTS FOLLOW THEME
   ============================================ */

/* Logo glow follows theme */
.logo-glow {
    background: var(--primary-color, #667eea) !important;
}

/* Welcome section follows theme */
.welcome-icon {
    color: var(--primary-color, #667eea) !important;
}

.welcome-content h2 {
    color: var(--primary-color, #667eea) !important;
}

/* Input focus follows theme */
#messageInput:focus {
    border-color: var(--primary-color, #667eea) !important;
}

/* Secondary button hover follows theme */
.btn.secondary:hover,
.theme-btn:hover {
    border-color: var(--primary-color, #667eea) !important;
}

/* Send button styling follows theme */
#sendButton {
    background: var(--primary-color, #667eea) !important;
}

/* Streaming cursor follows theme */
.message.streaming .cursor {
    background: linear-gradient(180deg, var(--primary-color, #667eea), var(--primary-dark, #764ba2)) !important;
}

/* Personality button follows theme */
.personality-btn {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.4);
}

.personality-btn i,
.personality-option i {
    color: var(--primary-color, #667eea) !important;
}

.personality-option.active i {
    background: var(--primary-color, #667eea) !important;
    color: #fff !important;
}

.personality-option.active {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.3);
}

/* Personality card active follows theme */
.personality-card.active .personality-card-icon {
    background: var(--primary-color, #667eea) !important;
}

.personality-card-icon i {
    color: var(--primary-color, #667eea) !important;
}

.personality-card.active .personality-card-icon i {
    color: #fff !important;
}

.personality-card.active .personality-check {
    background: var(--primary-color, #667eea) !important;
    border-color: var(--primary-color, #667eea) !important;
}

.personality-badge i {
    color: var(--primary-color, #667eea) !important;
}

.personality-badge {
    background: rgba(var(--primary-color-rgb, 102, 126, 234), 0.2);
}

/* Overlay title icon follows theme */
.overlay-title i {
    color: var(--primary-color, #667eea) !important;
}

/* Voice and auto-read buttons follow theme */
.voice-btn i {
    color: var(--primary-color, #667eea) !important;
}

.voice-btn:hover {
    border-color: var(--primary-color, #667eea) !important;
}

.auto-read-btn:hover i {
    color: var(--primary-color, #667eea) !important;
}

.auto-read-btn.active {
    background: var(--primary-color, #667eea) !important;
}

/* Upload button follows theme */
.upload-btn {
    border-color: rgba(var(--primary-color-rgb, 102, 126, 234), 0.4) !important;
}

/* Message counter badge follows theme */
#messageCount {
    background: var(--primary-color, #667eea) !important;
}

/* Connection status follows theme */
.action-btn.speaking {
    color: var(--primary-color, #667eea) !important;
}

/* Theme option active follows theme */
.theme-option.active {
    border-left-color: var(--primary-color, #667eea) !important;
}

/* Light mode active items follow theme */
[data-mode="light"] .chat-item.active {
    color: var(--primary-color, #667eea) !important;
    border-left-color: var(--primary-color, #667eea) !important;
}

[data-mode="light"] .brand-name {
    color: var(--primary-color, #667eea) !important;
}

/* Font option active follows theme */
.font-option.active {
    border-color: var(--primary-color, #667eea) !important;
}

.font-option.active::after {
    color: var(--primary-color, #667eea) !important;
}

/* Toggle slider active follows theme */
.toggle-slider::before {
    transition: transform 0.3s, background 0.3s;
}

input:checked + .toggle-slider {
    background: var(--primary-color, #667eea) !important;
}

/* Density/selector active follows theme */
.density-option.active {
    background: var(--primary-color, #667eea) !important;
    color: #fff !important;
}

/* Bubble style active follows theme */
.bubble-style-option.active {
    border-color: var(--primary-color, #667eea) !important;
}

/* Context panel active follows theme */
.context-font-btn.active {
    background: var(--primary-color, #667eea) !important;
    border-color: var(--primary-color, #667eea) !important;
}

.context-panel-header i,
.context-action i {
    color: var(--primary-color, #667eea) !important;
}

/* ============================================
   LIGHT MODE COMPREHENSIVE TEXT FIXES
   ============================================ */

body.light-mode {
    color: #1a1a2e;
}

/* Light mode: all standard buttons get dark text except primary/danger */
body.light-mode .btn {
    color: #1a1a2e;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

body.light-mode .btn i {
    color: #1a1a2e;
}

/* Primary buttons ALWAYS white text even in light mode */
body.light-mode .btn.primary,
body.light-mode .sidebar-new-chat,
body.light-mode #sendButton {
    color: #fff !important;
    background: var(--primary-color, #4f46e5) !important;
}

body.light-mode .btn.primary i,
body.light-mode .sidebar-new-chat i,
body.light-mode #sendButton i {
    color: #fff !important;
}

/* Light mode text colors for readability */
body.light-mode h1,
body.light-mode h2,
body.light-mode h3,
body.light-mode h4,
body.light-mode p,
body.light-mode span,
body.light-mode label,
body.light-mode .settings-description,
body.light-mode .setting-note,
body.light-mode .settings-section h3 {
    color: #1a1a2e;
}

body.light-mode .settings-description,
body.light-mode .setting-note {
    color: #555;
}

body.light-mode .settings-divider span {
    color: #1a1a2e;
}

/* Font selector in light mode */
body.light-mode .font-option {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .font-option:hover {
    background: rgba(79, 70, 229, 0.06);
    border-color: rgba(79, 70, 229, 0.3);
}

body.light-mode .font-option.active {
    background: rgba(79, 70, 229, 0.08);
    border-color: var(--primary-color, #4f46e5);
}

body.light-mode .font-preview {
    color: #1a1a2e;
}

body.light-mode .font-option.active .font-preview {
    color: var(--primary-color, #4f46e5);
}

/* Settings panel in light mode */
body.light-mode .settings-panel-content {
    background: #fff;
    color: #1a1a2e;
}

body.light-mode .settings-panel-header {
    border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light-mode .settings-panel-header h2 {
    color: #1a1a2e;
}

body.light-mode .settings-section {
    border-color: rgba(0, 0, 0, 0.06);
}

/* Toggle switch labels in light mode */
body.light-mode .toggle-setting span {
    color: #1a1a2e;
}

/* Slider and controls in light mode */
body.light-mode .slider-label {
    color: #1a1a2e;
}

body.light-mode .slider-value {
    color: #555;
}

/* Density/position buttons in light mode */
body.light-mode .density-option {
    color: #1a1a2e;
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

body.light-mode .density-option.active {
    background: var(--primary-color, #4f46e5);
    color: #fff;
}

/* Bubble style grid in light mode */
body.light-mode .bubble-style-option {
    color: #1a1a2e;
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-mode .bubble-style-option.active {
    border-color: var(--primary-color, #4f46e5);
    color: var(--primary-color, #4f46e5);
}

/* Custom CSS textarea in light mode */
body.light-mode .custom-css-textarea {
    background: #f8f9fa;
    color: #1a1a2e;
    border-color: rgba(0, 0, 0, 0.1);
}

/* Profile action buttons in light mode */
body.light-mode .profile-btn {
    color: #1a1a2e;
}

/* Welcome section in light mode */
body.light-mode .welcome-greeting {
    color: rgba(0, 0, 0, 0.35);
}

body.light-mode .welcome-content p {
    color: #555;
}

body.light-mode .welcome-content h2 {
    color: var(--primary-color, #4f46e5);
}

/* AI message bubble in light mode */
body.light-mode .message.ai .message-content {
    background: #ffffff;
    color: #1a1a2e;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

body.light-mode .message.ai .message-content p,
body.light-mode .message.ai .message-content li,
body.light-mode .message.ai .message-content span,
body.light-mode .message.ai .message-content code {
    color: #1a1a2e;
}

/* Action buttons in light mode */
body.light-mode .action-btn {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    color: #555;
}

body.light-mode .action-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #1a1a2e;
}

/* Message timestamp in light mode */
body.light-mode .message-timestamp {
    color: rgba(0, 0, 0, 0.4);
}

/* Sidebar elements in light mode */
body.light-mode .chat-item-title {
    color: #1a1a2e;
}

body.light-mode .chat-item-preview {
    color: #777;
}

body.light-mode .chat-item-time {
    color: #999;
}

/* AI mode dropdown in light mode */
body.light-mode .ai-mode-dropdown {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

body.light-mode .ai-mode-option {
    color: #1a1a2e;
}

body.light-mode .ai-mode-option:hover {
    background: rgba(79, 70, 229, 0.06);
}

/* Theme dropdown in light mode */
body.light-mode .theme-dropdown {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

body.light-mode .theme-option {
    color: #1a1a2e;
}

body.light-mode .theme-option:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* Personality overlay in light mode - covered separately above */

/* Scrollbar in light mode */
body.light-mode .chat-container::-webkit-scrollbar-thumb,
body.light-mode .recent-chats::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
}

body.light-mode .chat-container::-webkit-scrollbar-thumb:hover,
body.light-mode .recent-chats::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Global Announcement Banner */
.global-announcement-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    animation: bannerSlideDown 0.3s ease;
}

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

.global-announcement-info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
}

.global-announcement-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #000;
}

.global-announcement-success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #fff;
}

.global-announcement-error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #fff;
}

/* â•â•â•â•â•â•â• AI MODE HEADER DROPDOWN â•â•â•â•â•â•â• */
.ai-mode-wrapper {
    position: relative;
}

.ai-mode-display {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.ai-mode-display:hover,
.ai-mode-display.dropdown-open {
    background: var(--bg-tertiary, rgba(255,255,255,0.1));
}

.ai-mode-chevron {
    font-size: 0.6rem;
    margin-left: 2px;
    opacity: 0.5;
    transition: transform 0.25s ease;
}

.ai-mode-display.dropdown-open .ai-mode-chevron {
    transform: rotate(180deg);
    opacity: 1;
}

/* Dropdown panel */
.ai-mode-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    max-height: 420px;
    background: var(--bg-primary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.4);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px) scale(0.97);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 9999;
}

.ai-mode-dropdown-panel.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.ai-mode-dropdown-header {
    padding: 14px 16px 10px;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.5;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

.ai-mode-dropdown-list {
    max-height: 310px;
    overflow-y: auto;
    padding: 6px;
}

.ai-mode-dropdown-list::-webkit-scrollbar {
    width: 4px;
}

.ai-mode-dropdown-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

.ai-mode-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.ai-mode-dropdown-item:hover {
    background: var(--bg-tertiary, rgba(255,255,255,0.07));
}

.ai-mode-dropdown-item.active {
    background: var(--accent-color, #7c3aed);
    color: #fff;
}

.ai-mode-dropdown-item i:first-child {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
    opacity: 0.7;
}

.ai-mode-dropdown-item.active i:first-child {
    opacity: 1;
}

.ai-mode-dropdown-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.ai-mode-dropdown-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.ai-mode-dropdown-desc {
    font-size: 0.75rem;
    opacity: 0.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-mode-dropdown-item.active .ai-mode-dropdown-desc {
    opacity: 0.8;
}

/* Divider between standard and custom */
.ai-mode-dropdown-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.4;
    font-weight: 600;
}

.ai-mode-dropdown-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color, rgba(255,255,255,0.1));
}

/* Delete button on custom personas */
.ai-mode-delete-btn {
    background: none;
    border: none;
    color: inherit;
    opacity: 0;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.75rem;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.ai-mode-dropdown-item:hover .ai-mode-delete-btn {
    opacity: 0.4;
}

.ai-mode-delete-btn:hover {
    opacity: 1 !important;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

/* Footer with create button */
.ai-mode-dropdown-footer {
    padding: 8px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

.ai-mode-create-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border: 2px dashed var(--border-color, rgba(255,255,255,0.15));
    border-radius: 10px;
    background: transparent;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    font-family: inherit;
}

.ai-mode-create-btn:hover {
    opacity: 1;
    border-color: var(--accent-color, #7c3aed);
    color: var(--accent-color, #7c3aed);
    background: rgba(124, 58, 237, 0.08);
}

/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   PWA Standalone & Offline Enhancements
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */

/* Safe area insets for notched devices (iPhone X+, etc.) */
@supports (padding: env(safe-area-inset-top)) {
    .pwa-standalone .app-header {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }
    .pwa-standalone .input-area {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
    .pwa-standalone body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Disable pull-to-refresh in standalone PWA */
.pwa-standalone body {
    overscroll-behavior-y: contain;
}

/* Offline indicator bar */
html.is-offline::after {
    content: 'ðŸ“¡ You are offline';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100000;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #fff;
    text-align: center;
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: var(--font-family);
    animation: slideDown 0.3s ease;
}

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

/* Push content down when offline bar is visible */
html.is-offline .app-header {
    margin-top: 32px;
}
