/* ===== Root Variables ===== */
:root {
    /* Dark Theme Colors */
    --dark-bg-primary: #0a0a0f;
    --dark-bg-secondary: #13131a;
    --dark-bg-tertiary: #1a1a24;
    --dark-bg-card: #1f1f2c;
    --dark-bg-hover: #252534;
    --dark-text-primary: #ffffff;
    --dark-text-secondary: #a8a8b8;
    --dark-text-muted: #6b6b7c;
    --dark-border: #2a2a3c;
    --dark-border-light: #35354a;

    /* Light Theme Colors */
    --light-bg-primary: #ffffff;
    --light-bg-secondary: #f7f8fa;
    --light-bg-tertiary: #eef1f5;
    --light-bg-card: #ffffff;
    --light-bg-hover: #f0f2f5;
    --light-text-primary: #1a1a2e;
    --light-text-secondary: #5a5a6e;
    --light-text-muted: #8a8a9e;
    --light-border: #e1e4e8;
    --light-border-light: #d0d4da;

    /* Brand Colors */
    --accent-primary: #6366f1;
    --accent-secondary: #818cf8;
    --accent-hover: #4f46e5;
    --accent-light: rgba(99, 102, 241, 0.1);

    /* Model Colors */
    --chatgpt: #10a37f;
    --chatgpt-light: rgba(16, 163, 127, 0.1);
    --claude: #a855f7;
    --claude-light: rgba(168, 85, 247, 0.1);
    --gemini: #3b82f6;
    --gemini-light: rgba(59, 130, 246, 0.1);
    --grok: #06b6d4;
    --grok-light: rgba(6, 182, 212, 0.1);

    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Animations */
    --transition-fast: 150ms;
    --transition-normal: 250ms;
    --transition-slow: 350ms;

    /* Layout */
    --sidebar-width: 340px;
    --sidebar-mobile-width: 85vw;
    --header-height: 64px;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15);
}

/* ===== Dark Theme Variables (Default) ===== */
body, body[data-theme="dark"] {
    --bg-primary: var(--dark-bg-primary);
    --bg-secondary: var(--dark-bg-secondary);
    --bg-tertiary: var(--dark-bg-tertiary);
    --bg-card: var(--dark-bg-card);
    --bg-hover: var(--dark-bg-hover);
    --text-primary: var(--dark-text-primary);
    --text-secondary: var(--dark-text-secondary);
    --text-muted: var(--dark-text-muted);
    --border-color: var(--dark-border);
    --border-light: var(--dark-border-light);
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* ===== Light Theme Variables ===== */
body[data-theme="light"] {
    --bg-primary: var(--light-bg-primary);
    --bg-secondary: var(--light-bg-secondary);
    --bg-tertiary: var(--light-bg-tertiary);
    --bg-card: var(--light-bg-card);
    --bg-hover: var(--light-bg-hover);
    --text-primary: var(--light-text-primary);
    --text-secondary: var(--light-text-secondary);
    --text-muted: var(--light-text-muted);
    --border-color: var(--light-border);
    --border-light: var(--light-border-light);
    --shadow-color: rgba(0, 0, 0, 0.08);
}

/* Light theme specific adjustments */
body[data-theme="light"] .model-icon::before {
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

body[data-theme="light"] .consensus-card {
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
}

body[data-theme="light"] .model-response {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

body[data-theme="light"] .user-message {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.2);
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ===== Chat Container ===== */
.chat-container {
    display: flex;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    width: 100%;
    position: relative;
    overflow: hidden;
    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;
    transition: transform var(--transition-normal) cubic-bezier(0.4, 0, 0.2, 1);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 10;
    height: 100vh;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem 0.875rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform var(--transition-fast);
    width: 100%;
}

.app-logo:hover {
    transform: scale(1.02);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.mobile-menu-close {
    display: none;
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

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

/* Sidebar Scrollable Content */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.875rem 0.625rem 1.5rem 0.625rem;
}

.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Section Styles */
.sidebar-section {
    margin-bottom: 0.25rem;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.75rem;
}

.section-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    margin-top: 0.25rem;
    font-weight: 500;
}

/* Configuration Items */
.config-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    min-height: 56px;
}

.config-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-primary);
    transform: translateX(-3px);
    transition: transform var(--transition-fast);
}

