:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-2: #f3efe7;
  --text: #22201c;
  --muted: #6d675d;
  --faint: #9a9387;
  --line: #e6e0d5;
  --accent: #e8590c;
  --accent-soft: #fff0e6;
  --douban: #007722;
  --douban-soft: #e7f4ea;
  --weread: #1677ff;
  --weread-soft: #e8f1ff;
  --star: #f59f00;
  --s-r: #2f9e44; --s-n: #adb5bd; --s-c: #e03131;
  --tr-1: #e8590c; --tr-2: #1971c2; --tr-3: #2f9e44; --tr-4: #9c36b5; --tr-5: #c2255c;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 14px rgba(40, 30, 10, .05);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", sans-serif;
  --font-title: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", Georgia, serif;
}
/* 英文界面：标题的拉丁字母用 Georgia，宋体的西文字形不好看 */
html[lang="en"] {
  --font-title: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513; --surface: #1f1d1a; --surface-2: #2a2723; --text: #ece8e1; --muted: #a8a196; --faint: #7d776d;
    --line: #34302b; --accent: #ff7a33; --accent-soft: #3a2518; --douban: #4cc46a; --douban-soft: #183222;
    --weread: #69a6ff; --weread-soft: #172741; --shadow: none;
    --s-r: #51cf66; --s-n: #6c737a; --s-c: #ff6b6b;
    --tr-1: #ff8a4c; --tr-2: #4dabf7; --tr-3: #69db7c; --tr-4: #da77f2; --tr-5: #f783ac;
  }
}
:root[data-theme="dark"] {
  --bg: #161513; --surface: #1f1d1a; --surface-2: #2a2723; --text: #ece8e1; --muted: #a8a196; --faint: #7d776d;
  --line: #34302b; --accent: #ff7a33; --accent-soft: #3a2518; --douban: #4cc46a; --douban-soft: #183222;
  --weread: #69a6ff; --weread-soft: #172741; --shadow: none;
  --s-r: #51cf66; --s-n: #6c737a; --s-c: #ff6b6b;
  --tr-1: #ff8a4c; --tr-2: #4dabf7; --tr-3: #69db7c; --tr-4: #da77f2; --tr-5: #f783ac;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); }
a { color: inherit; }
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 8px; z-index: 99; background: var(--surface); padding: 6px 10px; border-radius: 8px; }

/* 顶栏 */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; white-space: nowrap; }
.logo em { font-style: normal; color: var(--accent); margin-left: 4px; }
.icon-btn { display: grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.lang-btn { font: 600 13px/1 var(--font, inherit); letter-spacing: .02em; }
#menu-btn { display: none; }
.search { flex: 1; max-width: 560px; margin-left: auto; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--faint); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); }
.search kbd { font: 12px var(--font); padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; }

