/* ==========================================================================
   三礼语料库 · Sanli Corpus
   ========================================================================== */

:root {
  --paper: #f7f3ea;
  --paper-2: #f1eadb;
  --card: #fffdf7;
  --card-2: #fbf7ee;
  --ink: #20221e;
  --ink-2: #45483f;
  --muted: #7b7d70;
  --line: #d8cfbb;
  --line-2: #e8e0d0;
  --red: #8c2f2a;
  --red-2: #b4473f;
  --red-soft: #f3ddd7;
  --gold: #a98643;
  --green: #2f5d50;
  --blue: #3d4f6b;
  --shadow: 0 18px 44px rgba(56, 44, 24, .10);
  --serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(169, 134, 67, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 20%, rgba(140, 47, 42, .05), transparent 60%),
    var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--red-soft); color: var(--red); }

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
  letter-spacing: .02em;
}

p { margin: 0 0 1em; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: fixed; left: 12px; top: -80px; z-index: 200;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 4px;
  transition: top .2s;
}
.skip:focus { top: 12px; }

.wrap { width: min(1240px, calc(100% - 56px)); margin: 0 auto; }

/* --------------------------------------------------------------- masthead */
.masthead {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247, 243, 234, .93);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.masthead-inner {
  width: min(1240px, calc(100% - 56px));
  margin: 0 auto;
  height: 68px;
  display: flex; align-items: center; gap: 42px;
}
.brand { display: flex; align-items: center; gap: 12px; flex: none; }
.seal {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  background: var(--red); color: #f8f1df;
  font-family: var(--serif); font-size: 25px; line-height: 1;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgba(255, 248, 232, .22);
}
.seal.small { width: 34px; height: 34px; font-size: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--serif); font-size: 20px; letter-spacing: .12em; }
.brand-text small { font-size: 9px; letter-spacing: .28em; color: var(--muted); margin-top: 4px; }

.main-nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.main-nav a {
  position: relative; padding: 8px 14px; font-size: 14px; color: var(--ink-2);
  border-radius: 3px; transition: color .18s, background .18s;
}
.main-nav a:hover { color: var(--red); background: rgba(140, 47, 42, .05); }
.main-nav a.active { color: var(--red); }
.main-nav a.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2px; background: var(--red);
}
.masthead-meta { display: flex; gap: 8px; color: var(--muted); font-family: var(--serif); font-size: 13px; letter-spacing: .16em; }
.masthead-meta i { font-style: normal; color: var(--line); }

/* ------------------------------------------------------------------- hero */
.hero {
  position: relative;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, transparent 0 96%, rgba(140, 47, 42, .05) 96% 96.2%, transparent 96.2%),
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(32, 34, 30, .035) 47px 48px);
  overflow: hidden;
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(700px 420px at 78% 40%, rgba(169, 134, 67, .12), transparent 68%);
  pointer-events: none;
}
.hero-inner {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: 56px; align-items: center;
  padding-top: 74px; padding-bottom: 62px;
}
.eyebrow {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; letter-spacing: .22em; color: var(--red);
  text-transform: uppercase; margin-bottom: 18px;
}
.eyebrow span { display: inline-block; width: 26px; height: 1px; background: var(--red); }
.hero h1 {
  font-size: clamp(48px, 6.6vw, 84px);
  letter-spacing: .08em;
  line-height: 1.02;
  margin: 0 0 18px;
}
.hero-sub { font-family: var(--serif); font-size: clamp(18px, 2vw, 23px); color: var(--ink-2); letter-spacing: .06em; margin-bottom: 14px; }
.hero-desc { max-width: 620px; color: var(--muted); font-size: 14.5px; line-height: 1.85; margin-bottom: 30px; }

