/* Book detail pages extend the approved Читопотам visual system. */
html[data-theme="dark"] { color-scheme: dark; }
.book-page { max-width: 1180px; }
.book-breadcrumbs { display: flex; align-items: center; gap: 9px; margin: 0 0 31px; color: var(--muted); font: 500 13px/1.45 var(--ui); min-width: 0; }
.book-breadcrumbs a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.book-breadcrumbs .icon { width: 15px; height: 15px; flex: none; }
.book-breadcrumbs span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-hero { display: grid; grid-template-columns: minmax(190px, 260px) minmax(0, 1fr); gap: clamp(28px, 5vw, 72px); align-items: start; padding-bottom: 43px; border-bottom: 1px solid var(--line); }
.book-hero-cover { max-width: 260px; }
.book-detail-cover { display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 12px; box-shadow: var(--shadow); }
.book-hero-copy { padding-top: 2px; max-width: 650px; }
.book-hero h1 { max-width: 18ch; margin: 0 0 13px; font: 750 clamp(32px, 4vw, 49px)/1.09 var(--ui); letter-spacing: -.03em; text-wrap: balance; overflow-wrap: anywhere; }
.book-author { margin: 0 0 18px; color: var(--muted); font: 500 16px/1.45 var(--ui); }
.book-facts { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; }
.book-facts li { display: inline-flex; align-items: center; min-height: 32px; padding: 5px 11px; border-radius: 8px; background: var(--soft); color: var(--ink); font: 500 13px/1.4 var(--ui); }
.book-lead { max-width: 58ch; margin: 0 0 24px; color: var(--ink); font: 400 16px/1.65 var(--ui); }
.book-primary-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.book-read-button { min-width: 146px; }
/* Share matches the icon-only bookmark: same 48 px zone, muted outline, no label. */
.book-share { display: none; align-items: center; justify-content: center; flex: 0 0 48px; width: 48px; height: 48px; padding: 4px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.book-share:hover { background: transparent; color: var(--blue); }
html.has-js .book-share { display: inline-flex; }
.book-share .icon { width: 32px; height: 32px; flex: none; }
.book-start-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; color: var(--blue); font: 500 14px/1.4 var(--ui); text-decoration: underline; text-underline-offset: 4px; }
.book-detail-body { max-width: 68ch; padding-top: 39px; }
.book-about h2, .book-source h2, .book-related h2 { margin: 0 0 14px; font: 700 25px/1.2 var(--ui); letter-spacing: -.025em; }
.book-about p { max-width: 68ch; margin: 0 0 18px; font: 400 16px/1.7 var(--ui); }
.book-series-link { color: var(--muted); font-size: 14px !important; }
.book-series-link a { color: var(--blue); display: inline-flex; align-items: center; gap: 5px; text-decoration: underline; text-underline-offset: 4px; }
.book-series-link .icon { width: 15px; height: 15px; }
.book-source { margin-top: 32px; padding-top: 18px; }
.book-source h2 { font-size: 18px; margin-bottom: 12px; }
.book-source p { margin: 0 0 10px; color: var(--muted); font: 400 14px/1.6 var(--ui); }
.book-source a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.book-related { margin-top: 42px; border-top: 1px solid var(--line); padding-top: 32px; }
.book-related h2 { margin-bottom: 22px; }
.book-related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.book-related-item { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; align-items: start; min-width: 0; }
.book-related-cover, .book-related-cover img { display: block; width: 76px; height: 96px; border-radius: 6px; }
.book-related-cover img { object-fit: cover; }
.book-related-item h3 { margin: 1px 0 6px; font: 650 16px/1.28 var(--ui); letter-spacing: -.015em; overflow-wrap: anywhere; }
.book-related-item h3 a:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.book-related-item p { margin: 0 0 5px; color: var(--muted); font: 400 12px/1.4 var(--ui); }
.book-related-read { display: inline-flex; align-items: center; gap: 3px; min-height: 34px; color: var(--blue); font: 600 13px/1.3 var(--ui); }
.book-related-read .icon { width: 15px; height: 15px; }
.completed-mark { display: inline-flex; align-items: center; gap: 5px; color: var(--blue); font: 600 13px/1.4 var(--ui); }
.completed-mark .icon { width: 16px; height: 16px; flex: none; }
.shelf-copy > .completed-mark { margin-bottom: 10px; }
.book-related-item .completed-mark { display: flex; margin-bottom: 4px; }
.finish-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 18px; }
.finish-actions .button { margin: 0; }
/* Catalogue cards share one reading order and adapt to their own column width. */
.library .book-card--compact .card-byline { margin: 8px 0 0; }
.library .book-card--compact .card-author { display: block; min-height: 0; padding: 0; color: inherit; font: inherit; }
.library .book-card--compact a.card-author:hover { text-decoration: underline; text-underline-offset: 3px; }
.library .book-card--compact > .card-byline + .card-title { margin-top: 4px; }
.library .book-card--compact > .card-meta { margin: 6px 0 8px; padding-top: 0; align-items: flex-start; flex-wrap: wrap; gap: 6px 12px; }
.library .book-card--compact > .card-actions { margin-top: 0; }
.library .book-card--compact .card-meta-main { min-width: 0; flex-wrap: wrap; white-space: normal; gap: 4px 8px; }
.library .book-card--compact .card-meta-main > span { display: inline-flex; align-items: center; gap: 6px; }
.library .book-card--compact .card-meta-main > span + span::before { content: '·'; margin-right: 2px; }
.library .book-card--compact .card-duration .icon { width: 15px; height: 15px; flex: none; }
.library .book-card--compact .card-recommendation { display: flex; align-items: flex-start; align-self: flex-start; gap: 6px; max-width: 100%; margin: -6px 0 18px; padding: 6px 9px; border-radius: 8px; color: var(--muted); background: var(--soft); font-size: var(--type-meta); line-height: 1.5; }
.library .book-card--compact .card-recommendation .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.library .book-card--compact .card-recommendation span { min-width: 0; overflow-wrap: anywhere; }
.book-card { container: book-card / inline-size; }
.book-card > .card-title { margin: 16px 0 0; min-height: 2.5em; line-height: 1.25; text-wrap: pretty; overflow-wrap: anywhere; }
.book-card .card-byline { margin: 0 0 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.book-card .card-author { display: flex; flex-wrap: wrap; align-items: center; gap: 0 8px; min-height: 44px; padding: 8px 0; }
.book-card .card-kind { color: var(--muted); }
.book-card > .card-meta { margin: 0 0 10px; gap: 6px 12px; font-size: 13px; }
.book-card > .card-title + .card-meta { margin-top: 10px; }
.library .book-card--compact > .card-title + .card-meta { margin-top: 6px; }
.book-card .card-meta-main { gap: 12px; }
.book-card .card-meta-main > span { white-space: nowrap; }
.book-card .age-tag { color: var(--ink); font-weight: 500; }
.book-card .card-status { font-weight: 500; }
.book-card > .card-blurb { margin: 0 0 20px; font-size: 14px; line-height: 1.55; }
.book-card .card-actions { display: flex; flex-wrap: nowrap; align-items: stretch; gap: 8px; margin-top: auto; }
.book-card .card-read { flex: 1; min-width: 0; width: auto; min-height: 48px; margin: 0; padding: 12px; font-size: 14px; gap: 6px; }
.book-card .card-read .icon { width: 17px; height: 17px; flex: none; }
.book-card .book-save { flex: none; align-self: stretch; min-width: 48px; min-height: 48px; padding: 12px; font-size: 13px; }
.book-card .book-save .icon { width: 20px; height: 20px; flex: none; }
@container book-card (max-width: 259px) {
  .book-card .book-save .favorite-label { display: none; }
}
@container book-card (max-width: 199px) {
  .book-card .card-read { font-size: 13px; padding-inline: 8px; }
  .book-card .card-read .icon { display: none; }
  .book-card .card-meta-main { gap: 4px 10px; }
}
@container book-card (max-width: 159px) {
  .book-card .card-actions { flex-direction: column; }
  .book-card .book-save .favorite-label { display: inline; }
}
.continue-card > a:first-child { display: block; flex: none; width: 48px; height: 60px; border-radius: 6px; overflow: hidden; }
.continue-card > a:first-child img { display: block; width: 100%; height: 100%; object-fit: cover; }
.continue-info h2 a:hover { text-decoration: underline; text-underline-offset: 3px; }
.reader-about { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 9px 12px; border-radius: 10px; color: var(--blue); font: 600 12px/1.3 var(--ui); white-space: nowrap; }
.reader-about:hover { background: var(--tint); }
.reader-about .icon { width: 19px; height: 19px; }
html:not(.has-js) button[data-action] { display: none !important; }
html:not(.has-js) .search-box { display: none !important; }
html:not(.has-js) .book-primary-actions .book-read-button { display: inline-flex; }
@media (max-width: 959px) {
  .book-hero { grid-template-columns: 210px minmax(0, 1fr); gap: 32px; }
  .book-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .reader-about { width: 44px; min-width: 44px; padding: 11px; }
  .reader-about span { display: none; }
}
@media (max-width: 599px) {
  .book-page { padding-top: 22px; }
  .book-breadcrumbs { margin-bottom: 21px; }
  .book-hero { grid-template-columns: 112px minmax(0, 1fr); gap: 0 18px; padding-bottom: 28px; }
  .book-hero-cover { grid-column: 1; grid-row: 1 / span 3; }
  .book-detail-cover { border-radius: 9px; }
  .book-hero-copy { display: contents; }
  .book-hero h1 { grid-column: 2; grid-row: 1; align-self: end; font-size: clamp(23px, 6vw, 31px); line-height: 1.1; margin: 0 0 7px; }
  .book-author { grid-column: 2; grid-row: 2; margin: 0 0 8px; font-size: 13px; }
  .book-facts { grid-column: 2; grid-row: 3; gap: 5px; align-self: start; margin: 0; }
  .book-facts li { min-height: 26px; padding: 4px 7px; font-size: 11px; }
  .book-lead { grid-column: 1 / -1; margin: 23px 0 19px; font-size: 15px; line-height: 1.6; }
  .book-primary-actions { grid-column: 1 / -1; flex-wrap: nowrap; gap: 4px; }
  .book-read-button { flex: 1 1 auto; min-width: 0; margin-right: 4px; }
  .book-start-link { grid-column: 1 / -1; }
  .book-detail-body { padding-top: 27px; }
  .book-about h2, .book-related h2 { font-size: 22px; }
  .book-about p { font-size: 15px; line-height: 1.65; }
  .book-source { margin-top: 25px; }
  .book-related { margin-top: 34px; padding-top: 26px; }
  .book-related-grid { grid-template-columns: 1fr; gap: 18px; }
  .continue-card > a:first-child { width: 34px; height: 43px; }
  .book-card > .card-title { margin-top: 12px; }
}
@media (max-width: 359px) {
  .book-hero { grid-template-columns: 96px minmax(0, 1fr); gap: 0 14px; }
  .book-hero h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .book-detail-cover, .book-share, .reader-about { transition: none !important; }
}

/* The catalogue stays mounted beneath the native modal, preserving scroll and filters. */
.book-dialog { width: 980px; max-width: calc(100vw - 32px); max-height: calc(100dvh - 32px); margin: auto; border: 0; border-radius: 14px; overflow: hidden; }
.book-dialog[open] { display: flex; flex-direction: column; }
.book-dialog::backdrop { background: #0d162bb3; backdrop-filter: none; }
.book-dialog-toolbar { display: flex; align-items: center; justify-content: space-between; flex: none; gap: 16px; padding: 8px 16px 8px 32px; background: var(--surface); }
.book-dialog-toolbar > span { flex: 1; color: var(--muted); font-size: 14px; }
.book-dialog-toolbar .icon-button { width: 44px; height: 44px; flex: none; color: var(--ink); background: var(--soft); border-radius: 10px; }
.book-dialog-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 8px 32px 32px; scrollbar-color: var(--blue) var(--surface); }
.book-dialog .book-hero { grid-template-columns: 180px minmax(0, 1fr); gap: 32px; padding-bottom: 28px; }
.book-dialog .book-hero h1 { font-size: 34px; }
.book-dialog .book-detail-body { padding-top: 28px; }
.book-dialog .book-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.book-dialog .book-related-read { min-height: 44px; }
@media (max-width: 599px) {
  .book-dialog { max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); }
  .book-dialog-toolbar { padding: 8px 12px 8px 20px; }
  .book-dialog-scroll { padding: 8px 20px 24px; }
  .book-dialog .book-hero { grid-template-columns: 96px minmax(0, 1fr); gap: 0 16px; }
  .book-dialog .book-hero h1 { font-size: clamp(22px, 5.7vw, 30px); }
  .book-dialog .book-related-grid { grid-template-columns: 1fr; }
}
@media (max-width: 359px) {
  .book-dialog-scroll { padding-inline: 16px; }
  .book-dialog .book-hero { grid-template-columns: 76px minmax(0, 1fr); gap: 0 12px; }
}

/* A quiet companion at the start of reading; scrolls away with the text. */
.reader-welcome { display: flex; align-items: center; gap: 10px; min-width: 0; }
.reading-hippo { display: block; width: 160px; height: auto; flex: none; user-select: none; pointer-events: none; }
.reader-welcome .reader-duration { flex: none; white-space: nowrap; }
.text-only .reading-hippo, .no-ornaments .reading-hippo { display: none; }
@media (max-width: 760px) {
  .reading-hippo { width: 112px; }
  .reader-welcome { gap: 6px; }
  .reader-start { gap: 8px; }
}
@media (max-width: 359px) {
  .reading-hippo { width: 88px; }
  .reader-welcome .reader-duration { font-size: 11px; gap: 4px; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1100px) {
  .reading-hippo { width: 100px; }
}
