:root {
  --bg: #0a0a0f;
  --bg2: #13131b;
  --bg3: #1c1c28;
  --bg4: #262636;
  --border: rgba(255,255,255,0.08);
  --border2: rgba(255,255,255,0.14);
  --text: #f3f4f6;
  --text2: #9ca3af;
  --text3: #6b7280;
  --accent: #8b5cf6;
  --accent2: #a855f7;
  --accent-glow: rgba(139, 92, 246, 0.25);
  --green: #10b981;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 16px;
  --sidebar-w: 280px;
  --topbar-h: 64px;
}

* {
  margin: 0; padding: 0; box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
body {
  background: var(--bg); color: var(--text);
  min-height: 100vh; min-height: 100dvh; overflow-x: hidden;
}
.hidden { display: none !important; }
code { font-family: 'JetBrains Mono', monospace; }

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Auth Screen ───────────────────────────────────────── */
.auth-screen {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 50% 30%, rgba(139,92,246,0.12) 0%, var(--bg) 70%);
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 24px; padding: 2.5rem 2rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; align-items: center;
}
.auth-logo {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1rem; color: #fff;
  box-shadow: 0 10px 25px var(--accent-glow);
}
.auth-logo svg { width: 30px; height: 30px; }
.auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.auth-sub { font-size: 0.85rem; color: var(--text2); margin-bottom: 2rem; text-align: center; }

.auth-form { width: 100%; display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text2); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.75rem 1rem; color: var(--text);
  font-size: 0.95rem; outline: none; transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
}
.form-error {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5; font-size: 0.85rem; padding: 0.6rem 1rem; border-radius: 10px;
}
.btn-primary {
  background: var(--accent); color: #fff; border: none;
  border-radius: 12px; padding: 0.8rem 1.5rem; font-weight: 600;
  font-size: 0.95rem; cursor: pointer; transition: all .2s;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.auth-switch { font-size: 0.85rem; color: var(--text2); text-align: center; margin-top: 0.5rem; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { underline: true; }

/* ── Main App Layout ───────────────────────────────────── */
.app {
  display: flex; height: 100vh; height: 100dvh; overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: width .2s, transform .2s; z-index: 20;
}
.sidebar.collapsed { width: 0; overflow: hidden; border: none; }
.sidebar-top { padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1rem; border-bottom: 1px solid var(--border); }
.sidebar-brand { display: flex; align-items: center; gap: 0.75rem; font-weight: 700; font-size: 1.1rem; }
.brand-icon { width: 32px; height: 32px; color: var(--accent); }
.new-chat-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: var(--bg3); border: 1px solid var(--border2); color: var(--text);
  padding: 0.7rem 1rem; border-radius: 12px; font-weight: 600; font-size: 0.88rem;
  cursor: pointer; transition: all .2s;
}
.new-chat-btn svg { width: 18px; height: 18px; }
.new-chat-btn:hover { background: var(--bg4); border-color: var(--accent); }

.sidebar-nav { padding: 0.75rem 0.75rem 0; display: flex; flex-direction: column; gap: 0.25rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem; width: 100%;
  padding: 0.7rem 0.85rem; border-radius: 12px; background: transparent;
  border: none; color: var(--text2); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: all .15s; text-align: left;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--bg3); color: var(--text); font-weight: 600; }

.chat-history-label { font-size: 0.72rem; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; padding: 1rem 1rem 0.4rem; }
.chat-history { flex: 1; overflow-y: auto; padding: 0 0.75rem; display: flex; flex-direction: column; gap: 0.2rem; }
.history-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 0.75rem; border-radius: 10px; cursor: pointer;
  color: var(--text2); font-size: 0.85rem; transition: background .15s;
}
.history-item:hover { background: var(--bg3); color: var(--text); }
.history-item.active { background: var(--bg3); color: var(--text); }
.history-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.history-actions { display: none; align-items: center; gap: 0.25rem; }
.history-item:hover .history-actions { display: flex; }
.history-btn { background: transparent; border: none; color: var(--text3); cursor: pointer; padding: 2px; }
.history-btn:hover { color: var(--red); }

