/* ===========================================
   CELLYN Design System - CSS Custom Properties
   Phase 5: UI Polish - Unified Color Palette
   =========================================== */

   :root {
    /* Primary Colors - Cellyn Brand (Deep Indigo + Violet) */
    --color-primary: #6D55D6;
    --color-primary-dark: #5D46BF;
    --color-primary-light: #E8E1FA;
    --color-gradient-start: #6C5CE7;
    --color-gradient-end: #5A4BD1;

    /* Success Colors */
    --color-success: #22c55e;
    --color-success-bg: #dcfce7;
    --color-success-dark: #16a34a;

    /* Error Colors */
    --color-error: #ef4444;
    --color-error-bg: #fee2e2;
    --color-error-dark: #dc2626;

    /* Warning Colors */
    --color-warning: #f59e0b;
    --color-warning-bg: #fef3c7;
    --color-warning-dark: #d97706;

    /* Neutral Colors */
    --color-text-primary: #1D1836;
    --color-text-secondary: #645D83;
    --color-text-muted: #9891B4;
    --color-border: #E6E0F2;
    --color-bg-primary: #ffffff;
    --color-bg-secondary: #ffffff;
    --color-bg-tertiary: #EEEBF7;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    /* 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.1);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;

    /* Z-Index Scale */
    --z-dropdown: 100;
    --z-modal: 200;
    --z-tooltip: 300;
}

/* ===========================================
   Status Indicator - Progress Display
   =========================================== */

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(109, 85, 214, 0.08) 0%, rgba(78, 58, 168, 0.08) 100%);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--color-primary);
    animation: fadeIn 0.3s ease;
}

.status-indicator .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-primary-light);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.analyzing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
}

.analyzing-indicator .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

/* ===========================================
   Thinking/Progress Text - Simple Inline
   =========================================== */

.thinking-text {
    color: var(--color-text-secondary);
    font-size: 14px;
    font-style: italic;
    animation: thinkingPulse 1.5s ease-in-out infinite;
}

@keyframes thinkingPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: #f5f0ff;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.brand-logo-mark {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    flex-shrink: 0;
}

.brand-logo-mark svg {
    width: 100%;
    height: 100%;
    display: block;
}

.header {
    background: linear-gradient(120deg, var(--color-gradient-start), var(--color-gradient-end));
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
}

.status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

/* V4 ENHANCEMENT: Additional status indicators */
.status-dot.hardcode {
    background: #fbbf24;
}

.status-dot.error {
    background: #ef4444;
}

.hardcode-badge {
    background: rgba(251, 191, 36, 0.2);
    color: #92400e;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
}

/* V10 INTEGRATION: Hardcode toggle from v4 */

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

/* Phase 31.2: Excel Sheet Style Tabs - Cellyn branded design */
.tabs {
    background: #DED8F8;
    display: flex;
    padding: 4px 0 0 0;
    gap: 0;
    border: none;
    position: relative;
    align-items: flex-end;
    min-height: 30px;
}

.tab {
    flex: 1;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text-secondary);
    font-weight: 400;
    text-align: center;
    background: transparent;
    border: none;
    border-radius: 0;
    transition: all 0.15s ease;
    position: relative;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab:hover:not(.active) {
    background: rgba(109, 85, 214, 0.12);
    color: var(--color-primary);
}

.tab.active {
    background: #F4F2F9;
    color: #1a1a1a;
    font-weight: 500;
    border: none;
    border-radius: 6px 6px 0 0;
    margin-bottom: 0;
    padding-bottom: 6px;
    box-shadow: none;
}

/* Purple indicator line at TOP of active tab - Cellyn branded */
.tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--color-primary);
    border-radius: 0 0 1px 1px;
    animation: tabIndicatorExpand 0.3s ease-out forwards;
    transform-origin: center;
}

@keyframes tabIndicatorExpand {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--color-bg-secondary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.selection-card {
    margin: 8px 12px 0 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #6D55D6;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.selection-card-title {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    padding: 8px 12px 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.selection-card-body {
    padding: 8px 12px 12px 12px;
    color: #1f2937;
    font-size: 13px;
}

/* Tooltip version of current selection (hover over chat area) */
.selection-tooltip {
    position: absolute;
    top: -10px;
    right: 0;
    background: rgba(17,24,39,0.88); /* dark gray */
    color: #fff;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px; /* smaller font */
    line-height: 1.2;
    white-space: nowrap; /* single line */
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none; /* only show on hover */
    pointer-events: none; /* avoid blocking interactions */
    z-index: 20;
}
.chat-container:hover .selection-tooltip {
    display: block;
}

/* Chat Tab Styles */
.chat-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--color-bg-secondary);
}

.message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    max-width: min(75%, 65ch);
    line-height: 1.45;
    animation: slideIn 0.3s ease-out;
}

.message.user {
    /* Fallback background for old structure without .message-bubble */
    background: #f0ebfa;
    color: #1f2937;
    margin-left: auto;
    max-width: min(70%, 60ch);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    text-align: left;
    padding: 10px 14px;
    border-radius: 14px;
}

/* Remove background/padding from container when using new bubble structure */
.message.user:has(.message-bubble) {
    background: none;
    padding: 0;
}

.message.assistant {
    background: transparent;
    border: none;
    padding: 10px 14px;
}

/* Remove background/padding from container when using new bubble structure */
.message.assistant:has(.message-bubble) {
    background: none;
    border: none;
    padding: 0;
}

.message.system {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    text-align: center;
    max-width: 100%;
    font-size: 12px;
}

.chat-input-container {
    display: flex;
    gap: 8px;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.chat-input:focus {
    border-color: #6D55D6;
}

.send-button {
    padding: 10px 20px;
    background: #6D55D6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.send-button:hover {
    background: #5D46BF;
}

.send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Automation Tab Styles */
.automation-section {
    margin-bottom: 16px;
}

.automation-section h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #374151;
}

.automation-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.automation-btn {
    padding: 10px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 12px;
}

.automation-btn:hover {
    background: #f3f4f6;
    border-color: #6D55D6;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.automation-btn.primary {
    background: #6D55D6;
    color: white;
    border-color: #6D55D6;
}

.automation-btn.primary:hover {
    background: #5D46BF;
}

/* Trainer Tab Styles */
.trainer-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.trainer-section h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.trainer-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.trainer-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
}

.trainer-button {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
}

.trainer-button.start {
    background: #10b981;
    color: white;
}

.trainer-button.stop {
    background: #ef4444;
    color: white;
}

.trainer-button.test {
    background: #6D55D6;
    color: white;
}

.trainer-button.save {
    background: #6D55D6;
    color: white;
}

.trainer-button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.trainer-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.trainer-status {
    padding: 12px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 12px;
}

.trainer-result {
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    margin-top: 12px;
}

.recording-indicator {
    background: #fee2e2;
    border: 2px solid #ef4444;
    color: #dc2626;
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-weight: bold;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% { opacity: 0.5; }
}

.actions-list {
    max-height: 200px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 12px;
    font-family: monospace;
    font-size: 11px;
}

.action-item {
    padding: 4px 0;
    border-bottom: 1px solid #e5e7eb;
}

.skills-list {
    max-height: 300px;
    overflow-y: auto;
}

/* Settings Tab Styles */
.settings-group {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.settings-group h3 {
    font-size: 16px;
    margin-bottom: 16px;
    color: #374151;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 14px;
    color: #4b5563;
}

.setting-value {
    font-size: 14px;
    color: #111827;
    font-weight: 500;
}

.log-container {
    background: #1f2937;
    color: #d1d5db;
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    max-height: 200px;
    overflow-y: auto;
}

.log-entry {
    margin-bottom: 4px;
}

.log-time {
    color: #6b7280;
    margin-right: 8px;
}

/* Office Dialog Styles */
.office-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 300px;
    max-width: 500px;
    padding: 20px;
}

.office-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.office-dialog h3 {
    margin-bottom: 16px;
    color: #374151;
}

.office-dialog input {
    width: 100%;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    margin-bottom: 16px;
}

.office-dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.office-dialog-button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.office-dialog-button.primary {
    background: #6D55D6;
    color: white;
}

