/* 牛津树电子点读本 —— 儿童绘本风样式 v2 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
[hidden] { display: none !important; }
/* 顶部悬浮提示 toast：录完/奖励等即时反馈，不占用底部状态栏，避开水印与按钮 */
.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translate(-50%, -12px);
  background: rgba(52, 42, 90, .94);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  padding: 10px 22px;
  border-radius: 26px;
  box-shadow: 0 8px 24px rgba(60, 40, 120, .28);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  max-width: 88vw;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
body {
  font-family: "Baloo 2", "Comic Sans MS", "Chalkboard SE", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(160deg, #fff7e0 0%, #eaf6ff 55%, #fdeff5 100%);
  color: #4a4a4a;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}
/* 背景装饰：漂浮的小圆点，像绘本纸上的彩色纸屑 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255,170,120,.35) 3px, transparent 4px),
    radial-gradient(circle, rgba(120,200,255,.4) 3px, transparent 4px),
    radial-gradient(circle, rgba(255,210,120,.35) 3px, transparent 4px),
    radial-gradient(circle, rgba(180,230,160,.4) 3px, transparent 4px),
    radial-gradient(circle, rgba(255,160,200,.35) 3px, transparent 4px);
  background-size: 180px 180px, 220px 220px, 260px 260px, 300px 300px, 340px 340px;
  background-position: 10px 20px, 60px 120px, 130px 40px, 40px 200px, 200px 160px;
  animation: floatDots 24s ease-in-out infinite alternate;
}
@keyframes floatDots {
  0% { transform: translateY(0); }
  100% { transform: translateY(-14px); }
}
main { position: relative; z-index: 1; max-width: 900px; margin: 0 auto; padding: 12px 16px 0; flex: 1 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; }

/* ---------- 顶部彩虹导航（一行极简：🏠 标题 ⭐） ---------- */
header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px 12px;
  background: linear-gradient(90deg, #6fc76f, #4fb0a8);
  color: #fff;
  box-shadow: 0 6px 18px rgba(79, 176, 168, .30);
  border-radius: 0 0 26px 26px;
  flex: 0 0 auto;
}
.navicon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.30);
  color: #fff;
  font-size: 21px;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
  transition: transform .15s ease, background .15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.navicon:hover { background: rgba(255,255,255,.5); transform: translateY(-2px); }
.navicon:active { transform: translateY(0) scale(.94); }
.navbtn {
  font-size: 14px;
  padding: 8px 16px;
  border: none;
  border-radius: 22px;
  background: rgba(255,255,255,.28);
  color: #fff;
  cursor: pointer;
  min-height: 46px;
  font-weight: 700;
  backdrop-filter: blur(2px);
  transition: transform .15s ease, background .15s ease;
}
.navbtn:hover { background: rgba(255,255,255,.45); transform: translateY(-2px); }
.navbtn:disabled { opacity: .4; cursor: default; transform: none; }
.quiznav {
  background: #fff;
  color: #5f6b7a;
  box-shadow: 0 3px 8px rgba(0,0,0,.15);
  font-size: 15px;
  height: 44px;                /* 统一按钮高度 */
  padding: 0 18px;
  border-radius: 999px;        /* 统一胶囊形 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.quiznav:hover { background: #f1f3f6; transform: translateY(-2px); }
.quiznav:disabled { background: rgba(255,255,255,.3); color: rgba(255,255,255,.7); box-shadow: none; }
.title {
  flex: 1;
  min-width: 0;
  font-size: 19px;
  font-weight: 800;
  text-align: center;
  letter-spacing: .5px;
  text-shadow: 0 2px 6px rgba(0,0,0,.18);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 阅读页顶部条：页码徽章 + 星星数 ---------- */
.pagebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.stars {
  position: relative;
  font-size: 15px;
  color: #e6a13a;
  letter-spacing: 1px;
  font-weight: 800;
  text-shadow: 0 1px 0 #fff;
  white-space: nowrap;
}
/* 顶部星星旁短暂弹出的 "+1" */
.starplus {
  position: absolute;
  top: -14px;
  right: 0;
  font-size: 14px;
  font-weight: 800;
  color: #ff8a00;
  pointer-events: none;
  animation: starPlusPop 1s ease-out forwards;
}
@keyframes starPlusPop {
  0% { opacity: 0; transform: translateY(6px) scale(.8); }
  25% { opacity: 1; transform: translateY(0) scale(1.15); }
  70% { opacity: 1; transform: translateY(-5px) scale(1); }
  100% { opacity: 0; transform: translateY(-13px) scale(1); }
}

/* ---------- 书架 ---------- */
#bookShelf { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding-bottom: 70px; }
.hello {
  margin: 18px 6px 2px;
  font-size: 22px;
  font-weight: 800;
  color: #4a6a5a;
  line-height: 1.3;
}
.hello small {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #8aa08f;
  margin-top: 5px;
  letter-spacing: .5px;
}
#shelfList {
  display: grid;
  grid-template-columns: repeat(2, 1fr);   /* 一行 2 本，卡片更宽，书名显示更多 */
  gap: 14px;
  margin-top: 14px;
}
.bookcard {
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(120, 100, 60, .13), 0 1px 4px rgba(120, 100, 60, .07);
  cursor: pointer;
  position: relative;
  transition: transform .15s ease, box-shadow .15s ease;
}
.bookcard:hover, .bookcard:active {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px rgba(120, 100, 60, .22);
}
.bookcard .cover {
  width: 100%;
  aspect-ratio: 3 / 4;   /* 竖版封面，像一本书 */
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #e8f2ff, #fff3e6);
  display: block;
  border: none;
}
.bookcard .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 无真封面时用第1页图兜底：微放大+中心裁切，观感接近封面 */
.bookcard .cover img.cover-p0 { object-position: center; transform: scale(1.12); }
.bookcard .cover .coverfallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 44px; background: linear-gradient(160deg,#fff7e0,#eaf6ff);
}
.bookcard .cover .page-tag {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(255,255,255,.92);
  color: #7a6a4a;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 1px 5px rgba(0,0,0,.08);
}
.bookcard .cover .stars-tag {
  position: absolute;
  top: 8px; right: 8px;   /* 与左上角页数徽章齐平 */
  background: rgba(255,255,255,.92);
  color: #e6a13a;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  box-shadow: 0 1px 5px rgba(0,0,0,.08);
}
.bookcard .cover .no {
  position: absolute;
  left: 8px; bottom: 8px;   /* 封面左下角：书的编号 */
  background: linear-gradient(135deg, #ffd86b, #ffb347);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: .5px;
  box-shadow: 0 2px 6px rgba(255, 170, 60, .35);
}
.bookcard .meta {
  display: flex;
  align-items: center;
  padding: 9px 12px 3px;
}
.bookcard .name {
  font-size: 14px;
  font-weight: 700;
  color: #4a5568;
  line-height: 1.35;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}
.bookcard .pr {
  padding: 4px 12px 12px;
}
.bookcard .pr .bar {
  height: 5px;
  border-radius: 99px;
  background: #f0ede4;
  overflow: hidden;
}
.bookcard .pr .bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffd86b, #ffb347);
  transition: width .5s ease;
}


/* ---------- 阅读页：一屏完整显示，按钮固定底部 ---------- */
#player {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 10px;
}
/* 顶部条：页码徽章 + 进度圆点 + 星星 */
.pagebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex: 0 0 auto;
}
.dots {
  flex: 1;
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 4px;
}
.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d8d2c2;
  flex: 0 0 auto;
  transition: all .25s ease;
}
.dots i.on { background: #ff9d4d; width: 18px; border-radius: 99px; }
.pagebar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.stars {
  font-size: 15px;
  color: #e6a13a;
  letter-spacing: 1px;
  font-weight: 800;
  text-shadow: 0 1px 0 #fff;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* 绘本图区：固定高度容器，图片在容器内完整显示不裁切。
   容器高度不随图片比例或下方句子多少而变化——翻页时图区不跳。 */
#pageArea {
  flex: 0 0 auto;
  height: 56vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, #ffffff, #fff7ef);
  border-radius: 26px;
  padding: 10px;
  text-align: center;
  box-shadow: 0 14px 34px rgba(255, 130, 170, .16);
  overflow: hidden;
  position: relative;
}
#pageImg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.10);
  object-fit: contain;
  display: block;
  transition: opacity .22s ease;
}
/* 翻页动画：下一页新页从右滑入，上一页新页从左滑入，方向感明确 */
#pageArea.sliding #pageImg { animation-duration: .3s; animation-timing-function: cubic-bezier(.25,.8,.35,1); }
#pageArea.slide-next #pageImg { animation-name: pageInFromRight; }
#pageArea.slide-prev #pageImg { animation-name: pageInFromLeft; }
@keyframes pageInFromRight {
  0% { transform: translateX(46px); opacity: .12; }
  100% { transform: translateX(0); opacity: 1; }
}
@keyframes pageInFromLeft {
  0% { transform: translateX(-46px); opacity: .12; }
  100% { transform: translateX(0); opacity: 1; }
}
#pageInfo {
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  color: #b07b5a;
  flex: 0 0 auto;
}
.pageBadge {
  display: inline-block;
  background: #fff0d4;
  border: 2px solid #ffc26b;
  border-radius: 18px;
  padding: 3px 12px;
  color: #c87f1a;
}

