/* ============================================================
   EpiForecast-MX — Clinical Indigo Theme 2026
   Dark editorial aesthetic with IMSS institutional identity
   Fully responsive: 320px → ultrawide
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Playfair+Display:ital,wght@0,700;1,700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── DESIGN TOKENS ─── */

:root {
  /* Surfaces — Clinical Indigo (azul pizarra) */
  --bg-deep: #0E1424;
  --bg-base: #131C30;
  --bg-raised: #18223A;
  --bg-card: #1C2740;
  --bg-card-hover: #243150;
  --bg-input: #141D33;
  --bg-glass: rgba(24, 34, 58, 0.80);
  --bg-glass-hover: rgba(36, 49, 80, 0.88);

  /* IMSS Palette */
  --burgundy: #F472B6;
  --burgundy-bright: #F9A8D4;
  --burgundy-dim: rgba(244, 114, 182, 0.18);
  --burgundy-glow: rgba(244, 114, 182, 0.30);
  --teal: #5B8DEF;
  --teal-bright: #8FB4FF;
  --teal-deep: #3A6FD8;
  --teal-dim: rgba(91, 141, 239, 0.15);
  --teal-glow: rgba(91, 141, 239, 0.25);
  --gold: #2DD4BF;
  --gold-bright: #5EEAD4;
  --gold-deep: #1AA396;
  --gold-dim: rgba(45, 212, 191, 0.15);
  --gold-glow: rgba(45, 212, 191, 0.25);

  /* Gradientes señalan jerarquía */
  --grad-primary: linear-gradient(135deg, var(--teal) 0%, var(--teal-bright) 100%);
  --grad-aurora: linear-gradient(135deg, var(--teal) 0%, #8FB4FF 35%, var(--gold) 70%, var(--gold-bright) 100%);
  --grad-burg: linear-gradient(135deg, var(--burgundy) 0%, var(--burgundy-bright) 100%);

  /* Sombras de color (chart hover, focus, hero) */
  --glow-teal-strong: 0 0 24px rgba(143, 180, 255, 0.35), 0 0 60px rgba(91, 141, 239, 0.18);
  --glow-gold-strong: 0 0 24px rgba(94, 234, 212, 0.30), 0 0 60px rgba(45, 212, 191, 0.15);
  --glow-burg-strong: 0 0 24px rgba(249, 168, 212, 0.30), 0 0 60px rgba(244, 114, 182, 0.15);

  /* Neutrals */
  --text-primary: #E7ECF5;
  --text-secondary: #9FB0CE;
  --text-muted: #6E82A6;
  /* #7C8DB0 sobre #0E1424 ≈ 5.5:1 (antes #44567A ≈ 2.3:1, ilegible en labels de 9px) */
  --text-faint: #7C8DB0;

  /* Borders */
  --border: rgba(91, 141, 239, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(91, 141, 239, 0.22);
  --border-hover: rgba(91, 141, 239, 0.32);

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 100px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.20);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.40), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-glow-teal: 0 0 20px rgba(91, 141, 239, 0.15), 0 0 60px rgba(91, 141, 239, 0.05);
  --shadow-glow-gold: 0 0 20px rgba(45, 212, 191, 0.12), 0 0 60px rgba(45, 212, 191, 0.04);
  --shadow-glow-burg: 0 0 20px rgba(244, 114, 182, 0.12), 0 0 60px rgba(244, 114, 182, 0.04);

  /* Typography */
  --font-body: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur: 0.3s;
  --dur-fast: 0.15s;
}

/* ─── RESET ─── */

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

/* ─── ACCESSIBILITY HELPERS ─── */

.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;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Reduced motion respect */
@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;
  }
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient background mesh */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 15% 5%, rgba(91, 141, 239, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 85% 95%, rgba(244, 114, 182, 0.04) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 50%, rgba(45, 212, 191, 0.03) 0%, transparent 45%);
  pointer-events: none;
  z-index: 0;
}

/* Subtle grid texture */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M40 0H0v40' fill='none' stroke='%23ffffff' stroke-opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ─── HEADER ─── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
  position: relative;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal) 30%, var(--gold) 70%, transparent);
  opacity: 0.5;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 1;
}

