:root {
  color-scheme: light;
  --bg: #dedad3;
  --surface: #d3cec6;
  --paper: #efeeeb;
  --ink: #0a0a0a;
  --muted: #5c5852;
  --accent: #155967;
  --accent-ink: #fff;
  --page-pad: clamp(1.25rem, 3vw, 3rem);
  font-family: "Segoe UI", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
::selection { color: #fff; background: var(--accent); }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  padding: .7rem 1rem;
  color: #fff;
  background: var(--ink);
}
.skip-link:focus { top: 1rem; }

.site-header {
  min-height: 5rem;
  padding: 1.1rem var(--page-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.brand { display: inline-flex; align-items: baseline; gap: .7rem; text-decoration: none; white-space: nowrap; }
.brand strong { font-size: 1.75rem; letter-spacing: -.06em; line-height: 1; }
.brand span { font-size: .95rem; font-weight: 600; }
.header-state { color: var(--muted); font-size: .875rem; }
.menu-toggle { display: none; padding: .55rem .8rem; border: 0; background: var(--ink); color: #fff; }

.home-hero {
  min-height: min(46rem, calc(100svh - 5rem));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(20rem, .95fr);
  align-items: stretch;
  gap: clamp(2rem, 5vw, 7rem);
  padding: clamp(3rem, 9vh, 7rem) var(--page-pad) clamp(3rem, 7vh, 6rem);
}
.hero-copy { display: flex; flex-direction: column; align-items: flex-start; }
.hero-copy h1 {
  margin: 0;
  font-size: clamp(3.2rem, 6.3vw, 7.5rem);
  font-weight: 450;
  letter-spacing: -.075em;
  line-height: 1.04;
}
.hero-copy h1 span { display: block; white-space: nowrap; }
.hero-copy p { max-width: 31rem; margin: 2.2rem 0 0; font-size: clamp(1.1rem, 1.5vw, 1.4rem); line-height: 1.6; }
.primary-link {
  display: inline-flex;
  align-items: center;
  gap: 2.4rem;
  margin-top: auto;
  padding: 1rem 1.2rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  text-decoration: none;
  transition: background .2s ease, transform .2s ease;
}
.primary-link:hover { background: #175264; transform: translateY(-2px); }
.hero-search {
  align-self: end;
  min-height: 22rem;
  display: flex;
  flex-direction: column;
  padding: clamp(1.5rem, 3vw, 2.7rem);
  background: var(--paper);
}
.hero-search-title { max-width: 17rem; margin: 0 0 2.5rem; font-size: clamp(1.55rem, 2.2vw, 2.2rem); line-height: 1.25; letter-spacing: -.04em; }
.hero-search .search { margin: 0; }
.hero-search-note { max-width: 27rem; margin: auto 0 0; color: var(--muted); font-size: .95rem; line-height: 1.55; }

.search { position: relative; }
.search label { display: block; margin-bottom: .65rem; font-weight: 650; font-size: .9rem; }
.search input {
  display: block;
  width: 100%;
  min-height: 3.2rem;
  padding: .85rem .95rem;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
}
.search input::placeholder { color: #6d6963; }
.search-hint { margin: .65rem 0 0; color: var(--muted); font-size: .875rem; line-height: 1.4; }
.search-results { margin-top: .7rem; max-height: 22rem; overflow: auto; background: #fff; }
.search-results a { display: block; padding: .85rem 1rem; text-decoration: none; }
.search-results a:nth-child(even) { background: #f2f0ec; }
.search-results a:hover, .search-results a:focus-visible { background: #e7f0f1; }
.search-results strong, .search-results small, .search-results span { display: block; }
.search-results strong { font-size: .95rem; }
.search-results small { margin-top: .12rem; color: var(--accent); font-size: .78rem; }
.search-results span { margin-top: .35rem; color: var(--muted); font-size: .82rem; line-height: 1.45; }
.search-empty { padding: .9rem 1rem; color: var(--muted); font-size: .9rem; }

.directory { padding: clamp(4rem, 8vw, 8rem) var(--page-pad) clamp(6rem, 10vw, 9rem); background: var(--paper); }
.directory-intro { display: flex; align-items: baseline; justify-content: space-between; gap: 2rem; margin-bottom: 4rem; }
.directory-intro h2 { margin: 0; font-size: clamp(2.6rem, 5vw, 5rem); font-weight: 450; letter-spacing: -.065em; }
.directory-intro p { margin: 0; color: var(--muted); font-size: 1rem; }
.directory-group { display: grid; grid-template-columns: minmax(10rem, .35fr) minmax(0, .65fr); gap: 3rem; max-width: 78rem; margin: 0 0 4.5rem; }
.directory-group h2 { margin: .4rem 0 0; color: var(--muted); font-size: 1.05rem; font-weight: 500; }
.directory-rows { min-width: 0; }
.directory-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; min-height: 3.5rem; padding: .72rem 0; text-decoration: none; transition: color .2s ease, transform .2s ease; }
.directory-row:hover { color: var(--accent); transform: translateX(.3rem); }
.directory-row span { font-size: clamp(1.1rem, 1.5vw, 1.4rem); font-weight: 550; }
.directory-row small { flex: 0 0 auto; color: var(--muted); font-size: .82rem; }

.reader-layout {
  display: grid;
  grid-template-columns: minmax(13rem, 16rem) minmax(0, 53rem) minmax(10rem, 14rem);
  gap: clamp(2rem, 3vw, 4rem);
  align-items: start;
  max-width: 110rem;
  min-height: calc(100vh - 5rem);
  margin: 0 auto;
  padding: 2.5rem var(--page-pad) 8rem;
}
.site-nav { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; scrollbar-width: thin; }
.site-nav .search { padding: 0 .5rem 1rem 0; }
.site-nav .search label { font-size: .88rem; }
.site-nav .search input { min-height: 2.7rem; padding: .55rem .65rem; font-size: .9rem; }
.site-nav .search-hint { font-size: .82rem; }
.site-nav .search-results { max-height: 20rem; }
.nav-group { margin-top: 1.6rem; }
.nav-group h2 { margin: 0 0 .5rem; color: var(--muted); font-size: .83rem; font-weight: 650; }
.nav-group ul, .toc ul { margin: 0; padding: 0; list-style: none; }
.nav-group li { margin: 0; }
.nav-group a { display: block; padding: .38rem .5rem; font-size: .9rem; line-height: 1.4; text-decoration: none; }
.nav-group a:hover, .nav-group a[aria-current="page"] { color: var(--accent); background: var(--paper); }
.nav-group a[aria-current="page"] { font-weight: 700; }
.reader-main { min-width: 0; }
.breadcrumb { display: flex; gap: .6rem; align-items: center; margin: .2rem 0 2.4rem; color: var(--muted); font-size: .85rem; }
.breadcrumb a:hover { color: var(--accent); }
.toc { position: sticky; top: 2rem; max-height: calc(100vh - 4rem); overflow: auto; scrollbar-width: thin; }
.toc h2 { margin: .1rem 0 .8rem; color: var(--muted); font-size: .85rem; font-weight: 650; }
.toc li { margin: .4rem 0; }
.toc .toc-level-3 { padding-left: .8rem; }
.toc a { color: var(--muted); font-size: .83rem; line-height: 1.5; text-decoration: none; }
.toc a:hover { color: var(--accent); }

.prose { font-size: 1.05rem; line-height: 1.74; overflow-wrap: anywhere; }
.prose > h1:first-child { margin: 0 0 2rem; font-size: clamp(2.3rem, 3.5vw, 4.3rem); font-weight: 500; letter-spacing: -.05em; line-height: 1.16; }
.prose h2 { margin: 4rem 0 1.2rem; font-size: clamp(1.6rem, 2vw, 2.2rem); font-weight: 550; letter-spacing: -.035em; line-height: 1.3; scroll-margin-top: 1.5rem; }
.prose h3 { margin: 2.7rem 0 .9rem; font-size: 1.3rem; line-height: 1.35; scroll-margin-top: 1.5rem; }
.prose h4, .prose h5, .prose h6 { margin: 2rem 0 .8rem; font-size: 1.08rem; scroll-margin-top: 1.5rem; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose pre { margin: 0 0 1.35rem; }
.prose p { max-width: 70ch; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li { margin: .4rem 0; }
.prose li > ul, .prose li > ol { margin-top: .5rem; }
.prose a { color: var(--accent); text-decoration-thickness: .1em; text-underline-offset: .17em; }
.prose a:hover { color: #174d5e; }
.prose blockquote { margin-left: 0; padding: 1rem 1.3rem; background: var(--paper); color: #33312d; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose code { padding: .12rem .28rem; background: var(--paper); font-family: Consolas, "Courier New", monospace; font-size: .88em; }
.prose pre { padding: 1.2rem 1.35rem; overflow: auto; background: #161c1d; color: #edf0ed; line-height: 1.55; }
.prose pre code { padding: 0; background: transparent; color: inherit; font-size: .86rem; }
.prose table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; font-size: .93rem; line-height: 1.55; }
.prose th, .prose td { min-width: 8rem; padding: .65rem .75rem; border: 1px solid #bab5ad; text-align: left; vertical-align: top; }
.prose th { background: var(--surface); font-weight: 650; }
.prose img { max-width: 100%; height: auto; }
.prose hr { height: 0; margin: 3rem 0; border: 0; border-top: 2px solid var(--surface); }
.page-links { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 5rem 0 0; }
.page-links a { min-height: 6rem; display: flex; flex-direction: column; justify-content: space-between; padding: 1.1rem; background: var(--paper); text-decoration: none; }
.page-links a:hover { background: #e6ecea; }
.page-links a:last-child { text-align: right; }
.page-links span { color: var(--muted); font-size: .82rem; }
.page-links strong { font-size: 1rem; }

.site-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; min-height: 17rem; padding: 2.5rem var(--page-pad) 4rem; background: var(--ink); color: #f7f5f0; }
.site-footer strong { font-size: clamp(4rem, 9vw, 8rem); font-weight: 550; letter-spacing: -.08em; line-height: 1; }
.site-footer p { max-width: 32rem; margin: .7rem 0; line-height: 1.6; }
.site-footer > div:last-child { align-self: end; }
.site-footer a { color: #b6e1e6; text-underline-offset: .22em; }

@media (max-width: 1180px) {
  .reader-layout { grid-template-columns: minmax(12rem, 15rem) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 800px) {
  .header-state { display: none; }
  .menu-toggle { display: inline-block; }
  .home-hero { min-height: auto; grid-template-columns: 1fr; gap: 3rem; padding-top: 3.5rem; }
  .hero-copy h1 { font-size: clamp(3.1rem, 10vw, 5rem); }
  .hero-copy p { margin: 1.5rem 0 2rem; }
  .primary-link { margin-top: 0; }
  .hero-search { min-height: 19rem; }
  .directory-group { grid-template-columns: 1fr; gap: 1rem; }
  .directory-intro { display: block; }
  .directory-intro p { margin-top: .6rem; }
  .reader-layout { display: block; padding-top: 1rem; }
  .site-nav { display: none; position: static; max-height: none; margin-bottom: 2rem; padding: 1.2rem; background: var(--paper); }
  .site-nav.is-open { display: block; }
  .breadcrumb { margin-bottom: 1.8rem; }
  .site-footer { min-height: 0; }
}

@media (max-width: 560px) {
  .site-header { min-height: 4.4rem; }
  .brand strong { font-size: 1.55rem; }
  .hero-copy h1 { font-size: clamp(2.6rem, 11.7vw, 3.8rem); }
  .hero-search { padding: 1.3rem; }
  .directory { padding-top: 4rem; }
  .directory-intro { margin-bottom: 2.5rem; }
  .directory-group { margin-bottom: 3rem; }
  .directory-row { min-height: 3.2rem; }
  .directory-row small { display: none; }
  .prose { font-size: 1rem; }
  .prose > h1:first-child { font-size: clamp(2rem, 9vw, 2.8rem); }
  .prose h2 { margin-top: 3rem; }
  .page-links { grid-template-columns: 1fr; }
  .page-links a:last-child { text-align: left; }
  .site-footer { grid-template-columns: 1fr; gap: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .primary-link, .directory-row { transition: none; }
}
