:root {
  color-scheme: dark;
  --bg-0: #0d0e11;
  --bg-1: #16181d;
  --bg-2: #20242a;
  --shadow: rgba(0, 0, 0, 0.34);
  --frame-shadow: rgba(0, 0, 0, 0.42);
  --page-size: min(68vmin, calc(100vh - 2rem), calc((100vw - 2rem) / 2));
  --spread-width: calc(var(--page-size) * 2);
  --spread-height: var(--page-size);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.06), transparent 35%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 38%, var(--bg-0) 100%);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  min-height: 100vh;
  overflow: hidden;
  color: #f6f7f8;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.booklet-app {
  width: 100%;
  min-height: calc(100vh - 2rem);
  display: grid;
  place-items: center;
}

.error-message {
  max-width: 34rem;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(17, 18, 21, 0.88);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  line-height: 1.45;
}

.debug-panel {
  position: fixed;
  left: 0.75rem;
  bottom: 0.75rem;
  z-index: 9999;
  margin: 0;
  padding: 0.65rem 0.8rem;
  max-width: min(34rem, calc(100vw - 1.5rem));
  white-space: pre-wrap;
  font: 12px/1.35 Consolas, "Courier New", monospace;
  color: #dfe6ee;
  background: rgba(10, 12, 15, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.booklet-frame {
  width: var(--spread-width);
  height: var(--spread-height);
  display: grid;
  place-items: center;
  position: relative;
  user-select: none;
}

.booklet-viewport {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: visible;
  filter: drop-shadow(0 30px 50px var(--frame-shadow));
}

.booklet-source {
  display: none;
}

.page-sheet {
  width: 100%;
  height: 100%;
  background: #0c0d10;
  overflow: hidden;
}

.page-sheet img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
}

.page-sheet-spacer {
  background: transparent;
  box-shadow: none;
}

.stf__block {
  box-shadow: none;
  transform: translateX(-50%) !important;
  transform-origin: center center !important;
}

.page-sheet-spacer.stf__item,
.page-sheet-spacer .stf__item,
.stf__item.page-sheet-spacer {
  background: transparent;
  box-shadow: none;
}

.stf__item {
  background: #0c0d10;
}

@media (max-width: 767px) {
  :root {
    --page-size: min(calc(100vw - 0.8rem), calc(100vh - 0.8rem));
    --spread-width: var(--page-size);
    --spread-height: var(--page-size);
  }

  .app-shell {
    padding: 0.4rem;
  }

  .booklet-app {
    min-height: 100vh;
  }
}
