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

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-user: rgba(99, 102, 241, 0.15);
  --bg-bot: rgba(30, 41, 59, 0.6);
  --border: rgba(99, 102, 241, 0.15);
  --border-focus: rgba(99, 102, 241, 0.5);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.25);
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
}
body::before {
  content: '';
  position: fixed; inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99,102,241,0.12), transparent),
    radial-gradient(ellipse 60% 40% at 80% 50%, rgba(139,92,246,0.06), transparent);
  pointer-events: none; z-index: 0;
}
.screen { position: relative; z-index: 1; height: 100%; }

/* ===== Glass ===== */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ===== Login ===== */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px;
  padding: 48px 36px; border-radius: var(--radius-xl);
  text-align: center; animation: fadeUp 0.6s ease-out;
}
.login-icon { font-size: 48px; margin-bottom: 16px; animation: float 3s ease-in-out infinite; }
.login-title {
  font-size: 1.75rem; font-weight: 700; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.login-subtitle { color: var(--text-secondary); margin-bottom: 28px; font-size: 0.925rem; }
.login-error { color: var(--error); font-size: 0.85rem; margin-top: 12px; min-height: 20px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-weight: 600; font-size: 0.925rem;
  border: none; border-radius: var(--radius-md); cursor: pointer;
  transition: all var(--transition); padding: 10px 20px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: white; box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px var(--accent-glow); filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-focus); background: rgba(99,102,241,0.08); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-full { width: 100%; }

/* ===== Inputs ===== */
.input-group { display: flex; flex-direction: column; gap: 6px; }
input, textarea {
  font-family: var(--font); font-size: 0.95rem;
  padding: 12px 16px; background: rgba(15,23,42,0.6);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-primary); transition: all var(--transition);
  outline: none; width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ===== Header ===== */
.header {
  border-bottom: 1px solid var(--border);
  background: rgba(10,14,26,0.85); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
}
.header-inner {
  max-width: 900px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 1.4rem; }
.logo-text {
  font-weight: 700; font-size: 1.05rem;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.header-actions { display: flex; gap: 8px; }

/* ===== Chat Container ===== */
.chat-container {
  display: flex; flex-direction: column;
  height: 100vh; padding-top: 56px;
}
.messages {
  flex: 1; overflow-y: auto; padding: 24px 20px 20px;
  scroll-behavior: smooth;
}
.messages::-webkit-scrollbar { width: 6px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.2); border-radius: 3px; }

/* ===== Welcome ===== */
.welcome-message {
  text-align: center; padding: 60px 20px;
  max-width: 600px; margin: 0 auto;
  animation: fadeUp 0.5s ease-out;
}
.welcome-icon { font-size: 3rem; margin-bottom: 16px; }
.welcome-message h2 {
  font-size: 1.5rem; font-weight: 700; margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.welcome-message p { color: var(--text-secondary); margin-bottom: 24px; }
.suggestions { display: flex; flex-direction: column; gap: 8px; }
.suggestion {
  font-family: var(--font); font-size: 0.875rem;
  padding: 12px 18px; border-radius: var(--radius-md);
  background: rgba(99,102,241,0.08); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition); text-align: left;
}
.suggestion:hover {
  background: rgba(99,102,241,0.15); border-color: var(--border-focus);
  color: var(--text-primary); transform: translateX(4px);
}

/* ===== Messages ===== */
.message {
  max-width: 800px; margin: 0 auto 16px;
  animation: fadeUp 0.3s ease-out;
}
.message-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.message-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; flex-shrink: 0;
}
.message-avatar.user { background: linear-gradient(135deg, var(--accent), #4f46e5); }
.message-avatar.bot { background: rgba(16,185,129,0.2); }
.message-name { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); }

.message-body {
  padding: 14px 18px; border-radius: var(--radius-lg);
  margin-left: 36px;
}
.message.user .message-body {
  background: var(--bg-user);
  border: 1px solid rgba(99,102,241,0.2);
}
.message.bot .message-body {
  background: var(--bg-bot);
  border: 1px solid rgba(255,255,255,0.06);
}
.message-body p { margin-bottom: 8px; }
.message-body p:last-child { margin-bottom: 0; }
.message-body strong { color: var(--accent-light); font-weight: 600; }
.message-body em { color: var(--text-secondary); }
.message-body code {
  background: rgba(0,0,0,0.3); padding: 2px 6px;
  border-radius: 4px; font-size: 0.85em;
}
.message-body ul, .message-body ol {
  margin: 8px 0; padding-left: 20px;
}
.message-body li { margin-bottom: 4px; }
.message-body h1, .message-body h2, .message-body h3 {
  margin: 12px 0 6px; color: var(--text-primary);
}
.message-body h3 { font-size: 1rem; }
.message-body table {
  width: 100%; border-collapse: collapse; margin: 8px 0;
  font-size: 0.85rem;
}
.message-body th, .message-body td {
  padding: 6px 10px; border: 1px solid rgba(255,255,255,0.08);
  text-align: left;
}
.message-body th {
  background: rgba(99,102,241,0.1);
  font-weight: 600; color: var(--accent-light);
}

/* ===== Typing Indicator ===== */
.typing-indicator {
  max-width: 800px; margin: 0 auto 16px;
  animation: fadeUp 0.3s ease-out;
}
.typing-dots {
  display: inline-flex; gap: 4px; padding: 14px 18px;
  background: var(--bg-bot); border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-lg); margin-left: 36px;
}
.typing-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted); animation: bounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ===== Input Area ===== */
.input-area {
  padding: 12px 20px 20px;
  background: linear-gradient(to top, var(--bg-primary) 70%, transparent);
}
#chat-form { max-width: 800px; margin: 0 auto; }
.input-row {
  display: flex; gap: 10px; align-items: flex-end;
}
#message-input {
  flex: 1; resize: none; min-height: 44px; max-height: 160px;
  padding: 11px 16px; border-radius: var(--radius-md);
  line-height: 1.5;
}
.send-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border: none; border-radius: var(--radius-md); cursor: pointer;
  color: white; transition: all var(--transition);
  box-shadow: 0 2px 12px var(--accent-glow);
}
.send-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.input-hint {
  text-align: center; font-size: 0.7rem; color: var(--text-muted);
  margin-top: 8px;
}

/* ===== Animations ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .header-actions { gap: 4px; }
  .btn-sm { padding: 6px 10px; font-size: 0.75rem; }
  .welcome-message { padding: 40px 16px; }
  .suggestion { font-size: 0.8rem; padding: 10px 14px; }
  .message-body { margin-left: 0; margin-top: 4px; }
}
