/* ============================================
   Atlas AI - Modern Smart UI Design
   Complete Redesign from Scratch
   ============================================ */

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

:root {
    /* Modern Light Theme (softer) */
    --font-ui: 'Aboreto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    /* Chat typography: use a highly readable font for messages + input only */
    --font-chat: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    /* Minimal Aboreto theme (setter-style) */
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f5;
    --bg-elevated: #ffffff;
    --bg-hover: #f0f0f0;
    
    --text-primary: #1a1a1a;
    --text-secondary: #444;
    --text-tertiary: #777;
    --text-muted: #999;
    
    --accent-primary: #1a1a1a;
    --accent-primary-hover: #000000;
    --accent-secondary: #333333;
    --accent-success: #1a1a1a;
    --accent-warning: #1a1a1a;
    --accent-danger: #1a1a1a;
    
    --border-color: #e5e5e5;
    --border-hover: #d1d1d1;
    
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
    --shadow-xl: none;
    --shadow-2xl: none;
    
    --sidebar-width: 92px;
    --header-height: 64px;
    --input-height: 64px;

    /* Responsive content stage width:
       - expands on wide screens to reduce blank space
       - capped to avoid overly long line lengths */
    --stage-max-width: clamp(1020px, 82vw, 1560px);
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;
    --radius-full: 9999px;
    
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Default tone accent (overridden by body[data-tone]) */
    --tone-accent: var(--accent-primary);
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #141414;
    --bg-elevated: #1a1a1a;
    --bg-hover: #252525;
    
    --text-primary: #FFD700;
    --text-secondary: #FFF8DC;
    --text-tertiary: #F5F5DC;
    --text-muted: #D3D3D3;
    
    --accent-primary: #FFD700;
    --accent-primary-hover: #FFA500;
    --accent-secondary: #FFF8DC;
    
    --border-color: #333333;
    --border-hover: #444444;
    
    --shadow-sm: 0 2px 8px rgba(255, 215, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(255, 215, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(255, 215, 0, 0.2);
    --shadow-xl: 0 12px 32px rgba(255, 215, 0, 0.25);
    --shadow-2xl: 0 16px 48px rgba(255, 215, 0, 0.3);
}

body {
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Tone accent colors (UI + subtle bubble accents) */
body[data-tone="normal"] { --tone-accent: #1a1a1a; }
body[data-tone="friendly"] { --tone-accent: #16a34a; }
body[data-tone="calm"] { --tone-accent: #2563eb; }
body[data-tone="formal"] { --tone-accent: #7c3aed; }
body[data-tone="critical"] { --tone-accent: #dc2626; }

body[data-theme="dark"][data-tone="normal"] { --tone-accent: #FFD700; }
body[data-theme="dark"][data-tone="friendly"] { --tone-accent: #FFA500; }
body[data-theme="dark"][data-tone="calm"] { --tone-accent: #FFD700; }
body[data-theme="dark"][data-tone="formal"] { --tone-accent: #FFF8DC; }
body[data-theme="dark"][data-tone="critical"] { --tone-accent: #FF6B6B; }

/* ============================================
   ANIMATIONS
   ============================================ */

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

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

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

/* ============================================
   APP CONTAINER
   ============================================ */

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    padding: 0;
    background: var(--bg-primary);
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: width var(--transition-slow), transform var(--transition-slow);
    position: relative;
    z-index: 100;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border-radius: 0;
    margin: 0;
    backdrop-filter: none;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

body.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    border-right: none;
    box-shadow: none;
}

body.sidebar-collapsed .sidebar > * {
    opacity: 0;
    pointer-events: none;
}

body.sidebar-collapsed .main-content {
    width: 100%;
}

.sidebar-top {
    padding: 12px 16px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--border-color);
    min-height: var(--header-height);
    justify-content: flex-start;
}

.sidebar-icon-btn {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.sidebar-icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-icon-btn.primary {
    background: var(--accent-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.sidebar-icon-btn.primary:hover {
    background: var(--accent-primary-hover);
    box-shadow: var(--shadow-md);
}

.sidebar-icon-btn svg {
    width: 20px;
    height: 20px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px 18px 14px;
}

.section-title {
    padding: 8px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.chats-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 16px 10px;
}

.chat-item {
    padding: 9px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    text-decoration: none;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-weight: 400;
    position: relative;
    animation: slideIn 0.3s ease backwards;
}

.chat-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-item.active {
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-weight: 500;
}

.chat-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-primary);
    border-radius: 0 2px 2px 0;
}

.chat-item-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    line-height: 1.4;
}

.chat-delete-btn {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--transition-base);
    opacity: 1;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
    vertical-align: middle;
}

.chat-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

.chats-loading {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

.projects-section {
    margin-top: 16px;
}

/* Gems section */
.gems-section {
    margin-top: 16px;
}

.gems-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 0 16px 10px;
}

.gem-item-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 0;
    width: 100%;
    min-width: 0;
}

.gem-item-wrapper.active {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    padding: 4px 10px;
}

.gem-item {
    padding: 4px 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 13px;
    border: none;
    background: transparent;
    text-align: left;
    flex-wrap: nowrap;
    overflow: hidden;
}

.gem-item-wrapper:hover {
    background: var(--bg-hover);
    border-radius: var(--radius-md);
    padding: 4px 10px;
}

.gem-item-wrapper:hover .gem-item {
    color: var(--text-primary);
}

.gem-item-wrapper.active .gem-item {
    color: var(--text-primary);
    font-weight: 500;
}

.gem-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    flex-wrap: nowrap;
    margin-right: 8px;
}

.gem-item-title {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
    font-weight: 500;
    transition: all var(--transition-base);
}

/* Metallic tone colors for gem names */
.gem-item-title.gem-tone-friendly {
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 50%, #4ade80 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(22, 163, 74, 0.3);
    filter: drop-shadow(0 1px 2px rgba(22, 163, 74, 0.4));
}

.gem-item-title.gem-tone-calm {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 50%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(37, 99, 235, 0.3);
    filter: drop-shadow(0 1px 2px rgba(37, 99, 235, 0.4));
}

.gem-item-title.gem-tone-formal {
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 50%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(124, 58, 237, 0.3);
    filter: drop-shadow(0 1px 2px rgba(124, 58, 237, 0.4));
}

.gem-item-title.gem-tone-critical {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 50%, #f87171 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(220, 38, 38, 0.3);
    filter: drop-shadow(0 1px 2px rgba(220, 38, 38, 0.4));
}

.gem-item-title.gem-tone-normal {
    color: var(--text-secondary);
}

[data-theme="dark"] .gem-item-title.gem-tone-friendly {
    background: linear-gradient(135deg, #22c55e 0%, #4ade80 50%, #86efac 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
    filter: drop-shadow(0 1px 2px rgba(34, 197, 94, 0.5));
}

[data-theme="dark"] .gem-item-title.gem-tone-calm {
    background: linear-gradient(135deg, #60a5fa 0%, #93c5fd 50%, #bfdbfe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(96, 165, 250, 0.4);
    filter: drop-shadow(0 1px 2px rgba(96, 165, 250, 0.5));
}

[data-theme="dark"] .gem-item-title.gem-tone-formal {
    background: linear-gradient(135deg, #a78bfa 0%, #c4b5fd 50%, #ddd6fe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(167, 139, 250, 0.4);
    filter: drop-shadow(0 1px 2px rgba(167, 139, 250, 0.5));
}

[data-theme="dark"] .gem-item-title.gem-tone-critical {
    background: linear-gradient(135deg, #f87171 0%, #fca5a5 50%, #fecaca 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(248, 113, 113, 0.4);
    filter: drop-shadow(0 1px 2px rgba(248, 113, 113, 0.5));
}

[data-theme="dark"] .gem-item-title.gem-tone-normal {
    color: var(--text-secondary);
}

.gem-tone-badge {
    flex-shrink: 0;
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 9999px;
    text-transform: capitalize;
    letter-spacing: 0.02em;
    border: 1px solid currentColor;
    opacity: 0.85;
    white-space: nowrap;
}

.gem-tone-badge.tone-friendly {
    color: #16a34a;
    border-color: #16a34a;
    background: rgba(22, 163, 74, 0.1);
}

.gem-tone-badge.tone-calm {
    color: #2563eb;
    border-color: #2563eb;
    background: rgba(37, 99, 235, 0.1);
}

.gem-tone-badge.tone-formal {
    color: #7c3aed;
    border-color: #7c3aed;
    background: rgba(124, 58, 237, 0.1);
}

.gem-tone-badge.tone-critical {
    color: #dc2626;
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.gem-tone-badge.tone-normal {
    color: var(--text-secondary);
    border-color: var(--border-color);
    background: var(--bg-tertiary);
}

[data-theme="dark"] .gem-tone-badge.tone-friendly {
    color: #22c55e;
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

[data-theme="dark"] .gem-tone-badge.tone-calm {
    color: #60a5fa;
    border-color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
}

[data-theme="dark"] .gem-tone-badge.tone-formal {
    color: #a78bfa;
    border-color: #a78bfa;
    background: rgba(167, 139, 250, 0.15);
}

[data-theme="dark"] .gem-tone-badge.tone-critical {
    color: #f87171;
    border-color: #f87171;
    background: rgba(248, 113, 113, 0.15);
}

[data-theme="dark"] .gem-tone-badge.tone-normal {
    color: var(--text-tertiary);
    border-color: var(--border-color);
    background: var(--bg-tertiary);
}

.gem-actions {
    display: inline-flex;
    gap: 4px;
    flex-shrink: 0;
    align-items: center;
    flex-wrap: nowrap;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.gem-item-wrapper:hover .gem-actions,
.gem-item-wrapper.active .gem-actions {
    opacity: 1;
}

.gem-action-btn {
    width: 20px;
    height: 20px;
    min-width: 20px;
    min-height: 20px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--transition-base);
    flex-shrink: 0;
    padding: 0;
}

.gem-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.gem-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
}

.new-project-btn {
    margin: 0 16px 12px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: all var(--transition-base);
}

.new-project-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    min-height: 56px;
}

.settings-link {
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    transition: all var(--transition-base);
    text-align: left;
    border-radius: var(--radius-md);
}

.settings-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-link svg {
    width: 18px;
    height: 18px;
}

/* Sidebar Toggle Float Button */
.sidebar-toggle-float {
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 1000;
    width: 48px;
    height: 48px;
    border: none;
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all var(--transition-base);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.4);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .sidebar-toggle-float {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border-color: rgba(255, 215, 0, 0.3);
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.3);
    color: #000000;
}

.sidebar.collapsed ~ .main-content .sidebar-toggle-float {
    display: flex;
}

.sidebar-toggle-float:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

[data-theme="dark"] .sidebar-toggle-float:hover {
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

.sidebar-toggle-float svg {
    width: 24px;
    height: 24px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    overflow: hidden;
    position: relative;
    padding: 14px;
}

.content-header {
    height: 64px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    background: linear-gradient(180deg, #ff8a00 0%, #ff6b00 55%, #ff4d00 100%);
    border-radius: 26px;
    box-shadow: 0 18px 46px rgba(255, 106, 0, 0.22);
    position: relative;
    z-index: 10;
    max-width: var(--stage-max-width);
    width: 100%;
    margin: 0 auto 12px;
}

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

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.atlas-logo {
    width: 32px;
    height: 32px;
    color: rgba(255, 255, 255, 0.96);
    flex-shrink: 0;
}

.app-name {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.theme-toggle-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
}

.theme-toggle-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.theme-toggle-btn .theme-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition-base), transform var(--transition-base);
    opacity: 0;
}

.theme-toggle-btn[data-theme="light"] .sun-icon {
    opacity: 1;
    transform: scale(1);
}

.theme-toggle-btn[data-theme="light"] .moon-icon {
    transform: scale(0.6);
}

.theme-toggle-btn[data-theme="dark"] .moon-icon {
    opacity: 1;
    transform: scale(1);
}

.theme-toggle-btn[data-theme="dark"] .sun-icon {
    transform: scale(0.6);
}

/* Header icon buttons (Help, Customize) */
.header-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
}

.header-icon-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* Orange header contextual styling */
.content-header .header-icon-btn,
.content-header .theme-toggle-btn {
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.95);
    position: relative;
    overflow: visible;
}

.content-header .header-icon-btn:hover,
.content-header .theme-toggle-btn:hover {
    color: #111111;
}

/* Header buttons: white circular hover mask + floating tooltip below */
.content-header .header-icon-btn::before,
.content-header .theme-toggle-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 34px;
    height: 34px;
    background: #ffffff;
    border-radius: 9999px;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 0;
}

.content-header .header-icon-btn:hover::before,
.content-header .theme-toggle-btn:hover::before {
    transform: translate(-50%, -50%) scale(1);
}

.content-header .header-icon-btn svg,
.content-header .theme-toggle-btn svg {
    position: relative;
    z-index: 1;
}

.content-header .header-icon-btn::after,
.content-header .theme-toggle-btn::after {
    content: attr(title);
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.92);
    color: #ffffff;
    padding: 8px 12px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.02em;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    transition: opacity 160ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.content-header .header-icon-btn:hover::after,
.content-header .theme-toggle-btn:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.content-header .upgrade-btn {
    background: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: none;
}

.content-header .upgrade-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}

.content-header .user-avatar {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.content-header .user-avatar:hover {
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.header-icon-btn i {
    font-size: 16px;
    line-height: 1;
}

.header-icon-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

.upgrade-btn {
    padding: 8px 12px;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-md);
}

.upgrade-btn:hover {
    transform: translateY(-1px);
    background: var(--bg-hover);
    box-shadow: none;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--bg-elevated);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.user-avatar:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

/* ============================================
   CHAT CONTAINER
   ============================================ */

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    max-width: var(--stage-max-width);
    width: 100%;
    margin: 0 auto;
}

.welcome-screen {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 56px 18px 28px;
    max-width: var(--stage-max-width);
    width: 100%;
    margin: 0 auto 8px;
    text-align: center;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    animation: fadeIn 0.6s ease;
}

.welcome-title {
    font-size: 34px;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(120deg, #4f46e5, #8b5cf6, #ec4899, #f59e0b, #22d3ee, #10b981);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    animation: helloGradient 9s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(79, 70, 229, 0.3));
}

[data-theme="dark"] .welcome-title {
    background: linear-gradient(120deg, #FFD700, #FFA500, #FFD700, #FFED4E, #FFD700, #FFA500);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 4px rgba(255, 215, 0, 0.4));
    font-family: 'Aboreto', cursive;
    animation: helloGradient 9s ease-in-out infinite;
}

.welcome-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    font-weight: 500;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

/* Welcome actions (orange action cards) */
.welcome-actions {
    width: 100%;
    max-width: 740px;
    margin: 22px auto 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 12px;
    padding: 0 6px;
}

.welcome-action-card {
    border: none;
    cursor: pointer;
    text-align: left;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 14px;
    border-radius: 22px;
    color: rgba(255, 255, 255, 0.96);
    background: linear-gradient(180deg, #ff8a00 0%, #ff6b00 55%, #ff4d00 100%);
    box-shadow: 0 16px 36px rgba(255, 106, 0, 0.18);
    transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 180ms ease, filter 180ms ease;
    position: relative;
    overflow: hidden;
}

.welcome-action-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 52px rgba(255, 106, 0, 0.22);
    filter: saturate(1.02);
}

.welcome-action-icon {
    width: 42px;
    height: 42px;
    border-radius: 9999px;
    display: grid;
    place-items: center;
    position: relative;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.96);
}

.welcome-action-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 9999px;
    background: #ffffff;
    transform: scale(0);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.welcome-action-icon svg {
    position: relative;
    z-index: 1;
}

.welcome-action-card:hover .welcome-action-icon::before {
    transform: scale(1);
}

.welcome-action-card:hover .welcome-action-icon {
    color: #111111;
}

.welcome-action-title {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 4px;
}

.welcome-action-desc {
    font-size: 12px;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.88);
}

@media (max-width: 640px) {
    .welcome-actions {
        grid-template-columns: 1fr;
        max-width: 460px;
    }
}

/* Embedded apps modal (Gaming / Office) */
.embedded-app-card {
    width: 90vw;
    height: 90vh;
    max-width: none;
    max-height: none;
    border-radius: 28px;
    overflow: hidden;
}

.embedded-app-header {
    background: linear-gradient(180deg, #ff8a00 0%, #ff6b00 55%, #ff4d00 100%);
    border-bottom: none;
}

.embedded-app-header h2 {
    color: #ffffff;
}

.embedded-app-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.embedded-app-open {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: none;
    font-weight: 800;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.22);
    transition: background var(--transition-base), transform var(--transition-base);
}

.embedded-app-open:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: translateY(-1px);
}

.embedded-app-header .modal-close {
    color: rgba(255, 255, 255, 0.95);
}

.embedded-app-header .modal-close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.embedded-app-body {
    padding: 0;
    position: relative;
}

#embeddedAppFrame {
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--bg-primary);
}

.embedded-app-fallback {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 24px;
    background: var(--bg-primary);
}

.embedded-app-fallback-title {
    font-size: 16px;
    font-weight: 900;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.embedded-app-fallback-desc {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 520px;
}

/* Simpler UI Mode */
body.ui-simple #thinkDeeperToggle,
body.ui-simple #historyBtn,
body.ui-simple #customizeBtn,
body.ui-simple #helpBtn,
body.ui-simple #upgradeBtn,
body.ui-simple #modelSelector {
    display: none !important;
}

body.ui-simple .sidebar-footer {
    padding: 8px 12px;
}

body.ui-simple .settings-section {
    margin-bottom: 20px;
}

body.ui-simple .gem-actions {
    display: none !important;
}

body.ui-simple.sidebar {
    padding: 8px 12px;
}

/* Stable Mode */
body.stable-mode .poseidon-launch-btn {
    display: none !important;
}

body.stable-mode #thinkDeeperToggle {
    display: none !important;
}

/* Additional Gradients for Light Mode */
.send-btn {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #ec4899 100%);
    color: white;
}

[data-theme="dark"] .send-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #000000;
}

.send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #f472b6 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

[data-theme="dark"] .send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 100%);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.3);
}

