:root {
  --bg: #0a0a0b;
  --bg-elev: #161618;
  --fg: #f4f4f5;
  --muted: #a1a1aa;
  --green: #34c759;
  --green-dim: #1f7a38;
  --red: #ff3b30;
  --blue: #0a84ff;
  --pad: #2c2c2e;
  --pad-active: #3a3a3c;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "SF Pro Display", "Segoe UI", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-bottom));
}

/* Formularios ocultos en llamadas / pantallas */
form[hidden],
#text-bar[hidden],
.lock-wrap[hidden],
.screen[hidden] {
  display: none !important;
}

/* —— Bloqueo código —— */
.lock-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
  max-width: 22rem;
  margin: 0 auto;
  width: 100%;
}

.brand-wordmark {
  display: block;
  width: min(100%, 20rem);
  height: auto;
  margin: 0 auto;
  object-fit: contain;
}

.brand-wordmark-sm {
  width: min(100%, 15rem);
}

.lock-wrap h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.lock-wrap .brand-wordmark {
  width: min(100%, 18rem);
  max-height: none;
}

.lock-wrap p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

@media (max-height: 700px) {
  .lock-wrap {
    gap: 1rem;
    justify-content: flex-start;
    padding-top: 0.75rem;
  }

  .lock-wrap .brand-wordmark {
    width: min(100%, 14rem);
  }
}

#lock-code {
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid #3f3f46;
  background: var(--bg-elev);
  color: var(--fg);
  font-size: 1.5rem;
  letter-spacing: 0.35em;
  text-align: center;
  text-transform: uppercase;
}

#lock-code:focus {
  outline: 2px solid var(--blue);
  border-color: transparent;
}

.btn-primary {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 0.95rem 1rem;
  background: var(--green);
  color: #041208;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
}

.btn-primary:active {
  filter: brightness(0.92);
}

.error {
  color: #ff6961;
  font-size: 0.9rem;
  margin: 0;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.install-box {
  margin-top: 1.25rem;
  text-align: center;
}

.btn-install {
  width: 100%;
  border: 1px solid var(--blue);
  border-radius: 12px;
  padding: 0.8rem 1rem;
  background: transparent;
  color: var(--blue);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
}

.btn-install:active {
  filter: brightness(0.85);
}

.install-help {
  margin: 0.75rem 0 0;
}

.link-formador {
  color: var(--blue);
  text-decoration: none;
  font-size: 0.9rem;
  text-align: center;
}

.nav-instructor {
  margin-top: 1.5rem;
  text-align: center;
}

.nav-instructor .link-formador {
  display: inline-block;
  padding: 0.5rem 0.75rem;
}

/* —— Marcador —— */
#screen-dial {
  justify-content: flex-start;
  gap: 0.35rem;
  padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
  padding-bottom: calc(0.75rem + var(--safe-bottom));
  max-width: 28rem;
  margin: 0 auto;
  width: 100%;
}

.dial-header {
  text-align: center;
  padding-top: 0.15rem;
  flex-shrink: 0;
}

.dial-header .brand-wordmark {
  width: min(78vw, 16rem);
  max-height: none;
  margin-bottom: 0;
  object-fit: contain;
  object-position: center;
}

#dial-display {
  min-height: 2.25rem;
  margin: 0.55rem 0 0.15rem;
  text-align: center;
  font-size: clamp(1.55rem, 6.5vw, 2.2rem);
  letter-spacing: 0.18em;
  font-weight: 300;
}

.dial-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(0.45rem, 1.8vw, 0.75rem);
  max-width: 17.5rem;
  margin: 0.35rem auto 0;
  width: 100%;
  flex: 1 1 auto;
  align-content: center;
}

.dial-pad button {
  aspect-ratio: 1;
  width: 100%;
  max-width: 4.6rem;
  justify-self: center;
  border: none;
  border-radius: 50%;
  background: var(--pad);
  color: var(--fg);
  font-size: clamp(1.35rem, 5.2vw, 1.7rem);
  cursor: pointer;
  padding: 0;
}

