/* ==================== AI Knowledge Base v3.0 — Neural Command Center ==================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ==================== VARIABLES ==================== */
:root {
  --bg-void: #04040a;
  --bg-primary: #070710;
  --bg-secondary: rgba(10, 10, 22, 0.88);
  --bg-tertiary: rgba(18, 18, 38, 0.65);
  --bg-hover: rgba(30, 30, 60, 0.55);
  --bg-input: rgba(14, 14, 30, 0.92);
  --bg-glass: rgba(12, 12, 28, 0.55);
  --bg-card: rgba(16, 16, 36, 0.7);

  --border: rgba(50, 50, 100, 0.3);
  --border-light: rgba(70, 70, 130, 0.25);
  --border-glow: rgba(124, 92, 255, 0.3);

  --text-primary: #eaeaf6;
  --text-secondary: #9898c4;
  --text-muted: #5555888;
  --text-dim: #3a3a66;

  --purple: #7c5cff;
  --purple-light: #a88fff;
  --purple-dark: #5a3ccc;
  --purple-glow: rgba(124, 92, 255, 0.15);
  --purple-glow-strong: rgba(124, 92, 255, 0.35);

  --cyan: #5ce0d8;
  --cyan-glow: rgba(92, 224, 216, 0.12);
  --cyan-dark: #3ab8b0;

  --green: #47e89c;
  --green-glow: rgba(71, 232, 156, 0.12);
  --red: #ff5c6c;
  --orange: #ff9f43;

  --gradient-main: linear-gradient(135deg, #7c5cff, #5a3ccc);
  --gradient-accent: linear-gradient(135deg, #7c5cff 0%, #5ce0d8 100%);
  --gradient-ai: linear-gradient(135deg, #0f0f28, #1a1a44);

  --sidebar-width: 300px;
  --topbar-height: 60px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ==================== RESET ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-void);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==================== NEURAL CANVAS ==================== */
#neuralCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* ==================== LAYOUT ==================== */
.app {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
  z-index: 1;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  backdrop-filter: blur(30px) saturate(1.6);
  -webkit-backdrop-filter: blur(30px) saturate(1.6);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow), opacity var(--transition);
  z-index: 100;
  position: relative;
}

/* Animated border glow */
.sidebar::after {
  content: '';
  position: absolute;
  top: 0;
  right: -1px;
  width: 2px;
  height: 100%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--purple) 20%,
    var(--cyan) 50%,
    var(--purple) 80%,
    transparent 100%
  );
  opacity: 0.4;
  animation: borderFlow 8s ease-in-out infinite;
}

@keyframes borderFlow {
  0%, 100% { opacity: 0.2; background-position: 0 0; }
  50% { opacity: 0.6; background-position: 0 100%; }
}

.sidebar.collapsed {
  transform: translateX(-100%);
  opacity: 0;
  position: absolute;
  height: 100%;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 11px;
}

.logo-icon-svg {
  animation: tesseractPulse 4s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(124, 92, 255, 0.5));
}

@keyframes tesseractPulse {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 8px rgba(124, 92, 255, 0.3)); }
  50% { transform: scale(1.1) rotate(5deg); filter: drop-shadow(0 0 20px rgba(124, 92, 255, 0.7)); }
}

