:root {
  color-scheme: dark;
  --bg: #050706;
  --panel: rgba(8, 11, 10, 0.74);
  --panel-solid: #101412;
  --ink: #f6fbf8;
  --muted: #a8b8af;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #35e895;
  --accent-strong: #20c877;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
  --read-progress: 0;
  --scroll-energy: 0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 18% -10%, rgba(53, 232, 149, 0.2), transparent 32rem),
    linear-gradient(180deg, #050706 0%, #0b0f0d 52%, #050706 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

body.is-scrolling {
  --scroll-energy: 1;
}

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

body.is-lightbox-open {
  overflow: hidden;
}

.topbar {
  position: fixed;
  z-index: 20;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  display: grid;
  grid-template-columns: minmax(64px, 1fr) auto minmax(116px, 1fr);
  align-items: center;
  width: min(760px, calc(100vw - 20px));
  min-height: 50px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.brand,
.site-link,
.page-count,
.lang-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand {
  justify-self: start;
  padding: 0 12px;
  letter-spacing: 0.12em;
}

.page-count {
  justify-self: center;
  gap: 2px;
  min-width: 58px;
  justify-content: center;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(53, 232, 149, 0.1);
  font-variant-numeric: tabular-nums;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

body.is-scrolling .page-count {
  box-shadow: 0 0 24px rgba(53, 232, 149, 0.24);
  transform: scale(1.04);
}

.top-actions {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
  min-width: 0;
}

.language-switch {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
}

.lang-button {
  justify-content: center;
  min-width: 34px;
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  cursor: pointer;
}

.lang-button.is-active {
  color: #06120d;
  background: var(--accent);
}

.site-link {
  justify-content: center;
  min-width: 58px;
  padding: 0 12px;
  border-radius: 999px;
  color: #06120d;
  background: var(--accent);
  font-size: 14px;
  box-shadow: 0 0 24px rgba(53, 232, 149, 0.28);
}

.site-link:hover,
.site-link:focus-visible,
.site-button:hover,
.site-button:focus-visible {
  background: #68f3b0;
}

.site-link:focus-visible,
.brand:focus-visible,
.chapter-button:focus-visible,
.page-dot:focus-visible,
.to-top:focus-visible,
.lang-button:focus-visible,
.step-button:focus-visible,
.zoom-button:focus-visible,
.site-button:focus-visible,
.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.read-progress {
  position: fixed;
  z-index: 19;
  top: calc(max(10px, env(safe-area-inset-top)) + 58px);
  left: 50%;
  width: min(720px, calc(100vw - 54px));
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-50%);
}

.read-progress span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #5bb8ff);
  transform: scaleX(var(--read-progress));
  transform-origin: left center;
  box-shadow: 0 0 calc(8px + var(--scroll-energy) * 16px) rgba(53, 232, 149, 0.52);
}

.chapter-rail {
  position: fixed;
  z-index: 18;
  top: calc(max(10px, env(safe-area-inset-top)) + 68px);
  left: 50%;
  display: flex;
  width: min(760px, calc(100vw - 20px));
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 11, 10, 0.68);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.24);
  scrollbar-width: none;
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.chapter-rail::-webkit-scrollbar {
  display: none;
}

.chapter-button {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 13px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font: 800 13px/1 system-ui, "Microsoft YaHei", sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.chapter-button::after {
  position: absolute;
  right: 10px;
  bottom: 5px;
  left: 10px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
  opacity: 0;
  transform: scaleX(0.45);
  transition: opacity 160ms ease, transform 160ms ease;
}

.chapter-button.is-active {
  color: #06120d;
  background: linear-gradient(135deg, var(--accent), #5bb8ff);
  box-shadow: 0 0 24px rgba(53, 232, 149, 0.26);
  transform: translateY(-1px);
}

.chapter-button.is-active::after {
  opacity: 0.68;
  transform: scaleX(1);
}

.brochure {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 128px 0 max(38px, env(safe-area-inset-bottom));
}

.spread {
  position: relative;
  min-height: 120vh;
  scroll-margin-top: 128px;
  opacity: 0.82;
  --glow: 0;
  transition: opacity 180ms ease;
}

.spread:first-child,
.spread.is-visible {
  opacity: 1;
}

.spread + .spread {
  margin-top: 10px;
}

picture,
img {
  display: block;
}

.spread img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  cursor: zoom-in;
  user-select: none;
}

.spread::before,
.spread::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  content: "";
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}

.spread::before {
  background:
    linear-gradient(110deg, transparent 18%, rgba(255, 255, 255, 0.24) 45%, transparent 62%),
    radial-gradient(circle at 50% 10%, rgba(53, 232, 149, 0.22), transparent 36%);
  mix-blend-mode: screen;
  transform: translateX(calc((1 - var(--glow)) * -56%));
  transition: opacity 180ms ease, transform 220ms ease;
}

