/* ═══════════════════════════════════════════════════════════
   style.css — NeuralChat ULTRA
   Vibrant Glassmorphism · Colorful · Study AI Theme
   Fonts: Plus Jakarta Sans + Fira Code
═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Fira+Code:wght@300;400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
textarea, input { font-family: inherit; -webkit-appearance: none; appearance: none; }
a { text-decoration: none; }
code { font-family: var(--mono); }

/* ── Design Tokens ─────────────────────────────────────── */
:root {
  /* Glass surfaces */
  --glass:         rgba(255,255,255,0.04);
  --glass2:        rgba(255,255,255,0.07);
  --glass3:        rgba(255,255,255,0.11);
  --glass4:        rgba(255,255,255,0.16);

  /* Borders */
  --border:        rgba(255,255,255,0.08);
  --border2:       rgba(255,255,255,0.14);
  --border3:       rgba(255,255,255,0.22);

  /* Text */
  --text:          #f0f2ff;
  --text2:         #a8aec8;
  --text3:         #5c6180;
  --text4:         #363a52;

  /* Background base */
  --bg:            #080a14;

  /* Vivid accent palette */
  --pink:          #f472b6;
  --pink-d:        rgba(244,114,182,0.15);
  --pink-b:        rgba(244,114,182,0.28);

  --violet:        #a78bfa;
  --violet-d:      rgba(167,139,250,0.15);
  --violet-b:      rgba(167,139,250,0.28);

  --cyan:          #22d3ee;
  --cyan-d:        rgba(34,211,238,0.12);
  --cyan-b:        rgba(34,211,238,0.25);

  --orange:        #fb923c;
  --orange-d:      rgba(251,146,60,0.13);

  --green:         #4ade80;
  --green-d:       rgba(74,222,128,0.12);
  --green-b:       rgba(74,222,128,0.25);

  --amber:         #fbbf24;
  --red:           #f87171;
  --red-d:         rgba(248,113,113,0.10);
  --red-b:         rgba(248,113,113,0.25);

  /* Gradients */
  --grad-main:     linear-gradient(135deg, #f97316 0%, #ec4899 50%, #a78bfa 100%);
  --grad-cool:     linear-gradient(135deg, #22d3ee 0%, #a78bfa 100%);
  --grad-fire:     linear-gradient(135deg, #fb923c 0%, #f472b6 100%);
  --grad-user:     linear-gradient(135deg, rgba(249,115,22,0.18) 0%, rgba(236,72,153,0.18) 100%);
  --grad-bot:      linear-gradient(135deg, rgba(34,211,238,0.08) 0%, rgba(167,139,250,0.08) 100%);

  /* User/bot bubbles */
  --user-bg:       rgba(249,115,22,0.12);
  --user-bdr:      rgba(249,115,22,0.35);
  --bot-bg:        rgba(167,139,250,0.07);
  --bot-bdr:       rgba(167,139,250,0.22);

  /* Typography */
  --sans:          'Plus Jakarta Sans', sans-serif;
  --mono:          'Fira Code', monospace;

  /* Radii */
  --r-xs:          5px;
  --r-sm:          10px;
  --r:             16px;
  --r-lg:          20px;
  --r-xl:          26px;

  /* Layout */
  --sidebar-w:     285px;
  --topbar-h:      62px;

  /* Shadows */
  --shadow:        0 8px 40px rgba(0,0,0,0.6);
  --shadow-lg:     0 24px 80px rgba(0,0,0,0.75);
  --glow-pink:     0 0 40px rgba(244,114,182,0.25);
  --glow-violet:   0 0 40px rgba(167,139,250,0.25);
  --glow-cyan:     0 0 40px rgba(34,211,238,0.2);
}

/* ── Base ──────────────────────────────────────────────── */
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  cursor: default;
}

/* ── Animated background canvas ────────────────────────── */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar        { width: 3px; height: 3px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: rgba(167,139,250,0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(167,139,250,0.5); }

/* ═══════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════ */
#app {
  position: relative; z-index: 1;
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

#main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  overflow: hidden; position: relative;
}

/* Mobile overlay */
#overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 9;
}
#overlay.show { display: block; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: rgba(12,14,26,0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(.4,0,.2,1);
  position: relative; z-index: 10;
}

/* Sidebar inner glow */
#sidebar::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 260px;
  background: radial-gradient(ellipse at 50% -20%, rgba(167,139,250,0.12) 0%, transparent 70%);
  pointer-events: none;
}

/* Logo */
.sb-logo {
  display: flex; align-items: center; gap: 13px;
  padding: 24px 22px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.sb-logo-mark {
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--grad-main);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 24px rgba(249,115,22,0.4), 0 0 0 1px rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}

.sb-logo-mark::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
}

.sb-logo-name {
  font-family: var(--sans);
  font-size: 18px; font-weight: 800;
  background: var(--grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.04em; line-height: 1;
}

.sb-logo-sub {
  font-size: 9px; color: var(--text3);
  letter-spacing: 0.14em; text-transform: uppercase;
  margin-top: 4px; font-weight: 500;
}

/* Scrollable body */
.sb-body {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-bottom: 10px;
}

.sb-section { padding: 18px 20px 0; }

.sb-label {
  font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text3); margin-bottom: 10px; font-weight: 600;
}

/* Model chip */
.sb-model {
  display: flex; align-items: center; gap: 12px;
  background: var(--glass2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 13px 15px;
  backdrop-filter: blur(10px);
  transition: background 0.2s, border-color 0.2s;
}
.sb-model:hover {
  background: var(--glass3);
  border-color: var(--border3);
}

.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
  box-shadow: 0 0 12px rgba(74,222,128,0.9);
  animation: livePulse 2.4s ease-in-out infinite;
}

.sb-model-name { font-size: 12.5px; color: var(--text); font-weight: 600; line-height: 1.25; }
.sb-model-sub  { font-size: 10px; color: var(--text3); margin-top: 2px; }

/* Stats */
.sb-stats-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 8px;
}

