.book-shell {
  --book-paper: #11151a;
  --book-ink: #e8e2d8;
  --book-muted: #b8ae9f;
  --book-line: rgba(232, 226, 216, 0.22);
  --book-link: #8fd7ff;
  --book-link-hover: #d2eeff;
  --book-link-underline: rgba(143, 215, 255, 0.78);
  --book-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  font-family: "PT Serif", Georgia, serif;
  max-width: 1440px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  color: var(--book-ink);
}

.book-hero {
  margin: 0 auto 2.5rem;
  max-width: 760px;
  text-align: center;
}

.book-eyebrow {
  margin: 0 0 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--book-muted);
  font-size: 0.72rem;
}

.book-title {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 4.8rem);
  line-height: 0.96;
}

.book-author,
.book-description {
  margin: 1rem auto 0;
  max-width: 56ch;
  color: var(--book-muted);
}

.book-date {
  margin: 0.4rem auto 0;
  max-width: 56ch;
  color: var(--book-muted);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.book-shell--poems-collection .book-description {
  margin-top: 1.05rem;
}

.book-shell--poems-collection .book-author {
  margin-top: 0.2rem;
  font-size: inherit;
  line-height: inherit;
  color: var(--book-muted);
}

.book-collection-intro-page {
  min-height: clamp(48vh, 58vh, 72vh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.book-collection-intro-desc {
  margin: 0;
  color: var(--book-muted);
  letter-spacing: 0.04em;
  font-size: clamp(1.2rem, 2.4vw, 2rem);
}

.book-collection-intro-author {
  margin: 0.4rem 0 0;
  color: var(--book-ink);
  line-height: 0.8;
  font-size: clamp(5rem, 20vw, 12rem);
}

.book-grid {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(180px, 240px);
  gap: 1.5rem;
  align-items: start;
}

/* The third column is empty — it mirrors the sidebar so the text is centred */
.book-page-wrap {
  grid-column: 2;
  min-width: 0;
}

.book-sidebar {
  position: sticky;
  top: 1.25rem;
}

.book-sidebar-inner,
.book-page {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)), var(--book-paper);
  border: 1px solid var(--book-line);
  box-shadow: var(--book-shadow);
}

.book-sidebar-inner {
  padding: 1.25rem 1.1rem;
  max-height: calc(100vh - 2.6rem);
  overflow-y: auto;
  scrollbar-color: rgba(232, 226, 216, 0.32) rgba(0, 0, 0, 0.28);
  scrollbar-width: thin;
}

.book-sidebar-inner::-webkit-scrollbar,
.book-toc-panel::-webkit-scrollbar {
  width: 10px;
}

.book-sidebar-inner::-webkit-scrollbar-track,
.book-toc-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.34);
  border-radius: 999px;
}

.book-sidebar-inner::-webkit-scrollbar-thumb,
.book-toc-panel::-webkit-scrollbar-thumb {
  background: rgba(232, 226, 216, 0.35);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.25);
}

.book-sidebar-inner::-webkit-scrollbar-thumb:hover,
.book-toc-panel::-webkit-scrollbar-thumb:hover {
  background: rgba(232, 226, 216, 0.5);
}

.book-sidebar-title {
  margin: 0 0 0.9rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--book-muted);
}

.book-toc {
  margin: 0;
  padding-left: 1.2rem;
}

.book-toc li + li {
  margin-top: 0.6rem;
}

.book-toc-group > li + li {
  margin-top: 0.35rem;
}

.book-toc-group-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.book-toc-toggle {
  width: 1.1rem;
  height: 1.1rem;
  border: 1px solid var(--book-line);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--book-muted);
  font-size: 0.6rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.book-toc-toggle:hover {
  color: var(--book-ink);
}

.book-toc-group .book-toc-children {
  margin-top: 0.5rem;
}

.book-toc-group:not(.is-open) .book-toc-children {
  display: none;
}

.book-toc-group:not(.is-open) .book-toc-toggle {
  transform: rotate(-90deg);
}

.book-toc ol {
  margin-top: 0.5rem;
  padding-left: 1.15rem;
}

.book-toc ol li + li {
  margin-top: 0.35rem;
}

.book-toc ol a {
  color: var(--book-muted);
  font-size: 0.92rem;
}

.book-toc a {
  color: inherit;
  text-decoration: none;
}

