
:root {
  --bg: #ece5d6;
  --bg-accent: #c7baa0;
  --panel: rgba(255, 250, 242, 0.78);
  --text: #2a221a;
  --muted: #7c6954;
  --shadow: rgba(44, 31, 18, 0.2);
  --page-shadow: rgba(28, 19, 10, 0.22);
  --button: #2f5d50;
  --button-hover: #23473d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 35%),
    linear-gradient(135deg, var(--bg), var(--bg-accent));
}

body {
  min-height: 100vh;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.35rem;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 1.25rem;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 20px 45px -24px var(--shadow);
}

.status {
  min-width: 4.5rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--muted);
}

.viewer {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.35rem;
  min-height: 0;
}

.viewer-panel {
  min-height: 0;
  height: 100%;
  display: grid;
  place-items: center;
}

.spread-shell {
  position: relative;
  width: min(98vw, 1400px);
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

.spread {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  align-items: center;
  justify-items: stretch;
}

.spread.is-single {
  grid-template-columns: minmax(0, 1fr);
  max-width: min(49vw, 760px);
  margin: 0 auto;
}

.page-card {
  width: 100%;
  max-width: none;
  height: min(100%, calc(100vh - 6rem));
  border-radius: 0;
  background: rgba(255, 252, 247, 0.7);
  box-shadow:
    0 22px 60px -28px var(--page-shadow),
    0 4px 10px rgba(255, 255, 255, 0.65) inset;
  overflow: hidden;
}

.spread:not(.is-single) .page-card:first-child {
  justify-self: end;
  border-radius: 0.75rem 0 0 0.75rem;
}

.spread:not(.is-single) .page-card:last-child {
  justify-self: start;
  border-radius: 0 0.75rem 0.75rem 0;
}

.page-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.page-card.placeholder {
  height: min(100%, calc(100vh - 6rem));
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.48), transparent 42%),
    rgba(244, 237, 224, 0.75);
}

.nav-button,
.toolbar button {
  border: 0;
  border-radius: 999px;
  background: var(--button);
  color: white;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.nav-button:hover,
.toolbar button:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
}

.nav-button:disabled,
.toolbar button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.nav-button {
  width: 3rem;
  height: 3rem;
  font-size: 1.35rem;
  box-shadow: 0 16px 28px -18px var(--shadow);
}

.toolbar {
  flex-wrap: wrap;
}

.toolbar button {
  padding: 0.75rem 1rem;
  font: inherit;
}

#page-slider {
  width: min(320px, 58vw);
  accent-color: var(--button);
}

@media (max-width: 900px) {
  .viewer {
    grid-template-columns: 1fr;
  }

  .nav-button {
    display: none;
  }

  .viewer-panel {
    min-height: auto;
  }

  .spread,
  .spread.is-single {
    grid-template-columns: minmax(0, 1fr);
    max-width: min(99vw, 900px);
  }

  .toolbar {
    padding: 0.7rem 0.85rem;
  }

  .spread .page-card.placeholder {
    display: none;
  }

  .toolbar {
    gap: 0.75rem;
  }

  .status {
    width: 100%;
    order: -1;
  }

  #page-slider {
    width: min(88vw, 520px);
  }

  .page-card,
  .page-card.placeholder {
    height: calc(100vh - 8.5rem);
  }
}
