:root {
  --paper: #F2F4F5;
  --ink: #15151D;
  --tone: rgba(21, 21, 29, .16);
  --panel: #FFFFFF;
  --blue: #2B3CFF;
  --on-blue: #FFFFFF;
  --yellow: #FFE45C;
  --display: "Dela Gothic One", "Hiragino Sans", "Yu Gothic", Impact, sans-serif;
  --body: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Trebuchet MS", system-ui, sans-serif;
  color-scheme: light;
  box-sizing: border-box;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12121A;
    --ink: #F2F4F5;
    --tone: rgba(242, 244, 245, .14);
    --panel: #1B1B27;
    --blue: #7480FF;
    --on-blue: #0D0D14;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: inherit; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 500;
  font-size: 1.0625rem;
  line-height: 1.55;
}
.app { min-height: 100vh; }
.wrap { max-width: 1080px; width: 100%; margin: 0 auto; padding: 0 20px; }
:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

/* ---------- Cabecera ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0; }
.brand { font-family: var(--display); font-size: 1.35rem; letter-spacing: .01em; }
.brand small { font-family: var(--body); font-weight: 700; font-size: .8rem; margin-left: 8px; opacity: .7; }

/* ---------- Hero ---------- */
.hero { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 56px; }
.panel { border: 4px solid var(--ink); background: var(--panel); position: relative; overflow: hidden; }
.hero-text {
  padding: clamp(24px, 4vw, 44px);
  display: flex; flex-direction: column; justify-content: center; gap: 18px;
  clip-path: polygon(0 0, 100% 0, 96% 100%, 0 100%);
  background-image: radial-gradient(var(--tone) 1.2px, transparent 1.7px);
  background-size: 9px 9px;
}
.hero h1 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: 1.02; margin: 0; letter-spacing: -.01em;
}
.hero h1 span { display: block; }
.hero p { margin: 0; max-width: 34ch; font-size: 1.1rem; }
.btn {
  align-self: flex-start;
  font-family: var(--display); font-size: 1rem;
  background: var(--blue); color: var(--on-blue);
  border: 4px solid var(--ink);
  padding: 12px 22px;
  box-shadow: 6px 6px 0 var(--ink);
  text-decoration: none; cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translate(3px, 3px); box-shadow: 3px 3px 0 var(--ink); }
.btn:active { transform: translate(6px, 6px); box-shadow: 0 0 0 var(--ink); }

.hero-art { min-height: 320px; background: var(--panel); }
.hero-art::before {
  content: ""; position: absolute; inset: -20%;
  background: repeating-conic-gradient(from 0deg at 50% 50%, var(--ink) 0 1.1deg, transparent 1.1deg 5.5deg);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 24%, #000 66%);
          mask-image: radial-gradient(circle at 50% 50%, transparent 24%, #000 66%);
  opacity: .85;
}
.hero-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.sfx {
  position: absolute; right: 8%; bottom: 8%;
  font-family: var(--display);
  font-size: clamp(2.6rem, 8vw, 4.4rem);
  color: var(--yellow);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-9deg);
  animation: slam .5s cubic-bezier(.2, 1.6, .4, 1) .25s both;
}
@keyframes slam {
  from { transform: rotate(-9deg) scale(2.6); opacity: 0; }
  to   { transform: rotate(-9deg) scale(1);   opacity: 1; }
}

