:root {
  /* Organic Dark Luxury Palette */
  --bg-app: #080c14;
  --bg-surface: #0e1420;
  --bg-surface-elevated: #141d2d;
  --bg-surface-hover: #1a2538;
  --bg-pill: rgba(255, 255, 255, 0.04);
  --bg-pill-hover: rgba(255, 255, 255, 0.08);
  
  --glass-bg: rgba(14, 20, 32, 0.75);
  --glass-border: rgba(255, 255, 255, 0.06);
  --glass-border-focus: rgba(0, 240, 255, 0.4);
  
  --text-main: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Curvaceous Accents */
  --cyan-primary: #00d8f6;
  --cyan-soft: rgba(0, 216, 246, 0.12);
  --cyan-glow: rgba(0, 216, 246, 0.25);
  --green-primary: #00e676;
  --green-soft: rgba(0, 230, 118, 0.12);
  --accent-blue: #3b82f6;
  --accent-purple: #a855f7;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Smooth Organic Radii (No Sharp Boxes) */
  --radius-full: 9999px;
  --radius-2xl: 28px;
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --header-height: 56px;
  --sidebar-width: 270px;
  --bottom-nav-height: 62px;
  --transition: all 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  position: relative;
}

body.not-authenticated #app,
body:not(.authenticated) #app {
  display: none !important;
}

/* Fluid Organic Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ==========================================================================
   Header: Aerodynamic Floating Nav Bar
   ========================================================================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 0 18px;
  z-index: 40;
  user-select: none;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  transition: var(--transition);
}
.brand:hover {
  background: var(--bg-pill);
}

.brand-title {
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.6px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-sovereign {
  background: var(--cyan-soft);
  color: var(--cyan-primary);
  font-size: 9px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  letter-spacing: 0.5px;
}

.btn-icon {
  background: var(--bg-pill);
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover {
  background: var(--bg-pill-hover);
  color: #fff;
  transform: scale(1.05);
}

.btn-new-chat-top {
  background: var(--cyan-soft);
  color: var(--cyan-primary);
  padding: 0 14px;
  width: auto;
  gap: 6px;
  font-weight: 600;
  font-size: 12.5px;
  border-radius: var(--radius-full);
}
.btn-new-chat-top:hover {
  background: rgba(0, 216, 246, 0.22);
  color: #fff;
  box-shadow: 0 0 14px var(--cyan-glow);
}

/* Aerodynamic Header Pills */
.header-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-pill);
  border: 1px solid var(--glass-border);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  transition: var(--transition);
}
.header-pill:hover {
  background: var(--bg-pill-hover);
  border-color: rgba(255, 255, 255, 0.12);
}

.indicator-pulse {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--green-primary);
  box-shadow: 0 0 8px var(--green-primary);
}

.dropdown-header {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 12px;
  font-family: var(--font-sans);
  font-weight: 500;
  outline: none;
  cursor: pointer;
}
.user-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 230, 118, 0.08);
  border: 1px solid rgba(0, 230, 118, 0.2);
  padding: 5px 12px;
  border-radius: var(--radius-full);
}
.user-status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--green-primary);
  box-shadow: 0 0 8px var(--green-primary);
}
.user-display-name {
  font-size: 11.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--green-primary);
  letter-spacing: 0.3px;
}
.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  border-radius: var(--radius-full);
  transition: var(--transition);
}
.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

/* View Mode Pill Capsule */
.view-mode-group {
  display: flex;
  background: var(--bg-pill);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.btn-mode {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}
.btn-mode:hover {
  color: var(--text-main);
}
.btn-mode.active {
  background: var(--cyan-soft);
  color: var(--cyan-primary);
}

.status-tag {
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--cyan-primary);
  background: var(--cyan-soft);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Workspace Layout (Sidebar + Fluid Chat Canvas)
   ========================================================================== */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar: Smooth Floating Drawer */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 30;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), margin-left 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-top-action {
  padding: 14px 14px 8px 14px;
}

.btn-new-chat-sidebar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-pill);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-new-chat-sidebar:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--cyan-primary);
  box-shadow: 0 4px 20px rgba(0, 216, 246, 0.15);
  transform: translateY(-1px);
}
.btn-new-chat-sidebar span {
  flex: 1;
  text-align: left;
  margin-left: 10px;
}

