/* ================================================================
   ChatAgent-BI — Dark glass-morphism dashboard (v2)
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #07090f;
  --bg-surface: #0d1117;
  --bg-card:    rgba(13,17,23,0.85);
  --bg-glass:   rgba(255,255,255,0.04);
  --bg-glass-2: rgba(255,255,255,0.06);
  --border:     rgba(255,255,255,0.07);
  --border-hover: rgba(99,102,241,0.4);
  --accent:     #6366f1;
  --accent2:    #8b5cf6;
  --accent3:    #a78bfa;
  --accent-glow: rgba(99,102,241,0.15);
  --text:       rgba(255,255,255,0.92);
  --text-dim:   rgba(255,255,255,0.55);
  --text-muted: rgba(255,255,255,0.28);
  --green:      #34d399;
  --red:        #f87171;
  --blue:       #60a5fa;
  --pink:       #f472b6;
  --yellow:     #fbbf24;
  --orange:     #fb923c;
  --cyan:       #22d3ee;
  --radius:     14px;
  --radius-sm:  8px;
  --font:       'Inter', -apple-system, sans-serif;
  --mono:       'JetBrains Mono', 'Fira Code', monospace;
  --topbar-h:   56px;
  --input-h:    80px;
  --sidebar-w:  280px;
  --thread-max: 900px;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

/* ── Auth overlay ──────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  backdrop-filter: blur(30px);
}
.auth-overlay.hidden { display: none; }

.auth-card {
  display: flex; flex-direction: row;
  width: 860px; max-width: 96vw; max-height: 92vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 80px rgba(0,0,0,0.4), 0 0 1px rgba(99,102,241,0.3);
}

/* ── Auth left panel (branding) ──────────────── */
.auth-left {
  flex: 1;
  background: linear-gradient(160deg, rgba(99,102,241,0.08) 0%, rgba(139,92,246,0.04) 50%, transparent 100%);
  border-right: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  padding: 40px 32px;
}
.auth-left-inner { max-width: 340px; }

.auth-logo {
  font-size: 2.4rem;
  color: var(--accent);
  filter: drop-shadow(0 0 16px var(--accent-glow));
  display: block;
  margin-bottom: 8px;
}
.auth-title {
  font-size: 1.7rem; font-weight: 800;
  background: linear-gradient(135deg, #fff 20%, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.auth-tagline {
  font-size: 0.82rem; color: var(--accent3);
  font-weight: 500; letter-spacing: 0.5px;
  margin-bottom: 28px;
}

.auth-features {
  display: flex; flex-direction: column; gap: 18px;
  margin-bottom: 28px;
}
.auth-feature {
  display: flex; align-items: flex-start; gap: 12px;
}
.auth-feature-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-glow);
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 10px;
  color: var(--accent);
}
.auth-feature div { min-width: 0; }
.auth-feature strong {
  display: block;
  font-size: 0.82rem; font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.auth-feature span {
  font-size: 0.72rem; color: var(--text-dim);
  line-height: 1.4;
}

.auth-trial-note {
  font-size: 0.75rem; color: var(--green);
  font-weight: 600;
  padding: 8px 14px;
  background: rgba(52,211,153,0.06);
  border: 1px solid rgba(52,211,153,0.12);
  border-radius: 10px;
  text-align: center;
}

/* ── Auth right panel (forms) ────────────────── */
.auth-right {
  width: 380px; flex-shrink: 0;
  padding: 40px 32px;
  display: flex; flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}
.auth-right-title {
  font-size: 1.3rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-right-subtitle {
  font-size: 0.8rem; color: var(--text-dim);
  margin-bottom: 24px;
}

/* ── Google Sign-In button ───────────────────── */
.google-signin-wrap { margin-bottom: 0; }
.google-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 11px 0;
  background: var(--bg-glass-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font); font-size: 0.85rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.google-btn:hover {
  border-color: var(--border-hover);
  background: var(--accent-glow);
  transform: translateY(-1px);
}
.google-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.google-btn svg { flex-shrink: 0; }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0;
  color: var(--text-muted); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 1px;
}
.auth-divider::before,
.auth-divider::after {
  content: ""; flex: 1;
  height: 1px; background: var(--border);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }

.auth-field label {
  display: block;
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.auth-field input {
  width: 100%;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font); font-size: 0.85rem;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(99,102,241,0.12);
}
.auth-field input::placeholder { color: var(--text-muted); }

.auth-error {
  font-size: 0.75rem; color: var(--red);
  min-height: 1em;
}
.auth-submit {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; border-radius: var(--radius-sm);
  padding: 11px 0;
  color: #fff; font-family: var(--font);
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}
.auth-submit:hover { opacity: 0.92; transform: translateY(-1px); }
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.auth-switch {
  text-align: center;
  font-size: 0.75rem; color: var(--text-muted);
}
.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.auth-switch a:hover { text-decoration: underline; }

/* Auth responsive — stack on narrow screens */
@media (max-width: 700px) {
  .auth-card { flex-direction: column; max-height: 96vh; }
  .auth-left { display: none; }
  .auth-right { width: 100%; padding: 32px 24px; }
}

/* ── Brand badge ──────────────────────────────── */
.brand-badge {
  font-size: 0.58rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 10px;
  padding: 2px 8px;
  margin-left: 4px;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Query counter ────────────────────────────── */
.query-counter {
  font-size: 0.7rem; font-weight: 600;
  color: var(--yellow);
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.2);
  border-radius: 10px;
  padding: 2px 10px;
  white-space: nowrap;
}
.query-counter.low {
  color: var(--orange);
  background: rgba(251,146,60,0.1);
  border-color: rgba(251,146,60,0.25);
}
.query-counter.exhausted {
  color: var(--red);
  background: rgba(248,113,113,0.1);
  border-color: rgba(248,113,113,0.25);
}
.query-counter.unlimited {
  color: var(--green);
  background: rgba(52,211,153,0.08);
  border-color: rgba(52,211,153,0.2);
}

/* ── User menu ────────────────────────────────── */
.user-menu {
  display: flex; align-items: center; gap: 6px;
}
.user-menu-name {
  font-size: 0.72rem; color: var(--text-dim);
  font-weight: 500;
  max-width: 100px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-logout {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: none; border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer; transition: all 0.2s;
}
.user-menu-logout:hover {
  border-color: var(--red); color: var(--red);
  background: rgba(248,113,113,0.08);
}

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.16); }

/* ── Top bar ────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: rgba(7,9,15,0.82);
  backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }

.sidebar-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: none; border: 1px solid transparent;
  border-radius: 8px; color: var(--text-dim);
  cursor: pointer; transition: all 0.2s;
}
.sidebar-toggle:hover { border-color: var(--border); color: var(--text); background: var(--bg-glass); }
.logo-icon {
  font-size: 1.2rem; color: var(--accent);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
.logo-text {
  font-size: 1rem; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }

.new-chat-btn {
  display: flex; align-items: center; gap: 5px;
  background: none; border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-dim);
  cursor: pointer; font-size: 0.72rem; font-family: var(--font);
  padding: 5px 11px; transition: all 0.2s; font-weight: 500;
}
.new-chat-btn:hover {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-glow);
}
.stat { font-size: 0.72rem; color: var(--text-muted); }
.stat span { color: var(--text-dim); font-weight: 600; margin-left: 3px; }
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green), 0 0 16px rgba(52,211,153,0.2);
  animation: pulse 2s infinite;
  position: relative;
}
.pulse-dot::after {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 50%;
  border: 1px solid rgba(52,211,153,0.2);
  animation: neuralPulse 3s ease-in-out infinite;
}
.pulse-dot.busy {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent), 0 0 20px rgba(99,102,241,0.3);
  animation: pulse-fast 0.8s infinite;
}
.pulse-dot.busy::after {
  border-color: rgba(99,102,241,0.3);
  animation: neuralPulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes pulse-fast {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* ── Sidebar (chat history) ─────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  transform: translateX(-100%);
  background: rgba(7,9,15,0.96);
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  z-index: 90;
  display: flex; flex-direction: column;
  transition: transform 0.3s ease;
}
body.sidebar-open .sidebar { transform: translateX(0); }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-title {
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-dim);
}
.sidebar-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.2rem; padding: 0 4px;
  transition: color 0.2s; line-height: 1;
}
.sidebar-close:hover { color: var(--text); }

.sidebar-list { flex: 1; overflow-y: auto; padding: 8px; }

.sidebar-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.15s;
  margin-bottom: 3px; position: relative;
}
.sidebar-item:hover { background: var(--bg-glass); }
.sidebar-item.active { background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.15); }

.sidebar-item-text { flex: 1; min-width: 0; }
.sidebar-item-title {
  font-size: 0.8rem; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.sidebar-item-meta { font-size: 0.66rem; color: var(--text-muted); margin-top: 2px; }

.sidebar-item-delete {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 0.85rem; padding: 0 2px;
  opacity: 0; transition: all 0.15s; flex-shrink: 0; margin-top: 2px;
}
.sidebar-item:hover .sidebar-item-delete { opacity: 1; }
.sidebar-item-delete:hover { color: var(--red); }

.sidebar-empty {
  padding: 24px 16px; text-align: center;
  color: var(--text-muted); font-size: 0.78rem;
}

.sidebar-item-icon {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); opacity: 0.4;
  flex-shrink: 0; margin-top: 7px;
}
.sidebar-item.active .sidebar-item-icon { opacity: 1; }

/* Layout shifts when sidebar is open */
.topbar, .main { transition: left 0.3s ease; }
body.sidebar-open .topbar { left: var(--sidebar-w); }
body.sidebar-open .main { left: var(--sidebar-w); }