.book-toc a:hover {
  text-decoration: underline;
}

.book-page {
  box-sizing: border-box;
  padding: clamp(1.5rem, 3vw, 3.2rem);
  width: 100%;
  max-width: 960px;
  min-width: 0;
  margin: 0 auto;
  border-radius: 10px;
}

.book-page-inner {
  max-width: 82ch;
  margin: 0 auto;
}

.book-intro {
  margin-bottom: 2rem;
  padding-bottom: 1.4rem;
  border-bottom: 1px solid var(--book-line);
}

.book-chapter + .book-chapter {
  margin-top: 2.8rem;
  padding-top: 2rem;
  border-top: 1px solid var(--book-line);
}

.book-chapter-header {
  margin-bottom: 1.25rem;
}

.book-chapter-header h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.book-chapter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.book-chapter-share-menu {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.book-chapter-share-menu > summary {
  list-style: none;
}

.book-chapter-share-menu > summary::-webkit-details-marker {
  display: none;
}

.book-chapter-share-btn,
.book-chapter-share-btn:visited {
  display: inline-block;
  padding: 0.3rem 0.68rem;
  border: 1px solid var(--book-line);
  border-radius: 6px;
  color: var(--book-muted);
  background: rgba(255, 255, 255, 0.03);
  font-family: "Quicksand", sans-serif;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.book-chapter-share-btn:hover,
.book-chapter-share-btn:focus-visible {
  color: var(--book-ink);
  border-color: rgba(232, 226, 216, 0.4);
  background: rgba(255, 255, 255, 0.07);
}

.book-chapter-share-options {
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 164px;
  border: 1px solid var(--book-line);
  border-radius: 8px;
  background: rgba(17, 21, 26, 0.97);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  padding: 0.25rem;
  z-index: 30;
}

.book-chapter-share-option,
.book-chapter-share-option:visited {
  display: block;
  padding: 0.4rem 0.52rem;
  border-radius: 6px;
  color: var(--book-ink);
  text-decoration: none;
  font-family: "Quicksand", sans-serif;
  font-size: 0.8rem;
  line-height: 1.2;
}

.book-chapter-share-option:hover,
.book-chapter-share-option:focus-visible {
  background: rgba(255, 255, 255, 0.12);
}

.book-chapter-date {
  margin: 0.45rem 0 0;
  color: var(--book-muted);
  font-size: 0.92rem;
  letter-spacing: 0.03em;
}

.book-chapter-kicker {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--book-muted);
}

.prose-flow {
  font-size: 1.08rem;
  line-height: 1.9;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.book-shell:not(.book-shell--poems-collection) .prose-flow {
  font-size: 1.12rem;
}

.prose-flow > :first-child {
  margin-top: 0;
}

.prose-flow > :last-child {
  margin-bottom: 0;
}

.prose-flow p,
.prose-flow ul,
.prose-flow ol,
.prose-flow blockquote,
.prose-flow pre {
  margin: 1rem 0;
}

.prose-flow a {
  color: var(--book-link);
  text-decoration-line: underline;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.16em;
  text-decoration-color: var(--book-link-underline);
  text-decoration-skip-ink: auto;
  transition: color 120ms ease, text-decoration-color 120ms ease;
}

.prose-flow a:visited {
  color: #b9d9ff;
  text-decoration-color: rgba(185, 217, 255, 0.82);
}

.prose-flow a:hover,
.prose-flow a:focus-visible {
  color: var(--book-link-hover);
  text-decoration-color: var(--book-link-hover);
}

.prose-flow a:focus-visible {
  outline: 2px solid var(--book-link-hover);
  outline-offset: 0.13em;
  border-radius: 0.15em;
}

.prose-flow ul,
.prose-flow ol {
  padding-left: 2rem;
}

.prose-flow blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid rgba(232, 226, 216, 0.35);
  color: #d6ccbc;
}

.prose-flow img,
.prose-flow video,
.prose-flow iframe {
  max-width: 100%;
  height: auto;
}

.prose-flow .book-media {
  margin: 1.2rem auto;
  max-width: 100%;
}

.prose-flow .book-media-image {
  text-align: center;
}

.prose-flow .book-media-image img {
  display: inline-block;
  margin: 0 auto;
}

.prose-flow .book-media-caption {
  margin-top: 0.5rem;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--book-muted);
  text-align: center;
}

