/* ============================================================
   语文电子书 · 翻页阅读器  —  主题：暖纸 + 书桌
   ============================================================ */
:root {
  --ink: #3a322a;
  --ink-soft: #6b6255;
  --paper: #fdfaf3;
  --paper-deep: #f3ead8;
  --desk: #e9e0ce;
  --desk-2: #d9cdb4;
  --accent: #b5492e;        /* 朱砂红 */
  --accent-soft: #d8836a;
  --line: #e6dcc6;
  --shadow: rgba(90, 70, 40, .28);
  --sidebar-w: 300px;
  --thumb-h: 104px;
  --toolbar-h: 60px;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 120% at 50% 0%, #f4eddd 0%, #e7dcc2 55%, #d8c9a8 100%);
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.toolbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--toolbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: rgba(253, 250, 243, .95);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}
.toolbar .brand {
  display: flex; align-items: center; gap: 12px; min-width: 0;
}
.toolbar .brand .logo {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--accent), #8f3521);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: "Songti SC", "SimSun", serif; font-weight: 700; font-size: 18px;
  box-shadow: 0 3px 8px rgba(181,73,46,.35);
}
.toolbar .brand .titles { display: flex; flex-direction: column; line-height: 1.15; }
.toolbar .brand .titles b { font-family: "Songti SC", "STSong", "SimSun", serif; font-size: 17px; letter-spacing: .5px; }
.toolbar .brand .titles span { font-size: 11.5px; color: var(--ink-soft); }

.toolbar .spacer { flex: 1; }

