.flipbook-shell {
  --fb-bg: #f5f7fb;
  --fb-toolbar: #ffffff;
  --fb-text: #101828;
  --fb-accent: #003cfe;
  height: 100vh;
  min-height: 620px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--fb-bg);
  color: var(--fb-text);
}

.embed-container,
.embed-body {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  background: var(--fb-bg, #f5f7fb);
}

.embed-container {
  max-width: none;
}

.flipbook-shell.is-embed {
  min-height: 100vh;
}

.flipbook-toolbar,
.flipbook-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(16, 24, 40, 0.12);
  background: var(--fb-toolbar);
}

.flipbook-controls {
  justify-content: center;
  border-top: 1px solid rgba(16, 24, 40, 0.12);
  border-bottom: 0;
}

.flipbook-title,
.flipbook-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.flipbook-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flipbook-title img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.flipbook-tools button,
.flipbook-tools a,
.flipbook-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 8px;
  background: rgba(0, 60, 254, 0.08);
  color: var(--fb-accent);
  font-size: 14px;
  line-height: 1;
  box-shadow: none;
}

.flipbook-tools a {
  text-decoration: none;
}

.flipbook-tools button:hover,
.flipbook-tools a:hover,
.flipbook-controls button:hover {
  background: var(--fb-accent);
  color: #fff;
  text-decoration: none;
}

.flipbook-body {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.flipbook-thumbs,
.flipbook-search {
  width: 132px;
  height: 100%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px;
  border-right: 1px solid rgba(16, 24, 40, 0.12);
  background: rgba(255, 255, 255, 0.72);
}

.flipbook-search {
  width: 300px;
  border-right: 0;
  border-left: 1px solid rgba(16, 24, 40, 0.12);
}

.flipbook-thumbs button,
.flipbook-search button {
  width: 100%;
  display: grid;
  gap: 6px;
  min-height: auto;
  margin-bottom: 10px;
  padding: 6px;
  border: 1px solid rgba(16, 24, 40, 0.12);
  background: #fff;
  color: var(--fb-text);
  box-shadow: none;
}

.flipbook-thumbs button.active {
  border-color: var(--fb-accent);
  box-shadow: 0 0 0 3px rgba(0, 60, 254, 0.12);
}

.flipbook-thumbs img {
  width: 100%;
  border-radius: 4px;
}

.flipbook-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px 58px;
  overflow: auto;
  overscroll-behavior: contain;
}

.flipbook-spread {
  --fb-zoom: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: fit-content;
  height: fit-content;
  max-width: none;
  max-height: none;
  transform: scale(var(--fb-zoom));
  transform-origin: center;
  transition: transform 150ms ease;
}

.flipbook-spread.turning .flipbook-page {
  transform-style: preserve-3d;
  backface-visibility: hidden;
  animation: fbTurnForward 520ms cubic-bezier(0.22, 0.74, 0.28, 1);
}

.flipbook-spread.turning.turn-back .flipbook-page {
  animation-name: fbTurnBack;
}

@keyframes fbTurnForward {
  0% {
    opacity: 0.28;
    transform: perspective(1300px) rotateY(-24deg) translateX(30px) scale(0.985);
    filter: brightness(0.88);
  }
  58% {
    opacity: 0.94;
    transform: perspective(1300px) rotateY(5deg) translateX(-4px) scale(1.006);
    filter: brightness(1.02);
  }
  100% {
    opacity: 1;
    transform: perspective(1300px) rotateY(0) translateX(0) scale(1);
    filter: brightness(1);
  }
}

@keyframes fbTurnBack {
  0% {
    opacity: 0.28;
    transform: perspective(1300px) rotateY(24deg) translateX(-30px) scale(0.985);
    filter: brightness(0.88);
  }
  58% {
    opacity: 0.94;
    transform: perspective(1300px) rotateY(-5deg) translateX(4px) scale(1.006);
    filter: brightness(1.02);
  }
  100% {
    opacity: 1;
    transform: perspective(1300px) rotateY(0) translateX(0) scale(1);
    filter: brightness(1);
  }
}

