/* 小说站全局样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #faf8f5;
  --card-bg: #ffffff;
  --text: #2c2c2c;
  --text-light: #666;
  --accent: #d4a574;
  --accent-dark: #b8895a;
  --border: #e8e0d8;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 8px;
  --max-width: 960px;
  --reading-width: 720px;
  --font-size: 17px;
  --line-height: 2;
  --letter-spacing: 0.02em;
  --font-family: 'Georgia', 'Noto Serif SC', 'Source Han Serif CN', serif;
}

/* 夜间模式 */
[data-theme="dark"] {
  --bg: #1a1a2e;
  --card-bg: #16213e;
  --text: #e0e0e0;
  --text-light: #a0a0a0;
  --accent: #e2b07a;
  --accent-dark: #c89660;
  --border: #2a2a4a;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* 护眼模式 */
[data-theme="green"] {
  --bg: #c7edcc;
  --card-bg: #d4f2d8;
  --text: #2c3e2c;
  --text-light: #556b55;
  --accent: #6aab6a;
  --accent-dark: #4e8f4e;
  --border: #a8d8a8;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* 羊皮纸模式 */
[data-theme="sepia"] {
  --bg: #f5e6c8;
  --card-bg: #faf0dc;
  --text: #5b4636;
  --text-light: #8b7355;
  --accent: #c49a6c;
  --accent-dark: #a67c52;
  --border: #dcc8a0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* 淡蓝模式 */
[data-theme="blue"] {
  --bg: #e8f0fe;
  --card-bg: #f0f5ff;
  --text: #2c3e50;
  --text-light: #5a7a9a;
  --accent: #5b9bd5;
  --accent-dark: #4178b0;
  --border: #c0d8f0;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  line-height: 1.8;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* 导航栏 */
.navbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  transition: background 0.3s;
}
.navbar h1 { font-size: 20px; font-weight: 600; color: var(--text); }
.navbar h1 a { color: inherit; text-decoration: none; }
.navbar nav { display: flex; align-items: center; gap: 16px; }
.navbar nav a {
  color: var(--text-light);
  text-decoration: none;
  font-size: 14px;
}
.navbar nav a:hover { color: var(--accent-dark); }

/* 主题切换按钮 */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text);
  transition: background 0.15s;
}
.theme-toggle:hover { background: var(--bg); }

/* 字号控制 */
.font-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.font-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 10px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.15s;
}
.font-btn:hover { background: var(--bg); }

/* 容器 */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px;
}

/* 书架网格 */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
}
.book-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s, background 0.3s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.book-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}
.book-card h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.book-card .meta { font-size: 13px; color: var(--text-light); margin-bottom: 8px; }
.book-card .desc {
  font-size: 14px;
  color: var(--text-light);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 章节目录 */
.book-header {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: background 0.3s;
}
.book-header h2 { font-size: 24px; margin-bottom: 8px; }
.book-header .author { color: var(--text-light); font-size: 14px; margin-bottom: 12px; }
.book-header .desc { color: var(--text-light); font-size: 15px; line-height: 1.6; }

.chapter-list {
  list-style: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background 0.3s;
}
.chapter-list li { border-bottom: 1px solid var(--border); }
.chapter-list li:last-child { border-bottom: none; }
.chapter-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.chapter-list a:hover { background: rgba(128,128,128,0.08); }
.chapter-list .chapter-title { font-size: 15px; }
.chapter-list .chapter-meta { font-size: 12px; color: var(--text-light); }

/* 阅读页 */
.reader {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 32px 24px;
}
.reader h2 {
  font-size: 22px;
  text-align: center;
  margin-bottom: 32px;
  color: var(--text);
}
.reader-content {
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  text-indent: 2em;
  letter-spacing: var(--letter-spacing);
  text-align: justify;
}
/* 阅读工具栏 */
.reader-toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
/* 阅读进度条 */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--accent);
  z-index: 999;
  transition: width 0.1s;
}
/* 导航 */
.reader-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.reader-nav a, .reader-nav span {
  color: var(--accent-dark);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 0.15s;
}
.reader-nav a:hover { background: rgba(128,128,128,0.08); }
.reader-nav .disabled { color: #999; pointer-events: none; border-color: var(--border); opacity: 0.5; }

/* 面包屑 */
.breadcrumb {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--accent-dark); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { margin: 0 6px; }

/* 返回顶部 */
.back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 998;
  transition: opacity 0.3s;
}
.back-to-top.visible { display: flex; }
.back-to-top:hover { background: var(--accent-dark); }

