/* Reader sizing is contained by the page, including native audio controls. */
body:has([data-pdf-reader]) .kh-grid,
body:has([data-pdf-reader]) .kh-copy,
[data-pdf-reader],
.reader-viewer,
.reader-stage,
.reader-flipbook {
  min-width: 0;
  max-width: 100%;
}
body:has([data-pdf-reader]) .kh-copy {
  overflow-wrap: anywhere;
}
body:has([data-pdf-reader]) audio {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.reader-actions > * {
  min-width: 0;
}
.reader-stage {
  position: relative;
  overflow: hidden;
}
.reader-loader {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  place-items: center;
  pointer-events: none;
  background: #ccdcd9d9;
}
.reader-stage[aria-busy='true'] > .reader-loader {
  display: grid;
}
.reader-spinner {
  display: block;
  width: 42px;
  height: 42px;
  border: 4px solid #287c7233;
  border-top-color: #287c72;
  border-radius: 50%;
  animation: reader-spin 0.8s linear infinite;
}
.flip-wait::after {
  content: '';
  width: 30px;
  height: 30px;
  border: 3px solid #287c7233;
  border-top-color: #287c72;
  border-radius: 50%;
  animation: reader-spin 0.8s linear infinite;
}
@keyframes reader-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .reader-spinner,
  .flip-wait::after {
    animation: none;
    border-style: dotted;
  }
}
:root[data-theme='dark'] .reader-loader {
  background: #251c53d9;
}
:root[data-theme='dark'] .reader-spinner,
:root[data-theme='dark'] .flip-wait::after {
  border-color: #b2deca44;
  border-top-color: #b2deca;
}
/* Fullscreen reserves the viewport for the book and a single exit control. */
.reader-viewer[data-fullscreen='true'] {
  box-sizing: border-box;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overflow: hidden;
}
.reader-toolbar-with-fullscreen {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.reader-toolbar-with-fullscreen .reader-pagination {
  margin: 0;
}
.reader-viewer[data-fullscreen='true'] .reader-toolbar-with-fullscreen {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  right: max(8px, env(safe-area-inset-right));
  z-index: 10;
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
}
.reader-viewer[data-fullscreen='true'] .reader-pagination {
  display: none;
}
.reader-viewer[data-fullscreen='true'] [data-pdf-fullscreen] {
  width: 44px;
  height: 44px;
  padding: 10px;
  border-radius: 50%;
  background: #fffdf8ee;
  color: #244655;
  box-shadow: 0 2px 12px #0003;
}
.reader-viewer[data-fullscreen='true'] [data-pdf-fullscreen-label] {
  display: none;
}
.reader-viewer[data-fullscreen='true'] .reader-stage {
  flex: 1;
  width: 100%;
  min-height: 0;
  max-height: none;
  padding: 2px;
  border-radius: 0;
}
.reader-fullscreen-open #home-music {
  display: none;
}
@media (max-width: 400px) {
  .reader-pagination {
    gap: 4px;
  }
  .reader-pagination > li {
    min-width: 0;
  }
  .reader-pagination label {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .reader-toolbar-with-fullscreen [data-pdf-fullscreen] {
    width: 40px;
    min-width: 40px;
    padding: 0;
  }
  .reader-toolbar-with-fullscreen [data-pdf-fullscreen-label] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