.shortcut-badge {
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.history-search-wrap {
  position: relative;
  margin: 6px 14px 8px 14px;
}
.history-search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.history-search-wrap input {
  width: 100%;
  background: var(--bg-app);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 8px 12px 8px 34px;
  font-size: 12px;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}
.history-search-wrap input:focus {
  border-color: var(--glass-border-focus);
  background: var(--bg-surface);
}

.sidebar-nav-tabs {
  display: flex;
  background: var(--bg-app);
  border-radius: var(--radius-full);
  margin: 4px 14px 8px 14px;
  padding: 3px;
}
.sidebar-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 0;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: var(--transition);
}
.sidebar-tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--cyan-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-section {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}
.sidebar-section.active {
  display: flex;
}

.history-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px;
}

.history-group-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 10px 4px 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 3px;
  transition: var(--transition);
  font-size: 12.5px;
}
.history-item:hover {
  background: var(--bg-pill);
  color: var(--text-main);
}
.history-item.active {
  background: var(--cyan-soft);
  color: var(--cyan-primary);
  font-weight: 600;
}

.history-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 6px;
}

.history-actions {
  display: none;
  gap: 3px;
}
.history-item:hover .history-actions {
  display: flex;
}
.history-btn {
  background: transparent;
  border: none;
  font-size: 11.5px;
  padding: 2px 5px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
}
.history-btn:hover {
  background: var(--bg-pill-hover);
  color: #fff;
}

.file-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.tree-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.tree-item:hover {
  background: var(--bg-pill);
  color: var(--text-main);
}
.tree-item.folder {
  color: var(--cyan-primary);
  font-weight: 500;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}
.sys-badge {
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--green-primary);
  box-shadow: 0 0 6px var(--green-primary);
}

/* ==========================================================================
   Center Pane: Organic Gemini/ChatGPT Flow Chat
   ========================================================================== */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  height: 100%;
  position: relative;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 24px;
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  z-index: 10;
}

.chat-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.active-session-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

.session-model-badge {
  font-size: 9.5px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--cyan-soft);
  color: var(--cyan-primary);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-header-action {
  background: var(--bg-pill);
  border: none;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}
.btn-header-action:hover {
  background: var(--bg-pill-hover);
  color: var(--text-main);
}

/* Messages Scroll Feed */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 140px 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

/* Welcome Hero */
.welcome-hero {
  text-align: center;
  padding: 50px 20px 20px 20px;
  margin: 0 auto;
  max-width: 650px;
}

.welcome-logo {
  margin-bottom: 16px;
  filter: drop-shadow(0 0 20px var(--cyan-glow));
}

.welcome-title {
  font-size: 24px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.welcome-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.quick-prompts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  text-align: left;
}

.prompt-card {
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
}
.prompt-card:hover {
  background: var(--bg-surface-elevated);
  border-color: rgba(0, 216, 246, 0.3);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.prompt-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan-primary);
  margin-bottom: 5px;
}
.prompt-card-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* Messages Bubbles: Ferrari Curvaceous & Clean Flow */
.message {
  display: flex;
  flex-direction: column;
  width: 100%;
  animation: fadeIn 0.25s ease;
}

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

/* User Message: Elegant Capsule */
.message.user-msg {
  align-items: flex-end;
}

.message.user-msg .msg-bubble {
  background: #141d2d;
  border: 1px solid rgba(0, 216, 246, 0.2);
  color: #ffffff;
  padding: 13px 18px;
  border-radius: 22px 22px 4px 22px;
  max-width: 78%;
  font-size: 14.5px;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

/* Assistant Message: Elegant Subtle Tinted Surface */
.message.assistant-msg {
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid rgba(255, 255, 255, 0.045);
  border-radius: var(--radius-2xl);
  padding: 18px 22px 16px 22px;
  transition: var(--transition);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
}
.message.assistant-msg:hover {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.028);
}

.msg-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
}

.msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.msg-avatar.ai {
  background: var(--cyan-soft);
  color: var(--cyan-primary);
}

.msg-author-name {
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 600;
}

.msg-model-tag {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

/* The Assistant Response Content */
.message.assistant-msg .msg-content {
  width: 100%;
  color: var(--text-main);
  font-size: 14.5px;
  line-height: 1.75;
  word-break: break-word;
}

/* Tool execution status: Sleek Capsule Pills */
.msg-tools-area {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.tool-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 216, 246, 0.05);
  border: 1px solid rgba(0, 216, 246, 0.15);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--cyan-primary);
  width: fit-content;
  max-width: 100%;
}
.tool-pill.success {
  background: rgba(0, 230, 118, 0.05);
  border-color: rgba(0, 230, 118, 0.18);
  color: var(--green-primary);
}