/* 管理后台 */
.admin-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: background 0.3s;
}
.admin-section h3 {
  font-size: 16px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 4px;
}
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}
.form-group textarea { min-height: 200px; resize: vertical; }
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  margin-right: 8px;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger { background: #e74c3c; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-top: 12px;
  font-size: 14px;
}
.msg-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.msg-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
[data-theme="dark"] .msg-success { background: #1a3a2a; color: #8fd4a4; border-color: #2a5a3a; }
[data-theme="dark"] .msg-error { background: #3a1a1a; color: #f4a0a0; border-color: #5a2a2a; }

/* 管理列表 */
.admin-list { list-style: none; }
.admin-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.admin-list li:last-child { border-bottom: none; }
.admin-list .item-info { flex: 1; }
.admin-list .item-title { font-size: 15px; color: var(--text); }
.admin-list .item-meta { font-size: 12px; color: var(--text-light); margin-top: 2px; }
.admin-list .item-actions { display: flex; gap: 6px; }

/* 空状态 */
.empty { text-align: center; padding: 60px 20px; color: var(--text-light); }
.empty p { font-size: 16px; margin-bottom: 8px; }

/* 加载状态 */
.loading { text-align: center; padding: 40px; color: var(--text-light); }

/* 404页面 */
.error-page { text-align: center; padding: 80px 20px; }
.error-page h2 { font-size: 72px; color: var(--accent); margin-bottom: 16px; }
.error-page p { font-size: 18px; color: var(--text-light); margin-bottom: 24px; }

/* 阅读设置面板 */
.settings-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 1000; display: none;
  align-items: flex-end; justify-content: center;
}
.settings-overlay.active { display: flex; }
.settings-panel {
  background: var(--card-bg); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 600px; padding: 20px 24px 32px;
  max-height: 70vh; overflow-y: auto;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  transition: background 0.3s;
}
.settings-panel h3 {
  font-size: 16px; margin-bottom: 20px; text-align: center;
  color: var(--text); position: relative;
}
.settings-panel .close-btn {
  position: absolute; right: 0; top: -2px; background: none;
  border: none; font-size: 20px; cursor: pointer; color: var(--text-light);
}
.setting-row {
  margin-bottom: 18px;
}
.setting-label {
  font-size: 13px; color: var(--text-light); margin-bottom: 8px; display: block;
}
.theme-options {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.theme-dot {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--border);
  cursor: pointer; transition: transform 0.15s, border-color 0.15s; position: relative;
}
.theme-dot:hover { transform: scale(1.1); }
.theme-dot.active { border-color: var(--accent); border-width: 3px; }
.theme-dot[data-theme="light"] { background: #faf8f5; }
.theme-dot[data-theme="dark"] { background: #1a1a2e; }
.theme-dot[data-theme="green"] { background: #c7edcc; }
.theme-dot[data-theme="sepia"] { background: #f5e6c8; }
.theme-dot[data-theme="blue"] { background: #e8f0fe; }
.font-options {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.font-option {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-size: 14px; color: var(--text); background: var(--bg);
  transition: border-color 0.15s, background 0.15s;
}
.font-option:hover { border-color: var(--accent); }
.font-option.active { border-color: var(--accent); background: var(--accent); color: #fff; }
.slider-row {
  display: flex; align-items: center; gap: 12px;
}
.slider-row input[type="range"] {
  flex: 1; accent-color: var(--accent); height: 4px;
}
.slider-row .slider-val {
  font-size: 13px; color: var(--text-light); min-width: 40px; text-align: right;
}

/* 阅读底部工具栏 */
.reader-bottom-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card-bg); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: center;
  padding: 8px 0; z-index: 999;
  transform: translateY(100%); transition: transform 0.3s, background 0.3s;
  max-width: 600px; margin: 0 auto;
}
.reader-bottom-bar.visible { transform: translateY(0); }
.bar-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer; color: var(--text-light);
  font-size: 12px; padding: 4px 12px; transition: color 0.15s;
}
.bar-btn:hover, .bar-btn:active { color: var(--accent); }
.bar-btn .bar-icon { font-size: 20px; }

/* 继续阅读卡片 */
.continue-reading {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px;
  color: #fff; text-decoration: none; display: flex;
  align-items: center; justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(212,165,116,0.3);
}
.continue-reading:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(212,165,116,0.4); }
.continue-info { flex: 1; }
.continue-info .continue-label { font-size: 12px; opacity: 0.85; margin-bottom: 4px; }
.continue-info .continue-title { font-size: 16px; font-weight: 600; }
.continue-info .continue-chapter { font-size: 13px; opacity: 0.85; margin-top: 2px; }
.continue-arrow { font-size: 24px; opacity: 0.8; }

/* 搜索框 */
.search-bar {
  display: flex; gap: 8px; margin-bottom: 20px;
}
.search-bar input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; background: var(--card-bg);
  color: var(--text); transition: background 0.3s, border-color 0.15s;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }
.search-bar button {
  padding: 10px 18px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); cursor: pointer;
  font-size: 14px; transition: background 0.15s;
}
.search-bar button:hover { background: var(--accent-dark); }
.search-results { margin-bottom: 20px; }
.search-results .result-item {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 8px;
  text-decoration: none; display: block; color: var(--text);
  transition: background 0.15s;
}
.search-results .result-item:hover { background: rgba(128,128,128,0.08); }
.search-results .result-book { font-size: 12px; color: var(--text-light); }
.search-results .result-title { font-size: 15px; margin: 4px 0; }
.search-results .result-snippet { font-size: 13px; color: var(--text-light); }
.search-results .result-snippet mark { background: rgba(212,165,116,0.3); color: inherit; padding: 0 2px; border-radius: 2px; }

/* 章节目录浮层 */
.toc-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 1001; display: none;
  align-items: center; justify-content: center;
}
.toc-overlay.active { display: flex; }
.toc-panel {
  background: var(--card-bg); border-radius: var(--radius);
  width: 90%; max-width: 400px; max-height: 70vh;
  display: flex; flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.toc-panel h3 {
  padding: 16px 20px; margin: 0; font-size: 16px;
  border-bottom: 1px solid var(--border); color: var(--text);
}
.toc-list {
  list-style: none; overflow-y: auto; flex: 1; padding: 0; margin: 0;
}
.toc-list li a {
  display: block; padding: 10px 20px; color: var(--text);
  text-decoration: none; font-size: 14px; border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.toc-list li a:hover { background: rgba(128,128,128,0.08); }
.toc-list li a.current { color: var(--accent); font-weight: 600; }

/* 响应式 */
@media (max-width: 640px) {
  .book-grid { grid-template-columns: 1fr; }
  .reader { padding: 20px 16px; }
  .reader-content { font-size: calc(var(--font-size) - 1px); }
  .navbar { padding: 12px 16px; }
  .navbar h1 { font-size: 17px; }
  .navbar nav { gap: 10px; }
  .navbar nav a { font-size: 13px; }
  .container { padding: 16px; }
  .book-header { padding: 16px; }
  .book-header h2 { font-size: 20px; }
  .chapter-list a { padding: 12px 16px; }
  .reader-toolbar { flex-wrap: wrap; gap: 8px; }
  .reader-nav { flex-direction: column; gap: 10px; }
  .reader-nav a, .reader-nav span { text-align: center; width: 100%; }
  .admin-list li { flex-direction: column; align-items: flex-start; gap: 8px; }
  .admin-list .item-actions { width: 100%; }
  .back-to-top { bottom: 20px; right: 20px; width: 38px; height: 38px; font-size: 16px; }
  .reader-bottom-bar { max-width: 100%; }
  .settings-panel { padding: 16px 16px 24px; }
  .back-to-top.has-bar { bottom: 70px; }
}
.back-to-top.has-bar { bottom: 80px; }
