/* ============================================================
   阅读器壳 · 样式（连续滚动 + 左右水平翻页动画版）
   - 上下滑动：正常垂直滚动
   - 左右滑动/点击：水平滑出/滑入动画 + 滚动一屏
   ============================================================ */

:root {
  --bg: #f4efe3;
  --bg-soft: #eae2cf;
  --text: #2c2416;
  --text-soft: #8a7d68;
  --accent: #9c6b3c;
  --line: #d5c9b0;
  --bar-bg: rgba(42, 34, 22, 0.82);
  --bar-text: #ede4d0;
  --shadow: rgba(0, 0, 0, 0.12);

  --xhs-top: 12px;
  --top-offset: calc(env(safe-area-inset-top, 0px) + var(--xhs-top));
  --bottom-offset: env(safe-area-inset-bottom, 0px);
}

body[data-theme="green"] {
  --bg: #cfe3d1;
  --bg-soft: #bdd6c0;
  --text: #28382a;
  --text-soft: #6b806e;
  --accent: #3a7a56;
  --line: #a5c4a9;
  --bar-bg: rgba(36, 54, 38, 0.82);
  --bar-text: #e6f2e8;
}

body[data-theme="night"] {
  --bg: #1a1b1e;
  --bg-soft: #232529;
  --text: #c8c8c8;
  --text-soft: #7a7a7a;
  --accent: #c9a06a;
  --line: #33363b;
  --bar-bg: rgba(16, 17, 19, 0.88);
  --bar-text: #d0d0d0;
}

body[data-theme="white"] {
  --bg: #fdfdfd;
  --bg-soft: #f0f0f0;
  --text: #222222;
  --text-soft: #888888;
  --accent: #a03a33;
  --line: #e2e2e2;
  --bar-bg: rgba(30, 30, 30, 0.82);
  --bar-text: #f0f0f0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC",
    STSong, "SimSun", serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.35s ease, color 0.35s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar.hidden-bar {
  transform: translateY(-100%);
}

.top-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--top-offset) + 2px) 16px 5px;
}

.top-bookinfo {
  display: flex;
  align-items: baseline;
  gap: 7px;
  text-align: center;
}

.top-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 1px;
  white-space: nowrap;
  color: var(--bar-text);
}

.top-divider {
  font-size: 11px;
  opacity: 0.35;
  color: var(--bar-text);
}

.top-sub {
  font-size: 11px;
  opacity: 0.55;
  white-space: nowrap;
  color: var(--bar-text);
}

/* ============================================================
   目录页
   ============================================================ */
.toc-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--top-offset) + 20px) 20px calc(var(--bottom-offset) + 40px);
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
  z-index: 50;
}

.toc-header {
  text-align: center;
  margin-bottom: 8px;
}

.view-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 10px;
  margin: 0 0 4px;
  color: var(--text);
}

.view-title::after {
  content: "";
  display: block;
  width: 36px;
  height: 2px;
  background: var(--accent);
  margin: 12px auto 0;
  border-radius: 1px;
}

.toc-count {
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 2px;
}

.toc-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}

.toc-item {
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.toc-item:last-child { border-bottom: none; }

.toc-btn {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  padding: 16px 4px;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, padding-left 0.2s;
  letter-spacing: 1px;
}

.toc-btn:active {
  background: var(--bg-soft);
  padding-left: 12px;
}

.toc-btn .idx {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  margin-right: 16px;
  font-variant-numeric: tabular-nums;
  min-width: 24px;
}

.toc-btn .name {
  flex: 1 1 auto;
}

.toc-btn .no {
  color: var(--text-soft);
  font-size: 11px;
  letter-spacing: 1px;
}

/* ============================================================
   搜索
   ============================================================ */
.search-box {
  position: relative;
  margin: 18px 0 14px;
}

.search-input {
  width: 100%;
  padding: 11px 38px 11px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg-soft);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  letter-spacing: 0.5px;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(156, 107, 60, 0.12);
}

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

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  display: none;
  line-height: 1;
}

.search-clear.visible {
  display: block;
}

.search-count {
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 1px;
  padding: 4px 4px 10px;
}

.search-results {
  list-style: none;
  margin: 0;
  padding: 0;
}

.search-item {
  padding: 14px 6px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.2s, padding-left 0.2s;
}

.search-item:active {
  background: var(--bg-soft);
  padding-left: 12px;
}

.search-item .ch {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 5px;
  letter-spacing: 1px;
}

.search-item .ctx {
  font-size: 14px;
  color: var(--text);
  line-height: 1.75;
}

.search-item .ctx mark {
  background: var(--accent);
  color: #fff;
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 600;
}

.search-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-soft);
  font-size: 14px;
  letter-spacing: 1px;
}

/* ============================================================
   阅读页（连续滚动）
   ============================================================ */
.reader-view {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  cursor: pointer;
}

/* 全章合并内容 */
.chapter-body {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--top-offset) + 16px) 22px 56px;
  transition: transform 0.28s ease, opacity 0.28s ease;
  will-change: transform, opacity;
}

/* 章节标题 */
.chapter-heading {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 6px;
  margin: 1.8em 0 1em;
  color: var(--text);
}

.chapter-heading::after {
  content: "";
  display: block;
  width: 36px;
  height: 2px;
  background: var(--accent);
  margin: 10px auto 0;
  border-radius: 1px;
  opacity: 0.7;
}

.chapter-block:first-child .chapter-heading {
  margin-top: 0.5em;
}

.chapter-body p {
  text-indent: 2em;
  line-height: 2.15;
  margin: 0 0 1em;
  text-align: justify;
  font-size: var(--fs, 17px);
  color: var(--text);
}

.chapter-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0.8em auto;
}

.chapter-body blockquote,
.chapter-body li {
  font-size: var(--fs, 17px);
  line-height: 2;
}

/* ---------- 左右水平翻页动画 ---------- */
.chapter-body.flip-next {
  animation: flipNext 0.5s ease;
}

.chapter-body.flip-prev {
  animation: flipPrev 0.5s ease;
}

@keyframes flipNext {
  0%   { transform: translateX(0); opacity: 1; }
  42%  { transform: translateX(-35%); opacity: 0; }
  58%  { transform: translateX(35%); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes flipPrev {
  0%   { transform: translateX(0); opacity: 1; }
  42%  { transform: translateX(35%); opacity: 0; }
  58%  { transform: translateX(-35%); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* 页面指示器 */
.page-indicator {
  position: fixed;
  bottom: calc(var(--bottom-offset) + 10px);
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-soft);
  letter-spacing: 2px;
  z-index: 1;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   底栏
   ============================================================ */
.reader-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 9px 10px calc(9px + var(--bottom-offset));
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.reader-bar.hidden-bar {
  transform: translateY(100%);
}

.bar-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
}

.bar-btn {
  font-family: inherit;
  background: rgba(255, 255, 255, 0.08);
  color: var(--bar-text);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 7px 0;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.3;
  white-space: nowrap;
  transition: background 0.2s, transform 0.15s, opacity 0.2s;
  letter-spacing: 0.5px;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.bar-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.96);
}

.bar-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.font-btn {
  font-weight: 600;
  flex: 0 0 40px;
}

/* ============================================================
   轻提示
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 200;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  letter-spacing: 1px;
  opacity: 0.95;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.2);
}

/* ============================================================
   原作者做同款入口（仅原作者原站使用，交付源码时整块移除）
   ============================================================ */
