/* ═══════════════════════════════════════════════════════════
   AI SOFTWARE HOUSE — DARK THEME CHAT INTERFACE
   Modern, sleek, polished styling with smooth animations
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables / Design Tokens ──────────────────────── */
:root {
    /* Core dark palette */
    --bg-primary:       #0a0a0f;
    --bg-secondary:     #111118;
    --bg-tertiary:      #1a1a24;
    --bg-elevated:      #22222e;
    --bg-hover:         #2a2a38;

    /* Surface & card colors */
    --surface-1:        #16161e;
    --surface-2:        #1e1e28;
    --surface-3:        #262632;

    /* Text hierarchy */
    --text-primary:     #f0f0f5;
    --text-secondary:   #a0a0b5;
    --text-tertiary:    #6b6b80;
    --text-muted:       #4a4a5c;

    /* Borders */
    --border-subtle:    #2a2a38;
    --border-default:   #333345;
    --border-strong:    #444458;

    /* Accent / Brand */
    --accent-primary:   #6366f1;
    --accent-hover:     #818cf8;
    --accent-glow:      rgba(99, 102, 241, 0.25);
    --accent-subtle:    rgba(99, 102, 241, 0.08);

    /* Agent colors */
    --agent-pm:         #f59e0b;
    --agent-re:         #3b82f6;
    --agent-sa:         #8b5cf6;
    --agent-impl:       #10b981;
    --agent-qa:         #ef4444;
    --agent-rf:         #06b6d4;
    --agent-devops:     #f97316;
    --agent-fd:         #ec4899;

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

    /* Spacing */
    --space-xs:         4px;
    --space-sm:         8px;
    --space-md:         16px;
    --space-lg:         24px;
    --space-xl:         32px;
    --space-2xl:        48px;

    /* Radius */
    --radius-sm:        6px;
    --radius-md:        10px;
    --radius-lg:        16px;
    --radius-xl:        20px;
    --radius-full:      9999px;

    /* Typography */
    --font-sans:        'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:        'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Layout */
    --sidebar-width:    290px;
    --top-bar-height:   60px;
    --input-height:     80px;

    /* Shadows */
    --shadow-sm:        0 1px 2px rgba(0,0,0,0.3);
    --shadow-md:        0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg:        0 8px 30px rgba(0,0,0,0.5);
    --shadow-glow:      0 0 20px var(--accent-glow);

    /* Transitions */
    --transition-fast:  150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base:  250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow:  400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset & Base ───────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    line-height: 1.6;
}

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* Selection */
::selection {
    background: var(--accent-primary);
    color: white;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 100;
    transition: transform var(--transition-base);
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-primary), #a855f7);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.logo-icon svg {
    width: 22px;
    height: 22px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.logo-subtitle {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* New Project Button */
.new-project-btn {
    margin: var(--space-md) var(--space-lg);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-subtle);
    color: var(--accent-hover);
    border: 1px dashed var(--accent-primary);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    transition: all var(--transition-base);
}

.new-project-btn svg {
    width: 16px;
    height: 16px;
}

.new-project-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-style: solid;
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

/* Sidebar Sections */
.sidebar-section {
    padding: var(--space-md) var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: var(--space-md);
}

/* Project List */
.project-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.project-item {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.project-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-subtle);
}

.project-item.active {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
}

.project-item-title {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.project-item-meta {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    margin-top: 2px;
}

.project-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.project-status-dot.completed { background: var(--success); }
.project-status-dot.running { background: var(--warning); animation: pulse-dot 1.5s infinite; }
.project-status-dot.error { background: var(--error); }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Agent List */
.sidebar-agents {
    flex: 0 0 auto;
    max-height: 380px;
    overflow-y: auto;
    border-top: 1px solid var(--border-subtle);
}

.agent-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.agent-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

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

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

.agent-item.active .agent-avatar {
    box-shadow: 0 0 10px color-mix(in srgb, var(--agent-color) 50%, transparent);
    animation: agent-glow 2s ease-in-out infinite;
}

@keyframes agent-glow {
    0%, 100% { box-shadow: 0 0 8px color-mix(in srgb, var(--agent-color) 30%, transparent); }
    50% { box-shadow: 0 0 16px color-mix(in srgb, var(--agent-color) 60%, transparent); }
}

.agent-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--agent-color) 15%, transparent);
    color: var(--agent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid color-mix(in srgb, var(--agent-color) 25%, transparent);
    transition: all var(--transition-base);
}