.office-dialog-button.secondary {
    background: #e5e7eb;
    color: #374151;
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Markdown rendering styles inside messages */
.message h1, .message h2, .message h3, .message h4, .message h5, .message h6 {
    margin: 8px 0 6px 0;
}
.message p { margin: 6px 0; }
.message ul, .message ol { margin: 6px 0 6px 18px; }
.message pre.md-code {
    background: #0b1020;
    color: #f3f4f6;
    padding: 10px;
    border-radius: 6px;
    overflow: auto;
}
.message code.md-inline {
    background: #eef2ff;
    color: #111827;
    padding: 1px 4px;
    border-radius: 4px;
}
 .message a { color: #6D55D6; text-decoration: underline; }
 .message hr { border: 0; border-top: 1px solid #e5e7eb; margin: 10px 0; }

/* Responsive width for small screens */
@media (max-width: 640px) {
    .message,
    .message.user,
    .message.assistant {
        max-width: 90%;
    }
}

/* ========================================
   MODERN CHAT UI ENHANCEMENTS
   ======================================== */

/* Modern Input Container */
.chat-input-wrapper {
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 8px 10px;
    transition: all 0.2s ease;
}

.input-container:focus-within {
    border-color: #6D55D6;
    background: white;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.chat-input-modern {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 13px;
    font-family: inherit;
    color: #1f2937;
    outline: none;
    min-height: 20px;
    max-height: 100px;
    line-height: 1.4;
    overflow-y: auto;
}

.chat-input-modern::placeholder {
    color: #9ca3af;
}

.input-actions {
    display: flex;
    align-items: center;
}

/* .send-btn-modern — see .chat-input-fixed .send-btn-modern below */

/* Modern Chat Bubbles */
.message {
    display: flex;
    gap: 8px;
    margin: 10px 0;
    animation: slideInMessage 0.3s ease-out;
    align-items: flex-start;
    font-size: 13px;
}

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

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

.message-avatar {
    display: none;
}

.avatar-circle {
    width: 100%;
    height: 100%;
    background: #6D55D6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 11px;
    font-weight: 600;
}

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

.message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message.user .message-content {
    align-items: flex-end;
}

.message-bubble {
    padding: 8px 12px;
    border-radius: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: #E9E7F8;
    color: #1f2937;
    border-radius: 14px 14px 2px 14px;
}

.message.assistant .message-bubble {
    background: transparent;
    color: #1f2937;
    border: none;
    border-radius: 0;
}

/* Phase 6: File Attachments in Messages */
.message-files {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message.user .message-files {
    border-top-color: rgba(109, 85, 214, 0.15);
}

.message.assistant .message-files {
    border-top-color: #e5e7eb;
}

.message-file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    font-size: 11px;
}

.message.user .message-file-item {
    background: rgba(109, 85, 214, 0.08);
}

.message.assistant .message-file-item {
    background: #f3f4f6;
}

.message-file-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    opacity: 0.8;
}

.message-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 150px;
}

.message-file-size {
    opacity: 0.7;
    flex-shrink: 0;
}

/* Markdown Formatting Styles */
.message-bubble strong {
    font-weight: 600;
    color: inherit;
}

.message-bubble em {
    font-style: italic;
    color: inherit;
}

.message-bubble code.md-inline {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #d63384;
}

.message.user .message-bubble code.md-inline {
    background: rgba(109, 85, 214, 0.1);
    color: #6D55D6;
}

.message-bubble pre.md-code {
    background: #f6f8fa;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    margin: 8px 0;
}

.message.user .message-bubble pre.md-code {
    background: rgba(109, 85, 214, 0.06);
    border-color: rgba(109, 85, 214, 0.15);
}

.message-bubble pre.md-code code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85em;
    line-height: 1.5;
    color: #1f2937;
}

.message.user .message-bubble pre.md-code code {
    color: #1f2937;
}

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

.message-bubble li {
    margin: 4px 0;
    line-height: 1.6;
}

.message-bubble h1, .message-bubble h2, .message-bubble h3,
.message-bubble h4, .message-bubble h5, .message-bubble h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-bubble h1 { font-size: 1.5em; }
.message-bubble h2 { font-size: 1.3em; }
.message-bubble h3 { font-size: 1.15em; }
.message-bubble h4 { font-size: 1.05em; }
.message-bubble h5 { font-size: 1em; }
.message-bubble h6 { font-size: 0.95em; }

.message-bubble p {
    margin: 8px 0;
    line-height: 1.6;
}

.message-bubble p:first-child {
    margin-top: 0;
}

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

.message-bubble hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 12px 0;
}

.message.user .message-bubble hr {
    border-top-color: rgba(109, 85, 214, 0.15);
}

.message-bubble a {
    color: #6D55D6;
    text-decoration: underline;
}

.message.user .message-bubble a {
    color: #6D55D6;
    text-decoration: underline;
}

.message-bubble a:hover {
    opacity: 0.8;
}

.message-timestamp,
.message-time {
    font-size: 10px;
    color: #9ca3af;
    padding: 0 4px;
    margin-top: 4px;
}

/* Specific styles for user and AI timestamps */
.message.user .message-timestamp {
    text-align: right;
}

.message.assistant .message-timestamp {
    text-align: left;
}

.message-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

.action-btn {
    padding: 6px;
    background: transparent;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #f3f4f6;
    border-color: #6D55D6;
    color: #6D55D6;
}

.action-btn svg {
    width: 14px;
    height: 14px;
}

/* ===========================================
   ENHANCED THINKING INDICATOR
   Phase 26.8.2: Compact, professional status display
   =========================================== */

.thinking-indicator {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    margin: 8px 0;
    background: transparent;
    border-radius: 12px;
    border: none;
    animation: thinking-enter 0.25s ease-out;
    position: relative;
    overflow: hidden;
}

/* Phase 6: Thinking header row */
.thinking-header {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

/* Phase 6: Thinking stages row */
.thinking-stages {
    display: flex;
    gap: 4px;
    position: relative;
    z-index: 1;
}

.thinking-stage {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.03);
    font-size: 11px;
    color: #94a3b8;
    transition: all 0.3s ease;
}

.thinking-stage .stage-icon {
    font-size: 12px;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.thinking-stage .stage-label {
    font-weight: 500;
}

.thinking-stage.active {
    background: rgba(112, 85, 226, 0.12);
    color: #6D55D6;
}

.thinking-stage.active .stage-icon {
    opacity: 1;
    animation: stage-pulse 1.5s infinite;
}

.thinking-stage.completed {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.thinking-stage.completed .stage-icon {
    opacity: 1;
}

@keyframes stage-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* Shimmer overlay removed — thinking indicator now blends with chat background */
.thinking-indicator::before {
    display: none;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

@keyframes thinking-enter {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Enhanced thinking dots with wave animation */
.thinking-dots {
    display: flex;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.thinking-dots .dot {
    width: 5px;
    height: 5px;
    background: #6D55D6;
    border-radius: 50%;
    animation: dot-wave 1.4s infinite ease-in-out;
    will-change: transform, opacity;
}

.thinking-dots .dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes dot-wave {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px) scale(1.1);
        opacity: 1;
    }
}

/* Enhanced thinking text with smooth transition */
.thinking-text {
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s ease, transform 0.2s ease;
    position: relative;
    z-index: 1;
    flex: 1;
}

/* Thinking text fade animation for state changes */
.thinking-text.fade {
    opacity: 0;
    transform: translateX(-4px);
}

/* Phase 26.8.2: Thinking timer - compact */
.thinking-timer {
    font-size: 11px;
    color: #94a3b8;
    font-variant-numeric: tabular-nums;
    min-width: 24px;
    text-align: right;
    margin-left: auto;
    position: relative;
    z-index: 1;
}

/* Phase 26.4: Transformation animation when converting to message */
.thinking-indicator.transforming {
    animation: thinking-transform 0.15s ease-out forwards;
}

@keyframes thinking-transform {
    to {
        opacity: 0;
        transform: scale(0.98) translateY(-4px);
    }
}

/* Progress bar under thinking indicator (optional) */
.thinking-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, #6D55D6, #6D55D6, #6D55D6);
    border-radius: 0 0 16px 16px;
    animation: progress-pulse 2s ease-in-out infinite;
    width: 30%;
}

@keyframes progress-pulse {
    0%, 100% {
        width: 20%;
        opacity: 0.5;
    }
    50% {
        width: 80%;
        opacity: 1;
    }
}

/* Streaming Text Container - CRITICAL for visibility */
.message-text {
    display: inline !important;
    opacity: 1 !important;
    visibility: visible !important;
    color: inherit;
    font-size: inherit;
    line-height: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ===========================================
   60 FPS STREAMING ANIMATIONS
   Phase 4: UI Polish - GPU-accelerated animations
   =========================================== */

/* Streaming Cursor - GPU-accelerated blink */
.message.streaming .cursor-blink {
    display: inline-block;
    width: 2px;
    height: 18px;
    background: #6D55D6;
    margin-left: 2px;
    vertical-align: middle;
    /* Use transform for GPU acceleration */
    animation: cursor-blink 1s ease-in-out infinite;
    will-change: opacity;
}

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

/* Cursor fade-out animation when streaming completes */
.cursor-blink.fade-out {
    animation: cursor-fade 0.2s ease-out forwards;
}

@keyframes cursor-fade {
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* Hide cursor when streaming is complete */
.message:not(.streaming) .cursor-blink {
    display: none;
}

/* Message actions slide-in animation */
.message-actions.slide-in {
    animation: slide-in-actions 0.3s ease-out forwards;
}

@keyframes slide-in-actions {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth text container for streaming */
.message.streaming .message-text {
    /* Optimize for text rendering during streaming */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Message bubble entrance animation */
.message {
    animation: message-enter 0.3s ease-out forwards;
    will-change: opacity, transform;
}

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

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1f2937;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 10000;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Smooth Scrolling */
.chat-messages {
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* =========================================
   NEW LAYOUT STYLES - Fixed Input & Scrollable Chat
   ========================================= */

/* Simple Header */
.header-simple {
    background: linear-gradient(120deg, var(--color-gradient-start), var(--color-gradient-end));
    color: white;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.header-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.header-title h1 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.02em;
}

.brand-logo-header .brand-logo-mark {
    width: 16px;
    height: 16px;
}

.header-title h1 #app-version {
    font-weight: 600;
}

.header-title .status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    opacity: 0.9;
}

/* ============================================
   Header Action Icons (Phase 1 UI Upgrade)
   ============================================ */

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 4px;
}

.header-icon-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.2s;
}

.header-icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.header-icon-btn:active {
    transform: scale(0.95);
}

.header-icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Chat Toolbar (new chat + history buttons) — floating */
.chat-toolbar {
    position: absolute;
    top: 4px;
    right: 8px;
    z-index: 10;
    display: flex;
    gap: 6px;
}

.chat-toolbar-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(109, 85, 214, 0.1);
    color: #6D55D6;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.chat-toolbar-btn:hover {
    background: rgba(109, 85, 214, 0.2);
    transform: scale(1.05);
}

.chat-toolbar-btn:active {
    transform: scale(0.95);
}

.chat-toolbar-btn svg {
    width: 16px;
    height: 16px;
}

/* Legacy welcome text (hidden) */
.welcome-text-container { display: none; }

/* ── Welcome Screen ── */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px 16px;
    overflow-y: auto;
    background: #ffffff;
}

.welcome-header {
    text-align: center;
    margin-bottom: 24px;
}

.welcome-greeting {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #6D55D6 0%, #a78bfa 35%, #c4b5fd 50%, #a78bfa 65%, #6D55D6 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: welcome-gradient-shine 6s ease-in-out infinite;
}

@keyframes welcome-gradient-shine {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

.welcome-subtitle {
    font-size: 17px;
    font-weight: 500;
    color: #374151;
    line-height: 1.4;
    min-height: 1.4em;
}

/* Typewriter blinking cursor */
.welcome-subtitle::after {
    content: '|';
    font-weight: 300;
    color: #6D55D6;
    animation: welcome-cursor-blink 0.8s ease-in-out infinite;
    margin-left: 1px;
}

@keyframes welcome-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ── Prompt Cards Grid ── */
.welcome-prompts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: calc(100% - 32px);
    margin: 0 16px;
}

.welcome-prompt-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.04);
}