.sidebar-footer {
  padding: 1rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.user-badge { display: flex; align-items: center; gap: 0.75rem; overflow: hidden; }
.user-avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #ec4899);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-name { font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.75rem; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn { background: transparent; border: none; color: var(--text3); cursor: pointer; padding: 0.5rem; border-radius: 8px; }
.logout-btn svg { width: 18px; height: 18px; }
.logout-btn:hover { background: var(--bg3); color: var(--red); }

/* ── Main Content Area ─────────────────────────────────── */
.main {
  flex: 1; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
  background: var(--bg);
}
.topbar {
  height: var(--topbar-h); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; flex-shrink: 0;
}
.icon-btn {
  background: transparent; border: none; color: var(--text2);
  padding: 0.5rem; border-radius: 10px; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--bg2); color: var(--text); }
.topbar-title { font-weight: 600; font-size: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.status-badge {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.2);
  color: #34d399; padding: 0.35rem 0.75rem; border-radius: 20px;
  font-size: 0.78rem; font-weight: 600;
}
.pulse { width: 8px; height: 8px; background: #34d399; border-radius: 50%; animation: pulseAnim 1.5s infinite; }

/* ── Views ─────────────────────────────────────────────── */
.view { flex: 1; display: none; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
.view.active { display: flex; }

/* ── Chat View ─────────────────────────────────────────── */
.messages {
  flex: 1; overflow-y: auto; padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.welcome-box {
  max-width: 600px; margin: auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 1rem;
}
.welcome-icon {
  width: 72px; height: 72px; border-radius: 24px;
  background: linear-gradient(135deg, var(--accent), #06b6d4);
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 15px 30px var(--accent-glow); margin-bottom: 0.5rem;
}
.welcome-icon svg { width: 40px; height: 40px; }
.welcome-box h2 { font-size: 1.6rem; font-weight: 700; }
.welcome-box p { color: var(--text2); font-size: 0.95rem; line-height: 1.5; }
.quick-prompts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; width: 100%; margin-top: 1rem; }
.qp-btn {
  background: var(--bg2); border: 1px solid var(--border); color: var(--text2);
  padding: 0.85rem 1rem; border-radius: 14px; font-size: 0.85rem; text-align: left;
  cursor: pointer; transition: all .2s; line-height: 1.4;
}
.qp-btn:hover { background: var(--bg3); border-color: var(--border2); color: var(--text); transform: translateY(-2px); }

/* Message rows */
.msg-row { display: flex; gap: 1rem; max-width: 850px; margin: 0 auto; width: 100%; }
.msg-row.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85rem;
}
.msg-avatar.ai { background: linear-gradient(135deg, var(--accent), #06b6d4); color: #fff; }
.msg-avatar.user { background: var(--bg3); border: 1px solid var(--border2); color: var(--text); }
.msg-bubble {
  max-width: 75%;
  word-break: break-word;
  min-width: 0;
  overflow-wrap: anywhere; background: transparent; border: none;
  border-radius: 18px; padding: 0.5rem 0; font-size: 0.95rem; line-height: 1.6; color: var(--text);
}
.msg-row.user .msg-bubble { background: transparent; border: none; color: var(--text); border-top-right-radius: 4px; }
.msg-row.ai .msg-bubble { border-top-left-radius: 4px; }
.msg-bubble p { margin-bottom: 0.75rem; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble img { max-width: 100%; border-radius: 12px; margin: 0.5rem 0; }
.msg-bubble pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem; overflow-x: auto; margin: 0.75rem 0; font-size: 0.88rem;
}

/* Thoughts box */
.thoughts-box {
  background: rgba(255,255,255,0.02); border: 1px dashed var(--border2);
  border-radius: 12px; padding: 0.75rem 1rem; margin-bottom: 1rem;
  font-size: 0.85rem; color: var(--text2);
}
.thoughts-summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; color: var(--accent); }

/* Input area */
.input-area {
  padding: 1rem 1.5rem 1.5rem; flex-shrink: 0; max-width: 850px; width: 100%; margin: 0 auto; position: relative;
}
.input-box {
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 20px; transition: border-color .2s; overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.input-box:focus-within { border-color: var(--accent); }
.image-preview-bar {
  padding: 0.75rem 1rem 0; display: flex; align-items: center; gap: 0.75rem;
}
.image-preview-card {
  position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border2);
}
.image-preview-card img { width: 100%; height: 100%; object-fit: cover; }
.remove-img-btn {
  position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.7); border: none;
  color: #fff; width: 20px; height: 20px; border-radius: 50%; font-size: 0.7rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.input-row { display: flex; align-items: flex-end; padding: 0.5rem 0.75rem; gap: 0.5rem; }
.input-row textarea {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-size: 0.95rem; line-height: 1.5; max-height: 150px; resize: none;
  outline: none; padding: 0.5rem 0;
}
.send-btn {
  background: var(--accent); border: none; color: #fff; width: 38px; height: 38px;
  border-radius: 12px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s; flex-shrink: 0;
}
.send-btn svg { width: 18px; height: 18px; }
.send-btn:hover:not(:disabled) { background: var(--accent2); transform: scale(1.05); }
.send-btn:disabled { background: var(--bg3); color: var(--text3); cursor: not-allowed; }
.input-hint { display: none !important; }

/* ── Other Views (Memory, Files, Profile) ──────────────── */
.view-header { padding: 2rem 2rem 1rem; max-width: 800px; margin: 0 auto; width: 100%; }
.view-header h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.view-header p { color: var(--text2); font-size: 0.9rem; }

.memory-add {
  display: flex; gap: 0.75rem; max-width: 800px; margin: 1rem auto 1.5rem; width: 100%; padding: 0 2rem;
}
.memory-add input {
  flex: 1; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.75rem 1rem; color: var(--text); outline: none;
}
.memory-add select {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
  padding: 0.75rem 1rem; color: var(--text); outline: none;
}
.memory-list, .files-list {
  flex: 1; overflow-y: auto; max-width: 800px; margin: 0 auto; width: 100%; padding: 0 2rem 2rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}
.mem-item, .file-item {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 14px;
  padding: 1rem 1.25rem; display: flex; justify-content: space-between; align-items: center;
}
.mem-content { font-size: 0.92rem; line-height: 1.4; }
.mem-cat { font-size: 0.72rem; background: var(--bg3); padding: 0.2rem 0.6rem; border-radius: 6px; color: var(--accent); font-weight: 600; }
.mem-del, .file-del { background: transparent; border: none; color: var(--text3); cursor: pointer; padding: 0.4rem; }
.mem-del:hover, .file-del:hover { color: var(--red); }

.file-upload-zone {
  max-width: 800px; margin: 1rem auto 1.5rem; width: calc(100% - 4rem);
  background: var(--bg2); border: 2px dashed var(--border2); border-radius: 20px;
  padding: 2.5rem; text-align: center; cursor: pointer; transition: all .2s; position: relative;
}
.file-upload-zone:hover { border-color: var(--accent); background: var(--bg3); }
.file-upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-upload-zone p { font-size: 0.95rem; margin: 0.5rem 0 0.25rem; font-weight: 500; }
.file-upload-zone .link { color: var(--accent); }
.file-upload-zone small { color: var(--text3); font-size: 0.8rem; }

.profile-form {
  max-width: 800px; margin: 0 auto; width: 100%; padding: 1rem 2rem 2rem; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1.5rem;
}
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-group.full { grid-column: 1 / -1; }

/* ── Voice Mode Overlay ────────────────────────────────── */
.voice-overlay {
  position: fixed; inset: 0; background: rgba(10,10,15,0.95); backdrop-filter: blur(20px);
  z-index: 9999; display: flex; flex-direction: column; justify-content: space-between;
}
.voice-topbar {
  padding: 1.5rem 2rem; display: flex; justify-content: space-between; align-items: center;
}
.voice-model-badge {
  background: var(--bg2); border: 1px solid var(--border2); padding: 0.4rem 1rem;
  border-radius: 20px; font-size: 0.85rem; font-weight: 600; color: #34d399;
}
.voice-close-btn {
  background: var(--bg2); border: 1px solid var(--border2); color: var(--text);
  width: 40px; height: 40px; border-radius: 50%; font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.voice-center {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2rem;
}
.voice-orb {
  position: relative; width: 180px; height: 180px; display: flex; align-items: center; justify-content: center;
}
.orb-core {
  width: 100px; height: 100px; border-radius: 50%;
  background: radial-gradient(circle, var(--accent), #06b6d4);
  display: flex; align-items: center; justify-content: center; color: #fff;
  box-shadow: 0 0 50px var(--accent-glow); z-index: 2; position: relative; overflow: hidden;
}
.orb-avatar-video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.85; z-index: -1;
}
.orb-core svg { width: 44px; height: 44px; }
.orb-ring {
  position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--accent);
  opacity: 0; transition: all .3s;
}
.voice-orb.active .orb-ring.r1 { animation: orbWave 2s infinite; }
.voice-orb.active .orb-ring.r2 { animation: orbWave 2s infinite 0.4s; }
.voice-orb.active .orb-ring.r3 { animation: orbWave 2s infinite 0.8s; }
.voice-orb.active .orb-ring.r4 { animation: orbWave 2s infinite 1.2s; }
.voice-orb.active .orb-ring.r5 { animation: orbWave 2s infinite 1.6s; }

/* ── Thinking / Processing State for Voice Orb ─────────── */
.voice-orb.active.thinking .orb-core {
  background: radial-gradient(circle at 30% 30%, #ec4899, #8b5cf6 45%, #06b6d4 80%, #10a37f) !important;
  background-size: 300% 300% !important;
  animation: orbThinkGradient 2s infinite ease-in-out, orbThinkPulse 1.1s infinite alternate ease-in-out !important;
  box-shadow: 0 0 90px rgba(168,85,247,0.95), 0 0 45px rgba(6,182,212,0.85), 0 0 25px rgba(236,72,153,0.7), inset 0 0 35px rgba(255,255,255,0.8) !important;
}
#voiceOrb.thinking .orb-core svg,
.voice-orb.thinking .orb-core svg {
  animation: starThinkRotate 3s infinite linear, starPulse 0.7s infinite alternate !important;
  color: #fff !important;
  filter: drop-shadow(0 0 12px rgba(255,255,255,0.9)) !important;
}

#voiceOrb.thinking .orb-ring,
.voice-orb.thinking .orb-ring,
.voice-orb.active.thinking .orb-ring {
  opacity: 1 !important;
}
#voiceOrb.thinking .orb-ring.r1,
.voice-orb.thinking .orb-ring.r1,
.voice-orb.active.thinking .orb-ring.r1 {
  animation: orbThinkSpin 2s linear infinite !important;
  border: 3px dashed #c084fc !important;
  box-shadow: 0 0 20px rgba(192,132,252,0.7) !important;
  transform: scale(1.2) !important;
}
#voiceOrb.thinking .orb-ring.r2,
.voice-orb.thinking .orb-ring.r2,
.voice-orb.active.thinking .orb-ring.r2 {
  animation: orbThinkSpinReverse 3s linear infinite !important;
  border: 3px dotted #38bdf8 !important;
  box-shadow: 0 0 25px rgba(56,189,248,0.7) !important;
  transform: scale(1.45) !important;
}
#voiceOrb.thinking .orb-ring.r3,
.voice-orb.thinking .orb-ring.r3,
.voice-orb.active.thinking .orb-ring.r3 {
  animation: orbThinkSpin 1.6s linear infinite !important;
  border: 2px dashed #ec4899 !important;
  box-shadow: 0 0 30px rgba(236,72,153,0.6) !important;
  transform: scale(1.75) !important;
}
#voiceOrb.thinking .orb-ring.r4,
.voice-orb.thinking .orb-ring.r4,
.voice-orb.active.thinking .orb-ring.r4 {
  animation: orbThinkWave 2.2s infinite ease-out !important;
  border: 2px solid rgba(168,85,247,0.8) !important;
}
#voiceOrb.thinking .orb-ring.r5,
.voice-orb.thinking .orb-ring.r5,
.voice-orb.active.thinking .orb-ring.r5 {
  animation: orbThinkWave 2.2s infinite ease-out 1.1s !important;
  border: 2px solid rgba(6,182,212,0.8) !important;
}

/* ── Orbiting Particles in Thinking State ──────────────── */
.orb-particles {
  position: absolute; inset: -40px; pointer-events: none; opacity: 0;
  transition: opacity 0.3s ease; display: flex; align-items: center; justify-content: center;
}
#voiceOrb.thinking .orb-particles,
.voice-orb.thinking .orb-particles {
  opacity: 1 !important;
  animation: orbThinkSpin 4s linear infinite;
}
.orb-particles span {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 14px #38bdf8, 0 0 24px #a855f7;
}
.orb-particles span:nth-child(1) { top: 0; left: 50%; transform: translate(-50%, 0); }
.orb-particles span:nth-child(2) { bottom: 0; left: 50%; transform: translate(-50%, 0); }
.orb-particles span:nth-child(3) { top: 50%; left: 0; transform: translate(0, -50%); }
.orb-particles span:nth-child(4) { top: 50%; right: 0; transform: translate(0, -50%); }

#voiceOrb.thinking ~ .voice-status,
.voice-orb.thinking ~ .voice-status {
  color: #c084fc !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px;
  text-shadow: 0 0 16px rgba(192,132,252,0.8), 0 0 30px rgba(56,189,248,0.6) !important;
  animation: statusThinkPulse 1.2s infinite alternate ease-in-out !important;
}

@keyframes orbThinkGradient {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes orbThinkPulse {
  0%   { transform: scale(0.95) rotate(0deg); }
  100% { transform: scale(1.22) rotate(18deg); }
}
@keyframes orbThinkSpin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
@keyframes orbThinkSpinReverse {
  0%   { transform: rotate(360deg); }
  100% { transform: rotate(0deg); }
}
@keyframes orbThinkWave {
  0%   { transform: scale(0.9); opacity: 0.9; border-width: 3px; }
  100% { transform: scale(2.6); opacity: 0; border-width: 1px; }
}
@keyframes starThinkRotate {
  0%   { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.2); }
  100% { transform: rotate(360deg) scale(1); }
}
@keyframes starPulse {
  0%   { opacity: 0.7; }
  100% { opacity: 1; }
}
@keyframes statusThinkPulse {
  0%   { transform: scale(0.98); opacity: 0.85; }
  100% { transform: scale(1.06); opacity: 1; }
}

/* ── Message Actions Bar (Read aloud & Copy buttons) ───── */
.msg-actions {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 0; padding-top: 0;
  max-height: 0; opacity: 0; pointer-events: none;
  overflow: hidden;
  border-top: 1px solid transparent;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.msg-bubble:hover .msg-actions,
.msg-bubble.show-actions .msg-actions {
  margin-top: 0.55rem; padding-top: 0.45rem;
  max-height: 250px; opacity: 1; pointer-events: auto;
  overflow: visible;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.msg-action-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text2); font-size: 0.78rem; font-weight: 500;
  padding: 0.35rem 0.7rem; border-radius: 8px; cursor: pointer;
  transition: all 0.2s ease; font-family: inherit;
}
.msg-action-btn:hover {
  background: rgba(255,255,255,0.1); color: var(--text);
  border-color: rgba(255,255,255,0.2); transform: translateY(-1px);
}
.msg-action-btn.active-tts {
  background: rgba(16,163,127,0.2); border-color: var(--accent);
  color: #34d399; animation: pulseAnim 1.2s infinite;
}
.msg-action-btn.success-copy {
  background: rgba(16,163,127,0.25); border-color: #34d399;
  color: #fff;
}
.msg-action-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.msg-more-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text2); font-size: 0.95rem; font-weight: 700;
  padding: 0.2rem 0.75rem; border-radius: 18px; cursor: pointer;
  transition: all 0.2s ease; font-family: inherit;
  letter-spacing: 1px;
}
.msg-more-btn:hover, .msg-more-btn.active {
  background: rgba(139,92,246,0.25); color: #fff;
  border-color: #8b5cf6; transform: scale(1.05);
  box-shadow: 0 0 10px rgba(139,92,246,0.4);
}
.msg-popup-menu {
  position: absolute; right: 0; bottom: 100%; margin-bottom: 8px;
  background: rgba(30, 30, 46, 0.96);
  border: 1px solid rgba(139,92,246,0.35);
  border-radius: 12px; padding: 6px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.65);
  display: flex; flex-direction: column; gap: 4px;
  z-index: 99; min-width: 145px;
  backdrop-filter: blur(16px);
}
.msg-popup-menu.hidden {
  display: none !important;
}
.msg-popup-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 11px; border: none; background: transparent;
  color: #e2e8f0; font-size: 0.82rem; font-weight: 500;
  border-radius: 8px; cursor: pointer; text-align: left;
  transition: all 0.15s ease; font-family: inherit;
}
.msg-popup-item:hover {
  background: rgba(139,92,246,0.25); color: #fff;
}