.sb-stat {
  background: var(--glass2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 15px;
  transition: background 0.2s;
}
.sb-stat:hover { background: var(--glass3); }

.sb-stat-num {
  font-family: var(--sans);
  font-size: 28px; font-weight: 800;
  background: var(--grad-main);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1; letter-spacing: -0.04em;
  transition: all 0.3s;
}

.sb-stat-lbl { font-size: 10px; color: var(--text3); margin-top: 5px; font-weight: 500; }

.sb-tokens {
  background: var(--glass2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 15px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10.5px;
}
.sb-tokens span:first-child { color: var(--text3); }
.sb-tokens span:last-child  { color: var(--cyan); font-weight: 600; font-family: var(--mono); font-size: 11px; }

/* Params */
.sb-params {
  background: var(--glass2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 2px 15px;
}

.sb-param {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; font-size: 11px;
}

.sb-param + .sb-param { border-top: 1px solid rgba(255,255,255,0.04); }
.sb-param span:first-child { color: var(--text3); }
.sb-param span:last-child  { color: var(--text2); font-family: var(--mono); font-size: 10.5px; }

.tag-on {
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.05em;
  background: var(--green-d);
  color: var(--green) !important;
  padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--green-b);
  font-family: var(--sans) !important;
}

/* Quick prompts */
.sb-prompts { display: flex; flex-direction: column; gap: 5px; }

.sb-prompt {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text2);
  font-size: 11.5px; font-weight: 500;
  text-align: left; line-height: 1.4;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.sb-prompt::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--grad-main);
  opacity: 0;
  transition: opacity 0.25s;
}

.sb-prompt:hover {
  color: var(--text);
  border-color: rgba(167,139,250,0.4);
  transform: translateX(3px);
}
.sb-prompt:hover::before { opacity: 0.06; }

.sb-prompt-icon { font-size: 13px; position: relative; z-index: 1; }
.sb-prompt span:not(.sb-prompt-icon) { position: relative; z-index: 1; }

/* Sidebar footer */
.sb-footer {
  padding: 14px 20px 20px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}

.btn-reset {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--glass2);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text2); font-size: 12px; font-weight: 500;
  transition: all 0.2s; width: 100%;
  justify-content: center;
}
.btn-reset:hover {
  background: var(--red-d);
  border-color: var(--red-b);
  color: var(--red);
}

.btn-key {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text3); font-size: 11px;
  transition: all 0.2s; width: 100%;
  justify-content: center;
}
.btn-key:hover {
  border-color: rgba(167,139,250,0.4);
  color: var(--violet);
  background: var(--violet-d);
}

.sb-credit {
  text-align: center;
  font-size: 9.5px; color: var(--text4);
  letter-spacing: 0.04em; padding-top: 2px;
}

/* ═══════════════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════════════ */
#topbar {
  height: var(--topbar-h);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(8,10,20,0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative; z-index: 5;
}

#topbar::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.4), rgba(244,114,182,0.4), transparent);
}

.topbar-l { display: flex; align-items: center; gap: 14px; }
.topbar-r { display: flex; align-items: center; gap: 12px; }

.menu-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  display: none; align-items: center; justify-content: center;
  background: var(--glass2); border: 1px solid var(--border2);
  color: var(--text2); transition: all 0.2s;
}
.menu-btn:hover { background: var(--glass3); color: var(--text); }

.topbar-brand { display: flex; align-items: center; gap: 10px; }

.topbar-title {
  font-size: 15px; font-weight: 700;
  background: var(--grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.status-pill {
  font-size: 10.5px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  letter-spacing: 0.06em; font-family: var(--mono);
  transition: all 0.3s;
}

.status-pill[data-s="ready"] {
  background: var(--green-d);
  color: var(--green);
  border: 1px solid var(--green-b);
}
.status-pill[data-s="thinking"] {
  background: var(--amber-d, rgba(251,191,36,0.12));
  color: var(--amber);
  border: 1px solid rgba(251,191,36,0.3);
  animation: pillPulse 1.2s ease-in-out infinite;
}
.status-pill[data-s="streaming"] {
  background: var(--violet-d);
  color: var(--violet);
  border: 1px solid var(--violet-b);
  animation: pillPulse 0.8s ease-in-out infinite;
}

@keyframes pillPulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.topbar-tokens {
  font-family: var(--mono);
  font-size: 10.5px; color: var(--text3);
  background: var(--glass2);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 11px;
}

.topbar-model {
  font-size: 11px; color: var(--text3);
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
  font-weight: 500;
}

.topbar-key-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px;
  background: var(--glass2);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text2); font-size: 11.5px; font-weight: 500;
  transition: all 0.2s;
}
.topbar-key-btn:hover {
  background: var(--violet-d);
  border-color: var(--violet-b);
  color: var(--violet);
}

/* ═══════════════════════════════════════════════════════════
   MESSAGES
═══════════════════════════════════════════════════════════ */
#messages {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 32px 28px;
  display: flex; flex-direction: column;
  gap: 6px;
}

/* ── Empty State ────────────────────────────────────────── */
#empty-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 60px 20px;
  min-height: 60%;
  animation: fadeUp 0.6s ease;
}

.empty-glow-ring {
  position: relative;
  margin-bottom: 28px;
}

.empty-glow-ring::before {
  content: '';
  position: absolute; inset: -18px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244,114,182,0.25) 0%, rgba(167,139,250,0.15) 50%, transparent 70%);
  animation: ringPulse 3s ease-in-out infinite;
}

.empty-glow-ring::after {
  content: '';
  position: absolute; inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(244,114,182,0.3);
  animation: ringPulse 3s ease-in-out infinite 0.5s;
}

.empty-ring {
  width: 76px; height: 76px;
  border-radius: 22px;
  background: var(--grad-main);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 40px rgba(249,115,22,0.4), 0 0 0 1px rgba(255,255,255,0.12);
  animation: iconFloat 4s ease-in-out infinite;
  position: relative; z-index: 1;
  overflow: hidden;
}