.header-logo {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: var(--r-md);
  overflow: hidden;
  transition: all var(--dur) var(--ease-out);
}

.header-logo:hover {
  transform: scale(1.05);
}

.header-logo img {
  height: 100%;
  width: auto;
  object-fit: contain;
}

.header-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.header h1 {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  line-height: 1;
  white-space: nowrap;
}

.header-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  padding-left: 10px;
  border-left: 1px solid var(--border-accent);
  letter-spacing: 0.2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1;
}

/* ─── HEADER INLINE STATS ─── */

.header-stats {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 auto 0 1.5rem;
}

.hstat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 14px;
  border-radius: var(--r-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  min-width: 68px;
  transition: all var(--dur) var(--ease-out);
}

.hstat:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}

.hstat-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--teal);
  line-height: 1.2;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
}

.hstat-lbl {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .header-stats { display: none; }
}

/* ─── STATUS INDICATORS ─── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
}

.badge-build {
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* ─── GEMINI STATUS ─── */

.gemini-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 14px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: all 0.4s ease;
  border: 1px solid transparent;
}

.gemini-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.4s ease;
}

.gemini-checking {
  background: var(--bg-card);
  color: var(--text-muted);
  border-color: var(--border-subtle);
}
.gemini-checking .gemini-dot {
  background: var(--text-muted);
  animation: pulse-dot 1.5s infinite;
}

.gemini-ok {
  background: rgba(91, 141, 239, 0.08);
  color: var(--teal);
  border-color: rgba(91, 141, 239, 0.15);
}
.gemini-ok .gemini-dot {
  background: var(--teal);
  box-shadow: 0 0 10px rgba(91, 141, 239, 0.5);
  animation: pulse-dot 2.5s infinite;
}

.gemini-off {
  background: var(--gold-dim);
  color: var(--gold);
  border-color: rgba(45, 212, 191, 0.15);
}
.gemini-off .gemini-dot {
  background: var(--gold);
  box-shadow: 0 0 6px rgba(45, 212, 191, 0.4);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

@media (max-width: 520px) {
  .gemini-status span:last-child { display: none; }
  .gemini-status { padding: 5px 8px; }
}

/* ─── RESET BUTTON ─── */

.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--dur) var(--ease-out);
}

.reset-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--burgundy);
  color: var(--burgundy);
  box-shadow: var(--shadow-glow-burg);
}

.reset-btn:active {
  transform: scale(0.97);
}

@media (max-width: 480px) {
  .reset-label { display: none; }
  .reset-btn { padding: 6px 8px; }
  .voice-btn-label { display: none; }
  .voice-header-btn { padding: 6px 8px; }
}

/* ─── VOICE HEADER BUTTONS ─── */

.voice-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all var(--dur) var(--ease-out);
}

.voice-header-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--teal);
  color: var(--teal);
}

.voice-header-btn:active {
  transform: scale(0.97);
}

/* Stop button: red accent when visible */
.voice-stop-btn {
  border-color: #F472B6;
  color: #F472B6;
  animation: stop-pulse 1.5s ease-in-out infinite;
}
.voice-stop-btn:hover {
  background: rgba(244, 114, 182, 0.1);
  border-color: #F472B6;
  color: #F472B6;
}
@keyframes stop-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 114, 182, 0.25); }
  50%      { box-shadow: 0 0 0 4px rgba(244, 114, 182, 0); }
}

/* Mute button: muted state */
.voice-mute-btn.muted {
  color: var(--text-muted);
  opacity: 0.5;
}
.voice-mute-btn.muted:hover {
  opacity: 0.8;
  color: var(--teal);
}

/* ─── CHAT AREA ─── */

.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}

.chat-area::before {
  content: '';
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  margin-bottom: -20px;
  background: linear-gradient(to bottom, var(--bg-base), transparent);
  pointer-events: none;
  z-index: 2;
  flex-shrink: 0;
}

.chat-area::-webkit-scrollbar {
  width: 5px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: var(--border-accent);
  border-radius: var(--r-pill);
}

.chat-area::-webkit-scrollbar-thumb:hover {
  background: var(--teal);
}

/* ─── MESSAGES ─── */

