.book-preview {
  padding: .55rem 1rem;
  border: 1px solid #77897a;
  border-radius: .2rem;
  font-weight: 600;
  text-decoration: none;
}
.book-preview:hover { background: #e9eee6; }
.cover-preview { cursor: zoom-in; }
.cover-preview:hover .book-cover { outline: 2px solid #89734d; outline-offset: 3px; }
:root:has(.sample-reader[open]) { overflow: hidden; }

.sample-reader {
  position: fixed;
  inset: 0;
  width: min(66rem, calc(100% - 3rem));
  height: min(92vh, 76rem);
  height: min(92dvh, 76rem);
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: .35rem;
  box-shadow: 0 1.25rem 5rem #101b1580;
  color: var(--ink);
  background: #e7e7df;
}
.sample-reader:not([open]) { display: none; }
.sample-reader[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.sample-reader::backdrop { background: rgb(16 29 24 / 72%); }
.sample-header, .sample-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .35rem 1.1rem;
  background: var(--paper);
}
.sample-header { border-bottom: 1px solid var(--rule); }
.sample-header h2 {
  padding-block: .2rem;
  font-size: clamp(1.25rem, 2.1vw, 1.55rem);
  line-height: 1.14;
  text-wrap: balance;
}
.sample-reader button, .sample-tools a, .sample-count {
  color: var(--ink);
  font: 550 var(--ui-font-size)/1.25 var(--sans);
}
.sample-reader button, .sample-tools a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: .35rem .65rem;
  border: 1px solid transparent;
  border-radius: .2rem;
  background: transparent;
  cursor: pointer;
}
.sample-close { flex: none; gap: .45rem; }
.sample-close span { font-size: 1.35rem; line-height: 1; }
.sample-reader button:hover, .sample-tools a:hover { background: #e7eae1; }
.sample-reader :focus-visible { outline: 3px solid #98612e; outline-offset: -3px; }

.sample-sheet {
  display: flex;
  min-width: 0;
  min-height: 0;
  margin-inline: 4rem;
  padding: .8rem .4rem;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-y pinch-zoom;
}
.sample-sheet img {
  flex: none;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  margin: auto;
  background: white;
  box-shadow: 0 1px 5px #26332a3d;
}
.sample-sheet.is-zoomed { touch-action: pan-x pan-y pinch-zoom; }
.sample-sheet.is-zoomed img { width: max(100%, 68rem); max-width: none; max-height: none; }
.sample-sheet p { margin: auto; padding: 1rem; font: 500 var(--ui-font-size)/1.5 var(--sans); }

.sample-toolbar { border-top: 1px solid var(--rule); }
.sample-pagination, .sample-tools { display: flex; align-items: center; gap: .5rem; }
.sample-count { white-space: nowrap; font-variant-numeric: tabular-nums; }
.sample-reader .sample-step {
  position: absolute;
  top: 50%;
  width: 44px;
  border-color: #b7bdb2;
  border-radius: 50%;
  background: var(--paper);
  transform: translateY(-50%);
}
.sample-prev { left: .6rem; }
.sample-next { right: .6rem; }
.sample-step span {
  display: block;
  width: .62rem;
  height: .62rem;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translateX(-.12rem) rotate(45deg);
}
.sample-prev span { transform: translateX(.12rem) rotate(-135deg); }
.sample-reader .sample-step:hover { background: #fdfcf8; border-color: #617364; }
.sample-reader .sample-step[aria-disabled="true"] { opacity: .4; cursor: default; }
.sample-tools { gap: .75rem; }
.sample-reader .sample-zoom { border-color: #aeb8ab; }

@media (max-width: 40rem), (max-height: 30rem) {
  .sample-reader {
    width: 100%;
    height: 100%;
    height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .sample-header, .sample-toolbar {
    padding-left: max(.65rem, env(safe-area-inset-left));
    padding-right: max(.65rem, env(safe-area-inset-right));
    gap: .4rem;
  }
  .sample-header { padding-top: max(.2rem, env(safe-area-inset-top)); }
  .sample-toolbar { flex-wrap: wrap; padding-bottom: max(.25rem, env(safe-area-inset-bottom)); }
  .sample-sheet { margin-inline: 0; padding: .4rem; }
  .sample-reader .sample-step { position: static; transform: none; border-color: transparent; }
  .sample-pagination, .sample-tools { gap: .1rem; }
  .sample-tools a, .sample-reader .sample-zoom { padding-inline: .4rem; }
}
@media (max-width: 26rem) {
  .sample-toolbar {
    justify-content: space-around;
    gap: .2rem;
    padding-left: max(.375rem, env(safe-area-inset-left));
    padding-right: max(.375rem, env(safe-area-inset-right));
  }
  .sample-tools a, .sample-reader .sample-zoom { padding-inline: .25rem; }
}
@media print {
  .sample-reader[open], .sample-reader::backdrop { display: none; }
}
