/* =================================================================
 * 自然拼读打卡 Aa - 全站样式
 * 书本风格 + 大按钮（适合儿童点选）+ 顶底录音 + 底部常驻 dock
 * ================================================================= */

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

html, body {
  margin: 0; padding: 0;
  font-family: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(180deg, #fff8e7 0%, #ffeec0 100%);
  color: #333;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------------------- 布局基础 ---------------------- */
main {
  padding: 70px 16px 110px;       /* 顶 70 = 留录音行空间, 底 110 = dock 空间 */
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------------------- 顶部录音行 ---------------------- */
.record-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px;
  background: linear-gradient(180deg, #ffe082, #ffd54f);
  border-bottom: 2px solid #f9a825;
  display: flex; align-items: center; justify-content: flex-start;
  gap: 14px; padding: 0 12px;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}

.rec-btn {
  border: none; background: #fff;
  color: #e65100;
  font-weight: bold;
  font-size: 18px;
  padding: 10px 22px;
  border-radius: 26px;
  box-shadow: 0 3px 0 #e65100;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
  display: inline-flex;
  align-items: center; gap: 8px;
  white-space: nowrap;
  flex: none;
}
.rec-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #e65100;
}
.rec-btn.is-recording {
  background: #e53935;
  color: #fff;
  box-shadow: 0 3px 0 #b71c1c;
  animation: pulse 1.2s infinite;
}
.rec-btn.is-recording:active { box-shadow: 0 1px 0 #b71c1c; }
/* 有未完成会话、本页刚加载还没开上麦 → “继续录音” */
.rec-btn.is-paused {
  background: #fb8c00;
  color: #fff;
  box-shadow: 0 3px 0 #e65100;
  animation: pulse 1.6s infinite;
}
.rec-btn.is-paused:active { box-shadow: 0 1px 0 #e65100; }
.rec-btn.is-paused .rec-dot { background: #fff; }
.rec-dot {
  display: inline-block; width: 12px; height: 12px;
  background: #b71c1c; border-radius: 50%;
}
.rec-btn.is-recording .rec-dot { background: #fff; }

/* 底部录音键：固定在左下角，位于常驻 dock 之上 */
.rec-btn-float {
  position: fixed;
  left: 12px;
  bottom: 68px;
  z-index: 101;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 3px 0 #b71c1c, 0 0 0 0 rgba(229,57,53,.6); }
  50%      { box-shadow: 0 3px 0 #b71c1c, 0 0 0 8px rgba(229,57,53,0); }
}

.record-bar .rec-status {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  color: #5d4037;
  text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------------- 底部常驻 dock ---------------------- */
.dock {
  position: fixed; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 8px;
  background: #fff;
  padding: 8px;
  border-radius: 36px;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
  z-index: 100;
  border: 2px solid #ffd54f;
}
.dock-bottom {
  bottom: 10px;
}
.dock-btn {
  border: none; background: #fff8e1;
  color: #6d4c00;
  font-weight: bold;
  font-size: 16px;
  padding: 10px 18px;
  border-radius: 26px;
  cursor: pointer;
  transition: background .15s;
}
.dock-btn:hover:not(:disabled) { background: #ffe082; }
.dock-btn:disabled { opacity: .4; cursor: not-allowed; }
.dock-home { background: #ffd54f; color: #4a2c00; }

/* ---------------------- 录音结果右侧悬浮框（非常驻） ---------------------- */
.rec-pop {
  position: fixed; top: 80px; right: 10px;
  width: 260px;
  background: #fff;
  border: 2px solid #43a047;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
  padding: 12px 14px;
  z-index: 110;
  animation: slideInRight .25s ease-out;
}
.rec-pop-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
  font-size: 14px; color: #2e7d32; font-weight: bold;
}
.rec-pop-loading {
  font-size: 13px; color: #ef6c00;
  text-align: center; padding: 14px 0;
}
.rec-pop-note {
  font-size: 12px; color: #c62828;
  background: #ffebee; border-radius: 8px;
  padding: 6px 8px; margin-bottom: 8px;
}
.rec-pop-close {
  border: none; background: transparent;
  font-size: 20px; cursor: pointer; color: #999;
}
.rec-pop-row {
  display: flex; align-items: center; gap: 8px;
  margin: 6px 0;
}
.rec-pop-row audio { flex: 1; height: 36px; }
.rec-pop-action {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  font-size: 15px; font-weight: bold;
  border-radius: 12px;
  border: 2px solid;
  cursor: pointer;
  text-align: center;
}
.rec-pop-action.dl { color: #1565c0; border-color: #1565c0; background: #e3f2fd; }
.rec-pop-action.sh { color: #2e7d32; border-color: #2e7d32; background: #e8f5e9; }
.rec-pop-action:hover { filter: brightness(.97); }

@keyframes slideInRight {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ---------------------- 主页目录 ---------------------- */
.toc-page { text-align: center; padding: 80px 16px 110px; }
.toc-title { font-size: 32px; margin: 0 0 4px; color: #e65100; }
.toc-sub   { font-size: 14px; color: #8d6e63; margin: 0 0 28px; }

.book-spread {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
}

.page-card {
  display: block;
  background: #fff;
  border: 3px solid #fbc02d;
  border-radius: 14px;
  padding: 0 0 14px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 4px 10px rgba(0,0,0,.10);
  transition: transform .15s, box-shadow .15s;
  overflow: hidden;
  position: relative;
}
.page-card:hover, .page-card:active {
  transform: translateY(-3px);
  box-shadow: 0 8px 16px rgba(0,0,0,.18);
}
.page-card-num {
  position: absolute; top: 6px; right: 10px;
  background: #fbc02d; color: #5d4037;
  padding: 4px 12px; border-radius: 12px;
  font-weight: bold; font-size: 16px;
}
.page-card-thumb { padding: 14px 12px 8px; }
.ph-section {
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 13px;
}
.ph-section .ph-bar {
  display: inline-block; padding: 2px 8px;
  border-radius: 8px; font-weight: bold;
  background: rgba(255,255,255,.6);
  margin-bottom: 4px;
}
.ph-section.orange { background: #ffe0b2; color: #6d3a00; }
.ph-section.blue   { background: #e3f2fd; color: #0d47a1; }
.ph-section.green  { background: #c8e6c9; color: #1b5e20; }
.ph-section.pink   { background: #fce4ec; color: #880e4f; }
.ph-section .ph-arrows, .ph-section .ph-words {
  font-family: "Comic Sans MS", cursive;
  font-size: 14px; color: #5d4037;
}
.page-card-footer {
  text-align: center;
  font-size: 12px; color: #8d6e63;
  border-top: 1px dashed #ffcc80; padding-top: 6px;
}

.page-corner {
  display: none;
}
.toc-tip { margin-top: 28px; color: #8d6e63; font-size: 13px; }

/* ---------------------- 内容页（P4–P7） ---------------------- */
.page-title {
  text-align: center;
  font-size: 22px;
  color: #6d3a00;
  margin: 0 0 4px;
}
.page-sub {
  text-align: center;
  font-size: 13px; color: #8d6e63;
  margin: 0 0 16px;
}

.section {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px 18px;
  margin-bottom: 18px;
  box-shadow: 0 3px 8px rgba(0,0,0,.07);
  border: 2px solid;
}
.section .sec-label {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 10px;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 10px;
}
.section.blend_say  { border-color: #ffb74d; }
.section.blend_say  .sec-label { background: #ffe0b2; color: #6d3a00; }
.section.blend_words{ border-color: #64b5f6; }
.section.blend_words .sec-label { background: #e3f2fd; color: #0d47a1; }
.section.sound      { border-color: #81c784; }
.section.sound      .sec-label { background: #c8e6c9; color: #1b5e20; }
.section.reading    { border-color: #f06292; }
.section.reading    .sec-label { background: #fce4ec; color: #880e4f; }

/* 单词网格 - 拼读项（a·X → aX） */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.word-tile {
  display: flex; flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 10px;
  background: #fff8e1;
  border: 1.5px solid #ffe082;
  cursor: pointer;
  transition: transform .1s, background .15s;
}
.word-tile:hover { background: #fff3c4; transform: translateY(-2px); }
.word-tile:active { transform: translateY(0); }
.word-tile .phonetic {
  font-family: "Comic Sans MS", cursive;
  font-size: 13px;
  color: #6d4c00;
}
.word-tile .word {
  font-family: "Comic Sans MS", cursive;
  font-size: 20px;
  font-weight: bold;
  color: #bf360c;
}
.word-tile.is-playing { background: #ffcc80; border-color: #fb8c00; }

/* Reading Fun 段落 */
.para-block {
  background: #fff8e1;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1.5px solid #ffe082;
}
.para-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.para-bar .para-play {
  background: #f06292;
  color: #fff;
  border: none;
  font-weight: bold;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 18px;
  cursor: pointer;
  box-shadow: 0 3px 0 #ad1457;
}
.para-bar .para-play:active { box-shadow: 0 1px 0 #ad1457; transform: translateY(2px); }
.para-bar .para-play.is-playing { background: #fbc02d; box-shadow: 0 3px 0 #f57f17; }

.para-text { line-height: 1.7; font-size: 16px; }
.para-text .w {
  display: inline-block;
  padding: 0 3px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s;
}
.para-text .w:hover { background: #fff3c4; }
.para-text .w.is-playing { background: #fbc02d; color: #5d4037; }

/* 录音可视提示 */
.rec-indicator {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(229,57,53,.95);
  color: #fff;
  padding: 6px 16px;
  border-radius: 18px;
  font-size: 14px;
  z-index: 90;
  display: none;
}
.rec-indicator.on { display: block; animation: pulse 1.2s infinite; }

/* 防止 iOS 输入框遮挡 - 主区 scroll 在 main 内 */
.page-section { scroll-margin-top: 70px; }