.empty-ring::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, transparent 60%);
}

@keyframes ringPulse {
  0%,100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.6; }
}

.empty-title {
  font-family: var(--sans);
  font-size: 32px; font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.6) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.04em; margin-bottom: 10px;
  line-height: 1.15;
}

.empty-sub {
  font-size: 12.5px; color: var(--text3); font-weight: 400;
  margin-bottom: 32px; letter-spacing: 0.02em;
}

.empty-chips {
  display: flex; flex-wrap: wrap;
  gap: 9px; justify-content: center; max-width: 540px;
}

.chip {
  padding: 9px 16px;
  background: var(--glass2);
  border: 1px solid var(--border2);
  border-radius: 50px;
  color: var(--text2); font-size: 12.5px; font-weight: 500;
  transition: all 0.25s;
  position: relative; overflow: hidden;
}

.chip::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--grad-main);
  opacity: 0;
  transition: opacity 0.25s;
}

.chip:hover {
  color: var(--text);
  border-color: rgba(244,114,182,0.45);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(244,114,182,0.2);
}
.chip:hover::before { opacity: 0.08; }
.chip:active { transform: translateY(0); }

/* ── Message row ────────────────────────────────────────── */
.msg-row {
  display: flex; gap: 13px;
  padding: 4px 0;
  animation: fadeUp 0.35s ease;
}

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

/* Avatar */
.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 11px;
  flex-shrink: 0; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  position: relative;
  overflow: hidden;
}

.msg-avatar.bot {
  background: var(--grad-cool);
  box-shadow: 0 4px 14px rgba(34,211,238,0.3);
}

.msg-avatar.bot::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
}

.msg-avatar.user {
  background: var(--grad-fire);
  box-shadow: 0 4px 14px rgba(251,146,60,0.3);
}

.msg-avatar.user::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
}

.msg-avatar svg { position: relative; z-index: 1; }

/* Bubble */
.bubble-wrap {
  display: flex; flex-direction: column;
  max-width: 72%;
  gap: 5px;
}

.msg-row.user .bubble-wrap { align-items: flex-end; }

.bubble {
  padding: 13px 17px;
  border-radius: var(--r);
  font-size: 13.5px; line-height: 1.7;
  position: relative;
  overflow: hidden;
  word-break: break-word;
}

/* Bot bubble */
.bubble.bot {
  background: var(--bot-bg);
  border: 1px solid var(--bot-bdr);
  border-bottom-left-radius: 5px;
  color: var(--text);
  backdrop-filter: blur(10px);
}

.bubble.bot::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, rgba(34,211,238,0.4), rgba(167,139,250,0.4), transparent);
}

/* User bubble */
.bubble.user {
  background: var(--user-bg);
  border: 1px solid var(--user-bdr);
  border-bottom-right-radius: 5px;
  color: var(--text);
  backdrop-filter: blur(10px);
}

.bubble.user::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(251,146,60,0.5), rgba(244,114,182,0.5));
}

/* Timestamp */
.msg-time {
  font-size: 10px; color: var(--text3);
  padding: 0 5px; font-family: var(--mono); font-weight: 300;
}

/* Thinking indicator */
.thinking-row {
  display: flex; gap: 13px; padding: 4px 0;
  animation: fadeUp 0.35s ease;
}

.thinking-bubble {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 16px;
  background: var(--bot-bg);
  border: 1px solid var(--bot-bdr);
  border-radius: var(--r);
  border-bottom-left-radius: 5px;
  backdrop-filter: blur(10px);
}

.thinking-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--violet);
  animation: dotBounce 1.3s ease-in-out infinite;
}
.thinking-dot:nth-child(2) { animation-delay: 0.18s; background: var(--pink); }
.thinking-dot:nth-child(3) { animation-delay: 0.36s; background: var(--cyan); }

/* ── Markdown inside bubbles ────────────────────────────── */
.bubble p { margin-bottom: 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble h1,.bubble h2,.bubble h3 {
  font-weight: 700; letter-spacing: -0.02em;
  background: var(--grad-cool);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 14px 0 8px;
}
.bubble h1 { font-size: 17px; }
.bubble h2 { font-size: 15px; }
.bubble h3 { font-size: 13.5px; }

.bubble ul,.bubble ol {
  padding-left: 20px; margin: 6px 0;
}
.bubble li { margin-bottom: 3px; }

.bubble code {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(167,139,250,0.12);
  border: 1px solid rgba(167,139,250,0.2);
  padding: 1px 6px; border-radius: 5px;
  color: var(--violet);
}

.bubble pre {
  background: rgba(8,10,20,0.8);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  margin: 10px 0; overflow: hidden;
}

.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px;
  background: rgba(167,139,250,0.07);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-size: 10px; font-family: var(--mono);
  color: var(--violet); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.1em;
}

.copy-code-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 10.5px; color: var(--text3);
  padding: 3px 8px; border-radius: 5px;
  background: var(--glass2); border: 1px solid var(--border);
  transition: all 0.2s;
}
.copy-code-btn:hover {
  color: var(--text); background: var(--glass3);
  border-color: var(--border2);
}

.bubble pre code {
  display: block;
  padding: 14px 16px;
  font-size: 12.5px;
  background: none; border: none; padding-top: 10px;
  color: var(--text); white-space: pre; overflow-x: auto;
  line-height: 1.7;
}

.bubble blockquote {
  border-left: 3px solid var(--violet);
  padding: 4px 0 4px 14px;
  color: var(--text2); margin: 8px 0;
  font-style: italic;
}

.bubble strong { color: var(--text); font-weight: 700; }
.bubble em { color: var(--pink); font-style: italic; }
.bubble hr { border: none; border-top: 1px solid var(--border2); margin: 12px 0; }

/* Cursor blink while streaming */
.cursor {
  display: inline-block;
  width: 2px; height: 14px;
  background: var(--violet);
  margin-left: 2px; vertical-align: middle;
  animation: blink 0.9s ease-in-out infinite;
  border-radius: 2px;
}