.hero-search {
  display: flex; align-items: stretch; max-width: 660px;
  background: var(--card); border: 1px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(32, 34, 30, .07);
}
.hero-search input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  padding: 17px 20px; font-size: 16px; outline: none;
}
.hero-search input::placeholder { color: #a3a294; }
.hero-search button {
  flex: none; border: 0; background: var(--red); color: #fff8ea;
  padding: 0 30px; font-family: var(--serif); font-size: 17px; letter-spacing: .2em;
  transition: background .18s;
}
.hero-search button:hover { background: #74231f; }

.examples { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; font-size: 13px; color: var(--muted); }
.examples > span { margin-right: 2px; }
.examples a {
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 253, 247, .55); transition: all .18s;
}
.examples a:hover { border-color: var(--red); color: var(--red); background: var(--card); }
.examples a.more { border-color: transparent; color: var(--red); padding-right: 0; }

.hero-art { display: flex; justify-content: center; }
.hero-art-frame {
  position: relative; width: min(100%, 330px); aspect-ratio: 3 / 4;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255,253,247,.7), rgba(241,234,219,.35)),
    repeating-linear-gradient(45deg, transparent 0 9px, rgba(169,134,67,.05) 9px 10px);
  display: grid; place-items: center;
  box-shadow: 14px 14px 0 rgba(140, 47, 42, .06);
}
.hero-art-frame::before, .hero-art-frame::after {
  content: ""; position: absolute; width: 26px; height: 26px; border-color: var(--gold); border-style: solid;
}
.hero-art-frame::before { left: 12px; top: 12px; border-width: 1px 0 0 1px; }
.hero-art-frame::after { right: 12px; bottom: 12px; border-width: 0 1px 1px 0; }
.hero-art-char {
  font-family: var(--serif); font-size: clamp(120px, 15vw, 190px); color: var(--red);
  line-height: 1; opacity: .9; transform: translateY(-6px);
  text-shadow: 5px 5px 0 rgba(140, 47, 42, .08);
}
.hero-art-caption {
  position: absolute; bottom: 28px; left: 0; right: 0; text-align: center;
  font-family: var(--serif); font-size: 12px; letter-spacing: .3em; color: var(--muted);
}

.hero-stats {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
}
.hero-stats > div { padding: 20px 8px 22px; text-align: center; border-right: 1px solid var(--line-2); }
.hero-stats > div:last-child { border-right: 0; }
.hero-stats strong { display: block; font-family: var(--serif); font-size: 25px; font-weight: 700; color: var(--ink); letter-spacing: .03em; }
.hero-stats span { display: block; margin-top: 2px; font-size: 11px; letter-spacing: .18em; color: var(--muted); }

/* ---------------------------------------------------------------- section */
.section { padding: 66px 0 4px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.section-head h2 { font-size: 30px; letter-spacing: .04em; }
.section-head .eyebrow { margin-bottom: 10px; }
.text-link { color: var(--red); font-size: 13.5px; letter-spacing: .04em; }
.text-link:hover { text-decoration: underline; text-underline-offset: 4px; }
.text-link.small { font-size: 12px; }

.book-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.book-card {
  position: relative; display: flex; flex-direction: column;
  min-height: 300px; padding: 26px 26px 20px;
  background: var(--card); border: 1px solid var(--line);
  transition: transform .22s, box-shadow .22s, border-color .22s;
  overflow: hidden;
}
.book-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--red); }
.book-card.accent-yili::before { background: var(--green); }
.book-card.accent-liji::before { background: var(--blue); }
.book-card:hover { transform: translateY(-5px); box-shadow: var(--shadow); border-color: #c9bda4; }
.book-card-top { display: flex; align-items: flex-start; justify-content: space-between; }
.book-card-label { font-size: 11px; letter-spacing: .24em; color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; }
.book-card-count { font-family: var(--serif); font-size: 38px; line-height: 1; color: var(--red); }
.accent-yili .book-card-count { color: var(--green); }
.accent-liji .book-card-count { color: var(--blue); }
.book-card-count small { font-size: 12px; color: var(--muted); margin-left: 2px; }
.book-card h3 { font-size: 34px; letter-spacing: .18em; margin: 26px 0 14px; }
.book-card p { color: var(--muted); font-size: 13.5px; line-height: 1.85; flex: 1; }
.book-card-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line-2); padding-top: 14px; font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.book-card-foot .go { color: var(--red); }

