
:root {
  color-scheme: light;
  --page: #f8f7ff;
  --surface: rgba(255, 255, 255, .82);
  --surface-solid: #fff;
  --text: #292849;
  --muted: #747397;
  --border: #e7e3f7;
  --accent: #8877ed;
  --accent-strong: #7562df;
  --accent-soft: #f0edff;
  --shadow: 0 14px 40px rgba(62, 48, 119, .08);
  --hero-start: #fffaff;
  --hero-end: #e4ddff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e1328;
  --surface: rgba(22, 28, 53, .86);
  --surface-solid: #151b34;
  --text: #f4f1ff;
  --muted: #b1b3d3;
  --border: #2b3357;
  --accent: #b3a0ff;
  --accent-strong: #9b86ff;
  --accent-soft: #272343;
  --shadow: 0 14px 40px rgba(0, 0, 0, .22);
  --hero-start: #11172f;
  --hero-end: #302457;
}

/* Configuración general */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
  transition: background .2s ease, color .2s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

img {
  max-width: 100%;
}

/* Encabezado */

.site-header {
  min-height: 76px;
  padding: 0 clamp(20px, 5vw, 76px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -.03em;
}

.brand-star {
  color: var(--accent);
  font-size: 1.7rem;
  line-height: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--accent-soft);
}

/* Botones */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform .18s ease,
    background .18s ease,
    border-color .18s ease,
    color .18s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  background: var(--accent);
  color: #fff;
}

.button-primary:hover {
  background: var(--accent-strong);
}

.button-quiet,
.button-outline {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: transparent;
}

:root[data-theme="dark"] .button-quiet,
:root[data-theme="dark"] .button-outline {
  color: var(--text);
}

/* Portada principal */

.hero {
  position: relative;
  overflow: hidden;
  min-height: 340px;
  display: flex;
  align-items: center;
  padding: 56px clamp(24px, 9vw, 140px);
  background: linear-gradient(
    112deg,
    var(--hero-start) 8%,
    var(--hero-end) 100%
  );
  border-bottom: 1px solid var(--border);
}

.hero-copy {
  position: relative;
  z-index: 2;
  max-width: 540px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .72rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.16;
}

h1 {
  margin: 0;
  font-size: clamp(2.6rem, 5vw, 4.4rem);
  letter-spacing: -.045em;
}

h1 span {
  color: var(--accent);
}

.hero-description {
  margin: 18px 0 24px;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* Cielo decorativo */

.hero-sky {
  position: absolute;
  inset: 0 0 0 40%;
  overflow: hidden;
  opacity: .95;
  pointer-events: none;
}

.hero-sky::before,
.hero-sky::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
}

.hero-sky::before {
  width: 320px;
  height: 220px;
  right: 5%;
  bottom: -105px;
  background: rgba(183, 166, 255, .3);
}

.hero-sky::after {
  width: 240px;
  height: 180px;
  right: 25%;
  bottom: -110px;
  background: rgba(255, 255, 255, .22);
}

.moon {
  position: absolute;
  right: 17%;
  top: 55px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fff9db;
  box-shadow: 0 0 38px rgba(255, 246, 207, .5);
}

.moon::after {
  content: "";
  position: absolute;
  top: -8px;
  left: 14px;
  width: 49px;
  height: 49px;
  border-radius: 50%;
  background: var(--hero-end);
}

:root[data-theme="dark"] .moon {
  background: #e8dcff;
  box-shadow: 0 0 38px rgba(197, 160, 255, .3);
}

:root[data-theme="dark"] .moon::after {
  background: var(--hero-end);
}

.star {
  position: absolute;
  color: var(--accent);
}

.star-one {
  top: 35%;
  right: 38%;
  font-size: 1.1rem;
}

.star-two {
  top: 23%;
  right: 10%;
  font-size: 1.5rem;
}

.star-three {
  top: 60%;
  right: 24%;
  font-size: 2.2rem;
}

.sky-horizon {
  position: absolute;
  right: -5%;
  bottom: -50px;
  width: 75%;
  height: 150px;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(
    180deg,
    rgba(178, 160, 246, .3),
    rgba(141, 126, 211, .08)
  );
  transform: rotate(-4deg);
}

