/**
 * 统一样式文件 - 目录页面和章节页面共用
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei",
    "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
  line-height: 1.6;
  color: #2c3e50;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  backdrop-filter: blur(10px);
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 60px 50px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

header h1 {
  font-size: 3em;
  margin-bottom: 15px;
  font-weight: 700;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  position: relative;
  z-index: 1;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 1.3em;
  opacity: 0.95;
  font-weight: 300;
  position: relative;
  z-index: 1;
}

/* 面包屑导航 */
.breadcrumb {
  padding: 20px 50px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-bottom: 1px solid #e9ecef;
  font-size: 0.95em;
}

.breadcrumb a {
  color: #667eea;
  text-decoration: none;
  transition: all 0.3s ease;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
}

.breadcrumb a:hover {
  color: #5568d3;
  background: rgba(102, 126, 234, 0.1);
}

.breadcrumb .separator {
  margin: 0 12px;
  color: #bbb;
}

.breadcrumb .current {
  color: #495057;
  font-weight: 600;
}

.chapter-list {
  padding: 50px;
  background: #ffffff;
}

.chapter-list ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 24px;
  padding: 0;
}

.empty-message {
  text-align: center;
  padding: 80px 20px;
  color: #6c757d;
  font-size: 1.2em;
}

/* 书籍卡片样式 */
.directory-item {
  background: #ffffff;
  border: none;
  border-radius: 16px;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border-left: 6px solid #667eea;
}

.directory-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
  transition: width 0.4s ease;
}

.directory-item::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.05) 0%,
    rgba(118, 75, 162, 0.05) 100%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
}

.directory-item:hover {
  transform: translateY(-8px) translateX(4px);
  box-shadow: 0 12px 40px rgba(102, 126, 234, 0.25);
  border-left-color: #5568d3;
}

.directory-item:hover::before {
  width: 10px;
}

.directory-item:hover::after {
  opacity: 1;
}

