/* Palette AI - Component Styles */
/* Buttons, forms, cards, modals, statistics, conversations */

/* Form Controls */
.control-group { 
    margin-bottom: 20px; 
}

.control-group label { 
    display: block; 
    margin-bottom: 6px; 
    font-weight: 500; 
    color: #374151; 
    font-size: 14px;
}

select, input, textarea { 
    width: 100%;
    padding: 8px 12px; 
    border: 1px solid #d1d5db; 
    border-radius: 6px; 
    font-size: 14px; 
    transition: border-color 0.2s;
}

select:focus, input:focus, textarea:focus { 
    outline: none; 
    border-color: #007aff; 
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.control-row { 
    display: flex;
    gap: 12px; 
    align-items: flex-start;
    flex-wrap: wrap;
}

.control-row > div {
    flex: 1;
    min-width: 0;
}

#prompt {
    resize: none;
    min-height: 250px;
    max-height: 200px;
    width: 100%;
    box-sizing: border-box;
}

#prompt:disabled {
    background-color: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
    opacity: 0.8;
    cursor: not-allowed;
}

/* ============================================================================
   BUTTONS - PHASE 10.5: MODERN STYLE
   ============================================================================ */

   .btn {
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 8px; /* More rounded */
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    user-select: none;
    min-width: 100px;
}

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

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

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

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

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

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

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

.btn-success:hover { 
    background: #059669;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

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

/* Cards */
.stat-card {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    text-align: center;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #007aff;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}

.result-card { 
    background: white; 
    border-radius: 8px; 
    border: 1px solid #e1e5e9;
    margin-bottom: 16px; 
    overflow: hidden;
}

.result-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
}

.result-meta { 
    font-size: 12px; 
    color: #6b7280; 
}

.result-content { 
    padding: 16px;
    line-height: 1.6; 
    color: #374151; 
    white-space: pre-wrap; 
    max-height: 950px;
    overflow-y: auto;
}

/* Conversation List - Clean list style, no borders */
.conversation-item {
    /* Removed all borders and styling - handled by layout.css */
}

.conversation-item:hover {
    /* Hover handled by layout.css */
}

.conversation-item.active {
    /* Active state handled by layout.css */
}

.conversation-title {
    /* Title styling handled by layout.css */
}

.conversation-preview {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.conversation-stats {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #9ca3af;
}

.conversation-empty {
    text-align: center;
    color: #6b7280;
    padding: 20px;
    font-style: italic;
}

/* File Upload */
.file-upload {
    border: 2px dashed #d1d5db;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload:hover {
    border-color: #007aff;
    background: #f8f9ff;
}

.file-upload.dragover {
    border-color: #007aff;
    background: #f0f8ff;
}

.uploaded-files {
    margin-top: 12px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f3f4f6;
    border-radius: 6px;
    margin-bottom: 6px;
    transition: all 0.2s ease;
}

.file-item:hover {
    background: #e5e7eb;
    transform: translateX(2px);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.file-remove {
    color: #ef4444;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.file-remove:hover {
    background: #fee2e2;
    transform: scale(1.1);
}

/* ============================================================================
   FILE ATTACHMENTS - PHASE 5
   ============================================================================ */

/* File Attachments Bar */
.file-attachments-bar {
    display: none; /* Hidden when no files */
    flex-wrap: nowrap;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    border-bottom: 1px solid var(--border-primary);
    overflow-x: auto;
    overflow-y: hidden;
    max-height: 80px;
    animation: slideDown 200ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 80px;
    }
}

/* File Attachment Item */
.file-attachment-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 150ms ease;
}

.file-attachment-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.file-icon {
    font-size: 18px;
    line-height: 1;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: 'SF Mono', Monaco, monospace;
}

.file-status {
    font-size: 14px;
    line-height: 1;
}

.file-preview-btn,
.file-remove-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1;
    transition: all 150ms ease;
}

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

.file-remove-btn:hover {
    background: var(--error);
    color: white;
}

/* Drag & Drop Overlay */
.drag-drop-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    pointer-events: none;
}

.drag-drop-overlay.active {
    display: flex;
    animation: fadeIn 150ms ease;
}

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

.drag-drop-text {
    text-align: center;
    color: white;
    font-size: 24px;
    font-weight: 600;
    padding: 40px;
    border: 3px dashed rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    background: rgba(0, 122, 255, 0.1);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { 
        border-color: rgba(255, 255, 255, 0.5);
        transform: scale(1);
    }
    50% { 
        border-color: rgba(0, 122, 255, 0.8);
        transform: scale(1.02);
    }
}

/* File Preview Modal */
.file-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    animation: fadeIn 200ms ease;
}

.file-preview-content {
    background: var(--bg-tertiary);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: 90vw;
    max-height: 90vh;
    width: 1000px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    border-radius: 12px 12px 0 0;
}

.file-preview-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.file-preview-icon {
    font-size: 24px;
}

.file-preview-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-nav-btn,
.preview-action-btn,
.preview-close-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: all 150ms ease;
}

.preview-nav-btn:hover,
.preview-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.preview-close-btn {
    font-size: 20px;
    font-weight: bold;
    padding: 4px 12px;
}

.preview-close-btn:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.preview-counter {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 0 8px;
}

.file-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-primary);
}

.file-preview-code {
    margin: 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
}

.file-preview-code code {
    background: none;
    padding: 0;
}

.file-preview-footer {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    font-size: 12px;
    color: var(--text-secondary);
    border-radius: 0 0 12px 12px;
}

/* Scrollbar styling for file bar */
.file-attachments-bar::-webkit-scrollbar {
    height: 6px;
}

.file-attachments-bar::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.file-attachments-bar::-webkit-scrollbar-thumb {
    background: var(--border-primary);
    border-radius: 3px;
}

