:root {
  --wb-primary: #066157;
  --wb-primary-light: #0aa18f;
  --wb-dark: #0d0f12;
  --wb-panel: #16191e;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: radial-gradient(circle at 50% 0%, #1a1f25 0%, var(--wb-dark) 60%);
  color: #f1f3f5;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--wb-primary-light);
  text-decoration: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.25rem;
  background: rgba(13, 15, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: #fff;
}

.topbar .brand .dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--wb-primary), var(--wb-primary-light));
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f1f3f5;
  font-size: 0.9rem;
  transition: background 0.2s, border-color 0.2s;
}

.btn-back:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.35);
}

.manual-title {
  text-align: center;
  padding: 1.4rem 1.25rem 0.4rem;
}

.manual-title .eyebrow {
  color: var(--wb-primary-light);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 0.35rem;
}

.manual-title h1 {
  margin: 0;
  font-size: clamp(1.3rem, 3.5vw, 2rem);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem 0.3rem;
}

.counter {
  min-width: 4.5rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #cfd4da;
  font-size: 0.95rem;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.4);
}

.book-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.5rem;
  min-height: 0;
}

.book-stage {
  position: relative;
  flex: 1;
  max-width: 820px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2200px;
  overflow: hidden;
}

.page {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  border-radius: 0.4rem;
  box-shadow: 0 1.4rem 3rem rgba(0, 0, 0, 0.55);
  transform-style: preserve-3d;
  background: #fff;
}

.page img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 190px);
  min-height: 220px;
  object-fit: contain;
  border-radius: 0.4rem;
  user-select: none;
  -webkit-user-drag: none;
}

.page::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 18px;
  border-radius: 0.4rem 0 0 0.4rem;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.page.turn-next {
  animation: turnNext 0.42s ease;
}

.page.turn-prev {
  animation: turnPrev 0.42s ease;
}

@keyframes turnNext {
  0% {
    transform: rotateY(-38deg);
    transform-origin: left center;
    opacity: 0.25;
  }
  100% {
    transform: rotateY(0deg);
    opacity: 1;
  }
}

@keyframes turnPrev {
  0% {
    transform: rotateY(38deg);
    transform-origin: right center;
    opacity: 0.25;
  }
  100% {
    transform: rotateY(0deg);
    opacity: 1;
  }
}

.book-stage.zoomed {
  overflow: auto;
  perspective: none;
  align-items: flex-start;
  justify-content: flex-start;
}

.book-stage.zoomed .page {
  box-shadow: none;
  max-width: none;
  max-height: none;
}

.book-stage.zoomed .page img {
  max-width: none;
  max-height: none;
  height: 150vh;
  width: auto;
  cursor: zoom-out;
}

.book-stage:not(.zoomed) .page img {
  cursor: zoom-in;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 50%;
  border: none;
  background: rgba(6, 97, 87, 0.55);
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

.nav-arrow.prev { left: 0.6rem; }
.nav-arrow.next { right: 0.6rem; }

.nav-arrow:hover {
  background: var(--wb-primary-light);
  transform: translateY(-50%) scale(1.06);
}

.nav-arrow:disabled {
  opacity: 0.25;
  cursor: default;
  transform: translateY(-50%);
}

.filmstrip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.8rem 1rem 1.1rem;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.filmstrip::-webkit-scrollbar {
  height: 7px;
}

.filmstrip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.filmstrip .mini {
  flex: 0 0 auto;
  width: 56px;
  height: 74px;
  border-radius: 0.4rem;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--wb-panel);
  cursor: pointer;
  padding: 0;
  scroll-snap-align: center;
  opacity: 0.55;
  transition: opacity 0.2s, border-color 0.2s;
}

.filmstrip .mini img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.filmstrip .mini.active,
.filmstrip .mini:hover {
  opacity: 1;
  border-color: var(--wb-primary-light);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 15, 18, 0.55);
  color: #dfe3e8;
  font-size: 0.95rem;
  z-index: 8;
  border-radius: 0.4rem;
}

.loading-overlay[hidden] {
  display: none !important;
}

@media (max-width: 600px) {
  .nav-arrow {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1rem;
  }

  .nav-arrow.prev { left: 0.3rem; }
  .nav-arrow.next { right: 0.3rem; }

  .page img {
    max-height: calc(100vh - 170px);
  }

  .book-wrap {
    padding: 0.3rem 0.3rem;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .topbar,
  .toolbar,
  .filmstrip,
  .manual-title {
    display: none !important;
  }

  .book-wrap {
    padding: 0;
  }

  .book-stage {
    max-width: 100vw;
  }

  .page img {
    max-height: 100vh;
    min-height: 0;
    border-radius: 0;
  }
}

/* Index page */
.index-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.index-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s, background 0.2s;
}

.index-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(10, 161, 143, 0.45);
}

.index-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.index-card p {
  margin: 0 0 0.9rem;
  color: #aeb6bf;
  font-size: 0.9rem;
}

.index-card .btn-open {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: 2rem;
  background: linear-gradient(135deg, var(--wb-primary), var(--wb-primary-light));
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}
