/* ═══════════════════════════════════════════════════════
   ARIS Client — Full UI Stylesheet
   Copied from web_ui + Auth + Cyberpunk layers
   ═══════════════════════════════════════════════════════ */
:root {
  --bg-base: #0a0b0f;
  --bg-surface: #111318;
  --bg-elevated: #1a1d26;
  --bg-hover: #1f2330;
  --border: #1e2235;
  --border-bright: #2a2f45;
  --accent: #6366f1;
  --accent-dim: rgba(99,102,241,0.15);
  --accent-glow: rgba(99,102,241,0.3);
  --cyan: #06b6d4;
  --cyan-dim: rgba(6,182,212,0.15);
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --text-primary: #e2e8f0;
  --text-secondary: #8892a4;
  --text-muted: #4a5568;
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --sidebar-w: 220px;
  --transition: 0.18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

body { display: flex; height: 100vh; height: 100dvh; position: fixed; inset: 0; width: 100%; }

/* PWA standalone — hide any browser chrome remnants */
@media (display-mode: standalone) {
  html, body { height: 100dvh; }
  body { padding-top: env(safe-area-inset-top); }
}

/* ── Three.js Canvas Background ── */
#cyberCanvas {
  position: fixed; top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0; pointer-events: none; opacity: 0.6;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
  pointer-events: none; z-index: 9998;
}

.sidebar, .main-content, #authScreen { position: relative; z-index: 1; }

/* ── Layout ── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid rgba(99,102,241,0.2);
  box-shadow: 2px 0 15px rgba(99,102,241,0.05);
  display: flex; flex-direction: column;
  z-index: 100;
}

.main-content {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; position: relative; min-width: 0;
}

/* ── Sidebar Header ── */
.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 32px; height: 32px; flex-shrink: 0; }
.logo-icon svg { width: 100%; height: 100%; }
.logo-name {
  font-size: 16px; font-weight: 700; letter-spacing: 0.05em;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
  text-shadow: none;
}
.logo-sub {
  display: block; font-size: 10px; color: var(--text-muted);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.logo-text { display: flex; flex-direction: column; }

/* Neon pulse on logo */
@keyframes neonPulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(99,102,241,0.6)); }
  50% { filter: drop-shadow(0 0 12px rgba(99,102,241,0.9)) drop-shadow(0 0 24px rgba(6,182,212,0.4)); }
}
.logo-icon { animation: neonPulse 3s ease-in-out infinite; }

/* ── Sidebar Nav ── */
.sidebar-nav {
  flex: 1; padding: 12px 8px;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto; min-height: 0;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  background: none; border: none; cursor: pointer;
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  transition: all var(--transition); text-align: left; width: 100%;
  font-family: var(--font-sans);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-dim); color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent), 0 0 10px rgba(99,102,241,0.1);
}
.nav-item.active svg { stroke: var(--accent); }

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 12px 16px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: stretch;
}
.status-indicator { display: flex; align-items: center; gap: 8px; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); transition: background var(--transition);
}
.status-dot.online {
  background: var(--green);
  box-shadow: 0 0 6px var(--green), 0 0 12px var(--green), 0 0 20px rgba(16,185,129,0.3);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
#statusText { font-size: 12px; color: var(--text-secondary); }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.btn-icon:hover { color: var(--text-primary); }
.btn-icon svg { width: 14px; height: 14px; }

/* ── Panels ── */
.panel { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.panel.active { display: flex; }
.panel-header {
  padding: 20px 28px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.panel-title h1 { font-size: 18px; font-weight: 600; }
.panel-title { display: flex; align-items: center; gap: 12px; }
.panel-actions { display: flex; align-items: center; gap: 10px; }
.session-badge {
  font-size: 11px; color: var(--text-muted);
  background: var(--bg-elevated); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 20px; font-family: var(--font-mono);
}
.panel-body {
  flex: 1; overflow-y: auto; padding: 24px 28px;
  display: flex; flex-direction: column; gap: 16px;
  background-image:
    linear-gradient(rgba(99,102,241,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,0.02) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── Chat ── */
.chat-split-layout { display: flex; flex: 1; overflow: hidden; min-width: 0; position: relative; }
.chat-main { display: flex; flex-direction: column; flex: 1; min-width: 0; overflow: hidden; position: relative; }
.messages-container {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 16px 20px; display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth; min-width: 0; width: 100%;
}
.messages-container::-webkit-scrollbar { width: 4px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }

/* ── Welcome Screen ── */
.welcome-screen {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; flex: 1; text-align: center;
  padding: 40px 20px; gap: 16px;
}
.welcome-logo { width: 80px; height: 80px; opacity: 0.9; animation: float 4s ease-in-out infinite; }
.welcome-logo svg {
  filter: drop-shadow(0 0 10px rgba(99,102,241,0.5)) drop-shadow(0 0 20px rgba(6,182,212,0.3));
}
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.welcome-screen h2 {
  font-size: 24px; font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
}
.welcome-screen p { color: var(--text-secondary); max-width: 400px; font-size: 14px; }
.welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.chip {
  background: var(--bg-elevated); border: 1px solid var(--border-bright);
  color: var(--text-secondary); padding: 6px 14px; border-radius: 20px;
  font-size: 12px; cursor: pointer; transition: all var(--transition);
  font-family: var(--font-sans);
}
.chip:hover {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-dim); box-shadow: 0 0 10px rgba(99,102,241,0.3);
}

/* ── Messages ── */
.message {
  display: flex; gap: 10px;
  max-width: min(780px, 95%); min-width: 0;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:translateY(0)} }
.message.user { flex-direction: row-reverse; align-self: flex-end; }
.message.assistant { align-self: flex-start; }
.message > div:not(.msg-avatar) { min-width: 0; max-width: 100%; overflow: hidden; }
.msg-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; margin-top: 2px;
}
.message.user .msg-avatar { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: white; }
.message.assistant .msg-avatar { background: linear-gradient(135deg, #0e7490, #06b6d4); color: white; }
.msg-bubble {
  padding: 9px 13px; border-radius: var(--radius);
  min-width: 0; max-width: 100%;
  line-height: 1.65; font-size: 13.5px;
  overflow: hidden; word-break: break-word; overflow-wrap: break-word;
}
.message.user .msg-bubble {
  background: var(--accent-dim); border: 1px solid rgba(99,102,241,0.25);
  border-right: 2px solid rgba(99,102,241,0.4);
  box-shadow: 2px 0 10px rgba(99,102,241,0.05);
}
.message.assistant .msg-bubble {
  background: none; border: none;
  border-left: none;
  box-shadow: none;
  padding: 4px 0;
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--text-primary);
}
.message.assistant .msg-bubble hr, .message.assistant .msg-bubble h1, .message.assistant .msg-bubble h2, .message.assistant .msg-bubble h3 {
  margin-top: 16px; margin-bottom: 8px;
}
.message.assistant .msg-bubble h2 { font-size: 18px; }
.message.assistant .msg-bubble h3 { font-size: 16px; }
.message.assistant .msg-bubble p { margin: 8px 0; }
.message.assistant .msg-bubble ul, .message.assistant .msg-bubble ol { margin: 8px 0; padding-left: 24px; }
.message.assistant .msg-bubble li { margin: 4px 0; }
.msg-bubble pre {
  background: var(--bg-base); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  overflow-x: auto; max-width: 100%;
  font-family: var(--font-mono); font-size: 12px;
  margin: 6px 0; white-space: pre; word-break: normal;
  -webkit-overflow-scrolling: touch;
}
.msg-bubble code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-base); padding: 1px 5px;
  border-radius: 3px; color: var(--cyan);
}
.msg-bubble pre code { background: none; padding: 0; color: var(--text-primary); }
.msg-bubble p { margin: 6px 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin: 6px 0; }
.msg-bubble li { margin: 3px 0; }
.msg-bubble img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
.msg-bubble table { width: 100%; border-collapse: collapse; font-size: 12px; overflow-x: auto; display: block; }
.msg-bubble table th, .msg-bubble table td { padding: 4px 8px; border: 1px solid var(--border); text-align: left; }
.msg-bubble table th { background: var(--bg-base); font-weight: 600; }
.msg-bubble blockquote { border-left: 3px solid var(--accent); padding-left: 12px; margin: 6px 0; color: var(--text-secondary); }
.msg-bubble a { color: var(--cyan); text-decoration: none; border-bottom: 1px solid rgba(6,182,212,0.3); padding-bottom: 1px; transition: all 0.2s ease; word-break: break-all; }
.msg-bubble a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.msg-bubble a:visited { color: #8b5cf6; border-bottom-color: rgba(139,92,246,0.3); }
.msg-time { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.cursor {
  display: inline-block; width: 2px; height: 14px;
  background: var(--accent); margin-left: 2px;
  animation: blink 0.8s infinite; vertical-align: middle;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ARIS Thinking Indicator — Cyberpunk A spinner */
.aris-thinking {
  display: flex; align-items: center; gap: 12px; padding: 4px 0;
}
.aris-think-spinner {
  flex-shrink: 0; animation: arisThinkSpin 1.5s linear infinite;
  filter: drop-shadow(0 0 6px rgba(99,102,241,0.4));
}
.aris-think-ring {
  animation: arisRingDash 1.5s ease-in-out infinite;
  transform-origin: center;
}
@keyframes arisThinkSpin { to { transform: rotate(360deg); } }
@keyframes arisRingDash {
  0% { stroke-dasharray: 10 90; stroke-dashoffset: 0; }
  50% { stroke-dasharray: 50 50; stroke-dashoffset: -20; }
  100% { stroke-dasharray: 10 90; stroke-dashoffset: -60; }
}
.aris-think-text {
  font-size: 12px; color: var(--accent); font-weight: 500;
  letter-spacing: 0.03em;
}
.aris-think-sub {
  font-size: 10px; color: var(--text-muted); margin-top: 2px;
  transition: opacity 0.2s ease; font-style: italic;
}
.aris-think-dots::after {
  content: ''; animation: arisDots 1.4s steps(4,end) infinite;
}
@keyframes arisDots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* ── Input Area ── */
.input-area { padding: 16px 28px 20px; border-top: 1px solid var(--border); flex-shrink: 0; }
.input-wrapper {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border-bright);
  border-radius: var(--radius); padding: 10px 12px;
  transition: border-color var(--transition);
}
.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15), 0 0 15px rgba(99,102,241,0.2), inset 0 0 5px rgba(99,102,241,0.05);
}
#chatInput {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text-primary); font-family: var(--font-sans); font-size: 14px;
  resize: none; max-height: 160px; line-height: 1.6;
}
#chatInput::placeholder { color: var(--text-muted); }
.input-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.char-count { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.send-btn {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
  box-shadow: 0 0 8px rgba(99,102,241,0.4), 0 0 2px rgba(99,102,241,0.8);
}
.send-btn:hover { background: #4f46e5; transform: scale(1.05); box-shadow: 0 0 15px rgba(99,102,241,0.6); }
.send-btn:disabled { background: var(--bg-hover); cursor: not-allowed; transform: none; box-shadow: none; }
.send-btn svg { width: 14px; height: 14px; stroke: white; }
.input-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; text-align: center; }

/* ── Buttons ── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: white; border: none;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all var(--transition); font-family: var(--font-sans);
  box-shadow: 0 0 8px rgba(99,102,241,0.4), 0 0 2px rgba(99,102,241,0.8);
  text-shadow: 0 0 4px rgba(255,255,255,0.3);
}
.btn-primary:hover { background: #4f46e5; transform: translateY(-1px); box-shadow: 0 0 15px rgba(99,102,241,0.6), 0 0 30px rgba(99,102,241,0.3); }
.btn-primary svg { width: 14px; height: 14px; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 7px;
  background: none; color: var(--text-secondary); border: 1px solid var(--border-bright);
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 13px; cursor: pointer; transition: all var(--transition);
  font-family: var(--font-sans);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-muted); }
.btn-ghost svg { width: 14px; height: 14px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Cards ── */
.card {
  background: var(--bg-elevated);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 1px rgba(99,102,241,0.3), inset 0 0 1px rgba(99,102,241,0.1);
  transition: all 0.3s ease;
}
.card:hover {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 0 8px rgba(99,102,241,0.3), 0 0 20px rgba(99,102,241,0.1), inset 0 0 2px rgba(99,102,241,0.15);
}
.card-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-header svg { width: 16px; height: 16px; stroke: var(--accent); flex-shrink: 0; }
.card-header h3 { font-size: 14px; font-weight: 600; flex: 1; }
.card-body { padding: 18px; }

/* ── Stats ── */
.stat-card {
  background: var(--bg-elevated); border: 1px solid rgba(99,102,241,0.15);
  border-radius: var(--radius); padding: 20px; text-align: center;
  transition: all 0.3s ease;
}
.stat-card:hover {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 0 15px rgba(99,102,241,0.15);
  transform: translateY(-2px);
}
.stat-value {
  font-size: 24px; font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
}
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  background: var(--bg-elevated); border: 1px solid var(--border-bright);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 13px; color: var(--text-primary);
  animation: slideIn 0.2s ease; min-width: 240px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 1px rgba(99,102,241,0.3);
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes slideIn { from{opacity:0;transform:translateX(20px)} to{opacity:1;transform:translateX(0)} }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); box-shadow: 0 0 3px rgba(99,102,241,0.5); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.5); }