.file-attachments-bar::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Export Dialog */
.export-format-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.export-format-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.export-format-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
}

.export-option {
    padding: 16px;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
}

.export-option:hover {
    border-color: #007aff;
    background: #f8f9ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.1);
}

.export-option-title {
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.export-option-desc {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

/* Status indicators */
.loading { 
    text-align: center; 
    padding: 40px; 
    color: #6b7280; 
}

.error { 
    background: #fee2e2; 
    color: #dc2626; 
    padding: 12px 16px; 
    border-radius: 6px; 
    margin: 12px 0; 
    border: 1px solid #fecaca;
}

.cost-display { 
    font-weight: 600; 
    color: #059669; 
}

.validation-warning {
    background: #fff3cd;
    color: #856404;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 8px 0;
    font-size: 12px;
    border: 1px solid #ffeaa7;
}

/* ============================================================================
   SETTINGS DROPDOWN (Phase 2)
   ============================================================================ */

   .settings-dropdown {
    position: fixed;
    width: 320px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
    flex-direction: column;
}

.settings-dropdown.open {
    display: flex;
    animation: slideDown 150ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

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

.settings-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    border-radius: 8px 8px 0 0;
}

.settings-dropdown-header span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all var(--transition-fast) var(--easing);
}

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

.settings-dropdown-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Compact setting sections */
.setting-section {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    margin-bottom: 12px;
}

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

.section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.setting-select,
.setting-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition-normal) var(--easing);
}

.setting-select:focus,
.setting-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.setting-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.setting-slider {
    width: 100%;
    height: 4px;
    background: var(--border-primary);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: background var(--transition-fast) var(--easing);
}

.setting-slider::-webkit-slider-thumb:hover {
    background: var(--accent-hover);
}

.setting-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-tertiary);
}

.input-with-reset {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-with-reset .setting-input {
    flex: 1;
}

.reset-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    transition: all var(--transition-fast) var(--easing);
}

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

.setting-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.setting-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-primary);
}

.setting-action-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal) var(--easing);
}

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

/* ============================================================================
   SETTINGS MODALS (Phase 2)
   ============================================================================ */

.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.settings-modal.open {
    display: flex;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.2); /* Changed from 0.5 to 0.2 */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    /* Removed backdrop-filter: blur(4px); */
}

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

.modal-content {
    position: relative;
    width: 90%;
    max-width: 500px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: scaleIn 200ms var(--easing);
}

.modal-content.large {
    max-width: 700px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 12px 20px; /* Adjusted bottom padding */
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    border-radius: 12px 12px 0 0;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

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

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px 16px 20px; /* Adjusted top padding */
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    border-radius: 0 0 12px 12px;
}

.modal-btn {
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal) var(--easing);
}

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

.modal-btn.primary:hover {
    background: var(--accent-hover);
}

.modal-btn.secondary {
    background: var(--bg-tertiary);
    border-color: var(--border-primary);
    color: var(--text-primary);
}

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

.modal-btn.small {
    padding: 6px 12px;
    font-size: 13px;
}

.setting-textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    line-height: 1.5;
    resize: vertical;
    transition: border-color var(--transition-normal) var(--easing);
}

.setting-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.setting-section {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
}

.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

/* ============================================================================
   API KEY CARDS - PHASE 14 REDESIGN
   ============================================================================ */

   .api-key-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 16px;
}

.api-key-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 12px;
    transition: all 0.2s ease;
}

.api-key-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.api-key-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.api-key-provider-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-key-provider-logo {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.api-key-status-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.api-key-status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.api-key-status-badge.untested {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.api-key-status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.api-key-status-badge.missing {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

.api-key-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.api-key-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.api-key-info-label {
    color: var(--text-secondary);
}

.api-key-info-value {
    color: var(--text-primary);
    font-weight: 500;
}

.api-key-masked {
    font-family: 'Courier New', monospace;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

.api-key-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-primary);
}

.api-key-action-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.api-key-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.api-key-action-btn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.api-key-action-btn.primary:hover {
    background: var(--accent-hover);
}

.api-key-action-btn.danger {
    background: transparent;
    border-color: var(--error);
    color: var(--error);
}

.api-key-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.api-key-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Health Summary Bar */
.api-key-health-summary {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

.health-summary-stats {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.health-stat {
    flex: 1;
    text-align: center;
}

.health-stat-value {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 2px;
}

.health-stat-value.good {
    color: #10b981;
}

.health-stat-value.warning {
    color: #fbbf24;
}

.health-stat-value.error {
    color: #ef4444;
}

.health-stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================================
ANALYTICS & ACCOUNT POPUPS (Phase 3.5)
============================================================================ */

.analytics-popup,
.account-popup {
    position: fixed;
    width: 380px;
    max-height: 600px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.analytics-popup.open,
.account-popup.open {
    display: flex;
    animation: slideDown 150ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.popup-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.popup-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all var(--transition-fast) var(--easing);
}

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

.popup-refresh-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all var(--transition-fast) var(--easing);
    }

.popup-refresh-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: rotate(180deg);
}

.popup-refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
   
.popup-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}
   
.analytics-overview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.analytics-section {
    margin-bottom: 16px;
}
   
.analytics-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Reduce spacing between chart containers */
.chart-container + .chart-container {
    margin-top: 16px;
}

/* Compact model distribution chart */
#modelDistributionChart {
    max-height: 160px !important;
}

.analytics-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 16px 0;
}

.popup-action-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background var(--transition-normal) var(--easing);
}

.popup-action-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

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

/* Popup Tabs */
.popup-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.popup-tab {
    flex: 1;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition-fast) var(--easing);
}

.popup-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}
   
.popup-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

/* Account Tab Content */
.account-tab-content {
    display: none;
}

.account-tab-content:first-child {
    display: block;
}

.account-info-section,
.usage-section,
.billing-plan {
    margin-bottom: 16px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
}
   
