/* ============================================================
   语料书房 — 小说阅读器样式
   支持多套模板风格切换（Botanical / Monochrome / Newsprint /
   Academia / Minimal Dark / Swiss Minimalist）
   ============================================================ */

/* ===== 默认模板：Botanical Organic ===== */
:root {
  --bg: #F9F8F4;
  --fg: #2D3A31;
  --surface: #fff;
  --surface-2: #F2F0EB;
  --text: var(--fg);
  --text-muted: #5f6e62;
  --text-subtle: #8C9A84;
  --accent: #C27B66;
  --accent-2: #4A5744;
  --accent-soft: rgba(194, 123, 102, 0.12);
  --border: #E6E2DA;
  --border-strong: #DCCFC2;

  --shadow-sm: 0 4px 6px -1px rgba(45, 58, 49, .05);
  --shadow: 0 10px 15px -3px rgba(45, 58, 49, .05);
  --shadow-lg: 0 20px 40px -10px rgba(45, 58, 49, .08);
  --shadow-xl: 0 25px 50px -12px rgba(45, 58, 49, .15);

  --radius-sm: 12px;
  --radius: 1.5rem;
  --radius-lg: 2.5rem;
  --radius-pill: 9999px;

  --display-font: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --ui-font: 'Source Sans 3', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', sans-serif;
  --read-font: 'Source Han Serif SC', 'Noto Serif SC', 'STSong', 'SimSun', 'Georgia', serif;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--ui-font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}

::selection {
  background: var(--accent);
  color: #fff;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

a { color: inherit; text-decoration: none; }

/* 全局纹理层 */
.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  opacity: .018;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='gn'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23gn)'/%3E%3C/svg%3E");
  background-repeat: repeat;
}

.vignette, .orb { display: none; pointer-events: none; }

.vignette {
  position: fixed;
  inset: 0;
  z-index: 86;
  background: radial-gradient(ellipse at center, transparent 0%, transparent 50%, rgba(0, 0, 0, .35) 100%);
}

.orb {
  position: fixed;
  z-index: 85;
  border-radius: 9999px;
  background: var(--accent);
}

.orb-top {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  opacity: .03;
  filter: blur(100px);
}

.orb-bottom {
  right: 0;
  bottom: 0;
  width: 300px;
  height: 300px;
  transform: translate(25%, 25%);
  opacity: .02;
  filter: blur(80px);
}

/* 加载页 */
.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  color: var(--text-muted);
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

/* 顶部导航 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1.5px solid var(--border);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--display-font);
  font-weight: 700;
  font-style: italic;
  font-size: 1.5rem;
  letter-spacing: -0.04em;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--display-font);
  font-style: italic;
  font-size: 1.1rem;
}

.search {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-subtle);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search input:focus {
  border-color: var(--text-subtle);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-subtle) 22%, transparent);
}

.search input::placeholder { color: var(--text-subtle); }

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 2.6rem;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.icon-btn:hover {
  border-color: var(--fg);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* 模板切换器 */
.template-switch {
  position: relative;
}

.template-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 100;
}

.template-menu.open { display: flex; }

.template-menu button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.template-menu button:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.template-menu button.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.template-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 页面容器 */
.page {
  max-width: 85rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.page-narrow {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* 统计栏 */
.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-chip {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-num {
  font-family: var(--display-font);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* 筛选条 */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.filter-bar.compact { margin-bottom: 0.55rem; }

.pill {
  display: inline-flex;
  align-items: center;
  height: 2.25rem;
  padding: 0 1rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
}

.pill:hover {
  border-color: var(--fg);
  color: var(--fg);
}

.pill.on {
  background: var(--fg);
  border-color: var(--fg);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.pill.sub {
  height: 2rem;
  padding: 0 0.8rem;
  font-size: 0.75rem;
}

.filter-divider {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  margin: 0 0.2rem;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-right: 0.25rem;
}

.sort-select {
  height: 2.25rem;
  padding: 0 0.85rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
  outline: none;
}

.sort-select:focus { border-color: var(--text-subtle); }

/* 书籍网格 */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.75rem;
  margin-top: 1.5rem;
}

.book-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.35s var(--ease);
}

.book-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-xl);
  border-color: var(--border-strong);
}

.book-cover {
  position: relative;
  height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.2rem;
  text-align: center;
}

.book-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 40%, rgba(0,0,0,0.2) 100%);
  pointer-events: none;
}

.book-cover-title {
  position: relative;
  z-index: 1;
  font-family: var(--display-font);
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.35;
  text-shadow: 0 1px 4px rgba(0,0,0,0.35);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.book-cover-author {
  position: relative;
  z-index: 1;
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.9);
}

.book-lang {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--fg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
}

.book-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0,0,0,0.12);
  z-index: 2;
}

.book-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.book-info {
  padding: 1rem 1.15rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.book-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.85rem;
}

.book-meta {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  color: var(--text-subtle);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.03em;
}

/* 分页 */
.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  padding: 2.5rem 0 1rem;
  flex-wrap: wrap;
}

.pager button {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.pager button:hover:not(:disabled) {
  border-color: var(--fg);
  color: var(--fg);
}

.pager button.on {
  background: var(--fg);
  border-color: var(--fg);
  color: #fff;
}

.pager button:disabled {
  opacity: 0.35;
  cursor: default;
}

.pager-total {
  font-size: 0.78rem;
  color: var(--text-subtle);
  margin-left: 0.5rem;
}

/* 通用按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 2.6rem;
  padding: 0 1.4rem;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--fg);
  background: transparent;
  color: var(--fg);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.btn:hover {
  background: var(--fg);
  color: #fff;
}

.btn-primary {
  background: var(--fg);
  border-color: var(--fg);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* 详情页 */
.detail-header {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2.5rem;
  padding: 2rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.detail-cover {
  width: 200px;
  height: 280px;
  border-radius: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.detail-cover .book-cover-title {
  font-size: 1.35rem;
  -webkit-line-clamp: 3;
}

.detail-body {
  display: flex;
  flex-direction: column;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
  margin-bottom: 1rem;
  width: fit-content;
  transition: color 0.15s var(--ease);
}

.back-link:hover { color: var(--accent); }

.detail-title {
  font-family: var(--display-font);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 600;
  line-height: 1.15;
  margin-bottom: 0.4rem;
}

.detail-author {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.detail-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.85;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 0.5rem;
  margin-bottom: 1.25rem;
}

.detail-desc:empty { display: none; }

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  font-size: 0.82rem;
  color: var(--text-subtle);
  margin-bottom: 1.25rem;
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: auto;
}

/* 章节列表 */
.chapter-panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chapter-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1.5px solid var(--border);
  background: var(--surface-2);
}

.chapter-head h3 {
  font-family: var(--display-font);
  font-size: 1.15rem;
  font-weight: 600;
}

.chapter-search {
  position: relative;
}

.chapter-search input {
  width: 220px;
  padding: 8px 10px 8px 34px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.82rem;
  outline: none;
}

.chapter-search input:focus { border-color: var(--text-subtle); }

.chapter-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-subtle);
}

