:root {
  --bg: #0a0e17;
  --bg-soft: #121826;
  --text: #e8edf7;
  --muted: #8a94a8;
  --dormido: #3a4660;
  --despierto: #2fe6c4;
  --pensando: #ffb347;
  --hablando: #6aa9ff;
  --user: #2a3550;
  --eco: #1a3a36;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: radial-gradient(circle at 50% 0%, #141b2e 0%, var(--bg) 60%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100%;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.head { text-align: center; }
.head h1 {
  margin: 0;
  font-size: 2.5rem;
  letter-spacing: 0.35em;
  font-weight: 700;
  background: linear-gradient(90deg, var(--despierto), var(--hablando));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hint { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.95rem; }

/* ----- Orbe ----- */
.orb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.orb {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  transition: box-shadow 0.4s ease, background 0.4s ease;
}

.orb-core {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: currentColor;
  transition: transform 0.3s ease, background 0.4s ease;
}

/* Estado: dormido (escucha pasiva) */
.orb.estado-dormido {
  color: var(--dormido);
  box-shadow: 0 0 40px -10px var(--dormido);
}
.orb.estado-dormido .orb-core { animation: respira 4s ease-in-out infinite; }

/* Estado: despierto (capturando orden) */
.orb.estado-despierto {
  color: var(--despierto);
  box-shadow: 0 0 70px -5px var(--despierto);
}
.orb.estado-despierto .orb-core { animation: pulso 1.1s ease-in-out infinite; }

/* Estado: pensando */
.orb.estado-pensando {
  color: var(--pensando);
  box-shadow: 0 0 70px -5px var(--pensando);
}
.orb.estado-pensando .orb-core { animation: gira 1.2s linear infinite; }

/* Estado: hablando */
.orb.estado-hablando {
  color: var(--hablando);
  box-shadow: 0 0 80px -5px var(--hablando);
}
.orb.estado-hablando .orb-core { animation: ondula 0.6s ease-in-out infinite; }

@keyframes respira {
  0%, 100% { transform: scale(0.92); opacity: 0.75; }
  50%      { transform: scale(1.0); opacity: 1; }
}
@keyframes pulso {
  0%, 100% { transform: scale(0.9); }
  50%      { transform: scale(1.12); }
}
@keyframes gira {
  0%   { transform: rotate(0deg) scale(1); border-radius: 50% 50% 50% 50%; }
  50%  { transform: rotate(180deg) scale(0.85); border-radius: 45% 55% 50% 50%; }
  100% { transform: rotate(360deg) scale(1); border-radius: 50%; }
}
@keyframes ondula {
  0%, 100% { transform: scale(1); }
  25%      { transform: scale(1.1); }
  50%      { transform: scale(0.95); }
  75%      { transform: scale(1.08); }
}

.estado-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ----- Aviso de soporte ----- */
.aviso {
  width: 100%;
  background: #3a1a1a;
  border: 1px solid #6b2b2b;
  color: #ffd7d7;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.oculto { display: none; }

/* ----- Transcripción en vivo ----- */
.interim {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

/* ----- Registro de conversación ----- */
.registro {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

.msg {
  max-width: 85%;
  padding: 0.6rem 0.9rem;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 0.98rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.user {
  align-self: flex-end;
  background: var(--user);
  border-bottom-right-radius: 4px;
}
.msg.eco {
  align-self: flex-start;
  background: var(--eco);
  border-bottom-left-radius: 4px;
}
.msg .quien {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

/* ----- Controles ----- */
.foot {
  margin-top: 0.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

/* Botón único: mantener pulsado para hablar */
.ptt {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--bg-soft);
  color: var(--text);
  border: 2px solid #2a3550;
  padding: 1rem 1.8rem;
  border-radius: 999px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none; /* evita scroll/zoom al mantener pulsado en móvil */
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s,
    box-shadow 0.2s;
}
.ptt:hover { border-color: var(--despierto); }
.ptt:focus-visible { outline: none; border-color: var(--despierto); }

/* Mientras se mantiene pulsado */
.ptt.pulsado {
  background: var(--despierto);
  color: #062b25;
  border-color: var(--despierto);
  transform: scale(0.97);
  box-shadow: 0 0 50px -8px var(--despierto);
}
.ptt-ico { font-size: 1.3rem; line-height: 1; }

/* Botón estándar (Enviar del formulario de texto) */
.btn {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid #2a3550;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn:hover { background: #1a2336; border-color: var(--despierto); }

/* Formulario de texto (alternativa universal) */
.form-texto {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 480px;
}
.form-texto input {
  flex: 1;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid #2a3550;
  border-radius: 999px;
  padding: 0.7rem 1.1rem;
  font-size: 0.95rem;
}
.form-texto input:focus {
  outline: none;
  border-color: var(--despierto);
}
.form-texto input::placeholder { color: var(--muted); }
