#main:has(> .books-reader) { padding-top: 1rem; }
.books-reader { --book-selected: color-mix(in srgb, var(--mauve) 5%, var(--mantle)); }
.books-reader > .path { margin-bottom: 1rem; }
.book-layout { display: grid; grid-template-columns: 16rem minmax(0, 1fr); gap: clamp(1.25rem, 3vw, 3rem); align-items: start; }
.book-layout > * { min-width: 0; }
.book-sidebar { position: sticky; top: calc(var(--header-h, 0px) + 1rem); max-height: min(calc(100dvh - var(--header-h, 0px) - 2rem), var(--book-sidebar-room, 80dvh)); display: flex; flex-direction: column; background: var(--mantle); border: 1px solid var(--surface0); border-radius: .6rem; }
.book-sidebar-controls { flex: 0 0 auto; padding: 1rem 1rem .25rem; }
.book-sidebar label { display: block; color: var(--subtext1); font-size: .8rem; margin-bottom: .4rem; }
.book-sidebar select, .book-sidebar input { width: 100%; min-width: 0; font-size: .9rem; padding: .55rem .65rem; }
.book-sidebar input { margin-bottom: .5rem; }
.book-sidebar label:not(:first-child) { margin-top: 1rem; }
.book-result-count { font-size: .8rem; color: var(--subtext1); margin: .35rem 0; }
.book-chapter-list { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: .35rem .65rem 1rem; scrollbar-gutter: stable; }
.book-contents, .book-sections { list-style: none; margin: 0; padding: 0; }
.book-contents > li { margin: .15rem 0; }
.book-contents > li > a { display: flex; align-items: baseline; gap: .65rem; padding: .6rem .65rem; border-radius: .35rem; text-decoration: none; color: var(--text); font-size: .9rem; overflow-wrap: anywhere; }
.book-chapter-number { color: var(--subtext1); font-size: .75rem; flex: 0 0 1.15rem; font-variant-numeric: tabular-nums; }
.book-contents a[aria-current="page"] { background: var(--book-selected); box-shadow: inset 3px 0 var(--mauve); font-weight: 600; }
.book-contents > li > a:hover, .book-search-result:hover { background: var(--surface0); }
.book-contents > li > a:hover .book-chapter-number, .book-search-result:hover span { color: var(--text); }
.book-sections { padding: .3rem .65rem .6rem 2.4rem; }
.book-sections a { display: block; color: var(--subtext1); text-decoration: none; padding: .3rem 0; font-size: .8rem; overflow-wrap: anywhere; }
.book-sections a:hover, .book-sections a[aria-current="location"] { color: var(--text); text-decoration: underline; text-underline-offset: .2em; }
.book-section-child { padding-left: .65rem; }
.book-search-result { display: block; color: var(--text); text-decoration: none; padding: .7rem .65rem; border-bottom: 1px solid var(--surface0); overflow-wrap: anywhere; }
.book-search-result strong { display: block; font-size: .9rem; }
.book-search-result span { display: block; font-size: .8rem; color: var(--subtext1); margin-top: .4rem; }
.book-article { width: 100%; max-width: 76rem; margin-inline: auto; padding: .5rem clamp(0rem, 2vw, 2rem) 2rem; }
.book-chapter-meta { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; font-size: .8rem; color: var(--subtext1); margin-bottom: .75rem; }
.book-article h1 { font-size: clamp(1.6rem, 2.5vw, 2rem); line-height: 1.25; margin-bottom: .75rem; scroll-margin-top: calc(var(--header-h, 0px) + 1.5rem); }
.book-article h1, .book-chapter-meta { overflow-wrap: anywhere; }
.book-details { color: var(--subtext1); font-size: .8rem; margin-bottom: 2rem; }
.book-details p { margin: .5rem 0; }
.book-article .chapter { font-size: 1rem; line-height: 1.7; }
.book-article .chapter > :is(p, ul, ol, blockquote) { max-width: 75ch; }
.book-article .chapter > :is(h2,h3,h4,h5,h6) { max-width: 65ch; color: var(--text); line-height: 1.3; }
.book-article .chapter h2 { font-size: 1.35rem; border-bottom: 1px solid var(--surface0); padding-bottom: .55rem; }
.book-article .chapter h3 { font-size: 1.1rem; }
.book-article .chapter blockquote { border-left-color: var(--mauve); border-radius: 0 .4rem .4rem 0; }
.book-article .chapter table { font-size: .9rem; }
.book-article .chapter th { color: var(--text); background: var(--mantle); border-bottom: 2px solid var(--field-border); }
.book-article .chapter :is(td,th) { border-inline: 0; padding: .65rem .8rem; }
.book-article .chapter tbody tr:nth-child(even) { background: var(--mantle); }
.book-pager { display: flex; justify-content: space-between; gap: 2rem; border-top: 1px solid var(--surface0); padding-top: 1.25rem; margin-top: 2.5rem; }
.book-pager a { display: flex; flex-direction: column; text-decoration: none; max-width: 45%; overflow-wrap: anywhere; }
.book-pager a:last-child:not(:first-child) { text-align: right; margin-left: auto; }
.book-pager span { font-size: .8rem; color: var(--subtext1); }
.book-notices:empty { display: none; }
.book-notices:not(:empty) { margin-bottom: 1rem; }
.books-sidebar-hidden .book-layout { grid-template-columns: minmax(0, 1fr); }
.books-sidebar-hidden .book-article { max-width: 90rem; }
@media (max-width: 40rem) {
  .book-layout { grid-template-columns: minmax(0, 1fr); }
  .book-sidebar { position: static; max-height: 28rem; }
  .book-article { padding-inline: 0; }
}
