/* ===== David AI — Ultra Modern 2026 Design ===== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

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

:root {
  --bg:           #030308;
  --bg-elev-1:    #080812;
  --bg-elev-2:    #0e0e1c;
  --bg-elev-3:    #141428;
  --bg-elev-4:    #1a1a32;
  --border:       #1e1e38;
  --border-soft:  #14142a;
  --border-strong:#2e2e52;
  --text:         #f0f0f8;
  --text-dim:     #9898b8;
  --text-mute:    #5858a0;
  --text-faint:   #363660;

  /* Vibrant multi-color palette */
  --accent:       #6d5afa;
  --accent-2:     #a78bfa;
  --accent-3:     #c084fc;
  --cyan:         #22d3ee;
  --cyan-soft:    rgba(34,211,238,0.15);
  --pink:         #f472b6;
  --pink-soft:    rgba(244,114,182,0.12);
  --emerald:      #34d399;
  --amber:        #fbbf24;

  --accent-glow:  rgba(109,90,250,0.25);
  --accent-soft:  rgba(109,90,250,0.12);
  --accent-hi:    rgba(109,90,250,0.3);
  --danger:       #f87171;
  --success:      #34d399;
  --warn:         #fbbf24;

  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 26px;
  --radius-pill: 999px;

  --shadow-1: 0 1px 3px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.03) inset;
  --shadow-2: 0 4px 20px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.04) inset;
  --shadow-3: 0 20px 60px rgba(0,0,0,0.8);
  --shadow-accent: 0 0 30px rgba(109,90,250,0.2);
  --shadow-cyan: 0 0 30px rgba(34,211,238,0.15);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;

  --sidebar-w: 290px;
  --topbar-h: 58px;
  --composer-max: 780px;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* ===== Aurora Background ===== */
.aurora-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.aurora-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.12;
  animation: aurora-drift 20s ease-in-out infinite alternate;
}

.aurora-blob:nth-child(1) {
  width: 70vw; height: 70vw;
  top: -30%; left: -20%;
  background: radial-gradient(circle, #6d5afa 0%, #c084fc 50%, transparent 70%);
  animation-duration: 25s;
}

.aurora-blob:nth-child(2) {
  width: 60vw; height: 60vw;
  top: 20%; right: -20%;
  background: radial-gradient(circle, #22d3ee 0%, #6d5afa 50%, transparent 70%);
  animation-duration: 30s;
  animation-delay: -8s;
}

.aurora-blob:nth-child(3) {
  width: 50vw; height: 50vw;
  bottom: -20%; left: 30%;
  background: radial-gradient(circle, #f472b6 0%, #6d5afa 50%, transparent 70%);
  animation-duration: 22s;
  animation-delay: -15s;
  opacity: 0.08;
}

@keyframes aurora-drift {
  0%   { transform: translate(0,0) scale(1) rotate(0deg); }
  33%  { transform: translate(3vw, 4vh) scale(1.05) rotate(5deg); }
  66%  { transform: translate(-2vw, 2vh) scale(0.97) rotate(-3deg); }
  100% { transform: translate(4vw, -3vh) scale(1.03) rotate(7deg); }
}

/* ===== Grid overlay ===== */
.grid-overlay {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(109,90,250,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(109,90,250,0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
  z-index: 0;
  animation: grid-fade 4s ease-in-out infinite alternate;
}

@keyframes grid-fade {
  0%   { opacity: 0.5; }
  100% { opacity: 1; }
}

/* ===== Particle Canvas ===== */
#particleCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

button { font-family: inherit; font-size: inherit; color: inherit; background: none; border: none; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
input, textarea { font-family: inherit; color: inherit; }

/* ===== Layout ===== */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr auto;
  height: 100vh;
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  transition: margin-left 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app.sidebar-collapsed { margin-left: 0; }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: rgba(8,8,18,0.85);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  border-right: 1px solid rgba(109,90,250,0.12);
  display: flex;
  flex-direction: column;
  z-index: 30;
  transform: translateX(0);
  transition: transform 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109,90,250,0.5), rgba(34,211,238,0.3), transparent);
}

.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  height: var(--topbar-h);
}

.new-chat-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  background: linear-gradient(135deg, rgba(109,90,250,0.15), rgba(34,211,238,0.08));
  color: var(--text);
  border: 1px solid rgba(109,90,250,0.3);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
  transition: all 0.25s cubic-bezier(0.16,1,0.3,1);
  position: relative;
  overflow: hidden;
}

.new-chat-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(109,90,250,0.2), rgba(34,211,238,0.1));
  opacity: 0;
  transition: opacity 0.25s;
}

