:root {
    --bg-mesh: radial-gradient(at 40% 20%, hsla(228,100%,94%,1) 0px, transparent 50%),
               radial-gradient(at 80% 0%, hsla(189,100%,96%,1) 0px, transparent 50%),
               radial-gradient(at 0% 50%, hsla(355,100%,97%,1) 0px, transparent 50%);
    --glass-bg: rgba(255, 255, 255, 0.70);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 4px 16px 0 rgba(31, 38, 135, 0.05);
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-mesh), #cbd5e1;
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4 { font-family: 'Outfit', sans-serif; font-weight: 600; }
.glass-panel { background: var(--glass-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--glass-border); border-radius: 12px; box-shadow: var(--glass-shadow); }

/* --- AUTH SPA SCREEN --- */
.auth-layout {
    width: 100vw; height: 100vh;
    display: flex; align-items: center; justify-content: center;
}
.auth-glass { width: 500px; padding: 40px; display: flex; flex-direction: column; gap: 30px; animation: slideUp 0.4s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.auth-header { text-align: center; }
.auth-header h1 { font-size: 2rem; margin-top: 10px; color: #1e293b;}
.auth-header h1 span { color: var(--accent); }
.persona-cards { display: flex; flex-direction: column; gap: 15px; }
.persona-card { display: flex; align-items: center; gap: 15px; padding: 15px 20px; border: 1px solid rgba(0,0,0,0.1); border-radius: 12px; cursor: pointer; transition: 0.2s; background: rgba(255,255,255,0.5); }
.persona-card:hover { transform: scale(1.02); border-color: var(--accent); background: white;}
.p-avatar { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.p-badge { font-size: 0.65rem; padding: 2px 6px; border-radius: 4px; font-weight: 600;}
.admin-badge { background: rgba(79, 70, 229, 0.1); color: var(--accent); }
.standard-badge { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.auth-form-mock { display: flex; flex-direction: column; gap: 10px; text-align: center; border-top: 1px dashed rgba(0,0,0,0.1); padding-top: 20px; font-size: 0.8rem; color: var(--text-secondary); }
.auth-form-mock input { padding: 10px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.1); }
.auth-form-mock button { padding: 10px; border-radius: 8px; border: none; background: #e2e8f0; color: #94a3b8; cursor: not-allowed; }

/* --- OS LAYOUT --- */
.os-layout { width: 100vw; height: 100vh; display: flex; flex-direction: column; }

/* TOP NAV BAR */
.top-nav { height: 48px; display: flex; justify-content: space-between; align-items: center; padding: 0 20px; background: rgba(255,255,255,0.85); border-bottom: 1px solid var(--glass-border); z-index: 10; }
.nav-left { display: flex; align-items: center; gap: 8px;}
.nav-left h2 { font-size: 1rem; color: #334155;}
.nav-left h2 span { font-weight: 400; color: var(--text-secondary); }
.search-bar { background: rgba(0,0,0,0.05); border: none; padding: 6px 12px; border-radius: 6px; width: 300px; outline: none; font-size: 0.85rem;}
.nav-right { display: flex; align-items: center; gap: 15px; font-size: 0.85rem; }
.user-persona { font-weight: 500; }

.app-layout { flex-grow: 1; display: flex; gap: 15px; padding: 15px; overflow: hidden; }

/* FAR LEFT ACTIVITY BAR */
.activity-bar { width: 48px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; padding: 10px 0; align-items: center; }
.activity-btn { width: 32px; height: 32px; border: none; background: transparent; border-radius: 8px; font-size: 1.2rem; cursor: pointer; transition: 0.2s; opacity: 0.6; }
.activity-btn:hover { background: rgba(0,0,0,0.05); opacity: 1; }
.activity-btn.active { opacity: 1; background: rgba(79, 70, 229, 0.1); color: var(--accent); }

/* WORKSPACE LEFT AREA */
.workspace { flex-grow: 1; display: flex; gap: 15px; min-width: 500px; }

.file-explorer { width: 250px; flex-shrink: 0; display: flex; flex-direction: column; padding: 15px 0; }
.explorer-header { display: flex; justify-content: space-between; align-items: center; padding: 0 15px 15px 15px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.explorer-header h3 { font-size: 0.85rem; letter-spacing: 0.5px; color: var(--text-secondary); text-transform: uppercase;}
.explorer-label { padding: 12px 15px 5px 15px; font-size: 0.75rem; font-weight: 600; color: #94a3b8; text-transform: capitalize; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); border-radius: 4px; padding: 4px; transition: background 0.2s; }
.icon-btn:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }

.file-list { list-style: none; overflow-y: auto; flex-grow: 1; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 8px 15px; font-size: 0.85rem; cursor: grab; border-left: 3px solid transparent; transition: all 0.2s; user-select: none; }
.file-item:active { cursor: grabbing; opacity: 0.7; }
.file-item:hover { background: rgba(255,255,255,0.5); }
.file-item.active { background: white; border-left-color: var(--accent); color: var(--accent); font-weight: 500; }
.file-item input { background: transparent; border: none; border-bottom: 1px solid var(--accent); font-family: inherit; font-size: inherit; color: inherit; width: 100%; outline: none; }

.editor-pane { flex-grow: 1; display: flex; flex-direction: column; overflow: hidden; }
.editor-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid rgba(0,0,0,0.05); background: rgba(255,255,255,0.4); }
.editor-title { display: flex; align-items: center; gap: 8px; flex-grow:1; }
.editor-title input { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 1.1rem; border: none; background: transparent; outline: none; color: var(--text-primary); width:100%; }
.danger-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); border-radius: 4px; padding: 4px; transition: 0.2s;}
.danger-btn:hover { color: var(--danger); background: rgba(239,68,68,0.1); }
.danger-btn.sm { background: rgba(239,68,68,0.1); color: var(--danger); }

.primary-btn { background: var(--accent); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 0.85rem; font-weight: 500; transition:0.2s;}
.primary-btn.sm { padding: 4px 10px; font-size: 0.75rem; }
.primary-btn.success { background: var(--success); }
.primary-btn:hover { opacity: 0.9; }

.editor-content { flex-grow: 1; position: relative; }
textarea#mainEditor, textarea#proposedEditor { position: absolute; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; padding: 20px; border: none; background: transparent; font-family: 'Fira Code', monospace; line-height: 1.6; font-size: 0.90rem; color: #334155; resize: none; outline: none; }
#mainEditor:disabled { background: rgba(0,0,0,0.02); }

/* Proposed Edit Overlay */
.proposal-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.95); z-index: 5; display: flex; flex-direction: column; animation: slideUp 0.3s ease;}
.proposal-header { display: flex; justify-content: space-between; align-items: center; background: rgba(16, 185, 129, 0.1); padding: 10px 20px; color: var(--success); border-bottom: 1px solid rgba(16,185,129,0.3); }
.proposal-diff { flex-grow: 1; position: relative; }
#proposedEditor { background: rgba(16, 185, 129, 0.05); color: #065f46; font-weight: 500;}

/* AGENT SIDEBAR (Right Side) */
.chat-sidebar { width: 400px; flex-shrink: 0; display: flex; flex-direction: column; }
header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.logo h1 { font-size: 1.1rem; display: inline-block; margin-left:8px; vertical-align: middle;}
.logo h1 span { color: var(--accent); }
.status-badge { padding: 4px 8px; background: rgba(16, 185, 129, 0.1); color: var(--success); border-radius: 4px; font-size: 0.7rem; font-weight: 600; }

.chat-container { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 15px; padding: 20px; }
.chat-container::-webkit-scrollbar { width: 6px; }
.chat-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.message { display: flex; gap: 10px; max-width: 90%; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.avatar { width: 32px; height: 32px; border-radius: 50%; background: #e2e8f0; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }
.user-message .bubble { background: var(--text-primary); color: white; border-radius: 12px 12px 2px 12px; }
.user-message .avatar { display: none; }
.system-message { align-self: flex-start; }
.system-message .bubble { background: #ffffff; color: var(--text-primary); border-radius: 2px 12px 12px 12px; border: 1px solid #e2e8f0; }
.bubble { padding: 10px 14px; font-size: 0.85rem; line-height: 1.5; word-break: break-word; white-space: pre-wrap; box-shadow: 0 2px 4px rgba(0,0,0,0.02); width:100%;}

/* Chat Input Bar */
.chat-input-wrapper { padding: 15px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(0,0,0,0.05); transition: background 0.3s;}
.chat-input-wrapper.dragover { background: rgba(79, 70, 229, 0.1); border: 2px dashed var(--accent); border-radius: 12px;}

.chat-controls { display: flex; justify-content: flex-start; align-items: center; gap: 8px; flex-wrap: wrap;}
.model-dropdown { background: white; border: 1px solid #cbd5e1; border-radius: 4px; padding: 4px 8px; font-size: 0.70rem; color: var(--text-secondary); outline: none; }

.attachment-preview { background: #e2e8f0; padding: 4px 10px; border-radius: 12px; font-size: 0.75rem; display: inline-flex; align-items: center; gap: 8px; color: var(--text-primary); }
.attachment-preview button { background: none; border: none; cursor: pointer; color: var(--danger); font-weight: bold;}

form { display: flex; align-items: flex-end; gap: 6px; width: 100%; border: 1px solid #cbd5e1; border-radius: 20px; padding: 4px; background: white; transition: border-color 0.2s;}
form:focus-within { border-color: var(--accent); }

/* Audio Layout */
.attach-btn, .mic-btn { cursor: pointer; font-size: 1.1rem; display:flex; align-items:center; justify-content:center; width: 32px; height: 32px; border-radius: 50%; transition: background 0.2s; color: var(--text-secondary); border: none; background: transparent; flex-shrink:0;}
.attach-btn:hover, .mic-btn:hover { background: #f1f5f9; color: var(--text-primary); }

.mic-btn.listening { color: white; background: var(--danger); animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

#chatInput { flex-grow: 1; background: transparent; border: none; padding: 8px 6px; font-family: inherit; font-size: 0.85rem; resize: none; max-height: 150px; overflow-y: auto; outline: none; }

.send-btn { background: var(--accent); color: white; border: none; border-radius: 50%; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; flex-shrink: 0; margin-bottom: 2px; margin-right: 2px;}
.send-btn:hover { background: var(--accent-hover); transform: scale(1.05); }
.send-btn:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; }

.context-hint { font-size: 0.7rem; color: var(--text-secondary); text-align: center; }

/* Minimal steps & Feedback styling */
.pipeline-step-container { margin-bottom: 8px; display: flex; flex-direction: column; gap: 2px; margin-left: 5px;}
.pipeline-step { font-size: 0.8rem; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; transition: color 0.1s; width: fit-content; }
.pipeline-step:hover { color: var(--accent); }
.step-caret { font-size: 0.6rem; transition: transform 0.2s; }
.step-caret.expanded { transform: rotate(90deg); }
.step-details { font-size: 0.75rem; color: var(--text-secondary); margin-left: 18px; padding-left: 8px; border-left: 2px solid #e2e8f0; margin-top: 2px; margin-bottom: 4px; display: none; white-space: pre-wrap; }

.feedback-widget { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e2e8f0; display: flex; flex-direction: column; gap: 5px; }
.feedback-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.feedback-btn { background: none; border: none; cursor: pointer; font-size: 1.1rem; opacity: 0.6; transition: opacity 0.2s; }
.feedback-btn:hover { opacity: 1; transform: scale(1.1); }
.judge-alert { background: rgba(239, 68, 68, 0.1); color: var(--danger); padding: 6px 10px; border-radius: 6px; font-size: 0.75rem; margin-bottom: 5px; }