/* Thinking Indicator */
.msg-thinking {
  margin-bottom: 8px;
}
.thinking-shimmer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--cyan-primary);
  font-size: 13px;
  font-style: italic;
}
.dot-flashing {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background-color: var(--cyan-primary);
  animation: dotFlashing 1s infinite alternate;
}
@keyframes dotFlashing {
  0% { opacity: 0.2; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.1); }
}

/* Markdown Rendering Inside Response */
.msg-body h1, .msg-body h2, .msg-body h3 {
  color: #fff;
  margin: 18px 0 10px 0;
  font-weight: 600;
}
.msg-body h1 { font-size: 19px; }
.msg-body h2 { font-size: 16.5px; }
.msg-body h3 { font-size: 15px; }

.msg-body p {
  margin-bottom: 14px;
}
.msg-body p:last-child {
  margin-bottom: 0;
}

.msg-body ul, .msg-body ol {
  margin-left: 22px;
  margin-bottom: 14px;
}
.msg-body li {
  margin-bottom: 5px;
}
.msg-body strong {
  color: #ffffff;
}

.msg-body code:not(pre code) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--cyan-primary);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* Code Blocks: Smooth Curved Containers with Floating Header */
.code-block-container {
  position: relative;
  background: #090d16;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  margin: 16px 0;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  padding: 8px 16px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

.code-lang-tag {
  color: var(--cyan-primary);
  font-weight: 600;
  text-transform: uppercase;
}

.code-block-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-code-action {
  background: var(--bg-pill);
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}
.btn-code-action:hover {
  background: var(--cyan-soft);
  color: #fff;
}

.code-block-container pre {
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  background: transparent !important;
}

/* ==========================================================================
   Slash Command Autocomplete Popover (Curved Glass Card)
   ========================================================================== */
.slash-menu {
  position: absolute;
  bottom: 96px;
  left: 24px;
  right: 24px;
  max-width: 620px;
  margin: 0 auto;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  z-index: 50;
  overflow: hidden;
  padding: 6px;
  animation: popIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.slash-menu.hidden {
  display: none;
}

.slash-menu-header {
  padding: 8px 14px 4px 14px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.slash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: var(--transition);
}
.slash-item:hover, .slash-item.selected {
  background: var(--bg-pill-hover);
}

.cmd-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--cyan-primary);
  background: var(--cyan-soft);
  padding: 3px 8px;
  border-radius: var(--radius-full);
  min-width: 80px;
}

.cmd-desc {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ==========================================================================
   Chat Input Card: Aerodynamic Capsule (Ferrari Style)
   ========================================================================== */
.chat-input-wrapper {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 28px 20px 28px;
  background: linear-gradient(to top, var(--bg-app) 75%, transparent 100%);
  z-index: 20;
}

.chat-input-card {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: 10px 14px 10px 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  transition: var(--transition);
}
.chat-input-card:focus-within {
  border-color: var(--glass-border-focus);
  box-shadow: 0 0 24px var(--cyan-glow);
  background: #162032;
}

.btn-slash-trigger {
  background: var(--bg-pill);
  border: none;
  color: var(--cyan-primary);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-slash-trigger:hover {
  background: var(--cyan-soft);
  transform: scale(1.08);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 160px;
  padding: 6px 0;
}

.btn-send {
  background: linear-gradient(135deg, var(--cyan-primary) 0%, #00b4d8 100%);
  border: none;
  color: #040912;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-send:hover {
  box-shadow: 0 0 16px var(--cyan-glow);
  transform: scale(1.08);
}

.chat-input-footer {
  text-align: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   Right Pane: Code Canvas (Curved Floating Surface)
   ========================================================================== */
.editor-pane {
  width: 50%;
  background: var(--bg-surface);
  border-left: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: var(--transition);
}

.editor-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  background: transparent;
  border-bottom: 1px solid var(--glass-border);
  padding: 0 16px;
}

.tab-list {
  display: flex;
  gap: 6px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-pill);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}
.tab.active {
  background: var(--cyan-soft);
  color: var(--cyan-primary);
  font-weight: 600;
}

.editor-tab-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-tab-action {
  background: var(--bg-pill);
  border: none;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}
.btn-tab-action:hover {
  background: var(--bg-pill-hover);
  color: var(--text-main);
}

.editor-container {
  flex: 1;
  position: relative;
  background: var(--bg-app);
}

#code-editor {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.65;
  padding: 20px;
  resize: none;
  outline: none;
  white-space: pre;
  tab-size: 2;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: var(--bg-surface);
  border-top: 1px solid var(--glass-border);
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
}

/* Layout View Modes */
body.layout-chat .editor-pane {
  display: none !important;
}
body.layout-chat .chat-pane {
  width: 100% !important;
}

body.layout-canvas .chat-pane {
  display: none !important;
}
body.layout-canvas .editor-pane {
  width: 100% !important;
}

body.layout-split .editor-pane {
  display: flex !important;
  width: 50% !important;
}
body.layout-split .chat-pane {
  width: 50% !important;
}

/* ==========================================================================
   Bottom Terminal Tray (Curved Sheet)
   ========================================================================== */
.terminal-tray {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 220px;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  z-index: 60;
  display: none;
  flex-direction: column;
  box-shadow: 0 -12px 36px rgba(0, 0, 0, 0.7);
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.terminal-tray.open {
  display: flex;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  padding: 8px 18px;
  border-bottom: 1px solid var(--glass-border);
  font-size: 11.5px;
  font-family: var(--font-mono);
}

.terminal-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green-primary);
  font-weight: 600;
}

