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

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: #F0F4FF;
  color: #1E293B;
  min-height: 100vh;
  padding: 24px 16px 48px;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

header {
  text-align: center;
  padding: 8px 0;
}

header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: #4338CA;
  letter-spacing: -0.5px;
}

.subtitle {
  margin-top: 6px;
  color: #64748B;
  font-size: 1rem;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(67, 56, 202, 0.08);
}

h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #334155;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: #334155;
}

/* Input section */
textarea {
  width: 100%;
  border: 2px solid #E2E8F0;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  color: #1E293B;
  resize: vertical;
  transition: border-color 0.2s;
  font-family: inherit;
}

textarea:focus {
  outline: none;
  border-color: #6366F1;
}

.btn-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-secondary {
  background: none;
  border: 1.5px solid #CBD5E1;
  border-radius: 8px;
  padding: 6px 16px;
  font-size: 0.875rem;
  color: #64748B;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: #F1F5F9;
  border-color: #94A3B8;
}

.examples { margin-top: 16px; }

.examples-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.btn-refresh {
  background: none;
  border: 1.5px solid #C7D2FE;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: #6366F1;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-refresh:hover { background: #EEF2FF; }

.examples-label {
  font-size: 0.825rem;
  color: #94A3B8;
  margin-bottom: 0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#examplesList {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-btn {
  background: #EEF2FF;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  color: #4338CA;
  cursor: pointer;
  transition: background 0.15s;
  line-height: 1.4;
}

.example-btn:hover { background: #E0E7FF; }

/* Record section */
.record-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 28px 24px;
}

.status-text {
  font-size: 0.95rem;
  color: #64748B;
  text-align: center;
}

.interim-text {
  font-size: 1rem;
  color: #6366F1;
  font-style: italic;
  min-height: 24px;
  text-align: center;
}

.btn-record {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #6366F1, #4338CA);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 14px 36px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
  transition: all 0.2s;
}

.btn-record:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5); }
.btn-record:active { transform: translateY(0); }

.btn-record.recording {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 4px 28px rgba(239, 68, 68, 0.7); }
}

.browser-note {
  font-size: 0.78rem;
  color: #94A3B8;
}

/* Results section */
.results-section { display: flex; flex-direction: column; gap: 20px; }

.score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.score-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F1F5F9;
  border: 5px solid #E2E8F0;
  gap: 2px;
  transition: border-color 0.3s;
}

.score-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.score-unit { font-size: 1rem; font-weight: 600; color: #64748B; }

.score-value.excellent { color: #10B981; }
.score-value.good { color: #F59E0B; }
.score-value.needs-work { color: #EF4444; }

.score-circle:has(.excellent) { border-color: #10B981; background: #ECFDF5; }
.score-circle:has(.good) { border-color: #F59E0B; background: #FFFBEB; }
.score-circle:has(.needs-work) { border-color: #EF4444; background: #FEF2F2; }

.score-message {
  font-size: 1.05rem;
  font-weight: 600;
  color: #475569;
}

/* Word comparison */
.comparison-block { background: #F8FAFC; border-radius: 12px; padding: 16px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.legend-item {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}

.legend-item.correct  { background: #DCFCE7; color: #16A34A; }
.legend-item.wrong    { background: #FEE2E2; color: #DC2626; }
.legend-item.missing  { background: #FEF9C3; color: #CA8A04; text-decoration: underline dashed; }
.legend-item.extra    { background: #EDE9FE; color: #7C3AED; }

.recognized-text {
  font-size: 1.15rem;
  line-height: 2;
  word-break: break-word;
}

.word {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  margin: 2px;
  font-weight: 500;
}

.word.correct  { background: #DCFCE7; color: #15803D; }
.word.wrong    { background: #FEE2E2; color: #B91C1C; cursor: help; }
.word.missing  { background: #FEF9C3; color: #92400E; text-decoration: underline dashed 2px; }
.word.extra    { background: #EDE9FE; color: #6D28D9; }

/* Feedback */
.feedback-block { }

.feedback-item {
  border-left: 4px solid #E2E8F0;
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 10px;
  background: #F8FAFC;
}

.feedback-item.error    { border-color: #EF4444; background: #FFF5F5; }
.feedback-item.warning  { border-color: #F59E0B; background: #FFFDF0; }
.feedback-item.info     { border-color: #6366F1; background: #F5F3FF; }
.feedback-item.intonation { border-color: #06B6D4; background: #F0FDFF; }

.feedback-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 4px;
}

.feedback-tip {
  font-size: 0.875rem;
  color: #475569;
  margin-top: 4px;
  white-space: pre-line;
}

.perfect-msg {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #16A34A;
  padding: 16px;
}

.btn-retry {
  align-self: center;
  background: none;
  border: 2px solid #6366F1;
  border-radius: 50px;
  padding: 10px 32px;
  font-size: 1rem;
  font-weight: 600;
  color: #6366F1;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-retry:hover { background: #EEF2FF; }

.hidden { display: none !important; }

@media (max-width: 480px) {
  header h1 { font-size: 1.5rem; }
  .btn-record { padding: 12px 28px; font-size: 1rem; }
}
