.fb-book {
  --fb-bg: #050505;
  --fb-surface: #0d0d0f;
  --fb-surface-soft: #18181b;
  --fb-surface-elevated: #212126;
  --fb-border: rgba(255, 255, 255, 0.09);
  --fb-text: #f5f5f5;
  --fb-muted: rgba(245, 245, 245, 0.6);
  --fb-accent: #d4d4d8;
  color: var(--fb-text);
  padding: 20px 0;
}

.fb-book--theme-light {
  --fb-bg: #e8edf3;
  --fb-surface: #ffffff;
  --fb-surface-soft: #f3f4f6;
  --fb-surface-elevated: #e5e7eb;
  --fb-border: rgba(15, 23, 42, 0.08);
  --fb-text: #0f172a;
  --fb-muted: #516074;
  --fb-accent: #3f3f46;
}

.fb-book__header,
.fb-book__app {
  width: min(1240px, calc(100% - 20px));
  margin: 0 auto;
}

.fb-book__header {
  margin-bottom: 12px;
}

.fb-book__header h2 {
  margin-bottom: 10px;
}

.fb-book__intro {
  color: var(--fb-muted);
}

.fb-book__app {
  border: 1px solid var(--fb-border);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--fb-surface) 0%, var(--fb-bg) 100%);
  overflow: hidden;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.34);
}

.fb-book__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--fb-border);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  backdrop-filter: blur(16px);
}

.fb-book__toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.fb-book__toolbar-group--nav,
.fb-book__toolbar-group--utilities {
  min-width: 0;
}

.fb-book__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--fb-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fb-text);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.fb-book__button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.fb-book__button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--fb-accent) 72%, white);
  outline-offset: 2px;
}

.fb-book__button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.fb-book__button--icon {
  width: 42px;
  min-width: 42px;
  padding: 0;
}

.fb-book__button--link {
  text-decoration: none;
}

.fb-book__button--download {
  padding-inline: 14px 16px;
}

.fb-book__page-indicator-shell {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--fb-border);
  background: rgba(255, 255, 255, 0.03);
}

.fb-book__page-indicator-label {
  color: var(--fb-muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fb-book__page-indicator {
  color: var(--fb-text);
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.fb-book__viewport {
  position: relative;
  padding: 14px;
  min-height: 680px;
}

.fb-book__cover-preview {
  margin-bottom: 12px;
}

.fb-book__cover-preview img {
  display: block;
  max-width: min(320px, 100%);
  border-radius: 14px;
  border: 1px solid var(--fb-border);
}

.fb-book__stage {
  position: relative;
  min-height: 640px;
  display: block;
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.04), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(0, 0, 0, 0.18));
  border: 1px solid var(--fb-border);
  overflow: hidden;
  padding: 10px;
}

.fb-book__stage canvas,
.fb-book__stage img,
.fb-book__stage .page {
  max-width: 100%;
  height: auto;
  display: block;
}

.fb-book__pageflip {
  width: 100%;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.25s ease;
}

.fb-book__pageflip .page {
  background: #fff;
}

.fb-book__html-page {
  background: #fff;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.fb-book__html-page-inner,
.fb-book__scroll-page-inner {
  width: 100%;
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.98));
}

.fb-book__html-page-inner canvas,
.fb-book__html-page-inner img,
.fb-book__scroll-page-inner canvas,
.fb-book__scroll-page-inner img {
  width: 100%;
  display: block;
}

.fb-book__html-page-inner canvas,
.fb-book__html-page-inner img {
  height: 100%;
  object-fit: contain;
}

.fb-book__page-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: #475569;
  font-size: 0.92rem;
}

.fb-book__fallback {
  margin-top: 16px;
  color: var(--fb-muted);
}

.fb-book__fallback a {
  color: var(--fb-accent);
}

.fb-book__notice {
  display: inline-flex;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--fb-border);
  color: var(--fb-muted);
}

.fb-book__scroll-pages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}

.fb-book__scroll-page {
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--fb-border);
  background: #fff;
}

.fb-book__scroll-page-inner {
  min-height: 0;
}

.fb-book__scroll-page-inner canvas,
.fb-book__scroll-page-inner img {
  height: auto;
}

.fb-book__scroll-sentinel {
  width: 100%;
  height: 1px;
}

@media (max-width: 900px) {
  .fb-book__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .fb-book__toolbar-group {
    justify-content: space-between;
  }

  .fb-book__viewport {
    min-height: 0;
    padding: 12px;
  }

  .fb-book__stage {
    min-height: 360px;
    padding: 8px;
  }

  .fb-book__pageflip {
    min-height: 320px;
  }
}