.msg {
  max-width: 78%;
  animation: msg-in 0.5s var(--ease-out);
  position: relative;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* User message */
.msg-user {
  align-self: flex-end;
  display: flex;
  flex-direction: row-reverse;
  gap: 12px;
}

.msg-avatar-user {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  background: linear-gradient(135deg, var(--burgundy), #BE185D);
  border: 1px solid rgba(244, 114, 182, 0.3);
  box-shadow: var(--shadow-sm), var(--shadow-glow-burg);
}

.msg-avatar-user svg {
  color: #fff;
  width: 20px;
  height: 20px;
}

.msg-user .msg-body {
  flex: 1;
  min-width: 0;
}

.msg-user .msg-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
  justify-content: flex-end;
}

.msg-user .msg-bubble {
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.25), rgba(190, 24, 93, 0.18));
  color: var(--text-primary);
  border-radius: var(--r-lg) 4px var(--r-lg) var(--r-lg);
  padding: 12px 18px;
  border: 1px solid rgba(244, 114, 182, 0.20);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.msg-user .msg-content {
  color: var(--text-primary);
}

.msg-user .msg-content strong {
  color: #fff;
}

/* Bot message */
.msg-bot {
  align-self: flex-start;
  display: flex;
  gap: 12px;
  animation: msg-enter 0.32s var(--ease-out) both;
}

.msg-user {
  animation: msg-enter-user 0.28s var(--ease-out) both;
}

@keyframes msg-enter {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes msg-enter-user {
  from { opacity: 0; transform: translateY(8px) translateX(8px); }
  to   { opacity: 1; transform: translateY(0) translateX(0); }
}

.msg-avatar {
  width: 63px;
  height: 63px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: radial-gradient(circle at 50% 32%, #2A3A5E 0%, #1C2740 60%, #18223A 100%);
  border: 2px solid var(--border-accent);
  box-shadow: var(--shadow-glow-teal);
  position: relative;
  transition: transform 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
}

.msg-bot:hover .msg-avatar {
  transform: scale(1.04) rotate(-1.5deg);
  box-shadow: 0 0 30px rgba(91, 141, 239, 0.35), 0 0 60px rgba(91, 141, 239, 0.12);
}

/* Avatar glow ring (gradiente animado al estar en speaking) */
.msg:has(.tts-btn.tts-speaking) .msg-avatar {
  animation: avatar-pulse 1.2s ease-in-out infinite;
}
@keyframes avatar-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(91, 141, 239, 0.25), 0 0 24px rgba(91, 141, 239, 0.10); }
  50%      { box-shadow: 0 0 22px rgba(91, 141, 239, 0.55), 0 0 40px rgba(91, 141, 239, 0.30); }
}

.msg-avatar img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  display: block;
}

.msg-avatar svg {
  color: var(--teal);
}

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.msg-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 400;
}

.msg-source {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.65px;
  text-transform: uppercase;
  font-family: var(--font-mono);
  position: relative;
}

.msg-source::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: badge-dot-pulse 2s ease-in-out infinite;
}

.badge-local {
  background: linear-gradient(135deg, rgba(91, 141, 239, 0.18), rgba(91, 141, 239, 0.06));
  color: var(--teal);
  border: 1px solid rgba(91, 141, 239, 0.25);
  box-shadow: 0 0 0 1px rgba(91, 141, 239, 0.05) inset;
}
.badge-local::before { background: var(--teal); box-shadow: 0 0 6px var(--teal); }

.badge-ai {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.18), rgba(45, 212, 191, 0.06));
  color: var(--gold);
  border: 1px solid rgba(45, 212, 191, 0.25);
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.05) inset;
}
.badge-ai::before { background: var(--gold); box-shadow: 0 0 6px var(--gold); }

/* Badge de error: distingue fallos del bot (rosa) de respuestas IA (verde-azul) */
.badge-error {
  background: linear-gradient(135deg, rgba(244, 114, 182, 0.18), rgba(244, 114, 182, 0.06));
  color: var(--burgundy);
  border: 1px solid rgba(244, 114, 182, 0.25);
  box-shadow: 0 0 0 1px rgba(244, 114, 182, 0.05) inset;
}
.badge-error::before { background: var(--burgundy); box-shadow: 0 0 6px var(--burgundy); }

