.book-page {
  --book-sidebar: 280px;
  background: #f5f7fd;
}

.book-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.book-topbar__inner {
  min-height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 18px;
}

.book-topbar__title {
  min-width: 0;
  padding-left: 18px;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-topbar__back {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
}

.book-topbar__back:hover { text-decoration: underline; }

.book-layout {
  display: grid;
  grid-template-columns: var(--book-sidebar) minmax(0, 1fr);
  gap: 56px;
  align-items: start;
  padding-top: 48px;
  padding-bottom: 80px;
}

.book-toc {
  position: sticky;
  top: calc(var(--nav-h) + 24px);
  max-height: calc(100vh - var(--nav-h) - 48px);
  overflow-y: auto;
  padding: 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .9);
  box-shadow: var(--shadow-sm);
  scrollbar-width: thin;
}

.book-toc strong {
  display: block;
  margin: 0 10px 12px;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.book-toc nav { display: grid; gap: 2px; }

.book-toc a {
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  transition: color .15s ease, background .15s ease;
}

.book-toc a:hover {
  color: var(--primary);
  background: var(--grad-soft);
}

.book-content {
  min-width: 0;
  max-width: 880px;
  padding: clamp(28px, 5vw, 64px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.book-content h1 {
  margin-bottom: 22px;
  font-size: clamp(32px, 5vw, 52px);
}

.book-author {
  display: flex;
  align-items: center;
  gap: 16px;
  width: fit-content;
  margin: 0 0 28px;
  padding: 10px 18px 10px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.book-author img {
  width: 88px;
  height: 88px;
  flex: 0 0 88px;
  border: 3px solid #fff;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  box-shadow: 0 8px 24px rgba(12, 15, 36, .18);
}

.book-author figcaption {
  display: grid;
  gap: 3px;
  color: var(--text);
}

.book-author figcaption strong {
  font-size: 15px;
  font-weight: 700;
}

.book-author figcaption span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}

.book-content h2 {
  scroll-margin-top: calc(var(--nav-h) + 20px);
  margin: 64px 0 20px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
  font-size: clamp(25px, 4vw, 32px);
}

.book-content h3 {
  scroll-margin-top: calc(var(--nav-h) + 20px);
  margin: 38px 0 14px;
  font-size: clamp(19px, 3vw, 23px);
}

.book-content p {
  margin-bottom: 16px;
  color: #364056;
  font-size: 16px;
}

.book-content strong { color: var(--text); }
.book-content em { color: var(--muted); }

.book-content blockquote {
  margin: 24px 0 34px;
  padding: 20px 24px;
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--grad-soft);
}

.book-content blockquote p { margin: 0; color: var(--text); }

.book-content ul,
.book-content ol {
  display: grid;
  gap: 9px;
  margin: 0 0 20px 24px;
  list-style: revert;
}

.book-content li { padding-left: 3px; color: #364056; }
.book-content li::marker { color: var(--primary); font-weight: 700; }

.book-content a { color: var(--primary); font-weight: 600; }
.book-content a:hover { text-decoration: underline; }

.book-content table {
  display: block;
  width: 100%;
  margin: 24px 0 30px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}

.book-content thead,
.book-content tbody { width: 100%; }

.book-content th,
.book-content td {
  min-width: 150px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.book-content th {
  background: var(--surface-soft);
  color: var(--text);
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.book-content pre {
  margin: 22px 0 28px;
  padding: 20px;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #e6e9f5;
}

.book-content code {
  font-family: "SFMono-Regular", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
}

.book-content :not(pre) > code {
  padding: 2px 6px;
  border-radius: 5px;
  background: #eef0ff;
  color: #4338ca;
}

.book-content hr {
  margin: 48px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.book-figure {
  margin: 34px 0 38px;
}

.book-figure img {
  width: 100%;
  height: auto;
  border: 1px solid #252a48;
  border-radius: var(--radius);
  background: var(--ink);
  box-shadow: 0 20px 55px rgba(12, 15, 36, .2);
}

.book-figure figcaption {
  margin-top: 11px;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

.book-footer {
  border-top: 1px solid var(--line);
  background: #fff;
}

.book-footer .container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px 24px;
  padding-top: 28px;
  padding-bottom: 28px;
}

.book-footer p { color: var(--muted); font-size: 14px; }
.book-footer a { color: var(--primary); font-size: 14px; font-weight: 700; }

@media (max-width: 960px) {
  .book-layout { grid-template-columns: 1fr; gap: 28px; padding-top: 28px; }
  .book-toc { position: static; max-height: none; }
  .book-toc nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book-content { max-width: none; }
}

@media (max-width: 640px) {
  .book-topbar__title { display: none; }
  .book-topbar__inner { gap: 10px; }
  .book-topbar__back { font-size: 12px; }
  .book-layout { padding-inline: 14px; }
  .book-toc nav { grid-template-columns: 1fr; }
  .book-content { padding: 26px 18px 40px; border-radius: var(--radius); }
  .book-author { gap: 12px; padding-right: 15px; }
  .book-author img { width: 72px; height: 72px; flex-basis: 72px; }
  .book-content h2 { margin-top: 48px; }
  .book-content blockquote { padding: 16px 18px; }
  .book-figure img { border-radius: 10px; }
}

@media print {
  .book-topbar, .book-toc, .book-footer { display: none; }
  .book-page { background: #fff; }
  .book-layout { display: block; padding: 0; }
  .book-content { max-width: none; padding: 0; border: 0; box-shadow: none; }
  .book-content h2 { break-before: page; }
  .book-figure { break-inside: avoid; }
  .book-figure img { box-shadow: none; }
}