/* ── Main layout (two-panel) ───────────────────── */
.main {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0; left: 0; right: 0;
  display: flex; flex-direction: row;
}

/* ── LEFT: Chat panel ──────────────────────────── */
.panel-chat {
  width: 36%;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  position: relative;
  background: var(--bg);
}

/* ── Chat thread ────────────────────────────────── */
.chat-thread {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 22px 80px;  /* extra bottom padding so last message isn't hidden by input */
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  min-height: 0;  /* critical for flex scroll to work */
}

/* ── RIGHT: Viz panel ──────────────────────────── */
.panel-viz {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
  background: var(--bg-surface);
}

/* Viz empty state */
.viz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  gap: 10px;
}
.viz-empty-icon { opacity: 0.25; margin-bottom: 8px; }
.viz-empty p {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}
.viz-empty span {
  font-size: 0.74rem;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ── Welcome ────────────────────────────────────── */
.welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  position: relative;
  padding: 32px 16px;
}
.welcome-glow {
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, rgba(139,92,246,0.06) 40%, transparent 70%);
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  animation: aiBreath 4s ease-in-out infinite;
}
.welcome h1 {
  font-size: 1.5rem; font-weight: 800;
  background: linear-gradient(135deg, #fff 20%, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 8px; position: relative;
}
.welcome p { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 24px; position: relative; }
.suggestions {
  display: flex; flex-wrap: wrap; gap: 10px;
  justify-content: center; max-width: 100%; position: relative;
}
.suggestion {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 16px;
  color: var(--text-dim);
  font-size: 0.76rem; font-family: var(--font);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}
.suggestion::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.04), transparent);
  background-size: 200% 100%;
  animation: shimmer 4s linear infinite;
  opacity: 0;
  transition: opacity 0.3s;
}
.suggestion:hover::before { opacity: 1; }
.suggestion:hover {
  background: var(--accent-glow);
  border-color: var(--border-hover);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99,102,241,0.15), 0 0 0 1px rgba(99,102,241,0.1);
}

/* ── Chat bubbles ───────────────────────────────── */
.msg {
  max-width: 100%;
  width: 100%;
  margin: 0 0 14px;
}

.msg-user {
  animation: msgSlideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.msg-user .bubble {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-radius: 18px 18px 4px 18px;
  padding: 10px 16px;
  max-width: 85%;
  font-size: 0.85rem; line-height: 1.55;
  box-shadow: 0 2px 16px rgba(99,102,241,0.2);
  position: relative;
}

.msg-agent {
  animation: msgSlideIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.msg-agent .bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px 18px 18px 18px;
  padding: 14px 18px;
  max-width: 92%;
  font-size: 0.84rem; line-height: 1.75;
  color: var(--text-dim);
  position: relative;
}
.msg-agent .bubble strong { color: var(--text); }

/* Bold labels at start of line (e.g. "Insight chiave:") */
.msg-agent .bubble .md-label {
  display: inline-block;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.2px;
  margin-top: 4px;
}

/* Paragraphs */
.msg-agent .bubble .md-p { margin: 0 0 10px; line-height: 1.75; }
.msg-agent .bubble .md-p:last-child { margin-bottom: 0; }
.msg-agent .bubble .md-p + .md-p { margin-top: 2px; }

/* Headings */
.msg-agent .bubble .md-h { margin: 0; font-family: inherit; }
.msg-agent .bubble .md-h2 { font-size: 1rem; font-weight: 700; color: var(--text); margin: 14px 0 6px; }
.msg-agent .bubble .md-h3 { font-size: 0.92rem; font-weight: 600; color: var(--text); margin: 12px 0 5px; }
.msg-agent .bubble .md-h4 { font-size: 0.86rem; font-weight: 600; color: var(--text-dim); margin: 10px 0 4px; }
.msg-agent .bubble .md-h:first-child { margin-top: 0; }

/* Lists */
.msg-agent .bubble .md-ul,
.msg-agent .bubble .md-ol {
  margin: 6px 0 12px; padding-left: 22px; line-height: 1.8;
}
.msg-agent .bubble .md-ul { list-style: disc; }
.msg-agent .bubble .md-ol { list-style: decimal; }
.msg-agent .bubble .md-ul li,
.msg-agent .bubble .md-ol li { margin-bottom: 4px; color: var(--text-dim); }
.msg-agent .bubble .md-ul li strong,
.msg-agent .bubble .md-ol li strong { color: var(--text); }
.msg-agent .bubble .md-ul li::marker { color: var(--accent); }
.msg-agent .bubble .md-ol li::marker { color: var(--accent); font-weight: 600; font-size: 0.82em; }

/* Horizontal rule */
.msg-agent .bubble .md-hr {
  border: none; border-top: 1px solid var(--border); margin: 12px 0;
}

/* Inline code */
.msg-agent .bubble .md-code {
  background: rgba(255,255,255,0.06); padding: 1px 5px;
  border-radius: 3px; font-size: 0.85em; font-family: 'JetBrains Mono', monospace;
}

/* Tables */
.msg-agent .bubble .md-table-wrap {
  overflow-x: auto; margin: 10px 0;
  border: 1px solid var(--border); border-radius: 8px;
}
.msg-agent .bubble .md-table {
  width: 100%; border-collapse: collapse; font-size: 0.78rem;
}
.msg-agent .bubble .md-table th {
  background: rgba(99,102,241,0.08); padding: 6px 10px;
  text-align: left; font-weight: 600; color: var(--text);
  border-bottom: 1px solid var(--border); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.msg-agent .bubble .md-table td {
  padding: 5px 10px; border-bottom: 1px solid rgba(255,255,255,0.04);
  color: var(--text-dim);
}
.msg-agent .bubble .md-table tr:last-child td { border-bottom: none; }
.msg-agent .bubble.brief {
  font-size: 0.82rem; color: var(--text-dim);
  padding: 12px 18px; line-height: 1.7;
  border: 1px solid rgba(99,102,241,0.1);
  background: rgba(99,102,241,0.03);
}

/* ── Tool steps ─────────────────────────────────── */
.tool-step {
  max-width: 100%; margin: 0 0 12px;
  animation: fadeSlideUp 0.25s ease;
}
.step-header {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 9px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem; color: var(--text-dim);
  transition: all 0.2s;
}
.step-header:hover { border-color: var(--border-hover); }
.step-icon { font-size: 0.7rem; transition: transform 0.2s; }
.step-header.open .step-icon { transform: rotate(90deg); }
.step-tool-name { font-weight: 600; color: var(--accent); font-family: var(--mono); font-size: 0.78rem; }
.step-body {
  display: none; padding: 10px 14px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: var(--mono); font-size: 0.75rem;
  color: var(--text-dim); white-space: pre-wrap; word-break: break-word;
  max-height: 200px; overflow-y: auto;
}
.step-header.open + .step-body { display: block; }

/* ── Result cards (rendered in viz panel) ────────── */
/* Metabase embedded iframe — proper sizing, hide watermark */
.card-embed-wrap {
  position: relative;
  overflow: hidden;
  padding-bottom: 0;
  min-height: 350px;
}
.card-embed-wrap iframe {
  display: block;
  width: 100%;
  min-height: 350px;
  border: none;
  border-radius: 8px;
  background: var(--bg-surface);
}
/* Clip the Metabase "Powered by" footer */
.card-embed-wrap::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 44px;
  background: var(--bg-card);
  z-index: 1;
}

.result-card {
  max-width: 100%;
  width: 100%;
  margin: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;  /* never compress cards — show full size */
  animation: cardMaterialize 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  transition: border-color 0.35s, box-shadow 0.35s, transform 0.35s;
  position: relative;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.1);
}
.result-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent 5%, var(--accent), var(--accent2), var(--accent3), transparent 95%);
  background-size: 200% 100%;
  animation: borderGlow 3s ease infinite;
  opacity: 0.5;
  z-index: 1;
}
/* Scan line effect on new cards */
.result-card::after {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 40%;
  background: linear-gradient(180deg, rgba(99,102,241,0.04), transparent);
  animation: scanLine 1.2s ease-out forwards;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}
