/* ===== RESET Y BASE ===== */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

html, body {
  background: var(--bg-primary);
  transition: background-color 0.6s ease;
  color: var(--text-primary);
  font-family: var(--font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  width: 100%;
  margin: auto;
  -ms-overflow-style: none;
  scrollbar-width: thin;
}

body::-webkit-scrollbar {
  display: none;
}

a {
  color: #ffffff;
  text-decoration: underline;
  transition: var(--transition-default);
}

a:hover {
  color: var(--accent-hover);
}


/* ===== SISTEMA DE VARIABLES MODULAR ===== */
:root {
  /* === COLORES PRINCIPALES === */
  --bg-primary: #0F0F0F;
  --bg-secondary: #1e1f21;
  --bg-tertiary: #242424;
  --bg-modal: #1E1E1E;
  --bg-input: #333;
  --bg-hover: rgba(255, 255, 255, 0.08);
  --bg-active: rgba(59, 130, 246, 0.15);
  
  /* === TEXTOS - MEJORADOS PARA CONTRASTE === */
  --text-primary: #E1E2EC;
  --text-secondary: #E1E2EC;      /* Mejorado: antes #f0f0f0 */
  --text-tertiary: #c0c0c0;       /* Mejorado: antes #b0b0b0 (contraste 4.8:1) */
  --text-muted: #a0a0a0;          /* Mejorado: antes #8e8e93 (contraste 4.5:1) */
  --text-hint: #b8b8c0;           /* Mejorado: antes #9ca3af (contraste 5.2:1) */
  
  /* === COLORES DE ACENTO === */
  --accent-color: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.3);
  --accent-opaque: rgba(59, 130, 246, 0.15);
  
  /* === COLORES DE BORDE === */
  --border-default: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.1);
  --border-medium: rgba(255, 255, 255, 0.15);
  --border-strong: rgba(255,255,255,0.311);
  
  /* === BURBUJAS === */
  --user-bubble-color: #0A84FF;
  
  /* === TIPOGRAFÍA === */
  --font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Fira Code', monospace;
  
  /* === TAMAÑOS DE FUENTE ESCALABLES === */
  /* Base en móviles: 16px mínimo para accesibilidad */
  --text-xs: clamp(0.75rem, 0.7rem + 0.3vw, 0.875rem);    /* 12px → 14px */
  --text-sm: clamp(0.875rem, 0.8rem + 0.4vw, 1rem);       /* 14px → 16px */
  --text-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);     /* 16px → 18px */
  --text-md: clamp(1.125rem, 1rem + 0.6vw, 1.25rem);      /* 18px → 20px */
  --text-lg: clamp(1.25rem, 1.1rem + 0.7vw, 1.5rem);      /* 20px → 24px */
  --text-xl: clamp(1.5rem, 1.3rem + 0.8vw, 1.75rem);      /* 24px → 28px */
  --text-2xl: clamp(1.75rem, 1.5rem + 1vw, 2rem);         /* 28px → 32px */
  --text-3xl: clamp(2rem, 1.8rem + 1.2vw, 2.5rem);        /* 32px → 40px */
  
  /* === ESPACIADOS === */
  --spacing-xs: clamp(0.35rem, 0.8rem + 0.3vw, 0.8rem);
  --spacing-sm: clamp(0.5rem, 0.4rem + 0.4vw, 0.75rem);
  --spacing-md: clamp(0.75rem, 0.6rem + 0.5vw, 1rem);
  --spacing-lg: clamp(1.4rem, 0.9rem + 0.6vw, 1.5rem);
  --spacing-xl: clamp(1.5rem, 1.2rem + 0.8vw, 2rem);
  
  /* === BORDES === */
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 30px;
  
  /* === SOMBRAS === */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 20px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 -5px 25px rgba(0, 0, 0, 0.3);
  
  /* === ANIMACIONES === */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-default: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* === LAYOUT === */
  --header-height: 73px;
  --header-height-mobile: 61px;
  --max-chat-width: 700px;
  
  /* === Z-INDEX === */
  --z-header: 1000;
  --z-modal: 10000;
  --z-dropdown: 1000;
  --z-toolbar: 100;
}

/* ===== SISTEMA DE CURSOR RESPONSIVE ===== */
/* Desktop: cursor pointer */
@media (hover: hover) and (pointer: fine) {
  button,
  .community-btn,
  .settings-tab-btn,
  .custom-select-trigger,
  .custom-select-option,
  .settings-switch-slider,
  .toolbar-btn,
  .send-btn {
    cursor: pointer;
  }
}

