:root {
  --bg-void: #060811;
  --bg-surface: #0b0f1d;
  --bg-panel: #0f1526;
  --bg-elevated: #161e35;
  --bg-hover: #1d2846;
  --bg-active: #243258;
  --border-subtle: rgba(120, 145, 205, 0.14);
  --border-bright: rgba(0, 240, 255, 0.36);
  --accent-cyan: #00f0ff;
  --accent-blue: #4f8cff;
  --accent-violet: #8b5cf6;
  --accent-magenta: #ff0077;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --text-primary: #eef2ff;
  --text-secondary: #9aa7c7;
  --text-muted: #647499;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
}

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

html, body, .app-root {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ==========================================
   Unified Single-Step 2FA Login View
   ========================================== */
.login-shell {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background:
    radial-gradient(circle at 20% 20%, rgba(79, 140, 255, 0.14), transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(255, 0, 119, 0.12), transparent 45%),
    linear-gradient(180deg, #04060d 0%, #090d1c 100%);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(11, 15, 29, 0.92);
  border: 1px solid rgba(0, 240, 255, 0.32);
  border-radius: 20px;
  padding: 34px 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65), 0 0 32px rgba(0, 240, 255, 0.09);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet), var(--accent-magenta));
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-brand-badge {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.18), rgba(139, 92, 246, 0.25));
  border: 1px solid rgba(0, 240, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.login-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 22px;
  line-height: 1.5;
}

.field-group {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  background: rgba(5, 8, 18, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 11px 13px;
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.12);
}

.field-input.totp-input {
  font-family: var(--font-mono);
  font-size: 22px;
  text-align: center;
  letter-spacing: 8px;
  color: var(--accent-cyan);
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
  margin-bottom: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 700;
  padding: 11px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.12s, filter 0.15s;
}

.btn-primary:hover {
  filter: brightness(1.12);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: rgba(0, 240, 255, 0.3);
}

.btn-ghost.active {
  background: rgba(79, 140, 255, 0.18);
  color: var(--accent-cyan);
  border-color: rgba(0, 240, 255, 0.45);
}

/* ==========================================
   IDE Workbench Layout
   ========================================== */
.ide-shell {
  display: grid;
  grid-template-rows: 42px 1fr 24px;
  width: 100%;
  height: 100%;
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 12px;
}

.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.4px;
  color: var(--accent-cyan);
  padding-right: 8px;
}

.select-compact {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}

.command-bar-btn {
  width: 320px;
  max-width: 36vw;
  background: var(--bg-void);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 5px 12px;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.command-bar-btn:hover {
  border-color: var(--accent-blue);
  color: var(--text-secondary);
}

.kbd-hint {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

.owner-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 3px 8px;
  border-radius: 999px;
}

/* Main 4-Column Body: ActivityBar | SidePanel | Editor+Terminal | AgentPane */
.workbench-body {
  display: grid;
  grid-template-columns: 48px 260px 1fr 410px;
  height: 100%;
  min-height: 0;
}

.workbench-body.sidebar-collapsed {
  grid-template-columns: 48px 0px 1fr 410px;
}

.workbench-body.agent-collapsed {
  grid-template-columns: 48px 260px 1fr 0px;
}

/* Activity Bar */
.activity-bar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 6px;
}

.activity-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.15s;
}

.activity-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.activity-btn.active {
  color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.1);
  border-color: rgba(0, 240, 255, 0.3);
}

/* Left Side Panel */
.side-panel {
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-header {
  height: 36px;
  padding: 0 10px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.panel-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 5px;
  font-size: 12px;
}

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

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}

/* File Tree */
.tree-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
  font-size: 12.5px;
  gap: 6px;
}

.tree-row:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tree-row.active {
  background: var(--bg-active);
  color: #fff;
}

.tree-label {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-row-actions {
  display: none;
  gap: 2px;
}

.tree-row:hover .tree-row-actions {
  display: flex;
}

.tree-children {
  padding-left: 13px;
  border-left: 1px solid rgba(120, 145, 205, 0.1);
  margin-left: 9px;
}

/* Center Column: Editor + Bottom Terminal */
.center-workbench {
  display: grid;
  grid-template-rows: 1fr 235px;
  min-width: 0;
  min-height: 0;
  background: var(--bg-void);
}

.center-workbench.terminal-collapsed {
  grid-template-rows: 1fr 32px;
}

.editor-stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  position: relative;
}

.tabs-bar {
  height: 35px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  overflow-x: auto;
  gap: 2px;
  padding: 0 6px;
  flex-shrink: 0;
}

.editor-tab {
  height: 29px;
  padding: 0 10px;
  border-radius: 6px 6px 0 0;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.editor-tab.active {
  background: var(--bg-void);
  color: var(--accent-cyan);
  border-color: rgba(0, 240, 255, 0.35);
}

.dirty-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-amber);
}