/* More Light Mode Gradients */
.sidebar-icon-btn.primary {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}

.model-selector {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
    border: 1px solid rgba(79, 70, 229, 0.2);
}

.model-selector:hover {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.15) 0%, rgba(124, 58, 237, 0.15) 100%);
}

.input-icon-btn:hover {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.1) 0%, rgba(124, 58, 237, 0.1) 100%);
}

.chat-item.active {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08) 0%, rgba(124, 58, 237, 0.08) 100%);
}

.gem-item-wrapper.active {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.08) 0%, rgba(124, 58, 237, 0.08) 100%);
}

.upgrade-btn {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    color: #1a1a1a;
    border: 1px solid #e5e5e5;
}

[data-theme="dark"] .upgrade-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #000000;
    border: none;
}

.upgrade-btn:hover {
    background: linear-gradient(135deg, #f0f0f0 0%, #e5e5e5 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .upgrade-btn:hover {
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 100%);
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

.welcome-pills {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 16px 0 12px;
    flex-wrap: wrap;
}

.pill {
    padding: 10px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.01em;
    border: 1px solid rgba(0, 0, 0, 0.05);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10);
    backdrop-filter: blur(8px);
    text-align: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pill.success {
    background: linear-gradient(135deg, #22c55e, #34d399);
    color: #0b3b23;
}

.pill.neutral {
    background: linear-gradient(135deg, #5b6cff, #7c8bff);
    color: #f8fafc;
}

.pill.ghost {
    background: transparent;
    border-style: dashed;
}

.pill.gold {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #3d2500;
    border: 1px solid rgba(124, 90, 0, 0.3);
    box-shadow: 0 10px 26px rgba(249, 191, 36, 0.2);
}

.welcome-quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 880px;
    margin: 12px auto 6px;
}

.quick-prompt-btn {
    padding: 12px 16px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.94));
    color: var(--text-primary);
    font-weight: 600;
    text-align: left;
    display: inline-flex;
    gap: 10px;
    align-items: center;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border var(--transition-fast), background var(--transition-fast);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
    backdrop-filter: blur(8px);
}