/* Copy message button */
.copy-msg-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--text3);
  padding: 3px 9px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--border);
  transition: all 0.2s; opacity: 0;
  margin-top: 3px;
}
.bubble-wrap:hover .copy-msg-btn { opacity: 1; }
.copy-msg-btn:hover { color: var(--text2); background: var(--glass2); }

/* Scroll button */
.scroll-btn {
  position: absolute; bottom: 100px; right: 28px;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--glass3);
  border: 1px solid var(--border2);
  backdrop-filter: blur(12px);
  color: var(--text2); z-index: 4;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.scroll-btn:hover { background: var(--violet-d); border-color: var(--violet-b); color: var(--violet); }
.scroll-btn.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* Error bar */
.error-bar {
  margin: 0 28px 12px;
  padding: 10px 16px;
  background: var(--red-d);
  border: 1px solid var(--red-b);
  border-radius: var(--r-sm);
  color: var(--red);
  font-size: 12px;
  display: none;
}
.error-bar.show { display: block; animation: fadeUp 0.3s ease; }

/* ═══════════════════════════════════════════════════════════
   INPUT AREA
═══════════════════════════════════════════════════════════ */
#input-area {
  padding: 14px 28px 26px;
  border-top: 1px solid var(--border);
  background: rgba(8,10,20,0.5);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
  position: relative;
}

#input-area::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.3), rgba(244,114,182,0.3), transparent);
}

.input-shell {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--glass2);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 12px 14px 12px 20px;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
  position: relative;
  overflow: hidden;
}

.input-shell::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--grad-main);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.input-shell:focus-within {
  border-color: rgba(167,139,250,0.5);
  box-shadow: 0 0 0 3px rgba(167,139,250,0.08), 0 0 30px rgba(167,139,250,0.1);
  background: var(--glass3);
}
.input-shell:focus-within::before { opacity: 0.025; }

#chat-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 14px; line-height: 1.65;
  resize: none; max-height: 160px; min-height: 22px;
  caret-color: var(--violet); letter-spacing: 0.01em;
  font-family: var(--sans); font-weight: 400;
}
#chat-input::placeholder { color: var(--text3); }

.input-btns {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; margin-bottom: 1px;
}

.char-count {
  font-family: var(--mono);
  font-size: 10px; color: var(--text3);
  min-width: 24px; text-align: right;
}
.char-count.warn { color: var(--amber); }
.char-count.over { color: var(--red); }

.send-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--grad-main);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.22s;
  box-shadow: 0 4px 20px rgba(249,115,22,0.4);
  position: relative; overflow: hidden;
}

.send-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
}

.send-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 28px rgba(244,114,182,0.55);
}
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; box-shadow: none; }

.input-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 9px; padding: 0 3px;
}
.input-hint { font-size: 10px; color: var(--text3); letter-spacing: 0.04em; }
.input-note { font-size: 10px; color: var(--text3); letter-spacing: 0.03em; }

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
#modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(16px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.25s ease;
}
#modal-backdrop.hidden { display: none; }

.modal {
  background: rgba(14,16,30,0.92);
  border: 1px solid var(--border2);
  border-radius: var(--r-xl);
  padding: 36px 32px 32px;
  width: 450px; max-width: 92vw;
  box-shadow: var(--shadow-lg), var(--glow-violet);
  animation: slideUp 0.3s ease;
  position: relative; overflow: hidden;
  backdrop-filter: blur(30px);
}

.modal-orb {
  position: absolute; top: -80px; right: -60px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(167,139,250,0.2) 0%, transparent 65%);
  pointer-events: none;
}

.modal-orb2 {
  position: absolute; bottom: -60px; left: -60px;
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgba(244,114,182,0.15) 0%, transparent 65%);
  pointer-events: none;
}

.modal::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.6), rgba(244,114,182,0.6), transparent);
}

.modal-header {
  display: flex; align-items: center; gap: 15px;
  margin-bottom: 18px; position: relative;
}

.modal-icon {
  width: 54px; height: 54px; border-radius: 16px; flex-shrink: 0;
  background: var(--grad-main);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 28px rgba(249,115,22,0.45);
  position: relative; overflow: hidden;
}
.modal-icon::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 60%);
}

.modal-title {
  font-family: var(--sans);
  font-size: 22px; font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.75) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}
.modal-sub-title { font-size: 11.5px; color: var(--text3); margin-top: 3px; }

.modal-desc {
  font-size: 12.5px; color: var(--text3); line-height: 1.75;
  margin-bottom: 22px; position: relative;
}
.modal-desc a { color: var(--violet); transition: color 0.18s; }
.modal-desc a:hover { color: var(--pink); text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.field-label { font-size: 9.5px; color: var(--text2); letter-spacing: 0.14em; text-transform: uppercase; font-weight: 600; }

.field-input-wrap { position: relative; }

.field-input-wrap input {
  width: 100%; background: var(--glass2);
  border: 1px solid var(--border2); border-radius: var(--r-sm);
  color: var(--text); font-family: var(--mono); font-size: 13px;
  padding: 13px 46px 13px 16px; outline: none;
  transition: border-color 0.22s, box-shadow 0.22s; letter-spacing: 0.03em;
}
.field-input-wrap input:focus {
  border-color: rgba(167,139,250,0.5);
  box-shadow: 0 0 0 3px rgba(167,139,250,0.1);
}
.field-input-wrap input::placeholder { color: var(--text3); }
.field-input-wrap input.shake { animation: shake 0.4s ease; border-color: rgba(248,113,113,0.5) !important; }

.eye-btn {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 7px; color: var(--text3); transition: all 0.18s;
}
.eye-btn:hover { color: var(--text2); background: var(--glass2); }

.field-hint { font-size: 11px; color: var(--text3); }
.field-hint code { color: var(--violet); font-family: var(--mono); font-size: 11px; }

.btn-primary {
  width: 100%; background: var(--grad-main); border: none;
  border-radius: var(--r-sm); color: white;
  font-family: var(--sans); font-size: 14px; font-weight: 700;
  padding: 14px 20px; cursor: pointer;
  transition: all 0.22s;
  box-shadow: 0 6px 26px rgba(249,115,22,0.45);
  display: flex; align-items: center; justify-content: center; gap: 9px;
  position: relative; overflow: hidden;
  letter-spacing: -0.01em;
}
.btn-primary::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 36px rgba(244,114,182,0.5); }
.btn-primary:active { transform: scale(0.98) translateY(0); }

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 200; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(14,16,30,0.95);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm); padding: 12px 18px;
  font-size: 12.5px; color: var(--text);
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
  pointer-events: auto; max-width: 300px;
  backdrop-filter: blur(20px);
}

