:root {
  --bar-bg: rgba(34, 37, 40, 0.55);
  --bar-line: rgba(255, 255, 255, 0.16);
  --bar-text: #ffffff;
  --muted: rgba(255, 255, 255, 0.68);
  --page-w: 583;
  --page-h: 825;
  --page-ratio: 0.706667;
  --book-ratio: 1.413333;
  --zoom: 1;
  --paper-bg: #f7f8fa;
  --spread-max: 1800px;
  --cover-pull: 0px;
  --pan-x: 0px;
  --pan-y: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #dbdee0;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  color: #111;
  background: #dbdee0;
}

.reader-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #dbdee0;
  background-image: url("assets/background.png");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}

.stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  overflow: hidden;
  perspective: 1800px;
}

.app.is-loading:not(.is-reader-prepared) .stage {
  visibility: hidden;
}

.book-shell {
  position: relative;
  z-index: 3;
  display: grid;
  place-items: center;
  width: min(calc(100vw - 136px), calc((100vh - 86px) * var(--book-ratio)), var(--spread-max));
  width: min(calc(100vw - 136px), calc((100dvh - 86px) * var(--book-ratio)), var(--spread-max));
  aspect-ratio: var(--book-ratio);
  transform: translate3d(var(--pan-x), var(--pan-y), 0) scale(var(--zoom));
  transform-origin: center;
  transition: transform 260ms ease;
  user-select: none;
  will-change: transform;
  touch-action: none;
}

.toc-tab {
  position: absolute;
  top: var(--toc-top, 0px);
  right: -27px;
  z-index: 6;
  width: 27px;
  height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  background: #b6111f;
  border: 0;
  border-radius: 0 4px 4px 0;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: top 260ms ease, right 260ms ease;
}

.toc-tab:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.86);
  outline-offset: 2px;
}

.app:not(.is-mobile-reader) .book-shell.is-front-cover {
  transform: translate3d(calc(-25% + var(--cover-pull) + var(--pan-x)), var(--pan-y), 0)
    scale(var(--zoom));
}

.app:not(.is-mobile-reader) .book-shell.is-end-cover {
  transform: translate3d(calc(25% + var(--pan-x)), var(--pan-y), 0) scale(var(--zoom));
}

.app:not(.is-mobile-reader) .book-shell.is-end-cover .toc-tab {
  right: calc(50% - 27px);
}

.app:not(.is-mobile-reader) .book-shell.is-cover-pulling {
  transition: none;
}

.book-shell.is-zoomed,
.book-shell.is-zoomed .page-flip,
.book-shell.is-zoomed canvas {
  cursor: grab;
}

.book-shell.is-panning {
  transition: none;
}

.book-shell.is-panning,
.book-shell.is-panning .page-flip,
.book-shell.is-panning canvas {
  cursor: grabbing;
}

.page-flip {
  width: 100%;
  height: 100%;
  overflow: visible;
  touch-action: none;
}

.page-flip .stf__wrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

.page-flip .stf__block {
  background: transparent;
}

.page-flip canvas {
  outline: 1px solid rgba(0, 0, 0, 0.12);
  touch-action: none;
}

.flip-page {
  overflow: hidden;
  background: var(--paper-bg);
  outline: 1px solid rgba(0, 0, 0, 0.12);
}

.book-shell.is-page-settled .flip-page:not(.is-settled-page) {
  display: none !important;
}

.flip-page img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  pointer-events: none;
}

.page-load-feedback {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
  color: #535d63;
  background: var(--paper-bg);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.flip-page.is-page-loading .page-load-feedback,
.flip-page.is-page-error .page-load-feedback {
  visibility: visible;
  opacity: 1;
}

.page-load-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(8, 121, 232, 0.18);
  border-top-color: #0879e8;
  border-radius: 50%;
  animation: page-load-spin 720ms linear infinite;
}

.page-load-copy,
.page-load-error-copy {
  font-size: 12px;
  line-height: 1.35;
}

.page-load-track {
  width: 92px;
  height: 3px;
  overflow: hidden;
  background: rgba(38, 48, 55, 0.12);
  border-radius: 2px;
}