.quick-prompt-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
    border-color: var(--border-hover);
    background: linear-gradient(135deg, rgba(255, 255, 255, 1), rgba(245, 247, 255, 0.98));
}

.quick-prompt-btn.quick-prompt-wide {
    grid-column: 1 / span 2;
    min-height: 54px;
    font-size: 15px;
}

.office-btn {
    background: linear-gradient(135deg, rgba(255, 198, 109, 0.26), rgba(255, 170, 92, 0.3));
    border-color: rgba(255, 170, 92, 0.5);
    font-weight: 700;
    color: #6a3900;
}

.quick-prompt-btn i,
.pill i {
    font-size: 14px;
}

/* Dark theme refinements for hero */
[data-theme="dark"] .welcome-screen {
    background: transparent;
    border: none;
    box-shadow: none;
}


[data-theme="dark"] .welcome-subtitle {
    color: #c9d2e4;
}

[data-theme="dark"] .pill {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
    color: #e5e7f2;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.38);
}

[data-theme="dark"] .pill.success {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #e0ffe8;
}

[data-theme="dark"] .pill.neutral {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #eef2ff;
}

[data-theme="dark"] .pill.gold {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff7ea;
    border-color: rgba(249, 191, 36, 0.4);
}

[data-theme="dark"] .quick-prompt-btn {
    border-color: rgba(255, 255, 255, 0.05);
    background: linear-gradient(135deg, rgba(18, 24, 39, 0.94), rgba(24, 30, 48, 0.94));
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    color: #e5e7eb;
}

