/* ============================================================
   BluBellFun — reader
   ============================================================ */

body.is-reader {
  background: var(--r-bg, #07070b);
  padding-bottom: 0;
}

.is-reader .site-header,
.is-reader .site-footer,
.is-reader .mobile-nav {
  display: none !important;
}

.reader {
  --r-bg: #07070b;
  --r-bar: rgba(8, 8, 13, 0.9);
  --r-panel: #12121a;
  --r-text: #f5f5f9;
  --r-muted: #aeaeC0;
  --r-line: rgba(255, 255, 255, 0.1);
  --r-hover: rgba(255, 255, 255, 0.06);
  --reader-width: 760px;
  min-height: 100vh;
  background: var(--r-bg);
  color: var(--r-text);
}

.reader[data-reader-theme='sepia'] {
  --r-bg: #16120e;
  --r-bar: rgba(24, 19, 14, 0.92);
  --r-panel: #211b15;
  --r-text: #f1e8d9;
  --r-muted: #b3a28b;
  --r-line: rgba(241, 232, 217, 0.1);
  --r-hover: rgba(241, 232, 217, 0.06);
}

.reader[data-reader-theme='light'] {
  --r-bg: #e9e6df;
  --r-bar: rgba(250, 248, 244, 0.92);
  --r-panel: #ffffff;
  --r-text: #17171d;
  --r-muted: #6f6f7c;
  --r-line: rgba(21, 21, 28, 0.09);
  --r-hover: rgba(21, 21, 28, 0.05);
}

.reader[data-width='narrow'] {
  --reader-width: 620px;
}

.reader[data-width='wide'] {
  --reader-width: 980px;
}

.reader-bar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 60;
  border-bottom: 1px solid var(--r-line);
  background: var(--r-bar);
  backdrop-filter: blur(20px) saturate(1.2);
  -webkit-backdrop-filter: blur(20px) saturate(1.2);
}

.reader-bar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 62px;
  max-width: 1560px;
  margin-inline: auto;
  padding-inline: clamp(12px, 2vw, 22px);
}

.reader-back {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border: 1px solid var(--r-line);
  border-radius: 50%;
  color: var(--r-muted);
  transition: background 0.18s, color 0.18s;
}

.reader-back:hover {
  background: var(--r-hover);
  color: var(--r-text);
}

.reader-back .icon {
  width: 18px;
  height: 18px;
}

.reader-heading {
  min-width: 0;
  flex: 1;
}

.reader-manga {
  display: block;
  overflow: hidden;
  max-width: 440px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-manga:hover {
  color: var(--primary);
}

.reader-chapter {
  display: block;
  overflow: hidden;
  max-width: 520px;
  margin-top: 1px;
  color: var(--r-muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: none;
}

.reader-action {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--r-muted);
  transition: background 0.16s, color 0.16s;
}

.reader-action:hover {
  background: var(--r-hover);
  color: var(--r-text);
}

.reader-action .icon {
  width: 18px;
  height: 18px;
}

.reader-action.is-saved {
  color: var(--rose);
}

.reader-action.is-saved .icon {
  fill: currentColor;
}

.reader-progress {
  height: 2px;
  background: transparent;
}

.reader-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--gradient);
  transition: width 0.15s linear;
}

.reader-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 86px 16px 104px;
}

.reader-page {
  position: relative;
  width: min(var(--reader-width), 100%);
  margin: 0;
  overflow: hidden;
  border-radius: 3px;
  background: #fbfaf6;
  box-shadow: 0 20px 60px -28px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(0, 0, 0, 0.12);
  animation: pageAppear 0.45s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 30ms);
}

@keyframes pageAppear {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.reader-page > svg {
  display: block;
  width: 100%;
  height: auto;
}

.reader-page::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 50px rgba(42, 34, 24, 0.06);
}

.reader[data-mode='single'] .reader-pages {
  padding-bottom: 130px;
}

.reader[data-mode='single'] .reader-page {
  display: none;
}

.reader[data-mode='single'] .reader-page.is-current {
  display: block;
  animation: none;
}

.reader[data-mode='single'] .reader-page {
  width: min(var(--reader-width), calc(100vw - 120px));
}