.logo-text {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #c8b0ff 0%, #7c5cff 40%, #5ce0d8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==================== STATS BAR ==================== */
.stats-bar {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  background: var(--bg-tertiary);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.stat:hover::before { opacity: 1; }
.stat:hover { border-color: var(--border-glow); transform: translateY(-2px); }

.stat-value {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--mono);
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

/* ==================== UPLOAD ==================== */
.upload-area {
  margin: 12px 16px;
  padding: 16px;
  border: 2px dashed rgba(124, 92, 255, 0.25);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.upload-area::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: conic-gradient(from 0deg, var(--purple), var(--cyan), var(--purple));
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.5s;
  z-index: -1;
  animation: rotateBorder 4s linear infinite;
}

@keyframes rotateBorder {
  to { transform: rotate(360deg); }
}

.upload-area:hover::before, .upload-area.dragover::before { opacity: 0.3; }

.upload-area:hover, .upload-area.dragover {
  border-color: var(--purple);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124, 92, 255, 0.15);
}

.upload-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.upload-content svg {
  color: var(--purple);
  filter: drop-shadow(0 0 8px rgba(124, 92, 255, 0.4));
}

/* ==================== FILE LIST ==================== */
.file-list-header {
  padding: 10px 16px;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}

.file-list::-webkit-scrollbar { width: 3px; }
.file-list::-webkit-scrollbar-track { background: transparent; }
.file-list::-webkit-scrollbar-thumb { background: rgba(124, 92, 255, 0.3); border-radius: 3px; }

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: default;
  transition: all var(--transition);
  margin-bottom: 3px;
  border: 1px solid transparent;
  position: relative;
}

.file-item:hover {
  background: var(--bg-hover);
  border-color: var(--border);
  transform: translateX(3px);
}

.file-icon { font-size: 16px; flex-shrink: 0; }
.file-info { flex: 1; min-width: 0; }

.file-name {
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.file-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-analyzed { background: var(--green-glow); color: var(--green); border: 1px solid rgba(71, 232, 156, 0.2); }
.badge-pending { background: rgba(255, 159, 67, 0.1); color: var(--orange); border: 1px solid rgba(255, 159, 67, 0.2); }

.file-delete {
  opacity: 0;
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  flex-shrink: 0;
}

.file-item:hover .file-delete { opacity: 0.6; }
.file-delete:hover { opacity: 1 !important; background: rgba(255, 92, 108, 0.12); }

.file-list-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 11px;
}

/* ==================== SIDEBAR FOOTER ==================== */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.powered-by {
  font-size: 9px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ==================== MAIN AREA ==================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
}

/* ==================== TOPBAR ==================== */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  backdrop-filter: blur(30px) saturate(1.6);
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--purple) 30%, var(--cyan) 70%, transparent 100%);
  opacity: 0.4;
}

.sidebar-toggle { display: none; }

.topbar-title { flex: 1; display: flex; flex-direction: column; }

.topbar-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.topbar-status {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--green);
  padding: 6px 12px;
  background: var(--green-glow);
  border-radius: 20px;
  border: 1px solid rgba(71, 232, 156, 0.15);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green), 0 0 20px rgba(71, 232, 156, 0.3);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green); }
  50% { opacity: 0.5; box-shadow: 0 0 3px var(--green); }
}

/* ==================== CHAT ==================== */
.chat-container {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat-container::-webkit-scrollbar { width: 4px; }
.chat-container::-webkit-scrollbar-track { background: transparent; }
.chat-container::-webkit-scrollbar-thumb { background: rgba(124, 92, 255, 0.2); border-radius: 4px; }
.chat-container::-webkit-scrollbar-thumb:hover { background: rgba(124, 92, 255, 0.4); }

.chat-messages {
  max-width: 820px;
  margin: 0 auto;
  padding: 20px 20px 10px;
}

/* ==================== WELCOME SCREEN ==================== */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 20px 40px;
  animation: welcomeReveal 1s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes welcomeReveal {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome-brain {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
}

.welcome-logo-svg {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  filter: drop-shadow(0 0 30px rgba(124, 92, 255, 0.5));
  animation: tesseractFloat 5s ease-in-out infinite;
}

@keyframes tesseractFloat {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg); filter: drop-shadow(0 0 20px rgba(124, 92, 255, 0.4)); }
  50% { transform: translate(-50%, -54%) rotate(8deg); filter: drop-shadow(0 0 40px rgba(124, 92, 255, 0.7)); }
}

.welcome-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top: 2px solid var(--purple);
  border-right: 2px solid var(--cyan);
  animation: ringRotate 6s linear infinite;
  opacity: 0.6;
}

.welcome-ring:nth-child(2) {
  inset: -10px;
  animation-duration: 10s;
  animation-direction: reverse;
  border-top-color: var(--cyan);
  border-right-color: var(--purple);
  opacity: 0.3;
}

