:root {
  --ink: #1f2d3d;
  --accent: #10b981;
  --accent-dark: #059669;
}

* {
  font-family: 'Nunito', system-ui, sans-serif;
}

button {
  user-select: none;
}

/* ---------- Animated gradient background ---------- */
.animated-bg {
  background: linear-gradient(-45deg, #5eead4, #38bdf8, #818cf8, #2dd4bf);
  background-size: 400% 400%;
  animation: gradientShift 16s ease infinite;
  overflow: hidden;
  position: relative;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---------- Floating blobs ---------- */
.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.4;
  z-index: 0;
  pointer-events: none;
}
.blob-1 { width: 320px; height: 320px; background: #fef08a; top: -80px; left: -60px; animation: float 12s ease-in-out infinite; }
.blob-2 { width: 280px; height: 280px; background: #f9a8d4; bottom: -70px; right: -50px; animation: float 14s ease-in-out infinite reverse; }
.blob-3 { width: 220px; height: 220px; background: #a5f3fc; top: 40%; right: 10%; animation: float 10s ease-in-out infinite; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -40px) scale(1.1); }
}

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

/* ---------- Glass card ---------- */
.glass-card {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 28px;
  box-shadow: 0 24px 60px rgba(31, 45, 61, 0.25);
  animation: cardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Mascot ---------- */
.mascot {
  display: inline-block;
  animation: bob 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.18));
}
.mascot.speaking { animation: wiggle 0.5s ease-in-out infinite; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg) scale(1.05); }
  50% { transform: rotate(8deg) scale(1.12); }
}

/* ---------- Typography ---------- */
.title {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  background: linear-gradient(90deg, #0d9488, #2563eb);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}
.subtitle {
  color: #475569;
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- Fields ---------- */
.field-label {
  display: block;
  font-weight: 700;
  color: #334155;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
}
.input-field {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18);
}
textarea.input-field { line-height: 1.5; }

/* ---------- Mic / voice input button ---------- */
.mic-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.85rem;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
  border: 2px solid rgba(37, 99, 235, 0.25);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.4rem;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}
.mic-btn:hover { transform: translateY(-1px); background: rgba(37, 99, 235, 0.18); }
.mic-btn.listening {
  color: #fff;
  background: #ef4444;
  border-color: #ef4444;
  animation: pulseRed 1.1s ease-in-out infinite;
}
@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* ---------- Textarea wrapper + char counter ---------- */
.textarea-wrap { position: relative; }
.char-count {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.85);
  padding: 0 4px;
  border-radius: 6px;
  pointer-events: none;
}

/* ---------- Sample phrase chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0f766e;
  background: rgba(45, 212, 191, 0.18);
  border: 1.5px solid rgba(13, 148, 136, 0.25);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  transition: transform 0.15s, background 0.2s;
}
.chip:hover { transform: translateY(-2px); background: rgba(45, 212, 191, 0.3); }
.chip:active { transform: scale(0.96); }

/* ---------- Copy button ---------- */
.copy-btn {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.1);
  border: 1.5px solid rgba(37, 99, 235, 0.25);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  transition: transform 0.15s, background 0.2s;
}
.copy-btn:hover { transform: translateY(-1px); background: rgba(37, 99, 235, 0.18); }
.copy-btn.copied { color: #fff; background: #10b981; border-color: #10b981; }

/* ---------- Play button ---------- */
.play-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.95rem;
  border-radius: 16px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.2rem;
  color: white;
  background: linear-gradient(135deg, #10b981, #2563eb);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.35);
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s;
}
.play-btn:hover { transform: translateY(-2px); filter: brightness(1.05); box-shadow: 0 16px 34px rgba(37, 99, 235, 0.45); }
.play-btn:active { transform: translateY(1px) scale(0.99); }
.play-btn.loading { opacity: 0.7; pointer-events: none; }
.play-btn.loading .btn-icon { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Sound waves ---------- */
.waves {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 0;
  margin: 0;
  opacity: 0;
  transition: height 0.3s, opacity 0.3s, margin 0.3s;
}
.waves.active {
  height: 38px;
  opacity: 1;
  margin: 0 0 0.5rem;
}
.waves span {
  width: 5px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(180deg, #10b981, #2563eb);
}
.waves.active span { animation: bounce 1s ease-in-out infinite; }
.waves span:nth-child(1) { animation-delay: 0s; }
.waves span:nth-child(2) { animation-delay: 0.1s; }
.waves span:nth-child(3) { animation-delay: 0.2s; }
.waves span:nth-child(4) { animation-delay: 0.3s; }
.waves span:nth-child(5) { animation-delay: 0.4s; }
.waves span:nth-child(6) { animation-delay: 0.3s; }
.waves span:nth-child(7) { animation-delay: 0.2s; }
.waves span:nth-child(8) { animation-delay: 0.1s; }
.waves span:nth-child(9) { animation-delay: 0s; }

@keyframes bounce {
  0%, 100% { height: 8px; }
  50% { height: 32px; }
}

/* ---------- Result panel ---------- */
.result-panel {
  background: rgba(255, 255, 255, 0.85);
  border: 2px dashed #2563eb;
  border-radius: 16px;
  padding: 1rem 1.1rem;
  animation: cardIn 0.4s ease;
}
.result-label {
  font-weight: 700;
  color: #2563eb;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.result-text {
  color: var(--ink);
  font-weight: 700;
  font-size: 1.15rem;
  word-break: break-word;
}

/* ---------- Footer ---------- */
.footer-note {
  color: rgba(255, 255, 255, 0.95);
  font-weight: 600;
  font-size: 0.85rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .animated-bg, .blob, .mascot, .glass-card, .waves.active span { animation: none; }
}
