/* Primary colors, each with one job:
   blue = brand and actions, yellow = warmth and highlights, red = recording. */
:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #5a6275;
  --line: #e6e9f0;
  --gray-50: #f5f7fa;
  --blue: #1e5eff;
  --blue-dark: #1747c9;
  --blue-50: #eef3ff;
  --blue-100: #d6e2ff;
  --yellow: #ffc928;
  --yellow-dark: #e0a800;
  --yellow-50: #fff8e0;
  --yellow-ink: #5c4300;
  --red: #d32f2f;
  --red-dark: #a61f1f;
  --red-50: #fdecec;
  --radius: 20px;
}

@property --p {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; background: #ffffff; }

body {
  color: var(--ink);
  font: 17px/1.55 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */

.top, main, .foot {
  max-width: 600px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

.top { padding-top: 18px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -0.01em;
}
.brand-mark { width: 30px; height: 30px; }

main { padding-bottom: 40px; }

.foot {
  padding-top: 8px;
  padding-bottom: 36px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

h1 {
  font-size: clamp(32px, 8vw, 44px);
  line-height: 1.08;
  font-weight: 900;
  letter-spacing: -0.02em;
  margin: 14px 0 14px;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 900;
  margin: 40px 0 6px;
}

h3 { font-size: 19px; line-height: 1.25; font-weight: 800; margin: 0; }

p { margin: 0 0 12px; }

h1, h2, h3, .score-label { text-wrap: balance; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.lead { font-size: 19px; color: var(--muted); margin-bottom: 26px; }
.muted { color: var(--muted); }
.fine { font-size: 14px; color: var(--muted); margin-top: 12px; }
.center { text-align: center; }
.error { color: var(--red); font-size: 15px; font-weight: 700; margin: 10px 0 0; }
.ok { color: var(--blue-dark); font-weight: 800; margin: 12px 0 0; }

.banner {
  margin: 14px 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--yellow-50);
  color: var(--yellow-ink);
  font-size: 14px;
  font-weight: 600;
}
.banner-info { background: var(--blue-50); color: var(--blue-dark); }

/* ---------- Buttons ---------- */

button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 13px 24px;
  min-height: 52px;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.08s ease;
}
button:focus-visible, input:focus-visible, a:focus-visible, [tabindex="-1"]:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
[tabindex="-1"]:focus { outline: none; }

.primary {
  background: var(--blue);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--blue-dark);
}
.primary:hover { background: #2d69ff; }
.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-dark); }
.primary:disabled { background: var(--blue-100); color: var(--blue-dark); box-shadow: none; cursor: default; transform: none; }

.big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  font-size: 19px;
}
.arrow { width: 22px; height: 22px; }

.secondary {
  background: #ffffff;
  color: var(--blue);
  border-color: var(--blue-100);
  font-weight: 800;
}
.secondary:hover { border-color: var(--blue); }

.ghost { background: transparent; color: var(--muted); font-weight: 700; }
.ghost:hover { color: var(--ink); }

/* ---------- Intro ---------- */

.hero-art { position: relative; height: 128px; margin: 20px 0 4px; }

