:root {
  color-scheme: light;
  --ink: #17332a;
  --paper: #f5f1e8;
  --paper-deep: #ebe4d5;
  --line: #c8c0b1;
  --muted: #68736a;
  --clay: #a65332;
  --moss: #49715b;
  --serif: "Songti SC", "Noto Serif CJK SC", "STSong", serif;
  --sans: "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 82% 10%, #e8ddc5 0, transparent 25rem), var(--paper);
  font-family: var(--sans);
  line-height: 1.6;
}

a { color: inherit; }

.skip-link {
  position: fixed;
  top: 0;
  left: 1rem;
  z-index: 2;
  padding: .6rem 1rem;
  transform: translateY(-110%);
  background: var(--ink);
  color: #fff;
}

.skip-link:focus { transform: translateY(0); }

.site-header, main, footer {
  width: min(1120px, calc(100% - 3rem));
  margin-inline: auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 5.5rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: .13em;
  text-decoration: none;
}

nav { display: flex; gap: 1.25rem; }
nav a { color: var(--muted); font-size: .9rem; text-decoration: none; }
nav a:hover, nav a:focus-visible, nav a[aria-current="page"] { color: var(--clay); text-decoration: underline; text-underline-offset: .35rem; }

.hero { max-width: 700px; padding: clamp(4rem, 11vw, 8rem) 0 4rem; }

.eyebrow {
  margin: 0 0 .9rem;
  color: var(--clay);
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .16em;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); }

h1 {
  margin-bottom: 1.3rem;
  font-size: clamp(2.7rem, 7vw, 5.3rem);
  font-weight: 600;
  letter-spacing: .08em;
  line-height: 1.25;
}

.lede { max-width: 33rem; color: var(--muted); font-size: 1.08rem; }

.reading-note { display: inline-flex; gap: .6rem; align-items: center; margin-top: 1.4rem; color: var(--moss); font-size: .88rem; }

.poem-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(250px, .72fr); gap: 1.4rem; align-items: start; }

.poem-card, .author-card, .collection-note, .prose-card {
  border: 1px solid var(--line);
  background: rgb(255 253 248 / .6);
}

.poem-card { min-height: 34rem; padding: clamp(1.6rem, 5vw, 4.2rem); }

.card-topline { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: clamp(2rem, 6vw, 4rem); }
.card-topline p { margin: 0; color: var(--moss); font-size: .85rem; }
button { border: 1px solid var(--ink); padding: .5rem .85rem; background: transparent; color: var(--ink); font: inherit; font-size: .86rem; cursor: pointer; }
button:hover, button:focus-visible { background: var(--ink); color: var(--paper); }
button:disabled { cursor: wait; opacity: .55; }

.poem-card h2 { margin-bottom: 2rem; font-size: clamp(1.75rem, 4vw, 2.75rem); font-weight: 500; letter-spacing: .08em; }
.poem-content { font-family: var(--serif); font-size: clamp(1.12rem, 2.4vw, 1.45rem); letter-spacing: .08em; line-height: 2.15; }
.poem-content p { margin: 0; }
.source { margin: 3rem 0 0; color: var(--muted); font-size: .78rem; }

.author-card { position: sticky; top: 1.2rem; padding: 2rem; }
.author-card h2 { margin-bottom: 2rem; font-size: 1.55rem; }
.author-name { margin-bottom: .2rem; font-family: var(--serif); font-size: 1.8rem; letter-spacing: .08em; }
.author-dynasty { color: var(--clay); font-size: .85rem; }
.author-description { color: #4a544d; font-size: .92rem; line-height: 1.9; }

.collection-note { margin: 7rem 0; padding: clamp(2rem, 5vw, 4rem); }
.collection-note h2, .prose-card h1 { margin-bottom: 1rem; font-size: clamp(1.9rem, 4vw, 3rem); font-weight: 500; letter-spacing: .06em; }
.collection-note p { max-width: 45rem; color: var(--muted); }
.text-link { color: var(--clay); font-weight: 700; text-underline-offset: .3rem; }

.prose { max-width: 860px; padding: 5rem 0; }
.prose-card { padding: clamp(1.5rem, 4vw, 3.5rem); }
.prose-card + .prose-card { margin-top: 1.4rem; }
.prose-card h2 { margin-top: 2.5rem; font-size: 1.55rem; }
.prose-card h2:first-of-type { margin-top: 0; }
.prose-card p, .prose-card li { color: #445149; }
.prose-card code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
pre { overflow-x: auto; padding: 1rem; background: #e8e2d5; color: #283d32; font-size: .82rem; line-height: 1.75; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--moss); font-weight: 700; }

.search-page { max-width: 980px; padding: 4.5rem 0 6rem; }
.search-hero { max-width: 660px; margin-bottom: 3rem; }
.search-hero h1 { margin-bottom: 1rem; font-size: clamp(2.4rem, 6vw, 4.4rem); }
.search-hero p:last-child { color: var(--muted); }
.search-panel, .search-results { border: 1px solid var(--line); background: rgb(255 253 248 / .6); padding: clamp(1.4rem, 4vw, 2.6rem); }
.search-panel h2, .search-results h2 { margin-bottom: 1.4rem; font-size: 1.55rem; }
.search-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 1rem; align-items: end; }
.search-field { display: grid; gap: .45rem; color: var(--moss); font-size: .84rem; font-weight: 700; }
.search-field-wide { min-width: 0; }
.search-field input, .search-field select { width: 100%; min-height: 2.6rem; border: 1px solid var(--line); border-radius: 0; background: #fffdf8; color: var(--ink); font: inherit; font-size: .95rem; padding: .45rem .6rem; }
.search-form button { min-height: 2.6rem; white-space: nowrap; }
.search-results { margin-top: 1.4rem; }
.results-topline { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-bottom: 1.2rem; }
.results-topline h2, .results-topline p { margin: 0; }
.results-topline p { color: var(--muted); font-size: .88rem; }
.search-list { display: grid; gap: .85rem; }
.search-result { border-top: 1px solid var(--line); padding: 1.25rem 0; }
.search-result:last-child { padding-bottom: 0; }
.result-meta, .result-source { margin-bottom: .45rem; color: var(--moss); font-size: .8rem; }
.result-source { margin: .85rem 0 0; color: var(--muted); }
.search-result h3 { margin-bottom: .6rem; font-size: 1.35rem; font-weight: 500; letter-spacing: .06em; }
.result-excerpt { margin: 0; color: #445149; font-family: var(--serif); line-height: 1.95; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 2rem; }
.pagination span { color: var(--muted); font-size: .86rem; }

footer { display: flex; flex-wrap: wrap; gap: .65rem 1.4rem; padding: 2rem 0 3rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }
footer a { text-underline-offset: .25rem; }

@media (max-width: 760px) {
  .site-header, main, footer { width: min(100% - 2rem, 1120px); }
  .site-header { min-height: 4.7rem; }
  nav { gap: .75rem; }
  nav a { font-size: .82rem; }
  .poem-layout { grid-template-columns: 1fr; }
  .poem-card { min-height: 28rem; }
  .author-card { position: static; }
  .collection-note { margin: 4rem 0; }
  .search-page { padding-top: 3rem; }
  .search-hero { margin-bottom: 2rem; }
  .search-form { grid-template-columns: 1fr; }
  .search-form button { width: 100%; }
  .results-topline { align-items: flex-start; flex-direction: column; }
}