.spread::after {
  box-shadow:
    inset 0 0 0 1px rgba(53, 232, 149, calc(0.08 + var(--glow) * 0.2)),
    0 0 calc(20px + var(--glow) * 42px) rgba(53, 232, 149, calc(var(--glow) * 0.2));
}

.spread.is-active::before,
.spread.is-active::after {
  opacity: calc(0.12 + var(--glow) * 0.42);
}

.spread.is-active img {
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(53, 232, 149, 0.12);
}

body.is-scrolling .spread.is-active::before {
  opacity: calc(0.18 + var(--glow) * 0.48);
}

.page-dots {
  position: fixed;
  z-index: 18;
  right: max(12px, calc((100vw - 760px) / 2 - 42px));
  top: 50%;
  display: grid;
  gap: 10px;
  padding: 9px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  transform: translateY(-50%);
  backdrop-filter: blur(18px);
}

.page-dot {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.34);
  transition: transform 160ms ease, background 160ms ease, height 160ms ease;
}

.page-dot.is-active {
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
  transform: scale(1.05);
}

.to-top {
  position: fixed;
  z-index: 19;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(84px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: var(--panel);
  font: 800 20px/1 system-ui, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(18px);
}

.to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.quick-actions {
  position: fixed;
  z-index: 19;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 42px 42px auto 42px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.34);
  transform: translateX(-50%) translateY(0);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
  backdrop-filter: blur(18px);
}

.quick-actions.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(18px);
}

.step-button,
.zoom-button,
.site-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.09);
  font: 800 22px/1 system-ui, sans-serif;
  text-decoration: none;
}

.step-button,
.zoom-button {
  width: 38px;
}

.step-button:active,
.zoom-button:active,
.site-button:active {
  transform: scale(0.96);
}

.site-button {
  min-width: 64px;
  padding: 0 16px;
  color: #06120d;
  background: var(--accent);
  font-size: 14px;
}

.lightbox {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: block;
  padding: 0;
  background: rgba(0, 0, 0, 0.94);
  opacity: 0;
  transition: opacity 180ms ease;
  overflow: hidden;
}

.lightbox[hidden] {
  display: none;
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox-scroll {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: max(62px, env(safe-area-inset-top)) 14px max(82px, env(safe-area-inset-bottom));
}

.lightbox-spread {
  width: min(100%, 760px);
  margin: 0 auto;
  scroll-margin-top: max(62px, env(safe-area-inset-top));
}

.lightbox-spread + .lightbox-spread {
  margin-top: 14px;
}

.lightbox img {
  display: block;
  width: min(100%, 760px);
  height: auto;
  border-radius: 10px;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.62);
  user-select: none;
}

.lightbox-close,
.lightbox-nav,
.lightbox-page {
  position: fixed;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(14, 18, 16, 0.78);
  backdrop-filter: blur(18px);
}

.lightbox-close {
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font: 800 26px/1 system-ui, sans-serif;
}

.lightbox-nav {
  bottom: max(18px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 42px;
  height: 44px;
  border-radius: 999px;
  font: 800 28px/1 system-ui, sans-serif;
}

.lightbox-prev {
  left: calc(50% - 92px);
}

.lightbox-next {
  right: calc(50% - 92px);
}

.lightbox-page {
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  min-width: 70px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--accent);
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
}

@media (min-width: 820px) {
  .brochure {
    padding-top: 128px;
    padding-right: 0;
    padding-left: 0;
  }

  .spread {
    min-height: auto;
    border-radius: 14px;
    overflow: hidden;
  }

  .spread img {
    border-radius: 14px;
  }
}

@media (max-width: 819px) {
  .topbar {
    grid-template-columns: auto auto 1fr;
    width: calc(100vw - 18px);
    padding: 7px 8px;
  }

  .brand {
    padding: 0 8px;
    font-size: 14px;
  }

  .page-count {
    min-width: 52px;
    font-size: 14px;
  }

  .top-actions {
    gap: 6px;
  }

  .language-switch {
    gap: 1px;
    padding: 2px;
  }

  .lang-button {
    min-width: 28px;
    min-height: 28px;
    padding: 0 6px;
    font-size: 11px;
  }

  .site-link {
    min-width: 48px;
    padding: 0 10px;
    font-size: 13px;
  }

  .chapter-rail {
    top: calc(max(10px, env(safe-area-inset-top)) + 64px);
    width: calc(100vw - 18px);
    padding: 5px;
  }

  .chapter-button {
    min-height: 30px;
    padding: 0 12px;
    font-size: 12px;
  }

  .brochure {
    padding-top: 124px;
  }

  .spread {
    min-height: auto;
    scroll-margin-top: 124px;
  }

  .page-dots {
    display: none;
  }

  .to-top {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(72px, env(safe-area-inset-bottom));
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .page-dot,
  .to-top,
  .quick-actions,
  .chapter-button,
  .spread,
  .lightbox-spread,
  .lightbox,
  .lightbox-scroll,
  .read-progress span {
    transition: none;
  }

  .spread::before,
  .spread::after {
    display: none;
  }
}