[data-theme="dark"] .quick-prompt-btn:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: linear-gradient(135deg, rgba(34, 43, 70, 0.98), rgba(40, 52, 82, 0.98));
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .office-btn {
    background: linear-gradient(135deg, rgba(249, 188, 58, 0.18), rgba(255, 158, 70, 0.2));
    border-color: rgba(255, 158, 70, 0.45);
    color: #ffe4b8;
}

/* Dark theme for compact main chat area */
[data-theme="dark"] .message-content {
    background: var(--bg-secondary);
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .message.user .message-content {
    background: rgba(138, 168, 255, 0.12);
    border-color: rgba(138, 168, 255, 0.22);
}

.welcome-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

.welcome-card {
    padding: 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    text-align: left;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), border var(--transition-fast);
}

.welcome-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

.welcome-card .card-title {
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.messages-container {
    width: 100%;
    max-width: var(--stage-max-width);
    margin: 0 auto;
    padding: 12px 14px 80px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    animation: fadeIn 0.4s ease;
}

.message-avatar {
    display: none;
}

.message.user {
    justify-content: flex-end;
}

.message-content {
    flex: 1;
    padding: 10px 12px;
    line-height: 1.55;
    font-size: 14px;
    font-weight: 400;
    font-family: var(--font-chat);
    word-wrap: break-word;
    color: var(--text-primary);
    max-width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--bg-secondary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', sans-serif;
}

.message.user .message-content {
    max-width: 82%;
    border-left: 3px solid var(--tone-accent);
    background: var(--bg-secondary);
}

.message.ai .message-content {
    max-width: 82%;
    border-left: 3px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Reduce markdown “clutter” inside messages */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 0 0 8px 0;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.message-content h1 { font-size: 18px; font-weight: 700; }
.message-content h2 { font-size: 16px; font-weight: 700; }
.message-content h3 { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.message-content strong {
    background: transparent;
    padding: 0;
    border-radius: 0;
}

.message-content .code-block,
.message-content pre.code-block {
    border-radius: 10px;
    box-shadow: none;
}

.message-content .inline-code,
.message-content code.inline-code {
    border-radius: 6px;
}

/* Gems sidebar */
.new-gem-btn {
    justify-content: center;
    width: calc(100% - 32px);
    margin: 8px 16px 12px;
    display: flex;
    align-items: center;
}

/* Tone options UI (Settings + Gem editor) */
.tone-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

/* Try-a-Gem cards */
.gems-try-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.gem-try-card {
    text-align: left;
    padding: 14px 14px 12px;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: border-color 150ms ease, transform 150ms ease;
}

.gem-try-card:hover {
    transform: translateY(-1px);
    border-color: var(--border-hover);
}

.gem-try-name {
    font-weight: 700;
    margin-bottom: 6px;
}

.gem-try-desc {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.gem-try-meta {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.gem-tone-badge,
.gem-sources-badge {
    font-size: 11px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.gem-try-card.tone-friendly { border-left: 3px solid #16a34a; }
.gem-try-card.tone-calm { border-left: 3px solid #2563eb; }
.gem-try-card.tone-formal { border-left: 3px solid #7c3aed; }
.gem-try-card.tone-critical { border-left: 3px solid #dc2626; }
.gem-try-card.tone-normal { border-left: 3px solid #1a1a1a; }

.tone-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    background: var(--bg-secondary);
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tone-option input {
    accent-color: var(--tone-accent);
}

.tone-normal { border-left: 3px solid #1a1a1a; }
.tone-friendly { border-left: 3px solid #16a34a; }
.tone-calm { border-left: 3px solid #2563eb; }
.tone-formal { border-left: 3px solid #7c3aed; }
.tone-critical { border-left: 3px solid #dc2626; }

[data-theme="dark"] .tone-option {
    background: var(--bg-secondary);
}

.message-content p {
    margin: 0 0 10px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content pre {
    background: var(--bg-elevated);
    padding: 16px;
    border-radius: var(--radius-lg);
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid var(--border-color);
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
}

.message-content code {
    background: var(--bg-elevated);
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    border: 1px solid var(--border-color);
    color: var(--accent-primary);
}

.message-content pre code {
    background: transparent;
    padding: 0;
    border: none;
    color: var(--text-primary);
}

/* User bubbles only */
.message.user .message-content {
    background: linear-gradient(135deg, rgba(90, 93, 240, 0.08), rgba(139, 92, 246, 0.06));
    border: 1px solid var(--border-color);
    padding: 14px 16px;
    border-radius: 20px;
    box-shadow: 10px 10px 24px rgba(15, 23, 42, 0.08), -8px -8px 18px rgba(255, 255, 255, 0.55);
}

.message.user .message-content p:last-child {
    margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 20px 0 12px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.message-content h1 {
    font-size: 24px;
}

.message-content h2 {
    font-size: 20px;
}

.message-content h3 {
    font-size: 18px;
}

.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.7;
}

.message-content .markdown-media {
    margin: 16px 0;
}

.message-content img.markdown-img {
    max-width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    display: block;
}

.message-content blockquote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content a {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all var(--transition-base);
}

.message-content a:hover {
    border-bottom-color: var(--accent-primary);
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.message-content table th,
.message-content table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.message-content table th {
    background: var(--bg-elevated);
    font-weight: 600;
    color: var(--text-primary);
}

.message-content table tr:last-child td {
    border-bottom: none;
}

/* ============================================
   RICH MARKDOWN FORMATTING STYLES
   ============================================ */

/* Enhanced Headers */
.message-content .markdown-h1,
.message-content .md-h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 24px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-primary);
    letter-spacing: -0.5px;
}

.message-content .markdown-h2,
.message-content .md-h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 20px 0 12px 0;
    letter-spacing: -0.3px;
}

.message-content .markdown-h3,
.message-content .md-h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 16px 0 10px 0;
}

/* First header in a response - no top margin */
.message-content > .markdown-h1:first-child,
.message-content > .markdown-h2:first-child,
.message-content > .markdown-h3:first-child,
.message-content > .md-h1:first-child,
.message-content > .md-h2:first-child,
.message-content > .md-h3:first-child {
    margin-top: 0;
}

/* Enhanced Bold and Emphasis */
.message-content strong {
    font-weight: 700;
    color: var(--text-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    padding: 1px 4px;
    border-radius: 3px;
}

.message-content em {
    font-style: italic;
    color: var(--text-secondary);
}

/* Enhanced Paragraphs */
.message-content .markdown-p,
.message-content .md-p {
    margin: 12px 0;
    line-height: 1.8;
}

.message-content .markdown-p:first-child,
.message-content .md-p:first-child {
    margin-top: 0;
}

.message-content .markdown-p:last-child,
.message-content .md-p:last-child {
    margin-bottom: 0;
}

/* Enhanced Lists */
.message-content .markdown-ul,
.message-content .markdown-ol {
    margin: 16px 0;
    padding-left: 24px;
}

.message-content .markdown-li {
    margin: 8px 0;
    padding-left: 8px;
    line-height: 1.7;
    position: relative;
}

.message-content .markdown-ul .markdown-li::marker {
    color: var(--accent-primary);
    font-weight: bold;
}

.message-content .markdown-ol {
    counter-reset: item;
}

.message-content .markdown-ol .markdown-li {
    counter-increment: item;
}

/* Enhanced Code Blocks */
.message-content .code-block,
.message-content pre.code-block {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin: 16px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    box-shadow: var(--shadow-sm);
}

.message-content .code-block code,
.message-content pre.code-block code {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text-primary);
    font-family: inherit;
}

/* Inline Code */
.message-content .inline-code,
.message-content code.inline-code {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Menlo', 'Fira Code', 'Consolas', monospace;
    border: 1px solid var(--border-color);
}

/* Enhanced Images */
.message-content .markdown-media,
.message-content .md-image {
    margin: 20px 0;
    text-align: center;
}

.message-content .markdown-img,
.message-content .md-image img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.message-content .markdown-img:hover,
.message-content .md-image img:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-xl);
}

.message-content .trainx-frame {
    width: 100%;
    height: 380px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

/* Enhanced Blockquotes */
.message-content blockquote {
    border-left: 4px solid var(--accent-primary);
    margin: 16px 0;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.message-content blockquote p {
    margin: 0;
}

/* Enhanced Links */
.message-content a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: all var(--transition-fast);
}

.message-content a:hover {
    color: var(--accent-primary-hover);
    border-bottom-color: var(--accent-primary);
}

/* Horizontal Rule */
.message-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: 24px 0;
}

/* Key-Value styling (Definition lists) */
.message-content .key-value {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}

.message-content .key-value .key {
    font-weight: 600;
    color: var(--text-primary);
    min-width: 120px;
}

.message-content .key-value .value {
    color: var(--text-secondary);
}

/* Info/Note/Warning boxes */
.message-content .info-box {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    margin: 16px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.message-content .info-box.info {
    background: rgba(99, 102, 241, 0.1);
    border-left: 4px solid var(--accent-primary);
}

.message-content .info-box.warning {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--accent-warning);
}

.message-content .info-box.success {
    background: rgba(16, 185, 129, 0.1);
    border-left: 4px solid var(--accent-success);
}

.message-content .info-box.error {
    background: rgba(239, 68, 68, 0.1);
    border-left: 4px solid var(--accent-danger);
}

/* ============================================
   INPUT CONTAINER
   ============================================ */

.input-container {
    padding: 14px 12px 16px;
    border-top: none;
    background: transparent;
    position: relative;
    z-index: 10;
    box-shadow: none;
}

.input-wrapper {
    max-width: var(--stage-max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(180deg, #ff8a00 0%, #ff6b00 55%, #ff4d00 100%);
    border: none;
    border-radius: 26px;
    padding: 10px 14px;
    transition: all var(--transition-base);
    box-shadow: 0 18px 46px rgba(255, 106, 0, 0.22);
    position: relative;
}

.input-wrapper:focus-within {
    box-shadow: 0 18px 46px rgba(255, 106, 0, 0.35);
    transform: translateY(-1px);
}

.input-left-actions,
.input-right-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.input-icon-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.9);
    transition: all var(--transition-base);
    position: relative;
}

.input-icon-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 0;
}

.input-icon-btn svg {
    position: relative;
    z-index: 1;
}

.input-icon-btn:hover {
    color: #ffffff;
}

.input-icon-btn:hover::before {
    transform: translate(-50%, -50%) scale(1);
}

/* Input button tooltips (matching sidebar style) */
.input-btn-with-tooltip {
    position: relative;
}

.input-tooltip {
    position: absolute;
    bottom: calc(100% + 14px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.92);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    transition: opacity 160ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 1000;
}

.input-btn-with-tooltip:hover .input-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

.poseidon-launch-btn.input-btn-with-tooltip {
    position: relative;
}

.send-btn.input-btn-with-tooltip {
    position: relative;
}

.model-selector.input-btn-with-tooltip {
    position: relative;
}

.input-icon-btn.active {
    background: var(--accent-primary);
    color: white;
}

.input-icon-btn svg {
    width: 18px;
    height: 18px;
}

.tools-btn {
    padding: 6px 10px;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    background: transparent;
    gap: 2px;
}

.tools-btn:hover {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

.tools-btn .tools-icon {
    width: 14px;
    height: 14px;
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    font-family: var(--font-chat);
    color: #ffffff;
    padding: 8px 0;
    min-height: 20px;
    max-height: 200px;
    line-height: 1.5;
    outline: none;
    font-weight: 400;
}

.message-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.model-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: 36px;
}

.model-selector:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.model-name {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
}

.model-selector svg {
    width: 12px;
    height: 12px;
}

.model-dropdown {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 8px;
    min-width: 180px;
    display: none;
    z-index: 1000;
    border: 1px solid var(--border-color);
    animation: scaleIn 0.2s ease;
}

.model-dropdown.open {
    display: block;
}

.model-option {
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-base);
}

.model-option:hover {
    background: var(--bg-hover);
}

.model-option.active {
    background: var(--bg-hover);
}

.model-option-name {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 400;
}

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

.model-option-note {
    font-size: 11px;
    color: var(--text-tertiary);
}

.model-option-note.locked {
    color: var(--accent-danger);
    font-weight: 500;
}

.model-option-status {
    font-size: 12px;
    color: var(--text-tertiary);
}

.model-option.unavailable {
    opacity: 0.5;
    cursor: not-allowed;
}

.model-option-setting.unavailable input[type="radio"] {
    cursor: not-allowed;
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-base);
    flex-shrink: 0;
    box-shadow: none;
    position: relative;
}

.send-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 0;
}

.send-btn svg {
    position: relative;
    z-index: 1;
}

.send-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

.send-btn:hover:not(:disabled)::before {
    transform: translate(-50%, -50%) scale(1);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.input-disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 12px;
    font-weight: 400;
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
    padding: 24px;
}

.glass-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-2xl);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    animation: scaleIn 0.3s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.settings-section {
    margin-bottom: 32px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.theme-options,
.model-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Customize / Gems modal */
.gems-try-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.gem-try-card {
    padding: 14px;
    border-radius: var(--radius-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: left;
}

.gem-try-card:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.gem-try-name {
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.gem-try-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.gems-manage-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.theme-option,
.model-option-setting {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all var(--transition-base);
}

.theme-option:hover,
.model-option-setting:hover:not(.unavailable) {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.theme-option input[type="radio"],
.model-option-setting input[type="radio"] {
    margin-right: 12px;
    cursor: pointer;
}

.theme-option span,
.model-option-setting span:not(.status-badge) {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
}

.status-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--accent-success);
    color: white;
    font-weight: 500;
}

.status-badge.locked {
    background: var(--bg-hover);
    color: var(--text-tertiary);
}

.model-option-setting.unavailable {
    opacity: 0.6;
    cursor: not-allowed;
}

.plan-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.plan-card {
    padding: 24px;
    border-radius: var(--radius-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
    animation: fadeIn 0.4s ease backwards;
}

.plan-card.active {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.plan-card.unavailable {
    opacity: 0.6;
}

.plan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.plan-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.plan-badge-current {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--accent-success);
    color: white;
    font-weight: 500;
}

.plan-badge-locked {
    font-size: 16px;
}

.plan-badge-coming {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: var(--accent-warning);
    color: white;
    font-weight: 500;
}

.plan-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.plan-period {
    font-size: 16px;
    color: var(--text-tertiary);
    font-weight: 400;
}

.plan-features {
    list-style: none;
    margin-bottom: 20px;
}

.plan-features li {
    padding: 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

.plan-note {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.upgrade-plan-btn {
    width: 100%;
    padding: 12px 24px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.upgrade-plan-btn:hover:not(:disabled) {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.upgrade-plan-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#proUnlockOverlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 39, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
    z-index: 9999;
}

#proUnlockOverlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.pro-unlock-card {
    width: 260px;
    height: 260px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.24), rgba(255, 255, 255, 0.28));
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 20px 20px 60px rgba(0, 0, 0, 0.25), -12px -12px 36px rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(16px);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: translateY(18px) scale(0.96);
    transition: transform 300ms ease, box-shadow 300ms ease;
}

#proUnlockOverlay.visible .pro-unlock-card {
    transform: translateY(0) scale(1);
    box-shadow: 24px 24px 68px rgba(0, 0, 0, 0.3), -14px -14px 40px rgba(255, 255, 255, 0.45);
}

.pro-unlock-orb {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.85), rgba(124, 90, 240, 0.8), rgba(90, 93, 240, 0.45));
    box-shadow: inset 12px 12px 26px rgba(255, 255, 255, 0.25), 0 16px 40px rgba(90, 93, 240, 0.35);
    animation: proOrbSpin 2.6s ease-in-out infinite;
}

.pro-unlock-text {
    margin-top: 18px;
    font-size: 18px;
    font-weight: 800;
    color: #fefefe;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

@keyframes proOrbSpin {
    0% { transform: rotateX(0deg) rotateY(0deg) scale(1); }
    50% { transform: rotateX(14deg) rotateY(18deg) scale(1.05); }
    100% { transform: rotateX(0deg) rotateY(0deg) scale(1); }
}

body.pro-unlocked .pill.gold {
    background: linear-gradient(135deg, rgba(255, 215, 128, 0.95), rgba(248, 193, 79, 0.92));
    color: #4b3300;
    box-shadow: 14px 14px 32px rgba(248, 193, 79, 0.3), -10px -10px 26px rgba(255, 255, 255, 0.5);
    border-color: rgba(124, 90, 0, 0.4);
}

body.pro-unlocked .user-avatar,
body.pro-unlocked .message.ai .message-avatar {
    box-shadow: 0 0 0 3px rgba(248, 193, 79, 0.28);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-secondary);
    transition: all var(--transition-base);
}

.form-group select.form-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-ui);
    transition: all var(--transition-base);
    cursor: pointer;
}

.form-group select.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.1);
}

[data-theme="dark"] .form-group select.form-select:focus {
    box-shadow: 0 0 0 3px rgba(245, 245, 245, 0.1);
}

.input-icon-btn.active.poseidon-listening {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    animation: pulse 1.5s ease-in-out infinite;
}

[data-theme="dark"] .input-icon-btn.active.poseidon-listening {
    background: rgba(248, 113, 113, 0.15);
    color: #f87171;
}

.input-icon-btn.active.poseidon-speaking {
    background: rgba(37, 99, 235, 0.1);
    color: #2563eb;
}

[data-theme="dark"] .input-icon-btn.active.poseidon-speaking {
    background: rgba(96, 165, 250, 0.15);
    color: #60a5fa;
}

.poseidon-launch-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #ffffff;
    transition: all var(--transition-base);
    box-shadow: none;
    flex-shrink: 0;
    outline: none;
}

.poseidon-launch-btn:focus,
.poseidon-launch-btn:focus-visible {
    outline: none;
    box-shadow: none;
}

.poseidon-launch-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.poseidon-launch-btn:active {
    transform: translateY(0) scale(0.98);
}

.poseidon-launch-btn svg {
    width: 20px;
    height: 20px;
}

/* Poseidon Overlay */
.poseidon-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.poseidon-container {
    width: 90%;
    max-width: 500px;
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    animation: scaleIn 0.3s ease;
}

.poseidon-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    color: white;
}

.poseidon-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.poseidon-status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #22c55e;
    animation: pulse 2s ease-in-out infinite;
}