@keyframes fbTurnSheen {
  0% {
    opacity: 0.42;
    transform: translateX(-70%);
  }
  45% {
    opacity: 0.26;
  }
  100% {
    opacity: 0;
    transform: translateX(70%);
  }
}

.flipbook-page {
  position: relative;
  flex: 0 0 auto;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(16, 24, 40, 0.22);
  overflow: hidden;
}

.flipbook-page::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.34), rgba(0, 0, 0, 0.08));
}

.flipbook-spread.turning .flipbook-page::after {
  animation: fbTurnSheen 520ms cubic-bezier(0.22, 0.74, 0.28, 1);
}

.flipbook-page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.flipbook-shell.can-click-fullscreen .flipbook-page {
  cursor: zoom-in;
}

.flipbook-shell.can-click-fullscreen:fullscreen .flipbook-page {
  cursor: zoom-out;
}

.flipbook-page figcaption {
  position: absolute;
  z-index: 4;
  right: 8px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(16, 24, 40, 0.72);
  color: #fff;
  font-size: 11px;
}

.flipbook-highlight-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.flipbook-link-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.flipbook-page-link {
  position: absolute;
  display: block;
  border-radius: 3px;
  pointer-events: auto;
  background: rgba(0, 60, 254, 0);
  transition: background 120ms ease, box-shadow 120ms ease;
}

.flipbook-page-link:hover,
.flipbook-page-link:focus-visible {
  background: rgba(0, 60, 254, 0.12);
  box-shadow: 0 0 0 2px rgba(0, 60, 254, 0.18);
  outline: none;
}

.flipbook-text-highlight {
  position: absolute;
  display: block;
  border-radius: 2px;
  background: rgba(255, 230, 0, 0.54);
  box-shadow: 0 0 0 1px rgba(214, 180, 0, 0.2);
  mix-blend-mode: multiply;
}

.flipbook-search mark {
  padding: 0 2px;
  border-radius: 3px;
  background: #ffe600;
  color: inherit;
}

.flipbook-search button {
  text-align: left;
}

.flipbook-search button strong,
.flipbook-search button span {
  display: block;
}

.flipbook-search button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.flipbook-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--fb-accent);
}

.flipbook-nav:hover,
.flipbook-nav:focus-visible {
  background: var(--fb-accent);
  color: #fff;
}

.flipbook-nav:hover i,
.flipbook-nav:focus-visible i {
  color: #fff;
}

.flipbook-nav.prev { left: 14px; }
.flipbook-nav.next { right: 14px; }

.flipbook-controls input {
  width: 72px;
  min-height: 34px;
  padding: 6px 8px;
  text-align: center;
}

.flipbook-share {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, 0.42);
}

.flipbook-share[hidden],
.flipbook-search[hidden] {
  display: none;
}

.flipbook-share > div {
  position: relative;
  width: min(460px, 100%);
  padding: 24px;
  border-radius: 8px;
  background: #fff;
}

.flipbook-share button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
}

.flipbook-lock {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f5f7fb;
}

.flipbook-empty {
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 760px) {
  .flipbook-shell {
    min-height: 100vh;
  }

  .flipbook-toolbar {
    align-items: flex-start;
  }

  .flipbook-tools {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .flipbook-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .flipbook-thumbs {
    display: none;
  }

  .flipbook-search {
    width: 100%;
    max-height: 220px;
    border-left: 0;
    border-bottom: 1px solid rgba(16, 24, 40, 0.12);
  }

  .flipbook-stage {
    padding: 16px 48px;
  }

  .flipbook-spread {
    width: 100%;
  }

  .flipbook-controls {
    position: sticky;
    bottom: 0;
    flex-wrap: wrap;
  }
}