.new-chat-btn:hover {
  border-color: rgba(109,90,250,0.6);
  box-shadow: 0 0 20px rgba(109,90,250,0.25), 0 0 40px rgba(34,211,238,0.1);
  transform: translateY(-1px);
}

.new-chat-btn:hover::after { opacity: 1; }

.sidebar-close {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: all 0.2s;
}

.sidebar-close:hover { background: var(--bg-elev-3); color: var(--text); transform: rotate(90deg); }

.sidebar-section {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar-section-title {
  padding: 8px 8px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-section-title::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse-dot 2s ease-in-out infinite;
}

.sidebar-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(109,90,250,0.3), transparent);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--accent); }
  50% { opacity: 0.4; box-shadow: 0 0 2px var(--accent); }
}

.global-list { display: flex; flex-direction: column; gap: 2px; }

.global-item {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  width: 100%;
  color: var(--text-dim);
  font-size: 13px;
  transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
  border: 1px solid transparent;
  position: relative;
  overflow: hidden;
}

.global-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), var(--cyan));
  transform: scaleY(0);
  transition: transform 0.2s;
  border-radius: 0 2px 2px 0;
}

.global-item:hover {
  background: rgba(109,90,250,0.08);
  color: var(--text);
  border-color: rgba(109,90,250,0.15);
  transform: translateX(4px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.global-item:hover::before { transform: scaleY(1); }

.global-item .gi-title {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  font-size: 13px;
}

.global-item .gi-meta {
  display: flex;
  gap: 6px;
  font-size: 11px;
  color: var(--text-mute);
  align-items: center;
}

.global-item .gi-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(109,90,250,0.15);
  color: var(--accent-2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-empty { padding: 16px 10px; color: var(--text-mute); font-size: 12px; text-align: center; }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--border-soft);
  background: rgba(8,8,18,0.5);
}

.sidebar-meta { font-size: 11px; color: var(--text-faint); line-height: 1.4; text-align: center; }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(109,90,250,0.1);
  background: rgba(3,3,8,0.85);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(109,90,250,0.4) 30%, rgba(34,211,238,0.3) 60%, transparent 100%);
}

.icon-btn, .ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-size: 13px;
  transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
  border: 1px solid transparent;
}

.icon-btn { width: 34px; padding: 0; }

.icon-btn:hover, .ghost-btn:hover {
  background: rgba(109,90,250,0.12);
  color: var(--text);
  border-color: rgba(109,90,250,0.3);
  box-shadow: 0 0 15px rgba(109,90,250,0.15);
}

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

.brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(109,90,250,0.3), rgba(34,211,238,0.15));
  border: 1px solid rgba(109,90,250,0.4);
  display: grid;
  place-items: center;
  color: var(--accent-2);
  position: relative;
  overflow: hidden;
  animation: brand-glow 3s ease-in-out infinite alternate;
}

.brand-mark::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, transparent 0deg, rgba(109,90,250,0.3) 60deg, transparent 120deg);
  animation: spin-slow 4s linear infinite;
}

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

@keyframes brand-glow {
  0%   { box-shadow: 0 0 10px rgba(109,90,250,0.3); }
  100% { box-shadow: 0 0 20px rgba(109,90,250,0.5), 0 0 40px rgba(34,211,238,0.15); }
}

