:root {
    /* SOTA Token System - 2026 Core Aesthetics */
    /* Dark blue-grays, pure blacks avoided for lower eye strain */
    --bg-base: #0F0F13;
    --surface-0: rgba(26, 26, 36, 0.4);
    --surface-1: rgba(255, 255, 255, 0.03);
    --surface-2: rgba(255, 255, 255, 0.06);
    --surface-elevated: rgba(30, 30, 42, 0.9);
    
    --border-light: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.4);
    
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    
    --accent-primary: #6366F1;
    --accent-primary-glow: rgba(99, 102, 241, 0.5);
    --accent-secondary: #10B981;
    --accent-warning: #F59E0B;
    --accent-danger: #EF4444;

    /* Proper Hierarchy Fonts SOTA */
    --font-ui: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Base 4px/8px Grid Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;

    /* Scaled Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden; 
    height: 100vh;
    font-size: 14px;
    line-height: 1.6;
    letter-spacing: -0.01em; /* SOTA text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----------------------------------------------------
    Ambient Motion - "System is alive"
------------------------------------------------------- */
.ambient-glow {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.15;
    z-index: 0;
    pointer-events: none;
    animation: drift 25s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
}
.glow-primary {
    top: -150px; left: -150px;
    background: var(--accent-primary);
    animation-delay: 0s;
}
.glow-secondary {
    bottom: -150px; right: -150px;
    background: var(--accent-secondary);
    animation-delay: -12s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(150px, 100px) scale(1.2); }
}

/* ----------------------------------------------------
    Layout Grid - Responsive & Structured
------------------------------------------------------- */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr 340px var(--workspace-width, 0px);
    grid-template-rows: 64px 1fr 32px;
    grid-template-areas: 
        "header header header"
        "main right workspace"
        "footer footer footer";
    height: 100vh;
    gap: var(--space-3);
    padding: var(--space-3);
    padding-bottom: var(--space-2);
    transition: grid-template-columns 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    z-index: 10;
}

/* ----------------------------------------------------
    Typography & Hierarchy Util
------------------------------------------------------- */
.mono-text { font-family: var(--font-mono); font-size: 12px; letter-spacing: -0.02em; }
.subtle { color: var(--text-muted); }
.text-success { color: var(--accent-secondary); text-shadow: 0 0 10px rgba(16,185,129,0.5); }
.text-info { color: var(--accent-primary); text-shadow: 0 0 10px rgba(99,102,241,0.5); }
.text-warning { color: var(--accent-warning); text-shadow: 0 0 10px rgba(245,158,11,0.5); }
.text-danger { color: var(--accent-danger); text-shadow: 0 0 10px rgba(239,68,68,0.5); }

/* ----------------------------------------------------
    SOTA True Glassmorphism Pattern (Knowledge Bank: 12px+ Blur)
------------------------------------------------------- */
.glass-panel {
    background: var(--surface-1);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05), 0 4px 24px rgba(0, 0, 0, 0.2);
    flex-direction: column;
    overflow: hidden; /* Ensure children don't bleed out */
}

/* For floating command center things */
.glass-panel-elevated {
    background: var(--surface-evelated);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

/* ----------------------------------------------------
    Top HUD Navigation
------------------------------------------------------- */
.top-hud {
    grid-area: header;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-4);
    flex-direction: row; /* Overriding default glass-panel */
}
.hud-left, .hud-center, .hud-right { display: flex; align-items: center; gap: var(--space-4); }

.status-indicator { display: flex; align-items: center; gap: var(--space-2); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; }
.pulse-dot.online {
    background: var(--accent-secondary);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse-animation 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes pulse-animation { to { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); } }

.divider { height: 24px; width: 1px; background: var(--border-light); }

.badge {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}
.primary-badge {
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
    border: 1px solid var(--accent-primary-glow);
}
.ai-badge {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-warning);
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.telemetry-item { display: flex; flex-direction: column; align-items: flex-start; }
.tel-label { font-size: 10px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;}
.tel-value { font-family: var(--font-mono); font-size: 16px; font-weight: 700; color: var(--text-primary); }
.highlight-cost .tel-value { color: var(--accent-danger); text-shadow: 0 0 15px rgba(239,68,68,0.4); }

