:root {
  --paper: #f6f1e7;
  --paper-deep: #ebe2d3;
  --paper-light: #fffdf8;
  --ink: #24211d;
  --ink-soft: #5f584e;
  --ink-faint: #857c6f;
  --rule: rgba(36, 33, 29, 0.16);
  --accent: #b7472e;
  --accent-dark: #86301f;
  --accent-pale: #f0d7c9;
  --serif: "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", SimSun, Georgia, serif;
  --sans: Inter, "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --reading-progress: 0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  z-index: -1;
  inset: 0;
  content: "";
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
}

a {
  color: inherit;
}

button {
  color: inherit;
  font: inherit;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: var(--paper-light);
  background: var(--ink);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.reader-bar {
  position: sticky;
  z-index: 40;
  top: 0;
  height: 64px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 0 clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--rule);
  background: rgba(246, 241, 231, 0.92);
  backdrop-filter: blur(18px);
}

.reader-progress-track {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  overflow: hidden;
  background: transparent;
}

.reader-progress-bar {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.reader-brand,
.reader-back {
  width: max-content;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.reader-brand {
  font-weight: 700;
}

.reader-brand span {
  margin-right: 9px;
  color: var(--accent);
}

.reader-back {
  justify-self: end;
}

.reader-back:hover,
.reader-brand:hover {
  color: var(--accent-dark);
}

.reader-status {
  justify-self: center;
  color: var(--ink-faint);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.contents-button {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.contents-button::before {
  width: 15px;
  height: 11px;
  border-block: 1px solid currentColor;
  content: "";
  background: linear-gradient(currentColor, currentColor) center / 100% 1px no-repeat;
}

.book-cover {
  position: relative;
  min-height: min(840px, calc(100vh - 64px));
  overflow: hidden;
  display: grid;
  align-items: center;
  padding: clamp(70px, 10vw, 148px) clamp(24px, 7vw, 104px);
  border-bottom: 1px solid var(--rule);
}

.book-cover::before {
  position: absolute;
  top: 9%;
  right: clamp(-80px, 4vw, 80px);
  width: min(40vw, 560px);
  aspect-ratio: 1;
  border: 1px solid rgba(183, 71, 46, 0.3);
  border-radius: 50%;
  content: "";
  box-shadow:
    0 0 0 34px rgba(183, 71, 46, 0.035),
    0 0 0 92px rgba(183, 71, 46, 0.025);
}

.book-cover::after {
  position: absolute;
  top: 18%;
  right: 11%;
  width: clamp(80px, 10vw, 150px);
  height: clamp(80px, 10vw, 150px);
  border-radius: 50%;
  content: "";
  background: var(--accent);
  opacity: 0.96;
}

.cover-inner {
  position: relative;
  z-index: 1;
  width: min(1160px, 100%);
  margin: 0 auto;
}

.cover-kicker {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 clamp(36px, 6vw, 76px);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.cover-kicker::before {
  width: 34px;
  height: 1px;
  content: "";
  background: currentColor;
}

.book-cover h1 {
  max-width: 900px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(56px, 8.6vw, 124px);
  font-weight: 750;
  line-height: 1.02;
  letter-spacing: -0.07em;
}

.cover-deck {
  max-width: 690px;
  margin: clamp(30px, 4vw, 52px) 0 0;
  color: var(--ink-soft);
  font-family: var(--serif);
  font-size: clamp(19px, 2vw, 27px);
  line-height: 1.72;
  letter-spacing: 0.015em;
}

.cover-deck p {
  margin: 0 0 0.85em;
}

.cover-deck p:last-child {
  margin-bottom: 0;
}

.cover-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: clamp(34px, 5vw, 60px);
}

.start-reading,
.continue-reading {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: 1px solid var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.start-reading {
  gap: 24px;
  color: var(--paper-light);
  background: var(--ink);
}

.start-reading::after {
  color: var(--accent-pale);
  content: "↓";
  font-size: 18px;
}

.start-reading:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.continue-reading {
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.continue-reading:hover {
  color: var(--accent-dark);
  border-color: var(--accent);
}

.continue-reading[hidden] {
  display: none;
}

.reading-shell {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(180px, 230px) minmax(0, 720px);
  justify-content: center;
  gap: clamp(58px, 8vw, 112px);
  padding: clamp(72px, 9vw, 132px) 0 clamp(110px, 13vw, 190px);
}

.contents {
  position: relative;
}

.contents-inner {
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 132px);
  overflow: auto;
  scrollbar-width: thin;
}

.contents-title {
  margin: 0 0 22px;
  color: var(--ink-faint);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.18em;
}

.contents-close {
  display: none;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.contents ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: chapter;
}

.contents li {
  counter-increment: chapter;
  border-top: 1px solid var(--rule);
}

.contents li:last-child {
  border-bottom: 1px solid var(--rule);
}

.contents a {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 8px;
  padding: 12px 5px 13px 0;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.45;
  transition: color 140ms ease, padding-left 140ms ease;
}

.contents a::before {
  color: var(--ink-faint);
  content: counter(chapter, decimal-leading-zero);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.contents a:hover,
.contents a.is-active {
  padding-left: 5px;
  color: var(--accent-dark);
}

.contents a.is-active::after {
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: -12px;
  width: 2px;
  content: "";
  background: var(--accent);
}

.contents-backdrop {
  display: none;
}

.article {
  min-width: 0;
  font-family: var(--serif);
  font-size: clamp(18px, 1.55vw, 20px);
  line-height: 1.95;
  letter-spacing: 0.012em;
}

.chapter {
  position: relative;
  scroll-margin-top: 92px;
  padding-top: 18px;
}

.chapter + .chapter {
  margin-top: clamp(104px, 12vw, 164px);
  padding-top: clamp(72px, 8vw, 112px);
  border-top: 1px solid var(--rule);
}

.chapter-number {
  display: block;
  margin-bottom: 26px;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.16em;
}

.chapter h2 {
  max-width: 680px;
  margin: 0 0 48px;
  font-family: var(--serif);
  font-size: clamp(38px, 5vw, 58px);
  font-weight: 760;
  line-height: 1.16;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.chapter h3 {
  margin: 3.4em 0 1em;
  color: var(--ink);
  font-family: var(--sans);
  font-size: clamp(23px, 2.5vw, 30px);
  font-weight: 720;
  line-height: 1.35;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.chapter h4 {
  margin: 2.8em 0 0.9em;
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 750;
  line-height: 1.5;
}

.chapter p {
  margin: 0 0 1.35em;
}

.chapter > p:first-of-type {
  color: #403a32;
  font-size: 1.12em;
  line-height: 1.9;
}

.chapter p + p {
  text-indent: 2em;
}

.chapter h2 + p,
.chapter h3 + p,
.chapter h4 + p,
.chapter blockquote + p,
.chapter ul + p,
.chapter ol + p,
.chapter hr + p {
  text-indent: 0;
}

.chapter strong {
  font-weight: 750;
  background: linear-gradient(transparent 72%, rgba(183, 71, 46, 0.18) 72%);
}

.chapter em {
  color: var(--accent-dark);
  font-style: normal;
}

.chapter a {
  text-decoration-color: rgba(183, 71, 46, 0.55);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.chapter a:hover {
  color: var(--accent-dark);
}

.chapter blockquote {
  position: relative;
  margin: 3.3em clamp(-54px, -4vw, -24px);
  padding: 30px clamp(28px, 4vw, 54px) 32px;
  border: 0;
  color: #3d2b24;
  background: var(--accent-pale);
  font-size: clamp(21px, 2vw, 27px);
  font-weight: 650;
  line-height: 1.72;
}

.chapter blockquote::before {
  position: absolute;
  top: -31px;
  left: 18px;
  color: var(--accent);
  content: "“";
  font-family: Georgia, serif;
  font-size: 84px;
  font-weight: 700;
  line-height: 1;
}

.chapter blockquote p {
  margin: 0;
  text-indent: 0;
}

.chapter blockquote p + p {
  margin-top: 0.8em;
}

.chapter ul,
.chapter ol {
  margin: 1.6em 0 2em;
  padding-left: 1.4em;
}

.chapter li {
  margin: 0.65em 0;
  padding-left: 0.25em;
}

.chapter li::marker {
  color: var(--accent);
  font-family: var(--sans);
  font-weight: 750;
}

.chapter hr {
  width: 54px;
  height: 1px;
  margin: 4.2em auto;
  border: 0;
  background: var(--accent);
}

.chapter code {
  padding: 0.12em 0.32em;
  border-radius: 3px;
  background: rgba(36, 33, 29, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.84em;
}

.chapter figure {
  margin: 3em 0;
}

.chapter img {
  display: block;
  max-width: 100%;
  height: auto;
}

.chapter figcaption {
  margin-top: 10px;
  color: var(--ink-faint);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.6;
}

.reader-colophon {
  margin-top: clamp(96px, 12vw, 150px);
  padding-top: 34px;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.75;
}

.reader-colophon p {
  max-width: 560px;
  margin: 0;
}

.reader-colophon a {
  display: inline-block;
  margin-top: 22px;
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 920px) {
  .reader-bar {
    grid-template-columns: 1fr auto auto;
  }

  .reader-brand {
    overflow: hidden;
    max-width: 42vw;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .reader-back {
    display: none;
  }

  .reader-status {
    justify-self: end;
  }

  .contents-button {
    display: inline-flex;
  }

  .book-cover {
    min-height: min(760px, calc(100vh - 64px));
  }

  .book-cover::before {
    top: 14%;
    right: -24vw;
    width: 72vw;
  }

  .book-cover::after {
    top: 20%;
    right: 8%;
  }

  .reading-shell {
    width: min(720px, calc(100% - 40px));
    display: block;
    padding-top: 76px;
  }

  .contents {
    position: fixed;
    z-index: 70;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 88vw);
    padding: 82px 28px 30px;
    background: var(--paper-light);
    box-shadow: -18px 0 50px rgba(36, 33, 29, 0.16);
    transform: translateX(105%);
    transition: transform 220ms ease;
  }

  .contents.is-open {
    transform: translateX(0);
  }

  .contents-inner {
    position: static;
    max-height: 100%;
  }

  .contents-close {
    position: absolute;
    top: 22px;
    right: 22px;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: var(--ink-soft);
    font-size: 0;
  }

  .contents-close::before,
  .contents-close::after {
    position: absolute;
    width: 20px;
    height: 1px;
    content: "";
    background: currentColor;
  }

  .contents-close::before {
    transform: rotate(45deg);
  }

  .contents-close::after {
    transform: rotate(-45deg);
  }

  .contents-backdrop {
    position: fixed;
    z-index: 60;
    inset: 0;
    display: block;
    border: 0;
    background: rgba(36, 33, 29, 0.46);
  }

  .contents-backdrop[hidden] {
    display: none;
  }

  body.contents-open {
    overflow: hidden;
  }

  .chapter blockquote {
    margin-inline: -12px;
  }
}

@media (max-width: 600px) {
  html {
    scroll-padding-top: 82px;
  }

  .reader-bar {
    height: 58px;
    gap: 12px;
    padding-inline: 16px;
  }

  .reader-brand span {
    margin-right: 5px;
  }

  .reader-status {
    font-size: 10px;
  }

  .book-cover {
    min-height: 660px;
    align-items: end;
    padding: 82px 22px 68px;
  }

  .book-cover::before {
    top: 5%;
    right: -36vw;
    width: 92vw;
  }

  .book-cover::after {
    top: 11%;
    right: 8%;
    width: 76px;
    height: 76px;
  }

  .cover-kicker {
    margin-bottom: 30px;
    font-size: 9px;
  }

  .book-cover h1 {
    max-width: 12em;
    font-size: clamp(48px, 16vw, 72px);
    line-height: 1.08;
    letter-spacing: -0.06em;
  }

  .cover-deck {
    margin-top: 26px;
    font-size: 18px;
    line-height: 1.65;
  }

  .cover-actions {
    margin-top: 32px;
  }

  .start-reading,
  .continue-reading {
    min-height: 44px;
    padding-inline: 16px;
  }

  .reading-shell {
    width: calc(100% - 40px);
    padding: 66px 0 110px;
  }

  .article {
    font-size: 18px;
    line-height: 1.92;
  }

  .chapter {
    scroll-margin-top: 76px;
  }

  .chapter + .chapter {
    margin-top: 88px;
    padding-top: 62px;
  }

  .chapter-number {
    margin-bottom: 20px;
  }

  .chapter h2 {
    margin-bottom: 36px;
    font-size: clamp(34px, 10vw, 45px);
    line-height: 1.2;
  }

  .chapter h3 {
    margin-top: 2.9em;
    font-size: 23px;
  }

  .chapter p {
    margin-bottom: 1.25em;
  }

  .chapter > p:first-of-type {
    font-size: 1.06em;
  }

  .chapter blockquote {
    margin: 2.8em -6px;
    padding: 28px 22px 26px;
    font-size: 20px;
  }

  .chapter blockquote::before {
    top: -24px;
    left: 10px;
    font-size: 66px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body {
    background: white;
  }

  body::before,
  .reader-bar,
  .contents,
  .contents-backdrop,
  .cover-actions {
    display: none !important;
  }

  .book-cover {
    min-height: 0;
    padding: 64px 0 80px;
  }

  .book-cover::before,
  .book-cover::after {
    display: none;
  }

  .reading-shell {
    width: 100%;
    display: block;
    padding: 0;
  }

  .article {
    width: 100%;
    max-width: none;
    color: black;
    font-size: 11pt;
  }

  .chapter + .chapter {
    break-before: page;
  }

  .chapter blockquote {
    margin-inline: 0;
    background: #f2f2f2;
  }
}
