/* ═══════════════════════════════════════════════════════════════════
   CYNEFLIX v215 — MANGA PAGE  ·  modal + in-page reader
   ───────────────────────────────────────────────────────────────────
   Colours reuse the existing brand tokens and the manga page's own
   purple accent (rgba(229,9,20,…)) that is already used by
   manga.html. Nothing here introduces a new brand colour.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --manga-accent: 167, 139, 250;
  --manga-accent-2: 196, 181, 253;
}

/* ── Detail modal ──────────────────────────────────────────────── */
.manga-modal-overlay {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .86);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: 16px;
  animation: mangaFadeIn .22s ease both;
}
@keyframes mangaFadeIn { from { opacity: 0 } to { opacity: 1 } }

.manga-modal {
  position: relative;
  background: #111;
  border-radius: 16px;
  max-width: 560px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 60px 140px rgba(0, 0, 0, .95), 0 0 0 1px rgba(255, 255, 255, .08);
  animation: mangaPop .26s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes mangaPop { from { opacity: 0; transform: translateY(18px) scale(.97) } to { opacity: 1; transform: none } }

.manga-modal-x {
  position: absolute; top: 12px; right: 12px; z-index: 4;
  background: rgba(255, 255, 255, .1); border: none;
  width: 32px; height: 32px; border-radius: 50%;
  color: #fff; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s ease, transform .2s ease;
}
.manga-modal-x:hover { background: rgba(var(--manga-accent), .35); transform: rotate(90deg); }

.manga-modal-hero { position: relative; display: flex; gap: 16px; padding: 18px 18px 16px; }
.manga-modal-cover {
  width: 108px; min-width: 108px; height: 156px;
  object-fit: cover; object-position: top;
  border-radius: 9px; background: #1a1a1a;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .75);
}
.manga-modal-head { flex: 1; min-width: 0; padding-top: 4px; }
.manga-modal-title {
  font-size: 20px; font-weight: 800; color: #fff;
  margin: 0 0 5px; line-height: 1.25;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 3; -webkit-box-orient: vertical;
}
.manga-modal-meta { font-size: 12px; color: rgba(255, 255, 255, .5); margin: 0 0 14px; }
.manga-modal-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.manga-modal-actions .btn { font-size: 13px; padding: 9px 16px; }

.manga-modal-body { padding: 0 18px 16px; }
.manga-modal-desc {
  font-size: 13px; color: rgba(255, 255, 255, .62);
  line-height: 1.65; margin: 0 0 4px;
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}
.manga-modal-credit {
  font-size: 11px; color: rgba(255, 255, 255, .3);
  margin: 0; padding: 0 18px 18px; line-height: 1.6;
}
.manga-modal-credit a { color: rgba(var(--manga-accent-2), .85); text-decoration: none; }
.manga-modal-credit a:hover { text-decoration: underline; }

/* ── Chapter list ──────────────────────────────────────────────── */
.manga-chapters { margin-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 14px; }
.manga-chapters-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: rgba(255, 255, 255, .55);
  margin-bottom: 10px;
}
.manga-chapters-count { color: rgba(var(--manga-accent-2), .8); font-weight: 600; text-transform: none; letter-spacing: 0; }
.manga-chapters-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; padding-right: 4px; }
.manga-chapters-loading { font-size: 13px; color: rgba(255, 255, 255, .4); padding: 16px 0; text-align: center; }

