:root {
  --azul: #1447e6;
  --verde: #10b981;
  --navy: #0b1330;
  --gris-fondo: #f4f6fb;
  --gris-borde: #e2e6f0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gris-fondo);
  color: var(--navy);
}

.app {
  max-width: 760px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(90deg, var(--azul), var(--verde));
  color: white;
}

.app-header h1 { font-size: 1.1rem; margin: 0; }

.app-header select {
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
}

.lista-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mensaje {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.mensaje p { margin: 0; }

.mensaje-usuario {
  align-self: flex-end;
  background: var(--azul);
  color: white;
  border-bottom-right-radius: 4px;
}

.mensaje-asistente {
  align-self: flex-start;
  background: white;
  border: 1px solid var(--gris-borde);
  border-bottom-left-radius: 4px;
}

.mensaje-error {
  align-self: flex-start;
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.mensaje-escalado {
  border-left: 4px solid #f59e0b;
}

.fuentes {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #4b5563;
}

.fuentes summary { cursor: pointer; font-weight: 600; }

.form-chat {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  background: white;
  border-top: 1px solid var(--gris-borde);
}

.form-chat textarea {
  flex: 1;
  resize: none;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--gris-borde);
  font-size: 0.95rem;
  font-family: inherit;
  max-height: 120px;
}

.form-chat button {
  padding: 0 20px;
  border: none;
  border-radius: 10px;
  background: var(--azul);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

.form-chat button:disabled {
  opacity: 0.6;
  cursor: default;
}

.indicador-escribiendo {
  align-self: flex-start;
  color: #6b7280;
  font-size: 0.85rem;
  font-style: italic;
}