.reader-single-arrows {
  position: fixed;
  top: 50%;
  right: 0;
  left: 0;
  z-index: 40;
  display: none;
  justify-content: space-between;
  padding-inline: clamp(8px, 2vw, 26px);
  transform: translateY(-50%);
  pointer-events: none;
}

.reader[data-mode='single'] .reader-single-arrows {
  display: flex;
}

.reader-arrow {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--r-line);
  border-radius: 50%;
  background: var(--r-bar);
  color: var(--r-text);
  box-shadow: 0 14px 30px -16px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
  transition: background 0.18s, transform 0.18s, opacity 0.18s;
}

.reader-arrow:hover {
  transform: scale(1.05);
}

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

.reader-arrow .icon {
  width: 20px;
  height: 20px;
}

.reader-hud {
  position: fixed;
  top: 74px;
  right: 18px;
  z-index: 45;
  display: none;
  padding: 5px 10px;
  border: 1px solid var(--r-line);
  border-radius: 999px;
  background: var(--r-bar);
  color: var(--r-muted);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.reader[data-mode='single'] .reader-hud {
  display: block;
}

.reader-bottom {
  position: fixed;
  right: 0;
  bottom: 18px;
  left: 0;
  z-index: 55;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.reader-bottom-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 50px;
  padding: 4px;
  border: 1px solid var(--r-line);
  border-radius: 999px;
  background: var(--r-bar);
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  pointer-events: auto;
}

.reader-bottom-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 42px;
  height: 42px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--r-muted);
  font-size: 11.5px;
  font-weight: 700;
  transition: background 0.16s, color 0.16s;
}

.reader-bottom-btn:hover {
  background: var(--r-hover);
  color: var(--r-text);
}

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

.reader-bottom-btn .icon {
  width: 17px;
  height: 17px;
}

.reader-bottom-center {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  border-right: 1px solid var(--r-line);
  border-left: 1px solid var(--r-line);
  color: var(--r-text);
  font-size: 11.5px;
  font-weight: 700;
}

.reader-bottom-center .counter {
  color: var(--r-muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.chapter-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 210px;
  overflow: hidden;
  color: inherit;
  font-size: inherit;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-select-btn .icon {
  width: 13px;
  height: 13px;
  color: var(--r-muted);
}

/* ---------------- Settings popover ---------------- */

.reader-settings {
  position: fixed;
  top: 72px;
  right: 16px;
  z-index: 70;
  width: 304px;
  max-width: calc(100vw - 24px);
  padding: 18px;
  border: 1px solid var(--r-line);
  border-radius: 20px;
  background: var(--r-panel);
  color: var(--r-text);
  box-shadow: 0 30px 80px -24px rgba(0, 0, 0, 0.8);
  animation: popIn 0.2s var(--ease);
}

.reader-settings[hidden] {
  display: none;
}

.settings-group + .settings-group {
  margin-top: 16px;
}

.settings-label {
  display: block;
  margin-bottom: 7px;
  color: var(--r-muted);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--r-line);
  border-radius: 11px;
  background: rgba(0, 0, 0, 0.15);
}

html[data-theme='light'] .segmented {
  background: rgba(0, 0, 0, 0.04);
}

.seg-btn {
  flex: 1;
  height: 32px;
  border-radius: 8px;
  color: var(--r-muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.16s, color 0.16s;
}

.seg-btn:hover {
  color: var(--r-text);
}

.seg-btn.is-active {
  background: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 6px 16px -8px var(--primary-glow);
}

.theme-swatches {
  display: flex;
  gap: 8px;
}

.theme-swatch {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  border: 1px solid var(--r-line);
  border-radius: 10px;
  color: var(--r-muted);
  font-size: 10.5px;
  font-weight: 700;
  transition: border-color 0.16s, color 0.16s;
}

.theme-swatch:hover {
  color: var(--r-text);
}

.theme-swatch.is-active {
  border-color: var(--primary);
  color: var(--r-text);
}

.theme-swatch i {
  width: 15px;
  height: 15px;
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 50%;
}

.theme-swatch i.dark {
  background: #0a0a10;
}
.theme-swatch i.sepia {
  background: #e7d9bf;
}
.theme-swatch i.light {
  background: #f7f4ee;
}

.reader-settings-hint {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--r-line);
  color: var(--r-muted);
  font-size: 10px;
  line-height: 1.55;
}

.reader-settings-hint .kbd {
  height: 20px;
  min-width: 20px;
  padding: 0 5px;
  border-color: var(--r-line);
  background: rgba(0, 0, 0, 0.12);
  color: var(--r-text);
  font-size: 9px;
}

html[data-theme='light'] .reader-settings-hint .kbd {
  background: rgba(0, 0, 0, 0.04);
}

/* ---------------- End of chapter ---------------- */

.reader-end {
  display: flex;
  justify-content: center;
  padding: 10px 16px 150px;
}

.reader-end-inner {
  width: min(760px, 100%);
  padding: clamp(26px, 4vw, 38px);
  border: 1px solid var(--r-line);
  border-radius: 24px;
  background:
    radial-gradient(70% 100% at 100% 0%, rgba(var(--primary-rgb), 0.1), transparent 65%),
    var(--r-panel);
  text-align: center;
}

.reader-end-inner h2 {
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: clamp(21px, 3vw, 28px);
  font-weight: 550;
  letter-spacing: -0.045em;
}

.reader-end-inner p {
  max-width: 460px;
  margin: 8px auto 0;
  color: var(--r-muted);
  font-size: 12px;
  line-height: 1.6;
}

.reader-end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 20px;
}

