﻿/* ===== 基础 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #1f6f5c;
  --primary-dark: #17564a;
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #22262b;
  --muted: #8a919c;
  --border: #e5e8ec;
  --danger: #d64545;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  /* 语义色（浅色主题） */
  --surface-2: var(--surface-2);      /* 次级背景：排序栏、徽章底、占位底 */
  --surface-3: var(--surface-3);      /* 投票按钮等 */
  --hover: var(--hover);          /* 行悬停 / 回复条 */
  --input-bg: #ffffff;
  --danger-bg: var(--danger-bg);
  --success-bg: var(--success-bg);
  --info-bg: var(--info-bg);
  --tag-bg: var(--tag-bg);
  --disabled-text: var(--disabled-text);
  --intro-text: var(--intro-text);
  /* 背景图占位（自行添加 public/uploads/bg/background.jpg 后全站生效） */
  --bg-overlay: rgba(245,246,248,.78);
  --bg-overlay-dark: rgba(18,20,24,.86);
}
/* ===== 黑夜模式（用户可切换，localStorage 持久化） ===== */
html.dark {
  --primary: #53c9a7;
  --primary-dark: #7adcbd;
  --bg: #14171c;
  --card: #1e232a;
  --text: #e6e9ed;
  --muted: #9aa3ae;
  --border: #2e3540;
  --danger: #ef7d7d;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --surface-2: #272d35;
  --surface-3: #2a313a;
  --hover: #242b33;
  --input-bg: #171b21;
  --danger-bg: #3a2326;
  --success-bg: #1c332c;
  --info-bg: #202c3d;
  --tag-bg: #1d2f2a;
  --disabled-text: #5c6570;
  --intro-text: #aeb6c0;
  color-scheme: dark;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg);
  /* 背景占位：图片未放置时仅显示渐变遮罩；放置 public/uploads/bg/background.jpg 后自动全站生效 */
  background-image: linear-gradient(var(--bg-overlay), var(--bg-overlay)), url('/uploads/bg/background.jpg');
  background-size: auto, cover;
  background-position: center;
  background-repeat: repeat, no-repeat;
  background-attachment: scroll, fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
html.dark body {
  background-image: linear-gradient(var(--bg-overlay-dark), var(--bg-overlay-dark)), url('/uploads/bg/background.jpg');
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 24px; padding-bottom: 40px; }
.muted { color: var(--muted); font-size: 13px; }

