/* style.css — 亲子英语启蒙小程序
 * 移动端优先，单手友好：大点击区、清晰层级、醒目播放键、温暖橙色主题。
 */
:root {
  --primary: #FF8A4C;
  --primary-d: #F4722B;
  --primary-l: #FFF2EA;
  --bg: #F6F7FB;
  --card: #FFFFFF;
  --ink: #2B2B2B;
  --ink-2: #6B7280;
  --ink-3: #9AA1AC;
  --line: #EDEFF3;
  --gold: #FFB020;
  --ok: #34C759;
  --shadow: 0 6px 20px rgba(30, 30, 40, 0.08);
  --radius: 16px;
  --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { max-width: 100%; }

/* ---------- 应用容器（桌面端居中成手机宽度） ---------- */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(var(--tab-h) + var(--safe-b) + 12px);
  box-shadow: 0 0 40px rgba(0,0,0,0.04);
}

/* ---------- 页面切换 ---------- */
.page { display: none; }
.page.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 首页 Hero ---------- */
.hero {
  background: linear-gradient(135deg, #FF9A5A, #FF7A3D);
  color: #fff;
  padding: 18px 18px 22px;
  border-bottom-left-radius: 26px;
  border-bottom-right-radius: 26px;
  box-shadow: 0 8px 22px rgba(255, 122, 61, 0.28);
}
.hero-top { display: flex; align-items: center; justify-content: space-between; }
.hero-title { font-size: 22px; font-weight: 800; letter-spacing: .5px; }
.hero-sub { font-size: 12.5px; opacity: .9; margin-top: 2px; }
.voice-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.35);
  padding: 7px 12px; border-radius: 999px;
  font-size: 13px; color: #fff; backdrop-filter: blur(4px);
}
.vc-icon { font-size: 16px; }

.search-entry {
  margin-top: 16px; width: 100%;
  display: flex; align-items: center; gap: 8px;
  background: #fff; color: var(--ink-3);
  padding: 13px 14px; border-radius: 14px;
  font-size: 14px; text-align: left; box-shadow: var(--shadow);
}
.search-entry .si { font-size: 15px; }

.hero-stats { display: flex; gap: 10px; margin-top: 16px; }
.hero-stats > div {
  flex: 1; background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 12px; padding: 10px 4px; text-align: center;
}
.hero-stats b { display: block; font-size: 20px; font-weight: 800; }
.hero-stats span { font-size: 11.5px; opacity: .92; }

/* ---------- 区块标题 ---------- */
.section-bar { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 18px 10px; }
.section-bar h2 { font-size: 16px; margin: 0; font-weight: 800; }
.section-bar .hint { font-size: 12px; color: var(--ink-3); }

/* ---------- 今日推荐 ---------- */
.today-card {
  margin: 0 18px; background: var(--card); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.today-label { display: inline-block; font-size: 12px; color: var(--primary-d); background: var(--primary-l); padding: 3px 10px; border-radius: 999px; font-weight: 700; }
.today-en { font-size: 21px; font-weight: 800; margin: 10px 0 4px; }
.today-cn { font-size: 14px; color: var(--ink-2); }
.today-play {
  margin-top: 12px; background: var(--primary); color: #fff;
  padding: 11px 18px; border-radius: 12px; font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 14px rgba(255,122,61,.35);
}

/* ---------- 场景网格 ---------- */
.scene-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding: 0 18px;
}
.scene-card {
  background: var(--card); border-radius: var(--radius); padding: 16px 14px;
  text-align: left; box-shadow: var(--shadow); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px; min-height: 92px;
  transition: transform .12s ease;
}
.scene-card:active { transform: scale(.97); }
.sc-icon { font-size: 30px; line-height: 1; }
.sc-name { font-size: 15.5px; font-weight: 700; }
.sc-sub { font-size: 12px; color: var(--ink-3); }

/* ---------- 章节 → 单元（二级） ---------- */
.sub-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; padding: 14px 18px;
}
.sub-card {
  background: var(--card); border-radius: var(--radius); padding: 15px 14px;
  text-align: left; box-shadow: var(--shadow); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px; min-height: 74px;
  transition: transform .12s ease;
}
.sub-card:active { transform: scale(.97); }
.sub-name { font-size: 15px; font-weight: 700; line-height: 1.35; }
.sub-sub { font-size: 12px; color: var(--ink-3); }

.foot-note { text-align: center; color: var(--ink-3); font-size: 11.5px; margin: 22px 18px 6px; line-height: 1.6; }

/* ---------- 顶部栏 ---------- */
.bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  background: var(--card); padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.bar-plain { justify-content: flex-start; }
.bar-back {
  font-size: 26px; line-height: 1; width: 36px; height: 36px;
  color: var(--ink); border-radius: 10px;
}
.bar-back:active { background: var(--line); }
.bar-title { flex: 1; display: flex; flex-direction: column; }
.bar-title > span { font-size: 17px; font-weight: 800; }
.bar-title small { font-size: 12px; color: var(--ink-3); font-weight: 500; }
.bar-act {
  background: var(--primary-l); color: var(--primary-d);
  font-size: 13.5px; font-weight: 700; padding: 8px 12px; border-radius: 10px;
}