.toast.success { border-color: var(--green-b); }
.toast.error   { border-color: var(--red-b); color: #f09090; }

.toast-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.toast.success .toast-dot { background: var(--green); box-shadow: 0 0 8px rgba(74,222,128,0.7); }
.toast.error   .toast-dot { background: var(--red);   box-shadow: 0 0 8px rgba(248,113,113,0.7); }
.toast.info    .toast-dot { background: var(--violet); box-shadow: 0 0 8px rgba(167,139,250,0.7); }

.toast.out { animation: toastOut 0.22s ease forwards; }

/* ═══════════════════════════════════════════════════════════
   ANIMATIONS
═══════════════════════════════════════════════════════════ */
@keyframes fadeUp   { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes slideUp  { from { opacity:0; transform:translateY(22px); } to { opacity:1; transform:translateY(0); } }

@keyframes livePulse {
  0%,100% { opacity:1; box-shadow: 0 0 12px rgba(74,222,128,0.9); }
  50%      { opacity:0.3; box-shadow: 0 0 4px rgba(74,222,128,0.2); }
}

@keyframes dotBounce {
  0%,80%,100% { transform:translateY(0);     opacity:0.3; }
  40%          { transform:translateY(-6px);  opacity:1; }
}

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

@keyframes iconFloat {
  0%,100% { transform:translateY(0)   rotate(0deg); }
  50%      { transform:translateY(-7px) rotate(2deg); }
}

@keyframes shake {
  0%,100% { transform:translateX(0); }
  20%      { transform:translateX(-6px); }
  40%      { transform:translateX(6px); }
  60%      { transform:translateX(-4px); }
  80%      { transform:translateX(4px); }
}

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

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

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET  (≤ 768px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Sidebar slides in as overlay */
  #sidebar {
    position: fixed; top: 0; left: 0; height: 100%;
    transform: translateX(-100%);
    z-index: 10; box-shadow: var(--shadow-lg);
    width: 280px; min-width: 0;
  }
  #sidebar.open { transform: translateX(0); }

  /* Always show hamburger */
  .menu-btn { display: flex !important; }

  /* Topbar */
  #topbar { padding: 0 14px; gap: 0; }
  .topbar-tokens { display: none; }
  #theme-label   { display: none; }          /* icon-only theme btn */

  /* Messages */
  #messages { padding: 18px 14px; gap: 4px; }

  /* Bubbles */
  .bubble     { max-width: 88%; font-size: 13.5px; }
  .bubble-wrap { max-width: 86%; }

  /* Input area */
  #input-area { padding: 10px 14px 18px; }

  /* Model dropdown panel — open upward and fit screen */
  .model-options { min-width: 180px; }

  /* Scroll button */
  .scroll-btn { right: 16px; bottom: 110px; }

  /* Error bar */
  .error-bar { margin: 0 14px 10px; }

  /* Chat list max-height taller on tablet */
  .chat-list { max-height: 220px; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE  (≤ 480px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  /* Root vars tightened */
  :root {
    --topbar-h: 54px;
    --r:        13px;
    --r-lg:     18px;
  }

  /* Topbar — very tight */
  #topbar { padding: 0 12px; height: var(--topbar-h); }
  .topbar-model    { display: none; }
  .topbar-title    { font-size: 13.5px; }
  .status-pill     { display: none; }        /* removed to save space */
  .topbar-key-btn  { padding: 6px 10px; font-size: 10.5px; gap: 5px; }
  #topbar .topbar-r { gap: 7px; }

  /* Messages */
  #messages { padding: 14px 12px; }

  /* Bubbles — full width feel */
  .bubble      { max-width: 94%; font-size: 13px; padding: 11px 13px; }
  .bubble-wrap { max-width: 90%; }

  /* Avatar smaller */
  .msg-avatar { width: 30px; height: 30px; border-radius: 10px; }

  /* Empty state */
  .empty-title { font-size: 22px; }
  .empty-ring  { width: 60px; height: 60px; }
  .empty-glow-ring { margin-bottom: 20px; }
  .empty-sub   { font-size: 11px; }

  /* Chips — 2-column grid on mobile */
  .empty-chips {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    width: 100%;
    max-width: 320px;
  }
  .empty-chips .chip { font-size: 11px; padding: 8px 10px; justify-content: flex-start; }

  /* Input area — bottom safe area */
  #input-area {
    padding: 10px 12px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  /* Input shell */
  .input-shell { padding: 10px 10px 10px 14px; border-radius: var(--r); }
  #chat-input  { font-size: 14px; }   /* prevent iOS zoom on focus */

  /* Buttons inside input */
  .send-btn, .stop-btn {
    width: 36px; height: 36px; border-radius: 10px;
  }
  .char-count { display: none; }   /* save space */

  /* Model row — wrap so dropdown doesn't overflow */
  .input-row-model { flex-wrap: wrap; }
  .model-trigger   { font-size: 11px; padding: 4px 9px 4px 10px; }
  .model-options   {
    min-width: 200px;
    max-width: calc(100vw - 28px);
    left: 0;
  }

  /* Input meta */
  .input-hint { display: none; }   /* "↵ send · shift+↵ newline" — not needed on touch */

  /* Scroll button */
  .scroll-btn { right: 14px; bottom: 100px; width: 34px; height: 34px; }

  /* Sidebar — full-width on very small phones */
  #sidebar { width: 100%; }

  /* Sidebar internal */
  .sb-logo { padding: 18px 16px 14px; }
  .sb-section { padding: 14px 16px 0; }
  .sb-footer  { padding: 12px 16px 16px; }
  .chat-list  { max-height: 180px; }

  /* Delete confirm dialog */
  .delete-confirm-box { padding: 20px 18px; }
  .delete-confirm-btns { flex-direction: row; }

  /* Toast */
  #toast-container { bottom: 14px; right: 14px; }

  /* Modal */
  .modal { padding: 26px 20px 22px; }

  /* Code blocks */
  .bubble pre code { font-size: 11.5px; }

  /* Topbar token count hidden */
  .topbar-tokens { display: none; }
}

/* ═══════════════════════════════════════════════════════════
   iOS Safari fixes
═══════════════════════════════════════════════════════════ */

/* Prevent bounce/overscroll on body */
html, body { overscroll-behavior: none; }

/* Fix 100vh bug on iOS — use dvh where supported */
#app { height: 100dvh; }

/* Tap highlight removal for interactive elements */
button, a, [role="option"] {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Ensure textarea doesn't zoom on iOS (requires font-size ≥ 16px at input focus)
   We set 14px on desktop but bump on mobile above. Additional meta viewport handles this. */
@supports (-webkit-touch-callout: none) {
  #chat-input { font-size: 16px; }
}

/* Prevent text selection on UI chrome */
.sb-logo, .topbar-l, .topbar-r, .input-btns,
.chat-item, .model-trigger, .btn-new-chat {
  -webkit-user-select: none;
  user-select: none;
}

/* Larger touch targets for chat item delete buttons */
.chat-item-del {
  width: 28px; height: 28px;
}
@media (max-width: 768px) {
  .chat-item { padding: 9px 10px; }
  .chat-item-del { opacity: 1; }   /* always visible on touch — no hover */
}

/* ═══════════════════════════════════════════════════════════
   MULTI-CHAT SIDEBAR
   Chat list + New Chat button
═══════════════════════════════════════════════════════════ */

/* Chat list section wrapper — between logo and sb-body */
.sb-chats {
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(8,10,20,0.3);
}

.sb-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 20px 8px;
}

/* New Chat button — matches .btn-key style */
.btn-new-chat {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  background: var(--glass2);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text2); font-size: 11px; font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s;
}
.btn-new-chat:hover {
  background: var(--violet-d);
  border-color: var(--violet-b);
  color: var(--violet);
}

/* Chat list scroll container */
.chat-list {
  max-height: 175px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 10px 10px;
  display: flex; flex-direction: column; gap: 2px;
}

/* Individual chat item */
.chat-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  border: 1px solid transparent;
  min-width: 0;
}
.chat-item:hover {
  background: var(--glass2);
  border-color: var(--border);
}
.chat-item.active {
  background: var(--violet-d);
  border-color: var(--violet-b);
}

.chat-item-icon {
  flex-shrink: 0; color: var(--text3);
  display: flex; align-items: center;
  transition: color 0.18s;
}
.chat-item.active .chat-item-icon { color: var(--violet); }

.chat-item-title {
  flex: 1; min-width: 0;
  font-size: 11.5px; color: var(--text2); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color 0.18s;
}
.chat-item.active .chat-item-title { color: var(--text); }

/* Delete (×) button — hidden until hover */
.chat-item-del {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text3);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
}
.chat-item:hover .chat-item-del { opacity: 1; }
.chat-item-del:hover {
  color: var(--red);
  background: var(--red-d);
}

