:root {
  --bg: #f7efe4;
  --card: #fffaf3;
  --line: #e6d8c4;
  --text: #3a2e25;
  --muted: #6e5f52;
  --primary: #b4532b;
  --primary-dark: #963f1d;
  --primary-soft: #f6e0d2;
  --good: #2c7249;
  --good-soft: #dff0e3;
  --bad: #a83a32;
  --bad-soft: #f9e2de;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 20px;
  line-height: 1.6;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px 18px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.loading { text-align: center; color: var(--muted); margin-top: 40vh; }

h1 { font-size: 28px; line-height: 1.35; margin: 8px 0 6px; }
h2 { font-size: 23px; line-height: 1.4; margin: 24px 0 10px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ---------- 顶部 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  margin-bottom: 8px;
}
.back {
  font: inherit;
  font-size: 20px;
  color: var(--primary-dark);
  background: none;
  border: 0;
  padding: 10px 14px 10px 4px;
  min-height: 52px;
  cursor: pointer;
}
.counter { color: var(--muted); font-size: 20px; }

.bar {
  height: 10px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 18px;
}
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }

/* ---------- 按钮 ---------- */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  padding: 14px 20px;
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-soft { background: var(--card); color: var(--primary-dark); border-color: var(--line); }
.btn-soft:active { background: var(--primary-soft); }
.btn:disabled { opacity: .45; }

.actions { margin-top: auto; padding-top: 24px; display: grid; gap: 14px; }
.actions.two { grid-template-columns: auto 1fr; }
.actions.two .btn { white-space: nowrap; padding: 14px 18px; }

/* 发音按钮 */
.sound-row { display: flex; gap: 12px; margin: 16px 0; }
.sound {
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  min-height: 64px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 2px solid var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  cursor: pointer;
  flex: 1.4;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.sound.slow { flex: 1; background: var(--card); border-color: var(--line); }
.sound.playing { background: var(--primary); color: #fff; border-color: var(--primary); }
.sound.small { min-height: 56px; min-width: 60px; font-size: 26px; padding: 4px 10px; flex: none; }
.sound.big { font-size: 26px; min-height: 84px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 20px;
}
.tag {
  display: inline-block;
  font-size: 18px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 99px;
  padding: 2px 14px;
  margin-bottom: 12px;
}
.en {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.3;
  margin: 4px 0;
  overflow-wrap: anywhere;
}
.en.sentence { font-size: 29px; }
.zh { font-size: 24px; margin: 6px 0 4px; }
.note {
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 12px;
  margin-top: 14px;
}
.note::before { content: "💡 "; }

.speaker { font-size: 19px; color: var(--muted); margin: 0; }
.dialog-part + .dialog-part { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; }

/* 拼读例词 */
.examples { list-style: none; padding: 0; margin: 12px 0 0; }
.examples li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.examples .words { flex: 1; min-width: 0; }
.examples .words b { font-size: 28px; display: block; line-height: 1.3; }
.examples .words span { color: var(--muted); }
.combo { font-size: 52px; font-weight: 800; color: var(--primary-dark); line-height: 1.2; margin: 4px 0 8px; }

/* ---------- 首页 ---------- */
.hello { margin: 12px 0 18px; }
.hello h1 { font-size: 30px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat b { display: block; font-size: 34px; line-height: 1.2; color: var(--primary-dark); }
.stat span { color: var(--muted); font-size: 18px; }
.cheer { background: var(--good-soft); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 18px; }
.home-actions { display: grid; gap: 14px; }
.review-done { text-align: center; color: var(--good); padding: 14px; border: 2px dashed var(--good-soft); border-radius: var(--radius); }
.offline {
  margin-top: auto;
  padding-top: 28px;
  font-size: 17px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 课程列表 ---------- */
.lesson-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.lesson-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 80px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.lesson-item:active { background: var(--primary-soft); }
.lesson-item .icon { font-size: 34px; width: 44px; text-align: center; flex: none; }
.lesson-item .name { flex: 1; font-weight: 600; font-size: 21px; line-height: 1.4; }
.lesson-item .name small { display: block; font-weight: 400; color: var(--muted); font-size: 17px; }
.lesson-item .state { font-size: 17px; color: var(--muted); flex: none; }
.lesson-item .state.done { color: var(--good); font-weight: 600; }
.part-title { font-size: 19px; color: var(--muted); margin: 20px 0 10px; font-weight: 600; }
.part-title:first-child { margin-top: 0; }

/* ---------- 课程封面 ---------- */
.cover-icon { font-size: 64px; text-align: center; margin: 18px 0 4px; }
.cover-meta { display: flex; justify-content: center; gap: 18px; color: var(--muted); margin: 8px 0 18px; }

/* ---------- 测验 ---------- */
.question { margin-bottom: 18px; }
.question .prompt { font-size: 20px; color: var(--muted); margin-bottom: 6px; }
.question .zh-big { font-size: 30px; font-weight: 700; line-height: 1.4; }
.options { display: grid; gap: 12px; }
.option {
  width: 100%;
  min-height: 64px;
  padding: 14px 18px;
  font: inherit;
  font-size: 22px;
  text-align: left;
  color: var(--text);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.option { position: relative; padding-right: 48px; }
.option small { display: block; color: var(--muted); font-size: 18px; }
.option.correct { border-color: var(--good); background: var(--good-soft); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); }
.option.correct::after, .option.wrong::after {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: 26px; font-weight: 700;
}
.option.correct::after { content: "✓"; color: var(--good); }
.option.wrong::after { content: "✗"; color: var(--bad); }
.option:disabled { cursor: default; opacity: 1; }

.feedback { border-radius: var(--radius); padding: 14px 18px; margin-top: 16px; }
.feedback.good { background: var(--good-soft); color: var(--good); }
.feedback.bad { background: var(--bad-soft); color: var(--bad); }
.feedback b { display: block; font-size: 22px; }
.feedback span { color: var(--text); }

.result-emoji { font-size: 72px; text-align: center; margin-top: 24px; }
.score { text-align: center; font-size: 26px; font-weight: 700; margin: 8px 0 12px; }

.hint-msg { font-size: 17px; color: var(--bad); text-align: center; min-height: 1em; margin: 0; }

@media (max-width: 360px) {
  body { font-size: 20px; }
  #app { padding-left: 14px; padding-right: 14px; }
  .en { font-size: 30px; }
  .sound { font-size: 20px; padding: 10px 8px; }
  .sound.big { font-size: 22px; }
}