/* 书籍项样式 */
.book-item {
  background: linear-gradient(135deg, #fff8f0 0%, #ffffff 100%);
  border: 2px solid #e8e5e0;
  border-left: 5px solid #8b7355;
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 3px 12px rgba(139, 115, 85, 0.15);
}

.book-item:hover {
  border-left-color: #6b5d4f;
  background: linear-gradient(135deg, #fefcf9 0%, #fff8f0 100%);
  transform: translateX(5px);
  box-shadow: 0 8px 25px rgba(139, 115, 85, 0.25);
}

.book-item:hover .item-icon {
  transform: scale(1.15) rotate(5deg);
  filter: drop-shadow(0 6px 12px rgba(139, 115, 85, 0.3));
}

/* 章节项样式 */
.chapter-item {
  background: #ffffff;
  border: 1px solid #e9ecef;
  border-left: 4px solid #28a745;
  border-radius: 12px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.chapter-item:hover {
  border-left-color: #218838;
  background: linear-gradient(135deg, #f0fff4 0%, #ffffff 100%);
  transform: translateX(4px);
  box-shadow: 0 6px 20px rgba(40, 167, 69, 0.2);
}

.item-link {
  display: flex;
  align-items: center;
  padding: 24px 28px;
  text-decoration: none;
  color: #2c3e50;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

.item-link:hover {
  color: #667eea;
}

.item-icon {
  font-size: 2.2em;
  margin-right: 20px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.15));
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.directory-item:hover .item-icon {
  transform: scale(1.2) rotate(10deg);
  filter: drop-shadow(0 6px 12px rgba(102, 126, 234, 0.4));
}

.item-title {
  flex: 1;
  font-size: 1.15em;
  line-height: 1.6;
  font-weight: 500;
  color: #2c3e50;
}

.directory-item .item-title {
  font-weight: 600;
  color: #1a1a1a;
  font-size: 1.2em;
}

.item-count {
  font-size: 0.9em;
  color: #667eea;
  background: linear-gradient(135deg, #e8f0fe 0%, #f0f4ff 100%);
  padding: 10px 16px;
  border-radius: 25px;
  margin-left: 15px;
  font-weight: 600;
  border: 2px solid rgba(102, 126, 234, 0.2);
  white-space: nowrap;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.directory-item:hover .item-count {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  transform: scale(1.1);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* 级别卡片样式 */
.level-cards-container {
  padding: 50px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 30px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.level-card {
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
  border: 2px solid transparent;
  position: relative;
}

.level-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(
    --card-gradient,
    linear-gradient(135deg, #667eea 0%, #764ba2 100%)
  );
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s ease;
}

.level-card:hover::before {
  transform: scaleX(1);
}

.level-card:hover {
  transform: translateY(-15px) scale(1.03);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.2);
  border-color: var(--card-color, #667eea);
}

.level-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.level-card-header {
  background: var(
    --card-gradient,
    linear-gradient(135deg, #667eea 0%, #764ba2 100%)
  );
  padding: 35px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  position: relative;
  overflow: hidden;
}

.level-card-header::before {
  content: "";
  position: absolute;
  top: -100%;
  right: -100%;
  width: 300%;
  height: 300%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.15) 0%,
    transparent 70%
  );
  transition: transform 0.8s ease;
}

.level-card:hover .level-card-header::before {
  transform: rotate(45deg) translate(50%, 50%);
}

.level-badge {
  font-size: 2em;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.3);
  padding: 12px 24px;
  border-radius: 30px;
  backdrop-filter: blur(15px);
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  transition: all 0.4s ease;
}

.level-card:hover .level-badge {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.level-icon {
  font-size: 3.5em;
  opacity: 0.95;
  filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.25));
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.level-card:hover .level-icon {
  transform: scale(1.15) rotate(10deg);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.35));
}

.level-card-body {
  padding: 35px 30px;
  background: #ffffff;
}

.level-title {
  font-size: 1.5em;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 25px;
  line-height: 1.4;
  min-height: 70px;
  display: flex;
  align-items: center;
}

.level-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  padding: 25px 0;
  border-top: 2px solid #f0f0f0;
  border-bottom: 2px solid #f0f0f0;
  background: linear-gradient(135deg, #fafbfc 0%, #ffffff 100%);
  border-radius: 12px;
  margin: 0 -10px;
  padding: 25px 10px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.stat-value {
  font-size: 2.5em;
  font-weight: bold;
  color: var(--card-color, #667eea);
  line-height: 1;
  text-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
  transition: transform 0.3s ease;
}

.level-card:hover .stat-value {
  transform: scale(1.1);
}

.stat-label {
  font-size: 0.95em;
  color: #6c757d;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-divider {
  color: #dee2e6;
  font-weight: 300;
  font-size: 2em;
  opacity: 0.5;
}

.level-card-footer {
  padding: 25px 30px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  text-align: center;
  border-top: 1px solid #f0f0f0;
}

.enter-text {
  color: var(--card-color, #667eea);
  font-weight: 600;
  font-size: 1.05em;
  transition: all 0.4s ease;
  display: inline-block;
  padding: 8px 16px;
  border-radius: 20px;
  background: rgba(102, 126, 234, 0.1);
}

.level-card:hover .enter-text {
  transform: translateX(10px);
  background: rgba(102, 126, 234, 0.2);
  padding: 8px 20px;
}

/* 上次阅读卡片样式 */
.last-read-card .level-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.last-read-card .level-card-header {
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.last-read-card:hover .level-card-header {
  border-color: rgba(255, 255, 255, 0.5);
}

footer {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  padding: 30px;
  text-align: center;
  color: #6c757d;
  font-size: 0.95em;
  border-top: 1px solid #e9ecef;
}

/* ========== 章节页面样式 ========== */
.navigation {
  margin-bottom: 20px;
  padding: 15px 20px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nav-button {
  display: inline-block;
  padding: 12px 24px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  text-decoration: none;
  border-radius: 8px;
  margin-right: 10px;
  transition: all 0.3s ease;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.nav-button:hover {
  background: linear-gradient(135deg, #5568d3 0%, #6a4190 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.reader-container {
  max-width: 900px;
  margin: 0 auto;
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.content {
  font-size: 1.1em;
  line-height: 1.8;
  color: #333;
}

.content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px auto;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.content p {
  margin-bottom: 1em;
}

.chapter-nav {
  margin-top: 40px;
  padding-top: 30px;
  border-top: 2px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.nav-link {
  display: inline-block;
  padding: 12px 24px;
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  color: #667eea;
  text-decoration: none;
  border-radius: 8px;
  border: 2px solid #e9ecef;
  transition: all 0.3s ease;
  font-weight: 500;
  flex: 1;
  text-align: center;
  max-width: 300px;
}

.nav-link:hover {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.nav-link.prev {
  text-align: left;
}

.nav-link.next {
  text-align: right;
}

/* EPUB原始样式保留 */
body {
  word-wrap: break-word;
}

p {
  margin-top: 1em;
  text-indent: 0em;
}

.title1 {
  font-size: 1.8em;
  font-weight: bold;
  margin-top: 0.2em;
  margin-bottom: 1em;
  text-align: center;
}

.title1A {
  font-size: 2.5em;
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 1em;
  text-align: center;
}

.title2 {
  font-size: 1.5em;
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 1em;
  text-align: center;
}

.title3 {
  font-size: 1.3em;
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 1em;
  text-align: center;
}

.title4 {
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 1em;
  text-align: center;
}

.title5 {
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 1em;
}

.title6 {
  font-size: 0.85em;
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 1em;
  text-align: center;
}

.subtitle {
  font-size: 1.3em;
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 0.5em;
  text-indent: 0em;
}

.subtitle1 {
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  text-align: center;
}

.subtitle1A {
  font-size: 1.3em;
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 0.5em;
  text-indent: 0em;
}

.subtitle2 {
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  text-indent: 0em;
}

.subtitle2A {
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  text-indent: 0em;
}

.subtitle2B {
  font-size: 1.2em;
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 1em;
  text-indent: 2em;
}

.subtitle3 {
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  text-indent: 0em;
}

.normaltext {
  text-indent: 2em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.normaltext02 {
  text-indent: 0em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

.mulu {
  font-size: 1.8em;
  font-weight: bold;
  text-align: center;
  margin-top: 1em;
  margin-bottom: 1em;
}

.mulu1 {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  text-indent: 0em;
}

.mulu1 a {
  color: #667eea;
  text-decoration: none;
  transition: color 0.3s ease;
}

.mulu1 a:hover {
  color: #5568d3;
  text-decoration: underline;
}

.picture {
  text-align: center;
  margin: 20px 0;
}

.picture img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.underline {
  text-decoration: underline;
}

.xt {
  font-style: italic;
  color: #666;
}

/* 兼容旧的类名 */
.chapter-link {
  display: flex;
  align-items: center;
  padding: 20px;
  text-decoration: none;
  color: #333;
  transition: color 0.3s ease;
}

.chapter-link:hover {
  color: #667eea;
}

.chapter-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 50%;
  font-weight: bold;
  margin-right: 15px;
  flex-shrink: 0;
}

.chapter-title {
  flex: 1;
  font-size: 1em;
  line-height: 1.4;
}

/* 响应式设计 */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  header {
    padding: 40px 25px;
  }

  header h1 {
    font-size: 2em;
  }

  .subtitle {
    font-size: 1.1em;
  }

  .chapter-list {
    padding: 30px 20px;
  }

  .chapter-list ul {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .item-link {
    padding: 18px 20px;
  }

  .level-cards-container {
    grid-template-columns: 1fr;
    padding: 30px 20px;
    gap: 25px;
  }

  .level-card-header {
    padding: 25px 20px;
  }

  .level-title {
    font-size: 1.2em;
    min-height: auto;
  }

  .stat-value {
    font-size: 2em;
  }

  .breadcrumb {
    padding: 15px 20px;
    font-size: 0.85em;
  }

  .level-badge {
    font-size: 1.5em;
    padding: 10px 20px;
  }

  .level-icon {
    font-size: 2.5em;
  }

  .reader-container {
    padding: 20px;
  }

  .navigation {
    padding: 12px 15px;
  }

  .nav-button {
    padding: 10px 18px;
    font-size: 13px;
    margin-right: 8px;
  }

  .chapter-nav {
    flex-direction: column;
    gap: 15px;
  }

  .nav-link {
    max-width: 100%;
    width: 100%;
  }
}

/* ========== 书籍单页阅读模式样式 - 电子书阅读器风格 ========== */
.book-reader-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #f5f3f0; /* 护眼的米黄色背景 */
}

.book-header {
  background: linear-gradient(
    135deg,
    #8b7355 0%,
    #6b5d4f 100%
  ); /* 书籍风格的棕色 */
  color: #f5f3f0;
  padding: 25px 40px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.book-header h1 {
  font-size: 1.8em;
  margin-bottom: 12px;
  font-weight: 600;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", serif;
}

.book-header .breadcrumb {
  background: transparent;
  padding: 0;
  border: none;
  font-size: 0.85em;
}

.book-header .breadcrumb a {
  color: rgba(245, 243, 240, 0.9);
  text-decoration: none;
  transition: color 0.3s ease;
}

.book-header .breadcrumb a:hover {
  color: #fff;
}

.book-header .breadcrumb .separator {
  color: rgba(245, 243, 240, 0.6);
  margin: 0 10px;
}

.book-header .breadcrumb .current {
  color: rgba(245, 243, 240, 0.9);
}

.book-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
  /* 确保布局容器不会与固定定位的侧边栏冲突 */
  z-index: 0;
}

.book-sidebar {
  width: 280px;
  background: #faf8f5; /* 浅米黄色侧边栏 */
  border-right: 2px solid #e8e5e0;
  overflow-y: auto;
  position: fixed; /* 使用fixed实现真正的固定定位，不随页面滚动 */
  top: 0; /* 从顶部开始，会被header覆盖，但通过padding-top留出空间 */
  left: 0; /* 固定在左侧 */
  height: 100vh; /* 全屏高度 */
  max-height: 100vh; /* 限制最大高度 */
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.08);
  z-index: 5; /* 降低z-index，确保不覆盖内容区域（header的z-index是100，内容区域默认是0，这里设为5确保在内容之上但不覆盖header） */
  /* 为header留出空间，header高度约120px（25px padding-top + 1.8em h1 + 12px margin + 0.85em breadcrumb + 25px padding-bottom） */
  padding-top: 120px;
  box-sizing: border-box;
  /* 确保侧边栏不会超出视口 */
  max-width: 280px;
}

.book-toc {
  padding: 25px 20px;
}

.book-toc h3 {
  font-size: 1.2em;
  margin-bottom: 20px;
  color: #5a4a3a;
  font-weight: 600;
  border-bottom: 2px solid #8b7355;
  padding-bottom: 12px;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", serif;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  margin-bottom: 6px;
}

.toc-link {
  display: block;
  padding: 10px 15px;
  color: #5a4a3a;
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.3s ease;
  font-size: 0.9em;
  line-height: 1.5;
  border-left: 3px solid transparent;
}

.toc-link:hover {
  background: #f0ede8;
  color: #8b7355;
  border-left-color: #8b7355;
  transform: translateX(3px);
}

.toc-link:active,
.toc-link:focus {
  background: #e8e5e0;
  color: #6b5d4f;
  border-left-color: #6b5d4f;
}

/* 当前章节高亮 */
.toc-link[href*="#chapter-"]:target,
.toc-link.active {
  background: #e8e5e0;
  color: #6b5d4f;
  border-left-color: #6b5d4f;
  font-weight: 500;
}

.book-content {
  flex: 1;
  overflow-y: auto;
  background: #fefcf9; /* 接近纸张的白色，带一点暖色调 */
  /* 为固定侧边栏留出左侧空间 */
  margin-left: 280px;
  /* 内容区域宽度：减去侧边栏宽度 */
  width: calc(100% - 280px);
  /* 内容区域内部使用flex布局实现内容居中 */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 50px 0; /* 上下内边距，左右内边距由内部内容控制 */
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.03);
  /* 确保内容区域可以正常滚动 */
  min-height: 100vh;
  /* 确保内容区域在侧边栏之上（如果需要） */
  position: relative;
  z-index: 1; /* 内容区域的z-index，确保在侧边栏之上（如果侧边栏z-index是5，这里设为1即可，因为内容区域在文档流中） */
}

.chapter-section {
  margin-bottom: 50px;
  padding-bottom: 35px;
  border-bottom: 1px solid #e8e5e0;
  scroll-margin-top: 20px; /* 平滑滚动时的偏移 */
}

/* 内容区域内部的章节区域，限制最大宽度并保持左右内边距，实现内容居中 */
.book-content > .chapter-section {
  max-width: 900px;
  width: 100%;
  padding-left: 80px; /* 左右内边距，保持原有的阅读体验 */
  padding-right: 80px;
  box-sizing: border-box;
}

.chapter-section:last-child {
  border-bottom: none;
}

.chapter-title {
  font-size: 1.8em;
  font-weight: 600;
  color: #3d3428;
  margin-bottom: 25px;
  padding-bottom: 12px;
  border-bottom: 2px solid #8b7355;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", serif;
  line-height: 1.4;
}

.chapter-content {
  font-size: 1.05em; /* 舒适的阅读字体大小 */
  line-height: 1.9; /* 宽松的行距，提升阅读体验 */
  color: #3d3428;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "SimSun",
    serif;
  text-align: justify;
  text-justify: inter-ideograph; /* 中文两端对齐 */
}

.chapter-content p {
  margin-bottom: 1.3em;
  text-indent: 2em; /* 中文段落首行缩进 */
  text-align: justify;
  word-spacing: 0.1em;
}

.chapter-content p:first-child {
  text-indent: 0; /* 段落开头不缩进 */
}

.chapter-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 30px auto;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  border: 1px solid #e8e5e0;
}

.chapter-content h1,
.chapter-content h2,
.chapter-content h3,
.chapter-content h4,
.chapter-content h5,
.chapter-content h6 {
  margin-top: 35px;
  margin-bottom: 18px;
  color: #3d3428;
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", serif;
  font-weight: 600;
  line-height: 1.4;
}

.chapter-content h1 {
  font-size: 1.6em;
  border-bottom: 2px solid #8b7355;
  padding-bottom: 10px;
}

.chapter-content h2 {
  font-size: 1.4em;
}

.chapter-content h3 {
  font-size: 1.2em;
}

/* 优化列表样式 */
.chapter-content ul,
.chapter-content ol {
  margin: 1.3em 0;
  padding-left: 2em;
  line-height: 1.9;
}

.chapter-content li {
  margin-bottom: 0.8em;
}

/* 优化表格样式 */
.chapter-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 25px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chapter-content table th,
.chapter-content table td {
  padding: 12px;
  border: 1px solid #e8e5e0;
  text-align: left;
}

.chapter-content table th {
  background: #f0ede8;
  font-weight: 600;
  color: #3d3428;
}

/* 平滑滚动 */
html {
  scroll-behavior: smooth;
}

/* 响应式设计 - 书籍阅读模式 */
@media (max-width: 1024px) {
  .book-sidebar {
    width: 240px;
    padding-top: 120px; /* 保持header空间 */
  }

  .book-content {
    padding: 40px 0; /* 上下内边距，左右内边距由内部内容控制 */
    margin-left: 240px; /* 调整为侧边栏宽度 */
    width: calc(100% - 240px); /* 减去侧边栏宽度 */
  }

  /* 中等屏幕下，章节内容的内边距适当减小 */
  .book-content > .chapter-section {
    padding-left: 50px;
    padding-right: 50px;
  }
}

@media (max-width: 768px) {
  .book-layout {
    flex-direction: column;
  }

  .book-sidebar {
    width: 100%;
    height: auto;
    max-height: 300px;
    position: relative; /* 移动端不使用fixed */
    left: auto; /* 取消fixed定位 */
    top: auto; /* 取消fixed定位 */
    padding-top: 0; /* 移动端不需要为header留空间 */
    border-right: none;
    border-bottom: 2px solid #e8e5e0;
  }

  .book-content {
    padding: 30px 0; /* 上下内边距，左右内边距由内部内容控制 */
    margin-left: 0; /* 移动端不需要左边距 */
    width: 100%; /* 移动端全宽 */
    align-items: stretch; /* 移动端内容区域全宽，不居中 */
  }

  /* 移动端章节内容的内边距 */
  .book-content > .chapter-section {
    padding-left: 25px;
    padding-right: 25px;
    max-width: 100%; /* 移动端不限制最大宽度 */
  }

  .book-header {
    padding: 20px 25px;
  }

  .book-header h1 {
    font-size: 1.4em;
  }

  .chapter-title {
    font-size: 1.5em;
  }

  .chapter-content {
    font-size: 1em;
    line-height: 1.8;
  }

  .chapter-content p {
    text-indent: 1.5em;
  }
}