/* ----------------------------------------------------
    Main Center Canvas - Chat Stream
------------------------------------------------------- */
.center-canvas { 
    grid-area: main; 
    position: relative; 
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.canvas-header {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    padding: 0 var(--space-4);
    background: rgba(0,0,0,0.1);
}
.tab {
    padding: var(--space-4) var(--space-4);
    font-size: 13px; font-weight: 600; color: var(--text-muted);
    cursor: pointer; position: relative;
    transition: color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.tab.active { color: var(--text-primary); text-shadow: 0 0 12px rgba(99, 102, 241, 0.5); }
.tab::after {
    content: ''; position: absolute; bottom: -1px; left: 0; width: 100%; height: 2px;
    background: var(--accent-primary); transform: scaleX(0);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: left;
}
.tab.active::after { transform: scaleX(1); }

.chat-stream {
    flex: 1; 
    overflow-y: auto; 
    padding: var(--space-5);
    display: flex; 
    flex-direction: column; 
    gap: var(--space-5);
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.1) 80%);
    scroll-behavior: smooth;
}

.message { max-width: 85%; animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.message.system-msg { margin: 0 auto; max-width: 100%; text-align: center; }

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

.msg-meta { display: flex; gap: var(--space-3); margin-bottom: var(--space-2); align-items: baseline; }
.system-msg .msg-meta { justify-content: center; }
.msg-author { font-size: 12px; font-weight: 700; color: var(--accent-primary); letter-spacing: 0.05em; text-transform: uppercase; }
.msg-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.msg-content {
    background: rgba(255,255,255,0.02);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    border-top-left-radius: 2px;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 14px;
}
.msg-content p { margin-bottom: var(--space-3); }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content strong { color: var(--text-primary); font-weight: 600; }
.msg-content pre {
    background: #09090C; padding: var(--space-3); border-radius: var(--radius-sm);
    border: 1px solid var(--border-light); overflow-x: auto; margin-bottom: var(--space-3);
}
.msg-content code { font-family: var(--font-mono); font-size: 12.5px; color: #E2E8F0; }

.system-msg .msg-content {
    background: transparent; border: none; font-style: italic; color: var(--text-muted); padding: 0; font-size: 12px;
}

/* ----------------------------------------------------
    Tool Usage Render Classes (NEW for RAW JSON overrides)
------------------------------------------------------- */
.tool-action-block {
    margin-top: var(--space-2);
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-left: 3px solid var(--accent-secondary);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    font-family: var(--font-ui);
}
.tool-action-title {
    font-size: 13px; font-weight: 600; color: var(--text-primary);
    margin-bottom: 4px; display: flex; align-items: center; gap: var(--space-2);
}
.tool-action-summary {
    font-size: 12px; color: var(--text-secondary);
}

.interactive-option {
    padding: var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(8px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    margin-top: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.interactive-option:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.12);
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.2);
}
.interactive-option:active {
    transform: translateY(0) scale(0.98);
}

/* Inline Decision Specifics */
.inline-decision-block {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-top: var(--space-3);
    border-left: 2px solid var(--accent-primary-glow);
    padding-left: var(--space-3);
}

.inline-option {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.inline-option:hover {
    background: var(--accent-primary-glow);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.inline-option .opt-title { font-weight: 700; font-size: 13px; color: var(--text-primary); }
.inline-option .opt-summary { font-size: 11px; color: var(--text-muted); margin-left: var(--space-3); }

/* Universal premium button styling for any dynamically injected buttons */
button, .btn-primary, .interactive-option button {
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
button:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ----------------------------------------------------
    Command Input Bar (Floating)
------------------------------------------------------- */
.prompt-bar {
    width: 100%;
    display: flex; 
    flex-direction: column;
    padding: var(--space-4);
    border-top: 1px solid var(--border-light);
    background: var(--surface-0);
    z-index: 50;
}
.prompt-meta { margin-bottom: var(--space-2); }
.input-wrapper { display: flex; align-items: center; gap: var(--space-3); }
#command-input {
    flex: 1; background: transparent; border: none; color: var(--text-primary);
    padding: var(--space-2); outline: none; font-family: var(--font-ui); font-size: 15px; resize: none;
}
#command-input::placeholder { color: var(--text-muted); }
.send-btn {
    background: var(--surface-2); border: 1px solid var(--border-light); color: var(--text-primary);
    width: 44px; height: 44px; border-radius: var(--radius-md); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.send-btn:hover { background: var(--accent-primary); color: white; transform: scale(1.05); border-color: var(--accent-primary); }

/* ----------------------------------------------------
    Right Sidebar - Widgets & SOTA North Star
------------------------------------------------------- */
.sidebar-right { grid-area: right; display: flex; flex-direction: column; gap: var(--space-4); }

.glass-widget {
    background: var(--surface-1);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex; flex-direction: column; gap: var(--space-3);
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.02);
}

.widget-header { 
    font-size: 10px; font-weight: 800; color: var(--text-muted); 
    letter-spacing: 0.12em; text-transform: uppercase; 
    border-bottom: 1px solid var(--border-light); 
    padding-bottom: var(--space-2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.technical-fragment {
    display: none !important;
}
.reveal-technical {
    font-size: 9px;
    padding: 2px 6px;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s;
}
.reveal-technical:hover { opacity: 1; border-color: var(--accent-primary); }

/* North Star Panel */
.north-star-widget {
    border: 1px solid rgba(245, 158, 11, 0.3);
    background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.05), transparent);
}
.ns-content { display: flex; flex-direction: column; gap: var(--space-2); }
.ns-macro { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.ns-focus { font-size: 13px; color: var(--text-secondary); font-style: italic; }
.ns-section { margin-top: var(--space-2); }
.ns-label { font-size: 10px; color: var(--text-muted); font-weight: 700; letter-spacing: 0.05em; display: block; margin-bottom: 6px; }
.ns-list { list-style: none; padding-left: 0; }
.ns-list li {
    font-size: 11px; color: var(--text-secondary); margin-bottom: var(--space-2);
    position: relative; padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}
.ns-list li:hover {
    background: rgba(245, 158, 11, 0.1);
    color: var(--text-primary);
    transform: translateX(4px);
}
.ns-list li::before {
    content: '→'; position: absolute; left: 4px; color: var(--accent-warning);
}

/* ROI Big Numbers */
.metric-block { display: flex; flex-direction: column; }
.metric-meta { font-size: 12px; color: var(--text-muted); }
.metric-big { font-family: var(--font-mono); font-size: 36px; font-weight: 700; color: var(--text-primary); letter-spacing: -1px; }

.sparkline { display: flex; align-items: flex-end; gap: 4px; height: 48px; margin-top: var(--space-2); }
.spark-bar { flex: 1; background: var(--surface-2); border-radius: 3px 3px 0 0; transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1); }

/* Circle Progress */
.chart-container { display: flex; justify-content: center; padding: var(--space-3) 0; }
.radial-progress { width: 120px; height: 120px; background-color: rgba(0,0,0,0.4); border-radius: 50%; position: relative; }
.radial-progress .circle .mask, .radial-progress .circle .fill { width: 120px; height: 120px; position: absolute; border-radius: 50%; }
.radial-progress .circle .mask { clip: rect(0px, 120px, 120px, 60px); }
.radial-progress .circle .mask .fill { clip: rect(0px, 60px, 120px, 0px); background-color: var(--accent-secondary); transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1); }
.radial-progress .inset {
    width: 100px; height: 100px; position: absolute; margin-left: 10px; margin-top: 10px;
    background-color: var(--surface-elevated); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: inset 0 4px 10px rgba(0,0,0,0.6);
}
.radial-progress .percentage { font-size: 24px; font-weight: 700; color: var(--text-primary); text-shadow: 0 0 15px rgba(16,185,129,0.2); }

.widget-footer { font-size: 11px; text-align: center; border-top: 1px solid var(--border-light); padding-top: var(--space-3); font-weight: 600; }

/* Watcher Logs */
.log-list { display: flex; flex-direction: column; gap: var(--space-3); overflow-y: auto; max-height: 180px; }
.log-item { display: flex; flex-direction: column; gap: 4px; padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-light); }
.log-item:last-child { border-bottom: none; }
.log-level { font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: 0.05em; }
.log-text { font-size: 13px; color: var(--text-secondary); line-height: 1.4; }
.log-time { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

/* ----------------------------------------------------
    Artifact Side Panel - Professional Flow
------------------------------------------------------- */
.artifact-side-panel {
    grid-area: workspace;
    position: relative;
    height: 100%;
    width: 100%;
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.artifact-side-panel.open {
    opacity: 1;
    pointer-events: all;
}

.artifact-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
}
.art-meta { display: flex; align-items: center; gap: var(--space-3); }

.artifact-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

/* ----------------------------------------------------
    System Footer - Constant Feedback
------------------------------------------------------- */
.system-footer {
    grid-area: footer;
    height: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--space-4);
    font-size: 10px;
}
.footer-left, .footer-right { display: flex; align-items: center; gap: var(--space-4); }
.status-item { opacity: 0.6; }

.mini-pulse { width: 6px; height: 6px; }

/* In-message Premium UI blocks */
.msg-content .preview-code-block {
    margin-top: var(--space-3);
    background: var(--surface-0);
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Fix for the misplaced preview buttons in the user screenshot */
.msg-content .manifestation-trigger {
    background: var(--accent-primary-glow);
    border: 1px solid var(--accent-primary);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}
.msg-content .manifestation-trigger:hover {
    background: var(--accent-primary);
    color: white;
}

/* ----------------------------------------------------
    Scrollbars & Global Polish
------------------------------------------------------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* HIDDEN UTILS */
.hidden { display: none !important; }