.info-label {
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
}

.usage-stat {
    margin-bottom: 12px;
}

.progress-bar {
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 3px;
    transition: width var(--transition-normal) var(--easing);
}
   
/* API Keys */
.api-key-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.api-key-item {
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
}

.api-key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.api-key-provider {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}
   
.api-key-action-btn {
    padding: 4px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast) var(--easing);
}

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

.api-key-value code {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 11px;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
}

   /* Compact API Keys */
.api-key-list.compact {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.api-key-item-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
}

.api-key-item-compact .api-key-provider {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 0 0 120px;
}

.api-key-status {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 10px;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    flex: 1;
}

.api-key-config-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    border-radius: 4px;
    transition: all var(--transition-fast) var(--easing);
}

.api-key-config-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Compare Models Popup */
.compare-popup {
    position: fixed;
    width: 420px;
    max-height: 600px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000; /* Increased from 1000 */
    display: none !important; /* Force hidden by default */
    flex-direction: column;
    overflow: hidden;
}

.compare-popup.open {
    display: flex !important; /* Force visible when open */
    animation: slideDown 150ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.model-selection-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.model-provider-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.provider-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 4px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: background var(--transition-fast) var(--easing);
    font-size: 13px;
    color: var(--text-primary);
}

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

.model-checkbox {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.model-checkbox-label input:checked + span {
    color: var(--accent-primary);
    font-weight: 500;
}

/* Analytics Tabs */
.analytics-tab-content {
    display: none;
    width: 100%;
}

.analytics-tab-content:first-child {
    display: block; /* Ensure first tab (overview) shows by default */
}

.usage-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Conversation Details Popup */
.conversation-details-popup {
    position: fixed;
    width: 380px;
    max-height: 600px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.conversation-details-popup.open {
    display: flex;
    animation: slideDown 150ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Compact Analytics Popup */
.analytics-popup .popup-content {
    max-height: 520px;
    overflow-y: auto;
}

.analytics-popup .stat-row {
    padding: 4px 0;
    margin-bottom: 0;
}

.analytics-popup .analytics-overview {
    gap: 4px;
    margin-bottom: 8px;
}

.analytics-popup .analytics-divider {
    margin: 8px 0;
}

.analytics-popup .analytics-section {
    margin-bottom: 8px;
}

.analytics-popup .analytics-section h4 {
    margin: 0 0 6px 0;
    font-size: 11px;
}

.analytics-popup table {
    font-size: 11px !important;
}

.analytics-popup table th,
.analytics-popup table td {
    padding: 4px 0 !important;
}

.analytics-popup .stat-label {
    font-size: 12px;
}

.analytics-popup .stat-value {
    font-size: 13px;
}

.conversation-detail-section {
    margin-bottom: 16px;
}

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

.conversation-detail-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.detail-label {
    color: var(--text-secondary);
}

.detail-value {
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
}

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

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

/* ============================================================================
   WEB SEARCH UI - PHASE 6
   ============================================================================ */

/* Search Indicator */
.search-indicator-message {
    padding: 12px 16px;
    margin: 12px 0;
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent-primary);
    border-radius: 6px;
    animation: fadeIn 200ms ease;
}

.search-indicator-content {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.search-icon {
    font-size: 18px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.search-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Source Panel */
.search-sources-panel {
    margin-top: 12px;
    padding: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    overflow: hidden;
}

.sources-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    cursor: pointer;
    transition: background 150ms ease;
}

.sources-header:hover {
    background: var(--bg-hover);
}

.sources-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
}

.sources-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    transition: all 150ms ease;
}

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

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
}

/* Source Card - Compact Version */
.source-card {
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    transition: all 150ms ease;
}

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

.source-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.source-number {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-primary);
    min-width: 18px;
}

.source-icon {
    font-size: 14px;
    line-height: 1;
}

.source-domain {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.source-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.source-snippet {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.source-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    margin-top: 4px;
}

.source-date {
    color: var(--text-tertiary);
}

.source-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 11px;
    transition: all 150ms ease;
}

.source-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* Search Analytics */
.query-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 6px;
}

.query-text {
    font-size: 13px;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.query-count {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 600;
    margin-left: 12px;
}

.top-queries-list {
    display: flex;
    flex-direction: column;
}

.stat-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.stat-bar-label {
    font-size: 13px;
    color: var(--text-primary);
    min-width: 80px;
    font-weight: 500;
    text-transform: capitalize;
}

.stat-bar-visual {
    flex: 1;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-hover));
    transition: width 300ms ease;
}

.stat-bar-value {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 40px;
    text-align: right;
}

.analytics-bars {
    display: flex;
    flex-direction: column;
}

.settings-popup {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: 420px;
    max-width: 90vw;
    max-height: 85vh;
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
}

.settings-popup.open {
    display: flex;
    animation: slideInFade 0.2s ease;
}

@media (max-width: 768px) {
    .settings-popup {
        width: 95vw;
        max-height: 90vh;
        left: 2.5vw !important;
        right: 2.5vw !important;
        top: 5vh !important;
    }
    
    /* Stack setting groups vertically on mobile */
    .setting-group {
        margin-bottom: 12px;
    }
    
    /* Larger touch targets on mobile */
    .setting-slider {
        height: 8px;
    }
    
    .setting-input,
    .setting-select {
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    /* Compact theme buttons on mobile */
    .theme-option-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    /* API key cards single column on mobile */
    .api-key-cards-grid {
        grid-template-columns: 1fr;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .popup-tabs {
        overflow-x: auto;
        scrollbar-width: none;
    }
    
    .popup-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .popup-tab {
        flex-shrink: 0;
        padding: 8px 12px;
        font-size: 12px;
    }
}

.settings-tab-content {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.settings-tab-content:first-child {
    display: flex; /* Show general tab by default */
}

/* Theme Option Buttons */
.theme-option-btn {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-normal) var(--easing);
}

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

.theme-option-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* ============================================================================
   ANALYTICS CHARTS - PHASE 10
   ============================================================================ */

   .analytics-charts-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
}

.chart-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 16px;
    min-height: 200px;
    position: relative;
}

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

