:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #677483;
  --line: #d8e1e8;
  --paper: #eef2f4;
  --surface: #ffffff;
  --red: #c9151e;
  --green: #0d6b4d;
  --blue: #245b8f;
  --shadow: 0 18px 58px rgba(23, 32, 42, .16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(180deg, #f8fafb 0%, var(--paper) 42%, #e7ecef 100%);
}

button,
a,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

img {
  display: block;
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 70px;
  padding: 10px clamp(14px, 4vw, 34px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid rgba(216, 225, 232, .9);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-photo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #dde5e9;
}

.brand-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand strong,
.brand small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions,
.reader-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.download-button {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  cursor: pointer;
}

.icon-button {
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.download-button {
  padding: 0 14px;
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  font-weight: 700;
}

.book-layout {
  display: grid;
  grid-template-columns: minmax(280px, .78fr) minmax(320px, 520px);
  gap: clamp(22px, 5vw, 70px);
  align-items: center;
  width: min(1120px, 100%);
  min-height: calc(100svh - 70px);
  margin: 0 auto;
  padding: clamp(22px, 5vw, 58px) clamp(16px, 4vw, 34px);
}

.book-info {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--red);
  font-size: 14px;
  font-weight: 800;
}

h1 {
  max-width: 8em;
  margin: 0 0 26px;
  font-size: clamp(42px, 8vw, 78px);
  line-height: 1.02;
  letter-spacing: 0;
}

.chapter-list {
  display: grid;
  gap: 10px;
  max-width: 430px;
}

.chapter-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, .86);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.chapter-card span {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #fff;
  background: var(--blue);
  border-radius: 50%;
  font-weight: 800;
}

.chapter-card strong,
.chapter-card small {
  min-width: 0;
}

.chapter-card small {
  color: var(--muted);
  font-size: 13px;
}

.chapter-card.active {
  border-color: rgba(201, 21, 30, .34);
  box-shadow: 0 12px 36px rgba(201, 21, 30, .12);
}

.chapter-card.active span {
  background: var(--red);
}

.phone-reader {
  position: relative;
  width: min(100%, 480px);
  margin: 0 auto;
  overflow: hidden;
  background: #111820;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 30px;
  box-shadow: var(--shadow);
}

.phone-reader::before {
  content: "";
  display: block;
  height: 22px;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .35) 0 3px, transparent 4px),
    #111820;
}

.reader-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 10px 14px;
  color: #fff;
  background: #17202a;
}

.reader-top span,
.reader-top strong {
  display: block;
}

.reader-top span {
  color: rgba(255, 255, 255, .72);
  font-size: 13px;
}

.reader-top strong {
  margin-top: 3px;
  font-size: 18px;
}

.reader-top .icon-button {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border-color: rgba(255, 255, 255, .18);
}

.book-viewport {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(66svh, 720px);
  padding: 14px;
  perspective: 1400px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .04), transparent 22%, transparent 78%, rgba(0, 0, 0, .2)),
    #28323a;
}

.book-page {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: min(60svh, 650px);
  overflow: hidden;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, .34);
  transform-origin: left center;
}

.book-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, .14), transparent 12%, transparent 88%, rgba(0, 0, 0, .08));
  opacity: .42;
}

.book-page img {
  width: 100%;
  height: min(60svh, 650px);
  object-fit: contain;
  background: #fff;
}

.book-page.turn-next {
  animation: turnNext .36s ease both;
}

.book-page.turn-prev {
  animation: turnPrev .36s ease both;
}

.reader-bottom {
  padding: 12px 14px 16px;
  background: #17202a;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--red);
}

.thumb-strip {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 3px;
}

.thumb {
  position: relative;
  width: 56px;
  height: 74px;
  flex: 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 7px;
  background: #e9eef0;
  cursor: pointer;
}

.thumb.active {
  border-color: var(--red);
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb span {
  position: absolute;
  right: 4px;
  bottom: 4px;
  min-width: 20px;
  padding: 2px 5px;
  color: #fff;
  background: rgba(23, 32, 42, .78);
  border-radius: 999px;
  font-size: 11px;
}

.qr-dialog {
  width: min(92vw, 380px);
  padding: 22px;
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.qr-dialog::backdrop {
  background: rgba(14, 24, 34, .55);
}

.qr-dialog h2 {
  margin: 0 34px 16px 0;
  font-size: 22px;
}

.qr-dialog img {
  width: min(100%, 280px);
  margin: 0 auto;
}

.qr-dialog p {
  overflow-wrap: anywhere;
  margin: 16px 0 0;
  color: var(--muted);
  text-align: center;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

@keyframes turnNext {
  0% {
    opacity: .52;
    transform: rotateY(-18deg) translateX(12px);
  }

  100% {
    opacity: 1;
    transform: rotateY(0) translateX(0);
  }
}

@keyframes turnPrev {
  0% {
    opacity: .52;
    transform: rotateY(18deg) translateX(-12px);
  }

  100% {
    opacity: 1;
    transform: rotateY(0) translateX(0);
  }
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
  }

  .brand {
    max-width: calc(100vw - 178px);
  }

  .download-button {
    width: 42px;
    padding: 0;
    overflow: hidden;
    color: transparent;
  }

  .download-button::before {
    content: "↓";
    color: #fff;
    font-size: 22px;
  }

  .book-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 22px;
  }

  .book-info {
    order: 2;
  }

  h1 {
    max-width: 9em;
    margin-bottom: 18px;
    font-size: 38px;
  }

  .phone-reader {
    order: 1;
    border-radius: 22px;
  }

  .book-viewport {
    min-height: 56svh;
    padding: 10px;
  }

  .book-page {
    min-height: 52svh;
  }

  .book-page img {
    height: 52svh;
  }

  .chapter-list {
    max-width: none;
  }
}

@media (max-width: 460px) {
  .top-actions {
    gap: 6px;
  }

  .icon-button,
  .download-button {
    min-width: 38px;
    height: 38px;
  }

  .brand-photo {
    width: 42px;
    height: 42px;
  }

  .brand strong {
    max-width: 150px;
  }

  .reader-top {
    min-height: 60px;
  }

  .chapter-card {
    grid-template-columns: 40px minmax(0, 1fr) auto;
  }
}
