/* Restoring system cursor when hardware cursor is disabled */
body.cursor-hidden,
body.cursor-hidden * {
    cursor: auto !important;
}

body.cursor-hidden button,
body.cursor-hidden a,
body.cursor-hidden .hover-target,
body.cursor-hidden .icon-btn,
body.cursor-hidden .primary-btn,
body.cursor-hidden .pill-btn,
body.cursor-hidden .history-item {
    cursor: pointer !important;
}

body.cursor-hidden textarea,
body.cursor-hidden input {
    cursor: text !important;
}

body.cursor-hidden .cursor-dot,
body.cursor-hidden .cursor-outline {
    display: none !important;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 01. ROOT VARIABLES & RESET                                     */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
:root {
    --bg-base: #000000;
    --bg-surface: #0a0a0a;
    --bg-panel: #111111;
    --border: #1f1f1f;
    --border-strong: #333333;
    --text-main: #ffffff;
    --text-muted: #888888;
    --primary: #ffffff;
    --primary-text: #000000;
    --error: #ef4444;
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
    --bg-base: #ffffff;
    --bg-surface: #f4f4f5;
    --bg-panel: #fafafa;
    --border: #e5e5e5;
    --border-strong: #d4d4d4;
    --text-main: #171717;
    --text-muted: #737373;
    --primary: #000000;
    --primary-text: #ffffff;
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-base);
    color: var(--text-main);
    height: 100dvh;
    overflow: hidden;
    cursor: none;
    /* Hide default cursor */
}

a,
button,
input,
textarea {
    cursor: none;
    outline: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 02. HARDWARE CURSOR                                            */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.cursor-dot {
    width: 6px;
    height: 6px;
    background: var(--text-main);
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 999999;
}

.cursor-outline {
    width: 36px;
    height: 36px;
    border: 1px solid var(--text-muted);
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 999999;
    transition: width 0.2s, height 0.2s, background 0.2s, border-color 0.2s;
}

.cursor-outline.hover {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-main);
}

[data-theme="light"] .cursor-outline.hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 03. IDE LAYOUT: ACTIVITY BAR & EXPLORER                        */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.studio-layout {
    display: flex;
    height: 100dvh;
    width: 100vw;
}

/* 1. Activity Bar (Far Left) */
.activity-bar {
    width: 56px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    z-index: 30;
}

.ab-top,
.ab-bottom {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.brand-icon svg {
    width: 24px;
    height: 24px;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.ab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.ab-btn:hover {
    color: var(--text-main);
    background: var(--border);
}

.ab-btn.active {
    color: var(--text-main);
    position: relative;
}

.ab-btn.active::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--text-main);
    border-radius: 0 4px 4px 0;
}

.ab-btn svg {
    width: 20px;
    height: 20px;
}

/* 2. Workspace Panel (Sidebar) */
.workspace-panel {
    width: 260px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
    z-index: 20;
    overflow: hidden;
    /* CRITICAL: Prevents icons from bleeding */
    white-space: nowrap;
    /* Prevents text from wrapping during collapse */
}

.workspace-panel.collapsed {
    width: 0;
    border: none;
    opacity: 0;
    /* Ensures the contents fade out cleanly */
}

.panel-header {
    padding: 1.2rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin: 0;
}

.panel-actions {
    display: flex;
    gap: 0.2rem;
}

/* 3. Main Stage (Right Area) */
.stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-base);
    min-width: 0;
}

.stage-header {
    height: 56px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    background: var(--bg-base);
    z-index: 10;
}

.context-breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.context-breadcrumb span {
    color: var(--text-main);
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    border: 1px solid var(--border);
    transition: 0.2s;
}

.model-selector:hover {
    border-color: var(--text-main);
    color: var(--text-main);
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.4);
}

.feed-viewport {
    flex: 1;
    overflow-y: auto;
    position: relative;
}

/* Common Buttons & Overlays */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 8px;
    padding: 0.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
    background: var(--border);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
}

@media (max-width: 768px) {
    .workspace-panel {
        position: fixed;
        height: 100vh;
        left: 56px;
    }

    .stage-header {
        padding: 0 1rem;
    }

    .context-breadcrumb {
        display: none;
    }

    /* Hide on mobile to save space */
}



