/* ============================================================
   蛊真人 · 在线阅读器  — 墨玉蛊匣
   主题通过 html[data-theme] 切换；字体通过 html[data-font] 切换
   ============================================================ */

:root {
  /* 默认主题：羊皮纸 */
  --bg: #f2e8d5;
  --bg-deep: #e9dcc2;
  --panel: #faf3e3;
  --panel-2: #f4ecd9;
  --text: #3d3226;
  --text-2: #6f6150;
  --text-3: #8f8371;
  --accent: #8a6d3b;
  --accent-soft: rgba(138, 109, 59, .14);
  --border: rgba(80, 62, 36, .18);
  --shadow: 0 10px 30px rgba(60, 45, 20, .14);
  --scrollbar: rgba(120, 95, 55, .35);
  --mark: #e7c96f;
  --mark-text: #3d3226;
}

html[data-theme="light"] {
  --bg: #f7f6f2;
  --bg-deep: #efede6;
  --panel: #ffffff;
  --panel-2: #f6f5f1;
  --text: #2b2b2b;
  --text-2: #5c5c5c;
  --text-3: #8f8f8f;
  --accent: #2e6b53;
  --accent-soft: rgba(46, 107, 83, .12);
  --border: rgba(20, 20, 20, .14);
  --shadow: 0 10px 30px rgba(20, 20, 20, .10);
  --scrollbar: rgba(30, 30, 30, .30);
  --mark: #ffe28a;
  --mark-text: #2b2b2b;
}

html[data-theme="eye"] {
  --bg: #cfe3d0;
  --bg-deep: #bfd6c1;
  --panel: #dcebdc;
  --panel-2: #d4e5d5;
  --text: #2c4233;
  --text-2: #51684f;
  --text-3: #71856c;
  --accent: #2f6b4f;
  --accent-soft: rgba(47, 107, 79, .14);
  --border: rgba(30, 80, 45, .18);
  --shadow: 0 10px 30px rgba(30, 60, 35, .14);
  --scrollbar: rgba(50, 100, 60, .35);
  --mark: #f4d977;
  --mark-text: #2c4233;
}

html[data-theme="dark"] {
  --bg: #191d24;
  --bg-deep: #14181e;
  --panel: #20252e;
  --panel-2: #1b2028;
  --text: #c8cdd4;
  --text-2: #97a0ab;
  --text-3: #6f7884;
  --accent: #5aa985;
  --accent-soft: rgba(90, 169, 133, .16);
  --border: rgba(255, 255, 255, .10);
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --scrollbar: rgba(150, 160, 175, .35);
  --mark: #8f7a3a;
  --mark-text: #e8e2d0;
}

html[data-theme="night"] {
  --bg: #0c0f14;
  --bg-deep: #090c10;
  --panel: #12161d;
  --panel-2: #0f1319;
  --text: #aeb6bf;
  --text-2: #7d8691;
  --text-3: #56606c;
  --accent: #62b98a;
  --accent-soft: rgba(98, 185, 138, .16);
  --border: rgba(255, 255, 255, .08);
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  --scrollbar: rgba(120, 135, 150, .35);
  --mark: #7a6a2f;
  --mark-text: #d8d2c0;
}

