/* ============ 小耳朵英语 · 主题变量 ============ */
:root {
  --bg: #f5fbf8;
  --bg-2: #eef6ff;
  --card: #ffffff;
  --ink: #2f403f;
  --ink-2: #7d9195;
  --ink-3: #aab9bb;
  --mint: #4ac9a6;
  --mint-d: #2aa787;
  --mint-soft: #e4f8f1;
  --orange: #ff8a4c;
  --orange-soft: #fff0e4;
  --blue: #62b4e8;
  --blue-soft: #e8f4fd;
  --line: #e8f1ee;
  --shadow: 0 10px 32px rgba(48, 112, 98, .10);
  --shadow-sm: 0 4px 14px rgba(48, 112, 98, .09);
  --font: "Trebuchet MS", "Comic Sans MS", "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16211f; --bg-2: #17232c; --card: #1d2a29;
    --ink: #eaf5f1; --ink-2: #9db3b1; --ink-3: #77908d;
    --mint-soft: #234239; --orange-soft: #3a2c22; --blue-soft: #21313d;
    --line: #2b3d3a; --shadow: 0 10px 32px rgba(0,0,0,.28);
    --shadow-sm: 0 4px 14px rgba(0,0,0,.22);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 8% 4%, rgba(98,180,232,.16), transparent 34%),
    radial-gradient(circle at 92% 12%, rgba(255,180,120,.16), transparent 32%),
    radial-gradient(circle at 50% 100%, rgba(74,201,166,.13), transparent 46%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

/* 背景漂浮的小点点，轻轻的，不抢戏 */
.dots { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.dots i {
  position: absolute; border-radius: 50%; opacity: .5;
  animation: float 9s ease-in-out infinite;
}
.dots i:nth-child(1) { width: 14px; height: 14px; background: var(--mint);  top: 12%; left: 6%;  animation-delay: 0s; }
.dots i:nth-child(2) { width: 9px;  height: 9px;  background: var(--orange); top: 22%; left: 92%; animation-delay: 1.4s; }
.dots i:nth-child(3) { width: 18px; height: 18px; background: var(--blue);   top: 62%; left: 3%;  animation-delay: 2.6s; opacity: .28; }
.dots i:nth-child(4) { width: 11px; height: 11px; background: var(--orange); top: 78%; left: 95%; animation-delay: 3.8s; }
.dots i:nth-child(5) { width: 7px;  height: 7px;  background: var(--mint);  top: 42%; left: 96%; animation-delay: .8s; }
@keyframes float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-18px) } }

.wrap { position: relative; z-index: 1; max-width: 880px; margin: 0 auto; padding: 30px 20px 70px; }

