.book-site {
  --book-max: 1540px;
  min-height: 100vh;
  background: #0b0e0c;
  color: #f0eee5;
}

.reading-progress {
  position: fixed;
  z-index: 100;
  inset: 0 0 auto;
  height: 2px;
  background: #79e6a2;
  transform: scaleX(.04);
  transform-origin: left;
}

@supports (animation-timeline: scroll()) {
  .reading-progress { animation: book-scroll-progress linear; animation-timeline: scroll(root); }
}

@keyframes book-scroll-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.book-topbar {
  position: sticky;
  z-index: 50;
  top: 0;
  height: 78px;
  padding-inline: max(28px, calc((100vw - var(--book-max)) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #29312b;
  background: rgba(11, 14, 12, .92);
  backdrop-filter: blur(16px);
}

.book-brand { display: inline-flex; align-items: center; gap: 13px; }
.book-brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #3a463d; color: #79e6a2; font: 700 10px/1 var(--mono); }
.book-brand-title { display: grid; gap: 3px; }
.book-brand-title strong { font: 500 12px/1 var(--serif); }
.book-brand-title small { color: #8c948c; font: 600 8px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.book-topbar nav { display: flex; align-items: center; gap: 34px; }
.book-topbar nav > a { color: #aeb4ac; font: 600 9px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; transition: color .16s ease; }
.book-topbar nav > a:hover { color: #79e6a2; }
.book-topbar .book-topbar-cta { min-height: 38px; padding-inline: 15px; display: inline-flex; align-items: center; gap: 18px; border: 1px solid #3a463d; color: #f0eee5; }

.book-kicker { margin: 0; display: flex; align-items: center; gap: 12px; color: #79e6a2; font: 650 9px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; }
.book-kicker > span { width: 30px; height: 1px; background: #79e6a2; }
.book-button { min-height: 54px; width: max-content; margin-top: 38px; padding: 0 23px; display: inline-flex; align-items: center; gap: 44px; background: #79e6a2; color: #0b0e0c; font: 700 11px/1 var(--mono); transition: transform .16s ease, background .16s ease, color .16s ease; }
.book-button:hover { transform: translateY(-2px); background: transparent; color: #79e6a2; box-shadow: inset 0 0 0 1px #79e6a2; }

/* Library */
.book-index { width: min(var(--book-max), calc(100% - 80px)); margin-inline: auto; }
.library-hero { min-height: 680px; padding: 92px 0 82px; display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 100px; align-items: center; }
.library-hero h1 { max-width: 850px; margin: 34px 0 30px; font: 400 clamp(60px, 6.2vw, 100px)/.94 var(--serif); letter-spacing: -.055em; }
.library-hero h1 em { color: #79e6a2; font-weight: 400; }
.library-lede { max-width: 680px; margin: 0; color: #b9beb6; font-size: 18px; line-height: 1.7; }
.library-status { padding: 34px; border: 1px solid #334037; background: #111612; }
.library-status > p { margin: 0 0 25px; color: #8c948c; font: 600 9px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; }
.library-status > strong { display: block; font: 400 96px/.9 var(--serif); letter-spacing: -.07em; }
.library-status > strong span { color: #59635c; font-size: .45em; letter-spacing: -.03em; }
.status-track { height: 3px; margin: 27px 0 35px; background: #29312b; }
.status-track i { display: block; height: 100%; background: #79e6a2; }
.library-status dl { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; }
.library-status dl div { border-left: 1px solid #29312b; padding-left: 14px; }
.library-status dl div:first-child { padding-left: 0; border-left: 0; }
.library-status dt { color: #f0eee5; font: 500 14px/1.2 var(--serif); }
.library-status dd { margin: 7px 0 0; color: #8c948c; font: 600 8px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.library-content { padding-bottom: 130px; }
.library-intro { display: grid; grid-template-columns: 190px 1fr 410px; gap: 45px; align-items: end; padding: 70px 0 55px; border-top: 1px solid #29312b; }
.library-intro h2 { margin: 0; font: 400 clamp(48px, 5vw, 76px)/.95 var(--serif); }
.library-intro > p:last-child { margin: 0; color: #9ca39b; font-size: 15px; line-height: 1.65; }
.chapter-group { margin-top: 72px; }
.chapter-group > header { min-height: 70px; display: grid; grid-template-columns: 60px 1fr auto; align-items: center; border-top: 1px solid #3a463d; border-bottom: 1px solid #29312b; }
.chapter-group > header span { color: #79e6a2; font: 600 9px/1 var(--mono); }
.chapter-group > header h2 { margin: 0; font: 400 25px/1.2 var(--serif); }
.chapter-group > header small { color: #8c948c; font: 600 8px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.chapter-cards { border-bottom: 1px solid #29312b; }
.chapter-card { min-height: 134px; display: grid; grid-template-columns: 60px minmax(0, 1fr) 72px 20px; gap: 22px; align-items: center; border-bottom: 1px solid #29312b; transition: background .16s ease, padding .16s ease; }
.chapter-card:last-child { border-bottom: 0; }
.chapter-card:hover { padding-inline: 18px; background: #111612; }
.chapter-card-number { color: #79e6a2; font: 600 10px/1 var(--mono); }
.chapter-card h3 { margin: 0 0 11px; font: 400 27px/1.15 var(--serif); }
.chapter-card p { max-width: 900px; margin: 0; color: #8c948c; font-size: 13px; line-height: 1.55; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chapter-card small { color: #8c948c; font: 600 8px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.chapter-card i { color: #79e6a2; font-style: normal; }
.coming-next { margin-top: 96px; padding: 50px 0; display: grid; grid-template-columns: 120px 1fr 390px; gap: 45px; align-items: start; border-top: 1px solid #3a463d; border-bottom: 1px solid #29312b; }
.coming-next > span { color: #79e6a2; font: 600 11px/1 var(--mono); }
.coming-next div p { margin: 0 0 15px; color: #8c948c; font: 600 9px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.coming-next h2 { margin: 0; max-width: 650px; font: 400 37px/1.1 var(--serif); }
.coming-next > p { margin: 0; color: #8c948c; font-size: 14px; line-height: 1.65; }

/* Reader */
.reader-layout { width: min(var(--book-max), calc(100% - 56px)); margin: 0 auto; display: grid; grid-template-columns: 270px minmax(0, 820px) 220px; gap: 60px; align-items: start; }
.chapter-sidebar { position: sticky; top: 106px; max-height: calc(100vh - 130px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: #3a463d transparent; padding-bottom: 24px; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; min-height: 45px; border-bottom: 1px solid #3a463d; color: #8c948c; font: 600 8px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.sidebar-head p { margin: 0; }
.sidebar-head span { color: #79e6a2; }
.chapter-sidebar nav { padding: 10px 0; }
.chapter-sidebar nav a { min-height: 50px; padding: 10px 9px; display: grid; grid-template-columns: 30px 1fr; gap: 6px; align-items: center; border-left: 1px solid transparent; color: #788078; transition: color .14s ease, background .14s ease, border-color .14s ease; }
.chapter-sidebar nav a:hover { color: #c8cbc2; background: #111612; }
.chapter-sidebar nav a.is-current { color: #f0eee5; border-color: #79e6a2; background: #111612; }
.chapter-sidebar nav a > span { color: #647069; font: 600 8px/1 var(--mono); }
.chapter-sidebar nav a.is-current > span { color: #79e6a2; }
.chapter-sidebar nav strong { font: 500 11px/1.35 var(--sans); }
.sidebar-all { display: flex; justify-content: space-between; margin-top: 8px; padding: 17px 10px; border-top: 1px solid #29312b; border-bottom: 1px solid #29312b; color: #b7bbb4; font: 600 9px/1 var(--mono); }
.reader-article { min-width: 0; padding: 84px 0 120px; }
.mobile-chapter-menu { display: none; }
.chapter-header { padding-bottom: 70px; border-bottom: 1px solid #3a463d; }
.chapter-breadcrumb { display: flex; gap: 10px; margin: 0 0 47px; color: #687169; font: 600 8px/1.4 var(--mono); letter-spacing: .09em; text-transform: uppercase; }
.chapter-breadcrumb a { color: #a9afa7; }
.chapter-breadcrumb a:hover { color: #79e6a2; }
.chapter-header h1 { max-width: 800px; margin: 32px 0 30px; font: 400 clamp(50px, 5vw, 78px)/.98 var(--serif); letter-spacing: -.045em; }
.chapter-meta { display: flex; flex-wrap: wrap; gap: 9px; }
.chapter-meta span { padding: 8px 10px; border: 1px solid #29312b; color: #899088; font: 600 8px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.chapter-brief { margin-top: 43px; display: grid; gap: 1px; background: #29312b; border: 1px solid #29312b; }
.chapter-brief > div { padding: 22px 25px; background: #111612; }
.chapter-brief small { color: #79e6a2; font: 650 8px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.chapter-brief p { margin: 10px 0 0; color: #c1c5bd; font-size: 14px; line-height: 1.65; }

.chapter-content { padding-top: 45px; color: #c8cbc2; font-size: 17px; line-height: 1.78; }
.chapter-content > :first-child { margin-top: 0; }
.chapter-content h2, .chapter-content h3, .chapter-content h4 { color: #f0eee5; scroll-margin-top: 105px; }
.chapter-content h2 { margin: 95px 0 25px; padding-top: 31px; border-top: 1px solid #29312b; font: 400 42px/1.12 var(--serif); letter-spacing: -.025em; }
.chapter-content h3 { margin: 54px 0 18px; font: 400 28px/1.2 var(--serif); }
.chapter-content h4 { margin: 38px 0 16px; font: 650 17px/1.3 var(--sans); }
.chapter-content p { margin: 0 0 24px; }
.chapter-content strong { color: #f0eee5; font-weight: 650; }
.chapter-content em { color: #d8dbd3; }
.chapter-content a { color: #79e6a2; border-bottom: 1px solid rgba(121, 230, 162, .35); }
.chapter-content a:hover { border-color: #79e6a2; }
.chapter-content ul, .chapter-content ol { margin: 0 0 28px; padding-left: 27px; }
.chapter-content li { margin: 9px 0; padding-left: 6px; }
.chapter-content li::marker { color: #79e6a2; font-family: var(--mono); font-size: .8em; }
.chapter-content hr { height: 1px; margin: 55px 0; border: 0; background: #29312b; }
.chapter-content blockquote { margin: 34px 0; padding: 24px 27px; border-left: 2px solid #79e6a2; background: #111612; color: #d4d7d0; }
.chapter-content blockquote p { margin: 0 0 9px; }
.chapter-content blockquote p:last-child { margin-bottom: 0; }
.chapter-content code { padding: .16em .4em; border: 1px solid #303a32; background: #151a16; color: #98efb7; font: 500 .82em/1.5 var(--mono); word-break: break-word; }
.chapter-content pre { position: relative; margin: 32px 0; padding: 46px 24px 24px; overflow-x: auto; border: 1px solid #303a32; background: #070908; color: #d3d9d1; line-height: 1.65; tab-size: 2; }
.chapter-content pre::before { content: "KOD"; position: absolute; top: 0; left: 0; right: 0; height: 29px; padding: 0 12px; display: flex; align-items: center; border-bottom: 1px solid #242b26; color: #657068; font: 600 8px/1 var(--mono); letter-spacing: .14em; }
.chapter-content pre code { display: block; min-width: max-content; padding: 0; border: 0; background: transparent; color: inherit; font-size: 13px; word-break: normal; }
.chapter-content table { width: 100%; display: block; margin: 32px 0; overflow-x: auto; border-collapse: collapse; font-size: 13px; line-height: 1.55; }
.chapter-content thead { background: #151b16; }
.chapter-content th, .chapter-content td { min-width: 140px; padding: 13px 15px; border: 1px solid #303a32; text-align: left; vertical-align: top; }
.chapter-content th { color: #f0eee5; font: 650 10px/1.4 var(--mono); letter-spacing: .04em; }
.chapter-content td { color: #adb3ab; }
.chapter-content td code { white-space: nowrap; }
.chapter-content img { max-width: 100%; height: auto; }

.chapter-pagination { margin-top: 90px; padding-top: 35px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; border-top: 1px solid #3a463d; }
.chapter-pagination a { min-height: 112px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid #29312b; background: #0e120f; transition: border-color .16s ease, background .16s ease; }
.chapter-pagination a:hover { border-color: #79e6a2; background: #111612; }
.chapter-pagination a.next { text-align: right; align-items: flex-end; }
.chapter-pagination small { color: #79e6a2; font: 600 8px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; }
.chapter-pagination strong { max-width: 280px; font: 400 18px/1.25 var(--serif); }

.on-page-toc { position: sticky; top: 106px; max-height: calc(100vh - 130px); overflow-y: auto; padding-bottom: 25px; scrollbar-width: thin; scrollbar-color: #3a463d transparent; }
.on-page-toc > p { margin: 0; min-height: 45px; display: flex; align-items: center; border-bottom: 1px solid #3a463d; color: #8c948c; font: 600 8px/1 var(--mono); letter-spacing: .13em; text-transform: uppercase; }
.on-page-toc nav { padding: 13px 0; border-bottom: 1px solid #29312b; }
.on-page-toc nav a { display: block; padding: 7px 0; color: #757e76; font-size: 10px; line-height: 1.45; transition: color .14s ease, transform .14s ease; }
.on-page-toc nav a:hover { color: #d4d7d0; transform: translateX(3px); }
.on-page-toc nav a.toc-sub { padding-left: 12px; color: #626b64; }
.toc-top { display: inline-flex; margin-top: 16px; color: #8c948c; font: 600 8px/1 var(--mono); text-transform: uppercase; }

@media (max-width: 1280px) {
  .reader-layout { grid-template-columns: 250px minmax(0, 820px); justify-content: center; }
  .on-page-toc { display: none; }
  .library-intro { grid-template-columns: 150px 1fr 330px; }
}

@media (max-width: 980px) {
  .book-topbar { padding-inline: 24px; }
  .reader-layout { width: min(820px, calc(100% - 44px)); display: block; }
  .chapter-sidebar { display: none; }
  .reader-article { padding-top: 30px; }
  .mobile-chapter-menu { display: block; margin-bottom: 58px; border: 1px solid #29312b; background: #111612; }
  .mobile-chapter-menu summary { min-height: 52px; padding: 0 16px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; list-style: none; color: #d5d8d1; font: 600 10px/1 var(--mono); }
  .mobile-chapter-menu summary::-webkit-details-marker { display: none; }
  .mobile-chapter-menu summary span { color: #79e6a2; }
  .mobile-chapter-menu nav { display: grid; padding: 8px; border-top: 1px solid #29312b; }
  .mobile-chapter-menu nav a { padding: 11px; color: #838b83; font-size: 12px; }
  .mobile-chapter-menu nav a.is-current { background: #192019; color: #f0eee5; }
  .library-hero { grid-template-columns: 1fr; gap: 55px; }
  .library-status { max-width: 500px; }
  .library-intro { grid-template-columns: 1fr; gap: 20px; }
  .coming-next { grid-template-columns: 80px 1fr; }
  .coming-next > p { grid-column: 2; }
}

@media (max-width: 700px) {
  .book-topbar { height: 68px; padding-inline: 16px; }
  .book-topbar nav { gap: 12px; }
  .book-topbar nav > a:not(.book-topbar-cta) { display: none; }
  .book-topbar .book-topbar-cta { min-height: 36px; padding-inline: 12px; }
  .book-brand-title { display: none; }
  .book-index { width: calc(100% - 36px); }
  .library-hero { min-height: auto; padding: 72px 0 80px; }
  .library-hero h1 { font-size: clamp(51px, 15vw, 72px); }
  .library-lede { font-size: 16px; }
  .library-status { padding: 25px; }
  .library-status > strong { font-size: 76px; }
  .library-intro { padding-top: 55px; }
  .chapter-group { margin-top: 55px; }
  .chapter-card { min-height: 126px; grid-template-columns: 38px 1fr 18px; gap: 13px; }
  .chapter-card small { display: none; }
  .chapter-card h3 { font-size: 21px; }
  .chapter-card p { font-size: 12px; -webkit-line-clamp: 3; }
  .chapter-card:hover { padding-inline: 8px; }
  .chapter-group > header { grid-template-columns: 38px 1fr; }
  .chapter-group > header small { display: none; }
  .coming-next { grid-template-columns: 1fr; gap: 20px; }
  .coming-next > p { grid-column: 1; }
  .reader-layout { width: calc(100% - 32px); }
  .reader-article { padding-bottom: 80px; }
  .mobile-chapter-menu { margin-bottom: 45px; }
  .chapter-header { padding-bottom: 50px; }
  .chapter-breadcrumb { margin-bottom: 35px; }
  .chapter-header h1 { font-size: clamp(44px, 13vw, 61px); }
  .chapter-brief > div { padding: 19px; }
  .chapter-content { font-size: 16px; line-height: 1.72; }
  .chapter-content h2 { margin-top: 72px; font-size: 34px; }
  .chapter-content h3 { font-size: 25px; }
  .chapter-content pre { margin-inline: -16px; padding-inline: 16px; border-left: 0; border-right: 0; }
  .chapter-pagination { grid-template-columns: 1fr; }
  .chapter-pagination a.next { text-align: left; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  .reading-progress { animation: none; transform: scaleX(1); }
}