.features-section { padding-bottom: 30px; }
.feature-grid { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.feature {
  padding: 26px 24px 30px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 247, .42); transition: background .2s;
}
.feature:hover { background: var(--card); }
.feature-num { font-family: var(--serif); font-size: 13px; color: var(--red); letter-spacing: .1em; }
.feature h3 { font-size: 19px; margin: 16px 0 10px; letter-spacing: .06em; }
.feature p { font-size: 13px; color: var(--muted); line-height: 1.8; margin: 0; }
.feature code { font-family: var(--mono); font-size: 12px; color: var(--ink-2); background: var(--paper-2); padding: 1px 4px; }

.quote-band { margin-top: 56px; background: var(--ink); color: #eee7d7; }
.quote-inner { padding: 54px 0; text-align: center; }
.quote-band blockquote { margin: 0; font-family: var(--serif); font-size: clamp(20px, 2.6vw, 30px); letter-spacing: .08em; line-height: 1.7; }
.quote-band cite { display: block; margin-top: 16px; font-style: normal; font-size: 12px; letter-spacing: .2em; color: #a9a08c; }

/* --------------------------------------------------------------- page head */
.page-head { padding: 54px 0 30px; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: clamp(34px, 4.2vw, 48px); letter-spacing: .1em; }
.page-head > p:last-child { margin: 12px 0 0; color: var(--muted); font-size: 14px; max-width: 720px; }

/* ----------------------------------------------------------------- search */
.search-layout {
  display: grid; grid-template-columns: 296px minmax(0, 1fr);
  gap: 38px; padding-top: 34px; padding-bottom: 80px; align-items: start;
}
.facets {
  position: sticky; top: 92px;
  background: var(--card); border: 1px solid var(--line); padding: 22px 20px;
  max-height: calc(100vh - 112px); overflow: auto;
}
.facet-block { margin-bottom: 20px; }
.facet-title-row { display: flex; align-items: center; justify-content: space-between; }
.facet-title { display: block; font-size: 11px; letter-spacing: .18em; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.facet-input, .facet-select {
  width: 100%; border: 1px solid var(--line); background: #fffef9;
  padding: 10px 12px; font-size: 14px; outline: none; border-radius: 2px;
}
.facet-input:focus, .facet-select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(140, 47, 42, .08); }
.facet-hint { font-size: 11.5px; line-height: 1.7; color: var(--muted); margin: 8px 0 0; background: var(--paper); padding: 8px 10px; border-left: 2px solid var(--line); }
.radio-list { display: flex; flex-direction: column; gap: 7px; }
.radio-list label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.radio-list input { accent-color: var(--red); }
.check-list { display: flex; flex-direction: column; gap: 7px; }
.book-check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.book-check-row input { accent-color: var(--red); }
.book-check-row em { margin-left: auto; font-style: normal; font-size: 11px; color: var(--muted); }
.link-btn { border: 0; background: none; color: var(--red); font-size: 11px; padding: 0; }
.facet-row { display: flex; gap: 10px; }
.facet-block.half { flex: 1; min-width: 0; }
.facet-actions { display: flex; gap: 8px; margin-top: 24px; }
.btn {
  border: 1px solid var(--ink); background: var(--card); padding: 10px 18px;
  font-size: 13.5px; letter-spacing: .08em; transition: all .18s; border-radius: 2px;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff8ec; flex: 1; }
.btn.primary:hover { background: #74231f; }
.btn.ghost:hover { border-color: var(--red); color: var(--red); }
.btn.tiny { padding: 5px 12px; font-size: 12px; border-color: var(--line); }
.btn.tiny:hover { border-color: var(--red); color: var(--red); }
.history { border-top: 1px solid var(--line-2); padding-top: 16px; margin-top: 4px; }
.history-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.history-chips a { font-size: 12px; padding: 2px 8px; border: 1px solid var(--line); color: var(--ink-2); }
.history-chips a:hover { border-color: var(--red); color: var(--red); }

.results-panel { min-width: 0; min-height: 500px; }
.results-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 18px;
  padding-bottom: 14px; border-bottom: 2px solid var(--ink);
}
.results-summary { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.results-summary strong { font-family: var(--serif); font-size: 22px; color: var(--red); letter-spacing: .04em; }
.results-summary span { font-size: 13px; color: var(--ink-2); }
.results-summary span b { color: var(--red); font-size: 15px; }
.results-summary em { font-style: normal; font-size: 11.5px; color: var(--muted); }
.results-tools { flex: none; }

.result-table { border-bottom: 1px solid var(--line); }
.result-table-head {
  display: grid; grid-template-columns: 52px 1fr;
  font-size: 10.5px; letter-spacing: .2em; color: var(--muted);
  padding: 9px 8px; border-bottom: 1px solid var(--line-2); background: rgba(241, 234, 219, .35);
}
.result-row {
  display: grid; grid-template-columns: 52px minmax(0, 1fr);
  padding: 15px 8px 16px; border-bottom: 1px solid var(--line-2);
  transition: background .15s;
}
.result-row:hover { background: rgba(255, 253, 247, .8); }
.res-idx { font-family: var(--serif); color: var(--muted); font-size: 13px; padding-top: 3px; }
.res-src { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 12px; }
.res-src a { color: var(--red); font-weight: 600; }
.res-src a:hover { text-decoration: underline; text-underline-offset: 3px; }
.res-src span { color: var(--muted); font-size: 11px; border-left: 1px solid var(--line); padding-left: 10px; }
.kwic {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px; align-items: baseline;
  font-family: var(--serif); font-size: 16.5px; line-height: 1.95; letter-spacing: .01em;
  word-break: break-all;
}
.kw-left { text-align: right; color: var(--ink-2); }
.kw-key { color: var(--red); font-weight: 700; white-space: nowrap; }
.kw-right { text-align: left; color: var(--ink-2); }
.kw-left .ell, .kw-right .ell { font-style: normal; color: #b3ab97; }
mark.hit { background: var(--red-soft); color: var(--red); font-weight: 700; padding: 0 1px; border-radius: 1px; }
mark.hit.soft { background: rgba(180, 71, 63, .10); color: var(--red); font-weight: 600; }
mark.hit.key { background: var(--red-soft); }

.results-foot { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0 0; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager a { min-width: 30px; height: 30px; display: grid; place-items: center; padding: 0 8px; border: 1px solid var(--line); background: var(--card); font-size: 12.5px; }
.pager a:hover { border-color: var(--red); color: var(--red); }
.pager a.current { background: var(--red); border-color: var(--red); color: #fff8ec; }
.pager a.disabled { pointer-events: none; opacity: .35; }
.pager .gap { color: var(--muted); padding: 0 2px; }

.results-empty { text-align: center; padding: 70px 24px; border: 1px dashed var(--line); background: rgba(255, 253, 247, .45); }
.results-empty.intro { border-style: solid; background: var(--card); }
.empty-seal {
  width: 62px; height: 62px; margin: 0 auto 20px; display: grid; place-items: center;
  font-family: var(--serif); font-size: 34px; color: var(--red);
  border: 1px solid var(--red); border-radius: 3px; transform: rotate(-3deg);
}
.results-empty h2 { font-size: 24px; margin-bottom: 10px; }
.results-empty p { color: var(--muted); font-size: 13.5px; }
.results-empty .error-text { color: var(--red); font-family: var(--mono); font-size: 12.5px; }
.syntax-cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 28px 0 8px; text-align: left; }
.syntax-cards > div { border: 1px solid var(--line-2); background: var(--card-2); padding: 12px; }
.syntax-cards strong { display: block; font-size: 10px; letter-spacing: .15em; color: var(--muted); margin-bottom: 6px; }
.syntax-cards span { display: block; font-family: var(--serif); color: var(--red); font-size: 14px; margin-bottom: 4px; }
.syntax-cards em { display: block; font-style: normal; font-size: 10.5px; color: var(--muted); }
.empty-history { font-size: 12px !important; margin-top: 16px; }
.empty-history a { color: var(--red); }

/* ----------------------------------------------------------------- browse */
.browse-wrap { padding-top: 20px; padding-bottom: 80px; }
.book-section { padding: 38px 0 40px; border-bottom: 1px solid var(--line); }
.book-section:last-child { border-bottom: 0; }
.book-section-head { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; gap: 24px; align-items: start; margin-bottom: 26px; }
.book-ord { font-family: var(--serif); font-size: 40px; color: var(--line); line-height: 1; padding-top: 4px; }
.book-section-head h2 { font-size: 38px; letter-spacing: .14em; margin-bottom: 8px; }
.book-section-head p { margin: 0; color: var(--muted); font-size: 13.5px; max-width: 640px; line-height: 1.85; }
.book-meta { display: flex; gap: 26px; margin: 2px 0 0; }
.book-meta div { text-align: right; }
.book-meta dt { font-size: 10px; letter-spacing: .2em; color: var(--muted); }
.book-meta dd { margin: 2px 0 0; font-family: var(--serif); font-size: 22px; }
.chapter-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); }
.chapter-grid li { background: var(--card); }
.chapter-grid a { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 13px 16px; transition: background .16s; }
.chapter-grid a:hover { background: var(--paper-2); }
.ch-no { font-family: var(--serif); font-size: 12px; color: var(--muted); }
.ch-name { font-family: var(--serif); font-size: 16px; letter-spacing: .05em; }
.ch-meta { font-size: 10.5px; color: var(--muted); }

/* ----------------------------------------------------------------- reader */
.reader-layout {
  display: grid; grid-template-columns: 236px minmax(0, 1fr);
  gap: 44px; padding-top: 30px; padding-bottom: 80px; align-items: start;
  max-width: 1180px;
}
.reader-side { position: sticky; top: 92px; max-height: calc(100vh - 112px); overflow: auto; padding-right: 8px; }
.reader-side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.side-book { border-bottom: 1px solid var(--line-2); }
.side-book summary {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 2px; cursor: pointer; font-family: var(--serif); font-size: 16px; list-style: none;
}
.side-book summary::-webkit-details-marker { display: none; }
.side-book summary::before { content: "＋"; font-size: 12px; color: var(--muted); margin-right: 6px; }
.side-book[open] summary::before { content: "－"; }
.side-book summary span { margin-left: auto; color: var(--muted); font-size: 10px; font-family: var(--sans); }
.side-book ol { list-style: none; margin: 0 0 8px; padding: 0 0 0 20px; }
.side-book li { font-size: 12.5px; line-height: 1.5; }
.side-book li a { display: block; padding: 4px 0; color: var(--ink-2); }
.side-book li a:hover { color: var(--red); }
.side-book li.current a { color: var(--red); font-weight: 700; }
.side-book li.current a::before { content: "▸ "; }

.reader-main { min-width: 0; }
.crumbs { display: flex; gap: 8px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); margin-bottom: 22px; }
.crumbs a:hover { color: var(--red); }
.crumbs em { font-style: normal; color: var(--ink-2); }
.chapter-head { padding-bottom: 24px; border-bottom: 2px solid var(--ink); margin-bottom: 0; }
.chapter-book { font-size: 11px; letter-spacing: .28em; color: var(--red); margin-bottom: 10px; }
.chapter-head h1 { font-size: clamp(34px, 4.4vw, 50px); letter-spacing: .16em; }
.chapter-meta { margin: 12px 0 0; font-size: 11.5px; letter-spacing: .1em; color: var(--muted); }

.reader-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 0; border-bottom: 1px solid var(--line-2); margin-bottom: 0;
}
.reader-search { display: flex; align-items: center; gap: 6px; flex: 1; max-width: 340px; }
.reader-search input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card); padding: 7px 10px; font-size: 12.5px; outline: none; }
.reader-search input:focus { border-color: var(--red); }
.reader-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.icon-btn { border: 1px solid var(--line); background: var(--card); padding: 6px 10px; font-size: 11.5px; color: var(--ink-2); }
.icon-btn:hover { border-color: var(--red); color: var(--red); }