.brand-name {
  font-weight: 800;
  letter-spacing: -0.04em;
  font-size: 16px;
  background: linear-gradient(135deg, #fff 20%, var(--accent-2) 60%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
  animation: gradient-shift 4s ease-in-out infinite alternate;
}

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

.brand-status {
  font-size: 11px;
  color: var(--text-mute);
  padding: 3px 10px;
  background: rgba(14,14,28,0.8);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
  transition: all 0.3s;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.brand-status::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.brand-status.busy {
  color: var(--warn);
  border-color: rgba(251,191,36,0.3);
  box-shadow: 0 0 12px rgba(251,191,36,0.15);
}

.brand-status.busy::before {
  background: var(--warn);
  box-shadow: 0 0 6px var(--warn);
  animation: pulse-warn 1s ease-in-out infinite;
}

.brand-status.error::before {
  background: var(--danger);
  box-shadow: 0 0 6px var(--danger);
}

@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Main ===== */
.main {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 20px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
}

/* ===== Welcome ===== */
.welcome {
  width: 100%;
  max-width: var(--composer-max);
  padding: 60px 0 28px;
  text-align: center;
  animation: welcome-in 700ms cubic-bezier(0.16,1,0.3,1) both;
}

@keyframes welcome-in {
  from { opacity: 0; transform: translateY(24px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.welcome.hidden { display: none; }

.welcome-title {
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 0 0 16px;
  background: linear-gradient(135deg, #fff 0%, var(--accent-2) 50%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  background-size: 200% 200%;
  animation: gradient-shift 5s ease-in-out infinite alternate;
  line-height: 1.1;
}

.welcome-orbs {
  position: relative;
  width: 80px; height: 80px;
  margin: 0 auto 28px;
}

.orb {
  position: absolute;
  border-radius: 50%;
  animation: orb-float 3s ease-in-out infinite alternate;
}

.orb-1 {
  width: 80px; height: 80px;
  background: radial-gradient(circle at 35% 35%, rgba(109,90,250,0.8), rgba(109,90,250,0.1) 70%);
  border: 1px solid rgba(109,90,250,0.4);
  box-shadow: 0 0 30px rgba(109,90,250,0.3), inset 0 0 20px rgba(109,90,250,0.1);
  animation-delay: 0s;
}

.orb-2 {
  width: 48px; height: 48px;
  top: -10px; right: -16px;
  background: radial-gradient(circle, rgba(34,211,238,0.7), rgba(34,211,238,0.1) 70%);
  border: 1px solid rgba(34,211,238,0.4);
  box-shadow: 0 0 20px rgba(34,211,238,0.3);
  animation-delay: -1s;
  animation-duration: 2.5s;
}

.orb-3 {
  width: 32px; height: 32px;
  bottom: -8px; right: -4px;
  background: radial-gradient(circle, rgba(244,114,182,0.7), rgba(244,114,182,0.1) 70%);
  border: 1px solid rgba(244,114,182,0.4);
  box-shadow: 0 0 15px rgba(244,114,182,0.3);
  animation-delay: -2s;
  animation-duration: 2s;
}

@keyframes orb-float {
  0%   { transform: translateY(0) scale(1); filter: brightness(1); }
  100% { transform: translateY(-6px) scale(1.04); filter: brightness(1.2); }
}

.welcome-sub {
  font-size: 16px;
  color: var(--text-dim);
  margin: 0 0 44px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
  font-weight: 300;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.chip {
  padding: 9px 18px;
  background: rgba(8,8,18,0.8);
  border: 1px solid rgba(109,90,250,0.2);
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  transition: all 0.25s cubic-bezier(0.16,1,0.3,1);
  position: relative;
  overflow: hidden;
  animation: chip-appear 500ms cubic-bezier(0.16,1,0.3,1) both;
  backdrop-filter: blur(10px);
}

.chip:nth-child(1) { animation-delay: 80ms; }
.chip:nth-child(2) { animation-delay: 140ms; }
.chip:nth-child(3) { animation-delay: 200ms; }
.chip:nth-child(4) { animation-delay: 260ms; }
.chip:nth-child(5) { animation-delay: 320ms; }
.chip:nth-child(6) { animation-delay: 380ms; }

@keyframes chip-appear {
  from { opacity: 0; transform: translateY(10px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(109,90,250,0.15), rgba(34,211,238,0.08));
  opacity: 0;
  transition: opacity 0.25s;
}

.chip:hover {
  color: var(--text);
  border-color: rgba(109,90,250,0.6);
  box-shadow: 0 0 25px rgba(109,90,250,0.25), 0 4px 15px rgba(0,0,0,0.4);
  transform: translateY(-3px) scale(1.02);
}

.chip:hover::before { opacity: 1; }

/* ===== Feature Hints ===== */
.feature-hints {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.feature-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-mute);
  padding: 5px 12px;
  background: rgba(14,14,28,0.6);
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-soft);
}

.feature-hint .fh-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

.fh-dot.purple { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.fh-dot.cyan   { background: var(--cyan);   box-shadow: 0 0 6px var(--cyan); }
.fh-dot.pink   { background: var(--pink);   box-shadow: 0 0 6px var(--pink); }
.fh-dot.green  { background: var(--success); box-shadow: 0 0 6px var(--success); }

/* ===== Chat ===== */
.chat {
  width: 100%;
  max-width: var(--composer-max);
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding-bottom: 28px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: msg-in 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.msg-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
}

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
}

.msg.user .msg-avatar {
  background: linear-gradient(135deg, rgba(34,211,238,0.3), rgba(109,90,250,0.3));
  border: 1px solid rgba(34,211,238,0.3);
  color: var(--cyan);
}

.msg.assistant .msg-avatar {
  background: linear-gradient(135deg, rgba(109,90,250,0.3), rgba(244,114,182,0.2));
  border: 1px solid rgba(109,90,250,0.4);
  color: var(--accent-2);
  box-shadow: 0 0 10px rgba(109,90,250,0.2);
  position: relative;
  overflow: hidden;
}

.msg.assistant .msg-avatar::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, transparent, rgba(109,90,250,0.4) 30deg, transparent 60deg);
  animation: spin-slow 3s linear infinite;
}

.msg-head .msg-author {
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.msg-head .msg-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: var(--radius-pill);
  background: rgba(109,90,250,0.15);
  border: 1px solid rgba(109,90,250,0.25);
  color: var(--accent-2);
  text-transform: uppercase;
  animation: tag-pulse 2s ease-in-out infinite alternate;
}

@keyframes tag-pulse {
  0%   { box-shadow: 0 0 0 rgba(109,90,250,0); }
  100% { box-shadow: 0 0 8px rgba(109,90,250,0.3); }
}

.msg.user .msg-tag {
  background: rgba(34,211,238,0.1);
  border-color: rgba(34,211,238,0.2);
  color: var(--cyan);
  animation: none;
}

.msg-body {
  font-size: 15px;
  color: var(--text);
  line-height: 1.75;
}

/* User bubble */
.msg.user .msg-body {
  background: linear-gradient(135deg, rgba(14,14,28,0.9), rgba(20,20,40,0.8));
  border: 1px solid rgba(34,211,238,0.15);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: inline-block;
  max-width: 85%;
  border-bottom-left-radius: var(--radius-xs);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.02) inset;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.msg.user .msg-body::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34,211,238,0.3), transparent);
}

/* Markdown */
.msg-body p { margin: 0 0 10px; }
.msg-body p:last-child { margin: 0; }
.msg-body h1, .msg-body h2, .msg-body h3, .msg-body h4 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 22px 0 10px;
  color: var(--text);
}
.msg-body h1 { font-size: 24px; }
.msg-body h2 {
  font-size: 19px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(109,90,250,0.2);
  background: linear-gradient(135deg, var(--text) 50%, var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.msg-body h3 { font-size: 17px; color: var(--accent-2); }
.msg-body h4 { font-size: 15px; }
.msg-body ul, .msg-body ol { margin: 0 0 10px; padding-left: 22px; }
.msg-body li { margin-bottom: 6px; }
.msg-body li::marker { color: var(--accent); }
.msg-body a {
  color: var(--cyan);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(34,211,238,0.3);
  transition: text-decoration-color 0.15s;
}
.msg-body a:hover { text-decoration-color: var(--cyan); }
.msg-body blockquote {
  border-left: 2px solid var(--accent);
  padding-left: 16px;
  margin: 14px 0;
  color: var(--text-dim);
  font-style: italic;
  background: rgba(109,90,250,0.05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 16px;
}
.msg-body hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109,90,250,0.3), transparent);
  margin: 22px 0;
}
.msg-body table {
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-2);
}
.msg-body th, .msg-body td {
  border: 1px solid var(--border-soft);
  padding: 10px 14px;
  text-align: left;
}
.msg-body th {
  background: rgba(109,90,250,0.1);
  font-weight: 700;
  font-size: 12px;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.msg-body tr:nth-child(even) td { background: rgba(255,255,255,0.01); }
.msg-body tr:hover td { background: rgba(109,90,250,0.04); }

/* Inline code */
.msg-body code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 2px 7px;
  background: rgba(109,90,250,0.12);
  border: 1px solid rgba(109,90,250,0.25);
  border-radius: 5px;
  color: var(--accent-2);
}