@keyframes badge-dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.35); opacity: 0.7; }
}

.msg-bubble-bot {
  background: linear-gradient(180deg, rgba(28, 39, 64, 0.92), rgba(24, 34, 58, 0.88));
  border: 1px solid var(--border);
  border-left: 3px solid rgba(91, 141, 239, 0.55);
  border-radius: 4px var(--r-lg) var(--r-lg) var(--r-lg);
  padding: 16px 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all var(--dur) var(--ease-out);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.02);
  position: relative;
}

/* Mensajes IA tienen gradient dorado en lugar de teal */
.msg-bot:has(.badge-ai) .msg-bubble-bot {
  border-left-color: rgba(45, 212, 191, 0.55);
}

.msg-bubble-bot:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md), var(--shadow-glow-teal), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transform: translateY(-1px);
}

/* Message content (Markdown) */
.msg-content {
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--text-primary);
}

.msg-content p {
  margin-bottom: 10px;
}

.msg-content p:last-child {
  margin-bottom: 0;
}

.msg-content strong {
  font-weight: 700;
  color: var(--teal);
}

.msg-content ul, .msg-content ol {
  padding-left: 20px;
  margin: 8px 0;
}

.msg-content li {
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.msg-content li::marker {
  color: var(--teal);
}

.msg-content img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  margin: 10px 0;
  border: 1px solid var(--border, #243150);
  cursor: zoom-in;
}

.img-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 22, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: zoom-out;
  padding: 24px;
}
.img-lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.msg-content em {
  color: var(--text-secondary);
  font-style: italic;
}

.msg-content code {
  background: rgba(91, 141, 239, 0.08);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--teal);
  border: 1px solid rgba(91, 141, 239, 0.1);
}

.msg-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.msg-content h1, .msg-content h2, .msg-content h3 {
  color: var(--text-primary);
  font-weight: 800;
  margin-top: 14px;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.msg-content h1 { font-size: 18px; }
.msg-content h2 { font-size: 16px; color: var(--teal); }
.msg-content h3 { font-size: 14px; color: var(--gold); }

.msg-content table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
  width: 100%;
  border-radius: var(--r-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.msg-content th, .msg-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.msg-content th {
  background: rgba(91, 141, 239, 0.08);
  font-weight: 700;
  color: var(--teal);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.msg-content td {
  color: var(--text-secondary);
}

/* Follow-up suggestions */
.msg-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  position: relative;
}

.msg-suggestions::before {
  content: 'Sigue explorando';
  position: absolute;
  top: -7px;
  left: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0 8px 0 0;
}

.msg-suggestions button {
  background: linear-gradient(135deg, rgba(91, 141, 239, 0.10), rgba(91, 141, 239, 0.04));
  border: 1px solid rgba(91, 141, 239, 0.22);
  color: var(--teal);
  padding: 7px 14px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--dur) var(--ease-out);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.msg-suggestions button::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(91, 141, 239, 0.15), transparent);
  transition: left 0.6s var(--ease-out);
}

.msg-suggestions button:hover {
  background: linear-gradient(135deg, rgba(91, 141, 239, 0.22), rgba(91, 141, 239, 0.10));
  border-color: var(--teal);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(91, 141, 239, 0.28);
}

.msg-suggestions button:hover::before { left: 100%; }

.msg-suggestions button:active {
  transform: translateY(0) scale(0.98);
}

.msg-suggestions button::after {
  content: '→';
  font-size: 14px;
  opacity: 0.5;
  transition: transform 0.2s, opacity 0.2s;
}

.msg-suggestions button:hover::after {
  transform: translateX(2px);
  opacity: 1;
}

/* Caret de streaming: parpadea al final del texto mientras EPI escribe */
.msg-streaming::after {
  content: '▍';
  color: var(--teal);
  margin-left: 1px;
  animation: stream-caret 1s steps(2) infinite;
}
@keyframes stream-caret { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Fuentes del RAG — chips clicables (estética documento, acento dorado) */
.msg-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  position: relative;
}

.msg-sources::before {
  content: 'Fuentes';
  position: absolute;
  top: -7px;
  left: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold);
  background: var(--bg-card);
  padding: 0 8px 0 0;
}