.breadcrumbs-bar {
  height: 28px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.ai-lens-strip {
  display: flex;
  align-items: center;
  gap: 6px;
}

.editor-split-area {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  min-height: 0;
  position: relative;
}

.editor-split-area.with-preview {
  grid-template-columns: 1fr 1fr;
}

.monaco-host, .diff-host {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.preview-pane {
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: #fff;
  min-height: 0;
}

.preview-toolbar {
  height: 30px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
}

.preview-iframe {
  flex: 1;
  border: none;
  width: 100%;
  background: #fff;
}

/* Ctrl+I Inline Command Floating Bar */
.inline-cmd-widget {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  width: min(620px, 90%);
  background: rgba(15, 21, 38, 0.97);
  border: 1px solid var(--accent-cyan);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.7), 0 0 24px rgba(0, 240, 255, 0.16);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diff-review-banner {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 21, 38, 0.96);
  border: 1px solid var(--accent-emerald);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 30;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
}

/* Bottom PTY Terminal Dock */
.terminal-dock {
  border-top: 1px solid var(--border-subtle);
  background: #070a14;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.terminal-header {
  height: 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  flex-shrink: 0;
}

.terminal-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.term-tab {
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--bg-panel);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  font-size: 11.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.term-tab.active {
  color: var(--accent-cyan);
  border-color: rgba(0, 240, 255, 0.4);
  background: var(--bg-elevated);
}

.terminal-viewport {
  flex: 1;
  min-height: 0;
  position: relative;
  padding: 4px 6px;
}

.xterm-slot {
  width: 100%;
  height: 100%;
}

/* Right Collaborative Agent & Auxiliary Pane */
.agent-pane {
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.aux-tabs {
  height: 36px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  padding: 0 6px;
  gap: 4px;
  flex-shrink: 0;
}

.aux-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.aux-tab-btn.active {
  background: var(--bg-elevated);
  color: var(--accent-cyan);
}

.agent-controls-bar {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(6, 8, 17, 0.55);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.engine-Row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-card {
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  line-height: 1.55;
  font-size: 13px;
  word-break: break-word;
}

.msg-card.user {
  background: rgba(79, 140, 255, 0.12);
  border-color: rgba(79, 140, 255, 0.3);
  align-self: flex-end;
  width: 92%;
}

.msg-card.assistant {
  background: var(--bg-surface);
  width: 100%;
}

.msg-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.thinking-box {
  background: rgba(139, 92, 246, 0.08);
  border-left: 2px solid var(--accent-violet);
  border-radius: 6px;
  padding: 6px 9px;
  margin-bottom: 8px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.thinking-summary {
  cursor: pointer;
  font-weight: 600;
  color: #c4b5fd;
  user-select: none;
}

.thinking-body {
  margin-top: 6px;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 11px;
  max-height: 180px;
  overflow-y: auto;
}

.tool-chip-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.tool-chip {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #a7f3d0;
}

/* Safe Markdown Rendered Blocks */
.md-code-wrap {
  margin: 8px 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
  background: #05070f;
}

.md-code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: var(--bg-elevated);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.md-code-pre {
  padding: 10px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #e2e8f0;
  white-space: pre;
}

.md-inline-code {
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-cyan);
}

.md-p {
  margin-bottom: 7px;
}

.md-h {
  margin: 10px 0 5px;
  color: #fff;
}

.md-list {
  padding-left: 18px;
  margin-bottom: 7px;
}

/* Chat Composer */
.composer-area {
  border-top: 1px solid var(--border-subtle);
  padding: 10px;
  background: var(--bg-surface);
  position: relative;
  flex-shrink: 0;
}

.context-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
}

.context-chip {
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--accent-cyan);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.composer-textarea {
  width: 100%;
  min-height: 68px;
  max-height: 180px;
  resize: vertical;
  background: var(--bg-void);
  border: 1px solid var(--border-subtle);
  border-radius: 9px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 12.5px;
  outline: none;
}

.composer-textarea:focus {
  border-color: var(--accent-cyan);
}

.composer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 7px;
}

.slash-popup {
  position: absolute;
  bottom: 100%;
  left: 10px;
  right: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  max-height: 210px;
  overflow-y: auto;
  box-shadow: 0 -12px 32px rgba(0, 0, 0, 0.6);
  z-index: 40;
}

.slash-item {
  padding: 7px 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
}

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

/* Status Bar */
.statusbar {
  background: #090d1a;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-secondary);
}

.status-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dot-online {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  margin-right: 4px;
}

/* Modals & Toasts */
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 12, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  z-index: 100;
}

.modal-box {
  width: min(560px, 92vw);
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.75);
}

.toast-root {
  position: fixed;
  bottom: 34px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 120;
}

.toast-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  color: var(--text-primary);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.card-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 8px;
}

