:root {
  color-scheme: dark;
  --ink: #050505;
  --paper: #f4f1e9;
  --line: #343434;
  --muted: #aaa69d;
  --chrome: #0c0c0c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 30%, #292929 0, #101010 45%, #050505 100%);
  color: #f7f7f4;
}

button, input, select { font: inherit; }
.language-select { color: #f7f7f4; background: #171717; border: 1px solid #555; border-radius: 8px; padding: 7px 6px; font-size: 13px; cursor: pointer; }
.language-select:focus-visible { outline: 2px solid #eee; outline-offset: 3px; }
button { color: inherit; }

body {
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 58px;
}

.topbar, .controls {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 max(18px, env(safe-area-inset-left));
  background: rgba(5, 5, 5, .94);
  border-color: #282828;
  backdrop-filter: blur(14px);
}

.topbar { border-bottom: 1px solid #282828; }
.controls { border-top: 1px solid #282828; justify-content: center; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 2px solid #eee;
  transform: rotate(45deg);
  font-size: 19px;
}

.brand-mark::first-letter { transform: rotate(-45deg); }

.book-title {
  min-width: 0;
  display: flex;
  gap: 12px;
  align-items: baseline;
  margin-inline: auto;
}

.book-title strong { letter-spacing: .12em; }
.book-title span { color: var(--muted); font-size: 12px; }

.icon-button, .controls button {
  border: 1px solid #3b3b3b;
  border-radius: 999px;
  background: #171717;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.icon-button { width: 36px; height: 36px; }
.controls button { width: 38px; height: 38px; font-size: 20px; }
.icon-button:hover, .controls button:hover { background: #292929; border-color: #707070; }
.icon-button:active, .controls button:active { transform: scale(.94); }
.controls button:disabled { opacity: .28; cursor: default; }

.reader {
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  padding: 10px 64px;
  overflow: hidden;
  perspective: 2200px;
  touch-action: pan-y pinch-zoom;
}

.book {
  position: relative;
  height: min(calc(100vh - 136px), calc((100vw - 142px) * .70664));
  max-height: 100%;
  aspect-ratio: 2110 / 1491;
  filter: drop-shadow(0 24px 38px rgba(0,0,0,.58));
  transform-style: preserve-3d;
}

.book.is-cover {
  aspect-ratio: 1055 / 1491;
  height: min(calc(100vh - 136px), calc((100vw - 44px) * 1.41327));
}

.cover-view {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.cover-view img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 0 0 1px #000, 11px 10px 0 #242424, 14px 13px 24px rgba(0,0,0,.7);
  user-select: none;
}

.spread-view {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 2px 1fr;
  align-items: center;
}

.spread-view[hidden], .cover-view[hidden] { display: none; }

.page {
  position: relative;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 0 1px #000;
}

.page.blank { background: linear-gradient(90deg, #ddd8ce, #f4f1e9 8%, #f4f1e9); }
.page-right.blank { background: linear-gradient(270deg, #ddd8ce, #f4f1e9 8%, #f4f1e9); }

.page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.gutter {
  align-self: stretch;
  z-index: 3;
  background: linear-gradient(90deg, #000, #595959 50%, #000);
  box-shadow: 0 0 20px 8px rgba(0,0,0,.52);
}

.turn-zone {
  position: absolute;
  z-index: 10;
  top: 0;
  bottom: 0;
  width: 22%;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.previous-zone { left: 0; cursor: w-resize; }
.next-zone { right: 0; cursor: e-resize; }

.turn-sheet { display: none; }

.page-jump { display: flex; align-items: center; gap: 7px; color: #bcb8ae; font-size: 12px; }
.page-jump input {
  width: 58px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid #404040;
  border-radius: 5px;
  background: #111;
  color: #fff;
  text-align: center;
}

.progress { width: min(28vw, 320px); height: 3px; overflow: hidden; border-radius: 2px; background: #333; }
.progress span { display: block; width: 0; height: 100%; background: #dedad0; transition: width .2s ease; }
.page-status { width: 92px; color: #c9c5bc; font-size: 12px; text-align: center; }

noscript { position: fixed; inset: 50% auto auto 50%; transform: translate(-50%,-50%); z-index: 100; background: #000; padding: 20px; }

@media (max-width: 800px) {
  body { grid-template-rows: 50px minmax(0,1fr) 54px; }
  .topbar { padding-inline: 13px; }
  .brand { font-size: 10px; }
  .brand-mark { width: 21px; height: 21px; }
  .book-title span { display: none; }
  .reader { padding: 8px 6px; }
  .book { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; }
  .book.is-cover { width: 100%; height: 100%; aspect-ratio: auto; }
  .spread-view { display: block; }
  .page { width: 100%; height: 100%; background: transparent; box-shadow: none; }
  .page img { object-fit: contain; }
  .page-left, .gutter { display: none; }
  .page-right.blank { display: block; }
  .turn-zone { width: 28%; }
  .progress { flex: 1; max-width: 150px; }
  .page-status { display: none; }
  .controls { gap: 9px; padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
