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

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

body {
  font-family: -apple-system, "Helvetica Neue", "PingFang SC", Arial, sans-serif;
  background: linear-gradient(160deg, #fff7ed 0%, #fdf2f8 55%, #eff6ff 100%);
  min-height: 100vh;
  color: #333;
  --ac1: #10b981;
  --ac2: #34d399;
}

/* 每个班一个主题色，切换班级时整体变色 */
body[data-cls="A"] { --ac1: #10b981; --ac2: #34d399; }
body[data-cls="B"] { --ac1: #3b82f6; --ac2: #60a5fa; }
body[data-cls="C"] { --ac1: #f97316; --ac2: #fb923c; }
body[data-cls="D"] { --ac1: #ec4899; --ac2: #f472b6; }

.hidden {
  display: none !important;
}

/* ---------- 首页 ---------- */

#home-view {
  max-width: 860px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

.home-link {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  z-index: 20;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  text-decoration: none;
}

.home-link:active {
  transform: scale(.94);
}

.home-header {
  text-align: center;
  margin-bottom: 20px;
}

.home-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: #1f2937;
}

.subtitle {
  font-size: 14px;
  color: #9ca3af;
  margin-top: 6px;
}

.class-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 420px;
  margin: 16px auto 0;
}

.class-tab {
  border: 1px solid rgba(0, 0, 0, .08);
  background: rgba(255, 255, 255, .85);
  border-radius: 14px;
  padding: 8px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
}

.class-tab .cls-name {
  font-size: 15px;
  font-weight: 800;
  color: #374151;
}

.class-tab .cls-desc {
  font-size: 11px;
  color: #9ca3af;
}

.class-tab.on {
  background: var(--ac1);
  border-color: var(--ac1);
}

.class-tab.on .cls-name {
  color: #fff;
}

.class-tab.on .cls-desc {
  color: #d1d5db;
}

.class-tab:active {
  transform: scale(.96);
}

.progress-wrap {
  margin: 16px auto 0;
  max-width: 420px;
}

.progress-bar {
  height: 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .06);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--ac2), var(--ac1));
  transition: width .4s ease;
}

.progress-text {
  font-size: 13px;
  color: #9ca3af;
  margin-top: 8px;
}

.day-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (min-width: 560px) {
  .day-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 768px) {
  .day-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
  }
}

.day-card {
  position: relative;
  background: rgba(255, 255, 255, .85);
  border: 1px solid rgba(0, 0, 0, .05);
  border-radius: 18px;
  padding: 14px 8px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.day-card:active {
  transform: scale(.96);
}

.day-card .emoji {
  font-size: 30px;
  line-height: 1;
}

.day-card .day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--ac1);
}

.day-card .day-topic {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.3;
}

.day-card.done {
  background: linear-gradient(150deg, #ecfdf5, #d1fae5);
  border-color: #a7f3d0;
}

.day-card .check {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 13px;
  color: #10b981;
  font-weight: 800;
}

.home-footer {
  text-align: center;
  font-size: 13px;
  color: #c4c8cf;
  margin-top: 28px;
}

/* ---------- 课程页 ---------- */

#lesson-view {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: calc(122px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
}

/* 标题栏固定在顶部，内容滚动时不动 */
.lesson-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: rgba(255, 248, 243, .85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .06);
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
}

.lesson-header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  font-size: 24px;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:active {
  transform: scale(.94);
}

#btn-play-all.playing {
  background: #fee2e2;
  color: #ef4444;
}

.lesson-title-wrap {
  flex: 1;
  text-align: center;
  min-width: 0;
}

.lesson-day {
  font-size: 12px;
  font-weight: 700;
  color: var(--ac1);
  letter-spacing: 1px;
}

.lesson-title {
  font-size: 18px;
  font-weight: 800;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin: 8px auto 0;
  max-width: 720px;
  flex-wrap: wrap;
  justify-content: center;
}

.tool-btn {
  border: 1px solid rgba(0, 0, 0, .08);
  background: rgba(255, 255, 255, .85);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  color: #4b5563;
  cursor: pointer;
}

.tool-btn.on {
  background: #1f2937;
  color: #fff;
  border-color: #1f2937;
}

.dialogue {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
}

.section-label {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: #9ca3af;
  letter-spacing: 2px;
  margin: 10px 0 2px;
}

.line {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 96%;
}

/* 每句的播放按钮：DOM 在气泡后 → 爸爸(正向)在右侧，女儿(反向)在左侧 */
.play-btn {
  flex: 0 0 auto;
  align-self: center;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  color: var(--ac1);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.play-btn:active {
  transform: scale(.9);
}

.line.speaking .play-btn {
  background: var(--ac1);
  color: #fff;
}

.line.kid {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.bubble {
  border-radius: 18px;
  padding: 11px 14px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .05);
  transition: background .2s ease;
}

.line.dad .bubble {
  background: #ffffff;
  border-bottom-left-radius: 6px;
}

.line.kid .bubble {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
  border-bottom-right-radius: 6px;
}

.bubble .en {
  font-size: 17px;
  line-height: 1.45;
  color: #1f2937;
  font-weight: 500;
}

.bubble .zh {
  font-size: 13px;
  color: #9ca3af;
  margin-top: 4px;
  line-height: 1.4;
}

body.hide-zh .bubble .zh {
  display: none;
}

.line.speaking .bubble {
  outline: 3px solid #fdba74;
}

/* 遮挡练习：文字被磨玻璃盖住，点一下显示 */
.line.masked .bubble .en,
.line.masked .bubble .zh {
  filter: blur(6px);
  user-select: none;
}

.line.masked .bubble {
  position: relative;
}

.line.masked .bubble {
  min-width: 170px;
}

.line.masked .bubble::after {
  content: '💡 ' attr(data-hint);
  white-space: pre-line;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  color: #4b5563;
  background: rgba(255, 255, 255, .4);
  border-radius: inherit;
}

.line.masked.revealed .bubble .en,
.line.masked.revealed .bubble .zh {
  filter: none;
}

.line.masked.revealed .bubble::after {
  display: none;
}

.tip {
  text-align: center;
  font-size: 12px;
  color: #c4c8cf;
  margin-top: 14px;
  line-height: 1.5;
}

.lesson-footer {
  display: flex;
  gap: 10px;
  padding-top: 10px;
}

.nav-btn,
.done-btn {
  border: none;
  border-radius: 16px;
  padding: 14px 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.nav-btn {
  flex: 1;
  background: rgba(255, 255, 255, .9);
  color: #6b7280;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .05);
}

.nav-btn:disabled {
  opacity: .35;
}

.done-btn {
  flex: 1.4;
  background: linear-gradient(135deg, var(--ac2), var(--ac1));
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

.done-btn.done {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 4px 14px rgba(16, 185, 129, .3);
}

.done-btn:active,
.nav-btn:active {
  transform: scale(.97);
}

/* 打卡庆祝 */
.celebrate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 90px;
  pointer-events: none;
  animation: pop 1.1s ease forwards;
  z-index: 50;
}

@keyframes pop {
  0% { transform: scale(.2); opacity: 0; }
  30% { transform: scale(1.2); opacity: 1; }
  60% { transform: scale(1); }
  100% { transform: scale(1.4); opacity: 0; }
}

@media (min-width: 768px) {
  .bubble .en { font-size: 19px; }
  .bubble .zh { font-size: 14px; }
  .lesson-title { font-size: 21px; }
}