.agent-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.agent-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-primary);
}

.agent-status {
    font-size: 0.65rem;
    color: var(--text-tertiary);
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.sidebar-footer-text {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.version {
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: 0.65rem;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar-overlay.visible {
    display: block;
    opacity: 1;
}


/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT AREA
   ═══════════════════════════════════════════════════════════ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    min-width: 0;
}

/* ── Top Bar ─────────────────────────────────────────────── */
.top-bar {
    height: var(--top-bar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 var(--space-lg);
    gap: var(--space-md);
    flex-shrink: 0;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

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

.menu-toggle svg {
    width: 22px;
    height: 22px;
}

.top-bar-info {
    flex: 1;
    min-width: 0;
}

.top-bar-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.phase-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.phase-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.phase-dot.active {
    background: var(--warning);
    animation: pulse-dot 1.5s infinite;
}

.phase-dot.error {
    background: var(--error);
}

.phase-text {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

.top-bar-actions {
    display: flex;
    gap: var(--space-sm);
}

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

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

.icon-btn.active {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-hover);
}

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

/* ── Pipeline Bar ────────────────────────────────────────── */
.pipeline-bar {
    background: var(--surface-1);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-md) var(--space-lg);
    overflow-x: auto;
    display: none; /* toggled via JS */
    flex-shrink: 0;
    animation: slideDown 300ms ease-out;
}

.pipeline-bar.visible {
    display: block;
}

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

.pipeline-phases {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: max-content;
}

.pipeline-phase {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-tertiary);
    white-space: nowrap;
    transition: all var(--transition-base);
}

.pipeline-phase-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-default);
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.pipeline-phase.completed .pipeline-phase-dot {
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.pipeline-phase.completed {
    color: var(--success);
}

.pipeline-phase.active {
    color: var(--accent-hover);
    background: var(--accent-subtle);
}

.pipeline-phase.active .pipeline-phase-dot {
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-glow);
    animation: pulse-dot 1.5s infinite;
}

.pipeline-connector {
    width: 24px;
    height: 2px;
    background: var(--border-default);
    flex-shrink: 0;
    transition: background var(--transition-base);
}

.pipeline-connector.completed {
    background: var(--success);
}

/* ═══════════════════════════════════════════════════════════
   CHAT CONTAINER
   ═══════════════════════════════════════════════════════════ */
.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    padding: 0;
    position: relative;
}

/* ── Welcome Screen ──────────────────────────────────────── */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    min-height: 100%;
    animation: fadeIn 600ms ease-out;
    text-align: center;
}

.welcome-screen.hidden {
    display: none;
}

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

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--accent-primary), #a855f7);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin-bottom: var(--space-lg);
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.3);
    animation: float 4s ease-in-out infinite;
}

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

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

.welcome-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    margin-bottom: var(--space-sm);
    background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 480px;
    line-height: 1.7;
    margin-bottom: var(--space-xl);
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
    max-width: 500px;
    margin-bottom: var(--space-xl);
}

.welcome-feature {
    display: flex;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    text-align: left;
    transition: all var(--transition-base);
}