.reader-end-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--r-line);
  color: var(--r-muted);
  font-size: 10px;
}

.reader-end-meta .icon {
  width: 13px;
  height: 13px;
  margin-right: 4px;
}

.reader-end .btn-soft {
  border-color: var(--r-line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--r-text);
}

html[data-theme='light'] .reader-end .btn-soft {
  background: rgba(0, 0, 0, 0.05);
}

/* ---------------- Channel list modal ---------------- */

.chapter-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 7px;
}

.chapter-modal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chapter-modal-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-3);
  color: var(--text);
}

.chapter-modal-btn.is-current {
  border-color: transparent;
  background: var(--primary);
  color: var(--primary-ink);
}

.chapter-modal-btn.is-read {
  color: var(--muted);
}

.chapter-modal-note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 10.5px;
  text-align: center;
}

/* ---------------- Reader responsive ---------------- */

@media (max-width: 900px) {
  .reader-bar-inner {
    height: 56px;
  }
  .reader-pages {
    gap: 10px;
    padding: 72px 8px 96px;
  }
  .reader[data-mode='single'] .reader-page {
    width: min(var(--reader-width), calc(100vw - 24px));
  }
  .reader-single-arrows {
    padding-inline: 4px;
  }
  .reader-arrow {
    width: 40px;
    height: 40px;
  }
  .reader-hud {
    top: 66px;
    right: 10px;
  }
  .reader-bottom {
    bottom: 10px;
    padding-inline: 10px;
  }
  .reader-bottom-inner {
    width: 100%;
    justify-content: space-between;
    height: 54px;
  }
  .reader-end {
    padding-bottom: 120px;
  }
  .reader-settings {
    top: 64px;
    right: 8px;
  }
}

@media (max-width: 620px) {
  .reader-heading .reader-chapter {
    max-width: 44vw;
  }
  .reader-manga {
    max-width: 42vw;
    font-size: 12px;
  }
  .reader-action {
    width: 34px;
    height: 34px;
  }
  .reader-actions {
    gap: 0;
  }
  .reader-back {
    width: 34px;
    height: 34px;
  }
  .reader-bottom-btn {
    min-width: 38px;
    padding: 0 8px;
  }
  .reader-bottom-center {
    gap: 8px;
    padding: 0 6px;
  }
  .chapter-select-btn {
    max-width: 118px;
  }
  .reader-end-inner {
    padding: 24px 18px;
  }
}

@media (max-width: 620px) {
  .reader[data-mode='single'] .reader-single-arrows {
    display: flex;
    top: 44%;
    bottom: auto;
    padding-inline: 8px;
    transform: translateY(-50%);
  }
  .reader-arrow {
    width: 38px;
    height: 38px;
  }
  .reader-single-arrows .reader-arrow {
    background: rgba(8, 8, 13, 0.82);
  }
}