.dial-pad button:active {
  background: var(--pad-active);
}

.dial-pad .sub {
  display: block;
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 0.1rem;
}

.dial-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(1.5rem, 8vw, 2.5rem);
  margin-top: 0.55rem;
  flex-shrink: 0;
}

.btn-round {
  width: 4.25rem;
  height: 4.25rem;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--pad);
}

.dial-actions .btn-round {
  width: 3.75rem;
  height: 3.75rem;
}

.btn-round.call {
  background: var(--green);
}

.dial-actions .btn-round.call {
  width: 4.15rem;
  height: 4.15rem;
}

.btn-round.hang {
  background: var(--red);
}

.btn-round.active {
  outline: 2px solid #fff;
}

.btn-round svg {
  width: 1.75rem;
  height: 1.75rem;
  fill: currentColor;
}

.dial-actions .btn-round svg {
  width: 1.6rem;
  height: 1.6rem;
}

#dial-hint,
#dial-error {
  text-align: center;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

#screen-dial .nav-instructor {
  margin-top: 0.35rem;
  flex-shrink: 0;
}

@media (min-height: 760px) and (min-width: 400px) {
  .dial-header .brand-wordmark {
    width: min(72vw, 17rem);
  }

  .dial-pad {
    max-width: 19rem;
    gap: 0.8rem;
    margin-top: 0.75rem;
  }

  .dial-pad button {
    max-width: 5rem;
  }

  .dial-actions {
    margin-top: 1.1rem;
  }
}

@media (max-height: 700px) {
  .dial-header .brand-wordmark {
    width: min(75vw, 13.5rem);
  }

  #dial-display {
    min-height: 1.85rem;
    margin: 0.25rem 0 0;
    font-size: 1.45rem;
  }

  .dial-pad {
    gap: 0.4rem;
    max-width: 15.5rem;
    margin-top: 0.15rem;
  }

  .dial-pad button {
    max-width: 3.85rem;
    font-size: 1.3rem;
  }

  .dial-pad .sub {
    display: none;
  }

  .dial-actions {
    margin-top: 0.35rem;
    gap: 1.4rem;
  }

  .dial-actions .btn-round {
    width: 3.35rem;
    height: 3.35rem;
  }

  .dial-actions .btn-round.call {
    width: 3.7rem;
    height: 3.7rem;
  }

  #screen-dial {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

/* —— Llamada —— */
.call-screen {
  justify-content: space-between;
  background: radial-gradient(ellipse at 50% 0%, #1c1c1f 0%, var(--bg) 55%);
}

.call-top {
  text-align: center;
  padding-top: 2.5rem;
}

.call-avatar {
  width: 5.5rem;
  height: 5.5rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a2a2e, #121214);
  display: grid;
  place-items: center;
  border: 1px solid #3f3f46;
}

.call-avatar svg {
  width: 2.5rem;
  height: 2.5rem;
  fill: var(--muted);
}

#call-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 600;
}

#call-status {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

#call-timer {
  margin-top: 0.5rem;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  color: var(--green);
  min-height: 1.4em;
}

.wave {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 5px;
  height: 2.5rem;
  margin: 1.75rem 0;
}

.wave span {
  width: 5px;
  height: 8px;
  border-radius: 3px;
  background: var(--muted);
  opacity: 0.35;
  transition: height 0.15s ease;
}

.wave[data-mode="speaking"] span,
.wave[data-mode="listening"] span,
.wave[data-mode="ringing"] span {
  opacity: 1;
  animation: wave 0.9s ease-in-out infinite;
  background: var(--green);
}

.wave[data-mode="listening"] span {
  background: var(--blue);
}

.wave span:nth-child(2) { animation-delay: 0.1s; }
.wave span:nth-child(3) { animation-delay: 0.2s; }
.wave span:nth-child(4) { animation-delay: 0.3s; }
.wave span:nth-child(5) { animation-delay: 0.15s; }