.msg-source-chip {
  display: inline-flex;
  align-items: stretch;
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.10), rgba(45, 212, 191, 0.04));
  border: 1px solid rgba(45, 212, 191, 0.22);
  border-radius: var(--r-pill);
  overflow: hidden;
  max-width: 100%;
  transition: all var(--dur) var(--ease-out);
}

.msg-source-chip svg { opacity: 0.75; flex-shrink: 0; }

.msg-source-chip .src-n {
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.7;
}

/* Parte enlace: abre el documento real */
.msg-source-chip .src-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 12px;
  color: var(--gold-bright);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-body);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-source-chip .src-open--static { cursor: default; }

/* Sub-botón: profundizar con el RAG */
.msg-source-chip .src-ask {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  background: rgba(45, 212, 191, 0.10);
  border: none;
  border-left: 1px solid rgba(45, 212, 191, 0.22);
  color: var(--gold-bright);
  cursor: pointer;
  transition: background var(--dur) var(--ease-out);
}
.msg-source-chip .src-ask:hover { background: rgba(45, 212, 191, 0.30); color: #fff; }

.msg-source-chip:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(45, 212, 191, 0.25);
}
.msg-source-chip .src-open:hover { color: #fff; }
.msg-source-chip:active { transform: translateY(0) scale(0.99); }

/* Charts — paneles más grandes, dramáticos */
.msg-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* antes 3 — más espacio por chart */
  gap: 14px;
  margin-top: 18px;
}

.msg-chart-grid .msg-chart-container {
  margin-top: 0;
}


.msg-chart-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 18px;
}

.msg-chart-stack .msg-chart-container {
  margin-top: 0;
}


.msg-chart-container {
  margin-top: 18px;
  padding: 20px 22px;
  background:
    radial-gradient(circle at 100% 0%, rgba(91, 141, 239, 0.04), transparent 50%),
    var(--bg-raised);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.02);
  transition: border-color 0.3s var(--ease-out), box-shadow 0.3s var(--ease-out);
  position: relative;
  height: 460px;
}

.msg-chart-grid .msg-chart-container { height: 380px; }
.msg-chart-stack .msg-chart-container { height: 440px; }
@media (min-width: 1400px) {
  .msg-chart-container { height: 520px; }
  .msg-chart-grid .msg-chart-container { height: 440px; }
}
@media (max-width: 768px) {
  .msg-chart-container { height: 360px; padding: 14px 16px; }
  .msg-chart-grid .msg-chart-container { height: 320px; }
}

/* Contenedores custom (mapa, semaforo, comparador, timelapse) usan padding interno propio */
.msg-chart-container:has(.mexico-map-wrapper),
.msg-chart-container:has(.timelapse-wrapper),
.msg-chart-container:has(.semaforo-wrapper),
.msg-chart-container:has(.comparador-wrapper) {
  height: auto;
  min-height: unset;
}

.msg-chart-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-aurora);
  opacity: 0.55;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.msg-chart-container:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-md), var(--glow-teal-strong);
}

.msg-chart-container canvas {
  width: 100% !important;
  height: 100% !important;
  max-height: none;
}

/* Mensajes que contienen chart standalone se expanden mucho más ancho */
.msg-bot:has(.msg-chart-container:only-child),
.msg-bot:has(.msg-chart-grid),
.msg-bot:has(.msg-chart-stack) {
  max-width: 96%;
}

/* Para mapas de México y herramientas custom, todavía más espacio */
.msg-bot:has(#tl-1, [id^="tl-"], [id^="sem-"], [id^="cmp-"], [id^="map-"]) {
  max-width: 98%;
}

@media (min-width: 1400px) {
  .msg-bot:has(.msg-chart-container) {
    max-width: 92%;
  }
}

/* Typing indicator */
.typing-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.typing {
  display: inline-flex;
  gap: 6px;
}

.typing-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.2px;
  animation: label-fade 1.6s ease-in-out infinite;
}

.typing span {
  width: 7px;
  height: 7px;
  background: var(--teal);
  border-radius: 50%;
  animation: bounce 1.4s infinite;
  opacity: 0.6;
}