/* ---- 字体选项 ---- */
html[data-font="default"] { --font-reader: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif; }
html[data-font="song"]    { --font-reader: "SimSun", "Songti SC", "Noto Serif SC", "STSong", serif; }
html[data-font="kai"]     { --font-reader: "KaiTi", "STKaiti", "Kaiti SC", "Noto Serif SC", serif; }
html[data-font="hei"]     { --font-reader: "SimHei", "Heiti SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
html[data-font="fang"]    { --font-reader: "FangSong", "STFangsong", "Noto Serif SC", serif; }
html[data-font="yahei"]   { --font-reader: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif; }
html { --font-display: "Noto Serif SC", "SimSun", "Songti SC", serif; }

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

html { height: 100%; }

body {
  font-family: var(--font-reader);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  transition: background .25s ease, color .25s ease;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

.hidden { display: none !important; }

/* ================= 顶栏 ================= */
#topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 12px;
  height: 52px; padding: 0 14px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { flex: 1; min-width: 0; display: flex; }
.brand a { display: flex; align-items: center; gap: 8px; color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: .06em; }
.brand svg { width: 20px; height: 20px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.top-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.font-steps {
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; margin: 0 3px;
}
.font-steps .icon-btn { width: 34px; height: 34px; border-radius: 0; }
.font-steps .icon-btn + .icon-btn { border-left: 1px solid var(--border); }
.font-steps .icon-btn:hover { background: var(--accent-soft); }

#scroll-progress {
  position: sticky; top: 52px; z-index: 59;
  height: 2px; background: transparent;
}
#scroll-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #c9a76a)); transition: width .1s linear; }

/* ================= 抽屉 & 遮罩 ================= */
#sidebar, #settings-panel {
  position: fixed; top: 0; bottom: 0; z-index: 80;
  width: min(340px, 88vw);
  background: var(--panel);
  box-shadow: var(--shadow);
  transition: transform .28s cubic-bezier(.22,.8,.3,1);
  display: flex; flex-direction: column;
}
#sidebar { left: 0; transform: translateX(-105%); }
#settings-panel { right: 0; transform: translateX(105%); }
body.sidebar-open #sidebar { transform: translateX(0); }
body.settings-open #settings-panel { transform: translateX(0); }

#mask {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.42);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
body.sidebar-open #mask, body.settings-open #mask { opacity: 1; pointer-events: auto; }

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
}
.sidebar-title { font-family: var(--font-display); font-weight: 700; font-size: 16px; letter-spacing: .08em; }
.settings-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
}

.book-tabs {
  display: flex; gap: 6px; padding: 0 14px 10px;
}
.book-tabs button {
  flex: 1; padding: 7px 6px; border-radius: 8px;
  font-size: 13px; color: var(--text-2);
  border: 1px solid var(--border);
  transition: all .15s ease;
}
.book-tabs button.active { background: var(--accent); color: var(--panel); border-color: var(--accent); }

.toc-search-box {
  display: flex; align-items: center; gap: 8px;
  margin: 0 14px 10px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel-2);
}
.toc-search-box svg { width: 16px; height: 16px; fill: none; stroke: var(--text-3); stroke-width: 1.8; }
.toc-search-box input { flex: 1; border: none; background: none; outline: none; font-size: 13px; color: var(--text); }

.toc-tools { display: flex; gap: 6px; padding: 0 14px 10px; flex-wrap: wrap; }
.toc-tools button {
  padding: 5px 10px; font-size: 12px; border-radius: 7px;
  border: 1px solid var(--border); color: var(--text-2);
  transition: all .15s ease;
}
.toc-tools button:hover { border-color: var(--accent); color: var(--accent); }

#toc { flex: 1; overflow-y: auto; padding: 0 8px 20px; }

.vol-group { margin-bottom: 4px; }
.vol-head {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 10px; border-radius: 8px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  color: var(--text); transition: background .15s ease;
}
.vol-head:hover { background: var(--accent-soft); }
.vol-head .chev {
  width: 16px; height: 16px; fill: none; stroke: var(--text-3);
  stroke-width: 2; transition: transform .2s ease; flex-shrink: 0;
}
.vol-group.collapsed .vol-head .chev { transform: rotate(-90deg); }
.vol-head .vol-sub { color: var(--text-3); font-size: 12px; font-weight: 400; margin-left: 2px; }
.vol-head .vol-count { margin-left: auto; font-size: 11px; color: var(--text-3); font-family: var(--font-reader); }

