:root {
  --teal: #204551;
  --teal-deep: #16353e;
  --teal-soft: #2a5a68;
  --gold: #C9A23F;
  --orange: #E07A3D;
  --sage: #8FAE8B;
  --white: #ffffff;
  --ink: #f4f7f6;
  --shadow: rgba(0, 0, 0, 0.45);
  --page-radius: 6px;
  --flip-ms: 700ms;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: radial-gradient(120% 90% at 50% 0%, var(--teal-soft) 0%, var(--teal) 45%, var(--teal-deep) 100%);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

body { min-height: 100dvh; }

.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  gap: 8px;
}

.topbar, .bottombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--orange));
  box-shadow: 0 0 0 3px rgba(201, 162, 63, 0.25);
  flex-shrink: 0;
}

.brand h1 {
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-btn, .nav-btn, .pdf-link, .dot {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--white);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, opacity 0.2s;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.icon-btn:hover, .nav-btn:hover, .pdf-link:hover, .dot:hover {
  background: rgba(255,255,255,0.16);
  border-color: rgba(201, 162, 63, 0.55);
}

.icon-btn:active, .nav-btn:active { transform: scale(0.96); }

.pdf-link {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border-color: rgba(201, 162, 63, 0.45);
  color: var(--gold);
}

.hidden { display: none !important; }

.stage-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 0;
}

.nav-btn {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  font-size: 1.75rem;
  line-height: 1;
  display: grid;
  place-items: center;
  user-select: none;
}

.nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

.book-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  perspective: 2200px;
}

.book {
  position: relative;
  width: min(96vw, 1100px);
  aspect-ratio: 1467 / 825;
  max-height: calc(100dvh - 140px);
  transform-style: preserve-3d;
  box-shadow:
    0 18px 50px var(--shadow),
    0 2px 0 rgba(201, 162, 63, 0.35);
  border-radius: var(--page-radius);
  background: #0f2a31;
}

.page {
  position: absolute;
  inset: 0;
  border-radius: var(--page-radius);
  overflow: hidden;
  background: #102f37;
  transform-origin: left center;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform;
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.06);
}

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

.page .shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,0.18) 0%, transparent 12%, transparent 88%, rgba(0,0,0,0.08) 100%);
  opacity: 0.55;
}

.page.flipping {
  z-index: 30 !important;
  transition: transform var(--flip-ms) cubic-bezier(0.22, 0.61, 0.36, 1);
  box-shadow:
    8px 0 24px rgba(0,0,0,0.35),
    inset -20px 0 40px rgba(0,0,0,0.15);
}

.page.flipping::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 60%, rgba(255,255,255,0.12) 85%, rgba(0,0,0,0.25) 100%);
  opacity: 0.9;
  pointer-events: none;
}

.hint {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translate(-50%, 120%);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  pointer-events: none;
  transition: opacity 0.4s;
}

.hint.fade { opacity: 0; }

.bottombar {
  padding-top: 4px;
}

.counter {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.9);
  min-width: 4.5rem;
}

.dots {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  padding: 0;
  background: rgba(255,255,255,0.22);
}

.dot.active {
  background: var(--gold);
  border-color: var(--gold);
  transform: scale(1.15);
}

@media (max-width: 720px) {
  .app { padding: 10px 10px 12px; }
  .nav-btn { width: 40px; height: 40px; font-size: 1.4rem; }
  .brand h1 { font-size: 0.92rem; }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .page.flipping { transition-duration: 1ms; }
}