.chapter-list {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.6rem;
}

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.25rem;
}

.chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  transition: background 0.15s var(--ease);
}

.chapter-item:hover { background: var(--surface-2); }

.chapter-item.read { opacity: 0.5; }

.chapter-item.current {
  background: var(--accent-soft);
  font-weight: 700;
  color: var(--accent);
}

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

.chapter-wc {
  font-size: 0.72rem;
  color: var(--text-subtle);
  white-space: nowrap;
}

/* 阅读页 */
.reader-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.reader-topbar {
  position: sticky;
  top: 0;
  z-index: 70;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg) 96%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1.5px solid var(--border);
}

.reader-topbar .back-link { margin-bottom: 0; }

.reader-book-title {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  z-index: 90;
}

.reader-progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s linear;
}

.reader-body {
  flex: 1;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 7.5rem;
}

.reader-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.reader-nav .btn {
  height: 2.4rem;
  padding: 0 1rem;
  font-size: 0.75rem;
}

.reader-nav-group {
  display: flex;
  gap: 0.45rem;
}

.chapter-title-main {
  font-family: var(--display-font);
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 600;
  text-align: center;
  margin-bottom: 2.25rem;
  color: var(--text);
}

.chapter-content {
  font-family: var(--read-font);
  font-size: 1.08rem;
  line-height: 2;
  color: var(--text);
  background: var(--surface);
  padding: 2.5rem 2.75rem;
  border-radius: var(--radius-lg);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 阅读工具栏 */
.read-toolbar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.7rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
  z-index: 80;
}

.read-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-width: 36px;
  padding: 0 0.5rem;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.read-toolbar button:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  margin: 0 0.2rem;
}

.font-label {
  min-width: 42px;
  font-size: 0.76rem;
}

/* 目录抽屉 */
.toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 34, 29, 0.35);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.toc-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.toc-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(380px, 86vw);
  background: var(--surface);
  border-right: 1.5px solid var(--border);
  z-index: 101;
  transform: translateX(-105%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.toc-drawer.open { transform: translateX(0); }

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1.5px solid var(--border);
  background: var(--surface-2);
}

.toc-header h3 {
  font-family: var(--display-font);
  font-size: 1.1rem;
  font-weight: 600;
}

.toc-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toc-close:hover { color: var(--fg); border-color: var(--fg); }

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem;
}

.toc-list .chapter-item {
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
}

/* 历史页 */
.history-empty {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.25rem;
}

.history-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.3rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.25s var(--ease);
}

.history-card:hover {
  border-color: var(--border-strong);
  transform: translateX(4px);
  box-shadow: var(--shadow-lg);
}

.history-main { flex: 1; min-width: 0; }

.history-name {
  font-family: var(--display-font);
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-prog {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.history-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.history-bar-wrap { width: 120px; }

.history-pct {
  font-size: 0.75rem;
  color: var(--text-subtle);
  text-align: right;
  margin-bottom: 0.25rem;
}

.history-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.history-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}

.history-delete {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-delete:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-subtle);
  margin-bottom: 1rem;
}

/* 通用图标 */
.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }


/* ============================================================
   环境装饰层
   ============================================================ */

.vignette {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 89;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 0%, transparent 50%, rgba(0,0,0,0.4) 100%);
}

.orb {
  display: none;
  position: fixed;
  border-radius: 9999px;
  background: var(--accent);
  pointer-events: none;
  z-index: 88;
  filter: blur(100px);
}

.orb-top {
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  opacity: 0.04;
}

.orb-bottom {
  right: -100px;
  bottom: -100px;
  width: 400px;
  height: 400px;
  opacity: 0.03;
}

.noise {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 87;
  pointer-events: none;
  opacity: 0.02;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   模板：Monochrome
   ============================================================ */
body[data-template="monochrome"] {
  --bg: #FFFFFF;
  --fg: #000000;
  --surface: #FFFFFF;
  --surface-2: #F5F5F5;
  --text: #000000;
  --text-muted: #525252;
  --text-subtle: #A3A3A3;
  --accent: #000000;
  --accent-2: #000000;
  --accent-soft: rgba(0, 0, 0, 0.08);
  --border: #000000;
  --border-strong: #000000;

  --shadow-sm: none;
  --shadow: none;
  --shadow-lg: none;
  --shadow-xl: none;

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --ui-font: 'Source Serif 4', Georgia, 'PingFang SC', 'Microsoft YaHei', serif;
  --read-font: 'Source Serif 4', 'Noto Serif SC', 'STSong', 'SimSun', Georgia, serif;
}

body[data-template="monochrome"] .grain {
  opacity: 0.04;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 1px, #000 1px, #000 2px),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 100% 4px, auto;
}

body[data-template="monochrome"] .topbar,
body[data-template="monochrome"] .reader-topbar {
  background: var(--bg);
  backdrop-filter: none;
  border-bottom: 2px solid var(--fg);
}

body[data-template="monochrome"] .logo-mark {
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  border: 2px solid var(--fg);
}

body[data-template="monochrome"] .book-card:hover,
body[data-template="monochrome"] .history-card:hover {
  transform: none;
  box-shadow: none;
}

body[data-template="monochrome"] .tag {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--fg);
}

body[data-template="monochrome"] .chapter-item.current {
  background: var(--fg);
  color: var(--bg);
}

body[data-template="monochrome"] .history-delete:hover {
  background: var(--fg);
  color: var(--bg);
}

/* ============================================================
   模板：Newsprint
   ============================================================ */
body[data-template="newsprint"] {
  --bg: #F9F9F7;
  --fg: #111111;
  --surface: #FFFFFF;
  --surface-2: #F5F5F5;
  --text: #111111;
  --text-muted: #525252;
  --text-subtle: #737373;
  --accent: #CC0000;
  --accent-2: #111111;
  --accent-soft: rgba(204, 0, 0, 0.10);
  --border: #E5E5E0;
  --border-strong: #111111;

  --shadow-sm: none;
  --shadow: none;
  --shadow-lg: none;
  --shadow-xl: none;

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Playfair Display', 'Times New Roman', serif;
  --ui-font: 'Inter', 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Lora', 'Noto Serif SC', 'STSong', Georgia, serif;
}

body[data-template="newsprint"] {
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' viewBox='0 0 4 4'%3E%3Cpath fill='%23111111' fill-opacity='0.04' d='M1 3h1v1H1V3zm2-2h1v1H3V1z'%3E%3C/path%3E%3C/svg%3E");
}

body[data-template="newsprint"] .grain {
  opacity: 0.5;
  background-image:
    linear-gradient(0deg, transparent 98%, rgba(0,0,0,0.02) 100%),
    linear-gradient(90deg, transparent 98%, rgba(0,0,0,0.02) 100%);
  background-size: 3px 3px;
}