.ch-list { display: flex; flex-direction: column; }
.vol-group.collapsed .ch-list { display: none; }
.ch-item {
  display: block; width: 100%; text-align: left;
  padding: 7px 12px 7px 26px; border-radius: 7px;
  font-size: 13.5px; line-height: 1.55; color: var(--text-2);
  border-left: 2px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.ch-item:hover { background: var(--accent-soft); color: var(--text); }
.ch-item.current { background: var(--accent-soft); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.ch-item .ch-num { color: var(--text-3); font-size: 12px; margin-right: 6px; }
.ch-item .ch-empty { color: var(--text-3); font-size: 12px; margin-left: 4px; }

.sidebar-foot {
  padding: 10px 14px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-3); line-height: 1.6;
}

/* ================= 主区域 & 首页 ================= */
#main { min-height: calc(100vh - 52px); }
.view { padding: 26px 18px 80px; max-width: 1080px; margin: 0 auto; }

/* ---- 首页 ---- */
.home-hero {
  position: relative;
  border-radius: 18px; overflow: hidden;
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 55%),
    linear-gradient(160deg, var(--panel), var(--bg-deep));
  padding: 34px 30px 28px;
  box-shadow: var(--shadow);
}
.home-seal {
  position: absolute; right: 22px; top: 18px;
  width: 92px; height: 92px; pointer-events: none;
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,.16);
}
.home-seal img {
  display: block; width: 100%; height: 100%;
  object-fit: cover; border-radius: 14px;
}
.home-kicker {
  font-size: 12px; letter-spacing: .35em; color: var(--accent);
  font-family: var(--font-display); font-weight: 600; margin-bottom: 10px;
}
.home-title {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(34px, 6vw, 54px); letter-spacing: .1em;
  line-height: 1.15;
}
.home-sub { margin-top: 8px; font-size: 15px; color: var(--text-2); font-family: var(--font-display); letter-spacing: .12em; }
.home-intro {
  margin-top: 18px; max-width: 640px;
  font-size: 14.5px; line-height: 2; color: var(--text-2);
}
.home-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.stat-chip {
  padding: 6px 12px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-2);
}
.stat-chip b { color: var(--accent); font-weight: 700; }

.home-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.primary-btn {
  padding: 11px 22px; border-radius: 10px;
  background: var(--accent); color: var(--panel);
  font-size: 15px; font-weight: 600; letter-spacing: .04em;
  transition: filter .15s ease, transform .1s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: scale(.98); }
.primary-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ghost-btn {
  padding: 11px 20px; border-radius: 10px;
  border: 1px solid var(--border); color: var(--text-2);
  font-size: 14px; transition: all .15s ease;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.home-preface { margin-top: 16px; }
.preface-toggle {
  padding: 9px 14px; border-radius: 9px; font-size: 13px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--border);
  transition: all .15s ease;
}
.preface-toggle:hover { filter: brightness(1.1); }
.preface-body {
  margin-top: 12px; padding: 18px 20px;
  border-radius: 12px; background: var(--panel-2);
  border: 1px solid var(--border);
}
.preface-body h3 { font-family: var(--font-display); font-weight: 700; font-size: 15px; margin-bottom: 10px; color: var(--accent); }
.preface-body p { font-size: 14px; line-height: 2; color: var(--text-2); text-indent: 2em; }

.home-books { margin-top: 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.book-card {
  display: block; text-align: left;
  padding: 20px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.book-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.book-card .bc-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: .05em; }
.book-card .bc-meta { margin-top: 8px; font-size: 12.5px; color: var(--text-3); line-height: 1.7; }
.book-card .bc-go { margin-top: 12px; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--accent); font-weight: 600; }
.book-card .bc-go svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ================= 阅读页 ================= */
#reader {
  max-width: var(--read-width, 760px);
  margin: 0 auto;
  padding: 20px 4px 30px;
}
.chapter-head {
  text-align: center;
  padding: 30px 0 26px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 30px;
}
.ch-vol { font-size: 13px; letter-spacing: .28em; color: var(--text-3); font-family: var(--font-display); margin-bottom: 12px; }
.ch-vol .ch-vol-sub { color: var(--accent); }
.ch-title { font-family: var(--font-display); font-weight: 700; font-size: clamp(22px, 3.6vw, 28px); letter-spacing: .05em; line-height: 1.4; }
.ch-num-line { font-size: 12px; color: var(--text-3); margin-top: 10px; letter-spacing: .2em; }

.chapter-body { font-size: var(--fs-reader, 18px); line-height: var(--lh-reader, 1.8); }
.chapter-body .para {
  margin: 0 0 0.6em;
  text-indent: 2em;
  text-align: justify;
  word-break: break-word;
  overflow-wrap: break-word;
}
.chapter-body .para.center { text-align: center; text-indent: 0; }
.chapter-body .para.empty-note {
  text-indent: 0; text-align: center;
  color: var(--text-3); font-size: .85em;
  padding: 40px 0; letter-spacing: .1em;
}
.chapter-body .gap { height: 1.2em; }