.page-indicator {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--ink-soft); white-space: nowrap;
}
.page-indicator b { color: var(--accent); font-size: 15px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; transition: all .15s ease;
}
.icon-btn:hover { background: var(--paper-deep); border-color: var(--accent-soft); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- 布局 ---------- */
.layout {
  position: fixed; inset: var(--toolbar-h) 0 var(--thumb-h) 0;
  display: flex;
}

/* 侧栏目录 */
.sidebar {
  width: var(--sidebar-w); flex: none;
  background: rgba(253, 250, 243, .97);
  border-right: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  transition: margin-left .28s ease;
  z-index: 30;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }

.sidebar .side-head {
  padding: 16px 18px 10px; font-size: 13px; color: var(--ink-soft);
  display: flex; align-items: center; gap: 6px; letter-spacing: .5px;
}
.sidebar .side-head b { color: var(--ink); font-size: 14px; }

.group { border-top: 1px solid var(--line); }
.group:first-child { border-top: none; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 18px; cursor: pointer; user-select: none;
  font-weight: 600; font-size: 14px; color: var(--ink);
  position: sticky; top: 0; background: rgba(253,250,243,.96); z-index: 2;
}
.group-head:hover { background: var(--paper-deep); }
.group-head .ic { font-size: 15px; }
.group-head .caret { margin-left: auto; font-size: 11px; color: var(--ink-soft); transition: transform .2s; }
.group-head.open .caret { transform: rotate(90deg); }

.group-items { overflow: hidden; max-height: 0; transition: max-height .25s ease; }
.group.open .group-items { max-height: 800px; }

.lesson {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px 8px 32px; cursor: pointer;
  font-size: 13.5px; color: var(--ink-soft);
  border-left: 3px solid transparent;
  transition: background .12s, color .12s;
}
.lesson:hover { background: var(--paper-deep); color: var(--ink); }
.lesson.active {
  background: linear-gradient(90deg, rgba(181,73,46,.10), transparent);
  color: var(--accent); border-left-color: var(--accent); font-weight: 600;
}
.lesson .pg { margin-left: auto; font-size: 11px; color: #b3a88f; }

/* 侧栏标签页 */
.side-tabs {
  display: flex; border-bottom: 1px solid var(--line);
  background: rgba(253, 250, 243, .95);
  position: sticky; top: 0; z-index: 3;
}
.side-tab {
  flex: 1; padding: 12px 8px; text-align: center;
  font-size: 13px; color: var(--ink-soft); cursor: pointer;
  border-bottom: 2px solid transparent; user-select: none;
  transition: all .15s;
}
.side-tab:hover { color: var(--ink); background: var(--paper-deep); }
.side-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.side-panel { max-height: calc(100vh - var(--toolbar-h) - var(--thumb-h) - 48px); overflow-y: auto; }
.side-panel.hidden { display: none; }

/* 课文朗读面板 */
.read-panel { padding: 12px 16px 80px; }
.read-line {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; margin-bottom: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; transition: all .15s;
}
.read-line:hover { border-color: var(--accent-soft); background: #fffaf3; transform: translateX(2px); }
.read-line.playing { border-color: var(--accent); background: linear-gradient(90deg, rgba(181,73,46,.08), transparent); }
.read-line .play-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.read-line.playing .play-icon { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.read-line .text { flex: 1; font-size: 14.5px; line-height: 1.85; color: var(--ink); }
.read-line .text .ch { display: inline-block; padding: 0 1px; border-radius: 3px; cursor: pointer; transition: background .12s; }
.read-line .text .ch:hover { background: rgba(181,73,46,.15); color: var(--accent); }
.read-line .text .ch.has-word { cursor: pointer; }
.read-empty { padding: 40px 20px; text-align: center; color: #b3a88f; font-size: 13px; }

/* ---------- 教学要点（侧栏「教学要点」标签页） ---------- */
.notes-panel { padding: 12px 16px 80px; }
.notes-title {
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 15px; color: var(--ink); letter-spacing: .5px;
  margin: 2px 0 10px; display: flex; align-items: baseline; gap: 8px;
}
.notes-title span { font-family: inherit; font-size: 11.5px; color: var(--ink-soft); }

.notes-card {
  background: #fff; border: 1px solid var(--line);
  border-left: 3px solid var(--c, var(--accent));
  border-radius: 12px; padding: 10px 13px; margin-bottom: 9px;
  box-shadow: 0 1px 4px rgba(120, 96, 60, .06);
  transition: transform .15s, box-shadow .15s;
}
.notes-card:hover { transform: translateX(2px); box-shadow: 0 3px 10px rgba(120, 96, 60, .12); }
.notes-card-head { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.notes-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c, var(--accent)); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--accent)) 18%, transparent);
}
.notes-card-head b {
  font-size: 13px; color: var(--c, var(--accent));
  font-family: "Songti SC", "STSong", "SimSun", serif; letter-spacing: 1px;
}
.notes-card-body {
  font-size: 13.5px; line-height: 1.9; color: var(--ink);
  white-space: normal; word-break: break-word;
}

.notes-empty { padding: 44px 18px; text-align: center; color: #b3a88f; font-size: 13px; }
.notes-empty-icon { font-size: 30px; margin-bottom: 8px; opacity: .8; }
.notes-empty p { margin: 0 0 14px; }
.notes-goto, .notes-edit {
  display: inline-block; padding: 6px 14px; border-radius: 999px;
  background: var(--accent); color: #fff; text-decoration: none;
  font-size: 12.5px; transition: opacity .15s, transform .15s;
}
.notes-goto:hover, .notes-edit:hover { opacity: .88; transform: translateY(-1px); }
.notes-edit {
  display: block; text-align: center; margin-top: 4px;
  background: transparent; color: var(--accent);
  border: 1px dashed var(--accent-soft);
}

/* 领读控制区 */
.read-control {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 2px 12px;
}
.read-btn {
  padding: 9px 20px; border: none; border-radius: 22px;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 600;
  cursor: pointer; box-shadow: 0 3px 10px rgba(181,73,46,.35);
  transition: all .15s; letter-spacing: 1px;
}
.read-btn:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(181,73,46,.45); }
.read-btn.active { background: #8f3521; }
.read-hint { font-size: 12px; color: #b3a88f; }
.read-lines { display: flex; flex-direction: column; gap: 8px; }

/* 本课生字区 */
.chars-section {
  margin-top: 18px; padding: 14px;
  background: linear-gradient(180deg, #fffaf3, #fdf6e8);
  border: 1px solid var(--line); border-radius: 12px;
}
.chars-title { font-size: 13px; color: var(--ink-soft); margin-bottom: 12px; font-weight: 600; }
.chars-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.char-cell {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; transition: all .12s;
}
.char-cell:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 3px 8px rgba(181,73,46,.2); }
.char-big {
  font-family: "Kaiti SC", "KaiTi", "STKaiti", "Songti SC", serif;
  font-size: 26px; color: var(--ink); line-height: 1.1;
}
.char-py { font-size: 10px; color: var(--accent); }

/* 课文动画按钮 */
.anim-btn {
  position: absolute; top: 12px; right: 12px; z-index: 15;
  padding: 8px 16px; border: none; border-radius: 20px;
  background: var(--accent); color: #fff; font-size: 14px;
  font-weight: 600; cursor: pointer; box-shadow: 0 4px 14px rgba(181,73,46,.45);
  transition: all .2s;
}
.anim-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(181,73,46,.55); }
.anim-btn.hidden { display: none; }
.anim-btn::before { content: ''; position: absolute; inset: -4px; border-radius: 24px; border: 2px solid var(--accent); opacity: 0; animation: pulse 1.8s ease-out infinite; }
@keyframes pulse { 0% { opacity: .6; transform: scale(.95); } 100% { opacity: 0; transform: scale(1.15); } }

/* 弹窗（通用） */
.modal { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; }
.modal.show { display: flex; animation: fadeIn .25s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
/* 【禁止使用 backdrop-filter】
   遮罩与弹窗内正在播放的 <video> 处于同一合成树，Chromium 必须每帧重新生成
   遮罩的「背景快照」，在本机 GPU 合成路径上会以硬边矩形闪出黑块
   （现象：弹窗左侧书页区域持续闪烁黑色方块）。
   改用更实的纯色遮罩来营造「背景后退」的层次，不做实时模糊。 */
.modal-mask { position: absolute; inset: 0; background: rgba(48, 40, 33, .75); }
.modal-box {
  position: relative; background: #fff;
  border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
  max-width: 92vw; max-height: 92vh; overflow: hidden;
  display: flex; flex-direction: column;
  animation: scaleIn .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes scaleIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  width: 36px; height: 36px; border: none; background: transparent;
  font-size: 26px; color: var(--ink-soft); cursor: pointer; z-index: 2;
  border-radius: 50%; transition: all .15s;
}
.modal-close:hover { background: var(--paper-deep); color: var(--accent); }

/* 视频弹窗 */
.video-box { width: 90vw; max-width: 1000px; }
.video-box h3 { padding: 16px 24px; margin: 0; font-size: 18px; color: var(--ink); border-bottom: 1px solid var(--line); }
/* 【禁止加 transform: translateZ(0)】见 #word-video 上方说明：会把视频推离标准合成路径导致黑屏 */
#video-player { width: 100%; max-height: 75vh; background: #000; }
/* 同页有多个课文动画时，标题下方给出切换按钮 */
.video-tabs { display: none; gap: 8px; flex-wrap: wrap; padding: 10px 24px 0; }
.video-tabs .vt-tab {
  padding: 5px 14px; border: 1px solid #d9c9a6; border-radius: 16px;
  background: #fdfaf3; color: #6b5a3a; font-size: 13px; cursor: pointer;
  font-family: inherit; transition: all .15s; white-space: nowrap;
}
.video-tabs .vt-tab:hover { border-color: var(--accent); color: var(--accent); }
.video-tabs .vt-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* 生字卡片 */
.word-box { width: 720px; max-width: 92vw; }
.word-head { display: flex; gap: 24px; padding: 28px 28px 16px; border-bottom: 1px dashed var(--line); }
.word-char {
  width: 130px; height: 150px; flex: none;
  background: linear-gradient(180deg, #fff, #fdf6e8);
  border: 2px solid var(--accent); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: "Kaiti SC", "KaiTi", "STKaiti", "Songti SC", serif;
  font-size: 84px; color: var(--ink);
  box-shadow: 0 4px 12px rgba(181,73,46,.2);
}
.word-info { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.word-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.word-row .lbl {
  display: inline-block; min-width: 44px; padding: 3px 8px;
  background: var(--paper-deep); color: var(--accent);
  border-radius: 4px; font-size: 12px; text-align: center;
}
.word-pinyin { color: var(--accent); font-size: 18px; font-weight: 600; letter-spacing: 1px; }
.word-audios { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.word-audio-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; background: #fff; border: 1px solid var(--accent-soft);
  border-radius: 20px; color: var(--accent); cursor: pointer; font-size: 13px;
  transition: all .12s;
}
.word-audio-btn:hover { background: var(--accent); color: #fff; }
.word-audio-btn.playing { background: var(--accent); color: #fff; }
.word-audio-btn .ic { font-size: 11px; }
.word-no-audio {
  display: inline-block; padding: 6px 14px;
  background: #f5f1e8; border: 1px dashed #d4c8b0; border-radius: 20px;
  color: #b3a88f; font-size: 12px;
}
.word-video-wrap { padding: 16px 28px 24px; }
.word-video-wrap h4 { font-size: 14px; color: var(--ink-soft); margin-bottom: 8px; }
/* 笔顺视频容器：尺寸由布局固定为正方形，不依赖 <video> 是否成功加载元数据。
   若改为跟随视频固有尺寸（fit-content），一旦媒体加载失败，<video> 会退化成
   300×150 默认盒，叠加的田字格（inset:0）随之变成扁矩形 —— 这是曾经的线上现象。 */
.word-video-grid { position: relative; width: 320px; height: 320px; max-width: 100%; margin: 0 auto; }
/* 支持 aspect-ratio 的内核改为「随宽度自适应的正方形」，窄窗口下自动缩小。
   用 @supports 包裹而不是直接写 aspect-ratio：老内核不认该属性会导致高度塌成 0。 */
@supports (aspect-ratio: 1 / 1) {
  .word-video-grid { width: min(320px, 100%); height: auto; aspect-ratio: 1 / 1; }
}
#word-video {
  width: 100%; height: 100%; object-fit: contain;
  background: #fafafa; border-radius: 8px; display: block;
  -webkit-user-select: none; user-select: none;
  /* 【禁止给本元素加 transform: translateZ(0) / will-change: transform】
     它会把视频推离标准合成路径，在部分 GPU 驱动下导致画面全黑，
     2026-09-24 曾因此回退。闪烁问题请从遮罩层（backdrop-filter）方向解决。 */
}
/* 田字格：叠加在笔顺视频上，外框 + 横中线 + 竖中线 */
.tianzige {
  position: absolute;
  inset: 0 0 0 0;
  pointer-events: none;
  border: 2px solid rgba(200, 80, 60, .5);
  background:
    linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(200,80,60,.35) calc(50% - 0.5px), rgba(200,80,60,.35) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to right, transparent calc(50% - 0.5px), rgba(200,80,60,.35) calc(50% - 0.5px), rgba(200,80,60,.35) calc(50% + 0.5px), transparent calc(50% + 0.5px));
  border-radius: 8px;
}

/* ---------- 笔顺视频自定义控制条（替代原生控件） ----------
   原生控件已去掉：静音、全屏、三点菜单里的下载
   仅保留：播放/暂停、进度、时间、播放速度、画中画            */
.wv-ctrl {
  position: absolute; left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: flex; align-items: center; gap: 7px;
  padding: 16px 8px 7px;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(to top, rgba(38, 30, 20, .66), rgba(38, 30, 20, .28) 55%, transparent);
  opacity: 1; transition: opacity .22s;
}
.wv-ctrl.idle { opacity: .22; }
.wv-ctrl.idle:hover { opacity: 1; }

.wv-btn {
  flex: none; width: 26px; height: 26px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 7px; cursor: pointer;
  background: transparent; color: #fff;
  transition: background .15s, transform .12s;
}
.wv-btn:hover { background: rgba(255, 255, 255, .2); }
.wv-btn:active { transform: scale(.92); }
.wv-btn svg { width: 17px; height: 17px; fill: currentColor; display: block; }
.wv-ic-pause { display: none; }
.wv-ctrl.playing .wv-ic-play { display: none; }
.wv-ctrl.playing .wv-ic-pause { display: block; }

.wv-rate {
  width: auto; min-width: 34px; padding: 0 6px;
  font-size: 12px; font-weight: 600; letter-spacing: .3px;
  font-variant-numeric: tabular-nums;
}

.wv-track {
  position: relative; flex: 1; min-width: 40px; height: 16px;
  display: flex; align-items: center; cursor: pointer;
}
.wv-track::before {
  content: ''; position: absolute; left: 0; right: 0;
  height: 4px; border-radius: 3px; background: rgba(255, 255, 255, .34);
  transition: height .15s;
}
.wv-track:hover::before { height: 6px; }
.wv-bar {
  position: absolute; left: 0; width: 0; height: 4px;
  border-radius: 3px; background: #fff; transition: height .15s;
}
.wv-track:hover .wv-bar { height: 6px; }
.wv-knob {
  position: absolute; top: 50%; left: 0;
  width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  opacity: 0; transition: opacity .15s;
}
.wv-track:hover .wv-knob { opacity: 1; }

.wv-time {
  flex: none; color: #fff; font-size: 11.5px;
  font-variant-numeric: tabular-nums; letter-spacing: .2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  white-space: nowrap;
}

/* 拼音表 */
.pinyin-box { width: 900px; max-width: 95vw; max-height: 88vh; }
.pinyin-box h3 { padding: 16px 24px; margin: 0; font-size: 18px; color: var(--ink); border-bottom: 1px solid var(--line); }
.pinyin-tabs {
  display: flex; gap: 4px; padding: 12px 20px 0;
  border-bottom: 1px solid var(--line); overflow-x: auto;
  flex-shrink: 0;
}
.pinyin-tab {
  padding: 8px 14px; cursor: pointer; font-size: 13px;
  color: var(--ink-soft); border-bottom: 2px solid transparent;
  white-space: nowrap; transition: all .12s;
}
.pinyin-tab:hover { color: var(--ink); }
.pinyin-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.pinyin-grid {
  flex: 1; overflow-y: auto; padding: 16px 20px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}
.pinyin-cell {
  padding: 14px 8px; text-align: center;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  font-size: 18px; color: var(--ink); cursor: pointer;
  transition: all .12s; font-family: "Times New Roman", serif;
  position: relative;
}
.pinyin-cell:hover { border-color: var(--accent); background: #fffaf3; transform: translateY(-2px); }
.pinyin-cell.playing { background: var(--accent); color: #fff; border-color: var(--accent); }
.pinyin-cell .noplay { display: block; font-size: 9px; color: #c5b89f; margin-top: 2px; }
.pinyin-cell.playing .noplay { color: rgba(255,255,255,.8); }

/* ============================================================
   标定系统
   ============================================================ */
/* 热点按钮（贴在书页上） */
.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 60;
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px; border: none; border-radius: 10px;
  cursor: pointer; background: transparent;
  transition: transform .15s ease;
  pointer-events: auto;
}
.hotspot:hover { transform: translate(-50%, -50%) scale(1.15); }
/* 框选出来的矩形区域热点（不用 transform 居中，按 w/h 直接铺）—— 不显示红色边框 */
.hotspot.hs-area {
  transform: none;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: block;
  padding: 0;
}
.hotspot.hs-area:hover {
  background: transparent;
  border-color: transparent;
}
/* 文字为空的矩形热点：用半透明云朵印记替代虚线框 */
.hotspot.hs-area.hs-empty-label {
  background: transparent;
  border: none;
}
.hotspot.hs-area.hs-empty-label::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  /* 等比缩放，且不超过所在标注框（区域热点框就是句子范围，溢出会盖住邻行） */
  width: min(calc(46px * var(--hs-k, 1)), 100%);
  height: min(calc(31px * var(--hs-k, 1)), 100%);
  background: var(--img-cloud, url('../icons/yunduo.png')) center / contain no-repeat;
  opacity: 0.45;
  filter: sepia(1) saturate(4) hue-rotate(-18deg);  /* 浅红色调 */
  pointer-events: none;
}
.hotspot.hs-area.hs-empty-label:hover { background: rgba(181,73,46,.08); }
.hotspot.hs-area.hs-empty-label:hover::after { opacity: 0.7; }
.hotspot .hs-icon {
  /* --hs-k 由 hotspots.js 按「书页实际渲染宽度 / 桌面基准 590px」算出，
     手机上自动缩小，保证图标占页面的视觉比例恒定（否则会盖住课文） */
  width: calc(40px * var(--hs-k, 1)); height: calc(40px * var(--hs-k, 1));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: calc(18px * var(--hs-k, 1)); color: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.3);
}
.hotspot .hs-label {
  padding: calc(2px * var(--hs-k, 1)) calc(8px * var(--hs-k, 1));
  border-radius: 10px; background: rgba(0,0,0,.6);
  color: #fff; white-space: nowrap;
  /* 字号下限 9px：再小在手机上就看不清了 */
  font-size: clamp(9px, calc(11px * var(--hs-k, 1)), 12px);
}
/* 矩形热点内的图标/文字：放在区域中心 */
.hotspot.hs-area .hs-icon {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: calc(32px * var(--hs-k, 1)); height: calc(32px * var(--hs-k, 1));
  font-size: calc(14px * var(--hs-k, 1));
}
.hotspot.hs-area .hs-label {
  position: absolute; left: 50%;
  top: calc(50% + 22px * var(--hs-k, 1));
  transform: translateX(-50%);
}
.hotspot.htype-video .hs-icon { background: #e67e22; }
.hotspot.htype-audio .hs-icon { background: #27ae60; }
.hotspot.htype-word .hs-icon { background: #b5492e; }
.hotspot.htype-pinyin .hs-icon { background: #2980b9; }
.hotspot.htype-flip .hs-icon { background: #8e44ad; }

/* ============================================================
   词汇表首页（pageIndex 108 / 显示第 109 页）顶部的「单词游戏」入口
   —— 独立 <a> 按钮，不属热点系统，用 --hs-k 等比缩放。
   ============================================================ */
#book .page .game-entry {
  position: absolute;
  left: 50%; top: 3.6%;
  transform: translateX(-50%);
  z-index: 65;
  display: inline-flex; align-items: center; gap: calc(7px * var(--hs-k, 1));
  padding: calc(6px * var(--hs-k, 1)) calc(16px * var(--hs-k, 1));
  border-radius: 999px;
  background: linear-gradient(135deg, #8b7fd4 0%, #6E68AE 100%);
  color: #fff; text-decoration: none; white-space: nowrap;
  box-shadow: 0 calc(3px * var(--hs-k, 1)) calc(10px * var(--hs-k, 1)) rgba(90,80,160,.35);
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s ease, box-shadow .15s ease;
}
#book .page .game-entry:hover { transform: translateX(-50%) translateY(-2px); box-shadow: 0 calc(6px * var(--hs-k, 1)) calc(14px * var(--hs-k, 1)) rgba(90,80,160,.45); }
#book .page .game-entry:active { transform: translateX(-50%) scale(.96); }
#book .page .game-entry .ge-emoji { font-size: calc(20px * var(--hs-k, 1)); line-height: 1; }
#book .page .game-entry .ge-txt { display: inline-flex; flex-direction: column; line-height: 1.1; }
#book .page .game-entry .ge-txt b { font-size: calc(14px * var(--hs-k, 1)); font-weight: 800; letter-spacing: .5px; }
#book .page .game-entry .ge-txt small { font-size: clamp(7px, calc(9px * var(--hs-k, 1)), 10px); opacity: .9; margin-top: calc(1px * var(--hs-k, 1)); }
#book .page .game-entry .ge-arrow { font-size: calc(20px * var(--hs-k, 1)); opacity: .85; margin-left: calc(1px * var(--hs-k, 1)); }

/* ============================================================
   PDF 第 56 页（pageIndex 55）底部「英语阶段性练习」入口
   与 game-entry 同构，但放在页面底部居中；青绿色区分单词游戏的紫色。
   试卷为同源本地直出文件，链接用相对路径 test/… ，不走 assetUrl/反代。
   ============================================================ */
#book .page .exam-entry {
  position: absolute;
  left: 50%; bottom: 3.2%;
  transform: translateX(-50%);
  z-index: 65;
  display: inline-flex; align-items: center; gap: calc(7px * var(--hs-k, 1));
  padding: calc(6px * var(--hs-k, 1)) calc(16px * var(--hs-k, 1));
  border-radius: 999px;
  background: linear-gradient(135deg, #3f9c8f 0%, #2c7a70 100%);
  color: #fff; text-decoration: none; white-space: nowrap;
  box-shadow: 0 calc(3px * var(--hs-k, 1)) calc(10px * var(--hs-k, 1)) rgba(44,122,112,.35);
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s ease, box-shadow .15s ease;
}
#book .page .exam-entry:hover { transform: translateX(-50%) translateY(-2px); box-shadow: 0 calc(6px * var(--hs-k, 1)) calc(14px * var(--hs-k, 1)) rgba(44,122,112,.45); }
#book .page .exam-entry:active { transform: translateX(-50%) scale(.96); }
#book .page .exam-entry .ee-emoji { font-size: calc(19px * var(--hs-k, 1)); line-height: 1; }
#book .page .exam-entry .ee-txt { display: inline-flex; flex-direction: column; line-height: 1.1; }
#book .page .exam-entry .ee-txt b { font-size: calc(14px * var(--hs-k, 1)); font-weight: 800; letter-spacing: .5px; }
#book .page .exam-entry .ee-txt small { font-size: clamp(7px, calc(9px * var(--hs-k, 1)), 10px); opacity: .9; margin-top: calc(1px * var(--hs-k, 1)); }
#book .page .exam-entry .ee-arrow { font-size: calc(20px * var(--hs-k, 1)); opacity: .85; margin-left: calc(1px * var(--hs-k, 1)); }

/* ============================================================
   课文动画热点（video）：用老师卡通形象 teacher.png 作为标记
   资源实际路径：ebooks/assets/icons/teacher.png（91x136，2:3 透明底）
   ============================================================ */
.hotspot.htype-video .hs-icon,
.hotspot.htype-note .hs-icon,
.hotspot.htype-reading .hs-icon {
  background: var(--img-teacher, url('../icons/teacher.png')) center / contain no-repeat;
  width: 54px; height: 81px;      /* 2:3 比例 */
  font-size: 0;                   /* 隐藏原 unicode 图标 */
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .28));
}
/* 区域热点：老师形象随标注框自适应（contain 不拉伸），并做轻微上下浮动 */
.hotspot.htype-video.hs-area .hs-icon,
.hotspot.htype-note.hs-area .hs-icon,
.hotspot.htype-reading.hs-area .hs-icon {
  width: 100%;
  height: 100%;
  /* 封顶尺寸随书页缩放：桌面 100×130，手机按比例收小，避免人物盖住正文 */
  max-width: calc(100px * var(--hs-k, 1));
  max-height: calc(130px * var(--hs-k, 1));
  /* 拖框很小时也要看得见老师标记（下限随缩放走，但留一个最小可见值） */
  min-width: max(14px, calc(20px * var(--hs-k, 1)));
  min-height: max(20px, calc(28px * var(--hs-k, 1)));
  background-size: contain;
  animation: hs-teacher-bob 2.8s ease-in-out infinite;
  transform-origin: 50% 100%;
}
@keyframes hs-teacher-bob {
  0%, 100% { transform: translate(-50%, -50%); }
  50%      { transform: translate(-50%, calc(-50% - 4px)); }
}
.hotspot.htype-video.hs-area:hover .hs-icon,
.hotspot.htype-note.hs-area:hover .hs-icon,
.hotspot.htype-reading.hs-area:hover .hs-icon {
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35)) brightness(1.03);
}
/* 标定模式下不要给透明老师图套白色方块阴影 */
body.calibrating .hotspot.htype-video .hs-icon,
body.calibrating .hotspot.htype-note .hs-icon,
body.calibrating .hotspot.htype-reading .hs-icon { box-shadow: none; }
/* 老师标记下方的文字改成小胶囊，贴在标注框底边外侧，不压正文 */
/* 标签贴在「人物脚底」：--hs-feet 由 JS 按图标实际可见高度算出，
   否则标注框比图片高时，标签会掉到框的底边，跟人物隔一大截。 */
.hotspot.htype-video.hs-area .hs-label,
.hotspot.htype-note.hs-area .hs-label,
.hotspot.htype-reading.hs-area .hs-label {
  top: calc(50% + var(--hs-feet, 40px));
  bottom: auto;
  transform: translate(-50%, -2px);
  padding: calc(1px * var(--hs-k, 1)) calc(7px * var(--hs-k, 1));
  font-size: clamp(8.5px, calc(10px * var(--hs-k, 1)), 11px);
  line-height: 1.5;
  border-radius: 9px;
  background: rgba(74, 66, 52, .72);
  white-space: nowrap;
}
.hotspot.htype-video.hs-area:hover .hs-label,
.hotspot.htype-note.hs-area:hover .hs-label,
.hotspot.htype-reading.hs-area:hover .hs-label { background: rgba(181, 73, 46, .85); }

/* ============================================================
   生字热点（运行时）—— 完全隐身不遮挡生字，只留点击区域
   标定模式下仍显示完整编辑图标（方便定位）
   ============================================================ */
.hotspot.htype-word .hs-icon { display: none !important; }
.hotspot.htype-word::before { display: none !important; }
/* 点状生字热点：48x48 透明点击区域（覆盖字中心，hover 给一个淡光环提示） */
.hotspot.htype-word:not(.hs-area) { width: 48px; height: 48px; }
.hotspot.htype-word:hover { box-shadow: 0 0 0 2px rgba(181,73,46,.18); border-radius: 50%; }
/* 标定模式下恢复完整编辑图标 */
body.calibrating .hotspot.htype-word .hs-icon { display: flex !important; }
body.calibrating .hotspot.htype-word::before { display: none; }

body.calibrating .hotspot { opacity: .9; }
body.calibrating .hotspot .hs-icon { box-shadow: 0 0 0 3px rgba(255,255,255,.8), 0 3px 10px rgba(0,0,0,.4); }
/* 标定模式下矩形热点显示更明显的编辑边框 */
body.calibrating .hotspot.hs-area { border-color: var(--accent); border-style: dashed; }
body.calibrating .hotspot::after {
  content: '编辑'; position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  padding: 1px 6px; border-radius: 4px; background: #333; color: #fff; font-size: 9px;
  white-space: nowrap; opacity: 0; transition: opacity .15s;
}
body.calibrating .hotspot:hover::after { opacity: 1; }

/* 标定模式：书页可点击定位（翻页由 JS 拦截 mousedown 冒泡实现，左右箭头仍可翻页） */
body.calibrating .page { cursor: crosshair; }
body.calibrating .stf__block { box-shadow: 0 0 0 2px rgba(181,73,46,.35), 0 22px 50px -8px var(--shadow); }

/* 标定工具栏（固定单行，超出宽度时横向滚动，绝不换行加高遮挡书页） */
.cal-toolbar {
  position: fixed; left: 50%; bottom: 14px;
  transform: translateX(-50%);
  display: none; align-items: center; gap: 10px;
  padding: 6px 12px; border-radius: 26px;
  background: rgba(40, 36, 30, .94);
  color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 90;
  max-width: calc(100vw - 20px);
  overflow-x: auto; overflow-y: hidden;
  flex-wrap: nowrap;
}
.cal-toolbar.show { display: flex; }
.cal-badge { background: #e67e22; padding: 3px 10px; border-radius: 14px; font-size: 12px; font-weight: 600; }
.cal-info { display: flex; align-items: center; gap: 10px; font-size: 12.5px; flex: 0 0 auto; white-space: nowrap; }
.cal-info > span { white-space: nowrap; }
.cal-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.cal-btn {
  padding: 6px 11px; border: 1px solid rgba(255,255,255,.3); border-radius: 16px;
  background: transparent; color: #fff; cursor: pointer; font-size: 12.5px;
  transition: all .15s; white-space: nowrap; flex: 0 0 auto;
}
/* 标定模式隐藏了底部缩略图栏，工具栏直接占用那条空带，不再压住书页 */
body.calibrating .thumb-bar { display: none; }
.cal-btn:hover { background: rgba(255,255,255,.15); }
.cal-btn.primary { background: #e67e22; border-color: #e67e22; font-weight: 600; }
.cal-btn.primary:hover { background: #d97706; }
.cal-btn.danger { color: #ff9d8a; }

/* 标定配置弹窗 */
.cal-box { width: 580px; max-width: 94vw; }
.cal-box h3 { padding: 16px 24px; margin: 0; font-size: 17px; color: var(--ink); border-bottom: 1px solid var(--line); }
.cal-box h3 span { color: var(--accent); font-size: 13px; margin-left: 8px; }
.cal-body { padding: 16px 24px; max-height: 70vh; overflow-y: auto; }

/* ============================================================
   配置表面板（查看 / 编辑 / 删除所有已标定热点）
   ============================================================ */
.list-box { width: 880px; max-width: 96vw; max-height: 86vh; display: flex; flex-direction: column; }
.list-box h3 { padding: 14px 20px; margin: 0; font-size: 16px; color: var(--ink); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.list-box h3 span { color: var(--accent); font-size: 13px; font-weight: 400; }
.list-toolbar { padding: 12px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); background: #faf6ed; }
.list-toolbar input { flex: 1; padding: 7px 12px; border: 1px solid #d4c8b0; border-radius: 6px; background: #fff; font-size: 13px; font-family: inherit; outline: none; }
.list-toolbar input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181,73,46,.1); }
.list-stats { font-size: 12px; color: #6b5a3a; font-family: monospace; white-space: nowrap; }
.list-table-wrap { flex: 1; overflow: auto; padding: 0; }
.list-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.list-table thead { position: sticky; top: 0; z-index: 1; background: linear-gradient(180deg, #f5ead2, #ebe0c2); }
.list-table th { padding: 8px 10px; text-align: left; font-weight: 600; color: #5a4a2a; border-bottom: 2px solid #d4c8b0; font-size: 12px; }
.list-table td { padding: 7px 10px; border-bottom: 1px solid #f0e8d4; vertical-align: middle; }
.list-table tbody tr { cursor: pointer; transition: background .12s; }
.list-table tbody tr:hover { background: var(--paper-deep); }
.list-table .col-page { font-weight: 600; color: var(--accent); font-size: 11.5px; line-height: 1.3; text-align: center; }
.list-table .col-content { color: var(--ink); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; }
.list-table .col-pos { color: #8b7c5a; font-family: monospace; font-size: 11px; }
.list-table .col-label { color: #6b5a3a; font-size: 12px; }
.list-table .col-actions { white-space: nowrap; }
.lt-type { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }
.lt-type-video { background: #fce4cf; color: #b5492e; }
.lt-type-audio { background: #d4edda; color: #1d6f42; }
.lt-type-word { background: #f8d7da; color: #a32a3b; }
.lt-type-pinyin { background: #cfe2f3; color: #1a5490; }
.lt-type-flip { background: #e2d2ee; color: #6a1b9a; }
.lt-btn { padding: 3px 9px; margin-right: 4px; border: 1px solid #d4c8b0; border-radius: 4px; background: #fffaf2; color: var(--ink); font-size: 11.5px; cursor: pointer; font-family: inherit; }
.lt-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.lt-btn.lt-del { color: #a32a3b; }
.lt-btn.lt-del:hover { background: #a32a3b; color: #fff; border-color: #a32a3b; }
.list-empty { padding: 60px 20px; text-align: center; color: #b3a88f; font-size: 14px; }
.list-footer { padding: 10px 20px; border-top: 1px solid var(--line); background: #faf6ed; }
.list-hint { color: #8b7c5a; font-size: 11.5px; }

/* ============================================================
   自定义 Combobox（搜索框 + 可滚动分组列表）
   ============================================================ */
.cb-wrap { position: relative; }
.cb-input {
  width: 100%; padding: 8px 36px 8px 12px;
  border: 1.5px solid #d4c8b0; border-radius: 8px;
  background: #fffaf2; font-size: 14px; color: var(--ink);
  font-family: inherit; box-sizing: border-box;
  cursor: pointer;
}
.cb-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181,73,46,.12); }
.cb-toggle {
  position: absolute; right: 4px; top: 4px;
  width: 28px; height: 28px;
  border: none; background: transparent; border-radius: 6px;
  cursor: pointer; font-size: 10px; color: #8b7c5a;
  display: flex; align-items: center; justify-content: center;
}
.cb-toggle:hover { background: var(--paper-deep); color: var(--accent); }
.cb-panel {
  display: none;
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 300;
  background: #fffaf2; border: 1.5px solid #d4c8b0; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(60,40,20,.18);
  flex-direction: column; overflow: hidden;
  max-height: 380px;
}
.cb-panel.cb-open { display: flex; animation: fadeIn .15s; }
.cb-search {
  width: 100%; padding: 8px 12px;
  border: none; border-bottom: 1px solid var(--line);
  background: #fff; font-size: 13px; font-family: inherit;
  box-sizing: border-box; outline: none;
}
.cb-search:focus { background: #fff8ed; }
.cb-list {
  flex: 1; overflow-y: auto; padding: 4px 0;
  scrollbar-width: thin;
}
.cb-list::-webkit-scrollbar { width: 6px; }
.cb-list::-webkit-scrollbar-thumb { background: #c8b894; border-radius: 3px; }
.cb-group-head {
  padding: 6px 14px;
  background: linear-gradient(180deg, #f5ead2, #ebe0c2);
  color: #6b5a3a; font-weight: 700; font-size: 12px;
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid #e0d5b8;
  border-bottom: 1px solid #e0d5b8;
}
.cb-group-count { font-size: 11px; color: #9c8d68; font-weight: 400; }
.cb-item {
  padding: 7px 14px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
  border-bottom: 1px solid #f0e8d4;
}
.cb-item:hover { background: var(--paper-deep); }
.cb-item.cb-active { background: rgba(181,73,46,.12); }
.cb-item.cb-selected { background: rgba(181,73,46,.18); border-left: 3px solid var(--accent); padding-left: 11px; }
.cb-item-label { font-size: 13px; color: var(--ink); font-weight: 500; }
.cb-item-fn { font-size: 10px; color: #a89875; font-family: monospace; }
.cb-empty { padding: 30px; text-align: center; color: #b3a88f; font-size: 13px; }
.cal-row { margin-bottom: 14px; }
.cal-row > label {
  display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px;
}
.cal-types { display: flex; gap: 8px; flex-wrap: wrap; }
.cal-type-btn {
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 20px;
  background: #fff; color: var(--ink); cursor: pointer; font-size: 13px;
  transition: all .12s;
}
.cal-type-btn:hover { border-color: var(--accent-soft); }
.cal-type-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.cal-row select, .cal-row input[type="text"], .cal-row input[type="number"] {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; color: var(--ink); background: #fff;
}
.cal-row select:focus, .cal-row input:focus { outline: none; border-color: var(--accent); }
.cal-hint { font-size: 12px; color: #b3a88f; margin-top: 6px; }
.cal-pos-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-pos-row > label { margin-bottom: 0; }
.cal-pos-row span { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-soft); }
.cal-pos-row input[type="number"] { width: 70px; }
.cal-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 24px; border-top: 1px solid var(--line);
}
.cal-footer .spacer { flex: 1; }
.cal-footer .cal-btn { color: var(--ink); border-color: var(--line); }
.cal-footer .cal-btn.primary { color: #fff; }
.cal-footer .cal-btn.danger { color: var(--accent); border-color: var(--accent-soft); }

/* ---------- 书本区 ---------- */
.book-area {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  padding: 22px 40px;
}
/* 书本宽度约束容器（JS 计算最大宽度以适配高度） */
.book-sizer {
  position: relative;
  width: 100%;
  max-width: 1180px;
}

#book { width: 100%; }

/* 翻页引擎页面 */
#book .page { overflow: hidden; }
#book .page img {
  width: 100%; height: 100%; display: block;
  pointer-events: none; user-select: none;
}
.stf__item { background: #fff; }
.stf__block { box-shadow: 0 22px 50px -8px var(--shadow), 0 6px 16px rgba(90,70,40,.18); border-radius: 2px; }

/* 两侧翻页点击热区 + 提示 */
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(255,255,255,.7); border: 1px solid var(--line);
  color: var(--ink); cursor: pointer; z-index: 20;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
  box-shadow: 0 4px 14px rgba(90,70,40,.18);
  transition: all .15s;
}
.nav-arrow:hover { background: #fff; color: var(--accent); transform: translateY(-50%) scale(1.06); }
.nav-arrow.prev { left: 8px; }
.nav-arrow.next { right: 8px; }
.nav-arrow:disabled { opacity: 0; pointer-events: none; }

/* ---------- 底部缩略图 ---------- */
.thumb-bar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--thumb-h);
  background: rgba(253, 250, 243, .95);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; padding: 0 14px;
  z-index: 40;
}
.thumb-scroll {
  display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px;
  scroll-behavior: smooth; flex: 1;
}
.thumb-scroll::-webkit-scrollbar { height: 6px; }
.thumb-scroll::-webkit-scrollbar-thumb { background: #d6c9ab; border-radius: 4px; }
.thumb {
  flex: none; width: 56px; height: 76px; border-radius: 4px;
  background-size: cover; background-position: center;
  border: 2px solid transparent; cursor: pointer; position: relative;
  box-shadow: 0 2px 6px rgba(90,70,40,.2);
  transition: transform .12s, border-color .12s;
}
.thumb:hover { transform: translateY(-3px); }
.thumb.active { border-color: var(--accent); }
.thumb .no {
  position: absolute; left: 3px; bottom: 2px; font-size: 9px; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

/* ---------- 开场遮罩 ---------- */
#intro {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(120% 120% at 50% 30%, #3a2d20 0%, #231a12 70%);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 20px;
  transition: opacity .6s ease;
}
#intro.hide { opacity: 0; pointer-events: none; }
#intro .book-ico { font-size: 56px; }
#intro h1 {
  color: #f4ecd8; font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 30px; letter-spacing: 6px; font-weight: 600;
}
#intro p { color: #cbb98f; font-size: 14px; letter-spacing: 2px; }
#intro .btn {
  margin-top: 8px; padding: 12px 34px; border-radius: 30px;
  background: var(--accent); color: #fff; font-size: 15px; letter-spacing: 4px;
  cursor: pointer; border: none; box-shadow: 0 6px 20px rgba(181,73,46,.5);
  transition: transform .15s;
}
#intro .btn:hover { transform: translateY(-2px); }

/* 移动端 */
@media (max-width: 820px) {
  :root { --toolbar-h: 52px; --thumb-h: 86px; }
  .sidebar { position: fixed; top: var(--toolbar-h); bottom: var(--thumb-h); left: 0; box-shadow: 8px 0 30px rgba(0,0,0,.15); }
  .book-area { padding: 12px 8px; }
  .nav-arrow { width: 40px; height: 40px; font-size: 17px; }

  .toolbar { padding: 0 10px; gap: 6px; height: var(--toolbar-h); }
  .toolbar .brand .titles { display: none; }
  .toolbar .brand .logo { width: 32px; height: 32px; font-size: 16px; border-radius: 8px; }
  .page-indicator { font-size: 11px; }
  .page-indicator b { font-size: 12px; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }
  .thumb { width: 44px; height: 60px; }
  .thumb .no { font-size: 8px; }
}

/* ---------- 页面教学配置面板（pagenotes.html） ---------- */
.pn-panel {
  width: 360px; flex: none;
  background: rgba(253, 250, 243, .96);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; overflow: hidden;
}
/* 面板内嵌工具条（替代原 fixed 底部工具条，避免遮挡书页与面板） */
.pn-toolbar {
  padding: 8px 10px;
  background: rgba(40, 36, 30, .95);
  display: flex; flex-direction: column; gap: 8px;
}
.pn-toolbar .cal-info { flex-wrap: wrap; row-gap: 2px; }
.pn-toolbar .cal-actions { flex-wrap: wrap; }
.pn-toolbar .cal-badge { background: #b5492e; }

/* 缩略图条被隐藏时（no-flip 配置页/标定页），书区回收底部空间 */
body.no-flip .layout { inset: var(--toolbar-h) 0 0 0; }
body.no-flip .tip { bottom: 26px; }

@media (max-width: 1280px) {
  .pn-panel { width: 320px; }
}

.pn-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); background: #faf6ed; }
.pn-head-row { display: flex; align-items: center; gap: 8px; }
.pn-head-title { font-size: 14.5px; font-family: "Songti SC", "STSong", "SimSun", serif; }
.pn-state {
  margin-left: auto; padding: 2px 10px; border-radius: 12px;
  font-size: 11.5px; color: #8b7c5a; background: #efe7d5; white-space: nowrap;
}
.pn-state.on { background: var(--accent); color: #fff; font-weight: 600; }
.pn-page-info {
  margin-top: 8px; font-size: 21px; color: var(--accent);
  font-family: "Songti SC", "STSong", "SimSun", serif; letter-spacing: 1px;
}
.pn-meta { margin-top: 2px; font-size: 11.5px; color: var(--ink-soft); }

.pn-server-warn {
  margin: 10px 16px 0; padding: 9px 11px;
  background: #fdf0ec; border: 1px solid #e8b7a6; border-radius: 8px;
  font-size: 12px; line-height: 1.7; color: #8a3b22;
}
.pn-server-warn a { color: #1a5f8f; text-decoration: underline; font-weight: 600; }
.pn-server-warn b { color: #8a3b22; }

.pn-body {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.pn-body::-webkit-scrollbar { width: 7px; }
.pn-body::-webkit-scrollbar-thumb { background: #d9cdb4; border-radius: 4px; }

.pn-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
  box-shadow: 0 1px 4px rgba(90, 70, 40, .06);
  transition: border-color .15s, box-shadow .15s;
}
.pn-card:focus-within { border-color: var(--accent); box-shadow: 0 2px 10px rgba(181, 73, 46, .14); }
.pn-card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pn-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.pn-card-head b { font-size: 13.5px; color: var(--ink); }
.pn-count { margin-left: auto; font-size: 11px; color: #b3a88f; }
.pn-count.filled { color: var(--accent); }
.pn-input {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; line-height: 1.75; resize: vertical;
  font-family: inherit; color: var(--ink); background: #fffdf8; min-height: 76px;
}
.pn-input:focus { outline: none; border-color: var(--accent); background: #fff; }
.pn-input::placeholder { color: #c3b9a2; }

.pn-foot { padding: 10px 16px 14px; border-top: 1px solid var(--line); background: #faf6ed; }
.pn-hint { font-size: 11.5px; color: #9c9078; line-height: 1.6; margin-bottom: 10px; }
.pn-foot-btns { display: flex; gap: 8px; }
.pn-btn {
  flex: 1; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 13px; cursor: pointer; transition: all .15s;
}
.pn-btn:hover { background: var(--paper-deep); border-color: var(--accent-soft); }
.pn-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pn-btn.primary:hover { background: #9e3d25; }
.pn-dirty { color: #ffb26b; font-size: 12px; }
.pn-list-box { width: 860px; max-width: 94vw; }
a.cal-btn { text-decoration: none; display: inline-flex; align-items: center; }

@media (max-width: 820px) {
  .pn-panel { width: 300px; }
  .pn-input { min-height: 58px; }
}

/* 工具提示 */
.tip {
  position: fixed; left: 50%; bottom: calc(var(--thumb-h) + 26px);
  transform: translateX(-50%); padding: 8px 16px; border-radius: 20px;
  background: rgba(58,50,42,.88); color: #f4ecd8; font-size: 12.5px; letter-spacing: 1px;
  opacity: 0; pointer-events: none; transition: opacity .3s;
  /* 必须高于 .modal(200)：媒体加载失败提示需要在弹窗打开时可见，
     否则「生字笔顺视频加载失败」这类提示会被压在弹窗遮罩之后 */
  z-index: 300;
}
.tip.show { opacity: 1; }

/* ============================================================
   英语版（五年级上）新增样式
   ============================================================ */
/* 注意：note / reading 的图标统一走上面 teacher.png 的规则，这里不要再给背景色，
   否则同特异性但更靠后的声明会把老师形象盖成纯色方块。 */
.hotspot.htype-unit_audio .hs-icon { background: #16a085; }
.hotspot.htype-note .hs-label,
.hotspot.htype-reading .hs-label,
.hotspot.htype-unit_audio .hs-label { color: #fff; }

/* 课文朗读列表项 */
.read-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 9px 10px; border-radius: 10px; cursor: pointer;
}
.read-item:hover { background: #f3ecd9; }
.read-item .ri-no {
  flex: none; width: 20px; height: 20px; line-height: 20px; text-align: center;
  background: #27ae60; color: #fff; border-radius: 50%; font-size: 12px;
  transform: translateY(2px);
}
.read-item .ri-text { font-size: 14px; color: #4a4234; }
.read-item .ri-zh { font-size: 12px; color: #a89b7d; margin-left: auto; }

/* 课堂笔记 / 课外阅读弹窗（都是整篇文档页，给足宽度，否则左侧目录 + 正文会挤成两行） */
.doc-box {
  width: 1240px; max-width: 94vw; height: 88vh;
  max-height: 90vh;
  display: flex; flex-direction: column;
}
.doc-box h3 {
  margin: 0; padding: 14px 24px; font-size: 17px; color: var(--ink);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf8, #fdf8ee);
}
.doc-box iframe {
  flex: 1; width: 100%; border: 0;
  background: #fdfaf3;
}

/* ============================================================
   云朵热点（和语文电子书一致）+ 翻译字幕条
   ============================================================ */
/* 区域热点：课文=浅黄色云朵，单词=浅红色云朵 */
.hotspot.hs-area.hs-cloud {
  background: transparent;
  border: none;
}
.hotspot.hs-area.hs-cloud::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  /* 同样等比缩放 + 不出框：手机上页面缩到 360px 时，52px 固定云朵会占 14% 页宽，
     直接压住课文；这里让云朵跟随 --hs-k，并且永远不超出句子框 */
  width: min(calc(52px * var(--hs-k, 1)), 100%);
  height: min(calc(35px * var(--hs-k, 1)), 100%);
  background: var(--img-cloud, url('../icons/yunduo.png')) center / contain no-repeat;
  opacity: 0.5;
  pointer-events: none;
}
/* 课文领读：浅黄色调 */
.hotspot.hs-area.hs-cloud.htype-audio::after {
  filter: sepia(1) saturate(3) hue-rotate(8deg) brightness(1.08);
}
/* 单词：浅红色调（与语文版云朵红调一致） */
.hotspot.hs-area.hs-cloud.htype-word::after {
  filter: sepia(1) saturate(4) hue-rotate(-18deg);
}
.hotspot.hs-area.hs-cloud:hover {
  border-radius: 8px;
}
.hotspot.hs-area.hs-cloud.htype-audio:hover { background: rgba(232, 200, 100, 0.14); }
.hotspot.hs-area.hs-cloud.htype-word:hover { background: rgba(224, 100, 80, 0.12); }
.hotspot.hs-area.hs-cloud:hover::after { opacity: 0.85; }
/* 播放中高亮（由 JS 加 .playing） */
.hotspot.hs-area.hs-cloud.htype-audio.playing { background: rgba(232, 200, 100, 0.22); }
.hotspot.hs-area.hs-cloud.htype-word.playing { background: rgba(224, 100, 80, 0.20); }
.hotspot.hs-area.hs-cloud.playing::after { opacity: 1; }

/* 翻译字幕条 */
#subtitle-bar {
  position: fixed;
  left: 50%; bottom: 74px;
  transform: translate(-50%, 20px);
  z-index: 300;
  max-width: 72vw;
  background: rgba(255, 252, 242, 0.96);
  border: 1.5px solid #e8d9a8;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(120, 90, 30, 0.18);
  padding: 10px 26px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
#subtitle-bar.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#sub-en {
  font-family: 'Comic Sans MS', 'Segoe UI', sans-serif;
  font-size: 17px; font-weight: 600; color: #4a4234;
}
#sub-zh {
  font-size: 13.5px; color: #b08a2e; margin-top: 2px;
}
#sub-en:empty { display: none; }
#sub-zh:empty { display: none; }

/* ============================================================
   音频播放控制器（课文领读 / 单元朗读）
   —— 点读句子时浮在底部，带进度、±15 秒、音量、关闭
   ============================================================ */
#audio-player {
  position: fixed;
  left: 50%;
  bottom: calc(var(--thumb-h) + 16px);
  width: min(520px, calc(100vw - 32px));
  z-index: 190;   /* 低于弹窗(200)，高于书页；避免盖住课文动画 */
  background: rgba(255, 252, 243, .98);
  border: 1px solid #ecdfc0;
  border-radius: 18px;
  box-shadow: 0 12px 34px rgba(90, 70, 40, .22), 0 2px 6px rgba(90, 70, 40, .10);
  padding: 10px 14px 8px;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
#audio-player.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

.ap-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.ap-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: #c9bda3;
}
#audio-player.playing .ap-dot {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(181, 73, 46, .5);
  animation: ap-pulse 1.6s ease-out infinite;
}
@keyframes ap-pulse {
  0% { box-shadow: 0 0 0 0 rgba(181, 73, 46, .45); }
  100% { box-shadow: 0 0 0 8px rgba(181, 73, 46, 0); }
}
.ap-type {
  font-size: 11.5px; font-weight: 700; color: #8a6a3a;
  letter-spacing: .4px; white-space: nowrap;
}
.ap-unit {
  font-size: 11px; color: #a39170; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.ap-close {
  margin-left: auto; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid #e6d9bc; background: #fff; color: #9c8d68;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.ap-close:hover { background: #f4e7cc; color: var(--accent); border-color: #e0cba4; }

.ap-text { padding: 4px 2px 2px; min-height: 34px; }
.ap-en {
  font-family: 'Comic Sans MS', 'Segoe UI', sans-serif;
  font-size: 15.5px; font-weight: 600; color: #4a4234;
  line-height: 1.35; overflow-wrap: anywhere;
}
.ap-zh { font-size: 12.5px; color: #b08a2e; margin-top: 1px; }
.ap-zh:empty { display: none; }

.ap-seek { position: relative; margin: 6px 0 2px; }
.ap-seek input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 16px; background: transparent; cursor: pointer;
}
.ap-seek input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--p, 0%), #e9dfca var(--p, 0%));
}
.ap-seek input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; border: 2.5px solid var(--accent);
  margin-top: -4px; box-shadow: 0 1px 3px rgba(90,70,40,.3);
  transition: transform .12s;
}
.ap-seek input[type=range]:active::-webkit-slider-thumb { transform: scale(1.15); }
.ap-seek input[type=range]::-moz-range-track { height: 5px; border-radius: 3px; background: #e9dfca; }
.ap-seek input[type=range]::-moz-range-progress { height: 5px; border-radius: 3px; background: var(--accent); }
.ap-seek input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: #fff;
  border: 2.5px solid var(--accent);
}

.ap-bar { display: flex; align-items: center; gap: 6px; padding: 2px 0 1px; }
.ap-time {
  font-size: 11px; color: #9c8d68; font-variant-numeric: tabular-nums;
  min-width: 30px; text-align: center;
}
.ap-btn {
  flex: none; border: 1px solid #e6d9bc; background: #fff; color: #6b5a3a;
  border-radius: 50%; width: 32px; height: 32px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-family: inherit; padding: 0;
  transition: all .14s; position: relative;
}
.ap-btn b { font-size: 8.5px; font-weight: 700; }
.ap-btn:hover { background: #fdf3e0; border-color: #ddc9a0; color: var(--accent); }
.ap-btn:active { transform: scale(.94); }
.ap-play {
  width: 40px; height: 40px; font-size: 15px;
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 3px 10px rgba(181, 73, 46, .3);
}
.ap-play:hover { background: #a63f26; border-color: #a63f26; color: #fff; }
.ap-vol { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.ap-vol input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 62px; height: 16px; background: transparent; cursor: pointer;
}
.ap-vol input[type=range]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: #e9dfca;
}
.ap-vol input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 11px; height: 11px; border-radius: 50%;
  background: #fff; border: 2px solid #c3a878; margin-top: -3.5px;
}
.ap-vol input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: #e9dfca; }
.ap-vol input[type=range]::-moz-range-thumb {
  width: 10px; height: 10px; border: 2px solid #c3a878; background: #fff; border-radius: 50%;
}
.ap-btn.ap-small { width: 26px; height: 26px; font-size: 12px; }

/* 手机：铺满宽度，音量条收进第二行时也不挤 */
@media (max-width: 560px) {
  #audio-player { width: calc(100vw - 20px); padding: 9px 11px 7px; border-radius: 15px; }
  .ap-vol input[type=range] { width: 48px; }
  .ap-en { font-size: 14.5px; }
}
/* 标定模式下不需要播放器 */
body.calibrating #audio-player { display: none; }

/* ============================================================
   移动端适配（手机 / 平板 / 横屏 / 刘海安全区）
   ------------------------------------------------------------
   设计目标：
     1. 竖屏手机（375–430 宽）一屏能看完整对开页，顶栏不换行不溢出；
     2. iPhone 刘海 / 底部小黑条不遮挡任何按钮（env(safe-area-inset-*)）；
     3. 触控目标 ≥ 40px（成人拇指可靠点中），热区不因缩放而点不到；
     4. 播放器在手机上变成贴底整宽面板，不遮住课文主体；
     5. 视频 / 笔记 / 阅读弹窗在手机上铺满，横屏时用满高度。
   ============================================================ */

/* ---------- 0. 触屏通用：去掉点击高亮与双击缩放抖动 ---------- */
@media (hover: none) and (pointer: coarse) {
  html { -webkit-text-size-adjust: 100%; }
  body { -webkit-tap-highlight-color: transparent; }
  button, .icon-btn, .thumb, .nav-arrow, .lesson, .group-head, .hotspot {
    touch-action: manipulation;
  }
  /* 触屏上 hover 效果会在点击后「粘住」，改成 active 反馈 */
  .icon-btn:hover, .nav-arrow:hover, .thumb:hover, .lesson:hover {
    background: inherit; transform: none; color: inherit;
  }
  .icon-btn:active { background: var(--paper-deep); }
  .nav-arrow:hover { transform: translateY(-50%); }
  .thumb:hover { transform: none; }
}

/* ---------- 1. 平板 / 窄桌面（≤1024）：侧栏压窄 ---------- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 260px; }
  .book-area { padding: 16px 26px; }
}

/* ---------- 2. 手机横屏 / 矮屏：优先保证书页高度 ---------- */
@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --toolbar-h: 46px;
    --thumb-h: 0px;          /* 矮屏直接收起缩略图条 */
  }
  .thumb-bar { display: none; }
  .toolbar .brand .titles { display: none; }
  .book-area { padding: 6px 44px; }
  .nav-arrow { width: 34px; height: 34px; font-size: 15px; }
  #subtitle-bar { bottom: 12px; }
  #audio-player { bottom: 10px; }
}

/* ---------- 3. 手机竖屏（≤820） ---------- */
@media (max-width: 820px) {
  /* 安全区：顶栏让出刘海，缩略图条让出底部小黑条 */
  :root {
    --toolbar-h: calc(52px + env(safe-area-inset-top, 0px));
    --thumb-h: calc(84px + env(safe-area-inset-bottom, 0px));
  }
  .toolbar {
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }
  .thumb-bar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: max(10px, env(safe-area-inset-left, 0px));
    padding-right: max(10px, env(safe-area-inset-right, 0px));
  }

  /* 书区：左右留白压到最小，把宽度全给书页 */
  .book-area { padding: 10px 4px; }

  /* 翻页箭头：不压书页，靠边、半透明，点中区域保持 44px */
  .nav-arrow {
    width: 44px; height: 44px; font-size: 18px;
    background: rgba(255, 255, 255, .55);
    border-color: rgba(230, 220, 198, .8);
    box-shadow: 0 2px 8px rgba(90, 70, 40, .14);
    opacity: .72;
  }
  .nav-arrow.prev { left: 0; }
  .nav-arrow.next { right: 0; }
  .nav-arrow:active { opacity: 1; }

  /* 顶栏按钮：44px 触控高度（视觉 36） */
  .icon-btn { width: 36px; height: 36px; font-size: 16px; border-radius: 9px; }
  .toolbar { gap: 5px; }
  .toolbar .brand { gap: 8px; }
  .toolbar .brand .logo { width: 34px; height: 34px; font-size: 15px; }
  .page-indicator { gap: 4px; font-size: 11.5px; }
  .page-indicator b { font-size: 12.5px; }

  /* 缩略图：从 56×76 收到 44×60，能一屏看到更多页 */
  .thumb-bar { padding: 0 8px; gap: 6px; }
  .thumb { width: 44px; height: 60px; }
  .thumb .no { font-size: 8px; left: 2px; bottom: 1px; }

  /* 字幕条：贴缩略图条上方，左右留 12px，长句自动换行 */
  #subtitle-bar {
    bottom: calc(var(--thumb-h) + 10px);
    max-width: calc(100vw - 24px);
    padding: 8px 16px;
    border-radius: 14px;
  }
  #sub-en { font-size: 15px; line-height: 1.4; }
  #sub-zh { font-size: 12.5px; }

  /* 播放器：贴底整宽，按钮加大，音量条收窄 */
  #audio-player {
    width: calc(100vw - 16px);
    bottom: calc(var(--thumb-h) + 10px);
    padding: 9px 12px 7px;
    border-radius: 16px;
  }
  .ap-btn { width: 34px; height: 34px; font-size: 13px; border-radius: 9px; }
  .ap-btn.ap-play { width: 40px; height: 40px; font-size: 15px; }
  .ap-btn.ap-small { width: 30px; height: 30px; }
  .ap-vol input[type=range] { width: 54px; }
  .ap-en { font-size: 14.5px; }
  .ap-zh { font-size: 12px; }
  .ap-seek input[type=range] { height: 26px; }   /* 加大可拖动高度 */
  .ap-close { width: 30px; height: 30px; }

  /* 弹窗：手机上铺满，避免小尺寸内嵌页面出现双层滚动 */
  .modal { padding: 0; }
  .modal-box {
    width: 100vw !important; max-width: 100vw !important;
    height: 100dvh; max-height: 100dvh !important;
    border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-close { top: calc(8px + env(safe-area-inset-top, 0px)); }
  /* 视频在手机上尽量给足高度（横屏时几乎满屏） */
  #video-player { max-height: calc(100dvh - 120px); }
  .video-box h3 { padding: 14px 44px 14px 16px; font-size: 15px; }
  .doc-box h3 { padding: 12px 44px 12px 16px; font-size: 15px; }

  /* 侧栏抽屉：占 86% 宽，剩余部分点击可关 */
  .sidebar { width: min(86vw, 340px); }
  .sidebar.collapsed { margin-left: calc(-1 * min(86vw, 340px)); }
  .lesson { padding: 11px 16px 11px 26px; font-size: 14px; }
  .group-head { padding: 13px 16px; }

}

/* ---------- 4. 小屏手机（≤400）：进一步压缩顶栏文案 ---------- */
@media (max-width: 400px) {
  :root { --sidebar-w: 84vw; }
  .page-indicator { font-size: 11px; }
  .page-indicator span:first-child { max-width: 62px; overflow: hidden; white-space: nowrap; }
  .icon-btn { width: 34px; height: 34px; font-size: 15px; }
  .toolbar { gap: 4px; }
  .thumb { width: 40px; height: 55px; }
  #sub-en { font-size: 14px; }
}

/* ---------- 5. 体验模式相关规则统一放在文件末尾的「体验模式」段 ---------- */

/* ============================================================
   体验模式（口令页点「免费体验」后 由 auth-gate.js 加 body.trial-mode）
   ------------------------------------------------------------
   目的：锁页只是「防翻页」，但缩略图条会把 115 页全部铺开、
        目录能列出 8 个单元，等于把全书内容都摆出来了。
        所以体验模式下与 trial.html 保持一致：收起缩略图与目录，
        只留「第 N 页」不显示总页数。
   ⚠ 只用 CSS 隐藏，元素必须保留 —— book.js / hotspots.js
     初始化时会访问 #thumb-scroll、#toc、#page-total 等节点。
   ============================================================ */
body.trial-mode { --thumb-h: 0px; }            /* 缩略图收起 → 书区用满高度 */

/* 底部常驻横幅约 54px，书区底边留出这段，避免书页被横幅压住 */
body.trial-mode .layout        { bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }

body.trial-mode .thumb-bar     { display: none !important; }
body.trial-mode .sidebar       { display: none !important; }
body.trial-mode #btn-toc       { display: none !important; }

/* 只留当前页，不暴露总页数 */
body.trial-mode #page-total,
body.trial-mode .page-indicator > span:nth-child(2) { display: none !important; }

/* 底部常驻横幅高约 54px：字幕条 / 播放器整体上移让位 */
body.trial-mode #subtitle-bar { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }
body.trial-mode #audio-player { bottom: calc(70px + env(safe-area-inset-bottom, 0px)); }

/* ===== 用户档案切换（C 端用户独立存档） ===== */
.top-user{position:relative;display:inline-flex;align-items:center;margin-right:8px;font-family:system-ui,sans-serif}
.eu-badge{display:inline-flex;align-items:center;gap:6px;height:34px;padding:0 10px 0 4px;border:1px solid rgba(110,104,174,.35);background:rgba(255,255,255,.7);border-radius:999px;cursor:pointer;font-size:13px;color:var(--ink);white-space:nowrap}
.eu-avatar{width:26px;height:26px;border-radius:50%;background:linear-gradient(135deg,#6E68AE,#8E86D0);color:#fff;display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:13px}
.eu-name{max-width:80px;overflow:hidden;text-overflow:ellipsis}
.eu-caret{color:#999;font-size:11px}
.eu-panel{display:none;position:absolute;top:40px;right:0;z-index:200;width:220px;background:#fff;border:1px solid #e3e0f0;border-radius:14px;box-shadow:0 8px 28px rgba(0,0,0,.18);padding:14px;color:#333}
.eu-panel.show{display:block}
.eu-title{font-size:12px;color:#999;margin-bottom:8px}
.eu-row{display:flex;align-items:center;gap:8px;padding:8px;border-radius:9px;cursor:pointer;font-size:14px}
.eu-row:hover{background:#f4f2fb}
.eu-row.on{background:#efedfa;color:#5a54a0;font-weight:700}
.eu-dot{width:9px;height:9px;border-radius:50%;background:#d8d8e0}
.eu-row.on .eu-dot{background:#6E68AE}
.eu-rname{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.eu-check{color:#6E68AE}
.eu-add{display:flex;gap:6px;margin-top:10px;border-top:1px solid #eee;padding-top:10px}
.eu-input{flex:1;min-width:0;height:30px;border:1px solid #ccc;border-radius:8px;padding:0 9px;font-size:13px}
.eu-addbtn{height:30px;border:1px solid #6E68AE;background:#6E68AE;color:#fff;border-radius:8px;padding:0 11px;font-size:13px;cursor:pointer;white-space:nowrap}
@media(max-width:640px){.eu-name{max-width:56px}.eu-badge{height:32px}}

/* ===== 词汇页顶部双入口：单词游戏 + 单词自然拼读（同标签跳转，历史回退） ===== */
#book .page .entries-bar {
  position: absolute; left: 50%; top: 3.6%; transform: translateX(-50%);
  z-index: 65; display: inline-flex; align-items: center;
  gap: calc(10px * var(--hs-k, 1));
}
#book .page .entries-bar .game-entry {
  position: static; left: auto; top: auto; transform: none;
}
#book .page .entries-bar .game-entry:hover { transform: translateY(-2px); }
#book .page .entries-bar .game-entry:active { transform: scale(.96); }
#book .page .entries-bar .game-entry.phonic-entry {
  background: linear-gradient(135deg, #4f9c8f 0%, #2c7a70 100%);
  box-shadow: 0 calc(3px * var(--hs-k, 1)) calc(10px * var(--hs-k, 1)) rgba(44,122,112,.35);
}