/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 04. EMPTY STATE & COMMAND BAR                                  */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Empty State / Welcome Screen */
.empty-stage {
    height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.nexus-ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.nexus-ring svg {
    width: 32px;
    height: 32px;
}

.empty-stage h1 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.empty-stage p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.pill-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    font-size: 0.85rem;
    transition: 0.2s;
    outline: none;
    transition: all 0.2s ease;

    /* THE FIX: Force uniform sizing and prevent squishing/wrapping */
    min-width: 180px;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
    flex-shrink: 0;
}

.pill-btn:hover {
    border-color: var(--text-main);
    color: var(--text-main);
    transform: translateY(-2px);
}

.command-bar-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
    /* Top padding creates the fade space, bottom padding pushes the bar up */
    padding: 5rem 1.5rem 2.5rem 1.5rem;
    background: linear-gradient(to top, var(--bg-base) 65%, transparent);
    z-index: 20;
}

.command-bar-wrapper>* {
    pointer-events: auto;
}


[data-theme="light"] .command-bar {
    background: rgba(255, 255, 255, 0.8);
}

.cmd-attach,
.cmd-submit {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    outline: none;
    transition: all 0.2s ease;
}

.cmd-attach {
    background: transparent;
    color: var(--text-muted);
}

.cmd-attach:hover {
    background: var(--border);
    color: var(--text-main);
}

.cmd-submit {
    background: var(--text-main);
    color: var(--bg-base);
}

.cmd-submit:hover {
    opacity: 0.8;
}

.cmd-submit svg {
    width: 18px;
    height: 18px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 05. MODALS & MULTI-PROVIDER CONFIGURATION                      */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* General Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.2s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    transform: scale(1);
    transition: transform 0.2s;
    overflow: hidden;
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.98);
}

.modal-header {
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    width: 160px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.context-menu.hidden {
    display: none;
}

.context-menu button {
    background: transparent;
    border: none;
    padding: 0.8rem 1rem;
    text-align: left;
    color: var(--text-main);
    font-size: 0.85rem;
    transition: background 0.2s;
    outline: none;
}

.context-menu button:hover {
    background: var(--border);
}

.danger-text {
    color: var(--error) !important;
}

/* Settings Layout */
.settings-layout {
    display: flex;
    min-height: 400px;
}

.border-right {
    border-right: 1px solid var(--border);
}

/* Provider Sidebar */
.settings-sidebar {
    width: 220px;
    background: var(--bg-panel);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
}

.settings-nav-title {
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    padding: 0 1.5rem;
    margin-bottom: 1rem;
    letter-spacing: 1px;
}

.settings-nav {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0 0.8rem;
}

.settings-nav li {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: none;
    font-weight: 500;
}

.settings-nav li:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.settings-nav li.active {
    border: 1px solid var(--border);
    font-weight: 500;
    background: var(--text-main);
    color: var(--bg-base);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}


.settings-nav li svg {
    width: 16px;
    height: 16px;
    opacity: 0.9;
}

/* Provider Settings Body */
.settings-body {
    flex: 1;
    padding: 2.5rem;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
}

.provider-header {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 2.5rem;
}

.provider-icon {
    width: 48px;
    height: 48px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.provider-icon svg {
    width: 24px;
    height: 24px;
    color: var(--text-main);
}

.provider-info h4 {
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.provider-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.api-key-container {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: auto;
}

.api-key-container label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 0.8rem;
    font-weight: 500;
}

.api-key-container input {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.api-key-container input:focus {
    border-color: var(--text-muted);
}

.settings-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Provider Model Selector */
.model-dropdown-wrapper {
    margin-top: 1.5rem;
    position: relative;
}

.model-dropdown-wrapper::after {
    content: '▼';
    position: absolute;
    right: 1rem;
    top: 2.2rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    pointer-events: none;
}

.model-dropdown {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
    appearance: none;
    cursor: none;
}

.model-dropdown:focus {
    border-color: var(--text-muted);
}

.model-dropdown option {
    background: var(--bg-panel);
    color: var(--text-main);
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 06. ENTERPRISE MODEL GRID (Refined Symmetry)                   */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.model-result-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 2fr 30px;
    /* Exact match to the header */
    gap: 2.7rem;
    align-items: center;
    padding: 0.6rem 1rem;
    margin-bottom: 2px;
    border-radius: 8px;
    /* Sharper corners */
    text-decoration: none;
    color: var(--text-main);
    transition: background 0.15s ease, border-color 0.15s ease;
    cursor: none;
    border: 1px solid transparent;
}

.model-result-item:hover

/* .model-result-item.active-model  */
    {
    background: var(--bg-surface);
    /* border-color: var(--border); */
    /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03); */
    /* Softer shadow */
}

/* Left Column: Icon + Text */
.model-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 0;
}

.model-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    /* Smaller, sharper */
    background: var(--bg-base);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    flex-shrink: 0;
}

