:root {
  --bg-color: rgba(240, 249, 255, 0.6);
  --control-bg: rgba(240, 249, 255, 0.6);
  --shadow-color: rgba(0, 0, 0, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Swiper --- */
.swiper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.swiper-slide {
  text-align: center;
  font-size: 18px;
  background: transparent;
  display: flex;
  height: fit-content;
  justify-content: center;
  margin: auto;
  align-items: center;
  box-shadow: 0 0px 12px rgba(0, 0, 0, 0.3);
  background-color: white;
  height: fit-content;
  border-radius: 6px;
}

/* In Swiper, the slide is the container. The canvas sits inside. */
.swiper-slide canvas {
  width: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: auto;
  height: fit-content;
}

/* Zoom Container (required for swiper zoom) */
.swiper-zoom-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- UI Controls --- */
#ui-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding-bottom: 24px;
  align-items: center;
  z-index: 100;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

#ui-layer.ui-hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.pill {
  /* More transparent Glassmorphism */
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #1e293b;

  padding: 6px 8px; /* Compact */
  border-radius: 99px;

  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08),
    0 2px 4px -1px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(255, 255, 255, 0.3);

  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;

  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pill:active {
  transform: scale(0.98);
}

.pill-divider {
  width: 1px;
  height: 20px;
  background: rgba(0, 0, 0, 0.15);
  margin: 0 4px;
}

.btn {
  background: none;
  border: none;
  font-size: 20px; /* Smaller icons */
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #475569;
}

.btn:hover {
  background: rgba(0, 0, 0, 0.08);
  color: #1e293b;
}

.btn:active {
  background: rgba(0, 0, 0, 0.12);
  transform: scale(0.9);
}

.btn:disabled {
  opacity: 0.3;
  pointer-events: none;
}

#page-text,
.page-indicator {
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: #334155;
  min-width: 50px;
  text-align: center;
  letter-spacing: -0.01em;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s;
}

.page-indicator:hover {
  background: rgba(0, 0, 0, 0.08);
}

.zoom-indicator {
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: #475569;
  min-width: 42px;
  text-align: center;
  letter-spacing: -0.01em;
}

/* Page Jump Modal - positioned above the pill */
.page-jump-modal {
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08),
    0 2px 4px -1px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(255, 255, 255, 0.3);
  margin-bottom: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
  transition: opacity 0.2s, transform 0.2s;
}

.page-jump-modal.hidden {
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
}

.page-jump-modal input {
  width: 70px;
  padding: 6px 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.8);
  color: #1e293b;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.page-jump-modal input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.page-jump-modal input::-webkit-outer-spin-button,
.page-jump-modal input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.page-jump-modal input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.jump-btn {
  background: #3b82f6 !important;
  color: white !important;
  font-size: 12px !important;
  font-weight: 600;
  padding: 0 12px;
  width: auto !important;
  border-radius: 8px !important;
}

.jump-btn:hover {
  background: #2563eb !important;
}

/* --- Toasts --- */
#toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 100;
}

/* --- Loader --- */
#loader {
  position: fixed;
  inset: 0;
  background: var(--bg-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.5s;
  pointer-events: none;
  color: #64748b;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}