.welcome-prompt-card:hover {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.1), 0 0 1px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

.welcome-prompt-card:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0, 0, 0, 0.04);
}

.welcome-prompt-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: #6D55D6;
    margin-top: 1px;
}

.welcome-prompt-icon svg {
    display: block;
}

.welcome-prompt-text {
    flex: 1;
    min-width: 0;
}

.welcome-prompt-title {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
    line-height: 1.3;
}

.welcome-prompt-desc {
    font-size: 11px;
    color: #9ca3af;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* New Content Layout */
.content-new {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 36px); /* Full height minus tabs (36px), header removed */
    overflow: hidden;
    background: var(--color-bg-primary);
}

.content-new #chat-tab.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: var(--color-bg-primary);
}

/* Scrollable Chat Messages Area */
.chat-messages-scrollable {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background: var(--color-bg-primary);
    scroll-behavior: smooth;
}

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

.chat-messages-scrollable::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-scrollable::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.chat-messages-scrollable::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Fixed Input at Bottom */
.chat-input-fixed {
    flex-shrink: 0;
    padding: 8px 12px 2px 12px;
    background: #f5f0ff;
    border-top: none;
    border-radius: 18px 18px 0 0;
    position: relative;
}

/* ═══════════════════════════════════════════════════════════════════════════
   DAILY CREDITS COUNTER - Production Only
   Shows credits used/remaining above the chat input
   ═══════════════════════════════════════════════════════════════════════════ */

.credits-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    margin-bottom: 10px;
    font-size: 12px;
    color: #6b7280;
    background: #f9fafb;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.credits-counter .credits-text {
    display: flex;
    align-items: center;
    gap: 2px;
}

.credits-counter #credits-used,
.credits-counter #credits-limit {
    font-weight: 600;
    color: #374151;
}

.credits-counter .credits-link {
    color: #6D55D6;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.credits-counter .credits-link:hover {
    color: #5a45c0;
}

/* Low credits warning (5 or fewer remaining) */
.credits-counter.credits-low {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.credits-counter.credits-low .credits-text {
    color: #92400e;
}

.credits-counter.credits-low #credits-used,
.credits-counter.credits-low #credits-limit {
    color: #b45309;
}

/* Credits exhausted (0 remaining) */
.credits-counter.credits-exhausted {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.credits-counter.credits-exhausted .credits-text {
    color: #991b1b;
}

.credits-counter.credits-exhausted #credits-used,
.credits-counter.credits-exhausted #credits-limit {
    color: #dc2626;
}

/* Credits exhausted message in chat */
.credits-exhausted-message {
    background: #fef2f2 !important;
    border: 1px solid #fecaca !important;
    border-radius: 12px;
    margin: 16px 0;
}

.credits-exhausted-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 4px;
}

.credits-exhausted-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    border-radius: 50%;
    color: #dc2626;
}

.credits-exhausted-text {
    flex: 1;
}

.credits-exhausted-text strong {
    display: block;
    color: #991b1b;
    font-size: 14px;
    margin-bottom: 4px;
}

.credits-exhausted-text p {
    color: #7f1d1d;
    font-size: 13px;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.credits-exhausted-text .credits-learn-more {
    color: #6D55D6;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}

.credits-exhausted-text .credits-learn-more:hover {
    color: #5a45c0;
}

/* Highlight effect for credits section in How it works */
.credits-section-highlight {
    animation: creditsSectionPulse 0.5s ease-in-out 3;
}

@keyframes creditsSectionPulse {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(112, 85, 226, 0.15);
    }
}

.chat-input-fixed .input-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    max-width: 100%;
    border: none;
    border-radius: 14px;
    padding: 8px 8px 4px 10px;
    background: #ffffff;
    transition: box-shadow 0.2s ease;
    gap: 0;
}

.chat-input-fixed .input-container:focus-within {
    box-shadow: 0 0 0 2px rgba(109, 85, 214, 0.12);
}

/* Top row: textarea + send button side by side */
.input-top-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.chat-input-fixed .chat-input-modern {
    flex: 1;
    min-height: 28px;
    max-height: 120px;
    padding: 4px 0;
    border: none;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: transparent;
    color: #1f2937;
}

.chat-input-fixed .chat-input-modern::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* Hide textarea scrollbar */
.chat-input-fixed .chat-input-modern::-webkit-scrollbar {
    width: 0;
    display: none;
}

.chat-input-fixed .chat-input-modern {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-input-fixed .send-btn-modern {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: #1B1935;
    color: #ffffff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-input-fixed .send-btn-modern svg path,
.chat-input-fixed .send-btn-modern svg line,
.chat-input-fixed .send-btn-modern svg polyline {
    stroke: #ffffff;
}

.chat-input-fixed .send-btn-modern:hover:not(:disabled) {
    background: #2a2650;
}

.chat-input-fixed .send-btn-modern:active:not(:disabled) {
    transform: scale(0.93);
}

.chat-input-fixed .send-btn-modern:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Stop mode: solid purple bg, swap icons via CSS */
.send-btn-modern.is-stop {
    background: #1B1935 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}
.send-btn-modern.is-stop .send-icon {
    display: none !important;
}
.send-btn-modern.is-stop .stop-icon {
    display: block !important;
    color: white;
}
.send-btn-modern .stop-icon {
    display: none !important;
    fill: white;
}
.send-btn-modern .send-icon {
    display: block !important;
}

/* ── Bottom actions row: attach + edit-mode (left), file pills (right) ── */
.input-bottom-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0;
    gap: 4px;
}

.input-actions-left {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    margin-right: auto;
}

/* ── Edit Mode Button ── */
.edit-mode-wrapper {
    position: relative;
}

.edit-mode-btn {
    width: 34px;
    height: 34px;
    background: transparent;
    color: #9ca3af;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.edit-mode-btn:hover {
    background: #f3f4f6;
    color: #6D55D6;
}

.edit-mode-btn.active {
    color: #6D55D6;
}

/* ── Edit Mode Popover ── */
.edit-mode-popover {
    position: absolute;
    bottom: 38px;
    left: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 6px;
    min-width: 190px;
    z-index: 200;
    animation: popoverFadeIn 0.15s ease;
}

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

.popover-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    font-family: 'Inter', -apple-system, sans-serif;
    transition: background 0.15s ease;
}

.popover-option:hover {
    background: #f3f4f6;
}

.popover-option.active {
    color: #6D55D6;
}

.popover-label {
    flex: 1;
}

.popover-check {
    flex-shrink: 0;
}

/* ── Inline File Preview Pills ── */
.file-preview-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
    scrollbar-width: none;
}

.file-preview-inline::-webkit-scrollbar {
    display: none;
}

.file-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    color: #166534;
    font-family: 'Inter', -apple-system, sans-serif;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 140px;
}

.file-pill .pill-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-pill .pill-remove {
    width: 14px;
    height: 14px;
    padding: 0;
    border: none;
    background: none;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
    flex-shrink: 0;
    line-height: 1;
    font-size: 13px;
}