.chapter-body {
  background: var(--card);
  border: 1px solid var(--line); border-top: 0;
  padding: 46px 58px 50px;
  box-shadow: 0 22px 50px rgba(56, 44, 24, .07);
}
.para {
  position: relative;
  font-family: var(--serif);
  font-size: var(--reader-size, 19px);
  line-height: 2.05;
  text-indent: 2em;
  margin: 0 0 .95em;
  letter-spacing: .015em;
  color: #262821;
}
.para:last-child { margin-bottom: 0; }
.pnum {
  position: absolute; left: -3.1em; top: .55em;
  font-family: var(--sans); font-size: 9.5px; color: #bdb49f;
  letter-spacing: 0; text-indent: 0; user-select: none;
}
.chapter-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 28px; }
.chapter-nav a {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  border: 1px solid var(--line); background: var(--card); transition: all .18s;
}
.chapter-nav a:hover { border-color: var(--red); background: #fffef9; }
.chapter-nav a span { font-size: 10px; letter-spacing: .18em; color: var(--muted); }
.chapter-nav a strong { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: .06em; }
.chapter-nav a.next { text-align: right; }
.chapter-nav .placeholder { border: 1px dashed var(--line-2); }

/* ------------------------------------------------------------------ stats */
.stats-wrap { padding-top: 32px; padding-bottom: 80px; }
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.stat-card { border: 1px solid var(--line); background: var(--card); padding: 20px 22px; position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; right: -18px; bottom: -24px; width: 70px; height: 70px; border: 1px solid var(--line-2); border-radius: 50%; }
.stat-card span { display: block; font-size: 10.5px; letter-spacing: .2em; color: var(--muted); }
.stat-card strong { display: inline-block; font-family: var(--serif); font-size: 34px; margin-top: 8px; letter-spacing: .02em; }
.stat-card em { font-style: normal; font-size: 11px; color: var(--muted); margin-left: 5px; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.panel { border: 1px solid var(--line); background: var(--card); padding: 24px 26px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line-2); }
.panel-head h2 { font-size: 21px; letter-spacing: .06em; }
.panel-head > span { font-size: 10.5px; letter-spacing: .18em; color: var(--muted); }
.book-bars { display: flex; flex-direction: column; gap: 15px; }
.book-bar { display: grid; grid-template-columns: 58px minmax(0, 1fr) 70px; align-items: center; gap: 12px; font-size: 13px; }
.bar-label { font-family: var(--serif); letter-spacing: .08em; }
.bar-track { height: 8px; background: var(--paper-2); overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--red); transition: width .5s ease; }
.accent-yili .bar-track i { background: var(--green); }
.accent-liji .bar-track i { background: var(--blue); }
.bar-value { text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.panel-note { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line-2); font-size: 11.5px; color: var(--muted); line-height: 1.75; }