/* 搜索命中 */
.chapter-body mark, #search-results mark {
  background: var(--mark); color: var(--mark-text);
  border-radius: 3px; padding: 0 2px;
}

/* ---- 评论区（Twikoo） ---- */
.comments-section {
  max-width: var(--read-width, 760px);
  margin: 56px auto 10px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}
.comments-title {
  margin: 0 0 18px;
  font-size: 16px; font-weight: 600;
  letter-spacing: .08em;
  color: var(--accent);
  font-family: var(--font-display);
}
.comments-off {
  color: var(--text-2); opacity: .7;
  font-size: 13px; line-height: 1.8;
}

/* ---- 关于本站 ---- */
.about-page { max-width: 760px; margin: 0 auto; }
.about-head {
  padding: 10px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.about-title {
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 900;
  letter-spacing: .1em;
  color: var(--text);
}
.about-sub {
  margin-top: 10px;
  font-size: 13px;
  letter-spacing: .28em;
  color: var(--accent);
  font-family: var(--font-display);
}
.about-body {
  padding: 34px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.about-avatar {
  width: 128px; height: 128px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
}
.about-note {
  margin: 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text-2);
  text-align: center;
  letter-spacing: .06em;
}
@media (max-width: 560px) {
  .about-avatar { width: 104px; height: 104px; }
  .about-note { font-size: 14px; }
}
.about-section {
  padding: 20px 4px;
  border-bottom: 1px solid var(--border);
}
.about-section h3 {
  margin: 0 0 10px;
  font-size: 16px; font-weight: 600;
  letter-spacing: .06em;
  color: var(--accent);
  font-family: var(--font-display);
}
.about-section p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.95;
  color: var(--text-2);
}
.about-list {
  margin: 0; padding: 0;
  list-style: none;
  display: flex; flex-direction: column; gap: 8px;
}
.about-list li {
  position: relative;
  padding-left: 18px;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-2);
}
.about-list li::before {
  content: "";
  position: absolute; left: 2px; top: .62em;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .8;
}

/* ---- 首页底部链接 ---- */
.home-foot {
  margin-top: 26px;
  text-align: center;
  font-size: 13px;
}
.home-foot a {
  color: var(--text-3);
  letter-spacing: .12em;
  transition: color .15s ease;
}
.home-foot a:hover { color: var(--accent); }

#chapter-nav {
  max-width: var(--read-width, 760px);
  margin: 10px auto 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 2px 6px;
  border-top: 1px solid var(--border);
}
.cnav-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px;
  font-size: 14px; color: var(--text-2);
  border: 1px solid var(--border);
  transition: all .15s ease;
}
.cnav-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.cnav-btn:disabled { opacity: .35; pointer-events: none; }
.cnav-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cnav-meta { font-size: 12.5px; color: var(--text-3); text-align: center; }

.chapter-loading {
  text-align: center; padding: 90px 0;
  color: var(--text-3); font-size: 14px; letter-spacing: .15em;
}

/* ================= 搜索页 ================= */
.search-head h2 { font-family: var(--font-display); font-weight: 700; font-size: 22px; margin-bottom: 14px; }
#search-form { display: flex; gap: 8px; }
#search-input {
  flex: 1; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--panel);
  font-size: 14px; outline: none;
  transition: border-color .15s ease;
}
#search-input:focus { border-color: var(--accent); }
.search-tip { margin-top: 10px; font-size: 12.5px; color: var(--text-3); }

.search-progress {
  display: flex; align-items: center; gap: 10px;
  margin-top: 18px; font-size: 13px; color: var(--text-2);
}
.search-progress .bar { flex: 1; height: 4px; border-radius: 3px; background: var(--border); overflow: hidden; }
.search-progress .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s ease; }