.page-load-track span {
  display: block;
  width: 38%;
  height: 100%;
  background: #0879e8;
  border-radius: inherit;
  animation: page-load-track 1.05s ease-in-out infinite;
}

.page-load-error-copy,
.page-load-retry {
  display: none;
}

.page-load-retry {
  align-items: center;
  justify-content: center;
  min-width: 108px;
  height: 34px;
  padding: 0 14px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  background: #2d3438;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  pointer-events: auto;
}

.page-load-retry:hover,
.page-load-retry:focus-visible {
  background: #15191b;
  outline: 2px solid rgba(8, 121, 232, 0.34);
  outline-offset: 2px;
}

.flip-page.is-page-error .page-load-spinner,
.flip-page.is-page-error .page-load-copy,
.flip-page.is-page-error .page-load-track {
  display: none;
}

.flip-page.is-page-error .page-load-error-copy,
.flip-page.is-page-error .page-load-retry {
  display: inline-flex;
}

@keyframes page-load-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes page-load-track {
  from {
    transform: translateX(-105%);
  }
  to {
    transform: translateX(265%);
  }
}

.return-page-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  display: none;
  width: 50%;
  height: 100%;
  overflow: hidden;
  background: var(--paper-bg);
  outline: 1px solid rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.return-page-layer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
}

.return-cover-layer {
  position: absolute;
  z-index: 6;
  display: none;
  overflow: hidden;
  background: var(--paper-bg);
  outline: 1px solid rgba(0, 0, 0, 0.12);
  pointer-events: none;
  transform-origin: 0 0;
}

.return-cover-layer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
}

.end-page-layer {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 3;
  display: none;
  width: 50%;
  height: 100%;
  overflow: hidden;
  background: var(--paper-bg);
  outline: 1px solid rgba(0, 0, 0, 0.12);
  pointer-events: none;
}

.end-page-layer img,
.end-cover-layer img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
}

.end-cover-layer {
  position: absolute;
  z-index: 6;
  display: none;
  overflow: hidden;
  background: var(--paper-bg);
  outline: 1px solid rgba(0, 0, 0, 0.12);
  pointer-events: none;
  transform-origin: 0 0;
}

.book-shell.is-closing-cover.is-flipping.is-return-cover-ready .flip-page[data-index="0"],
.book-shell.is-closing-cover.is-flipping.is-return-cover-ready .flip-page[data-index="1"] {
  opacity: 0;
  pointer-events: none;
}

.book-shell.is-closing-cover.is-flipping.is-return-cover-ready .return-page-layer {
  display: block;
}

.book-shell.is-closing-cover.is-flipping.is-return-cover-ready .return-cover-layer {
  display: block;
}

.book-shell.is-ending-cover.is-flipping.is-end-cover-ready .flip-page.is-last-interior-page,
.book-shell.is-ending-cover.is-flipping.is-end-cover-ready .flip-page.is-back-cover-page {
  opacity: 0;
  pointer-events: none;
}

.book-shell.is-ending-cover.is-flipping.is-end-cover-ready .end-page-layer,
.book-shell.is-ending-cover.is-flipping.is-end-cover-ready .end-cover-layer {
  display: block;
}

.book-shell.is-closing-cover.is-flipping .stf__outerShadow,
.book-shell.is-ending-cover.is-flipping .stf__outerShadow {
  display: none !important;
}

.nav-zone {
  position: absolute;
  top: 13%;
  bottom: 13%;
  z-index: 4;
  width: 14vw;
  min-width: 96px;
  border: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

.nav-zone::before {
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  content: "";
  border-top: 4px solid rgba(255, 255, 255, 0.72);
  border-right: 4px solid rgba(255, 255, 255, 0.72);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.22));
  opacity: 0.78;
}

.nav-zone:hover::before,
.nav-zone:focus-visible::before {
  opacity: 1;
}

.nav-zone:focus-visible {
  outline: none;
}

.nav-prev {
  left: 0;
}