.typing span:nth-child(2) { animation-delay: 0.16s; }
.typing span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes label-fade {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* ─── INPUT BAR ─── */

.input-bar {
  padding: 12px 24px 16px;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.input-bar::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--teal) 30%, var(--gold) 70%, transparent);
  opacity: 0.2;
}

.input-wrapper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 4px 4px 4px 0;
  transition: all var(--dur) var(--ease-out);
}

.input-wrapper:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.18), 0 0 24px rgba(91, 141, 239, 0.20), 0 8px 32px rgba(91, 141, 239, 0.08);
  background: var(--bg-card);
  transform: translateY(-1px);
}

.input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px 0 16px;
  color: var(--text-muted);
  transition: color var(--dur) var(--ease-out);
}

.input-wrapper:focus-within .input-icon {
  color: var(--teal);
}

.input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 11px 8px;
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  color: var(--text-primary);
  font-weight: 400;
}

.input-wrapper input::placeholder {
  color: var(--text-muted);
}

.input-wrapper button {
  background: linear-gradient(135deg, var(--teal), #3A6FD8);
  color: #fff;
  border: none;
  border-radius: var(--r-lg);
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--dur) var(--ease-out);
  flex-shrink: 0;
  box-shadow: 0 2px 12px rgba(91, 141, 239, 0.25);
}

.input-wrapper button:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 20px rgba(91, 141, 239, 0.4);
}

.input-wrapper button:active {
  transform: scale(0.97);
}

/* Consulta en vuelo: el botón Enviar se deshabilita para evitar envíos concurrentes */
.input-wrapper button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── BOTÓN FLOTANTE «BAJAR» (auto-scroll condicional) ─── */
.scroll-down-btn {
  position: absolute;
  bottom: calc(100% + 14px);
  right: 22px;
  z-index: 150;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border-accent);
  border-radius: var(--r-pill);
  background: rgba(24, 34, 58, 0.94);
  color: var(--teal);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out),
              background var(--dur-fast), border-color var(--dur-fast);
}
.scroll-down-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.scroll-down-btn:hover {
  background: var(--teal-dim);
  border-color: var(--teal);
}

/* ─── MIC BUTTON ─── */
.mic-btn {
  background: transparent !important;
  box-shadow: none !important;
  color: var(--text-muted) !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: 50% !important;
  transition: all 0.25s var(--ease-out) !important;
}
.mic-btn:hover {
  color: var(--teal) !important;
  background: rgba(91, 141, 239, 0.08) !important;
  transform: scale(1.06);
  box-shadow: none !important;
}
.mic-btn.mic-active {
  color: #F472B6 !important;
  background: rgba(244, 114, 182, 0.12) !important;
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 114, 182, 0.3); }
  50%      { box-shadow: 0 0 0 8px rgba(244, 114, 182, 0); }
}

/* ─── ACCIONES DE MENSAJE (copy / TTS) ─── */
.msg-action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  margin-left: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s, transform 0.15s;
  vertical-align: middle;
  min-width: 28px;
  min-height: 28px;
}
.msg-action-btn:hover {
  color: var(--teal);
  background: rgba(91, 141, 239, 0.08);
}
.msg-action-btn:active { transform: scale(0.92); }

.copy-btn.copied {
  color: var(--teal);
  background: rgba(91, 141, 239, 0.14);
}
.copy-btn.copied svg { animation: copy-pop 0.3s ease-out; }
@keyframes copy-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* TTS keeps its own state styling */
.tts-btn.tts-speaking {
  color: var(--teal);
  animation: tts-wave 0.6s ease-in-out infinite alternate;
}
@keyframes tts-wave {
  0%   { transform: scale(1); }
  100% { transform: scale(1.15); }
}

/* ─── WELCOME HERO ─── */
.welcome-hero {
  background:
    radial-gradient(circle at 0% 0%, rgba(91, 141, 239, 0.10), transparent 50%),
    radial-gradient(circle at 100% 100%, rgba(45, 212, 191, 0.08), transparent 50%),
    linear-gradient(135deg, rgba(28, 39, 64, 0.4), rgba(24, 34, 58, 0.2));
  border-radius: var(--r-lg);
  padding: 4px 0 8px;
  margin: -4px 0;
}