.search-results-count { margin: 18px 0 6px; font-size: 13px; color: var(--text-3); }
.search-result {
  display: block; width: 100%; text-align: left;
  padding: 14px 16px; margin-bottom: 10px;
  border-radius: 12px; background: var(--panel);
  border: 1px solid var(--border);
  transition: border-color .15s ease, transform .12s ease;
}
.search-result:hover { border-color: var(--accent); transform: translateY(-1px); }
.sr-head { font-size: 13px; color: var(--accent); margin-bottom: 6px; font-family: var(--font-display); }
.sr-head b { color: var(--text); }
.sr-body { font-size: 13.5px; line-height: 1.9; color: var(--text-2); }

/* ================= 移动端底部导航 ================= */
#bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  height: 54px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
#bottom-nav button { flex: 1; font-size: 13px; color: var(--text-2); transition: color .15s ease; }
#bottom-nav button:hover, #bottom-nav button:active { color: var(--accent); }

/* ================= 设置面板 ================= */
.settings-body { flex: 1; overflow-y: auto; padding: 4px 16px 24px; }
.set-group { padding: 14px 0; border-bottom: 1px solid var(--border); }
.set-label { font-size: 13px; color: var(--text-2); margin-bottom: 10px; display: flex; align-items: baseline; gap: 8px; }
.set-value { color: var(--accent); font-size: 12px; }

.theme-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.theme-swatch {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-3);
}
.theme-swatch .sw {
  width: 100%; aspect-ratio: 4/3; border-radius: 8px;
  border: 2px solid var(--border);
  transition: transform .12s ease, border-color .15s ease;
}
.theme-swatch.active .sw { border-color: var(--accent); transform: scale(1.06); box-shadow: var(--shadow); }

input[type="range"] {
  width: 100%; appearance: none; -webkit-appearance: none;
  height: 4px; border-radius: 3px;
  background: var(--border); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--panel); cursor: pointer;
}

select {
  width: 100%; padding: 9px 10px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel-2);
  font-size: 13.5px; outline: none;
}
select:focus { border-color: var(--accent); }

.switch-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px; color: var(--text-2);
  cursor: pointer; user-select: none;
}
.switch-row input { width: 40px; height: 22px; appearance: none; -webkit-appearance: none; border-radius: 999px; background: var(--border); position: relative; transition: background .2s ease; cursor: pointer; }
.switch-row input::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--panel); transition: left .2s ease;
}
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { left: 21px; }

#btn-reset-settings { margin-top: 18px; width: 100%; }
.settings-note { margin-top: 12px; font-size: 11.5px; color: var(--text-3); line-height: 1.8; }

/* ================= Toast ================= */
#toast {
  position: fixed; left: 50%; bottom: 70px; z-index: 120;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 18px; border-radius: 10px;
  background: var(--text); color: var(--bg);
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: var(--shadow);
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ================= 回到顶部 ================= */
#btn-top {
  position: fixed; right: 18px; bottom: 74px; z-index: 50;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease, color .15s ease;
}
#btn-top.show { opacity: 1; pointer-events: auto; }
#btn-top:hover { color: var(--accent); }
#btn-top svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ================= 响应式 ================= */
@media (max-width: 900px) {
  .home-books { grid-template-columns: 1fr; }
  #bottom-nav { display: flex; }
  .view { padding-bottom: 96px; }
  #btn-top { bottom: 66px; }
  #toast { bottom: 66px; }
}

