/* ==================== 课本页面 ==================== */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f4f6fb;
  color: #333;
}

.header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 18px 0;
  position: relative;
}
.header-inner { max-width: 860px; margin: 0 auto; padding: 0 60px; text-align: center; }
.header h1 { margin: 0; font-size: 22px; }
.header p { margin: 4px 0 0; font-size: 13px; opacity: 0.9; }
.btn-back-home {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  color: #fff; text-decoration: none; font-size: 14px; font-weight: 600;
  background: rgba(255,255,255,0.2); padding: 6px 14px; border-radius: 12px;
}
.btn-back-home:hover { background: rgba(255,255,255,0.35); }

/* 学科切换 */
.tb-subject-tabs {
  max-width: 860px; margin: 14px auto 0; padding: 0 16px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.tb-subject-tab {
  text-decoration: none;
  padding: 8px 16px; border-radius: 16px;
  font-size: 14px; font-weight: 700; color: #555;
  background: #fff; border: 2px solid transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.tb-subject-tab:hover { background: #f0f2fb; }
.tb-subject-tab.active {
  background: #667eea; color: #fff; border-color: #667eea;
}

/* 年级选择 */
.tb-grade-pills {
  max-width: 860px; margin: 12px auto 0; padding: 0 16px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.tb-grade-pill {
  background: #f0f2f8; border: 2px solid transparent; border-radius: 16px;
  padding: 6px 14px; font-size: 13px; font-weight: 600; color: #555; cursor: pointer;
}
.tb-grade-pill:hover { background: #e4e7f2; }
.tb-grade-pill.active { background: #667eea; color: #fff; border-color: #667eea; }

/* 学期切换 */
.tb-semester-tabs {
  max-width: 860px; margin: 10px auto 0; padding: 0 16px;
  display: flex; gap: 8px;
}
.tb-sem-tab {
  background: #fff; border: 2px solid transparent; border-radius: 16px;
  padding: 5px 14px; font-size: 13px; font-weight: 600; color: #555; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.tb-sem-tab.active { background: #10b981; color: #fff; border-color: #10b981; }

/* 语速 */
.tb-rate-pills {
  max-width: 860px; margin: 10px auto 0; padding: 0 16px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.tb-rate-label { font-size: 13px; color: #888; }
.tb-rate-pill {
  background: #f0f2f8; border: 2px solid transparent; border-radius: 14px;
  padding: 4px 12px; font-size: 13px; font-weight: 600; color: #555; cursor: pointer;
}
.tb-rate-pill.active { background: #10b981; color: #fff; border-color: #10b981; }

/* 单元导航（旧，隐藏） */
.tb-unit-list { display: none; }

/* 主体布局：左目录 + 右课文 */
.tb-layout {
  max-width: 1000px; margin: 14px auto 40px; padding: 0 16px;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

/* 左侧目录 */
.tb-toc {
  background: #fff; border-radius: 14px; padding: 14px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  position: sticky; top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
.tb-toc__title {
  font-size: 15px; font-weight: 700; color: #333;
  padding: 0 8px 10px; border-bottom: 1px solid #f0f0f5; margin-bottom: 8px;
}
.tb-toc__list { display: flex; flex-direction: column; gap: 2px; }
.tb-toc-unit { margin-bottom: 2px; }
.tb-toc-unit__name {
  width: 100%; text-align: left; border: none; background: none;
  padding: 7px 8px; font-size: 13.5px; font-weight: 700; color: #555;
  cursor: pointer; border-radius: 8px;
}
.tb-toc-unit__name:hover { background: #f0f2fb; }
.tb-toc-unit.open .tb-toc-unit__name { color: #8b5cf6; }
.tb-toc-unit__items { display: flex; flex-direction: column; padding-left: 10px; gap: 1px; }
.tb-toc-lesson {
  width: 100%; text-align: left; border: none; background: none;
  padding: 5px 10px; font-size: 13px; color: #666;
  cursor: pointer; border-radius: 8px;
}
.tb-toc-lesson:hover { background: #f5f3ff; }
.tb-toc-lesson.active { background: #ede9fe; color: #6d28d9; font-weight: 700; }

/* 右侧内容 */
.tb-content { min-width: 0; }

/* 本课重点提示 */
.tb-tips {
  margin-top: 10px;
  background: #fef9e7;
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  padding: 12px 14px;
}
.tb-tips__title {
  font-size: 14px; font-weight: 700; color: #b45309; margin-bottom: 4px;
}
.tb-tips__text { font-size: 14px; color: #7d6608; line-height: 1.8; }

/* 本课词语表 */
.tb-words-box {
  margin-top: 10px;
  background: #f5f8ff;
  border: 1px solid #dbe6ff;
  border-radius: 10px;
  padding: 12px 14px;
}
.tb-words-box__header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; font-weight: 700; color: #2b6cb0;
  margin-bottom: 8px; flex-wrap: wrap; gap: 6px;
}
.tb-speak--small { padding: 5px 12px; font-size: 12.5px; }
.tb-lesson-words { display: flex; flex-wrap: wrap; gap: 6px; }
.tb-lesson-word {
  border: none; background: #fff; border-radius: 14px;
  padding: 5px 12px; font-size: 13.5px; color: #444;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: all 0.15s;
}
.tb-lesson-word:hover {
  background: #8b5cf6; color: #fff;
  transform: translateY(-1px);
}

/* 听写面板 */
.tb-dict-btn {
  border: none; border-radius: 16px; padding: 5px 12px;
  background: linear-gradient(135deg, #f59e0b 0%, #e67e22 100%);
  color: #fff; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.tb-dict-btn:hover { opacity: 0.92; }
.tb-dict-panel { margin-top: 10px; }
.tb-dict {
  background: #fffdf5;
  border: 1px dashed #f0c26b;
  border-radius: 12px;
  padding: 14px;
}
.tb-dict__title {
  font-size: 15px; font-weight: 700; color: #b45309; margin-bottom: 10px;
}
.tb-dict__settings {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px;
}
.tb-dict__label { font-size: 13px; color: #888; }
.tb-dict-opt {
  border: none; background: #f5f0e0; border-radius: 12px;
  padding: 4px 12px; font-size: 13px; color: #7d6608; cursor: pointer;
}
.tb-dict-opt:hover { background: #f0e6c8; }
.tb-dict-opt.active { background: #f59e0b; color: #fff; }
.tb-dict-start {
  width: 100%; border: none; border-radius: 14px; padding: 10px;
  background: linear-gradient(135deg, #f59e0b 0%, #e67e22 100%);
  color: #fff; font-size: 14.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 10px rgba(245, 158, 11, 0.3);
}
.tb-dict__progress {
  font-size: 15px; color: #444; text-align: center; margin-bottom: 8px;
}
.tb-dict__progress b { color: #e67e22; font-size: 18px; }
.tb-dict__hint {
  text-align: center; font-size: 13px; color: #999; margin-bottom: 10px;
}
.tb-dict__controls {
  display: flex; justify-content: center; gap: 8px; margin-bottom: 10px;
}
.tb-dict__answers {
  background: #fff; border-radius: 10px; padding: 10px 12px;
  font-size: 14px; color: #333; line-height: 1.9;
}

@media (max-width: 760px) {
  .tb-layout { grid-template-columns: 1fr; }
  .tb-toc { position: static; max-height: 300px; }
}
.tb-empty {
  text-align: center; color: #aaa; padding: 50px 0; font-size: 15px;
}

/* 语文/英语内容卡片 */
.tb-card {
  background: #fff; border-radius: 14px; padding: 16px 18px;
  margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.tb-card__header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tb-card__icon { font-size: 20px; }
.tb-card__title { font-size: 16px; font-weight: 700; color: #333; }
.tb-card__author { font-size: 12px; color: #999; }
.tb-text { font-size: 15.5px; line-height: 2; color: #444; }
.tb-text p { margin: 0 0 10px; text-indent: 2em; }

/* ==================== 古诗：按课本版式排版 ==================== */
.tb-card--poem .tb-card__header {
  flex-direction: column; align-items: center; gap: 2px; margin-bottom: 14px;
}
.tb-card--poem .tb-card__icon { display: none; }
.tb-card--poem .tb-card__title { font-size: 19px; letter-spacing: 2px; }
.tb-card--poem .tb-card__author { font-size: 13px; color: #888; }
.tb-poem {
  text-align: center;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", "楷体", serif;
  font-size: 19px; line-height: 2.2; color: #333;
  letter-spacing: 2px; margin: 4px 0 16px;
}
.tb-poem__line {
  margin: 0; padding: 2px 4px; border-radius: 6px;
  cursor: pointer; transition: background 0.15s;
}
.tb-poem__line:hover { background: #f5f3ff; }

/* ==================== 英文课本：对话气泡排版 ==================== */
.tb-dialogue--en { display: flex; flex-direction: column; gap: 12px; margin: 14px 0; }
.tb-dialog-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.7;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  position: relative;
  color: #333;
}
.tb-dialog-bubble--left {
  align-self: flex-start;
  background: #f6f4ff;
  border: 2px solid #ddd6fe;
  border-bottom-left-radius: 4px;
}
.tb-dialog-bubble--right {
  align-self: flex-end;
  background: #eef2ff;
  border: 2px solid #c7d2fe;
  border-bottom-right-radius: 4px;
}
.tb-dialog-bubble__avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.tb-dialog-bubble--left .tb-dialog-bubble__avatar { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.tb-dialog-bubble--right .tb-dialog-bubble__avatar { background: linear-gradient(135deg, #818cf8, #6366f1); }
.tb-dialog-bubble__body { min-width: 0; }
.tb-dialog-bubble__speaker {
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 2px;
}
.tb-dialog-bubble--left .tb-dialog-bubble__speaker { color: #7c3aed; }
.tb-dialog-bubble--right .tb-dialog-bubble__speaker { color: #4f46e5; }
/* 英文短文排版：不缩进、段间距（英语课本风格） */
.tb-text--en p { text-indent: 0; margin: 0 0 14px; }
.tb-text--en { font-size: 16px; line-height: 1.9; }
/* 英文课文：句子/气泡点击朗读 */
.tb-sentence {
  cursor: pointer;
  border-radius: 6px;
  padding: 1px 3px;
  transition: background 0.15s;
}
.tb-sentence:hover { background: #ede9fe; }
.tb-click-line { margin: 0 0 10px; }
.tb-dialog-bubble { cursor: pointer; }
.tb-dialog-bubble:hover { box-shadow: 0 3px 10px rgba(109, 40, 217, 0.18); }
.tb-rate-hint { font-size: 12px; color: #999; margin-left: 8px; }
.tb-dialogue { margin-bottom: 10px; }
.tb-dialogue__line { font-size: 15px; line-height: 2; color: #444; }
.tb-dialogue__speaker { font-weight: 700; color: #8b5cf6; margin-right: 6px; }
.tb-words { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tb-word {
  background: #f5f6fb; border-radius: 10px; padding: 6px 12px;
  display: flex; gap: 8px; align-items: center;
  cursor: pointer; border: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.tb-word:hover {
  background: #ede9fe; border-color: #8b5cf6; transform: translateY(-1px);
}
.tb-word__en { font-size: 14px; font-weight: 600; color: #4c1d95; }
.tb-word__zh { font-size: 13px; color: #777; }
.tb-speak {
  border: none; border-radius: 18px; padding: 7px 16px;
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #fff; font-size: 13.5px; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 10px rgba(109, 40, 217, 0.3);
}
.tb-speak:hover { opacity: 0.92; }

/* 数学单元 */
.tb-math-unit {
  background: #fff; border-radius: 14px; padding: 16px 18px;
  margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.tb-math-unit__title {
  font-size: 16px; font-weight: 700; color: #2b6cb0;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid #e8eef7;
}
.tb-math-points { margin: 0; padding-left: 18px; }
.tb-math-points li { font-size: 14.5px; color: #444; line-height: 1.9; margin-bottom: 4px; }
.tb-math-example {
  margin-top: 10px; background: #fef9e7; border-left: 3px solid #f59e0b;
  border-radius: 8px; padding: 10px 14px; font-size: 14px; color: #7d6608; line-height: 1.9;
}

.tb-vocab-tab { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.tb-vocab-tab.active { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.tb-vocab-box {
  background: #fff; border-radius: 14px; padding: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.tb-vocab-box__header {
  font-size: 16px; font-weight: 700; color: #333;
  margin-bottom: 10px;
}

@media (max-width: 600px) {
  .header-inner { padding: 0 40px; }
  .tb-text { font-size: 14.5px; }
  .tb-poem { font-size: 17px; letter-spacing: 1px; }
}

/* 听写中隐藏单词的提示条 */
.tb-dict-hiding-note {
  background: #fdf2e9;
  border: 1.5px dashed #e67e22;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  color: #b45309;
  margin: 10px 0;
  text-align: center;
}

/* 单词标签拼读按钮 */
.tb-lesson-word-wrap {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.tb-lesson-spell {
  border: none;
  background: #ede9fe;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.tb-lesson-spell:hover { background: #8b5cf6; transform: scale(1.1); }
/* 单词表卡片拼读按钮 */
.tb-word__spell {
  border: none;
  background: #ede9fe;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 11px;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
  transition: all 0.15s;
}
.tb-word__spell:hover { background: #8b5cf6; transform: scale(1.1); }
