:root {
  --bg: #0b1220;
  --card: rgba(17, 27, 46, 0.85);
  --text: #e8eefc;
  --muted: #a8b3d6;
  --accent: #6aa6ff;
  --danger: #ff5c7a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 20% 10%, #1a2a50, var(--bg));
  color: var(--text);
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.header p { color: var(--muted); margin-top: 6px; }

.card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px;
  margin-top: 16px;
  backdrop-filter: blur(6px);
}

.row {
  display: grid;
  grid-template-columns: 120px 1fr 120px 1fr 140px 1fr;
  gap: 10px;
  align-items: center;
}

input, select, button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.2);
  color: var(--text);
  padding: 10px 12px;
}

.actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions > button {
  width: auto;
}

button { cursor: pointer; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

#btnStart { border-color: rgba(106,166,255,0.6); }
#btnStop  { border-color: rgba(255,92,122,0.6); }

.tutor {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(240px, 260px) 1fr;
  gap: 14px;
  align-items: center;
}

.avatarWrap .hint { margin-top: 8px; color: var(--muted); font-size: 12px; }

.avatar {
  width: 100%;
  max-width: 240px;
  height: 160px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  background:
    radial-gradient(circle at 35% 35%, rgba(106,166,255,0.9), rgba(106,166,255,0.0) 55%),
    radial-gradient(circle at 70% 70%, rgba(255,92,122,0.6), rgba(255,92,122,0.0) 55%),
    rgba(0,0,0,0.22);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
}

.face {
  width: 140px;
  height: 120px;
  border-radius: 999px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.10);
  position: relative;
}

.eye {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.85);
  position: absolute;
  top: 42px;
}
.eye.left { left: 44px; }
.eye.right { right: 44px; }

.mouth {
  width: 48px;
  height: 14px;
  border-radius: 0 0 14px 14px;
  background: rgba(255,255,255,0.78);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 74px;
}

/* Estados */
.avatar.listening {
  outline: 2px solid rgba(106,166,255,0.55);
  animation: listeningPulse 0.7s infinite alternate;
}

.avatar.talking {
  outline: 2px solid rgba(255,92,122,0.55);
}

.avatar.talking .mouth {
  animation: talk 0.14s infinite alternate;
}

@keyframes talk {
  from { height: 10px; width: 44px; opacity: 0.75; }
  to   { height: 26px; width: 54px; opacity: 0.95; }
}

@keyframes listeningPulse {
  from { transform: scale(1.00); filter: brightness(1.0); }
  to   { transform: scale(1.01); filter: brightness(1.12); }
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.08);
  padding: 10px;
  border-radius: 12px;
  min-height: 72px;
  color: var(--text);
}

/* Responsive */
@media (max-width: 900px) {
  .row {
    grid-template-columns: 120px 1fr;
  }

  .tutor {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .avatar {
    max-width: 100%;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .container { padding: 16px; }

  .row {
    grid-template-columns: 1fr;
  }

  .actions > button {
    width: 100%;
  }

  .avatar {
    height: 150px;
  }
}

.loading {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: grid;
    place-items: center;
    z-index: 9999;
}

    .loading.hidden {
        display: none;
    }

.loadingCard {
    width: min(420px, calc(100vw - 32px));
    background: rgba(17, 27, 46, 0.95);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    backdrop-filter: blur(8px);
}

.loadingTitle {
    margin-top: 10px;
    font-weight: 700;
}

.loadingText {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.spinner {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    border-radius: 999px;
    border: 4px solid rgba(255,255,255,0.18);
    border-top-color: rgba(106,166,255,0.95);
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }