/* 英语小乐园 · 人教PEP三年级上册(2024新版) - 儿童友好样式 */
:root {
  --primary: #42A5F5;
  --primary-dark: #1E88E5;
  --green: #4CAF50;
  --green-dark: #388E3C;
  --orange: #FF9800;
  --red: #EF5350;
  --bg: #F5F9FF;
  --card: #FFFFFF;
  --text: #333333;
  --text-light: #888888;
  --radius: 18px;
  --shadow: 0 3px 12px rgba(66, 165, 245, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 18px;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== 顶部栏 ===== */
#topbar {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 18px 14px;
  text-align: center;
  flex-shrink: 0;
}
.topbar-title { font-size: 24px; font-weight: 700; }
.topbar-sub { font-size: 14px; opacity: 0.9; margin-top: 2px; }

/* ===== 主内容区 ===== */
#main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(90px + env(safe-area-inset-bottom));
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== 单元选择器 ===== */
.unit-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.unit-selector::-webkit-scrollbar { display: none; }
.unit-chip {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: 24px;
  background: #fff;
  border: 2px solid #E3EEFB;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}
.unit-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===== 卡片列表 ===== */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.section-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.1s;
  border-left: 6px solid var(--primary);
}
.section-card:active { transform: scale(0.98); }
.section-card.done { border-left-color: var(--green); }
.section-card.playing { border-left-color: var(--orange); box-shadow: 0 3px 16px rgba(255, 152, 0, 0.35); }

.part-badge {
  flex-shrink: 0;
  min-width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.section-card.part-A .part-badge { background: var(--primary); }
.section-card.part-B .part-badge { background: var(--green); }
.section-card.part-C .part-badge { background: var(--orange); }
.section-card.part-intro .part-badge { background: #AB47BC; }
.section-card.part-words .part-badge { background: #8D6E63; }

.section-info { flex: 1; min-width: 0; }
.section-title { font-size: 18px; font-weight: 600; line-height: 1.35; }
.section-meta { font-size: 13px; color: var(--text-light); margin-top: 2px; }

.section-actions { display: flex; gap: 8px; flex-shrink: 0; }
.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s;
  background: #EAF3FE;
}
.icon-btn:active { transform: scale(0.9); }
.icon-btn.play { background: #E8F5E9; color: var(--green-dark); }
.icon-btn.speak { background: #FFF3E0; color: var(--orange); }
.icon-btn.disabled { opacity: 0.35; }

/* ===== 通用按钮 ===== */
.btn {
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  transition: transform 0.1s, opacity 0.15s;
  min-height: 48px;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; }
.btn-green { background: var(--green); }
.btn-blue { background: var(--primary); }
.btn-gray { background: #BDBDBD; }
.btn-big { width: 100%; padding: 18px; font-size: 22px; border-radius: 20px; }

/* ===== 今日任务 ===== */
#tasks-unit-banner {
  background: linear-gradient(135deg, #66BB6A, #43A047);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
#tasks-unit-banner .banner-title { font-size: 22px; font-weight: 700; }
#tasks-unit-banner .banner-sub { font-size: 14px; opacity: 0.92; margin-top: 4px; }

.checkin-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #FFF8E1;
  border: 2px dashed #FFB300;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 14px;
}
.checkin-strip .strip-text { font-size: 16px; font-weight: 600; color: #F57F17; }
.checkin-strip .strip-btn {
  border: none;
  background: var(--orange);
  color: #fff;
  border-radius: 14px;
  padding: 10px 18px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}

/* ===== 点读页面查看器 ===== */
.page-viewer {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 14px;
  touch-action: pan-y;
}
.page-viewer img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 62vh;
  object-fit: contain;
  background: #fff;
}
.page-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: var(--primary);
  cursor: pointer;
  user-select: none;
}
.page-nav:active { background: #E3EEFB; }
#page-nav-left { left: 10px; }
#page-nav-right { right: 10px; }
.page-label {
  position: absolute;
  bottom: 10px;
  right: 12px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
}

/* ===== 跟读弹窗 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff;
  border-radius: 22px;
  padding: 22px;
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.modal-title { font-size: 21px; font-weight: 700; text-align: center; margin-bottom: 12px; }
.modal-text {
  background: #F5F9FF;
  border-radius: 14px;
  padding: 16px;
  font-size: 19px;
  line-height: 1.7;
  color: #1a5276;
  margin-bottom: 16px;
  min-height: 60px;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

.record-status {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--orange);
  padding: 18px;
}
.record-status.recording { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

/* ===== 评分展示 ===== */
.score-box { margin-top: 8px; }
.score-total-wrap { text-align: center; padding: 10px 0 6px; }
.score-total { font-size: 64px; font-weight: 800; line-height: 1; }
.score-total.good { color: var(--green); }
.score-total.mid { color: var(--primary); }
.score-total.low { color: var(--orange); }
.score-verdict { font-size: 18px; font-weight: 600; margin-top: 6px; color: var(--text); }
.score-bars { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.score-bar-row { display: flex; align-items: center; gap: 10px; }
.score-bar-label { width: 68px; font-size: 15px; color: var(--text-light); text-align: right; flex-shrink: 0; }
.score-bar-track { flex: 1; height: 18px; background: #EEF2F7; border-radius: 9px; overflow: hidden; }
.score-bar-fill { height: 100%; border-radius: 9px; background: linear-gradient(90deg, var(--primary), #7EC8FF); transition: width 0.6s ease; }
.score-bar-val { width: 44px; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.score-actions { display: flex; gap: 10px; }
.score-actions .btn { flex: 1; }

/* ===== 打卡 ===== */
.streak-box {
  text-align: center;
  background: linear-gradient(135deg, #FF9800, #F57C00);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.streak-num { font-size: 56px; font-weight: 800; line-height: 1.1; }
.streak-label { font-size: 16px; opacity: 0.95; }
.checkin-total { text-align: center; font-size: 15px; color: var(--text-light); margin-bottom: 12px; }
.calendar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 12px;
  background: #F0F4F9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-light);
}
.cal-day .day-num { font-size: 17px; font-weight: 700; }
.cal-day.done { background: #E8F5E9; color: var(--green-dark); }
.cal-day.today { border: 2px solid var(--primary); }
.cal-day .day-star { font-size: 14px; }

/* ===== 底部Tab栏 ===== */
#tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: #fff;
  border-top: 1px solid #E8EEF6;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}
.tab-btn {
  flex: 1;
  padding: 10px 0 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  color: var(--text-light);
  transition: color 0.15s;
}
.tab-icon { font-size: 24px; }
.tab-text { font-size: 12px; font-weight: 600; }
.tab-btn.active { color: var(--primary); }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  padding: 12px 22px;
  border-radius: 24px;
  font-size: 16px;
  z-index: 200;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.hidden { display: none; }

/* ===== 空状态 ===== */
.empty-tip {
  text-align: center;
  font-size: 18px;
  color: var(--text-light);
  padding: 60px 20px;
}