/* ═══════════════════════════════════════════════════════════
   MODEL DROPDOWN — custom, near input box
═══════════════════════════════════════════════════════════ */

.input-row-model {
  display: flex; align-items: center; gap: 7px;
  margin: 7px 0 4px;
  position: relative;
}

.model-row-icon {
  color: var(--text3); flex-shrink: 0;
}

/* Wrapper — needed for absolute positioning of options panel */
.model-dropdown {
  position: relative;
}

/* Trigger button — pill that shows active model */
.model-trigger {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px 5px 12px;
  background: var(--glass2);
  border: 1px solid var(--border2);
  border-radius: var(--r-sm);
  color: var(--text2);
  font-family: var(--sans); font-size: 11.5px; font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  user-select: none;
}
.model-trigger:hover {
  background: var(--glass3);
  border-color: var(--border3);
  color: var(--text);
}
.model-dropdown.open .model-trigger {
  background: var(--glass3);
  border-color: rgba(167,139,250,0.45);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(167,139,250,0.08);
}

/* Chevron rotates when open */
.model-chevron {
  color: var(--text3); flex-shrink: 0;
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), color 0.2s;
}
.model-dropdown.open .model-chevron {
  transform: rotate(180deg);
  color: var(--violet);
}

/* Options panel — floats above input area */
.model-options {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 0;
  min-width: 220px;
  background: rgba(13,15,30,0.97);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: 5px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.7), 0 0 0 1px rgba(167,139,250,0.06);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  z-index: 50;
  /* Closed state */
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s cubic-bezier(.4,0,.2,1);
}
/* Top gradient line — same motif as topbar/input-area */
.model-options::before {
  content: '';
  position: absolute; top: 0; left: 10%; right: 10%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.5), rgba(244,114,182,0.5), transparent);
  border-radius: 1px;
}
/* Open state */
.model-dropdown.open .model-options {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Individual option row */
.model-option {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
  user-select: none;
}
.model-option:hover {
  background: var(--glass3);
  border-color: var(--border);
}
.model-option.active {
  background: var(--violet-d);
  border-color: var(--violet-b);
}

/* Option name */
.model-opt-name {
  font-size: 12px; font-weight: 600;
  color: var(--text2);
  transition: color 0.15s;
  white-space: nowrap;
}
.model-option:hover .model-opt-name,
.model-option.active .model-opt-name { color: var(--text); }

/* Provider tag badge */
.model-opt-tag {
  font-size: 9.5px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text3);
  background: var(--glass2);
  border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 20px;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.model-option.active .model-opt-tag {
  color: var(--violet);
  background: var(--violet-d);
  border-color: var(--violet-b);
}

/* Disabled state during streaming */
.model-dropdown.disabled .model-trigger {
  opacity: 0.4; cursor: not-allowed;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   LIGHT MODE  —  body.light overrides
   All dark tokens flipped; accents (violet/pink/cyan/orange)
   stay the same since they work on both backgrounds.
═══════════════════════════════════════════════════════════ */

body.light {
  /* Glass surfaces — opaque white layers */
  --glass:   rgba(255,255,255,0.55);
  --glass2:  rgba(255,255,255,0.75);
  --glass3:  rgba(255,255,255,0.90);
  --glass4:  rgba(255,255,255,1.00);

  /* Borders — dark on white */
  --border:  rgba(0,0,0,0.07);
  --border2: rgba(0,0,0,0.11);
  --border3: rgba(0,0,0,0.18);

  /* Text */
  --text:  #0f1120;
  --text2: #373c68;
  --text3: #8288aa;
  --text4: #c2c6dc;

  /* Page background — soft lavender-white */
  --bg: #edeffe;

  /* Bubble colours — lighter tints */
  --user-bg:  rgba(249,115,22,0.07);
  --user-bdr: rgba(249,115,22,0.22);
  --bot-bg:   rgba(167,139,250,0.07);
  --bot-bdr:  rgba(167,139,250,0.18);

  /* Gradient-user / gradient-bot keep same opacity, look fine */
}

/* ── Structural overrides ─────────────────────────────── */

body.light #sidebar {
  background: rgba(235,237,255,0.92);
  border-right-color: rgba(0,0,0,0.09);
}

body.light #sidebar::before {
  background: radial-gradient(ellipse at 50% -20%, rgba(167,139,250,0.09) 0%, transparent 70%);
}

