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

:root {
  --bg: #1a1a1a;
  --toolbar-bg: rgba(0,0,0,0.7);
  --btn-bg: rgba(255,255,255,0.15);
  --btn-hover: rgba(255,255,255,0.3);
  --text: #e0e0e0;
  --accent: #c8a96e;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ── Layout ─────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  gap: 12px;
  padding: 8px;
}

/* ── Book wrapper ────────────────────────────────────── */
#book-wrap {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
}

#book {
  position: relative;
  /* dimensions set by JS */
}

/* turn.js page styling */
#book .page {
  overflow: hidden;
  background: #fff;
}

#book .page img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Page shadow on double-spread seam */
#book .page.odd  { box-shadow:  4px 0 12px rgba(0,0,0,0.5); }
#book .page.even { box-shadow: -4px 0 12px rgba(0,0,0,0.5); }

/* Hard cover feel */
#book .p1, #book .p30 { background: #2c1a0e; }

/* ── Toolbar ─────────────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--toolbar-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 40px;
  padding: 8px 16px;
  flex-shrink: 0;
}

#toolbar button {
  background: var(--btn-bg);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text);
  border-radius: 24px;
  padding: 6px 18px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
#toolbar button:hover  { background: var(--btn-hover); }
#toolbar button:active { transform: scale(0.95); }
#toolbar button:disabled { opacity: 0.3; cursor: default; }

#page-info {
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 80px;
  text-align: center;
  white-space: nowrap;
}

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

.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(200,169,110,0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading p { font-size: 0.9rem; color: var(--accent); }

/* ── Mobile nav arrows (tap zones) ──────────────────── */
.tap-zone {
  display: none;
  position: absolute;
  top: 0; bottom: 0;
  width: 20%;
  z-index: 10;
  cursor: pointer;
}
.tap-zone.left  { left: 0; }
.tap-zone.right { right: 0; }

@media (max-width: 767px) {
  .tap-zone { display: block; }
  #toolbar { gap: 8px; padding: 6px 12px; }
  #toolbar button { padding: 5px 14px; font-size: 0.9rem; }
}
