/* 红楼一梦 · 样式
 * 颜色全部取自 :root 上的 --*-rgb，由 main.js 随滚动在六卷色板间插值。
 */
@font-face { font-family: "HL Kai"; src: url(../fonts/hl-kai.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "HL Song"; src: url(../fonts/hl-song-900.woff2) format("woff2"); font-weight: 900; font-display: swap; }

:root {
  --bg-rgb: 18 20 28; --ink-rgb: 233 226 208; --acc-rgb: 184 149 90; --pi-rgb: 222 111 95;
  --bg: rgb(var(--bg-rgb)); --ink: rgb(var(--ink-rgb));
  --soft: rgb(var(--ink-rgb) / .66); --line: rgb(var(--ink-rgb) / .18);
  --acc: rgb(var(--acc-rgb)); --pi: rgb(var(--pi-rgb));
  --kai: "HL Kai", "LXGW WenKai", "Kaiti SC", STKaiti, KaiTi, serif;
  --song: "Songti SC", STSong, "Noto Serif SC", "Source Han Serif SC", "Noto Serif CJK SC", SimSun, serif;
  --disp: "HL Song", "Noto Serif SC", "Songti SC", STSong, serif;
  --gut: clamp(16px, 5vw, 56px);
  font-size: 17px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--song); line-height: 1.85;
  text-align: justify; word-break: normal; line-break: strict;
  overflow-x: hidden;
}
h1, h2, h3, h4, p { margin: 0; }
h2, h3, h4, .ln, .zh-ln, .grp-title, .act-name { word-break: keep-all; overflow-wrap: break-word; text-align: start; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--pi); outline-offset: 3px; }
::selection { background: rgb(var(--pi-rgb) / .35); }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
main, .rail { position: relative; z-index: 1; }

.skip { position: fixed; left: 12px; top: -60px; z-index: 30; padding: 8px 14px; background: var(--ink); color: var(--bg); }
.skip:focus { top: 12px; }

/* ── 顶栏 ── */
.bar {
  position: fixed; inset: 0 0 auto; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gut) 22px;
  background: linear-gradient(rgb(var(--bg-rgb) / .92) 40%, rgb(var(--bg-rgb) / 0));
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.brand { font-family: var(--disp); font-weight: 900; font-size: 16px; letter-spacing: .32em; text-decoration: none; white-space: nowrap; }
.tools { display: flex; gap: 8px; }
.tools button, .ghost, .round {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 99px; background: rgb(var(--ink-rgb) / .05);
  padding: 5px 14px; font-size: 14px; line-height: 1.6; white-space: nowrap;
  transition: background .25s, border-color .25s, color .25s;
}
.tools button:hover, .ghost:hover, .round:hover { border-color: var(--acc); background: rgb(var(--ink-rgb) / .1); }
#btn-pi[aria-pressed="true"] { color: var(--pi); border-color: rgb(var(--pi-rgb) / .6); }
#btn-pi[aria-pressed="false"] { text-decoration: line-through; color: var(--soft); }
.ghost[aria-pressed="true"] { background: var(--pi); border-color: var(--pi); color: var(--bg); }

/* 签筒：竹筒里插三根签 */
.tube { position: relative; width: 9px; height: 12px; margin-top: 4px; border: 1.5px solid currentColor; border-top: 0; border-radius: 0 0 2px 2px; }
.tube::before, .tube::after {
  content: ""; position: absolute; bottom: 4px; width: 1.5px; height: 12px; background: var(--pi); border-radius: 1px;
}
.tube::before { left: 1px; transform: rotate(-12deg); }
.tube::after { right: 1px; transform: rotate(10deg); height: 10px; }
.shake .tube { animation: shake .65s ease-in-out; transform-origin: 50% 100%; }
@keyframes shake { 20% { transform: rotate(-16deg); } 40% { transform: rotate(14deg); } 60% { transform: rotate(-10deg); } 80% { transform: rotate(6deg) translateY(-2px); } }

