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

:root {
  --bg: #1a1a1a;
  --header-bg: #111;
  --accent: #c8a96e;
  --text: #f0ece4;
  --shadow: 0 8px 40px rgba(0,0,0,0.7);
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; overflow: hidden; }

/* ── Header ── */
header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid #2a2a2a;
  height: 56px;
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  height: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.logo { font-size: 1.1rem; font-weight: 600; color: var(--accent); letter-spacing: 0.03em; }
.header-controls { display: flex; align-items: center; gap: 10px; }
#page-indicator { font-size: 0.85rem; color: #aaa; min-width: 110px; text-align: center; }

.nav-btn {
  background: #2a2a2a; border: 1px solid #3a3a3a; color: var(--text);
  padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 1rem;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: var(--accent); color: #111; border-color: var(--accent); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }

/* ── Viewer ── */
#viewer-wrap {
  position: fixed; top: 56px; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}

#book-container {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}

/* StPageFlip page styling */
.page {
  background: #fff;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.page img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  draggable: false;
}

/* Cover pages (first/last) */
.page-cover {
  background: #1a0f06;
  display: flex; align-items: center; justify-content: center;
}
.page-cover img { object-fit: cover; }

/* ── Loading overlay ── */
#loading-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); z-index: 50; gap: 16px;
  transition: opacity 0.4s;
}
#loading-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 44px; height: 44px;
  border: 4px solid #333;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── WhatsApp button ── */
#wa-btn {
  position: fixed; bottom: 28px; right: 28px; z-index: 200;
  display: flex; align-items: center; gap: 10px;
  background: #25D366; color: #fff;
  border: none; border-radius: 50px; padding: 13px 22px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 20px rgba(37, 211, 102, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
#wa-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 28px rgba(37, 211, 102, 0.6); }
#wa-btn:active { transform: translateY(0); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .logo { font-size: 0.9rem; }
  #wa-btn span { display: none; }
  #wa-btn { padding: 13px; border-radius: 50%; }
  #wa-btn svg { width: 24px; height: 24px; }
}

/* Disable context menu & selection on book area */
#book-container { -webkit-touch-callout: none; }