/* ===== 顶栏 ===== */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.header-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.logo { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: 1px; }
.logo span { color: var(--primary); }
.main-nav { display: flex; gap: 18px; }
.nav-link { color: var(--text); font-size: 15px; padding: 4px 2px; border-bottom: 2px solid transparent; }
.nav-link:hover { color: var(--primary); border-bottom-color: var(--primary); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.header-search { display: flex; align-items: center; }
.header-search input, .inline-search input {
  width: 180px; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius); outline: none; font-size: 14px;
}
.header-search input:focus, .inline-search input:focus { border-color: var(--primary); }
.header-search button, .inline-search button {
  padding: 7px 14px; border: 1px solid var(--primary); background: var(--primary);
  color: #fff; border-radius: 0 var(--radius) var(--radius) 0; cursor: pointer; font-size: 14px;
}
.auth-links { display: flex; gap: 10px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.mini-avatar {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-size: 13px; overflow: hidden; flex: none;
}
.default-avatar { background: linear-gradient(135deg, #1f6f5c, #4a9c84); }
.link-btn {
  background: none; border: none; color: var(--primary); cursor: pointer;
  font-size: 14px; padding: 2px 4px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.link-title { color: var(--text); }
.link-title:hover { color: var(--primary); }
.inline-form { display: inline; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius); border: 1px solid transparent;
  font-size: 14px; cursor: pointer; background: var(--surface-2); color: var(--text);
  transition: all .15s; text-align: center; line-height: 1.4;
}
.btn:hover { opacity: .92; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-disabled { background: var(--surface-2); color: var(--disabled-text); cursor: not-allowed; }
.btn.liked { background: #ffe9e9; color: var(--danger); border-color: var(--danger); }
.btn:disabled { background: var(--surface-2); color: var(--disabled-text); cursor: not-allowed; }

/* ===== 表单 ===== */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; font-weight: 500; }
.field input, .field textarea, .field select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; outline: none; font-family: inherit; background: var(--input-bg); width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); }
.field textarea { resize: vertical; line-height: 1.7; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.form-actions { display: flex; gap: 12px; margin-top: 6px; }
.auth-card {
  max-width: 420px; margin: 40px auto; background: var(--card);
  border-radius: 14px; box-shadow: var(--shadow); padding: 32px;
}
.auth-card h1 { font-size: 22px; margin-bottom: 20px; text-align: center; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.auth-alt a { color: var(--primary); }
.form-card {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 24px; max-width: 720px;
}
.form-card .field textarea { font-size: 15px; }
.form-card .field input[type="file"] { padding: 6px; }

/* ===== 提示 ===== */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-success { background: var(--success-bg); color: var(--primary-dark); }
.alert-info { background: var(--info-bg); color: #2c5ca8; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.empty-tip {
  text-align: center; padding: 60px 20px; color: var(--muted); background: var(--card);
  border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  align-items: center; gap: 16px;
}

/* ===== 首页 ===== */
.section-title { font-size: 19px; font-weight: 700; margin: 28px 0 16px; display: flex; align-items: baseline; gap: 10px; }
.section-title small { font-size: 13px; color: var(--muted); font-weight: 400; }
.recommend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.recommend-card {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 18px 20px;
}
.recommend-card h3 { font-size: 15px; margin-bottom: 12px; }
.rank-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.rank-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.rank-num {
  width: 22px; height: 22px; border-radius: 6px; background: var(--surface-2); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none;
}
.rank-1 { background: #ffe9d6; color: #c9761b; }
.rank-2 { background: #eceff3; color: #66707c; }
.rank-3 { background: #f3e3d8; color: #a3613a; }
.rank-title { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-title:hover { color: var(--primary); }
.rank-meta { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; }

.library-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.library-toolbar .section-title { margin: 20px 0 0; }
.toolbar-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.sort-tabs { display: flex; background: var(--surface-2); border-radius: var(--radius); padding: 3px; }
.sort-tabs a {
  padding: 6px 16px; border-radius: 8px; font-size: 14px; color: var(--muted);
}
.sort-tabs a.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.inline-search { display: flex; }

.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px; margin-top: 18px;
}
.book-card {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s;
}
.book-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.book-cover { position: relative; aspect-ratio: 3 / 4; background: var(--surface-2); overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #1f6f5c, #3d8a74); color: rgba(255,255,255,.9);
  font-size: 20px; font-weight: 600; letter-spacing: 2px;
}
.cover-placeholder.large { font-size: 34px; }
.status-badge {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.62); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 20px;
}
.status-badge.static { position: static; background: var(--surface-2); color: var(--muted); padding: 3px 10px; }
.status-badge.static.finished { background: var(--success-bg); color: var(--primary-dark); }
.book-info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.book-title { font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-author { font-size: 12px; color: var(--muted); }
.book-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tag {
  font-size: 11px; color: var(--primary); background: var(--tag-bg); padding: 2px 8px; border-radius: 12px;
}
.book-meta { margin-top: auto; display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 28px 0 10px; font-size: 14px; color: var(--muted); }

/* ===== 书籍详情 ===== */
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.book-detail {
  display: flex; gap: 28px; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow); padding: 26px; flex-wrap: wrap;
}
.detail-cover { width: 220px; flex: none; }
.detail-cover img, .detail-cover .cover-placeholder {
  width: 220px; aspect-ratio: 3 / 4; border-radius: 10px; object-fit: cover;
}
.detail-info { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 12px; }
.detail-title { font-size: 26px; font-weight: 700; }
.detail-author { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.author-line { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.detail-tags { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.detail-intro { font-size: 14px; color: var(--intro-text); white-space: pre-wrap; }
.detail-stats { display: flex; gap: 28px; margin-top: 4px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat b { font-size: 18px; }
.stat span { font-size: 12px; color: var(--muted); }
.detail-actions { display: flex; gap: 12px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.chapter-section { margin-top: 30px; }
.chapter-list {
  list-style: none; background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden;
}
.chapter-list li { border-bottom: 1px solid var(--border); }
.chapter-list li:last-child { border-bottom: none; }
.chapter-list a {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: var(--text); font-size: 14px;
}
.chapter-list a:hover { background: var(--hover); color: var(--primary); }
.chapter-no { color: var(--muted); font-size: 13px; min-width: 30px; }

/* ===== 阅读页 ===== */
.read-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 16px 24px;
  flex-wrap: wrap;
}
.read-title h1 { font-size: 18px; }
.read-title h2 { font-size: 15px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.read-back { font-size: 14px; }
.read-meta { font-size: 13px; color: var(--muted); }
.read-content {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 34px 40px; margin-top: 16px; min-height: 60vh;
  font-family: Georgia, "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: 17px; line-height: 2; word-break: break-word;
}
.read-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }

/* ===== 个人中心 ===== */
.profile-layout { display: grid; grid-template-columns: 1fr 240px; gap: 20px; }
.profile-card {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 26px;
}
.profile-head { display: flex; gap: 18px; align-items: center; margin-bottom: 22px; }
.profile-head h1 { font-size: 22px; }
.avatar-large {
  width: 72px; height: 72px; border-radius: 50%; overflow: hidden; flex: none;
  background: linear-gradient(135deg, #1f6f5c, #4a9c84); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.avatar-large img { width: 100%; height: 100%; object-fit: cover; }
.sub-title { font-size: 16px; margin: 26px 0 14px; padding-top: 18px; border-top: 1px solid var(--border); }
.sub-title:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.profile-side { display: flex; flex-direction: column; gap: 12px; align-self: start; }

/* ===== 作家后台 ===== */
.author-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 10px 0 20px; flex-wrap: wrap; }
.author-head h1 { font-size: 22px; }
.author-head h1 small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.head-actions { display: flex; gap: 10px; }
.table-wrap { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 700px; }
.data-table th {
  text-align: left; padding: 12px 16px; background: var(--hover); color: var(--muted);
  font-weight: 500; font-size: 13px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--hover); }
.cell-book { display: flex; align-items: center; gap: 10px; color: var(--text); }
.cell-title { font-weight: 500; }
.cell-book:hover .cell-title { color: var(--primary); }
.cell-cover { width: 36px; height: 48px; object-fit: cover; border-radius: 5px; flex: none; background: var(--surface-2); }
.placeholder-sm {
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px;
  color: #fff; background: linear-gradient(160deg, #1f6f5c, #3d8a74);
}
.cell-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.stat-strip {
  display: flex; gap: 12px; flex-wrap: wrap; background: var(--card);
  border-radius: 14px; box-shadow: var(--shadow); padding: 16px 22px; margin-bottom: 18px;
}
.stat-strip .stat { flex: 1; min-width: 100px; }
.cover-preview { width: 48px; height: 64px; object-fit: cover; border-radius: 5px; display: inline-block; vertical-align: middle; margin-left: 6px; }

/* ===== 错误页 ===== */
.error-card {
  max-width: 460px; margin: 80px auto; text-align: center; background: var(--card);
  border-radius: 14px; box-shadow: var(--shadow); padding: 40px; display: flex;
  flex-direction: column; gap: 14px; align-items: center;
}
.error-card h1 { font-size: 24px; }
.error-card p { color: var(--muted); }

/* ===== 页脚 ===== */
.site-footer {
  background: var(--card); border-top: 1px solid var(--border);
  padding: 18px 0; text-align: center; color: var(--muted); font-size: 13px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .recommend-grid { grid-template-columns: 1fr; }
  .header-search { display: none; }
  .book-detail { flex-direction: column; }
  .detail-cover, .detail-cover img, .detail-cover .cover-placeholder { width: 100%; max-width: 220px; }
  .profile-layout { grid-template-columns: 1fr; }
  .read-content { padding: 22px 18px; font-size: 16px; }
  .field-row { flex-direction: column; }
  .book-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* ===== 站点统计条 ===== */
.site-stats {
  display: flex; gap: 12px; background: var(--card); border-radius: 14px;
  box-shadow: var(--shadow); padding: 16px 22px; margin-bottom: 8px; flex-wrap: wrap;
}
.site-stats .stat { flex: 1; min-width: 90px; }

/* ===== 评论 ===== */
.comment-section { margin-top: 30px; }
.comment-form {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px;
}
.comment-form textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; font-size: 14px; font-family: inherit; resize: vertical; outline: none;
}
.comment-form textarea:focus { border-color: var(--primary); }
.comment-form-foot { display: flex; justify-content: flex-end; }
.comment-login-tip { margin: 8px 0 16px; font-size: 13px; }
.comment-login-tip a { color: var(--primary); }
.comment-list { display: flex; flex-direction: column; gap: 12px; }
.empty-comment { text-align: center; color: var(--muted); padding: 28px 0; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); font-size: 14px; }
.comment-item, .reply-item {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px;
}
.comment-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.comment-author { font-size: 13px; font-weight: 600; }
.comment-time { font-size: 12px; color: var(--muted); margin-left: auto; }
.comment-content { font-size: 14px; line-height: 1.7; word-break: break-word; margin-bottom: 8px; }
.comment-actions { display: flex; gap: 6px; align-items: center; }
.vote-btn {
  background: var(--surface-3); border: 1px solid transparent; border-radius: 20px;
  padding: 3px 10px; font-size: 12px; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; gap: 4px;
}
.vote-btn:hover { border-color: var(--border); }
.vote-btn.active { background: var(--success-bg); color: var(--primary-dark); border-color: #bfe3d5; }
.vote-btn.active-down { background: var(--danger-bg); color: var(--danger); border-color: #f0c4c4; }
.reply-box { margin-top: 8px; }
.reply-box.hidden { display: none; }
.reply-form { display: flex; gap: 8px; }
.reply-form input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; outline: none; }
.reply-form input:focus { border-color: var(--primary); }
.reply-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.reply-item { background: var(--hover); box-shadow: none; border: 1px solid var(--border); }
.reply-item .comment-content { margin-bottom: 6px; }
.comment-new {
  animation: fadeIn .3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ===== 管理后台 ===== */
.admin-nav { display: flex; gap: 6px; background: var(--surface-2); border-radius: var(--radius); padding: 3px; flex-wrap: wrap; }
.admin-nav a { padding: 6px 14px; border-radius: 8px; font-size: 13px; color: var(--muted); }
.admin-nav a.active { background: var(--card); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.admin-stats { margin-bottom: 8px; }
.admin-quick .sub-title { border: none; margin-bottom: 12px; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.quick-card {
  background: var(--card); border-radius: 12px; box-shadow: var(--shadow); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 4px; color: var(--text);
}
.quick-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,.08); transform: translateY(-2px); }
.quick-card b { font-size: 15px; }
.quick-card span { font-size: 12px; color: var(--muted); }
.filter-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.filter-tabs a {
  padding: 7px 18px; border-radius: 20px; background: var(--card); color: var(--muted);
  font-size: 13px; box-shadow: var(--shadow);
}
.filter-tabs a.active { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 8px; }
.role-badge { font-size: 12px; padding: 2px 10px; border-radius: 12px; white-space: nowrap; }
.role-badge.super { background: #fdf0e3; color: #b96a12; }
.role-badge.admin { background: #e8f0fb; color: #2c5ca8; }
.role-badge.user { background: var(--surface-2); color: var(--muted); }
.status-badge.static.pending { background: #fdf6e0; color: #a07b10; }
.status-badge.static.rejected { background: var(--danger-bg); color: var(--danger); }
.audit-note { font-size: 11px; color: var(--danger); margin-top: 2px; max-width: 180px; }
.perm-details { position: relative; display: inline-block; }
.perm-details summary { cursor: pointer; list-style: none; }
.perm-details summary::-webkit-details-marker { display: none; }
.perm-form {
  position: absolute; right: 0; top: 100%; z-index: 30; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
  padding: 12px; min-width: 200px; display: flex; flex-direction: column; gap: 8px; margin-top: 4px;
}
.perm-form input[type="text"], .perm-form textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: inherit; width: 100%;
}
.perm-check { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.perm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.comment-cell { max-width: 360px; word-break: break-word; }

/* ===== 黑夜模式：特殊元素覆盖 ===== */
html.dark .rank-1 { background: #4a3417; color: #e8a84e; }
html.dark .rank-2 { background: #2b313a; color: #98a2ad; }
html.dark .rank-3 { background: #3d2b20; color: #cd8f63; }
html.dark .role-badge.super { background: #4a3417; color: #e8a84e; }
html.dark .role-badge.admin { background: #22334a; color: #7fb0e8; }
html.dark .role-badge.user { background: var(--surface-2); color: var(--muted); }
html.dark .status-badge.static.pending { background: #45391d; color: #d9b45c; }
html.dark .status-badge.static.rejected { background: var(--danger-bg); color: var(--danger); }
html.dark .btn.liked { background: #46272a; color: var(--danger); border-color: var(--danger); }
html.dark .vote-btn.active { background: var(--success-bg); border-color: #1e4a3c; }
html.dark .vote-btn.active-down { background: var(--danger-bg); border-color: #57303a; }
html.dark .cover-placeholder { background: linear-gradient(160deg, #185244, #2e6b5b); }
html.dark .default-avatar, html.dark .avatar-large { background: linear-gradient(135deg, #185244, #2e6b5b); }
html.dark .placeholder-sm { background: linear-gradient(160deg, #185244, #2e6b5b); }
html.dark .tag { background: var(--tag-bg); color: var(--primary); }
html.dark .alert-error { background: var(--danger-bg); }
html.dark .alert-success { background: var(--success-bg); }
html.dark .alert-info { background: var(--info-bg); color: #8fb4e8; }
html.dark .perm-form input[type="text"], html.dark .perm-form textarea,
html.dark .reply-form input { background: var(--input-bg); }
html.dark .data-table th { background: #1a1f26; }
html.dark .read-content { background: var(--card); }
html.dark .chapter-list a:hover { background: var(--hover); }

/* ===== 移动端适配 ===== */
@media (max-width: 768px) {
  .header-inner { gap: 12px; }
  .main-nav { gap: 12px; }
  .nav-link { font-size: 14px; }
  .header-right { gap: 8px; }
  .site-stats { padding: 12px 14px; }
  .book-grid { gap: 12px; }
  .read-header { padding: 12px 14px; }
  .read-nav { flex-wrap: wrap; }
  .read-nav .btn { flex: 1; min-width: 90px; }
  .comment-actions { flex-wrap: wrap; }
  .reply-form { flex-direction: column; }
  .reply-form .btn { align-self: flex-end; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 560px) {
  .container { padding: 0 10px; }
  .header-inner { height: 54px; gap: 8px; }
  .logo { font-size: 16px; letter-spacing: .5px; }
  .main-nav { gap: 10px; }
  .nav-link { font-size: 13px; }
  .header-right { gap: 6px; }
  .header-right .btn { padding: 5px 10px; font-size: 13px; }
  .auth-links { gap: 6px; }
  .nickname { display: none; }            /* 小屏只显示头像 */
  .user-menu { gap: 6px; }
  .site-stats .stat b { font-size: 16px; }
  .site-stats .stat span { font-size: 11px; }
  .book-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .book-title { font-size: 14px; }
  .book-info { padding: 10px 10px 12px; }
  .section-title { font-size: 17px; }
  .recommend-grid { gap: 10px; }
  .detail-stats { gap: 18px; }
  .stat b { font-size: 16px; }
  .read-content { padding: 18px 14px; font-size: 15.5px; line-height: 1.9; }
  .comment-item, .reply-item { padding: 12px; }
  .data-table { min-width: 620px; }      /* 表格保持横向滚动 */
  .perm-form { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); width: 260px; }
  .author-head { flex-direction: column; align-items: flex-start; }
  .author-head .head-actions, .author-head .admin-nav { width: 100%; }
  .admin-nav a { flex: 1; text-align: center; padding: 6px 8px; font-size: 12px; }
  .quick-grid { grid-template-columns: 1fr; }
  .filter-tabs { flex-wrap: wrap; }
  .error-card { margin: 40px auto; padding: 28px 18px; }
  .profile-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .form-card { padding: 16px; }
  .auth-card { padding: 22px 18px; margin: 20px auto; }
}

/* 背景固定定位在移动端改为滚动，避免性能问题 */
@media (max-width: 768px) {
  body { background-attachment: scroll, scroll; }
}

/* ===== 主题切换按钮 ===== */
.theme-toggle {
  background: none; border: none; cursor: pointer; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px; border-radius: 8px; width: 32px; height: 32px; flex: none;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
html.dark .theme-toggle .icon-sun { display: none; }
html:not(.dark) .theme-toggle .icon-moon { display: none; }