/* 布局 */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); max-width: 1360px; margin: 0 auto; }
.sidebar { position: sticky; top: 60px; height: calc(100vh - 60px); overflow-y: auto; padding: 18px 12px 40px; border-right: 1px solid var(--line); }
.nav { list-style: none; margin: 0 0 8px; padding: 0; }
.nav a, .topic-link { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); }
.nav a:hover, .topic-link:hover { background: var(--surface-2); color: var(--text); }
.nav a.active, .topic-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-h { margin: 18px 10px 4px; font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--faint); }
.topic-link small { color: var(--faint); font-size: 12px; }
.sidebar details summary { list-style: none; cursor: pointer; margin: 6px 0 2px; padding: 5px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.sidebar details summary::-webkit-details-marker { display: none; }
.sidebar details summary::before { content: '▸'; display: inline-block; width: 14px; color: var(--faint); transition: transform .15s; }
.sidebar details[open] summary::before { transform: rotate(90deg); }
.sidebar details summary:hover { background: var(--surface-2); }
.sidebar details .topic-link { padding-left: 24px; }
.main { min-width: 0; padding: 24px 28px 64px; outline: none; }
.loading { color: var(--muted); }

/* 列表页头 */
.page-h { margin: 0 0 4px; font: 700 28px/1.3 var(--font-title); }
.page-sub { margin: 0 0 18px; color: var(--muted); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 18px; }
.seg { display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none; padding: 3px; background: var(--surface-2); border-radius: 10px; }
.seg button { flex: none; white-space: nowrap; border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.sort { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.sort select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.count { margin-left: auto; color: var(--faint); font-size: 14px; }

/* 年代筛选 */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; font-size: 13px; }
.chips .lbl { color: var(--faint); margin-right: 4px; min-width: 6.5em; }
.chip.pick { border: 1px solid var(--line); background: var(--surface); }
.chip.pick:hover { border-color: var(--accent); color: var(--text); }
.chip.pick.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.count-line { color: var(--faint); font-size: 14px; margin: 4px 0 14px; }
.muted { color: var(--faint); font-weight: 400; font-size: 13px; }
.rest-box { margin: 22px 0; text-align: center; }
.sentinel { height: 1px; }

/* 书卡片 */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.card { display: grid; grid-template-columns: 34px 92px minmax(0, 1fr); gap: 16px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.rank { font: 700 20px/1 var(--font-title); color: var(--faint); text-align: right; padding-top: 4px; }
.card:nth-child(-n+3) .rank { color: var(--accent); }
.cover { width: 92px; aspect-ratio: 3 / 4.3; border-radius: 6px; overflow: hidden; background: var(--surface-2); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover.ph { display: grid; place-items: center; padding: 8px; text-align: center; font: 600 12px/1.35 var(--font-title);
  color: #fff; background: hsl(var(--h) 38% 46%); }
.body { min-width: 0; }
.title { margin: 0; font: 700 19px/1.35 var(--font-title); }
.title a { text-decoration: none; }
.title a:hover { color: var(--accent); }
.en { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.en .au { color: var(--faint); }
.blurb { margin: 8px 0 10px; color: var(--text); font-size: 14.5px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  text-decoration: none; white-space: nowrap; }
a.chip:hover { color: var(--text); }
.chip.douban { background: var(--douban-soft); color: var(--douban); font-weight: 600; }
.chip.weread { background: var(--weread-soft); color: var(--weread); font-weight: 600; }
.chip.free { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.warn { background: transparent; border: 1px dashed var(--line); color: var(--faint); }
.chip.hn { color: var(--accent); background: transparent; padding-left: 0; }
.card-en .title { font-family: var(--font); font-size: 17px; }
.en-only { font-family: var(--font) !important; }
.stars { color: var(--star); letter-spacing: -1px; }
.empty { padding: 48px 0; text-align: center; color: var(--muted); }

/* 详情页 */
.back { display: inline-block; margin-bottom: 16px; color: var(--muted); text-decoration: none; font-size: 14px; }
.back:hover { color: var(--accent); }
.detail { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.detail .cover { width: 220px; border-radius: 8px; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.detail .cover.ph { font-size: 18px; padding: 20px; }
.detail h1 { margin: 0; font: 700 30px/1.3 var(--font-title); }
.detail .subtitle { margin: 4px 0 0; color: var(--muted); font-size: 16px; }
.detail .en-title { margin: 10px 0 0; font-size: 16px; color: var(--muted); }
.rating-box { display: flex; align-items: center; gap: 14px; margin: 18px 0; padding: 14px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); width: fit-content; }
.rating-box .num { font: 700 34px/1 var(--font-title); color: var(--douban); }
.rating-box .num.na { font-size: 18px; color: var(--faint); }
.rating-box small { display: block; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 14px;
  border: 1px solid var(--line); background: var(--surface); }
.btn:hover { border-color: var(--accent); }
.btn.douban { background: var(--douban); border-color: var(--douban); color: #fff; }
.btn.weread { background: var(--weread); border-color: var(--weread); color: #fff; }
.btn.free { background: var(--accent); border-color: var(--accent); color: #fff; }
.section-h { margin: 28px 0 10px; font: 700 17px var(--font-title); }
.kv { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 14.5px; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; }
.note { padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; font-size: 14px; }
.editions { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.editions a { color: var(--douban); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.stat b { display: block; font: 700 22px var(--font-title); }
.stat span { color: var(--muted); font-size: 13px; }
.prose { max-width: 680px; }
.prose p, .prose li { color: var(--text); }
.prose code { padding: 1px 5px; background: var(--surface-2); border-radius: 4px; font-size: 13px; }

/* 详情页：HN */
.sec { margin-top: 28px; }
.stance { margin: 14px 0 0; max-width: 520px; }
.sbar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; gap: 2px; }
.sbar i, .dot { background: var(--s-n); }
.s-r { background: var(--s-r) !important; } .s-n { background: var(--s-n) !important; } .s-c { background: var(--s-c) !important; }
.slg { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.why { margin: 18px 0; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.why h2 { margin: 0 0 6px; font: 700 16px var(--font-title); }
.why p { margin: 6px 0; }
.why-c span { color: var(--s-c); font-weight: 600; }
.why-n { color: var(--faint); font-size: 12px; }
.why-en summary, #desc summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.why-en p, #desc p { color: var(--muted); font-size: 14px; }
#desc { margin-top: 14px; }
.chart { width: 100%; max-width: 720px; height: auto; display: block; }
.chart line { stroke: var(--line); }
.chart text { fill: var(--faint); font-size: 11px; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.comments { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; max-width: 820px; }
.comment { padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.comment-h { font-size: 13px; color: var(--faint); }
.comment-h a { color: var(--muted); text-decoration: none; }
.comment-h a:hover { color: var(--accent); }
.comment-h .who { font-weight: 600; color: var(--text); }
.comment p { margin: 6px 0; white-space: pre-line; overflow-wrap: anywhere; }
.comment mark { background: var(--accent-soft); color: inherit; padding: 0 2px; border-radius: 3px; }
.comment .thread { font-size: 13px; color: var(--faint); text-decoration: none; }
.comment .thread:hover { color: var(--accent); }
.tag { font-size: 12px; padding: 0 6px; border-radius: 99px; }
.tag-recommend { color: var(--s-r); background: color-mix(in srgb, var(--s-r) 14%, transparent); }
.tag-neutral { color: var(--muted); background: var(--surface-2); }
.tag-critical { color: var(--s-c); background: color-mix(in srgb, var(--s-c) 14%, transparent); }

/* 小卡片 */
.minis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.mini { display: flex; flex-direction: column; gap: 4px; padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; min-width: 0; }
.mini:hover { border-color: var(--accent); }
.mini .cover { width: 100%; margin-bottom: 4px; }
.mini b { font: 700 14px/1.35 var(--font-title); }
.mini small { color: var(--faint); font-size: 12px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-note { font-size: 12px; color: var(--muted); line-height: 1.4; }

/* 趋势 */
.tr-sec { margin: 0 0 40px; }
.tr-gh { margin: 22px 0 10px; font-size: 15px; }
.spark { width: 100%; height: 36px; display: block; margin-top: 4px; }
.spark line { stroke: var(--line); }
.spark .ar { fill: var(--accent-soft); }
.spark .ln { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.spark .pk { fill: var(--accent); }
.spark-x { display: flex; justify-content: space-between; font-size: 10px; color: var(--faint); }
.tr-scroll { overflow-x: auto; padding-bottom: 6px; }
.tr-bump { width: 100%; min-width: 780px; height: auto; display: block; }
.tr-bump .grid line { stroke: var(--line); }
.tr-bump .ax, .tr-cmp .ax { fill: var(--faint); font-size: 12px; }
.tr-bump .tl { fill: var(--muted); font-size: 12px; }
.tr-bump .bk-l { fill: none; stroke: var(--faint); stroke-width: 2.2; opacity: .55; }
.tr-bump .bk-d { fill: var(--faint); opacity: .7; }
.tr-bump .bk { cursor: pointer; }
.tr-bump .books:hover .bk { opacity: .18; }
.tr-bump .books .bk:hover { opacity: 1; }
.tr-bump .bk:hover .bk-l { stroke: var(--accent); stroke-width: 3.5; opacity: 1; }
.tr-bump .bk:hover .bk-d { fill: var(--accent); opacity: 1; }
.tr-search { position: relative; max-width: 520px; }
.tr-search input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tr-search input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tr-list { position: absolute; z-index: 10; left: 0; right: 0; top: 44px; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.tr-list li.muted { padding: 8px 10px; }
.tr-list button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.tr-list button:hover { background: var(--surface-2); }
.tr-list small { display: block; color: var(--faint); font-size: 12px; }
.tr-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; padding: 0; }
.tr-legend li { display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; background: var(--surface); }
.tr-legend a { text-decoration: none; }
.tr-legend .sw { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.tr-legend .x { border: 0; background: transparent; cursor: pointer; color: var(--faint); font-size: 16px; line-height: 1; padding: 0 6px; }
.tr-box { overflow-x: auto; }
.tr-cmp { width: 100%; min-width: 520px; max-width: 900px; height: auto; display: block; }
.tr-cmp .grid line { stroke: var(--line); }
.tr-cmp .cl { fill: none; stroke-width: 2.4; }
.tr-cmp .cd { opacity: 0; }
.tr-cmp .cd:hover { opacity: 1; }

/* 手机 */
@media (max-width: 860px) {
  #menu-btn { display: grid; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 30; top: 60px; left: 0; width: 260px; background: var(--bg); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .main { padding: 18px 16px 48px; }
  .search kbd, .logo em + * { display: none; }
  .logo span { font-size: 15px; }
  .card { grid-template-columns: 72px minmax(0, 1fr); gap: 12px; padding: 12px; }
  .card .rank { position: absolute; }
  .card { position: relative; }
  .card .rank { left: 8px; top: 8px; z-index: 1; padding: 2px 6px; font-size: 13px; background: var(--surface); border-radius: 6px; }
  .cover { width: 72px; }
  .title { font-size: 17px; }
  .detail { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .detail .cover { width: 160px; }
  .detail h1 { font-size: 24px; }
  .count { margin-left: 0; width: 100%; }
  .chips .lbl { width: 100%; }
  .minis { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
}
@media (max-width: 480px) {
  .logo span { display: none; }
  .topbar { gap: 6px; }
  .search { min-width: 0; }
  .icon-btn { width: 34px; }
}