/* Móviles y tablets táctiles: cursor default */
@media (hover: none) and (pointer: coarse) {
  button,
  .community-btn,
  .settings-tab-btn,
  .custom-select-trigger,
  .custom-select-option,
  .settings-switch-slider,
  .toolbar-btn,
  .send-btn {
    cursor: default;
  }
}

/* ===== PREFERS-REDUCED-MOTION ===== */
@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;
  }
  
  .message-container {
    scroll-behavior: auto !important;
  }
}

/* ===== NUEVO HEADER MINIMALISTA ===== */

.alondra-header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-header);
    background: var(--bg-primary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.alondra-header__container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.50rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* ===== LADO IZQUIERDO ===== */
.alondra-header__left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
}

/* ===== CENTRO ===== */
.alondra-header__center {
    padding: 4px 5px;
    border-radius: 26px;
    flex: 1;
    min-width: 0; /* ← CRUCIAL para que el truncado funcione */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow: hidden; /* ← ayuda al truncado */
}

.alondra-chat__theme {
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: -0.3px;
    white-space: nowrap;
    max-width: 100%; /* ← importante para truncar */
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
}

.brand-alondra{
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== LADO DERECHO ===== */
.alondra-header__right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== BOTONES ICONOS BASE ===== */
.alondra-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-secondary);
}

.alondra-icon-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.05);
}

/* === TAMAÑOS POR DEFECTO (DESKTOP) === */
.alondra-icon-btn--settings,
.alondra-icon-btn--newchat {
    width: 40px;
    height: 40px;
}

/* Versiones móviles (ocultas en desktop) */
.alondra-icon-btn--settings-mobile,
.alondra-icon-btn--newchat-mobile {
    display: none;
    width: 40px;
    height: 40px;
}

/* ===== RESPONSIVE ===== */

/* Tablets y móviles grandes (< 768px) */
@media screen and (max-width: 768px) {
    .alondra-header__container {
        padding: 0.6rem 1rem;
    }
    
    .alondra-brand__name {
        font-size: 1.1rem;
    }
    
    /* Ocultar versiones desktop, mostrar móviles */
    .alondra-icon-btn--settings,
    .alondra-icon-btn--newchat {
        display: none;
    }
    
    .alondra-icon-btn--settings-mobile,
    .alondra-icon-btn--newchat-mobile {
        display: flex;
        width: 35px;
        height: 35px;
    }
}

/* Móviles pequeños (< 480px) */
@media screen and (max-width: 480px) {
    .alondra-header__container {
        padding: 0.5rem 0.875rem;
    }
    
    .alondra-brand__name {
        font-size: 1rem;
    }
    
    .alondra-icon-btn--settings-mobile,
    .alondra-icon-btn--newchat-mobile {
        width: 35px;
        height: 35px;
    }
}

/* Pantallas grandes (> 1400px) */
@media screen and (min-width: 1400px) {
    .alondra-header__container {
        padding: 0.875rem 2rem;
    }
    
    .alondra-brand__name {
        font-size: 1.35rem;
    }
    
    .alondra-icon-btn--settings,
    .alondra-icon-btn--newchat {
        width: 44px;
        height: 44px;
    }
}


/* ===== REDUCCIÓN DE MOVIMIENTO ===== */
@media (prefers-reduced-motion: reduce) {
    .alondra-icon-btn {
        transition: none;
    }
    .alondra-icon-btn:hover {
        transform: none;
    }
}

/* --------------------------------------------
   7. ACCESIBILIDAD - MEJORADO
--------------------------------------------- */
/* Focus visible para todos los elementos interactivos */
.settings-tab-btn:focus-visible,
.settings-modal-close:focus-visible,
.custom-select-trigger:focus-visible,
.settings-btn:focus-visible,
.toolbar-btn:focus-visible,
.send-btn:focus-visible,
.chip:focus-visible,
.action-btn:focus-visible,
.rate-limit-acknowledge-btn:focus-visible {
    outline: 3px solid #3b82f6;
    outline-offset: 3px;
    position: relative;
    z-index: 10;
}

/* ===== MODAL CONFIGURACIÓN ===== */
.settings-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8); /* Mejorado: antes 0.7 */
  z-index: var(--z-modal);
  display: none;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.settings-modal-overlay.active {
  display: flex;
  opacity: 1;
}

