:root {
  --app-height: 100vh;
  --bg: #0f0f0f;
  --surface: rgba(12, 12, 12, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.05);
  --border: rgba(50, 139, 177, 0.26);
  --text: #ffffff;
  --accent: #328bb1;
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Poppins", Arial, Helvetica, sans-serif;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button {
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

.grid-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 80px 80px;
  animation: moveGrid 40s linear infinite;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    rgba(0, 0, 0, 0) 38%,
    rgba(0, 0, 0, 0.72) 100%
  );
}

@keyframes moveGrid {
  from {
    background-position: 0 0, 0 0;
  }

  to {
    background-position: 800px 800px, 800px 800px;
  }
}

.reader-app,
.flipbook-section {
  width: 100%;
  height: var(--app-height);
  min-height: var(--app-height);
  overflow: hidden;
}

.viewer-card {
  position: relative;
  width: 100%;
  height: var(--app-height);
  overflow: hidden;
  border: 1px solid rgba(50, 139, 177, 0.14);
  background: linear-gradient(180deg, rgba(17, 17, 17, 0.84), rgba(10, 10, 10, 0.97));
  box-shadow: var(--shadow);
}

.viewer-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top center, rgba(50, 139, 177, 0.12), transparent 34%),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  pointer-events: none;
}

.floating-tools,
.pager,
.book-viewport,
.corner-button {
  position: relative;
  z-index: 1;
}

.floating-tools {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: flex;
  gap: 10px;
}

.tool-button,
.pager-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.25s ease,
    border-color 0.25s ease,
    background 0.25s ease,
    box-shadow 0.25s ease,
    color 0.25s ease;
}

.tool-button:hover,
.pager-button:hover {
  transform: translateY(-2px);
}

.tool-button {
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 999px;
  color: #f4fbff;
  font-size: 0.92rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 10, 10, 0.9);
}

.tool-button-primary {
  color: var(--accent);
  border-color: rgba(50, 139, 177, 0.68);
  box-shadow:
    0 0 14px rgba(50, 139, 177, 0.35),
    inset 0 0 10px rgba(50, 139, 177, 0.14);
}

.tool-button-primary:hover,
.pager-button:hover {
  background: rgba(50, 139, 177, 0.12);
}

.tool-button:disabled,
.pager-button:disabled {
  cursor: not-allowed;
  transform: none;
  opacity: 0.4;
  box-shadow: none;
}

.book-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 18px 18px 92px;
  background:
    radial-gradient(circle at top center, rgba(50, 139, 177, 0.08), transparent 38%),
    linear-gradient(180deg, rgba(15, 15, 15, 0.7), rgba(7, 7, 7, 0.97));
}

.book-viewport::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.flipbook-host {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.flipbook-mount {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px 16px 64px;
}

.pager {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(-50%);
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(50, 139, 177, 0.3);
  background: rgba(10, 10, 10, 0.92);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.corner-button {
  position: absolute;
  bottom: 16px;
  z-index: 5;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  color: #f4fbff;
  font-size: 0.92rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 10, 10, 0.92);
  box-shadow:
    0 0 14px rgba(50, 139, 177, 0.22),
    inset 0 0 10px rgba(50, 139, 177, 0.08);
}

.corner-button:hover {
  transform: translateY(-2px);
  background: rgba(50, 139, 177, 0.12);
}

.corner-button:disabled {
  cursor: not-allowed;
  transform: none;
  opacity: 0.4;
  box-shadow: none;
}

.corner-button-left {
  left: 16px;
}

.corner-button-right {
  right: 16px;
}

.pager-button {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  color: var(--accent);
  font-size: 1.4rem;
  line-height: 1;
  border: 1px solid rgba(50, 139, 177, 0.6);
  background: rgba(255, 255, 255, 0.03);
  box-shadow:
    0 0 14px rgba(50, 139, 177, 0.26),
    inset 0 0 10px rgba(50, 139, 177, 0.12);
}

.page-pill {
  min-width: 116px;
  padding: 0 8px;
  text-align: center;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}

.state-card {
  position: absolute;
  z-index: 6;
  display: grid;
  place-items: center;
  width: min(460px, calc(100% - 40px));
  min-height: 132px;
  padding: 20px 24px;
  text-align: center;
  color: #f4fbff;
  border-radius: 24px;
  border: 1px solid rgba(50, 139, 177, 0.28);
  background: rgba(10, 10, 10, 0.92);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

.state-error {
  border-color: rgba(251, 113, 133, 0.35);
  color: #ffe4ea;
  background: rgba(57, 11, 18, 0.95);
}

.state-card[hidden] {
  display: none !important;
}

.stf__wrapper {
  margin: 0 auto;
  filter: drop-shadow(0 26px 40px rgba(0, 0, 0, 0.4));
}

.stf__block {
  overflow: visible;
  border-radius: 0;
}

.flipbook-host .stf__parent {
  transition: transform 0.28s ease;
}

.flipbook-host[data-book-state="front-cover"] .stf__parent {
  transform: translate3d(-25%, 0, 0);
}

.flipbook-host[data-book-state="back-cover"] .stf__parent {
  transform: translate3d(25%, 0, 0);
}

.stf__item,
.stf__item img {
  background: #ffffff;
}

.page-sheet {
  width: 100%;
  height: 100%;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.22);
  outline: 1px solid rgba(50, 139, 177, 0.28);
  outline-offset: -1px;
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  border-radius: 0;
}

.page-sheet img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  background: #ffffff;
  border-radius: 0;
}

@media (max-width: 720px) {
  .floating-tools {
    top: 12px;
    right: 12px;
    flex-direction: column;
    align-items: flex-end;
  }

  .tool-button {
    min-height: 42px;
    padding: 10px 14px;
    font-size: 0.84rem;
  }

  .book-viewport {
    padding: 92px 8px 92px;
  }

  .flipbook-mount {
    padding: 16px 10px 62px;
  }

  .pager {
    bottom: 10px;
    gap: 8px;
    padding: 8px;
  }

  .corner-button {
    bottom: 10px;
    min-height: 42px;
    padding: 10px 14px;
    font-size: 0.84rem;
  }

  .corner-button-left {
    left: 10px;
  }

  .corner-button-right {
    right: 10px;
  }

  .pager-button {
    width: 42px;
    height: 42px;
  }

  .page-pill {
    min-width: 90px;
    font-size: 0.92rem;
  }
}