.poseidon-status-indicator.listening {
    background: #ef4444;
    animation: pulse 1s ease-in-out infinite;
}

.poseidon-status-indicator.speaking {
    background: #3b82f6;
    animation: pulse 1.5s ease-in-out infinite;
}

.poseidon-status-text {
    font-weight: 600;
    font-size: 16px;
}

.poseidon-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.poseidon-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.poseidon-content {
    padding: 32px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    min-height: 300px;
    background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-secondary) 100%);
}

.poseidon-visualizer {
    width: 100%;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.poseidon-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
}

.wave-bar {
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, #2563eb 0%, #60a5fa 100%);
    border-radius: 2px;
    animation: wave 1.2s ease-in-out infinite;
}

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

.poseidon-visualizer.listening .wave-bar {
    background: linear-gradient(180deg, #ef4444 0%, #f87171 100%);
    animation-duration: 0.8s;
}

.poseidon-visualizer.speaking .wave-bar {
    background: linear-gradient(180deg, #3b82f6 0%, #60a5fa 100%);
    animation-duration: 1s;
}

@keyframes wave {
    0%, 100% {
        height: 20px;
        opacity: 0.5;
    }
    50% {
        height: 60px;
        opacity: 1;
    }
}

.poseidon-transcript {
    width: 100%;
    max-height: 200px;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    font-size: 14px;
}

.transcript-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.transcript-text {
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 20px;
}

.poseidon-controls {
    padding: 20px 24px;
    display: flex;
    gap: 12px;
    justify-content: center;
    border-top: 1px solid var(--border-color);
    background: var(--bg-elevated);
}

.poseidon-control-btn {
    flex: 1;
    max-width: 150px;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-base);
}

.poseidon-control-btn.hold-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.poseidon-control-btn.hold-btn:hover {
    background: var(--bg-hover);
}

.poseidon-control-btn.end-btn {
    background: #dc2626;
    color: white;
}

.poseidon-control-btn.end-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.poseidon-control-btn svg {
    width: 20px;
    height: 20px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-base);
    animation: fadeIn 0.3s ease backwards;
}