.result-card:hover {
  border-color: rgba(99,102,241,0.3);
  box-shadow: 0 12px 48px rgba(99,102,241,0.12), 0 4px 16px rgba(0,0,0,0.15);
  transform: translateY(-2px);
}

/* Chart container — height set dynamically by JS */
.card-chart {
  padding: 4px 2px 0 2px;
  position: relative;
  width: 100%;
  /* Default height, JS will override per chart type */
  min-height: 60px;
  background: linear-gradient(180deg, rgba(99,102,241,0.015) 0%, transparent 60%);
}
.card-chart .js-plotly-plot { border-radius: 0; width: 100% !important; height: 100% !important; }
.card-chart .plot-container { width: 100% !important; height: 100% !important; }
.card-chart .svg-container { width: 100% !important; height: 100% !important; }
.card-chart .modebar { opacity: 0; transition: opacity 0.3s; background: transparent !important; }
.card-chart:hover .modebar { opacity: 0.7; }
.card-chart .modebar-btn { color: var(--text-dim) !important; font-size: 14px !important; }
.card-chart .modebar-btn:hover { color: var(--accent) !important; }
.card-chart .modebar-group { padding: 0 2px !important; }

/* Dashboard-only label */
.card-dash-label {
  padding: 24px 16px; text-align: center;
  font-size: 0.85rem; color: var(--text-dim);
}

/* Data table */
.card-data { padding: 10px 14px; overflow-x: auto; }
.card-data table {
  width: 100%; border-collapse: collapse;
  font-size: 0.78rem; font-family: var(--mono);
}
.card-data th {
  text-align: left; padding: 8px 12px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
  color: var(--text-dim); font-weight: 600; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.card-data td {
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.025);
  color: var(--text);
}
.card-data tr:hover td { background: rgba(255,255,255,0.015); }
.card-data-inline {
  max-height: 220px; overflow-y: auto;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* Card footer */
.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.1);
  backdrop-filter: blur(4px);
}
.card-title {
  font-size: 0.82rem; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 50%;
}
.card-actions { display: flex; align-items: center; gap: 10px; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 10px;
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px;
}
.b-bar     { background: rgba(59,130,246,0.12); color: #60a5fa; }
.b-line    { background: rgba(16,185,129,0.12); color: #34d399; }
.b-pie     { background: rgba(236,72,153,0.12); color: #f472b6; }
.b-table   { background: rgba(156,163,175,0.1); color: #9ca3af; }
.b-scatter { background: rgba(245,158,11,0.12); color: #fbbf24; }
.b-area    { background: rgba(139,92,246,0.12); color: #a78bfa; }
.b-dash    { background: rgba(249,115,22,0.12); color: #fb923c; }
.b-data    { background: rgba(6,182,212,0.12); color: #22d3ee; }
.b-scalar  { background: rgba(16,185,129,0.12); color: #34d399; }
.b-heatmap { background: rgba(245,158,11,0.12); color: #fbbf24; }
.b-treemap { background: rgba(139,92,246,0.12); color: #a78bfa; }

/* ── Scalar / metric display ────────────────────── */
.scalar-hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 28px 36px;
  background: linear-gradient(145deg, rgba(99,102,241,0.06) 0%, rgba(139,92,246,0.03) 50%, rgba(236,72,153,0.02) 100%);
  position: relative;
}
.scalar-hero::after {
  content: "";
  position: absolute; bottom: 0; left: 20%; right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.15), transparent);
}
.scalar-hero .scalar-value {
  font-size: 3.4rem; font-weight: 800;
  background: linear-gradient(135deg, #fff 20%, var(--accent) 60%, var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.scalar-hero .scalar-label {
  font-size: 0.72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1.5px; margin-top: 8px;
  font-weight: 500;
}
.scalar-grid {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0;
}
.scalar-item {
  flex: 1; min-width: 130px; max-width: 240px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 26px 16px;
  border-right: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(99,102,241,0.03), transparent);
  transition: background 0.3s;
}
.scalar-item:hover {
  background: linear-gradient(145deg, rgba(99,102,241,0.06), rgba(139,92,246,0.02));
}
.scalar-item:last-child { border-right: none; }
.scalar-item .scalar-value {
  font-size: 2rem; font-weight: 800;
  background: linear-gradient(135deg, #fff 20%, var(--accent) 70%, var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.scalar-item .scalar-label {
  font-size: 0.66rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px; margin-top: 5px;
  text-align: center; font-weight: 500;
}

.link-btn {
  font-size: 0.72rem; color: var(--accent);
  text-decoration: none; font-weight: 500;
  transition: color 0.2s;
}
.link-btn:hover { color: var(--accent2); }

/* ── External links in agent text ──────────────── */
.ext-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  padding: 1px 6px 1px 2px;
  border-radius: 4px;
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.12);
  transition: all 0.2s;
  word-break: break-all;
}
.ext-link:hover {
  background: rgba(99,102,241,0.18);
  border-color: rgba(99,102,241,0.4);
  color: #fff;
}

/* ── Card body layout (SQL panel + content) ──── */
.card-body {
  display: flex; flex-direction: row; overflow: hidden;
}
.card-content { flex: 1; min-width: 0; }

/* SQL side panel */
.sql-panel {
  width: 0; overflow: hidden;
  background: rgba(0,0,0,0.15);
  border-right: 1px solid var(--border);
  transition: width 0.3s ease;
  flex-shrink: 0;
}
.result-card.sql-open .sql-panel { width: 320px; }
.sql-panel-inner {
  width: 320px; padding: 12px;
  overflow-y: auto; max-height: 420px;
}
.sql-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 8px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem; font-weight: 600;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px;
}
.sql-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.1rem; padding: 0 2px;
  transition: color 0.2s; line-height: 1;
}
.sql-close:hover { color: var(--text); }
.sql-panel pre {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--mono); font-size: 0.72rem;
  color: var(--green); white-space: pre-wrap;
  overflow-x: auto; line-height: 1.5; margin-bottom: 10px;
}
.sql-panel .card-data { padding: 0; }
.sql-panel .card-data table { font-size: 0.72rem; }
.sql-panel .card-data th { font-size: 0.65rem; padding: 6px 8px; }
.sql-panel .card-data td { padding: 4px 8px; font-size: 0.72rem; }

/* ── Metabase Overlay with Chat ──────────────── */
#metabase-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.mb-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}
.mb-overlay-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.mb-overlay-close {
  background: none; border: none;
  color: var(--text-dim); font-size: 1.4rem;
  cursor: pointer; padding: 4px 8px;
}
.mb-overlay-close:hover { color: #ef4444; }
.mb-overlay-iframe {
  flex: 1;
  width: 100%;
  border: none;
}
/* Floating chat toggle */
.mb-overlay-chat {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2001;
}
.mb-chat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 50px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  transition: transform 0.2s;
}
.mb-chat-toggle:hover { transform: scale(1.05); }
/* Chat panel */
.mb-chat-panel {
  flex-direction: column;
  width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  overflow: hidden;
}
.mb-chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(99,102,241,0.08);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.mb-chat-minimize {
  margin-left: auto;
  background: none; border: none;
  color: var(--text-dim); font-size: 1.2rem;
  cursor: pointer;
}
.mb-chat-input-wrap {
  display: flex;
  padding: 12px;
  gap: 8px;
}
.mb-chat-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.82rem;
  outline: none;
}
.mb-chat-input:focus { border-color: var(--accent); }
.mb-chat-send {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
}
.mb-chat-send:hover { background: var(--accent2); }

/* Clear memory button */
.clear-memory-btn {
  background: none; border: 1px solid rgba(239,68,68,0.2);
  border-radius: 6px; cursor: pointer;
  color: rgba(239,68,68,0.6); padding: 5px 8px;
  transition: all 0.2s;
}
.clear-memory-btn:hover {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  border-color: #ef4444;
}

/* Ask Laura button */
.ask-btn {
  background: none; border: 1px solid rgba(99,102,241,0.2);
  border-radius: 6px; cursor: pointer;
  font-size: 0.75rem; padding: 2px 8px;
  color: var(--accent); transition: all 0.2s;
}
.ask-btn:hover {
  background: rgba(99,102,241,0.1);
  border-color: var(--accent);
}

/* SQL button in footer */
.sql-btn {
  display: flex; align-items: center; gap: 4px;
  background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-muted);
  cursor: pointer; font-size: 0.68rem; font-family: var(--mono);
  padding: 3px 10px; transition: all 0.2s;
}
.sql-btn:hover { border-color: var(--accent); color: var(--accent); }
.result-card.sql-open .sql-btn {
  color: var(--accent); border-color: var(--accent);
  background: rgba(99,102,241,0.08);
}

/* ── Follow-up chips ────────────────────────────── */
.follow-ups {
  max-width: 100%; margin: 2px 0 16px;
  display: flex; flex-wrap: wrap; gap: 8px;
  animation: msgSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  margin-left: 42px; /* align with bubble (past avatar) */
}
.follow-up-chip {
  background: var(--bg-glass-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 8px 16px;
  color: var(--text-dim); font-size: 0.76rem;
  font-family: var(--font); cursor: pointer;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
}
.follow-up-chip::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(99,102,241,0.06), rgba(139,92,246,0.04));
  opacity: 0;
  transition: opacity 0.25s;
}
.follow-up-chip:hover {
  background: var(--accent-glow);
  border-color: var(--border-hover);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99,102,241,0.1);
}
.follow-up-chip:hover::before { opacity: 1; }

