:root {
  color-scheme: light;
  --bg: #f7f4ec;
  --surface: #fffdf8;
  --surface-2: #fbf2e4;
  --ink: #232018;
  --muted: #746b5d;
  --line: #e5d8c2;
  --brand: #8a3f21;
  --brand-2: #1f6b52;
  --brand-soft: #f3dfce;
  --green-soft: #e4f0e8;
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(138, 63, 33, 0.12), transparent 30rem),
    linear-gradient(180deg, #fbf6ec 0%, var(--bg) 36%, #f5efe4 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.7;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid rgba(229, 216, 194, 0.9);
  background: rgba(255, 253, 248, 0.9);
  backdrop-filter: blur(12px);
}

.topbar-inner,
.container {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 0;
}

.brand,
.nav,
.meta,
.item-head,
.section-head,
.pagination {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--brand);
  color: #fff8ee;
  font-family: "Songti SC", "STSong", serif;
}

.nav {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.nav a {
  padding: 7px 10px;
  border-radius: 999px;
}

.nav a:hover,
.nav a.active,
.side-list a:hover,
.side-list a.active,
.side-list button:hover,
.side-list button.active,
.pagination a.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 28px;
  padding: 58px 0 32px;
}

.page-hero {
  padding: 54px 0 34px;
}

.eyebrow,
.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  font-weight: 700;
}

.eyebrow {
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.72);
  color: var(--brand);
  font-size: 13px;
}

.pill {
  padding: 3px 9px;
  background: var(--green-soft);
  color: var(--brand-2);
  font-size: 12px;
}

.pill.brown {
  background: var(--brand-soft);
  color: var(--brand);
}

.hero h1,
.page-hero h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 14px;
  font-size: clamp(28px, 4vw, 34px);
  line-height: 1.18;
  letter-spacing: -0.03em;
}

.hero p,
.page-hero p,
.section-head p,
.item p,
.article p,
.empty-state {
  color: var(--muted);
}

.hero p,
.page-hero p {
  max-width: 740px;
  margin: 0;
  font-size: 17px;
  line-height: 1.85;
}

.page-hero-fulltext {
  padding: 4px 10px;
  border: 1px solid rgba(138, 63, 33, 0.2);
  border-radius: 999px;
  background: rgba(138, 63, 33, 0.06);
  color: #8a3f21;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
}

.page-hero-fulltext:hover {
  background: rgba(138, 63, 33, 0.12);
}

.search-panel {
  margin-top: 28px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.search-panel form,
.filter {
  display: grid;
  gap: 10px;
}

.search-panel form {
  grid-template-columns: 1fr auto;
}

.filter {
  grid-template-columns: 1.4fr repeat(2, minmax(130px, 0.4fr)) auto;
  margin-bottom: 20px;
}

.search-panel input,
.book-search-form input,
.filter input,
.filter select {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
}

.search-panel input {
  padding: 10px 12px 10px 16px;
}

.field {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.button,
.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff8ee;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button.secondary,
.pagination a {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--brand);
}

.hero-card,
.card,
.item,
.article,
.sidebar {
  border: 1px solid var(--line);
}

.hero-card {
  align-self: stretch;
  padding: 24px;
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.82);
}

.hero-card h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.card,
.item,
.article {
  background: var(--surface);
}

.stats,
.grid,
.list,
.toc,
.side-list {
  display: grid;
}

.stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fffaf1;
}

