/* 德王府 · 长文阅读页 */
:root {
  --paper: #faf8f5;
  --ink: #1c1917;
  --muted: #78716c;
  --accent: #00a86b;
  --bar-bg: rgba(250, 248, 245, 0.82);
  --rule: rgba(28, 25, 23, 0.08);
  --fs: clamp(1.0625rem, 0.95rem + 0.55vw, 1.1875rem);
  --lh: 1.9;
  --measure: 38rem;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}
body {
  font-family: "Noto Serif SC", "Songti SC", "SimSun", serif;
  background: var(--paper);
  color: var(--ink);
  line-height: var(--lh);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: var(--safe-b);
}
a { color: var(--accent); text-decoration: none; }
a:focus-visible {
  outline: 3px solid rgba(0, 168, 107, 0.4);
  outline-offset: 3px;
  border-radius: 8px;
}

/* sticky bar */
.reader-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  background: var(--bar-bg);
  border-bottom: 1px solid var(--rule);
  padding-top: var(--safe-t);
}
.reader-bar__inner {
  max-width: calc(var(--measure) + 4rem);
  margin: 0 auto;
  padding: 10px max(16px, var(--safe-r)) 10px max(16px, var(--safe-l));
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}
.reader-bar__back {
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 4px 2px;
}
.reader-bar__title {
  flex: 1;
  text-align: center;
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reader-bar__actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.fs-btn {
  font-family: "Noto Sans SC", -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(28, 25, 23, 0.05);
  border: none;
  border-radius: 980px;
  min-width: 36px;
  min-height: 36px;
  padding: 0 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fs-btn:active { background: rgba(28, 25, 23, 0.12); }

/* toc */
.toc {
  position: sticky;
  top: calc(48px + var(--safe-t));
  z-index: 35;
  background: rgba(250, 248, 245, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.toc[hidden] { display: none; }
.toc__inner {
  max-width: calc(var(--measure) + 4rem);
  margin: 0 auto;
  padding: 12px max(16px, var(--safe-r)) 14px max(16px, var(--safe-l));
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.toc a {
  font-family: "Noto Sans SC", -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: rgba(28, 25, 23, 0.04);
  padding: 6px 12px;
  border-radius: 980px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.toc a:hover { color: var(--ink); background: rgba(28, 25, 23, 0.08); }

/* reader body */
.reader {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(28px, 6vw, 48px) max(20px, var(--safe-l)) clamp(64px, 12vw, 96px) max(20px, var(--safe-r));
  font-size: var(--fs);
}
.reader-hero {
  text-align: center;
  margin-bottom: clamp(36px, 8vw, 56px);
  padding-bottom: clamp(28px, 5vw, 40px);
  border-bottom: 1px solid var(--rule);
}
.reader-hero__eyebrow {
  font-family: "Noto Sans SC", -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.reader-hero__title {
  font-size: clamp(1.75rem, 1.3rem + 2.2vw, 2.35rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.35;
  margin-bottom: 10px;
}
.reader-hero__sub {
  font-size: clamp(0.95rem, 0.88rem + 0.35vw, 1.05rem);
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-bottom: 20px;
}
.reader-hero__by {
  font-family: "Noto Sans SC", -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: 0.2em;
}

.chapter {
  margin-bottom: clamp(40px, 8vw, 64px);
}
.chapter__title {
  font-size: clamp(1.15rem, 1.02rem + 0.6vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.45;
  text-align: center;
  margin: 0 0 1.4em;
  padding-top: 0.5em;
}
.chapter__poem {
  text-align: center;
  margin: 0 auto 1.8em;
  color: var(--muted);
  font-size: 0.95em;
  line-height: 1.85;
}
.chapter__poem p { margin: 0; }

.reader p {
  margin: 0 0 1.15em;
  text-align: justify;
  text-justify: inter-ideograph;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.scene-break {
  border: none;
  height: 0;
  margin: 1.8em auto;
  text-align: center;
  position: relative;
}
.scene-break::before {
  content: "· · ·";
  color: var(--muted);
  letter-spacing: 0.45em;
  font-size: 0.85em;
  display: block;
}

.reader-foot {
  text-align: center;
  padding-top: 2em;
  border-top: 1px solid var(--rule);
  font-family: "Noto Sans SC", -apple-system, sans-serif;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
.reader-foot p { margin: 0 0 0.6em; text-align: center; }
.reader-foot__notice {
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #a8a29e;
}
.reader-foot a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  font-weight: 500;
}

/* anti-copy (best-effort) */
.reader,
.reader * {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}
.reader-bar,
.toc {
  -webkit-user-select: none;
  user-select: none;
}

/* tablet+ */
@media (min-width: 768px) {
  :root {
    --fs: clamp(1.125rem, 1rem + 0.4vw, 1.25rem);
    --lh: 1.95;
    --measure: 40rem;
  }
  .reader {
    padding-left: 32px;
    padding-right: 32px;
  }
}

@media (min-width: 1024px) {
  :root { --measure: 42rem; }
}

@media print {
  .reader-bar, .toc, .reader-bar__actions { display: none !important; }
  body { background: #fff; }
  .reader { max-width: none; }
}

/* subtle chapter eyebrow / preface */
.chapter__eyebrow {
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: center;
  margin: -0.25rem 0 1.25rem;
}
.chapter--preface .chapter__title {
  font-size: 1.15rem;
}
.chapter--preface p {
  color: var(--muted);
  font-size: 0.95em;
}