body[data-template="newsprint"] .topbar,
body[data-template="newsprint"] .reader-topbar {
  background: var(--bg);
  backdrop-filter: none;
  border-bottom: 4px solid var(--fg);
}

body[data-template="newsprint"] .logo {
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.04em;
}

body[data-template="newsprint"] .logo-mark {
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  font-style: normal;
}

body[data-template="newsprint"] .book-card,
body[data-template="newsprint"] .detail-header,
body[data-template="newsprint"] .chapter-panel,
body[data-template="newsprint"] .history-card,
body[data-template="newsprint"] .chapter-content {
  border: 1px solid var(--fg);
}

body[data-template="newsprint"] .book-card:hover,
body[data-template="newsprint"] .history-card:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 0 var(--fg);
}

body[data-template="newsprint"] .tag {
  background: var(--fg);
  color: var(--bg);
}

body[data-template="newsprint"] .chapter-item.current {
  background: var(--accent);
  color: #fff;
}

body[data-template="newsprint"] .reader-progress > span,
body[data-template="newsprint"] .history-bar > span,
body[data-template="newsprint"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Academia
   ============================================================ */
body[data-template="academia"] {
  --bg: #1C1714;
  --fg: #E8DFD4;
  --surface: #251E19;
  --surface-2: #3D332B;
  --text: #E8DFD4;
  --text-muted: #9C8B7A;
  --text-subtle: #C9A962;
  --accent: #C9A962;
  --accent-2: #D4B872;
  --accent-soft: rgba(201, 169, 98, 0.15);
  --border: #4A3F35;
  --border-strong: #C9A962;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, .2);
  --shadow: 0 8px 16px -4px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 30px -8px rgba(0, 0, 0, .35);
  --shadow-xl: 0 20px 40px -12px rgba(0, 0, 0, .45);

  --radius-sm: 4px;
  --radius: 4px;
  --radius-lg: 4px;
  --radius-pill: 4px;

  --display-font: 'Cormorant Garamond', Georgia, serif;
  --ui-font: 'Cinzel', 'PingFang SC', 'Microsoft YaHei', serif;
  --read-font: 'Crimson Pro', 'Noto Serif SC', 'STSong', Georgia, serif;
}

body[data-template="academia"] .grain,
body[data-template="academia"] .vignette {
  display: block;
}

body[data-template="academia"] .grain {
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23n)'/%3E%3C/svg%3E");
}

body[data-template="academia"] .topbar,
body[data-template="academia"] .reader-topbar {
  background: rgba(28, 23, 20, 0.92);
  border-bottom: 1px solid var(--border);
}

body[data-template="academia"] .logo {
  font-style: normal;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
}

body[data-template="academia"] .logo-mark {
  border-radius: 4px;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  font-style: normal;
}

body[data-template="academia"] .btn-primary {
  background: linear-gradient(180deg, #D4B872 0%, #C9A962 50%, #B8953F 100%);
  color: var(--bg);
  border: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.2), inset 0 -1px 0 rgba(0,0,0,.2), 0 2px 8px rgba(0,0,0,.3);
}

body[data-template="academia"] .btn-primary:hover {
  filter: brightness(1.1);
}

body[data-template="academia"] .pill.on {
  background: var(--accent);
  color: var(--bg);
}

body[data-template="academia"] .chapter-item.current {
  background: rgba(201, 169, 98, 0.2);
  color: var(--accent);
}

body[data-template="academia"] .reader-progress > span,
body[data-template="academia"] .history-bar > span,
body[data-template="academia"] .book-progress > span {
  background: var(--accent);
}

body[data-template="academia"] .toc-overlay {
  background: rgba(0, 0, 0, 0.5);
}

/* ============================================================
   模板：Minimal Dark
   ============================================================ */
body[data-template="minimal-dark"] {
  --bg: #0a0a0f;
  --fg: #fafafa;
  --surface: rgba(26, 26, 36, 0.6);
  --surface-2: rgba(26, 26, 36, 0.85);
  --text: #fafafa;
  --text-muted: #71717a;
  --text-subtle: #71717a;
  --accent: #f59e0b;
  --accent-2: #fbbf24;
  --accent-soft: rgba(245, 158, 11, 0.15);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, .2);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, .25);
  --shadow-lg: 0 20px 40px -10px rgba(0, 0, 0, .35);
  --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, .45);

  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --display-font: 'Space Grotesk', system-ui, sans-serif;
  --ui-font: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="minimal-dark"] .orb,
body[data-template="minimal-dark"] .noise {
  display: block;
}

body[data-template="minimal-dark"] .topbar,
body[data-template="minimal-dark"] .reader-topbar {
  background: rgba(10, 10, 15, 0.8);
  border-bottom: 1px solid var(--border);
}

body[data-template="minimal-dark"] .logo {
  font-style: normal;
  font-weight: 600;
}

body[data-template="minimal-dark"] .logo-mark {
  border-radius: 10px;
  background: var(--accent);
  color: var(--bg);
  font-style: normal;
}

body[data-template="minimal-dark"] .book-card,
body[data-template="minimal-dark"] .detail-header,
body[data-template="minimal-dark"] .chapter-panel,
body[data-template="minimal-dark"] .history-card,
body[data-template="minimal-dark"] .chapter-content,
body[data-template="minimal-dark"] .read-toolbar,
body[data-template="minimal-dark"] .stat-chip,
body[data-template="minimal-dark"] .template-menu {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body[data-template="minimal-dark"] .book-card:hover,
body[data-template="minimal-dark"] .history-card:hover {
  background: rgba(26, 26, 36, 0.8);
  border-color: var(--border-strong);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.15);
}

body[data-template="minimal-dark"] .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

body[data-template="minimal-dark"] .btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

body[data-template="minimal-dark"] .pill.on {
  background: var(--accent);
  color: var(--bg);
}

