/* ============================================================
   MS FORMATION BOT — Dark Luxury AI Interface
   Design: Futuristic Glassmorphism + Living Animations
   Version: 2.0 — Complete Rewrite
   ============================================================ */

/* ── Reset & Box Model ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  /* Core backgrounds */
  --bg-deep:           #050510;
  --bg-surface:        #0a0a1a;
  --bg-card:           rgba(15, 15, 35, 0.7);
  --bg-card-hover:     rgba(20, 20, 45, 0.8);

  /* Gradients */
  --gradient-primary:  linear-gradient(135deg, #6C5CE7, #a855f7, #00D2FF);
  --gradient-hot:      linear-gradient(135deg, #f43f5e, #ec4899, #a855f7);
  --gradient-subtle:   linear-gradient(135deg, rgba(108,92,231,0.15), rgba(0,210,255,0.15));

  /* Text */
  --text-primary:      #f0f0f8;
  --text-secondary:    #7878a0;
  --text-muted:        #4a4a6a;

  /* Accent colors */
  --accent-purple:     #6C5CE7;
  --accent-cyan:       #00D2FF;
  --accent-pink:       #ec4899;

  /* Glow shadows */
  --glow-purple:       0 0 30px rgba(108, 92, 231, 0.3);
  --glow-cyan:         0 0 30px rgba(0, 210, 255, 0.3);
  --glow-pink:         0 0 30px rgba(236, 72, 153, 0.3);

  /* Borders */
  --border-subtle:     rgba(108, 92, 231, 0.15);

  /* Radii */
  --radius-sm:         8px;
  --radius-md:         14px;
  --radius-lg:         20px;
  --radius-xl:         28px;

  /* Typography */
  --font-ui:           'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:         'JetBrains Mono', 'Fira Code', monospace;

  /* Easing */
  --ease-out:          cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring:       cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-bounce:       cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ── Global Base ────────────────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-deep);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  transition: background 0.3s var(--ease-out), color 0.3s var(--ease-out);
}

/* ── Custom Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent-purple), var(--accent-cyan));
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #8b7cf0, #33dbff);
}

/* ── Text Selection ─────────────────────────────────────────── */
::selection {
  background: rgba(108, 92, 231, 0.4);
  color: var(--text-primary);
}
::-moz-selection {
  background: rgba(108, 92, 231, 0.4);
  color: var(--text-primary);
}

/* ── Focus States ───────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Utility ────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

.error-text {
  color: #f43f5e;
  font-style: italic;
}

/* ============================================================
   KEYFRAME ANIMATIONS
   ============================================================ */

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-12px); }
}

@keyframes pulse-glow {
  0%, 100% {
    opacity: 0.3;
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.3), 0 0 40px rgba(0, 210, 255, 0.1);
  }
  50% {
    opacity: 0.6;
    box-shadow: 0 0 40px rgba(108, 92, 231, 0.6), 0 0 80px rgba(0, 210, 255, 0.25);
  }
}

@keyframes gradient-shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-in-right {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes typewriter-cursor {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes rotate-slow {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.05); }
}

@keyframes shimmer {
  0%   { transform: translateX(-100%) skewX(-12deg); }
  100% { transform: translateX(200%) skewX(-12deg); }
}

@keyframes bounce-in {
  0%, 80%, 100% {
    transform: translateY(0);
    animation-timing-function: ease-out;
  }
  40% {
    transform: translateY(-12px);
    animation-timing-function: ease-in;
  }
}

@keyframes ripple {
  0% {
    transform: scale(0);
    opacity: 0.5;
  }
  100% {
    transform: scale(4);
    opacity: 0;
  }
}