.settings-modal {
  width: 100%;
  max-width: 580px;
  height: 98vh;
  max-height: 95vh;
  background: var(--bg-modal);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  overflow: hidden;
  animation: modalSlideUp var(--transition-slow) cubic-bezier(0.2, 0.9, 0.4, 1.1);
  box-shadow: var(--shadow-modal);
}

@keyframes modalSlideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Header modal */
.settings-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg) var(--spacing-xl);
  background: var(--bg-modal);
  flex-shrink: 0;
}

.settings-modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.settings-modal-close {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition-default);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.settings-modal-close:hover {
  background: var(--bg-hover);
}

/* Tabs */
.settings-tabs-nav {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  overflow-x: auto;
  scrollbar-width: thin;
  flex-shrink: 0;
  background: var(--bg-modal);
}

.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-md) var(--spacing-lg);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: #d0d0d0; /* Mejorado: antes var(--text-primary) que era blanco sobre gris claro */
  transition: var(--transition-default);
  white-space: nowrap;
  flex-shrink: 0;
}

.settings-tab-btn.active-tab {
  color: var(--text-primary);
  background: #444;
}

/* Contenido tabs */
.settings-tabs-content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--spacing-xl);
  scrollbar-width: thin;
  background: var(--bg-modal);
  min-height: 0;
}

.settings-tab-pane {
  display: none;
  animation: fadeIn var(--transition-fast);
}

.settings-tab-pane.active-pane {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Secciones */
.settings-section {
  padding: 10px 8px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  margin: 20px 0;
  padding: 10px 0;
}

.profile-container {
  padding: var(--spacing-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-name {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid #444;
  background: #383838;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: var(--transition-default);
}

.profile-initial {
  font-size: var(--text-2xl);
  text-transform: uppercase;
  color: var(--text-primary);
}

.settings-section-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: var(--radius-md);
  padding: 15px 20px;
  background: #292929;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Inputs */
.settings-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 15px 20px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  transition: var(--transition-default);
  box-sizing: border-box;
}

.settings-input:focus {
  outline: none;
  border-color: var(--border-strong);
  background: #555;
}

.settings-input::placeholder {
  color: #b0b0b8; /* Mejorado: antes #8e8e93 (contraste 4.6:1) */
}

/* Botones de acción */
.settings-button-group {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-md);
}

.settings-btn {
  padding: 10px 15px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  transition: var(--transition-default);
  border: none;
}

.settings-btn-primary {
  background: var(--accent-color);
  color: var(--text-primary);
}


.settings-btn-secondary {
  background: transparent;
  color: #f87474;
  border: 1px solid #f87474;
}

/* Textos de ayuda - CONTRASTE MEJORADO */
.settings-input-hint,
.settings-select-hint,
.settings-switch-hint {
  font-size: var(--text-xs);
  color: #c0c0c8; /* Mejorado: antes #9ca3af (contraste 6.2:1) */
  margin-top: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  line-height: 1.5;
}

/* Custom Select */
.custom-select {
  position: relative;
  width: 100%;
  user-select: none;
}

.custom-select-trigger {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: var(--transition-default);
}

.custom-select-trigger:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-medium);
}

.custom-select.open .custom-select-trigger {
  border-color: var(--border-strong);
  background: rgba(0, 0, 0, 0.5);
}

.custom-select-value {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 400;
}

.custom-select-arrow {
  font-size: 0.65rem;
  color: #c0c0c8; /* Mejorado: antes #8e8e93 (contraste 4.8:1) */
  transition: transform var(--transition-fast);
}

.custom-select.open .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-modal);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  max-height: 240px;
  overflow-y: auto;
  z-index: var(--z-dropdown);
  display: none;
  box-shadow: var(--shadow-lg);
}

.custom-select.open .custom-select-dropdown {
  display: block;
}

.custom-select-option {
  padding: 15px 20px;
  transition: background var(--transition-fast);
  font-size: var(--text-sm);
  color: #d0d0d8; /* Mejorado: antes #b0b0b0 (contraste 5.5:1) */
  border-bottom: 1px solid var(--border-default);
}

.custom-select-option:last-child {
  border-bottom: none;
}

.custom-select-option:hover {
  background: var(--bg-hover);
}

.custom-select-option.selected {
  background: var(--bg-active);
  color: var(--text-primary);
}