/* Code blocks */
.code-block {
  position: relative;
  margin: 16px 0;
  background: #060610;
  border: 1px solid rgba(109,90,250,0.2);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-2), 0 0 30px rgba(109,90,250,0.05);
  transition: box-shadow 0.3s;
}

.code-block:hover {
  box-shadow: var(--shadow-2), 0 0 40px rgba(109,90,250,0.1);
}

.code-block::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109,90,250,0.5), rgba(34,211,238,0.3), transparent);
}

.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(8,8,20,0.8);
  border-bottom: 1px solid rgba(109,90,250,0.1);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-mute);
  letter-spacing: 0.04em;
}

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

.code-lang-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

/* macOS-style dots */
.code-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.code-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}

.code-dot-r { background: #ff5f57; }
.code-dot-y { background: #ffbd2e; }
.code-dot-g { background: #28ca41; }

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--text-dim);
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  transition: all 0.2s;
  font-family: var(--font-sans);
}

.code-copy:hover {
  background: rgba(109,90,250,0.12);
  color: var(--text);
  border-color: rgba(109,90,250,0.3);
}

.code-copy.copied {
  color: var(--success);
  border-color: rgba(52,211,153,0.3);
}

.msg-body pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
}

.msg-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-family: var(--font-mono);
  color: inherit;
}