@keyframes morph-blob {
  0%   { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
  25%  { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
  50%  { border-radius: 50% 60% 30% 60% / 40% 50% 60% 50%; }
  75%  { border-radius: 60% 30% 60% 40% / 60% 40% 40% 60%; }
  100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
}

@keyframes border-dance {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

@keyframes orb-drift {
  0%   { transform: translate(0, 0) scale(1); }
  33%  { transform: translate(40px, -30px) scale(1.1); }
  66%  { transform: translate(-20px, 20px) scale(0.9); }
  100% { transform: translate(0, 0) scale(1); }
}

@keyframes orb-drift-alt {
  0%   { transform: translate(0, 0) scale(0.9); }
  33%  { transform: translate(-35px, 25px) scale(1); }
  66%  { transform: translate(30px, -20px) scale(1.1); }
  100% { transform: translate(0, 0) scale(0.9); }
}

/* ============================================================
   SCREEN SYSTEM
   ============================================================ */

.screen {
  display: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.screen.active {
  display: flex;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

#login-screen {
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
}

/* Animated background blobs */
#login-screen::before,
#login-screen::after {
  content: '';
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

#login-screen::before {
  width: 500px;
  height: 500px;
  top: -15%;
  left: -10%;
  background: radial-gradient(circle, rgba(108, 92, 231, 0.18) 0%, transparent 70%);
  filter: blur(80px);
  animation: morph-blob 18s ease-in-out infinite, orb-drift 25s ease-in-out infinite;
  border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
}

#login-screen::after {
  width: 600px;
  height: 600px;
  bottom: -20%;
  right: -15%;
  background: radial-gradient(circle, rgba(0, 210, 255, 0.12) 0%, transparent 70%);
  filter: blur(80px);
  animation: morph-blob 22s ease-in-out infinite reverse, orb-drift-alt 30s ease-in-out infinite;
  border-radius: 30% 70% 60% 40% / 50% 40% 60% 50%;
}

.login-container {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
}

/* Third blob via login-container */
.login-container::before {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(236, 72, 153, 0.08) 0%, transparent 70%);
  filter: blur(80px);
  animation: morph-blob 15s ease-in-out infinite 5s, orb-drift 20s ease-in-out infinite 8s;
  pointer-events: none;
  z-index: -1;
  border-radius: 50% 50% 30% 70% / 40% 60% 50% 50%;
}

/* ── Login Card ─────────────────────────────────────────────── */
.login-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: rgba(10, 10, 30, 0.6);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 48px;
  box-shadow:
    0 25px 80px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(108, 92, 231, 0.08) inset,
    var(--glow-purple);
  animation: slide-up 0.6s var(--ease-out) both;
  overflow: hidden;
}

/* Animated gradient border via pseudo */
.login-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-xl);
  padding: 1px;
  background: linear-gradient(135deg, #6C5CE7, #a855f7, #00D2FF, #6C5CE7);
  background-size: 300% 300%;
  animation: border-dance 6s ease infinite;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.5;
}

/* Top highlight */
.login-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  pointer-events: none;
}

/* ── Login Logo ─────────────────────────────────────────────── */
.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 40px;
  gap: 14px;
}

.logo-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: rgba(108, 92, 231, 0.1);
  border: 1px solid rgba(108, 92, 231, 0.25);
}

.logo-icon svg {
  width: 80px;
  height: 80px;
  animation: breathe 4s ease-in-out infinite;
  filter: drop-shadow(0 0 16px rgba(108, 92, 231, 0.6)) drop-shadow(0 0 32px rgba(0, 210, 255, 0.3));
}

.login-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.1;
}

.login-title .accent {
  background: linear-gradient(135deg, #6C5CE7, #a855f7, #00D2FF);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 8s ease infinite;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: -4px;
}

/* ── Login Form ─────────────────────────────────────────────── */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.input-group {
  position: relative;
  display: flex;
  flex-direction: column;
  margin-bottom: 24px;
}

.input-group label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
  transition: color 0.3s var(--ease-out);
}

.input-group:focus-within label {
  color: var(--accent-cyan);
}

.input-group input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border-subtle);
  padding: 12px 0;
  font-size: 1rem;
  font-family: var(--font-ui);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.3s var(--ease-out);
  letter-spacing: 0.01em;
}

.input-group input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.input-group input:focus {
  border-bottom-color: transparent;
}

.input-line {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--accent-purple), var(--accent-cyan));
  border-radius: 2px;
  transition: width 0.4s var(--ease-out);
}

.input-group:focus-within .input-line {
  width: 100%;
}

/* ── Login Button ───────────────────────────────────────────── */
.btn-login {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-ui);
  border: none;
  border-radius: var(--radius-md);
  background: var(--gradient-primary);
  background-size: 200% 200%;
  color: #fff;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
  margin-top: 8px;
  animation: gradient-shift 8s ease infinite;
  letter-spacing: 0.02em;
}

/* Shimmer sweep on hover */
.btn-login::before {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.25) 50%,
    transparent 100%
  );
  transform: skewX(-12deg);
  opacity: 0;
  transition: opacity 0.1s;
}

.btn-login:hover::before {
  opacity: 1;
  animation: shimmer 0.6s ease forwards;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow-purple), 0 12px 32px rgba(108, 92, 231, 0.35);
}

.btn-login:active {
  transform: translateY(0) scale(0.98);
}

