:root {
  --bg-0: #f4f7ee;
  --bg-1: #dce8ff;
  --bg-2: #fff3d9;
  --ink: #122025;
  --ink-soft: #415863;
  --card: rgba(255, 255, 255, 0.75);
  --stroke: rgba(18, 32, 37, 0.16);
  --accent: #ef5d2f;
  --accent-strong: #d44e25;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

html {
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  font-family: Manrope, "Segoe UI", sans-serif;
  color: var(--ink);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 14% 18%, rgba(255, 255, 255, 0.26) 0%, transparent 36%),
    radial-gradient(circle at 86% 24%, rgba(255, 255, 255, 0.2) 0%, transparent 40%),
    linear-gradient(145deg, #ef5d2f 0%, #f9ae42 100%);
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1rem 2.5rem;
  display: grid;
  gap: 1rem;
}

.hero {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 1.05rem 1.25rem;
  backdrop-filter: blur(6px);
  animation: lift-in 520ms ease;
}

h1 {
  margin: 0.4rem 0;
  font-size: clamp(1.5rem, 3.5vw, 2.5rem);
  line-height: 1.08;
}

.subheading {
  margin: 0;
  color: var(--ink-soft);
  max-width: 70ch;
}

.controls {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  padding: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  animation: lift-in 620ms ease;
}

.file-label,
.btn {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 0.56rem 0.9rem;
  font-weight: 700;
  background: #fff;
}

.file-label {
  cursor: pointer;
}

#pdfInput {
  max-width: 240px;
}

.btn {
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.btn:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.page-jump {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
}

.quality-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
}

#qualityMode {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  font: inherit;
  background: #fff;
}

#pageNumberInput {
  width: 6rem;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  font: inherit;
}

.page-indicator {
  margin: 0;
  font-weight: 700;
  color: var(--ink-soft);
}

.viewer-wrap {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--stroke);
  border-radius: 24px;
  min-height: 680px;
  overflow: hidden;
  padding: 1rem;
  display: grid;
  place-items: center;
  animation: lift-in 760ms ease;
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.viewer-wrap.drag-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px rgba(15, 118, 110, 0.14);
  background: rgba(241, 255, 251, 0.9);
}

.drop-hint {
  margin: 0 0 0.5rem;
  color: var(--ink-soft);
  font-weight: 700;
  text-align: center;
}

.status {
  font-weight: 700;
  color: var(--ink-soft);
  text-align: center;
}

.status.error {
  color: var(--danger);
}

.flipbook-container {
  width: min(100%, 1050px);
  display: grid;
  place-items: center;
  overflow: hidden;
}

#flipbook {
  width: min(100%, 1000px);
  height: min(78vh, 840px);
  position: relative;
  overflow: visible;
  user-select: none;
  -webkit-user-select: none;
}

.page {
  overflow: hidden;
  background: #fff;
  border-radius: 4px;
}

.blank-front-page,
.blank-back-page {
  background: #fff;
}

.page img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.stf__parent,
.stf__wrapper,
.stf__block {
  overflow: visible;
}

@media (max-width: 900px) {
  .viewer-wrap {
    min-height: 500px;
  }

  #flipbook {
    width: min(100%, 680px);
    height: min(68vh, 620px);
  }
}

@media (max-width: 640px) {
  .controls {
    gap: 0.5rem;
  }

  #pdfInput {
    max-width: 100%;
  }

  #flipbook {
    width: min(100%, 420px);
    height: min(66vh, 560px);
  }
}

@keyframes lift-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
