/* 往事 · 老建回忆录 —— 纸本、墨色、一方朱印 */
:root {
  --paper: #f4eee2;
  --paper-2: #ebe3d3;
  --ink: #221d17;
  --ink-2: #4a4238;
  --muted: #685d50;
  --rule: #d6cbb7;
  --seal: #a8322a;
  --plate-bg: #f8f4ea;
  --shadow: 0 1px 2px rgba(60, 40, 20, .08), 0 8px 24px rgba(60, 40, 20, .08);
  --fs: 20px;
  --measure: 34em;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17140f; --paper-2: #1f1b15; --ink: #e9e0cf; --ink-2: #cfc4b0;
    --muted: #aa9f8e; --rule: #3a332a; --seal: #c4473c; --plate-bg: #ece4d4;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #17140f; --paper-2: #1f1b15; --ink: #e9e0cf; --ink-2: #cfc4b0;
  --muted: #aa9f8e; --rule: #3a332a; --seal: #c4473c; --plate-bg: #ece4d4;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  font-size: var(--fs);
  line-height: 2;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
body::before { /* 极淡的纸纹 */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5;
  background-image: radial-gradient(rgba(120, 90, 50, .05) 1px, transparent 1px);
  background-size: 3px 3px;
}
a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }
.wrap { position: relative; z-index: 1; }

/* —— 朱印 —— */
.seal {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 1.9em; padding: .22em 0; gap: .06em;
  background: var(--seal); color: #fbf3e8;
  font-weight: 700; font-size: 1em; line-height: 1;
  border-radius: 3px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.18);
}
.seal i { font-style: normal; display: block; }
.seal.big { font-size: 22px; margin-top: .2em; }

/* —— 顶栏 —— */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, calc((100vw - 1100px) / 2));
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 90%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  font-size: 15px; line-height: 1.4;
}
.bar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-height: 44px; min-width: 44px; }
.bar .brand .seal { font-size: 14px; }
.bar .brand b { font-size: 17px; letter-spacing: .3em; font-weight: 700; }
.bar .where { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.bar button, .bar a.btn {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--paper); border: 1px solid var(--ink-2);
  border-radius: 999px; padding: 0 14px; min-height: 40px; min-width: 44px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.bar button:disabled { opacity: .35; cursor: default; }
.bar button:hover, .bar a.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: var(--seal); transition: width .1s linear; }
@media (max-width: 560px) { .bar .where { display: none; } .bar .brand b { display: none; } .bar { gap: 6px; } .bar .brand { margin-right: auto; } .bar button, .bar a.btn { padding: 0 10px; font-size: 15px; } }

/* —— 目录抽屉 —— */
.drawer { position: fixed; inset: 0; z-index: 40; display: none; }
.drawer.open { display: block; }
.drawer .scrim { position: absolute; inset: 0; background: rgba(20, 14, 8, .35); }
.drawer nav {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 88vw);
  background: var(--paper); border-left: 1px solid var(--rule); overflow-y: auto;
  padding: 24px 24px 48px; font-size: 16px; line-height: 1.7;
}
.drawer nav h2 { font-size: 14px; letter-spacing: .4em; color: var(--muted); font-weight: 500; margin: 24px 0 6px; }
.drawer nav a { display: block; padding: 10px 0; font-size: 18px; text-decoration: none; border-bottom: 1px dotted var(--rule); }
.drawer nav a[aria-current] { color: var(--seal); font-weight: 700; }
.drawer .close { float: right; font: inherit; background: none; border: 1px solid var(--rule); border-radius: 999px; padding: 6px 14px; color: var(--ink-2); cursor: pointer; font-size: 16px; }

/* —— 封面（首页） —— */
.cover {
  min-height: calc(100vh - 60px);
  min-height: calc(100svh - 60px);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: center; gap: clamp(24px, 5vw, 72px);
  max-width: 1100px; margin: 0 auto; padding: 48px 16px 64px;
}
.cover .art { box-shadow: var(--shadow); background: var(--plate-bg); padding: 10px; }
.cover .titles { display: flex; gap: clamp(18px, 3vw, 36px); align-items: flex-start; justify-content: center; }
.cover h1 {
  writing-mode: vertical-rl; font-size: clamp(64px, 11vw, 132px); line-height: 1; margin: 0;
  font-weight: 900; letter-spacing: .12em;
}
.cover .sub { writing-mode: vertical-rl; font-size: clamp(18px, 2vw, 22px); letter-spacing: .5em; color: var(--ink-2); margin-top: .4em; }
.cover .sub::before { content: ""; display: inline-block; height: 2.2em; width: 1px; background: var(--seal); margin-bottom: .6em; }
.cover .author { margin-top: 28px; font-size: 18px; letter-spacing: .3em; color: var(--ink-2); }
.cover .actions { margin-top: 36px; display: flex; gap: 12px; flex-wrap: wrap; }
.btn-main, .btn-ghost {
  display: inline-block; padding: 10px 22px; border-radius: 999px; text-decoration: none; font-size: 16px; line-height: 1.5; letter-spacing: .15em;
}
.btn-main { background: var(--ink); color: var(--paper); }
.btn-ghost { border: 1px solid var(--ink-2); color: var(--ink); }
.cover .right { display: flex; flex-direction: column; align-items: flex-start; }
@media (max-width: 760px) {
  .cover { grid-template-columns: 1fr; padding-top: 28px; min-height: auto; }
  .cover .right { align-items: center; text-align: center; }
  .cover .art { order: 2; }
  .cover .actions { justify-content: center; }
}