body[data-template="minimal-dark"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ============================================================
   模板：Swiss Minimalist
   ============================================================ */
body[data-template="swiss"] {
  --bg: #FFFFFF;
  --fg: #000000;
  --surface: #FFFFFF;
  --surface-2: #F2F2F2;
  --text: #000000;
  --text-muted: #666666;
  --text-subtle: #666666;
  --accent: #E44D21;
  --accent-2: #FF3000;
  --accent-soft: rgba(228, 77, 33, 0.12);
  --border: #000000;
  --border-strong: #000000;

  --shadow-sm: none;
  --shadow: none;
  --shadow-lg: none;
  --shadow-xl: none;

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  --ui-font: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="swiss"] .grain {
  opacity: 0.04;
  background-image: linear-gradient(90deg, rgba(0,0,0,0.04) 1px, transparent 1px);
  background-size: 25% 100%;
}

body[data-template="swiss"] .topbar,
body[data-template="swiss"] .reader-topbar {
  background: var(--bg);
  backdrop-filter: none;
  border-bottom: 2px solid var(--fg);
}

body[data-template="swiss"] .logo {
  font-family: var(--ui-font);
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.04em;
}

body[data-template="swiss"] .logo-mark {
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  font-style: normal;
}

body[data-template="swiss"] .btn,
body[data-template="swiss"] .icon-btn,
body[data-template="swiss"] .pill,
body[data-template="swiss"] .search input,
body[data-template="swiss"] .sort-select {
  border-width: 2px;
}

body[data-template="swiss"] .book-card,
body[data-template="swiss"] .detail-header,
body[data-template="swiss"] .chapter-panel,
body[data-template="swiss"] .history-card,
body[data-template="swiss"] .chapter-content {
  border: 2px solid var(--fg);
}

body[data-template="swiss"] .book-card:hover,
body[data-template="swiss"] .history-card:hover {
  transform: none;
  box-shadow: none;
  background: var(--surface-2);
}

body[data-template="swiss"] .tag {
  background: var(--accent);
  color: #fff;
}

body[data-template="swiss"] .chapter-item.current {
  background: var(--accent);
  color: #fff;
}

body[data-template="swiss"] .reader-progress > span,
body[data-template="swiss"] .history-bar > span,
body[data-template="swiss"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Bauhaus
   ============================================================ */
body[data-template="bauhaus"] {
  --bg: #F0F0F0;
  --fg: #121212;
  --surface: #FFFFFF;
  --surface-2: #E8E8E8;
  --text: #121212;
  --text-muted: #525252;
  --text-subtle: #757575;
  --accent: #D02020;
  --accent-2: #1040C0;
  --accent-soft: rgba(208, 32, 32, 0.08);
  --border: #121212;
  --border-strong: #121212;

  --shadow-sm: 2px 2px 0 0 var(--fg);
  --shadow: 4px 4px 0 0 var(--fg);
  --shadow-lg: 6px 6px 0 0 var(--fg);
  --shadow-xl: 8px 8px 0 0 var(--fg);

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Outfit', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ui-font: 'Outfit', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Outfit', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="bauhaus"] .topbar,
body[data-template="bauhaus"] .reader-topbar {
  background: var(--bg);
  backdrop-filter: none;
  border-bottom: 4px solid var(--fg);
}

body[data-template="bauhaus"] .logo {
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.04em;
}

body[data-template="bauhaus"] .logo-mark {
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  font-style: normal;
}

body[data-template="bauhaus"] .icon-btn,
body[data-template="bauhaus"] .btn,
body[data-template="bauhaus"] .pill,
body[data-template="bauhaus"] .search input,
body[data-template="bauhaus"] .sort-select {
  border-width: 2px;
}

body[data-template="bauhaus"] .book-card,
body[data-template="bauhaus"] .detail-header,
body[data-template="bauhaus"] .chapter-panel,
body[data-template="bauhaus"] .history-card,
body[data-template="bauhaus"] .chapter-content,
body[data-template="bauhaus"] .read-toolbar,
body[data-template="bauhaus"] .template-menu {
  border: 2px solid var(--fg);
  box-shadow: 4px 4px 0 0 var(--fg);
}

body[data-template="bauhaus"] .book-card:hover,
body[data-template="bauhaus"] .history-card:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 0 var(--fg);
}

body[data-template="bauhaus"] .tag {
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--fg);
}

body[data-template="bauhaus"] .chapter-item.current {
  background: var(--accent);
  color: #fff;
}

body[data-template="bauhaus"] .reader-progress > span,
body[data-template="bauhaus"] .history-bar > span,
body[data-template="bauhaus"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Cyberpunk
   ============================================================ */
body[data-template="cyberpunk"] {
  --bg: #0a0a0f;
  --fg: #e0e0e0;
  --surface: rgba(18, 18, 26, 0.85);
  --surface-2: #12121a;
  --text: #e0e0e0;
  --text-muted: #6b7280;
  --text-subtle: #6b7280;
  --accent: #00ff88;
  --accent-2: #ff00ff;
  --accent-soft: rgba(0, 255, 136, 0.12);
  --border: #2a2a3a;
  --border-strong: #00ff88;

  --shadow-sm: 0 0 5px rgba(0, 255, 136, 0.15);
  --shadow: 0 0 10px rgba(0, 255, 136, 0.2);
  --shadow-lg: 0 0 20px rgba(0, 255, 136, 0.25);
  --shadow-xl: 0 0 30px rgba(0, 255, 136, 0.3);

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Orbitron', 'Share Tech Mono', 'PingFang SC', sans-serif;
  --ui-font: 'JetBrains Mono', 'Share Tech Mono', 'PingFang SC', 'Microsoft YaHei', monospace;
  --read-font: 'JetBrains Mono', 'Share Tech Mono', 'PingFang SC', 'Microsoft YaHei', monospace;

  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(0, 255, 136, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 136, .035) 1px, transparent 1px);
  background-size: 50px 50px;
}

body[data-template="cyberpunk"] .grain {
  opacity: 0.4;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, .25) 2px, rgba(0, 0, 0, .25) 4px);
  mix-blend-mode: multiply;
}

body[data-template="cyberpunk"] .topbar,
body[data-template="cyberpunk"] .reader-topbar {
  background: rgba(10, 10, 15, .92);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
}

body[data-template="cyberpunk"] .logo {
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-shadow: 0 0 5px #00ff88, 0 0 10px #00ff8840;
}

body[data-template="cyberpunk"] .logo-mark {
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  box-shadow: 0 0 5px #00ff88, 0 0 10px #00ff8840;
  font-style: normal;
}

body[data-template="cyberpunk"] .book-card,
body[data-template="cyberpunk"] .detail-header,
body[data-template="cyberpunk"] .chapter-panel,
body[data-template="cyberpunk"] .history-card,
body[data-template="cyberpunk"] .chapter-content,
body[data-template="cyberpunk"] .read-toolbar,
body[data-template="cyberpunk"] .template-menu {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 0 20px rgba(0, 255, 136, .06), inset 0 0 30px rgba(0, 0, 0, .4);
}

body[data-template="cyberpunk"] .book-card:hover,
body[data-template="cyberpunk"] .history-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(0, 255, 136, .15);
}

body[data-template="cyberpunk"] .tag {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

body[data-template="cyberpunk"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="cyberpunk"] .reader-progress > span,
body[data-template="cyberpunk"] .history-bar > span,
body[data-template="cyberpunk"] .book-progress > span {
  background: var(--accent);
}

body[data-template="cyberpunk"] .pill.on {
  background: var(--accent);
  color: var(--bg);
}

body[data-template="cyberpunk"] .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 255, 136, .3);
}

/* ============================================================
   模板：Neo-Brutalism
   ============================================================ */