.bubble {
  position: absolute;
  padding: 10px 20px 12px;
  border-radius: 22px;
  font-weight: 900;
  font-size: 28px;
  line-height: 1.1;
}
.bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  width: 18px;
  height: 18px;
  background: inherit;
  border-radius: 3px;
  transform: rotate(45deg);
}
.bubble-es { left: 0; top: 6px; background: var(--yellow); color: var(--ink); transform: rotate(-5deg); }
.bubble-es::after { left: 24px; }
.bubble-en { left: 34%; top: 58px; background: var(--blue); color: #ffffff; transform: rotate(4deg); }
.bubble-en::after { right: 24px; }

.confetti { position: absolute; border-radius: 50%; }
.c1 { width: 16px; height: 16px; background: var(--red); left: 74%; top: 12px; }
.c2 { width: 10px; height: 10px; background: var(--yellow); left: 86%; top: 46px; }
.c3 { width: 12px; height: 12px; background: var(--blue); left: 80%; top: 96px; }
.c4 { width: 8px; height: 8px; background: var(--red); left: 94%; top: 82px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; }
.chips span {
  font-size: 14px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
}
.chips span:nth-child(1) { background: var(--blue-50); color: var(--blue-dark); }
.chips span:nth-child(2) { background: var(--yellow-50); color: var(--yellow-ink); }
.chips span:nth-child(3) { background: var(--red-50); color: var(--red-dark); }

.steps { list-style: none; padding: 0; margin: 34px 0 0; display: grid; gap: 16px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; }
.steps strong { display: block; font-weight: 800; font-size: 17px; }
.steps span:not(.num) { color: var(--muted); font-size: 15px; }
.num {
  flex: none;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-weight: 900;
}
.n1 { background: var(--blue); color: #ffffff; }
.n2 { background: var(--yellow); color: var(--ink); }
.n3 { background: var(--red); color: #ffffff; }

.reassure {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 30px;
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--blue-50);
}
.reassure svg { flex: none; width: 24px; height: 24px; fill: var(--red); margin-top: 2px; }
.reassure p { margin: 0; font-size: 16px; }
.reassure strong { font-weight: 800; }

/* ---------- Recording ---------- */

.progress { display: flex; gap: 6px; margin: 26px 0 14px; }
.progress span { flex: 1; height: 8px; border-radius: 4px; background: var(--line); }
.progress span.done { background: var(--blue); }
.progress span.current { background: var(--yellow); }

.step { font-size: 15px; font-weight: 800; color: var(--muted); margin: 0 0 12px; }

.say {
  position: relative;
  background: var(--blue-50);
  border: 2px solid var(--blue-100);
  border-radius: 24px;
  padding: 18px 20px 22px;
  margin: 0 0 22px;
}
.say::after {
  content: "";
  position: absolute;
  left: 36px;
  bottom: -11px;
  width: 20px;
  height: 20px;
  background: var(--blue-50);
  border-right: 2px solid var(--blue-100);
  border-bottom: 2px solid var(--blue-100);
  transform: rotate(45deg);
}
.say-label { font-size: 14px; font-weight: 800; color: var(--blue-dark); margin: 0 0 6px; }
.sentence {
  font-size: clamp(23px, 6vw, 29px);
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}

.hint { color: var(--muted); font-size: 16px; margin-bottom: 24px; }

.record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 62px;
  font-size: 19px;
  font-weight: 800;
  background: var(--red);
  color: #ffffff;
  box-shadow: 0 4px 0 var(--red-dark);
}
.record:hover { background: #dc3a3a; }
.record:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-dark); }
.record .mic { width: 24px; height: 24px; fill: currentColor; }
.record[data-mode="listening"] {
  background: var(--red-50);
  color: var(--red-dark);
  border-color: var(--red);
  box-shadow: none;
  animation: pulse 1.4s ease-in-out infinite;
}
.record[data-mode="preparing"], .record[data-mode="busy"] {
  background: var(--gray-50);
  color: var(--muted);
  box-shadow: none;
  cursor: progress;
}
.record:disabled { cursor: progress; transform: none; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(211, 47, 47, 0); }
}

.meter { margin: 18px 0 0; text-align: center; }
.bars { display: flex; justify-content: center; align-items: center; gap: 6px; height: 48px; }
.bars span {
  width: 8px;
  height: 6px;
  border-radius: 4px;
  background: var(--line);
  transition: height 0.08s linear, background-color 0.2s ease;
}
.meter.hearing .bars span { background: var(--blue); }
.meter.hearing .bars span:nth-child(3n + 2) { background: var(--yellow); }
.meter-label { margin: 6px 0 0; font-size: 15px; font-weight: 800; color: var(--muted); }
.meter.hearing .meter-label { color: var(--blue-dark); }

.status { text-align: center; color: var(--muted); font-weight: 700; margin-top: 14px; min-height: 1.5em; }
#rec-status { color: var(--red); }

/* ---------- Analyzing ---------- */

#analyzing { text-align: center; padding-top: 90px; }
.loader { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.loader span { width: 16px; height: 16px; border-radius: 50%; animation: hop 0.9s ease-in-out infinite; }
.loader span:nth-child(1) { background: var(--blue); }
.loader span:nth-child(2) { background: var(--yellow); animation-delay: 0.15s; }
.loader span:nth-child(3) { background: var(--red); animation-delay: 0.3s; }
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-12px); }
}
#analyzing .status { color: var(--ink); font-size: 19px; }

/* ---------- Results ---------- */

.result-hero { display: flex; align-items: center; gap: 22px; margin: 26px 0 22px; }