/* ── Expand button on cards ─────────────────────── */
.card-expand {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-muted);
  cursor: pointer; font-size: 0.72rem;
  transition: all 0.2s;
}
.card-expand:hover { border-color: var(--accent); color: var(--accent); }
.result-card.expanded .card-chart { height: 560px !important; }
.result-card.expanded {
  box-shadow: 0 16px 64px rgba(99,102,241,0.15), 0 4px 16px rgba(0,0,0,0.2);
}

/* ── AI Thinking indicator (futuristic) ────────── */
.typing {
  max-width: 100%; margin: 0 0 12px;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px 14px 14px 14px;
  width: fit-content;
  position: relative;
  overflow: hidden;
}
/* Shimmer scan across the thinking bar */
.typing::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.06), transparent);
  background-size: 200% 100%;
  animation: shimmer 2s infinite linear;
  pointer-events: none;
}

.typing-dots {
  display: flex; align-items: center; gap: 5px;
}
.typing-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: typing-neural 1.6s infinite;
  box-shadow: 0 0 6px rgba(99,102,241,0.4);
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; background: var(--accent2); box-shadow: 0 0 6px rgba(139,92,246,0.4); }
.typing-dot:nth-child(3) { animation-delay: 0.4s; background: var(--accent3); box-shadow: 0 0 6px rgba(167,139,250,0.4); }
@keyframes typing-neural {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.3; }
  30% { transform: translateY(-6px) scale(1.3); opacity: 1; }
  60% { transform: translateY(1px) scale(0.9); opacity: 0.5; }
}

.typing-label {
  font-size: 0.7rem; color: var(--text-muted);
  font-weight: 500; letter-spacing: 0.5px;
}

/* ── Thinking Steps (reasoning animation) ──── */
.thinking-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}
.thinking-step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-8px);
  transition: all 0.4s ease;
}
.thinking-step.active {
  opacity: 1;
  transform: translateX(0);
  color: var(--text-dim);
}
.thinking-step.done {
  opacity: 0.35;
  transform: translateX(0);
}
.thinking-icon {
  font-size: 0.85rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.thinking-text {
  font-weight: 500;
  letter-spacing: 0.02em;
}
.thinking-step.active .thinking-text {
  animation: thinkPulse 1.5s ease-in-out infinite;
}
@keyframes thinkPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* ── AI Avatar (photo) ────────────────────────── */
.ai-avatar {
  position: relative;
  width: 44px; height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: visible;
}
.ai-avatar-icon {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgba(99,102,241,0.3);
  box-shadow: 0 0 8px rgba(99,102,241,0.2);
}
/* Glow ring on thinking state */
.ai-avatar.thinking {
  animation: aiBreath 2s ease-in-out infinite;
}
.ai-avatar.thinking .ai-avatar-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-right-color: var(--accent2);
  animation: orbit1 1.5s linear infinite;
  pointer-events: none;
}
.ai-avatar.thinking::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 70%);
  animation: neuralPulse 2s ease-in-out infinite;
  pointer-events: none;
}

/* Avatar next to agent messages */
.msg-agent {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
}
.msg-agent .ai-avatar { margin-top: 2px; }
.msg-agent .bubble-wrap {
  display: flex; flex-direction: column; align-items: flex-start;
  max-width: calc(100% - 48px);
}

/* User avatar */
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ec4899, #f59e0b);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  box-shadow: 0 0 6px rgba(236,72,153,0.2);
  overflow: hidden;
}
.msg-user {
  display: flex; justify-content: flex-end;
  gap: 8px; align-items: flex-start;
}

/* ── Floating AI Avatar (PiP presenter) ──────────── */
.floating-avatar {
  position: fixed;
  bottom: 16px; right: 16px;
  z-index: 1000;
  display: none;
  flex-direction: column;
  align-items: center;
}
.floating-avatar.active { display: flex; animation: floatIn 0.5s cubic-bezier(0.16,1,0.3,1); }
.floating-avatar.hiding {
  display: flex;
  animation: floatOut 0.4s ease-in forwards;
  pointer-events: none;
}
@keyframes floatIn {
  from { opacity: 0; transform: translateY(30px) scale(0.9); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes floatOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(20px) scale(0.92); }
}

/* Avatar character — full face in circle */
.floating-avatar-character {
  width: 140px; height: 140px;
  cursor: pointer;
  user-select: none;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
  animation: avatarBreathe 4s ease-in-out infinite;
  z-index: 2;
  position: relative;
  transition: filter 0.3s ease, transform 0.3s ease;
  border-radius: 50%;
  overflow: hidden;
  background: #0a0c14;
}
.floating-avatar-character video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;  /* full head with space above hair */
  display: block;
  border-radius: 50%;
}
.floating-avatar-character:active { transform: scale(0.95); }

/* Hover state — scale up with glow */
.floating-avatar-character:hover {
  filter: drop-shadow(0 4px 24px rgba(99,102,241,0.4));
  transform: scale(1.06);
}

/* Paused overlay */
.floating-avatar-character.paused::after {
  content: "||";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  color: white;
  font-size: 32px;
  font-weight: 300;
  letter-spacing: 6px;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s;
}
.floating-avatar-character.paused:hover::after {
  opacity: 1;
}