.welcome-ring:nth-child(3) {
  inset: -20px;
  animation-duration: 15s;
  opacity: 0.15;
}

@keyframes ringRotate { to { transform: rotate(360deg); } }

.welcome-screen h1 {
  font-size: 30px;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, var(--purple-light) 40%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-screen p {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 32px;
  max-width: 460px;
  line-height: 1.7;
  font-weight: 400;
}

.welcome-hints {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  max-width: 500px;
  width: 100%;
}

.hint-btn {
  padding: 14px 16px;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  font-family: var(--font);
  font-weight: 500;
  line-height: 1.4;
}

.hint-btn:hover {
  background: var(--bg-hover);
  border-color: var(--purple);
  color: var(--text-primary);
  transform: translateY(-3px);
  box-shadow: 0 0 30px rgba(124, 92, 255, 0.12), 0 8px 32px rgba(0,0,0,0.3);
}

/* ==================== MESSAGES ==================== */
.message {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  animation: msgSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.message.user .message-avatar {
  background: var(--gradient-main);
  box-shadow: 0 4px 20px rgba(124, 92, 255, 0.3);
}

.message.ai .message-avatar {
  background: var(--gradient-ai);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.message-body { flex: 1; min-width: 0; }

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.message-name { font-size: 12px; font-weight: 700; }
.message.user .message-name { color: var(--purple-light); }
.message.ai .message-name { color: var(--cyan); }

.message-model {
  font-size: 9px;
  color: var(--text-dim);
  background: rgba(124, 92, 255, 0.08);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.3px;
  border: 1px solid rgba(124, 92, 255, 0.12);
}

.message-text {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-primary);
  word-break: break-word;
}

.message.ai .message-text {
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: 2px var(--radius) var(--radius) var(--radius);
  border: 1px solid var(--border);
  border-left: 2px solid;
  border-image: linear-gradient(180deg, var(--purple), var(--cyan)) 1;
}

.message.user .message-text {
  padding: 12px 16px;
  background: rgba(124, 92, 255, 0.08);
  border-radius: var(--radius) 2px var(--radius) var(--radius);
  border: 1px solid rgba(124, 92, 255, 0.15);
}

.message-text p { margin-bottom: 8px; }
.message-text p:last-child { margin-bottom: 0; }
.message-text strong { color: var(--purple-light); font-weight: 700; }
.message-text em { color: var(--cyan); font-style: italic; }

.message-text ul, .message-text ol { margin: 8px 0; padding-left: 20px; }
.message-text li { margin-bottom: 4px; }

.message-text code {
  background: rgba(124, 92, 255, 0.1);
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--purple-light);
  border: 1px solid rgba(124, 92, 255, 0.12);
}

.message-text pre {
  background: rgba(4, 4, 14, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 10px 0;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
}

.message-text pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
}

.message-text blockquote {
  border-left: 3px solid var(--purple);
  padding: 8px 14px;
  margin: 8px 0;
  background: var(--purple-glow);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.message-text h1, .message-text h2, .message-text h3 { margin: 14px 0 6px; }
.message-text h1 { font-size: 17px; }
.message-text h2 { font-size: 15px; color: var(--purple-light); }
.message-text h3 { font-size: 14px; color: var(--cyan); }

.message-text hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

.message-time {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 6px;
  font-weight: 500;
}

/* ==================== NEURAL THINKING ANIMATION ==================== */
.thinking-neural {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 14px 0;
}

.neural-node {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: relative;
}

.neural-node::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: neuralFire 2s ease-in-out infinite;
}

.neural-node:nth-child(1)::before { background: var(--purple); animation-delay: 0s; }
.neural-node:nth-child(2)::before { background: var(--purple-light); animation-delay: 0.3s; }
.neural-node:nth-child(3)::before { background: var(--cyan); animation-delay: 0.6s; }
.neural-node:nth-child(4)::before { background: var(--cyan-dark); animation-delay: 0.9s; }
.neural-node:nth-child(5)::before { background: var(--purple); animation-delay: 1.2s; }

.neural-line {
  width: 18px;
  height: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}

.neural-line::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--purple), var(--cyan), transparent);
  animation: neuralSignal 1.5s ease-in-out infinite;
}