/* ── 卷次导轨 ── */
.rail { position: fixed; left: 20px; top: 50%; transform: translateY(-50%); z-index: 15; display: flex; flex-direction: column; gap: 6px; }
.rail a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--soft); font-size: 12px; padding: 3px 0; }
.rail a::before { content: ""; width: 14px; height: 1px; background: currentColor; transition: width .3s; }
.rail .r-name { opacity: 0; transform: translateX(-4px); transition: opacity .3s, transform .3s; font-family: var(--disp); font-weight: 900; letter-spacing: .1em; }
.rail a:hover .r-name, .rail a[aria-current] .r-name { opacity: 1; transform: none; }
.rail a[aria-current] { color: var(--pi); }
.rail a[aria-current]::before { width: 26px; }
@media (max-width: 1199px) { .rail { display: none; } }

/* ── 开篇：石 ── */
.hero {
  min-height: 100svh; display: grid; justify-items: center; align-content: center; gap: 28px;
  padding: 90px var(--gut) 56px; text-align: center;
}
.hero-eyebrow { font-size: 13px; letter-spacing: .4em; color: var(--soft); animation: rise 1.4s .2s both; }
.stone { position: relative; width: min(300px, 58vw); }
.stone-svg { display: block; width: 100%; height: auto; overflow: visible; animation: rise 2s both; }
.stone-halo { fill: #b8955a; opacity: .2; animation: breathe 6s ease-in-out infinite; }
.stone-vein { fill: none; stroke: rgb(232 211 160 / .14); stroke-width: 1.2; stroke-linecap: round; }
@keyframes breathe { 50% { opacity: .34; } }
.stone-text {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: .9em;
  writing-mode: vertical-rl; font-family: var(--disp); font-weight: 900;
  font-size: clamp(26px, 7.4vw, 40px); letter-spacing: .32em; color: #e8d3a0;
  text-shadow: 0 0 18px rgb(232 211 160 / .35);
}
.stone-text i { font-style: normal; display: inline-block; animation: surface 1.6s calc(.9s + var(--k) * .17s) both; }
@keyframes surface { from { opacity: 0; filter: blur(8px); transform: translateX(-.15em); } }
.hero-after { font-family: var(--kai); font-size: 19px; letter-spacing: .2em; animation: rise 1.6s 3s both; }
.hero-cue {
  display: grid; justify-items: center; gap: 10px; margin-top: 10px; text-decoration: none;
  font-family: var(--disp); font-weight: 900; letter-spacing: .5em; text-indent: .5em; color: var(--acc);
  animation: rise 1.4s 3.6s both;
}
.hero-cue i { width: 1px; height: 46px; background: linear-gradient(var(--acc), transparent); animation: drip 2.4s ease-in-out infinite; transform-origin: top; }
@keyframes drip { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1); opacity: 0; } }
.hero-note { font-size: 13px; color: var(--soft); letter-spacing: .2em; animation: rise 1.4s 4s both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ── 卷首卡：色板在此转换 ── */
.act-card { position: relative; height: 170vh; }
.act-in {
  --o: clamp(0, calc((var(--p, 1) - .55) / .45), 1);
  position: sticky; top: 0; height: 100svh; display: grid; place-items: center;
  opacity: var(--o); transform: translateY(calc((1 - var(--o)) * 24px));
}
.act-v {
  writing-mode: vertical-rl; display: flex; flex-direction: column; align-items: flex-start; gap: clamp(14px, 3vw, 36px);
  max-height: 86svh;
}
.act-no {
  font-family: var(--disp); font-weight: 900; font-size: 15px; letter-spacing: .2em;
  padding: .55em .3em; background: var(--pi); color: var(--bg); border-radius: 2px; transform: rotate(-3deg);
}
.act-name {
  font-family: var(--disp); font-weight: 900; font-size: clamp(96px, 22vh, 220px);
  line-height: 1; letter-spacing: calc(.06em + (1 - var(--o)) * .3em);
}
.act-motto { font-family: var(--kai); font-size: clamp(18px, 2.6vh, 24px); letter-spacing: .28em; color: var(--ink); padding-top: 1.6em; }
.act-range { font-size: 13px; letter-spacing: .3em; color: var(--soft); padding-top: 3.4em; }

/* ── 组 ── */
.grp { max-width: 1180px; margin: 0 auto; padding: clamp(72px, 13vh, 150px) var(--gut); }
.grp-head { display: grid; gap: 10px; margin-bottom: clamp(32px, 6vh, 56px); max-width: 40em; }
.grp-hui { font-size: 13px; letter-spacing: .3em; color: var(--acc); }
.grp-title { font-family: var(--disp); font-weight: 900; font-size: clamp(36px, 5.4vw, 64px); line-height: 1.15; letter-spacing: .06em; }
.grp-count { font-family: var(--kai); color: var(--pi); font-size: 15px; }
.grp-intro { color: var(--soft); line-height: 1.95; }
.grp-caveat { font-size: 14px; color: var(--soft); border-left: 2px solid var(--line); padding-left: 12px; }
[id^="p-"], .grp { scroll-margin-top: 80px; }

/* ── 诗行 ── */
.st, .ln { display: block; }
.ln { padding-inline-start: 1em; text-indent: -1em; }
.st + .st { margin-block-start: 1em; }
.pb-body, .v-body, .ce-text, .pane .pb-body, .lt-riddle, .ht-body, .lk-body, .rd-body {
  font-family: var(--kai); font-size: 19px; line-height: 1.95; text-align: start;
}
mark.hid {
  background: none; color: var(--pi);
  -webkit-text-emphasis: filled dot; text-emphasis: filled dot;
  -webkit-text-emphasis-position: under right; text-emphasis-position: under right;
}
.part + .part { display: block; margin-top: 1.2em; }
.part { display: block; }
.part-t { display: block; font-family: var(--song); font-size: 14px; color: var(--acc); letter-spacing: .2em; margin-bottom: .3em; }

/* 朱批 */
.pi { font-family: var(--kai); color: var(--pi); font-size: 15px; line-height: 1.9; text-align: justify; }
.pi-tag {
  display: inline-block; font-size: 12px; line-height: 1; padding: 3px 3px 2px; margin-right: .5em;
  border: 1px solid currentColor; border-radius: 2px; vertical-align: .15em;
}
body.no-pi .pi:not(.rd-pi) { display: none; }
.seal {
  display: inline-block; font-family: var(--disp); font-weight: 900; font-size: 13px; letter-spacing: .1em;
  padding: 2px 6px; background: var(--pi); color: var(--bg); border-radius: 2px; transform: rotate(-6deg);
}

/* ── flow：正文 + 旁批 ── */
.flow { max-width: 980px; }
.pb {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 17em); column-gap: clamp(28px, 6vw, 80px);
  padding: 44px 0; border-top: 1px solid var(--line);
}
.pb > .pb-head, .pb > .pb-body { grid-column: 1; }
.pb > .pi { grid-column: 2; grid-row: 1 / span 2; padding-top: .4em; }
.pb-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 18px; }
.pb-head h4 { font-family: var(--disp); font-weight: 900; font-size: 26px; letter-spacing: .06em; line-height: 1.3; }
.pb-meta { font-size: 14px; color: var(--soft); }