/* ---------- Biblioteca ---------- */
.shelf-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.shelf-head h2 { font-family: var(--display); font-weight: 400; font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: .95rem; cursor: pointer; }
.switch input { width: 20px; height: 20px; accent-color: var(--blue); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 18px; margin: 0; padding: 0; list-style: none;
}
.grid.rtl { direction: rtl; }
.card { direction: ltr; border: 4px solid var(--ink); background: var(--panel); display: flex; flex-direction: column; }
.card[hidden] { display: none; }
.cover {
  aspect-ratio: 5 / 6;
  border-bottom: 4px solid var(--ink);
  background-color: var(--panel);
  background-image: radial-gradient(var(--tone) 1.3px, transparent 1.8px);
  background-size: 8px 8px;
  position: relative;
}
.cover.spot { background-color: var(--blue); background-image: radial-gradient(rgba(0, 0, 0, .22) 1.3px, transparent 1.8px); }
.cover svg, .cover img { width: 100%; height: 100%; display: block; object-fit: cover; }
.cover .tag {
  position: absolute; left: 10px; top: 10px;
  background: var(--yellow); color: #15151D;
  border: 3px solid #15151D;
  font-weight: 700; font-size: .8rem; padding: 1px 9px;
}
.info { padding: 14px 14px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.info h3 { font-family: var(--display); font-weight: 400; font-size: 1.25rem; line-height: 1.15; margin: 0; }
.info .meta { margin: 0; font-size: .92rem; opacity: .8; }
.more {
  margin-top: auto; align-self: flex-start;
  font: inherit; font-weight: 700; font-size: .95rem;
  background: none; color: var(--ink);
  border: 0; border-bottom: 3px solid var(--blue);
  padding: 2px 0; cursor: pointer;
}
.bubble {
  position: relative;
  margin: 6px 0 4px; padding: 12px 14px;
  background: var(--paper); color: var(--ink);
  border: 3px solid var(--ink); border-radius: 22px;
  font-size: .95rem; line-height: 1.45;
}
.bubble::after {
  content: ""; position: absolute; left: 26px; top: -14px;
  width: 18px; height: 18px; background: var(--paper);
  border-left: 3px solid var(--ink); border-top: 3px solid var(--ink);
  transform: rotate(45deg);
}
.bubble[hidden] { display: none; }
.empty { padding: 28px; border: 4px dashed var(--ink); text-align: center; font-weight: 700; }
.empty[hidden] { display: none; }

footer { margin: 64px 0 28px; font-size: .9rem; opacity: .8; border-top: 4px solid var(--ink); padding-top: 16px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .hero-text { clip-path: none; }
  .hero-art { min-height: 260px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .sfx { animation: none; }
  .btn { transition: none; }
}

.read { font-weight: 700; font-size: .95rem; color: var(--ink); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 4px; text-decoration-color: var(--blue); align-self: flex-start; }

/* ---------- Lector ---------- */
.reader-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 8px 0 18px; }
.reader-bar h1 { font-family: var(--display); font-weight: 400; font-size: clamp(1.3rem, 3.5vw, 1.9rem); margin: 0; }
.reader-bar select, .nav-btn { font: inherit; font-weight: 700; color: var(--ink); background: var(--panel); border: 3px solid var(--ink); padding: 6px 12px; cursor: pointer; }
.nav-btn:disabled { opacity: .35; cursor: default; }
.page-view { border: 4px solid var(--ink); background: var(--panel); max-width: 640px; margin: 0 auto; }
.page-view img { display: block; width: 100%; height: auto; }
.reader-nav { display: flex; gap: 10px; justify-content: center; align-items: center; margin: 16px 0; font-weight: 700; }

/* ---------- Menú lateral desplegable ---------- */
.sidebar { position: fixed; top: 0; left: 0; z-index: 30; width: 250px; max-width: 85vw; height: 100vh; padding: 22px 16px; border-right: 4px solid var(--ink); background: var(--panel); display: flex; flex-direction: column; gap: 28px; transform: translateX(-105%); transition: transform .25s ease; visibility: hidden; }
.app.menu-open .sidebar { transform: none; visibility: visible; }
.sidebar .brand { line-height: 1.1; padding-right: 36px; }
.sidebar .brand small { display: block; margin: 6px 0 0; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu a { font-weight: 700; color: var(--ink); text-decoration: none; padding: 9px 12px; border: 3px solid transparent; }
.menu a:hover { border-color: var(--ink); }
.menu a[aria-current="page"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.menu-toggle { position: fixed; top: 25px; left: 16px; z-index: 20; width: 46px; height: 42px; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 0 10px; background: var(--panel); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); cursor: pointer; }
.menu-toggle span { display: block; height: 3px; background: var(--ink); }
.menu-close { position: absolute; top: 14px; right: 14px; font: inherit; font-weight: 700; color: var(--ink); background: none; border: 3px solid var(--ink); width: 34px; height: 34px; cursor: pointer; }
.scrim { position: fixed; inset: 0; z-index: 25; background: rgba(0, 0, 0, .45); }
.scrim[hidden] { display: none; }
.top { padding-left: 64px; }

/* ---------- Login / Register ---------- */
.auth { display: flex; gap: 10px; }
.auth-btn { font-weight: 700; font-size: .95rem; color: var(--ink); background: var(--panel); text-decoration: none; border: 3px solid var(--ink); padding: 7px 16px; box-shadow: 4px 4px 0 var(--ink); transition: transform .1s, box-shadow .1s; }
.auth-btn.primary { background: var(--blue); color: var(--on-blue); }
.auth-btn:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }


/* ---------- Sinopsis al pasar el cursor ---------- */
.cover { overflow: hidden; }
.cover img { transition: transform .45s ease, filter .45s ease; }
.cover .tag { z-index: 2; }
.synopsis {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 10px;
  padding: 18px 16px;
  color: #F2F4F5;
  background: linear-gradient(to top, rgba(13, 13, 20, .96) 0%, rgba(13, 13, 20, .88) 55%, rgba(13, 13, 20, .35) 100%);
  opacity: 0; transform: translateY(14px);
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.synopsis p { margin: 0; font-size: .95rem; line-height: 1.5; }
.syn-tag { align-self: flex-start; background: var(--yellow); color: #15151D; border: 3px solid #15151D; font-weight: 700; font-size: .78rem; padding: 0 9px; }
.cover:hover .synopsis, .cover:focus .synopsis, .cover:focus-within .synopsis { opacity: 1; transform: none; }
.cover:hover img, .cover:focus img { transform: scale(1.07); filter: blur(2px) brightness(.8); }
@media (prefers-reduced-motion: reduce) {
  .cover img, .synopsis { transition: none; }
  .cover:hover img, .cover:focus img { transform: none; }
}

/* ---------- Lista de capítulos ---------- */
a.cover { display: block; color: inherit; text-decoration: none; cursor: pointer; }
.serie-head { display: grid; grid-template-columns: minmax(160px, 260px) 1fr; gap: 24px; align-items: start; margin: 8px 0 24px; }
.serie-cover { width: 100%; aspect-ratio: 5 / 7; object-fit: cover; border: 4px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); }
.serie-head h1 { font-family: var(--display); font-weight: 400; font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.1; margin: 0 0 6px; }
.serie-head .meta { margin: 0 0 18px; opacity: .8; }
.chapters { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.chapters a { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--panel); color: var(--ink); text-decoration: none; font-weight: 700; border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); transition: transform .1s, box-shadow .1s; }
.chapters a:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); background: var(--blue); color: var(--on-blue); }
.chapters small { font-weight: 500; opacity: .75; }
@media (max-width: 640px) { .serie-head { grid-template-columns: 1fr; } .serie-cover { max-width: 240px; } }