.freq-panel { margin-bottom: 18px; }
.freq-head { align-items: center; }
.freq-head > div:first-child { display: flex; align-items: baseline; gap: 12px; }
.seg-tabs { display: flex; gap: 2px; background: var(--paper); padding: 3px; border: 1px solid var(--line-2); }
.seg-tabs button { border: 0; background: transparent; padding: 4px 12px; font-size: 11.5px; color: var(--muted); }
.seg-tabs button.active { background: var(--ink); color: var(--paper); }
.freq-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line-2); border: 1px solid var(--line-2); }
.freq-cell { display: grid; grid-template-columns: 24px 30px minmax(0, 1fr) 48px; align-items: center; gap: 8px; background: var(--card); padding: 7px 10px; transition: background .15s; }
.freq-cell:hover { background: var(--paper-2); }
.freq-rank { font-size: 9.5px; color: #b6ae9a; font-variant-numeric: tabular-nums; }
.freq-char { font-family: var(--serif); font-size: 21px; line-height: 1; }
.freq-bar { height: 5px; background: var(--paper-2); }
.freq-bar i { display: block; height: 100%; background: rgba(140, 47, 42, .55); }
.freq-num { text-align: right; font-size: 10.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.chapter-rank { list-style: none; margin: 0; padding: 0; }
.chapter-rank li { display: grid; grid-template-columns: 34px minmax(0, 1.15fr) minmax(60px, .85fr) 78px; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px dotted var(--line-2); font-size: 13px; }
.chapter-rank li:last-child { border-bottom: 0; }
.rank-no { font-family: var(--serif); font-size: 11px; color: var(--muted); }
.chapter-rank a { font-family: var(--serif); letter-spacing: .03em; }
.chapter-rank a:hover { color: var(--red); }
.rank-bar { height: 4px; background: var(--paper-2); }
.rank-bar i { display: block; height: 100%; background: var(--gold); }
.rank-value { text-align: right; font-size: 11px; color: var(--muted); }

/* ------------------------------------------------------------------ about */
.about-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 40px; padding-top: 34px; padding-bottom: 80px; align-items: start; }
.prose { max-width: 760px; }
.prose h2 { font-size: 24px; margin: 34px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line-2); letter-spacing: .06em; }
.prose h2:first-child { margin-top: 0; }
.prose p { font-size: 14px; line-height: 1.95; color: var(--ink-2); }
.prose ul { padding-left: 1.2em; color: var(--ink-2); font-size: 14px; line-height: 1.95; }
.prose li { margin-bottom: 4px; }
.prose code, .syntax-row code { font-family: var(--mono); font-size: 12.5px; background: var(--paper-2); padding: 2px 6px; border: 1px solid var(--line-2); }
.prose .muted { color: var(--muted); font-size: 12.5px; }
.syntax-table { border-top: 1px solid var(--line-2); margin: 8px 0 16px; }
.syntax-row { display: grid; grid-template-columns: 190px 1fr; gap: 18px; padding: 10px 0; border-bottom: 1px solid var(--line-2); align-items: baseline; }
.syntax-row span { font-size: 12.5px; color: var(--muted); }
.about-side { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 16px; }
.about-side h3 { font-size: 18px; margin-bottom: 14px; }
.about-stats { margin: 0; }
.about-stats div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dotted var(--line-2); }
.about-stats div:last-child { border-bottom: 0; }
.about-stats dt { font-size: 12px; color: var(--muted); }
.about-stats dd { margin: 0; font-family: var(--serif); font-size: 14px; }
.side-links { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.side-links a { font-size: 12.5px; color: var(--red); }
.side-links a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ----------------------------------------------------------------- footer */
.site-footer { background: var(--ink); color: #d8d0bf; margin-top: 30px; }
.footer-inner { width: min(1240px, calc(100% - 56px)); margin: 0 auto; padding: 42px 0 26px; display: grid; grid-template-columns: 1fr auto; gap: 22px 40px; align-items: start; }
.footer-brand { display: flex; gap: 14px; align-items: center; }
.footer-brand strong { font-family: var(--serif); font-size: 17px; letter-spacing: .14em; color: #f2ead8; }
.footer-brand p { margin: 3px 0 0; font-size: 11.5px; color: #9c9482; }
.footer-links { display: flex; gap: 20px; font-size: 12px; }
.footer-links a:hover { color: #f2ead8; }
.footer-note { grid-column: 1 / -1; margin: 6px 0 0; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.09); font-size: 10.5px; color: #8b8372; letter-spacing: .04em; }

/* ------------------------------------------------------------------ misc */
.notfound { padding: 120px 0; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 14px);
  background: var(--ink); color: var(--paper); padding: 10px 20px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .22s; z-index: 300; border-radius: 2px;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.page-enter { animation: pageIn .38s ease both; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .hero-inner { grid-template-columns: minmax(0, 1.4fr) minmax(220px, .6fr); gap: 32px; }
  .hero-art-frame { width: 250px; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .chapter-grid { grid-template-columns: repeat(2, 1fr); }
  .freq-grid { grid-template-columns: repeat(3, 1fr); }
  .search-layout { grid-template-columns: 264px minmax(0, 1fr); gap: 26px; }
  .chapter-body { padding: 38px 42px 42px; }
  .reader-layout { grid-template-columns: 210px minmax(0, 1fr); gap: 28px; }
  .about-wrap { grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; }
}

@media (max-width: 860px) {
  .wrap, .masthead-inner, .footer-inner { width: calc(100% - 36px); }
  .masthead-inner { gap: 20px; }
  .masthead-meta { display: none; }
  .main-nav { justify-content: flex-end; overflow-x: auto; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a { padding: 8px 10px; white-space: nowrap; }
  .hero-inner { grid-template-columns: 1fr; padding-top: 50px; padding-bottom: 42px; }
  .hero-art { display: none; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stats > div:nth-child(2) { border-right: 0; }
  .hero-stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--line-2); }
  .book-grid { grid-template-columns: 1fr; }
  .book-card { min-height: 0; }
  .search-layout { grid-template-columns: 1fr; gap: 22px; }
  .facets { position: static; max-height: none; }
  .results-panel { min-height: 300px; }
  .syntax-cards { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .freq-grid { grid-template-columns: repeat(2, 1fr); }
  .book-section-head { grid-template-columns: 46px minmax(0, 1fr); }
  .book-meta { grid-column: 2; justify-content: flex-start; }
  .book-section-head h2 { font-size: 30px; }
  .chapter-grid { grid-template-columns: 1fr; }
  .reader-layout { grid-template-columns: 1fr; gap: 18px; }
  .reader-side { position: static; max-height: 260px; border: 1px solid var(--line); background: var(--card); padding: 14px 16px; }
  .reader-main { order: 1; }
  .reader-side { order: 2; }
  .chapter-body { padding: 28px 22px 30px; }
  .pnum { display: none; }
  .about-wrap { grid-template-columns: 1fr; }
  .about-side { position: static; }
  .syntax-row { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }
  .brand-text small { display: none; }
  .brand-text strong { font-size: 18px; }
  .seal { width: 34px; height: 34px; font-size: 22px; }
  .masthead-inner { height: 60px; }
  .main-nav a { font-size: 13px; padding: 8px 8px; }
  .hero h1 { font-size: 46px; }
  .hero-sub { font-size: 16px; }
  .hero-search { flex-direction: column; }
  .hero-search button { padding: 12px; letter-spacing: .3em; }
  .section { padding-top: 44px; }
  .section-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .section-head h2 { font-size: 25px; }
  .feature-grid { grid-template-columns: 1fr; }
  .quote-inner { padding: 36px 0; }
  .page-head { padding: 36px 0 22px; }
  .results-head { align-items: flex-start; flex-direction: column; gap: 10px; }
  .result-row { grid-template-columns: 34px minmax(0, 1fr); padding: 12px 4px; }
  .kwic { display: block; font-size: 15px; line-height: 2; }
  .kw-left, .kw-right { display: inline; }
  .kw-left::after { content: ""; }
  .kw-key { display: inline; }
  .results-foot { flex-direction: column; align-items: flex-start; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .stat-card strong { font-size: 26px; }
  .freq-grid { grid-template-columns: 1fr 1fr; }
  .freq-cell { grid-template-columns: 20px 26px minmax(0,1fr) 38px; padding: 6px 8px; }
  .freq-char { font-size: 18px; }
  .book-section-head { grid-template-columns: 1fr; gap: 10px; }
  .book-ord { display: none; }
  .book-meta { grid-column: 1; }
  .chapter-body { padding: 22px 16px 26px; }
  .chapter-nav { grid-template-columns: 1fr; }
  .reader-toolbar { align-items: flex-start; flex-direction: column; }
  .reader-search { max-width: none; width: 100%; }
  .reader-side { order: 2; }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-links { flex-wrap: wrap; gap: 14px; }
}

@media (max-width: 520px) {
  .brand-text { display: none; }
  .masthead-inner { gap: 10px; }
  .main-nav a { padding: 8px 7px; font-size: 12.5px; }
}

@media print {
  .masthead, .site-footer, .facets, .reader-side, .reader-toolbar, .chapter-nav, .results-tools, .pager, .toast { display: none !important; }
  body { background: #fff; }
  .search-layout, .reader-layout, .about-wrap { display: block; padding: 0; }
  .chapter-body { border: 0; box-shadow: none; padding: 0; }
  .para { font-size: 12pt; line-height: 1.9; }
  .pnum { display: none; }
}