.chart-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.chart-subtitle {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.chart-canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 250px;
}

/* Small sparkline charts */
.sparkline-container {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.sparkline-card {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sparkline-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sparkline-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.sparkline-change {
    font-size: 10px;
    color: var(--success);
}

.sparkline-change.negative {
    color: var(--error);
}

/* Export buttons */
.analytics-export-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-primary);
}

.export-buttons {
    display: flex;
    gap: 8px;
}

.export-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-fast) var(--easing);
}

.export-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.export-btn:active {
    transform: translateY(0);
}

/* Loading state for charts */
.chart-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-tertiary);
    font-size: 13px;
}

.chart-loading::before {
    content: '';
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive charts */
@media (max-width: 768px) {
    .chart-container {
        padding: 12px;
        min-height: 180px;
    }
    
    .chart-canvas {
        max-height: 200px;
    }
    
    .sparkline-container {
        flex-direction: column;
        gap: 8px;
    }
    
    /* PHASE 10: Full-screen popups on mobile */
    .analytics-popup,
    .account-popup,
    .settings-popup,
    .compare-popup {
        width: 100vw !important;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border-radius: 0;
    }

    /* PHASE 10.5: Bubble adjustments for mobile */
    .message-content {
        max-width: 85% !important;
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    .chat-container {
        padding: 12px;
        gap: 16px;
        max-width: 100%;
    }
    
    .chat-input-wrapper {
        max-width: 100%;
        padding: 8px 10px;
    }
    
    .chat-input {
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    /* Larger touch targets */
    .chat-input-btn {
        width: 40px;
        height: 40px;
    }
    
    /* Adjust popup content for mobile */
    .popup-content {
        max-height: calc(100vh - 120px);
    }
    
    /* Stack export buttons vertically on mobile */
    .export-buttons {
        flex-direction: column;
    }
    
    .export-btn {
        width: 100%;
    }
}

/* ============================================================================
   PROGRESS INDICATORS - PHASE 10
   ============================================================================ */

   .progress-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    z-index: 999;
    animation: slideInUp 200ms var(--easing);
    max-width: 300px;
}

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

.progress-indicator-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.progress-indicator-icon {
    font-size: 18px;
    animation: spin 1s linear infinite;
}

.progress-indicator-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-indicator-bar {
    height: 4px;
    background: var(--bg-secondary);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-indicator-fill {
    height: 100%;
    background: var(--accent-primary);
    transition: width 300ms ease;
}

/* Indeterminate progress animation */
.progress-indicator-fill.indeterminate {
    width: 30%;
    animation: indeterminateProgress 1.5s ease-in-out infinite;
}

@keyframes indeterminateProgress {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(300%);
    }
    100% {
        transform: translateX(-100%);
    }
}

/* ============================================================================
   ACCESSIBILITY - REDUCED MOTION - PHASE 10
   ============================================================================ */

/* Respect user's motion preferences for accessibility */
@media (prefers-reduced-motion: reduce) {
    /* Disable all animations and transitions */
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    /* Disable specific transform animations */
    .popup-refresh-btn:hover,
    .btn:active,
    .chat-input-btn:active,
    .header-icon-btn:active,
    .file-item:hover,
    .export-btn:hover {
        transform: none !important;
    }
    
    /* Disable pulse animations */
    #stopBtn,
    .search-icon,
    .drag-drop-text {
        animation: none !important;
    }
    
    /* Disable chart loading spinner */
    .chart-loading::before {
        animation: none !important;
        border-top-color: var(--accent-primary);
    }
}

/* ============================================================================
   SYSTEM PROMPT MODAL - SPECIFIC FIX
   ============================================================================ */

   #systemPromptModal {
    position: fixed !important;
    display: none !important;
    flex-direction: column;
    z-index: 2500 !important; /* Higher than everything else */
}

#systemPromptModal.open {
    display: flex !important;
    animation: slideDown 150ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* ============================================================================
   MODAL VISIBILITY FIX - ENSURE ALL MODALS SHOW WHEN OPEN
   ============================================================================ */

/* Hidden by default */
.settings-popup:not(.open),
#systemPromptModal:not(.open),
.compare-popup:not(.open),
.analytics-popup:not(.open),
.account-popup:not(.open),
.conversation-details-popup:not(.open) {
    display: none !important;
}

/* Visible when open */
.settings-popup.open,
#systemPromptModal.open,
.compare-popup.open,
.analytics-popup.open,
.account-popup.open,
.conversation-details-popup.open {
    display: flex !important;
}

/* ============================================================================
   CUSTOM MODEL SELECTOR DROPDOWN - CENTERED
   ============================================================================ */

   .model-selector-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    min-width: 180px;
    max-width: 250px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: all 0.15s ease;
}

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

.model-selector-btn:active,
.model-selector-btn.open {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

#currentModelDisplay {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-selector-popup {
    position: fixed;
    width: 350px;
    max-height: 500px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    /* Positioned by JS - centered below button */
}

.model-selector-popup.open {
    display: flex;
    animation: slideDown 150ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.model-selector-search {
    padding: 12px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

.model-selector-search input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
}

.model-selector-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.model-selector-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.model-group {
    margin-bottom: 12px;
}

.model-group-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin-bottom: 4px;
}