.welcome-feature:hover {
    border-color: var(--border-default);
    background: var(--surface-3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.feature-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.feature-text {
    display: flex;
    flex-direction: column;
}

.feature-text strong {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.feature-text span {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

/* Suggestions */
.welcome-suggestions {
    width: 100%;
    max-width: 540px;
}

.suggestions-label {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    margin-bottom: var(--space-md);
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
}

.suggestion-chip {
    padding: 8px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

/* ── Messages Area ───────────────────────────────────────── */
.messages-area {
    padding: var(--space-lg);
    display: none;
    flex-direction: column;
    gap: var(--space-md);
    min-height: 100%;
}

.messages-area.active {
    display: flex;
}

/* ── Message Bubble ──────────────────────────────────────── */
.message {
    display: flex;
    gap: var(--space-md);
    max-width: 85%;
    animation: messageIn 400ms var(--transition-spring);
    animation-fill-mode: both;
}

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

/* User messages */
.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
    border: none;
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
}

.message.user .message-bubble .message-text {
    color: white;
}

/* Agent messages */
.message.agent {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid;
    transition: all var(--transition-base);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--accent-primary), #7c3aed);
    color: white;
    border-color: transparent;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: 4px;
}

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

.message-sender {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.message-time {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.message-phase-badge {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--accent-subtle);
    color: var(--accent-hover);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.message-bubble {
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg);
    padding: var(--space-md);
    transition: all var(--transition-fast);
    position: relative;
    overflow: visible;
}

.message-bubble:hover {
    border-color: var(--border-default);
}

.message-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ── Markdown: Paragraphs ──────────────────────────────── */
.message-text p {
    margin-bottom: 0.6em;
}

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

/* ── Markdown: Headings ────────────────────────────────── */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.35;
    margin-top: 1.1em;
    margin-bottom: 0.5em;
}

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child {
    margin-top: 0;
}

.message-text h1 {
    font-size: 1.3em;
    padding-bottom: 0.3em;
    border-bottom: 1px solid var(--border-subtle);
}

.message-text h2 {
    font-size: 1.15em;
    padding-bottom: 0.25em;
    border-bottom: 1px solid var(--border-subtle);
}

.message-text h3 {
    font-size: 1.05em;
}

.message-text h4 {
    font-size: 0.95em;
    color: var(--text-secondary);
}

.message-text h5,
.message-text h6 {
    font-size: 0.88em;
    color: var(--text-secondary);
}

/* ── Markdown: Bold / Italic / Strikethrough ───────────── */
.message-text strong {
    color: var(--accent-hover);
    font-weight: 600;
}

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

.message-text del {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

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

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

/* ── Markdown: Inline Code ─────────────────────────────── */
.message-text code {
    font-family: var(--font-mono);
    font-size: 0.82em;
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--accent-hover);
    border: 1px solid var(--border-subtle);
}

/* Don't double-style code inside pre blocks */
.message-text pre code {
    background: none;
    padding: 0;
    border: none;
    border-radius: 0;
    font-size: 0.85rem;
    color: inherit;
}

/* ── Markdown: Code Blocks ─────────────────────────────── */
.md-code-block {
    margin: 0.75em 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: #0d1117;
}

.md-code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid var(--border-subtle);
}

.md-code-lang {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.md-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    font-family: var(--font-sans);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.md-copy-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

.md-code-block pre {
    margin: 0;
    padding: 14px 16px;
    overflow-x: auto;
    background: transparent;
    border: none;
    border-radius: 0;
}

.md-code-block pre code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.55;
    tab-size: 4;
}

/* Fallback for bare pre (no wrapper) */
.message-text > pre {
    background: #0d1117;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    overflow-x: auto;
    margin: 0.75em 0;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

/* ── Markdown: Lists ───────────────────────────────────── */
.message-text ul,
.message-text ol {
    padding-left: 1.5em;
    margin: 0.5em 0;
}

.message-text ul {
    list-style-type: disc;
}

.message-text ol {
    list-style-type: decimal;
}

.message-text li {
    margin-bottom: 0.3em;
    line-height: 1.6;
    color: var(--text-primary);
}

.message-text li::marker {
    color: var(--accent-primary);
}

.message-text li > p {
    margin-bottom: 0.25em;
}

/* Nested lists */
.message-text ul ul,
.message-text ol ol,
.message-text ul ol,
.message-text ol ul {
    margin-top: 0.2em;
    margin-bottom: 0.2em;
}

/* ── Markdown: Blockquotes ─────────────────────────────── */
.message-text blockquote {
    border-left: 3px solid var(--accent-primary);
    padding: 0.5em 1em;
    margin: 0.75em 0;
    background: var(--accent-subtle);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}

.message-text blockquote p {
    margin-bottom: 0.3em;
}

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

/* ── Markdown: Tables ──────────────────────────────────── */
.md-table-wrap {
    overflow-x: auto;
    margin: 0.75em 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.md-table th {
    background: var(--surface-3);
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid var(--border-default);
    white-space: nowrap;
}

.md-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

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

.md-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

/* ── Markdown: Horizontal Rules ────────────────────────── */
.message-text hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-default), transparent);
    margin: 1em 0;
}

/* ── Markdown: Images ──────────────────────────────────── */
.message-text img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 0.5em 0;
}