.model-icon svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    opacity: 0.8;
}

.model-result-info {
    min-width: 0;
    font-family: 'JetBrains Mono', monospace;
    text-overflow: ellipsis;
}

.model-result-info h4 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.1rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-result-info p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Data Columns */
.model-data {
    padding-left: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Tags Column (Switched to Inter to reduce noise) */
.model-tags {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.model-tag {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: var(--bg-base);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

/* Action Icon */
.model-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.2s;
    color: var(--text-muted);
}

.model-result-item:hover .model-status-icon {
    opacity: 1;
    transform: translateX(0);
}

.model-result-item.active-model .model-status-icon {
    opacity: 1;
    transform: translateX(0);
    color: #10b981;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 07. PREFERENCES HUB (Ultra-Premium Redesign)                   */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */


/* Smooth Content Fade */
.settings-fade-in {
    animation: subtleFade 0.3s ease-out forwards;
}

@keyframes subtleFade {
    0% {
        opacity: 0;
        transform: translateY(4px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Vault Headers & Typography */
.vault-header {
    margin-bottom: 2.5rem;
}

.vault-header h3 {
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.vault-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.settings-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'JetBrains Mono', monospace;
}

/* Minimalist Ghost Inputs */
.vault-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.vault-input-group label {
    font-size: 0.85rem;
    color: var(--text-main);
    font-weight: 500;
}

.vault-input {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

.vault-input:focus {
    border-color: var(--text-main);
    background: rgba(255, 255, 255, 0.02);
}

.vault-textarea {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-main);
    padding: 1rem;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.vault-textarea:focus {
    border-color: var(--text-main);
    background: rgba(255, 255, 255, 0.02);
}

/* Clean Rows & Sliders */
.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border);
    gap: 5px;
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-row-info h4 {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0.2rem;
    color: var(--text-main);
}

.settings-row-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
    max-width: 400px;
}

.range-slider {
    width: 200px;
    accent-color: var(--text-main);
    cursor: none;
}

/* Refined Provider Layout (No Boxy Cards) */
.provider-group {
    margin-bottom: 2.5rem;
}

.vault-footer {
    margin-top: auto;
    padding-top: 2rem;
    display: flex;
    justify-content: flex-end;
}

/* Premium Primary Button */
.primary-btn {
    background: var(--text-main);
    color: var(--bg-base);
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: none;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
}

.primary-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Native-looking Scrollbar for the Settings Body */
#settings-body-content::-webkit-scrollbar {
    width: 6px;
}

#settings-body-content::-webkit-scrollbar-track {
    background: transparent;
}

#settings-body-content::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
}

/* Dynamic Endpoint Cards & Secondary Buttons */
.custom-endpoint-card {
    border: 1px solid var(--border-strong);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    position: relative;
    background: rgba(0, 0, 0, 0.1);
}

.secondary-btn {
    background: transparent;
    color: var(--text-main);
    border: 1px dashed var(--border-strong);
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: none;
    transition: all 0.2s ease;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--text-muted);
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 08. MULTIMODAL COMMAND BAR (Integrated)                        */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* The Unified Container */
.command-bar {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    justify-content: center;
    z-index: 20;
    box-shadow: 2px 2px 20px 0px #00000030;
    padding: 0.5rem;
    gap: 0.5rem;
    width: 100%;
    max-width: 800px;
}

.command-bar:focus-within {
    border-color: var(--text-muted);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* Internal Staging Area */
.staging-area {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem 0.5rem 0.75rem 0.5rem;
    overflow-x: auto;
    width: 100%;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

.staging-area.hidden {
    display: none;
}

.staging-thumb {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* The Remove Button Container */
.staging-thumb-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: none;
    transition: all 0.2s;
    z-index: 10;
    opacity: 0;
    transform: scale(0.8);
    line-height: 0;
    /* Strips default font baseline metrics */
}

.staging-thumb:hover .staging-thumb-remove {
    opacity: 1;
    transform: scale(1);
}

.staging-thumb-remove:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* The Input Row & Perfect Vertical Centering */
.command-input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    width: 100%;
}

.command-input-row .icon-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.2rem;
    /* Nudges the buttons up to match text baseline */
}

.command-input-row textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    padding: 0.55rem 0;
    max-height: 200px;
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 09. WORKSPACE EXPLORER (Sidebar Memory)                        */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

.panel-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem 1rem;
    gap: 2px;
}

/* Individual Chat Thread Item */
.history-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: none;
    transition: all 0.2s;
    color: var(--text-muted);
    font-size: 0.85rem;
    position: relative;
    border: 1px solid transparent;
    /* Prevents layout shift */
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.history-item.active {
    background: var(--bg-surface);
    color: var(--text-main);
    font-weight: 500;
    border-color: var(--border);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.history-item-icon {
    width: 14px;
    height: 14px;
    margin-right: 0.5rem;
    opacity: 0.7;
    flex-shrink: 0;
}

.history-item-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
    margin-right: 0.5rem;
}

/* Premium Inline Editing State */
.history-item-title[contenteditable="true"] {
    background: var(--bg-base);
    color: var(--text-main);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--text-muted);
    text-overflow: clip;
    white-space: nowrap;
    cursor: text;
}