:root[data-theme="dark"] .sky-horizon {
  background: linear-gradient(
    180deg,
    rgba(116, 91, 196, .35),
    rgba(46, 47, 103, .12)
  );
}

/* Catálogo de novelas */

.novels-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 56px clamp(20px, 5vw, 76px) 68px;
}

.section-heading {
  margin-bottom: 28px;
  text-align: center;
}

.section-heading .eyebrow {
  margin-bottom: 8px;
}

h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  letter-spacing: -.035em;
}

.heading-flourish {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
}

.novel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.novel-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform .2s ease, box-shadow .2s ease;
}

.novel-card:hover {
  transform: translateY(-3px);
}

/* Portadas dinámicas de PostgreSQL */

.cover {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 190px;
  margin: 12px 12px 0;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    var(--accent-soft),
    var(--hero-end)
  );
}

.cover::before,
.cover::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
}

.cover::before {
  width: 220px;
  height: 220px;
  top: -80px;
  right: -30px;
  background: rgba(255, 255, 255, .16);
}

.cover::after {
  width: 180px;
  height: 180px;
  bottom: -100px;
  left: -15px;
  background: rgba(12, 14, 37, .12);
}

.cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-placeholder {
  color: var(--accent-strong);
  font-size: 2.4rem;
}

.cover-placeholder-title {
  max-width: 80%;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  overflow-wrap: anywhere;
}

/* Información de cada novela */

.novel-info {
  padding: 15px 17px 18px;
}

.novel-info h3 {
  margin: 0 0 9px;
  font-size: 1.22rem;
}

.novel-info h3 a:hover {
  color: var(--accent-strong);
}

.novel-info p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: .9rem;
  overflow-wrap: anywhere;
}

.read-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent-strong);
  font-size: .86rem;
  font-weight: 700;
}

.read-link:hover {
  text-decoration: underline;
}

:root[data-theme="dark"] .read-link {
  color: var(--accent);
}

.catalog-message {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

/* Pie de página */

.site-footer {
  padding: 28px clamp(20px, 5vw, 76px) 18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-brand {
  font-size: 1.1rem;
}

.footer-tagline {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
}

.footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .82rem;
}

.footer-links a:hover {
  color: var(--accent-strong);
}

.copyright {
  margin: 25px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: .75rem;
}

/* Tablets */

@media (max-width: 800px) {
  .hero {
    padding-top: 48px;
    padding-bottom: 48px;
  }

  .hero-sky {
    left: 25%;
    opacity: .45;
  }

  .novel-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .footer-top {
    justify-content: center;
    text-align: center;
  }
}

/* Teléfonos */

@media (max-width: 540px) {
  .site-header {
    padding: 14px 16px;
    flex-wrap: wrap;
  }

  .brand {
    font-size: 1.12rem;
  }

  .header-actions {
    gap: 7px;
  }

  .button {
    min-height: 38px;
    padding: 0 12px;
    font-size: .82rem;
  }

  .theme-toggle {
    width: 36px;
    height: 36px;
  }

  .hero {
    min-height: 340px;
    padding: 42px 22px;
  }

  .hero-sky {
    left: 10%;
    opacity: .28;
  }

  .desktop-break {
    display: none;
  }

  .novels-section {
    padding: 42px 16px 48px;
  }

  .novel-grid {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .cover {
    min-height: 210px;
  }

  .footer-links {
    justify-content: center;
    gap: 14px;
  }
}

.account-greeting {
    max-width: 220px;
    overflow-wrap: anywhere;
    font-size: 0.92rem;
}

.logout-form {
    display: inline-flex;
    margin: 0;
}

@media (max-width: 520px) {
    .account-greeting {
        max-width: 110px;
        font-size: 0.8rem;
    }

    .header-actions {
        gap: 0.45rem;
    }
}

/* Accesibilidad: reducir animaciones */

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

  .novel-card:hover,
  .button:hover {
    transform: none;
  }
}


/* =========================================================
   Ficha de novela
   ========================================================= */

.novel-page {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 30px 0 76px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: .86rem;
}

.breadcrumbs a {
  color: var(--accent-strong);
  font-weight: 600;
}

.breadcrumbs a:hover {
  text-decoration: underline;
}

.breadcrumbs span:last-child {
  overflow-wrap: anywhere;
}

/* Portada e información */

.novel-detail {
  display: grid;
  grid-template-columns: minmax(220px, 310px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(28px, 5vw, 58px);
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-cover {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(
    145deg,
    var(--accent-soft),
    var(--hero-end)
  );
  box-shadow: 0 18px 42px rgba(62, 48, 119, .13);
}

.detail-cover > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-cover-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  height: 100%;
  padding: 24px;
  text-align: center;
  color: var(--accent-strong);
}

.detail-cover-placeholder > span {
  font-size: 3rem;
}

.detail-cover-placeholder p {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.detail-information {
  min-width: 0;
  padding: 8px 0;
}

.detail-information .eyebrow {
  margin-bottom: 14px;
}

.detail-information h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.35rem);
  overflow-wrap: anywhere;
}

.novel-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 20px;
}

