/* ============================================================
   Brainiall Chat — Glass+Gradient Design System
   ============================================================ */

/* --- Base & Variables --- */
:root {
  --bg-start: #0f0a1e;
  --bg-end: #1a0a2e;
  --glass-bg: rgba(255,255,255,0.03);
  --glass-border: rgba(255,255,255,0.08);
  --glass-blur: blur(10px);
  --accent-start: #8b5cf6;
  --accent-end: #06b6d4;
  --user-bg: linear-gradient(135deg, rgba(139,92,246,0.25), rgba(99,102,241,0.15));
  --user-border: rgba(139,92,246,0.2);
  --ai-bg: rgba(255,255,255,0.03);
  --ai-border: rgba(255,255,255,0.06);
  --radius-card: 14px;
  --radius-pill: 20px;
  --radius-msg: 14px;
  --radius-input: 14px;
  --sidebar-w: 220px;
  --topbar-h: 54px;
  /* Token scale (added Ciclo 168 — Gap #235) */
  --brn-text-primary: #fff;
  --brn-text-secondary: #a0a0b8;
  --brn-text-muted: #a1a1aa;
  --brn-border-light: #e2e8f0;
  --brn-border-muted: #a8a29e;
  --brn-surface-2: #1e1b36;
  --brn-purple-light: #c4b5fd;
  --brn-purple-accent: #a78bfa;
  --brn-red: #ef4444;
  --brn-green: #34d399;
  --brn-radius-xs: 4px;
  --brn-radius-sm: 6px;
  --brn-radius-md: 8px;
  --brn-radius-lg: 10px;
  --brn-radius-xl: 12px;
  --brn-radius-2xl: 16px;
  --brn-radius-round: 999px;

}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  color: #e2e8f0;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  -webkit-font-smoothing: antialiased;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-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.14); }

