/* 小说阅读器样式 - 移动端优先 */

/* ===== 主题系统（通过 body class 切换） ===== */

/* 默认：羊皮纸 */
body {
  --bg-color: #f5f0e8;
  --text-color: #3a3a3a;
  --text-size: 18px;
  --line-height: 1.8;
  --primary: #8b5e3c;
  --primary-light: #a67c52;
  --header-bg: #faf8f5;
  --border: #e8e0d6;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  font-size: var(--text-size);
  line-height: var(--line-height);
  -webkit-font-smoothing: antialiased;
}

/* 纯白 */
body.theme-white {
  --bg-color: #ffffff;
  --text-color: #333333;
  --header-bg: #fafafa;
  --border: #e0e0e0;
  --primary: #8b5e3c;
  --primary-light: #a67c52;
}

/* 护眼绿 */
body.theme-green {
  --bg-color: #cce8cc;
  --text-color: #2d4a2d;
  --header-bg: #d4ecd4;
  --border: #a8d0a8;
  --primary: #3d7a3d;
  --primary-light: #5a9a5a;
}

/* 淡蓝 */
body.theme-blue {
  --bg-color: #d4e8f0;
  --text-color: #2c4a5a;
  --header-bg: #dcecf4;
  --border: #b0d0e0;
  --primary: #3a7a8a;
  --primary-light: #5a9aaa;
}

/* 夜间 */
body.theme-dark {
  --bg-color: #1a1a1a;
  --text-color: #c8c8c8;
  --header-bg: #222222;
  --border: #333333;
  --primary: #c8a06e;
  --primary-light: #d4b082;
}

body.theme-dark .toc-search input {
  background: #2a2a2a;
  border-color: #444;
  color: #c8c8c8;
}

/* ===== 头部导航 ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--primary);
}

.header-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: var(--primary);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.header-btn:active {
  background: rgba(139, 94, 60, 0.1);
}

/* ===== 阅读区域 ===== */
.reader-area {
  position: absolute;
  top: 51px;
  left: 0;
  right: 0;
  bottom: 52px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px 40px;
}

.reader-area.toc-open {
  overflow-y: hidden;
}

.chapter-title {
  font-size: calc(var(--text-size) + 4px);
  font-weight: 700;
  text-align: center;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.chapter-content {
  font-size: var(--text-size);
  line-height: var(--line-height);
  text-align: justify;
  word-wrap: break-word;
  letter-spacing: 0.5px;
}

.chapter-content p {
  text-indent: 0;
  margin-bottom: 0;
}

.chapter-content br {
  display: block;
  content: "";
  margin: 8px 0;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 15px;
}

.loading .spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

.error {
  text-align: center;
  padding: 40px 20px;
  color: #c0392b;
  font-size: 15px;
}

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 52px;
  background: var(--header-bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--primary);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.2s;
}

.nav-btn:active {
  background: rgba(139, 94, 60, 0.1);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-btn .icon {
  font-size: 18px;
  line-height: 1;
}

/* ===== 目录面板 ===== */
.toc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.toc-overlay.active {
  opacity: 1;
  visibility: visible;
}

.toc-panel {
  position: fixed;
  top: 0;
  right: -85%;
  width: 85%;
  max-width: 360px;
  height: 100%;
  background: var(--header-bg);
  z-index: 201;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0,0,0,0.1);
}

.toc-panel.active {
  right: 0;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.toc-header h2 {
  font-size: 16px;
  color: var(--primary);
}

/* 排序切换按钮 */
.toc-sort-btn {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg-color);
  color: var(--primary);
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  margin-left: auto;
  margin-right: 8px;
  line-height: 1.4;
}

.toc-sort-btn:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 刷新按钮 */
.toc-refresh-btn {
  font-size: 16px;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  background: var(--bg-color);
  color: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toc-refresh-btn:active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.toc-refresh-btn.loading {
  opacity: 0.6;
  cursor: not-allowed;
  animation: spin 0.8s linear infinite;
}

.toc-search {
  padding: 10px 16px;
  flex-shrink: 0;
}

/* 最后阅读跳转条 */
.toc-last-read-bar {
  padding: 0 16px 8px;
  flex-shrink: 0;
}

.toc-jump-btn {
  width: 100%;
  padding: 7px 0;
  border: 1px dashed var(--primary);
  background: rgba(139, 94, 60, 0.06);
  color: var(--primary);
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.toc-jump-btn:active {
  background: rgba(139, 94, 60, 0.15);
}

.toc-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--bg-color);
  color: var(--text-color);
}

.toc-search input:focus {
  border-color: var(--primary);
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0;
}

.toc-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text-color);
}

.toc-item:active {
  background: rgba(139, 94, 60, 0.08);
}

.toc-item.active {
  color: var(--primary);
  font-weight: 600;
  background: rgba(139, 94, 60, 0.06);
}

.toc-item .chapter-num {
  min-width: 48px;
  font-size: 12px;
  color: #999;
  flex-shrink: 0;
}

.toc-item .chapter-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 最后阅读章节标记 */
.toc-item .last-read-mark {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  margin-left: 6px;
  flex-shrink: 0;
  line-height: 1.5;
}

.toc-item.last-read {
  background: rgba(139, 94, 60, 0.08);
}

.toc-item.last-read .chapter-num {
  color: var(--primary);
  font-weight: 600;
}

.toc-loading {
  text-align: center;
  padding: 20px;
  color: #999;
  font-size: 14px;
}

/* ===== 设置面板 ===== */
.settings-overlay {
  position: fixed;
  bottom: 52px;
  left: 0;
  right: 0;
  background: var(--header-bg);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding: 16px;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

.settings-overlay.active {
  transform: translateY(0);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.settings-row:last-child {
  margin-bottom: 0;
}

.settings-label {
  font-size: 14px;
  color: #666;
  flex-shrink: 0;
  min-width: 60px;
}

.settings-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.font-size-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-color);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.font-size-btn:active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.font-size-display {
  min-width: 36px;
  text-align: center;
  font-size: 14px;
  color: var(--primary);
  font-weight: 600;
}

.theme-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-btn[data-theme="bg-yellow"] { background: #f5f0e8; border-color: #d4c8a0; }
.theme-btn[data-theme="bg-white"]  { background: #ffffff; border-color: #ccc; }
.theme-btn[data-theme="bg-green"]  { background: #cce8cc; border-color: #8ab88a; }
.theme-btn[data-theme="bg-blue"]   { background: #d4e8f0; border-color: #90b8c8; }
.theme-btn[data-theme="bg-dark"]   { background: #2c2c2c; border-color: #555; }

.theme-btn.active {
  border-color: var(--primary);
  transform: scale(1.1);
}

/* ===== 进度显示 ===== */
.progress-bar {
  height: 3px;
  background: var(--border);
  position: fixed;
  top: 48px;
  left: 0;
  right: 0;
  z-index: 99;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.3s;
  width: 0%;
}

/* ===== 滚动条美化 ===== */
.reader-area::-webkit-scrollbar,
.toc-list::-webkit-scrollbar {
  width: 4px;
}

.reader-area::-webkit-scrollbar-track,
.toc-list::-webkit-scrollbar-track {
  background: transparent;
}

.reader-area::-webkit-scrollbar-thumb,
.toc-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}



