:root {
  --bg: #FFF9F0;
  --card: #FFFFFF;
  --ink: #3A3226;
  --ink-soft: #8A7F6D;
  --brand: #FFB84D;
  --brand-deep: #F59E1B;
  --radius: 20px;
  --shadow: 0 4px 16px rgba(120, 90, 40, .10);
}

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

body {
  margin: 0;
  padding: 0 0 120px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}

/* 顶部 */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 8px;
}
.logo { font-size: 30px; }
.title { font-size: 22px; font-weight: 800; letter-spacing: 1px; }

/* 定时关闭（右上角） */
.timer-btn {
  margin-left: auto;
  border: 2px solid #EFE3CE; background: #fff; color: var(--ink-soft);
  font-size: 14px; font-weight: 700; font-family: inherit;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  transition: all .15s ease;
}
.timer-btn.on { border-color: var(--brand); background: #FFF3DF; color: var(--brand-deep); }
.timer-btn:active { transform: scale(.95); }

/* 麦克风 / 点播区
   ⚠️ 这里曾经翻过车：HTML 用的是 .ask-area，CSS 写的是 .mic-area，
   两个名字对不上 → 整个点播区丢了「居中 + 内边距」，大麦克风按钮挤在左上角。
   两个名字都留着，谁改都不会再断。 */
.mic-area, .ask-area { text-align: center; padding: 8px 20px 20px; }

.mic-btn {
  width: 116px; height: 116px; border-radius: 50%;
  border: none; background: linear-gradient(160deg, #FFD08A, var(--brand-deep));
  box-shadow: 0 8px 24px rgba(245, 158, 27, .38);
  font-size: 46px; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative; /* 让右上角的小红点能绝对定位 */
}
.mic-btn:active, .mic-btn.recording {
  transform: scale(.93);
  box-shadow: 0 0 0 12px rgba(255, 184, 77, .28);
}
/* 录音中：背景变红、图标从🎤 换成 ✓ */
.mic-btn.listening {
  animation: pulse 1.2s infinite;
  background: linear-gradient(160deg, #FFB1A8, #E5584F);
  box-shadow: 0 8px 24px rgba(229, 88, 79, .42);
}
.mic-btn.listening .mic-icon-mic { display: none; }
.mic-btn:not(.listening) .mic-icon-done { display: none; }
.mic-icon { line-height: 1; }
.mic-btn.off, .mic-btn:disabled {
  background: #EDE5D8; color: #B5AA97; box-shadow: none; cursor: default;
  font-size: 40px;
}
/* 录音中右上角的小红点（再点一下就停的视觉提示） */
.mic-rec-dot {
  position: absolute; top: 14px; right: 14px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(229, 88, 79, .6);
  animation: blinker 1s infinite;
}
@keyframes blinker {
  50% { opacity: .3; }
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,184,77,.45); }
  50%     { box-shadow: 0 0 0 18px rgba(255,184,77,0); }
}

.mic-hint { margin-top: 14px; font-size: 15px; color: var(--ink-soft); }
.asr-text {
  margin-top: 8px; font-size: 20px; font-weight: 700; min-height: 28px;
  color: var(--brand-deep);
}

/* 打字点播（麦克风用不了时的兜底） */
.type-toggle {
  margin-top: 14px; border: none; background: transparent;
  color: var(--ink-soft); font-size: 14px; font-family: inherit;
  text-decoration: underline; cursor: pointer; padding: 6px;
}
.type-box {
  display: flex; gap: 8px; margin: 4px auto 0; max-width: 460px;
}
.type-box input {
  flex: 1; min-width: 0;
  border: 2px solid #EFE3CE; border-radius: 14px;
  padding: 13px 16px; font-size: 16px; font-family: inherit;
  color: var(--ink); background: #fff; outline: none;
}
.type-box input:focus { border-color: var(--brand); }
.type-box button {
  border: none; border-radius: 14px;
  background: linear-gradient(160deg, #FFD08A, var(--brand-deep));
  color: #fff; font-size: 16px; font-weight: 800; font-family: inherit;
  padding: 0 22px; cursor: pointer;
}
.type-box button:active { transform: scale(.96); }

/* 快捷条 */
.quick-row { text-align: center; padding: 0 16px 16px; }
.quick-btn {
  border: 2px solid #EFE3CE; background: #fff; color: var(--ink);
  font-size: 16px; font-weight: 700; font-family: inherit;
  padding: 12px 22px; border-radius: 999px; cursor: pointer;
  box-shadow: var(--shadow);
}
.quick-btn:active { transform: scale(.96); }

/* 分类横条 */
.cat-bar {
  display: flex; gap: 10px; overflow-x: auto;
  padding: 0 16px 16px;
  scrollbar-width: none;
}
.cat-bar::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  border: 2px solid #EFE3CE; background: #fff; color: var(--ink);
  font-size: 15px; font-weight: 700; font-family: inherit;
  padding: 10px 16px; border-radius: 999px; cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.cat.on {
  border-color: var(--brand); background: #FFF3DF; color: var(--brand-deep);
}
.cat:active { transform: scale(.95); }
.cat-emoji { font-size: 18px; }
.cat-name { white-space: nowrap; }
.cat-count {
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
  background: #F5EEE2; border-radius: 999px; padding: 1px 7px;
}
.cat.on .cat-count { background: #FFE6BE; color: var(--brand-deep); }

/* 最近听过 */
.recent-sec { padding: 0 16px 16px; }
.sec-title { font-size: 14px; font-weight: 700; color: var(--ink-soft); margin-bottom: 10px; }
.recent-row {
  display: flex; gap: 10px; overflow-x: auto;
  scrollbar-width: none; padding-bottom: 2px;
}
.recent-row::-webkit-scrollbar { display: none; }
.recent-card {
  flex: 0 0 116px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: none; background: var(--card); box-shadow: var(--shadow);
  border-radius: 16px; padding: 12px 10px; cursor: pointer;
  font-family: inherit; color: var(--ink);
}
.recent-card:active { transform: scale(.95); }
.recent-emoji { font-size: 30px; line-height: 1; }
.recent-title {
  font-size: 13px; font-weight: 700; line-height: 1.3;
  text-align: center;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
}

/* 故事网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; padding: 0 16px;
}

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px 14px; text-align: center;
  box-shadow: var(--shadow); cursor: pointer;
  transition: transform .12s ease;
  border: 2px solid transparent;
}
.card:active { transform: scale(.96); }
.card.playing { border-color: var(--brand); }

.card-emoji { font-size: 44px; line-height: 1; }
.card-title {
  margin-top: 10px; font-size: 16px; font-weight: 700;
  line-height: 1.35; word-break: break-all;
}
.card-dur { margin-top: 6px; font-size: 12px; color: var(--ink-soft); }

/* 播放器 */
.player {
  position: fixed; left: 12px; right: 12px; bottom: 12px;
  background: #fff; border-radius: 18px;
  box-shadow: 0 8px 30px rgba(120, 90, 40, .20);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; z-index: 50;
}
.player.hidden { display: none; }

.player-cover { font-size: 34px; }
.player-info { flex: 1; min-width: 0; }
.player-title {
  font-size: 15px; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.player-bar {
  margin-top: 7px; height: 5px; border-radius: 3px; background: #F0E6D6; overflow: hidden;
}
.player-bar-fill { height: 100%; width: 0; background: var(--brand-deep); transition: width .3s linear; }
.sleep-left { margin-top: 5px; font-size: 11px; color: var(--ink-soft); }

.player-btn {
  border: none; background: transparent; font-size: 26px; cursor: pointer;
  padding: 4px; line-height: 1;
}
.player-btn.play { font-size: 32px; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%) translateY(20px);
  background: rgba(58, 50, 38, .92); color: #fff;
  padding: 12px 22px; border-radius: 999px; font-size: 16px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 99;
  max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 继续收听 / 连载卡片副标题 */
.recent-sub {
  font-size: 11px; color: var(--ink-soft);
  text-align: center; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-all;
}

/* 播放器连载条（第几集 / 上下集切换） */
.player-series {
  margin-top: 6px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 12px; color: var(--ink-soft);
}
#pSeries {
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-btn-ep {
  border: 1.5px solid #EFE3CE; background: #fff; color: var(--ink);
  font-size: 12px; font-weight: 700; font-family: inherit;
  padding: 5px 9px; border-radius: 999px; cursor: pointer;
  white-space: nowrap;
}
.player-btn-ep:active { transform: scale(.95); }
.player-btn-ep:disabled {
  color: #C5BBA8; border-color: #F0E6D6; background: #FBF7F0; cursor: default;
}

/* 空态 */
.empty {
  text-align: center; color: var(--ink-soft);
  padding: 40px 20px; font-size: 15px; grid-column: 1 / -1;
}

/* ================================================================== */
/* 底部导航 / 许愿页 / 激活门（09-18 新增）                              */
/* ================================================================== */

/* ★页签切换靠 body 上的 data-view，不搬 DOM★
   加一个页签 = nav.json 加一条 + 这里加一组选择器，不用动 JS 结构。 */
body { padding-bottom: 76px; }   /* 别让底部导航压住最后一张卡片 */

.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; background: #FFFDF9;
  border-top: 1px solid var(--line, #F0E6D6);
  padding-bottom: env(safe-area-inset-bottom, 0px);   /* 全面屏底部那条横杠 */
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 10px; border: 0; background: transparent; cursor: pointer;
  color: var(--ink-soft); font-size: 11px;
}
.tab-item .tab-emoji { font-size: 21px; line-height: 1.1; filter: grayscale(.5); opacity: .7; }
.tab-item.on { color: var(--brand-deep); font-weight: 700; }
.tab-item.on .tab-emoji { filter: none; opacity: 1; transform: translateY(-1px); }

/* 播放器要抬到导航栏上面，否则会被盖住 */
.player { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
.toast { bottom: 150px; }

/* ---- 页签与区块的对应关系（全部在这一处可见） ---- */
body[data-view="library"] .ask-area,
body[data-view="library"] .quick-row,
body[data-view="library"] #recentSec,
body[data-view="library"] #continueSec { display: none; }

body[data-view="wishes"] .ask-area,
body[data-view="wishes"] .quick-row,
body[data-view="wishes"] #catBar,
body[data-view="wishes"] #recentSec,
body[data-view="wishes"] #continueSec,
body[data-view="wishes"] #grid { display: none; }

#wishView { display: none; }
body[data-view="wishes"] #wishView { display: block; }

/* ---- 许愿页 ---- */
.wish-view { padding: 4px 12px 10px; }
.wish-ask { display: flex; gap: 8px; margin: 10px 0 14px; }
.wish-ask input {
  flex: 1; min-width: 0; padding: 12px 14px; font-size: 16px;
  border: 1px solid var(--line, #F0E6D6); border-radius: 12px; background: #FFFDF9;
}
.wish-ask input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.wish-ask button {
  padding: 12px 18px; font-size: 15px; font-weight: 700; border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; cursor: pointer;
}
.wish-list { display: flex; flex-direction: column; gap: 8px; }
.wish-item {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-radius: 12px; background: #FFFDF9;
  border: 1px solid var(--line, #F0E6D6);
}
.wish-text { flex: 1; min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.wish-count { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.wish-state {
  font-size: 11px; padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  background: #FDF3E0; color: var(--brand-deep);
}
.wish-state.done { background: #E4F4EC; color: #2E7D57; }

/* ---- 激活门 ---- */
.gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: #FFF7EA; padding: 20px;
}
.gate-card {
  width: 100%; max-width: 330px; background: #fff; text-align: center;
  border: 1px solid var(--line, #F0E6D6); border-radius: 18px;
  padding: 26px 22px 22px; box-shadow: 0 10px 30px rgba(0,0,0,.06);
}
.gate-emoji { font-size: 46px; line-height: 1; }
.gate-card h2 { margin: 12px 0 8px; font-size: 17px; line-height: 1.4; }
.gate-hint { margin: 0 0 16px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.6; min-height: 40px; }
.gate-input {
  width: 100%; box-sizing: border-box; text-align: center;
  font-size: 26px; letter-spacing: 8px; font-weight: 700;
  padding: 12px 8px; border: 2px solid var(--brand); border-radius: 12px;
  background: #FFFDF9; color: var(--brand-deep);
}
.gate-input:focus { outline: none; box-shadow: 0 0 0 4px rgba(255,184,77,.25); }
.gate-go {
  width: 100%; margin-top: 14px; padding: 14px; font-size: 17px; font-weight: 800;
  border: 0; border-radius: 12px; background: var(--brand); color: #fff; cursor: pointer;
}
.gate-go:disabled { opacity: .6; }

/* ---- 家长确认框（复用激活门的壳，只多两个按钮） ---- */
.ask-row { display: flex; gap: 10px; margin-top: 4px; }
.ask-btn {
  flex: 1; padding: 13px; font-size: 15px; font-weight: 800;
  border: 1px solid var(--line, #F0E6D6); border-radius: 12px;
  background: #FFFDF9; color: var(--ink, #4A3F35); cursor: pointer;
}
.ask-btn.danger { background: #E8705E; border-color: #E8705E; color: #fff; }

/* 长按左上角 🎧 时的"按到了"反馈 —— 没有它家长会以为长按没反应 */
.logo { transition: transform .15s, filter .15s; }
.logo-press { transform: scale(1.25); filter: drop-shadow(0 0 8px rgba(255,184,77,.9)); }

/* ==================================================================
   断点：窄屏 / 横屏
   ------------------------------------------------------------------
   2026-09-26 补的 —— 之前整个文件一条 @media 都没有，全靠 flex-wrap 和横滑硬扛。
   孩子端绝大多数是手机，两种场景真的会崩：
     ① 小屏（320-375px，iPhone SE 一类）：150px 的最小卡片宽 → 一行只剩一个半，
        标题和定时按钮开始互相挤；
     ② 横屏：116px 的大麦克风 + 提示文字把首屏吃掉，故事列表整个被顶到屏幕外，
        孩子划半天看不到故事。
   ⚠️ 选择器跟上面保持一致（`.mic-area, .ask-area` 两个名字都要写 ——
      这对别名就是当年"HTML 写 ask-area、CSS 写 mic-area"翻车留下的，别只写一个）。
   ================================================================== */
@media (max-width: 380px) {
  .topbar { padding: 12px 14px 6px; gap: 8px; }
  .title { font-size: 19px; }
  .logo { font-size: 26px; }
  .timer-btn { font-size: 12.5px; padding: 7px 11px; }
  .mic-area, .ask-area { padding: 6px 14px 14px; }
  .mic-btn { width: 88px; height: 88px; font-size: 36px; }
  .mic-hint { margin-top: 10px; font-size: 13.5px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 10px; padding: 0 12px; }
  .card { padding: 14px 10px; }
  .cat-bar { padding: 0 12px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .mic-area, .ask-area { padding: 2px 20px 8px; }
  .mic-btn { width: 64px; height: 64px; font-size: 28px; }
  .mic-hint { margin-top: 4px; font-size: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
  .player { bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
}

/* 工具类：放最后，用 !important，否则会被前面的 display 覆盖 */
.hidden { display: none !important; }