/* Name + waveform under avatar */
.floating-avatar-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  height: 20px;
}
.avatar-name-text {
  font-size: 0.65rem;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
/* Speech waveform bars — hidden by default, shown when speaking */
.avatar-waveform {
  display: none;
  align-items: center;
  gap: 2px;
  height: 16px;
}
.floating-avatar.speaking .avatar-waveform {
  display: flex;
}
.floating-avatar.speaking .avatar-name-text {
  color: rgba(99,102,241,0.7);
}
.avatar-waveform span {
  width: 3px;
  background: #6366f1;
  border-radius: 2px;
  animation: waveBar 0.8s ease-in-out infinite;
}
.avatar-waveform span:nth-child(1) { height: 4px; animation-delay: 0s; }
.avatar-waveform span:nth-child(2) { height: 8px; animation-delay: 0.1s; }
.avatar-waveform span:nth-child(3) { height: 14px; animation-delay: 0.2s; }
.avatar-waveform span:nth-child(4) { height: 8px; animation-delay: 0.3s; }
.avatar-waveform span:nth-child(5) { height: 4px; animation-delay: 0.4s; }
@keyframes waveBar {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  50% { transform: scaleY(1); opacity: 1; }
}

/* Speaking state — soft glow around the person, no border */
.floating-avatar.speaking .floating-avatar-character {
  animation: avatarBreathe 3s ease-in-out infinite;
  filter: drop-shadow(0 0 12px rgba(99,102,241,0.25)) drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

/* Speaking + hover — extra glow */
.floating-avatar.speaking .floating-avatar-character.hover {
  filter: drop-shadow(0 4px 32px rgba(99,102,241,0.55));
  transform: scale(1.05);
}

/* Breathing animation — livelier */
@keyframes avatarBreathe {
  0%, 100% { transform: scale(1); }
  30%      { transform: scale(1.015) translateY(-1px); }
  50%      { transform: scale(1.025); }
  70%      { transform: scale(1.015) translateY(1px); }
}
@keyframes avatarHeadBob {
  0%   { transform: scale(1) translateY(0) rotate(-0.5deg); }
  100% { transform: scale(1.015) translateY(-4px) rotate(0.5deg); }
}

/* Click bounce keyframes */
@keyframes avatarClick {
  0%   { transform: scale(1); }
  20%  { transform: scale(0.9); }
  50%  { transform: scale(1.1); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* Speech bubble — hidden by default, shown only when speaking */
.floating-avatar-bubble {
  display: none;
}
.floating-avatar.speaking .floating-avatar-bubble {
  display: block;
  background: rgba(15,15,25,0.92);
  backdrop-filter: blur(32px) saturate(1.4);
  -webkit-backdrop-filter: blur(32px) saturate(1.4);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px rgba(99,102,241,0.15);
  width: 260px;
  overflow: hidden;
  z-index: 1;
  margin-top: 8px;
  animation: bubbleFadeIn 0.3s ease;
}
@keyframes bubbleFadeIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Bubble header */
.floating-avatar-bubble-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.floating-avatar-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.6rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: #ef4444;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 3px;
  padding: 2px 7px;
}
.floating-live-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #ef4444; box-shadow: 0 0 6px #ef4444;
  animation: blink 1.2s step-end infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
.floating-avatar-label {
  flex: 1; font-size: 0.72rem; font-weight: 600;
  color: var(--text-dim); letter-spacing: 0.03em;
}
.floating-avatar-stop {
  background: none; border: none;
  color: rgba(255,255,255,0.4); cursor: pointer;
  padding: 3px; border-radius: 4px; line-height: 1;
  transition: all 0.2s ease;
}
.floating-avatar-stop:hover {
  color: #ef4444; background: rgba(239,68,68,0.12);
}
.floating-avatar.speaking .floating-avatar-stop { display: inline-flex !important; }
.floating-avatar-close {
  background: none; border: none;
  color: rgba(255,255,255,0.35); font-size: 1rem;
  cursor: pointer; line-height: 1; padding: 2px;
}
.floating-avatar-close:hover { color: rgba(255,255,255,0.8); }

/* Speaking state — enhanced bubble glow */
.floating-avatar.speaking .floating-avatar-bubble {
  border-color: rgba(99,102,241,0.4);
  box-shadow: 0 8px 36px rgba(0,0,0,0.4), 0 0 28px rgba(99,102,241,0.2), inset 0 0 0 1px rgba(99,102,241,0.1);
}

/* (Lottie handles its own animation — no CSS overlay needed) */

/* Floating text */
.floating-avatar-text {
  padding: 6px 14px 4px;
  font-size: 0.82rem; line-height: 1.5;
  color: rgba(255,255,255,0.9);
  max-height: 70px; overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99,102,241,0.3) transparent;
}
.floating-avatar-text:empty { display: none; }
.floating-avatar-text.typing-active::after {
  content: "\2588"; color: var(--accent);
  animation: blink 0.8s step-end infinite;
}

/* Floating waveform */
.floating-avatar-wave {
  display: flex; align-items: center;
  gap: 2px; height: 16px;
  padding: 0 14px 10px;
}
.floating-avatar-wave span {
  display: block; width: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border-radius: 2px;
  animation: presenterWave 0.5s ease-in-out infinite alternate;
}
.floating-avatar-wave span:nth-child(1)  { animation-delay: 0.00s; height: 3px; }
.floating-avatar-wave span:nth-child(2)  { animation-delay: 0.05s; height: 8px; }
.floating-avatar-wave span:nth-child(3)  { animation-delay: 0.10s; height: 13px; }
.floating-avatar-wave span:nth-child(4)  { animation-delay: 0.15s; height: 7px; }
.floating-avatar-wave span:nth-child(5)  { animation-delay: 0.20s; height: 15px; }
.floating-avatar-wave span:nth-child(6)  { animation-delay: 0.25s; height: 10px; }
.floating-avatar-wave span:nth-child(7)  { animation-delay: 0.30s; height: 5px; }
.floating-avatar-wave span:nth-child(8)  { animation-delay: 0.35s; height: 12px; }
.floating-avatar-wave span:nth-child(9)  { animation-delay: 0.40s; height: 8px; }
.floating-avatar-wave span:nth-child(10) { animation-delay: 0.45s; height: 4px; }
@keyframes presenterWave {
  0%   { transform: scaleY(0.3); }
  100% { transform: scaleY(1); }
}

/* ── Language pills (flag buttons) ───────────────── */
.lang-pills {
  display: flex; gap: 3px;
}
.lang-pill {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted);
  font-size: 0.65rem; font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.04em;
}
.lang-pill:hover { border-color: var(--accent); color: var(--text-primary); }
.lang-pill.active {
  background: rgba(99,102,241,0.15);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 8px rgba(99,102,241,0.2);
}

/* ── SQL Query button ──────────────────────────── */
.sql-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.25s;
  border-radius: 8px;
  position: relative;
}
.sql-btn:hover { color: var(--accent); border-color: rgba(99,102,241,0.2); }
.sql-btn.active {
  color: var(--accent);
  background: rgba(99,102,241,0.1);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(99,102,241,0.2);
}
.sql-btn svg { width: 16px; height: 16px; }

/* ── Voice / Audio button ──────────────────────── */
.voice-btn {
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.25s;
  border-radius: 50%;
  position: relative;
}
.voice-btn:hover { color: var(--accent); }
.voice-btn.recording {
  color: var(--red);
  animation: pulse-fast 0.8s infinite;
}
.voice-btn.recording::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--red);
  opacity: 0.4;
  animation: neuralPulse 1.5s ease-in-out infinite;
}
.voice-btn svg { width: 18px; height: 18px; }

/* TTS speaker button */
.tts-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: none; border: 1px solid transparent;
  border-radius: 4px; color: var(--text-muted);
  cursor: pointer; transition: all 0.2s;
  margin-left: 4px; vertical-align: middle;
  padding: 0;
}
.tts-btn:hover { color: var(--accent); border-color: var(--border); }
.tts-btn.speaking { color: var(--accent); }
.tts-btn svg { width: 13px; height: 13px; }

/* Audio waveform visualizer */
.audio-wave {
  display: flex; align-items: center; gap: 2px;
  height: 20px; margin-left: 8px;
}
.audio-wave-bar {
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
  animation: waveform 0.6s ease-in-out infinite;
}
.audio-wave-bar:nth-child(2) { animation-delay: 0.1s; animation-duration: 0.5s; }
.audio-wave-bar:nth-child(3) { animation-delay: 0.2s; animation-duration: 0.7s; }
.audio-wave-bar:nth-child(4) { animation-delay: 0.15s; animation-duration: 0.4s; }
.audio-wave-bar:nth-child(5) { animation-delay: 0.25s; animation-duration: 0.55s; }