/* ── columns：竖排卡片横向长卷 ── */
.strip-wrap { position: relative; }
.strip {
  display: flex; gap: 18px; overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; padding: 4px 2px 22px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.vcard { flex: 0 0 auto; scroll-snap-align: start; display: flex; flex-direction: column; }
.v {
  writing-mode: vertical-rl; height: min(430px, 62svh); padding: 26px 22px;
  border: 1px solid var(--line); background: rgb(var(--ink-rgb) / .035);
  display: flex; flex-direction: column; gap: 0;
}
.v-t { font-family: var(--disp); font-weight: 900; font-size: 22px; letter-spacing: .12em; margin-left: .5em; }
.v-a { font-size: 13px; color: var(--soft); letter-spacing: .2em; margin-left: 1.2em; padding-top: .4em; }
.v-body { font-size: 19px; line-height: 1.9; }
.vcard > .pi { width: 0; min-width: 100%; margin-top: 12px; font-size: 14px; }
.strip-ctl { display: flex; justify-content: flex-end; gap: 8px; }
.round { width: 38px; height: 38px; justify-content: center; padding: 0; font-size: 20px; }

/* ── judgment：判词翻页 ── */
.ce-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin-bottom: 24px; }
.ce-tip { font-size: 14px; color: var(--soft); }
.ce-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 18px; }
.ce { perspective: 1400px; }
.flip { display: grid; height: 100%; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.3, .7, .2, 1); }
.ce.open .flip { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 1px solid rgb(var(--acc-rgb) / .45); padding: 22px 20px; min-height: 340px; text-align: start;
}
.front {
  display: grid; grid-template-rows: auto 1fr auto auto; justify-items: center; gap: 12px;
  background: radial-gradient(120% 80% at 50% 30%, rgb(var(--acc-rgb) / .14), transparent 70%), rgb(var(--bg-rgb) / .6);
  outline-offset: -6px; box-shadow: inset 0 0 0 5px var(--bg), inset 0 0 0 6px rgb(var(--acc-rgb) / .3);
}
.ce-book { font-size: 12px; letter-spacing: .4em; color: var(--acc); }
.ce-em { align-self: center; font-family: var(--disp); font-weight: 900; font-size: 92px; line-height: 1; color: var(--ink); opacity: .9; }
.ce-pic { font-family: var(--kai); font-size: 15px; color: var(--soft); line-height: 1.75; }
.ce-hint { font-size: 12px; letter-spacing: .5em; text-indent: .5em; color: var(--pi); }
.front:hover .ce-em { color: var(--pi); }
.back { transform: rotateY(180deg); background: rgb(var(--bg-rgb) / .92); cursor: pointer; display: grid; align-content: start; gap: 12px; }
.ce-name { font-family: var(--disp); font-weight: 900; font-size: 24px; letter-spacing: .1em; }
.ce-text { font-size: 18px; }
.back .pi { font-size: 14px; }

