/* ============================================================
   陌路书屋 全局样式 v1.0(移动端优先,番茄风格)
   ============================================================ */
:root {
  --accent: #ff6b35;
  --accent-dark: #e8551f;
  --accent-soft: #fff1ea;
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #232323;
  --text-2: #8a8a8a;
  --line: #ececec;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --header-h: 48px;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

.container { max-width: 680px; margin: 0 auto; padding: 0 12px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
}
.topbar .logo { font-size: 18px; font-weight: 800; color: var(--accent); letter-spacing: 1px; white-space: nowrap; }
.topbar .logo em { font-style: normal; color: var(--text); }

/* ---------- 搜索/筛选 ---------- */
.search-bar {
  flex: 1; display: flex; align-items: center; gap: 6px;
  background: var(--bg); border-radius: 18px; padding: 6px 12px;
}
.search-bar input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 14px; color: var(--text); min-width: 0;
}
.search-bar .icon { color: var(--text-2); font-size: 14px; }

.cats {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 14px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cats .chip {
  flex-shrink: 0; padding: 5px 14px; border-radius: 16px;
  background: var(--card); color: var(--text-2); font-size: 13px;
  border: 1px solid var(--line); cursor: pointer;
}
.cats .chip.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ---------- 封面墙 ---------- */
.book-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 14px 10px; padding: 6px 14px 24px;
}
@media (min-width: 520px) {
  .book-grid { grid-template-columns: repeat(4, 1fr); gap: 18px 14px; }
}
.book-card { cursor: pointer; }
.book-cover {
  position: relative; width: 100%; aspect-ratio: 3 / 4;
  border-radius: 8px; overflow: hidden; background: #e8e5e0;
  box-shadow: var(--shadow);
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book-cover .badge {
  position: absolute; top: 6px; left: 6px; font-size: 10px;
  background: rgba(0, 0, 0, 0.55); color: #fff; padding: 2px 7px; border-radius: 8px;
}
.book-title {
  margin-top: 7px; font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.book-author { font-size: 11.5px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-last {
  font-size: 11px; color: var(--accent); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.empty-tip { text-align: center; color: var(--text-2); padding: 60px 0; font-size: 14px; }

/* ---------- 详情页 ---------- */
.detail-head {
  background: linear-gradient(160deg, #2a1e16 0%, #4a2c17 55%, #1c1420 100%);
  color: #fff; padding: 22px 16px 18px;
}
.detail-top { display: flex; gap: 14px; }
.detail-cover {
  width: 108px; flex-shrink: 0; aspect-ratio: 3 / 4;
  border-radius: 8px; overflow: hidden; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 8px; }
.detail-info h1 { font-size: 20px; font-weight: 800; line-height: 1.3; }
.detail-info .author { font-size: 13px; opacity: 0.85; }
.detail-stats { display: flex; gap: 14px; font-size: 12px; opacity: 0.9; margin-top: 6px; }
.detail-stats b { font-size: 14px; display: block; }
.detail-stats span { opacity: 0.75; font-size: 11px; }

.read-btn {
  display: flex; align-items: center; justify-content: center;
  margin: 16px 0 2px; padding: 12px 0; border-radius: 24px;
  background: linear-gradient(90deg, var(--accent), #ff8f4d);
  color: #fff; font-size: 16px; font-weight: 700; letter-spacing: 4px;
  box-shadow: 0 4px 14px rgba(255, 107, 53, 0.4);
  cursor: pointer;
}

.detail-section {
  background: var(--card); margin: 10px 0; border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.detail-section h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; position: relative; padding-left: 10px; }
.detail-section h2::before {
  content: ""; position: absolute; left: 0; top: 3px; bottom: 3px;
  width: 4px; border-radius: 2px; background: var(--accent);
}
.intro-text { font-size: 14px; color: #555; line-height: 1.8; white-space: pre-wrap; }

/* 目录 */
.chapter-vol { margin-bottom: 12px; }
.chapter-vol .vol-name { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 4px; }
.chapter-list { list-style: none; }
.chapter-list li {
  padding: 11px 2px; border-bottom: 1px solid var(--line);
  font-size: 14.5px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
}
.chapter-list li:last-child { border-bottom: none; }
.chapter-list .w { font-size: 11.5px; color: var(--text-2); }

/* ---------- 阅读页 ---------- */
.reader { min-height: 100vh; background: #fffdf9; }
.reader.night { background: #141414; color: #b6b6b6; }
.reader.night .read-top, .reader.night .read-bottom, .reader.night .read-panel { background: #1e1e1e; border-color: #2a2a2a; color: #c8c8c8; }
.reader.night .read-content .chapter-title { color: #e0e0e0; }

.read-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  height: var(--header-h); background: #fffdf9;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 14px;
}
.read-top .back, .read-top .toc-btn, .read-top .set-btn { cursor: pointer; font-size: 16px; padding: 6px; color: inherit; background: none; border: none; }
.read-top .chap-name { flex: 1; text-align: center; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; }

.read-content {
  max-width: 680px; margin: 0 auto;
  padding: calc(var(--header-h) + 18px) 20px 90px;
  font-size: 17px; line-height: 1.95;
  word-break: break-word;
}
.read-content .chapter-title { font-size: 21px; font-weight: 800; text-align: center; margin-bottom: 24px; }
.read-content p { text-indent: 2em; margin: 0 0 0.9em; }
.read-content .author-line { text-align: center; color: var(--text-2); font-size: 13px; margin-bottom: 26px; }

.read-nav {
  max-width: 680px; margin: 0 auto; padding: 0 20px 16px;
  display: flex; gap: 10px;
}
.read-nav button {
  flex: 1; padding: 11px 0; border-radius: 20px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-size: 14px; cursor: pointer;
}
.read-nav button:disabled { opacity: 0.4; cursor: not-allowed; }

/* 底部栏(进度) */
.read-bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  height: 52px; background: #fffdf9; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; padding: 0 14px;
}
.read-bottom .progress-txt { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.read-bottom progress {
  flex: 1; height: 4px; appearance: none; -webkit-appearance: none; border: none;
}
.read-bottom progress::-webkit-progress-bar { background: #e5e2dc; border-radius: 2px; }
.read-bottom progress::-webkit-progress-value { background: var(--accent); border-radius: 2px; }

/* 目录抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 80;
  opacity: 0; visibility: hidden; transition: opacity 0.25s;
}
.drawer-mask.show { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(78vw, 320px); z-index: 90;
  background: var(--card); transform: translateX(-100%); transition: transform 0.28s;
  display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer .drawer-head {
  padding: 14px 16px; font-weight: 700; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.drawer .drawer-head .close { cursor: pointer; color: var(--text-2); font-size: 18px; }
.drawer .drawer-body { flex: 1; overflow-y: auto; padding: 6px 8px 20px; }
.drawer .d-vol { font-size: 12px; color: var(--text-2); padding: 10px 8px 4px; }
.drawer .d-item {
  padding: 10px 8px; border-radius: 8px; font-size: 14px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.drawer .d-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* 阅读设置面板 */
.read-panel {
  position: fixed; left: 0; right: 0; bottom: 52px; z-index: 70;
  background: #fffdf9; border-top: 1px solid var(--line);
  padding: 14px 18px; transform: translateY(120%); transition: transform 0.28s;
}
.read-panel.show { transform: translateY(0); }
.read-panel .row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.read-panel .row:last-child { margin-bottom: 0; }
.read-panel .row label { font-size: 13px; color: var(--text-2); width: 56px; flex-shrink: 0; }
.read-panel input[type="range"] { flex: 1; accent-color: var(--accent); }
.read-panel .val { font-size: 12px; color: var(--text-2); width: 40px; text-align: right; }
.read-panel .seg { display: flex; gap: 6px; }
.read-panel .seg span {
  padding: 5px 12px; border-radius: 14px; font-size: 13px;
  border: 1px solid var(--line); cursor: pointer;
}
.read-panel .seg span.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- 页脚 ---------- */
.footer {
  text-align: center; color: var(--text-2); font-size: 12px;
  padding: 22px 16px 30px;
}
.footer .brand { font-weight: 700; color: var(--accent); font-size: 13px; margin-bottom: 4px; }

/* ---------- 通用 ---------- */
.hidden { display: none !important; }
.loading { text-align: center; color: var(--text-2); padding: 50px 0; font-size: 14px; }