.custom-select-option strong {
  display: block;
  font-size: var(--text-sm);
  margin-bottom: 2px;
}

.custom-select-option small {
  display: block;
  font-size: var(--text-xs);
  color: #b0b0b8; /* Mejorado: antes #8e8e93 (contraste 4.6:1) */
  margin-top: 2px;
}

/* Slider Temperatura */
.slider-modern-container {
  width: 100%;
  padding: var(--spacing-xs) 0;
}

.slider-modern-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.slider-label-precise,
.slider-label-creative {
  font-size: var(--text-xs);
  color: #c8c8d0; /* Mejorado: antes #b0b0b0 (contraste 5.2:1) */
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.slider-value {
  background: var(--bg-input);
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.slider-modern-track {
  position: relative;
  width: 100%;
  height: 4px;
  background: var(--border-soft);
  border-radius: var(--radius-full);
  margin: var(--spacing-lg) 0;
}

.slider-modern-fill {
  position: absolute;
  height: 100%;
  background: var(--accent-color);
  border-radius: var(--radius-full);
  pointer-events: none;
  transition: width 0.05s linear;
}

.slider-modern-thumb {
  position: absolute;
  width: 16px;
  height: 16px;
  background: var(--text-primary);
  border-radius: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast);
  pointer-events: auto;
}

.slider-modern-thumb:hover {
  transform: translate(-50%, -50%) scale(1.15);
}

.slider-modern-scale {
  display: flex;
  justify-content: space-between;
  margin-top: var(--spacing-sm);
  padding: 0 2px;
}

.slider-modern-scale span {
  font-size: var(--text-xs);
  color: #c0c0c8; /* Mejorado: antes #9ca3af (contraste 5.2:1) */
  font-family: var(--font-mono);
}

/* Switch */
.settings-switch-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.settings-switch-label {
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 400;
}

.settings-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.settings-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.settings-switch-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-medium);
  transition: var(--transition-fast);
  border-radius: 34px;
}

.settings-switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-primary);
  transition: var(--transition-fast);
  border-radius: 50%;
}

.settings-switch input:checked + .settings-switch-slider {
  background-color: var(--accent-color);
}

.settings-switch input:checked + .settings-switch-slider:before {
  transform: translateX(22px);
}

/* Color preview */
.color-preview {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin-right: var(--spacing-sm);
  vertical-align: middle;
  box-shadow: var(--shadow-sm);
}

.custom-select-value .color-preview {
  width: 16px;
  height: 16px;
  margin-right: var(--spacing-xs);
}

.custom-select-option .color-preview {
  width: 16px;
  height: 16px;
  margin-right: var(--spacing-sm);
}

/* Versión */
.version-website {
  text-align: center;
  font-size: var(--text-xs);
  color: #b0b0b8; /* Mejorado: antes #9ca3af (contraste 5.2:1) */
  padding: var(--spacing-lg) var(--spacing-xl);
  margin: 0;
  border-top: 1px solid var(--border-default);
  flex-shrink: 0;
  background: var(--bg-modal);
}

/* ===== CHAT CONTAINER ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100% - var(--header-height));
  width: 100%;
  max-width: var(--max-chat-width);
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* Message Container */
.message-container {
  flex: 1;
  overflow-y: auto;
  padding: 15px 0;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
  scroll-behavior: smooth;
}

/* Mensajes */
.message-ia,
.message-user {
  display: flex;
  flex-direction: column;
  animation: fadeIn var(--transition-slow) ease-out;
}

.message-user {
  align-items: flex-end;
  padding: 10px 0;
}

/* Burbujas */
.bubble {
  max-width: 100%;
  border-radius: 26px;
  padding: 0.6rem 1.12rem;
  line-height: 1.7;
  font-size: var(--text-base);
  position: relative;
  transition: var(--transition-default);
  hyphens: auto;
}

.bot-bubble {
  color: var(--text-secondary);
  align-self: flex-start;
}

.user-bubble {
  color: var(--text-primary);
  align-self: flex-end;
  margin: 0 14px;
  max-width: 85% !important;
  border-bottom-right-radius: 4px;
}

/* Acciones del mensaje */
.message-actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 3px 10px;
  margin: 4px 6px;
  opacity: 0;
  transition: var(--transition-default);
}

.message-ia:hover .message-actions,
.message-user:hover .message-actions {
  opacity: 1;
}