.history-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateX(4px);
}

.history-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.history-item-description {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ============================================
   LOADING STATES
   ============================================ */

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

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

@media (max-width: 768px) {
    /* Sidebar becomes horizontal bottom nav on mobile */
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        z-index: 200;
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-rail {
        flex-direction: row;
        justify-content: space-around;
        padding: 8px 12px;
        height: auto;
    }

    .nav-rail-spacer {
        display: none;
    }

    .nav-rail-btn {
        width: 48px;
        height: 48px;
    }

    .nav-rail-tooltip {
        bottom: calc(100% + 10px);
        left: 50%;
        top: auto;
        transform: translateX(-50%) translateY(-6px) scale(0.98);
    }

    .nav-rail-btn:hover .nav-rail-tooltip {
        transform: translateX(-50%) translateY(0) scale(1);
    }

    .main-content {
        margin-left: 0;
        padding-bottom: 80px; /* Space for bottom nav */
    }

    .content-header {
        padding: 12px 16px;
        margin: 0;
        border-radius: 0;
    }

    .welcome-title {
        font-size: 32px;
    }

    .welcome-screen {
        padding: 24px 16px;
    }

    .welcome-actions {
        grid-template-columns: 1fr;
        gap: 16px;
        max-width: 100%;
    }

    .welcome-action-card {
        padding: 20px;
    }

    .messages-container {
        padding: 24px 16px 120px;
    }

    .input-container {
        padding: 12px 16px 16px;
    }

    .input-wrapper {
        padding: 10px 12px;
    }

    .input-icon-btn,
    .poseidon-launch-btn {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .input-tooltip {
        bottom: calc(100% + 10px);
        font-size: 12px;
        padding: 8px 12px;
    }

    .plan-options {
        grid-template-columns: 1fr;
    }

    /* Embedded app modal fullscreen on mobile */
    .embedded-app-card {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    /* Modal dashboard adjustments */
    .modal.modal-dashboard {
        padding: 0;
    }

    .modal.modal-dashboard .glass-card {
        border-radius: 0;
    }

    /* Chat list grid on mobile */
    #recentChatsModal #chatsList {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .welcome-title {
        font-size: 28px;
    }

    .welcome-hero {
        font-size: 16px;
    }

    .welcome-action-card {
        padding: 16px;
    }

    .welcome-action-card-icon {
        width: 40px;
        height: 40px;
    }

    .content-header {
        padding: 10px 12px;
    }

    .header-icon-btn,
    .theme-toggle-btn,
    .upgrade-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .input-wrapper {
        padding: 8px 10px;
    }

    .input-icon-btn,
    .poseidon-launch-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .model-selector {
        padding: 6px 10px;
        font-size: 12px;
    }

    .nav-rail-btn {
        width: 44px;
        height: 44px;
    }
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden {
    display: none !important;
}

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

.slide-in {
    animation: slideIn 0.3s ease;
}

/* ============================================
   ENHANCED FEATURES v1.4.2
   ============================================ */

/* Keyboard Shortcuts Help */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 0;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: background var(--transition-base);
}

.shortcut-item:hover {
    background: var(--bg-hover);
}

.shortcut-keys {
    display: flex;
    gap: 4px;
    align-items: center;
}

.shortcut-keys kbd {
    padding: 4px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.shortcut-action {
    font-weight: 500;
    color: var(--text-secondary);
}

/* Advanced Search */

/* Smart Suggestions */
.smart-suggestions {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition-base);
    color: var(--text-primary);
    font-size: 14px;
}

.suggestion-item:hover,
.suggestion-item.active {
    background: var(--bg-hover);
}

.suggestion-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.suggestion-item:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Notifications */
.notifications-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.notification {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 300px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-info {
    border-left: 3px solid var(--accent-primary);
}

.notification-success {
    border-left: 3px solid #16a34a;
}

.notification-error {
    border-left: 3px solid #dc2626;
}

.notification-warning {
    border-left: 3px solid #f59e0b;
}

.notification-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.notification-message {
    flex: 1;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

.notification-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text-tertiary);
    transition: color var(--transition-base);
    flex-shrink: 0;
}

.notification-close:hover {
    color: var(--text-primary);
}

/* Quick Actions Menu */
.quick-actions-menu {
    position: absolute;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 8px;
    z-index: 1000;
    min-width: 200px;
    animation: fadeIn 0.2s ease;
}

.quick-action-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-primary);
    font-size: 14px;
    transition: background var(--transition-base);
    text-align: left;
}