/* Action Buttons */
.history-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.history-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 22px;
    height: 22px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: none;
    transition: all 0.2s;
}

.history-action-btn:hover {
    background: var(--bg-panel);
    color: var(--text-main);
}

.history-action-btn.delete:hover {
    color: var(--error);
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 10. CHAT STREAM & MESSAGES (PREMIUM UX)                        */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

#chat-stream {
    scroll-behavior: smooth;
    padding: 2rem 15% 14rem 15% !important;
    /* Massive bottom padding clears the command bar */
}

@media (max-width: 1024px) {
    #chat-stream {
        padding: 2rem 5% 14rem 5% !important;
    }
}

#chat-stream.hidden,
#welcome-screen.hidden {
    display: none !important;
}

/* Individual Message Layout */
.message-row {
    display: flex;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    gap: 1.2rem;
    animation: subtleFade 0.3s ease-out forwards;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.ai {
    justify-content: flex-start;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-main);
    margin-top: 0.2rem;
}

/* Content Wrappers */
.message-content-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    min-width: 0;
}

/* CRITICAL: Forces full width so user text isn't squished */
.message-row.user .message-content-wrapper {
    align-items: flex-end;
    width: 100%;
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.message-row.user .message-content {
    background: var(--text-main);
    color: var(--bg-base);
    padding: 0.85rem 1.25rem;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-soft);
    width: fit-content;
    max-width: 100%;
}

.message-row.ai .message-content {
    background: transparent;
    color: var(--text-main);
    padding: 0.5rem 0;
}

/* Markdown Styling */
.message-content strong {
    font-weight: 600;
    color: var(--text-main);
}

/* Base styles for all markdown headings */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.3;
}

/* Custom cascading margins: top right bottom left */
.message-content h1 {
    margin: 2.2rem 0 1.2rem 0;
    /* Massive top spacing for major sections */
    font-size: 1.6rem;
}

.message-content h2 {
    margin: 1.8rem 0 1rem 0;
    /* Standard section spacing */
    font-size: 1.3rem;
}

.message-content h3 {
    margin: 3rem 0 0.8rem 0;
    /* Tighter spacing for subsections */
    font-size: 1.1rem;
}

.message-content h4 {
    margin: 1.2rem 0 0.5rem 0;
    /* Very tight for minor points */
    font-size: 0.95rem;
}

.message-content code {
    font-family: 'JetBrains Mono', monospace;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
}

/* FIX: Premium Code Block Wrapper (Stitches header and code perfectly) */
.code-block-wrapper {
    margin: 1rem 0 0 0;
    border-radius: 8px;
    /* Prevents the header and pre from detaching */
    border: 1px solid var(--border-strong);
    background: var(--bg-panel);
    box-shadow: var(--shadow-soft);
    white-space: normal;
    /* FIX: Collapses the invisible HTML formatting gaps */
    padding-bottom: 1rem;
    width: 800px;
}