/* ── App footer ─────────────────────────────────── */
.app-footer {
  position: fixed; bottom: 0; right: 0;
  text-align: right;
  padding: 8px 20px;
  font-size: 0.62rem;
  color: var(--text-muted);
  letter-spacing: 0.3px;
  z-index: 40;
  pointer-events: none;
  opacity: 0.7;
}
.app-footer strong {
  color: var(--text-dim);
  font-weight: 600;
}
.app-footer a {
  color: var(--accent);
  text-decoration: none;
  pointer-events: auto;
  transition: color 0.2s;
}
.app-footer a:hover { color: var(--accent2); }

/* ── Input bar (inside chat panel) ──────────────── */
.input-bar {
  padding: 12px 18px 16px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  flex-shrink: 0;
}
.input-wrap {
  display: flex; align-items: center; gap: 0;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 24px rgba(99,102,241,0.12), 0 0 0 1px rgba(99,102,241,0.15);
  animation: glowRing 3s ease-in-out infinite;
}
.input-wrap .voice-btn {
  width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 16px 0 0 16px;
}
#user-input {
  flex: 1;
  background: none; border: none; outline: none;
  padding: 14px 12px 14px 4px;
  color: var(--text);
  font-family: var(--font); font-size: 0.88rem;
}
#user-input::placeholder { color: var(--text-muted); }
#send-btn {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  color: var(--accent); cursor: pointer;
  transition: all 0.2s;
  border-radius: 0 16px 16px 0;
}
#send-btn:hover { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
#send-btn:disabled { opacity: 0.25; cursor: not-allowed; }

/* ── Error bubble ───────────────────────────────── */
.msg-error {
  display: flex; flex-direction: row;
  align-items: flex-start; gap: 10px;
  animation: msgSlideIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.msg-error .bubble-wrap { display: flex; flex-direction: column; max-width: calc(100% - 42px); }
.msg-error .bubble {
  background: rgba(248,113,113,0.06);
  border: 1px solid rgba(248,113,113,0.15);
  color: var(--red);
  border-radius: 4px 18px 18px 18px;
  padding: 10px 18px;
  font-size: 0.85rem;
}

/* ── Animations — futuristic AI feel ──────────── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Neural network thinking animation */
@keyframes neuralPulse {
  0%, 100% { opacity: 0.15; transform: scale(1); }
  25% { opacity: 0.6; transform: scale(1.08); }
  50% { opacity: 0.3; transform: scale(1); }
  75% { opacity: 0.5; transform: scale(1.04); }
}

/* Orbiting dots around avatar */
@keyframes orbit1 {
  from { transform: rotate(0deg) translateX(22px) rotate(0deg); }
  to   { transform: rotate(360deg) translateX(22px) rotate(-360deg); }
}
@keyframes orbit2 {
  from { transform: rotate(120deg) translateX(22px) rotate(-120deg); }
  to   { transform: rotate(480deg) translateX(22px) rotate(-480deg); }
}
@keyframes orbit3 {
  from { transform: rotate(240deg) translateX(22px) rotate(-240deg); }
  to   { transform: rotate(600deg) translateX(22px) rotate(-600deg); }
}

/* Glow ring pulse */
@keyframes glowRing {
  0%, 100% { box-shadow: 0 0 4px var(--accent), 0 0 12px rgba(99,102,241,0.15); }
  50% { box-shadow: 0 0 8px var(--accent), 0 0 24px rgba(99,102,241,0.3), 0 0 48px rgba(139,92,246,0.1); }
}

/* Scanning line effect */
@keyframes scanLine {
  0% { transform: translateY(-100%); opacity: 0; }
  20% { opacity: 0.6; }
  80% { opacity: 0.6; }
  100% { transform: translateY(100%); opacity: 0; }
}

/* Gradient border animation for cards */
@keyframes borderGlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Shimmer loading effect */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Waveform animation for audio */
@keyframes waveform {
  0%, 100% { height: 4px; }
  50% { height: 18px; }
}

/* Breathing glow for AI presence */
@keyframes aiBreath {
  0%, 100% { opacity: 0.4; filter: blur(20px); }
  50% { opacity: 0.8; filter: blur(30px); }
}

/* Card entrance with depth */
@keyframes cardMaterialize {
  0% { opacity: 0; transform: translateY(24px) scale(0.95) rotateX(2deg); filter: blur(4px); }
  60% { opacity: 1; transform: translateY(-2px) scale(1.005) rotateX(0); filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scale(1) rotateX(0); filter: blur(0); }
}

/* Message entrance */
@keyframes msgSlideIn {
  0% { opacity: 0; transform: translateX(-8px) translateY(6px); }
  60% { transform: translateX(1px) translateY(-1px); }
  100% { opacity: 1; transform: translateX(0) translateY(0); }
}

/* User message entrance (from right) */
@keyframes msgSlideInRight {
  0% { opacity: 0; transform: translateX(8px) translateY(6px); }
  60% { transform: translateX(-1px) translateY(-1px); }
  100% { opacity: 1; transform: translateX(0) translateY(0); }
}

/* ── Responsive ─────────────────────────────────── */

/* Sidebar overlay for all sizes */
.sidebar-overlay {
  display: none; position: fixed;
  inset: 0; background: rgba(0,0,0,0.5);
  z-index: 85;
}

/* ── Tablet (max 900px) ─────────────────────────── */
@media (max-width: 900px) {
  .main { flex-direction: column; }
  .panel-chat {
    width: 100%; min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 55vh;
  }
  .panel-viz {
    flex: 1; min-height: 0;
    padding: 16px 18px;
    gap: 18px;
  }
  .welcome h1 { font-size: 1.15rem; }
  .suggestions { flex-direction: column; align-items: center; }
  .suggestion { width: 100%; max-width: 340px; text-align: center; }

  /* Sidebar: overlay mode */
  body.sidebar-open .topbar { left: 0; }
  body.sidebar-open .main { left: 0; }
  .sidebar { width: 85vw; max-width: 320px; }
  body.sidebar-open .sidebar-overlay { display: block; }

  /* Topbar: hide brand badge, compact gaps */
  .brand-badge { display: none; }
  .topbar-right { gap: 10px; }

  /* Cards: reduce padding */
  .card-footer { padding: 8px 12px; }
  .card-title { font-size: 0.78rem; max-width: 45%; }
  .card-actions { gap: 8px; }

  /* SQL panel: narrower */
  .result-card.sql-open .sql-panel { width: 260px; }
  .sql-panel-inner { width: 260px; }

  /* Scalar grid: stack on tablet */
  .scalar-grid { flex-direction: row; flex-wrap: wrap; }
  .scalar-item { min-width: 100px; padding: 18px 12px; }

  /* Footer: compact */
  .app-footer { font-size: 0.58rem; padding: 6px 14px; }
}

/* ── Mobile (max 600px) ─────────────────────────── */
@media (max-width: 600px) {
  :root {
    --topbar-h: 48px;
    --sidebar-w: 260px;
  }

  /* Topbar: compact */
  .topbar { padding: 0 12px; }
  .topbar-left { gap: 8px; }
  .topbar-right { gap: 6px; }
  .logo-text { font-size: 0.88rem; }
  .logo-icon { font-size: 1rem; }
  .new-chat-btn span,
  .new-chat-btn { font-size: 0; padding: 5px 8px; gap: 0; }
  .new-chat-btn svg { font-size: initial; }
  /* Hide stats on mobile */
  .stat { display: none; }
  .theme-toggle { width: 28px; height: 28px; }
  .theme-toggle svg { width: 14px; height: 14px; }

  /* User menu: compact */
  .user-menu-name { max-width: 60px; font-size: 0.66rem; }
  .user-menu-logout { width: 24px; height: 24px; }

  /* Main layout: stack with more chat space */
  .panel-chat { max-height: 60vh; }
  .chat-thread { padding: 14px 12px 10px; }

  /* Viz panel: tighter */
  .panel-viz { padding: 12px 10px; gap: 14px; }

  /* Welcome */
  .welcome { padding: 20px 12px; }
  .welcome h1 { font-size: 1.05rem; }
  .welcome p { font-size: 0.8rem; margin-bottom: 16px; }
  .suggestion { padding: 7px 12px; font-size: 0.72rem; }

  /* Bubbles: compact */
  .msg-user .bubble { padding: 8px 12px; font-size: 0.82rem; max-width: 90%; }
  .msg-agent .bubble { padding: 10px 12px; font-size: 0.8rem; max-width: 95%; }

  /* Input bar: edge-to-edge */
  .input-bar { padding: 8px 10px 12px; }
  #user-input { padding: 12px 14px; font-size: 0.84rem; }
  #send-btn { width: 42px; height: 42px; }

  /* Result cards */
  .result-card { border-radius: 10px; }
  .card-footer { padding: 8px 10px; flex-wrap: wrap; gap: 6px; }
  .card-title { font-size: 0.74rem; max-width: 100%; white-space: normal; }
  .card-actions { width: 100%; justify-content: flex-end; }
  .badge { font-size: 0.58rem; padding: 2px 8px; }
  .card-expand { width: 24px; height: 24px; font-size: 0.65rem; }

  /* SQL panel: full width overlay */
  .result-card.sql-open .sql-panel { width: 100%; }
  .sql-panel-inner { width: 100%; }
  .card-body { flex-direction: column; }
  .sql-panel { border-right: none; border-bottom: 1px solid var(--border); }

  /* Follow-up chips */
  .follow-ups { gap: 6px; margin-left: 32px; }
  .follow-up-chip { padding: 6px 12px; font-size: 0.72rem; border-radius: 14px; }

  /* Scalars */
  .scalar-hero { padding: 24px 16px; }
  .scalar-hero .scalar-value { font-size: 2.4rem; }
  .scalar-grid { flex-direction: column; }
  .scalar-item { border-right: none; border-bottom: 1px solid var(--border); padding: 16px 12px; }
  .scalar-item:last-child { border-bottom: none; }
  .scalar-item .scalar-value { font-size: 1.5rem; }

  /* Data tables */
  .card-data { padding: 6px 8px; }
  .card-data th { padding: 6px 8px; font-size: 0.64rem; }
  .card-data td { padding: 4px 8px; font-size: 0.72rem; }

  /* Tool steps */
  .step-header { padding: 7px 10px; font-size: 0.75rem; }
  .step-body { font-size: 0.7rem; padding: 8px 10px; }

  /* Footer: hide on mobile */
  .app-footer { display: none; }

  /* Auth overlay */
  .auth-card { width: 100%; max-width: 100vw; border-radius: 0; max-height: 100vh; }
  .auth-right { padding: 24px 20px; }
  .auth-right-title { font-size: 1.1rem; }

  /* Sidebar */
  .sidebar { width: 85vw; max-width: 280px; }
  .sidebar-item { padding: 10px 12px; }
  .sidebar-item-title { font-size: 0.76rem; }

  /* Avatar: smaller on mobile */
  .ai-avatar { width: 34px; height: 34px; }
  .ai-avatar-icon { width: 34px; height: 34px; }
  .user-avatar { width: 24px; height: 24px; font-size: 0.6rem; }
  .msg-agent { gap: 6px; }
  .msg-agent .bubble-wrap { max-width: calc(100% - 36px); }

  /* Floating avatar: compact on mobile */
  .floating-avatar { width: 200px; bottom: 50px; right: 12px; }
  .floating-avatar-character { width: 120px; height: 120px; margin-bottom: -8px; }
  .floating-avatar-text { font-size: 0.75rem; max-height: 50px; }
  .floating-avatar-badge { font-size: 0.55rem; }
  .msg-user { gap: 6px; }

  /* Voice button: smaller */
  .voice-btn { width: 36px; height: 36px; }
  .voice-btn svg { width: 15px; height: 15px; }
}

/* ── Small mobile (max 400px) ───────────────────── */
@media (max-width: 400px) {
  .topbar { padding: 0 8px; }
  .topbar-left { gap: 6px; }
  .topbar-right { gap: 4px; }
  .logo-text { font-size: 0.82rem; }
  .query-counter { font-size: 0.6rem; padding: 2px 6px; }

  .panel-chat { max-height: 55vh; }
  .chat-thread { padding: 10px 8px 8px; }
  .panel-viz { padding: 8px 6px; gap: 10px; }

  .welcome h1 { font-size: 0.95rem; }
  .welcome p { font-size: 0.75rem; }
  .suggestion { padding: 6px 10px; font-size: 0.68rem; }

  .msg { margin-bottom: 10px; }
  .msg-user .bubble { padding: 7px 10px; font-size: 0.78rem; border-radius: 14px 14px 4px 14px; }
  .msg-agent .bubble { padding: 8px 10px; font-size: 0.76rem; border-radius: 4px 14px 14px 14px; }

  .input-bar { padding: 6px 6px 10px; }
  #user-input { padding: 10px 12px; font-size: 0.8rem; }
  #send-btn { width: 38px; height: 38px; }
  .input-wrap { border-radius: 12px; }

  .follow-up-chip { padding: 5px 10px; font-size: 0.68rem; }

  .result-card { border-radius: 8px; }
  .card-footer { padding: 6px 8px; }
  .card-title { font-size: 0.7rem; }

  .auth-right { padding: 20px 16px; }
  .auth-field input { padding: 8px 12px; font-size: 0.82rem; }
  .auth-submit { padding: 10px 0; font-size: 0.84rem; }
  .google-btn { padding: 9px 0; font-size: 0.82rem; }
}

/* ── Theme toggle button ───────────────────────── */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: none; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer;
  color: var(--text-dim); transition: all 0.25s;
}
.theme-toggle:hover {
  border-color: var(--border-hover); color: var(--text);
  background: var(--bg-glass);
}
/* In dark mode: show sun, hide moon */
.theme-toggle .icon-sun { display: block; }
.theme-toggle .icon-moon { display: none; }
/* In light mode: show moon, hide sun */
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ══════════════════════════════════════════════════
   LIGHT THEME
   ══════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg:         #f5f6fa;
  --bg-surface: #ffffff;
  --bg-card:    rgba(255,255,255,0.92);
  --bg-glass:   rgba(0,0,0,0.03);
  --bg-glass-2: rgba(0,0,0,0.05);
  --border:     rgba(0,0,0,0.09);
  --border-hover: rgba(99,102,241,0.45);
  --accent:     #4f46e5;
  --accent2:    #7c3aed;
  --accent3:    #8b5cf6;
  --accent-glow: rgba(79,70,229,0.1);
  --text:       #1e1e2e;
  --text-dim:   #555567;
  --text-muted: #8e8ea0;
  --green:      #059669;
  --red:        #dc2626;
  --blue:       #2563eb;
  --pink:       #db2777;
  --yellow:     #ca8a04;
  --orange:     #ea580c;
  --cyan:       #0891b2;
}