/* ── Chat Thinking Avatar Animation ─────────────────────── */
.msg-row.ai.thinking-row .msg-avatar.ai {
  background: radial-gradient(circle at 30% 30%, #a855f7, #06b6d4, #10a37f);
  background-size: 200% 200%;
  animation: orbThinkGradient 2s infinite, dotBounce 1.2s infinite ease-in-out;
  box-shadow: 0 0 16px rgba(168,85,247,0.7);
}

.voice-status { font-size: 1.1rem; color: var(--text2); font-weight: 500; transition: color .2s; }
.voice-orb.active ~ .voice-status { color: #34d399; }
.voice-transcript { max-width: 600px; font-size: .95rem; color: var(--text); min-height: 24px; font-style: italic; opacity: .9; }

.voice-bottom {
  display: flex; flex-direction: column; align-items: center; gap: .75rem;
  padding: 2rem;
}
.voice-mic-btn {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--bg3); border: 2px solid var(--border2);
  color: var(--text); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s; box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.voice-mic-btn svg { width: 30px; height: 30px; }
.voice-mic-btn:hover { background: var(--bg4); border-color: var(--accent); transform: scale(1.05); }
.voice-mic-btn.listening { background: var(--accent); border-color: #34d399; color: #fff; animation: pulseAnim .8s infinite; }
.voice-hint { font-size: .8rem; color: var(--text3); }

/* ── Commands Menu Popup ────────────────────────────────── */
.cmds-menu {
  position: absolute; bottom: 85px; left: 1rem; z-index: 50;
  background: var(--bg2); border: 1px solid var(--border2);
  border-radius: 14px; padding: .6rem; width: 260px;
  box-shadow: 0 10px 35px rgba(0,0,0,.6);
  display: flex; flex-direction: column; gap: .35rem;
  animation: fadeUp .2s ease;
}
.cmds-title {
  font-size: .75rem; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .05em;
  padding: .35rem .6rem .2rem;
}
.cmd-item {
  background: transparent; border: none; border-radius: 8px;
  padding: .6rem .75rem; color: var(--text); font-size: .85rem;
  text-align: left; cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.cmd-item:hover { background: var(--bg3); color: var(--accent); }

/* ── New Keyframes ──────────────────────────────────────── */
@keyframes pulseAnim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.6; transform: scale(0.95); }
}
@keyframes dotBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-5px); }
}
@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes orbFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}
@keyframes orbWave {
  0%   { transform: scale(0.8); opacity: .8; border-width: 3px; }
  100% { transform: scale(2.2); opacity: 0; border-width: 1px; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .messages { padding: 1rem 0.75rem !important; }
  .msg-row { gap: 0.5rem; }
  .msg-bubble { max-width: 95% !important; padding: 0.85rem 1rem; font-size: 0.9rem; }
  .welcome-box { padding: 0; width: 100%; }
  .welcome-features { padding: 0.75rem !important; font-size: 0.8rem !important; margin-left: 0 !important; }
  .sidebar-backdrop {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 90; display: none;
  }
  .sidebar-backdrop.show { display: block; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
    box-shadow: 4px 0 30px rgba(0,0,0,.6);
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }
  .sidebar.collapsed {
    transform: translateX(-100%); width: var(--sidebar-w);
  }
  .sidebar.open {
    transform: translateX(0); width: var(--sidebar-w);
  }
  .quick-prompts { grid-template-columns: 1fr; }
  .profile-grid  { grid-template-columns: 1fr; }
  .msg-bubble    { max-width: 90%; }
}

/* ── Generated AI Images & Action Buttons ────────────────── */
.generated-img-card {
  margin: 1.1rem 0;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 12px 35px rgba(0,0,0,0.5);
  max-width: 520px;
  transition: border-color 0.25s ease;
}
.generated-img-card:hover {
  border-color: rgba(168,85,247,0.4);
}
.generated-img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform .35s ease;
}
.generated-img:hover {
  transform: scale(1.015);
}
.img-bottom-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
  padding: .65rem 1rem;
  background: rgba(15,15,18,0.85);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.img-alt-label {
  font-size: .83rem;
  color: var(--text2);
  font-weight: 500;
  display: flex; align-items: center; gap: 0.35rem;
}
.img-action-buttons {
  display: flex; align-items: center; gap: 0.5rem;
}
.img-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: #e2e8f0; font-size: 0.78rem; font-weight: 600;
  padding: 0.38rem 0.75rem; border-radius: 8px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.35rem;
  transition: all 0.2s ease; font-family: inherit;
}
.img-btn:hover {
  background: rgba(255,255,255,0.15); color: #fff;
  transform: translateY(-1px);
}
.img-btn.download-btn {
  background: linear-gradient(135deg, rgba(16,163,127,0.3), rgba(6,182,212,0.3));
  border-color: rgba(16,163,127,0.5);
  color: #34d399;
}
.img-btn.download-btn:hover {
  background: linear-gradient(135deg, rgba(16,163,127,0.5), rgba(6,182,212,0.5));
  color: #fff; border-color: #34d399;
}