.stat strong {
  display: block;
  color: var(--brand);
  font-size: 26px;
  line-height: 1;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.section {
  padding: 30px 0;
}

.section-head {
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-head p {
  max-width: 620px;
  margin: 4px 0 0;
}

.grid {
  gap: 16px;
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.card {
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-body {
  padding: 20px;
}

.category-card {
  min-height: 180px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.category-card:hover {
  transform: translateY(-2px);
  border-color: rgba(138, 63, 33, 0.45);
}

.category-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 20px;
}

.category-card p,
.item p,
.article p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  padding-top: 10px;
}

.sidebar {
  position: sticky;
  top: 82px;
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 253, 248, 0.86);
}

.sidebar h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.side-list {
  gap: 6px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.side-list a,
.side-list button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  text-align: left;
}

.list {
  gap: 12px;
}

.item,
.article {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: var(--radius-md);
}

.item-link {
  color: inherit;
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.item-link:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.item-head {
  justify-content: space-between;
  gap: 16px;
}

.item h3,
.article h3 {
  margin: 0;
  font-size: 20px;
}

.item-subtitle {
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

.item-facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  margin: 0;
  color: #3f392f;
  font-size: 13px;
}

.item-facts dt {
  color: var(--muted);
  font-weight: 700;
}

.item-facts dd {
  min-width: 0;
  margin: 0;
}

.meta {
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px dashed var(--line);
}

.kv:first-child {
  border-top: 0;
}

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

.kv dd {
  margin: 0;
}

.detail-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}

.article-content {
  padding: 28px;
}

.article-content h2 {
  margin: 24px 0 8px;
  font-size: 22px;
}

.article-content p {
  margin: 0 0 14px;
  color: #3f392f;
}

.toc {
  gap: 8px;
}

.toc-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.toc-row span:first-child {
  color: var(--brand);
  font-weight: 800;
}

.book-entry-section {
  content-visibility: auto;
  contain-intrinsic-size: 36px;
  margin: 0;
  padding-left: var(--entry-indent);
  scroll-margin-top: 82px;
}

.book-entry-section + .book-entry-section {
  margin-top: 0;
}

.book-entry-section.is-hidden {
  display: none;
}

.book-entry-section.is-collapsed p {
  display: none;
}

.book-toc-scroll {
  max-height: min(64vh, 620px);
  margin-bottom: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.book-toc-scroll .side-list {
  margin-bottom: 0;
}

.book-entry-node {
  display: flex;
  align-items: center;
  min-height: 28px;
}

.book-entry-toggle {
  flex: 0 0 22px;
  width: 22px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #aab2bd;
  font: inherit;
  cursor: pointer;
}

.book-entry-title {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #3f392f;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
}

.book-entry-title:hover,
.book-entry-title.active {
  background: rgba(138, 63, 33, 0.06);
}

.book-entry-section p {
  margin: 6px 0 8px 22px;
  font-size: 14px;
  text-indent: 2em;
}

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

.book-browser {
  display: grid;
  gap: 16px;
}

.book-filter-bar {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.book-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.book-list-layout {
  padding-top: 0;
}

.filter-chips {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
}

.filter-label {
  padding-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filter-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip-row a,
.book-pagination a {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.filter-chip-row a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.filter-chip-row a:hover,
.filter-chip-row a.active,
.book-pagination a:hover:not(.disabled),
.book-pagination a.active {
  border-color: rgba(138, 63, 33, 0.45);
  background: var(--brand-soft);
  color: var(--brand);
}

.category-card.active {
  border-color: rgba(138, 63, 33, 0.45);
  background: #fffaf1;
}

.pagination {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.book-pagination {
  justify-content: flex-end;
  margin-top: 0;
}

.list-pagination-top {
  padding: 8px 0;
}

.filter + .list-pagination-top {
  margin-top: 4px;
}

.list-pagination-top + .list {
  margin-top: 0;
}

.list-pagination-bottom {
  padding: 8px 0;
}

.list + .list-pagination-bottom {
  margin-top: 0;
}

.book-pagination a {
  min-width: 42px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 700;
}

.book-pagination a.disabled {
  cursor: not-allowed;
  opacity: 0.46;
  pointer-events: none;
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.page-jump input {
  width: 54px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  text-align: center;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.62);
  text-align: center;
}

.footer {
  margin-top: 40px;
  padding: 28px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 920px) {
  .hero,
  .layout,
  .detail-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .grid-3,
  .grid-4,
  .filter {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    line-height: 1.58;
  }

  .topbar-inner,
  .container {
    width: min(100% - 20px, 1180px);
  }

  .topbar-inner {
    align-items: center;
    flex-direction: column;
    gap: 8px;
    padding: 10px 0;
  }

  .brand {
    gap: 8px;
    font-size: 15px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }

  .nav {
    justify-content: center;
    gap: 2px 4px;
    font-size: 13px;
  }

  .nav a {
    padding: 5px 8px;
  }

  .hero,
  .page-hero {
    padding: 26px 0 16px;
  }

  .eyebrow {
    padding: 4px 8px;
    font-size: 12px;
  }

  .hero h1,
  .page-hero h1 {
    margin: 12px 0 8px;
    font-size: 24px;
    line-height: 1.24;
  }

  .hero p,
  .page-hero p {
    font-size: 15px;
    line-height: 1.65;
  }

  .detail-shell {
    gap: 12px;
  }

  .article-content {
    padding: 10px;
    border-radius: var(--radius-md);
  }

  .book-entry-node {
    min-height: 24px;
  }

  .book-entry-toggle {
    flex-basis: 14px;
    width: 14px;
    font-size: 13px;
  }

  .book-entry-title {
    padding: 3px 4px;
    font-size: 13px;
    line-height: 1.35;
  }

  .book-entry-section {
    padding-left: 0;
    scroll-margin-top: 74px;
  }

  .book-entry-section p {
    margin: 4px 0 6px 8px;
    font-size: 13px;
    line-height: 1.72;
    text-indent: 1.35em;
  }

  .book-entry-sidebar {
    display: none;
  }

  .sidebar {
    padding: 14px;
    border-radius: var(--radius-md);
  }

  .section-head,
  .item-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-panel,
  .field {
    border-radius: var(--radius-md);
  }

  .card-body,
  .item,
  .article,
  .empty-state {
    padding: 14px;
  }

  .search-panel form,
  .stats,
  .kv,
  .item-facts,
  .book-search-form,
  .filter-chips,
  .toc-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .topbar-inner,
  .container {
    width: min(100% - 16px, 1180px);
  }

  .nav {
    font-size: 12px;
  }

  .nav a {
    padding: 4px 7px;
  }

  .hero,
  .page-hero {
    padding-top: 20px;
  }

  .hero h1,
  .page-hero h1 {
    font-size: 22px;
  }

  .article-content {
    padding: 8px;
  }

  .book-entry-title,
  .book-entry-section p {
    font-size: 12.5px;
  }

  .book-entry-section p {
    margin-left: 6px;
    line-height: 1.68;
  }
}