/* Image result */
.image-card {
  margin-top: 12px;
  border: 1px solid rgba(109,90,250,0.2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--bg-elev-1);
  max-width: 580px;
  box-shadow: var(--shadow-2);
  transition: all 0.35s cubic-bezier(0.16,1,0.3,1);
  position: relative;
}

.image-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(109,90,250,0.05), rgba(34,211,238,0.03));
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.3s;
}

.image-card:hover {
  box-shadow: var(--shadow-3), 0 0 40px rgba(109,90,250,0.2);
  transform: translateY(-4px) scale(1.01);
  border-color: rgba(109,90,250,0.4);
}

.image-card:hover::before { opacity: 1; }

.image-card img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg-elev-2);
  transition: opacity 0.4s ease;
}

.image-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(8,8,18,0.8);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(109,90,250,0.1);
  font-size: 12px;
  color: var(--text-mute);
}

.image-card-actions { display: flex; gap: 6px; }

.mini-btn {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(109,90,250,0.2);
  background: rgba(109,90,250,0.08);
  transition: all 0.2s;
}

.mini-btn:hover {
  background: rgba(109,90,250,0.2);
  color: var(--text);
  border-color: rgba(109,90,250,0.5);
  box-shadow: 0 0 12px rgba(109,90,250,0.2);
  transform: translateY(-1px);
}

/* Skeleton */
.img-skeleton {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 580px;
  background: linear-gradient(
    110deg,
    var(--bg-elev-1) 8%,
    rgba(109,90,250,0.08) 20%,
    rgba(34,211,238,0.05) 28%,
    var(--bg-elev-1) 36%
  );
  background-size: 300% 100%;
  animation: skeleton-shimmer 1.8s ease-in-out infinite;
  display: grid;
  place-items: center;
  color: var(--text-mute);
  font-size: 13px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Document card */
.doc-card {
  margin-top: 14px;
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(8,8,18,0.9), rgba(14,14,28,0.8));
  border: 1px solid rgba(109,90,250,0.2);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 500px;
  box-shadow: var(--shadow-1);
  transition: all 0.25s;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.doc-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109,90,250,0.5), transparent);
}

.doc-card:hover {
  border-color: rgba(109,90,250,0.4);
  box-shadow: var(--shadow-2), 0 0 25px rgba(109,90,250,0.15);
  transform: translateY(-2px);
}

.doc-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(109,90,250,0.25), rgba(34,211,238,0.15));
  border: 1px solid rgba(109,90,250,0.3);
  display: grid;
  place-items: center;
  color: var(--accent-2);
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 0 15px rgba(109,90,250,0.15);
}