/* ── Login Error ────────────────────────────────────────────── */
.login-error {
  font-size: 0.85rem;
  color: #f43f5e;
  text-align: center;
  min-height: 20px;
  margin-top: 12px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
}

.login-error.visible,
.login-error:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

/* ── Login Footer ───────────────────────────────────────────── */
.login-footer {
  margin-top: 32px;
  text-align: center;
}

.login-footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ============================================================
   CHAT SCREEN — Base Layout
   ============================================================ */

#chat-screen {
  position: relative;
  overflow: hidden;
  flex-direction: row;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 300px;
  min-width: 300px;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

/* ── Sidebar Header ─────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 10px;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  letter-spacing: -0.01em;
  animation: breathe 4s ease-in-out infinite;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.4);
  flex-shrink: 0;
}

.sidebar-logo span {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-new-chat {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  flex-shrink: 0;
}

.btn-new-chat:hover {
  border-color: var(--accent-purple);
  color: var(--accent-purple);
  background: rgba(108, 92, 231, 0.1);
  transform: rotate(90deg);
}

.btn-new-chat svg {
  transition: inherit;
}

/* ── Conversations List ─────────────────────────────────────── */
.sidebar-conversations {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conversations-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 8px 4px;
}

.conversation-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s var(--ease-out);
  margin-bottom: 2px;
  overflow: hidden;
}

.conversation-item:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.conversation-item.active {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* Active indicator bar */
.conversation-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  height: 60%;
  width: 3px;
  background: var(--gradient-primary);
  border-radius: 0 2px 2px 0;
  animation: slide-up 0.3s var(--ease-out) both;
}

.conversation-item svg {
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.conversation-item:hover svg,
.conversation-item.active svg {
  opacity: 1;
}

.conversation-meta {
  flex: 1;
  min-width: 0;
}

.conversation-title {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.conversation-date {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Sidebar Footer ─────────────────────────────────────────── */
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(108, 92, 231, 0.35);
}

#user-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s var(--ease-out);
  flex-shrink: 0;
}

.btn-logout:hover {
  color: #f43f5e;
}

/* ── Empty Sidebar State ────────────────────────────────────── */
.sidebar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 16px;
  text-align: center;
}

.sidebar-empty svg {
  opacity: 0.2;
  color: var(--text-secondary);
}

.sidebar-empty p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Sidebar Toggle (mobile) ────────────────────────────────── */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  place-items: center;
}

.sidebar-toggle:hover {
  border-color: var(--accent-purple);
  box-shadow: var(--glow-purple);
}

/* Overlay behind mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 998;
  animation: slide-up 0.2s ease both;
}

.sidebar-overlay.visible {
  display: block;
}

/* ============================================================
   CHAT MAIN AREA
   ============================================================ */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, rgba(10, 10, 30, 0.8) 0%, var(--bg-deep) 60%);
}

/* Animated ambient orbs in background */
.chat-main::before {
  content: '';
  position: absolute;
  width: 700px;
  height: 700px;
  top: -20%;
  right: -20%;
  background: radial-gradient(circle, rgba(108, 92, 231, 0.05) 0%, transparent 60%);
  filter: blur(60px);
  animation: orb-drift 30s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.chat-main::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  bottom: 10%;
  left: -10%;
  background: radial-gradient(circle, rgba(0, 210, 255, 0.04) 0%, transparent 60%);
  filter: blur(60px);
  animation: orb-drift-alt 25s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   WELCOME SCREEN
   ============================================================ */

.welcome {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  text-align: center;
  animation: slide-up 0.6s var(--ease-out) both;
  overflow-y: auto;
}

.welcome-logo {
  margin-bottom: 4px;
}

.welcome-icon {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--gradient-primary);
  background-size: 200% 200%;
  animation: breathe 3s ease-in-out infinite, gradient-shift 8s ease infinite;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.03em;
}

/* Pulsing outer ring */
.welcome-icon::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--gradient-primary);
  background-size: 200% 200%;
  opacity: 0.3;
  animation: pulse-glow 2s ease-in-out infinite, gradient-shift 8s ease infinite;
  z-index: -1;
}

/* Outer orbit ring */
.welcome-icon::after {
  content: '';
  position: absolute;
  inset: -18px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  animation: pulse-glow 3s ease-in-out infinite reverse, rotate-slow 20s linear infinite;
}

.welcome h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 28px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.welcome h2 span {
  background: var(--gradient-primary);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 6s ease infinite;
}

.welcome > p {
  color: var(--text-secondary);
  margin-top: 8px;
  font-size: 1rem;
}