/* align="left" */
.prose-flow .book-media-image--left {
  float: left;
  margin: 0.4rem 1.4rem 1rem 0;
  text-align: left;
}

.prose-flow .book-media-image--left .book-media-caption {
  text-align: left;
}

/* align="right" */
.prose-flow .book-media-image--right {
  float: right;
  margin: 0.4rem 0 1rem 1.4rem;
  text-align: right;
}

.prose-flow .book-media-image--right .book-media-caption {
  text-align: right;
}

/* align="center" es el comportamiento por defecto, pero se puede forzar */
.prose-flow .book-media-image--center {
  clear: both;
  text-align: center;
}


.prose-flow table {
  border: none !important;
  border-collapse: collapse;
  color: inherit;
}
.prose-flow table tr {
  background: transparent !important;
}
.prose-flow table td,
.prose-flow table th {
  border: none !important;
  color: inherit;
  vertical-align: top;
}

.prose-flow .book-media-video video,
.prose-flow .book-media-audio audio {
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

.prose-flow .book-media-video {
  clear: both;
  text-align: center;
}

.prose-flow .book-media-video > div {
  margin-left: auto;
  margin-right: auto;
}

.prose-flow .book-media-video--left-text {
  float: left;
  margin: 0.4rem 1.4rem 1rem 0;
  text-align: left;
}

.prose-flow .book-media-video--left-text > div {
  margin-left: 0;
  margin-right: auto;
}

.prose-flow .book-media-video--right-text {
  float: right;
  margin: 0.4rem 0 1rem 1.4rem;
  text-align: right;
}

.prose-flow .book-media-video--right-text > div {
  margin-left: auto;
  margin-right: 0;
}

.prose-flow .book-media-video--left {
  clear: both;
  width: 100%;
  margin: 1.2rem 0;
  text-align: left;
}

.prose-flow .book-media-video--left > div {
  margin-left: 0;
  margin-right: auto;
}

.prose-flow .book-media-video--right {
  clear: both;
  width: 100%;
  margin: 1.2rem 0;
  text-align: right;
}

.prose-flow .book-media-video--right > div {
  margin-left: auto;
  margin-right: 0;
}

.prose-flow .book-media-video--center {
  clear: both;
  width: 100%;
  margin: 1.2rem 0;
  text-align: center;
}

.book-poem-entry + .book-poem-entry {
  margin-top: 2.6rem;
  padding-top: 2rem;
  border-top: 1px solid var(--book-line);
}

.book-poem-title {
  margin: 0;
  font-family: "Cormorant Garamond", ui-serif, Georgia, serif;
  font-size: clamp(1.6rem, 1.35rem + 1.3vw, 2.2rem);
  line-height: 1.1;
}

.book-poem-date {
  margin: 0.35rem 0 1.2rem;
  color: var(--book-muted);
  font-size: 0.92rem;
  letter-spacing: 0.03em;
}

.book-poem-body {
  font-family: "Cormorant Garamond", ui-serif, Georgia, serif;
  font-size: clamp(1.2rem, 1.1rem + 0.55vw, 1.55rem);
  line-height: 1.85;
  text-align: left;
  text-justify: auto;
  hyphens: none;
}

.book-poem-body .poem-style-left {
  text-align: left;
}

.book-poem-body .poem-style-right {
  text-align: right;
}

.book-poem-body .poem-style-justify {
  text-align: justify;
}

@media (max-width: 900px) {
  .book-grid {
    grid-template-columns: 1fr;
  }

  .book-page-wrap {
    grid-column: 1;
  }

  .book-sidebar {
    position: static;
  }
}

/* ── Mode toggle bar ─────────────────────────────────────────── */

.book-mode-bar {
  display: flex;
  justify-content: center;
  margin: 0 auto 2rem;
  width: fit-content;
  border: 1px solid var(--book-line);
  border-radius: 4px;
  overflow: hidden;
}

.book-mode-btn {
  background: none;
  border: none;
  padding: 0.4rem 1.2rem;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--book-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.book-mode-btn + .book-mode-btn {
  border-left: 1px solid var(--book-line);
}

.book-mode-btn.is-active {
  background: var(--book-ink);
  color: var(--book-paper);
}

.book-pager-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--book-line);
  border-radius: 4px;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--book-muted);
  user-select: none;
  cursor: pointer;
}

