:root {
  --ink: #2b2118;
  --paper: #f7f7f4;
  --accent: #8b3a2f;
  --line: rgba(43, 33, 24, 0.22);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  color: var(--ink);
  background: var(--paper);
  font-family: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC", serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.7;
}

a { color: inherit; }

.rule {
  width: 56px;
  height: 1px;
  margin: 1.3em auto 2.2em;
  background: var(--accent);
}

/* ---------- 顶部导航 ---------- */
.reader-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: rgba(245, 239, 227, 0.95);
  border-bottom: 1px solid var(--line);
}

.reader-top a,
.reader-top button {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
  color: inherit;
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
}

.reader-top button:disabled { opacity: 0.35; cursor: default; }
.top-left { display: flex; gap: 8px; }
.top-right { display: flex; gap: 8px; }

/* ---------- 首页 ---------- */
body.home {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: #e9e2d5;
}

.home .bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.home .bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("img/mountain.jpg") center center / cover no-repeat;
  opacity: 0.5;
  filter: grayscale(0.22) sepia(0.1);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, transparent 22%, rgba(0, 0, 0, 0.5) 30%, #000 38%);
  mask-image: linear-gradient(to bottom, transparent 0%, transparent 22%, rgba(0, 0, 0, 0.5) 30%, #000 38%);
}

.home .bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(250, 246, 238, 0.36);
}

.home .stage {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10vh 12vw 18vh;
}

.home .title {
  position: relative;
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-start;
  gap: 0.42em;
  margin: 0;
  font-weight: 600;
  line-height: 1;
  transform: translateY(calc(-2 * clamp(2.7rem, 12.5vw, 5.2rem)));
}

.home .title span {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", "SimSun", serif;
  font-weight: 600;
  letter-spacing: 0.16em;
  font-size: clamp(2.7rem, 12.5vw, 5.2rem);
}

.home .title .name {
  transform: translateY(-0.42em);
}

.home .title .book {
  font-size: clamp(2.4rem, 11vw, 4.6rem);
  transform: translateY(1.05em);
  opacity: 0.92;
}

.home-foot {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 13px;
  line-height: 1.9;
  letter-spacing: 0.06em;
  opacity: 0.75;
}

.enter {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: calc(46vh + 18px + clamp(2.7rem, 12.5vw, 5.2rem));
  transform: translateX(-50%);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 10px 20px 11px;
  border: 1px solid rgba(96, 146, 158, 0.55);
  border-radius: 2px;
  background: transparent;
  overflow: hidden;
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  box-shadow: inset 0 0 12px rgba(96, 146, 158, 0.14), 0 0 14px rgba(96, 146, 158, 0.12);
  animation: techGlow 2.8s ease-in-out infinite;
}

.enter::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(150, 205, 215, 0.45), transparent);
  transform: skewX(-22deg);
  animation: techSweep 3s ease-in-out infinite;
}

.enter-text,
.enter-arrow {
  position: relative;
  z-index: 1;
}

.enter-arrow {
  font-size: 24px;
  line-height: 1.1;
  color: rgba(96, 146, 158, 0.95);
  animation: bob 1.8s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(5px); }
}

@keyframes techGlow {
  0%, 100% { box-shadow: inset 0 0 10px rgba(96, 146, 158, 0.1), 0 0 10px rgba(96, 146, 158, 0.08); }
  50% { box-shadow: inset 0 0 16px rgba(96, 146, 158, 0.24), 0 0 20px rgba(96, 146, 158, 0.22); }
}

@keyframes techSweep {
  0% { left: -60%; }
  60%, 100% { left: 130%; }
}

/* ---------- 目录 ---------- */
.contents-page { background: #f7f7f4; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 9vh 7vw calc(12vh + env(safe-area-inset-bottom));
}

.contents-page .wrap {
  padding: calc(66px + env(safe-area-inset-top)) 6vw calc(16px + env(safe-area-inset-bottom));
}

.toc-head { text-align: center; }
.toc-head h1 { margin: 0; font-size: 1.55rem; font-weight: 700; letter-spacing: 0.28em; }
.toc-head .rule { margin: 0.7em auto 1.1em; width: 42px; }
.toc-group { margin-top: 1.15em; }
.toc-group h2 {
  margin: 0;
  padding-left: 0.6em;
  border-left: 3px solid var(--accent);
  font-size: 1rem;
  letter-spacing: 0.06em;
}
.toc-group h2 a { text-decoration: none; }
.toc-group ul { list-style: none; margin: 0.25em 0 0; padding: 0; }
.toc-group li { border-bottom: 1px dashed var(--line); }
.toc-group li a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 34px;
  padding: 4px 4px 4px 1.2em;
  text-decoration: none;
  font-size: 0.95rem;
}
.toc-group li a:active { background: rgba(139, 58, 47, 0.07); }
.lock-note { font-size: 0.7rem; letter-spacing: 0.08em; opacity: 0.6; }

