:root {
  color-scheme: light;
  --bg: #eef1f5;
  --paper: #ffffff;
  --ink: #101318;
  --muted: #68727f;
  --line: rgba(16, 19, 24, 0.12);
  --blue: #155bff;
  --cyan: #2fc8d7;
  --shadow: 0 24px 80px rgba(18, 28, 45, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    linear-gradient(rgba(16, 19, 24, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 19, 24, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 18% 0%, rgba(47, 200, 215, 0.18), transparent 26rem),
    radial-gradient(circle at 88% 16%, rgba(21, 91, 255, 0.11), transparent 28rem),
    var(--bg);
  background-size: 64px 64px, 64px 64px, auto, auto, auto;
  color: var(--ink);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

a,
button {
  color: inherit;
  font: inherit;
}

a {
  text-decoration: none;
}

button {
  cursor: pointer;
}

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 100%;
  height: 3px;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.deck-toolbar {
  position: fixed;
  top: 14px;
  left: 50%;
  z-index: 90;
  width: min(1320px, calc(100% - 28px));
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 9px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 58px rgba(18, 28, 45, 0.12);
  backdrop-filter: blur(20px);
}

.deck-brand {
  display: grid;
  gap: 2px;
  min-width: 142px;
  padding: 0 10px;
}

.deck-brand strong {
  font-size: 1rem;
  line-height: 1.15;
}

.deck-brand span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.chapter-nav {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px;
  scrollbar-width: none;
}

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

.chapter-nav a,
.download-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.chapter-nav a {
  padding: 0 12px;
  color: #4d5867;
}

.chapter-nav a:hover,
.chapter-nav a.is-active {
  background: rgba(21, 91, 255, 0.1);
  color: var(--blue);
}

.download-link {
  padding: 0 16px;
  background: var(--ink);
  color: white;
}

.deck-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 92px 20px 88px;
}

.slide-stack {
  position: relative;
  width: min(1280px, calc(100vw - 40px));
  height: calc(min(1280px, calc(100vw - 40px)) * 0.5622);
  max-height: calc(100vh - 190px);
}

.slide-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px) scale(0.992);
  transition:
    opacity 220ms ease,
    transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.slide-frame.is-current {
  z-index: 2;
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0) scale(1);
}

.slide-frame img {
  width: 100%;
  height: 100%;
  display: block;
  overflow: hidden;
  border: 1px solid rgba(16, 19, 24, 0.1);
  border-radius: 8px;
  background: var(--paper);
  object-fit: contain;
  box-shadow: var(--shadow);
}

.slide-frame figcaption {
  position: absolute;
  right: 14px;
  bottom: -16px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(16, 19, 24, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #4d5867;
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: 0 12px 32px rgba(18, 28, 45, 0.12);
  backdrop-filter: blur(14px);
}

.deck-controls {
  position: fixed;
  bottom: 18px;
  left: 50%;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(-50%);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 46px rgba(18, 28, 45, 0.14);
  backdrop-filter: blur(18px);
}

.flip-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
}

.flip-button:disabled {
  cursor: default;
  opacity: 0.32;
}

.page-readout {
  min-width: 94px;
  display: flex;
  justify-content: center;
  gap: 5px;
  color: #3f4a59;
  font-size: 1.1rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .deck-toolbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .chapter-nav {
    grid-column: 1 / -1;
    order: 3;
  }

  .deck-stage {
    padding-top: 130px;
  }

  .slide-stack {
    max-height: calc(100vh - 238px);
  }
}

@media (max-width: 560px) {
  .deck-toolbar {
    top: 8px;
    width: calc(100% - 16px);
    gap: 8px;
  }

  .deck-brand span {
    display: none;
  }

  .download-link {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.8rem;
  }

  .chapter-nav a {
    min-height: 34px;
    padding: 0 10px;
    font-size: 0.8rem;
  }

  .deck-stage {
    padding: 122px 10px 82px;
  }

  .slide-stack {
    width: calc(100vw - 20px);
    height: calc((100vw - 20px) * 0.5622);
    max-height: calc(100vh - 232px);
  }

  .slide-frame img {
    border-radius: 6px;
  }

  .slide-frame figcaption {
    right: 8px;
    bottom: -14px;
    min-height: 28px;
    font-size: 0.72rem;
  }

  .deck-controls {
    bottom: 12px;
    gap: 8px;
    padding: 7px;
  }

  .flip-button {
    width: 44px;
    height: 44px;
    font-size: 1.8rem;
  }

  .page-readout {
    min-width: 78px;
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slide-frame {
    transition: none;
  }
}

@media print {
  body {
    height: auto;
    overflow: visible;
    background: white;
  }

  .deck-toolbar,
  .progress-bar,
  .deck-controls,
  .slide-frame figcaption {
    display: none;
  }

  .deck-stage {
    display: block;
    height: auto;
    padding: 0;
  }

  .slide-stack {
    width: 100%;
    height: auto;
    max-height: none;
  }

  .slide-frame {
    position: static;
    width: 100%;
    height: auto;
    opacity: 1;
    transform: none;
    page-break-after: always;
  }

  .slide-frame img {
    width: 100%;
    height: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}