.file-pill .pill-remove:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* ── Drag & Drop Overlay ── */
.drag-overlay {
    position: absolute;
    inset: 0;
    background: rgba(109, 85, 214, 0.08);
    border: 2px dashed #6D55D6;
    border-radius: 12px;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.drag-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #6D55D6;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', -apple-system, sans-serif;
}

/* Generation status moved to professional-chat.css (inline in chat area) */

.saved-workflows-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #6D55D6;
    font-family: 'Inter', -apple-system, sans-serif;
    padding: 4px 2px;
    border-radius: 6px;
    transition: color 0.15s ease;
}

.saved-workflows-btn:hover {
    color: #5b45c0;
}

/* Phase 6: File Attachment Button */
.attach-btn-modern {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    background: transparent;
    color: #6b7280;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-right: 4px;
}

.attach-btn-modern:hover {
    background: #f3f4f6;
    color: #6D55D6;
}

.attach-btn-modern:active {
    transform: scale(0.95);
}

.attach-btn-modern.has-files {
    color: #6D55D6;
    background: rgba(127, 101, 235, 0.1);
}

/* Phase 6: File Preview (legacy - kept for backward compat) */
.file-preview-container {
    display: none !important;
}

/* Undo Button - Inline (after execution results) */
.undo-btn-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.undo-btn-inline:hover {
    background: #e5e7eb;
    color: #374151;
    border-color: #d1d5db;
}

.undo-btn-inline:active {
    transform: scale(0.95);
}

.undo-btn-inline.undo-success {
    background: #dcfce7;
    color: #16a34a;
    border-color: #86efac;
}

.undo-btn-inline.undo-warning {
    background: #fef3c7;
    color: #d97706;
    border-color: #fcd34d;
}

.undo-btn-inline svg {
    flex-shrink: 0;
}

/* Override old chat-messages padding since it's now inside scrollable container */
.chat-messages-scrollable .chat-messages {
    padding: 0;
    max-height: none;
    overflow: visible;
}

/* Automation, Audit, and Settings tabs: display content at top with scrolling */
#automation-tab.active,
#history-tab.active,
#settings-tab.active {
    overflow-y: auto;
    padding: 10px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #faf9fc 0%, #f8f6fc 40%, #f2edfa 70%, #eee8f8 85%, #EAE4F7 100%);
}

/* Ensure automation and settings sections start from top */
#automation-tab .automation-section,
#settings-tab .settings-group {
    margin: 0;
}

/* === SCROLL TO BOTTOM BUTTON === */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    padding: 10px 16px;
    background: #6D55D6;
    color: white;
    border: none;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
}

.scroll-to-bottom-btn.show {
    opacity: 1;
    transform: translateY(0);
    display: flex;
}

.scroll-to-bottom-btn:hover {
    background: #5D46BF;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

.scroll-to-bottom-btn:active {
    transform: translateY(0);
}

/* Make chat-messages-scrollable container relative for absolute positioning */
.chat-messages-scrollable {
    position: relative;
}

/* === MARKDOWN RENDERING STYLES === */

/* Tables */
.md-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 4px 0;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    display: block;
}

.md-table thead {
    background: #6D55D6;
    color: white;
}

.md-table th {
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #5D46BF;
    white-space: nowrap;
}

.md-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.15s;
}

.md-table tbody tr:last-child {
    border-bottom: none;
}

.md-table tbody tr:hover {
    background-color: #f9fafb;
}

.md-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.md-table td {
    padding: 5px 8px;
    color: #374151;
    font-size: 11px;
}

/* Highlight numeric values in tables */
.md-table td:has(strong) {
    font-weight: 600;
}

/* Dividers */
.md-divider {
    border: none;
    border-top: 2px solid #e5e7eb;
    margin: 20px 0;
}

/* Headings */
.md-h1, .md-h2, .md-h3, .md-h4, .md-h5, .md-h6 {
    margin-top: 16px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #111827;
}

.message-text > .md-h3:first-child,
.message-text > p:first-child > .md-h3:first-child {
    margin-top: 4px;
}

.md-h1 { font-size: 24px; }
.md-h2 { font-size: 20px; }
.md-h3 { font-size: 18px; }
.md-h4 { font-size: 16px; }
.md-h5 { font-size: 14px; }
.md-h6 { font-size: 13px; }

/* Code blocks */
.md-code {
    background: #1f2937;
    color: #e5e7eb;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    margin: 12px 0;
}

.md-inline {
    background: #f3f4f6;
    color: #ef4444;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* Message text content */
.message-text p {
    margin: 6px 0;
    line-height: 1.6;
}

.message-text p:first-child {
    margin-top: 0;
}

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

.message-text strong {
    color: #111827;
}

/* Cell References - Clickable links to Excel cells */
.cell-ref {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    color: #0369a1;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Segoe UI Semibold', 'SF Pro Text', -apple-system, sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid #7dd3fc;
    display: inline-block;
    vertical-align: baseline;
    line-height: inherit;
    text-decoration: none;
}

.cell-ref:hover {
    background: linear-gradient(135deg, #7dd3fc, #38bdf8);
    color: #0c4a6e;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.3);
}

.cell-ref:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Lists - Enhanced styling */
.md-list {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
}

.md-list li {
    margin: 8px 0;
    line-height: 1.6;
    padding-left: 24px;
    position: relative;
}

.md-list li::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 10px;
    width: 6px;
    height: 6px;
    background: var(--color-primary, #6D55D6);
    border-radius: 50%;
}

ol.md-list {
    counter-reset: list-counter;
}

ol.md-list li {
    counter-increment: list-counter;
}

ol.md-list li::before {
    content: counter(list-counter);
    width: auto;
    height: auto;
    background: var(--color-primary, #6D55D6);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    top: 4px;
    left: 0;
}

/* Ensure tables are responsive */
@media (max-width: 768px) {
    .md-table {
        font-size: 12px;
    }
    
    .md-table th,
    .md-table td {
        padding: 8px 12px;
    }
}

/* === CHANGE PROPOSAL BUTTONS === */

.approval-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
    border: none !important;
    padding: 6px 12px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    border-radius: 6px !important;
}

.approval-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.reject-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: white !important;
    border: none !important;
    padding: 6px 12px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    border-radius: 6px !important;
}

.reject-btn:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.approval-btn svg,
.reject-btn svg {
    stroke-width: 2px;
}

/* === TABLE CONTAINER & ACTIONS === */

.md-table-container {
    max-height: 300px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    margin: 8px 0;
}

.table-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 16px;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* === ADD TO SHEET BUTTON === */

.add-to-sheet-btn {
    background: #6D55D6 !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    transition: all 0.2s ease !important;
    line-height: 1 !important;
    height: auto !important;
    min-height: unset !important;
    white-space: nowrap !important;
    width: auto !important;
    max-width: fit-content !important;
    flex-shrink: 0 !important;
    box-shadow: 0 2px 8px rgba(112, 85, 226, 0.25) !important;
}

.add-to-sheet-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #5D46BF 0%, #6D55D6 100%) !important;
    transform: translateY(-2px) scale(1.02) !important;
    box-shadow: 0 6px 20px rgba(112, 85, 226, 0.4) !important;
}

.add-to-sheet-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.98) !important;
    box-shadow: 0 2px 8px rgba(112, 85, 226, 0.3) !important;
}

.add-to-sheet-btn:disabled {
    background: linear-gradient(135deg, #4CAF50, #45a049) !important;
    cursor: not-allowed !important;
    opacity: 1 !important;
}

.add-to-sheet-btn svg {
    width: 16px !important;
    height: 16px !important;
    flex-shrink: 0 !important;
    display: inline-block !important;
}

.add-to-sheet-btn span {
    display: inline-block !important;
    line-height: 1 !important;
}

/* === REMOVE FROM SHEET BUTTON === */

.remove-from-sheet-btn {
    background: #f44336 !important;
    color: white !important;
    border: none !important;
    padding: 6px 12px !important;
    font-weight: 600 !important;
    font-size: 11px !important;
    border-radius: 5px !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    transition: all 0.2s ease !important;
    line-height: 1 !important;
    height: auto !important;
    min-height: unset !important;
    white-space: nowrap !important;
    max-width: fit-content !important;
}

.remove-from-sheet-btn:hover {
    background: #d32f2f !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.remove-from-sheet-btn svg {
    width: 14px !important;
    height: 14px !important;
    flex-shrink: 0 !important;
    display: inline-block !important;
}

.remove-from-sheet-btn span {
    display: inline-block !important;
    line-height: 1 !important;
}

/* === FORMULA PROPOSAL UI === */

.formula-display {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    font-family: 'Courier New', Consolas, Monaco, monospace;
    overflow-x: auto;
    overflow-y: auto;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.formula-display code {
    color: #d73a49;
    font-size: 13px;
    font-weight: 600;
}

.formula-details {
    margin: 12px 0;
    padding: 12px;
    background: #f8f9fa;
    border-left: 3px solid #6D55D6;
    border-radius: 4px;
}

.formula-details p {
    margin: 6px 0;
    font-size: 12px;
    line-height: 1.5;
}

.formula-details strong {
    color: #374151;
    font-weight: 600;
}

.formula-details code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #6D55D6;
}

.formula-explanation {
    margin: 12px 0;
    padding: 10px;
    background: #eef2ff;
    border-radius: 6px;
    font-size: 12px;
    color: #4b5563;
    line-height: 1.6;
}

.confidence-high {
    color: #059669 !important;
}

.confidence-medium {
    color: #f59e0b !important;
}

.confidence-low {
    color: #ef4444 !important;
}

/* ===================================== */
/* MODEL BUILDER CONFIRMATION MODAL */
/* ===================================== */

.model-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.confirmation-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    padding: 0;
    animation: slideUp 0.3s ease;
}