.nav-prev::before {
  left: clamp(12px, 2vw, 34px);
  transform: translateY(-50%) rotate(-135deg);
}

.nav-next {
  right: 0;
}

.nav-next::before {
  right: clamp(12px, 2vw, 34px);
  transform: translateY(-50%) rotate(45deg);
}

.topbar,
.bottombar {
  position: absolute;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--bar-text);
  background: var(--bar-bg);
  border: 1px solid var(--bar-line);
  border-radius: 8px;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.topbar {
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  padding: 5px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.bottombar {
  right: auto;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  width: min(calc(100vw - 34px), 1380px);
  min-height: 38px;
  padding: 4px 8px;
  justify-content: center;
  background: transparent;
  border-color: transparent;
  backdrop-filter: none;
  opacity: 0.86;
  transform: translateX(-50%);
  transition: opacity 180ms ease;
}

.chrome-on .topbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.topbar:focus-within {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.chrome-on .bottombar,
.bottombar:hover,
.bottombar:focus-within {
  opacity: 1;
}

.title-block {
  min-width: 0;
  flex: 1;
  line-height: 1.15;
}

.title-block strong,
.title-block span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.title-block strong {
  font-size: 14px;
  font-weight: 700;
}

.title-block span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  color: #fff;
  background: rgba(45, 49, 52, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  cursor: pointer;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}

.icon-button:hover,
.icon-button:focus-visible,
.icon-button.is-active {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.divider {
  flex: 0 0 1px;
  width: 1px;
  height: 24px;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.18);
}

.page-jump {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  min-width: 86px;
  padding: 0 8px;
  color: #fff;
  background: rgba(45, 49, 52, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.18));
}

.page-jump input {
  width: 36px;
  height: 25px;
  color: #fff;
  text-align: center;
  background: rgba(0, 0, 0, 0.16);
  border: 0;
  border-radius: 6px;
  outline: none;
}

.drawer {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  bottom: max(10px, env(safe-area-inset-bottom));
  left: max(10px, env(safe-area-inset-left));
  z-index: 20;
  width: min(320px, calc(100vw - 20px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  color: #fff;
  background: rgba(25, 28, 30, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.3);
  transform: translateX(calc(-100% - 16px));
  transition: transform 220ms ease;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-head strong {
  font-size: 16px;
}

.drawer-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.drawer-search svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: rgba(255, 255, 255, 0.75);
}

.drawer-search input {
  min-width: 0;
  flex: 1;
  color: #fff;
  background: transparent;
  border: 0;
  outline: none;
}

.drawer-search input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.thumb-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.thumb-button {
  display: grid;
  gap: 5px;
  padding: 0;
  color: #fff;
  text-align: center;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.thumb-button img {
  width: 100%;
  aspect-ratio: var(--page-w) / var(--page-h);
  object-fit: fill;
  background: #f7f8fa;
  border: 2px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
}

.thumb-button span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.74);
}

.thumb-button.is-current img,
.thumb-button:focus-visible img {
  border-color: #fff;
  outline: none;
}

.status-pill {
  display: none;
}

.toast {
  position: absolute;
  left: 50%;
  top: max(72px, calc(env(safe-area-inset-top) + 72px));
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 9px 12px;
  color: #fff;
  text-align: center;
  background: rgba(20, 22, 24, 0.86);
  border-radius: 8px;
  transform: translate(-50%, -8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.loader {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  color: #20262a;
  background-color: #e4e7e9;
  background-image: url("assets/background.png");
  background-position: center;
  background-size: cover;
  isolation: isolate;
  transition: opacity 280ms ease, visibility 280ms ease;
}

.loader::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background: rgba(239, 242, 244, 0.96);
}

.loader-visual {
  position: relative;
  width: 72px;
  height: 72px;
  animation: loader-arrive 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.loader-visual img {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(29, 71, 130, 0.2), 0 2px 8px rgba(25, 31, 36, 0.16);
}

.loader-page {
  position: absolute;
  top: 17px;
  right: 7px;
  width: 24px;
  height: 38px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 2px 8px 8px 2px;
  box-shadow: 3px 2px 7px rgba(12, 69, 156, 0.18);
  transform-origin: left center;
  animation: loader-page-turn 1.25s cubic-bezier(0.45, 0, 0.2, 1) infinite;
}

.loader-copy {
  display: grid;
  gap: 6px;
  min-height: 46px;
  text-align: center;
}

.loader-copy strong {
  font-size: 17px;
  line-height: 1.25;
}

.loader-copy span {
  color: #687177;
  font-size: 12px;
  line-height: 1.35;
}

.loader-progress {
  width: min(260px, calc(100vw - 72px));
  height: 4px;
  overflow: hidden;
  background: rgba(38, 48, 55, 0.13);
  border-radius: 2px;
}

.loader-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: #0879e8;
  border-radius: inherit;
  transform: scaleX(0.06);
  transform-origin: left center;
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.loader-retry {
  display: none;
  min-width: 104px;
  height: 36px;
  padding: 0 16px;
  color: #fff;
  font-weight: 700;
  background: #2d3438;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.loader-retry:hover,
.loader-retry:focus-visible {
  background: #15191b;
  outline: 2px solid rgba(8, 121, 232, 0.35);
  outline-offset: 2px;
}

.has-load-error .loader-page {
  display: none;
}

.has-load-error .loader-progress span {
  background: #b6111f;
}

.has-load-error .loader-retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.is-ready .loader {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

@keyframes loader-arrive {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes loader-page-turn {
  0%,
  16% {
    opacity: 0;
    transform: perspective(100px) rotateY(-72deg) translateX(-2px);
  }
  42% {
    opacity: 0.9;
  }
  78%,
  100% {
    opacity: 0;
    transform: perspective(100px) rotateY(72deg) translateX(5px);
  }
}

.app.is-mobile-reader .book-shell {
  width: min(calc(100vw - 12px), calc((100vh - 34px) * var(--page-ratio)), 560px);
  width: min(calc(100vw - 12px), calc((100dvh - 34px) * var(--page-ratio)), 560px);
  aspect-ratio: var(--page-ratio);
}

.app.is-mobile-reader .stage {
  perspective: 1100px;
}

.app.is-mobile-reader .nav-zone {
  width: 18vw;
  min-width: 56px;
  pointer-events: none;
}

.app.is-mobile-reader .topbar {
  left: 8px;
  right: 8px;
  min-height: 38px;
  padding: 4px;
  gap: 5px;
  background: rgba(31, 34, 36, 0.66);
}

.app.is-mobile-reader .title-block strong {
  font-size: 12px;
}

.app.is-mobile-reader .title-block span {
  display: none;
}

.app.is-mobile-reader .icon-button {
  width: 32px;
  height: 32px;
}

.app.is-mobile-reader .icon-button svg {
  width: 18px;
  height: 18px;
}

.app.is-mobile-reader .bottombar {
  width: min(calc(100vw - 16px), 360px);
  min-height: 40px;
  padding: 4px;
  gap: 5px;
  background: rgba(31, 34, 36, 0.68);
}

.app.is-mobile-reader .bottombar .divider,
.app.is-mobile-reader .bottombar [data-action="first"],
.app.is-mobile-reader .bottombar [data-action="last"] {
  display: none;
}

.app.is-mobile-reader .page-jump {
  min-width: 76px;
  height: 32px;
  padding-inline: 5px;
}

.app.is-mobile-reader .page-jump input {
  height: 24px;
}

@media (max-width: 520px) {
  .topbar {
    left: 8px;
    right: 8px;
  }

  .title-block span {
    display: none;
  }

  .bottombar {
    width: calc(100vw - 16px);
    gap: 5px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .bottombar .divider,
  .bottombar [data-action="first"],
  .bottombar [data-action="last"] {
    display: none;
  }

  .page-jump {
    min-width: 80px;
    padding-inline: 6px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .topbar {
    left: max(10px, env(safe-area-inset-left));
    right: auto;
    width: min(420px, calc(100vw - 20px));
  }

  .bottombar {
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
