:root {
  --paper: #f5efe1;
  --paper-2: #efe6d2;
  --ink: #2b2620;
  --ink-soft: #5a5247;
  --seal: #9e2b25;
  --seal-soft: #c0392b;
  --gold: #a8852c;
  --line: #d8cdb4;
  --shadow: rgba(43, 38, 32, 0.12);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Noto Serif SC", "Songti SC", "STSong", "SimSun", "Georgia", serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(168, 133, 44, 0.06), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(158, 43, 37, 0.05), transparent 45%),
    var(--paper);
  color: var(--ink);
  line-height: 1.85;
  min-height: 100vh;
}

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

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 22px; }

/* ---------- 顶部 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(245, 239, 225, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo-img { height: 38px; width: auto; display: block; }
.brand .seal {
  width: 38px; height: 38px; flex: none;
  background: var(--seal); color: #fff;
  border-radius: 6px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 20px;
  box-shadow: 0 2px 6px var(--shadow);
}
.brand .name { font-size: 20px; font-weight: 700; letter-spacing: 2px; }
.brand .name small { font-weight: 400; color: var(--ink-soft); font-size: 12px; letter-spacing: 1px; margin-left: 6px; }
.nav { display: flex; gap: 26px; font-size: 15px; }
.nav a { color: var(--ink-soft); transition: color .2s; position: relative; }
.nav a:hover { color: var(--seal); }
.nav a::after {
  content: ""; position: absolute; left: 0; bottom: -6px; width: 0; height: 2px;
  background: var(--seal); transition: width .25s;
}
.nav a:hover::after { width: 100%; }
@media (max-width: 720px) { .nav { display: none; } }

/* ---------- 英雄区 ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 78px 0 64px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.hero::before {
  content: "書"; position: absolute; right: -10px; top: -40px;
  font-size: 340px; color: rgba(168, 133, 44, 0.07);
  line-height: 1; pointer-events: none; font-weight: 700;
}
.hero h1 {
  font-size: clamp(34px, 6vw, 58px);
  letter-spacing: 8px; font-weight: 800;
  margin-bottom: 8px;
}
.hero .sub {
  font-size: clamp(15px, 2.4vw, 19px);
  color: var(--ink-soft); letter-spacing: 3px;
  margin-bottom: 26px;
}
.hero .lead {
  max-width: 720px; margin: 0 auto 30px;
  color: var(--ink-soft); font-size: 16px; line-height: 2;
}
.stats { display: flex; gap: 36px; justify-content: center; flex-wrap: wrap; }
.stat { text-align: center; }
.stat .num {
  font-size: 34px; font-weight: 800; color: var(--seal);
  display: block; line-height: 1.1;
}
.stat .lab { font-size: 13px; color: var(--ink-soft); letter-spacing: 2px; }

/* ---------- 搜索 ---------- */
.searchbar {
  margin: -28px auto 0; max-width: 640px; position: relative; z-index: 5;
}
.searchbar input {
  width: 100%; padding: 16px 46px 16px 22px;
  font-size: 16px; font-family: inherit;
  border: 1px solid var(--line); border-radius: 40px;
  background: #fffdf7; color: var(--ink);
  box-shadow: 0 8px 24px var(--shadow);
  outline: none; transition: border .2s, box-shadow .2s;
}
.searchbar input:focus { border-color: var(--gold); box-shadow: 0 8px 28px rgba(168,133,44,.22); }
.searchbar .ico {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); font-size: 18px;
}

/* ---------- 区块标题 ---------- */
.section { padding: 56px 0; }
.section-head { text-align: center; margin-bottom: 34px; }
.section-head .k {
  display: inline-block; font-size: 13px; letter-spacing: 4px;
  color: var(--seal); border: 1px solid var(--seal);
  padding: 3px 14px; border-radius: 20px; margin-bottom: 12px;
}
.section-head h2 { font-size: 30px; letter-spacing: 4px; }
.section-head p { color: var(--ink-soft); margin-top: 8px; font-size: 15px; }