.doc-info { flex: 1; min-width: 0; }
.doc-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-meta { font-size: 12px; color: var(--text-mute); }

/* ===== Thinking indicator ===== */
.thinking {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 14px;
  padding: 14px 20px;
  background: rgba(8,8,18,0.8);
  border: 1px solid rgba(109,90,250,0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.thinking::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(109,90,250,0.08), transparent);
  animation: thinking-scan 2s ease-in-out infinite;
}

@keyframes thinking-scan {
  0%   { left: -60%; }
  100% { left: 160%; }
}

.thinking-dots {
  display: inline-flex;
  gap: 5px;
}

.thinking-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-bounce 1.5s ease-in-out infinite;
  box-shadow: 0 0 8px var(--accent-glow);
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; background: var(--accent); }
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; background: var(--cyan); }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; background: var(--pink); }

@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0) scale(0.85); opacity: 0.4; }
  40%           { transform: translateY(-7px) scale(1.1); opacity: 1; }
}

/* Error */
.msg-body.error {
  color: var(--danger);
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.25);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

/* Image preview in attachment */
.att-img-preview {
  width: 40px; height: 40px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* ===== Simulation Cards ===== */
.sim-card {
  margin: 14px 0;
  background: rgba(6,6,16,0.9);
  border: 1px solid rgba(109,90,250,0.25);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-2), 0 0 40px rgba(109,90,250,0.08);
  position: relative;
}

.sim-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--cyan), var(--pink), var(--accent));
  background-size: 200% 100%;
  animation: gradient-scroll 2s linear infinite;
}

@keyframes gradient-scroll {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

.sim-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(109,90,250,0.1);
  background: rgba(8,8,20,0.6);
}

.sim-header .sim-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 16px;
  background: rgba(109,90,250,0.15);
  border: 1px solid rgba(109,90,250,0.3);
}

.sim-title { font-weight: 700; font-size: 14px; flex: 1; }
.sim-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  background: rgba(52,211,153,0.15);
  border: 1px solid rgba(52,211,153,0.3);
  border-radius: var(--radius-pill);
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  animation: live-blink 1.5s ease-in-out infinite;
}

@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.sim-body { padding: 16px; }

/* Chart Simulation */
.sim-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 80px;
}

.sim-bar {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--accent), rgba(109,90,250,0.3));
  animation: bar-rise 0.6s cubic-bezier(0.16,1,0.3,1) both;
  position: relative;
  cursor: pointer;
  transition: filter 0.2s;
  min-width: 8px;
}

.sim-bar:hover { filter: brightness(1.4); }

@keyframes bar-rise {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

.sim-bar:nth-child(1)  { animation-delay: 0ms; }
.sim-bar:nth-child(2)  { animation-delay: 40ms; }
.sim-bar:nth-child(3)  { animation-delay: 80ms; }
.sim-bar:nth-child(4)  { animation-delay: 120ms; }
.sim-bar:nth-child(5)  { animation-delay: 160ms; }
.sim-bar:nth-child(6)  { animation-delay: 200ms; }
.sim-bar:nth-child(7)  { animation-delay: 240ms; }
.sim-bar:nth-child(8)  { animation-delay: 280ms; }

/* Neural Net Simulation */
.neural-canvas {
  width: 100%;
  height: 140px;
  border-radius: var(--radius-md);
  background: rgba(3,3,10,0.8);
}

/* Typing Simulation */
.typing-sim {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--success);
  padding: 12px 14px;
  background: rgba(3,3,10,0.9);
  border-radius: var(--radius-md);
  min-height: 60px;
  border: 1px solid rgba(52,211,153,0.15);
  position: relative;
}

.typing-cursor {
  display: inline-block;
  width: 8px; height: 1.2em;
  background: var(--success);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink-cursor 0.8s steps(1) infinite;
}

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

/* Waveform Simulation */
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 60px;
  justify-content: center;
}

.wave-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--cyan);
  animation: wave-animate 1.2s ease-in-out infinite alternate;
  box-shadow: 0 0 4px rgba(34,211,238,0.4);
}