body[data-template="neo-brutalism"] {
  --bg: #FFFDF5;
  --fg: #000000;
  --surface: #FFFFFF;
  --surface-2: #FFF9E6;
  --text: #000000;
  --text-muted: #444444;
  --text-subtle: #666666;
  --accent: #FF6B6B;
  --accent-2: #FFD93D;
  --accent-soft: rgba(255, 107, 107, 0.12);
  --border: #000000;
  --border-strong: #000000;

  --shadow-sm: 2px 2px 0 0 var(--fg);
  --shadow: 4px 4px 0 0 var(--fg);
  --shadow-lg: 6px 6px 0 0 var(--fg);
  --shadow-xl: 8px 8px 0 0 var(--fg);

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ui-font: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="neo-brutalism"] .topbar,
body[data-template="neo-brutalism"] .reader-topbar {
  background: var(--bg);
  backdrop-filter: none;
  border-bottom: 4px solid var(--fg);
}

body[data-template="neo-brutalism"] .logo {
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: -0.04em;
}

body[data-template="neo-brutalism"] .logo-mark {
  border-radius: 0;
  background: var(--accent);
  color: var(--fg);
  font-style: normal;
  border: 2px solid var(--fg);
}

body[data-template="neo-brutalism"] .icon-btn,
body[data-template="neo-brutalism"] .btn,
body[data-template="neo-brutalism"] .pill,
body[data-template="neo-brutalism"] .search input,
body[data-template="neo-brutalism"] .sort-select {
  border-width: 2px;
}

body[data-template="neo-brutalism"] .book-card,
body[data-template="neo-brutalism"] .detail-header,
body[data-template="neo-brutalism"] .chapter-panel,
body[data-template="neo-brutalism"] .history-card,
body[data-template="neo-brutalism"] .chapter-content,
body[data-template="neo-brutalism"] .read-toolbar,
body[data-template="neo-brutalism"] .template-menu {
  border: 2px solid var(--fg);
  box-shadow: 4px 4px 0 0 var(--fg);
}

body[data-template="neo-brutalism"] .book-card:hover,
body[data-template="neo-brutalism"] .history-card:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 0 var(--fg);
}

body[data-template="neo-brutalism"] .tag {
  background: var(--accent);
  color: var(--fg);
  border: 2px solid var(--fg);
}

body[data-template="neo-brutalism"] .chapter-item.current {
  background: var(--accent);
  color: var(--fg);
}