.welcome > p strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Quick Prompts ───────────────────────────────────────────── */
.quick-prompts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 36px;
  max-width: 560px;
  width: 100%;
}

.quick-prompt {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s var(--ease-out);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.quick-prompt::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity 0.3s;
  border-radius: inherit;
}

.quick-prompt:hover {
  transform: translateY(-4px);
  border-color: var(--accent-purple);
  box-shadow: var(--glow-purple);
  background: var(--bg-card-hover);
}

.quick-prompt:active {
  transform: translateY(-1px);
}

.qp-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.quick-prompt span:last-child {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  font-weight: 500;
  position: relative;
  z-index: 1;
  transition: color 0.3s;
}

.quick-prompt:hover span:last-child {
  color: var(--text-primary);
}

/* ============================================================
   MESSAGES AREA
   ============================================================ */

.messages-container {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.messages {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
}

/* ── Individual Message ─────────────────────────────────────── */
.message {
  margin-bottom: 24px;
  animation: slide-up 0.4s var(--ease-out) both;
}

.message.user {
  animation: slide-in-right 0.4s var(--ease-out) both;
}

.message.assistant {
  animation: slide-in-left 0.4s var(--ease-out) both;
}

/* Stagger animations for sequential messages */
.message:nth-child(1) { animation-delay: 0s; }
.message:nth-child(2) { animation-delay: 0.05s; }
.message:nth-child(3) { animation-delay: 0.1s; }

.message-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.message.user .message-row {
  flex-direction: row-reverse;
}

/* ── Message Avatars ─────────────────────────────────────────── */
.message-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.bot-avatar {
  background: var(--gradient-primary);
  color: #fff;
  animation: breathe 4s ease-in-out infinite;
  box-shadow: 0 2px 12px rgba(108, 92, 231, 0.4);
}

.user-avatar-bubble {
  background: rgba(108, 92, 231, 0.2);
  color: var(--accent-purple);
  border: 1px solid var(--border-subtle);
}

/* ── Message Content ─────────────────────────────────────────── */
.message-content {
  max-width: 85%;
  min-width: 0;
}

.message-sender {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.message.user .message-sender {
  text-align: right;
  display: none;
}

.message-text {
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  line-height: 1.7;
  font-size: 0.92rem;
}

.message.assistant .message-text {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-top-left-radius: 4px;
  color: var(--text-primary);
}

.message.user .message-text {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.25), rgba(0, 210, 255, 0.15));
  border: 1px solid rgba(108, 92, 231, 0.3);
  border-top-right-radius: 4px;
  color: var(--text-primary);
}

/* ── Message Actions ─────────────────────────────────────────── */
.message-actions {
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.2s var(--ease-out);
}

.message:hover .message-actions {
  opacity: 1;
}

.btn-copy-msg {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-ui);
  padding: 4px 0;
  transition: color 0.2s;
}

.btn-copy-msg:hover {
  color: var(--accent-cyan);
}

/* ── Markdown Body ───────────────────────────────────────────── */
.markdown-body {
  font-size: 0.9375rem;
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: break-word;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 16px;
  margin-bottom: 8px;
}

.markdown-body h1 { font-size: 1.3rem; }
.markdown-body h2 { font-size: 1.15rem; }
.markdown-body h3 { font-size: 1rem; }
.markdown-body h4 { font-size: 0.9375rem; }

.markdown-body p {
  margin-bottom: 8px;
}

.markdown-body p:last-child {
  margin-bottom: 0;
}

.markdown-body strong {
  color: var(--text-primary);
  font-weight: 600;
}

.markdown-body em {
  color: var(--accent-cyan);
  font-style: italic;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 20px;
  margin-bottom: 8px;
}

.markdown-body li {
  margin-bottom: 4px;
}

.markdown-body li::marker {
  color: var(--accent-purple);
}

.markdown-body a {
  color: var(--accent-cyan);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.markdown-body a:hover {
  border-bottom-color: var(--accent-cyan);
}

.markdown-body blockquote {
  border-left: 3px solid var(--accent-purple);
  padding-left: 16px;
  color: var(--text-secondary);
  font-style: italic;
  margin: 8px 0;
  background: rgba(108, 92, 231, 0.06);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 16px;
}

.markdown-body code:not(pre code) {
  background: rgba(108, 92, 231, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent-cyan);
  border: 1px solid rgba(108, 92, 231, 0.2);
  white-space: nowrap;
}

.markdown-body hr {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

/* ── Code Blocks ─────────────────────────────────────────────── */
.markdown-body pre {
  margin: 12px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: rgba(5, 5, 20, 0.8);
  position: relative;
}

.markdown-body pre .code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(108, 92, 231, 0.1);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.code-lang {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--accent-purple);
}

.btn-copy-code {
  font-size: 0.7rem;
  background: rgba(108, 92, 231, 0.2);
  border: none;
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-ui);
  font-weight: 500;
  transition: background 0.2s;
}