.quick-action-item:hover {
    background: var(--bg-hover);
}

.quick-action-item svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

/* Enhanced Input Area */
.input-wrapper {
    position: relative;
}

.quick-actions-btn {
    /* Already styled as input-icon-btn */
}

/* Export/Import Styles */
.export-import-section {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    margin-top: 16px;
}

.export-import-buttons {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.export-btn,
.import-btn {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-base);
}

.export-btn:hover,
.import-btn:hover {
    background: var(--bg-hover);
    border-color: var(--tone-accent);
}

/* Analytics Dashboard */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.analytics-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    text-align: center;
}

.analytics-card-title {
    font-size: 12px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.analytics-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--tone-accent);
}

.analytics-chart {
    margin-top: 24px;
}

.analytics-chart h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.chart-container {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.chart-bars {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    height: 200px;
    padding: 20px 0;
}

.chart-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.chart-bar {
    width: 100%;
    background: linear-gradient(to top, var(--tone-accent), var(--accent-primary));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    position: relative;
    min-height: 20px;
    transition: all var(--transition-base);
    cursor: pointer;
}

.chart-bar:hover {
    opacity: 0.8;
    transform: scaleY(1.05);
}

.chart-bar-value {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.chart-bar-label {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    transform: rotate(-45deg);
    transform-origin: center;
    white-space: nowrap;
}

.text-muted {
    color: var(--text-tertiary);
    text-align: center;
    padding: 40px;
}

/* Responsive Enhancements */
@media (max-width: 768px) {
    .notifications-container {
        right: 12px;
        left: 12px;
        max-width: none;
    }
    
    .notification {
        min-width: auto;
    }
    
    .quick-actions-menu {
        right: 12px;
        left: 12px;
        min-width: auto;
    }
    
    .smart-suggestions {
        left: 12px;
        right: 12px;
    }
    
    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-bars {
        gap: 8px;
        height: 150px;
    }
    
    .chart-bar-label {
        font-size: 10px;
    }
}

/* ============================================
   BACKGROUND CUSTOMIZATION v1.4.3
   ============================================ */

.background-presets {
    margin-top: 12px;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    width: 100%;
}

.background-preset-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
    width: 100%;
    visibility: visible !important;
    opacity: 1 !important;
}

.background-preset {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-tertiary);
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.background-preset:hover {
    border-color: var(--tone-accent);
    transform: translateY(-2px);
}

.background-preset.active {
    border-color: var(--tone-accent);
    background: var(--bg-hover);
    box-shadow: 0 0 0 2px var(--tone-accent);
}

.background-preview {
    width: 100%;
    height: 60px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
}

.background-preview.pattern-dots {
    background-image: radial-gradient(circle, var(--text-tertiary) 1px, transparent 1px);
    background-size: 12px 12px;
    background-color: var(--bg-secondary);
}

.background-preview.pattern-grid {
    background-image: 
        linear-gradient(var(--text-tertiary) 1px, transparent 1px),
        linear-gradient(90deg, var(--text-tertiary) 1px, transparent 1px);
    background-size: 12px 12px;
    background-color: var(--bg-secondary);
}

.background-preview.liquid-preview {
    background: linear-gradient(135deg, 
        rgba(102, 126, 234, 0.6) 0%, 
        rgba(118, 75, 162, 0.6) 25%,
        rgba(79, 172, 254, 0.6) 50%,
        rgba(67, 233, 123, 0.6) 75%,
        rgba(250, 112, 154, 0.6) 100%);
    background-size: 400% 400%;
    animation: liquidFlow 15s ease infinite;
    position: relative;
    overflow: hidden;
}

.background-preview.liquid-preview::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: liquidRotate 20s linear infinite;
}

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

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

