/* ═══════════════════════════════════════════════════════════════════
   MangaBest Reader

   Design brief: the images are the content, so the interface gets out of
   their way. Near-black with a slight cool cast rather than pure #000 —
   pure black next to a bright manga page produces a harsh edge and makes
   the page look like it is glowing. Accent colour is admin-configurable
   and injected as --mbt-accent, so it is used only where a decision is
   being offered, never as decoration.

   No webfont. On a page whose LCP is a 900KB manga scan, a font request
   competes with the thing the reader actually came for.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --mbt-accent: #c0392b;

  --bg:      #0b0d10;
  --bg-2:    #12151a;
  --bg-3:    #191d24;
  --line:    #242932;
  --line-2:  #333944;
  --ink:     #e8eaed;
  --ink-2:   #a6adb8;
  --ink-3:   #6b7280;
  --ok:      #4ade80;

  --r:       10px;
  --r-sm:    6px;
  --pad:     clamp(14px, 4vw, 28px);
  --max:     1140px;
  --max-read: 900px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[data-theme="light"] {
  --bg:     #ffffff;
  --bg-2:   #f6f7f9;
  --bg-3:   #eef0f4;
  --line:   #e2e5ea;
  --line-2: #cbd0d8;
  --ink:    #14171c;
  --ink-2:  #4b5563;
  --ink-3:  #8b929c;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
a   { color: inherit; }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--mbt-accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.screen-reader-text, .mbt-skip {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.mbt-skip:focus {
  position: fixed; top: 10px; left: 10px; width: auto; height: auto;
  clip-path: none; z-index: 200; background: var(--bg-3); color: var(--ink);
  padding: 10px 16px; border-radius: var(--r-sm);
}

.mbt-main { max-width: var(--max); margin: 0 auto; padding: 0 var(--pad) 64px; }
.mbt-muted { color: var(--ink-3); }

/* ── Header ─────────────────────────────────────────────────────── */

.mbt-head {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.mbt-head__in {
  max-width: var(--max); margin: 0 auto; padding: 0 var(--pad);
  height: 58px; display: flex; align-items: center; gap: 18px;
}
.mbt-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 650; }
/* A small accent block instead of a logo file: nothing to load, and it reads
   as intentional rather than as a missing image. */
.mbt-brand__mark {
  width: 8px; height: 20px; border-radius: 2px;
  background: var(--mbt-accent);
}
.mbt-brand__name {
  font-size: 15px; letter-spacing: -0.01em;
  max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.mbt-nav { margin-left: auto; }
.mbt-nav__list { display: flex; gap: 18px; list-style: none; margin: 0; padding: 0; }
.mbt-nav__list a { text-decoration: none; font-size: 14px; color: var(--ink-2); }
.mbt-nav__list a:hover { color: var(--ink); }

.mbt-head__tools { display: flex; gap: 6px; margin-left: auto; }
.mbt-nav + .mbt-head__tools { margin-left: 0; }
.mbt-icon {
  display: grid; place-items: center; width: 34px; height: 34px;
  background: transparent; border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--ink-2); cursor: pointer; font-size: 18px; line-height: 1;
}
.mbt-icon:hover { color: var(--ink); border-color: var(--line-2); }

/* ── Hero / series header ───────────────────────────────────────── */

.mbt-hero { position: relative; margin-bottom: 34px; }
/* The cover, blurred and heavily darkened, as the page's only atmosphere.
   Every series brings its own palette this way without a per-site theme. */
.mbt-hero__bg {
  position: absolute; inset: -60px -50vw 0; z-index: 0;
  background-image: var(--cover); background-size: cover; background-position: center 22%;
  filter: blur(48px) saturate(1.3); opacity: .28;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 92%);
}
[data-theme="light"] .mbt-hero__bg { opacity: .18; }

.mbt-hero__in {
  position: relative; z-index: 1;
  max-width: var(--max); margin: 0 auto; padding: 34px var(--pad) 0;
  display: grid; grid-template-columns: 220px 1fr; gap: clamp(20px, 4vw, 40px);
}