.book-pager-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 0.85rem;
  height: 0.85rem;
  border: 1px solid var(--book-line);
  border-radius: 2px;
  background: #11151a;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  vertical-align: middle;
}
.book-pager-switch input[type="checkbox"]:checked {
  background: #11151a;
  border-color: var(--book-ink);
}
.book-pager-switch input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 0.17rem;
  top: 0.02rem;
  width: 0.32rem;
  height: 0.52rem;
  border: 2px solid #e8e2d8;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ── Scroll mode chapter navigation bar ─────────────────────── */

.book-chapter-nav {
  display: grid;
  grid-template-columns: 1fr 3fr;
  align-items: stretch;
  gap: 0.75rem;
  margin: 2.5rem 0 1rem;
  padding: 1rem 0;
  border-top: 1px solid var(--book-line);
}

.book-chap-nav-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--book-line);
  border-radius: 4px;
  padding: 0.5rem 1.2rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--book-ink);
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.book-chap-nav-btn--prev {
  justify-self: stretch;
}

.book-chap-nav-btn--next {
  justify-self: stretch;
}

.book-chap-nav-btn:hover:not(:disabled) {
  background: var(--book-ink);
  color: var(--book-paper);
}

.book-chap-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.book-shell.is-paged .book-chapter-nav {
  display: none;
}

@media (max-width: 640px) {
  .book-chapter-nav {
    grid-template-columns: 1fr;
  }
}

/* ── Paged mode - shell overrides ────────────────────────────── */

.book-shell.is-paged {
  --book-paper: #11151a;
  --book-ink: #e8e2d8;
  --book-muted: #b8ae9f;
  --book-line: rgba(232, 226, 216, 0.22);
  --book-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100dvh;
  height: 100vh; /* fallback */
  padding: 1rem 1rem 0;
  overflow: hidden;
  max-width: 100%;
}

.book-shell.is-paged .book-hero {
  margin-bottom: 0.5rem;
}

.book-shell.is-paged .book-title {
  font-size: clamp(1.3rem, 2.8vw, 2rem);
}

.book-shell.is-paged .book-author,
.book-shell.is-paged .book-description {
  display: none;
}

.book-shell.is-paged .book-mode-bar {
  margin-bottom: 0.5rem;
}

.book-shell.is-paged .book-grid {
  height: 100%;
  min-height: 0;
  grid-template-columns: 1fr;
  gap: 0;
  overflow: visible;
  align-items: stretch;
}

.book-shell.is-paged .book-sidebar {
  display: none;
}

.book-shell.is-paged .book-page-wrap {
  grid-column: 1; /* reset: single-column in paged mode */
  align-self: stretch;
}

.book-shell.is-paged .book-page {
  box-sizing: border-box;
  position: relative;
  overflow-y: hidden;
  overflow-x: hidden;
  height: 100%;
  min-height: 0;
  /* Left/right padding only — NO top/bottom padding on the clip container.
     If inner starts below the clip edge (due to padding-top), pageH cannot
     equal clientHeight without overlap or clipping at page boundaries.
     Vertical spacing is handled by .book-page-inner padding instead. */
  padding: 0 clamp(1rem, 2vw, 2rem);
  width: min(100%, 960px);
  margin: 0 auto;
  border-radius: 10px;
}

.book-shell.is-paged .book-page-inner {
  box-sizing: border-box;
  min-height: 0;
  max-width: 72ch;
  margin: 0 auto;
  /* Vertical padding here provides visual spacing without offsetting inner
     relative to the clip container, so pageH = page.clientHeight is exact. */
  padding: clamp(1rem, 2vw, 2rem) 0;
}

.book-shell.is-paged .book-sidebar-inner,
.book-shell.is-paged .book-page,
.book-shell.is-paged .book-pager-bar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)), var(--book-paper);
}

.book-shell.is-paged .book-toc-panel {
  background: var(--book-paper);
}

.book-shell.is-paged .book-mode-bar,
.book-shell.is-paged .book-mode-btn + .book-mode-btn,
.book-shell.is-paged .book-pager-btn {
  border-color: var(--book-line);
}

.book-shell.is-paged .book-pager-switch {
  border-color: var(--book-line);
}

.book-shell.is-paged .book-mode-btn.is-active,
.book-shell.is-paged .book-pager-btn:hover:not(:disabled) {
  background: var(--book-ink);
  color: #11151a;
}

