/* ============================================================
   蛊真人 在线阅读 — 样式
   三套配色: 日 /夜 / 纸 ; 全部走 CSS 变量,JS 只切data-skin
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --maxw: 760px;
  --radius: 14px;
  --fs: 18px;          /* 正文字号, 可被 JS 覆写 */
  --lh: 1.95;          /* 行高 */
  --ls: .02em;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
          -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Songti SC", "SimSun", "Noto Serif CJK SC", Georgia, serif;
}

/* 日间(默认) */
[data-skin="day"] {
  --bg:        #f4f1ea;
  --bg-soft:   #eae6dc;
  --panel:#fffdf8;
  --line:      #ddd6c7;
  --txt:       #2b2622;
  --txt-soft:  #6b625a;
  --txt-dim:   #9a9086;
  --accent:    #8a2b2b;
  --accent-2:  #b8763a;
  --chip:      #efe9dd;
  --shadow:    0 1px 3px rgba(60,50,35,.10);
  --hl:        rgba(184,118,58,.20);
}

/* 夜间 */
[data-skin="night"] {
  --bg:        #14110f;
  --bg-soft:   #1c1815;
  --panel:     #1f1a17;
  --line:      #352d27;
  --txt:       #cfc5b8;
  --txt-soft:  #94897c;
  --txt-dim:   #6b6257;
  --accent:    #d98b5f;
  --accent-2:  #c9a227;
  --chip:      #292219;
  --shadow:    0 1px 3px rgba(0,0,0,.4);
  --hl:        rgba(217,139,95,.18);
}

/* 纸(护眼米黄) */
[data-skin="paper"] {
  --bg:        #e8dfc8;
  --bg-soft:   #ddd2b6;
  --panel:     #f2ead6;
  --line:      #cbbb98;
  --txt:       #3a3226;
  --txt-soft:  #6d6250;
  --txt-dim:   #93866e;
  --accent:    #7a4a1e;
  --accent-2:  #96702c;
  --chip:      #ddd2b6;
  --shadow:    0 1px 3px rgba(90,70,35,.14);
  --hl:        rgba(150,112,44,.20);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性必须能压过组件自身的 display，否则 [hidden] 形同虚设。
   UA 的 [hidden]{display:none} 优先级低于任何类选择器，这里显式兜住。 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--font);
  line-height: 1.6;
  transition: background .25s, color .25s;
}

button { font-family: inherit; cursor: pointer; }
b { color: var(--accent); font-weight: 600; }
.dim { color: var(--txt-dim); }

/* ============================================================
   顶栏(两页共用)
   ============================================================ */
.topbar, .readbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner, .readbar {
  display: flex; align-items: center; gap: 12px;
  max-width: var(--maxw); margin: 0 auto;
  padding: 10px 16px;
}

/* 品牌 */
.brand { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.brand-mark {
  flex: none;
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent), var(--accent-2));
  color: #fff; font-family: var(--serif);
  font-size: 22px; font-weight: 700;
  box-shadow: var(--shadow);
}
.brand-txt { min-width: 0; }
.brand h1 {
  margin: 0; font-family: var(--serif);
  font-size: 19px; letter-spacing: .08em; font-weight: 700;
}
.brand-sub { margin: 1px 0 0; font-size: 12px; color: var(--txt-dim); }

/* 按钮 */
.topbar-actions { display: flex; gap: 6px; flex: none; }
.icon-btn, .rbtn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--chip); color: var(--txt-soft);
  border: 1px solid transparent; border-radius: 9px;
  padding: 7px 10px; font-size: 13px;
  transition: background .18s, color .18s, transform .12s;
}
.icon-btn:hover, .rbtn:hover { background: var(--bg-soft); color: var(--txt); }
.icon-btn:active, .rbtn:active { transform: scale(.95); }
.icon-btn .ico, .rbtn .ico { font-size: 14px; line-height: 1; }

@media (max-width: 560px) {
  .icon-btn .lbl { display: none; }
  .icon-btn { padding: 8px 11px; }
}

/* ============================================================
   书架页
   ============================================================ */
.book {
  max-width: var(--maxw); margin: 0 auto;
  padding: 22px 16px calc(60px + env(safe-area-inset-bottom));
}