/* ---------- 四部卡片 ---------- */
.cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
@media (max-width: 860px) { .cats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .cats { grid-template-columns: 1fr; } }
.cat-card {
  background: #fffdf7; border: 1px solid var(--line); border-radius: 12px;
  padding: 22px 20px; cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s;
  position: relative; overflow: hidden;
}
.cat-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px var(--shadow); border-color: var(--gold); }
.cat-card .big { font-size: 40px; font-weight: 800; color: var(--seal); line-height: 1; }
.cat-card h3 { font-size: 19px; margin: 10px 0 4px; letter-spacing: 2px; }
.cat-card .st { font-size: 13px; color: var(--gold); margin-bottom: 8px; }
.cat-card p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.7; }
.cat-card .count { position: absolute; top: 16px; right: 18px; font-size: 12px; color: var(--ink-soft); }

/* ---------- 筛选条 ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 26px; justify-content: center;
}
.chip {
  padding: 7px 16px; border-radius: 20px; font-size: 14px;
  border: 1px solid var(--line); background: #fffdf7; color: var(--ink-soft);
  cursor: pointer; transition: all .2s; letter-spacing: 1px;
}
.chip:hover { border-color: var(--gold); color: var(--ink); }
.chip.active { background: var(--seal); color: #fff; border-color: var(--seal); }

/* ---------- 书目列表 ---------- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }
.book {
  background: #fffdf7; border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 20px 18px; cursor: pointer; transition: transform .2s, box-shadow .2s, border-color .2s;
  display: flex; flex-direction: column; min-height: 100%;
}
.book:hover { transform: translateY(-3px); box-shadow: 0 10px 24px var(--shadow); border-color: var(--gold); }
.book .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.book h3 { font-size: 21px; letter-spacing: 1px; line-height: 1.3; }
.book .meta { font-size: 12.5px; color: var(--seal); margin-top: 4px; letter-spacing: 1px; }
.book .badge {
  flex: none; font-size: 12px; padding: 3px 9px; border-radius: 6px;
  background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.book .desc {
  font-size: 13.5px; color: var(--ink-soft); margin-top: 12px; line-height: 1.75;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.book .foot { margin-top: auto; padding-top: 12px; font-size: 12px; color: var(--gold); letter-spacing: 1px; }
.empty { text-align: center; color: var(--ink-soft); padding: 60px 0; font-size: 16px; }

/* ---------- 详情弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(43, 38, 32, 0.55);
  display: none; align-items: flex-start; justify-content: center;
  z-index: 100; padding: 40px 16px; overflow-y: auto;
}
.modal-mask.open { display: flex; }
.modal {
  background: var(--paper); max-width: 680px; width: 100%;
  border-radius: 14px; border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0,0,0,.3); padding: 34px 36px;
  position: relative; animation: pop .25s ease;
}
@keyframes pop { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal .close {
  position: absolute; top: 16px; right: 18px; font-size: 26px;
  color: var(--ink-soft); cursor: pointer; line-height: 1; border: none; background: none;
}
.modal .close:hover { color: var(--seal); }
.modal .m-badge {
  display: inline-block; font-size: 12px; padding: 3px 12px; border-radius: 16px;
  background: var(--seal); color: #fff; letter-spacing: 1px; margin-bottom: 12px;
}
.modal h2 { font-size: 30px; letter-spacing: 2px; }
.modal .m-meta { color: var(--seal); font-size: 14px; margin: 6px 0 18px; letter-spacing: 1px; }
.modal .m-sub { font-size: 13px; color: var(--ink-soft); border-left: 3px solid var(--gold); padding-left: 12px; margin-bottom: 20px; }
.modal .m-desc { font-size: 15.5px; line-height: 2; margin-bottom: 22px; }
.modal .m-excerpt {
  background: #fffdf7; border: 1px dashed var(--gold); border-radius: 10px;
  padding: 18px 20px; font-size: 16px; line-height: 2; color: var(--ink);
  position: relative;
}
.modal .m-excerpt::before { content: "“"; position: absolute; left: 8px; top: -6px; font-size: 40px; color: var(--gold); opacity: .4; }
.modal .m-content-label {
  font-size: 13px; letter-spacing: 3px; color: var(--seal);
  border-left: 3px solid var(--seal); padding-left: 10px; margin-bottom: 12px;
}
.modal .m-content {
  background: #fffdf7; border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 20px; margin-bottom: 6px;
  max-height: 60vh; overflow-y: auto;
}
.modal .m-passage {
  font-size: 16px; line-height: 2.1; color: var(--ink);
  padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.modal .m-passage:last-child { border-bottom: none; }
.modal .m-tags { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.modal .m-tags span {
  font-size: 12px; padding: 3px 11px; border-radius: 14px;
  background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line);
}

/* ---------- 页脚 ---------- */
.foot-note {
  border-top: 1px solid var(--line); padding: 40px 0 30px;
  text-align: center; color: var(--ink-soft); font-size: 13.5px; line-height: 1.9;
}
.foot-note .seal-line { color: var(--seal); letter-spacing: 2px; margin-bottom: 6px; }