@keyframes wave-animate {
  0%   { height: 4px; opacity: 0.3; }
  100% { height: var(--h); opacity: 1; }
}

/* ===== Composer ===== */
.composer-wrap {
  width: 100%;
  padding: 10px 20px 16px;
  background: linear-gradient(to top, rgba(3,3,8,0.95) 40%, transparent);
  border-top: 1px solid transparent;
  position: relative;
  z-index: 5;
}

.attachments {
  max-width: var(--composer-max);
  margin: 0 auto 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.attachments:empty { display: none; }

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(14,14,28,0.9);
  border: 1px solid rgba(109,90,250,0.25);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-dim);
  animation: chip-in 220ms cubic-bezier(0.16,1,0.3,1) both;
  backdrop-filter: blur(10px);
}

@keyframes chip-in {
  from { opacity: 0; transform: scale(0.85) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.attachment-chip .ac-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 500;
}

.attachment-chip .ac-remove {
  width: 18px; height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-mute);
  transition: all 0.15s;
}

.attachment-chip .ac-remove:hover {
  background: rgba(248,113,113,0.15);
  color: var(--danger);
}

.composer {
  max-width: var(--composer-max);
  margin: 0 auto;
  background: rgba(8,8,18,0.9);
  border: 1px solid rgba(109,90,250,0.2);
  border-radius: var(--radius-xl);
  padding: 10px 10px 10px 14px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  transition: all 0.3s cubic-bezier(0.16,1,0.3,1);
  box-shadow: var(--shadow-1), 0 0 0 0 rgba(109,90,250,0);
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
}

.composer::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109,90,250,0.3), rgba(34,211,238,0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.composer:focus-within {
  border-color: rgba(109,90,250,0.5);
  box-shadow: 0 0 0 3px rgba(109,90,250,0.1), var(--shadow-2), 0 0 30px rgba(109,90,250,0.1);
}

.composer:focus-within::before { opacity: 1; }

.attach-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  color: var(--text-mute);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
  margin-bottom: 2px;
  border: 1px solid transparent;
}

.attach-btn:hover {
  background: rgba(109,90,250,0.12);
  color: var(--accent-2);
  transform: rotate(20deg) scale(1.05);
  border-color: rgba(109,90,250,0.3);
}

.user-input {
  flex: 1;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  line-height: 1.6;
  padding: 10px 4px;
  max-height: 240px;
  min-height: 24px;
  color: var(--text);
}

.user-input::placeholder { color: var(--text-mute); }

/* Send button with gradient ring */
.send-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16,1,0.3,1);
  margin-bottom: 2px;
  box-shadow: 0 2px 16px rgba(109,90,250,0.5);
  position: relative;
  overflow: hidden;
}

.send-btn::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, var(--accent), var(--cyan), var(--pink), var(--accent));
  background-size: 200% 200%;
  border-radius: calc(var(--radius-md) + 2px);
  z-index: -1;
  animation: gradient-spin 3s linear infinite;
  opacity: 0;
  transition: opacity 0.2s;
}

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

.send-btn:hover:not(:disabled) {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 6px 24px rgba(109,90,250,0.7);
}

.send-btn:hover::before { opacity: 1; }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.send-btn .stop-icon { display: none; }
.send-btn.is-loading {
  background: rgba(20,20,40,0.9);
  color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(109,90,250,0.3);
  animation: loading-pulse 1.5s ease-in-out infinite;
}
.send-btn.is-loading .send-icon { display: none; }
.send-btn.is-loading .stop-icon { display: block; }

@keyframes loading-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(109,90,250,0.2), 0 0 15px rgba(109,90,250,0.1); }
  50%       { box-shadow: 0 0 0 4px rgba(109,90,250,0.3), 0 0 25px rgba(109,90,250,0.2); }
}

.composer-meta {
  max-width: var(--composer-max);
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-mute);
}

.hint { font-family: var(--font-sans); }

.model-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.model-picker-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
}

.model-select {
  padding: 4px 28px 4px 10px;
  background: rgba(14,14,28,0.9);
  border: 1px solid rgba(109,90,250,0.2);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235858a0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}