.book-shell.is-paged .book-pager-btn,
.book-shell.is-paged .book-pager-toc-btn,
.book-shell.is-paged .book-toc-close {
  color: var(--book-ink);
}

.book-shell.is-paged .book-pager-info,
.book-shell.is-paged .book-sidebar-title,
.book-shell.is-paged .book-eyebrow,
.book-shell.is-paged .book-author,
.book-shell.is-paged .book-description,
.book-shell.is-paged .book-chapter-kicker,
.book-shell.is-paged .book-pager-switch {
  color: var(--book-muted);
}

/* In paged mode chapters must start at a clean page boundary — kill inter-chapter margin/padding */
.book-shell.is-paged .book-chapter + .book-chapter {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.book-shell.is-paged .prose-flow blockquote {
  border-left-color: rgba(232, 226, 216, 0.35);
  color: #d6ccbc;
}

.book-shell.is-paged.is-paged-pending .book-page-inner {
  visibility: hidden;
}

/* ── Page inner - animated translation ──────────────────────── */

.book-page-inner {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* ── Pager controls bar ──────────────────────────────────────── */

.book-pager-bar {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--book-line);
  background: linear-gradient(180deg, rgba(255,255,255,0.42), rgba(255,255,255,0.16)), var(--book-paper);
  flex-shrink: 0;
}

.book-shell.is-paged .book-pager-bar {
  position: relative;
  border-top: 1px solid var(--book-line);
  box-shadow: 0 -8px 22px rgba(0, 0, 0, 0.2);
}

.book-pager-bar.is-visible {
  display: flex;
}

/* ── Page wrapper + line-nudge buttons ──────────────────── */

.book-page-wrap {
  /* transparent wrapper — layout handled by book-page directly */
}

.book-shell.is-paged .book-page-wrap {
  height: 100%;
  min-height: 0;
  align-self: stretch;
}

.book-line-nudge-btn {
  display: none;
  position: absolute;
  right: 0.75rem;
  z-index: 10;
  background: var(--book-paper);
  border: 1px solid var(--book-line);
  border-radius: 4px;
  width: 1.8rem;
  height: 1.4rem;
  font-size: 0.55rem;
  line-height: 1;
  color: var(--book-muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  opacity: 0.65;
}

#book-line-up {
  top: 0.6rem;
}

#book-line-down {
  bottom: 0.6rem;
}

.book-page-wrap.is-paged .book-line-nudge-btn {
  display: flex;
}

.book-line-nudge-btn:hover {
  background: var(--book-ink);
  color: var(--book-paper);
  opacity: 1;
}

.book-pager-btn {
  background: none;
  border: 1px solid var(--book-line);
  border-radius: 3px;
  padding: 0.35rem 1.4rem;
  font-size: 1.25rem;
  color: var(--book-ink);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}

.book-pager-btn:hover:not(:disabled) {
  background: var(--book-ink);
  color: var(--book-paper);
}

.book-pager-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.book-pager-toc-btn {
  background: none;
  border: none;
  padding: 0.3rem 0.6rem;
  font-size: 1.1rem;
  color: var(--book-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.book-pager-toc-btn:hover {
  color: var(--book-ink);
}

.book-pager-info {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--book-muted);
  min-width: 5.5ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  cursor: text;
}

.book-pager-jump-input {
  width: 5ch;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--book-muted);
  color: var(--book-ink);
  font-size: 0.78rem;
  font-family: inherit;
  letter-spacing: 0.1em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
  padding: 0;
}

/* ── TOC overlay (paged mode) ────────────────────────────────── */

.book-toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.book-toc-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.book-toc-panel {
  background: #11151a;
  border-top: 1px solid rgba(232, 226, 216, 0.22);
  box-shadow: 0 -12px 40px rgba(26, 18, 12, 0.22);
  width: 100%;
  max-width: 640px;
  max-height: 60dvh;
  max-height: 60vh;
  overflow-y: auto;
  scrollbar-color: rgba(232, 226, 216, 0.32) rgba(0, 0, 0, 0.28);
  scrollbar-width: thin;
  padding: 1.5rem 1.5rem 2rem;
  position: relative;
  transform: translateY(12px);
  transition: transform 0.2s;
  border-radius: 8px 8px 0 0;
}

.book-toc-overlay.is-open .book-toc-panel {
  transform: translateY(0);
}