.config-item:hover {
    background: var(--bg-hover);
    transform: translateX(2px);
}

.config-item.active {
    background: var(--bg-card);
    border-color: var(--accent-primary);
}

.config-item.active::before {
    transform: translateX(0);
}

.config-icon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    background: var(--accent-light);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 1.125rem;
    flex-shrink: 0;
}

.config-content {
    flex: 1;
    min-width: 0;
}

.config-content h5 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.config-models {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Model Items List */
.models-list {
    padding-bottom: 0.5rem;
}

/* Model Items */
.model-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.model-item:last-child {
    margin-bottom: 0.75rem;
}

.model-item:hover {
    background: var(--bg-hover);
    transform: translateX(2px);
}

.model-item.selected {
    background: var(--bg-card);
    border-color: var(--accent-primary);
}

.model-item.selected .model-checkbox {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.model-item.selected .model-checkbox::after {
    opacity: 1;
    transform: scale(1);
}

.model-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 6px;
    background: transparent;
    position: absolute;
    right: 1rem;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.model-checkbox::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
}

.model-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 8px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.model-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform var(--transition-fast);
}

.model-item:hover .model-icon {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.model-item:hover .model-icon img {
    transform: scale(1.1);
}

.model-item.selected .model-icon {
    background: var(--accent-light);
    border-color: var(--accent-primary);
}

.model-content {
    flex: 1;
    min-width: 0;
}

.model-content h5 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-info {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.model-price {
    color: var(--accent-primary);
    font-weight: 500;
}

/* ===== Main Chat Area ===== */
.chat-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
    min-width: 0; /* Prevent flex child from growing beyond parent */
}

/* Chat Header */
.chat-header {
    height: var(--header-height);
    padding: 0 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
    gap: 1rem;
}

.mobile-menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    font-size: 1.25rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    margin-right: auto; /* Push everything else to the right */
}

.mobile-menu-toggle:hover {
    background: var(--bg-hover);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.user-avatar:hover {
    transform: scale(1.05);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    padding-bottom: 140px; /* Space for fixed input container */
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
}

.empty-state-icon {
    width: 120px;
    height: 120px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.empty-state h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    max-width: 400px;
}

/* Response Tabs */
.response-tabs {
    padding: 1rem 2rem;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.response-tabs h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.tab-buttons {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: var(--border-radius-sm);
}

.tab-btn {
    padding: 0.5rem 1.25rem;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.tab-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 2px 4px var(--shadow-color);
}

/* Consensus Card */
.consensus-card {
    background: linear-gradient(135deg, var(--bg-card), var(--bg-tertiary));
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    padding-bottom: 2rem;
    position: relative;
    overflow: visible;
    min-height: 170px;
}

.consensus-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
}

.consensus-card::after {
    content: '';
    position: absolute;
    top: 10%;
    right: 5%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, var(--accent-primary), transparent);
    opacity: 0.03;
    border-radius: 50%;
    z-index: 0;
}

.consensus-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
    position: relative;
    z-index: 1;
}

.consensus-header i {
    font-size: 1.25rem;
    color: var(--accent-primary);
}

.consensus-header h4 {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
}

.consensus-text {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    text-align: left;
    position: relative;
    z-index: 1;
}

.consensus-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.consensus-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    padding: 0.3rem 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius-xl);
    font-size: 0.7rem;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    line-height: 1.2;
}

.tag.verified {
    background: var(--success);
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: var(--success);
}

.view-details {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: gap var(--transition-fast);
    white-space: nowrap;
}

.view-details:hover {
    gap: 0.625rem;
}

/* Model Response Cards */
.model-response {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1.25rem;
    padding-bottom: 1.5rem;
    transition: all var(--transition-fast);
    overflow: visible;
}

.model-response:hover {
    box-shadow: 0 4px 12px var(--shadow-color);
    transform: translateY(-1px);
}

.response-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.model-info {
    display: flex;
    align-items: center;
    gap: 0.875rem;
}

.model-avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    padding: 8px;
}

.model-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.model-info-text h5 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.response-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.response-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
}

.action-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
}

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

.action-btn.liked {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
}

.response-content {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
}

/* Formatted content styles for AI responses */
.response-content .formatted-content,
.response-content > div {
    word-wrap: break-word;
}

.response-content h1,
.response-content h2,
.response-content h3 {
    color: var(--text-primary);
    margin: 1rem 0 0.5rem;
    font-weight: 600;
}

