:root {
  color-scheme: dark;
  --ink: #241a20;
  --rose: #f0cac1;
  --cream: #fcf1ec;
  --muted: #ceb9bc;
  --line: #ffffff29;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  font-family: "Century Gothic", "Trebuchet MS", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 290px; background: var(--ink); color: var(--cream); }
button, a { color: inherit; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid #ffc9b8; outline-offset: 4px; }

.top {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(18px, 5vw, 82px);
  border-bottom: 1px solid var(--line);
}
.brand { font: 28px/1 Georgia, serif; white-space: nowrap; }
.brand span { display: block; margin-top: 6px; color: var(--muted); font: 10px/1.2 "Trebuchet MS", sans-serif; letter-spacing: .17em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  color: var(--cream);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  font-size: 13px;
}
.pdf { border-color: var(--line); }
.pdf .long-label { margin-right: -5px; }
.icon { display: inline-block; flex: none; position: relative; }
.grid { width: 14px; height: 14px; background: linear-gradient(var(--cream) 0 0) 0 0 / 5px 5px, linear-gradient(var(--cream) 0 0) 100% 0 / 5px 5px, linear-gradient(var(--cream) 0 0) 0 100% / 5px 5px, linear-gradient(var(--cream) 0 0) 100% 100% / 5px 5px; background-repeat: no-repeat; }
.download { font-size: 19px; line-height: .8; border-bottom: 1px solid currentColor; padding-bottom: 3px; }
.magnify { width: 13px; height: 13px; border: 1px solid currentColor; border-radius: 50%; margin-right: 3px; }
.magnify::after { content: ""; position: absolute; width: 6px; height: 1px; background: currentColor; transform: rotate(45deg); left: 9px; top: 11px; }

.reader {
  min-height: calc(100dvh - 76px);
  display: grid;
  grid-template-rows: 1fr auto;
  background: radial-gradient(ellipse at 60% 41%, #65434a 0%, #442c36 43%, #2b2028 95%);
}
.view {
  --view-inset: clamp(20px, 3.2dvh, 38px);
  position: relative;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: var(--view-inset) 0;
  overflow: clip;
}
.book {
  --page: min(calc((100vw - clamp(40px, 7vw, 100px)) / 2), max(230px, calc(100dvh - 150px - 2 * var(--view-inset))));
  position: relative;
  width: calc(2 * var(--page));
  height: var(--page);
  perspective: calc(var(--page) * 2.5);
  isolation: isolate;
  touch-action: pan-y;
  user-select: none;
}
.spread { position: absolute; inset: 0; }
.paper {
  width: var(--page);
  height: var(--page);
  position: absolute;
  top: 0;
}
.paper { background: white; box-shadow: 0 9px 28px #170e1580, 0 1px 5px #160e1b45; }
.paper.left { left: 0; }
.paper.right { left: var(--page); }
.paper img { width: 100%; height: 100%; display: block; object-fit: contain; }
.paper::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.paper.left::after { background: linear-gradient(270deg, #2813153e 0%, #21101d11 2.5%, transparent 7%); }
.paper.right::after { background: linear-gradient(90deg, #28131538 0%, #21101d0d 3%, transparent 8%); }
.book[data-cover="front"] .paper::after { background: linear-gradient(90deg, #28222914, transparent 4%); }
.book[data-cover="back"] .paper::after { background: linear-gradient(270deg, #28222914, transparent 4%); }
.leaf { position: absolute; z-index: 3; pointer-events: none; }
.book.turning { cursor: grabbing; }

.intro { position: absolute; inset: 0 50% 0 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 0 9% 0 4%; }
.intro[hidden] { display: none; }
.edition { color: var(--rose); font-size: 11px; letter-spacing: .24em; }
h1 { margin: 18px 0 26px; font: 400 clamp(38px, 5.2vw, 86px)/.99 Georgia, serif; letter-spacing: -.055em; }
.start { background: var(--rose); color: #2c1721; display: inline-flex; gap: 26px; align-items: center; min-height: 45px; border: 0; border-radius: 4px; padding: 0 15px 0 18px; font-size: 13px; font-weight: bold; }
.start span { font-size: 17px; }
.noscript { text-align: center; }

.controls { min-height: 74px; padding: 11px clamp(18px, 5vw, 82px); display: grid; grid-template-columns: 1fr auto 1fr; gap: 15px; align-items: center; border-top: 1px solid var(--line); }
.hint { margin: 0; color: var(--muted); font-size: 12px; }
.pager { display: flex; align-items: center; min-height: 48px; background: #21161eb8; border: 1px solid var(--line); border-radius: 26px; padding: 2px; }
.pager button { display: grid; place-items: center; width: 44px; height: 42px; background: transparent; border: 0; border-radius: 50%; }
.pager button:disabled { opacity: .31; }
.pager button:not(:disabled):last-child { background: var(--rose); color: #291a20; }
.chevron { width: 9px; height: 9px; border-top: 1.5px solid currentColor; border-right: 1.5px solid currentColor; transform: translateX(-2px) rotate(45deg); }
.chevron.leftward { transform: translateX(2px) rotate(-135deg); }
output { min-width: 97px; padding: 0 7px; color: var(--cream); text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.zoom { justify-self: end; }
.short-label { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.dialog { color: var(--cream); border: 1px solid var(--line); background: #30232c; border-radius: 10px; padding: 0; width: min(94vw, 820px); max-height: 88dvh; }
.dialog::backdrop { background: #170f17d6; }
.dialog-header { position: sticky; z-index: 1; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 16px; background: #30232c; border-bottom: 1px solid var(--line); }
.dialog h2 { font: 24px/1.1 Georgia, serif; margin: 0; }
.square { background: transparent; border: 1px solid var(--line); border-radius: 5px; color: var(--cream); width: 41px; height: 41px; font: 25px/1 Georgia, serif; }
.square:disabled { opacity: .38; }
.index-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(114px, 1fr)); gap: 12px; padding: 16px; }
.thumbnail { display: grid; gap: 7px; justify-items: start; color: var(--cream); text-align: left; background: transparent; border: 1px solid var(--line); border-radius: 5px; padding: 7px; font-size: 12px; line-height: 1.3; }
.thumbnail img { width: 100%; aspect-ratio: 1; object-fit: cover; background: white; }
.thumbnail[aria-current="page"] { border-color: var(--rose); }
.zoom-dialog { width: min(96vw, 1300px); max-height: 94dvh; overflow: hidden; }
.zoom-tools { display: flex; align-items: center; gap: 8px; }
.zoom-tools h2 { margin-right: 6px; }
.zoom-scroller { max-height: calc(94dvh - 64px); overflow: auto; overscroll-behavior: contain; background: #231921; }
.zoom-pages { width: max(100%, var(--zoom-width, 100%)); display: flex; justify-content: center; gap: 2px; }
.zoom-pages img { display: block; width: min(100%, var(--zoom-width, 100%)); object-fit: contain; align-self: start; background: white; }
.zoom-pages.double img { width: calc((100% - 2px) / 2); }

@media (hover: hover) and (pointer: fine) {
  .tool:hover, .square:not(:disabled):hover, .pager button:not(:disabled):hover, .thumbnail:hover { background-color: #ffffff19; }
  .start:hover, .pager button:not(:disabled):last-child:hover { background-color: #ffded4; }
}
@media (max-width: 799px) {
  .top { min-height: 65px; padding-inline: 14px; }
  .brand { font-size: 22px; }
  .brand span { font-size: 8px; }
  .tool { padding-inline: 9px; }
  .long-label { display: none; }
  .short-label { display: inline; }
  .reader { min-height: calc(100dvh - 65px); }
  .view { --view-inset: 18px; }
  .book { --page: min(calc(100vw - 28px), max(205px, calc(100dvh - 167px)), 580px); width: var(--page); }
  .paper.right, .paper.left { left: 0; }
  .paper.left::after, .paper.right::after { background: linear-gradient(90deg, #28131522, transparent 5%); }
  .intro { display: none; }
  .controls { min-height: 66px; padding: 8px 14px; gap: 5px; }
  .hint { visibility: hidden; height: 0; overflow: hidden; }
  .zoom { min-width: 44px; }
  .zoom-tools h2 { font-size: 19px; }
}