/* —— 首页分区 —— */
.section { max-width: 1100px; margin: 0 auto; padding: 56px 16px; border-top: 1px solid var(--rule); }
.section > h2 {
  font-size: 15px; font-weight: 500; letter-spacing: .6em; color: var(--muted); margin: 0 0 28px;
  display: flex; align-items: center; gap: 12px;
}
.section > h2::before { content: ""; width: 18px; height: 2px; background: var(--seal); }
.poem-card { max-width: 36em; }
.poem-card p { margin: 0 0 1em; text-indent: 2em; text-align: justify; color: var(--ink-2); }
.verse { margin: 1.4em 0; padding-left: 2em; font-size: 1.08em; letter-spacing: .12em; line-height: 2.1; }
.verse span { display: block; }

.toc { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 0 40px; }
.toc h3 { grid-column: 1 / -1; margin: 28px 0 6px; font-size: 22px; letter-spacing: .4em; font-weight: 700; }
.toc h3:first-child { margin-top: 0; }
.toc a {
  display: flex; align-items: center; gap: 14px; padding: 10px 0; text-decoration: none;
  border-bottom: 1px solid var(--rule); line-height: 1.5;
}
.toc a .n { color: var(--seal); min-width: 2.6em; font-weight: 700; letter-spacing: .05em; }
.toc a .t { flex: 1; }
.toc a img { width: 72px; height: 40px; object-fit: cover; opacity: .9; filter: grayscale(.2); }
.toc a:hover .t { text-decoration: underline; text-underline-offset: 4px; }

.continue { display: none; margin-top: 18px; font-size: 15px; color: var(--muted); }
.continue a { color: var(--seal); }

/* —— 正文 —— */
.chapter { max-width: var(--measure); margin: 0 auto; padding: 56px 16px 32px; }
.chapter header { text-align: center; margin-bottom: 44px; }
.chapter header .kicker { font-size: 14px; letter-spacing: .6em; color: var(--muted); }
.chapter header h1 { margin: 10px 0 0; font-size: clamp(28px, 5vw, 40px); line-height: 1.4; font-weight: 900; letter-spacing: .14em; }
.chapter header .byline { margin-top: 10px; color: var(--ink-2); letter-spacing: .4em; }
.chapter header::after { content: ""; display: block; width: 28px; height: 2px; background: var(--seal); margin: 22px auto 0; }
.chapter p { margin: 0 0 .55em; text-indent: 2em; text-align: justify; hanging-punctuation: allow-end; }
.chapter p.sign { text-align: right; text-indent: 0; color: var(--ink-2); margin-top: 1.4em; }
.chapter p.lead { text-indent: 0; color: var(--ink-2); font-size: .95em; margin-bottom: 1.2em; }

figure { margin: 2.2em 0; }
figure.plate { margin-left: calc(-1 * min(12vw, 7em)); margin-right: calc(-1 * min(12vw, 7em)); }
figure.plate .frame { background: var(--plate-bg); padding: 8px; box-shadow: var(--shadow); }
figure.plate img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
@media (max-width: 1000px) { figure.plate { margin-left: -16px; margin-right: -16px; } figure.plate .frame { padding: 0; box-shadow: none; } }
figcaption { margin-top: 12px; font-size: .86em; line-height: 1.8; color: var(--muted); text-align: center; padding: 0 16px; }
figcaption q { quotes: "「" "」"; }
figure.photo { text-align: center; }
figure.photo .frame { display: inline-block; background: #fbf8f1; padding: 10px 10px 12px; box-shadow: var(--shadow); max-width: min(100%, 360px); }
figure.photo.wide .frame { max-width: min(100%, 460px); }
figure.photo img { filter: sepia(.08); }
figure.photo figcaption { letter-spacing: .3em; }

/* —— 上下章 —— */
.pager { max-width: var(--measure); margin: 24px auto 0; padding: 0 16px 72px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--rule); text-decoration: none; line-height: 1.6; border-radius: 4px; }
.pager a:hover { border-color: var(--ink-2); }
.pager small { display: block; color: var(--muted); font-size: 14px; letter-spacing: .3em; }
.pager .next { text-align: right; grid-column: 2; }
.pager span { font-size: 18px; }

/* —— 画卷页 —— */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 28px 24px; }
.gallery a { text-decoration: none; display: block; }
.gallery .frame { background: var(--plate-bg); padding: 6px; box-shadow: var(--shadow); }
.gallery img { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
.gallery .cap { margin-top: 10px; font-size: 14px; line-height: 1.7; color: var(--muted); }
.gallery .cap b { color: var(--ink); font-weight: 600; margin-right: .6em; }

/* —— 版权页 —— */
.colophon { max-width: 26em; margin: 0 auto; text-align: center; font-size: 15px; line-height: 2; color: var(--ink-2); }
.covers { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 48px; }
.covers figure { margin: 0; }
.colophon .t { font-size: 28px; font-weight: 900; letter-spacing: .4em; color: var(--ink); margin-bottom: 0; }

footer.site {
  border-top: 1px solid var(--rule); padding: 28px 16px 40px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.8;
}
footer.site a { text-decoration: none; border-bottom: 1px dotted var(--muted); }

:focus-visible { outline: 2px solid var(--seal); outline-offset: 3px; }
@media print {
  .bar, .pager, footer.site, .drawer { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  figure.plate { margin-left: 0; margin-right: 0; }
}