body[data-template="neo-brutalism"] .reader-progress > span,
body[data-template="neo-brutalism"] .history-bar > span,
body[data-template="neo-brutalism"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Art Deco
   ============================================================ */
body[data-template="art-deco"] {
  --bg: #0A0A0A;
  --fg: #F2F0E4;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --text: #F2F0E4;
  --text-muted: #888888;
  --text-subtle: #D4AF37;
  --accent: #D4AF37;
  --accent-2: #F2E8C4;
  --accent-soft: rgba(212, 175, 55, 0.15);
  --border: #333333;
  --border-strong: #D4AF37;

  --shadow-sm: 0 0 10px rgba(212, 175, 55, 0.1);
  --shadow: 0 0 15px rgba(212, 175, 55, 0.15);
  --shadow-lg: 0 0 25px rgba(212, 175, 55, 0.2);
  --shadow-xl: 0 0 35px rgba(212, 175, 55, 0.25);

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Marcellus', Georgia, serif;
  --ui-font: 'Josefin Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Josefin Sans', 'Noto Serif SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="art-deco"] .grain,
body[data-template="art-deco"] .vignette {
  display: block;
}

body[data-template="art-deco"] .grain {
  opacity: 0.05;
  mix-blend-mode: normal;
  background-image:
    repeating-linear-gradient(45deg, var(--accent) 0px, var(--accent) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(-45deg, var(--accent) 0px, var(--accent) 1px, transparent 1px, transparent 40px);
}

body[data-template="art-deco"] .topbar,
body[data-template="art-deco"] .reader-topbar {
  background: rgba(10, 10, 10, .92);
  border-bottom: 1px solid var(--border-strong);
}

body[data-template="art-deco"] .logo {
  font-style: normal;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

body[data-template="art-deco"] .logo-mark {
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  font-style: normal;
}

body[data-template="art-deco"] .book-card,
body[data-template="art-deco"] .detail-header,
body[data-template="art-deco"] .chapter-panel,
body[data-template="art-deco"] .history-card,
body[data-template="art-deco"] .chapter-content,
body[data-template="art-deco"] .read-toolbar,
body[data-template="art-deco"] .template-menu {
  border: 1px solid var(--border);
  background: var(--surface);
}

body[data-template="art-deco"] .book-card:hover,
body[data-template="art-deco"] .history-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

body[data-template="art-deco"] .tag {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

body[data-template="art-deco"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="art-deco"] .reader-progress > span,
body[data-template="art-deco"] .history-bar > span,
body[data-template="art-deco"] .book-progress > span {
  background: var(--accent);
}

body[data-template="art-deco"] .pill.on {
  background: var(--accent);
  color: var(--bg);
}

body[data-template="art-deco"] .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* ============================================================
   模板：Claymorphism
   ============================================================ */
body[data-template="claymorphism"] {
  --bg: #F4F1FA;
  --fg: #332F3A;
  --surface: rgba(255, 255, 255, 0.65);
  --surface-2: #ffffff;
  --text: #332F3A;
  --text-muted: #635F69;
  --text-subtle: #7C3AED;
  --accent: #7C3AED;
  --accent-2: #DB2777;
  --accent-soft: rgba(124, 58, 237, 0.12);
  --border: rgba(124, 58, 237, 0.2);
  --border-strong: #7C3AED;

  --shadow-sm: 8px 8px 16px rgba(160, 150, 180, .15), -6px -6px 12px rgba(255, 255, 255, .8);
  --shadow: 16px 16px 32px rgba(160, 150, 180, .18), -10px -10px 24px rgba(255, 255, 255, .85), inset 2px 2px 6px rgba(139, 92, 246, .02), inset -2px -2px 6px rgba(255, 255, 255, .9);
  --shadow-lg: 30px 30px 60px #cdc6d9, -30px -30px 60px #ffffff, inset 4px 4px 8px rgba(139, 92, 246, .05), inset -4px -4px 8px rgba(255, 255, 255, .9);
  --shadow-xl: var(--shadow-lg);

  --radius-sm: 16px;
  --radius: 24px;
  --radius-lg: 32px;
  --radius-pill: 9999px;

  --display-font: 'Nunito', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ui-font: 'DM Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'DM Sans', 'Noto Serif SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="claymorphism"] .topbar,
body[data-template="claymorphism"] .reader-topbar {
  background: rgba(255, 255, 255, .70);
  backdrop-filter: blur(24px);
  border-bottom: none;
  box-shadow: var(--shadow);
  border-radius: 0 0 var(--radius) var(--radius);
}

body[data-template="claymorphism"] .logo {
  font-style: normal;
  font-weight: 900;
  color: var(--accent);
}

body[data-template="claymorphism"] .logo-mark {
  background: var(--accent);
  color: #fff;
  font-style: normal;
}

body[data-template="claymorphism"] .book-card,
body[data-template="claymorphism"] .detail-header,
body[data-template="claymorphism"] .chapter-panel,
body[data-template="claymorphism"] .history-card,
body[data-template="claymorphism"] .chapter-content,
body[data-template="claymorphism"] .read-toolbar,
body[data-template="claymorphism"] .template-menu {
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

body[data-template="claymorphism"] .book-card:hover,
body[data-template="claymorphism"] .history-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

body[data-template="claymorphism"] .tag {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="claymorphism"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="claymorphism"] .reader-progress > span,
body[data-template="claymorphism"] .history-bar > span,
body[data-template="claymorphism"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Terminal
   ============================================================ */
body[data-template="terminal"] {
  --bg: #0a0a0a;
  --fg: #33ff00;
  --surface: #0f0f0f;
  --surface-2: #141414;
  --text: #33ff00;
  --text-muted: rgba(51, 255, 0, .6);
  --text-subtle: #1f521f;
  --accent: #33ff00;
  --accent-2: #ffb000;
  --accent-soft: rgba(51, 255, 0, .12);
  --border: #1f521f;
  --border-strong: #33ff00;

  --shadow-sm: 0 0 5px rgba(51, 255, 0, .2);
  --shadow: 0 0 8px rgba(51, 255, 0, .25);
  --shadow-lg: 0 0 12px rgba(51, 255, 0, .3);
  --shadow-xl: 0 0 16px rgba(51, 255, 0, .35);

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'JetBrains Mono', 'VT323', 'PingFang SC', monospace;
  --ui-font: 'JetBrains Mono', 'VT323', 'PingFang SC', 'Microsoft YaHei', monospace;
  --read-font: 'JetBrains Mono', 'VT323', 'PingFang SC', 'Microsoft YaHei', monospace;

  background-color: var(--bg);
  text-shadow: 0 0 5px rgba(51, 255, 0, .35);
}

body[data-template="terminal"] .grain,
body[data-template="terminal"] .vignette {
  display: block;
}

body[data-template="terminal"] .grain {
  opacity: 0.2;
  mix-blend-mode: normal;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(51, 255, 0, .15) 2px, rgba(51, 255, 0, .15) 4px);
}

body[data-template="terminal"] .vignette {
  background: radial-gradient(circle at center, transparent 50%, rgba(0, 0, 0, .55) 100%);
}

body[data-template="terminal"] .topbar,
body[data-template="terminal"] .reader-topbar {
  background: rgba(10, 10, 10, .9);
  border-bottom: 1px solid var(--border);
}

body[data-template="terminal"] .logo {
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

body[data-template="terminal"] .logo-mark {
  border-radius: 0;
  background: var(--accent);
  color: var(--bg);
  font-style: normal;
}

body[data-template="terminal"] .icon-btn,
body[data-template="terminal"] .btn,
body[data-template="terminal"] .pill,
body[data-template="terminal"] .search input,
body[data-template="terminal"] .sort-select {
  border-width: 1px;
  border-style: dashed;
}

body[data-template="terminal"] .book-card,
body[data-template="terminal"] .detail-header,
body[data-template="terminal"] .chapter-panel,
body[data-template="terminal"] .history-card,
body[data-template="terminal"] .chapter-content,
body[data-template="terminal"] .read-toolbar,
body[data-template="terminal"] .template-menu {
  border: 1px dashed var(--border);
  background: var(--surface);
}

body[data-template="terminal"] .book-card:hover,
body[data-template="terminal"] .history-card:hover {
  border-color: var(--accent);
  background: rgba(51, 255, 0, .05);
}

body[data-template="terminal"] .tag {
  background: transparent;
  color: var(--accent);
  border: 1px dashed var(--accent);
}

body[data-template="terminal"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="terminal"] .reader-progress > span,
body[data-template="terminal"] .history-bar > span,
body[data-template="terminal"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Vaporwave
   ============================================================ */
body[data-template="vaporwave"] {
  --bg: #090014;
  --fg: #E0E0E0;
  --surface: rgba(26, 16, 60, 0.8);
  --surface-2: #1a103c;
  --text: #E0E0E0;
  --text-muted: #8a7aaa;
  --text-subtle: #FF00FF;
  --accent: #FF00FF;
  --accent-2: #00FFFF;
  --accent-soft: rgba(255, 0, 255, .12);
  --border: #2D1B4E;
  --border-strong: #FF00FF;

  --shadow-sm: 0 0 5px rgba(255, 0, 255, .2);
  --shadow: 0 0 10px rgba(255, 0, 255, .25);
  --shadow-lg: 0 0 20px rgba(255, 0, 255, .3);
  --shadow-xl: 0 0 30px rgba(255, 0, 255, .35);

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Share Tech Mono', 'Orbitron', monospace;
  --ui-font: 'Share Tech Mono', 'Orbitron', 'PingFang SC', 'Microsoft YaHei', monospace;
  --read-font: 'Share Tech Mono', 'Orbitron', 'PingFang SC', 'Microsoft YaHei', monospace;

  background-color: var(--bg);
  background-image:
    linear-gradient(transparent 95%, rgba(255, 0, 255, .18) 95%),
    linear-gradient(90deg, transparent 95%, rgba(255, 0, 255, .18) 95%);
  background-size: 60px 60px;
}

body[data-template="vaporwave"] .grain {
  opacity: 0.35;
  background: linear-gradient(rgba(18, 16, 20, 0) 50%, rgba(0, 0, 0, .25) 50%);
  background-size: 100% 4px;
  mix-blend-mode: multiply;
}

body[data-template="vaporwave"] .topbar,
body[data-template="vaporwave"] .reader-topbar {
  background: rgba(9, 0, 20, .92);
  border-bottom: 2px solid var(--border);
}

body[data-template="vaporwave"] .logo {
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  text-shadow: 0 0 5px #FF00FF, 0 0 10px rgba(255, 0, 255, .4);
}

body[data-template="vaporwave"] .logo-mark {
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  box-shadow: 0 0 5px #FF00FF, 0 0 10px rgba(255, 0, 255, .4);
  font-style: normal;
}

body[data-template="vaporwave"] .book-card,
body[data-template="vaporwave"] .detail-header,
body[data-template="vaporwave"] .chapter-panel,
body[data-template="vaporwave"] .history-card,
body[data-template="vaporwave"] .chapter-content,
body[data-template="vaporwave"] .read-toolbar,
body[data-template="vaporwave"] .template-menu {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 0 20px rgba(255, 0, 255, .08);
}

body[data-template="vaporwave"] .book-card:hover,
body[data-template="vaporwave"] .history-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(255, 0, 255, .2);
}

body[data-template="vaporwave"] .tag {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

body[data-template="vaporwave"] .pill.on,
body[data-template="vaporwave"] .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

body[data-template="vaporwave"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="vaporwave"] .reader-progress > span,
body[data-template="vaporwave"] .history-bar > span,
body[data-template="vaporwave"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Material
   ============================================================ */
body[data-template="material"] {
  --bg: #FFFBFE;
  --fg: #1C1B1F;
  --surface: #F3EDF7;
  --surface-2: #E7E0EC;
  --text: #1C1B1F;
  --text-muted: #49454F;
  --text-subtle: #6750A4;
  --accent: #6750A4;
  --accent-2: #7C3AED;
  --accent-soft: rgba(103, 80, 164, .12);
  --border: #79747E;
  --border-strong: #6750A4;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .14);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, .10), 0 2px 4px -2px rgba(0, 0, 0, .10);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .10), 0 4px 6px -4px rgba(0, 0, 0, .10);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .10), 0 8px 10px -6px rgba(0, 0, 0, .10);

  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;

  --display-font: 'Roboto', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ui-font: 'Roboto', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Roboto', 'Noto Serif SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="material"] .topbar,
body[data-template="material"] .reader-topbar {
  background: rgba(255, 251, 254, .8);
  border-bottom: 1px solid rgba(121, 116, 126, .1);
}

body[data-template="material"] .logo {
  font-style: normal;
  font-weight: 500;
  color: var(--fg);
}

body[data-template="material"] .logo-mark {
  background: var(--accent);
  color: var(--bg);
  font-style: normal;
}

body[data-template="material"] .book-card,
body[data-template="material"] .detail-header,
body[data-template="material"] .chapter-panel,
body[data-template="material"] .history-card,
body[data-template="material"] .chapter-content,
body[data-template="material"] .read-toolbar,
body[data-template="material"] .template-menu {
  background: var(--surface);
  border: 1px solid rgba(121, 116, 126, .15);
  box-shadow: var(--shadow);
}

body[data-template="material"] .book-card:hover,
body[data-template="material"] .history-card:hover {
  box-shadow: var(--shadow-lg);
}

body[data-template="material"] .tag {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="material"] .pill.on,
body[data-template="material"] .btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

body[data-template="material"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="material"] .reader-progress > span,
body[data-template="material"] .history-bar > span,
body[data-template="material"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Luxury
   ============================================================ */
body[data-template="luxury"] {
  --bg: #F9F8F6;
  --fg: #1A1A1A;
  --surface: #FFFFFF;
  --surface-2: #EBE5DE;
  --text: #1A1A1A;
  --text-muted: #6C6863;
  --text-subtle: #D4AF37;
  --accent: #D4AF37;
  --accent-2: #B8860B;
  --accent-soft: rgba(212, 175, 55, .12);
  --border: rgba(26, 26, 26, .08);
  --border-strong: #D4AF37;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow: 0 4px 12px rgba(0, 0, 0, .05);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, .06);
  --shadow-xl: 0 20px 48px rgba(0, 0, 0, .08);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --display-font: 'Playfair Display', Georgia, serif;
  --ui-font: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Inter', 'Noto Serif SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="luxury"] .grain {
  opacity: 0.03;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

body[data-template="luxury"] .topbar,
body[data-template="luxury"] .reader-topbar {
  background: rgba(249, 248, 246, .92);
  border-bottom: 1px solid var(--border);
}

body[data-template="luxury"] .logo {
  font-family: var(--ui-font);
  font-style: normal;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: 1.1rem;
}

body[data-template="luxury"] .logo-mark {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  font-style: normal;
}

body[data-template="luxury"] .book-card,
body[data-template="luxury"] .detail-header,
body[data-template="luxury"] .chapter-panel,
body[data-template="luxury"] .history-card,
body[data-template="luxury"] .chapter-content,
body[data-template="luxury"] .read-toolbar,
body[data-template="luxury"] .template-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

body[data-template="luxury"] .book-card:hover,
body[data-template="luxury"] .history-card:hover {
  box-shadow: var(--shadow-lg);
}

body[data-template="luxury"] .tag {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

body[data-template="luxury"] .pill.on,
body[data-template="luxury"] .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

body[data-template="luxury"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="luxury"] .reader-progress > span,
body[data-template="luxury"] .history-bar > span,
body[data-template="luxury"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Kinetic
   ============================================================ */
body[data-template="kinetic"] {
  --bg: #09090B;
  --fg: #FAFAFA;
  --surface: #27272A;
  --surface-2: #18181B;
  --text: #FAFAFA;
  --text-muted: #A1A1AA;
  --text-subtle: #DFE104;
  --accent: #DFE104;
  --accent-2: #DFE104;
  --accent-soft: rgba(223, 225, 4, .12);
  --border: #3F3F46;
  --border-strong: #DFE104;

  --shadow-sm: 0 0 5px rgba(223, 225, 4, .1);
  --shadow: 0 0 10px rgba(223, 225, 4, .15);
  --shadow-lg: 0 0 20px rgba(223, 225, 4, .2);
  --shadow-xl: 0 0 30px rgba(223, 225, 4, .25);

  --radius-sm: 0;
  --radius: 0;
  --radius-lg: 0;
  --radius-pill: 0;

  --display-font: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ui-font: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="kinetic"] .topbar,
body[data-template="kinetic"] .reader-topbar {
  background: rgba(9, 9, 11, .9);
  border-bottom: 1px solid var(--border);
}

body[data-template="kinetic"] .logo {
  font-style: normal;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: -.05em;
}

body[data-template="kinetic"] .logo-mark {
  border-radius: 0;
  background: var(--accent);
  color: var(--bg);
  font-style: normal;
}

body[data-template="kinetic"] .book-card,
body[data-template="kinetic"] .detail-header,
body[data-template="kinetic"] .chapter-panel,
body[data-template="kinetic"] .history-card,
body[data-template="kinetic"] .chapter-content,
body[data-template="kinetic"] .read-toolbar,
body[data-template="kinetic"] .template-menu {
  border: 1px solid var(--border);
  background: var(--surface);
}

body[data-template="kinetic"] .book-card:hover,
body[data-template="kinetic"] .history-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

body[data-template="kinetic"] .tag {
  background: var(--accent);
  color: var(--bg);
}

body[data-template="kinetic"] .pill.on,
body[data-template="kinetic"] .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

body[data-template="kinetic"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="kinetic"] .reader-progress > span,
body[data-template="kinetic"] .history-bar > span,
body[data-template="kinetic"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Web3
   ============================================================ */
body[data-template="web3"] {
  --bg: #030304;
  --fg: #ffffff;
  --surface: #0F1115;
  --surface-2: #0a0b0f;
  --text: #ffffff;
  --text-muted: #94A3B8;
  --text-subtle: #F7931A;
  --accent: #F7931A;
  --accent-2: #FFD600;
  --accent-soft: rgba(247, 147, 26, .12);
  --border: rgba(255, 255, 255, .1);
  --border-strong: #F7931A;

  --shadow-sm: 0 0 10px rgba(247, 147, 26, .1);
  --shadow: 0 0 20px rgba(247, 147, 26, .15);
  --shadow-lg: 0 0 30px rgba(247, 147, 26, .2);
  --shadow-xl: 0 0 40px rgba(247, 147, 26, .25);

  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --display-font: 'Space Grotesk', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --ui-font: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'Inter', 'Noto Serif SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;

  background-color: var(--bg);
  background-image:
    linear-gradient(to right, rgba(30, 41, 59, .3) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(30, 41, 59, .3) 1px, transparent 1px);
  background-size: 50px 50px;
}

body[data-template="web3"] .topbar,
body[data-template="web3"] .reader-topbar {
  background: rgba(3, 3, 4, .8);
  border-bottom: 1px solid var(--border);
}

body[data-template="web3"] .logo {
  font-style: normal;
  font-weight: 700;
}

body[data-template="web3"] .logo-mark {
  background: linear-gradient(135deg, #EA580C, #F7931A);
  color: var(--bg);
  font-style: normal;
}

body[data-template="web3"] .book-card,
body[data-template="web3"] .detail-header,
body[data-template="web3"] .chapter-panel,
body[data-template="web3"] .history-card,
body[data-template="web3"] .chapter-content,
body[data-template="web3"] .read-toolbar,
body[data-template="web3"] .template-menu {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 0 30px rgba(247, 147, 26, .08);
}

body[data-template="web3"] .book-card:hover,
body[data-template="web3"] .history-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 30px rgba(247, 147, 26, .15);
}

body[data-template="web3"] .tag {
  background: rgba(247, 147, 26, .1);
  color: var(--accent);
  border: 1px solid rgba(247, 147, 26, .3);
}

body[data-template="web3"] .pill.on,
body[data-template="web3"] .btn-primary {
  background: linear-gradient(90deg, #EA580C, #F7931A);
  color: #fff;
  border-color: transparent;
}

body[data-template="web3"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="web3"] .reader-progress > span,
body[data-template="web3"] .history-bar > span,
body[data-template="web3"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   模板：Maximalism
   ============================================================ */
body[data-template="maximalism"] {
  --bg: #0D0D1A;
  --fg: #FFFFFF;
  --surface: #2D1B4E;
  --surface-2: #1a103c;
  --text: #FFFFFF;
  --text-muted: #A78BFA;
  --text-subtle: #FF3AF2;
  --accent: #FF3AF2;
  --accent-2: #00F5D4;
  --accent-soft: rgba(255, 58, 242, .12);
  --border: #2D1B4E;
  --border-strong: #FF3AF2;

  --shadow-sm: 0 0 10px rgba(255, 58, 242, .15);
  --shadow: 0 0 20px rgba(255, 58, 242, .2);
  --shadow-lg: 0 0 40px rgba(255, 58, 242, .3);
  --shadow-xl: 0 0 60px rgba(255, 58, 242, .35);

  --radius-sm: 8px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;

  --display-font: 'Bangers', cursive;
  --ui-font: 'DM Sans', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --read-font: 'DM Sans', 'Noto Serif SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

body[data-template="maximalism"] {
  background-color: var(--bg);
  background-image:
    radial-gradient(circle, var(--accent) 1px, transparent 1px),
    repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 230, 0, .04) 10px, rgba(255, 230, 0, .04) 20px);
  background-size: 24px 24px, 100% 100%;
}

body[data-template="maximalism"] .topbar,
body[data-template="maximalism"] .reader-topbar {
  background: rgba(13, 13, 26, .85);
  border-bottom: 4px solid var(--accent);
}

body[data-template="maximalism"] .logo {
  font-family: var(--display-font);
  font-style: normal;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(255, 58, 242, .5);
}

body[data-template="maximalism"] .logo-mark {
  background: linear-gradient(135deg, var(--accent), var(--accent-2), #FFE600);
  color: var(--bg);
  font-style: normal;
  border: 3px solid #FFE600;
  box-shadow: 0 0 15px rgba(255, 58, 242, .4), 4px 4px 0 var(--surface-2);
}

body[data-template="maximalism"] .book-card,
body[data-template="maximalism"] .detail-header,
body[data-template="maximalism"] .chapter-panel,
body[data-template="maximalism"] .history-card,
body[data-template="maximalism"] .chapter-content,
body[data-template="maximalism"] .read-toolbar,
body[data-template="maximalism"] .template-menu {
  border: 2px solid var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow);
}

body[data-template="maximalism"] .book-card:hover,
body[data-template="maximalism"] .history-card:hover {
  border-color: var(--accent-2);
  box-shadow: 0 0 40px rgba(0, 245, 212, .25);
}

body[data-template="maximalism"] .tag {
  background: var(--accent);
  color: var(--bg);
  border: 2px solid #FFE600;
}

body[data-template="maximalism"] .pill.on,
body[data-template="maximalism"] .btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

body[data-template="maximalism"] .chapter-item.current {
  background: var(--accent-soft);
  color: var(--accent);
}

body[data-template="maximalism"] .reader-progress > span,
body[data-template="maximalism"] .history-bar > span,
body[data-template="maximalism"] .book-progress > span {
  background: var(--accent);
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
  .topbar {
    padding: 0.9rem 1rem;
    gap: 0.75rem;
  }

  .logo-text { display: none; }

  .search input {
    padding: 9px 10px 9px 34px;
    font-size: 0.85rem;
  }

  .top-actions .btn-text { display: none; }

  .template-menu {
    right: -0.5rem;
    min-width: 160px;
  }

  .page, .page-narrow { padding: 1.25rem 1rem 3rem; }

  .stats-strip { gap: 0.5rem; }

  .stat-chip { padding: 0.45rem 0.8rem; }

  .stat-num { font-size: 1.1rem; }

  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.3rem;
  }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }

  .book-cover { height: 115px; }

  .book-cover-title { font-size: 1rem; }

  .book-info { padding: 0.75rem; }

  .book-desc { -webkit-line-clamp: 1; }

  .detail-header {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 1.25rem;
    padding: 1.25rem;
  }

  .detail-cover { width: 150px; height: 210px; }

  .detail-title { font-size: 1.5rem; }

  .detail-actions { justify-content: center; }

  .chapter-grid { grid-template-columns: 1fr; }

  .chapter-search input { width: 100%; }

  .reader-body { padding: 1.25rem 1rem 6.5rem; }

  .chapter-content {
    padding: 1.25rem;
    font-size: 1rem;
    line-height: 1.9;
  }

  .reader-nav {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .reader-nav-group { width: 100%; justify-content: space-between; }

  .read-toolbar {
    bottom: 12px;
    padding: 0.4rem;
  }

  .read-toolbar button {
    height: 34px;
    min-width: 32px;
    font-size: 0.78rem;
  }
}

@media (max-width: 480px) {
  .book-grid { grid-template-columns: repeat(2, 1fr); }
}