/* Topbar - light */
[data-theme="light"] .topbar {
  background: rgba(245,246,250,0.88);
  border-bottom-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .logo-icon {
  filter: drop-shadow(0 0 4px rgba(79,70,229,0.15));
}

/* Sidebar - light */
[data-theme="light"] .sidebar {
  background: rgba(255,255,255,0.97);
}
[data-theme="light"] .sidebar-item.active {
  background: rgba(79,70,229,0.06);
  border-color: rgba(79,70,229,0.15);
}

/* User bubble - light */
[data-theme="light"] .msg-user .bubble {
  box-shadow: 0 2px 12px rgba(79,70,229,0.15);
}

/* Agent bubble - light */
[data-theme="light"] .msg-agent .bubble {
  background: var(--bg-surface);
  border-color: rgba(0,0,0,0.07);
  color: #444455;
}
[data-theme="light"] .msg-agent .bubble .md-label {
  color: var(--accent);
}
[data-theme="light"] .msg-agent .bubble.brief {
  background: rgba(79,70,229,0.03);
  border-color: rgba(79,70,229,0.08);
}
[data-theme="light"] .msg-agent .bubble .md-code {
  background: rgba(0,0,0,0.05);
}
[data-theme="light"] .msg-agent .bubble .md-table th {
  background: rgba(79,70,229,0.06);
}
[data-theme="light"] .msg-agent .bubble .md-table td {
  border-bottom-color: rgba(0,0,0,0.05);
}

/* Result cards - light */
[data-theme="light"] .result-card {
  background: var(--bg-surface);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
}
[data-theme="light"] .result-card::before {
  opacity: 0.6;
}
[data-theme="light"] .result-card:hover {
  border-color: rgba(79,70,229,0.3);
  box-shadow: 0 8px 32px rgba(79,70,229,0.1), 0 2px 8px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}
[data-theme="light"] .card-chart {
  background: linear-gradient(180deg, rgba(79,70,229,0.015) 0%, transparent 60%);
}
[data-theme="light"] .card-footer {
  background: rgba(0,0,0,0.02);
  border-top-color: rgba(0,0,0,0.06);
}

/* Scalar - light */
[data-theme="light"] .scalar-hero {
  background: linear-gradient(145deg, rgba(79,70,229,0.05) 0%, rgba(124,58,237,0.02) 50%, rgba(236,72,153,0.015) 100%);
}
[data-theme="light"] .scalar-hero::after {
  background: linear-gradient(90deg, transparent, rgba(79,70,229,0.12), transparent);
}
[data-theme="light"] .scalar-hero .scalar-value,
[data-theme="light"] .scalar-item .scalar-value {
  background: linear-gradient(135deg, #1e1e2e 15%, var(--accent) 60%, var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
[data-theme="light"] .scalar-item:hover {
  background: linear-gradient(145deg, rgba(79,70,229,0.05), rgba(124,58,237,0.015));
}

/* SQL panel - light */
[data-theme="light"] .sql-panel {
  background: rgba(0,0,0,0.02);
}
[data-theme="light"] .sql-panel pre {
  background: #1e1e2e;
  color: #34d399;
  border-color: rgba(0,0,0,0.1);
}

/* Panels - light */
[data-theme="light"] .panel-chat {
  border-right-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .panel-viz {
  background: #f0f1f5;
}
[data-theme="light"] .viz-empty-icon svg { stroke: var(--text-muted); }

/* Input bar - light */
[data-theme="light"] .input-bar {
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
[data-theme="light"] .input-wrap {
  background: var(--bg-surface);
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
[data-theme="light"] .input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(79,70,229,0.08), 0 0 0 1px rgba(79,70,229,0.12);
}

/* Welcome - light */
[data-theme="light"] .welcome h1 {
  background: linear-gradient(135deg, #1e1e2e 20%, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
[data-theme="light"] .welcome-glow {
  background: radial-gradient(circle, rgba(79,70,229,0.06) 0%, transparent 70%);
}

/* Suggestion chips - light */
[data-theme="light"] .suggestion {
  background: var(--bg-surface);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
[data-theme="light"] .suggestion:hover {
  background: rgba(79,70,229,0.05);
  border-color: rgba(79,70,229,0.3);
}

/* Follow-up chips - light */
[data-theme="light"] .follow-up-chip {
  background: var(--bg-surface);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
[data-theme="light"] .follow-up-chip:hover {
  background: rgba(79,70,229,0.06);
  border-color: rgba(79,70,229,0.3);
  box-shadow: 0 3px 10px rgba(79,70,229,0.08);
}

/* Ext links - light */
[data-theme="light"] .ext-link {
  background: rgba(79,70,229,0.06);
  border-color: rgba(79,70,229,0.15);
}
[data-theme="light"] .ext-link:hover {
  background: rgba(79,70,229,0.12);
  color: var(--accent);
}

/* Error bubble - light */
[data-theme="light"] .msg-error .bubble {
  background: rgba(220,38,38,0.06);
  border-color: rgba(220,38,38,0.15);
}

/* Typing indicator - light */
[data-theme="light"] .typing {
  background: var(--bg-surface);
  border-color: rgba(0,0,0,0.08);
}
[data-theme="light"] .typing::before {
  background: linear-gradient(90deg, transparent, rgba(79,70,229,0.04), transparent);
}
[data-theme="light"] .typing-dot { box-shadow: 0 0 4px rgba(79,70,229,0.3); }

/* AI Avatar - light */
[data-theme="light"] .ai-avatar-icon {
  border-color: rgba(79,70,229,0.25);
  box-shadow: 0 0 6px rgba(79,70,229,0.12);
}
[data-theme="light"] .user-avatar {
  box-shadow: 0 0 4px rgba(236,72,153,0.15);
}
/* Floating avatar - light */
[data-theme="light"] .floating-avatar-bubble {
  background: rgba(255,255,255,0.96);
  border-color: rgba(79,70,229,0.15);
  box-shadow: 0 8px 36px rgba(0,0,0,0.1), 0 0 16px rgba(79,70,229,0.06);
}
[data-theme="light"] .floating-avatar-text {
  color: rgba(0,0,0,0.85);
}
[data-theme="light"] .floating-avatar-close {
  color: rgba(0,0,0,0.35);
}
[data-theme="light"] .floating-avatar-close:hover {
  color: rgba(0,0,0,0.7);
}
[data-theme="light"] .floating-avatar-bubble-header {
  border-bottom-color: rgba(0,0,0,0.06);
}
[data-theme="light"] .floating-avatar-label {
  color: rgba(0,0,0,0.5);
}
[data-theme="light"] .floating-avatar-character {
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}
[data-theme="light"] .floating-avatar-character.hover {
  filter: drop-shadow(0 4px 16px rgba(79,70,229,0.25));
}
[data-theme="light"] .floating-avatar.speaking .floating-avatar-character {
  filter: drop-shadow(0 4px 22px rgba(79,70,229,0.35));
}
[data-theme="light"] .floating-avatar-badge {
  background: rgba(239,68,68,0.06);
  border-color: rgba(239,68,68,0.2);
}

/* Voice button - light */
[data-theme="light"] .voice-btn:hover { color: var(--accent); }
[data-theme="light"] .tts-btn:hover { color: var(--accent); }
/* Language / SQL - light */
[data-theme="light"] .lang-pill {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.1);
  color: rgba(0,0,0,0.5);
}
[data-theme="light"] .lang-pill:hover { border-color: var(--accent); color: rgba(0,0,0,0.75); }
[data-theme="light"] .lang-pill.active {
  background: rgba(79,70,229,0.08);
  border-color: var(--accent);
  color: var(--accent);
}
[data-theme="light"] .sql-btn:hover { border-color: rgba(79,70,229,0.2); }
[data-theme="light"] .sql-btn.active {
  background: rgba(79,70,229,0.06);
  border-color: var(--accent);
}

/* Scrollbar - light */
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.2);
}

/* Sidebar overlay - light */
[data-theme="light"] .sidebar-overlay {
  background: rgba(0,0,0,0.2);
}

/* Status dot - light */
[data-theme="light"] .pulse-dot {
  box-shadow: 0 0 6px rgba(5,150,105,0.5);
}

/* Auth overlay - light */
[data-theme="light"] .auth-overlay {
  background: rgba(245,246,250,0.98);
}
[data-theme="light"] .auth-card {
  background: #fff;
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 20px 60px rgba(0,0,0,0.1), 0 0 1px rgba(79,70,229,0.2);
}
[data-theme="light"] .auth-left {
  background: linear-gradient(160deg, rgba(79,70,229,0.06) 0%, rgba(124,58,237,0.03) 50%, transparent 100%);
  border-right-color: rgba(0,0,0,0.06);
}
[data-theme="light"] .auth-feature-icon {
  background: rgba(79,70,229,0.06);
  border-color: rgba(79,70,229,0.12);
}
[data-theme="light"] .auth-trial-note {
  background: rgba(5,150,105,0.05);
  border-color: rgba(5,150,105,0.1);
}
[data-theme="light"] .auth-title {
  background: linear-gradient(135deg, #1e1e2e 20%, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
[data-theme="light"] .auth-field input {
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .google-btn {
  background: #fff;
  border-color: rgba(0,0,0,0.12);
  color: #333;
}
[data-theme="light"] .google-btn:hover {
  background: rgba(79,70,229,0.04);
  border-color: rgba(79,70,229,0.3);
}

/* Badges - light */
[data-theme="light"] .b-bar   { background: rgba(37,99,235,0.08); }
[data-theme="light"] .b-line  { background: rgba(5,150,105,0.08); }
[data-theme="light"] .b-pie   { background: rgba(219,39,119,0.08); }
[data-theme="light"] .b-scatter { background: rgba(202,138,4,0.08); }
[data-theme="light"] .b-area  { background: rgba(124,58,237,0.08); }
[data-theme="light"] .b-dash  { background: rgba(234,88,12,0.08); }
[data-theme="light"] .b-data  { background: rgba(8,145,178,0.08); }
[data-theme="light"] .b-scalar { background: rgba(5,150,105,0.08); }
