/* 英语小乐园 · 人教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; } }

/* ===== 卡片列表 ===== */
.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-banner {
  background: linear-gradient(135deg, #66BB6A, #43A047);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.tasks-banner .banner-title { font-size: 20px; font-weight: 700; }
.tasks-banner .banner-sub { font-size: 14px; opacity: 0.92; margin-top: 4px; }

/* 任务标签(当前页的任务) */
.task-items { display: flex; flex-direction: column; gap: 10px; padding: 4px 0; }
.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border-left: 6px solid var(--primary);
  transition: all 0.12s;
}
.task-item.done { border-left-color: var(--green); }
.task-item.playing { border-left-color: var(--orange); box-shadow: 0 3px 16px rgba(255, 152, 0, 0.35); }
.task-item-info { flex: 1; min-width: 0; }
.task-item-title { font-size: 16px; font-weight: 600; line-height: 1.35; }
.task-item-status { font-size: 13px; color: var(--text-light); margin-top: 2px; }
.task-item.done .task-item-status { color: var(--green-dark); }
.task-item-actions { display: flex; gap: 8px; flex-shrink: 0; }
.task-item-empty {
  text-align: center;
  font-size: 14px;
  color: var(--text-light);
  padding: 16px 0;
}

/* ===== 打卡页签 ===== */
.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.future { background: #FAFBFC; color: #C5CDD5; border: 1px dashed #E3E8ED; }
.cal-day .day-star { font-size: 14px; }
.checkin-tip {
  text-align: center;
  font-size: 14px;
  color: var(--text-light);
  background: #FFF8E1;
  border: 1px dashed #FFB300;
  border-radius: 12px;
  padding: 10px 14px;
}

/* ===== 点读页面查看器 ===== */
.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: 28px;
  padding: 24px 22px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 12px 44px rgba(0,0,0,0.28);
}
.modal-title {
  font-size: 21px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 12px;
  color: #1a5276;
}
.modal-text {
  background: linear-gradient(135deg, #F5F9FF, #EAF4FF);
  border: 2px dashed #BBDEFB;
  border-radius: 18px;
  padding: 18px;
  font-size: 20px;
  line-height: 1.8;
  color: #1a5276;
  margin-bottom: 16px;
  min-height: 60px;
}
.modal-actions { display: flex; gap: 12px; }
.modal-actions .btn { flex: 1; }
.modal-actions .btn {
  border-radius: 22px;
  min-height: 56px;
  font-size: 19px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.16);
}
#btn-demo { background: linear-gradient(135deg, #42A5F5, #1565C0); }
#btn-record { background: linear-gradient(135deg, #66BB6A, #388E3C); }
#btn-record:active { animation: none; }
.record-status {
  text-align: center;
  font-size: 19px;
  font-weight: 700;
  color: var(--orange);
  padding: 20px;
}
.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: 14px 0 8px; }
.score-total {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  font-size: 50px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  margin-bottom: 8px;
}
.score-total.good { background: linear-gradient(135deg, #66BB6A, #388E3C); box-shadow: 0 6px 20px rgba(76,175,80,0.42); }
.score-total.mid { background: linear-gradient(135deg, #42A5F5, #1565C0); box-shadow: 0 6px 20px rgba(66,165,245,0.42); }
.score-total.low { background: linear-gradient(135deg, #FFB74D, #F57C00); box-shadow: 0 6px 20px rgba(255,152,0,0.42); }
.score-stars { font-size: 24px; letter-spacing: 3px; line-height: 1.4; }
.score-verdict { font-size: 18px; font-weight: 700; margin-top: 4px; 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; }

/* ===== 底部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;
}

/* ===== 点读 - 单元列表 ===== */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  padding: 4px 0;
}
.unit-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
  border: 2px solid transparent;
}
.unit-card:active {
  transform: scale(0.96);
  border-color: var(--primary);
  box-shadow: 0 4px 18px rgba(66, 165, 245, 0.30);
}
.unit-card .unit-card-id {
  font-size: 13px;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.unit-card .unit-card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}
.unit-card .unit-card-pages {
  font-size: 13px;
  color: var(--text-light);
}
.unit-card:nth-child(1) { border-top: 4px solid var(--primary); }
.unit-card:nth-child(2) { border-top: 4px solid var(--green); }
.unit-card:nth-child(3) { border-top: 4px solid var(--orange); }
.unit-card:nth-child(4) { border-top: 4px solid #AB47BC; }
.unit-card:nth-child(5) { border-top: 4px solid #EF5350; }
.unit-card:nth-child(6) { border-top: 4px solid #26C6DA; }
.unit-card:nth-child(7) { border-top: 4px solid #8D6E63; }

/* ===== 点读 - 单元详情 ===== */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid #E3EEFB;
}
.btn-back {
  flex-shrink: 0;
  border: none;
  background: #E3EEFB;
  color: var(--primary);
  font-size: 16px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-back:active { background: #D0E3F7; }
.detail-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

/* ===== 点读 - 翻页查看器 ===== */
.flipper {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.flipper-stage {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: pan-y;
}
.flipper-stage img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 62vh;
  object-fit: contain;
  background: #fff;
}
.img-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--text-light);
  font-size: 16px;
  font-weight: 600;
  z-index: 3;
  min-height: 200px;
}
.img-loading.hidden { display: none; }
.flipper-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  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;
  z-index: 5;
}
.flipper-nav:active { background: #E3EEFB; }
.flipper-prev { left: 10px; }
.flipper-next { right: 10px; }
.page-card-label {
  position: absolute;
  bottom: 10px;
  right: 12px;
  background: rgba(0,0,0,0.50);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 10px;
  pointer-events: none;
  z-index: 5;
}

/* ===== 翻页进度 ===== */
.flipper-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 6px 6px;
}
.flipper-progress #flipper-progress-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-light);
  flex-shrink: 0;
}
.progress-dots {
  display: flex;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
}
.progress-dots::-webkit-scrollbar { display: none; }
.progress-dots .dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D0E3F7;
  cursor: pointer;
  transition: all 0.15s;
}
.progress-dots .dot.active {
  width: 20px;
  border-radius: 10px;
  background: var(--primary);
}

/* ===== 音频标签栏 ===== */
.audio-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 4px 4px;
}
.audio-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 2px solid #E3EEFB;
  border-radius: 20px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
  max-width: 100%;
  box-shadow: var(--shadow);
}
.audio-tag:active {
  transform: scale(0.95);
  border-color: var(--primary);
}
.audio-tag .audio-tag-icon {
  flex-shrink: 0;
  font-size: 16px;
}
.audio-tag .audio-tag-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-tag.playing {
  background: #FFF3E0;
  border-color: var(--orange);
  color: #F57F17;
  box-shadow: 0 2px 10px rgba(255, 152, 0, 0.30);
}
.audio-tag.playing .audio-tag-icon {
  animation: bounce 0.6s ease-in-out infinite;
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

/* ===== 跟读标签 ===== */
/* ===== 跟读标签(儿童友好) ===== */
.speak-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  max-width: 100%;
  box-shadow: 0 3px 12px rgba(66, 165, 245, 0.22);
}
.speak-tag:active {
  transform: scale(0.93);
  box-shadow: 0 1px 6px rgba(0,0,0,0.15);
}
.speak-tag .speak-tag-icon {
  flex-shrink: 0;
  font-size: 22px;
}
.speak-tag .speak-tag-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.speak-tag .speak-tag-best {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #FFB300, #FF8F00);
  border-radius: 14px;
  padding: 3px 10px;
  box-shadow: 0 2px 5px rgba(255, 152, 0, 0.4);
}
.speak-tag .speak-tag-go {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: rgba(255,255,255,0.30);
  border-radius: 14px;
  padding: 3px 10px;
}
/* part 分色 */
.speak-tag.part-a { background: linear-gradient(135deg, #42A5F5, #1E88E5); }
.speak-tag.part-b { background: linear-gradient(135deg, #66BB6A, #388E3C); }
.speak-tag.part-c { background: linear-gradient(135deg, #FFB74D, #F57C00); }
.speak-tag.part-intro { background: linear-gradient(135deg, #BA68C8, #8E24AA); }
.speak-tag.part-words { background: linear-gradient(135deg, #A1887F, #6D4C41); }
.speak-empty {
  width: 100%;
  text-align: center;
  font-size: 15px;
  color: var(--text-light);
  padding: 10px 0;
}