.model-option {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.model-option.selected {
    background: var(--accent-primary);
    color: white;
    font-weight: 500;
}

.model-option-name {
    flex: 1;
}

.model-option-check {
    font-size: 14px;
    opacity: 0;
}

.model-option.selected .model-option-check {
    opacity: 1;
}

/* ============================================================================
   SMART ROUTING UI COMPONENTS (PHASE 11) - ULTRA COMPACT
   ============================================================================ */

/* Radio Options for Priority Mode Selection - FINAL COMPACT VERSION */
.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px !important; /* Force override any inline styles */
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 0 !important;
}

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

.radio-option input[type="radio"] {
    margin: 0;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.radio-option input[type="radio"]:checked + .radio-option-content .radio-option-title {
    color: var(--accent-primary);
    font-weight: 600;
}

.radio-option-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    line-height: 1;
}

.radio-option-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
    margin: 0;
    padding: 0;
}

.radio-option-desc {
    font-size: 10px;
    color: var(--text-secondary);
    line-height: 1.2;
    margin: 2px 0 0 0;
    padding: 0;
}

/* Checkbox Options */
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-primary);
    margin: 0 !important;
    padding: 0 !important;
}

.checkbox-option input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
}

.checkbox-option:hover {
    color: var(--accent-primary);
}

/* Input Groups for Settings */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}

.input-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.input-group input[type="number"],
.input-group input[type="text"] {
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    transition: border-color 0.2s ease;
    margin: 0;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.input-hint {
    font-size: 10px;
    color: var(--text-secondary);
    margin: 0;
}

/* Settings Section - Remove all default spacing */
#routingTab .settings-section {
    padding: 10px 16px !important;
    margin: 0 !important;
}

#routingTab .settings-section-header {
    margin-bottom: 8px !important;
}

#routingTab .settings-section-title {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
}

/* Priority Mode Container - CRITICAL: Remove gap */
#routingTab .settings-section > div[style*="gap"] {
    gap: 6px !important; /* Minimal gap between radio buttons */
}

/* Slider Group - Compact */
.slider-group {
    margin: 0 !important;
    padding: 0 !important;
}

.slider-label {
    font-size: 12px;
    margin: 0 0 4px 0 !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-value {
    font-weight: 600;
    color: var(--accent-primary);
}

/* Help Text */
.settings-help-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 0 !important;
    line-height: 1.4;
}

/* Routing Badge in Messages */
.message-content.smart-selected {
    border-left: 3px solid var(--accent-primary);
}

.routing-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(16, 163, 127, 0.1);
    border: 1px solid var(--accent-primary);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-primary);
    margin-left: 8px;
}

/* Test Routing Result Box */
#testRoutingResult {
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    margin: 0;
}

#testRoutingResult strong {
    color: var(--text-primary);
}

#testRoutingResult div {
    color: var(--text-secondary);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 8px 16px;
    font-size: 13px;
    margin: 0;
}

/* ============================================================================
   API KEY MANAGEMENT UI (PHASE 11.5)
   ============================================================================ */

/* Health Summary Bar */
.api-key-health-summary {
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    margin-bottom: 16px;
}

.health-progress-bar {
    width: 100%;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.health-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--success));
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

/* API Key Cards Grid */
.api-key-cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

/* Provider Card */
.api-key-provider-card {
    padding: 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.api-key-provider-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.api-key-provider-card.error {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.05);
}

/* Card Header */
.api-key-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.api-key-provider-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Status Badge */
.api-key-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.api-key-status-badge.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.api-key-status-badge.untested {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.api-key-status-badge.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.api-key-status-badge.not-configured {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-tertiary);
}

/* Key Info */
.api-key-info {
    margin-bottom: 10px;
}

.api-key-display {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.api-key-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

.api-key-meta.error {
    color: var(--error);
}

/* Card Actions */
.api-key-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.api-key-btn {
    padding: 5px 12px;
    font-size: 12px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.api-key-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

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

.api-key-btn.primary:hover {
    opacity: 0.9;
}

.api-key-btn.danger {
    color: var(--error);
}

.api-key-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error);
}

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

.modal-container {
    background: var(--bg-secondary); /* Changed from --bg-primary for unified look */
    border: 1px solid var(--border-primary); /* Added subtle border */
    border-radius: 8px; /* Reduced from 12px */
    box-shadow: var(--shadow-md); /* Changed from heavy custom shadow */
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

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

.modal-close-btn {
    background: none;
    border: none;
    font-size: 24px; /* Reduced from 28px */
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 28px; /* Reduced from 32px */
    height: 28px; /* Reduced from 32px */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px; /* Reduced from 6px */
    transition: all 0.15s ease; /* Faster transition */
}

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

.modal-content {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.form-group {
    margin-bottom: 14px; /* Slightly tighter */
}

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

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    background: var(--bg-tertiary); /* Changed for subtle depth */
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.15s ease; /* Faster */
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.form-hint {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Test Result Animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.test-result-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
    animation: slideDown 0.3s ease;
}

.test-result-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    animation: slideDown 0.3s ease;
}

/* Spinner Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    animation: spin 1s linear infinite;
}

/* ============================================================================
   PHASE 14.1: COST ESTIMATION UI (INLINE HEADER)
   ============================================================================ */

/* Ensure chat header stats area can contain warnings */
#chatStats {
    display: flex !important;
    align-items: center !important; /* Vertical center */
    justify-content: center !important; /* Horizontal center */
    width: auto !important; /* Changed from 100% */
    height: 100% !important;
    position: relative !important;
    overflow: visible !important;
}

/* Cost Preview Tooltip (non-blocking) */
.cost-preview-tooltip {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    min-width: 250px;
    transition: opacity 0.3s ease;
}

.cost-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-primary);
}

.cost-preview-amount {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-primary);
}

.cost-preview-confidence {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
}