.mbt-cover { position: relative; }
.mbt-cover img {
  width: 100%; aspect-ratio: 3/4.3; object-fit: cover;
  border-radius: var(--r); border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(0,0,0,.45);
  display: block;
}
.mbt-cover__badge {
  position: absolute; left: 10px; bottom: 10px;
  background: var(--mbt-accent); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 5px 10px; border-radius: 999px;
}

.mbt-eyebrow {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--mbt-accent); font-weight: 700;
}
.mbt-title {
  margin: 0 0 6px;
  font-size: clamp(28px, 5.5vw, 52px); line-height: 1.04;
  letter-spacing: -0.03em; font-weight: 800;
  text-wrap: balance;
}
.mbt-alt { margin: 0 0 14px; color: var(--ink-3); font-size: 13.5px; }

.mbt-stats { display: flex; flex-wrap: wrap; gap: 6px 20px; font-size: 13.5px; color: var(--ink-2); }
.mbt-stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.mbt-stats small { color: var(--ink-3); }

.mbt-genres { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 14px 0 0; padding: 0; }
.mbt-genres li {
  font-size: 12px; padding: 4px 11px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink-2);
}

.mbt-synopsis { margin: 16px 0 0; max-width: 62ch; color: var(--ink-2); font-size: 15px; }
.mbt-synopsis p { margin: 0; }

.mbt-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* ── Buttons ────────────────────────────────────────────────────── */

.mbt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink);
  font: 600 14px/1 var(--sans); text-decoration: none; cursor: pointer;
  transition: border-color .14s, background .14s;
}
.mbt-btn:hover { border-color: var(--ink-3); background: var(--bg-3); }
.mbt-btn--primary { background: var(--mbt-accent); border-color: var(--mbt-accent); color: #fff; }
.mbt-btn--primary:hover { filter: brightness(1.1); background: var(--mbt-accent); }
.mbt-btn--ghost { background: transparent; border-color: var(--line); }
.mbt-btn.is-disabled { opacity: .32; pointer-events: none; }
.mbt-linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--mbt-accent); font: inherit; font-size: 13px;
}

.mbt-input {
  width: 100%; padding: 10px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  font: 14px/1.5 var(--sans);
}
.mbt-input::placeholder { color: var(--ink-3); }
.mbt-input:focus { outline: none; border-color: var(--mbt-accent); }

/* ── Rating ─────────────────────────────────────────────────────── */

.mbt-rate { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-size: 13px; color: var(--ink-3); }
.mbt-rate__stars { display: inline-flex; }
.mbt-star {
  background: none; border: 0; cursor: pointer; padding: 0 2px;
  font-size: 21px; line-height: 1; color: var(--line-2); transition: color .1s;
}
.mbt-star.is-on, .mbt-star:hover, .mbt-star:hover ~ .mbt-star { color: var(--mbt-accent); }
/* Hover highlights left-to-right, so the sibling combinator has to undo the
   stars after the cursor rather than before it. */
.mbt-rate__stars:hover .mbt-star { color: var(--mbt-accent); }
.mbt-rate__stars:hover .mbt-star:hover ~ .mbt-star { color: var(--line-2); }
.mbt-rate__msg { color: var(--ok); }

/* ── Chapter ledger ─────────────────────────────────────────────── */
/* Deliberately a dense list, not a card grid. Someone looking for chapter 847
   is scanning numbers; cards put six chapters on a phone screen where a list
   puts fifteen. */