.neural-line:nth-child(2n)::after { animation-delay: 0.4s; }
.neural-line:nth-child(4n)::after { animation-delay: 0.8s; }

@keyframes neuralFire {
  0%, 100% { transform: scale(0.6); opacity: 0.3; box-shadow: none; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px currentColor; }
}

@keyframes neuralSignal {
  0% { left: -100%; }
  100% { left: 200%; }
}

/* ==================== INPUT AREA ==================== */
.input-area {
  padding: 12px 20px 18px;
  flex-shrink: 0;
  position: relative;
}

.input-area::before {
  content: '';
  position: absolute;
  top: -30px; left: 0; right: 0;
  height: 30px;
  background: linear-gradient(to top, var(--bg-void), transparent);
  pointer-events: none;
}

.input-wrapper {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-input);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 8px 8px 18px;
  transition: all var(--transition);
}

.input-wrapper:focus-within {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-glow), 0 0 40px rgba(124, 92, 255, 0.1);
}

.input-wrapper textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  resize: none;
  max-height: 150px;
  padding: 6px 0;
}

.input-wrapper textarea::placeholder { color: var(--text-dim); }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  border: none;
  background: var(--gradient-main);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(124, 92, 255, 0.3);
  position: relative;
  overflow: hidden;
}

.send-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.1));
  opacity: 0;
  transition: opacity var(--transition);
}

.send-btn:hover { transform: scale(1.08) translateY(-1px); box-shadow: 0 6px 28px rgba(124, 92, 255, 0.5); }
.send-btn:hover::after { opacity: 1; }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; box-shadow: none; }

.input-footer {
  text-align: center;
  padding-top: 8px;
  font-size: 10px;
  color: var(--text-dim);
  max-width: 820px;
  margin: 0 auto;
  font-weight: 500;
}

/* ==================== BUTTONS ==================== */
.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
}

.btn-icon:hover {
  background: var(--bg-hover);
  border-color: var(--purple);
  color: var(--purple-light);
}

/* ==================== OVERLAY ==================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 2, 8, 0.85);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: overlayFade 0.3s ease;
}

@keyframes overlayFade { from { opacity: 0; } to { opacity: 1; } }

.overlay-content { text-align: center; }

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--purple);
  border-right: 3px solid var(--cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
  box-shadow: 0 0 24px var(--purple-glow);
}

@keyframes spin { to { transform: rotate(360deg); } }

.overlay-content p { font-size: 14px; color: var(--text-secondary); font-weight: 500; }

/* ==================== MODAL ==================== */
.modal-card {
  background: var(--bg-secondary);
  backdrop-filter: blur(30px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 0 40px rgba(124, 92, 255, 0.08);
  animation: modalAppear 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalAppear {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px; transition: color var(--transition); }
.modal-close:hover { color: var(--text-primary); }

.modal-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  margin-bottom: 12px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition);
}

.modal-input:focus { border-color: var(--purple); }

.modal-textarea {
  flex: 1;
  min-height: 240px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 12px;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.modal-textarea:focus { border-color: var(--purple); }

.modal-submit {
  margin-top: 12px;
  padding: 13px;
  background: var(--gradient-main);
  border: none;
  border-radius: 12px;
  color: white;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(124, 92, 255, 0.3);
}

.modal-submit:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(124, 92, 255, 0.45); }

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-secondary);
  backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: auto;
  animation: toastIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 260px;
  max-width: 380px;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--purple); }
.toast.leaving { animation: toastOut 0.3s ease forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(30px); } }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    height: 100%;
    transform: translateX(-100%);
    opacity: 0;
  }

  .sidebar.open { transform: translateX(0); opacity: 1; }
  .sidebar-toggle { display: flex; }
  .welcome-hints { grid-template-columns: 1fr; }
  .chat-messages { padding: 14px; }
  .input-area { padding: 8px 14px 12px; }
}