.confirmation-header {
    background: #6D55D6;
    color: white;
    padding: 20px 24px;
    border-radius: 12px 12px 0 0;
}

.confirmation-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.confirmation-body {
    padding: 24px;
    color: #374151;
    line-height: 1.6;
    white-space: pre-wrap;
}

.confirmation-actions {
    padding: 16px 24px 24px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #6D55D6;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(112, 85, 226, 0.4);
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
}

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

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

/* ---------- Auth overlay ---------- */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, #f0eff2 0%, #eae8f0 40%, #d8d2f0 75%, #cfc6ee 100%);
    display: flex;
    align-items: stretch;
    justify-content: center;
    z-index: 9999;
    overflow-y: auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.auth-card {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-y: auto;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    color: var(--color-text-primary);
}

/* Minimalistic scrollbar for auth card */
.auth-card::-webkit-scrollbar {
    width: 4px;
}

.auth-card::-webkit-scrollbar-track {
    background: transparent;
}

.auth-card::-webkit-scrollbar-thumb {
    background: rgba(112, 85, 226, 0.3);
    border-radius: 2px;
}

.auth-card::-webkit-scrollbar-thumb:hover {
    background: rgba(112, 85, 226, 0.5);
}

/* Auth view switching */
#login-view {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}
#signup-view {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.auth-view.hidden {
    display: none;
}

/* Hero area for login — large centered brand, 40% height */
.auth-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 12px 60px;
}

.auth-hero-brand {
    font-family: 'Aileron', 'Outfit', 'Inter', sans-serif;
    font-size: 56px;
    font-weight: 700;
    letter-spacing: -0.03em;
    background: linear-gradient(90deg, #a855f7, #7c6be6, #6d5fd6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    user-select: none;
}
.auth-hero-tagline {
    font-size: 13px;
    color: #6b6b6b;
    text-align: center;
    margin: 8px 0 0;
    padding: 0 4px;
    line-height: 1.5;
}
@keyframes gradient-shift {
    0%   { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

/* Body area below hero (login) or at top (signup) */
.auth-body {
    padding: 0 18px 16px;
}

.auth-heading {
    font-size: 22px;
    font-weight: 700;
    color: #1D1836;
    margin: 0 0 4px;
    text-align: left;
}

.auth-heading-signup {
    text-align: center;
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 52px;
    padding-top: 56px;
}
.auth-brand-gradient {
    background: linear-gradient(90deg, #a855f7, #7c6be6, #6d5fd6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.auth-subheading {
    font-size: 14px;
    color: #9ca3af;
    margin: 0 0 20px;
    text-align: left;
    line-height: 1.4;
}

/* Profile completion modal — override the full-page auth overlay */
#profile-completion-overlay.auth-overlay {
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}

#profile-completion-overlay .pc-card {
    min-height: auto;
    overflow: hidden;
}

.auth-heading-pc {
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 4px;
    padding-top: 24px;
}

.pc-subtitle {
    text-align: center;
    color: #9891B4;
    font-size: 13px;
    margin: 0 0 28px;
    line-height: 1.5;
}

.auth-skip-link {
    background: none;
    border: none;
    color: #6D55D6;
    cursor: pointer;
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
    font-weight: 500;
    transition: color 0.15s ease;
}
.auth-skip-link:hover {
    color: #5D41DE;
}

[data-theme="dark"] #profile-completion-overlay .pc-card {
    background: #1f1f35;
}

/* Keep old .auth-logo and .auth-info-text for profile-completion modal */
.auth-logo {
    text-align: center;
    margin-bottom: 16px;
}

.auth-logo-text {
    font-size: 32px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.brand-logo-auth {
    justify-content: center;
    gap: 10px;
}

.brand-logo-auth .brand-logo-mark {
    width: 28px;
    height: 28px;
}

.brand-logo-auth .brand-logo-text {
    background: linear-gradient(90deg, #a855f7, #7c5cd6, #4f7de5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-info-text {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 14px;
    margin: 0 0 24px;
    line-height: 1.5;
}

.auth-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}

.auth-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0 0 4px;
}

.auth-subtext {
    margin: 4px 0 0;
    color: var(--color-text-secondary);
    font-size: 14px;
}

.auth-toggle {
    display: none;
    background: #f3f4f6;
    border: none;
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
    margin: 0 0 18px;
    width: 100%;
}

.auth-toggle-btn {
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    padding: 8px 14px;
    white-space: nowrap;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease, color 0.2s ease;
    flex: 1;
    text-align: center;
}

.auth-toggle-btn.active {
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(109, 85, 214, 0.28);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 0;
}

.auth-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--color-text-primary);
    font-size: 12px;
}

/* Phase 31.2: Side-by-side name fields for signup */
.auth-name-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.auth-label-half {
    flex: 1;
    min-width: 0;
}

.auth-input {
    background: #ffffff;
    border: 1px solid #e8e8ec;
    border-radius: 50px;
    padding: 10px 16px;
    color: var(--color-text-primary);
    font-size: 13px;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input:focus {
    outline: none;
    border-color: #7c6be6;
    box-shadow: none;
}

.auth-input::placeholder {
    color: #b0b0b8;
}

/* Input with left icon (login email/password) */
.auth-input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-with-icon .auth-input {
    padding-left: 48px;
}

.auth-field-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
}

.auth-input-with-icon .auth-input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
}

/* Hide browser's native password reveal buttons to avoid duplicate icons */
.auth-input::-ms-reveal,
.auth-input::-ms-clear,
.auth-input::-webkit-credentials-auto-fill-button,
.auth-input::-webkit-contacts-auto-fill-button {
    display: none !important;
    visibility: hidden;
    pointer-events: none;
}

/* Custom select dropdown (Company Size) */
.auth-select-wrap {
    position: relative;
}
.auth-select-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    text-align: left;
}
.auth-select-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.auth-select-label.placeholder {
    color: #b0b0b8;
}
.auth-select-arrow {
    flex-shrink: 0;
    color: #9ca3af;
    transition: transform 0.15s ease;
}
.auth-select-btn.open .auth-select-arrow {
    transform: rotate(180deg);
}
.auth-select-popover {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    padding: 4px;
    z-index: 100;
    animation: popoverFadeIn 0.15s ease;
}
.auth-select-option {
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    transition: background 0.15s ease;
}
.auth-select-option:hover {
    background: #f3f4f6;
}
.auth-select-option.active {
    color: #6D55D6;
}
[data-theme="dark"] .auth-select-popover {
    background: #24243d;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.06);
}
[data-theme="dark"] .auth-select-option {
    color: #f0f0f5;
}
[data-theme="dark"] .auth-select-option:hover {
    background: #2a2a45;
}

.auth-submit {
    margin-top: 6px;
    padding: 10px;
    background: #1D1836;
    color: #ffffff;
    white-space: nowrap;
    text-align: center;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.08s ease, transform 0.08s ease, box-shadow 0.08s ease;
}
.auth-submit {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
}
.auth-submit:hover {
    background: #6D55D6;
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(109, 85, 214, 0.32);
}
.auth-submit.loading {
    pointer-events: none;
    background: #6D55D6;
}

/* iOS-style spinner (8 blades, pure CSS) */
.auth-spinner {
    width: 18px;
    height: 18px;
    position: relative;
    animation: auth-spin 0.8s steps(8) infinite;
}
.auth-spinner .blade {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 5px;
    margin-left: -1px;
    background: #ffffff;
    border-radius: 1px;
    transform-origin: center 9px;
}
.auth-spinner .blade:nth-child(1) { transform: rotate(0deg);   opacity: 1; }
.auth-spinner .blade:nth-child(2) { transform: rotate(45deg);  opacity: 0.875; }
.auth-spinner .blade:nth-child(3) { transform: rotate(90deg);  opacity: 0.75; }
.auth-spinner .blade:nth-child(4) { transform: rotate(135deg); opacity: 0.625; }
.auth-spinner .blade:nth-child(5) { transform: rotate(180deg); opacity: 0.5; }
.auth-spinner .blade:nth-child(6) { transform: rotate(225deg); opacity: 0.375; }
.auth-spinner .blade:nth-child(7) { transform: rotate(270deg); opacity: 0.25; }
.auth-spinner .blade:nth-child(8) { transform: rotate(315deg); opacity: 0.125; }

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

.auth-privacy-text {
    text-align: center;
    font-size: 12px;
    color: var(--color-text-secondary);
    margin: 12px 0 0;
    line-height: 1.5;
}

.auth-privacy-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.auth-privacy-link:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.auth-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 11px;
    color: var(--color-text-secondary);
    line-height: 1.5;
    cursor: pointer;
    margin: 4px 0;
}

