:root {
  --primary: #ff6b6b;
  --primary-dark: #e85555;
  --secondary: #4ecdc4;
  --secondary-dark: #3bb5ac;
  --bg: #fef9f0;
  --card-bg: #ffffff;
  --text: #2f2f3a;
  --muted: #7a7a8c;
  --success: #57c785;
  --radius: 18px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Comic Sans MS", "Trebuchet MS", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--primary);
  color: white;
}

.brand { font-size: 1.5rem; font-weight: bold; }

.icon-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.screen { text-align: center; }
.hidden { display: none !important; }

h1 { font-size: 1.6rem; }

input[type="text"], textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #ddd;
  border-radius: 12px;
  font-size: 1rem;
  margin: 10px 0;
  font-family: inherit;
}

.primary-btn, .secondary-btn, .record-btn {
  border: none;
  border-radius: 999px;
  padding: 14px 28px;
  font-size: 1.05rem;
  font-weight: bold;
  cursor: pointer;
  margin: 6px;
  transition: transform 0.1s ease;
}
.primary-btn:active, .secondary-btn:active, .record-btn:active { transform: scale(0.96); }

.primary-btn { background: var(--primary); color: white; }
.primary-btn:hover { background: var(--primary-dark); }
.primary-btn:disabled { background: #ccc; cursor: not-allowed; }

.secondary-btn { background: var(--secondary); color: white; }
.secondary-btn:hover { background: var(--secondary-dark); }
.secondary-btn:disabled { background: #ccc; cursor: not-allowed; }

.record-btn {
  background: var(--primary);
  color: white;
  font-size: 1.2rem;
  padding: 18px 32px;
}
.record-btn:disabled { background: #ccc; cursor: not-allowed; }
.record-btn.listening {
  background: #d33;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(221,51,51,0.5); }
  70% { box-shadow: 0 0 0 16px rgba(221,51,51,0); }
  100% { box-shadow: 0 0 0 0 rgba(221,51,51,0); }
}

.error-text { color: var(--primary-dark); font-weight: bold; }

.spinner {
  width: 40px;
  height: 40px;
  margin: 20px auto;
  border: 5px solid #eee;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lesson-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 12px;
}
.lesson-name { color: var(--muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; }
.book-title { font-size: 1.4rem; font-weight: bold; }

.media-area {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-area video, .media-area img { width: 100%; height: 100%; object-fit: contain; }
.no-media { color: white; font-size: 1.2rem; }

.media-controls { margin: 14px 0; }

.prompt-label { color: var(--muted); margin: 0 0 6px; font-size: 0.9rem; }

.question-card {
  background: var(--secondary);
  color: white;
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.question-card .prompt-label { color: rgba(255,255,255,0.85); }
.phrase-question { font-size: 1.3rem; font-weight: bold; margin: 0; }

.watch-prompt {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  margin: 8px 0;
}
.watch-prompt.hidden { display: none; }

.record-area, .review-area, .evaluating-area, .feedback-area, .fallback-area {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  margin: 16px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.record-status { color: var(--muted); min-height: 1.2em; }
.live-transcript { font-size: 1.1rem; font-style: italic; min-height: 1.4em; }

.review-transcript {
  font-size: 1.2rem;
  background: var(--bg);
  border-radius: 12px;
  padding: 12px;
}

.feedback-praise {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--success);
  margin: 0 0 14px;
}

.feedback-transcript {
  font-size: 1.2rem;
  font-weight: bold;
  background: var(--bg);
  border-radius: 12px;
  padding: 12px;
  margin: 0 0 14px;
}

.feedback-suggestion {
  background: var(--bg);
  border-left: 3px solid var(--secondary);
  border-radius: 0 12px 12px 0;
  padding: 10px 14px;
  margin: 0 0 14px;
}
.feedback-suggestion .prompt-label { margin: 0 0 4px; }
.feedback-suggestion p:last-child { margin: 0; font-size: 1rem; white-space: pre-line; }

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

.intro-eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.85rem; }
.intro-coverart {
  width: 100%;
  max-width: 320px;
  border-radius: var(--radius);
  margin: 16px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.settings-panel {
  position: fixed;
  top: 60px;
  right: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  width: min(320px, 90vw);
  z-index: 10;
}