/* ---------- 阅读页 ---------- */
.reader-page { max-width: 840px; margin: 0 auto; padding: 26px 22px 90px; }
.r-loading { text-align: center; color: var(--ink-soft); padding: 80px 0; }
.r-back { display: inline-block; margin: 6px 0 14px; color: var(--seal); font-size: 15px; letter-spacing: 1px; }
.r-back:hover { text-decoration: underline; }
.r-crumb { color: var(--gold); font-size: 14px; letter-spacing: 2px; margin-bottom: 8px; }
.r-title {
  font-size: 36px; font-weight: 700; letter-spacing: 5px; line-height: 1.3;
  margin: 2px 0 10px; position: relative; padding-bottom: 16px;
}
.r-title::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 64px; height: 3px;
  background: var(--seal); border-radius: 2px;
}
.r-meta { color: var(--ink-soft); font-size: 16px; margin-bottom: 20px; letter-spacing: 1px; }
.r-desc {
  background: rgba(255, 253, 247, 0.75); border: 1px solid var(--line);
  border-left: 4px solid var(--gold); border-radius: 8px;
  padding: 14px 18px; font-size: 16px; line-height: 2; color: var(--ink-soft); margin-bottom: 22px;
}
.r-label {
  display: inline-block; background: var(--seal); color: #fff; font-size: 13px;
  padding: 4px 14px; border-radius: 20px; letter-spacing: 3px; margin-bottom: 14px;
}
.r-label.is-excerpt { background: var(--ink-soft); }
.badge-full { background: var(--seal); color: #fff; border-color: var(--seal); }
.badge-excerpt { background: var(--paper-2); color: var(--ink-soft); }
.r-content {
  background: #fffdf7; border: 1px solid var(--line); border-radius: 12px;
  padding: 30px 34px;
}
.r-passage {
  font-size: 18px; line-height: 2.2; color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
  margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px dashed var(--line);
}
.r-passage:last-child { border-bottom: none; padding-bottom: 0; }
.r-nav {
  display: flex; justify-content: space-between; gap: 16px; margin-top: 34px; flex-wrap: wrap;
}
.r-navprev, .r-navnext { flex: 1 1 0; min-width: 0; max-width: 48%; }
.r-navprev { text-align: left; }
.r-navnext { text-align: right; }
.r-navlink { color: var(--seal); font-size: 15px; display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: top; }
.r-navlink .r-navlabel { color: var(--ink-soft); font-size: 12px; margin-right: 8px; letter-spacing: 1px; }
.r-navlink:hover { text-decoration: underline; }
.r-navlink.r-disabled { color: transparent; pointer-events: none; }
.r-empty { text-align: center; padding: 90px 0; color: var(--ink-soft); line-height: 2.4; font-size: 17px; }
.r-empty a { color: var(--seal); text-decoration: underline; }

/* 当前导航高亮 */
.nav a.active { color: var(--seal); }
.nav a.active::after { width: 100%; }

/* 书目卡片作为锚点（提升收录） */
.book { color: inherit; text-decoration: none; }

/* 阅读页翻页 */
.r-pages.paginated .r-page { display: none; }
.r-pages.paginated .r-page.active { display: block; }
.r-pager {
  display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line);
}
.r-pager button {
  font-family: inherit; font-size: 14px; padding: 8px 18px;
  border: 1px solid var(--line); background: #fffdf7; color: var(--seal);
  border-radius: 20px; cursor: pointer; transition: all .2s;
}
.r-pager button:hover { border-color: var(--seal); background: var(--seal); color: #fff; }
.r-pageinfo { font-size: 14px; color: var(--ink-soft); letter-spacing: 1px; }
.r-pagejump {
  font-family: inherit; font-size: 14px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fffdf7;
  color: var(--ink); cursor: pointer;
}

@media (max-width: 640px) {
  .r-title { font-size: 28px; letter-spacing: 3px; }
  .r-content { padding: 22px 18px; }
  .r-passage { font-size: 16.5px; line-height: 2.05; }
}
