:root {
  color-scheme: dark;
  font-family: Inter, "Avenir Next", system-ui, sans-serif;
  background: #101923;
  color: #f3f7fb;
  --muted: #b1c0d0;
  --line: #304254;
  --accent: #56cef8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at 62% 13%, #1c3044 0%, #121e2a 48%, #0d151e 100%);
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:not(:disabled) { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.masthead {
  background: #101923;
  border-bottom: 1px solid var(--line);
}

.masthead-inner {
  width: min(calc(100% - 64px), 1392px);
  min-height: 79px;
  margin-inline: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.title-block {
  padding-inline-start: 15px;
  border-inline-start: 3px solid var(--accent);
}

.title-block h1 {
  margin: 0;
  font-size: clamp(1.17rem, 2.2vw, 1.6rem);
  line-height: 1.08;
  font-weight: 780;
  letter-spacing: -.035em;
}

.title-block p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .77rem;
}

.button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #192737;
  color: #f4f8fc;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
  font-size: .83rem;
  font-weight: 650;
}

.button:hover:not(:disabled) {
  border-color: #5d94ad;
  background: #23394b;
}

.button:disabled { opacity: .45; }
.pdf-link span { color: var(--accent); }

.workspace {
  width: min(calc(100% - 64px), 1392px);
  margin: 25px auto 34px;
  display: grid;
  grid-template-columns: 206px minmax(0, 1fr);
  grid-template-areas: "contents reader";
  align-items: start;
  gap: 24px;
}

.reader {
  grid-area: reader;
  min-width: 0;
  display: grid;
  justify-items: center;
  --book-width: min(100%, 1056px, calc(max(440px, 100svh - 184px) * 22 / 17));
}

.book-frame {
  isolation: isolate;
  position: relative;
  width: var(--book-width);
  aspect-ratio: 22 / 17;
  overflow: hidden;
  perspective: 2200px;
  perspective-origin: 50% 48%;
  background: #183b60;
  outline: 1px solid #4d637a;
  border-radius: 3px;
  box-shadow: 0 16px 36px #050c157d, 0 2px 9px #02060e82;
  touch-action: pan-y pinch-zoom;
}

.page-image, .turning-sheet {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.page-image {
  object-fit: contain;
  user-select: none;
}

.turning-sheet {
  z-index: 1;
  transform-origin: left center;
  backface-visibility: hidden;
  pointer-events: none;
}

.turning-sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #02091280, #0209120d 24%, transparent 58%, #02091248);
  opacity: var(--fold-shadow, 0);
}

@property --fold-shadow {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

.toolbar {
  width: var(--book-width);
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.navigation {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 10px;
}

.arrow {
  width: 44px;
  padding: 0;
  font: 1.8rem/1 system-ui, sans-serif;
}

.arrow span { margin-top: -3px; }

.page-number {
  min-width: 4.1ch;
  text-align: center;
  color: #e2eaf4;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}

.zoom-button { grid-column: 3; justify-self: end; }

.zoom-icon {
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 100%;
  position: relative;
  margin-inline-end: 2px;
}

.zoom-icon::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 1.5px;
  background: currentColor;
  transform: rotate(45deg);
  top: 8px;
  left: 7px;
}

.contents {
  grid-area: contents;
  min-width: 0;
  background: #111d29;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px 9px 9px;
}

.contents h2 {
  margin: 1px 8px 11px;
  font-size: .73rem;
  color: var(--muted);
  font-weight: 730;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.page-list {
  padding: 0;
  margin: 0;
  list-style: none;
  display: grid;
  gap: 5px;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 59px;
  padding: 6px 7px;
  text-align: left;
  font-size: .75rem;
  line-height: 1.25;
  font-weight: 660;
  color: #e6eef6;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
}

.page-jump:hover { background: #1e3042; }

.page-jump[aria-current="page"] {
  background: #1c354a;
  border-color: #5ac8ed;
  color: #fff;
}

.page-jump small {
  display: block;
  color: var(--muted);
  font-size: .64rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .07em;
  margin-bottom: 3px;
}

.page-jump[aria-current="page"] small { color: #92dcf8; }

.page-jump img {
  flex: 0 0 auto;
  width: 54px;
  height: auto;
  border: 1px solid #64758b;
  border-radius: 2px;
}

.detail {
  width: min(calc(100% - 26px), 1260px);
  max-width: none;
  max-height: calc(100dvh - 26px);
  padding: 0;
  color: #f3f7fb;
  background: #101923;
  border: 1px solid #53687c;
  border-radius: 10px;
}

.detail::backdrop { background: #080c13de; }

.detail[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.detail-header {
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 { margin: 0; font-size: .95rem; }

.detail-controls { display: flex; flex-wrap: wrap; gap: 6px; }

.detail-scroll {
  overflow: auto;
  overscroll-behavior: contain;
  background: #0b131d;
  max-height: calc(100dvh - 96px);
}

.detail-scroll img { display: block; width: max(1120px, 155%); height: auto; }
.detail-scroll.is-fit img { width: 100%; }
body:has(.detail[open]) { overflow: hidden; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

html:not(.reader-ready) .interactive { display: none; }

@media (max-width: 850px) {
  .workspace {
    width: min(calc(100% - 32px), 730px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "reader" "contents";
    margin-top: 18px;
    gap: 18px;
  }

  .masthead-inner { width: calc(100% - 32px); min-height: 68px; }
  .reader { --book-width: 100%; }
  .contents { padding-bottom: 5px; }
  .page-list {
    display: flex;
    overflow-x: auto;
    padding: 2px 3px 8px;
    scroll-padding-inline: 3px;
    scrollbar-width: thin;
    scrollbar-color: #587188 #111d29;
  }

  .page-list li { flex: 1 0 105px; }
  .page-jump { display: grid; gap: 5px; align-content: start; height: 100%; }
  .page-jump img { width: 55px; }
  .page-jump small { display: inline; margin-inline-end: 4px; }
}

@media (max-width: 420px) {
  .masthead-inner, .workspace { width: calc(100% - 28px); }
  .title-block { padding-inline-start: 10px; }
  .toolbar { grid-template-columns: 1fr auto; }
  .navigation { grid-column: 1; }
  .zoom-button { grid-column: 2; }
  .detail-header { padding-inline: 9px; }
}
