:root {
  /* 宣纸作底，墨色阅读，朱砂点缀。 */
  --bg: #f5f1e8;
  --card: #fcfaf5;
  --text: #302f2b;
  --muted: #6e685f;
  --line: #e4ddd0;
  --accent: #a63d32;
  --accent-hover: #8f3229;
  --tag-bg: #eee8dc;
  --serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

main { padding: 28px 16px 48px; }

/* 栏目导航：暖白底、墨色文字，当前栏目以朱砂标记。 */
.main-header { background: var(--card); color: var(--text); border-bottom: 1px solid var(--line); }
.main-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 64px; padding-top: 12px; padding-bottom: 12px; }
.main-logo { flex-shrink: 0; font-family: var(--serif); font-size: 15px; font-weight: 700; white-space: nowrap; }
.main-nav { display: flex; flex: 1; min-width: 0; align-items: center; gap: 14px; white-space: nowrap; font-size: 15px; }
.main-nav a { padding: 4px 0; border-bottom: 2px solid transparent; }
.main-nav .section-start { border-left: 1px solid var(--line); padding-left: 16px; }
.main-nav a.active, .main-nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.main-header a:hover { color: var(--accent); }
.search-mini { display: flex; flex-shrink: 0; align-items: center; margin-left: auto; gap: 4px; min-width: 0; }
.search-mini input { width: 150px; min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); color: var(--text); font: inherit; font-size: 13px; }
.search-mini button { flex-shrink: 0; padding: 5px 0 5px 6px; border: 0; background: transparent; color: var(--accent); font: inherit; font-size: 14px; cursor: pointer; }
.search-mini button:hover { color: var(--accent-hover); }
@media (max-width: 900px) {
  .main-header .wrap { flex-wrap: wrap; gap: 10px 20px; }
  .main-nav { order: 3; flex: 0 0 100%; overflow-x: auto; gap: 20px; scrollbar-width: thin; padding-bottom: 2px; }
  .main-nav a { flex-shrink: 0; }
  .search-mini input { width: 160px; }
}
@media (max-width: 380px) {
  .main-header .wrap { gap: 10px; }
  .search-mini input { width: 135px; }
}