body.light .sb-chats {
  background: rgba(225,228,255,0.5);
  border-bottom-color: rgba(0,0,0,0.07);
}

body.light .sb-logo {
  border-bottom-color: rgba(0,0,0,0.08);
}

body.light .sb-footer {
  border-top-color: rgba(0,0,0,0.08);
}

body.light #topbar {
  background: rgba(237,239,254,0.88);
  border-bottom-color: rgba(0,0,0,0.08);
}
body.light #topbar::after {
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.3), rgba(244,114,182,0.3), transparent);
}

body.light #input-area {
  background: rgba(237,239,254,0.90);
  border-top-color: rgba(0,0,0,0.08);
}
body.light #input-area::before {
  background: linear-gradient(90deg, transparent, rgba(167,139,250,0.2), rgba(244,114,182,0.2), transparent);
}

body.light .input-shell {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.12);
}
body.light .input-shell:focus-within {
  background: #fff;
  border-color: rgba(167,139,250,0.45);
  box-shadow: 0 0 0 3px rgba(167,139,250,0.09), 0 0 22px rgba(167,139,250,0.08);
}

body.light #chat-input { color: var(--text); caret-color: var(--violet); }
body.light #chat-input::placeholder { color: var(--text3); }

/* Messages area */
body.light #messages { background: transparent; }

body.light .bubble.bot {
  background: rgba(167,139,250,0.07);
  border-color: rgba(167,139,250,0.18);
}
body.light .bubble.user {
  background: rgba(249,115,22,0.07);
  border-color: rgba(249,115,22,0.2);
}
body.light .bubble { color: var(--text); }

/* Code blocks in light mode */
body.light .bubble pre {
  background: rgba(240,242,255,0.9);
  border-color: rgba(0,0,0,0.1);
}
body.light .code-header {
  background: rgba(167,139,250,0.08);
  border-bottom-color: rgba(0,0,0,0.08);
}
body.light .bubble pre code { color: #1a1b2e; }

/* Thinking bubble */
body.light .thinking-bubble {
  background: rgba(167,139,250,0.07);
  border-color: rgba(167,139,250,0.18);
}

/* Topbar pills */
body.light .topbar-tokens {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.1);
  color: var(--text3);
}
body.light .topbar-model {
  background: rgba(255,255,255,0.5);
  border-color: rgba(0,0,0,0.09);
}

/* Topbar buttons */
body.light .topbar-key-btn {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.11);
  color: var(--text2);
}
body.light .topbar-key-btn:hover {
  background: var(--violet-d);
  border-color: var(--violet-b);
  color: var(--violet);
}

/* Scroll button */
body.light .scroll-btn {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.12);
  color: var(--text2);
}

/* Error bar */
body.light .error-bar { background: rgba(248,113,113,0.06); }

/* Chat items */
body.light .chat-item:hover  { background: rgba(255,255,255,0.7); }
body.light .chat-item.active { background: var(--violet-d); }

/* Model dropdown trigger */
body.light .model-trigger {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.11);
  color: var(--text2);
}
body.light .model-trigger:hover,
body.light .model-dropdown.open .model-trigger {
  background: #fff;
  border-color: rgba(167,139,250,0.4);
  color: var(--text);
}

/* Model options panel */
body.light .model-options {
  background: rgba(248,249,255,0.99);
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 -8px 36px rgba(0,0,0,0.12), 0 0 0 1px rgba(167,139,250,0.08);
}
body.light .model-option:hover  { background: rgba(167,139,250,0.06); border-color: rgba(0,0,0,0.06); }
body.light .model-opt-name      { color: var(--text2); }
body.light .model-opt-tag       { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.08); color: var(--text3); }