.cost-preview-breakdown {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cost-preview-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.cost-preview-row span:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* Inline Cost Warning (MUST be inline, not modal) */
.cost-warning-inline {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px !important;
    background: linear-gradient(135deg, #FFF3CD 0%, #FFE082 100%) !important;
    border: 2px solid #FFB74D !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    animation: slideIn 0.3s ease !important;
    box-shadow: 0 2px 8px rgba(255, 183, 77, 0.3) !important;
    width: 100% !important;
    box-sizing: border-box !important;
    position: relative !important;  /* CRITICAL: Not fixed/absolute */
    margin: 0 !important;
    z-index: 1 !important;  /* Low z-index to stay inline */
}

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

.cost-warning-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.cost-warning-text {
    font-weight: 600;
    color: #E65100;
    white-space: nowrap;
    flex-shrink: 0;
}

.cost-warning-reason {
    color: #F57C00;
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Inline Buttons */
.cost-btn-alternatives,
.cost-btn-cancel-inline,
.cost-btn-proceed-inline {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.cost-btn-alternatives {
    background: white;
    color: #1976D2;
    border: 1px solid #1976D2;
}

.cost-btn-alternatives:hover {
    background: #E3F2FD;
    border-color: #1565C0;
}

.cost-btn-cancel-inline {
    background: white;
    color: #666;
    border: 1px solid #ddd;
}

.cost-btn-cancel-inline:hover {
    background: #f5f5f5;
    border-color: #999;
}

.cost-btn-proceed-inline {
    background: #FF9800;
    color: white;
}

.cost-btn-proceed-inline:hover {
    background: #F57C00;
}

/* Alternatives Dropdown */
.cost-alternatives-dropdown {
    position: relative;  /* Changed from absolute to relative */
    width: 100%;
    margin-top: 8px;
    background: white;
    border: 2px solid #FFB74D;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.2);
    z-index: 1000;
    animation: dropdownSlide 0.2s ease;
}

.cost-alternatives-dropdown.hidden {
    display: none !important;
}

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

.cost-alternatives-list {
    display: flex;
    flex-direction: column;
    padding: 8px;
    gap: 6px;
}

.cost-alternative-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #FFF8E1;
    border: 1px solid #FFE082;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    width: 100%;
}

.cost-alternative-item:hover {
    background: #FFECB3;
    border-color: #FFB74D;
    transform: translateX(4px);
}

.cost-alt-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cost-alt-name {
    font-weight: 600;
    font-size: 13px;
    color: #333;
}

.cost-alt-badge {
    display: inline-block;
    background: #4CAF50;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    width: fit-content;
}

.cost-alt-savings {
    font-size: 14px;
    color: #4CAF50;
    font-weight: 600;
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .cost-warning-inline {
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .cost-warning-reason {
        max-width: 150px;
    }
    
    .cost-btn-alternatives,
    .cost-btn-cancel-inline,
    .cost-btn-proceed-inline {
        font-size: 11px;
        padding: 3px 8px;
    }
}

/* ============================================================================
   PHASE 14.1: COST ESTIMATION UI (INLINE HEADER) - ENHANCED
   ============================================================================ */

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

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

.cost-alternatives-dropdown.hidden {
    display: none !important;
}

/* Hover effects for buttons */
.cost-btn-alternatives:hover {
    background: #E3F2FD !important;
    border-color: #1565C0 !important;
}

.cost-btn-cancel-inline:hover {
    background: #f5f5f5 !important;
    border-color: #999 !important;
}

.cost-btn-proceed-inline:hover {
    background: #F57C00 !important;
}

.cost-alternative-item:hover {
    background: #FFECB3 !important;
    border-color: #FFB74D !important;
    transform: translateX(4px);
}

/* Ensure chat header stats area can contain warnings */
.chat-header-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    min-height: 20px;
    overflow: visible;
}

/* Cost tracker positioning override */
#costTrackerInline {
    position: absolute !important;
    left: 50% !important;
    top: 46% !important;
    transform: translate(-50%, -50%) !important;
    margin-top: 3px !important;  /* Adjust this value: positive = down, negative = up */
}

/* ============================================================================
   MOBILE RESPONSIVE DESIGN - Phase 3
   ============================================================================ */

/* Tablet Landscape & Below (1024px) */
@media (max-width: 1024px) {
    .layout-container {
        grid-template-columns: 280px 1fr;
    }
    
    .sidebar {
        width: 280px;
    }
    
    .artifact-pane {
        width: 45%;
    }
}

/* Tablet Portrait (768px) */
@media (max-width: 768px) {
    .layout-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 300px;
        overflow-y: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .main-content {
        padding: 12px;
    }
    
    .artifact-pane {
        position: fixed;
        top: 0;
        right: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    .artifact-pane.visible {
        transform: translateX(0);
    }
    
    .model-selector {
        flex-direction: column;
        gap: 8px;
    }
    
    .model-selector-header {
        width: 100%;
    }
    
    .model-selector-dropdown {
        width: 100%;
        max-width: none;
    }
    
    .chat-input-container {
        padding: 12px;
    }
    
    .popup-content {
        width: 95vw;
        max-width: none;
        margin: 10px;
    }
}

/* Mobile (480px) */
@media (max-width: 480px) {
    .sidebar-header {
        padding: 12px;
    }
    
    .new-chat-btn {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .message-content {
        font-size: 14px;
    }
    
    .chat-input-wrapper textarea {
        font-size: 15px;
        min-height: 44px; /* iOS touch target minimum */
    }
    
    .send-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }
    
    .model-selector-list {
        max-height: 60vh;
    }
    
    .popup-tabs {
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .popup-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .popup-tab {
        font-size: 13px;
        padding: 10px 16px;
        white-space: nowrap;
    }
    
    /* Make buttons easier to tap */
    button, .clickable {
        min-height: 44px;
        min-width: 44px;
    }
}

/* iOS Safe Area Support */
@supports (padding: env(safe-area-inset-bottom)) {
    .chat-input-container {
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }
    
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .conversation-item:hover,
    .model-option:hover,
    button:hover {
        transform: none;
    }
    
    /* Add active states for touch */
    .conversation-item:active {
        background: var(--hover-bg);
        transform: scale(0.98);
    }
    
    button:active {
        transform: scale(0.95);
    }
    
    /* Larger touch targets */
    .icon-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ============================================================================
   COMPACT API KEYS TAB - PHASE 14.5 (ULTRA MINIMAL HEIGHT)
   ============================================================================ */

/* Force absolute minimum vertical spacing */
#apikeysTab {
    line-height: 1.2 !important;
}

#apikeysTab .api-key-health-summary {
    padding: 6px 8px !important;
    margin-bottom: 6px !important;
}

#apikeysTab .api-key-health-summary > div:first-child {
    margin-bottom: 4px !important;
}

#apikeysTab .health-summary-stats {
    gap: 8px !important;
    margin-top: 4px !important;
}

#apikeysTab .health-stat {
    padding: 0 !important;
}

