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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #f5f0e1 0%, #e8d9b9 100%);
  min-height: 100vh;
  color: #2c2416;
  padding: 20px;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

header {
  text-align: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

h1 {
  font-size: 28px;
  color: #8b4513;
  margin-bottom: 6px;
}

.subtitle {
  color: #888;
  font-size: 14px;
}

.poem-picker,
.voice-picker {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.poem-picker label,
.voice-picker label {
  font-weight: 500;
}

#poem-select,
#voice-select {
  flex: 1;
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid #d4c5a8;
  border-radius: 6px;
  background: #fafafa;
  font-size: 15px;
  cursor: pointer;
}

.voice-hint {
  flex-basis: 100%;
  font-size: 12px;
  color: #999;
}

.voice-picker { margin-bottom: 24px; }

.poem-display {
  background: #fdf8ec;
  border-left: 4px solid #c0885a;
  padding: 24px 28px;
  border-radius: 6px;
  margin-bottom: 28px;
  text-align: center;
}

#poem-title {
  font-size: 22px;
  color: #6b3410;
  margin-bottom: 4px;
}

.author {
  color: #999;
  font-size: 13px;
  margin-bottom: 16px;
}

.poem-body {
  font-size: 19px;
  line-height: 2;
  color: #3a2c18;
  font-family: "STKaiti", "Kaiti SC", "楷体", serif;
}

.poem-body .line {
  display: block;
}

/* ---------- 卡通老师 ---------- */
.teacher-stage {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin-bottom: 8px;
  min-height: 220px;
}

.teacher {
  width: 200px;
  height: 220px;
  transform-origin: 100px 200px;
  animation: idle-bob 2.8s ease-in-out infinite;
  filter: drop-shadow(0 6px 12px rgba(90, 100, 220, 0.18));
}

.teacher-stage.speaking .teacher {
  animation: speak-bob 0.7s ease-in-out infinite;
}

/* 豆包是圆球，更适合上下浮动而不是左右晃 */
@keyframes idle-bob {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-4px) scale(1.01); }
}

@keyframes speak-bob {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-3px) scale(1.03); }
}

/* 说话时嘴角的笑弧淡出（嘴张开时不要重叠） */
.smile-line {
  transition: opacity 0.15s;
}
.teacher-stage.speaking .smile-line {
  opacity: 0;
}

/* 眨眼：每 4 秒眨一次 */
.eye {
  transform-origin: center;
  animation: blink 4.2s infinite;
}
.eye-right { animation-delay: 0.05s; }

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  94%, 98%      { transform: scaleY(0.1); }
}

/* 嘴巴在说话时由 JS 控制 ry，平时是椭圆，说话时变高 */
#mouth {
  transition: ry 0.08s linear, rx 0.08s linear, fill 0.2s;
}

.teacher-stage.speaking #mouth {
  fill: #c0445a;
}

/* 说话气泡 */
.speech-bubble {
  position: absolute;
  top: 6px;
  right: 8px;
  max-width: 230px;
  background: #fff;
  border: 2px solid #7d8af0;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  color: #2a2f5a;
  box-shadow: 0 4px 14px rgba(90, 100, 220, 0.18);
  animation: bubble-pop 0.25s ease-out;
}

.speech-bubble.hidden { display: none; }

.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 30px;
  border: 10px solid transparent;
  border-top-color: #7d8af0;
  border-bottom: 0;
}

.speech-bubble::before {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 32px;
  border: 8px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
  z-index: 1;
}

@keyframes bubble-pop {
  from { opacity: 0; transform: translateY(-6px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 听老师范读小按钮 ---------- */
.btn-link {
  background: none;
  border: 1px solid #c0885a;
  color: #8b4513;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 12px;
  transition: all 0.2s;
}
.btn-link:hover  { background: #c0885a; color: #fff; }
.btn-link:disabled { opacity: 0.5; cursor: not-allowed; }

/* 朗读评价按钮 */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.result-actions { display: flex; gap: 8px; }

.btn-tts {
  background: #fff;
  border: 1px solid #c0885a;
  color: #8b4513;
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-tts:hover  { background: #c0885a; color: #fff; }
.btn-tts.hidden { display: none; }
.btn-tts-stop   { border-color: #c04020; color: #c04020; }
.btn-tts-stop:hover { background: #c04020; color: #fff; }

/* ---------- 录音 ---------- */
.recorder {
  text-align: center;
  margin-bottom: 24px;
}

.recorder button {
  padding: 12px 28px;
  font-size: 16px;
  border-radius: 24px;
  border: none;
  cursor: pointer;
  margin: 0 6px;
  transition: all 0.2s;
}

.btn-primary {
  background: #c0885a;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #a56e44;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #eee;
  color: #555;
}

.btn-secondary:hover:not(:disabled) {
  background: #ddd;
}

.recorder button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.status {
  margin-top: 14px;
  color: #666;
  font-size: 14px;
  min-height: 20px;
}

.status.recording {
  color: #d04020;
}

.status.recording::before {
  content: "● ";
  animation: blink 1s infinite;
}

@keyframes blink {
  50% { opacity: 0.3; }
}

.timer {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 24px;
  color: #888;
  margin-top: 8px;
}

.result {
  background: #f7f3ea;
  padding: 20px 24px;
  border-radius: 8px;
  border: 1px solid #e0d0b0;
}

.result.hidden {
  display: none;
}

.result h3 {
  color: #6b3410;
}

.scores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.score-item {
  background: #fff;
  padding: 12px;
  border-radius: 6px;
  text-align: center;
  border: 1px solid #e8dec8;
}

.score-item .label {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}

.score-item .value {
  font-size: 22px;
  font-weight: 600;
  color: #c0885a;
}

.score-item .value.good { color: #4a8b3b; }
.score-item .value.warn { color: #d4a017; }
.score-item .value.bad  { color: #c04020; }

.comment {
  background: #fff;
  padding: 14px 16px;
  border-radius: 6px;
  line-height: 1.7;
  color: #3a2c18;
  margin-bottom: 12px;
  white-space: pre-wrap;
}

.stars {
  background: #fff;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.stars:empty { display: none; }

.star-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 15px;
}

.star-row + .star-row {
  border-top: 1px dashed #e8dec8;
}

.star-label {
  color: #6b3410;
  font-weight: 500;
  /* 父容器 .star-row 用了 justify-content: space-between，
     stars 会自动右对齐到容器右边，所以不同字数的 label 也能让星星纵向对齐 */
}

.star-marks {
  letter-spacing: 2px;
  font-size: 18px;
}

details {
  font-size: 13px;
  color: #666;
}

details summary {
  cursor: pointer;
  user-select: none;
}

.recognized {
  background: #fff;
  padding: 10px 12px;
  margin-top: 8px;
  border-radius: 4px;
  font-family: "STKaiti", "Kaiti SC", serif;
  line-height: 1.8;
}

.recognized .err {
  color: #c04020;
  text-decoration: underline wavy;
}

.recognized .miss {
  color: #aaa;
  text-decoration: line-through;
}
