/* 小说站全局样式 */
* { 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;
}

/* 夜间模式 */
[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);
}

body {
  font-family: 'Georgia', 'Noto Serif SC', 'Source Han Serif CN', serif;
  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: 2;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
  text-indent: 2em;
  letter-spacing: 0.02em;
}
/* 阅读工具栏 */
.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; }

/* 响应式 */
@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; }
}