/* ── Markdown: Task Lists (GFM) ────────────────────────── */
.message-text input[type="checkbox"] {
    margin-right: 6px;
    accent-color: var(--accent-primary);
}

/* Phase separator */
.phase-separator {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    animation: fadeIn 400ms ease-out;
}

.phase-separator-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-default), transparent);
}

.phase-separator-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    background: var(--bg-primary);
    padding: 4px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    white-space: nowrap;
}

/* File cards inside messages */
.file-cards {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    margin-top: var(--space-md);
}

.file-card {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.78rem;
}

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

.file-card-icon {
    font-size: 1rem;
}

.file-card-name {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-secondary);
}

/* ── Download Button ─────────────────────────────────────── */
.download-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-lg) 0;
    animation: messageIn 500ms var(--transition-spring);
    animation-fill-mode: both;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 14px 32px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-base);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35), 0 0 0 0 rgba(16, 185, 129, 0);
    position: relative;
    overflow: hidden;
}

.download-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.download-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.45), 0 0 20px rgba(16, 185, 129, 0.15);
}

.download-btn:hover::before {
    opacity: 1;
}

.download-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.download-btn svg {
    flex-shrink: 0;
    animation: downloadBounce 2s ease-in-out infinite;
}

@keyframes downloadBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(3px); }
}

.download-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-align: center;
}

/* ── Typing Indicator ────────────────────────────────────── */
.typing-indicator {
    display: none;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    animation: fadeIn 300ms ease-out;
}

.typing-indicator.visible {
    display: flex;
}

.typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    flex-shrink: 0;
    background: var(--surface-2);
    color: var(--text-tertiary);
    border: 1px solid var(--border-subtle);
}

.typing-content {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.typing-name {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.typing-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0ms; }
.typing-dots span:nth-child(2) { animation-delay: 200ms; }
.typing-dots span:nth-child(3) { animation-delay: 400ms; }

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}


/* ═══════════════════════════════════════════════════════════
   INPUT AREA
   ═══════════════════════════════════════════════════════════ */
.input-area {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-subtle);
    padding: var(--space-md) var(--space-lg);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-sm) var(--space-sm) var(--space-sm) var(--space-md);
    transition: all var(--transition-base);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.input-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

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

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

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    max-height: 150px;
    padding: 6px 0;
}

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

.input-actions {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
}

.char-count {
    font-size: 0.65rem;
    color: var(--text-muted);
    white-space: nowrap;
    margin-bottom: 10px;
}

.send-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-base);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: var(--surface-3);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

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

.input-hint {
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: var(--space-sm);
}

.input-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    background: var(--surface-3);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.62rem;
}


/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 300px;
    max-width: 450px;
    animation: toastIn 400ms var(--transition-spring);
}

.toast.removing {
    animation: toastOut 300ms ease-in forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-body {
    flex: 1;
}

.toast-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.toast-message {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.toast.error { border-left: 3px solid var(--error); }
.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }


/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    animation: fadeIn 200ms ease-out;
}

.modal-overlay.visible {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 300ms var(--transition-spring);
}

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

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

.modal-title {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

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

.modal-body {
    flex: 1;
    overflow: auto;
    padding: var(--space-lg);
}

.modal-code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.6;
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
}

.modal-code .hljs {
    background: transparent;
    padding: 0;
}


/* ═══════════════════════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════════════════════ */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: flex;
    }

    .welcome-features {
        grid-template-columns: 1fr;
    }
}