.ring {
  --p: 0;
  flex: none;
  width: 136px;
  height: 136px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--blue) calc(var(--p) * 1%), var(--blue-50) 0);
  transition: --p 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ring-inner {
  width: 106px;
  height: 106px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#score { font-size: 46px; font-weight: 900; line-height: 1; letter-spacing: -0.02em; }
.of { font-size: 13px; font-weight: 800; color: var(--muted); margin-top: 2px; }

.kicker { font-size: 14px; font-weight: 800; color: var(--blue-dark); margin: 0 0 4px; }
.score-label { font-size: 20px; line-height: 1.3; font-weight: 900; margin: 0 0 6px; }
.encourage { color: var(--muted); font-size: 15px; margin: 0; }

.subscores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.sub { border-radius: 16px; padding: 12px 14px; }
.sub dt { font-size: 13px; font-weight: 800; }
.sub dd { margin: 2px 0 0; font-size: 26px; font-weight: 900; color: var(--ink); }
.sub-blue { background: var(--blue-50); }
.sub-blue dt { color: var(--blue-dark); }
.sub-yellow { background: var(--yellow-50); }
.sub-yellow dt { color: var(--yellow-ink); }
.sub-red { background: var(--red-50); }
.sub-red dt { color: var(--red-dark); }

.sounds { display: grid; gap: 16px; margin-top: 18px; }

.sound {
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
}
.sound-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sound-head h3 { flex: 1; }
.rank {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: 16px;
}
.sound:nth-child(3n + 1) .rank { background: var(--blue); color: #ffffff; }
.sound:nth-child(3n + 2) .rank { background: var(--yellow); color: var(--ink); }
.sound:nth-child(3n + 3) .rank { background: var(--red); color: #ffffff; }
.pill {
  flex: none;
  font-size: 13px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--gray-50);
  color: var(--muted);
}
.sound p { font-size: 16px; }
.sound strong { font-weight: 800; }

.heard {
  margin: 0 0 14px;
  padding: 10px 14px 10px 32px;
  background: var(--yellow-50);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}
.heard li + li { margin-top: 4px; }

.words { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.words-label { flex-basis: 100%; font-size: 14px; font-weight: 700; color: var(--muted); }
.word {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 8px 14px;
  background: #ffffff;
  border-color: var(--blue-100);
  color: var(--blue);
  font-weight: 800;
  font-size: 15px;
}
.word:hover { background: var(--blue-50); border-color: var(--blue); }
.word svg { width: 17px; height: 17px; fill: currentColor; }

.pill-good { background: var(--blue-50); color: var(--blue-dark); }

.strengths { display: grid; gap: 12px; margin-top: 16px; }
.strength {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--blue-50);
}
.strength-check {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: #ffffff;
  font-weight: 900;
  font-size: 18px;
}
.strength-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.strength-head strong { font-weight: 800; font-size: 17px; }
.strength p { margin: 0; font-size: 16px; }

.listen { display: grid; gap: 12px; margin-top: 16px; }
.listen-row { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.listen-text { font-weight: 800; font-size: 17px; margin: 0 0 10px; }
.listen-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.listen-btn { flex: 1 1 140px; min-height: 46px; padding: 10px 16px; font-weight: 800; font-size: 15px; }
.listen-btn.mine { background: var(--red-50); color: var(--red-dark); }
.listen-btn.natural { background: var(--blue-50); color: var(--blue-dark); }
.listen-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.listen-btn.playing, .word.playing { outline: 3px solid var(--yellow); outline-offset: 2px; }

.cta {
  margin-top: 40px;
  padding: 24px 20px;
  border-radius: 24px;
  background: var(--yellow);
}
.cta h2 { margin-top: 0; }
.cta p { color: var(--ink); }
.cta label { display: block; font-weight: 800; font-size: 15px; margin: 16px 0 6px; }
.cta input[type="email"] {
  width: 100%;
  font: inherit;
  padding: 12px 16px;
  min-height: 52px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: #ffffff;
  color: var(--ink);
}
.cta input[type="email"]::placeholder { color: #8a90a0; }
.cta input[aria-invalid="true"] { border-color: var(--red); }
.cta .error { color: var(--red-dark); }
.cta .ok { color: var(--ink); }
.cta .check { display: flex; gap: 10px; align-items: flex-start; font-weight: 700; margin: 14px 0 18px; }
.cta .check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--blue); flex: none; }
.cta button { width: 100%; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.actions button { flex: 1 1 200px; }

@media (max-width: 520px) {
  .result-hero { flex-direction: column; text-align: center; gap: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
