/* ============================================================
   Manga Reader — mobile-first, Android + iOS friendly
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: #0a0a0a; color: #eee;
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
  /* NOTE: do NOT set overscroll-behavior-y:none here — on Chromium desktop it
     disables mouse-wheel scrolling of the page while touch still works. */
}
img { max-width: 100%; }
a { -webkit-tap-highlight-color: transparent; }

/* ---------- Top bar (sticky) ---------- */
.reader-topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top));
  padding-left: calc(10px + env(safe-area-inset-left));
  padding-right: calc(10px + env(safe-area-inset-right));
  min-height: 54px;
  background: rgba(13,14,15,.97);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 2px solid var(--primary, #ff6740);
}
.reader-back {
  display: flex; align-items: center; gap: 6px;
  color: #fff; text-decoration: none; font-weight: 600; font-size: 14px;
  flex: 0 1 auto; min-width: 0; max-width: 44%;
}
.reader-back svg { flex-shrink: 0; }
.reader-manga-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-chapter-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; min-width: 0; }
.reader-nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 40px; padding: 0 11px; border-radius: 9px;
  background: #2c2c2c; color: #eee; text-decoration: none;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.reader-nav-btn:active { background: var(--primary, #ff6740); color: #fff; }
.reader-chapter-select {
  min-height: 40px; max-width: 150px; padding: 0 8px;
  border-radius: 9px; background: #2c2c2c; color: #eee;
  border: 1px solid #444; font-size: 13px; -webkit-appearance: none; appearance: none;
}
.reader-settings { flex-shrink: 0; }
.reader-mode-btn {
  min-width: 40px; min-height: 40px; border-radius: 9px; border: none;
  background: #2c2c2c; color: #eee; font-size: 18px; cursor: pointer;
}
.reader-mode-btn:active { background: var(--primary, #ff6740); color: #fff; }

/* ---------- Pages ---------- */
.reader-container { width: 100%; margin: 0 auto; }
.reader-page { width: 100%; text-align: center; line-height: 0; }
.reader-page img { display: block; width: 100%; height: auto; margin: 0 auto; }

/* Scroll (webtoon) mode: continuous vertical, capped width on desktop */
.reader-container.scroll-mode { max-width: 900px; }

/* Single-page mode: one page fitted to the screen, tap to advance */
.reader-container.single-mode { max-width: 100%; }
.reader-container.single-mode .reader-page { display: none; }
.reader-container.single-mode .reader-page.active {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100dvh - 56px);
}
.reader-container.single-mode .reader-page.active img {
  width: auto; max-width: 100%;
  max-height: calc(100dvh - 60px); object-fit: contain;
}

/* ---------- Empty ---------- */
.reader-empty { text-align: center; padding: 80px 20px; color: #aaa; }
.reader-empty a { color: var(--primary, #ff6740); text-decoration: none; font-weight: 600; }

/* ---------- Bottom nav ---------- */
.reader-bottom-nav {
  padding: 16px 10px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  background: #0d0e0f; border-top: 2px solid var(--primary, #ff6740);
}
.reader-nav-inner { display: flex; gap: 8px; max-width: 900px; margin: 0 auto; }
.nav-btn-full, .nav-btn-manga {
  display: flex; align-items: center; justify-content: center;
  min-height: 50px; padding: 0 12px; border-radius: 11px;
  text-decoration: none; font-size: 14px; font-weight: 700; text-align: center;
}
.nav-btn-full { flex: 1; background: #2c2c2c; color: #eee; }
.nav-btn-full:active { background: var(--primary, #ff6740); color: #fff; }
.nav-btn-full.disabled { opacity: .4; pointer-events: none; }
.nav-btn-manga { flex: 0 0 auto; background: var(--primary, #ff6740); color: #fff; }

/* ---------- Progress ---------- */
.reader-progress { position: fixed; left: 0; right: 0; top: 0; z-index: 101; pointer-events: none; }
.progress-bar { height: 3px; background: var(--primary, #ff6740); width: 0; transition: width .12s ease; }
.progress-text {
  position: fixed; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 95;
  background: rgba(0,0,0,.72); color: #fff; font-size: 12px; font-weight: 600;
  padding: 5px 12px; border-radius: 20px; pointer-events: none;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}

/* ---------- Phone tweaks ---------- */
@media (max-width: 600px) {
  .reader-topbar { gap: 6px; min-height: 50px; }
  .reader-back { font-size: 13px; max-width: 36%; }
  .reader-nav-btn { padding: 0 9px; font-size: 12px; min-height: 38px; }
  .reader-chapter-select { max-width: 104px; font-size: 12px; min-height: 38px; }
  .reader-mode-btn { min-width: 38px; min-height: 38px; }
  .nav-btn-full, .nav-btn-manga { min-height: 46px; font-size: 13px; }
}
@media (max-width: 380px) {
  .reader-back .reader-manga-title { display: none; }
  .reader-back { max-width: 44px; }
}