/* Mobile */
@media (max-width: 640px) {
    :root {
        --space-lg: 16px;
        --space-xl: 24px;
    }

    .top-bar {
        padding: 0 var(--space-md);
    }

    .top-bar-title {
        font-size: 0.85rem;
    }

    .welcome-title {
        font-size: 1.4rem;
    }

    .welcome-subtitle {
        font-size: 0.85rem;
    }

    .welcome-features {
        grid-template-columns: 1fr;
    }

    .suggestion-chips {
        flex-direction: column;
        align-items: stretch;
    }

    .suggestion-chip {
        text-align: center;
    }

    .message {
        max-width: 95%;
    }

    .messages-area {
        padding: var(--space-md);
    }

    .input-area {
        padding: var(--space-sm) var(--space-md);
    }

    .input-hint {
        display: none;
    }

    .pipeline-bar {
        padding: var(--space-sm) var(--space-md);
    }

    .pipeline-phase span {
        display: none;
    }

    .pipeline-phase-dot {
        width: 10px;
        height: 10px;
    }

    .pipeline-connector {
        width: 16px;
    }

    .sidebar-agents {
        display: none;
    }

    .modal-content {
        max-width: 100%;
        max-height: 90vh;
        margin: var(--space-md);
    }

    .toast {
        min-width: unset;
        max-width: calc(100vw - 32px);
    }

    .toast-container {
        left: var(--space-md);
        right: var(--space-md);
    }
}

/* Large screens */
@media (min-width: 1400px) {
    .message {
        max-width: 70%;
    }
}

/* ═══════════════════════════════════════════════════════════
   UTILITY & ANIMATION HELPERS
   ═══════════════════════════════════════════════════════════ */
.hidden {
    display: none !important;
}

/* Staggered message animation */
.message:nth-child(1) { animation-delay: 0ms; }
.message:nth-child(2) { animation-delay: 50ms; }
.message:nth-child(3) { animation-delay: 100ms; }
.message:nth-child(4) { animation-delay: 150ms; }
.message:nth-child(5) { animation-delay: 200ms; }

/* Glow effects for agent colors on message bubbles */
.message.agent .message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    background: var(--agent-msg-color, var(--accent-primary));
    opacity: 0.7;
}

/* Shimmer loading effect */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Smooth scroll anchor */

/* ═══════════════════════════════════════════════════════════
   AGENT CONVERSATION STYLES
   Real-time agent-to-agent communication display
   Human-like, natural team conversation feel
   ═══════════════════════════════════════════════════════════ */

/* Conversation messages enter with smooth animation */
.message.conversation-msg {
    margin-bottom: 4px;
}

.message.conversation-start {
    margin-top: 4px;
}

.message.conversation-done {
    margin-bottom: 12px;
}

/* Conversation bubble variations */
.conversation-bubble {
    position: relative;
    border-left: 3px solid var(--agent-msg-color, var(--accent-primary)) !important;
}

.conversation-start-bubble {
    background: var(--surface-1) !important;
    border-left-color: var(--info) !important;
    opacity: 0.9;
}

