:root {
  color-scheme: light;
  --paper: #f2e8db;
  --ink: #26211c;
  --muted: #66594c;
  --rule: #a69a8b;
  --accent: #833b30;
  --serif: "Noto Serif CJK SC", "Songti SC", STSong, SimSun, serif;
  --sans: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

*, *::after, *::before { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background-color: var(--paper);
  background-image: linear-gradient(#f4eeef90, #f4eeef90), url("paper.webp");
  background-size: auto, 560px;
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.65;
}
.wrap { width: min(1440px, calc(100% - clamp(36px, 8.6vw, 132px))); margin-inline: auto; }
a { color: inherit; text-underline-offset: 0.22em; }
a:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.opening {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  padding-block: clamp(20px, 1.6vw, 26px);
  border-bottom: 1px solid var(--rule);
}
.opening::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 50%;
  width: 1px;
  background: #7e6a5226;
  box-shadow: 2px 0 6px #7e6a5229;
  pointer-events: none;
}
.cover { width: min(84%, 517px); margin: 0 auto; position: relative; inset-inline-start: -2%; }
.cover img {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(6px 13px 12px #47342243);
}
.opening-text { padding-inline: clamp(25px, 6vw, 96px) 16px; }
h1, h2 { margin: 0; font-family: var(--serif); line-height: 1.2; }
h1 { color: #151310; font-size: clamp(3.25rem, 6.3vw, 6.125rem); letter-spacing: 0.055em; }
h1::after, #contents-title::after {
  content: "";
  display: block;
  width: 46px;
  height: 4px;
  background: var(--accent);
}
h1::after { margin-block: 0.42em; }
#preface-title { font-size: clamp(1.65rem, 2.8vw, 2.55rem); letter-spacing: 0.09em; }
.period, .lede { color: var(--muted); font-size: clamp(1.05rem, 1.6vw, 1.45rem); }
.period { margin: 0.95em 0 0.35em; letter-spacing: 0.075em; }
.period span { margin-inline-start: 0.36em; }
.lede { margin: 0 0 1.75em; line-height: 1.85; }
.open-book {
  display: inline-block;
  min-width: min(100%, 222px);
  padding: 0.57em 1.5em;
  border: 1px solid var(--muted);
  text-decoration: none;
  text-align: center;
  font-size: clamp(1.1rem, 1.65vw, 1.5rem);
  letter-spacing: 0.095em;
  transition: background-color 180ms ease;
}
.open-book:hover { background: #735c3a12; }

.index { padding: clamp(24px, 3vw, 49px) clamp(0px, 3.2vw, 50px) 0; }
.index-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: clamp(18px, 2.1vw, 34px);
  border-bottom: 1px solid var(--rule);
}
#contents-title { font-size: clamp(2rem, 3.5vw, 3.25rem); letter-spacing: 0.065em; }
#contents-title::after { width: 40px; margin-top: 0.45em; }
.search { flex: 0 1 42%; margin-top: 0.16rem; }
.search-field { position: relative; }
.search-field::before, .search-field::after {
  content: "";
  position: absolute;
  top: 50%;
  pointer-events: none;
}
.search-field::before {
  left: 19px;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-60%);
}
.search-field::after {
  left: 32px;
  width: 8px;
  border-top: 1.5px solid var(--muted);
  transform: translateY(5px) rotate(45deg);
}
.search input {
  width: 100%;
  min-height: 55px;
  border: 1px solid var(--muted);
  border-radius: 999px;
  color: var(--ink);
  background: #fff7ec38;
  font: inherit;
  font-size: clamp(1rem, 1.45vw, 1.2rem);
  padding: 0.55em 1.05em 0.55em 2.9em;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.index-count {
  margin: 0;
  padding-block: clamp(16px, 2.1vw, 32px);
  color: var(--muted);
  text-align: center;
  font-size: clamp(1rem, 1.6vw, 1.38rem);
  letter-spacing: 0.05em;
}
.empty { color: var(--muted); margin: 0; padding-bottom: 22px; text-align: center; }
.entry { border-top: 1px solid var(--rule); scroll-margin-top: 12px; }
.entry summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(124px, 20%) 1fr;
  align-items: baseline;
  gap: 10px 22px;
  list-style: none;
  padding: 18px 30px 18px 0;
  cursor: pointer;
}
.entry summary::-webkit-details-marker { display: none; }
.entry summary::after { content: "+"; position: absolute; right: 0; color: var(--muted); font-size: 1.1rem; }
.entry[open] summary::after { content: "−"; }
.entry summary:hover .entry-title { text-decoration: underline; text-underline-offset: 0.2em; }
.entry-date { color: var(--muted); font-family: var(--sans); font-size: 0.88rem; }
.entry-title { font-size: 1.28rem; font-weight: 700; overflow-wrap: anywhere; }
.article-body { max-width: 38em; line-height: 2; font-size: 1.125rem; margin: 0 auto; padding: 6px 0 36px; overflow-wrap: anywhere; }
.article-body p { margin: 0 0 1em; white-space: pre-wrap; }
.article-body a { font-family: var(--sans); font-size: 0.88rem; color: var(--accent); }
.colophon {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 0 26px;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.9rem;
}
.colophon a { text-decoration: none; }
.colophon a:hover { text-decoration: underline; }

@media (max-width: 740px) {
  .opening { grid-template-columns: minmax(0, 1fr); padding-block: 22px 34px; }
  .opening::before { display: none; }
  .opening-text { padding: 0; }
  .cover { width: min(78%, 330px); margin-bottom: 14px; inset-inline-start: 0; }
  h1 { font-size: clamp(2.75rem, 10.5vw, 4.2rem); }
  h1::after { margin-block: 0.36em; }
  #preface-title { font-size: 1.65rem; }
  .lede { margin-bottom: 1.25em; }
  .index { padding-inline: 0; }
  .index-header { flex-direction: column; align-items: stretch; gap: 16px; }
  .search { flex: auto; }
  .search input { min-height: 48px; padding-left: 3.05em; }
  .entry summary { grid-template-columns: 1fr; gap: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .open-book { transition: none; }
}
