body.chapter-page {
  max-width: none;
  margin: 0;
  padding: 0;
}

.chapter-shell {
  display: grid;
  grid-template-columns: minmax(220px, 250px) minmax(0, 900px);
  gap: 40px;
  width: min(100%, 1240px);
  margin: 0 auto;
  padding: 54px 24px 100px;
}

.chapter-content {
  min-width: 0;
}

.chapter-content h2 {
  scroll-margin-top: 24px;
}

.chapter-toc {
  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  scrollbar-width: thin;
}

.chapter-toc summary {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: #f4f8fb;
  color: var(--ink);
  font-size: .95rem;
}

.chapter-toc:not([open]) summary {
  border-bottom: 0;
}

.chapter-toc summary span {
  color: var(--muted);
  font-size: .75rem;
  font-weight: 400;
}

.chapter-toc nav {
  padding: 7px 0 10px;
}

.chapter-toc nav a {
  display: block;
  padding: 7px 14px;
  border-left: 3px solid transparent;
  color: #4b5563;
  font-size: .82rem;
  line-height: 1.5;
}

.chapter-toc nav a:hover,
.chapter-toc nav a:focus-visible {
  border-left-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  text-decoration: none;
}

@media (max-width: 1100px) {
  .chapter-shell {
    grid-template-columns: minmax(0, 900px);
    justify-content: center;
  }

  .chapter-toc {
    position: static;
    max-height: none;
  }

  .chapter-toc summary {
    position: static;
  }

  .chapter-toc nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .chapter-shell {
    gap: 20px;
    padding: 30px 20px 70px;
  }

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