/* ============ MangaBao · estilos ============ */
:root {
  --bg: #0e1014;
  --surface: #171a21;
  --surface-2: #1f232c;
  --surface-3: #282d38;
  --border: #2a2f3a;
  --text: #e9ebf1;
  --muted: #98a1b3;
  --faint: #6b7385;
  --accent: #ff4d6d;
  --accent-2: #ff8fa3;
  --accent-soft: rgba(255, 77, 109, .14);
  --gold: #ffc53d;
  --green: #22c55e;
  --radius: 12px;
  --font: "Nunito Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Bangers", Impact, "Arial Black", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Logo ---------- */
.logo {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 1px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.logo .b { color: var(--accent); }
.logo-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #b5179e);
  display: grid; place-items: center;
  font-size: 20px;
  color: #fff;
  transform: rotate(-6deg);
  box-shadow: 0 4px 14px rgba(255, 77, 109, .35);
}
.logo .domain {
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(14, 16, 20, .9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.nav { display: flex; gap: 2px; }
.nav a {
  padding: 6px 11px; border-radius: 8px;
  color: var(--muted); font-weight: 700; font-size: 14px;
}
.nav a:hover, .nav a.on { color: var(--text); background: var(--surface-2); }
.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 12px; height: 38px; min-width: 0;
}
.search svg { flex: none; color: var(--muted); }
.search input {
  background: none; border: 0; outline: 0;
  width: 190px; min-width: 0; font-size: 14px;
}
.search input::placeholder { color: var(--faint); }
@media (max-width: 820px) {
  .nav { display: none; }
  .logo .domain { display: none; }
  .search input { width: 100px; }
}
@media (max-width: 380px) { .search input { width: 64px; } }

/* ---------- Badges & buttons ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 800;
  background: var(--surface-3); color: var(--text);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.genre { background: var(--surface-2); border-color: var(--border); cursor: pointer; }
.badge.genre:hover { border-color: var(--accent); color: var(--accent-2); }
.badge.type { background: var(--accent); color: #fff; letter-spacing: .5px; }
.badge.new { background: var(--accent); color: #fff; font-size: 10px; padding: 1px 7px; letter-spacing: .5px; }
.status {
  background: rgba(34, 197, 94, .13);
  color: #4ade80;
  border-color: rgba(34, 197, 94, .45);
  text-transform: uppercase; letter-spacing: .6px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink {
  0%   { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, .7); }
  50%  { opacity: .3; }
  70%  { box-shadow: 0 0 0 7px rgba(34, 197, 94, 0); }
  100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 800; font-size: 15px;
  transition: transform .12s, background .15s, border-color .15s;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 20px rgba(255, 77, 109, .3); }
.btn.primary:hover { background: #ff3358; }
.btn.big { min-height: 54px; font-size: 17px; width: 100%; }

.heart { width: 20px; height: 20px; transition: transform .2s; }
.heart path { fill: none; stroke: currentColor; stroke-width: 2; }
.btn.following { border-color: var(--accent); color: var(--accent-2); background: var(--accent-soft); }
.btn.following .heart path { fill: var(--accent); stroke: var(--accent); }
.btn.following .heart { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

/* ---------- Ad banner (parodia) ---------- */
.ad {
  position: relative;
  margin-top: 16px;
  border-radius: var(--radius);
  padding: 14px 48px 14px 16px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 10px, transparent 10px 20px),
    linear-gradient(90deg, #3b0a45, #7a0f3a 55%, #b8321a);
  border: 2px dashed rgba(255, 197, 61, .6);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.ad .ad-label {
  flex-basis: 100%; margin-bottom: -8px;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,.55);
}
.ad .ad-title { font-family: var(--display); font-size: 24px; letter-spacing: 1px; color: var(--gold); line-height: 1.1; }
.ad .ad-text { font-size: 14px; color: #f3dbe2; flex: 1 1 260px; }
.ad .ad-cta {
  background: var(--gold); color: #3b0a45; border: 0; border-radius: 8px;
  padding: 8px 14px; font-weight: 900; animation: wiggle 2.4s infinite;
}
@keyframes wiggle { 0%, 88%, 100% { transform: rotate(0); } 91% { transform: rotate(-4deg); } 94% { transform: rotate(4deg); } 97% { transform: rotate(-2deg); } }
.ad .ad-close {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.25);
  color: #fff; font-size: 16px; line-height: 1;
  display: grid; place-items: center;
}
.ad .ad-close:hover { background: rgba(0,0,0,.7); }

/* ---------- Hero / ficha ---------- */
.breadcrumbs { font-size: 13px; color: var(--muted); margin: 18px 0 0; }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs span { margin: 0 6px; color: var(--faint); }

.hero { position: relative; overflow: hidden; margin-top: 16px; }
.hero-bg {
  position: absolute; inset: -60px;
  background-size: cover; background-position: center;
  filter: blur(30px) brightness(.35) saturate(1.3);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(14,16,20,.15) 0%, var(--bg) 100%);
}
.hero-inner {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 250px 1fr; gap: 32px;
  padding-top: 32px; padding-bottom: 28px;
}
.cover-box { position: relative; }
.cover {
  width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover;
  border-radius: var(--radius);
  box-shadow: 0 20px 44px rgba(0,0,0,.6);
  background: var(--surface-2);
}
.cover-box .badge.type { position: absolute; bottom: 10px; left: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.info { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.info h1 {
  margin: 0; font-size: clamp(26px, 4.4vw, 42px); line-height: 1.12; font-weight: 900;
  text-wrap: balance;
}
.alt-title { margin: -6px 0 0; color: var(--muted); font-size: 15px; font-style: italic; }
.author { font-size: 14px; color: var(--muted); }
.author b { color: var(--accent-2); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; font-size: 14px; color: var(--muted); }
.stats b { color: var(--text); font-size: 15px; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 17px; }
.rating { display: inline-flex; align-items: center; gap: 8px; }
.rating .score { font-size: 20px; font-weight: 900; color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }

@media (max-width: 720px) {
  .hero-inner { grid-template-columns: 1fr; justify-items: center; text-align: center; gap: 20px; padding-top: 24px; }
  .cover-box { width: min(210px, 58vw); }
  .info { align-items: center; }
  .badges, .stats, .actions { justify-content: center; }
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 100%; }
}

/* ---------- Layout inferior ---------- */
.content { display: grid; grid-template-columns: 1fr 320px; gap: 20px; padding-top: 8px; padding-bottom: 40px; align-items: start; }
@media (max-width: 900px) { .content { grid-template-columns: 1fr; } }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card h2 { margin: 0; font-size: 18px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.card h2::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--accent); }

.synopsis { position: relative; white-space: pre-line; color: #cdd2dc; font-size: 15px; max-height: 7.5em; overflow: hidden; transition: max-height .35s ease; }
.synopsis.open { max-height: 80em; }
.synopsis:not(.open).clamped::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3em;
  background: linear-gradient(transparent, var(--surface));
}
.link-btn { background: none; border: 0; padding: 6px 0 0; color: var(--accent-2); font-weight: 800; font-size: 14px; }

/* Lista de capítulos */
.sort-btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 5px 10px; font-size: 13px; font-weight: 700; color: var(--muted); }
.sort-btn:hover { color: var(--text); }
.ch-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ch-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent;
  transition: border-color .15s, background .15s;
}
a.ch-item:hover { border-color: var(--accent); background: var(--surface-3); }
.ch-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ch-num { font-weight: 900; display: flex; align-items: center; gap: 8px; }
.ch-title { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; font-size: 12px; color: var(--muted); flex: none; text-align: right; }
.scan-tag { color: var(--accent-2); font-weight: 800; }
.ch-item.read .ch-num { color: var(--muted); }
.ch-item.read .ch-num::after { content: "✓ leído"; font-size: 11px; font-weight: 700; color: var(--green); }
.ch-item.locked { opacity: .75; border: 1px dashed var(--border); background: transparent; }
@media (max-width: 480px) {
  .ch-item { flex-direction: column; align-items: stretch; gap: 6px; }
  .ch-meta { flex-direction: row; justify-content: space-between; align-items: center; }
}

