/* =================================================================
 * 自然拼读打卡 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;
}

/* ---------------------- 布局基础 ---------------------- */
/* ---------------------- 右上角「站点首页」键 ---------------------- */
.home-link {
  position: fixed;
  top: 11px; right: 10px;
  z-index: 130;
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px 0 10px;
  border-radius: 17px;
  background: #fff;
  color: #2b7fff;
  font-family: inherit; font-size: 13.5px; font-weight: 800;
  text-decoration: none;
  border: 1px solid rgba(0, 0, 0, .08);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .18);
  white-space: nowrap;
}
.home-link .shelly-icon { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; vertical-align: middle; }
.home-link:active { transform: translateY(1px); }

main {
  padding: 92px 16px 110px;       /* 顶 92 = 留左上悬浮录音钮空间, 底 110 = dock 空间 */
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------------------- 顶部录音行 ---------------------- */
/* 悬浮按钮组：只占左上角，不再通栏；右侧留给「Shelly 主页」键 */
.record-bar {
  position: fixed; top: 11px; left: 10px;
  z-index: 120;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 4px;
  height: auto; padding: 0;
  max-width: min(60vw, 430px);
  background: transparent;
  border: 0;
  box-shadow: none;
}

.rec-btn {
  border: none; background: #fff;
  color: #e65100;
  font-weight: bold;
  font-size: 15px;
  padding: 9px 18px;
  border-radius: 22px;
  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 {
  font-size: 12.5px;
  color: #5d4037;
  background: rgba(255, 255, 255, .93);
  border-radius: 10px;
  padding: 3px 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .10);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: left;
}

/* ---------------------- 底部常驻 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;
  white-space: nowrap;
  flex: none;
}
.dock-btn:hover:not(:disabled) { background: #ffe082; }
.dock-btn:disabled { opacity: .4; cursor: not-allowed; }
.dock-home { background: #ffd54f; color: #4a2c00; }

/* 录音结束后锁页：dock 变灰 + 顶部状态高亮 */
body.nav-locked .dock-btn { opacity: .45; filter: grayscale(1); }
body.nav-locked .dock-btn:disabled { opacity: .25; }
body.nav-locked .dock::after {
  content: '🔒 先下载 / 分享录音';
  position: absolute; top: -26px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 12px; font-weight: bold;
  color: #b71c1c; background: #fff; border: 1px solid #ef9a9a;
  border-radius: 12px; padding: 3px 10px;
}
.record-bar .rec-status.is-warn {
  color: #b71c1c; font-weight: bold;
}

/* ---------------------- 录音结果右侧悬浮框（非常驻） ---------------------- */
.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-lock {
  font-size: 12px; color: #8d6e00; font-weight: bold;
  background: #fff8e1; border: 1px dashed #ffca28; border-radius: 8px;
  padding: 6px 8px; margin-bottom: 8px; line-height: 1.5;
}
.rec-pop.shake { animation: popShake .4s ease; }
@keyframes popShake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-7px); }
  75%     { transform: translateX(7px); }
}
.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.sh.main {
  font-size: 17px; padding: 14px 12px; margin-top: 10px;
  background: #2e7d32; color: #fff;
  box-shadow: 0 4px 14px rgba(46,125,50,.3);
}
.rec-pop-hint {
  font-size: 11.5px; color: #2e7d32; text-align: center;
  margin: 5px 0 8px; line-height: 1.5;
}
.rec-pop-action.copy { color: #6a1b9a; border-color: #6a1b9a; background: #f3e5f5; font-size: 13px; padding: 8px 10px; }
.rec-pop-action:hover { filter: brightness(.97); }
.rec-pop-action:disabled { opacity: .6; }

/* 分享至微信：环境不支持的指引区 */
.rec-pop-qr { margin-top: 8px; }
.rec-pop-note.ok   { color: #2e7d32; background: #e8f5e9; }
.rec-pop-note.warn { color: #8d6e00; background: #fff8e1; }
.rec-pop-guide { font-size: 12px; color: #444; line-height: 1.6; }
.rec-pop-guide p { margin: 6px 0; font-size: 12px; }
.rec-pop-guide p b { color: #c62828; }
.rec-pop-guide p.ok { color: #2e7d32; font-weight: bold; }
.rec-pop-mini-row { display: flex; gap: 6px; margin-top: 6px; }
.rec-pop-mini {
  flex: 1; font-size: 12px; font-weight: bold; padding: 8px 4px;
  border-radius: 10px; border: 1.5px solid #1565c0; color: #1565c0;
  background: #e3f2fd; cursor: pointer;
}
.rec-pop-mini.wx { border-color: #2e7d32; color: #2e7d32; background: #e8f5e9; }
.rec-pop-env { margin-top: 8px; font-size: 11px; color: #9e9e9e; text-align: center; }
/* 手机竖屏：弹窗铺满宽度，指引文字才看得清 */
@media (max-width: 520px) {
  .rec-pop { left: 8px; right: 8px; width: auto; max-height: 74vh; overflow-y: auto; }
  .rec-pop-action { font-size: 14px; padding: 9px 10px; }
  .rec-pop-guide p, .rec-pop-guide { font-size: 12.5px; }
}

@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; }
.toc-proof { margin-top: 10px; font-size: 13px; }
.toc-proof a { color: #a1887f; text-decoration: none; border: 1px dashed #d7ccc8;
  border-radius: 14px; padding: 5px 12px; display: inline-block; }

/* ---- 目录分组（P4–P72） ---- */
.toc-group { max-width: 980px; margin: 0 auto 18px; text-align: left; }
.toc-group-title {
  font-size: 15px; color: #5d4037; margin: 0 0 8px;
  padding-left: 10px; border-left: 5px solid #fbc02d;
}
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}
.page-card.small {
  border-width: 2px; padding: 10px 6px 8px; border-radius: 12px;
}
.page-card.small .page-card-num {
  position: static; display: inline-block;
  font-size: 15px; padding: 3px 10px; margin-bottom: 4px;
}
.page-card.small .page-card-footer {
  font-size: 11px; border: 0; padding-top: 2px; line-height: 1.3;
  min-height: 28px; display: flex; align-items: center; justify-content: center;
}
.toc-resume {
  display: inline-block; margin: 0 0 18px;
  background: #fff3c4; color: #e65100; font-weight: bold;
  padding: 10px 20px; border-radius: 22px; text-decoration: none;
  box-shadow: 0 3px 8px rgba(0,0,0,.10);
}

/* ---------------------- 内容页（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: default;          /* 点卡片不再发音，发音只走卡内的 .tile-play */
  transition: background .15s;
}
.word-tile:hover { background: #fff3c4; }
.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; }

/* 录制中：点单词卡任意位置即「记入跟读」（不发音），卡片闪一下作为反馈 */
body.rec-on .word-tile { cursor: pointer; }
.word-tile.rec-tap {
  animation: recTap .55s ease-out;
  border-color: #43a047;
}
/* 录制中：点句子方框任意位置即「记入整句跟读」（不发音），方框闪一下作为反馈 */
body.rec-on .para-block { cursor: pointer; }
.para-block.rec-tap {
  animation: recTapPara .55s ease-out;
  border-color: #43a047;
}
@keyframes recTapPara {
  0%   { background: #c8e6c9; }
  60%  { background: #e8f5e9; }
  100% { background: #fff8e1; }
}

@keyframes recTap {
  0%   { background: #c8e6c9; transform: scale(1.06); }
  60%  { background: #e8f5e9; transform: scale(1.0); }
  100% { background: #fff8e1; transform: scale(1); }
}

/* 单词卡播放键：只有点它才发音，点单词本身不发声 */
.tile-play {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; margin-bottom: 3px;
  border: none; border-radius: 50%;
  background: #fb8c00; color: #fff;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 0 #e65100;
  transition: background .15s, transform .08s;
  -webkit-tap-highlight-color: transparent;
}
.tile-play:hover { background: #f57c00; }
.tile-play:active { transform: translateY(1px); box-shadow: 0 1px 0 #e65100; }
.tile-play.is-playing { background: #d84315; box-shadow: 0 2px 0 #bf360c; }

/* 录制模式切换（录屏 / 单词卡）+ 帮助 */
.rec-mode {
  display: inline-flex; align-items: center; gap: 6px; margin-left: 8px;
  font-size: 13px; vertical-align: middle;
}
.rec-mode label {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer;
  background: #fff; border: 1px solid #e2c98f; border-radius: 999px;
  padding: 5px 12px; color: #7a5a1a; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.rec-mode label.is-on { background: #ffcf5c; border-color: #e0a800; font-weight: 700; }
.rec-mode input { margin: 0; }
.rec-help-btn {
  width: 28px; height: 28px; line-height: 1; cursor: pointer;
  background: #fff; border: 1px solid #ddd; border-radius: 50%;
  font-size: 15px; color: #8a6a1a;
}
.rec-help-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9999;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.rec-help-box {
  background: #fff; border-radius: 14px; max-width: 560px; width: 100%;
  max-height: 84vh; overflow: auto; padding: 18px 22px 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,.28); color: #3a2c10;
}
.rec-help-box h3 { margin: 0 0 12px; font-size: 18px; }
.rec-help-box p { margin: 14px 0 4px; font-size: 15px; }
.rec-help-box ol { margin: 4px 0; padding-left: 22px; font-size: 14px; line-height: 1.95; }
.rec-help-box .tip {
  background: #fff8e1; border-left: 4px solid #ffc107;
  padding: 8px 12px; font-size: 13.5px; line-height: 1.7; margin: 8px 0; border-radius: 4px;
}
.rec-help-close {
  float: right; border: none; background: none; font-size: 24px;
  cursor: pointer; color: #999; line-height: 1; padding: 0 4px;
}

/* 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: 2; font-size: 16px; }
/* 点读单词：放大到与"▶整句"按键相当，方便小朋友点击、避免误触 */
.para-text .w {
  display: inline-block;
  padding: 6px 12px;
  margin: 3px 2px;
  border-radius: 18px;
  background: #fce4ec;
  font-size: 16px;
  font-weight: bold;
  color: #880e4f;
  text-align: center;
  cursor: pointer;
  transition: background .12s;
}
.para-text .w .zh {
  display: block;
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  color: #ad1457;
}
.para-text .w:hover { background: #fff3c4; }
.para-text .w.is-playing { background: #fbc02d; color: #5d4037; }

/* 句尾中文整句翻译 */
.para-text .sent-zh {
  font-size: 14px;
  font-weight: 600;
  color: #880e4f;
  margin-left: 8px;
}
/* 拼读卡中文 */
.word-tile .zh {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  margin-top: 1px;
  line-height: 1.3;
}

/* 录音可视提示 */
.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: 92px; }