.welcome-hero-title {
  font-family: var(--font-display);
  font-size: clamp(22px, 3.5vw, 32px);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  line-height: 1.15;
}

/* Variante compacta: primer mensaje mínimo y poco invasivo */
.welcome-hero--compact { padding: 0; margin: 0; background: none; }
.welcome-hero--compact .welcome-hero-title { font-size: clamp(17px, 2.2vw, 21px); margin-bottom: 4px; }
.welcome-hero--compact .welcome-hero-sub { font-size: 13px; margin-bottom: 0; color: var(--text-muted); }

.welcome-brand {
  background: linear-gradient(135deg, var(--teal) 0%, #9DB6FF 50%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  letter-spacing: -1px;
}

.welcome-hero-sub {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 18px;
  max-width: 64ch;
}

.welcome-hero-sub strong {
  color: var(--teal);
  font-weight: 700;
}

/* Hero de bienvenida: KPIs animados + selector de padecimiento + gráfico vivo */
.hero-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 4px 0 18px;
}
.hero-kpi {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border-radius: var(--r-md, 14px);
  background: linear-gradient(135deg, rgba(36, 49, 79, 0.55), rgba(24, 34, 58, 0.35));
  border: 1px solid rgba(91, 141, 239, 0.16);
}
.hero-kpi-ic {
  width: 24px;
  height: 24px;
  flex: none;
  color: var(--teal, #5B8DEF);
  opacity: 0.95;
}
.hero-kpi-txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.hero-kpi-val {
  font-family: var(--font-display);
  font-size: clamp(19px, 2.4vw, 24px);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.hero-kpi-lbl { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

.hero-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(36, 49, 79, 0.4);
  border: 1px solid rgba(91, 141, 239, 0.18);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, color 0.18s, transform 0.12s;
}
.hero-pill:hover { transform: translateY(-1px); color: var(--text-primary); }
.hero-pill-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--pill, #5B8DEF);
  box-shadow: 0 0 8px var(--pill, #5B8DEF);
}
.hero-pill-cie {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  opacity: 0.85;
}
.hero-pill.is-active {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--pill) 18%, transparent);
  border-color: var(--pill, #5B8DEF);
}
.hero-pill.is-active .hero-pill-cie { color: var(--pill, #5B8DEF); opacity: 1; }

.hero-chart-wrap { margin-top: 2px; }
.hero-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.hero-cap-chip {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(36, 49, 79, 0.45);
  border: 1px solid rgba(91, 141, 239, 0.14);
}
.hero-cap-chip b { color: var(--text-primary); font-weight: 700; }
.hero-cap-chip[style*="--pill"] b { color: var(--pill); }

@media (max-width: 640px) {
  .hero-kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .hero-kpi { padding: 10px 11px; gap: 9px; }
}

.welcome-quickstats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.welcome-qs {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(14, 20, 36, 0.45);
  border: 1px solid rgba(91, 141, 239, 0.15);
  border-radius: var(--r-md);
  padding: 10px 14px;
  transition: all 0.25s var(--ease-out);
}

.welcome-qs:hover {
  border-color: var(--teal);
  background: rgba(91, 141, 239, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(91, 141, 239, 0.18);
}

.welcome-qs-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(91, 141, 239, 0.18), rgba(91, 141, 239, 0.06));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  flex-shrink: 0;
}

.welcome-qs-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 0;
}

.welcome-qs-val {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.welcome-qs-lbl {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-top: 2px;
}

.welcome-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.welcome-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border-accent);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--teal);
  font-style: normal;
  margin: 0 2px;
}

/* ─── MOBILE THUMB-FIRST: targets ≥ 44px ─── */
@media (max-width: 768px) {
  .mic-btn, #sendBtn, .prompt-toggle {
    min-width: 44px;
    min-height: 44px;
  }
  .msg-action-btn {
    min-width: 36px;
    min-height: 36px;
    padding: 8px;
  }
  .prompt-item {
    min-height: 36px;
    padding: 8px 14px;
  }
  .voice-header-btn, .reset-btn {
    min-height: 36px;
  }
}

.input-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
  font-weight: 400;
}

.hint-icon {
  display: flex;
  align-items: center;
  opacity: 0.5;
}