/* 继续阅读卡片 */
.resume-card {
  display: flex; align-items: center; gap: 18px;
  background: linear-gradient(135deg,
              color-mix(in srgb, var(--accent) 10%, var(--panel)),
              var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.resume-meta { flex: 1; min-width: 0; }
.resume-label {
  font-size: 11px; letter-spacing: .16em;
  color: var(--accent); text-transform: uppercase;
}
.resume-card h2 {
  margin: 5px 0 3px; font-family: var(--serif);
  font-size: 18px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.resume-card p { margin: 0; font-size: 13px; color: var(--txt-dim); }

.btn-primary {
  flex: none;
  background: var(--accent); color: #fff;
  border: 0; border-radius: 10px;
  padding: 11px 20px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
  transition: filter .18s, transform .12s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:active { transform: scale(.96); }
@media (max-width: 520px) {
  .resume-card { flex-direction: column; align-items: stretch; gap: 14px; }
  .btn-primary { width: 100%; }
}

/* 卷 */
.vol { margin-bottom: 26px; }
.vol-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 0 4px 12px; cursor: pointer;
  user-select: none;
}
.vol-no {
  font-family: var(--serif); font-size: 13px;
  color: var(--accent); letter-spacing: .1em; flex: none;
}
.vol-title {
  margin: 0; font-family: var(--serif);
  font-size: 19px; font-weight: 700; letter-spacing: .05em;
  flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vol-meta { flex: none; font-size: 12px; color: var(--txt-dim); }
.vol-arrow {
  flex: none; color: var(--txt-dim); font-size: 12px;
  transition: transform .22s;
}
.vol.collapsed .vol-arrow { transform: rotate(-90deg); }
.vol.collapsed .chap-list { display: none; }

.vol-rule { height: 1px; background: var(--line); border: 0; margin: 0 0 10px; }

/* 章节行 */
.chap-list {
  display: grid; gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.chap {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  padding: 12px 16px; text-decoration: none; color: inherit;
  transition: background .15s;
}
.chap:hover { background: var(--bg-soft); }
.chap-no {
  flex: none; min-width: 44px;
  font-family: var(--serif); font-size: 12px;
  color: var(--txt-dim); font-variant-numeric: tabular-nums;
}
.chap-name {
  flex: 1; min-width: 0; font-size: 15px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chap-name mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 2px; }
.chap-len { flex: none; font-size: 11px; color: var(--txt-dim); }
.chap.read { color: var(--txt-dim); }
.chap.read .chap-no { color: var(--accent-2); }
.chap.current {
  background: color-mix(in srgb, var(--accent) 12%, var(--panel));
  box-shadow: inset 3px 0 0 var(--accent);
}
.chap.current .chap-name { color: var(--accent); font-weight: 600; }

@media (max-width: 520px) {
  .chap-len { display: none; }
  .chap-no { min-width: 38px; font-size: 11px; }
  .chap-name { font-size: 14px; }
}

/* 搜索 */
.searchbar { border-top: 1px solid var(--line); }
.searchbar-inner {
  display: flex; gap: 8px; align-items: center;
  max-width: var(--maxw); margin: 0 auto; padding: 12px 16px;
}
#searchInput {
  flex: 1; min-width: 0;
  background: var(--panel); color: var(--txt);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 13px; font-size: 15px; outline: none;
  transition: border-color .18s;
}
#searchInput:focus { border-color: var(--accent); }
#searchInput::-webkit-search-cancel-button { filter: grayscale(1) opacity(.5); }
.btn-ghost {
  flex: none; background: var(--chip); color: var(--txt-soft);
  border: 0; border-radius: 10px; padding: 10px 14px; font-size: 14px;
}
.btn-ghost:hover { background: var(--bg-soft); }
.search-results {
  max-width: var(--maxw); margin: 0 auto;
  padding: 0 16px 16px;
  max-height: 60vh; overflow-y: auto;
}
.search-results:empty { display: none; }
.search-hint { color: var(--txt-dim); font-size: 13px; padding: 8px 4px; }

.book-foot {
  text-align: center; color: var(--txt-dim);
  font-size: 12px; padding: 30px 0 10px; line-height: 2;
}
.book-foot p { margin: 0; }

/* ============================================================
   阅读页
   ============================================================ */
.readbar-title {
  flex: 1; min-width: 0; text-align: center;
  font-family: var(--serif); font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.readbar-right { display: flex; gap: 5px; flex: none; }
@media (max-width: 520px) {
  .rbtn { padding: 7px 9px; }
  #btnA .ico, #btnB .ico { font-size: 12px; }
}

/* 进度条 */
.progress {
  position: sticky; top: calc(60px + env(safe-area-inset-top));
  height: 2px; background: var(--bg-soft); z-index: 39;
}
.progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s linear;
}

.reader {
  max-width: var(--maxw); margin: 0 auto;
  padding: 30px 22px calc(70px + env(safe-area-inset-bottom));
}

.chapter { animation: fade .28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.chapter h1 {
  margin: 0 0 6px; font-family: var(--serif);
  font-size: calc(var(--fs) + 8px); font-weight: 700;
  letter-spacing: .04em; line-height: 1.4;
}
.chap-sub {
  margin: 0 0 30px; padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--txt-dim); letter-spacing: .05em;
}

.chapter p {
  margin: 0 0 1.05em;
  font-family: var(--serif);
  font-size: var(--fs); line-height: var(--lh);
  letter-spacing: var(--ls);
  text-align: justify;
  text-indent: 2em;
  word-break: break-word;
}

.loading {
  text-align: center; color: var(--txt-dim);
  font-size: 14px; padding: 80px 0;
}
.error { text-align: center; color: var(--accent); padding: 60px 0; font-size: 14px; }

/* 上下章 */
.chapnav {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 52px 0 26px;
}
.btn-nav {
  background: var(--panel); color: var(--txt-soft);
  border: 1px solid var(--line); border-radius: 11px;
  padding: 14px 12px; font-size: 14px;
  transition: background .16s, color .16s, transform .12s, opacity .2s;
}
.btn-nav:hover:not(:disabled) { background: var(--bg-soft); color: var(--accent); }
.btn-nav:active:not(:disabled) { transform: scale(.97); }
.btn-nav:disabled { opacity: .32; cursor: not-allowed; }
.btn-nav.next { text-align: right; }

.reader-foot {
  text-align: center; color: var(--txt-dim);
  font-size: 12px; letter-spacing: .3em;
  padding: 30px 0 10px;
}

/* 回到顶部 */
.to-top {
  position: fixed; right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--panel); color: var(--txt-soft);
  border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: 17px; z-index: 45;
  opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s;
  transform: translateY(8px);
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:active { transform: scale(.92); }

@media (max-width: 520px) {
  .reader { padding: 24px 18px 60px; }
  .chapnav { grid-template-columns: 1fr; }
}

/* 无障碍:尊重减少动效 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}