.auth-checkbox {
    margin-top: 2px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
    flex-shrink: 0;
}

.auth-checkbox-label span {
    flex: 1;
}

.auth-label-text {
    display: inline;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.auth-required {
    color: #ef4444;
    font-weight: 600;
    margin-left: 2px;
}

/* Auth Input Wrapper for password toggle */
.auth-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.auth-input-wrapper .auth-input {
    width: 100%;
    padding-right: 48px; /* Make room for the eye icon */
}

.auth-input-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
    user-select: none;
    z-index: 1;
}

.auth-input-icon svg {
    width: 14px;
    height: 14px;
}

.auth-input-icon {
    color: #c8c8d0;
}

.auth-input-icon:hover {
    color: #9090a0;
}

/* ===== Auth V2 - Clean Form Style ===== */
.auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-field-half {
    flex: 1;
    min-width: 0;
}

.auth-label-v2 {
    font-size: 13px;
    font-weight: 600;
    color: #151717;
}

.auth-inputForm {
    border: 1.5px solid #ecedec;
    border-radius: 10px;
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    transition: border-color 0.2s ease-in-out;
    position: relative;
}

.auth-inputForm:focus-within {
    border-color: #6D55D6;
}

.auth-input-v2 {
    border: none;
    outline: none;
    width: 100%;
    height: 100%;
    font-size: 14px;
    color: #151717;
    background: transparent;
    font-family: inherit;
}

.auth-input-v2::placeholder {
    color: #b0b0b0;
    font-family: inherit;
}

.auth-inputForm .auth-input-icon {
    position: static;
    transform: none;
    flex-shrink: 0;
}

.auth-submit-v2 {
    margin-top: 6px;
    padding: 12px;
    background: #6D55D6;
    color: white;
    font-size: 15px;
    font-weight: 500;
    border-radius: 10px;
    height: 44px;
    width: 100%;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: inherit;
}

.auth-submit-v2:hover {
    background: #5D41DE;
}

.auth-social {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 4px;
}