/* Para dispositivos táctiles, mostrar siempre las acciones */
@media (hover: none) and (pointer: coarse) {
  .message-actions {
    opacity: 1;
  }
}

.action-btn {
  width: 30px;
  height: 30px;
  color: #cccc;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
}

.action-btn:hover {
  background: #333;
}


/* Streaming */
#streaming-message .bubble {
  transition: all 0.1s ease;
}

#streaming-message .message-actions {
  opacity: 0;
  transition: opacity var(--transition-slow);
}

.message-ia:not(#streaming-message) .message-actions {
  opacity: 1;
}

/* Área de mensaje */
.message-area {
  padding: var(--spacing-lg) var(--spacing-lg);
  transition: var(--transition-default);
  position: relative;
  width: 100%;
}

@media screen and (min-width: 1024px) {
  .message-area:not(.sticky) {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    border-top: none;
    background: transparent;
  }
}

.message-area.sticky {
  position: sticky;
  bottom: 0;
  background: var(--bg-primary);
  z-index: var(--z-toolbar);
}

/* Input container */
.input-container {
  display: flex;
  flex-direction: column;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  padding: 10px 10px;
  border-radius: 26px;
  margin: 0 5px;
}

.textarea-wrapper {
  background: transparent;
  border-radius: 15px;
  border: none;
  transition: var(--transition-default);
  overflow: hidden;
  background: var(--bg-tertiary);
}

.chat-textarea {
  width: 100%;
  min-height: 35px;
  max-height: 200px;
  border: none;
  padding: 8px 4px;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: var(--text-base);
  line-height: 1.5;
  resize: none;
  outline: none;
}

.chat-textarea::placeholder {
  color: #b8b8c0; /* Mejorado: antes #b0b0b0 (contraste 5.2:1) */
  opacity: 0.8;
  font-size: var(--text-base);
}

/* Toolbar */
.input-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  gap: var(--spacing-xs);
  align-items: center;
}

.toolbar-btn {
  width: auto;
  padding: var(--spacing-xs) var(--spacing-md);
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-primary);
  gap: var(--spacing-xs);
  border: 1px solid var(--border-strong);
  font-weight: 400;
  font-size: var(--text-base);
  border-radius: 50px;
  transition: var(--transition-default);
}

.active-btn {
  background-color: var(--accent-opaque);
  border: 1px solid var(--accent-soft);
  color: var(--accent-color);
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50px;
  background-color: var(--accent-soft);
  border: 1px solid var(--accent-opaque);
  color: #e0e0e0; /* Mejorado: antes #cccc (contraste 5.5:1 sobre fondo) */
}

.send-btn-active {
  background: var(--accent-color);
  color: #ffffff;
}

.note-hint {
  font-size: var(--text-xs);
  color: #d0d0d8; /* Mejorado: antes #ffffff (se mantiene legible) */
  margin-top: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
  line-height: 1.5;
  text-align: center;
}

/* ===== WELCOME CHAT ===== */
.welcome-chat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 0 15px;
    gap: 1.5rem;
    height: 100%;
}

.welcome-header h2 {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 5px;
}

.welcome-header h1 {
    color: #ffffff;
    font-size: 1.8rem;
    font-weight: 500;
    margin: 0;
}

/* Contenedor base para Móviles (Vertical) */
.chips-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    animation: lucidFade 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s backwards;
}

.chip {
    background: #101112;
    border: 1px solid var(--border-soft);
    color: var(--text-primary);
    padding: 15px 18px;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    transition: background 0.3s ease;
    white-space: nowrap;
    width: auto;
}

.chip:hover {
    background: #333;
}

@keyframes lucidFade {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tablets, Laptops y PCs (Grid) */
@media screen and (min-width: 768px) {
    .welcome-chat {
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      padding: 80px 15px;
      margin: 15px 0;
      gap: 1.5rem;
    }
    .chips-container {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); 
    }
    
    .chip {
      width: 100%;
    }
}

/* ===== ESTILOS DE MARKDOWN PARA BOT-BUBBLE ===== */
.bot-bubble em,
.bot-bubble i {
  font-style: italic;
  color: var(--text-secondary);
}

.bot-bubble hr {
    border: none;
    height: 1px;
    background: #333;
    margin: 1.5rem 0;
}