/* 搜索 */
.search-big { display: flex; gap: 8px; }
.search-big input {
  flex: 1; min-width: 0; height: 42px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 16px;
}
.search-big input:focus { outline: none; border-color: var(--accent); }
.search-big button {
  height: 42px; padding: 0 22px; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; font-size: 16px; cursor: pointer;
}
.search-big button:hover, .home-search-row button:hover { background: var(--accent-hover); }
.search-mini input::placeholder, .search-big input::placeholder, .home-search-row input::placeholder { color: var(--muted); opacity: 1; }
mark { background: #f6e3a1; color: inherit; padding: 0 1px; border-radius: 2px; }

.site-footer { color: var(--muted); font-size: 13px; text-align: center; padding: 24px 0 40px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px 28px;
  margin-bottom: 20px;
}

.section-title {
  font-family: var(--serif);
  font-size: 19px;
  margin: 0 0 16px;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  line-height: 1.3;
}

.muted { color: var(--muted); }

/* 首页 */
.hero { text-align: center; padding: 20px 0 8px; }
.hero h1 { font-family: var(--serif); font-size: 34px; margin: 0; letter-spacing: 6px; }
.hero p { color: var(--muted); margin: 6px 0 0; }

/* 标签 */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  display: inline-block;
  background: var(--tag-bg);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 14px;
  line-height: 1.8;
}
.tag small { color: var(--muted); margin-left: 4px; }
.tag:hover { background: var(--accent); color: #fff; }
.tag:hover small { color: var(--card); }

/* 朝代筛选栏 */
.dynasty-bar { display: flex; flex-wrap: wrap; gap: 6px 4px; }
.dynasty-bar a { padding: 2px 12px; border-radius: 4px; font-size: 15px; }
.dynasty-bar a:hover { background: var(--tag-bg); color: var(--accent); }
.dynasty-bar a.active { background: var(--accent); color: #fff; }

/* 诗文列表 */
.poem-list { list-style: none; margin: 0; padding: 0; }
.poem-list li { padding: 14px 0; border-bottom: 1px dashed var(--line); }
.poem-list li:last-child { border-bottom: 0; }
.poem-list .name { font-family: var(--serif); font-size: 18px; font-weight: 600; }
.poem-list .meta { color: var(--muted); font-size: 14px; margin-left: 8px; }
.poem-list .excerpt { color: #5c574e; font-family: var(--serif); margin-top: 2px; }
.poem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 28px; }

/* 详情 */
.poem-head { text-align: center; }
.poem-head h1 { font-family: var(--serif); font-size: 28px; margin: 0 0 6px; letter-spacing: 2px; }
.poem-head .author { color: var(--muted); }
.poem-head .author b { color: var(--text); font-weight: 400; }
.poem-head .author a:hover b { color: var(--accent); }
.poem-head .cipai-line { font-size: 14px; color: var(--muted); margin-top: 2px; }
.poem-head .cipai-line a { color: var(--accent); }
.poem-content {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 2.1;
  text-align: center;
  margin: 22px 0;
}
.poem-content p { margin: 0; }
.poem-content.long { text-align: left; text-indent: 2em; font-size: 17px; }
.poem-content.long p { margin-bottom: 8px; }
.poem-tags { justify-content: center; margin-top: 8px; }

.prose p { margin: 0 0 10px; text-align: justify; }
.prose h3 { font-size: 15px; color: var(--accent); margin: 18px 0 8px; }
.prose h3:first-child { margin-top: 0; }
.source { font-size: 13px; color: var(--muted); margin-top: 12px; }

/* 古籍 */
.guji-row { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.guji-row:last-child { border-bottom: 0; }
.guji-part { flex: none; color: var(--accent); font-weight: 600; }
.book-text p { text-indent: 2em; }
.book-text h3 { font-family: var(--serif); font-size: 17px; color: var(--text); margin: 18px 0 8px; text-indent: 0; }
.toc-volume { font-family: var(--serif); font-size: 16px; color: var(--accent); margin: 16px 0 6px; }
.toc { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 4px 16px; }
.toc li { padding: 4px 0; border-bottom: 1px dashed var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc small { margin-left: 6px; font-size: 11px; color: var(--accent); border: 1px solid var(--accent); border-radius: 3px; padding: 0 3px; }

/* 分页 */
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 36px; height: 36px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 4px; background: var(--card); font-size: 14px;
}
.pager .current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .gap { border: 0; background: none; }

.breadcrumb { font-size: 14px; line-height: 20px; color: var(--muted); margin: 0 0 16px; }
main:has(> .breadcrumb) { padding-top: 16px; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb ol { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0; min-height: 20px; list-style: none; margin: 0; padding: 0; }
.breadcrumb li { display: inline-flex; align-items: center; line-height: 20px; min-width: 0; overflow-wrap: anywhere; }
.breadcrumb-separator { margin: 0 10px; color: var(--muted); opacity: .5; }
.breadcrumb [aria-current="page"] { color: var(--text); }

@media (max-width: 600px) {
  .card { padding: 18px 16px; }
  .hero h1 { font-size: 28px; }
  .poem-content { font-size: 17px; }
}

.card, .poem-list li, .prose { overflow-wrap: anywhere; }
.poem-head h1 { line-height: 1.5; }
.toc li { white-space: normal; }
.pager a { height: auto; min-height: 36px; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@media (max-width: 600px) {
  .poem-head h1 { font-size: 24px; letter-spacing: 1px; }
  .poem-list .meta { display: block; margin-left: 0; }
  .guji-row { align-items: flex-start; }
  .toc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* 搜索区域下方的水墨山水画。 */
/* 首页首屏:水墨图作背景,搜索框叠在图上 */
.home-hero { position: relative; display: flex; align-items: center; justify-content: center; min-height: 120px; margin-bottom: 16px; padding: 16px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg) center 35% / cover no-repeat; overflow: hidden; }
.home-hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(252,250,245,.15), rgba(252,250,245,.5)); }
.home-search { position: relative; width: 100%; max-width: 560px; text-align: center; }
.home-hero-title { margin: 0 0 8px; font-size: 20px; letter-spacing: 4px; color: var(--text); text-shadow: 0 1px 2px var(--card); }
.home-search-row { display: flex; gap: 8px; background: rgba(252,250,245,.92); padding: 6px; border-radius: 8px; box-shadow: 0 4px 16px rgba(48,47,43,.08); }
.home-search-row input { flex: 1; min-width: 0; height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--text); font-size: 16px; }
.home-search-row input:focus { outline: none; border-color: var(--accent); }
.home-search-row button { height: 40px; padding: 0 22px; border: 0; border-radius: 6px; background: var(--accent); color: #fff; font-size: 16px; cursor: pointer; }
.main-header.is-home .search-mini { display: none; }

/* 站点顶部小栏：与古诗词栏目导航分开 */
.site-bar { background: var(--tag-bg); color: var(--muted); font-size: 13px; }
.site-bar-in { display: flex; align-items: center; justify-content: flex-end; min-height: 32px; }
.site-links { display: flex; gap: 16px; }
.site-links a { color: var(--muted); }
.site-links a:hover { color: var(--accent); }
.main-nav a { font-size: 15px; }

/* 卡片网格：诗题、摘要各限两行，作者另起一行，卡片高度整齐 */
.poem-grid li { display: flex; flex-direction: column; }
.poem-grid .name, .poem-grid .excerpt { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.poem-grid .name { line-height: 1.5; }
.poem-grid .meta { display: block; margin-left: 0; }
.badges { display: flex; gap: 4px; margin-top: 6px; }
.badges span { font-size: 11px; line-height: 1.6; color: var(--accent); border: 1px solid var(--accent); border-radius: 3px; padding: 0 4px; opacity: .85; }

/* 首页：主栏 + 侧栏的紧凑布局 */
.home-hero { min-height: 0; padding: 14px 16px; margin-bottom: 12px; }
.home-hero-title { font-size: 18px; margin-bottom: 6px; }
.home-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; align-items: start; }
.home-cols .card { padding: 12px 16px 14px; margin-bottom: 12px; border-radius: 6px; }
.home-cols .section-title { font-size: 16px; margin: 0; padding-left: 8px; }
.home-cols .section-title a:hover { color: var(--accent); }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.block-more { flex-shrink: 0; color: var(--muted); font-size: 13px; }
.block-more:hover { color: var(--accent); }

/* 每日一诗：左诗右评 */
.daily-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: center; }
.daily-text { text-align: center; }
.daily-title { font-family: var(--serif); font-size: 20px; margin: 0; line-height: 1.5; }
.daily-title a:hover, .daily-author a:hover { color: var(--accent); }
.daily-author { color: var(--muted); font-size: 13px; }
.daily-content { font-family: var(--serif); font-size: 16px; line-height: 1.9; margin-top: 6px; }
.daily-content p { margin: 0; }
.daily-note { margin: 0; padding-left: 14px; border-left: 1px dashed var(--line); color: var(--muted); font-size: 14px; line-height: 1.8; text-align: justify; }

/* 精选：两列，诗题 + 作者 + 首句 */
.dense-poems { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.dense-poems li { padding: 6px 0; border-bottom: 1px dashed var(--line); min-width: 0; }
.dense-poems li:nth-last-child(-n+2) { border-bottom: 0; }
.dp-name { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.dp-meta { color: var(--muted); font-size: 12px; margin-left: 6px; }
.dp-meta i { font-style: normal; color: var(--accent); border: 1px solid currentColor; border-radius: 2px; font-size: 11px; line-height: 1; padding: 1px 2px; margin-left: 4px; }
.dp-excerpt { display: block; color: #5c574e; font-family: var(--serif); font-size: 14px; line-height: 1.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 选集诗目：两两并排的小卡片 */
.collection-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }

/* 诗目列表：诗题 + 作者，一行一首 */
.title-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; font-size: 14px; line-height: 2; }
.title-list.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.title-list li { display: flex; gap: 4px; min-width: 0; white-space: nowrap; }
.title-list a { overflow: hidden; text-overflow: ellipsis; }
.title-list span { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.title-list span::before { content: "· "; }

/* 侧栏：链接网格 */
.link-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 6px; font-size: 14px; line-height: 2; }
.link-grid a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-side .link-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (max-width: 860px) {
  .home-cols { grid-template-columns: minmax(0, 1fr); }
  .link-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  main:has(.home-cols) { padding: 12px 10px 32px; }
  .daily-body { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .daily-note { padding: 8px 0 0; border-left: 0; border-top: 1px dashed var(--line); }
  .dense-poems, .collection-grid { grid-template-columns: minmax(0, 1fr); }
  .dense-poems li:nth-last-child(2) { border-bottom: 1px dashed var(--line); }
  .title-list.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .link-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* 古籍总览：四部导航、按类列出全部书名 */
.page-head { padding: 12px 16px 10px; margin-bottom: 12px; border-radius: 6px; }
.page-head .section-title { font-size: 18px; margin: 0; padding-left: 8px; }
.guji-nav .guji-row { padding: 4px 0; align-items: flex-start; }
.guji-nav .guji-part { width: 3em; line-height: 28px; }
.guji-cats { display: flex; flex-wrap: wrap; gap: 0 4px; min-width: 0; }
.guji-cats a { padding: 0 8px; border-radius: 4px; font-size: 14px; line-height: 28px; }
.guji-cats a small { color: var(--muted); font-size: 11px; margin-left: 2px; }
.guji-cats a:hover { background: var(--tag-bg); }
.guji-cats a.active { background: var(--accent); color: #fff; }
.guji-cats a.active small { color: var(--card); }
.group-row { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.group-row:last-child { border-bottom: 0; }
.group-name { flex: 0 0 5.5em; color: var(--accent); font-size: 14px; line-height: 2; font-weight: 600; }
.group-links { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5em, 1fr)); gap: 0 10px; font-size: 14px; line-height: 2; }
.group-links a { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guji-intro { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; color: #5c574e; font-size: 13px; line-height: 1.7; margin-top: 2px; }
.guji-books li { padding: 8px 0; }
.home-side .guji-side-list, .home-side .guji-chapters { grid-template-columns: minmax(0, 1fr); }
.home-side .guji-side-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 600px) {
  .group-row { flex-direction: column; gap: 0; }
  .group-name { flex-basis: auto; }
  .group-links { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 列表页：页头说明、两列诗词卡片的两行摘要 */
.page-note { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.page-prose { font-size: 14px; line-height: 1.8; }
.page-prose p:last-child { margin-bottom: 0; }
.page-head .dynasty-bar a { font-size: 14px; padding: 0 10px; line-height: 28px; }
.poem-cards li { padding: 8px 0; }
.poem-cards .dp-excerpt { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.home-main .pager { margin-top: 14px; }

/* 作者名录：名字网格 */
.author-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 0 12px; font-size: 14px; line-height: 2.1; }
.author-grid li { display: flex; align-items: baseline; gap: 4px; min-width: 0; white-space: nowrap; border-bottom: 1px dashed var(--line); }
.author-grid a { overflow: hidden; text-overflow: ellipsis; }
.author-grid small { flex-shrink: 0; color: var(--muted); font-size: 11px; }
@media (max-width: 600px) {
  .author-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 可折叠的长内容（作者生平等） */
.fold { border-bottom: 1px dashed var(--line); }
.fold:last-child { border-bottom: 0; }
.fold summary { cursor: pointer; padding: 6px 0; font-size: 15px; font-weight: 600; color: var(--accent); list-style: none; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: "＋"; display: inline-block; width: 1.4em; color: var(--muted); font-weight: 400; }
.fold[open] summary::before { content: "－"; }
.fold p { font-size: 14px; }
.fold[open] { padding-bottom: 8px; }
.title-list span { overflow: hidden; text-overflow: ellipsis; }

/* 诗词详情侧栏 */
.side-intro { margin: 0 0 8px; color: var(--muted); font-size: 13px; line-height: 1.8; text-align: justify; }
.home-side .side-titles { grid-template-columns: minmax(0, 1fr); }
.home-side .side-titles a::before { content: "· "; color: var(--muted); }

/* 全部标签 / 词牌：字母导航与分组 */
.letter-nav { display: flex; flex-wrap: wrap; gap: 4px; }
.letter-nav a { min-width: 28px; text-align: center; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; line-height: 26px; }
.letter-nav a:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.group-letter { flex-basis: 2em; font-family: var(--serif); font-size: 18px; line-height: 1.6; }
.group-links small { color: var(--muted); font-size: 11px; margin-left: 3px; }
.group-links:has(small) { grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr)); }
.group-row { scroll-margin-top: 12px; }