.background-preset span {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.custom-background-preview {
    position: relative;
}

.background-preview-large {
    position: relative;
    width: 100%;
    height: 120px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.background-preview-large:hover {
    border-color: var(--tone-accent);
}

.custom-background-preview.active .background-preview-large {
    border-color: var(--tone-accent);
    box-shadow: 0 0 0 2px var(--tone-accent);
}

/* Full-page background support */
body.bg-custom {
    min-height: 100vh;
}

body.bg-custom::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image: var(--custom-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    opacity: var(--bg-opacity, 1);
    pointer-events: none;
}

.background-preview-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-custom-bg {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: var(--radius-full);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all var(--transition-base);
}

.remove-custom-bg:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Background Application Styles */
.main-content.bg-gradient-1 {
    background: linear-gradient(135deg, rgba(102, 126, 234, var(--bg-opacity, 1)) 0%, rgba(118, 75, 162, var(--bg-opacity, 1)) 100%);
}

.main-content.bg-gradient-2 {
    background: linear-gradient(135deg, rgba(240, 147, 251, var(--bg-opacity, 1)) 0%, rgba(245, 87, 108, var(--bg-opacity, 1)) 100%);
}

.main-content.bg-gradient-3 {
    background: linear-gradient(135deg, rgba(79, 172, 254, var(--bg-opacity, 1)) 0%, rgba(0, 242, 254, var(--bg-opacity, 1)) 100%);
}

.main-content.bg-gradient-4 {
    background: linear-gradient(135deg, rgba(67, 233, 123, var(--bg-opacity, 1)) 0%, rgba(56, 249, 215, var(--bg-opacity, 1)) 100%);
}

.main-content.bg-gradient-5 {
    background: linear-gradient(135deg, rgba(250, 112, 154, var(--bg-opacity, 1)) 0%, rgba(254, 225, 64, var(--bg-opacity, 1)) 100%);
}

.main-content.bg-pattern-1 {
    background-image: radial-gradient(circle, var(--text-tertiary) 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: var(--bg-primary);
    opacity: var(--bg-opacity, 1);
}

.main-content.bg-pattern-2 {
    background-image: 
        linear-gradient(var(--text-tertiary) 1px, transparent 1px),
        linear-gradient(90deg, var(--text-tertiary) 1px, transparent 1px);
    background-size: 20px 20px;
    background-color: var(--bg-primary);
    opacity: var(--bg-opacity, 1);
}

.main-content.bg-liquid {
    background: linear-gradient(135deg, 
        rgba(102, 126, 234, var(--bg-opacity, 0.6)) 0%, 
        rgba(118, 75, 162, var(--bg-opacity, 0.6)) 25%,
        rgba(79, 172, 254, var(--bg-opacity, 0.6)) 50%,
        rgba(67, 233, 123, var(--bg-opacity, 0.6)) 75%,
        rgba(250, 112, 154, var(--bg-opacity, 0.6)) 100%);
    background-size: 400% 400%;
    animation: liquidFlow 15s ease infinite;
    position: relative;
}

.main-content.bg-liquid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    animation: liquidRotate 20s linear infinite;
    pointer-events: none;
}

.main-content.bg-custom {
    background-image: var(--custom-bg-image, none);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    min-height: 100vh;
}

.main-content.bg-custom::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    opacity: calc(1 - var(--bg-opacity, 1));
    pointer-events: none;
}

.main-content.bg-default {
    background:
        radial-gradient(1200px 700px at 18% 0%, rgba(255, 138, 0, 0.10), transparent 60%),
        radial-gradient(900px 600px at 82% 28%, rgba(255, 77, 0, 0.07), transparent 55%),
        var(--bg-primary);
}

/* Ensure chat content is readable over backgrounds */
.main-content.bg-gradient-1 .message,
.main-content.bg-gradient-2 .message,
.main-content.bg-gradient-3 .message,
.main-content.bg-gradient-4 .message,
.main-content.bg-gradient-5 .message,
.main-content.bg-liquid .message,
.main-content.bg-custom .message {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .main-content.bg-gradient-1 .message,
[data-theme="dark"] .main-content.bg-gradient-2 .message,
[data-theme="dark"] .main-content.bg-gradient-3 .message,
[data-theme="dark"] .main-content.bg-gradient-4 .message,
[data-theme="dark"] .main-content.bg-gradient-5 .message,
[data-theme="dark"] .main-content.bg-liquid .message,
[data-theme="dark"] .main-content.bg-custom .message {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

/* Opacity slider styling */
#backgroundOpacity {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
}

#backgroundOpacity::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--tone-accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
}

#backgroundOpacity::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--tone-accent);
    cursor: pointer;
    border: 2px solid var(--bg-secondary);
}

/* ============================================
   MODERN NAV RAIL SIDEBAR (ORANGE / CURVED)
   ============================================ */

.sidebar {
    width: 92px;
    min-width: 92px;
    background: transparent;
    border-right: none;
    box-shadow: none;
    overflow: visible;
    padding: 14px 10px;
}

.nav-rail {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 18px 10px;
    border-radius: 40px;
    background: linear-gradient(180deg, #ff8a00 0%, #ff6b00 55%, #ff4d00 100%);
    box-shadow: 0 18px 46px rgba(255, 106, 0, 0.35);
    position: relative;
    overflow: visible;
}

.nav-rail-spacer {
    flex: 1;
}

.nav-rail-btn {
    width: 52px;
    height: 52px;
    border: none;
    background: transparent;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.94);
    position: relative;
    transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), color 180ms ease;
}

.nav-rail-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 52px;
    height: 52px;
    background: #ffffff;
    border-radius: 9999px;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    z-index: 0;
}

.nav-rail-btn svg {
    position: relative;
    z-index: 1;
}

.nav-rail-btn:hover {
    transform: translateY(-1px);
    color: #111111;
}

.nav-rail-btn:hover::before {
    transform: translate(-50%, -50%) scale(1);
}

.nav-rail-btn--primary {
    background: rgba(255, 255, 255, 0.12);
}

.nav-rail-btn--primary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.nav-rail-tooltip {
    position: absolute;
    left: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%) translateX(-6px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.92);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    transition: opacity 160ms ease, transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nav-rail-btn:hover .nav-rail-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0) scale(1);
}

/* ============================================
   DASHBOARD-STYLE FULLSCREEN MODALS
   ============================================ */

.modal.modal-dashboard {
    align-items: stretch;
    justify-content: stretch;
    padding: 18px;
}

.modal.modal-dashboard .glass-card {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 28px;
    animation: dashboardIn 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes dashboardIn {
    from {
        opacity: 0;
        transform: translateX(18px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Recent Chats “gallery” layout */
#recentChatsModal .modal-body {
    padding: 18px;
}

#recentChatsModal #chatsList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    padding: 0;
}

#recentChatsModal .chat-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    padding: 14px;
}

#recentChatsModal .chat-item:hover {
    background: var(--bg-hover);
    transform: translateY(-1px);
}

#recentChatsModal .chat-item.active::before {
    display: none;
}

/* Remove History button and shift Think Deeper into its slot */
#thinkDeeperToggle {
    margin-left: 36px;
}