/* ---------- 详情工具条 ---------- */
.detail-toolbar {
  display: flex; gap: 10px; padding: 12px 14px;
  position: sticky; top: 56px; z-index: 20; background: var(--bg);
}
.seg {
  display: flex; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 4px; gap: 4px; flex: 1;
}
.seg button {
  flex: 1; padding: 9px 6px; border-radius: 9px; font-size: 13.5px;
  color: var(--ink-2); font-weight: 600;
}
.seg button.on { background: var(--primary); color: #fff; box-shadow: 0 4px 10px rgba(255,122,61,.3); }
.seg-rate { flex: 1.1; }
.seg-wide button { flex: 1; }

/* ---------- 句子列表 ---------- */
.list { padding: 4px 14px calc(var(--tab-h) + var(--safe-b) + 90px); }
.s-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 12px; margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(30,30,40,.04);
}
.s-row.playing { border-color: var(--primary); box-shadow: 0 4px 14px rgba(255,122,61,.22); }
.s-main { flex: 1; min-width: 0; }
.s-en { font-size: 16.5px; font-weight: 700; line-height: 1.35; word-break: break-word; }
.s-cn { font-size: 13.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.35; }
.s-tag { display: inline-block; font-size: 11px; color: var(--primary-d); background: var(--primary-l); padding: 2px 8px; border-radius: 999px; margin-bottom: 4px; font-weight: 700; }
.s-badge { display: inline-block; font-size: 10.5px; color: #fff; background: var(--gold); padding: 1px 7px; border-radius: 999px; margin-right: 6px; vertical-align: middle; font-weight: 700; }
.s-curated .s-en::first-letter { }
.s-play {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 5px 12px rgba(255,122,61,.35);
}
.s-play:active { transform: scale(.92); }
.s-fav {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  font-size: 20px; color: var(--ink-3); background: var(--bg);
}
.s-fav.on { color: var(--primary-d); }
.s-fav:active { transform: scale(.9); }

.list-end { text-align: center; color: var(--ink-3); font-size: 12px; padding: 6px 0 4px; }
.empty { text-align: center; color: var(--ink-3); font-size: 14px; padding: 48px 24px; line-height: 1.8; }

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 100%; max-width: 480px;
  height: calc(var(--tab-h) + var(--safe-b));
  display: flex; background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b); z-index: 40;
  box-shadow: 0 -4px 18px rgba(30,30,40,.06);
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--ink-3); font-size: 11.5px; font-weight: 600;
}
.tabbar button i { font-size: 21px; font-style: normal; }
.tabbar button.on { color: var(--primary-d); }

/* ---------- 正在播放浮条 ---------- */
.now-playing {
  position: fixed; left: 50%;
  /* 默认隐藏：彻底移出屏幕底部 + 透明 + 不可点，绝不遮挡菜单栏 */
  transform: translateX(-50%) translateY(calc(100% + 90px));
  /* 播放时贴在菜单栏正上方，留 8px 间隙 */
  bottom: calc(var(--tab-h) + var(--safe-b) + 8px);
  width: calc(100% - 32px); max-width: 448px;
  background: #2B2B2B; color: #fff; border-radius: 14px;
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); z-index: 50;
  opacity: 0; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
}
/* 播放时：完全可见可用，且稳稳在菜单栏上方 */
.now-playing.show { transform: translateX(-50%) translateY(0); opacity: .98; pointer-events: auto; }
.np-wave { display: flex; align-items: flex-end; gap: 3px; height: 18px; }
.np-wave i { width: 3px; background: var(--primary); border-radius: 2px; animation: wave 1s infinite ease-in-out; }
.np-wave i:nth-child(1) { height: 8px; animation-delay: 0s; }
.np-wave i:nth-child(2) { height: 16px; animation-delay: .15s; }
.np-wave i:nth-child(3) { height: 11px; animation-delay: .3s; }
.np-wave i:nth-child(4) { height: 18px; animation-delay: .45s; }
@keyframes wave { 0%,100% { transform: scaleY(.4); } 50% { transform: scaleY(1); } }
.np-text { flex: 1; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-stop { background: rgba(255,255,255,.16); color: #fff; padding: 7px 14px; border-radius: 9px; font-size: 13px; font-weight: 700; }

/* ---------- 设置页 ---------- */
.set-wrap { padding: 16px 14px; }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.set-title { font-size: 15px; font-weight: 800; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.set-val { color: var(--primary-d); font-weight: 700; font-size: 14px; }
.set-tip { font-size: 12px; color: var(--ink-3); margin-top: 10px; line-height: 1.5; }

.voice-picker { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.voice-opt {
  text-align: left; padding: 11px 13px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg); font-size: 14px; color: var(--ink);
}
.voice-opt.on { border-color: var(--primary); background: var(--primary-l); color: var(--primary-d); font-weight: 700; }
.voice-opt .v-lang { font-size: 11px; color: var(--ink-3); }
.voice-none { font-size: 13px; color: var(--ink-3); padding: 8px 2px; line-height: 1.6; }

#rateRange { width: 100%; accent-color: var(--primary); margin: 4px 0 2px; }
.range-marks { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-3); }
.try-btn { width: 100%; background: var(--primary); color: #fff; padding: 13px; border-radius: 12px; font-size: 14.5px; font-weight: 700; box-shadow: 0 6px 14px rgba(255,122,61,.32); }
.set-about { text-align: center; font-size: 11.5px; color: var(--ink-3); line-height: 1.8; margin-top: 8px; }

/* ---------- 搜索页 ---------- */
.search-bar { gap: 8px; }
.search-bar input {
  flex: 1; border: 1px solid var(--line); background: var(--bg);
  border-radius: 11px; padding: 10px 13px; font-size: 15px; outline: none;
}
.search-bar input:focus { border-color: var(--primary); }
.quick-tags { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
.q-tag { background: var(--card); border: 1px solid var(--line); color: var(--ink-2); padding: 7px 13px; border-radius: 999px; font-size: 13px; }
.q-tag:active { background: var(--primary-l); }

/* ---------- 警告条 ---------- */
.tts-warn { margin: 0 18px 4px; background: #FFF7E6; border: 1px solid #FFE0A3; color: #9A6B00; font-size: 12.5px; padding: 12px 14px; border-radius: 12px; line-height: 1.6; }