/* ── Topbar Export Chat Button ───────────────────────────── */
.topbar-export-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(168,85,247,0.15);
  border: 1px solid rgba(168,85,247,0.35);
  color: #e879f9; font-size: 0.8rem; font-weight: 600;
  padding: 0.35rem 0.8rem; border-radius: 20px; cursor: pointer;
  transition: all 0.2s ease; font-family: inherit;
}
.topbar-export-btn:hover {
  background: rgba(168,85,247,0.3); color: #fff;
  box-shadow: 0 0 15px rgba(168,85,247,0.5);
  transform: translateY(-1px);
}

/* ── Blocked User Full Screen Overlay ────────────────────── */
.blocked-screen-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: radial-gradient(circle at center, rgba(30,10,20,0.95) 0%, rgba(10,10,14,0.98) 100%);
  backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
  animation: fadeUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.blocked-card {
  max-width: 520px; width: 100%;
  background: rgba(24, 15, 25, 0.85);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: 24px; padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0,0,0,0.8), 0 0 40px rgba(248, 113, 113, 0.15);
  display: flex; flex-direction: column; align-items: center; gap: 1.25rem;
}
.blocked-icon-box {
  width: 76px; height: 76px; border-radius: 50%;
  background: rgba(248, 113, 113, 0.12);
  border: 2px solid rgba(248, 113, 113, 0.4);
  display: flex; align-items: center; justify-content: center;
  color: #f87171;
  box-shadow: 0 0 25px rgba(248, 113, 113, 0.3);
}
.blocked-icon { width: 40px; height: 40px; }
.blocked-title {
  font-size: 1.6rem; font-weight: 700; color: #fff;
  margin: 0;
}
.blocked-msg {
  font-size: 0.95rem; color: #fca5a5; line-height: 1.6;
  background: rgba(248, 113, 113, 0.06);
  padding: 1rem 1.2rem; border-radius: 14px;
  border: 1px solid rgba(248, 113, 113, 0.15);
  margin: 0;
}
.blocked-instructions {
  font-size: 0.85rem; color: var(--text2); font-weight: 500; line-height: 1.4;
}
.blocked-admin-contacts {
  display: flex; flex-direction: column; gap: 0.75rem; width: 100%;
}
.btn-contact {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  padding: 0.85rem 1.2rem; border-radius: 14px;
  font-size: 0.9rem; font-weight: 600; text-decoration: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-telegram {
  background: linear-gradient(135deg, #0088cc, #005f8f);
  color: #fff; border: 1px solid rgba(0, 136, 204, 0.5);
  box-shadow: 0 4px 15px rgba(0, 136, 204, 0.3);
}
.btn-telegram:hover {
  background: linear-gradient(135deg, #0099e6, #0077b3);
  transform: translateY(-2px); box-shadow: 0 8px 25px rgba(0, 136, 204, 0.45);
}
.btn-email {
  background: rgba(255,255,255,0.06); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.15);
}
.btn-email:hover {
  background: rgba(255,255,255,0.12); color: #fff;
  border-color: rgba(255,255,255,0.3);
}
.blocked-footer-actions {
  margin-top: 0.5rem; width: 100%;
}
.blocked-footer-actions .btn-secondary { width: 100%; }

/* Typing Indicator */
.typing-indicator {
  display: flex; gap: 4px; align-items: center; justify-content: center; height: 24px;
}
.typing-indicator span {
  width: 6px; height: 6px; background: #fff; border-radius: 50%; opacity: 0.4;
  animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
/* Quick Actions / Commands Menu styling */
.cmds-popup-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: rgba(30, 30, 36, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.cmds-menu-header {
  width: 100%;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cmds-item {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.cmds-item:hover {
  background: rgba(255, 157, 0, 0.15);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 157, 0, 0.1);
}

.cmds-popup-menu.hidden {
  display: none !important;
}

/* ── Shop Card Animations ── */
@keyframes floatIcon {
  0%,100% { transform: translateY(0px) scale(1); }
  50%      { transform: translateY(-8px) scale(1.05); }
}

.shop-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  overflow: hidden;
  transition: transform 0.25s, box-shadow 0.25s;
}
.shop-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.5);
}
.shop-card-purchased {
  border-color: rgba(16,185,129,0.3) !important;
  background: rgba(16,185,129,0.04) !important;
}