.book-toc-panel .book-sidebar-title {
  color: #b8ae9f;
}

.book-toc-panel .book-toc a {
  color: #e8e2d8;
}

.book-toc-panel .book-toc a:hover {
  color: #ffffff;
}

.book-toc-close {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1rem;
  color: #e8e2d8;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}

.book-toc-close:hover {
  color: #ffffff;
}

/* ── Image modal ───────────────────────────────────────────── */

body.book-modal-open {
  overflow: hidden;
}

.book-page-inner img {
  cursor: zoom-in;
}

.book-float-video-target {
  position: relative;
}

.book-float-video-hint {
  display: none;
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 5;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: #fff;
  padding: 0.1rem 0.55rem;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.5;
  pointer-events: none;
}

.book-shell.is-video-float-enabled .book-float-video-target {
  cursor: pointer;
}

.book-shell.is-video-float-enabled .book-float-video-target iframe,
.book-shell.is-video-float-enabled .book-float-video-target video {
  pointer-events: none;
}

.book-shell.is-video-float-enabled .book-float-video-hint {
  display: inline-flex;
}

.book-float-video-disable-overlay {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.book-float-video-enable-btn {
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 4px;
  color: #e8e2d8;
  padding: 0.28rem 0.6rem;
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.2;
  white-space: nowrap;
}

.book-float-video-enable-btn:hover {
  background: rgba(0, 0, 0, 0.85);
  border-color: rgba(255, 255, 255, 0.55);
}

.book-float-video-enable-btn:active {
  background: rgba(0, 0, 0, 0.92);
}

.book-image-modal {
  position: fixed;
  inset: 0;
  z-index: 260;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.book-image-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.book-image-modal-img {
  max-width: 96vw;
  max-height: 94vh;
  width: auto;
  height: auto;
  object-fit: contain;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.6);
}

.book-image-modal-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.book-image-modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

.book-video-float {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 250;
  width: min(560px, calc(100vw - 2rem));
  aspect-ratio: 16 / 9;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
}

.book-video-float.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.book-video-float-window {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: #0d1116;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.62);
}

.book-video-float-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 2.25rem;
  padding: 0.25rem 0.4rem 0.25rem 0.7rem;
  background: rgba(14, 20, 28, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  cursor: move;
  touch-action: none;
}

.book-video-float-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: #b8ae9f;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  user-select: none;
  cursor: pointer;
  flex-shrink: 0;
}

.book-video-float-switch input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 0.82rem;
  height: 0.82rem;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 2px;
  background: #0d1116;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.book-video-float-switch input[type="checkbox"]:checked {
  background: #0d1116;
  border-color: #e8e2d8;
}

.book-video-float-switch input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 0.16rem;
  top: 0.01rem;
  width: 0.31rem;
  height: 0.5rem;
  border: 2px solid #e8e2d8;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.book-video-float-title {
  color: #d6ccbc;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.book-video-float-media {
  flex: 1;
  width: 100%;
  min-height: 0;
}

.book-video-float-media video {
  background: #000;
}

.book-video-float-close {
  position: static;
  width: 2rem;
  height: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.book-video-float-close:hover {
  background: rgba(0, 0, 0, 0.82);
}

.book-video-float-resize {
  position: absolute;
  right: 0.2rem;
  bottom: 0.2rem;
  width: 1.2rem;
  height: 1.2rem;
  border: none;
  background: transparent;
  cursor: nwse-resize;
  touch-action: none;
  padding: 0;
}

.book-video-float-resize::before {
  content: '';
  position: absolute;
  right: 0.15rem;
  bottom: 0.15rem;
  width: 0.7rem;
  height: 0.7rem;
  border-right: 2px solid rgba(255, 255, 255, 0.66);
  border-bottom: 2px solid rgba(255, 255, 255, 0.66);
}

@media (max-width: 700px) {
  .book-pager-bar {
    gap: 0.7rem;
    padding-inline: 0.5rem;
  }

  .book-shell.is-paged {
    padding-inline: 0.35rem;
    padding-bottom: 0;
  }

  .book-shell.is-paged .book-page {
    padding: 0.75rem;
    width: 100%;
    border-radius: 0;
  }

  .book-shell.is-paged .book-page-inner {
    max-width: none;
  }

  .book-video-float {
    right: 0.5rem;
    left: 0.5rem;
    bottom: 0.6rem;
    width: auto;
  }
}