/* ── qu：十四支曲 ── */
.qu { display: grid; grid-template-columns: minmax(0, 15em) minmax(0, 1fr); gap: clamp(24px, 5vw, 72px); align-items: start; }
.qu-list { position: sticky; top: 84px; list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.qu-list button {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%;
  padding: 7px 14px; margin-left: -1px; border: 0; border-left: 2px solid transparent; background: none; text-align: start;
}
.qu-t { font-family: var(--kai); font-size: 17px; }
.qu-w { font-size: 12px; color: var(--soft); white-space: nowrap; }
.qu-list [aria-selected="true"] { border-left-color: var(--pi); color: var(--pi); background: rgb(var(--pi-rgb) / .08); }
.qu-list [aria-selected="true"] .qu-w { color: inherit; }
.qu-list button:hover { background: rgb(var(--ink-rgb) / .05); }
.pane { min-height: 320px; }
.pane-in { animation: rise .6s both; display: grid; gap: 4px; }
.pane .pb-head h4 { font-size: clamp(26px, 3.6vw, 40px); }
.pane .pb-body { margin-bottom: 22px; }

/* ── ring：菊花诗十二题 ── */
.ring-wrap { display: grid; grid-template-columns: minmax(0, 440px) minmax(0, 1fr); gap: clamp(28px, 6vw, 80px); align-items: center; }
.ring { position: relative; aspect-ratio: 1; width: 100%; }
.ring-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ring-svg circle { fill: none; stroke: var(--line); stroke-width: 1; }
.ring-svg .ring-prog { stroke: var(--pi); stroke-width: 2; stroke-dasharray: var(--d, 1) 12; transform: rotate(-90deg); transition: stroke-dasharray .7s; }
.petal {
  position: absolute; left: 50%; top: 50%; width: 13%; aspect-ratio: 1; margin: -6.5%; padding: 0;
  display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--bg);
  font-family: var(--disp); font-weight: 900; font-size: clamp(15px, 2.2vw, 21px);
  transform: rotate(calc(var(--i) * 30deg)) translateY(-300%) rotate(calc(var(--i) * -30deg));
  transition: background .3s, color .3s, border-color .3s;
}
.petal.past { color: var(--acc); border-color: rgb(var(--acc-rgb) / .5); }
.petal[aria-selected="true"] { background: var(--pi); border-color: var(--pi); color: var(--bg); }
.petal:hover { border-color: var(--pi); }
.ring-core { position: absolute; inset: 30%; display: grid; place-items: center; align-content: center; text-align: center; pointer-events: none; }
.rc-ch { font-family: var(--disp); font-weight: 900; font-size: clamp(56px, 9vw, 112px); line-height: 1; }
.rc-no { font-size: 13px; letter-spacing: .3em; color: var(--soft); margin-top: 8px; }
.pane-nav { display: flex; align-items: center; gap: 14px; margin-top: 22px; font-size: 13px; color: var(--soft); }