.model-select:hover { border-color: rgba(109,90,250,0.4); }
.model-select:focus { outline: none; border-color: rgba(109,90,250,0.6); box-shadow: 0 0 0 2px rgba(109,90,250,0.1); }
.model-select option { background: #0e0e1c; color: var(--text); }

/* ===== Backdrop ===== */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.backdrop.visible { opacity: 1; pointer-events: auto; }

/* ===== Toast Notifications ===== */
.toast-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: rgba(14,14,28,0.95);
  border: 1px solid rgba(109,90,250,0.3);
  border-radius: var(--radius-lg);
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  box-shadow: var(--shadow-3), 0 0 20px rgba(109,90,250,0.15);
  backdrop-filter: blur(20px);
  animation: toast-in 400ms cubic-bezier(0.16,1,0.3,1) both;
  pointer-events: all;
}

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

.toast.success { border-color: rgba(52,211,153,0.4); }
.toast.error   { border-color: rgba(248,113,113,0.4); }

/* ===== Scroll to bottom button ===== */
.scroll-bottom-btn {
  position: sticky;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(109,90,250,0.2);
  border: 1px solid rgba(109,90,250,0.4);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 20px rgba(109,90,250,0.2);
  transition: all 0.2s;
  cursor: pointer;
  z-index: 5;
  animation: float-btn 2s ease-in-out infinite alternate;
}

.scroll-bottom-btn.visible { display: flex; }
.scroll-bottom-btn:hover { transform: translateX(-50%) translateY(0) scale(1.05); background: rgba(109,90,250,0.3); }

@keyframes float-btn {
  0%   { box-shadow: 0 4px 20px rgba(0,0,0,0.4), 0 0 20px rgba(109,90,250,0.2); }
  100% { box-shadow: 0 8px 30px rgba(0,0,0,0.5), 0 0 30px rgba(109,90,250,0.35); }
}

/* ===== Message Actions ===== */
.msg-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s;
  margin-top: 4px;
}

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

.msg-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-mute);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.msg-action-btn:hover {
  background: rgba(109,90,250,0.08);
  color: var(--text-dim);
  border-color: rgba(109,90,250,0.2);
}

/* ===== Mobile ===== */
@media (max-width: 860px) {
  .app { margin-left: 0; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-3); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 12px; }
  .brand-status { display: none; }
  .top-actions .ghost-btn span { display: none; }
  .top-actions .ghost-btn { width: 34px; padding: 0; }
  .main { padding: 16px 14px 8px; }
  .welcome { padding: 32px 0 20px; }
  .composer-wrap { padding: 8px 12px 14px; }
  .composer-meta { font-size: 10px; }
  .msg.user .msg-body { max-width: 95%; }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(109,90,250,0.25);
  border-radius: 3px;
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover { background: rgba(109,90,250,0.5); }

::selection { background: rgba(109,90,250,0.25); color: var(--text); }

:focus-visible {
  outline: 2px solid rgba(109,90,250,0.7);
  outline-offset: 2px;
}

/* ===== Special Animations ===== */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-6px); }
}

@keyframes glow-pulse {
  0%, 100% { filter: drop-shadow(0 0 4px var(--accent)); }
  50%       { filter: drop-shadow(0 0 12px var(--accent)); }
}

/* ===== Reactions ===== */
.reaction-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.reaction {
  padding: 3px 10px;
  background: rgba(109,90,250,0.08);
  border: 1px solid rgba(109,90,250,0.2);
  border-radius: var(--radius-pill);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.reaction:hover {
  background: rgba(109,90,250,0.2);
  border-color: rgba(109,90,250,0.4);
  transform: scale(1.1);
}

.reaction.active {
  background: rgba(109,90,250,0.25);
  border-color: rgba(109,90,250,0.5);
}

.reaction span { font-size: 11px; color: var(--text-mute); font-weight: 600; }

/* ===== Progress Bar ===== */
.gen-progress {
  height: 2px;
  background: rgba(109,90,250,0.1);
  border-radius: 1px;
  overflow: hidden;
  margin-top: 8px;
}

.gen-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 1px;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
  transform-origin: left;
}

@keyframes progress-indeterminate {
  0%   { transform: translateX(-100%) scaleX(0.3); }
  50%  { transform: translateX(50%) scaleX(0.8); }
  100% { transform: translateX(300%) scaleX(0.2); }
}