@media (max-width: 560px) {
  #topbar { padding: 0 8px; gap: 4px; }
  .brand a { font-size: 15px; }
  .icon-btn { width: 34px; height: 34px; }
  .home-hero { padding: 26px 20px 22px; }
  .home-seal { width: 64px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ===== 首页翻书封面 ===== */
#book-cover {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; overflow: hidden;
}
#book-cover::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 130% at 50% 18%, #1d2b26 0%, #10181a 52%, #070b0d 100%);
  opacity: 1;
  transition: opacity .55s ease .18s;
}
#book-cover.leaving {
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0s linear 1.05s;
}
#book-cover.leaving::before { opacity: 0; }
.book-scene {
  perspective: 1800px; position: relative;
  transition: transform .75s cubic-bezier(.33, .7, .4, 1) .12s, opacity .75s ease .12s;
}
#book-cover.leaving .book-scene { transform: scale(.95) translateY(12px); opacity: 0; }
body.cover-done #view-home {
  animation: home-settle .85s cubic-bezier(.22, .66, .36, 1) both;
}
@keyframes home-settle {
  from { opacity: .4; transform: scale(.988) translateY(18px); }
  to { opacity: 1; transform: none; }
}
.book-scene { perspective: 1800px; position: relative; }
.book-scene::after {
  content: ""; position: absolute; left: 50%; bottom: -30px;
  width: 92%; height: 26px; transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%, rgba(0,0,0,.55), rgba(0,0,0,0) 72%);
  border-radius: 50%; filter: blur(6px);
}
.book {
  position: relative; width: min(400px, 76vw); aspect-ratio: 10 / 13.5;
  transform-style: preserve-3d;
}
.book-first-page {
  position: absolute; inset: 0;
  background: linear-gradient(105deg, #f5ecda 0%, #efe4cd 68%, #e8dcc2 100%);
  border-radius: 5px 14px 14px 5px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.14), 0 22px 54px rgba(0,0,0,.5);
}
.book-first-page::after {
  content: ""; position: absolute; top: 4px; right: -7px; bottom: 4px; width: 7px;
  background: repeating-linear-gradient(180deg, #f6eedd 0 2px, #d9c9a6 2px 3px);
  border-radius: 0 4px 4px 0;
}
.book-cover-face {
  position: absolute; inset: 0;
  transform-origin: left center;
  transform: rotateY(0deg);
  transition: transform 1.15s cubic-bezier(.24, .66, .32, 1);
  border-radius: 5px 13px 13px 5px;
  background:
    linear-gradient(160deg, rgba(255,255,255,.09) 0%, rgba(255,255,255,0) 34%),
    linear-gradient(200deg, #275245 0%, #1d3d34 46%, #162b27 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 26px 60px rgba(0,0,0,.55);
}
.book-cover-face::before {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,.32), rgba(0,0,0,0) 88%);
  border-radius: 5px 0 0 5px;
}
.book-cover-face::after {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0; width: 38%;
  background: linear-gradient(90deg, rgba(0,0,0,.30), rgba(0,0,0,0) 100%);
  pointer-events: none;
}
#book-cover.open .book-cover-face { transform: rotateY(-158deg); }
.cover-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px 30px;
}
.cover-kicker {
  font-size: 11px; letter-spacing: .5em; text-indent: .5em;
  color: rgba(243,233,214,.62);
  font-family: var(--font-display); margin-bottom: 10px;
}
.cover-author {
  font-size: 13px; font-weight: 600;
  letter-spacing: .34em; text-indent: .34em;
  color: rgba(243,233,214,.8);
  font-family: var(--font-display); margin-bottom: 22px;
}
.cover-seal {
  width: 84px; height: 84px; object-fit: cover; border-radius: 14px;
  border: 1px solid rgba(243,233,214,.28);
  box-shadow: 0 0 26px rgba(255,236,180,.18), 0 8px 20px rgba(0,0,0,.35);
  margin-bottom: 26px;
}
.cover-title {
  font-size: clamp(46px, 9vw, 68px);
  font-family: var(--font-display); font-weight: 900;
  color: #f3e9d6;
  letter-spacing: .16em; text-indent: .16em;
  text-shadow: 0 3px 18px rgba(0,0,0,.4);
}
.cover-sub {
  margin-top: 14px;
  max-width: 90%;
  text-align: center;
  font-size: 12px; letter-spacing: .12em;
  line-height: 1.9;
  color: rgba(243,233,214,.62);
  font-family: var(--font-display);
}
.cover-hint {
  position: absolute; left: 0; right: 0; bottom: 26px; text-align: center;
  font-size: 12px; letter-spacing: .3em; text-indent: .3em;
  color: rgba(243,233,214,.45);
  font-family: var(--font-display);
  animation: cover-hint-pulse 2.4s ease-in-out infinite;
}
@keyframes cover-hint-pulse {
  0%, 100% { opacity: .42; }
  50% { opacity: .9; }
}
@media (max-width: 560px) {
  .book { width: min(320px, 82vw); }
  .cover-seal { width: 64px; height: 64px; border-radius: 11px; margin-bottom: 20px; }
  .cover-kicker { margin-bottom: 6px; }
  .cover-author { margin-bottom: 18px; }
  .cover-hint { bottom: 22px; }
}