/* ── lantern：元宵灯谜 ── */
.lanterns { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 48px 24px; }
.lt { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.lt-lamp { position: relative; display: flex; flex-direction: column; align-items: center; padding-top: 28px; transform-origin: 50% 0; animation: sway 4.4s calc(var(--i) * -.7s) ease-in-out infinite alternate; }
.lt-lamp::before { content: ""; position: absolute; top: 0; left: 50%; width: 1px; height: 28px; background: rgb(var(--acc-rgb) / .7); }
@keyframes sway { from { transform: rotate(-2.5deg); } to { transform: rotate(2.5deg); } }
.lt-cap { width: 52px; height: 9px; border-radius: 3px; background: #c9953f; }
.lt-body {
  writing-mode: vertical-rl; display: grid; place-items: center; width: 96px; height: 118px; margin: -1px 0;
  border-radius: 46% / 42%; color: #f3d9a0;
  background: repeating-linear-gradient(90deg, transparent 0 18px, rgb(0 0 0 / .14) 18px 19px), radial-gradient(circle at 50% 42%, #7c241b, #4a120d 75%);
  box-shadow: 0 0 0 rgb(255 196 110 / 0); transition: background .6s, box-shadow .8s, color .6s;
}
.lt-who { font-family: var(--kai); font-size: 14px; letter-spacing: .2em; }
.lt-ans { display: none; font-family: var(--disp); font-weight: 900; font-size: 22px; letter-spacing: .1em; }
.lt-tassel { width: 2px; height: 30px; background: linear-gradient(#c9953f, transparent); }
.lt.lit .lt-body {
  color: #7a1d12;
  background: repeating-linear-gradient(90deg, transparent 0 18px, rgb(122 29 18 / .12) 18px 19px), radial-gradient(circle at 50% 42%, #fff1c4, #f6b04e 55%, #c94a24);
  box-shadow: 0 0 46px 10px rgb(255 196 110 / .45);
}
.lt.lit .lt-who { display: none; }
.lt.lit .lt-ans { display: block; }
.lt-riddle { font-size: 18px; text-align: center; }
.lt-riddle .ln { padding: 0; text-indent: 0; }
.lt-by { font-size: 13px; color: var(--soft); }
.lt-reveal { display: grid; gap: 8px; max-width: 24em; }
.lt-answer { font-size: 15px; color: var(--acc); letter-spacing: .1em; }
.lt-answer b { font-family: var(--disp); font-weight: 900; font-size: 20px; color: var(--ink); }

/* ── haitang：同韵六首 ── */
.ht-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 28px; }
.ht-rh { display: flex; gap: .5em; font-family: var(--disp); font-weight: 900; font-size: 22px; color: var(--pi); }
.ht { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); gap: 32px 16px; }
.ht-p { display: grid; align-content: start; gap: 12px; }
.ht-p header { display: flex; align-items: flex-start; justify-content: space-between; min-height: 2.4em; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.ht-p h4 { font-family: var(--disp); font-weight: 900; font-size: 20px; letter-spacing: .06em; }
.ht-p h4 small { font-family: var(--song); font-weight: 400; font-size: 13px; color: var(--soft); margin-left: .5em; }
.ht-body { font-size: 17px; }
.ht-body .ln, .ht-body .pi, .ht-p > .pi { transition: color .6s, opacity .6s; }
.rh { font-weight: inherit; color: var(--pi); transition: color .6s, text-shadow .6s; }
.ht.only .ht-body .ln { color: transparent; }
.ht.only .rh { color: var(--pi); text-shadow: 0 0 14px rgb(var(--pi-rgb) / .5); }
.ht.only .ht-p > .pi { opacity: .15; }

/* ── moon：香菱三稿 ── */
.moons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(22px, 4vw, 56px); }
.mo { display: grid; align-content: start; gap: 6px; }
.moon { display: block; width: 92px; height: 92px; margin-bottom: 14px; overflow: visible; }
.mo-dark { fill: rgb(var(--ink-rgb) / .1); stroke: var(--line); }
.mo-lit { fill: #fff7de; filter: drop-shadow(0 0 10px rgb(255 247 222 / .8)); }
.mo-v { font-family: var(--kai); color: var(--pi); font-size: 15px; }
.mo .pb-head { margin-bottom: 10px; }
.mo .pb-body { font-size: 18px; margin-bottom: 14px; }

/* ── linked：联句 ── */
.lk { position: relative; padding: 48px 0; border-top: 1px solid var(--line); }
.lk-k {
  position: absolute; right: 0; top: 18px; font-family: var(--disp); font-weight: 900; font-size: clamp(120px, 18vw, 220px);
  line-height: 1; color: rgb(var(--ink-rgb) / .07); pointer-events: none;
}
.lk .pb-head { position: relative; }
.lk-body { position: relative; columns: 14em; column-gap: 48px; column-rule: 1px solid var(--line); font-size: 18px; margin-bottom: 18px; }
.lk-body .ln { break-inside: avoid; }
.lk:not(.open) .lk-body { columns: auto; max-width: 30em; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.lk:not(.open) .ln:nth-child(n+9) { display: none; }
.lk > .pi { max-width: 40em; margin-top: 18px; }

/* ── daiyu：葬花吟逐行浮现 ── */
.zh { max-width: 760px; margin: 0 auto 72px; display: grid; justify-items: center; gap: 18px; text-align: center; }
.zh-head h4 { font-family: var(--disp); font-weight: 900; font-size: clamp(44px, 7vw, 80px); letter-spacing: .14em; text-indent: .14em; line-height: 1.2; text-align: center; }
.zh-head .pb-meta { margin-top: 6px; }
.zh-body { font-family: var(--kai); font-size: clamp(18px, 2.3vw, 22px); line-height: 2.15; }
.zh-ln { text-align: inherit; transition: opacity 1.4s, transform 1.4s, filter 1.4s; }
.js .zh-ln:not(.in) { opacity: 0; transform: translateY(14px); filter: blur(5px); }
.zh-last { margin-top: 1.2em; color: var(--pi); font-size: 1.15em; }
.zh > .pi { max-width: 34em; }
.zh-hint { font-size: 13px; color: var(--soft); letter-spacing: .2em; }

/* ── lei：芙蓉女儿诔，竖排长卷 ── */
.lei { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.lei-scroll {
  writing-mode: vertical-rl; width: 100%; height: min(70svh, 600px); overflow-x: auto; overflow-y: hidden;
  padding: 26px 30px; border-top: 2px solid rgb(var(--pi-rgb) / .7); border-bottom: 2px solid rgb(var(--pi-rgb) / .7);
  background: rgb(var(--ink-rgb) / .03); scroll-snap-type: none;
}
.lei-text {
  font-family: var(--kai); font-size: 19px; line-height: 2.2; letter-spacing: .06em;
  background-image: repeating-linear-gradient(to left, transparent 0 calc(2.2em - 1px), rgb(var(--pi-rgb) / .22) calc(2.2em - 1px) 2.2em);
}
.lei-text p { text-indent: 2em; text-align: start; }
.lei-hint { font-size: 13px; color: var(--soft); }
.lei > .pi { max-width: 40em; }

/* ── haole：好了歌 / 好了歌解 ── */
.hl, .hj { max-width: 860px; margin: 0 auto; padding: 44px 0; }
.hj { border-top: 1px solid var(--line); }
.hl-body, .hj-body { font-family: var(--kai); font-size: clamp(18px, 2.2vw, 21px); line-height: 2.1; margin-bottom: 20px; }
.hl-st + .hl-st { margin-top: 1.1em; }
.k-hao, .k-le { font-family: var(--disp); font-weight: 900; color: var(--pi); font-size: 1.15em; }
.hj-ln { display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.2em; overflow-x: clip; }
.hj-a { text-align: end; }
.hj-b { text-align: start; transition: opacity 1.2s .5s, transform 1.2s .5s; transform-origin: 0 50%; }
.js .hj-ln:not(.in) .hj-b { opacity: 0; transform: perspective(400px) rotateY(-70deg); }
.hl > .pi, .hj > .pi { max-width: 40em; }

/* ── 尾声 ── */
.finale { position: relative; height: 240vh; }
.fin-in { position: sticky; top: 0; height: 100svh; display: grid; place-items: center; align-content: center; gap: 30px; text-align: center; }
.fin-line {
  writing-mode: vertical-rl; font-family: var(--disp); font-weight: 900; font-size: clamp(30px, 6.4svh, 80px);
  letter-spacing: .32em; line-height: 1.6; color: var(--ink); text-align: start;
  opacity: calc(1 - clamp(0, (var(--q, 0) - .76) * 2.6, .6));
}
.fin-line span { display: inline-block; opacity: clamp(0, calc((var(--q, 1) - .1 - var(--k) * .045) * 14), 1); }
.fin-sub, .fin-back { opacity: clamp(0, calc((var(--q, 1) - .8) * 7), 1); }
.fin-sub { font-size: 13px; letter-spacing: .3em; color: var(--soft); }
.fin-back { font-family: var(--kai); font-size: 16px; letter-spacing: .3em; text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 4px; }

/* ── 弹窗 ── */
dialog {
  color: var(--ink); background: var(--bg); border: 1px solid var(--line); padding: 0; border-radius: 3px;
  width: min(720px, calc(100vw - 24px)); max-width: none; max-height: calc(100svh - 32px); overflow: hidden;
  box-shadow: 0 30px 80px rgb(0 0 0 / .45);
}
dialog::backdrop { background: rgb(0 0 0 / .55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog[open] { animation: rise .35s both; }
.x { position: absolute; top: 10px; right: 10px; z-index: 2; width: 38px; height: 38px; border: 0; background: none; font-size: 26px; line-height: 1; color: var(--soft); }
.x:hover { color: var(--ink); }
.rd-in { position: relative; max-height: calc(100svh - 34px); overflow: auto; padding: 40px clamp(20px, 6vw, 48px) 0; }
.rd-lot { font-family: var(--disp); font-weight: 900; color: var(--pi); letter-spacing: .3em; margin-bottom: 6px; }
.rd-eyebrow { font-size: 13px; color: var(--acc); letter-spacing: .2em; }
#rd-title { font-family: var(--disp); font-weight: 900; font-size: clamp(28px, 6vw, 38px); line-height: 1.25; margin: 6px 40px 4px 0; }
.rd-meta { font-size: 14px; color: var(--soft); margin-bottom: 24px; }
.rd-body { margin-bottom: 22px; }
.rd-body.is-lei { font-size: 17px; }
.rd-body.is-lei p { text-indent: 2em; margin-bottom: .6em; }
.rd-body [data-ans] { margin-top: 18px; }
.rd-ans { display: block; color: var(--acc); margin-bottom: 6px; font-family: var(--song); }
.rd-ans b { font-family: var(--disp); font-weight: 900; color: var(--ink); font-size: 1.2em; }
.rd-pi { margin-bottom: 26px; }
.rd-nav {
  position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between;
  padding: 14px 0 18px; background: linear-gradient(rgb(var(--bg-rgb) / 0), var(--bg) 30%); border-top: 1px solid var(--line);
}
.rd-nav button { border: 1px solid var(--line); border-radius: 99px; background: rgb(var(--ink-rgb) / .04); padding: 5px 14px; font-size: 14px; }
.rd-nav button:disabled { opacity: .35; cursor: default; }
.rd-nav button:not(:disabled):hover { border-color: var(--acc); }

#toc { width: min(980px, calc(100vw - 24px)); }
.toc-in { max-height: calc(100svh - 34px); overflow: auto; }
.toc-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px;
  padding: 22px 60px 16px clamp(20px, 4vw, 36px); background: var(--bg); border-bottom: 1px solid var(--line);
}
#toc-title { font-family: var(--disp); font-weight: 900; font-size: 24px; letter-spacing: .1em; }
#toc-q {
  flex: 1 1 220px; font: inherit; font-size: 15px; color: var(--ink); background: rgb(var(--ink-rgb) / .05);
  border: 1px solid var(--line); border-radius: 99px; padding: 6px 16px;
}
#toc-q::placeholder { color: var(--soft); }
.toc-head .x { top: 16px; }
.toc-list { padding: 8px clamp(20px, 4vw, 36px) 32px; }
.toc-act h3 { font-family: var(--disp); font-weight: 900; font-size: 18px; letter-spacing: .12em; color: var(--pi); margin: 22px 0 6px; }
.toc-g h4 { font-size: 13px; color: var(--acc); letter-spacing: .2em; margin: 12px 0 4px; font-weight: 400; }
.toc-g ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 2px 14px; }
.toc-g button {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 10px; width: 100%;
  border: 0; background: none; padding: 5px 8px; text-align: start; border-radius: 3px;
}
.toc-g button span { font-family: var(--kai); font-size: 16px; }
.toc-g button small { font-size: 12px; color: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: end; }
.toc-g button:hover { background: rgb(var(--ink-rgb) / .07); }
.toc-empty { padding: 32px 0; color: var(--soft); }

/* 跳转后的一闪 */
.flash { animation: flash 1.8s ease-out; }
@keyframes flash {
  0%, 30% { outline: 2px solid rgb(var(--pi-rgb) / .9); outline-offset: 6px; }
  100% { outline: 2px solid rgb(var(--pi-rgb) / 0); outline-offset: 18px; }
}

/* ── 窄屏 ── */
@media (max-width: 760px) {
  :root { font-size: 16px; }
  .bar { padding-top: 10px; }
  .brand { font-size: 14px; letter-spacing: .2em; }
  .tools { gap: 6px; }
  .tools button { padding: 4px 10px; font-size: 13px; }
  .pb { grid-template-columns: minmax(0, 1fr); }
  .pb > .pi { grid-column: 1; grid-row: auto; padding-top: 14px; }
  .qu, .ring-wrap { grid-template-columns: minmax(0, 1fr); }
  .qu-list { position: static; display: flex; overflow-x: auto; border-left: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .qu-list button { flex-direction: column; align-items: flex-start; gap: 0; margin: 0 0 -1px; border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; padding: 6px 12px; }
  .qu-list [aria-selected="true"] { border-bottom-color: var(--pi); }
  .ring { max-width: 360px; margin: 0 auto; }
  .moons { grid-template-columns: minmax(0, 1fr); }
  .mo { grid-template-columns: 80px minmax(0, 1fr); column-gap: 18px; }
  .mo .moon { width: 72px; height: 72px; grid-row: 1 / span 3; }
  .mo > * { grid-column: 2; }
  .mo > .moon { grid-column: 1; }
  .face { min-height: 300px; }
  .ce-em { font-size: 80px; }
  .lanterns { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 14px; }
  .lt-riddle { font-size: 16px; }
  .hj-ln { grid-template-columns: minmax(0, 1fr); }
  .hj-a { text-align: start; }
  .hj-b { padding-left: 2em; }
  .lk-k { font-size: 110px; }
}
@media (max-width: 420px) {
  .lanterns { grid-template-columns: minmax(0, 1fr); }
  .rd-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .rd-nav button { padding: 5px 0; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .js .zh-ln:not(.in), .js .hj-ln:not(.in) .hj-b { opacity: 1; transform: none; filter: none; }
}