/* Info lateral */
.info-list { margin: 0; display: grid; gap: 0; }
.info-list div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.info-list div:last-child { border-bottom: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 800; text-align: right; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: #0b0c10; padding: 28px 0 36px; }
.support {
  display: flex; gap: 16px; align-items: flex-start;
  background: linear-gradient(135deg, rgba(255,77,109,.12), rgba(181,23,158,.08));
  border: 1px solid rgba(255,77,109,.35);
  border-radius: var(--radius);
  padding: 18px;
}
.support .ico { font-size: 28px; line-height: 1; }
.support h3 { margin: 0 0 4px; font-size: 16px; font-weight: 900; }
.support p { margin: 0; color: #cdd2dc; font-size: 14px; }
.foot-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: center; margin-top: 22px; font-size: 12px; color: var(--faint); }
.foot-bottom .logo { font-size: 22px; }
.foot-bottom .logo-mark { width: 24px; height: 24px; font-size: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; z-index: 100;
  transform: translate(-50%, 20px); opacity: 0;
  background: #fff; color: #111; font-weight: 800; font-size: 14px;
  padding: 10px 16px; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
  transition: opacity .25s, transform .25s;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast a { color: var(--accent); text-decoration: underline; margin-left: 6px; }

/* ============ LECTOR ============ */
body.reader { background: #090a0d; }
.rbar, .rfoot {
  position: fixed; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: rgba(14, 16, 20, .95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform .25s ease;
}
.rbar { top: 0; height: 54px; border-bottom: 1px solid var(--border); }
.rfoot { bottom: 0; height: calc(58px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); }
.progress { position: fixed; top: 54px; left: 0; right: 0; height: 3px; z-index: 41; background: rgba(255,255,255,.06); transition: transform .25s ease; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .2s; }
body.bars-hidden .rbar { transform: translateY(-100%); }
body.bars-hidden .rfoot { transform: translateY(100%); }
body.bars-hidden .progress { transform: translateY(-54px); }

.icon-btn {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; min-width: 40px; padding: 0 10px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2);
  font-weight: 800; font-size: 14px;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn.disabled { opacity: .35; pointer-events: none; }
.icon-btn svg { width: 18px; height: 18px; }
.rbar .logo { font-size: 22px; }
.rbar .logo-mark { width: 24px; height: 24px; font-size: 15px; }
.rtitle { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.rtitle b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rtitle span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-btn .lbl { display: inline; }
@media (max-width: 640px) { .rbar .logo { display: none; } .mode-btn .lbl { display: none; } .rfoot .icon-btn span { display: none; } }

.ch-select {
  flex: 1; min-width: 0; height: 40px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 0 10px; font-weight: 700; font-size: 14px;
}
.page-ind { flex: none; font-weight: 900; font-size: 13px; min-width: 58px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }

#stage { padding-top: 57px; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }

/* Cascada */
.cascade { max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.pg { margin: 0; position: relative; background: #14161b; aspect-ratio: 2 / 1; scroll-margin-top: 57px; }
.pg.loaded { aspect-ratio: auto; background: none; }
/* Las viñetas estrechas se muestran a su tamaño real, centradas, sin estirarse */
.pg img { width: auto; max-width: 100%; height: auto; margin: 0 auto; }
.pg .ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #353a46; font-family: var(--display); font-size: 56px; pointer-events: none;
}
.pg.loaded .ph { display: none; }
/* En pantallas grandes, las viñetas estrechas consecutivas se colocan lado a lado (en móvil, una debajo de otra) */
@media (min-width: 769px) {
  .cascade { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: flex-start; }
  .pg { flex: 0 0 100%; }
  .pg.loaded { flex-basis: var(--w, 100%); }
  .pg.loaded img { width: 100%; }
}
.pg-err {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  color: var(--muted); font-size: 14px; border: 2px dashed var(--border);
}
.pg-err code { color: var(--accent-2); }

/* Página a página */
.paged {
  position: relative;
  height: calc(100vh - 57px - 66px);
  height: calc(100dvh - 57px - 66px - env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: center;
  user-select: none; -webkit-user-select: none;
  touch-action: pan-y pinch-zoom;
  overflow: hidden;
}
.paged img { max-width: 100%; max-height: 100%; object-fit: contain; transition: opacity .15s; }
.paged img.loading { opacity: .25; }
.zone {
  position: absolute; top: 0; bottom: 0; width: 38%;
  background: none; border: 0; padding: 0;
  display: flex; align-items: center;
  color: rgba(255,255,255,0); font-size: 40px;
  transition: color .2s, background .2s;
}
.zone-l { left: 0; justify-content: flex-start; padding-left: 16px; }
.zone-r { right: 0; justify-content: flex-end; padding-right: 16px; }
@media (hover: hover) {
  .zone:hover { color: rgba(255,255,255,.7); }
  .zone-l:hover { background: linear-gradient(90deg, rgba(0,0,0,.35), transparent); }
  .zone-r:hover { background: linear-gradient(-90deg, rgba(0,0,0,.35), transparent); }
}
body.mode-paged .cascade { display: none; }
body.mode-cascade .paged { display: none; }
body.mode-paged:not(.at-end) .end { display: none; }
body.mode-paged.at-end .paged { display: none; }

/* Final de capítulo */
.end { max-width: 720px; margin: 0 auto; padding: 28px 16px 20px; display: flex; flex-direction: column; gap: 18px; }
.end-mark { text-align: center; font-family: var(--display); font-size: 30px; letter-spacing: 2px; color: var(--muted); }
.note-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.note-head small { display: block; color: var(--muted); font-size: 12px; }
.scan-av {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, #ffb703, var(--accent));
  color: #1a0b10; font-family: var(--display); font-size: 20px; letter-spacing: 1px;
  display: grid; place-items: center;
}
.note-text { margin: 0; white-space: pre-line; color: #d6dae3; font-size: 15px; }
.note-text.final { font-size: 16px; }
.coming {
  text-align: center; padding: 26px 18px;
  border-radius: var(--radius);
  border: 1px dashed rgba(34,197,94,.5);
  background: radial-gradient(ellipse at top, rgba(34,197,94,.12), transparent 70%), var(--surface);
}
.coming h3 { margin: 12px 0 6px; font-size: 24px; font-weight: 900; }
.coming p { margin: 4px 0; color: var(--muted); }
.end-links { display: flex; gap: 10px; }
.end-links .btn { flex: 1; font-size: 14px; }

/* Comentarios */
.c-input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--faint);
  font-size: 14px; margin-bottom: 14px;
}
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.comment { display: flex; gap: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  font-weight: 900; font-size: 15px; color: #fff;
  text-transform: uppercase;
}
.c-body { min-width: 0; flex: 1; }
.c-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; }
.c-top b { font-size: 14px; word-break: break-all; }
.c-top time { color: var(--faint); }
.c-badge { font-size: 10px; padding: 1px 7px; }
.c-badge.autor { background: var(--accent); color: #fff; }
.c-badge.vip { background: var(--gold); color: #2a1a00; }
.c-text { margin: 3px 0 6px; font-size: 15px; color: #d6dae3; overflow-wrap: anywhere; }
.c-actions { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.like-btn { background: none; border: 0; padding: 0; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 13px; }
.like-btn.on { color: var(--accent-2); }
.like-btn.on .heart path { fill: var(--accent); stroke: var(--accent); }
.like-btn .heart { width: 16px; height: 16px; }
