body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fff;
  color: #1f1f1f;
  overflow: hidden;
}

#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  align-items: center;
  overflow: hidden;
}

.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.25rem 0;
  flex-shrink: 0;
}

.toolbar button {
  padding: 0.25rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
}

.toolbar button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#page-status {
  min-width: 5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#viewer-container {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

#flipbook {
  width: 100%;
  height: 100%;
  background: #f8f9fa;
  border: 1px solid #d1d5db;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#flipbook canvas {
  max-width: 100%;
  max-height: 100%;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  -webkit-font-smoothing: subpixel-antialiased;
  -moz-osx-font-smoothing: auto;
}

#flipbook.single-page-flip {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1rem 0.5rem;
  perspective: 1600px;
}

.single-page-flip-stage {
  position: relative;
  width: min(100%, 560px);
  height: auto;
  max-height: 100%;
  aspect-ratio: var(--page-aspect, 3 / 4);
  transform-style: preserve-3d;
  margin: 0 auto;
}

.single-page-flip-surface {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background-color: #ffffff;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.2);
}

.single-page-flip-surface--current {
  z-index: 2;
}

.single-page-flip-surface--backdrop {
  z-index: 1;
  opacity: 0;
  transition: opacity 160ms ease-out;
}

.single-page-flip-surface--backdrop.is-visible {
  opacity: 1;
}

.single-page-flip-surface--flip {
  z-index: 3;
  transform: rotateY(0deg);
  transform-style: preserve-3d;
  opacity: 0;
  transition: transform 520ms cubic-bezier(0.22, 0.61, 0.36, 1), opacity 140ms ease-out;
}

.single-page-flip-surface--flip.is-active {
  opacity: 1;
}

.single-page-flip-surface--flip.is-flipping-forward {
  transform: rotateY(-180deg);
}

.single-page-flip-surface--flip.is-flipping-backward {
  transform: rotateY(180deg);
}

.single-page-flip-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.single-page-flip-face--back {
  transform: rotateY(180deg);
}