/* Sidebar sections */
body.light .sb-model  { background: rgba(255,255,255,0.6); border-color: rgba(0,0,0,0.09); }
body.light .sb-stat   { background: rgba(255,255,255,0.55); border-color: rgba(0,0,0,0.07); }
body.light .sb-tokens { background: rgba(255,255,255,0.55); border-color: rgba(0,0,0,0.07); }
body.light .sb-params { background: rgba(255,255,255,0.55); border-color: rgba(0,0,0,0.07); }
body.light .sb-param + .sb-param { border-top-color: rgba(0,0,0,0.05); }
body.light .sb-prompt { background: rgba(255,255,255,0.4); border-color: rgba(0,0,0,0.07); }
body.light .sb-prompt:hover { border-color: rgba(167,139,250,0.3); }
body.light .btn-reset { background: rgba(255,255,255,0.55); border-color: rgba(0,0,0,0.1); }
body.light .btn-key   { border-color: rgba(0,0,0,0.09); color: var(--text3); }

/* Modal */
body.light .modal {
  background: rgba(248,249,255,0.98);
  border-color: rgba(0,0,0,0.1);
}
body.light .field-input-wrap input {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.12);
  color: var(--text);
}
body.light .field-input-wrap input:focus {
  border-color: rgba(167,139,250,0.5);
}

/* Toast */
body.light .toast {
  background: rgba(248,249,255,0.98);
  border-color: rgba(0,0,0,0.1);
}

/* Empty state */
body.light .empty-title { color: var(--text); }
body.light .empty-sub   { color: var(--text3); }
body.light .chip {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.1);
  color: var(--text2);
}
body.light .chip:hover {
  background: rgba(255,255,255,0.95);
  border-color: rgba(167,139,250,0.35);
}

/* Status pills — keep same tint, they read fine on light */
body.light .menu-btn { background: rgba(255,255,255,0.6); border-color: rgba(0,0,0,0.1); color: var(--text2); }

/* Scrollbar */
body.light ::-webkit-scrollbar-thumb { background: rgba(167,139,250,0.25); }
body.light ::-webkit-scrollbar-thumb:hover { background: rgba(167,139,250,0.45); }

/* Copy buttons */
body.light .copy-code-btn { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.09); color: var(--text3); }
body.light .copy-code-btn:hover { background: rgba(0,0,0,0.07); color: var(--text2); }
body.light .copy-msg-btn { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.08); }
body.light .copy-msg-btn:hover { background: rgba(0,0,0,0.07); }

/* Canvas — slightly transparent in light so it blends nicely */
body.light #bg-canvas { opacity: 0.35; }

/* Transition all colour changes smoothly */
body, #sidebar, #topbar, #input-area, .input-shell,
.bubble, .model-options, .model-trigger, .modal,
.chat-item, .sb-model, .sb-stat, .topbar-key-btn,
.toast, .sb-chats {
  transition: background 0.28s ease, border-color 0.28s ease, color 0.18s ease, box-shadow 0.28s ease;
}

/* ═══════════════════════════════════════════════════════════
   STOP BUTTON  — hidden by default, shown via .is-streaming
═══════════════════════════════════════════════════════════ */

/* Stop button hidden by default */
#stop-btn {
  display: none;
}

/* When streaming: hide send, show stop */
#input-btns.is-streaming #send-btn { display: none; }
#input-btns.is-streaming #stop-btn { display: flex; }

.stop-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(248,113,113,0.15);
  border: 1px solid rgba(248,113,113,0.35);
  color: var(--red);
  align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  cursor: pointer;
}
.stop-btn:hover {
  background: rgba(248,113,113,0.28);
  border-color: rgba(248,113,113,0.6);
  transform: scale(1.06);
}
.stop-btn:active { transform: scale(0.94); }

body.light .stop-btn {
  background: rgba(248,113,113,0.1);
  border-color: rgba(248,113,113,0.3);
}

/* ═══════════════════════════════════════════════════════════
   COPY RESPONSE — always visible on bot messages
═══════════════════════════════════════════════════════════ */
.msg-row.bot .copy-msg-btn {
  opacity: 1 !important;
}

/* ═══════════════════════════════════════════════════════════
   DELETE CONFIRM DIALOG
═══════════════════════════════════════════════════════════ */
.delete-confirm-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.18s ease;
}
.delete-confirm-backdrop.hidden { display: none; }

.delete-confirm-box {
  background: rgba(14,16,30,0.97);
  border: 1px solid var(--border2);
  border-radius: var(--r-lg);
  padding: 26px 28px;
  width: 360px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.75), var(--glow-violet);
  backdrop-filter: blur(30px);
  animation: slideUp 0.22s ease;
  display: flex; flex-direction: column; gap: 14px;
  position: relative;
  overflow: hidden;
}
.delete-confirm-box::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(248,113,113,0.5), rgba(244,114,182,0.4), transparent);
}

.delete-confirm-icon {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: var(--red-d);
  border: 1px solid var(--red-b);
  display: flex; align-items: center; justify-content: center;
  color: var(--red);
}

.delete-confirm-title {
  font-size: 16px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em;
}
.delete-confirm-sub {
  font-size: 12px; color: var(--text3); margin-top: 3px;
}

.delete-confirm-btns {
  display: flex; gap: 9px; justify-content: flex-end;
}

.delete-btn-no {
  padding: 9px 18px;
  background: var(--glass2); border: 1px solid var(--border2);
  border-radius: var(--r-sm); color: var(--text2);
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: all 0.18s;
}
.delete-btn-no:hover { background: var(--glass3); color: var(--text); }

.delete-btn-yes {
  padding: 9px 18px;
  background: var(--red-d); border: 1px solid var(--red-b);
  border-radius: var(--r-sm); color: var(--red);
  font-family: var(--sans); font-size: 12.5px; font-weight: 700;
  cursor: pointer; transition: all 0.18s;
}
.delete-btn-yes:hover {
  background: rgba(248,113,113,0.22);
  border-color: rgba(248,113,113,0.5);
}

/* Light mode for delete confirm */
body.light .delete-confirm-box {
  background: rgba(248,249,255,0.98);
  border-color: rgba(0,0,0,0.1);
}
body.light .delete-btn-no {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.1);
}