.btn-copy-code:hover {
  background: rgba(108, 92, 231, 0.4);
}

.btn-copy-code.copied {
  color: #2ed573;
  background: rgba(46, 213, 115, 0.15);
}

.markdown-body pre code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #e8e8f0;
  padding: 16px;
  overflow-x: auto;
  background: transparent;
  border: none;
  tab-size: 2;
}

/* ── Tables ──────────────────────────────────────────────────── */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.markdown-body th {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.markdown-body td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(108, 92, 231, 0.05);
  color: var(--text-secondary);
  vertical-align: top;
}

.markdown-body tr:last-child td {
  border-bottom: none;
}

.markdown-body tr:hover td {
  background: rgba(108, 92, 231, 0.04);
}

/* ── Typing Indicator ────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  border-top-left-radius: 4px;
  width: fit-content;
}

.typing-indicator span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.typing-indicator span:nth-child(1) {
  background: var(--accent-purple);
  animation: bounce-in 1.4s ease-in-out 0s infinite;
}

.typing-indicator span:nth-child(2) {
  background: #a855f7;
  animation: bounce-in 1.4s ease-in-out 0.15s infinite;
}

.typing-indicator span:nth-child(3) {
  background: var(--accent-cyan);
  animation: bounce-in 1.4s ease-in-out 0.3s infinite;
}

/* ============================================================
   INPUT AREA
   ============================================================ */

.input-area {
  position: relative;
  z-index: 5;
  flex-shrink: 0;
  padding: 16px 20px 24px;
}

/* Separator line at top of input area */
.input-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--border-subtle) 30%,
    var(--border-subtle) 70%,
    transparent 100%
  );
  pointer-events: none;
}

.input-wrapper {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 6px 6px 6px 20px;
  transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

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

#message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 200px;
  min-height: 24px;
  padding: 10px 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

#message-input::placeholder {
  color: var(--text-muted);
}

.btn-send {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.3s var(--ease-out);
  position: relative;
  overflow: hidden;
}

.btn-send::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
}

.btn-send:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: var(--glow-purple);
}

.btn-send:hover:not(:disabled)::before {
  opacity: 1;
}

.btn-send:active:not(:disabled) {
  transform: scale(0.95);
}

.btn-send:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.input-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-top: 10px;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 0.8125rem;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out), transform 0.3s var(--ease-out);
  z-index: 9000;
  white-space: nowrap;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: rgba(244, 63, 94, 0.4);
  color: #f43f5e;
}

.toast.success {
  border-color: rgba(46, 213, 115, 0.4);
  color: #2ed573;
}

/* ============================================================
   RESPONSIVE — Tablet
   ============================================================ */

@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    width: 260px;
    min-width: 260px;
  }

  .messages {
    padding: 20px 16px;
  }
}

/* ============================================================
   RESPONSIVE — Mobile (<=768px)
   ============================================================ */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85vw;
    max-width: 320px;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5);
  }

  .sidebar-toggle {
    display: grid;
  }

  .chat-main {
    width: 100%;
  }

  .quick-prompts {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .welcome-icon {
    width: 80px;
    height: 80px;
    font-size: 1.75rem;
  }

  .welcome h2 {
    font-size: 1.4rem;
  }

  .welcome {
    padding: 60px 20px 32px;
  }

  .message-content {
    max-width: 90%;
  }

  .messages {
    padding: 20px 14px;
  }

  .input-area {
    padding: 12px 14px 20px;
  }
}

/* ============================================================
   RESPONSIVE — Small Mobile (<=480px)
   ============================================================ */

@media (max-width: 480px) {
  .login-card {
    padding: 32px 24px;
  }

  .login-title {
    font-size: 1.6rem;
  }

  .input-wrapper {
    border-radius: var(--radius-lg);
    padding: 4px 4px 4px 16px;
  }

  .messages {
    padding: 16px 12px;
  }

  .message-text {
    padding: 12px 14px;
    font-size: 0.875rem;
  }
}

/* ============================================================
   ACCESSIBILITY — Reduced Motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
