:root {
  --paper: #f4efe3;
  --paper-deep: #ece4d4;
  --ink: #1f1c18;
  --ink-soft: #4c463f;
  --mist: rgba(31, 28, 24, 0.08);
  --line: rgba(57, 50, 43, 0.16);
  --accent: #7f2018;
  --accent-soft: rgba(127, 32, 24, 0.1);
  --card: rgba(250, 246, 238, 0.84);
  --shadow: 0 22px 50px rgba(31, 28, 24, 0.08);
  --font-body: "STSong", "Songti SC", "Noto Serif CJK SC", serif;
  --font-display: "Kaiti SC", "STKaiti", "KaiTi", serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(86, 92, 95, 0.08), transparent 32%),
    linear-gradient(180deg, #f7f3ea, var(--paper));
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.paper-grain,
.ink-wash {
  pointer-events: none;
  position: fixed;
  inset: 0;
}

.paper-grain {
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(92, 80, 71, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(92, 80, 71, 0.025) 1px, transparent 1px);
  background-size: 14px 14px;
  mix-blend-mode: multiply;
}

.ink-wash {
  z-index: -1;
  filter: blur(10px);
}

.ink-wash-left {
  background:
    radial-gradient(circle at 10% 8%, rgba(12, 19, 27, 0.14), transparent 18%),
    radial-gradient(circle at 18% 24%, rgba(27, 31, 36, 0.12), transparent 22%),
    radial-gradient(circle at 4% 54%, rgba(40, 47, 54, 0.08), transparent 18%);
}

.ink-wash-right {
  background:
    radial-gradient(circle at 92% 14%, rgba(17, 21, 25, 0.12), transparent 16%),
    radial-gradient(circle at 88% 46%, rgba(29, 34, 40, 0.11), transparent 20%),
    radial-gradient(circle at 102% 72%, rgba(46, 56, 62, 0.09), transparent 16%);
}

.hero {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  max-width: 1280px;
  margin: 0 auto;
  padding: 56px 28px 24px;
}

.hero__seal {
  width: 112px;
  height: 112px;
  border: 2px solid rgba(127, 32, 24, 0.7);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 58px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: rgba(255, 248, 240, 0.75);
  box-shadow: inset 0 0 0 8px rgba(127, 32, 24, 0.08);
  transform: rotate(-4deg);
}

.hero__eyebrow {
  margin: 0 0 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--ink-soft);
}

.hero h1 {
  margin: 0;
  font-size: clamp(34px, 4.4vw, 58px);
  line-height: 1.08;
  font-family: var(--font-display);
  font-weight: 400;
}

.hero__subtitle {
  max-width: 760px;
  margin: 16px 0 0;
  font-size: 17px;
  line-height: 1.9;
  color: var(--ink-soft);
}

.hero__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.hero__meta span {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.58);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 28px 48px;
}

.toc-panel,
.content-panel {
  border: 1px solid var(--line);
  background: rgba(249, 244, 236, 0.72);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.toc-panel {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px 16px 20px;
  border-radius: 28px;
}

.toc-panel__header,
.content-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.toc-panel__header h2,
.content-toolbar {
  margin: 0;
}

.toc-intro {
  margin: 10px 2px 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.7;
}

.toc-toggle,
.ghost-button,
.chapter-card__jump {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 251, 244, 0.72);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.toc-toggle:hover,
.ghost-button:hover,
.chapter-card__jump:hover,
.toc-link:hover {
  transform: translateY(-1px);
  border-color: rgba(127, 32, 24, 0.38);
}

.toc-part {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 18px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  color: var(--ink-soft);
}

.toc-part strong {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--ink);
}

.toc-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.toc-link {
  display: grid;
  gap: 4px;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid transparent;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.5);
  transition: all 180ms ease;
}

.toc-link.is-active {
  background: rgba(127, 32, 24, 0.12);
  border-color: rgba(127, 32, 24, 0.24);
  color: var(--accent);
}

.toc-link__kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.toc-link__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
}

.toc-link__excerpt {
  font-size: 12px;
  color: rgba(76, 70, 63, 0.82);
  line-height: 1.45;
}

.content-panel {
  border-radius: 34px;
  padding: 20px;
}

.search {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.search span {
  white-space: nowrap;
  color: var(--ink-soft);
}

.search input {
  width: min(100%, 420px);
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 247, 0.8);
  padding: 12px 16px;
  font: inherit;
  color: var(--ink);
  outline: none;
}

.search input:focus {
  border-color: rgba(127, 32, 24, 0.36);
  box-shadow: 0 0 0 4px rgba(127, 32, 24, 0.08);
}

.chapter-stream {
  display: grid;
  gap: 22px;
  margin-top: 20px;
}

.chapter-card {
  position: relative;
  overflow: hidden;
  border-radius: 26px;
  padding: 24px;
  border: 1px solid rgba(55, 49, 43, 0.12);
  background:
    linear-gradient(145deg, rgba(255, 253, 248, 0.9), rgba(246, 239, 228, 0.82)),
    var(--card);
  box-shadow: 0 16px 30px rgba(32, 26, 20, 0.05);
}

.chapter-card::before {
  content: "";
  position: absolute;
  inset: -30% auto auto 75%;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(15, 20, 27, 0.08), transparent 70%);
  filter: blur(3px);
}

.chapter-card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.chapter-card__part {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.chapter-card__title {
  margin: 0;
  font-size: 30px;
  font-family: var(--font-display);
  font-weight: 400;
}

.chapter-card__summary {
  margin-top: 16px;
  padding: 14px 16px;
  border-left: 3px solid rgba(127, 32, 24, 0.34);
  background: rgba(255, 250, 243, 0.72);
  color: var(--ink-soft);
  line-height: 1.9;
}

.chapter-card__block {
  margin-top: 18px;
}

.chapter-card__block h4 {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.chapter-card__original,
.chapter-card__notes p {
  margin: 0;
  line-height: 2;
  font-size: 17px;
}

.chapter-card__original {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(252, 247, 238, 0.86);
  border: 1px solid rgba(57, 50, 43, 0.08);
}

.chapter-card__notes {
  display: grid;
  gap: 14px;
}

.chapter-card.is-collapsed .chapter-card__block {
  display: none;
}

.chapter-card.is-collapsed .chapter-card__summary {
  margin-bottom: 0;
}

.chapter-card.is-hidden {
  display: none;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .toc-panel {
    position: static;
    height: auto;
  }
}

@media (max-width: 720px) {
  .hero {
    grid-template-columns: 1fr;
    padding: 40px 18px 18px;
  }

  .hero__seal {
    width: 92px;
    height: 92px;
    font-size: 48px;
  }

  .layout {
    padding: 14px 18px 32px;
  }

  .content-toolbar,
  .toc-panel__header {
    flex-direction: column;
    align-items: stretch;
  }

  .search {
    flex-direction: column;
    align-items: stretch;
  }

  .search input {
    width: 100%;
  }

  .toc-list {
    grid-template-columns: 1fr;
  }

  .chapter-card {
    padding: 20px;
  }

  .chapter-card__header {
    flex-direction: column;
  }
}
