/* book.shizhiyuansu.com —— 书城与阅读页
   一本书一个颜色（封面 SVG 生成），页面本身用中性色，别抢戏。
   阅读页的行宽卡在 36em 左右：再宽眼睛就要来回扫，再窄一屏装的字太少。 */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f7f6f3;
  --card: #fff;
  --tx: #22201d;
  --tx2: #6b655d;
  --line: #e5e1da;
  --brand: #8a5a2b;
  --brand-tx: #fff;
  --read-bg: #fbf9f5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 18px rgba(0, 0, 0, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --card: #1e1d22;
    --tx: #e8e5e0;
    --tx2: #9a948c;
    --line: #2e2c33;
    --brand: #c9955a;
    --brand-tx: #1a1712;
    --read-bg: #1a191e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; max-width: 100%; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 18px; }

/* ---------- 顶栏 ---------- */
.top {
  position: sticky; top: 0; z-index: 9;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 14px; height: 58px; }
.brand {
  font-family: "Songti SC", SimSun, serif;
  font-size: 20px; font-weight: 700; letter-spacing: .06em;
  color: var(--tx); white-space: nowrap;
}
.brand:hover { text-decoration: none; color: var(--brand); }

.find { display: flex; gap: 8px; margin-left: auto; flex: 1; max-width: 420px; }
.find input {
  flex: 1; min-width: 0; height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--card); color: var(--tx); font-size: 15px;
}
.find input:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 1px; }
.find button {
  height: 36px; padding: 0 16px; border: 0; border-radius: 9px;
  background: var(--brand); color: var(--brand-tx); font-size: 15px; font-weight: 600;
  cursor: pointer;
}
.find button:hover { filter: brightness(1.08); }

/* ---------- 首页 ---------- */
.hero { padding: 34px 0 10px; }
.hero h1 {
  margin: 0 0 6px;
  font-family: "Songti SC", SimSun, serif;
  font-size: 30px; letter-spacing: .04em;
}
.hero p { margin: 0; color: var(--tx2); }
.hero .stat { margin-top: 8px; font-size: 14px; }

.cat { margin: 30px 0 10px; }
.cat > h2 {
  margin: 0 0 14px; font-size: 17px; font-weight: 700;
  padding-left: 10px; border-left: 3px solid var(--brand);
}

/* 分类筛选条：书少的时候比「一类一节」好看得多 */
.chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 22px 0 16px;
}
.chips a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--tx); font-size: 14px;
  white-space: nowrap;
}
.chips a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.chips a.on {
  background: var(--brand); border-color: var(--brand); color: var(--brand-tx); font-weight: 600;
}
.chips a span {
  font-size: 12px; opacity: .62; font-variant-numeric: tabular-nums;
}

/* 书单：首页、搜索结果、分类共用一套结构（书源规则认的就是 .result-list li） */
.result-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
}
.result-list li {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.result-list li > a { display: block; }
.result-list img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 8px; margin-bottom: 9px; background: var(--line);
}
.result-list b {
  display: block; font-size: 15px; line-height: 1.4;
  font-weight: 600; color: var(--tx);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.result-list .author { margin: 4px 0 0; font-size: 13px; color: var(--tx2); }
.result-list .intro {
  margin: 6px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--tx2);
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.result-list .meta { margin: auto 0 0; padding-top: 8px; font-size: 12px; color: var(--tx2); }

/* ---------- 详情页 ---------- */
.book-head {
  display: grid; grid-template-columns: 172px 1fr; gap: 26px;
  padding: 30px 0 8px;
}
.book-head .cover img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 10px; box-shadow: var(--shadow);
}
.book-head h1 {
  margin: 0 0 8px; font-family: "Songti SC", SimSun, serif;
  font-size: 28px; line-height: 1.35; letter-spacing: .02em;
}
.book-head .author { margin: 0 0 14px; color: var(--tx2); font-size: 14px; }
.book-head .intro { margin: 0 0 12px; font-size: 15px; line-height: 1.8; }
.book-head .meta { margin: 0 0 16px; color: var(--tx2); font-size: 13px; }
.book-head .acts { margin: 0; }

.btn {
  display: inline-block; padding: 10px 20px; border-radius: 9px;
  background: var(--brand); color: var(--brand-tx);
  font-size: 15px; font-weight: 600;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }

#catalog {
  margin: 0; padding: 0; list-style: none;
  display: grid; gap: 2px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 4px;
}
#catalog li { margin: 0; }
#catalog a {
  display: block; padding: 9px 12px; border-radius: 7px;
  font-size: 14.5px; color: var(--tx);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#catalog a:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); text-decoration: none; }

/* ---------- 阅读页 ---------- */
.read { max-width: 760px; }
.crumb { padding: 18px 0 0; font-size: 13px; color: var(--tx2); }
.chapter {
  background: var(--read-bg); border: 1px solid var(--line); border-radius: 14px;
  margin: 16px 0 0; padding: 34px 34px 40px;
}
.chapter h1 {
  margin: 0 0 6px; font-family: "Songti SC", SimSun, serif;
  font-size: 24px; line-height: 1.4; letter-spacing: .02em;
}
.chapter .meta { margin: 0 0 26px; font-size: 13px; color: var(--tx2); }
#content { font-size: 17.5px; line-height: 1.95; letter-spacing: .01em; }
#content p { margin: 0 0 1.05em; text-indent: 2em; }
#content p:last-child { margin-bottom: 0; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 22px 0 40px;
}
.pager a, .pager .off {
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; color: var(--tx);
}
.pager a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pager .off { color: var(--tx2); opacity: .5; }

/* ---------- 空态 ---------- */
.empty { text-align: center; padding: 70px 0; }
.empty h1 { font-size: 22px; margin: 0 0 10px; }
.empty p { color: var(--tx2); margin: 0 0 18px; }
.empty code {
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  padding: 2px 7px; font-size: 13px;
}
.empty-tip { padding: 30px 0; color: var(--tx2); }

/* ---------- 页脚 ---------- */
.foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 22px 0 34px; }
.foot p { margin: 0 0 5px; font-size: 12.5px; color: var(--tx2); }

@media (max-width: 640px) {
  .top .wrap { height: 54px; gap: 10px; }
  .brand { font-size: 18px; }
  .find input { font-size: 14px; }
  .find button { padding: 0 12px; }
  .result-list { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
  .result-list .intro { display: none; }
  .book-head { grid-template-columns: 112px 1fr; gap: 16px; }
  .book-head h1 { font-size: 22px; }
  .chapter { padding: 22px 18px 28px; border-radius: 10px; }
  .chapter h1 { font-size: 20px; }
  #content { font-size: 17px; line-height: 1.9; }
  #catalog { grid-template-columns: 1fr; }
}