/* ---------- 分屏阅读 ---------- */
body.reader {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.screens { height: 100%; }

.screen {
  display: none;
  height: 100vh;
  height: 100dvh;
}

.screen.active { display: block; }

.theme-rain { --paper: #e6edef; --accent: #4d6b77; background: #e6edef; }
.theme-farm { --paper: #f0e9d8; --accent: #8a6a35; background: #f0e9d8; }
.theme-country { --paper: #edd9d0; --accent: #8b3a2f; background: #edd9d0; }
.theme-prose { --paper: #f7f7f4; --accent: #6b4f35; background: #f7f7f4; }

.screen-inner {
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(76px + env(safe-area-inset-top)) 8vw calc(66px + env(safe-area-inset-bottom));
  overflow-y: auto;
  text-align: center;
}

.screen-kicker {
  font-size: 12px;
  letter-spacing: 0.16em;
  opacity: 0.6;
  margin-bottom: 1.6em;
}

.poem-title,
.essay-title {
  margin: 0 0 1.1em;
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.2em;
}

.poem-lines p {
  margin: 0.22em 0;
  font-size: 1.05rem;
  line-height: 2;
  letter-spacing: 0.05em;
}

.poem-lines .note,
.reader p.note {
  font-size: 0.84rem;
  opacity: 0.7;
}

.reader p.note-under-title {
  margin: -0.7em 0 1.7em;
}

/* ---------- 第一辑排版微调 ---------- */
:root { --return-gap: 1.9em; }

/* 小字归位，标题与正文下移一个回车 */
.poetry-reader .poem-title:not(.poem-title-second),
.poetry-reader .screen-kicker + .poem-lines {
  margin-top: var(--return-gap);
}

.poem-lines .gap-line { margin-top: var(--return-gap); }

.poem-title-nowrap {
  white-space: nowrap;
  font-size: clamp(1rem, 5.4vw, 1.5rem);
  letter-spacing: 0.04em;
}

.poem-subtitle {
  margin: 0 0 1em;
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.2em;
}

.poem-subtitle-note {
  margin: -0.85em 0 1.3em;
  font-size: 0.84rem;
  opacity: 0.7;
  letter-spacing: 0.08em;
}

.poem-lines .note-sm { font-size: 0.72rem; line-height: 1.1; }
.poem-lines .note-right { text-align: right; padding-right: 16px; }
.poem-lines .note-tight { text-align: left; line-height: 1.1; letter-spacing: 0.01em; }

.poetry-reader .continuation .poem-lines {
  margin-top: calc(var(--return-gap) + 3.5em);
}

.compact-page { --return-gap: 1.1em; }

.compact-page .poem-title,
.compact-page .poem-title-second {
  font-size: clamp(1.1rem, 5vw, 1.55rem);
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.compact-page .poem-title { margin-bottom: 0.5em; }
.compact-page .poem-title-second { margin-top: 0.7em; }
.compact-page .poem-lines p { margin: 0.08em 0; line-height: 1.85; }

.reader .subhead {
  margin: 1.2em 0 0.5em;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.reader p.prose {
  margin: 0 0 0.8em;
  text-align: justify;
  text-indent: 2em;
  font-size: 16px;
  line-height: 2;
  white-space: pre-wrap;
}

.screen.has-float .screen-inner { padding-left: 52px; }

.float-nav {
  display: flex;
  position: fixed;
  left: 8px;
  top: 50%;
  z-index: 25;
  flex-direction: column;
  gap: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translate(-32px, -50%);
  transition: opacity 0.3s ease, transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s linear 0.55s;
  pointer-events: none;
}

.float-nav.show {
  opacity: 1;
  visibility: visible;
  transform: translate(0, -50%);
  transition: opacity 0.3s ease, transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s;
  pointer-events: auto;
}

.float-nav a,
.float-nav button {
  writing-mode: vertical-rl;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: 2px;
  color: inherit;
  text-decoration: none;
  padding: 7px 3px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
}

.float-nav button:disabled { opacity: 0.35; cursor: default; }

.screen-count {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  z-index: 20;
  text-align: center;
  font-size: 12px;
  opacity: 0.6;
}

/* ---------- 单页通用页头与导航（照片墙） ---------- */
.chapter-head { text-align: center; }
.series { font-size: 0.78rem; letter-spacing: 0.24em; opacity: 0.65; }
.chapter-head h1 {
  margin: 0.42em 0 0;
  font-size: clamp(1.9rem, 8vw, 2.9rem);
  font-weight: 700;
  letter-spacing: 0.2em;
}
/* ---------- 照片墙密码页 ---------- */
.photos-page { background: #eae7e0; }

.photos-page .wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-top: calc(78px + env(safe-area-inset-top));
}

.lock-box {
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.6rem 1.2rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  text-align: center;
}
.lock-hint { margin: 0 0 1.2em; font-size: 0.95rem; letter-spacing: 0.1em; }
.lock-box input {
  width: 100%;
  padding: 0.8em;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink);
  font-family: inherit;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 0.4em;
}
.lock-box button {
  width: 100%;
  margin-top: 1em;
  padding: 0.8em;
  border: 1px solid var(--accent);
  border-radius: 2px;
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.14em;
  cursor: pointer;
}
.err { min-height: 1.4em; margin: 0.8em 0 0; color: #a33; font-size: 0.86rem; }
.placeholder { display: none; text-align: center; }
.placeholder p { font-size: 1.05rem; letter-spacing: 0.08em; }
body.unlocked .lock-box { display: none; }
body.unlocked .placeholder { display: block; }

/* ---------- 桌面微调 ---------- */
@media (min-width: 700px) {
  .home .stage { padding-bottom: 22vh; }
  .home-foot { font-size: 14px; }
  .enter { right: 28px; bottom: calc(84px + env(safe-area-inset-bottom)); }
  .screen-inner { padding-left: 10vw; padding-right: 10vw; }
  .reader p.prose, .poem-lines p { font-size: 1.1rem; }
}