/* ─── STATS CARDS (if used) ─── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px 24px;
  flex-shrink: 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--dur) var(--ease-out);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  opacity: 0;
  transition: opacity var(--dur) var(--ease-out);
}

.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

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

.stat-card--verde::before { background: var(--teal); }
.stat-card--dorado::before { background: var(--gold); }
.stat-card--guinda::before { background: var(--burgundy); }
.stat-card--teal::before { background: var(--teal); }

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card--verde .stat-icon { background: var(--teal-dim); color: var(--teal); }
.stat-card--dorado .stat-icon { background: var(--gold-dim); color: var(--gold); }
.stat-card--guinda .stat-icon { background: var(--burgundy-dim); color: var(--burgundy); }
.stat-card--teal .stat-icon { background: var(--teal-dim); color: var(--teal); }

.stat-content { flex: 1; min-width: 0; }

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE BREAKPOINTS
   ═══════════════════════════════════════════ */

/* Tablet landscape */
@media (max-width: 1024px) {
  .msg { max-width: 85%; }
}

/* Tablet */
@media (max-width: 900px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 14px 20px;
  }
}

/* Tablet portrait / large phone */
@media (max-width: 768px) {
  .msg-chart-grid {
    grid-template-columns: 1fr;
  }
  .header {
    padding: 10px 16px;
  }

  .header h1 {
    font-size: 15px;
  }

  .chat-area {
    padding: 16px;
  }

  .input-bar {
    padding: 10px 16px 14px;
  }

  .msg {
    max-width: 90%;
  }
}

/* Phone */
@media (max-width: 480px) {
  .header {
    padding: 8px 12px;
  }

  .header-left { gap: 10px; }

  .header-logo {
    width: 34px;
    height: 34px;
    border-radius: var(--r-sm);
  }

  .header h1 {
    font-size: 13px;
  }

  .header-sub {
    display: none;
  }

  .header-right { gap: 6px; }
  .badge-build { font-size: 9px; padding: 3px 8px; }

  /* Chat */
  .chat-area {
    padding: 10px 10px;
    gap: 12px;
  }

  .msg { max-width: 95%; }

  .msg-avatar, .msg-avatar-user {
    width: 30px;
    height: 30px;
    border-radius: var(--r-sm);
  }
  .msg-avatar {
    width: 46px;
    height: 46px;
    border-radius: var(--r-md);
  }

  .msg-avatar-user svg { width: 16px; height: 16px; }

  .msg-bot, .msg-user { gap: 8px; }

  .msg-bubble-bot {
    padding: 12px 14px;
  }

  .msg-user .msg-bubble {
    padding: 10px 14px;
  }

  .msg-content { font-size: 13px; }

  /* Input */
  .input-bar {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .input-hint { display: none; }

  .input-wrapper {
    border-radius: var(--r-lg);
  }

  .input-wrapper input {
    padding: 10px 6px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  .input-wrapper button {
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
  }

  .mic-btn { width: 34px !important; height: 34px !important; }

  .input-icon { padding: 0 10px 0 12px; }

  /* When virtual keyboard is open, hide non-essential elements */
  body.keyboard-open .site-nav { display: none; }
  body.keyboard-open .header { display: none; }

  body.keyboard-open .chat-area {
    flex: 1;
    min-height: 120px;
  }
}

/* Small phone */
@media (max-width: 360px) {
  .header h1 { font-size: 12px; }
  .header-logo { width: 30px; height: 30px; }
  .msg-content { font-size: 12.5px; }
}

/* Large screens / ultrawide */
@media (min-width: 1400px) {
  .chat-area { padding: 28px 40px; }
  .input-bar { padding: 14px 40px 18px; }
  .header { padding: 12px 40px; }
  .msg { max-width: 70%; }
}

@media (min-width: 1800px) {
  .msg { max-width: 60%; }
  .chat-area { padding: 32px 60px; }
  .input-bar { padding: 16px 60px 20px; }
  .header { padding: 14px 60px; }
}

/* ─── SELECTION & FOCUS ─── */

::selection {
  background: rgba(91, 141, 239, 0.25);
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ─── SCROLLBAR for Firefox ─── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-accent) transparent;
}