.code-header {
    background: var(--bg-surface);
    padding: 0.7rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    border-bottom: 1px solid var(--border-strong);

    /* FIX: Sticky Header (Travels down the block with you) */
    position: sticky;
    top: -2rem;
    z-index: 10;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.code-header button {
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-panel);
    color: var(--text-muted);
    transition: 0.2s;
}

.code-header button:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}

.message-content pre {
    margin: 0 !important;
    /* Overrides default spacing */
    padding: 2rem 0 2rem 2rem !important;
    overflow-x: auto;
    background: transparent !important;
    /* Uses wrapper bg */
    border: none !important;
    box-shadow: none !important;
    /* border-radius: 0 !important; */
}

.message-content pre code {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    font-size: 0.85rem;
    line-height: 1.8;
    /* FIX: Removed color override so Highlight.js can apply syntax colors */
}

/* Force Highlight.js to inherit our background so it seamlessly matches the UI */
.hljs {
    background: transparent !important;
}

/* Sleek Horizontal Scrollbar for Code Blocks */
.message-content pre::-webkit-scrollbar {
    height: 8px;
}

.message-content pre::-webkit-scrollbar-track {
    background: transparent;
    margin: 0 4px;
}

.message-content pre::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
}

.message-content pre::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.streaming-cursor {
    display: inline-block;
    width: 8px;
    height: 16px;
    background-color: var(--text-main);
    vertical-align: middle;
    margin-left: 4px;
    animation: blink 1s step-end infinite;
}

/* Markdown Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--border);
    /* Inner border trick */
}

.message-content th,
.message-content td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.message-content th {
    background: var(--bg-surface);
    font-weight: 600;
    color: var(--text-main);
}

.message-content tr:last-child td {
    border-bottom: none;
}

.message-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="light"] .message-content tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

/* Action Bar (Copy, Retry) */
.message-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message-row:hover .message-actions,
.message-row.error .message-actions {
    opacity: 1;
}

.msg-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    cursor: none;
}

.msg-action-btn:hover {
    background: var(--bg-surface);
    color: var(--text-main);
}

.message-row.error .message-content {
    color: var(--error);
}

/* User Message Edit Controls */
.message-actions.user-actions {
    justify-content: flex-end;
}

.message-row.user .msg-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.edit-container {
    width: 100%;
    min-width: 300px;
    background: var(--bg-surface);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.edit-textarea {
    background: var(--bg-base);
    color: var(--text-main);
    border: 1px solid var(--border-strong);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* ELITE ATTACHMENT PILLS (ChatGPT / Gemini Style)                */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.user-attachments-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    width: 100%;
    justify-content: flex-end;
    /* Aligns pills to the right above user text */
}

.attachment-pill {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    user-select: none;
}

/* File Document Pill */
.attachment-pill.file {
    padding: 0.4rem 0.8rem;
    gap: 0.6rem;
    max-width: 220px;
}

.attachment-pill .file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ef4444;
    /* Vivid red for code/documents */
    background: rgba(239, 68, 68, 0.1);
    padding: 0.4rem;
    border-radius: 8px;
}

.attachment-pill .file-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.attachment-pill .file-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-pill .file-ext {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    margin-top: 2px;
}

/* Image Thumbnail Pill */
.attachment-pill.image {
    width: 80px;
    height: 80px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
}

.attachment-pill.image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 11. BUTTONS & UI LOCKS                                         */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
.primary-btn-cancel {
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 2px solid var(--border);
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: none;
    transition: 0.2s;
}

.primary-btn-cancel:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
}


.cmd-submit.stop-mode {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-main);
}

.cmd-submit.stop-mode:hover {
    background: rgba(239, 68, 68, 0.1);
    /* Faint red on hover */
    border-color: var(--error);
    color: var(--error);
}

/* Remove the opacity lock so the button remains clickable to stop */
.generating-lock {
    opacity: 1;
    pointer-events: auto;
}


/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 12. DRAG & DROP OVERLAY                                        */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
#global-drag-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 185, 129, 0.05);
    /* Faint Nexus Green */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 4px dashed #10b981;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#global-drag-overlay.active {
    opacity: 1;
}

#global-drag-overlay h2 {
    color: #10b981;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 600;
    pointer-events: none;
}