.mbt-chapters { margin-top: 40px; }
.mbt-chapters__head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.mbt-chapters__head h2 { margin: 0; font-size: 20px; letter-spacing: -0.02em; }
.mbt-chapters__tools { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.mbt-chapters__tools .mbt-input { width: 190px; }

.mbt-ch-list { list-style: none; margin: 0; padding: 0; }
.mbt-ch { border-bottom: 1px solid var(--line); }
.mbt-ch[hidden] { display: none; }
.mbt-ch > a {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px 13px 12px; text-decoration: none;
  border-left: 2px solid transparent;
  transition: background .12s, border-color .12s;
}
.mbt-ch > a:hover { background: var(--bg-2); border-left-color: var(--mbt-accent); }
.mbt-ch__num {
  font: 600 14px/1 var(--mono); font-variant-numeric: tabular-nums;
  flex: none; min-width: 116px; color: var(--ink);
}
.mbt-ch__title {
  color: var(--ink-2); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mbt-ch__date { margin-left: auto; flex: none; color: var(--ink-3); font-size: 12.5px; }
.mbt-ch__new {
  flex: none; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--mbt-accent); border: 1px solid currentColor; border-radius: 3px; padding: 2px 6px;
}
/* Already-read chapters dim. Written by JS from local history — on a 1000
   chapter series, knowing where you stopped is the single most useful thing
   this page can tell you. */
.mbt-ch.is-read .mbt-ch__num { color: var(--ink-3); font-weight: 500; }
.mbt-ch.is-read .mbt-ch__title { color: var(--ink-3); }

/* ── FAQ ────────────────────────────────────────────────────────── */

.mbt-faq { margin-top: 46px; max-width: 74ch; }
.mbt-faq h2 { font-size: 20px; letter-spacing: -0.02em; margin: 0 0 10px; }
.mbt-faq__item { border-bottom: 1px solid var(--line); padding: 12px 0; }
.mbt-faq__item summary {
  cursor: pointer; font-weight: 600; font-size: 15px; list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.mbt-faq__item summary::-webkit-details-marker { display: none; }
.mbt-faq__item summary::before {
  content: "›"; color: var(--mbt-accent); font-size: 18px;
  transition: transform .15s; display: inline-block;
}
.mbt-faq__item[open] summary::before { transform: rotate(90deg); }
.mbt-faq__item p { margin: 8px 0 2px 28px; color: var(--ink-2); font-size: 14.5px; }

/* ── Reader ─────────────────────────────────────────────────────── */

.mbt-crumbs { font-size: 12.5px; color: var(--ink-3); padding: 16px 0 4px; }
.mbt-crumbs a { text-decoration: none; }
.mbt-crumbs a:hover { color: var(--ink); }
.mbt-crumbs span { margin: 0 6px; }

.mbt-reader-head {
  display: flex; align-items: flex-start; gap: 16px;
  padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.mbt-reader-head h1 { margin: 0; font-size: clamp(20px, 3.5vw, 28px); letter-spacing: -0.02em; }
.mbt-reader-sub { margin: 4px 0 0; color: var(--ink-2); font-size: 14px; }
.mbt-reader-head .mbt-btn { margin-left: auto; flex: none; }

.mbt-bookmark .mbt-bookmark__on { display: none; }
.mbt-bookmark.is-on .mbt-bookmark__on { display: inline; }
.mbt-bookmark.is-on .mbt-bookmark__off { display: none; }
.mbt-bookmark.is-on { border-color: var(--mbt-accent); color: var(--mbt-accent); }

.mbt-chnav { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.mbt-chnav .mbt-select { flex: 1; min-width: 0; }
.mbt-chnav select {
  width: 100%; padding: 11px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--bg-2); color: var(--ink);
  font: 14px/1 var(--sans); cursor: pointer;
}

.mbt-reader { max-width: var(--max-read); margin: 0 auto; background: #000; border-radius: var(--r); overflow: hidden; }
[data-theme="light"] .mbt-reader { background: var(--bg-3); }
.mbt-page {
  /* content-visibility keeps the browser from laying out 60 offscreen images
     at once; contain-intrinsic-size stops that from causing scrollbar jitter. */
  content-visibility: auto;
  contain-intrinsic-size: auto 1200px;
}
.mbt-page img { display: block; width: 100%; height: auto; }
/* Hotlinked pages have no stored dimensions. A typical manga page ratio keeps
   them from collapsing to zero height and shoving the layout on load; any image
   that does carry width/height overrides this with its own real ratio. */
.mbt-page img:not([width]) { aspect-ratio: 2 / 3; object-fit: contain; }
.mbt-reader__empty { padding: 60px 20px; text-align: center; }

/* ── Ads ────────────────────────────────────────────────────────── */

.mbt-main .mb-ad, .mb-ad { margin: 18px auto; text-align: center; max-width: var(--max-read); min-height: 1px; }
.mb-ad--reader_inline { margin: 6px auto; }

/* ── Comments ───────────────────────────────────────────────────── */

.mbt-comments { max-width: var(--max-read); margin: 44px auto 0; }
.mbt-comments h2 { font-size: 18px; letter-spacing: -0.02em; margin: 0 0 14px; }
.mbt-cform { margin-bottom: 26px; display: grid; gap: 9px; }
.mbt-cform__row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.mbt-cform__foot { display: flex; align-items: center; gap: 12px; }
.mbt-cform__foot .mbt-btn { margin-left: auto; }
.mbt-replying { font-size: 13px; color: var(--ink-3); }

.mbt-clist { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.mbt-clist--sub {
  margin: 12px 0 0 0; padding-left: 16px;
  border-left: 2px solid var(--line); gap: 12px;
}
.mbt-c__head { display: flex; align-items: baseline; gap: 10px; font-size: 13.5px; }
.mbt-c__head time { color: var(--ink-3); font-size: 12px; }
.mbt-c__body { margin: 5px 0 6px; color: var(--ink-2); font-size: 14.5px; overflow-wrap: anywhere; }

/* ── History drawer ─────────────────────────────────────────────── */

.mbt-drawer { position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.6); display: flex; justify-content: flex-end; }
.mbt-drawer[hidden] { display: none; }
.mbt-drawer__panel {
  width: min(400px, 92vw); background: var(--bg-2); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.mbt-drawer__head {
  display: flex; align-items: center; padding: 16px var(--pad);
  border-bottom: 1px solid var(--line);
}
.mbt-drawer__head h2 { margin: 0; font-size: 16px; }
.mbt-drawer__head .mbt-icon { margin-left: auto; }
.mbt-drawer__body { overflow-y: auto; padding: 8px 0; }
.mbt-drawer__body a {
  display: flex; align-items: baseline; gap: 10px;
  padding: 11px var(--pad); text-decoration: none; font-size: 14px;
}
.mbt-drawer__body a:hover { background: var(--bg-3); }
.mbt-drawer__body time { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.mbt-drawer__empty { padding: 30px var(--pad); color: var(--ink-3); font-size: 14px; }

/* ── Pages / prose / empty ──────────────────────────────────────── */

.mbt-page-wrap, .mbt-page:has(> article) { }
.mbt-prose { max-width: 70ch; margin: 30px auto; }
.mbt-prose h1 { font-size: clamp(24px, 4vw, 36px); letter-spacing: -0.02em; }
.mbt-prose a { color: var(--mbt-accent); }

.mbt-empty { text-align: center; padding: 90px 20px; }
.mbt-empty__code { font: 800 68px/1 var(--mono); color: var(--line-2); margin: 0 0 8px; }
.mbt-empty h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: -0.02em; }
.mbt-empty p { color: var(--ink-2); margin: 0 0 22px; }

/* ── Footer ─────────────────────────────────────────────────────── */

.mbt-foot { border-top: 1px solid var(--line); margin-top: 60px; background: var(--bg-2); }
.mbt-foot__in { max-width: var(--max); margin: 0 auto; padding: 30px var(--pad); }
.mbt-foot__brand { margin: 0 0 8px; font-weight: 650; }
.mbt-foot__nav { display: flex; flex-wrap: wrap; gap: 16px; list-style: none; margin: 0 0 12px; padding: 0; font-size: 14px; }
.mbt-foot__nav a { color: var(--ink-2); text-decoration: none; }
.mbt-foot__nav a:hover { color: var(--ink); }
.mbt-foot__note { margin: 0; color: var(--ink-3); font-size: 12.5px; max-width: 70ch; }

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .mbt-hero__in { grid-template-columns: 130px 1fr; gap: 18px; padding-top: 22px; }
  .mbt-cover__badge { font-size: 10px; padding: 4px 8px; }
  .mbt-nav { display: none; }
}

@media (max-width: 560px) {
  .mbt-hero__in { grid-template-columns: 1fr; }
  .mbt-cover { width: 148px; }
  .mbt-chapters__tools { width: 100%; margin-left: 0; }
  .mbt-chapters__tools .mbt-input { flex: 1; width: auto; }
  .mbt-ch__num { min-width: 96px; font-size: 13px; }
  .mbt-ch__title { display: none; }
  .mbt-cform__row { grid-template-columns: 1fr; }
  .mbt-chnav .mbt-btn { padding: 11px 12px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