#apikeysTab .health-stat-value {
    font-size: 14px !important;
    margin-bottom: 1px !important;
    line-height: 1 !important;
}

#apikeysTab .health-stat-label {
    font-size: 9px !important;
    line-height: 1 !important;
}

#apikeysTab .api-key-cards-grid {
    gap: 4px !important;
    margin-top: 6px !important;
}

#apikeysTab .api-key-card,
#apikeysTab .api-key-provider-card {
    padding: 6px 8px !important;
    margin-bottom: 0 !important;
}

#apikeysTab .api-key-card-header {
    margin-bottom: 4px !important;
}

#apikeysTab .api-key-provider-name {
    font-size: 12px !important;
    gap: 4px !important;
    line-height: 1.2 !important;
}

#apikeysTab .api-key-provider-logo {
    width: 16px !important;
    height: 16px !important;
}

#apikeysTab .api-key-status-badge {
    padding: 1px 5px !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
}

#apikeysTab .api-key-card-body {
    gap: 3px !important;
}

#apikeysTab .api-key-info {
    margin-bottom: 4px !important;
}

#apikeysTab .api-key-info-row {
    padding: 2px 0 !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
}

#apikeysTab .api-key-info-label {
    font-size: 10px !important;
}

#apikeysTab .api-key-info-value {
    font-size: 10px !important;
}

#apikeysTab .api-key-display {
    font-size: 11px !important;
    margin-bottom: 2px !important;
    line-height: 1.2 !important;
}

#apikeysTab .api-key-meta {
    font-size: 9px !important;
    line-height: 1.2 !important;
}

#apikeysTab .api-key-masked {
    font-size: 10px !important;
    padding: 1px 4px !important;
}

#apikeysTab .api-key-actions,
#apikeysTab .api-key-card-actions {
    margin-top: 4px !important;
    padding-top: 4px !important;
    gap: 3px !important;
}

#apikeysTab .api-key-action-btn,
#apikeysTab .api-key-btn {
    padding: 3px 6px !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
}

#apikeysTab .api-key-security-settings {
    padding: 6px 8px !important;
    margin-top: 6px !important;
}

#apikeysTab .api-key-security-settings h4 {
    font-size: 11px !important;
    margin: 0 0 3px 0 !important;
    line-height: 1.2 !important;
}

#apikeysTab .api-key-security-settings p {
    font-size: 9px !important;
    line-height: 1.3 !important;
    margin: 0 !important;
}

/* Minimize icon sizes */
#apikeysTab i[data-lucide] {
    width: 11px !important;
    height: 11px !important;
}

#apikeysTab .api-key-security-settings i[data-lucide] {
    width: 12px !important;
    height: 12px !important;
}

/* Remove any default margins from buttons */
#apikeysTab button {
    margin: 0 !important;
}

/* Compact the "Test All Keys" button in header */
#apikeysTab .btn-secondary {
    padding: 3px 8px !important;
    font-size: 10px !important;
}

/* Reduce spacing between label and content */
#apikeysTab .api-key-health-summary span {
    display: inline-block;
    line-height: 1.2 !important;
}

/* Single-row API key layout */
.api-key-row:hover {
    background: var(--bg-hover) !important;
    border-color: var(--accent-primary) !important;
    transform: translateX(2px);
}

/* Make status badges more compact in row layout */
.api-key-row .api-key-status-badge {
    padding: 2px 6px !important;
    font-size: 9px !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.api-key-row .api-key-status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.api-key-row .api-key-status-badge.untested {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.api-key-row .api-key-status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.api-key-row .api-key-status-badge.missing {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

/* Compact buttons in row layout */
.api-key-row .api-key-action-btn {
    white-space: nowrap;
}

.api-key-row .api-key-action-btn:hover {
    transform: translateY(-1px);
}

/* ============================================================================
   COMPACT ACCOUNT TAB - MATCH ROUTING/API KEYS COMPACTNESS
   ============================================================================ */

/* Make account tab match routing tab compactness */
#accountTab .account-info-section,
#accountTab .usage-section,
#accountTab .billing-plan {
    margin-bottom: 8px !important;
}

#accountTab .account-info-section h4,
#accountTab .usage-section h4,
#accountTab .billing-plan h4 {
    font-size: 11px !important;
    font-weight: 600 !important;
    margin: 0 0 6px 0 !important;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-primary);
}

#accountTab .info-row {
    padding: 3px 0 !important;
    font-size: 11px !important;
    line-height: 1.3 !important;
}

#accountTab .info-label {
    font-size: 10px !important;
    color: var(--text-secondary);
}

#accountTab .info-value {
    font-size: 11px !important;
    font-weight: 500;
    color: var(--text-primary);
}

/* Compact usage stats */
#accountTab .usage-stat {
    margin-bottom: 8px !important;
}