/* ═══════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════ */
#authScreen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
}
#authScreen.hidden { display: none; }

.auth-container {
  display: flex !important; flex-direction: row !important; align-items: center; gap: 50px;
  max-width: 920px; width: 92%; position: relative; z-index: 2;
  flex-wrap: nowrap;
}

/* Left: 3D A */
.auth-3d-side {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-width: 300px; min-height: 400px; position: relative;
}
#authCanvas { width: 100%; height: 400px; display: block; background: transparent; }
.auth-brand { text-align: center; margin-top: -8px; position: relative; z-index: 5; }
.auth-brand-name {
  font-size: 48px; font-weight: 900; letter-spacing: 0.1em;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
}
.auth-brand-full {
  display: block; font-size: 10px; color: var(--text-muted);
  letter-spacing: 0.18em; text-transform: uppercase; margin-top: 4px;
}
.auth-brand-powered { display: block; font-size: 10px; color: var(--text-muted); margin-top: 12px; }
.auth-brand-powered a {
  color: var(--cyan); text-decoration: none; font-weight: 600;
  transition: color 0.2s; border-bottom: 1px solid rgba(6,182,212,0.3);
}
.auth-brand-powered a:hover { color: var(--accent); }

/* Right: Form */
.auth-form-side { flex: 1; min-width: 340px; max-width: 420px; }
.auth-card {
  background: var(--bg-surface);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 16px; padding: 32px;
  box-shadow: 0 0 40px rgba(99,102,241,0.06), 0 0 1px rgba(99,102,241,0.4);
}
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.auth-tab {
  flex: 1; padding: 10px; text-align: center;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 14px; font-weight: 600;
  font-family: var(--font-sans);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.auth-tab:hover { color: var(--text-secondary); }

.auth-form { display: none; flex-direction: column; gap: 12px; }
.auth-form.active { display: flex; }
.auth-form label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.auth-form input[type="email"],
.auth-form input[type="password"],
.auth-form input[type="text"] {
  background: var(--bg-elevated); border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm); padding: 10px 14px;
  color: var(--text-primary); font-size: 13px; outline: none;
  font-family: var(--font-sans); transition: border-color 0.2s;
  width: 100%;
}
.auth-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.auth-submit {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff; border: none; padding: 12px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: all 0.2s; font-family: var(--font-sans);
  box-shadow: 0 0 12px rgba(99,102,241,0.5);
  width: 100%;
}
.auth-submit:hover { transform: translateY(-1px); box-shadow: 0 0 24px rgba(99,102,241,0.7); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.auth-submit svg { width: 16px; height: 16px; }

.auth-msg {
  display: none; padding: 10px 14px;
  border-radius: var(--radius-sm); font-size: 12px; text-align: center;
}
.auth-msg.error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--red); }
.auth-msg.success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: var(--green); }
.auth-msg.show { display: block; }

/* Captcha canvas */
.captcha-row {
  display: flex; align-items: center; gap: 10px;
}
.captcha-row canvas {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-bright);
  cursor: pointer;
  flex-shrink: 0;
}
.captcha-row input {
  flex: 1;
  min-height: 44px;
  min-width: 0;
}
.captcha-refresh {
  background: none; border: 1px solid var(--border-bright);
  color: var(--text-muted); border-radius: var(--radius-sm);
  width: 36px; height: 36px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0;
}
.captcha-refresh:hover { border-color: var(--accent); color: var(--accent); }
.captcha-refresh svg { width: 16px; height: 16px; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .auth-container { flex-direction: column; gap: 20px; }
  .auth-3d-side { min-width: unset; width: 100%; }
  #authCanvas { height: 220px; }
  .auth-form-side { min-width: unset; max-width: 100%; width: 100%; }
  .auth-brand-name { font-size: 32px; }
  .auth-card { padding: 20px; }
}