#linePanel {
  flex: 0 1 auto;
  max-height: 34vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 10px;
  padding: 0 2px 2px;
}
#linePanel::-webkit-scrollbar { width: 5px; }
#linePanel::-webkit-scrollbar-thumb { background: #e3dcc9; border-radius: 99px; }
.linePanel-fade { animation: fadeIn .3s ease; }
.linerow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 20px;
  background: #fff;
  margin-bottom: 8px;
  box-shadow: 0 3px 10px rgba(130, 160, 220, .12);
  border: 2px solid transparent;
}
.linerow.playing {
  background: linear-gradient(120deg, #fff6dc, #fff0c2);
  border-color: #ffb733;
  box-shadow: 0 6px 18px rgba(255, 183, 51, .30);
}
.linerow .idx {
  width: 30px; height: 30px;
  line-height: 30px;
  text-align: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #7ec8ff, #5b9df5);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 3px 6px rgba(91, 157, 245, .35);
}
.linerow .text { flex: 1; font-size: 18px; color: #555; min-width: 0; }
.linerow .en { color: #333; font-weight: 700; font-size: 20px; }
.linerow .zh { color: #b0a08c; font-size: 14px; margin-top: 2px; }
.linerow .btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  flex-shrink: 0;
  width: 290px;
}
.minibtn {
  border: none;
  border-radius: 18px;
  padding: 10px 6px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  min-height: 48px;
  width: 100%;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.12);
  transition: filter .15s ease, opacity .15s ease;
}
.minibtn:hover { filter: brightness(1.06); }
.minibtn:active { filter: brightness(.96); }
.minibtn.listen { background: linear-gradient(135deg, #64b5f6, #42a5f5); }
.minibtn.rec { background: linear-gradient(135deg, #ffb74d, #ff9800); }
.minibtn.rec.on { background: linear-gradient(135deg, #ffab5e, #ff8a3d); animation: recPulse .9s infinite; }
.minibtn.voice { background: linear-gradient(135deg, #81c784, #66bb6a); }
.minibtn.voice.off, .minibtn:disabled { opacity: .42; pointer-events: none; filter: none; }
@keyframes recPulse {
  0%, 100% { box-shadow: 0 4px 10px rgba(255,138,61,.4); }
  50% { box-shadow: 0 6px 18px rgba(255,138,61,.6); }
}

/* ---------- 两侧翻页箭头（贴在绘本左右、垂直居中） ---------- */
.sidenav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 8;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .82);
  color: #c9872a;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s ease, background .15s ease;
}
.sidenav svg { display: block; }
#btnPrevSide { left: 10px; }
#btnNextSide { right: 10px; }
.sidenav:active { transform: translateY(-50%) scale(.9); background: #fff; }
.sidenav:disabled { opacity: .35; cursor: default; }
.status {
  text-align: center;
  margin-top: 12px;
  min-height: 26px;
  color: #8a6d3b;
  font-size: 15px;
  font-weight: 700;
}
.status.pop { animation: statusPop .6s ease; }
@keyframes statusPop {
  0% { transform: scale(.7); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.tip { text-align: center; color: #a89a80; margin-top: 30px; font-size: 16px; font-weight: 600; }
.filetip {
  background: #fff4e5;
  border: 2px solid #ffd89b;
  color: #8a5b00;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 14px;
  line-height: 1.7;
}

/* ---------- 情景问答陪练（聊天对话框式） ---------- */
.quizhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 10px; flex-shrink: 0; padding: 0 12px; }
.quizprog {
  color: #8a97b8;
  font-size: 15px;
  font-weight: 800;
  background: #fff;
  border-radius: 16px;
  padding: 8px 14px;
  box-shadow: 0 3px 10px rgba(130,160,220,.15);
}
/* 聊天消息滚动区 */
.quizchat {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 12px 18px;
}
.msg { display: flex; align-items: flex-start; gap: 9px; max-width: 90%; }
.msg.me {
  align-self: stretch;         /* 占满行宽 */
  flex-direction: row;         /* 正向：气泡左、头像右 */
  justify-content: flex-end;   /* 整组靠右，头像贴对话框右缘 */
  max-width: 100%;
}
.msg.me .msg-body { align-items: flex-end; }
.msg.me .msg-bubble { min-width: 0; }
/* 消息进入动画 */
.msg-in { animation: msgIn .3s cubic-bezier(.2,.8,.3,1); }
@keyframes msgIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: none; }
}
/* 头像：Buddy 绿色小龙 SVG */
.msg-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e8fbd8, #d2f5bc);
  border: 2px solid #b8e69a;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(90,160,62,.28);
  overflow: hidden;
}
.msg.me .msg-avatar {
  background: linear-gradient(135deg, #efe9ff, #e0d4ff);
  border-color: #cdbcff;
  font-size: 22px;
  box-shadow: 0 3px 10px rgba(126,87,194,.25);
}
.msg-svg { width: 100%; height: 100%; display: block; }
/* 小龙眨眼 */
.msg-avatar .buddy-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: buddyBlink 4.5s infinite;
}
@keyframes buddyBlink {
  0%, 92%, 96%, 100% { transform: scaleY(1); }
  94% { transform: scaleY(.08); }
}
.msg-body { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; }
.msg.me .msg-body { align-items: flex-end; }
/* 小标签（如 "Say it with me"） */
.msg-tag {
  font-size: 12px;
  font-weight: 800;
  color: #2a9d8f;
  background: #e3f7f4;
  border-radius: 10px;
  padding: 3px 10px;
  letter-spacing: .3px;
}
.msg-bubble {
  padding: 12px 16px;
  border-radius: 20px;
  border-top-left-radius: 6px;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.5;
  background: #eef7e8;
  color: #2e4d22;
  border: 2px solid #cde8b8;
  word-break: break-word;
  min-height: 22px;
  box-shadow: 0 3px 8px rgba(90,160,62,.10);
}
/* 题目气泡：更醒目 */
.msg-bubble.msg-q {
  background: linear-gradient(135deg, #f6f1ff, #efe7ff);
  border-color: #c9b4ff;
  color: #4a2fa0;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(126,87,194,.16);
}
/* 正确答案气泡：薄荷绿 */
.msg-bubble.msg-ref {
  background: #e6faf4;
  border-color: #9fe6d6;
  color: #176b5d;
  box-shadow: 0 3px 10px rgba(42,157,143,.14);
}
.msg.me .msg-bubble {
  background: linear-gradient(135deg, #efe9ff, #e6dcff);
  color: #4a3096;
  border-color: #d6c6ff;
  border-top-left-radius: 20px;
  border-top-right-radius: 6px;
  box-shadow: 0 3px 8px rgba(126,87,194,.12);
}
/* "正在输入"三个点 */
.msg-bubble.dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 42px;
}
.msg-bubble.dots::before {
  content: "· · ·";
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1;
  color: #7aa06a;
  animation: dotsBlink 1.1s infinite;
}
@keyframes dotsBlink {
  0%, 100% { opacity: .25; }
  50% { opacity: 1; }
}
/* 气泡下操作行 */
.msg-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
/* 次级按钮（再听 / 跳过 / 返回书）：统一白底灰字胶囊 */
.msg-listen,
.msg-skip {
  height: 44px;                /* 与主按钮同高 */
  padding: 0 18px;
  border-radius: 999px;        /* 统一胶囊形 */
  border: 2px solid #e2e6f0;
  background: #fff;
  color: #6b7490;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.msg-listen:hover,
.msg-skip:hover { filter: brightness(.97); }
/* 主按钮：Next（Buddy 绿色系，统一胶囊） */
.msg-next {
  height: 44px;
  padding: 0 28px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #6fdc8f, #3fae6a);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(63,174,106,.35);
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.msg-next:hover { filter: brightness(1.05); }
/* 底部固定输入栏：点输入框 → 输入法语音说话 → 文字上屏 → 点 ✓ 提交 */
.quizinputbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 12px;   /* 固定值，避免国产 WebView safe-area 异常导致输入栏被顶高 */
  background: rgba(255,253,248,.97);
  border-top: 2px solid #eee7ff;
  box-shadow: 0 -6px 18px rgba(126, 87, 194, .07);
  flex-shrink: 0;
}
.quizanswer {
  flex: 1 1 auto;
  min-width: 0;
  padding: 13px 16px;
  font-size: 17px;
  font-weight: 700;
  color: #3a2f6b;
  background: #fff;
  border: 2.5px solid #c9b8ff;
  border-radius: 24px;
  outline: none;
  font-family: inherit;
  box-shadow: 0 3px 10px rgba(150,120,220,.10);
}
.quizanswer:focus { border-color: #8b6fe8; }
.quizanswer::placeholder { color: #a99cd6; font-weight: 600; }
.quizanswer.shake { animation: quizShake .4s ease; border-color: #ff8a3d; }
@keyframes quizShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.quizbtn.submit {
  flex-shrink: 0;
  height: 48px;
  min-height: 48px;            /* 压过媒体查询里的 min-height，全局统一 */
  min-width: 72px;
  padding: 0 22px;
  border-radius: 999px;        /* 统一胶囊形 */
  border: none;
  background: linear-gradient(135deg, #6fdc8f, #3fae6a);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(63,174,106,.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.quizbtn.submit:active { transform: scale(.93); }
.quizanswer.busy, .quizbtn.submit.busy {
  opacity: .45;
  pointer-events: none;
}
.quizanswer.busy::placeholder { color: #b7b3d0; }
@media (max-width: 480px) {
  .quizanswer { font-size: 16px; padding: 12px 14px; }
  .msg-bubble { font-size: 17px; padding: 10px 14px; }
  .msg-bubble.msg-q { font-size: 18px; }
  /* 陪练时让底部输入栏通栏铺满屏幕两侧（配合 body.quiz-on 去掉外层 main 的左右留白） */
  body.quiz-on main { padding-left: 0; padding-right: 0; }
  .quizinputbar {
    padding-left: 12px;
    padding-right: 12px;
  }
}
/* 判分反馈色（错题用柔和的薄荷绿，低打击感，儿童友好） */
.quizfb.good { color: #2e7d32; }
.quizfb.ok { color: #5b8def; }
.quizfb.warn { color: #26a69a; }

/* ---------- 陪练按钮：与"整页读"同排的药丸（在 .pagebtns 内），非悬浮 ---------- */
.fab {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #6fdc8f, #3fae6a);
  color: #fff;
  box-shadow: 0 4px 10px rgba(63,174,106,.35);
  transition: background .15s ease, filter .15s ease;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.fab:hover { filter: brightness(1.06); }
.fab:active { filter: brightness(.94); }
.fab.look { background: linear-gradient(135deg, #6fdc8f, #3fae6a); box-shadow: 0 4px 10px rgba(63,174,106,.35); }
.fab[hidden] { display: none; }

/* ---------- 底部固定按钮组：整页读 + 陪练 并排，左下角固定、留边距，不贴边不随滚动 ---------- */
.pagebtns {
  position: fixed;
  left: 16px;
  bottom: 8px;   /* 固定值：部分国产 WebView 的 env(safe-area-inset-bottom) 会返回异常大值，导致按钮被顶高 */
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  -webkit-tap-highlight-color: transparent;
}
.pageplay {
  height: 36px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .3px;
  background: linear-gradient(135deg, #56c276, #3aa878);
  box-shadow: 0 4px 10px rgba(58, 168, 120, .30);
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  -webkit-tap-highlight-color: transparent;
  transition: filter .15s ease;
}
.pageplay:active { filter: brightness(.94); }
.pageplay.is-playing { background: linear-gradient(135deg, #ffa94d, #f5881f); box-shadow: 0 4px 10px rgba(245, 136, 31, .30); }
.pageplay:disabled { opacity: .4; cursor: default; box-shadow: none; }
/* 播放 / 暂停 图标与文字切换 */
.pageplay .ic-pause, .pageplay .tx-pause { display: none; }
.pageplay.is-playing .ic-play, .pageplay.is-playing .tx-play { display: none; }
.pageplay.is-playing .ic-pause, .pageplay.is-playing .tx-pause { display: inline-flex; }

/* ---------- 星星庆祝动效 ---------- */
.starBurst {
  position: fixed;
  z-index: 99;
  pointer-events: none;
  font-size: 30px;
  animation: starFly 1.2s ease-out forwards;
}
@keyframes starFly {
  0% { transform: translateY(0) scale(.4) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-90px) scale(1.6) rotate(40deg); opacity: 0; }
}

/* ---------- 页面切换淡入 ---------- */
.fadein { animation: fadeIn .35s ease; }
@keyframes fadeIn { 0% { opacity: 0; } 100% { opacity: 1; } }

/* ---------- 成就页 ---------- */
#achvView, #quizView {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1 1 auto;
  min-height: 0;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 8px 16px 30px;
}
/* 陪练视图改为纵向布局：聊天区滚动 + 底部输入栏固定 */
#quizView {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 0 0;   /* 横向 padding 下放到 head/chat/输入栏，底部由 .quizhint 兜底留白 */
  max-width: 640px;
}
.quizhint {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 13px;
  line-height: 1.3;
  color: #9aa5c4;
  height: 44px;               /* 固定紧凑高度：文字居中，与右下角水印同处一区、水平错开 */
  padding: 0 104px;           /* 左右对称留白（右侧避让水印），文字严格居中不贴边 */
  flex: 0 0 auto;
}
.achvhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.achvtitle { font-size: 24px; font-weight: 800; color: #7e57c2; text-shadow: 0 2px 0 #fff; }
.achvcard {
  background: linear-gradient(160deg, #ffffff, #fffbe8);
  border-radius: 28px;
  padding: 26px 20px 24px;
  box-shadow: 0 14px 36px rgba(255, 180, 80, .18);
  border: 3px solid #fff;
  text-align: center;
}
.achvsum { padding: 6px 0 16px; }
.achvnum { font-size: 52px; font-weight: 900; color: #ffb300; line-height: 1.1; text-shadow: 0 3px 0 #fff2c4; }
.achvstats { display: flex; justify-content: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.achvstats .stat {
  background: #fff;
  border-radius: 16px;
  padding: 8px 16px;
  box-shadow: 0 4px 12px rgba(130,160,220,.14);
  font-size: 13px;
  color: #9aa7c8;
  font-weight: 700;
}
.achvstats .stat b { display: block; font-size: 20px; color: #4a6fd8; }
.achvcard h3 { font-size: 16px; color: #1f4fa0; margin: 18px 0 10px; text-align: left; }
.progrow { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.progname { width: 40%; text-align: left; font-size: 14px; font-weight: 700; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progbar {
  flex: 1;
  height: 16px;
  border-radius: 10px;
  background: #fff;
  border: 2px solid #e6dcff;
  overflow: hidden;
}
.progfill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #ffd54f, #ffb300);
  transition: width .5s ease;
  min-width: 6px;
}
.progmeta { font-size: 13px; color: #9aa7c8; font-weight: 700; white-space: nowrap; }
#achvBadges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.badge {
  background: #f4f6fd;
  border: 2px dashed #d4ddf2;
  border-radius: 18px;
  padding: 14px 10px;
  text-align: center;
  filter: grayscale(.9);
  opacity: .65;
}
.badge.got {
  background: linear-gradient(160deg, #fff8e1, #fff3cd);
  border: 2.5px solid #ffd54f;
  filter: none;
  opacity: 1;
  box-shadow: 0 6px 16px rgba(255, 190, 60, .30);
}
.badgeico { font-size: 34px; }
.badgename { font-size: 15px; font-weight: 800; color: #4a6fd8; margin-top: 6px; }
.badgedesc { font-size: 12px; color: #9aa7c8; margin-top: 3px; font-weight: 600; }

/* ---------- 跟读奖励：星星飞入 + 撒花 ---------- */
.starFlyIn {
  position: fixed;
  z-index: 99;
  pointer-events: none;
  font-size: 40px;
  animation: starFlyInAnim .85s ease-out forwards;
}
@keyframes starFlyInAnim {
  0% { transform: translateY(0) scale(.6) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-46vh) scale(1.3) rotate(30deg); opacity: 0; }
}
.confetti {
  position: fixed;
  top: -30px;
  z-index: 98;
  pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(112vh) rotate(320deg); opacity: .15; }
}

/* ---------- 小屏适配（手机优先） ---------- */
@media (max-width: 480px) {
  main { padding: 10px 12px 0; }
  .bookcard .name { font-size: 13px; }
  #shelfList { gap: 10px; }
  .sidenav { width: 38px; height: 38px; }
  .sidenav svg { width: 20px; height: 20px; }
  #btnPrevSide { left: 6px; }
  #btnNextSide { right: 6px; }
  .linerow { flex-wrap: wrap; gap: 6px; }
  .linerow .btns { width: 100%; }
  .minibtn { text-align: center; padding: 10px 4px; font-size: 13px; }
  .quizq { font-size: 22px; min-height: 80px; }
  /* 手机上顶栏只留核心按钮：隐藏 logo 和管理入口，陪练/书单保持 */
  .logo { display: none; }
  .adminlink { display: none; }
  header { gap: 8px; padding: 10px 10px 11px; }
  .navbtn { padding: 8px 10px; font-size: 13px; }
  .quiznav { font-size: 14px; padding: 8px 12px; }
  .title { font-size: 16px; }
  .stars { font-size: 14px; }
  .navicon { width: 42px; height: 42px; font-size: 19px; }
  #linePanel { max-height: 30vh; }
  /* 手机端图区固定 50vh：句子再多/再长，只在句子区内滚动，图区不动 */
  #pageArea { height: 50vh; }
}

/* ---------- 平板适配（iPad 等 ≥768px） ---------- */
@media (min-width: 768px) {
  main { max-width: 1080px; padding: 16px 26px 0; }
  header { border-radius: 18px; padding: 12px 18px; }
  .title { font-size: 22px; }
  .navicon { width: 52px; height: 52px; font-size: 24px; border-radius: 16px; }
  .hello { font-size: 30px; margin-top: 26px; }
  .hello small { font-size: 17px; }
  #shelfList { grid-template-columns: repeat(3, 1fr); gap: 20px; }
  .bookcard { border-radius: 22px; }
  .bookcard .name { font-size: 16px; }
  .bookcard .cover .page-tag, .bookcard .cover .stars-tag, .bookcard .cover .no { font-size: 13px; padding: 4px 10px; }
  #pageArea { border-radius: 30px; padding: 16px; }
  #pageImg { border-radius: 18px; }
  #linePanel { max-height: 30vh; }
  .linerow { padding: 14px 16px; border-radius: 22px; }
  .linerow .idx { width: 36px; height: 36px; line-height: 36px; font-size: 16px; }
  .linerow .en { font-size: 22px; }
  .linerow .zh { font-size: 16px; }
  .minibtn { padding: 12px 18px; font-size: 16px; min-height: 52px; }
  .navbtn { padding: 12px 20px; font-size: 16px; }
  .sidenav { width: 54px; height: 54px; }
  .sidenav svg { width: 28px; height: 28px; }
  #btnPrevSide { left: 14px; }
  #btnNextSide { right: 14px; }
  .stars { font-size: 18px; }
  .pageBadge { font-size: 15px; padding: 4px 14px; }
  .quizq { font-size: 26px; }
  .quizbtn { min-height: 56px; font-size: 18px; }
}
/* 大平板 / iPad 横屏：一行 4 本 */
@media (min-width: 1100px) {
  #shelfList { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- 首页启动加载动画（预载语音引擎） ---------- */
#bootScreen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #fdf6e9, #e9f6ff);
  transition: opacity .45s ease;
}
#bootScreen.done { opacity: 0; pointer-events: none; }
.bootcard {
  text-align: center;
  padding: 36px 46px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(120, 100, 60, .18);
}
.bootspinner {
  width: 66px; height: 66px;
  margin: 0 auto 20px;
  border-radius: 50%;
  border: 6px solid #ffe9b8;
  border-top-color: #ffb347;
  animation: bootspin 1s linear infinite;
}
@keyframes bootspin { to { transform: rotate(360deg); } }
.boottitle { font-size: 20px; font-weight: 800; color: #4a6a5a; }
.bootsub { font-size: 13px; color: #9aa68f; margin-top: 8px; }
.bootbar {
  width: 190px; height: 8px;
  margin: 18px auto 0;
  border-radius: 99px;
  background: #f0ede4;
  overflow: hidden;
}
.bootbar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffd86b, #ffb347);
  animation: bootfill 1.4s ease-in-out infinite;
}
@keyframes bootfill {
  0% { width: 15%; }
  50% { width: 72%; }
  100% { width: 15%; }
}