/* --- Glass Utility --- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
}

/* --- Gradient Utility --- */
.gradient-text {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gradient-bg {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
}

.gradient-border {
  position: relative;
}
.gradient-border::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* --- Buttons --- */
.btn-gradient {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 24px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-gradient:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(139,92,246,0.35);
}
.btn-gradient:active { transform: translateY(0); }

.btn-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: #e2e8f0;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 10px 24px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-glass:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.16);
  transform: translateY(-1px);
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-w);
  background: rgba(15,10,30,0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  top: 0; left: 0;
  z-index: 40;
  padding-left: env(safe-area-inset-left, 0);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-header .logo-icon {
  width: 30px; height: 30px;
  border-radius: var(--brn-radius-md);
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: #fff;
  flex-shrink: 0;
}
.sidebar-header .logo-text {
  font-weight: 700; font-size: 15px; color: #fff;
}

.new-chat-btn {
  margin: 12px;
  padding: 9px 0;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.2s, box-shadow 0.2s;
  width: calc(100% - 24px);
}
.new-chat-btn:hover {
  opacity: 0.9;
  box-shadow: 0 2px 12px rgba(139,92,246,0.3);
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.conv-item {
  padding: 9px 12px;
  border-radius: var(--brn-radius-lg);
  font-size: 13px;
  color: #a0a0b8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.conv-item:hover { background: rgba(255,255,255,0.05); color: #d0d0e0; }
.conv-item.active {
  background: rgba(139,92,246,0.15);
  color: #c4b5fd;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-footer .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-footer .user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-footer .user-email {
  font-size: 12px;
  color: #a0a0b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer .user-plan {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: var(--brn-radius-lg);
  background: rgba(139,92,246,0.2);
  color: #c4b5fd;
  display: inline-block;
  margin-top: 2px;
}
.sidebar-footer .logout-btn {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--brn-radius-sm);
  transition: color 0.2s, background 0.2s;
}
.sidebar-footer .logout-btn:hover {
  color: #ef4444;
  background: rgba(239,68,68,0.1);
}

/* --- Main Layout --- */
.main-area {
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  flex: 1;
}

/* --- Top Bar --- */
.topbar {
  height: var(--topbar-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(15,10,30,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-shrink: 0;
}

/* --- Mode Pills --- */
.mode-pills {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.04);
  padding: 3px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255,255,255,0.06);
}
.mode-pill {
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: #b4b4c7;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: transparent;
  white-space: nowrap;
}
.mode-pill:hover { color: #bbb; }
.mode-pill.active[data-mode="chat"] {
  background: rgba(139,92,246,0.3);
  color: #c4b5fd;
}
.mode-pill.active[data-mode="image"] {
  background: rgba(16,185,129,0.15);
  color: #34d399;
}
.mode-pill.active[data-mode="video"] {
  background: rgba(245,158,11,0.15);
  color: #fbbf24;
}

/* --- Model Selector --- */
.model-select {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--brn-radius-lg);
  color: #d0d0e0;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  min-width: 180px;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.model-select:hover { border-color: rgba(255,255,255,0.16); }
.model-select:focus { border-color: var(--accent-start); }
.model-select option { background: #1a0a2e; color: #e2e8f0; }

/* --- Messages Area --- */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
}
.messages-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

/* --- Message Bubbles --- */
.message {
  margin-bottom: 20px;
  animation: fadeIn 0.35s ease;
}
.message-user .bubble {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-radius: var(--radius-msg);
  padding: 12px 16px;
  max-width: 85%;
  margin-left: auto;
  font-size: 14px;
  line-height: 1.6;
}
.message-ai .bubble {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: var(--radius-msg);
  padding: 12px 16px;
  max-width: 85%;
  font-size: 14px;
  line-height: 1.6;
}
.message-ai .model-label {
  font-size: 11px;
  color: #a1a1aa;
  margin-bottom: 4px;
  font-weight: 500;
}

/* Markdown inside messages */
.bubble p { margin: 0 0 8px 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble strong { color: #f0f0f0; }
.bubble a { color: #8b5cf6; text-decoration: underline; }
.bubble a:hover { color: #a78bfa; }
.bubble code {
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: var(--brn-radius-xs);
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 13px;
}
.bubble pre {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--brn-radius-md);
  padding: 14px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 13px;
}
.bubble pre code {
  background: none;
  padding: 0;
  font-size: 13px;
}
.bubble ul, .bubble ol {
  margin: 4px 0;
  padding-left: 20px;
}
.bubble li { margin-bottom: 4px; }

/* --- Image in message --- */
.msg-image {
  max-width: 480px;
  border-radius: var(--brn-radius-xl);
  margin-top: 8px;
  cursor: pointer;
  transition: transform 0.2s;
  border: 1px solid rgba(255,255,255,0.06);
}
.msg-image:hover { transform: scale(1.02); }

/* --- Video in message --- */
.msg-video {
  max-width: 480px;
  border-radius: var(--brn-radius-xl);
  margin-top: 8px;
  border: 1px solid rgba(255,255,255,0.06);
}
.msg-video video {
  width: 100%;
  border-radius: var(--brn-radius-xl);
  display: block;
}

/* --- Video Progress --- */
.video-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.15);
  border-radius: var(--brn-radius-xl);
  margin-top: 8px;
}
.video-progress-text {
  font-size: 13px;
  color: #fbbf24;
}

/* --- Input Area --- */
.input-area {
  padding: 12px 20px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0));
  border-top: 1px solid var(--glass-border);
  background: rgba(15,10,30,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.input-wrapper {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-input);
  color: #e2e8f0;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  min-height: 46px;
  max-height: 200px;
  field-sizing: content;
}
.chat-input::placeholder { color: #9ca3af; }
.chat-input:focus { border-color: rgba(139,92,246,0.5); }

.send-btn {
  width: 46px;
  height: 46px;
  border: none;
  border-radius: var(--brn-radius-xl);
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  flex-shrink: 0;
}
.send-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 3px 14px rgba(139,92,246,0.35);
}
.send-btn:active { transform: translateY(0); }
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.send-btn svg { width: 20px; height: 20px; }

/* --- Welcome / Empty State --- */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px 20px;
}
.welcome-icon {
  width: 60px; height: 60px;
  border-radius: var(--brn-radius-2xl);
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: #fff;
  margin-bottom: 20px;
}
.welcome-title {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
}
.welcome-sub {
  font-size: 14px;
  color: #a1a1aa;
  max-width: 400px;
}

.welcome-prompts {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 640px;
}
.welcome-prompt {
  background: rgba(124, 58, 237, 0.06);
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: var(--brn-radius-xl);
  padding: 14px 14px 12px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font-family: inherit;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.welcome-prompt:hover {
  background: rgba(124, 58, 237, 0.12);
  border-color: rgba(124, 58, 237, 0.4);
  transform: translateY(-1px);
}
.welcome-prompt .wp-icon { font-size: 20px; line-height: 1; }
.welcome-prompt .wp-label { font-size: 13px; line-height: 1.35; color: #c4b5fd; font-weight: 500; }
html[data-theme="light"] .welcome-prompt .wp-label { color: #5b21b6; }

@media (max-width: 480px) {
  .welcome-prompts { grid-template-columns: repeat(2, 1fr); }
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

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

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

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.typing-indicator span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #8b5cf6;
  animation: typing 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.shimmer {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

/* --- Landing Page Specifics --- */

/* Hero */
.hero-gradient-text {
  background: linear-gradient(135deg, #fff 0%, #c4b5fd 30%, #8b5cf6 50%, #06b6d4 70%, #fff 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 6s ease infinite;
}

/* Model badges on landing */
.model-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #a0a0b8;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s;
}
.model-badge:hover {
  border-color: rgba(139,92,246,0.3);
  color: #c4b5fd;
}

/* Feature cards */
.feature-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--brn-radius-2xl);
  padding: 28px;
  transition: border-color 0.3s, transform 0.2s, box-shadow 0.3s;
}
.feature-card:hover {
  border-color: rgba(139,92,246,0.25);
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(139,92,246,0.08);
}
.feature-icon {
  width: 44px; height: 44px;
  border-radius: var(--brn-radius-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 16px;
}

/* Pricing cards */
.pricing-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--brn-radius-2xl);
  padding: 32px 24px;
  transition: border-color 0.3s, transform 0.2s, box-shadow 0.3s;
  position: relative;
}
.pricing-card:hover {
  border-color: rgba(139,92,246,0.3);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(139,92,246,0.1);
}
.pricing-card.popular {
  border-color: rgba(139,92,246,0.4);
  box-shadow: 0 0 30px rgba(139,92,246,0.12);
}
.pricing-card.popular::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 17px;
  padding: 1px;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
.popular-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 16px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pricing-price {
  font-size: 36px;
  font-weight: 800;
  color: #fff;
}
.pricing-price .currency { font-size: 18px; font-weight: 600; color: #a0a0b8; }
.pricing-price .period { font-size: 14px; font-weight: 400; color: #a1a1aa; }
.pricing-feature {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #a0a0b8;
  padding: 6px 0;
}
.pricing-feature .check {
  color: #8b5cf6;
  font-weight: 700;
  flex-shrink: 0;
}

/* --- Demo Chat Mockup --- */
.demo-chat {
  max-width: 560px;
  margin: 0 auto;
  border-radius: var(--brn-radius-2xl);
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  overflow: hidden;
}
.demo-topbar {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #b4b4c7;
}
.demo-messages {
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.demo-msg-user {
  background: var(--user-bg);
  border: 1px solid var(--user-border);
  border-radius: var(--brn-radius-xl);
  padding: 10px 14px;
  font-size: 13px;
  max-width: 80%;
  align-self: flex-end;
  animation: fadeIn 0.5s ease both;
}
.demo-msg-ai {
  background: var(--ai-bg);
  border: 1px solid var(--ai-border);
  border-radius: var(--brn-radius-xl);
  padding: 10px 14px;
  font-size: 13px;
  max-width: 80%;
  align-self: flex-start;
}
.demo-msg-ai.delay1 { animation: fadeIn 0.5s ease 0.8s both; }
.demo-msg-ai.delay2 { animation: fadeIn 0.5s ease 2.2s both; }
.demo-msg-ai.delay3 { animation: fadeIn 0.5s ease 3.6s both; }
.demo-msg-user.delay4 { animation: fadeIn 0.5s ease 5s both; }
.demo-msg-ai.delay5 { animation: fadeIn 0.5s ease 6s both; }
.demo-msg-user.delay6 { animation: fadeIn 0.5s ease 7.5s both; }
.demo-msg-ai.delay7 { animation: fadeIn 0.5s ease 8.5s both; }

.demo-image-placeholder {
  width: 200px;
  height: 140px;
  border-radius: var(--brn-radius-lg);
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(6,182,212,0.15));
  border: 1px solid rgba(16,185,129,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  font-size: 28px;
}

.demo-video-placeholder {
  width: 200px;
  height: 120px;
  border-radius: var(--brn-radius-lg);
  background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(239,68,68,0.1));
  border: 1px solid rgba(245,158,11,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  font-size: 28px;
  position: relative;
}
.demo-video-placeholder::after {
  content: '';
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  position: absolute;
}

/* --- Footer (landing) --- */
.landing-footer {
  border-top: 1px solid var(--glass-border);
  padding: 40px 20px;
  text-align: center;
}
.landing-footer a {
  color: #a1a1aa;
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s;
}
.landing-footer a:hover { color: #c4b5fd; }

/* --- Mobile Toggle --- */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: #e2e8f0;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--brn-radius-md);
  transition: background 0.2s;
}
.mobile-menu-btn:hover { background: rgba(255,255,255,0.06); }

/* --- Image Lightbox --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  cursor: pointer;
  animation: fadeIn 0.2s ease;
}
.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--brn-radius-xl);
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    width: 280px;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .main-area { margin-left: 0; }

  .mobile-menu-btn { display: flex; }

  .mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 35;
    display: none;
  }
  .mobile-overlay.show { display: block; }

  .messages-inner { padding: 0 12px; }

  .input-wrapper { padding: 0; }

  .message-user .bubble,
  .message-ai .bubble { max-width: 95%; }

  .model-select { min-width: 140px; }

  /* Landing page mobile */
  .landing-hero h1 { font-size: 32px !important; }
  .landing-features { grid-template-columns: 1fr !important; }
  .landing-pricing { grid-template-columns: 1fr !important; max-width: 360px; margin: 0 auto; }
  .model-badges { justify-content: center; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 10px; gap: 8px; }
  .mode-pill { padding: 8px 14px; font-size: 12px; min-height: 36px; }
  .model-select { min-width: 110px; font-size: 12px; min-height: 36px; }
  .chat-input { padding: 12px 14px; font-size: 16px; }
  .send-btn { width: 44px; height: 44px; }
  .new-chat-btn { padding: 12px 0; font-size: 14px; }
  .conv-item { padding: 12px; min-height: 44px; display: flex; align-items: center; }
}

/* =============================================================
   BRAINIALL CHAT POLISH — v20260416g
   ============================================================= */

/* --- Light theme override --- */
html[data-theme="light"] {
  --bg-start: #f5f3ff;
  --bg-end: #ecfeff;
  --glass-bg: rgba(255,255,255,0.5);
  --glass-border: rgba(0,0,0,0.08);
  --user-bg: linear-gradient(135deg, rgba(139,92,246,0.18), rgba(99,102,241,0.10));
  --user-border: rgba(139,92,246,0.25);
  --ai-bg: rgba(255,255,255,0.6);
  --ai-border: rgba(0,0,0,0.06);
}
html[data-theme="light"] body,
html[data-theme="light"] {
  color: #1e1b36;
  background: linear-gradient(135deg, #f5f3ff, #ecfeff) !important;
}
html[data-theme="light"] body {
  background: linear-gradient(135deg, #f5f3ff, #ecfeff) !important;
}
html[data-theme="light"] .sidebar { background: rgba(255,255,255,0.75); }
html[data-theme="light"] .topbar { background: rgba(255,255,255,0.7); }
html[data-theme="light"] .input-area { background: rgba(255,255,255,0.7); }
html[data-theme="light"] .chat-input {
  background: #fff;
  color: #1e1b36;
  border-color: rgba(0,0,0,0.12);
}
html[data-theme="light"] .chat-input::placeholder { color: #4b5563; }
html[data-theme="light"] .logo-text { color: #1e1b36; }
html[data-theme="light"] .conv-item { color: #57534e; }
html[data-theme="light"] .conv-item:hover { background: rgba(139,92,246,0.08); color: #1e1b36; }
html[data-theme="light"] .conv-item.active { background: rgba(139,92,246,0.15); color: #6d28d9; }
html[data-theme="light"] .welcome-title { color: #1e1b36; }
html[data-theme="light"] .welcome-sub { color: #525252; }
html[data-theme="light"] .bubble { color: #1e1b36; }
html[data-theme="light"] .bubble strong { color: #0f172a; }
html[data-theme="light"] .bubble code { background: rgba(0,0,0,0.06); color: #0f172a; }
html[data-theme="light"] .bubble pre { background: #0f172a; color: #e5e7eb; }
html[data-theme="light"] .model-select { background: #fff; color: #1e1b36; border-color: rgba(0,0,0,0.12); }
html[data-theme="light"] .model-select option { background: #fff; color: #1e1b36; }
html[data-theme="light"] .mode-pill { color: #525252; }
html[data-theme="light"] .mode-pill:hover { color: #1e1b36; }
html[data-theme="light"] .user-email { color: #57534e; }
html[data-theme="light"] .sidebar-footer .logout-btn { color: #4b5563; }
html[data-theme="light"] .x-search-input { background: #fff; color: #1e1b36; border-color: rgba(0,0,0,0.12); }
html[data-theme="light"] .x-advanced-panel { background: rgba(255,255,255,0.7); border-color: rgba(0,0,0,0.08); }
html[data-theme="light"] .x-chip { background: #fff; color: #57534e; border-color: rgba(0,0,0,0.1); }
html[data-theme="light"] .x-chip.active { color: #fff; }
html[data-theme="light"] .x-suggest-chip { background: rgba(255,255,255,0.85); color: #1e1b36; border-color: rgba(0,0,0,0.08); }
html[data-theme="light"] .x-ctx-menu { background: rgba(255,255,255,0.98); border-color: rgba(0,0,0,0.1); }
html[data-theme="light"] .x-ctx-item { color: #1e1b36; }
html[data-theme="light"] .x-ctx-item:hover { background: rgba(139,92,246,0.1); }
html[data-theme="light"] .x-modal { background: #fff; color: #1e1b36; border-color: rgba(0,0,0,0.08); }
html[data-theme="light"] kbd {
  background: #f3f4f6 !important; color: #0f172a !important; border-color: rgba(0,0,0,0.12) !important;
}

/* --- Search --- */
.x-search-wrap {
  position: relative;
  margin: 10px 12px 4px;
}
.x-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #525252;
  pointer-events: none;
}
.x-search-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--brn-radius-lg);
  color: #e2e8f0;
  padding: 8px 10px 8px 32px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.x-search-input:focus { border-color: rgba(139,92,246,0.5); }
.x-search-input::placeholder { color: #525252; }

/* --- Conv items: title + more button --- */
.conv-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.x-conv-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.x-conv-more {
  background: transparent;
  border: none;
  color: #525252;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--brn-radius-sm);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.conv-item:hover .x-conv-more { opacity: 1; }
.x-conv-more:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
@media (max-width: 768px) {
  .x-conv-more { opacity: 1; }
}
.x-conv-rename-input {
  flex: 1;
  background: rgba(139,92,246,0.15);
  border: 1px solid rgba(139,92,246,0.5);
  border-radius: var(--brn-radius-sm);
  color: #e2e8f0;
  padding: 2px 6px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}

/* --- Context menu --- */
.x-ctx-menu {
  position: fixed;
  z-index: 120;
  background: rgba(26,10,46,0.98);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--brn-radius-lg);
  padding: 4px;
  min-width: 160px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  animation: xFadeScale 0.12s ease;
}
@keyframes xFadeScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.x-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  color: #e2e8f0;
  padding: 8px 10px;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: var(--brn-radius-sm);
  transition: background 0.12s, color 0.12s;
}
.x-ctx-item:hover { background: rgba(139,92,246,0.2); }
.x-ctx-item.x-ctx-danger { color: #f87171; }
.x-ctx-item.x-ctx-danger:hover { background: rgba(239,68,68,0.12); color: #fca5a5; }

/* --- Suggested prompt chips --- */
.x-suggest-chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 28px;
  width: 100%;
  max-width: 760px;
  padding: 0 12px;
}
.x-suggest-chip {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255,255,255,0.035);
  border: 1px solid rgba(255,255,255,0.08);
  color: #d0d0e0;
  padding: 12px 14px;
  padding-right: 34px;
  border-radius: var(--brn-radius-xl);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, transform 0.12s, box-shadow 0.18s;
  font-family: inherit;
  text-align: left;
  overflow: hidden;
}
.x-suggest-chip:hover {
  border-color: rgba(139,92,246,0.45);
  background: rgba(139,92,246,0.08);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139,92,246,0.18);
}
.x-suggest-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--brn-radius-md);
  background: rgba(139,92,246,0.1);
  transition: background 0.2s, transform 0.2s;
}
.x-suggest-chip:hover .x-suggest-icon {
  background: rgba(139,92,246,0.2);
  transform: rotate(-3deg) scale(1.05);
}
.x-suggest-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}
.x-suggest-title {
  font-size: 13px;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.x-suggest-desc {
  font-size: 11px;
  color: #4b5563;
  line-height: 1.3;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-2px);
  transition: max-height 0.22s ease, opacity 0.18s ease, transform 0.22s ease;
}
.x-suggest-chip:hover .x-suggest-desc,
.x-suggest-chip:focus-visible .x-suggest-desc {
  max-height: 2em;
  opacity: 1;
  transform: translateY(0);
}
.x-suggest-link {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--brn-radius-sm);
  color: #8b5cf6;
  background: rgba(139,92,246,0.08);
  border: 1px solid rgba(139,92,246,0.2);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.18s, transform 0.18s, background 0.18s;
  text-decoration: none;
  pointer-events: none;
}
.x-suggest-chip:hover .x-suggest-link,
.x-suggest-chip:focus-visible .x-suggest-link {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.x-suggest-link:hover {
  background: rgba(139,92,246,0.2);
  color: #c4b5fd;
}

/* Owner badge */
.x-plan-owner {
  background: linear-gradient(135deg, #f59e0b, #ef4444) !important;
  color: #fff !important;
  font-weight: 700 !important;
  letter-spacing: 0.5px;
  padding: 2px 10px !important;
  font-size: 10px !important;
}

/* --- Advanced panels --- */
.x-advanced-panel {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
  border-top: 1px solid var(--glass-border);
  background: rgba(255,255,255,0.02);
}
.x-adv-toggle {
  background: transparent;
  border: none;
  color: #a0a0b8;
  font-size: 12px;
  font-weight: 500;
  padding: 10px 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-family: inherit;
  transition: color 0.15s;
}
.x-adv-toggle:hover { color: #c4b5fd; }
.x-chev { transition: transform 0.2s; }
.x-adv-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.x-advanced-panel.open .x-adv-body {
  padding: 4px 0 14px;
}
.x-adv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 12px;
  flex-wrap: wrap;
}
.x-adv-row label {
  min-width: 90px;
  color: #a0a0b8;
  font-weight: 500;
}
.x-adv-row.x-adv-full { flex-direction: column; align-items: stretch; }
.x-adv-row.x-adv-full label { margin-bottom: 4px; }
.x-chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.x-chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #a0a0b8;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: var(--brn-radius-lg);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.x-chip:hover { border-color: rgba(139,92,246,0.4); color: #c4b5fd; }
.x-chip.active {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  border-color: transparent;
}
.x-adv-input, .x-adv-textarea {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--brn-radius-md);
  color: #e2e8f0;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s;
}
.x-adv-input:focus, .x-adv-textarea:focus { border-color: rgba(139,92,246,0.5); }

/* --- Stop button state --- */
.send-btn.x-stop {
  background: linear-gradient(135deg, #ef4444, #f97316);
}
.send-btn.x-stop:hover {
  box-shadow: 0 3px 14px rgba(239,68,68,0.4);
}

/* --- AI message actions (copy + regenerate) --- */
.x-ai-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.15s;
}
.message-ai:hover .x-ai-actions { opacity: 1; }
.x-ai-action {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.06);
  color: #525252;
  padding: 4px 8px;
  border-radius: var(--brn-radius-sm);
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.x-ai-action:hover { color: #c4b5fd; border-color: rgba(139,92,246,0.3); background: rgba(139,92,246,0.08); }

/* --- Interrupted tag --- */
.x-interrupted {
  display: inline-block;
  margin-top: 4px;
  color: #f59e0b;
  font-size: 12px;
  font-style: italic;
}

/* --- Improved typing indicator --- */
@keyframes typingPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}
.x-typing span { animation: typingPulse 1.2s infinite ease-in-out; }
.x-typing span:nth-child(2) { animation-delay: 0.18s; }
.x-typing span:nth-child(3) { animation-delay: 0.36s; }

/* --- Code block copy button --- */
.x-pre {
  position: relative;
}
.x-copy-code {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #a0a0b8;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--brn-radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s;
  font-family: inherit;
}
.bubble pre:hover .x-copy-code { opacity: 1; }
.x-copy-code:hover { color: #c4b5fd; background: rgba(139,92,246,0.12); }

/* --- Markdown tables --- */
.x-md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}
.x-md-table th, .x-md-table td {
  border: 1px solid rgba(255,255,255,0.08);
  padding: 6px 10px;
  text-align: left;
}
.x-md-table th { background: rgba(255,255,255,0.04); font-weight: 600; }

/* Headings inside bubble */
.bubble h1, .bubble h2, .bubble h3 {
  font-weight: 700;
  margin: 12px 0 6px;
  color: #fff;
}
.bubble h1 { font-size: 20px; }
.bubble h2 { font-size: 17px; }
.bubble h3 { font-size: 15px; }

/* --- Model avatar --- */
.x-model-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.x-model-avatar {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* --- Timestamps & token badge --- */
.x-msg-time {
  font-size: 10px;
  color: #525252;
  margin-top: 6px;
  cursor: help;
}
.x-token-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--brn-radius-lg);
  font-size: 10px;
  color: #525252;
}

/* --- Image grid + actions --- */
.x-image-grid {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.x-image-grid-1 { grid-template-columns: 1fr; }
.x-image-grid-2 { grid-template-columns: 1fr 1fr; }
.x-image-grid-3 { grid-template-columns: repeat(3, 1fr); }
.x-image-grid-4 { grid-template-columns: 1fr 1fr; }
.x-image-wrap {
  position: relative;
  display: inline-block;
}
.x-image-overlay {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.x-image-wrap:hover .x-image-overlay { opacity: 1; }
.x-img-action {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 6px;
  border-radius: var(--brn-radius-md);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.x-img-action:hover { background: rgba(139,92,246,0.6); }
.x-image-regen {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  color: #a0a0b8;
  padding: 4px 10px;
  border-radius: var(--brn-radius-md);
  cursor: pointer;
  font-size: 11px;
  margin-top: 6px;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
}
.x-image-regen:hover { color: #c4b5fd; border-color: rgba(139,92,246,0.3); }

/* --- Video wrap + actions --- */
.x-video-wrap { position: relative; }
.x-video-actions {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.x-video-wrap:hover .x-video-actions { opacity: 1; }
.x-video-action {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 6px;
  border-radius: var(--brn-radius-md);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.x-video-action:hover { background: rgba(139,92,246,0.6); }

/* --- Video progress (improved) --- */
.x-video-progress {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.x-video-progress .spinner { flex-shrink: 0; margin-top: 2px; }
.x-vp-content { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.x-vp-text { font-size: 13px; color: #fbbf24; }
.x-vp-bar {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.x-vp-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  transition: width 0.35s ease;
  border-radius: 3px;
}
.x-vp-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #a0a0b8;
}

/* --- Lightbox polish --- */
.x-lightbox-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 94vw;
  max-height: 94vh;
}
.x-lightbox-box img {
  max-width: 90vw;
  max-height: 82vh;
  border-radius: var(--brn-radius-xl);
  object-fit: contain;
}
.x-lightbox-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  padding: 8px 14px;
  border-radius: var(--brn-radius-xl);
  max-width: 90vw;
}
.x-lightbox-caption {
  color: #e2e8f0;
  font-size: 12px;
  max-width: 500px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.x-lightbox-btn {
  background: rgba(139,92,246,0.3);
  color: #fff;
  border: 1px solid rgba(139,92,246,0.4);
  padding: 6px 12px;
  border-radius: var(--brn-radius-md);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}
.x-lightbox-btn:hover { background: rgba(139,92,246,0.45); }
.x-lightbox-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.x-lightbox-close:hover { background: rgba(239,68,68,0.6); }

/* --- Toasts --- */
.x-toast-stack {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.x-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--brn-radius-lg);
  background: rgba(26,10,46,0.96);
  backdrop-filter: blur(12px);
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: xSlideIn 0.2s ease;
  font-size: 13px;
}
@keyframes xSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.x-toast-msg { flex: 1; }
.x-toast-error { border-color: rgba(239,68,68,0.4); }
.x-toast-error .x-toast-msg { color: #fca5a5; }
.x-toast-success { border-color: rgba(34,197,94,0.4); }
.x-toast-success .x-toast-msg { color: #86efac; }
.x-toast-confirm { border-color: rgba(245,158,11,0.4); }
.x-toast-close {
  background: transparent;
  border: none;
  color: #525252;
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}
.x-toast-close:hover { color: #e2e8f0; }
.x-toast-action {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: var(--brn-radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
}
.x-toast-action:hover { opacity: 0.9; }

/* --- Modals --- */
.x-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: fadeIn 0.15s ease;
}
.x-modal {
  background: rgba(26,10,46,0.98);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--brn-radius-2xl);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  color: #e2e8f0;
}
.x-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.x-modal-header h3 { margin: 0; font-size: 16px; font-weight: 600; }
.x-modal-close {
  background: transparent;
  border: none;
  color: #525252;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}
.x-modal-close:hover { color: #e2e8f0; }
.x-kbd-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.x-kbd-row span { color: #a0a0b8; }
.x-modal kbd {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 11px;
  color: #e2e8f0;
  margin-left: 4px;
}

/* --- Token budget (sidebar footer) --- */
.x-msg-budget {
  padding: 8px 12px;
  border-top: 1px solid var(--glass-border);
}
.x-msg-budget-label {
  font-size: 10px;
  color: #525252;
  margin-bottom: 4px;
}
.x-msg-budget-track {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.x-msg-budget-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
  transition: width 0.3s ease;
}
.x-msg-budget-fill.near-limit {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
}

/* --- Theme toggle --- */
.x-theme-btn {
  margin-right: 4px;
}

/* --- Memory button (sidebar footer) --- */
.x-memory-btn {
  margin-right: 2px;
}
.x-memory-btn:hover {
  color: #c4b5fd !important;
  background: rgba(139, 92, 246, 0.12) !important;
}

/* --- Memory modal --- */
.x-memory-modal {
  max-width: 540px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  display: flex;
  flex-direction: column;
}
.x-memory-modal .x-modal-body {
  overflow-y: auto;
  padding-right: 4px;
}
.x-memory-intro {
  color: #a0a0b8;
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 14px;
}
.x-memory-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--brn-radius-lg);
  font-size: 13px;
  color: #e5e7eb;
  cursor: pointer;
  margin-bottom: 10px;
}
.x-memory-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.x-memory-slider {
  position: relative;
  width: 38px;
  height: 20px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--brn-radius-round);
  transition: background 0.2s;
  flex-shrink: 0;
}
.x-memory-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.x-memory-toggle input:checked + .x-memory-slider {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
}
.x-memory-toggle input:checked + .x-memory-slider::after {
  transform: translateX(18px);
}
.x-memory-count {
  font-size: 11px;
  color: #4b5563;
  margin-bottom: 12px;
  text-align: right;
}
.x-memory-add-row {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.x-memory-add-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
  padding: 10px 12px;
  border-radius: var(--brn-radius-md);
  font-size: 13px;
  outline: none;
}
.x-memory-add-input:focus {
  border-color: rgba(139, 92, 246, 0.5);
}
.x-memory-add-btn {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  border: none;
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--brn-radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.x-memory-add-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.x-memory-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}
.x-memory-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--brn-radius-md);
  transition: background 0.15s;
}
.x-memory-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.x-memory-item.pinned {
  background: rgba(139, 92, 246, 0.08);
  border-color: rgba(139, 92, 246, 0.25);
}
.x-memory-item-text {
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
  color: #e5e7eb;
  word-break: break-word;
}
.x-memory-item-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.x-memory-icon-btn {
  background: transparent;
  border: none;
  color: #4b5563;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--brn-radius-sm);
  font-size: 13px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.x-memory-icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
}
.x-memory-icon-btn.x-memory-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}
.x-memory-empty {
  text-align: center;
  color: #4b5563;
  font-size: 12px;
  padding: 16px 8px;
  line-height: 1.5;
}
.x-memory-edit-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #e5e7eb;
  padding: 6px 8px;
  border-radius: var(--brn-radius-sm);
  font-size: 13px;
  outline: none;
  margin-bottom: 6px;
}
.x-memory-save, .x-memory-cancel {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e5e7eb;
  padding: 4px 10px;
  border-radius: var(--brn-radius-sm);
  font-size: 11px;
  cursor: pointer;
  margin-right: 4px;
}
.x-memory-save {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  border-color: transparent;
}
.x-memory-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 12px;
}
.x-memory-danger {
  width: 100%;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  padding: 10px;
  border-radius: var(--brn-radius-md);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
}
.x-memory-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}
.x-memory-lgpd {
  color: #525252;
  font-size: 11px;
  line-height: 1.5;
  margin: 0;
  text-align: center;
}

/* Light theme overrides — memory modal */
html[data-theme="light"] .x-memory-intro { color: #57534e; }
html[data-theme="light"] .x-memory-toggle { background: #f9fafb; border-color: rgba(0, 0, 0, 0.08); color: #1e1b36; }
html[data-theme="light"] .x-memory-slider { background: rgba(0, 0, 0, 0.12); }
html[data-theme="light"] .x-memory-count { color: #525252; }
html[data-theme="light"] .x-memory-add-input { background: #fff; border-color: rgba(0, 0, 0, 0.12); color: #1e1b36; }
html[data-theme="light"] .x-memory-item { background: #f9fafb; border-color: rgba(0, 0, 0, 0.06); }
html[data-theme="light"] .x-memory-item:hover { background: #f3f4f6; }
html[data-theme="light"] .x-memory-item.pinned { background: rgba(139, 92, 246, 0.06); border-color: rgba(139, 92, 246, 0.25); }
html[data-theme="light"] .x-memory-item-text { color: #1e1b36; }
html[data-theme="light"] .x-memory-icon-btn { color: #525252; }
html[data-theme="light"] .x-memory-icon-btn:hover { background: rgba(0, 0, 0, 0.05); color: #1e1b36; }
html[data-theme="light"] .x-memory-empty { color: #525252; }
html[data-theme="light"] .x-memory-edit-input { background: #fff; color: #1e1b36; }
html[data-theme="light"] .x-memory-footer { border-top-color: rgba(0, 0, 0, 0.06); }
html[data-theme="light"] .x-memory-lgpd { color: #4b5563; }

/* --- Responsive tweaks --- */
@media (max-width: 480px) {
  .x-suggest-chips { grid-template-columns: 1fr; gap: 8px; padding: 0 8px; }
  .x-suggest-chip { padding: 10px 12px; padding-right: 34px; }
  .x-suggest-icon { width: 28px; height: 28px; font-size: 18px; }
  .x-suggest-title { font-size: 13px; white-space: normal; }
  .x-suggest-desc { max-height: 2em; opacity: 0.7; transform: none; }
  .x-suggest-link { opacity: 1; pointer-events: auto; transform: none; }
  .x-advanced-panel { padding: 0 12px; }
  .x-ai-actions { opacity: 1; }
  .x-image-overlay, .x-video-actions { opacity: 1; }
  .x-image-grid-3, .x-image-grid-4 { grid-template-columns: 1fr 1fr; }
}

/* =============================================================
   FILE UPLOAD — v20260416k
   ============================================================= */

/* Paperclip button — mirrors send-btn sizing with a glass (non-gradient)
   treatment so the CTA still visually wins. */
.x-upload-btn {
  width: 46px;
  height: 46px;
  border: 1px solid var(--glass-border);
  border-radius: var(--brn-radius-xl);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  flex-shrink: 0;
}
.x-upload-btn:hover {
  color: #fff;
  border-color: rgba(139,92,246,0.45);
  background: rgba(139,92,246,0.12);
}
.x-upload-btn:active { transform: translateY(1px); }
.x-upload-btn svg { width: 20px; height: 20px; }

html[data-theme="light"] .x-upload-btn {
  background: #fff;
  border-color: rgba(0,0,0,0.12);
  color: #57534e;
}
html[data-theme="light"] .x-upload-btn:hover {
  background: rgba(139,92,246,0.08);
  color: #6d28d9;
}

/* Pill strip above the textarea */
.x-attachments {
  max-width: 760px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0;
}

.x-attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 10px;
  border-radius: var(--radius-pill);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  font-size: 13px;
  line-height: 1.2;
  color: #e2e8f0;
  max-width: 280px;
  transition: border-color 0.2s, background 0.2s;
}
.x-attachment-pill.x-pill-ready {
  border-color: rgba(16,185,129,0.35);
  background: rgba(16,185,129,0.08);
}
.x-attachment-pill.x-pill-error {
  border-color: rgba(239,68,68,0.45);
  background: rgba(239,68,68,0.08);
}
.x-attachment-pill.x-pill-uploading {
  border-color: rgba(139,92,246,0.35);
  background: rgba(139,92,246,0.08);
}

.x-pill-icon {
  flex-shrink: 0;
  color: #a78bfa;
}
.x-pill-ready .x-pill-icon { color: #34d399; }
.x-pill-error .x-pill-icon { color: #ef4444; }

.x-pill-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
  font-weight: 500;
}
.x-pill-size {
  color: #4b5563;
  font-size: 11px;
  flex-shrink: 0;
}
.x-pill-ok {
  color: #34d399;
  font-weight: 700;
  font-size: 14px;
}

/* OCR badge — shown on scanned PDFs that needed tesseract fallback.
   Small, muted amber so the user knows text may be imperfect but the pill
   itself stays visually calm. */
.x-pill-ocr {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--brn-radius-xs);
  background: rgba(245, 158, 11, 0.14);
  color: #f59e0b;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.4;
  flex-shrink: 0;
}

.x-pill-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(139,92,246,0.25);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: xPillSpin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes xPillSpin { to { transform: rotate(360deg); } }

.x-pill-retry {
  background: transparent;
  border: 1px solid rgba(239,68,68,0.5);
  color: #ef4444;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  transition: background 0.2s, color 0.2s;
}
.x-pill-retry:hover { background: rgba(239,68,68,0.15); color: #fca5a5; }

.x-pill-x {
  background: transparent;
  border: none;
  color: #4b5563;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  transition: color 0.2s, background 0.2s;
}
.x-pill-x:hover { color: #fff; background: rgba(255,255,255,0.1); }

html[data-theme="light"] .x-attachment-pill { color: #1e1b36; }
html[data-theme="light"] .x-pill-x { color: #525252; }
html[data-theme="light"] .x-pill-x:hover { color: #1e1b36; background: rgba(0,0,0,0.06); }

/* Drop zone overlay — full-viewport, backdrop-blurred, dashed purple
   border, centered icon+text. Lives above everything except the
   impersonation banner. */
.x-drop-zone {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15,10,30,0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
  animation: xDropZoneIn 0.15s ease-out;
}
.x-drop-zone-inner {
  border: 2px dashed rgba(139,92,246,0.7);
  border-radius: 22px;
  padding: 48px 72px;
  background: rgba(139,92,246,0.08);
  text-align: center;
  color: #fff;
  box-shadow: 0 12px 48px rgba(139,92,246,0.25);
  max-width: 90vw;
}
.x-drop-zone-inner svg {
  color: #a78bfa;
  margin-bottom: 12px;
}
.x-drop-zone-text {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.x-drop-zone-sub {
  margin-top: 6px;
  font-size: 13px;
  color: #cbd5e1;
}
@keyframes xDropZoneIn {
  from { opacity: 0; transform: scale(0.985); }
  to   { opacity: 1; transform: scale(1); }
}

html[data-theme="light"] .x-drop-zone { background: rgba(245,243,255,0.85); }
html[data-theme="light"] .x-drop-zone-inner {
  background: rgba(139,92,246,0.1);
  color: #1e1b36;
}
html[data-theme="light"] .x-drop-zone-sub { color: #57534e; }

/* Mobile tweaks */
@media (max-width: 480px) {
  .x-upload-btn { width: 44px; height: 44px; }
  .x-upload-btn svg { width: 18px; height: 18px; }
  .x-attachment-pill { max-width: 100%; font-size: 12px; padding: 5px 8px; }
  .x-pill-name { max-width: 120px; }
  .x-drop-zone-inner { padding: 32px 28px; }
  .x-drop-zone-text { font-size: 16px; }
  .x-drop-zone-sub { font-size: 12px; }
}

/* =============================================================
   Voice (STT + TTS) — mic button, recording pulse, speak button
   ============================================================= */

/* Screen-reader-only live region for aria-live announcements. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Mic button — mirrors .x-upload-btn glass treatment. */
.x-mic-btn {
  width: 46px;
  height: 46px;
  border: 1px solid var(--glass-border);
  border-radius: var(--brn-radius-xl);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.x-mic-btn:hover {
  color: #fff;
  border-color: rgba(139,92,246,0.45);
  background: rgba(139,92,246,0.12);
}
.x-mic-btn:active { transform: translateY(1px); }
.x-mic-btn svg { width: 20px; height: 20px; }
.x-mic-btn[disabled], .x-mic-btn.x-mic-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.x-mic-timer {
  display: none;
  font-size: 11px;
  font-weight: 600;
  color: #ef4444;
  min-width: 28px;
}

/* Recording state: red pulsing border + red mic + visible timer. */
.x-mic-btn.recording {
  border-color: rgba(239,68,68,0.9);
  background: rgba(239,68,68,0.1);
  color: #ef4444;
  animation: micPulse 1.1s ease-in-out infinite;
  width: auto;
  min-width: 64px;
  padding: 0 10px;
}
.x-mic-btn.recording .x-mic-timer { display: inline-block; }
.x-mic-btn.x-mic-busy { opacity: 0.7; cursor: wait; }

@keyframes micPulse {
  0%   { box-shadow: 0 0 0 0 rgba(239,68,68,0.55); opacity: 1; }
  50%  { box-shadow: 0 0 0 6px rgba(239,68,68,0.0); opacity: 0.7; }
  100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.0); opacity: 1; }
}

html[data-theme="light"] .x-mic-btn {
  background: #fff;
  border-color: rgba(0,0,0,0.12);
  color: #57534e;
}
html[data-theme="light"] .x-mic-btn:hover {
  background: rgba(139,92,246,0.08);
  color: #6d28d9;
}

/* Speak (TTS) button on AI bubbles — keeps the .x-ai-action layout. */
.x-speak-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.06);
  color: #525252;
  padding: 4px 8px;
  border-radius: var(--brn-radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  position: relative;
}
.x-speak-btn:hover {
  color: #c4b5fd;
  border-color: rgba(139,92,246,0.3);
  background: rgba(139,92,246,0.08);
}
.x-speak-btn[disabled] { opacity: 0.6; cursor: wait; }
.x-speak-btn.x-speak-playing { color: #a78bfa; border-color: rgba(139,92,246,0.5); }
.x-speak-btn.x-speak-loading svg { animation: spkSpin 1s linear infinite; }
@keyframes spkSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.x-speak-caret {
  font-size: 10px;
  line-height: 1;
  color: inherit;
  padding: 2px 4px;
  margin-left: 1px;
  border-radius: var(--brn-radius-xs);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
}
.x-speak-caret:hover { background: rgba(139,92,246,0.1); }

/* Voice picker dropdown. */
.x-voice-picker {
  position: absolute;
  z-index: 9500;
  min-width: 140px;
  background: rgba(18,12,38,0.96);
  border: 1px solid rgba(139,92,246,0.25);
  border-radius: var(--brn-radius-lg);
  padding: 4px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
html[data-theme="light"] .x-voice-picker {
  background: #fff;
  border-color: rgba(0,0,0,0.1);
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}
.x-voice-picker button {
  background: transparent;
  border: 0;
  color: #e2e8f0;
  padding: 7px 10px;
  border-radius: var(--brn-radius-sm);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
html[data-theme="light"] .x-voice-picker button { color: #1f2937; }
.x-voice-picker button:hover { background: rgba(139,92,246,0.14); }
.x-voice-picker button[data-active="true"] { color: #a78bfa; font-weight: 600; }
.x-voice-picker .x-voice-check { font-size: 12px; opacity: 0.9; }

@media (max-width: 480px) {
  .x-mic-btn { width: 44px; height: 44px; }
  .x-mic-btn svg { width: 18px; height: 18px; }
  .x-mic-btn.recording { width: auto; min-width: 60px; }
}


/* --- Memory suggestions + search + voice-picker groups (Sprint 5b) --- */
.x-memory-suggested-banner {
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-radius: var(--brn-radius-xl);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.x-memory-suggestion {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
}
.x-memory-suggestion:first-of-type { border-top: none; }
.x-mem-approve, .x-mem-reject {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #d0d0e0;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.12s, background 0.15s;
}
.x-mem-approve { color: #34d399; border-color: rgba(52, 211, 153, 0.3); }
.x-mem-approve:hover { background: rgba(52, 211, 153, 0.15); transform: scale(1.08); }
.x-mem-reject { color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }
.x-mem-reject:hover { background: rgba(239, 68, 68, 0.15); transform: scale(1.08); }

.x-memory-search {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
  padding: 8px 12px;
  border-radius: var(--brn-radius-lg);
  font-size: 13px;
  margin-bottom: 10px;
}
.x-memory-search:focus { border-color: rgba(139, 92, 246, 0.5); outline: none; }

/* Voice picker language groups */
.x-voice-group-header {
  font-size: 11px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 4px;
}
.x-voice-group-header:first-of-type { border-top: none; margin-top: 0; }
.x-voice-native {
  display: inline-block;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: var(--brn-radius-xs);
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-left: 4px;
  vertical-align: middle;
}

/* ============================================================
   Gallery modal + lightbox (SOTA visual library)
   ============================================================ */
.x-gallery-modal {
  width: min(1100px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.x-gallery-modal .x-modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.x-gallery-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.x-gallery-filters {
  display: inline-flex;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--brn-radius-round);
  padding: 3px;
  gap: 2px;
}
.x-gallery-tab {
  padding: 6px 16px;
  border: none;
  background: transparent;
  color: #4b5563;
  border-radius: var(--brn-radius-round);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.x-gallery-tab.active {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  color: #fff;
  font-weight: 600;
}
.x-gallery-tab:hover:not(.active) { color: #fff; }
.x-gallery-count { font-size: 12px; color: #525252; }

.x-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 200px;
}
.x-gallery-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--brn-radius-xl);
  overflow: hidden;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}
.x-gallery-card:hover {
  transform: translateY(-2px);
  border-color: rgba(139,92,246,0.4);
}
.x-gallery-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.x-gallery-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: var(--brn-radius-xs);
  background: rgba(0,0,0,0.6);
  color: #fff;
  backdrop-filter: blur(6px);
}
.x-gallery-sentinel {
  padding: 14px;
  text-align: center;
  color: #525252;
  font-size: 12px;
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.04);
  cursor: default;
}
.x-gallery-empty {
  text-align: center;
  padding: 40px 20px;
  color: #4b5563;
  font-size: 14px;
}
.x-gallery-empty a { color: #c4b5fd; font-weight: 600; }

/* Lightbox */
.x-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.92);
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
}
.x-lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  overflow: hidden;
}
.x-lightbox-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--brn-radius-lg);
  box-shadow: 0 12px 48px rgba(0,0,0,0.4);
}
.x-lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 24px;
  border-radius: 50%;
  cursor: pointer;
  backdrop-filter: blur(8px);
  z-index: 2;
}
.x-lightbox-meta {
  background: #0f0a1e;
  border-left: 1px solid rgba(255,255,255,0.06);
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.x-lightbox-label { font-size: 11px; color: #525252; text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 6px; }
.x-lightbox-text { color: #e5e7eb; font-size: 13px; line-height: 1.55; word-break: break-word; }
.x-lightbox-submeta { display: flex; flex-wrap: wrap; gap: 6px; }
.x-chip-tag {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(139,92,246,0.12);
  color: #c4b5fd;
  border-radius: var(--brn-radius-round);
  font-size: 11px;
  font-weight: 600;
}
.x-lightbox-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}
.x-lb-btn {
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  color: #e5e7eb;
  border-radius: var(--brn-radius-lg);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
}
.x-lb-btn:hover { background: rgba(255,255,255,0.1); }
.x-lb-danger { color: #fca5a5; }
.x-lb-danger:hover { background: rgba(239,68,68,0.08); }

@media (max-width: 720px) {
  .x-lightbox-overlay { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .x-lightbox-meta { border-left: none; border-top: 1px solid rgba(255,255,255,0.06); max-height: 40vh; }
  .x-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 14px; gap: 8px; }
}

/* ============================================================
   Reference image uploader (img2img + i2v)
   ============================================================ */
.x-ref-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(139,92,246,0.04);
  border: 1px dashed rgba(139,92,246,0.3);
  border-radius: var(--brn-radius-lg);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.x-ref-upload:hover, .x-ref-upload.dragging {
  background: rgba(139,92,246,0.1);
  border-color: rgba(139,92,246,0.5);
}
.x-ref-upload-hint {
  flex: 1;
  font-size: 12px;
  color: #a0a0b8;
}
.x-ref-preview {
  position: relative;
  flex-shrink: 0;
}
.x-ref-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--brn-radius-md);
  border: 1px solid rgba(255,255,255,0.08);
}
.x-ref-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ============================================================
   Model comparator (grid side-by-side)
   ============================================================ */
.x-compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(6,182,212,0.08);
  border: 1px solid rgba(6,182,212,0.2);
  border-radius: var(--brn-radius-md);
  color: #67e8f9;
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 8px;
}
.x-compare-toggle input[type=checkbox] {
  accent-color: #06b6d4;
}
.x-compare-panel {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.x-compare-panel select {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  color: #e5e7eb;
  padding: 6px 10px;
  border-radius: var(--brn-radius-md);
  font-size: 12px;
}
.x-compare-result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.x-compare-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.x-compare-col .x-compare-label {
  font-size: 11px;
  color: #c4b5fd;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.x-compare-col img, .x-compare-col video {
  width: 100%;
  border-radius: var(--brn-radius-lg);
  border: 1px solid rgba(255,255,255,0.06);
}

/* ============================================================
   RTL support (Arabic, Hebrew, Farsi, Urdu)
   ============================================================
   Enabled automatically by i18n.js setting document.documentElement.dir.
   We flip sidebar, mirror flex rows, and align text where needed.
   CSS logical props (margin-inline-*, padding-inline-*) would be better
   but this codebase still uses margin-left/right. RTL overrides fix those. */

[dir="rtl"] { text-align: right; }
[dir="rtl"] .sidebar { right: 0; left: auto; transform: translateX(100%); border-right: none; border-left: 1px solid var(--glass-border); }
[dir="rtl"] .sidebar.open { transform: translateX(0); }
[dir="rtl"] .main-area { margin-left: 0; margin-right: var(--sidebar-w); }
[dir="rtl"] .topbar { flex-direction: row-reverse; }
[dir="rtl"] .x-modal-header { flex-direction: row-reverse; }
[dir="rtl"] .x-modal-close { margin-left: 0; margin-right: auto; }
[dir="rtl"] .x-attachments { direction: rtl; }
[dir="rtl"] .sidebar-footer { flex-direction: row-reverse; }
[dir="rtl"] .message-user { align-self: flex-start; }
[dir="rtl"] .message-ai { align-self: flex-end; }
[dir="rtl"] .x-toast { right: auto; left: 16px; }
[dir="rtl"] .x-chip-group { flex-direction: row-reverse; }
[dir="rtl"] .x-gallery-filters { flex-direction: row-reverse; }
[dir="rtl"] .x-gallery-card-badge { right: auto; left: 8px; }
[dir="rtl"] .academy-nav { flex-direction: row-reverse; }
[dir="rtl"] .studio-nav { flex-direction: row-reverse; }
[dir="rtl"] .studio-hero { direction: rtl; }
[dir="rtl"] .studio-footer { flex-direction: row-reverse; }
[dir="rtl"] .x-memory-toggle, [dir="rtl"] .x-memory-toggle span { direction: rtl; }
[dir="rtl"] .x-lightbox-overlay { grid-template-columns: 320px 1fr; }
[dir="rtl"] .x-lightbox-meta { border-left: none; border-right: 1px solid rgba(255,255,255,0.06); }

/* Mobile RTL tweaks */
@media (max-width: 768px) {
  [dir="rtl"] .main-area { margin-right: 0; }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  [dir="rtl"] .x-toast { left: 8px; right: 8px; }
  [dir="rtl"] .x-lightbox-overlay { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
}

/* Mobile tablet polish (<=480px) */
@media (max-width: 480px) {
  .x-modal { width: 95vw; max-width: 95vw; max-height: 92vh; padding: 14px; }
  .x-modal-header h3 { font-size: 16px; }
  .x-memory-toggle { padding: 8px; font-size: 12px; }
  .btn-gradient, .btn-glass { padding: 8px 16px; font-size: 13px; }
  .mode-pill { padding: 6px 10px; font-size: 12px; }
  .x-chip { padding: 4px 10px; font-size: 11px; }
  .input-wrapper { padding: 8px; gap: 4px; }
  .chat-input { font-size: 13px; }
  #xVoiceLive { display: none; }
  /* Studio/Academy/Gallery cards more compact */
  .x-gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; padding: 12px; }
  .academy-grid { grid-template-columns: 1fr; }
  .studio-logo-grid { grid-template-columns: 1fr 1fr; }
}


/* ===== a11y-focus-visible: keyboard focus ring =====
   Only shows on keyboard navigation (not mouse clicks) via :focus-visible.
   Cyan accent contrasts against purple gradient buttons for clear visibility. */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible,
details:focus-visible {
  outline: 2px solid #06b6d4;
  outline-offset: 3px;
  border-radius: var(--brn-radius-sm);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.2);
  transition: box-shadow 0.1s ease;
}
/* Skip-to-content link (a11y hidden until focused) */
.skip-to-content {
  position: absolute;
  top: -40px;
  left: 0;
  background: #06b6d4;
  color: #0a0a0f;
  padding: 8px 16px;
  z-index: 9999;
  text-decoration: none;
  font-weight: 700;
  border-radius: 0 0 8px 0;
}
.skip-to-content:focus-visible {
  top: 0;
}
/* ===== a11y-focus-visible end ===== */

/* ===== overflow-x-fix: confina glow-blob decorativos dentro da viewport =====
   Evita scroll horizontal indesejado causado por blobs posicionados fora do viewport.
   Regra global no html/body garante zero horizontal scroll em qualquer viewport. */
html, body { overflow-x: hidden; max-width: 100%; }
.glow-blob { pointer-events: none; max-width: 100vw; }
/* ===== overflow-x-fix end ===== */

/* ===== DESIGN-TOKENS-MANIFEST (v1 - 2026-04-22) =====
 * Use these tokens instead of hardcoded values to keep visual consistency:
 *
 * Colors:
 *   Purple accent:  #7c3aed (primary)  · #c4b5fd (light text)
 *   Cyan accent:    #06b6d4 (gradient end)
 *   Success green:  #34d399
 *   Text secondary: #94a3b8
 *   Text muted:     #64748b
 *   BG base:        #0a0a0f
 *   BG card:        #11111a
 *   BG hover:       #1a1a26
 *   Border:         #2a2a3a
 *
 * Radii (canonical - avoid random values):
 *   Inputs:         4px (--radius-input)
 *   Small btn/tag:  8px
 *   Cards:          12px
 *   Modals:         16px
 *   Pills:          999px
 *
 * Spacing scale: 4, 8, 14, 20, 28, 40, 60, 80 px
 * Font family:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif
 * ====================================================== */

/* --- Enhance Prompt Button (Ciclo 193 viral polish) --- */
.enhance-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(139,92,246,0.35);
  border-radius: var(--brn-radius-xl);
  background: rgba(139,92,246,0.08);
  color: var(--accent-start);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-right: 6px;
}
.enhance-btn:hover {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 3px 14px rgba(139,92,246,0.35);
  border-color: transparent;
}
.enhance-btn:active { transform: translateY(0); }
.enhance-btn:disabled {
  opacity: 0.5;
  cursor: progress;
  pointer-events: none;
}
.enhance-btn svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}
.enhance-btn:hover svg {
  transform: rotate(20deg) scale(1.1);
}
.enhance-btn.loading svg {
  animation: enhance-spin 1s linear infinite;
}
@keyframes enhance-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Enhance suggestion modal */
.enhance-modal { max-width: 640px; }
.enhance-modal .enh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--brn-radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.enhance-modal .enh-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  margin-bottom: 6px;
}
.enhance-modal .enh-text {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.enhance-modal .enh-rationale {
  font-style: italic;
  opacity: 0.75;
  font-size: 13px;
  margin-top: 8px;
}
.enhance-modal .enh-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  flex-wrap: wrap;
}
/* ============================================================
   Polish Top 1% — micro-details que elevam percepção de qualidade
   Ciclo 198 — carregado globalmente via style.css append
   ============================================================ */

/* ---- 1. Focus-visible consistente (keyboard navigation premium) ---- */
/* Remove default outline, adiciona ring gradient roxo visible only on tab */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: 0 0 0 2px rgba(10, 10, 15, 1), 0 0 0 4px #a855f7;
  border-radius: 6px;
}
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible,
[role="button"]:focus-visible, [tabindex]:focus-visible {
  box-shadow: 0 0 0 2px rgba(10, 10, 15, 1), 0 0 0 4px #a855f7;
}

/* ---- 2. Micro-interactions em buttons ---- */
button, .btn, .x-btn, a.btn-primary, a.x-btn-primary {
  transition: transform 0.12s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.18s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.15s ease,
              background 0.2s ease !important;
  will-change: transform;
}
button:active:not(:disabled), .btn:active, .x-btn:active {
  transform: scale(0.97) translateZ(0) !important;
}
button:not(:disabled):hover, .btn:not(:disabled):hover, .x-btn:not(:disabled):hover {
  transform: translateY(-1px) translateZ(0);
}

/* Cards lift on hover */
.card, .x-card, .tier, .out-card, .metric, .brn-ul-stat, .reward-card, .suggestions a, .explore-tile {
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.2s ease;
  will-change: transform;
}
.card:hover, .x-card:hover, .tier:hover, .out-card:hover, .reward-card:hover, .suggestions a:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.15);
  border-color: rgba(124, 58, 237, 0.35);
}

/* ---- 3. Skeleton shimmer unificado ---- */
@keyframes brn-shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}
.skeleton, [data-skeleton], .brn-skeleton {
  background: linear-gradient(90deg,
    rgba(139, 92, 246, 0.04) 0%,
    rgba(139, 92, 246, 0.12) 50%,
    rgba(139, 92, 246, 0.04) 100%);
  background-size: 1000px 100%;
  animation: brn-shimmer 1.6s ease-in-out infinite;
  border-radius: 8px;
  color: transparent !important;
}
.skeleton-text { height: 14px; margin: 6px 0; }
.skeleton-text.sk-lg { height: 20px; }
.skeleton-circle { border-radius: 50%; }

/* ---- 4. Typography premium (Inter-ready feature settings) ---- */
html {
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1,
                         "ss01" 1, "ss03" 1,  /* stylistic alternates (Inter) */
                         "cv11" 1;             /* single-story a (Inter) */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body {
  font-variant-ligatures: common-ligatures contextual;
}

/* Tabular nums for numbers (prices, counters, stats) */
.price, .num, .brn-ul-num, .counter, .stat-num, [data-tabular] {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* Better heading spacing */
h1, h2, h3 { letter-spacing: -0.015em; line-height: 1.15; }
h1 { letter-spacing: -0.02em; }

/* ---- 5. Reduced motion respect (WCAG 2.3.3) ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .brn-ul-pulse, .bt-track, .cursor, .spin { animation: none !important; }
}

/* ---- 6. Selection color on-brand ---- */
::selection { background: rgba(168, 85, 247, 0.35); color: #fff; }
::-moz-selection { background: rgba(168, 85, 247, 0.35); color: #fff; }

/* ---- 7. Scrollbar polido (webkit) ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.02); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.35), rgba(6, 182, 212, 0.35));
  border-radius: 10px;
  border: 2px solid rgba(10, 10, 15, 0.9);
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, rgba(124, 58, 237, 0.6), rgba(6, 182, 212, 0.6)); }

/* ---- 8. Empty states enriched ---- */
.empty-state, .x-empty, .explore-empty {
  text-align: center;
  padding: 48px 24px;
  max-width: 420px;
  margin: 0 auto;
}
.empty-state::before, .x-empty::before, .explore-empty::before {
  content: "";
  display: block;
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  background: radial-gradient(circle, rgba(168, 85, 247, 0.18) 0%, transparent 70%);
  border-radius: 50%;
  position: relative;
}

/* ---- 9. Loading state for fetch buttons ---- */
button[data-loading="true"], .btn[data-loading="true"] {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
  color: transparent !important;
}
button[data-loading="true"]::after, .btn[data-loading="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: brn-spin-loader 0.7s linear infinite;
}
@keyframes brn-spin-loader { to { transform: rotate(360deg); } }

/* ---- 10. Image + video lazy with fade-in ---- */
img, video {
  transition: opacity 0.3s ease;
}
img[loading="lazy"]:not(.loaded), video:not(.loaded) { opacity: 0; }
img.loaded, video.loaded { opacity: 1; }

/* ---- 11. Links accessible underline on hover (non-nav) ---- */
main a:not(.btn):not(.x-btn):not(.nav a):not(.nav-right a):not(.brand) {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  opacity: 0.9;
  transition: opacity 0.15s, background-size 0.25s;
}
main a:not(.btn):not(.x-btn):hover {
  opacity: 1;
  background-size: 100% 2px;
}

/* ---- 12. Heading subtle text gradient applied automatically to hero h1 ---- */
.hero h1, h1.hero-h1 {
  background: linear-gradient(135deg, #a855f7 0%, #06b6d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}

/* ---- 13. Image blur-up placeholder (native lazy + blur) ---- */
img[data-blur-up] {
  filter: blur(18px); transition: filter 0.5s ease;
}
img[data-blur-up].loaded { filter: blur(0); }

/* ---- 14. Mobile touch targets 44x44 minimum (WCAG 2.5.5) ---- */
@media (max-width: 640px) {
  button, a.btn, a.x-btn, .nav-right a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

/* ---- 15. Print-friendly (investor/partner share) ---- */
@media print {
  .nav, nav.nav, #brn-live-ticker, #brn-onboarding, #brn-usage-live, .cookie-banner, #xCookieBanner {
    display: none !important;
  }
  body { background: #fff !important; color: #000 !important; }
  a { text-decoration: underline; color: #000 !important; }
}

/* ============================================================
   Ciclo 198++ fixes — bugs detected by rigorous Playwright test
   ============================================================ */

/* --- Bug 1 fix: reduced-motion override com specificity reforçada --- */
/* JS toggles body.reduced-motion based on matchMedia (robust vs CSS-only) */
body.reduced-motion #brn-live-ticker .bt-track,
body.reduced-motion .bt-track,
body.reduced-motion .brn-ul-pulse,
body.reduced-motion .brn-hero-demo .cursor,
body.reduced-motion .brn-hero-demo .spin,
body.reduced-motion .onb-cel-card,
body.reduced-motion [class*="animation"] {
  animation: none !important;
  animation-duration: 0s !important;
  transition: none !important;
}
/* Media-query double lock */
@media (prefers-reduced-motion: reduce) {
  #brn-live-ticker .bt-track,
  #brn-live-ticker .brn-ul-pulse,
  .brn-ul-pulse,
  .brn-hero-demo *,
  [class*="brn-"] * {
    animation: none !important;
    animation-duration: 0s !important;
  }
}

/* --- Bug 2 fix: touch targets 44x44 em mobile com specificity maior --- */
@media (max-width: 640px) {
  .nav-right a,
  nav.nav .nav-right a,
  a.btn,
  .btn,
  button:not(.brn-onb-toggle):not(.brn-onb-dismiss):not(.brn-ul-close) {
    min-height: 44px !important;
    padding: 10px 12px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
  }
  /* Nav compacta especifica: reduz padding horizontal mas mantém altura */
  nav.nav .nav-right { gap: 4px; flex-wrap: wrap; }
  nav.nav .nav-right a { margin-left: 0 !important; padding: 10px 12px !important; }
}

/* Fix typography — cascade para body + html+body specificity */
html, body {
  font-feature-settings: "kern" 1, "liga" 1, "calt" 1, "ss01" 1, "ss03" 1, "cv11" 1 !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
  text-rendering: optimizeLegibility !important;
}

/* Fix touch targets — specific class targets que pricing.html usa */
@media (max-width: 640px) {
  .bt-opt, .bt-opt.bt-month, .bt-opt.bt-year,
  .quiz-option, .quiz-answer, .plan-answer,
  button.bt-opt, button[class*="quiz"], button[class*="plan"],
  button[class*="tier"], .tier button, .tier a {
    min-height: 44px !important;
    padding: 12px 16px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    line-height: 1.3 !important;
  }
  /* Nav links mobile */
  nav.nav .nav-right,
  header.nav .nav-right {
    gap: 2px !important;
    padding: 0 !important;
  }
  nav.nav .nav-right a,
  header.nav .nav-right a {
    min-height: 44px !important;
    padding: 10px 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    font-size: 13px !important;
    line-height: 1 !important;
  }
}
