:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --panel: #141414;
  --panel-2: #1a1a1a;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f0f0f0;
  --muted: rgba(240, 240, 240, 0.65);
  --accent: #8b5cf6;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app {
  width: min(1100px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.app--embed {
  width: 100vw;
  min-height: 100vh;
  padding: 16px;
}

.app--viewing .hero,
.app--viewing .toolbar,
.app--viewing .state {
  display: none;
}

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.hero p {
  max-width: 65ch;
  color: var(--muted);
}

.toolbar {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.field input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 14px 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.actions button, .pager button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 16px;
}

.actions button:hover, .pager button:hover {
  border-color: color-mix(in srgb, var(--accent) 60%, white 40%);
}

.actions button:disabled, .pager button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.state {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
}

.state--error {
  color: #fecaca;
}

.viewer {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel);
}

.book {
  position: relative;
  max-width: 1000px;
  height: min(74vh, 840px);
  margin: 0 auto;
  perspective: 1800px;
  touch-action: pan-y;
}

.book__spread {
  position: relative;
  width: 100%;
  height: 100%;
}

.page {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  border-radius: 18px;
  background-color: #fff;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.page--left {
  left: 0;
  transform-origin: right center;
}

.page--right {
  right: 0;
  transform-origin: left center;
}

.sheet {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 5;
}

.sheet--next {
  left: 50%;
  transform-origin: left center;
  transform: rotateY(0deg);
}

.sheet--next.sheet--animate {
  transform: rotateY(-180deg);
}

.sheet--prev {
  left: 0;
  transform-origin: right center;
  transform: rotateY(180deg);
}

.sheet--prev.sheet--animate {
  transform: rotateY(0deg);
}

.sheet__face {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background-color: #fff;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  backface-visibility: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

.sheet__face--back {
  transform: rotateY(180deg);
}

.book__hotspot {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  border: 0;
  background: transparent;
  z-index: 10;
}

.book__hotspot:disabled {
  cursor: not-allowed;
}

.book__hotspot--prev {
  left: 0;
}

.book__hotspot--next {
  right: 0;
}

.pager {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pager span {
  color: var(--muted);
}

.dots {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 255, 255, 0.28);
}

.dot--active {
  background: var(--accent);
  transform: scale(1.15);
}

@media (max-width: 720px) {
  .book {
    height: 62vh;
  }

  .page {
    width: 100%;
  }

  .page--left, .page--right {
    display: none;
  }

  .book__hotspot {
    width: 50%;
  }
}