@media (max-width: 768px) {
  /* Sidebar: hidden by default, toggled via hamburger */
  .sidebar {
    position: fixed; left: -260px; top: 0; bottom: 0;
    width: 260px; min-width: 260px;
    z-index: 500; transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  .sidebar.mobile-open { left: 0; }
  .sidebar .logo-text { display: flex; }
  .sidebar .nav-item span { display: inline; }
  .sidebar-footer span { display: inline; }

  /* Mobile overlay when sidebar is open */
  .mobile-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 499;
  }
  .mobile-overlay.show { display: block; }

  /* Hamburger button */
  .mobile-hamburger {
    display: flex; position: fixed; top: 8px; left: 8px; z-index: 200;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 6px;
    cursor: pointer; color: var(--text-secondary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  }
  .mobile-hamburger svg { width: 18px; height: 18px; }

  /* Main content full width */
  .main-content { margin-left: 0; }

  /* Panel header — COMPACT single line */
  .panel-header {
    padding: 6px 8px 6px 42px;
    flex-wrap: nowrap; gap: 6px;
    min-height: 0;
  }
  .panel-title h1 { font-size: 13px; white-space: nowrap; }
  .panel-title { flex-shrink: 1; min-width: 0; overflow: hidden; }
  .session-badge { display: none; }
  .panel-actions {
    display: flex; flex-wrap: nowrap; gap: 4px; align-items: center;
    flex-shrink: 0;
  }
  /* Hide text labels on buttons, keep only icons */
  .panel-actions .btn-ghost { padding: 5px 6px; font-size: 0; gap: 0; }
  .panel-actions .btn-ghost svg { width: 14px; height: 14px; }
  /* Context meter hide */
  .context-meter { display: none; }
  /* Language buttons tiny */
  .panel-actions div[style*="display:flex"][style*="gap:2px"] button {
    padding: 2px 4px; font-size: 8px;
  }

  /* Chat messages — prevent overflow */
  .messages-container { padding: 8px 6px; gap: 6px; }
  .message { max-width: 92%; }
  .message > div:not(.msg-avatar) { min-width: 0; max-width: calc(100% - 34px); overflow: hidden; }
  .msg-bubble { padding: 7px 9px; font-size: 13px; line-height: 1.5; overflow-wrap: break-word; word-break: break-word; }
  .msg-avatar { width: 24px; height: 24px; font-size: 10px; }
  .msg-time { font-size: 9px; }

  /* Code blocks — critical for mobile overflow */
  .msg-bubble pre { font-size: 11px; padding: 6px; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .msg-bubble code { font-size: 11px; word-break: break-all; }
  .msg-bubble pre code { word-break: normal; }
  .code-block { max-width: 100%; overflow: hidden; }
  .code-block pre { font-size: 11px; padding: 6px 8px; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .code-header { padding: 3px 6px; }
  .code-lang { font-size: 9px; }
  .copy-btn { font-size: 9px; padding: 1px 5px; }

  /* Input area — compact, always visible */
  .input-area { padding: 4px 6px 6px; }
  .input-wrapper { padding: 6px 8px; border-radius: 12px; gap: 6px; }
  #chatInput { font-size: 16px; max-height: 80px; }
  .input-hint { display: none; }
  .send-btn { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }
  .stop-btn { width: 38px; height: 38px; }
  .attach-btn { width: 32px; height: 32px; }
  .voice-btn { width: 32px; height: 32px; }
  .char-count { display: none; }

  /* Welcome screen — compact */
  .welcome-screen { padding: 16px 10px; gap: 10px; }
  .welcome-logo { width: 48px; height: 48px; }
  .welcome-screen h2 { font-size: 17px; }
  .welcome-screen p { font-size: 12px; max-width: 100%; }
  .welcome-chips { gap: 5px; }
  .chip { font-size: 11px; padding: 5px 10px; }

  /* Files panel: full width overlay on mobile */
  .files-panel.open { width: 100%; min-width: 100%; position: absolute; right: 0; top: 0; bottom: 0; z-index: 300; }

  /* Sandbox — stacked layout */
  #panel-sandbox .panel-body { flex-direction: column; }
  #panel-sandbox .panel-body > div { min-height: 180px; border-right: none !important; border-bottom: 1px solid var(--border); }
  #panel-sandbox .panel-body > div:last-child { border-bottom: none; }
  #panel-sandbox .panel-header .panel-actions { flex-wrap: wrap; gap: 3px; }
  #panel-sandbox .panel-header .panel-actions select { font-size: 11px; padding: 3px 6px; }
  #panel-sandbox .panel-header .panel-actions .btn-ghost,
  #panel-sandbox .panel-header .panel-actions .btn-primary { font-size: 10px; padding: 4px 6px; }
  #panel-sandbox .panel-header .panel-actions .btn-ghost { font-size: 10px; }
  #sandboxCode { font-size: 12px; padding: 8px; }

  /* Cards */
  .card-body { padding: 10px; }
  .card-header { padding: 8px 12px; }
  .panel-body { padding: 8px; }

  /* Account fields */
  .account-field input { font-size: 16px; }

  /* Captcha — bigger touch targets on mobile */
  .captcha-row { gap: 8px; }
  .captcha-row canvas { width: 120px; height: 44px; flex-shrink: 0; }
  .captcha-row input { font-size: 16px; min-height: 44px; padding: 10px 14px; }
  .captcha-refresh { width: 44px; height: 44px; }

  /* Forgot overlay */
  .forgot-card { padding: 16px; width: 95%; }

  /* Toast */
  .toast-container { bottom: 8px; right: 6px; left: 6px; }
  .toast { min-width: unset; font-size: 12px; padding: 8px 12px; }

  /* Chat history in sidebar */
  .chat-history-section { max-height: 40vh; }

  /* File preview */
  .file-preview-inner { padding: 4px 8px; }
  .file-preview-icon { font-size: 16px; }
  .file-preview-info span:first-child { font-size: 12px; }

  /* File download card */
  .file-download-card { padding: 6px 10px; gap: 6px; flex-wrap: wrap; }
  .fdc-icon { font-size: 20px; }
  .fdc-name { font-size: 11px; }

  /* Build pipeline */
  .build-pipeline { padding: 6px 10px; }
  .ps-label { font-size: 10px; }
  .ps-status { font-size: 9px; }

  /* Preview modal */
  #previewModal > div:first-child { padding: 4px 8px; }
  #previewModal > div:first-child span { font-size: 11px; }
}

@media (max-width: 480px) {
  .auth-container { width: 96%; gap: 10px; }
  #authCanvas { height: 150px; }
  .auth-brand-name { font-size: 26px; }
  .auth-brand-full { font-size: 8px; }
  .auth-card { padding: 14px; }
  .auth-form input { font-size: 16px; }
  .auth-submit { padding: 10px; font-size: 13px; }
  .captcha-row canvas { width: 110px; height: 40px; }
  .captcha-row { gap: 6px; }
  .captcha-row input { font-size: 16px; min-height: 44px; padding: 10px 12px; flex: 1; min-width: 80px; }
  .captcha-refresh { width: 40px; height: 40px; }

  .message { max-width: 95%; }
  .msg-bubble { padding: 6px 8px; font-size: 12.5px; }
  .msg-bubble pre { font-size: 10px; padding: 5px; }
  .code-block pre { font-size: 10px; padding: 5px 6px; }

  /* Panel header — even more compact */
  .panel-header { padding: 5px 6px 5px 40px; gap: 4px; }
  .panel-title h1 { font-size: 12px; }
  .panel-actions .btn-ghost { padding: 4px 5px; }
  .panel-actions .btn-ghost svg { width: 12px; height: 12px; }

  /* Stat cards in API keys */
  .stat-card { padding: 10px; }
  .stat-value { font-size: 18px; }

  /* Sandbox */
  #panel-sandbox .panel-body > div { min-height: 150px; }
  #sandboxCode { font-size: 11px; }

  /* Account grid */
  .card-body div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* Auth form grid */
  .auth-form div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

  /* Input area — minimal padding */
  .input-area { padding: 3px 4px 4px; }
  .input-wrapper { gap: 4px; padding: 5px 6px; }
  .attach-btn { width: 28px; height: 28px; }
  .voice-btn { width: 28px; height: 28px; }
  .send-btn { width: 34px; height: 34px; }

  /* Welcome */
  .welcome-screen { padding: 12px 8px; gap: 8px; }
  .welcome-logo { width: 40px; height: 40px; }
  .welcome-screen h2 { font-size: 15px; }
  .welcome-screen p { font-size: 11px; }
  .chip { font-size: 10px; padding: 4px 8px; }
}

/* Very small phones (iPhone SE, Galaxy S8, etc.) */
@media (max-width: 360px) {
  .panel-header { padding: 4px 4px 4px 38px; }
  .panel-title h1 { font-size: 11px; }
  .panel-actions .btn-ghost { padding: 3px 4px; }
  .panel-actions div[style*="display:flex"][style*="gap:2px"] { display: none !important; }
  .messages-container { padding: 4px 3px; gap: 4px; }
  .message { max-width: 98%; }
  .msg-bubble { padding: 5px 6px; font-size: 12px; }
  .msg-avatar { width: 20px; height: 20px; font-size: 8px; }
  .input-area { padding: 2px 3px 4px; }
  .input-wrapper { padding: 4px 5px; gap: 3px; }
  .send-btn { width: 32px; height: 32px; }
  .attach-btn { width: 26px; height: 26px; }
  .voice-btn { width: 26px; height: 26px; }
  .auth-card { padding: 10px; }
  .auth-form label { font-size: 11px; }
  .auth-submit { padding: 8px; font-size: 12px; }
  .captcha-row canvas { width: 100px; height: 36px; }
  .captcha-row { flex-wrap: wrap; gap: 6px; }
  .captcha-row input { font-size: 16px; min-height: 44px; padding: 10px 12px; width: 100%; flex-basis: 100%; order: 3; }
  .captcha-refresh { width: 36px; height: 36px; }
  .chip { font-size: 9px; padding: 3px 6px; }
  .welcome-screen { padding: 8px 4px; }
  .welcome-logo { width: 36px; height: 36px; }
  .welcome-screen h2 { font-size: 14px; }
  #sandboxCode { font-size: 10px; padding: 6px; }
  .code-block pre { font-size: 9px; padding: 4px 5px; }
}

/* ═══════════════════════════════════════════════════════
   CHAT HISTORY SIDEBAR
   ═══════════════════════════════════════════════════════ */
.chat-history-section {
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex: 1; overflow: hidden; min-height: 0;
}
.chat-history-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 6px;
  font-size: 11px; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.chat-history-list {
  flex: 1; overflow-y: auto; padding: 4px 6px 8px;
}
.chat-history-empty { font-size: 11px; color: var(--text-muted); padding: 8px 6px; }
.chat-history-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 8px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition);
}
.chat-history-item:hover { background: var(--bg-hover); }
.chat-history-item.active { background: var(--accent-dim); }
.chat-history-item-title {
  flex: 1; font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-history-item.active .chat-history-item-title { color: var(--text-primary); }
.chat-history-item-del {
  opacity: 0; background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 2px; border-radius: 3px;
  transition: opacity var(--transition); flex-shrink: 0;
}
.chat-history-item:hover .chat-history-item-del { opacity: 1; }
.chat-history-item-del:hover { color: var(--red); }
.chat-history-item-del svg { width: 12px; height: 12px; }

/* ═══════════════════════════════════════════════════════
   ACCOUNT PANEL
   ═══════════════════════════════════════════════════════ */
.account-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.account-field label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.account-field input {
  background: var(--bg-base); border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm); padding: 9px 12px;
  color: var(--text-primary); font-size: 13px; outline: none;
  font-family: var(--font-sans); transition: border-color 0.2s; width: 100%;
}
.account-field input:focus { border-color: var(--accent); }
.account-field input:disabled { opacity: 0.5; cursor: not-allowed; }

/* ═══════════════════════════════════════════════════════
   FORGOT PASSWORD OVERLAY
   ═══════════════════════════════════════════════════════ */
.forgot-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  align-items: center; justify-content: center;
}
.forgot-overlay.show { display: flex; }
.forgot-card {
  background: var(--bg-surface); border: 1px solid rgba(99,102,241,0.2);
  border-radius: 16px; padding: 32px; max-width: 400px; width: 90%;
  box-shadow: 0 0 40px rgba(99,102,241,0.06);
}
.forgot-card h3 {
  font-size: 18px; font-weight: 700; margin-bottom: 16px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
}
.forgot-close {
  float: right; background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 18px; padding: 4px;
}
.forgot-close:hover { color: var(--text-primary); }