.manga-chapter {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; cursor: pointer;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 10px; padding: 10px 12px;
  color: #fff; font-family: inherit;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.manga-chapter:hover {
  background: rgba(var(--manga-accent), .12);
  border-color: rgba(var(--manga-accent), .38);
  transform: translateX(3px);
}
.manga-chapter-num { font-size: 13.5px; font-weight: 700; }
.manga-chapter-meta {
  font-size: 12px; color: rgba(255, 255, 255, .6);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.manga-chapter-group { font-size: 10.5px; color: rgba(var(--manga-accent-2), .62); letter-spacing: .02em; }

/* ── Reader ────────────────────────────────────────────────────── */
.manga-reader {
  position: fixed; inset: 0; z-index: 9500;
  background: #070707;
  display: flex; flex-direction: column;
  animation: mangaFadeIn .2s ease both;
}
.manga-reader[hidden] { display: none; }

.manga-reader-top {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; flex: 0 0 auto;
  background: rgba(10, 10, 10, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  position: sticky; top: 0; z-index: 3;
}
.mrd-info { flex: 1; min-width: 0; }
.mrd-title {
  margin: 0; font-size: 14px; font-weight: 700; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mrd-sub {
  margin: 0; font-size: 11.5px; color: rgba(255, 255, 255, .45);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mrd-tools { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.mrd-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 9px; color: #fff; font-size: 12px; font-weight: 700;
  font-family: inherit; cursor: pointer; text-decoration: none;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
}
.mrd-btn:hover { background: rgba(var(--manga-accent), .2); border-color: rgba(var(--manga-accent), .4); transform: translateY(-1px); }
.mrd-q.is-light { color: rgba(var(--manga-accent-2), .95); border-color: rgba(var(--manga-accent), .4); }
#mrd-count {
  font-size: 12px; color: rgba(255, 255, 255, .5); font-variant-numeric: tabular-nums;
  min-width: 58px; text-align: right;
}

.mrd-scroll { flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; background: #070707; }
.mrd-pages { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0 0 24px; }

.mrd-page {
  position: relative;
  width: 100%;
  max-width: 860px;
  min-height: 320px; /* Keep unloaded pages distinct so lazy loading stays bounded. */
  background: #0d0d0d;
}
.mrd-page-box {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  min-height: 320px;
}
.mrd-page-fail { font-size: 12px; color: rgba(255, 255, 255, .3); }
.mrd-img {
  display: block; width: 100%; height: auto;
  opacity: 0; transition: opacity .35s ease;
}
.mrd-img[src] { opacity: 1; }
.mrd-page-num {
  position: absolute; right: 8px; top: 8px;
  font-size: 10px; font-weight: 700; color: rgba(255, 255, 255, .35);
  background: rgba(0, 0, 0, .55); padding: 2px 7px; border-radius: 20px;
  pointer-events: none; opacity: 0; transition: opacity .2s ease;
}
.mrd-page:hover .mrd-page-num { opacity: 1; }

.mrd-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 70px 20px; color: rgba(255, 255, 255, .45); font-size: 13.5px;
  flex-direction: column; text-align: center;
}
.mrd-loading p { margin: 0 0 6px; }
.mrd-loading-sub { font-size: 12px; color: rgba(255, 255, 255, .35); max-width: 380px; }
.mrd-empty-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.mrd-error { color: rgba(255, 140, 140, .8); }
.mrd-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .18);
  border-top-color: rgba(var(--manga-accent-2), .95);
  animation: mrdSpin .7s linear infinite;
  display: inline-block;
}
@keyframes mrdSpin { to { transform: rotate(360deg) } }

.mrd-foot {
  flex: 0 0 auto; padding: 8px 14px;
  font-size: 10.5px; color: rgba(255, 255, 255, .3);
  background: rgba(10, 10, 10, .92);
  border-top: 1px solid rgba(255, 255, 255, .07);
  text-align: center;
}
.mrd-foot a { color: rgba(var(--manga-accent-2), .8); text-decoration: none; }
.mrd-foot a:hover { text-decoration: underline; }
.mrd-foot strong { color: rgba(255, 255, 255, .5); font-weight: 600; }

@media (max-width: 640px) {
  .manga-modal-hero { flex-direction: column; }
  .manga-modal-cover { width: 92px; min-width: 92px; height: 132px; }
  .mrd-title { font-size: 13px; }
  #mrd-count { min-width: 46px; font-size: 11px; }
}

/* ── v216 — MangaDex proxy status chip ───────────────────────────
   Small pill in the filter bar showing which Worker base is
   answering, so a mis-deployed Worker is obvious at a glance. */
.manga-proxy-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  align-self: center;
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .04);
  color: rgba(255, 255, 255, .55);
  transition: color .25s ease, border-color .25s ease, background .25s ease;
  user-select: none;
}
.manga-proxy-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  flex: 0 0 auto;
}
.manga-proxy-chip[data-state="idle"] .manga-proxy-dot {
  background: #f11c27;
  animation: mdx-pulse 1.2s ease-in-out infinite;
}
.manga-proxy-chip[data-state="ok"] {
  color: rgba(221,60,68, .95);
  border-color: rgba(221,60,68, .32);
  background: rgba(221,60,68, .09);
}
.manga-proxy-chip[data-state="ok"] .manga-proxy-dot {
  background: #E50914;
  box-shadow: 0 0 10px rgba(221,60,68, .7);
}
.manga-proxy-chip[data-state="bad"] {
  color: rgba(255, 90, 90, .95);
  border-color: rgba(255, 90, 90, .35);
  background: rgba(255, 90, 90, .09);
}
.manga-proxy-chip[data-state="bad"] .manga-proxy-dot {
  background: #ff5a5a;
  box-shadow: 0 0 10px rgba(255, 90, 90, .7);
  animation: mdx-pulse .9s ease-in-out infinite;
}
@keyframes mdx-pulse {
  0%, 100% { opacity: 1 }
  50%      { opacity: .35 }
}
@media (max-width: 640px) {
  .manga-proxy-chip { font-size: 10px; padding: 6px 10px; }
}