.auth-social-btn {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid #e5e5e5;
    background: #ffffff;
    color: #1D1836;
    border-radius: 50px;
    padding: 13px 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

.auth-social-btn:hover:not(:disabled) {
    border-color: #6D55D6;
    box-shadow: 0 4px 12px rgba(109, 85, 214, 0.10);
    transform: translateY(-1px);
}

.auth-social-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.auth-social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.auth-social-btn-label {
    line-height: 1;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 8px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e5e5;
}

.auth-divider span {
    color: #b0b0b8;
    font-size: 13px;
    text-transform: lowercase;
    letter-spacing: 0;
}

.auth-otp-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.auth-label-otp {
    flex: 1;
}

.auth-otp-send-btn {
    border: 1px solid #e8e8ec;
    color: #645bff;
    background: #ffffff;
    border-radius: 50px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    min-width: 110px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
}
.auth-otp-send-btn .arrow-wrapper {
    display: flex;
    align-items: center;
}
.auth-otp-send-btn .arrow {
    margin-top: 1px;
    width: 8px;
    background: #ffffff;
    height: 2px;
    position: relative;
    transition: 0.2s;
}
.auth-otp-send-btn .arrow::before {
    content: "";
    box-sizing: border-box;
    position: absolute;
    border: solid #645bff;
    border-width: 0 2px 2px 0;
    display: inline-block;
    top: -2px;
    right: 2px;
    transition: 0.2s;
    padding: 2px;
    transform: rotate(-45deg);
}
.auth-otp-send-btn:hover:not(:disabled) .arrow {
    background: #645bff;
}
.auth-otp-send-btn:hover:not(:disabled) .arrow::before {
    right: 0;
}

.auth-otp-send-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.auth-otp-hint {
    margin-top: -4px;
    margin-bottom: 2px;
    font-size: 10px;
    color: var(--color-text-muted);
    text-align: center;
    display: block;
}

.auth-switch-text {
    text-align: center;
    font-size: 14px;
    color: #1D1836;
    margin: 20px 0 0;
}

.auth-switch-link {
    background: none;
    border: none;
    color: #1D1836;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}

.auth-switch-link:hover {
    color: #6D55D6;
    text-decoration: underline;
}

.auth-forgot-row {
    display: flex;
    justify-content: flex-end;
    margin-top: -4px;
}

.auth-link-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.auth-link-btn:hover {
    text-decoration: underline;
}

.auth-forgot-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border: 1px solid #e5e5e5;
    border-radius: 24px;
    background: rgba(109, 85, 214, 0.03);
}

.auth-forgot-submit {
    margin-top: 0;
}

.auth-name-row {
    display: flex;
    gap: 10px;
}
.auth-company-row {
    display: flex;
    gap: 10px;
}

/* Password Strength Indicator */
.password-strength-segments {
    margin-top: 6px;
    display: flex;
    gap: 4px;
}
.pw-seg {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: #e0e0e4;
    transition: background 0.3s ease;
}
.pw-seg.active {
    background: #7c6be6;
}

.auth-message {
    min-height: 18px;
    color: var(--color-success-dark);
    font-size: 14px;
    margin-top: 4px;
    text-align: center;
}

.auth-message.error {
    color: var(--color-error-dark);
}

.auth-setting-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.hidden {
    display: none !important;
}

.auth-locked .content-new {
    filter: blur(2px);
    pointer-events: none;
    user-select: none;
}

/* ===========================================
   PHASE 7: Chat History Sidebar
   Like ChatGPT/Claude conversation sidebar
   =========================================== */

.chat-history-toggle {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: all 0.2s;
    z-index: 10;
}

.chat-history-toggle:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.chat-history-sidebar {
    position: fixed;
    top: 36px; /* Below tabs (36px), header removed */
    left: 0;
    width: 280px;
    height: calc(100vh - 36px);
    background: var(--color-bg-primary);
    border-right: 1px solid var(--color-border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    transform: translateX(0);
    transition: transform 0.3s ease;
}

.chat-history-sidebar.hidden {
    transform: translateX(-100%);
    display: flex !important;
    pointer-events: none;
    opacity: 0;
}

.chat-history-sidebar:not(.hidden) {
    pointer-events: auto;
    opacity: 1;
}

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

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

.close-sidebar-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

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

.chat-history-search {
    padding: 12px;
    border-bottom: 1px solid var(--color-border);
}

.chat-history-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-history-search input:focus {
    border-color: var(--color-primary);
}

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

.conversation-item {
    padding: 12px;
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: var(--color-bg-secondary);
}

.conversation-item.active {
    background: var(--color-primary-light);
    border-left: 3px solid var(--color-primary);
}

.conv-workbook {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.conv-workbook::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--color-success);
    border-radius: 50%;
}

.conv-preview {
    font-size: 12px;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.conv-date {
    font-size: 11px;
    color: var(--color-text-muted);
}

.conversation-loading,
.conversation-empty {
    padding: 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

.new-conversation-btn {
    margin: 8px;
    padding: 10px;
    background: linear-gradient(135deg, var(--color-gradient-start), var(--color-gradient-end));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.new-conversation-btn:hover {
    opacity: 0.9;
}

/* ===========================================
   Phase 10.16: Graceful Failure Handling UI
   Enhanced to match chat message styling
   =========================================== */

/* Clarification Prompt Styles - Matches chat bubble design */
.clarification-prompt {
    background: transparent;
    border: none;
    padding: 0;
    margin: 4px 0;
    line-height: 1.6;
}

.clarification-message {
    font-size: 14px;
    color: var(--color-text-primary);
    margin: 0 0 16px 0;
    font-weight: 400;
    line-height: 1.6;
}

.clarification-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.clarification-btn {
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--color-bg-primary), var(--color-bg-secondary));
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-primary);
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    white-space: nowrap;
}

.clarification-btn:hover {
    background: linear-gradient(135deg, var(--color-primary-light), var(--color-primary));
    border-color: var(--color-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(var(--color-primary-rgb), 0.25);
}

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

/* Rate Limit Message Styles - Inline with chat */
.rate-limit-message {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #fff8e1, #ffecb3);
    border: 1px solid #ffc107;
    border-radius: 12px;
    padding: 12px 16px;
    color: #856404;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.15);
}

.rate-limit-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* Fallback Message Styles - Inline with chat */
.fallback-message {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #f5f5f5, #eeeeee);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--color-text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.fallback-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* Retry button in error states */
.error-retry-btn {
    margin-left: 12px;
    padding: 6px 14px;
    background: var(--color-primary);
    border: none;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.15s ease;
}

.error-retry-btn:hover {
    background: var(--color-primary-dark);
    transform: scale(1.02);
}

/* ===========================================
   AI Genius Progress Bar
   Phase 12: Progress indicator for chunked operations
   =========================================== */

.genius-progress-container {
    background: var(--color-bg-secondary, #f9fafb);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-lg, 12px);
    padding: 12px 16px;
    margin: 8px 0;
    animation: fadeIn 0.2s ease;
}

.genius-progress-container .progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13px;
}

.genius-progress-container .progress-message {
    color: var(--color-text-primary, #1f2937);
    font-weight: 500;
}

.genius-progress-container .progress-details {
    color: var(--color-text-secondary, #6b7280);
    font-size: 12px;
}

.genius-progress-container .progress-bar-track {
    background: var(--color-border, #e5e7eb);
    border-radius: var(--radius-sm, 6px);
    height: 8px;
    overflow: hidden;
}

.genius-progress-container .progress-bar-fill {
    background: linear-gradient(90deg, var(--color-gradient-start, #6C5CE7), var(--color-gradient-end, #5A4BD1));
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: var(--radius-sm, 6px);
}

/* ===========================================
   PHASE 13.0.1: PERSISTENT ERROR MESSAGES
   Error messages displayed in chat (not toasts)
   =========================================== */

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

.error-bubble {
    background: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: 12px;
    padding: 12px 16px;
}

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

.error-icon {
    font-size: 16px;
}

.error-title {
    font-weight: 600;
    color: #b91c1c;
    font-size: 14px;
}

.error-content {
    margin-bottom: 12px;
}

.error-text {
    color: #7f1d1d;
    font-size: 13px;
    margin: 0 0 8px 0;
    line-height: 1.5;
    word-break: break-word;
}

.error-suggestion {
    color: #92400e;
    font-size: 12px;
    margin: 8px 0 0 0;
    padding: 8px 10px;
    background: rgba(251, 191, 36, 0.15);
    border-radius: 6px;
    border-left: 3px solid #f59e0b;
}

.error-actions {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #fecaca;
}

.copy-error-btn {
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    color: #374151;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.copy-error-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

/* ===========================================
   Chat Message Flow Consistency
   Keep tight vertical rhythm and fixed side segregation
   =========================================== */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-messages .message {
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: flex-start;
}

.chat-messages .message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    justify-content: flex-start;
    white-space: normal;
    overflow-wrap: break-word;
}

.chat-messages .message.assistant {
    align-self: flex-start;
    flex-direction: row;
    justify-content: flex-start;
}

.chat-messages .message .message-avatar {
    margin-top: 2px;
}

.chat-messages .message .message-content {
    width: auto;
    max-width: min(90%, 44rem);
    flex: 0 1 auto;
}

.chat-messages .message.user .message-content {
    align-items: flex-end;
}

.chat-messages .message.assistant .message-content {
    align-items: flex-start;
}

.chat-messages .message .message-bubble {
    display: inline-block;
    width: auto;
    max-width: 100%;
    min-height: 0;
    height: auto;
    padding: 10px 14px;
    line-height: 1.45;
}

/* Adaptive bubble corner geometry */
.chat-messages .message.user .message-bubble.bubble-short {
    border-radius: 18px 18px 7px 18px;
}

.chat-messages .message.user .message-bubble.bubble-medium {
    border-radius: 16px 16px 5px 16px;
}

.chat-messages .message.user .message-bubble.bubble-long {
    border-radius: 14px 14px 3px 14px;
}

.chat-messages .message.assistant .message-bubble.bubble-short {
    border-radius: 18px 18px 18px 7px;
}

.chat-messages .message.assistant .message-bubble.bubble-medium {
    border-radius: 16px 16px 16px 5px;
}

.chat-messages .message.assistant .message-bubble.bubble-long {
    border-radius: 14px 14px 14px 3px;
}

/* ===========================================
   DARK MODE — [data-theme="dark"]
   =========================================== */

/* 1. CSS Variable Overrides */
[data-theme="dark"] {
    --color-primary: #8B75E8;
    --color-primary-dark: #7B65D8;
    --color-primary-light: #2d2850;
    --color-gradient-start: #8B75E8;
    --color-gradient-end: #6C5CE7;

    --color-success-bg: #1a2e1a;
    --color-error-bg: #2e1a1a;
    --color-warning-bg: #2e2a1a;

    --color-text-primary: #f0f0f5;
    --color-text-secondary: #a8a3c0;
    --color-text-muted: #706b8a;
    --color-border: #353550;
    --color-bg-primary: #1a1a2e;
    --color-bg-secondary: #1f1f35;
    --color-bg-tertiary: #2a2a45;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.4);
}

/* 2. Tab Bar */
[data-theme="dark"] .tab-bar {
    background: #1a1a2e;
    border-bottom-color: #353550;
}
[data-theme="dark"] .tab {
    color: #a8a3c0;
}
[data-theme="dark"] .tab.active {
    background: #1f1f35;
    color: #f0f0f5;
    box-shadow: 0 1px 0 #1f1f35;
}
[data-theme="dark"] .tab:hover:not(.active) {
    background: rgba(139, 117, 232, 0.1);
}

/* 3. Chat Area */
[data-theme="dark"] .welcome-screen {
    background: #1a1a2e;
}
[data-theme="dark"] .welcome-title {
    color: #f0f0f5;
}
[data-theme="dark"] .welcome-subtitle {
    color: #a8a3c0;
}
[data-theme="dark"] .welcome-prompt-card {
    background: #24243d;
    border-color: #353550;
}
[data-theme="dark"] .welcome-prompt-card:hover {
    background: #2a2a45;
    border-color: #8B75E8;
}
[data-theme="dark"] .welcome-prompt-title {
    color: #f0f0f5;
}
[data-theme="dark"] .welcome-prompt-text {
    color: #a8a3c0;
}

[data-theme="dark"] #chatMessagesScrollable,
[data-theme="dark"] .messages-display,
[data-theme="dark"] .chat-messages-container {
    background: #1a1a2e;
}

/* User message bubble */
[data-theme="dark"] .message.user {
    background: transparent;
}
[data-theme="dark"] .message.user .message-bubble {
    background: #2d2850;
    color: #f0f0f5;
}

/* Assistant message bubble */
[data-theme="dark"] .message.assistant .message-bubble {
    background: #24243d;
    color: #f0f0f5;
}

/* Date separator */
[data-theme="dark"] .date-separator {
    background: #2a2a45;
    color: #706b8a;
}
[data-theme="dark"] .date-separator span {
    background: #2a2a45;
    color: #706b8a;
}

/* 4. Input Area */
[data-theme="dark"] .input-container {
    background: #1f1f35;
    border-color: #353550;
}
[data-theme="dark"] .input-container:focus-within {
    background: #24243d;
    border-color: #8B75E8;
}
[data-theme="dark"] .chat-input-field {
    color: #f0f0f5;
}
[data-theme="dark"] .chat-input-field::placeholder {
    color: #706b8a;
}

/* 5. Code blocks & inline code */
[data-theme="dark"] .message code.md-inline,
[data-theme="dark"] code.md-inline {
    background: #2a2a45;
    color: #c8c3e0;
}
[data-theme="dark"] .message pre {
    background: #1a1a2e;
    border-color: #353550;
}

/* 6. Buttons & Actions */
[data-theme="dark"] .action-btn:hover {
    background: #2a2a45;
}
[data-theme="dark"] .edit-mode-btn:hover {
    background: #2a2a45;
}
[data-theme="dark"] .edit-mode-popover {
    background: #24243d;
    border-color: #353550;
}
[data-theme="dark"] .popover-option {
    color: #f0f0f5;
}
[data-theme="dark"] .popover-option:hover {
    background: #2a2a45;
}
[data-theme="dark"] .attach-btn-modern:hover {
    background: #2a2a45;
}

/* 7. Selection cards */
[data-theme="dark"] .selection-card {
    background: #24243d;
    border-color: #353550;
}
[data-theme="dark"] .selection-card-title {
    color: #f0f0f5;
}
[data-theme="dark"] .selection-card-body {
    color: #a8a3c0;
}

/* 8. Keyboard shortcut badge */
[data-theme="dark"] .keyboard-shortcut-badge {
    background: #2a2a45;
    color: #706b8a;
    border-color: #353550;
}

/* 9. File pills */
[data-theme="dark"] .file-pill {
    background: #1a2e2a;
    border-color: #2a4a3a;
    color: #7ed3a0;
}

/* 10. Message file items */
[data-theme="dark"] .message.assistant .message-file-item {
    background: #2a2a45;
}

/* 11. Confirmation dialog */
[data-theme="dark"] .confirmation-content {
    background: #24243d;
    color: #f0f0f5;
}

/* 12. Modal overlay */
[data-theme="dark"] .modal-overlay-main,
[data-theme="dark"] .modal-dialog-main {
    background: #1f1f35;
    color: #f0f0f5;
}

/* 13. Auth overlay */
[data-theme="dark"] .auth-overlay {
    background: linear-gradient(135deg, #1a1a2e 0%, #231740 50%, #3a1f6e 100%);
}
[data-theme="dark"] .auth-card {
    background: transparent;
}
[data-theme="dark"] .auth-heading {
    color: #f0f0f5;
}
[data-theme="dark"] .auth-hero-brand {
    color: #f0f0f5;
}
[data-theme="dark"] .auth-heading {
    -webkit-text-fill-color: unset;
}
[data-theme="dark"] .auth-subheading {
    color: #706b8a;
}
[data-theme="dark"] .auth-switch-text {
    color: #f0f0f5;
}
[data-theme="dark"] .auth-switch-link {
    color: #f0f0f5;
}
[data-theme="dark"] .auth-submit {
    background: #f0f0f5;
    color: #1a1a2e;
}
[data-theme="dark"] .auth-submit:hover {
    background: #8B75E8;
    color: #ffffff;
}
[data-theme="dark"] .auth-toggle {
    background: #2a2a45;
}
[data-theme="dark"] .auth-toggle-btn {
    color: #a8a3c0;
}
[data-theme="dark"] .auth-toggle-btn.active {
    color: #f0f0f5;
    background: #8B75E8;
}
[data-theme="dark"] .auth-input,
[data-theme="dark"] .auth-input-v2 {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.10);
    color: #f0f0f5;
}
[data-theme="dark"] .auth-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: #8B75E8;
}
[data-theme="dark"] .auth-field-icon svg {
    stroke: #706b8a;
}
[data-theme="dark"] .auth-input::placeholder,
[data-theme="dark"] .auth-input-v2::placeholder {
    color: #706b8a;
}
[data-theme="dark"] .auth-inputForm {
    border-color: #353550;
    background: #24243d;
}
[data-theme="dark"] .auth-inputForm:focus-within {
    border-color: #8B75E8;
}
[data-theme="dark"] .auth-input-icon {
    color: #706b8a;
}
[data-theme="dark"] .auth-social-btn {
    background: #24243d;
    border-color: #353550;
    color: #f0f0f5;
}
[data-theme="dark"] .auth-social-btn:hover:not(:disabled) {
    background: #2a2a45;
    box-shadow: 0 6px 16px rgba(109, 85, 214, 0.25);
}
[data-theme="dark"] .auth-divider span {
    color: #706b8a;
}
[data-theme="dark"] .auth-divider::before,
[data-theme="dark"] .auth-divider::after {
    background: #353550;
}
[data-theme="dark"] .auth-otp-send-btn {
    background: #24243d;
    border-color: #8B75E8;
    color: #8B75E8;
}
[data-theme="dark"] .auth-otp-send-btn:hover:not(:disabled) {
    background: rgba(139, 117, 232, 0.12);
}
[data-theme="dark"] .auth-otp-hint {
    color: #706b8a;
}
[data-theme="dark"] .auth-link-btn {
    color: #8B75E8;
}
[data-theme="dark"] .auth-forgot-panel {
    border-color: #353550;
    background: rgba(139, 117, 232, 0.05);
}
[data-theme="dark"] .auth-privacy-text {
    color: #706b8a;
}

/* 14. Automation buttons */
[data-theme="dark"] .automation-btn {
    background: #24243d;
    border-color: #353550;
    color: #f0f0f5;
}
[data-theme="dark"] .automation-btn:hover {
    background: #2a2a45;
}

/* 15. Trainer section */
[data-theme="dark"] .trainer-section {
    background: #24243d;
    color: #f0f0f5;
}
[data-theme="dark"] .trainer-section h3 {
    color: #f0f0f5;
}
[data-theme="dark"] .trainer-section p {
    color: #a8a3c0;
}
[data-theme="dark"] .trainer-status {
    background: #2a2a45;
}
[data-theme="dark"] .trainer-input {
    background: #1f1f35;
    border-color: #353550;
    color: #f0f0f5;
}

/* 16. Settings group */
[data-theme="dark"] .settings-group {
    background: #24243d;
}

/* 17. Office dialog */
[data-theme="dark"] .office-dialog {
    background: #24243d;
    color: #f0f0f5;
}
[data-theme="dark"] .office-dialog h3 {
    color: #f0f0f5;
}
[data-theme="dark"] .office-dialog-button.secondary {
    border-color: #353550;
    color: #a8a3c0;
}

/* 18. HR / separators */
[data-theme="dark"] .message hr {
    border-top-color: #353550;
}

/* 19. Copy error button */
[data-theme="dark"] .copy-error-btn {
    background: #24243d;
    border-color: #353550;
    color: #a8a3c0;
}
[data-theme="dark"] .copy-error-btn:hover {
    background: #2a2a45;
}

/* 20. File upload area */
[data-theme="dark"] .file-upload-area {
    background: #24243d;
    border-color: #353550;
}

/* 21. Scrollbar for dark mode */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #1a1a2e;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #353550;
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #454565;
}

/* 22. General body / html background */
[data-theme="dark"],
[data-theme="dark"] body {
    background: #1a1a2e;
    color: #f0f0f5;
}

/* 23. Chat history sidebar search */
[data-theme="dark"] .chat-history-search input {
    background: #1f1f35;
    color: #f0f0f5;
}

[data-theme="dark"] .chat-history-search input::placeholder {
    color: #706b8a;
}

/* 24. Tab content / main panel */
[data-theme="dark"] .tab-content {
    background: #1a1a2e;
}

/* 25. Status indicator */
[data-theme="dark"] .status-indicator {
    background: linear-gradient(135deg, rgba(139, 117, 232, 0.12) 0%, rgba(139, 117, 232, 0.08) 100%);
}

/* 25b. Main content wrapper */
[data-theme="dark"] .content-new {
    background: #1a1a2e;
}

[data-theme="dark"] .content-new #chat-tab.active {
    background: #1a1a2e;
}

[data-theme="dark"] .chat-messages-scrollable {
    background: #1a1a2e;
}

[data-theme="dark"] #automation-tab.active,
[data-theme="dark"] #history-tab.active,
[data-theme="dark"] #settings-tab.active {
    background: #1a1a2e;
}

/* 26. Tabs container (light purple gradient) */
[data-theme="dark"] .tabs {
    background: #1a1a2e;
}

/* 27. Chat input wrapper (white bottom area) */
[data-theme="dark"] .chat-input-wrapper {
    background: #1f1f35;
    border-top-color: #353550;
}

/* 28. Chat input fixed (light purple bottom area) */
[data-theme="dark"] .chat-input-fixed {
    background: #1f1f35;
}

[data-theme="dark"] .chat-input-fixed .input-container {
    background: #24243d;
}

[data-theme="dark"] .chat-input-fixed .input-container:focus-within {
    box-shadow: 0 0 0 2px rgba(139, 117, 232, 0.2);
}

[data-theme="dark"] .chat-input-fixed .chat-input-modern {
    color: #f0f0f5;
}

[data-theme="dark"] .chat-input-fixed .chat-input-modern::placeholder {
    color: #706b8a;
}

[data-theme="dark"] .chat-input-fixed .send-btn-modern {
    background: linear-gradient(135deg, rgba(139, 117, 232, 0.4), rgba(109, 85, 214, 0.6));
    color: #f0f0f5;
}

/* 29. Chat toolbar buttons */
[data-theme="dark"] .chat-toolbar-btn {
    background: rgba(139, 117, 232, 0.15);
    color: #8B75E8;
}

[data-theme="dark"] .chat-toolbar-btn:hover {
    background: rgba(139, 117, 232, 0.25);
}

/* 30. Credits counter */
[data-theme="dark"] .credits-counter {
    background: #2a2a45;
    color: #706b8a;
}

/* 31. Chat input modern (non-fixed) */
[data-theme="dark"] .chat-input-modern {
    color: #f0f0f5;
}

[data-theme="dark"] .chat-input-modern::placeholder {
    color: #706b8a;
}

/* 35. Attach button + edit-mode button — light purple icons */
[data-theme="dark"] .attach-btn-modern {
    color: #8B75E8;
}

[data-theme="dark"] .attach-btn-modern:hover {
    background: rgba(139, 117, 232, 0.15);
    color: #a895f0;
}

[data-theme="dark"] .edit-mode-btn {
    color: #8B75E8;
}

[data-theme="dark"] .edit-mode-btn:hover {
    background: rgba(139, 117, 232, 0.15);
    color: #a895f0;
}

/* 36. Template gallery button in input area — light purple */
[data-theme="dark"] .template-gallery-btn {
    color: #8B75E8;
}

/* 37. Cellyn input box (inline style override) */
.cellyn-input-box {
    background: #fff;
}
.cellyn-chat-textarea {
    color: #1f2937;
}

[data-theme="dark"] .cellyn-input-box {
    background: #24243d !important;
}

[data-theme="dark"] .cellyn-chat-textarea {
    color: #f0f0f5 !important;
}

[data-theme="dark"] .cellyn-chat-textarea::placeholder {
    color: #706b8a !important;
}

/* 38. Override inline style colors on attach/edit buttons */
[data-theme="dark"] #attachBtn {
    color: #8B75E8 !important;
}

[data-theme="dark"] #editModeBtn {
    color: #8B75E8 !important;
}

[data-theme="dark"] .edit-mode-icon-hand {
    filter: brightness(1.5) saturate(0.8);
}

/* 32. System message */
[data-theme="dark"] .message.system {
    background: #2e2a1a;
    border-color: #4a4530;
    color: #fbbf24;
}

/* 33. Chat input container / chat-input-area generic */
[data-theme="dark"] .chat-input-container {
    background: #1f1f35;
}

/* 34. Input container generic */
[data-theme="dark"] .input-container {
    background: #24243d;
    border-color: #353550;
}

[data-theme="dark"] .input-container:focus-within {
    background: #24243d;
    border-color: #8B75E8;
    box-shadow: 0 0 0 2px rgba(139, 117, 232, 0.15);
}