/* ============ 顶部 ============ */
.hero { text-align: center; margin-bottom: 26px; }
.hero-logo {
  width: 68px; height: 68px; margin: 0 auto 14px;
  border-radius: 24px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--mint), #74dcc0);
  box-shadow: 0 10px 24px rgba(74,201,166,.35);
  transform: rotate(-6deg);
}
.hero-logo svg { width: 38px; height: 38px; fill: #fff; }
.hero h1 { margin: 0; font-size: clamp(26px, 5.4vw, 36px); letter-spacing: 2px; font-weight: 800; }
.hero h1 .accent { color: var(--mint-d); }
.hero p { margin: 8px 0 0; color: var(--ink-2); font-size: clamp(13px, 3vw, 15px); }
.hero .spark { color: var(--orange); }

/* ============ 单元切换 ============ */
.tabs { display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; display: flex; align-items: center; gap: 9px;
  padding: 9px 16px 9px 10px; border: 2px solid transparent;
  border-radius: 999px; background: var(--card); color: var(--ink-2);
  font-family: var(--font); font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: .2s ease;
}
.tab:hover { transform: translateY(-2px); }
.tab.on { border-color: var(--mint); color: var(--mint-d); background: var(--mint-soft); }
.tab .num {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--mint-soft); color: var(--mint-d); font-size: 13px; flex: 0 0 auto;
}
.tab.on .num { background: var(--mint); color: #fff; }

/* ============ 控制条 ============ */
.panel {
  background: var(--card); border-radius: 26px; padding: 20px;
  box-shadow: var(--shadow); margin-bottom: 18px;
}
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  border: none; cursor: pointer; font-family: var(--font); font-weight: 800;
  border-radius: 999px; transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(.96); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn-main {
  padding: 13px 24px; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, var(--mint), #6fd8bb);
  box-shadow: 0 8px 20px rgba(74,201,166,.38);
}
.btn-main.playing { background: linear-gradient(135deg, var(--orange), #ffb27a); box-shadow: 0 8px 20px rgba(255,138,76,.35); }
.btn-sing {
  padding: 13px 22px; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, #ffa463, #ff7d8f);
  box-shadow: 0 8px 20px rgba(255,125,143,.34);
}
.btn-sing.playing { background: linear-gradient(135deg, var(--mint), #6fd8bb); box-shadow: 0 8px 20px rgba(74,201,166,.35); }
.btn-ghost {
  padding: 12px 18px; font-size: 14px; color: var(--ink-2);
  background: var(--bg); border: 2px solid var(--line);
}
.btn-ghost.on { color: var(--mint-d); border-color: var(--mint); background: var(--mint-soft); }

.seg-wrap {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 24px; margin-top: 16px; padding-top: 16px;
  border-top: 2px dashed var(--line);
}
.seg { display: flex; align-items: center; gap: 8px; min-width: 0; }
.seg-label { font-size: 13px; color: var(--ink-3); font-weight: 700; white-space: nowrap; }
.seg-box { display: flex; background: var(--bg); border: 2px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg-box button {
  border: none; background: transparent; color: var(--ink-2); cursor: pointer;
  font-family: var(--font); font-size: 13px; font-weight: 700; padding: 6px 13px;
  border-radius: 999px; transition: .18s ease; white-space: nowrap;
}
.seg-box button.on { background: var(--card); color: var(--mint-d); box-shadow: var(--shadow-sm); }

.progress { height: 6px; border-radius: 99px; background: var(--line); margin-top: 16px; overflow: hidden; display: none; }
.progress.show { display: block; }
.progress > i { display: block; height: 100%; width: 0%; border-radius: 99px; background: linear-gradient(90deg, var(--mint), var(--blue)); transition: width .35s ease; }
.status { margin-top: 10px; font-size: 13px; color: var(--ink-3); text-align: center; min-height: 18px; }

/* ============ 主内容卡（呼应教材橙虚线框） ============ */
.book {
  position: relative; background: var(--card);
  border: 2.5px dashed #ffcba5; border-radius: 30px;
  padding: 24px 20px; box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .book { border-color: #6b4b34; } }
.song-mode .book { border-color: #ffc4d0; }  /* 歌唱模式，虚线框换粉橙 */
.book-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; padding: 0 4px; }
.book-head .tag {
  background: var(--orange-soft); color: var(--orange); font-weight: 800; font-size: 12px;
  padding: 5px 12px; border-radius: 999px; letter-spacing: .5px;
}
.book-head h2 { margin: 0; font-size: clamp(17px, 3.8vw, 21px); font-weight: 800; }
.book-head .sub { color: var(--ink-3); font-size: 12px; margin-left: auto; white-space: nowrap; }

/* 每一句 */
.line {
  position: relative; display: grid; grid-template-columns: 54px 1fr 48px;
  align-items: center; gap: 12px; padding: 16px 12px; margin-top: 10px;
  border-radius: 20px; border: 2px solid transparent; cursor: pointer;
  transition: background .2s ease, border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.line:hover { background: var(--bg); }
.line.active {
  background: var(--mint-soft); border-color: var(--mint);
  box-shadow: var(--shadow-sm); transform: translateY(-1px);
}
.line-badge {
  width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center;
  background: var(--c-soft, var(--blue-soft)); color: var(--c, var(--blue));
  position: relative; flex: 0 0 auto;
}
.line-badge svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.line-badge .idx {
  position: absolute; top: -5px; left: -5px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--card); color: var(--ink-3); font-size: 11px; font-weight: 800;
  display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.line.active .line-badge .idx { background: var(--mint); color: #fff; }

.line-main { min-width: 0; }
.line-en { font-size: clamp(18px, 3.6vw, 22px); font-weight: 800; line-height: 1.5; letter-spacing: .2px; }
.line-en .w { border-radius: 6px; padding: 0 1px; transition: background .15s ease, color .15s ease; }
.line-en .w.speaking { background: var(--orange); color: #fff; }
.line-en .hi { color: var(--orange); white-space: nowrap; }  /* 橙色动作短语不拆行 */
/* 只在「单词」模式下才提示单词可点 */
.mode-word .line-en .w { cursor: pointer; }
.mode-word .line-en .w:hover { background: #fff2c9; color: #b26a00; }
.mode-word .line-en .hi .w:hover { background: var(--orange); color: #fff; }
.line-meta { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.place {
  font-size: 12.5px; font-weight: 800; color: var(--mint-d);
  background: var(--mint-soft); padding: 3px 10px; border-radius: 999px;
}
.cn { font-size: 13px; color: var(--ink-2); }

.play-btn {
  width: 46px; height: 46px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; color: var(--mint-d); background: var(--mint-soft);
  transition: transform .18s ease, background .18s ease, color .18s ease;
  -webkit-tap-highlight-color: transparent;
}
.play-btn:hover { transform: scale(1.09); }
.play-btn svg { width: 20px; height: 20px; fill: currentColor; }
.line.active .play-btn { background: var(--mint); color: #fff; }
.line.active .play-btn svg { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1) } 50% { transform: scale(1.16) } }

/* 播放中的小音柱（跟在中文释义后面，不压字） */
.bars { display: none; gap: 3px; align-items: flex-end; height: 16px; margin-left: 2px; }
.line.active .bars { display: inline-flex; }
.bars i { width: 4px; border-radius: 3px; background: var(--mint); animation: bar .7s ease-in-out infinite alternate; }
.bars i:nth-child(1) { height: 7px;  animation-delay: 0s; }
.bars i:nth-child(2) { height: 14px; animation-delay: .22s; }
.bars i:nth-child(3) { height: 9px;  animation-delay: .44s; }
@keyframes bar { from { height: 5px } to { height: 16px } }

/* 歌唱模式：小音符 + 图标轻轻摇摆 */
.notes { display: none; gap: 4px; color: var(--orange); font-size: 15px; font-weight: 800; margin-left: 2px; font-family: "Segoe UI Symbol", "Segoe UI", sans-serif; }
.line.active.singing .notes { display: inline-flex; animation: notefloat 1.1s ease-in-out infinite; }
.line.active.singing .line-badge { animation: wiggle .9s ease-in-out infinite; }
@keyframes notefloat { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }
@keyframes wiggle { 0%,100% { transform: rotate(0) } 25% { transform: rotate(-8deg) } 75% { transform: rotate(8deg) } }

/* ============ 页脚 ============ */
.tipbar {
  margin-top: 16px; text-align: center; font-size: 13px; color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
}
.tipbar b { color: var(--orange); }
.howto { margin-top: 22px; text-align: center; }
.howto summary {
  cursor: pointer; display: inline-block; list-style: none; color: var(--ink-3);
  font-size: 13px; font-weight: 700; padding: 8px 18px; border-radius: 999px;
  border: 2px dashed var(--line);
}
.howto summary::-webkit-details-marker { display: none; }
.howto ol {
  text-align: left; max-width: 560px; margin: 14px auto 0; padding: 18px 18px 18px 40px;
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow-sm);
  color: var(--ink-2); font-size: 13px; line-height: 2;
}
.howto code { background: var(--mint-soft); color: var(--mint-d); padding: 2px 7px; border-radius: 6px; font-weight: 700; }
.howto-note { margin: 14px 2px 0; font-size: 13px; line-height: 1.75; color: var(--ink-2); background: var(--mint-soft); border-radius: 12px; padding: 10px 14px; }
.footer { text-align: center; margin-top: 30px; color: var(--ink-3); font-size: 12px; }

/* ============ 自适应 ============ */
@media (max-width: 640px) {
  .wrap { padding: 22px 14px 56px; }
  .panel { padding: 16px; border-radius: 22px; }
  .controls { gap: 9px; }
  .btn-main { flex: 1 1 calc(50% - 5px); padding: 14px 8px; font-size: 15px; }
  .btn-sing { flex: 1 1 calc(50% - 5px); padding: 14px 8px; font-size: 15px; }
  .btn-ghost { flex: 1 1 auto; padding: 11px 12px; }
  .seg-wrap { grid-template-columns: 1fr; gap: 10px 14px; }
  .seg { justify-content: space-between; }
  .seg-box { flex: 1 1 auto; justify-content: space-around; }
  .seg-box button { padding: 7px 10px; }
  .book { padding: 18px 12px; border-radius: 24px; }
  .book-head { flex-wrap: wrap; gap: 8px; }
  .book-head .sub { margin-left: 0; width: 100%; }
  .line { grid-template-columns: 44px 1fr 42px; gap: 9px; padding: 14px 8px; border-radius: 17px; }
  .line-badge { width: 44px; height: 44px; border-radius: 14px; }
  .line-badge svg { width: 24px; height: 24px; }
  .play-btn { width: 42px; height: 42px; }
  .bars { display: none !important; }
  .line-en { font-size: clamp(17px, 4.4vw, 20px); }
  .cn { font-size: 12.5px; }
}