#accountTab .usage-stat > div:first-child {
    display: flex;
    justify-content: space-between;
    font-size: 10px !important;
    margin-bottom: 3px !important;
}

#accountTab .progress-bar {
    height: 4px !important;
}

/* Compact dividers */
#accountTab .analytics-divider {
    margin: 8px 0 !important;
}

/* Compact any paragraphs */
#accountTab p {
    font-size: 10px !important;
    line-height: 1.4 !important;
    margin: 4px 0 !important;
}

/* Compact list items */
#accountTab ul {
    margin: 6px 0 !important;
    padding-left: 16px !important;
}

#accountTab li {
    font-size: 10px !important;
    line-height: 1.4 !important;
    margin-bottom: 3px !important;
}

/* Compact buttons in account tab */
#accountTab .popup-action-btn {
    padding: 6px 12px !important;
    font-size: 10px !important;
    margin-top: 6px !important;
}

/* Compact icons */
#accountTab i[data-lucide] {
    width: 11px !important;
    height: 11px !important;
}

/* Make the upgrade section more compact */
#accountTab .billing-plan {
    padding: 8px 10px !important;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-primary);
}

/* If there are any spacing containers */
#accountTab > div {
    gap: 6px !important;
}

/* Feedback Modal Styles */
.rating-star {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all 0.15s ease;
    user-select: none;
}

.rating-star:hover,
.rating-star.active {
    color: #fbbf24;
    transform: scale(1.1);
}

/* ========================================
   PANEL TYPOGRAPHY - COMPLETE CONTROL
   ======================================== */

/* PANEL HEADERS */
.popup-header .popup-title,
#settingsPopup .popup-header .popup-title,
#accountPopup .popup-header .popup-title,
#systemPromptModal .popup-header .popup-title,
#analyticsPopup .popup-header .popup-title,
#comparePopup .popup-header .popup-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
}

/* TAB LABELS */
.popup-tab,
#settingsPopup .popup-tab,
#accountPopup .popup-tab,
.settings-popup .popup-tab {
    font-size: 14px !important;
    font-weight: 500 !important;
    padding: 8px 14px !important;
}

.popup-tab.active {
    font-weight: 600 !important;
}

/* SECTION HEADERS (uppercase labels like "THEME", "WEB SEARCH") */
.settings-tab-content label[style*="text-transform: uppercase"],
.popup-content label[style*="text-transform: uppercase"],
.setting-group label {
    font-size: 12px !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px !important;
}

/* FIELD LABELS (regular labels above inputs) */
.setting-label,
.settings-tab-content label,
#generalTab label,
#voiceTab label,
#routingTab label,
#advancedTab label,
#accountGeneralTab label,
#accountApiKeysTab label,
.popup-content label {
    font-size: 12px !important;
    font-weight: 500 !important;
}

/* INPUT FIELDS & SELECTS */
.setting-input,
.setting-select,
#settingsPopup input[type="text"],
#settingsPopup input[type="number"],
#settingsPopup select,
#accountPopup input[type="text"],
#accountPopup input[type="email"],
#accountPopup select {
    font-size: 12px !important;
}

/* BUTTONS IN PANELS */
.popup-action-btn,
.theme-option-btn,
.setting-btn,
#settingsPopup button,
#accountPopup button {
    font-size: 12px !important;
    font-weight: 500 !important;
}

/* SMALL BUTTONS (like reset, close) */
.reset-btn,
.popup-close-btn {
    font-size: 11px !important;
}

/* HELPER TEXT / HINTS */
.setting-hint,
.api-key-meta,
div[style*="font-size: 8px"],
div[style*="font-size: 9px"] {
    font-size: 10px !important;
    color: var(--text-tertiary) !important;
}

/* VALUE DISPLAYS (like temperature value, slider values) */
#tempValue,
#speechRateValue,
#speechPitchValue,
#costWeightValue,
#qualityWeightValue,
#speedWeightValue,
#minQualityValue,
span[style*="color: var(--accent-primary)"] {
    font-size: 12px !important;
    font-weight: 600 !important;
}

/* BODY TEXT / PARAGRAPHS */
.popup-content p,
.settings-tab-content p,
#settingsPopup p,
#accountPopup p {
    font-size: 12px !important;
    line-height: 1.5 !important;
}

/* RADIO BUTTON LABELS */
.radio-option span,
.radio-option-content span {
    font-size: 11px !important;
}

/* CHECKBOX LABELS */
label[style*="cursor: pointer"] span,
.settings-tab-content label span {
    font-size: 11px !important;
}

/* API KEY STATUS BADGES */
.api-key-status-badge {
    font-size: 10px !important;
    font-weight: 600 !important;
}

/* USAGE COUNTS & METADATA */
span[style*="font-size: 10px"] {
    font-size: 10px !important;
}

/* ============================================================================
   MODEL INFO POPUP
   ============================================================================ */

   .model-info-popup {
    position: fixed;
    width: 380px;
    max-height: 80vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.model-info-popup.open {
    display: flex;
}

.model-info-popup .popup-content {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
}

/* Smart Routing section - highlighted */
.model-info-section.smart-routing {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

/* Provider sections */
.model-info-section {
    margin-bottom: 20px;
}

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

.model-info-provider-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-primary);
}

/* Model info items */
.model-info-item {
    padding: 10px;
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    transition: all 0.15s ease;
}

.model-info-item:last-child {
    margin-bottom: 0;
}

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

/* Model info header (for smart routing) */
.model-info-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.model-info-icon {
    font-size: 20px;
}

.model-info-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.model-info-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 6px 0;
}

.model-info-description {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 8px 0;
}

/* Use case tags */
.model-info-use-cases {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.use-case-tag {
    display: inline-block;
    padding: 3px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.model-info-section.smart-routing .use-case-tag {
    background: rgba(16, 163, 127, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Divider */
.model-info-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 16px 0;
}