.response-content h1 { font-size: 1.5rem; }
.response-content h2 { font-size: 1.3rem; }
.response-content h3 { font-size: 1.1rem; }

.response-content pre {
    background: var(--bg-darker, #1e1e1e);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1rem 0;
}

.response-content code {
    background: var(--bg-darker, #2d2d2d);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 0.9em;
}

.response-content pre code {
    background: transparent;
    padding: 0;
}

.response-content ul,
.response-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.response-content li {
    margin: 0.25rem 0;
}

.response-content a {
    color: var(--primary, #4299e1);
    text-decoration: none;
    transition: opacity 0.2s;
}

.response-content a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.response-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1rem 0;
    display: block;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.response-content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.response-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.response-content th,
.response-content td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
}

.response-content th {
    background: var(--bg-darker);
    font-weight: 600;
}

.response-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.source-count,
.verified {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.verified {
    color: var(--success);
}

.expand-btn {
    margin-left: auto;
    padding: 0.375rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

/* User Message */
.user-message {
    align-self: flex-end;
    max-width: 70%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    padding: 1rem 1.25rem;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 4px var(--border-radius-lg);
    box-shadow: 0 4px 12px var(--accent-light);
    animation: slideInRight var(--transition-normal) ease-out;
}

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

/* Chat Input Container */
.chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 1rem 1.5rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    z-index: 50;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.input-wrapper {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 1rem;
    transition: all var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-light);
}

.chat-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9375rem;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.5;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.875rem;
    justify-content: flex-end;
}

.enhance-prompt {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.enhance-prompt:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.cost-indicator {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border-radius: var(--border-radius-sm);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.send-button {
    padding: 0.625rem 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border: none;
    border-radius: var(--border-radius-sm);
    color: white;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px var(--accent-light);
}

.send-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--accent-light);
}

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

.selected-models {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-top: 0.875rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.model-badge {
    padding: 0.375rem 0.875rem;
    border-radius: var(--border-radius-xl);
    font-size: 0.8125rem;
    font-weight: 500;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    background: var(--accent-primary);
}

.model-badge:hover {
    transform: scale(1.05);
}

.model-badge.chatgpt {
    background: var(--chatgpt);
}

.model-badge.claude {
    background: var(--claude);
}

.model-badge.gemini {
    background: var(--gemini);
}

.model-badge.grok {
    background: var(--grok);
}

.model-badge.perplexity {
    background: #20808d;
}

.model-badge.mistral {
    background: #ff6b00;
}

.model-badge.cohere {
    background: #39a7a7;
}

.model-badge.deepseek {
    background: #5436da;
}

.model-badge.dalle {
    background: #ea4c89;
}

.model-badge.groq {
    background: #f55036;
}

.model-badge .remove-model {
    font-size: 0.875rem;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
    cursor: pointer;
}

.model-badge:hover .remove-model {
    opacity: 1;
}

.add-model-btn {
    padding: 0.375rem 0.875rem;
    background: transparent;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius-xl);
    color: var(--text-muted);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.add-model-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-light);
}

/* Loading States */
.loading-indicator {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.loading-dots {
    display: flex;
    gap: 0.5rem;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: pulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9998;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* ===== Responsive Design ===== */

/* Desktop styles */
@media (min-width: 769px) {
    .sidebar {
        position: fixed;
    }

    .chat-main {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }

    .chat-input-container {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        width: auto;
        padding: 1.5rem 2rem;
        padding-bottom: 1.5rem;
        border-radius: 0;
        margin: 0;
    }

    .chat-messages {
        padding-bottom: 2rem;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    :root {
        font-size: 15px;
    }

    .chat-container {
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .chat-main {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        margin-left: 0; /* Override desktop margin */
        width: 100%;
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: var(--sidebar-mobile-width);
        transform: translateX(-100%);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
        z-index: 9999;
        transition: transform var(--transition-normal);
    }

    .sidebar.active {
        transform: translateX(0);
        z-index: 9999;
    }

    .mobile-menu-toggle {
        display: flex;
        margin-right: auto; /* Ensures it stays on the left on mobile */
    }

    .mobile-menu-close {
        display: flex;
    }

    .chat-header {
        padding: 0 1rem;
        flex-shrink: 0;
    }

    .chat-messages {
        padding: 1rem;
        padding-bottom: 200px; /* Extra space for mobile fixed input */
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
    }

    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 0.75rem;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
        background: var(--bg-secondary);
        border-top: 1px solid var(--border-color);
        border-radius: 0;
        margin: 0;
        z-index: 100;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
    }

    .response-tabs {
        padding: 0.875rem 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.875rem;
    }

    .tab-buttons {
        width: 100%;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
        padding: 0.625rem 0.5rem;
        font-size: 0.8125rem;
    }

    .consensus-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        margin-bottom: 0.75rem;
    }

    .response-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.875rem;
    }

    .response-actions {
        align-self: flex-end;
    }

    .user-message {
        max-width: 85%;
    }

    .input-wrapper {
        padding: 0.625rem;
    }

    .chat-input {
        font-size: 0.9375rem;
        min-height: 48px;
        line-height: 1.6;
    }

    .input-actions {
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 0.5rem;
        margin-top: 0.625rem;
    }

    .enhance-prompt {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }

    .cost-indicator {
        padding: 0.4rem 0.75rem;
        font-size: 0.75rem;
    }

    .send-button {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .selected-models {
        margin-top: 0.625rem;
        font-size: 0.75rem;
        gap: 0.5rem;
    }

    .model-badge {
        padding: 0.25rem 0.625rem;
        font-size: 0.75rem;
    }

    .add-model-btn {
        padding: 0.25rem 0.625rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    :root {
        font-size: 14px;
    }

    .chat-input-container {
        padding: 0.625rem;
        padding-bottom: calc(0.625rem + env(safe-area-inset-bottom, 0px));
    }

    .chat-input {
        min-height: 56px;
        line-height: 1.7;
    }

    .consensus-card {
        padding: 0.875rem;
        padding-bottom: 1.25rem;
        min-height: auto;
    }

    .consensus-content {
        font-size: 0.875rem;
        line-height: 1.5;
        margin-bottom: 1rem;
    }

    .consensus-footer {
        gap: 0.75rem;
        margin-top: 0.5rem;
    }

    .sidebar {
        width: 100%;
    }

    .app-logo {
        width: 100%;
        justify-content: center;
        padding: 0 0.5rem;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .config-item,
    .model-item {
        padding: 0.75rem;
    }

    .model-response {
        padding: 1rem;
        padding-bottom: 1.25rem;
        overflow: visible;
    }

    .consensus-card {
        padding: 1rem;
        padding-bottom: 1.5rem;
        min-height: auto;
        overflow: visible;
    }

    .consensus-tags {
        width: 100%;
        justify-content: flex-start;
    }

    .tag {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }

    .empty-state-icon {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .empty-state h2 {
        font-size: 1.25rem;
    }

    .user-message {
        max-width: 90%;
    }
}

/* ===== Utility Classes ===== */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fade-in {
    animation: fadeIn var(--transition-normal) ease-in;
}

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

.slide-up {
    animation: slideUp var(--transition-normal) ease-out;
}

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

/* ===== Streaming Response Styles ===== */
.streaming-response {
    min-height: 100px;
    position: relative;
}

.streaming-placeholder {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    color: var(--text-secondary);
}

.stream-loading {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Focus mode streaming tabs */
.focus-mode-container[data-focus-stream="true"] .focus-tab {
    position: relative;
}

.focus-mode-container[data-focus-stream="true"] .focus-tab.processing::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -8px;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 1s ease-in-out infinite;
}

/* Compare mode streaming sections */
.compare-section.processing {
    border-left-color: var(--primary) !important;
    animation: borderPulse 1.5s ease-in-out infinite;
}

@keyframes borderPulse {
    0%, 100% {
        border-left-width: 4px;
    }
    50% {
        border-left-width: 6px;
    }
}

.compare-section .streaming-placeholder {
    padding: 0.5rem 0;
}

/* Consensus section */
.consensus-section {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1rem;
}

/* Markdown content in streaming */
.streaming-response .markdown-content {
    line-height: 1.6;
}

.streaming-response .markdown-content p {
    margin-bottom: 0.5rem;
}

.streaming-response .markdown-content code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875em;
}

.streaming-response .markdown-content pre {
    background: var(--bg-tertiary);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 0.5rem 0;
}

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

.streaming-response .markdown-content em {
    font-style: italic;
}