@keyframes wave {
  0%, 100% { height: 8px; }
  50% { height: 28px; }
}

.transcript-mini {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 2.8em;
  padding: 0 0.5rem;
  line-height: 1.35;
}

.transcript-mini strong {
  color: #d4d4d8;
  font-weight: 500;
}

.call-controls {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding-bottom: 0.5rem;
}

.call-controls .label {
  display: block;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

.ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#text-bar {
  margin-top: 1rem;
}

#text-bar[hidden] {
  display: none !important;
}

#text-form {
  display: flex;
  gap: 0.5rem;
}

#text-input {
  flex: 1;
  border-radius: 12px;
  border: 1px solid #3f3f46;
  background: var(--bg-elev);
  color: var(--fg);
  padding: 0.75rem 0.9rem;
  -webkit-user-select: text;
  user-select: text;
}

#text-form button {
  border: none;
  border-radius: 12px;
  padding: 0 1rem;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

/* —— Fin —— */
.ended-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.25rem;
  max-width: 24rem;
  margin: 0 auto;
  width: 100%;
}

.ended-wrap .brand-wordmark {
  margin-bottom: 0.15rem;
}

.ended-wrap h1 {
  margin: 0;
  font-size: 1.5rem;
}

#checklist {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #27272a;
  border-radius: 12px;
  overflow: hidden;
}

#checklist li {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #27272a;
  font-size: 0.95rem;
}

#checklist li:last-child {
  border-bottom: none;
}

#checklist li.ok span:last-child {
  color: var(--green);
}

#checklist li.miss span:last-child {
  color: #f59e0b;
}

/* Prueba de sonido */
.check-wrap {
  gap: 1rem;
  text-align: left;
}

.check-wrap h1 {
  margin: 0;
}

.check-step {
  border: 1px solid #27272a;
  border-radius: 12px;
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.check-step h2 {
  margin: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.check-num {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: #27272a;
  font-size: 0.85rem;
}

.check-step.ok .check-num {
  background: var(--green);
  color: #0a0a0b;
}

.check-answer p,
.check-step p {
  margin: 0;
}

.check-buttons {
  display: flex;
  gap: 0.6rem;
}

.check-buttons > button {
  flex: 1;
}

.check-msg {
  font-size: 0.9rem;
  color: #d4d4d8;
}

.check-msg.ok { color: var(--green); }
.check-msg.warn { color: #f59e0b; }

.link-plain {
  background: none;
  border: none;
  color: #a1a1aa;
  text-decoration: underline;
  font-size: 0.9rem;
  padding: 0.4rem;
  cursor: pointer;
  align-self: center;
}

.dial-check {
  text-align: center;
  margin: 0.25rem 0 0;
}

/* Valoración de la llamada */
.summary-heading {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a1a1aa;
  text-align: left;
}

.eval-overall {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.75rem;
}

.eval-overall.ok { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.eval-overall.warn { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.eval-overall.bad { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.eval-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid #27272a;
  border-radius: 12px;
  overflow: hidden;
  text-align: left;
}

.eval-list li {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.15rem 0.6rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #27272a;
}

.eval-list li:last-child { border-bottom: none; }

.eval-icon {
  grid-row: span 3;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.3;
}

.eval-list li.ok .eval-icon { color: var(--green); }
.eval-list li.warn .eval-icon { color: #f59e0b; }
.eval-list li.bad .eval-icon { color: #f87171; }

.eval-title { font-weight: 600; font-size: 0.95rem; }
.eval-detail { font-size: 0.9rem; color: #d4d4d8; }
.eval-tip { font-size: 0.85rem; color: #a1a1aa; font-style: italic; }

/* Dato que el alumno no dio y el simulador supuso para seguir. */
#checklist li.unknown span:last-child {
  color: #9ca3af;
  font-style: italic;
}

#summary-panel[hidden] {
  display: none !important;
}

.btn-ghost {
  background: transparent;
  border: 1px solid #3f3f46;
  color: var(--fg);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  width: 100%;
  cursor: pointer;
}