/* ---------- Logo pequeño en la esquina ---------- */

.logo-mini { position: relative; flex: none; width: 46px; height: 56px; border: 3px solid var(--ink); background: var(--panel); overflow: hidden; display: block; }
.logo-mini::before { content: ""; position: absolute; inset: -20%; background: repeating-conic-gradient(from 0deg at 50% 50%, var(--ink) 0 2.2deg, transparent 2.2deg 11deg); -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 24%, #000 66%); mask-image: radial-gradient(circle at 50% 50%, transparent 24%, #000 66%); opacity: .85; }
.logo-mini svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.logo-mini .sfx { right: 2px; bottom: 1px; font-size: .62rem; -webkit-text-stroke: 1.5px var(--ink); text-shadow: 1px 1px 0 var(--ink); animation: none; }
.logo-mini:hover { transform: translate(1px, 1px); }
.site-id { display: flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.site-name { font-family: var(--display); font-size: 1.25rem; letter-spacing: .01em; white-space: nowrap; }
.site-id:hover .logo-mini { transform: translate(1px, 1px); }
@media (max-width: 520px) { .site-name { display: none; } }

/* ---------- Lector: herramientas, cascada y pantalla completa ---------- */
.reader { background: var(--paper); }
.reader-tools { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; justify-content: center; padding: 10px 0 14px; background: var(--paper); }
.rt-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nav-btn[aria-pressed="true"] { background: var(--blue); color: var(--on-blue); }
.seg { gap: 0; border: 3px solid var(--ink); }
.seg-btn { font: inherit; font-weight: 700; color: var(--ink); background: var(--panel); border: 0; padding: 6px 14px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 3px solid var(--ink); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.page-view img { cursor: pointer; }
.cascade { max-width: 720px; margin: 0 auto; border: 4px solid var(--ink); background: var(--panel); }
.cascade[hidden], #paginado[hidden], .reader-end[hidden], #finNext[hidden] { display: none; }
.cascade img { display: block; width: 100%; height: auto; aspect-ratio: auto 2 / 3; }
.reader-end { text-align: center; padding: 28px 0 8px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.reader-end p { margin: 0; }
.chapters .ok { font-style: normal; font-size: .8rem; background: var(--yellow); color: #15151D; border: 2px solid #15151D; padding: 0 8px; margin-left: 8px; }
.reader:fullscreen, .reader.is-fs { background: var(--paper); height: 100vh; overflow-y: auto; padding: 0 16px 24px; }
.reader:fullscreen .page-view { max-width: 900px; width: fit-content; }
.reader:fullscreen .page-view img { width: auto; max-width: 100%; max-height: calc(100vh - 150px); margin: 0 auto; }
.reader:fullscreen .cascade { max-width: 860px; }

/* ---------- Avatar (sesión iniciada) ---------- */
.avatar { width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); background: var(--blue); color: var(--on-blue); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 1.2rem; text-decoration: none; overflow: hidden; box-shadow: 4px 4px 0 var(--ink); transition: transform .1s, box-shadow .1s; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
a.avatar:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.avatar.big { width: 110px; height: 110px; font-size: 2.6rem; box-shadow: 6px 6px 0 var(--ink); }

/* ---------- Login / Registro / Perfil ---------- */
.auth-page { display: flex; justify-content: center; padding: 12px 0 8px; }
.auth-card { position: relative; width: 100%; max-width: 480px; border: 4px solid var(--ink); background: var(--panel); overflow: hidden; box-shadow: 8px 8px 0 var(--ink); }
.art-bg { position: absolute; inset: 0; opacity: .3; pointer-events: none; }
.art-bg::before { content: ""; position: absolute; inset: -20%; background: repeating-conic-gradient(from 0deg at 50% 50%, var(--ink) 0 1.1deg, transparent 1.1deg 5.5deg); -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 24%, #000 66%); mask-image: radial-gradient(circle at 50% 50%, transparent 24%, #000 66%); }
.art-bg svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-form { position: relative; display: flex; flex-direction: column; gap: 14px; padding: clamp(22px, 5vw, 36px); }
.auth-form h1 { font-family: var(--display); font-weight: 400; font-size: clamp(1.7rem, 5vw, 2.3rem); line-height: 1.1; margin: 0; }
.auth-sub { margin: 0; font-weight: 700; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; }
.auth-form input[type="text"], .auth-form input[type="email"], .auth-form input[type="password"] { font: inherit; font-weight: 500; color: var(--ink); background: var(--paper); border: 3px solid var(--ink); padding: 10px 12px; width: 100%; }
.auth-form input[readonly] { opacity: .7; }
.form-msg { min-height: 1.4em; margin: 0; font-weight: 700; }
.form-msg.is-error { color: #D7263D; }
@media (prefers-color-scheme: dark) { .form-msg.is-error { color: #FF7A8A; } }
.auth-form .btn { align-self: stretch; text-align: center; }
.auth-form .btn:disabled { opacity: .6; cursor: default; }
.auth-alt { margin: 0; text-align: center; font-weight: 700; }
.profile-top { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-btns { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.file-btn { display: inline-block; }
.profile-h { font-family: var(--display); font-weight: 400; font-size: 1.3rem; margin: 6px 0 0; }
#formPerfil { display: flex; flex-direction: column; gap: 14px; }
#quitarFoto[hidden] { display: none; }

/* ---------- Mi biblioteca / guardar ---------- */
.card { position: relative; }
.fav { position: absolute; top: 10px; right: 10px; z-index: 3; width: 40px; height: 44px; display: flex; align-items: center; justify-content: center; background: var(--panel); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); cursor: pointer; padding: 0; transition: transform .1s, box-shadow .1s; }
.fav svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linejoin: round; }
.fav:hover { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.fav[aria-pressed="true"] { background: var(--yellow); }
.fav[aria-pressed="true"] svg { fill: #15151D; stroke: #15151D; }
.fav[aria-pressed="true"]:not(:hover) { box-shadow: 3px 3px 0 var(--ink); }
.page-title { font-family: var(--display); font-weight: 400; font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0; }
.shelf-head .meta { margin: 0; font-weight: 700; opacity: .8; }
.save-btn { align-self: flex-start; margin: 0 0 18px; }
.progress { height: 10px; border: 3px solid var(--ink); background: var(--paper); }
.progress span { display: block; height: 100%; background: var(--blue); }
.empty { padding: 28px; border: 4px dashed var(--ink); text-align: center; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty p { margin: 0; }
.empty[hidden], #estante[hidden] { display: none; }

/* ---------- Aviso modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 100%; max-width: 420px; background: var(--panel); color: var(--ink); border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; margin: 0; }
.modal p { margin: 0; }
.modal-btns { display: flex; flex-direction: column; gap: 10px; }
.modal-btns .btn { text-align: center; }
.modal-btns .nav-btn { text-align: center; text-decoration: none; display: block; }