.conversation-start-bubble .message-text {
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.conversation-critique-bubble {
    background: rgba(239, 68, 68, 0.05) !important;
    border-left-color: var(--error) !important;
}

.conversation-critique-bubble::before {
    content: '';
    position: absolute;
    top: 8px;
    left: -10px;
    width: 6px;
    height: 6px;
    background: var(--error);
    border-radius: 50%;
}

.conversation-refinement-bubble {
    background: rgba(16, 185, 129, 0.05) !important;
    border-left-color: var(--success) !important;
}

.conversation-refinement-bubble::before {
    content: '';
    position: absolute;
    top: 8px;
    left: -10px;
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
}

.conversation-done-bubble {
    background: rgba(99, 102, 241, 0.05) !important;
    border-left-color: var(--accent-primary) !important;
}

.conversation-message-bubble {
    background: var(--surface-2) !important;
}

/* Conversation type badges */
.conv-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.conv-badge-start {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.conv-badge-critique {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.conv-badge-refine {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.conv-badge-done {
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
}

/* Conversation message text — full display, no truncation */
.conversation-critique-bubble .message-text,
.conversation-refinement-bubble .message-text {
    max-height: none;
    overflow-y: visible;
}

.conversation-critique-bubble .message-text::-webkit-scrollbar,
.conversation-refinement-bubble .message-text::-webkit-scrollbar {
    width: 4px;
}

.conversation-critique-bubble .message-text::-webkit-scrollbar-thumb,
.conversation-refinement-bubble .message-text::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 2px;
}

/* Conversation avatar — slightly smaller for conversation flow */
.conv-avatar {
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    font-size: 0.6rem !important;
}


/* ═══════════════════════════════════════════════════════════
   COMPLEXITY BANNER STYLES
   Shows the detected project complexity tier
   ═══════════════════════════════════════════════════════════ */

.complexity-banner {
    margin: 12px 0 16px;
    animation: fadeSlideIn 0.4s ease;
}

.complexity-banner-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    border: 1px solid;
}

.complexity-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.complexity-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.complexity-desc {
    font-size: 0.82rem;
    color: var(--text-primary);
    font-weight: 500;
}

.complexity-stats {
    font-size: 0.72rem;
    color: var(--text-muted);
}

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

/* Phase separator improvements */
.phase-separator {
    animation: fadeSlideIn 0.3s ease;
}

.phase-separator-label {
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.3px;
}


/* ═══════════════════════════════════════════════════════════
   LIGHT THEME
   Activated via <html data-theme="light"> (toggled in the UI and
   persisted to localStorage). Only the design tokens are
   overridden, so every component adapts automatically.
   ═══════════════════════════════════════════════════════════ */
:root { color-scheme: dark; }

:root[data-theme="light"] {
    color-scheme: light;

    --bg-primary:       #f7f8fc;
    --bg-secondary:     #ffffff;
    --bg-tertiary:      #eef0f6;
    --bg-elevated:      #ffffff;
    --bg-hover:         #eaecf4;

    --surface-1:        #ffffff;
    --surface-2:        #f4f5fa;
    --surface-3:        #eaecf4;

    --text-primary:     #1a1a2e;
    --text-secondary:   #4a4a63;
    --text-tertiary:    #6b6b85;
    --text-muted:       #9a9ab0;

    --border-subtle:    #e4e6f0;
    --border-default:   #d4d7e6;
    --border-strong:    #bcc0d6;

    --accent-glow:      rgba(99, 102, 241, 0.18);
    --accent-subtle:    rgba(99, 102, 241, 0.08);

    --shadow-sm:        0 1px 2px rgba(20, 20, 50, 0.06);
    --shadow-md:        0 4px 12px rgba(20, 20, 50, 0.10);
    --shadow-lg:        0 8px 30px rgba(20, 20, 50, 0.15);
}

/* Code blocks stay dark in light mode for readability of syntax colors,
   but soften the bare-pre fallback background border. */
:root[data-theme="light"] .message-text code {
    background: var(--surface-3);
    color: #5b21b6;
}

/* Smooth the transition when toggling themes */
body,
.sidebar,
.top-bar,
.input-area,
.message-bubble,
.modal-content {
    transition: background-color var(--transition-base), border-color var(--transition-base), color var(--transition-base);
}

/* ── Theme toggle icon swap ──────────────────────────────── */
#themeToggleBtn .icon-sun,
#themeToggleBtn .icon-moon { width: 18px; height: 18px; }

/* Default (dark) → show the sun (click to go light). Hide the moon. */
#themeToggleBtn .icon-moon { display: none; }
#themeToggleBtn .icon-sun  { display: block; }

/* Light theme → show the moon (click to go dark). Hide the sun. */
:root[data-theme="light"] #themeToggleBtn .icon-sun  { display: none; }
:root[data-theme="light"] #themeToggleBtn .icon-moon { display: block; }


/* ═══════════════════════════════════════════════════════════
   BACKEND CONNECTION STATUS (sidebar footer)
   ═══════════════════════════════════════════════════════════ */
.connection-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    transition: background var(--transition-base), box-shadow var(--transition-base);
}

.connection-status.online .connection-dot {
    background: var(--success);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.connection-status.offline .connection-dot {
    background: var(--error);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.connection-status.connecting .connection-dot {
    background: var(--warning);
    animation: pulse-dot 1.2s infinite;
}

.connection-text { font-weight: 500; }


/* ═══════════════════════════════════════════════════════════
   ACCESSIBILITY — respect reduced-motion preference
   ═══════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