.terminal-cwd {
  color: var(--text-muted);
  font-weight: normal;
}

.terminal-cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 520px;
  margin-left: 20px;
}

#terminal-cmd-input {
  flex: 1;
  background: var(--bg-app);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  padding: 6px 14px;
  color: var(--green-primary);
  font-family: var(--font-mono);
  font-size: 11.5px;
  outline: none;
}
#terminal-cmd-input:focus {
  border-color: var(--green-primary);
}

.btn-terminal-run {
  background: var(--green-soft);
  border: none;
  color: var(--green-primary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.btn-terminal-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
}
.btn-terminal-icon:hover {
  color: #fff;
  background: var(--bg-pill);
}

.terminal-output {
  flex: 1;
  padding: 12px 18px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: #00e676;
  white-space: pre-wrap;
  background: var(--bg-app);
}

/* Attachment Button & Voice Button in Input Card */
.btn-input-action {
  background: var(--bg-pill);
  border: none;
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-input-action:hover {
  background: var(--bg-pill-hover);
  color: var(--text-main);
  transform: scale(1.05);
}

.btn-mic {
  color: var(--text-muted);
}
.btn-mic:hover {
  color: var(--cyan-primary);
}
.btn-mic.listening {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #ef4444 !important;
  animation: pulseMic 1.2s infinite alternate;
}

@keyframes pulseMic {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(239, 68, 68, 0.4); }
  100% { transform: scale(1.12); box-shadow: 0 0 16px rgba(239, 68, 68, 0.8); }
}

/* Attachment Previews Bar */
.attachment-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 860px;
  margin: 0 auto 8px auto;
  padding: 6px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
}
.attachment-previews.hidden {
  display: none;
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-pill);
  border: 1px solid var(--glass-border);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-family: var(--font-sans);
  color: var(--text-main);
}
.attachment-thumb {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: cover;
}
.attachment-name {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-remove-attachment {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
  border-radius: var(--radius-full);
}
.btn-remove-attachment:hover {
  color: #ef4444;
}

/* Assistant Response Bottom Footer Actions (Copy + TTS Voice) */
.msg-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.btn-msg-action {
  background: var(--bg-pill);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-family: var(--font-sans);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.btn-msg-action:hover {
  background: var(--bg-pill-hover);
  color: var(--cyan-primary);
  border-color: rgba(0, 216, 246, 0.25);
  transform: translateY(-1px);
}
.btn-msg-action.copied {
  background: rgba(0, 230, 118, 0.15) !important;
  color: var(--green-primary) !important;
  border-color: rgba(0, 230, 118, 0.3) !important;
}

.btn-speak-tts.speaking {
  color: var(--cyan-primary);
  animation: pulseMic 1s infinite alternate;
}

.msg-body {
  user-select: text !important;
  -webkit-user-select: text !important;
}

/* ==========================================================================
   Mobile Responsive Navigation & Polish
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border);
  z-index: 80;
  justify-content: space-around;
  align-items: center;
  padding: 4px 10px;
}

.mobile-nav-item {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  transition: var(--transition);
}
.mobile-nav-item.active {
  color: var(--cyan-primary);
  background: var(--cyan-soft);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 70;
}
.sidebar-overlay.active {
  display: block;
}

/* Breakpoints for Mobile Fluidity */
@media (max-width: 860px) {
  .desktop-only, .desktop-only-text {
    display: none !important;
  }

  .app-header {
    padding: 0 12px;
    height: 52px;
  }

  .brand-title {
    font-size: 12.5px;
  }

  .header-pill {
    padding: 4px 10px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 290px;
    transform: translateX(-100%);
    z-index: 75;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .view-mode-group {
    display: none;
  }

  body.layout-split .chat-pane {
    width: 100% !important;
  }
  body.layout-split .editor-pane {
    display: none !important;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .chat-messages {
    padding: 16px 18px 210px 18px !important;
    gap: 20px;
  }

  .message.user-msg .msg-bubble {
    max-width: 88%;
    padding: 12px 16px;
    font-size: 14px;
  }

  .message.assistant-msg .msg-content {
    font-size: 14px;
    line-height: 1.65;
    padding-left: 0;
  }

  .chat-input-wrapper {
    bottom: var(--bottom-nav-height);
    padding: 8px 12px 10px 12px;
  }

  .chat-input-card {
    padding: 8px 10px 8px 12px;
    gap: 6px;
    border-radius: var(--radius-xl);
  }

  #chat-input {
    font-size: 14px;
  }

  .btn-input-action, .btn-slash-trigger, .btn-send {
    width: 34px;
    height: 34px;
  }

  .terminal-tray {
    bottom: var(--bottom-nav-height);
    height: 250px;
  }
}

/* ==========================================================================
   Sovereign Login Modal Screen (Glassmorphism + Organic Curves)
   ========================================================================== */
/* ==========================================================================
   Sovereign Login Screen with 3D Interactive Canvas Background
   ========================================================================== */
.login-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 40px 10vw;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow: hidden;
}
.login-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (max-width: 860px) {
  .login-modal {
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px 16px 20px 16px;
  }
}

/* Full-Screen 3D Holographic Canvas */
.login-3d-bg {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  z-index: 1;
  display: block;
  opacity: 0;
  transition: opacity 0.6s ease;
  cursor: grab;
}
.login-3d-bg:active {
  cursor: grabbing;
}

.login-backdrop-tint {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(circle at 30% 50%, rgba(8, 12, 20, 0.2) 0%, rgba(4, 8, 16, 0.85) 100%);
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 390px;
  background: rgba(14, 20, 32, 0.82);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(0, 216, 246, 0.22);
  border-radius: var(--radius-2xl);
  padding: 34px 30px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.85), 0 0 32px rgba(0, 216, 246, 0.15);
  animation: loginCardSlide 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes loginCardSlide {
  0% { opacity: 0; transform: scale(0.94) translateY(12px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  font-size: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  text-align: center;
}
.login-error.hidden {
  display: none;
}

.login-input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-input-group label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-input-wrapper input {
  width: 100%;
  background: rgba(8, 12, 20, 0.7);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 12px 16px;
  font-size: 13.5px;
  font-family: var(--font-sans);
  color: #fff;
  outline: none;
  transition: var(--transition);
}
.login-input-wrapper input:focus {
  border-color: var(--cyan-primary);
  box-shadow: 0 0 16px var(--cyan-glow);
  background: rgba(16, 23, 38, 0.9);
}

.btn-login-submit {
  margin-top: 8px;
  background: linear-gradient(135deg, var(--cyan-primary) 0%, #0099ff 100%);
  border: none;
  color: #040912;
  font-size: 13.5px;
  font-weight: 700;
  padding: 13px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(0, 216, 246, 0.3);
}
.btn-login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 216, 246, 0.5);
}
.btn-login-submit:active {
  transform: scale(0.98);
}

/* Sidebar Footer User Profile */
.user-profile-sidebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 6px;
}

.user-profile-main {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.user-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--green-primary);
  box-shadow: 0 0 8px var(--green-primary);
  flex-shrink: 0;
}

.user-display-name {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: var(--bg-pill);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.3);
  transform: scale(1.08);
}

