#td-chat {
  max-width: 100%;
  margin: 20px auto;
  background: rgba(0,0,0,0.1);
  color: #fff;
  /*padding: 20px;*/
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  backdrop-filter: blur(4px);
}

#td-chat .td-chat-messages {
  max-height: 30vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.td-bubble {
  /*background: rgba(255,255,255,0.1);*/
  padding: 10px 14px;
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
  line-height: 1.5;
  white-space: pre-line;
  backdrop-filter: blur(4px);
}

.td-cursor {
  display: inline-block;
  width: 1px;
  height: 1em;
  background: #fff;
  margin-left: 2px;
  animation: td-blink 1s steps(1) infinite;
}

.td-thinking {
  opacity: 0.8;
  font-style: italic;
}

.td-dots::after {
  content: '...';
  display: inline-block;
  overflow: hidden;
  width: 0;
  animation: td-ellipsis 1s steps(3, end) infinite;
}

@keyframes td-ellipsis {
  to { width: 1.5em; }
}

@keyframes td-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* Ajustes específicos para dispositivos móviles */
@media screen and (max-width: 767px) {
  #td-chat .td-chat-messages {
    max-height: 100vh;   /* Mayor altura para móviles */
    gap: 8px;            /* Menor separación entre mensajes */
    padding: 0 1em;      /* Añadir padding lateral */
  }
}

/* Ajustes para pantallas muy pequeñas (portrait phones) */
@media screen and (max-width: 480px) {
  #td-chat .td-chat-messages {
    max-height: 100vh;     /*Aún más altura en móviles pequeños */
    gap: 6px;
  }
}