/* Auth link buttons */
.auth-link {
  background: none; border: none; color: var(--cyan); cursor: pointer;
  font-size: 12px; font-family: var(--font-sans); padding: 0;
  transition: color 0.2s;
}
.auth-link:hover { color: var(--accent); }

/* ═══════════════════════════════════════════════════════
   FILES PANEL + BUILD PIPELINE + FILE UPLOAD
   ═══════════════════════════════════════════════════════ */
.files-panel { width:0; min-width:0; overflow:hidden; display:flex; flex-direction:column; background:var(--bg-surface); border-left:1px solid rgba(99,102,241,0.2); box-shadow:-2px 0 15px rgba(99,102,241,0.05); transition:width 0.3s ease,min-width 0.3s ease; flex-shrink:0; }
.files-panel.open { width:320px; min-width:320px; }
.files-panel-header { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; border-bottom:1px solid var(--border); flex-shrink:0; }
.files-panel-title { font-size:13px; font-weight:600; color:var(--text-primary); }
.files-panel-count { font-size:11px; font-weight:700; background:var(--accent-dim); color:var(--text-primary); border:1px solid rgba(99,102,241,0.3); padding:1px 7px; border-radius:10px; font-family:var(--font-mono); }
.files-panel-list { flex:1; overflow-y:auto; padding:12px; display:flex; flex-direction:column; gap:8px; }
.files-panel-empty { color:var(--text-muted); font-size:12px; text-align:center; padding:24px 0; }
.files-panel-footer { padding:12px; border-top:1px solid var(--border); flex-shrink:0; }
.fp-file-item { background:var(--bg-elevated); border:1px solid rgba(99,102,241,0.1); border-radius:var(--radius-sm); padding:10px 12px; display:flex; align-items:center; gap:10px; transition:all 0.2s; }
.fp-file-item:hover { border-color:rgba(6,182,212,0.3); box-shadow:0 0 8px rgba(6,182,212,0.1); }
.fp-file-icon { font-size:20px; flex-shrink:0; }
.fp-file-info { flex:1; min-width:0; }
.fp-file-name { font-size:12px; font-weight:600; color:var(--text-primary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.fp-file-meta { font-size:10px; color:var(--text-muted); font-family:var(--font-mono); margin-top:2px; }
.fp-dl-btn { background:none; border:1px solid var(--border-bright); color:var(--text-muted); padding:4px 8px; border-radius:var(--radius-sm); cursor:pointer; font-size:11px; flex-shrink:0; transition:all var(--transition); display:flex; align-items:center; }
.fp-dl-btn:hover { border-color:var(--accent); color:var(--accent); }
.fp-dl-btn svg { width:11px; height:11px; }
.fp-badge { display:inline-block; font-size:9px; font-weight:700; padding:1px 6px; border-radius:8px; text-transform:uppercase; letter-spacing:0.05em; margin-left:6px; vertical-align:middle; }
.fp-badge-new { background:rgba(16,185,129,0.15); color:var(--green); border:1px solid rgba(16,185,129,0.3); }
.fp-badge-edited { background:rgba(245,158,11,0.15); color:var(--yellow); border:1px solid rgba(245,158,11,0.3); }

/* Build Pipeline */
.build-pipeline { padding:12px 16px; border-bottom:1px solid var(--border); display:flex; flex-direction:column; gap:0; flex-shrink:0; }
.pipeline-step { display:flex; align-items:center; gap:10px; padding:6px 0; }
.ps-icon { width:22px; height:22px; border-radius:50%; background:var(--bg-hover); border:1px solid var(--border-bright); color:var(--text-muted); font-size:11px; font-weight:700; display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:all 0.3s; }
.pipeline-step.active .ps-icon { background:var(--accent-dim); border-color:var(--accent); color:var(--accent); }
.pipeline-step.done .ps-icon { background:rgba(16,185,129,0.15); border-color:var(--green); color:var(--green); }
.ps-info { flex:1; min-width:0; }
.ps-label { font-size:12px; font-weight:600; color:var(--text-secondary); }
.ps-status { font-size:10px; color:var(--text-primary); margin-top:1px; }
.pipeline-step.active .ps-label { color:var(--text-primary); }
.pipeline-step.active .ps-status { color:var(--cyan); font-weight:600; }
.pipeline-step.done .ps-label { color:var(--green); }
.ps-dot { width:8px; height:8px; border-radius:50%; background:var(--bg-hover); flex-shrink:0; transition:all 0.3s; }
.pipeline-step.active .ps-dot { background:var(--accent); box-shadow:0 0 6px var(--accent),0 0 15px var(--accent); animation:pulse 1s infinite; }
.pipeline-step.done .ps-dot { background:var(--green); box-shadow:0 0 6px var(--green); }
.pipeline-connector { width:1px; height:12px; background:var(--border); margin-left:11px; }
.ps-bar-wrap { height:3px; background:var(--bg-hover); border-radius:2px; overflow:hidden; margin-top:4px; }
.ps-bar { height:100%; background:linear-gradient(90deg,var(--accent),var(--cyan)); border-radius:2px; transition:width 0.4s ease; }
.pipeline-step.done .ps-bar { background:var(--green); width:100% !important; }

/* Context Meter */
.context-meter { display:flex; align-items:center; gap:6px; }
.context-bar { width:80px; height:4px; background:var(--bg-hover); border-radius:2px; overflow:hidden; }
.context-fill { height:100%; background:linear-gradient(90deg,var(--green),var(--yellow),var(--red)); border-radius:2px; transition:width 0.5s ease; box-shadow:0 0 4px rgba(99,102,241,0.5); }
#contextPct { font-size:11px; color:var(--text-muted); font-family:var(--font-mono); }

/* Stop Button */
.stop-btn { width:34px; height:34px; border-radius:var(--radius-sm); background:var(--red); border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:all var(--transition); flex-shrink:0; }
.stop-btn:hover { background:#dc2626; transform:scale(1.05); }
.stop-btn svg { width:14px; height:14px; fill:white; }

/* File Upload */
.attach-btn { width:32px; height:32px; flex-shrink:0; display:flex; align-items:center; justify-content:center; color:var(--text-muted); cursor:pointer; border-radius:var(--radius-sm); transition:color var(--transition); }
.attach-btn:hover { color:var(--accent); }
.attach-btn svg { width:16px; height:16px; }
.file-preview { margin-bottom:8px; animation:fadeIn 0.2s ease; }
.file-preview-inner { display:flex; align-items:center; gap:10px; background:var(--bg-elevated); border:1px solid var(--border-bright); border-radius:var(--radius-sm); padding:8px 12px; }
.file-preview-icon { font-size:20px; flex-shrink:0; }
.file-preview-info { flex:1; display:flex; flex-direction:column; gap:2px; }
.file-preview-info span:first-child { font-size:13px; color:var(--text-primary); }
.file-preview-remove { background:none; border:none; cursor:pointer; color:var(--text-muted); font-size:14px; padding:2px 6px; border-radius:4px; }
.file-preview-remove:hover { color:var(--red); }

/* Code Blocks (marked + highlight.js) */
.code-block { background:#0d1117; border:1px solid var(--border); border-radius:var(--radius-sm); overflow:hidden; margin:8px 0; font-family:var(--font-mono); max-width:100%; min-width:0; }
.code-header { display:flex; align-items:center; justify-content:space-between; padding:5px 12px; background:#161b22; border-bottom:1px solid var(--border); flex-wrap:wrap; gap:4px; }
.code-lang { font-size:11px; color:var(--text-muted); text-transform:uppercase; letter-spacing:0.06em; }
.copy-btn { display:flex; align-items:center; gap:5px; background:none; border:1px solid var(--border-bright); color:var(--text-muted); padding:2px 8px; border-radius:var(--radius-sm); font-size:11px; cursor:pointer; transition:all var(--transition); white-space:nowrap; }
.copy-btn:hover { color:var(--text-primary); border-color:var(--accent); }
.code-block pre { margin:0; padding:12px 14px; overflow-x:auto; font-size:12.5px; line-height:1.55; background:transparent; max-width:100%; -webkit-overflow-scrolling:touch; }
.code-block pre code { background:none; padding:0; border-radius:0; font-size:inherit; white-space:pre; word-break:normal; }
.inline-code { font-family:var(--font-mono); font-size:12px; background:rgba(99,102,241,0.12); color:#a5b4fc; padding:2px 6px; border-radius:4px; border:1px solid rgba(99,102,241,0.2); }
.msg-bubble .code-block { max-width:100%; overflow:hidden; }
.msg-bubble .code-block pre { overflow-x:auto; white-space:pre; word-break:normal; word-wrap:normal; -webkit-overflow-scrolling:touch; }

/* Search badge */
.search-badge { display:inline-flex; align-items:center; gap:5px; font-size:11px; color:var(--cyan); background:var(--cyan-dim); border:1px solid rgba(6,182,212,0.25); padding:2px 8px; border-radius:20px; margin-bottom:8px; }
.search-badge svg { width:11px; height:11px; }

/* Mobile hamburger - hidden on desktop */
.mobile-hamburger { display:none; }
.mobile-overlay { display:none; }

/* File download card in chat */
.file-download-card { display:flex; align-items:center; gap:12px; margin-top:12px; padding:12px 16px; background:var(--bg-surface); border:1px solid var(--border-bright); border-radius:var(--radius); border-left:3px solid var(--accent); }
.fdc-icon { font-size:28px; flex-shrink:0; }
.fdc-info { flex:1; min-width:0; }
.fdc-name { font-size:13px; font-weight:600; color:var(--text-primary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.fdc-size { font-size:11px; color:var(--text-muted); font-family:var(--font-mono); margin-top:2px; }
.fdc-btn { flex-shrink:0; }

/* File bubble in chat */
.file-bubble { background:var(--bg-elevated); border:1px solid var(--border-bright); border-radius:var(--radius-sm); padding:8px 12px; display:flex; align-items:center; gap:10px; margin-bottom:8px; font-size:12px; }
.file-bubble-icon { font-size:18px; }
.file-bubble-name { color:var(--text-primary); font-weight:500; }
.file-bubble-meta { color:var(--text-muted); font-size:10px; }

/* Image thumbnail in chat */
.img-thumb-chat { width:120px; height:120px; object-fit:cover; border-radius:10px; border:1px solid var(--border-bright); cursor:pointer; transition:all 0.2s ease; display:block; margin-bottom:4px; }
.img-thumb-chat:hover { border-color:var(--accent); box-shadow:0 0 12px rgba(99,102,241,0.3); transform:scale(1.03); }
/* ARIS inline images in chat messages */
.msg-bubble .chat-img-wrap { display:inline-block; margin:4px 2px; vertical-align:top; }
.msg-bubble .chat-img-wrap img { transition:all 0.2s ease; }
.msg-bubble .chat-img-wrap img:hover { border-color:var(--accent); box-shadow:0 4px 16px rgba(99,102,241,0.3); transform:scale(1.05); }
.msg-bubble img[onerror] { background:var(--bg-base); }
/* Image preview in file preview bar */
.file-preview-thumb { width:48px; height:48px; object-fit:cover; border-radius:6px; border:1px solid var(--border-bright); flex-shrink:0; }
/* Fullscreen image viewer */
.img-viewer-overlay { position:fixed; inset:0; z-index:9500; background:rgba(0,0,0,0.92); display:flex; align-items:center; justify-content:center; cursor:zoom-out; animation:fadeIn 0.2s ease; }
.img-viewer-overlay img { max-width:95vw; max-height:90vh; object-fit:contain; border-radius:8px; box-shadow:0 8px 40px rgba(0,0,0,0.6); }
.img-viewer-close { position:absolute; top:16px; right:16px; background:rgba(255,255,255,0.1); border:1px solid rgba(255,255,255,0.2); color:#fff; width:36px; height:36px; border-radius:50%; cursor:pointer; font-size:18px; display:flex; align-items:center; justify-content:center; transition:all 0.2s; }
.img-viewer-close:hover { background:rgba(239,68,68,0.3); border-color:rgba(239,68,68,0.5); }
/* Drag & drop overlay */
.drop-overlay { position:absolute; inset:0; z-index:100; background:rgba(99,102,241,0.08); border:2px dashed var(--accent); border-radius:var(--radius); display:none; align-items:center; justify-content:center; pointer-events:none; }
.drop-overlay.active { display:flex; }
.drop-overlay-text { font-size:16px; font-weight:600; color:var(--accent); background:var(--bg-elevated); padding:12px 24px; border-radius:12px; border:1px solid var(--accent); }

/* Pipeline spinner */
.pipeline-spinner { display:inline-block; width:10px; height:10px; border:2px solid var(--border-bright); border-top-color:var(--accent); border-radius:50%; animation:spin 0.8s linear infinite; vertical-align:middle; margin-right:4px; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ═══════════════════════════════════════════════════════
   VISUAL UPGRADE — Modern Glass UI + Micro-interactions
   ═══════════════════════════════════════════════════════ */

/* ── Smooth page transitions ── */
.panel { animation: panelIn 0.3s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ── Glassmorphism on sidebar ── */
.sidebar {
  background: rgba(17,19,24,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(99,102,241,0.12);
}

/* ── Gradient border on active nav item ── */
.nav-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(6,182,212,0.08));
  border-left: 3px solid transparent;
  border-image: linear-gradient(180deg, #6366f1, #06b6d4) 1;
  box-shadow: 0 0 20px rgba(99,102,241,0.08);
}
.nav-item {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 3px solid transparent;
}
.nav-item:hover {
  transform: translateX(2px);
  background: rgba(99,102,241,0.06);
}

/* ── Improved message bubbles ── */
.message {
  animation: msgSlide 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes msgSlide {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.message.user .msg-bubble {
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(99,102,241,0.08));
  border: 1px solid rgba(99,102,241,0.2);
  border-right: 2px solid rgba(99,102,241,0.5);
  border-radius: 16px 16px 4px 16px;
}
.message.assistant .msg-bubble {
  background: none;
  border: none;
  border-left: none;
  border-radius: 0;
  box-shadow: none;
  padding: 4px 0;
  font-size: 14.5px;
  line-height: 1.75;
}

/* ── Avatar glow ── */
.msg-avatar {
  box-shadow: 0 0 12px rgba(99,102,241,0.2);
  transition: transform 0.2s ease;
}
.message:hover .msg-avatar { transform: scale(1.1); }
.message.user .msg-avatar {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  box-shadow: 0 0 12px rgba(99,102,241,0.3);
}
.message.assistant .msg-avatar {
  background: linear-gradient(135deg, #0e7490, #06b6d4);
  box-shadow: none;
  width: 28px; height: 28px; font-size: 12px;
}

/* ── Improved input area ── */
.input-wrapper {
  background: rgba(26,29,38,0.8);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(99,102,241,0.1);
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.input-wrapper:focus-within {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.1), 0 0 30px rgba(99,102,241,0.08), inset 0 0 20px rgba(99,102,241,0.02);
  transform: translateY(-1px);
}

/* ── Send button pulse upgrade ── */
.send-btn {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-radius: 12px;
  box-shadow: 0 0 15px rgba(99,102,241,0.4), 0 2px 8px rgba(0,0,0,0.3);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.send-btn:hover {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  box-shadow: 0 0 25px rgba(99,102,241,0.6), 0 4px 16px rgba(0,0,0,0.3);
  transform: scale(1.08);
}
.send-btn:active { transform: scale(0.95); }

/* ── Improved cards with gradient border ── */
.card {
  background: rgba(26,29,38,0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(99,102,241,0.1);
  border-radius: 16px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.3), rgba(6,182,212,0.3), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.card:hover::before { opacity: 1; }
.card:hover {
  border-color: rgba(99,102,241,0.25);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), 0 0 0 1px rgba(99,102,241,0.1);
  transform: translateY(-2px);
}

/* ── Improved chips ── */
.chip {
  background: rgba(26,29,38,0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 24px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.chip::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(6,182,212,0.1));
  opacity: 0;
  transition: opacity 0.25s ease;
}
.chip:hover::before { opacity: 1; }
.chip:hover {
  border-color: rgba(99,102,241,0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(99,102,241,0.15);
}

/* ── Welcome screen upgrade ── */
.welcome-screen h2 {
  font-size: 28px;
  background: linear-gradient(135deg, #6366f1, #06b6d4, #a855f7);
  background-size: 200% 200%;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
  animation: gradientShift 4s ease infinite;
}
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.welcome-logo {
  filter: drop-shadow(0 0 20px rgba(99,102,241,0.4)) drop-shadow(0 0 40px rgba(6,182,212,0.2));
}

/* ── Improved buttons ── */
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-radius: 10px;
  box-shadow: 0 0 12px rgba(99,102,241,0.3), 0 2px 6px rgba(0,0,0,0.2);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.btn-primary:hover::after { opacity: 1; }
.btn-primary:hover {
  box-shadow: 0 0 24px rgba(99,102,241,0.5), 0 4px 12px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-ghost {
  border-radius: 10px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-ghost:hover {
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.3);
  transform: translateY(-1px);
}

/* ── Improved toast notifications ── */
.toast {
  background: rgba(26,29,38,0.95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(99,102,241,0.05);
  animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ── Chat history items ── */
.chat-history-item {
  border-radius: 10px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}
.chat-history-item:hover {
  background: rgba(99,102,241,0.06);
  border-color: rgba(99,102,241,0.1);
  transform: translateX(2px);
}
.chat-history-item.active {
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(6,182,212,0.05));
  border-color: rgba(99,102,241,0.2);
}

/* ── Files panel glass ── */
.files-panel {
  background: rgba(17,19,24,0.9);
  backdrop-filter: blur(16px);
  border-left: 1px solid rgba(99,102,241,0.15);
}
.fp-file-item {
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.fp-file-item:hover {
  background: rgba(99,102,241,0.06);
  border-color: rgba(6,182,212,0.25);
  transform: translateX(2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* ── Pipeline steps glow ── */
.pipeline-step.active .ps-icon {
  box-shadow: 0 0 12px rgba(99,102,241,0.5), 0 0 24px rgba(99,102,241,0.2);
  animation: stepPulse 1.5s ease-in-out infinite;
}
@keyframes stepPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(99,102,241,0.4); }
  50% { box-shadow: 0 0 20px rgba(99,102,241,0.7), 0 0 40px rgba(99,102,241,0.3); }
}
.pipeline-step.done .ps-icon {
  box-shadow: 0 0 12px rgba(16,185,129,0.5);
}

/* ── Code blocks modern ── */
.code-block {
  border-radius: 14px;
  border: 1px solid rgba(99,102,241,0.12);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3), inset 0 0 20px rgba(0,0,0,0.2);
  overflow: hidden;
}
.code-header {
  background: rgba(22,27,34,0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(99,102,241,0.1);
}

/* ── Auth screen glass ── */
.auth-card {
  background: rgba(17,19,24,0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(99,102,241,0.08);
}
.auth-tab {
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px 8px 0 0;
}
.auth-tab.active {
  background: rgba(99,102,241,0.08);
}
.auth-tab:hover {
  background: rgba(99,102,241,0.04);
}
.auth-submit {
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: 0 0 20px rgba(99,102,241,0.4), 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.auth-submit::before {
  content: '';
  position: absolute; top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.auth-submit:hover::before { opacity: 1; }
.auth-submit:hover {
  box-shadow: 0 0 32px rgba(99,102,241,0.6), 0 8px 24px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}
.auth-form input {
  border-radius: 10px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.auth-form input:focus {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.1), 0 0 20px rgba(99,102,241,0.05);
  transform: translateY(-1px);
}

/* ── Captcha canvas glow ── */
.captcha-row canvas {
  border-radius: 10px;
  border: 1px solid rgba(99,102,241,0.2);
  box-shadow: 0 0 8px rgba(99,102,241,0.1);
  transition: all 0.2s ease;
}
.captcha-row canvas:hover {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 0 16px rgba(99,102,241,0.2);
}

/* ── Forgot password overlay glass ── */
.forgot-overlay {
  backdrop-filter: blur(12px);
}
.forgot-card {
  background: rgba(17,19,24,0.9);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

/* ── Account fields ── */
.account-field input {
  border-radius: 10px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.account-field input:focus {
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
  transform: translateY(-1px);
}

/* ── Stat cards shimmer ── */
.stat-card {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
}
.stat-card::after {
  content: '';
  position: absolute; top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.05), transparent);
  animation: shimmerCard 3s ease-in-out infinite;
}
@keyframes shimmerCard {
  0% { left: -100%; }
  50% { left: 100%; }
  100% { left: 100%; }
}

/* ── Scrollbar modern ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(99,102,241,0.3), rgba(6,182,212,0.3));
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(99,102,241,0.5), rgba(6,182,212,0.5));
}

/* ── Panel header glass ── */
.panel-header {
  background: rgba(17,19,24,0.6);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(99,102,241,0.08);
}

/* ── Session badge glow ── */
.session-badge {
  background: rgba(26,29,38,0.8);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 20px;
  box-shadow: 0 0 8px rgba(99,102,241,0.05);
}

/* ── Status dot improved ── */
.status-dot.online {
  box-shadow: 0 0 6px var(--green), 0 0 12px var(--green), 0 0 24px rgba(16,185,129,0.2);
}

/* ── Sidebar footer glass ── */
.sidebar-footer {
  background: rgba(17,19,24,0.5);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(99,102,241,0.08);
}

/* ── Mobile hamburger modern ── */
.mobile-hamburger {
  background: rgba(17,19,24,0.9);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 1px rgba(99,102,241,0.05);
  transition: all 0.25s ease;
}
.mobile-hamburger:hover {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 4px 24px rgba(99,102,241,0.15);
}

/* ── Noise texture overlay ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  z-index: 9997; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.3;
}

/* ── Improved file download card ── */
.file-download-card {
  border-radius: 14px;
  background: rgba(26,29,38,0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(99,102,241,0.12);
  transition: all 0.25s ease;
}
.file-download-card:hover {
  border-color: rgba(99,102,241,0.3);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

/* ── Sandbox editor modern ── */
#sandboxCode {
  background: rgba(10,11,15,0.9);
  caret-color: var(--accent);
}
#sandboxCode::selection {
  background: rgba(99,102,241,0.3);
}

/* ── 3D A brand text glow ── */
.auth-brand-name {
  filter: drop-shadow(0 0 20px rgba(99,102,241,0.3));
  animation: brandPulse 3s ease-in-out infinite;
}
@keyframes brandPulse {
  0%, 100% { filter: drop-shadow(0 0 15px rgba(99,102,241,0.2)); }
  50% { filter: drop-shadow(0 0 30px rgba(99,102,241,0.5)) drop-shadow(0 0 60px rgba(6,182,212,0.2)); }
}

/* ═══════════════════════════════════════════════════════
   NEW CLIENT FEATURES
   ═══════════════════════════════════════════════════════ */

/* Voice Button */
.voice-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer;
  border-radius: var(--radius-sm); background: none; border: none;
  transition: all 0.25s ease;
}
.voice-btn:hover { color: var(--accent); }
.voice-btn svg { width: 16px; height: 16px; }
.voice-btn.voice-active {
  color: var(--red);
  animation: voicePulse 1s ease-in-out infinite;
  background: rgba(239,68,68,0.1);
  border-radius: 50%;
}

/* Toggle Switch */
.tgl { position:relative; display:inline-block; width:40px; height:22px; flex-shrink:0; cursor:pointer; }
.tgl input { opacity:0; width:0; height:0; position:absolute; }
.tgl-slider { position:absolute; inset:0; background:var(--bg-hover); border:1px solid var(--border); border-radius:11px; transition:all 0.3s; }
.tgl-slider::before { content:''; position:absolute; top:2px; left:2px; width:16px; height:16px; background:var(--text-muted); border-radius:50%; transition:all 0.3s; }
.tgl input:checked + .tgl-slider { background:var(--accent); border-color:var(--accent); }
.tgl input:checked + .tgl-slider::before { transform:translateX(18px); background:#fff; }
@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

/* Bookmark Stars */
.bookmark-star {
  font-size: 14px;
  transition: all 0.2s ease;
}
.bookmark-star:hover {
  transform: scale(1.3);
  color: #f59e0b !important;
  opacity: 1 !important;
}

/* Theme Toggle */
#themeToggle {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: all 0.3s ease;
}
#themeToggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(99,102,241,0.2);
}

/* Preview button in files panel */
.preview-btn {
  color: var(--cyan) !important;
  border-color: rgba(6,182,212,0.3) !important;
}
.preview-btn:hover {
  color: var(--cyan) !important;
  border-color: var(--cyan) !important;
  box-shadow: 0 0 8px rgba(6,182,212,0.2);
}

/* ═══════════════════════════════════════════════════════
   LIGHT MODE — Clean, modern, no cyberpunk effects
   ═══════════════════════════════════════════════════════ */
body.light-mode::after { display: none !important; }  /* Remove scanlines */
body.light-mode::before { display: none !important; }  /* Remove noise texture */
body.light-mode #cyberCanvas { display: none !important; }
body.light-mode #authCanvas { display: block !important; }  /* Keep auth 3D A visible */

body.light-mode {
  background: #f5f7fa;
}

body.light-mode .sidebar {
  background: #ffffff;
  border-right: 1px solid #e2e5ea;
  box-shadow: 1px 0 8px rgba(0,0,0,0.04);
  backdrop-filter: none;
}

body.light-mode .logo-name {
  background: linear-gradient(135deg, #4f46e5, #0891b2);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
  filter: none;
  animation: none;
}
body.light-mode .logo-icon { animation: none; filter: none; }

body.light-mode .nav-item { color: #4a5568; }
body.light-mode .nav-item:hover { background: #f0f2f5; color: #1a1a2e; }
body.light-mode .nav-item.active {
  background: rgba(79,70,229,0.06);
  color: #4f46e5;
  border-image: linear-gradient(180deg, #4f46e5, #0891b2) 1;
  box-shadow: none;
}

body.light-mode .panel-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e5ea;
  backdrop-filter: none;
}

body.light-mode .messages-container {
  background: #f5f7fa;
}

body.light-mode .message.user .msg-bubble {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  color: #ffffff;
  border: none;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 2px 8px rgba(79,70,229,0.2);
}

body.light-mode .message.assistant .msg-bubble {
  background: none;
  color: #1a1a2e;
  border: none;
  box-shadow: none;
  border: 1px solid #e2e5ea;
  border-left: 3px solid #4f46e5;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  backdrop-filter: none;
}

body.light-mode .msg-avatar {
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
body.light-mode .message.user .msg-avatar {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
}
body.light-mode .message.assistant .msg-avatar {
  background: linear-gradient(135deg, #0891b2, #06b6d4);
}

body.light-mode .msg-bubble code {
  background: #f0f2f5;
  color: #4f46e5;
  border: 1px solid #e2e5ea;
}
body.light-mode .msg-bubble a { color: #4f46e5; border-bottom-color: rgba(79,70,229,0.3); }
body.light-mode .msg-bubble a:hover { color: #0e7490; border-bottom-color: #0e7490; }
body.light-mode .msg-bubble a:visited { color: #7c3aed; border-bottom-color: rgba(124,58,237,0.3); }
body.light-mode .msg-bubble pre {
  background: #1e1e2e;
  color: #e2e8f0;
  border: 1px solid #e2e5ea;
}

body.light-mode .input-area {
  background: #ffffff;
  border-top: 1px solid #e2e5ea;
}
body.light-mode .input-wrapper {
  background: #f5f7fa;
  border: 1px solid #d1d5db;
  backdrop-filter: none;
}
body.light-mode .input-wrapper:focus-within {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
  transform: none;
}
body.light-mode #chatInput { color: #1a1a2e; }
body.light-mode #chatInput::placeholder { color: #9ca3af; }

body.light-mode .send-btn {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 2px 8px rgba(79,70,229,0.25);
  animation: none;
}
body.light-mode .send-btn:hover {
  box-shadow: 0 4px 16px rgba(79,70,229,0.35);
}

body.light-mode .welcome-screen h2 {
  background: linear-gradient(135deg, #4f46e5, #0891b2);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
  animation: none;
}
body.light-mode .welcome-logo { filter: none; }

body.light-mode .chip {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #4a5568;
  backdrop-filter: none;
}
body.light-mode .chip::before { display: none; }
body.light-mode .chip:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  background: rgba(79,70,229,0.04);
  box-shadow: 0 2px 8px rgba(79,70,229,0.1);
}

body.light-mode .card {
  background: #ffffff;
  border: 1px solid #e2e5ea;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  backdrop-filter: none;
}
body.light-mode .card::before { display: none; }
body.light-mode .card:hover {
  border-color: #d1d5db;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
body.light-mode .card-header {
  border-bottom: 1px solid #f0f2f5;
}

body.light-mode .btn-primary {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  box-shadow: 0 2px 6px rgba(79,70,229,0.2);
}
body.light-mode .btn-primary::after { display: none; }
body.light-mode .btn-primary:hover {
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

body.light-mode .btn-ghost {
  color: #4a5568;
  border-color: #d1d5db;
}
body.light-mode .btn-ghost:hover {
  background: #f0f2f5;
  border-color: #b8bfc7;
}

body.light-mode .toast {
  background: #ffffff;
  border: 1px solid #e2e5ea;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  backdrop-filter: none;
}

body.light-mode .sidebar-footer {
  background: #ffffff;
  border-top: 1px solid #e2e5ea;
  backdrop-filter: none;
}

body.light-mode .status-dot.online {
  box-shadow: 0 0 4px #10b981;
}

body.light-mode .chat-history-item:hover {
  background: #f0f2f5;
}
body.light-mode .chat-history-item.active {
  background: rgba(79,70,229,0.06);
  border-color: rgba(79,70,229,0.15);
}

body.light-mode .files-panel {
  background: #ffffff;
  border-left: 1px solid #e2e5ea;
  backdrop-filter: none;
}
body.light-mode .fp-file-item {
  background: #f5f7fa;
  border: 1px solid #e2e5ea;
}
body.light-mode .fp-file-item:hover {
  background: #f0f2f5;
  border-color: #d1d5db;
}

body.light-mode .code-block {
  border: 1px solid #e2e5ea;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
body.light-mode .code-header {
  background: #f5f7fa;
  backdrop-filter: none;
}

body.light-mode .stat-card {
  background: #ffffff;
  border: 1px solid #e2e5ea;
}
body.light-mode .stat-card::after { display: none; }
body.light-mode .stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
body.light-mode .stat-value {
  background: linear-gradient(135deg, #4f46e5, #0891b2);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; color: transparent;
}

body.light-mode .session-badge {
  background: #f0f2f5;
  border: 1px solid #d1d5db;
}

body.light-mode .auth-card {
  background: #ffffff;
  border: 1px solid #e2e5ea;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  backdrop-filter: none;
}

body.light-mode #authScreen {
  background: #f5f7fa;
}

body.light-mode .auth-brand-name {
  filter: none;
  animation: none;
}

body.light-mode .auth-form input {
  background: #f5f7fa;
  border: 1px solid #d1d5db;
  color: #1a1a2e;
}
body.light-mode .auth-form input:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
body.light-mode .auth-tab { color: #9ca3af; }
body.light-mode .auth-tab.active { color: #4f46e5; border-bottom-color: #4f46e5; }

body.light-mode .forgot-overlay { backdrop-filter: blur(4px); background: rgba(0,0,0,0.3); }
body.light-mode .forgot-card {
  background: #ffffff;
  border: 1px solid #e2e5ea;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  backdrop-filter: none;
}

body.light-mode .account-field input {
  background: #f5f7fa;
  border: 1px solid #d1d5db;
  color: #1a1a2e;
}

body.light-mode .panel-body {
  background-image: none;
}

body.light-mode #sandboxCode {
  background: #1e1e2e;
  color: #e2e8f0;
}

body.light-mode .context-fill {
  box-shadow: none;
}

body.light-mode #themeToggle {
  background: #ffffff;
  border: 1px solid #d1d5db;
  color: #4a5568;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

body.light-mode .mobile-hamburger {
  background: #ffffff;
  border: 1px solid #d1d5db;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

body.light-mode ::-webkit-scrollbar-thumb {
  background: #d1d5db;
  box-shadow: none;
}
body.light-mode ::-webkit-scrollbar-thumb:hover {
  background: #b8bfc7;
}

body.light-mode .search-badge {
  background: rgba(8,145,178,0.08);
  border-color: rgba(8,145,178,0.2);
}

body.light-mode .file-download-card {
  background: #f5f7fa;
  border: 1px solid #e2e5ea;
  backdrop-filter: none;
}

body.light-mode .pipeline-step.active .ps-icon {
  animation: none;
}

/* Sidebar 3D A canvas */
#sidebarA {
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(99,102,241,0.3), 0 0 24px rgba(99,102,241,0.1);
}

/* ARIS text flicker */
#arisFlicker {
  transition: opacity 0.05s ease;
  text-shadow: 0 0 8px rgba(99,102,241,0.6), 0 0 16px rgba(99,102,241,0.3);
}

/* ── Safe area insets for notched phones ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .input-area { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .sidebar-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .toast-container { bottom: calc(12px + env(safe-area-inset-bottom)); }
  #authScreen { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
}

/* ── HR Module Sidebar Navigation ── */
.hr-nav-item {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  text-align: left;
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}
.hr-nav-item:hover {
  background: rgba(99,102,241,0.08);
  color: var(--text-primary);
}
.hr-nav-active {
  background: rgba(99,102,241,0.12);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}
#panel-hr.active { display: flex; flex-direction: column; height: 100%; }
#panel-hr > div { flex: 1; width: 100%; display: flex; min-height: 0; overflow: hidden; }
#panel-hr > div > div:last-child { flex: 1; overflow-y: auto !important; min-height: 0; padding: 16px; }
#hrSidebar { overflow-y: auto !important; flex-shrink: 0; }
/* HR never gets modular window styling */
body.modular-mode #panel-hr { position: relative !important; border: none !important; border-radius: 0 !important; box-shadow: none !important; }
body.modular-mode #panel-hr .mw-titlebar { display: none !important; }
body.modular-mode #panel-hr .mw-resize-corner,
body.modular-mode #panel-hr .mw-resize-edge { display: none !important; }

/* HR responsive */
@media (max-width: 768px) {
  #hrSidebar { width: 52px !important; min-width: 52px !important; padding: 8px 0 !important; }
  .hr-nav-item { font-size: 14px; padding: 10px 0; text-align: center; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .hr-nav-item { font-size: 0; }
  .hr-nav-item::first-letter { font-size: 16px; }
  #panel-hr > div > div:last-child { padding: 12px !important; }
}

/* ── HR Form Modal Fields ── */
.hr-field {
  margin-bottom: 12px;
}
.hr-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.hr-field input,
.hr-field select,
.hr-field textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.hr-field input:focus,
.hr-field select:focus,
.hr-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.hr-field input::placeholder,
.hr-field textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}
.hr-field select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

/* HR modern table styling */
#panel-hr table tr:hover {
  background: rgba(99,102,241,0.04);
}
#panel-hr .card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#panel-hr .card:hover {
  transform: translateY(-1px);
}

/* ── Scroll fixes for panels with long content ── */
.panel-body > .card .card-body {
  overflow-y: auto;
}
/* Ensure panel-body scrolls on small screens */
@media (max-height: 700px) {
  .panel-body {
    padding: 12px 16px;
  }
}
/* Chat history section scroll */
.chat-history-section {
  overflow-y: auto;
  min-height: 0;
  flex-shrink: 1;
}

/* ── Compact UI mode ── */
body.compact-ui .panel-header { padding: 8px 16px 6px; }
body.compact-ui .panel-body { padding: 12px 16px; gap: 10px; }
body.compact-ui .msg-bubble { padding: 6px 10px; font-size: 12.5px; }
body.compact-ui .input-area { padding: 8px 16px 10px; }
body.compact-ui .card-body { padding: 12px; }
body.compact-ui .card-header { padding: 8px 12px; }

/* ── Bubble styles ── */
body.bubble-compact .msg-bubble { padding: 5px 9px; font-size: 12px; line-height: 1.5; }
body.bubble-compact .message { gap: 6px; }
body.bubble-compact .msg-avatar { width: 22px; height: 22px; font-size: 9px; }
body.bubble-cozy .msg-bubble { padding: 14px 18px; font-size: 15px; line-height: 1.8; border-radius: 16px; }
body.bubble-cozy .message { gap: 14px; }

/* ── Code monokai theme ── */
body.code-monokai .msg-bubble pre { background: #272822; }
body.code-monokai .msg-bubble code { color: #f92672; }
body.code-monokai .msg-bubble pre code { color: #f8f8f2; }

/* Hide HR floating chat on mobile — it overlaps send button */
@media (max-width: 768px) {
  #hrArisChat { display: none !important; }
}

/* ── Email Chip Input (like Outlook/Gmail) ── */
.email-chips-wrap {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; min-height: 36px;
  cursor: text; transition: border-color 0.2s;
}
.email-chips-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.email-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.email-chip {
  display: flex; align-items: center; gap: 4px;
  background: var(--accent-dim); border: 1px solid rgba(99,102,241,0.3);
  border-radius: 12px; padding: 2px 6px 2px 10px;
  font-size: 12px; color: var(--accent); font-family: var(--font-sans);
  white-space: nowrap; animation: fadeIn 0.15s ease;
}
.email-chip-del {
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: rgba(99,102,241,0.2); color: var(--accent);
  font-size: 11px; cursor: pointer; display: flex;
  align-items: center; justify-content: center; transition: all 0.12s;
  padding: 0; line-height: 1;
}
.email-chip-del:hover { background: rgba(239,68,68,0.2); color: #ef4444; }
.email-chip-input {
  flex: 1; min-width: 120px; background: none; border: none;
  outline: none; color: var(--text-primary); font-size: 13px;
  font-family: var(--font-sans); padding: 4px 0;
}
.email-chip-input::placeholder { color: var(--text-muted); }
