:root {
  color-scheme: dark;

  --bg: #101827;
  --panel: rgba(14, 23, 38, 0.90);
  --paper: #f6f0e4;
  --accent: #e8b55c;
  --text: #f7f8fb;
  --muted: #aeb9cb;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background:
    radial-gradient(
      circle at 50% 20%,
      #263858 0%,
      #101827 45%,
      #070c15 100%
    );
  color: var(--text);
}

button {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.08);
  color: white;
  border-radius: 14px;
  padding: 12px 17px;
  font-size: 15px;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background 150ms ease;
}

button:hover {
  background: rgba(255,255,255,0.14);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

button.primary {
  background: var(--accent);
  color: #18202b;
  font-weight: 800;
}

.hidden {
  display: none !important;
}


/* HOME */

.welcome-screen {
  height: 100%;
  display: grid;
  place-items: center;
  padding: 4vh 4vw;
}

.welcome-card {
  width: min(1100px, 94vw);
  max-height: 90vh;
  display: grid;
  grid-template-columns:
    minmax(280px, 0.8fr)
    minmax(360px, 1.2fr);
  gap: 42px;
  align-items: center;
  padding: 34px;
  border-radius: 30px;
  background: var(--panel);
  box-shadow:
    0 35px 100px rgba(0,0,0,0.5);
  backdrop-filter: blur(20px);
}

.cover {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 22px;
  box-shadow:
    0 28px 55px rgba(0,0,0,0.45);
}

.eyebrow {
  color: var(--accent);
  letter-spacing: 0.20em;
  font-size: 12px;
  font-weight: 900;
}

h1 {
  max-width: 630px;
  margin:
    7px 0
    18px;
  font-size:
    clamp(
      32px,
      4vw,
      58px
    );
  line-height: 1.04;
}

.intro {
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 18px;
}

.welcome-actions {
  display: grid;
  gap: 11px;
}

.welcome-settings {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}


/* READER */

.reader-screen {
  height: 100%;
  display: grid;
  grid-template-rows:
    auto
    1fr
    auto;
}

.reader-toolbar,
.reader-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding:
    13px
    20px;
  background: rgba(4, 9, 16, 0.72);
  backdrop-filter: blur(16px);
  z-index: 20;
}

.reader-title {
  font-weight: 750;
}

.reader-actions,
.transport {
  display: flex;
  gap: 8px;
}

.reading-stage {
  min-height: 0;
  display: grid;
  grid-template-columns:
    72px
    1fr
    72px;
  align-items: center;
  padding:
    20px
    10px;
  perspective: 3000px;
}

.edge-button {
  width: 56px;
  height: 92px;
  padding: 0;
  border-radius: 28px;
  font-size: 48px;
  z-index: 10;
}

.book {
  position: relative;
  width: min(
    1400px,
    calc(100vw - 180px)
  );
  aspect-ratio: 2 / 1;
  margin: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  filter:
    drop-shadow(
      0 32px 48px
      rgba(0,0,0,0.55)
    );
  transform-style: preserve-3d;
}

.page {
  position: relative;
  overflow: hidden;
  background: var(--paper);
}

.left-page {
  border-radius:
    20px
    3px
    3px
    20px;
}

.right-page {
  border-radius:
    3px
    20px
    20px
    3px;
}

.page img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: var(--paper);
}

.empty-page {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      110deg,
      #f8f3e8,
      #e7ddca
    );
}

.binding {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 28px;
  z-index: 8;
  transform: translateX(-50%);
  pointer-events: none;
  background:
    linear-gradient(
      90deg,
      rgba(0,0,0,0.34),
      rgba(255,255,255,0.05),
      rgba(0,0,0,0.30)
    );
  box-shadow:
    0 0 24px
    rgba(0,0,0,0.35);
}

.book-shadow {
  position: absolute;
  inset:
    2%
    -2%
    -4%;
  border-radius: 26px;
  background: rgba(0,0,0,0.35);
  filter: blur(24px);
  transform: translateZ(-20px);
}

.audio-active {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  box-shadow:
    inset 0 0 0 5px
    rgba(232,181,92,0.82),
    inset 0 0 50px
    rgba(232,181,92,0.18);
  transition: opacity 250ms ease;
}

.audio-active.active {
  opacity: 1;
}


/* Page-turn sheet */

.turn-sheet {
  position: absolute;
  left: 50%;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 15;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,0.94),
      rgba(242,235,220,0.98)
    );
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  border-radius:
    3px
    20px
    20px
    3px;
}

.turn-sheet.turn-next {
  opacity: 1;
  animation:
    turnNext
    720ms
    cubic-bezier(.42,.02,.20,1)
    forwards;
}

.turn-sheet.turn-prev {
  opacity: 1;
  transform-origin: left center;
  animation:
    turnPrev
    720ms
    cubic-bezier(.42,.02,.20,1)
    forwards;
}

@keyframes turnNext {
  from {
    transform:
      rotateY(0deg);
    box-shadow:
      -6px 0 18px
      rgba(0,0,0,0.15);
  }

  50% {
    box-shadow:
      -35px 5px 45px
      rgba(0,0,0,0.50);
  }

  to {
    transform:
      rotateY(-180deg);
    box-shadow:
      -3px 0 8px
      rgba(0,0,0,0.10);
  }
}

@keyframes turnPrev {
  from {
    transform:
      rotateY(-180deg);
  }

  to {
    transform:
      rotateY(0deg);
  }
}

.reader-footer {
  color: var(--muted);
}

#status {
  min-width: 220px;
}

#pageIndicator {
  min-width: 150px;
  text-align: right;
}


@media (max-width: 850px) {
  .welcome-card {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .cover {
    max-width: 360px;
    margin: auto;
  }

  .reader-title {
    display: none;
  }

  .reading-stage {
    grid-template-columns:
      44px
      1fr
      44px;
  }

  .edge-button {
    width: 40px;
    height: 70px;
    font-size: 34px;
  }

  .book {
    width:
      calc(
        100vw - 105px
      );
  }

  .reader-footer {
    font-size: 13px;
  }
}


/* ==========================================================
   Reading mode selector
   ========================================================== */

.reading-mode-list {
  display: grid;
  gap: 12px;
}

.reading-mode-card {
  width: 100%;
  min-height: 82px;

  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 14px;
  align-items: center;

  padding: 15px 18px;

  text-align: left;

  background:
    rgba(255, 255, 255, 0.065);
}

.reading-mode-card:hover {
  background:
    rgba(255, 255, 255, 0.13);
}

.reading-mode-card.primary-mode {
  border-color:
    rgba(232, 181, 92, 0.60);

  background:
    rgba(232, 181, 92, 0.11);
}

.mode-icon {
  display: grid;
  place-items: center;

  font-size: 31px;
}

.mode-copy {
  display: grid;
  gap: 4px;
}

.mode-copy strong {
  font-size: 18px;
}

.mode-copy small {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.welcome-actions-secondary {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