.novel-metadata span,
.chapter-count {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: .78rem;
  font-weight: 600;
}

:root[data-theme="dark"] .novel-metadata span,
:root[data-theme="dark"] .chapter-count {
  color: var(--text);
}

.detail-description {
  margin-top: 25px;
  color: var(--muted);
  font-size: .97rem;
  line-height: 1.9;
  overflow-wrap: anywhere;
}

.detail-description p {
  margin: 0 0 14px;
}

.detail-read-button {
  display: inline-flex;
  gap: 10px;
  margin-top: 24px;
  min-height: 48px;
  padding: 0 24px;
}

.chapters-empty {
  margin-top: 22px;
  color: var(--muted);
  font-size: .9rem;
}

/* Lista de capítulos */

.chapters-section {
  margin-top: 52px;
}

.chapters-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.chapters-heading .eyebrow {
  margin-bottom: 7px;
}

.chapters-heading h2 {
  overflow-wrap: anywhere;
}

.chapter-list {
  display: grid;
  gap: 11px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chapter-item {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  transition:
    transform .18s ease,
    border-color .18s ease,
    background .18s ease;
}

.chapter-item:hover {
  transform: translateX(3px);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.chapter-number {
  flex: 0 0 43px;
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

:root[data-theme="dark"] .chapter-number {
  color: var(--text);
}

.chapter-information {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chapter-title {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.chapter-date {
  color: var(--muted);
  font-size: .78rem;
}

.chapter-arrow {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 1.25rem;
}

:root[data-theme="dark"] .chapter-arrow {
  color: var(--accent);
}

.chapters-empty-panel,
.novel-message {
  padding: 38px 24px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  text-align: center;
  box-shadow: var(--shadow);
}

.chapters-empty-panel > span,
.message-star {
  color: var(--accent);
  font-size: 2rem;
}

.chapters-empty-panel p,
.novel-message p {
  color: var(--muted);
}

.chapters-empty-panel p:last-child {
  margin-bottom: 0;
}

.novel-message {
  max-width: 700px;
  margin: 55px auto;
}

.novel-message h1 {
  margin-top: 12px;
  font-size: clamp(1.8rem, 4vw, 2.7rem);
}

.novel-message .button {
  margin-top: 12px;
}

/* Adaptación a móviles */

@media (max-width: 700px) {
  .novel-page {
    width: min(100% - 32px, 560px);
    padding-top: 22px;
    padding-bottom: 50px;
  }

  .novel-detail {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
    padding: 22px;
    border-radius: 19px;
  }

  .detail-cover {
    width: min(100%, 260px);
    margin: 0 auto;
  }

  .detail-information {
    padding: 0;
  }

  .detail-information h1 {
    font-size: clamp(1.9rem, 8vw, 2.7rem);
  }

  .chapters-section {
    margin-top: 38px;
  }

  .chapter-item {
    gap: 12px;
    padding: 13px;
  }

  .chapter-number {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
  }
}

@media (max-width: 420px) {
  .chapters-heading {
    align-items: start;
    flex-direction: column;
  }

  .novel-metadata {
    gap: 7px;
  }

  .chapter-arrow {
    font-size: 1.05rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chapter-item:hover {
    transform: none;
  }
}