.bot-bubble strong,
.bot-bubble b {
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

/* .bot-bubble strong {
  background-image: repeating-linear-gradient(
    90deg,
    var(--text-tertiary),
    var(--text-tertiary) 2px,
    transparent 2px,
    transparent 5px
  );
  background-repeat: repeat-x;
  background-position: bottom;
  background-size: 4px 2px;
  padding-bottom: 2px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
} */

.bot-bubble h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin: var(--spacing-xl) 0 var(--spacing-lg) 0;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: none;
}

.bot-bubble h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: var(--spacing-lg) 0 var(--spacing-md) 0;
  color: var(--text-primary);
  line-height: none;
}

.bot-bubble h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: var(--spacing-lg) 0 var(--spacing-sm) 0;
  color: var(--text-primary);
  line-height: none;
}

.bot-bubble p {
  color: var(--text-secondary);
  font-size: var(--text-base);
}

.bot-bubble ul,
.bot-bubble ol {
  margin: var(--spacing-md) 0 var(--spacing-md) var(--spacing-xl);
  padding: 0;
  color: var(--text-secondary);
}

.bot-bubble li {
  margin: var(--spacing-xs) 0;
}

.bot-bubble a {
  color: var(--accent-color);
  border-bottom: 1px solid transparent;
  transition: var(--transition-fast);
}

.bot-bubble a:hover {
  border-bottom-color: var(--accent-color);
  color: var(--accent-hover);
}

.bot-bubble .table-wrapper {
  width: 100%;
  padding: 5px 8px;
  overflow-x: auto;
  margin: var(--spacing-lg) 0;
  border-radius: var(--radius-md);
}

.bot-bubble table {
  border-collapse: collapse;
  white-space: nowrap;
  font-size: var(--text-sm);
  background-color: var(--bg-primary);
  border-radius: var(--radius-md);
}

.bot-bubble th {
  padding: 5px 8px;
  text-align: left;
  font-weight: 700;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.bot-bubble td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-strong);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
}

.bot-bubble blockquote {
  margin: var(--spacing-lg) 0;
  padding: var(--spacing-md) var(--spacing-lg) var(--spacing-md) var(--spacing-xl);
  border-left: 4px solid var(--accent-color);
  background-color: var(--bg-active);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-tertiary);
  font-style: italic;
}

/* ===== RESPONSIVE GLOBAL ===== */
@media screen and (max-width: 1024px) {
  .chat-container {
    height: calc(100% - var(--header-height-mobile));
  }
  
  .user-bubble {
    max-width: 85% !important;
  }
  
  .message-area {
    padding: var(--spacing-md) var(--spacing-md);
  }
}

@media screen and (max-width: 768px) {
  .chat-container {
    height: calc(100% - var(--header-height-mobile));
  }
  
  .message-container {
    padding: 15px 0;
    gap: var(--spacing-lg);
  }
  
  .user-bubble {
    max-width: 85% !important;
  }
  
  .message-actions {
    opacity: 1;
    transform: none;
  }
  
  .message-area {
    padding: var(--spacing-sm) var(--spacing-sm) var(--spacing-lg); 
  }
  
  .send-btn {
    width: 30px;
    height: 30px;
  }
  
  
  .chat-textarea {
    min-height: 45px;
  }
}

@media screen and (max-width: 640px) {
  .settings-modal-overlay {
    align-items: flex-end;
  }
  
  .settings-modal {
    width: 100%;
    max-height: 98%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: modalSlideUpMobile var(--transition-slow);
  }
  
  @keyframes modalSlideUpMobile {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
  
  .settings-modal-header {
    padding: var(--spacing-md) var(--spacing-lg);
  }
  
  .settings-tab-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-sm);
  }
  
  .settings-tabs-content {
    padding: var(--spacing-lg);
  }
  
  .settings-button-group {
    gap: var(--spacing-sm);
    display: flex;
  }
  
  .settings-btn {
    width: 100%;
    text-align: center;
  }
}

@media screen and (max-width: 480px) {

  .user-bubble {
    max-width: 85% !important;
  }
  
  .settings-tab-btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--text-sm);
  }
  
  .settings-tabs-content {
    padding: var(--spacing-md);
  }
  
  .input-toolbar {
    gap: var(--spacing-xs);
  }
  
  .toolbar-left {
    gap: var(--spacing-xs);
  }
  
  .toolbar-btn {
    width: 30px;
    height: 30px;
  }
  
  .toolbar-btn svg {
    flex-shrink: 0;
  }
  
  .toolbar-btn > .btn-text {
    display: none;
  }
}