/* ==========================================================
   MangaMundo — tema oscuro, acento rojo, tarjetas horizontales
   ========================================================== */
:root {
  --bg: #121216;
  --bg2: #0d0d10;
  --surface: #1e1f25;
  --surface2: #26272f;
  --border: #2a2b33;
  --border2: #393a44;
  --text: #f1f1f4;
  --muted: #9a9ba6;
  --faint: #6b6c77;
  --accent: #ff4d5b;
  --accent-bg: #d4202f;
  --accent-d: #b81a28;
  --gold: #ffd23f;
  --grad: linear-gradient(135deg, #ff2d3d, #ff5a3d);
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 6px;
  --shadow: 0 14px 34px -14px rgba(0, 0, 0, .8);
  --wrap: 1180px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 14px/1.5 Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { flex: 1; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { letter-spacing: -.01em; line-height: 1.2; margin: 0; }
code { font: 12.5px ui-monospace, Consolas, monospace; background: var(--surface2); padding: 1px 6px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- botones ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 6px; border: 1px solid transparent; background: none; color: var(--text);
  font: inherit; font-weight: 650; cursor: pointer; white-space: nowrap; transition: filter .15s, background .15s, border-color .15s;
}
.btn-primary { background: var(--accent-bg); color: #fff; }
.btn-primary:hover { background: var(--accent-d); }
.btn-ghost { border-color: var(--border2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-soft { background: var(--surface2); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn.disabled { opacity: .45; pointer-events: none; }
.btn.danger:hover { border-color: var(--err); color: #fca5a5; }

/* ---------------- cabecera ---------------- */
.site-header { position: sticky; top: 0; z-index: 40; background: #16161a; box-shadow: 0 1px 0 #24242a; }
.header-inner { display: flex; align-items: center; gap: 34px; height: 58px; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.logo em { font-style: normal; color: var(--accent); }
.logo-mark img { width: 38px; height: 38px; transition: transform .2s; }
.logo-mark:hover img { transform: rotate(-6deg) scale(1.05); }
.main-nav { display: flex; gap: 2px; height: 100%; }
.main-nav a {
  position: relative; display: flex; align-items: center; padding: 0 14px; height: 100%;
  font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #b9b9c1;
  transition: color .15s;
}
.main-nav a:hover { color: #fff; }
.main-nav a[aria-current] { color: #fff; }
.main-nav a::after {
  content: ""; position: absolute; left: 50%; bottom: 14px; width: 16px; height: 2px; margin-left: -8px;
  background: #fff; border-radius: 2px; transform: scaleX(0); transition: transform .2s;
}
.main-nav a[aria-current]::after, .main-nav a:hover::after { transform: scaleX(1); }
.main-nav a:hover:not([aria-current])::after { background: var(--accent-bg); }
.header-icons { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; color: #e9e9ee; transition: background .15s, color .15s; }
.icon-btn:hover { background: #25252b; color: #fff; }
.icon-btn.round { border-radius: 50%; background: #2a2a31; }
.icon-btn.round:hover { background: var(--accent-bg); }
.tagline-bar { text-align: center; font-size: 11.5px; color: #c6c6cc; padding: 4px 16px; background: #26262c; }
@media (max-width: 640px) {
  .header-inner { gap: 6px; }
  .main-nav { overflow-x: auto; scrollbar-width: none; }
  .main-nav::-webkit-scrollbar { display: none; }
  .main-nav a { padding: 0 9px; letter-spacing: .06em; font-size: 11px; }
  .main-nav a::after { bottom: 12px; }
}

/* ---------------- clasificación (banda roja) ---------------- */
.ranking {
  position: relative; padding: 26px 0 28px; overflow: hidden;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 14px),
    radial-gradient(900px 300px at 20% 0%, rgba(255, 70, 70, .35), transparent 70%),
    linear-gradient(180deg, #8a1a1c 0%, #5e1012 70%, #121216 100%);
}
.rank-head { margin-bottom: 14px; }
.rank-head h2 { font-size: 22px; font-weight: 600; }
.rank-tabs { display: flex; gap: 22px; margin-top: 10px; }
.rank-tabs button {
  background: none; border: 0; padding: 4px 0; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: #f3d7d7; border-bottom: 2px solid transparent;
}
.rank-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.rank-tabs button:hover { color: #fff; }
.rank-top { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.rank-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(210px, 1fr); gap: 10px; margin-top: 12px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x mandatory; }
.rank-rail::-webkit-scrollbar-thumb { background: var(--accent-bg); border-color: #5e1012; }
@media (max-width: 860px) { .rank-top { grid-template-columns: 1fr; } }

.rcard { display: flex; background: rgba(24, 24, 29, .92); border-radius: 6px; overflow: hidden; scroll-snap-align: start; transition: transform .15s, box-shadow .15s; }
.rcard:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px rgba(255, 45, 61, .6), var(--shadow); }
.rcard img { width: 64px; height: 90px; object-fit: cover; flex: none; }
.rcard.big img { width: 40%; height: 150px; }
.rcard-body { flex: 1; min-width: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.rcard-top { display: flex; align-items: center; gap: 6px; }
.rnum { font-size: 20px; font-weight: 800; color: var(--gold); line-height: 1; }
.rnum::before { content: "#"; font-size: 12px; color: #a08832; margin-right: 1px; vertical-align: top; }
.rcard.big .rnum { font-size: 26px; }
.stat { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rcard-title { font-weight: 600; font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard:not(.big) .rcard-title { -webkit-line-clamp: 1; }
.rcard.big .rcard-title { font-size: 15px; }
.rcard.big .mrow-tags { margin-top: auto; }

/* ---------------- búsqueda + orden ---------------- */
.listing { padding-top: 48px; padding-bottom: 20px; }
.big-title { text-align: center; font-size: clamp(26px, 4.2vw, 40px); font-weight: 800; margin-bottom: 26px; }
.big-search { display: flex; align-items: center; background: #1a1a1f; border: 1px solid var(--border); border-radius: 4px; }
.big-search:focus-within { border-color: #4a4b55; }
.big-search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text); font: inherit; font-size: 15px; padding: 18px 16px; }
.big-search button { background: none; border: 0; color: var(--text); padding: 12px 16px; cursor: pointer; }
.sortbar { display: flex; align-items: center; gap: 12px; margin: 14px 0 20px; flex-wrap: wrap; }
.sorts { display: flex; gap: 6px; flex-wrap: wrap; }
.sorts a {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 4px;
  font-size: 11.5px; font-weight: 600; color: var(--muted); background: #1a1a1f; border: 1px solid var(--border);
}
.sorts a span { max-width: 0; overflow: hidden; white-space: nowrap; transition: max-width .2s; }
.sorts a:hover span, .sorts a[aria-current] span { max-width: 120px; }
.sorts a[aria-current] { color: #fff; border-color: var(--accent); background: rgba(255, 45, 61, .14); }
.sort-count { margin-left: auto; font-size: 12.5px; }
.genre-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 20px; }

/* ---------------- tarjetas horizontales ---------------- */
.rows { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; }
@media (max-width: 860px) { .rows { grid-template-columns: 1fr; } }
.mrow { display: flex; background: var(--surface); border-radius: 4px; overflow: hidden; min-height: 168px; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); transition: box-shadow .15s; }
.mrow:hover { box-shadow: 0 0 0 1px #3c3d47, var(--shadow); }
.mrow-cover { position: relative; flex: none; width: 120px; background: var(--surface2); }
.mrow-cover img { width: 120px; height: 100%; min-height: 168px; object-fit: cover; transition: filter .2s; }
.mrow:hover .mrow-cover img { filter: brightness(1.1); }
.status-chip {
  position: absolute; top: 6px; left: 6px; z-index: 1; display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: rgba(40, 40, 46, .9); color: #e7e7ea;
}
.status-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.status-chip.s-en-emision::before { background: var(--ok); }
.status-chip.s-finalizado::before { background: #60a5fa; }
.status-chip.s-hiatus::before { background: var(--warn); }
.new-chip { position: absolute; bottom: 6px; left: 6px; font-size: 9.5px; font-weight: 800; letter-spacing: .06em; padding: 2px 6px; border-radius: 3px; background: var(--accent-bg); color: #fff; }
.mrow-body { flex: 1; min-width: 0; padding: 12px 16px; display: flex; flex-direction: column; }
.mrow-top { display: flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--muted); }
.mrow-title { font-size: 15px; font-weight: 700; margin: 4px 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow-title a:hover { color: var(--accent); }
.mrow-tags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: #2b2c34; color: #e2e2e6;
}
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .6; }
.tag.more { background: none; color: var(--muted); padding-left: 2px; }
.tag.more::before { display: none; }
a.tag:hover, .tag.on { background: rgba(255, 45, 61, .2); color: #ffd0d4; }
.mrow-desc { margin: 0 0 6px; font-size: 12.5px; color: #c3c3ca; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mrow-read { margin-top: auto; align-self: flex-start; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); padding: 4px 0; }
.mrow-read:hover { color: #ff7b85; }
@media (max-width: 480px) {
  .mrow-cover, .mrow-cover img { width: 96px; }
  .mrow-top .stat:last-child { display: none; }
}

h1.tagline-bar { margin: 0; font-size: 11.5px; font-weight: 500; letter-spacing: 0; line-height: 1.5; }
.h1-type { display: block; margin-top: 6px; font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.aliases { margin: -6px 0 14px; font-size: 13.5px; color: #d6d6dc; }
.faq { max-width: 900px; }
.faq h2 { font-size: 20px; margin-bottom: 14px; }
.faq details { background: var(--surface); border-radius: 6px; margin-bottom: 8px; border-left: 3px solid transparent; }
.faq details[open] { border-left-color: var(--accent); }
.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 650; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; float: right; color: var(--accent); font-weight: 800; }
.faq details[open] summary::after { content: "–"; }
.faq details p { margin: 0; padding: 0 16px 14px; color: #c9c9cf; }

/* ---------------- presentación (SEO) ---------------- */
.about { margin-top: 44px; padding-top: 40px; padding-bottom: 10px; border-top: 1px solid var(--border); }
.about-head { text-align: center; margin-bottom: 22px; }
.about-head h2 { font-size: clamp(22px, 3.2vw, 30px); font-weight: 800; }
.about-sub { margin: 8px 0 0; color: var(--accent); font-weight: 600; }
.about-text { max-width: 860px; margin: 0 auto 34px; color: #cfcfd5; font-size: 14.5px; line-height: 1.7; text-align: center; }
.about-text p { margin: 0 0 12px; }
.about-text strong { color: var(--text); }
.about-h3 { font-size: 19px; font-weight: 700; margin: 0 0 16px; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 34px; }
@media (max-width: 860px) { .features { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .features { grid-template-columns: 1fr; } }
.feature { display: flex; gap: 14px; align-items: flex-start; padding: 16px; background: var(--surface); border-radius: 6px; border-left: 3px solid var(--accent); transition: transform .15s, background .15s; }
.feature:hover { transform: translateY(-2px); background: var(--surface2); }
.feature-ic { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 10px; background: rgba(255, 45, 61, .14); color: var(--accent); }
.feature h3 { font-size: 14.5px; margin: 1px 0 4px; }
.feature p { margin: 0; font-size: 13px; color: var(--muted); }
.genre-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 30px; }
.genre-cloud .tag { font-size: 12px; padding: 5px 12px; }
.about-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 20px 24px; border-radius: 8px;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .03) 0 2px, transparent 2px 14px), linear-gradient(90deg, #6e1416, #3a0d0f);
}
.about-cta span { font-size: 17px; font-weight: 700; }

/* ---------------- paginación ---------------- */
.pager { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin: 36px 0 16px; }
.pager a, .pager span { min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: 4px; font-weight: 600; font-size: 13px; }
.pager a:hover { background: var(--surface2); }
.pager .cur { background: var(--accent-bg); color: #fff; }
.pager .off { color: var(--faint); }
.pager .gap { color: var(--muted); }

/* ---------------- ficha ---------------- */
.section { padding-top: 32px; padding-bottom: 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: 20px; }
.manga-hero { position: relative; overflow: hidden; }
.manga-hero::before { content: ""; position: absolute; inset: -40px; background: var(--hero) center / cover; filter: blur(36px) saturate(120%); opacity: .35; }
.manga-hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg) 0%, rgba(18, 18, 22, .6) 60%, rgba(94, 16, 18, .45)); }
.manga-head { position: relative; z-index: 1; display: grid; grid-template-columns: 230px 1fr; gap: 30px; padding-top: 34px; padding-bottom: 30px; }
.manga-cover-wrap { position: relative; }
.manga-cover { width: 230px; aspect-ratio: 3 / 4.2; object-fit: cover; border-radius: 6px; box-shadow: 0 24px 50px -18px rgba(0, 0, 0, .9); }
.manga-cover-wrap .status-chip { top: 10px; left: 10px; font-size: 11px; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.crumbs a:hover { color: var(--text); }
.manga-info h1 { font-size: clamp(24px, 3.6vw, 36px); margin-bottom: 16px; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stats div { background: rgba(30, 31, 37, .85); border: 1px solid var(--border); border-radius: 6px; padding: 8px 14px; min-width: 96px; }
.stats b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11.5px; color: var(--muted); }
.manga-desc { color: #d0d0d6; max-width: 760px; margin: 4px 0 20px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 720px) { .manga-head { grid-template-columns: 1fr; } .manga-cover { width: 160px; } }

.chapter-tools { display: flex; gap: 8px; }
.chapter-tools input { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 7px 12px; color: var(--text); font: inherit; width: 170px; outline: 0; }
.chapter-tools input:focus { border-color: var(--accent); }
.chapters { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 8px; }
.chapters a { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 4px; background: var(--surface); border-left: 3px solid transparent; transition: background .15s, border-color .15s; }
.chapters a:hover { background: var(--surface2); border-left-color: var(--accent); }
.chapters li.read a { opacity: .55; }
.chapters li.read .ch-num::after { content: " ✓"; color: var(--ok); }
.chapters li.current a { border-left-color: var(--accent); background: var(--surface2); }
.ch-num { font-weight: 650; }
.ch-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------------- lector ---------------- */
.reader-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; }
.reader-progress i { display: block; height: 100%; width: 0; background: var(--accent-bg); }
.reader-head { padding-top: 20px; }
.reader-head h1 { font-size: 20px; margin-bottom: 16px; }
.reader-nav { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin: 0 0 20px; }
.reader-nav.bottom { margin: 26px 0 40px; }
.ch-select select {
  appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%239a9ba6' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") right 12px center no-repeat;
  border: 1px solid var(--border2); border-radius: 6px; color: var(--text); font: inherit; font-weight: 600; padding: 10px 36px 10px 14px; cursor: pointer; min-width: 180px;
}
.pages { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; background: #000; }
.pages img { width: 100%; height: auto; min-height: 120px; background: var(--surface); }

/* ---------------- vacío / 404 ---------------- */
.empty { text-align: center; padding: 80px 20px; }
.empty-art { font-size: 54px; margin-bottom: 8px; }
.empty h1 { font-size: 26px; margin-bottom: 8px; }
.empty p { margin: 0 0 22px; }
.small-empty { padding: 40px 20px; border: 1px dashed var(--border2); border-radius: 6px; }

/* ---------------- pie ---------------- */
.site-footer { margin-top: 56px; background: #1a1a1f; border-top: 1px solid var(--border); padding: 34px 0 0; }
.footer-cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; padding-bottom: 28px; }
.footer-cols nav { display: flex; flex-direction: column; gap: 8px; }
.footer-cols .f-title { font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; margin-bottom: 4px; }
.footer-cols a { font-size: 12.5px; color: var(--muted); }
.footer-cols a:hover { color: var(--text); }
.footer-copy { text-align: center; font-size: 12px; color: var(--muted); padding: 18px 16px; border-top: 1px solid var(--border); }
@media (max-width: 720px) { .footer-cols { grid-template-columns: 1fr 1fr; } }

/* ---------------- toasts (admin) ---------------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; max-width: calc(100vw - 36px); }
.toast { padding: 12px 16px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--border2); box-shadow: var(--shadow); font-size: 14px; max-width: 420px; animation: tin .25s ease-out; }
.toast.ok { border-left: 3px solid var(--ok); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.err { border-left: 3px solid var(--err); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } html { scroll-behavior: auto; } }

/* bandeau cookies (Google Analytics) */
.consent { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60; max-width: 560px; margin: 0 auto; display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.45); }
.consent p { margin: 0; flex: 1 1 260px; font-size: 14px; }
.consent div { display: flex; gap: 8px; }
