:root {
  --bg: #fbf7f1;
  --bg-soft: #f3ebe2;
  --surface: #ffffff;
  --text: #201b20;
  --muted: #746a71;
  --accent: #7c3aed;
  --accent-2: #f59e0b;
  --border: #eadfd5;
  --shadow: 0 22px 60px rgba(42, 28, 54, .13);
  --radius: 24px;
}

[data-theme="dark"] {
  --bg: #111018;
  --bg-soft: #181522;
  --surface: #1d1928;
  --text: #fff8f0;
  --muted: #c9bdc6;
  --accent: #a78bfa;
  --accent-2: #fbbf24;
  --border: #342d3d;
  --shadow: 0 24px 70px rgba(0,0,0,.38);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(124,58,237,.16), transparent 34rem),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { width: min(1160px, 92%); margin: 0 auto; }

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  min-height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.brand {
  font-family: Georgia, serif;
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -.02em;
}

.brand span { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-links a,
.icon-btn {
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
  font: inherit;
}

.nav-links a:hover,
.icon-btn:hover {
  border-color: var(--border);
  background: var(--surface);
}

.hero {
  padding: 84px 0 58px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.08fr .92fr;
  align-items: center;
  gap: 42px;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 13px;
  font-weight: 800;
}

h1, h2, h3 {
  line-height: 1.12;
  margin-top: 0;
}

.hero h1 {
  font-family: Georgia, serif;
  font-size: clamp(42px, 7vw, 76px);
  font-weight: 600;
  letter-spacing: -.045em;
  margin: 14px 0 18px;
}

.lead {
  color: var(--muted);
  font-size: 20px;
  max-width: 700px;
}

.hero-card {
  background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--surface), var(--accent) 7%));
  border: 1px solid var(--border);
  border-radius: 32px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.hero-card img {
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.section { padding: 56px 0; }

.section h2 {
  font-family: Georgia, serif;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 600;
  letter-spacing: -.025em;
  margin-bottom: 24px;
}

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

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

.card {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.story-card {
  display: flex;
  flex-direction: column;
}

.story-card img {
  border-radius: 18px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--bg-soft);
}

.story-card h3 {
  font-family: Georgia, serif;
  font-size: 27px;
  font-weight: 600;
  margin: 16px 0 6px;
}

.muted { color: var(--muted); }

.pill {
  display: inline-flex;
  width: fit-content;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: #fff;
  padding: 12px 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 16px 35px rgba(124,58,237,.28);
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.form {
  display: grid;
  gap: 14px;
}

.input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
}

textarea { min-height: 130px; resize: vertical; }

.footer {
  padding: 36px 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.reader-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 28px;
  align-items: start;
}

.chapter-list {
  position: sticky;
  top: 98px;
}

.chapter-item {
  display: block;
  width: 100%;
  margin-bottom: 10px;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.chapter-item.read {
  border-color: #60a5fa;
  color: #2563eb;
}

.chapter-item.locked {
  opacity: .62;
}

.reader {
  font-size: var(--reader-size, 18px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(22px, 4vw, 38px);
  box-shadow: var(--shadow);
}

.reader p[data-body] {
  font-family: Georgia, serif;
  font-size: var(--reader-size, 18px);
  line-height: 1.9;
}

.progress {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.carousel {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 280px);
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 12px;
  scroll-snap-type: x mandatory;
}

.carousel .card { scroll-snap-align: start; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: none;
  max-width: 320px;
  padding: 13px 16px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow);
}

.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px;
}

.sidebar a {
  display: block;
  margin: 5px 0;
  padding: 11px 12px;
  border-radius: 14px;
}

.sidebar a:hover { background: var(--bg-soft); }

.admin-main { padding: 30px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 18px;
  background: var(--surface);
}

.table th,
.table td {
  padding: 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.chart {
  height: 190px;
  display: flex;
  align-items: end;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(124,58,237,.18), rgba(245,158,11,.15));
}

.bar {
  flex: 1;
  background: var(--accent);
  border-radius: 10px 10px 0 0;
  opacity: .78;
}

.hide { display: none !important; }

@media (max-width: 860px) {
  .hero-grid,
  .reader-layout,
  .admin-shell,
  .grid,
  .grid.two,
  .stats {
    grid-template-columns: 1fr;
  }

  .nav-inner {
    align-items: flex-start;
    padding: 14px 0;
  }

  .chapter-list,
  .sidebar {
    position: relative;
    top: auto;
    height: auto;
  }

  .admin-main { padding: 22px; }
}

/* =========================================================
   CAPA FINAL RESPONSIVA GLOBAL
   Mantiene el estilo visual existente y corrige TODAS las páginas:
   Home, Relatos, Relato, Checkout, Login, Registro, Recuperación,
   Blog, Biblioteca y Admin.
   ========================================================= */

/* Seguridad visual global */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

/* Tablas, formularios y elementos que suelen romper móvil */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
}

.input,
textarea,
select,
button {
  max-width: 100%;
}

.card,
.reader,
.hero-card {
  min-width: 0;
}

.mobile-menu-toggle {
  display: none;
}

/* Pantallas grandes */
@media (min-width: 1200px) {
  .container {
    width: min(1180px, 92%);
  }

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

/* Laptops y tablets horizontales */
@media (max-width: 1180px) {
  .container {
    width: min(94%, 1040px);
  }

  .hero-grid {
    grid-template-columns: minmax(0, 1fr) minmax(300px, .76fr);
    gap: 30px;
  }

  .hero h1 {
    font-size: clamp(42px, 6vw, 66px);
  }

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

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

  .reader-layout {
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 22px;
  }

  .admin-shell {
    grid-template-columns: 235px minmax(0, 1fr);
  }

  .admin-main {
    min-width: 0;
  }
}

/* Tablets verticales y móviles grandes */
@media (max-width: 920px) {
  .container {
    width: min(92%, 760px);
  }

  .nav {
    position: sticky;
  }

  .nav-inner {
    position: relative;
    min-height: 68px;
    padding: 12px 0;
    align-items: center;
  }

  .brand {
    font-size: 23px;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  .nav-links {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 10px);
    z-index: 200;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a,
  .nav-links .icon-btn {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border-color: var(--border);
    background: color-mix(in srgb, var(--surface) 88%, var(--bg-soft));
    text-align: left;
  }

  .hero {
    padding: 46px 0 34px;
  }

  .hero-grid,
  .reader-layout,
  .admin-shell,
  .grid,
  .grid.two,
  .stats {
    grid-template-columns: 1fr;
  }

  .hero-card {
    width: min(100%, 470px);
    margin: 0 auto;
    transform: none;
  }

  .hero-card img {
    max-height: 560px;
    width: 100%;
    object-fit: cover;
  }

  .section {
    padding: 38px 0;
  }

  .chapter-list,
  .sidebar {
    position: relative;
    top: auto;
    height: auto;
  }

  .chapter-list {
    order: 1;
  }

  .reader {
    order: 2;
    padding: 24px;
  }

  .reader p[data-body] {
    font-size: var(--reader-size, 17px);
    line-height: 1.85;
  }

  .admin-shell {
    min-height: auto;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar a {
    display: inline-flex;
    margin: 4px 5px 4px 0;
  }

  .admin-main {
    padding: 22px;
  }

  .table {
    min-width: 720px;
  }

  .chart {
    height: 170px;
  }
}

/* Celulares */
@media (max-width: 680px) {
  body {
    font-size: 15.8px;
  }

  .container {
    width: 92%;
  }

  .nav-inner {
    gap: 10px;
  }

  .brand {
    font-size: 21px;
  }

  .mobile-menu-toggle {
    padding: 9px 11px;
    font-size: 14px;
  }

  .hero {
    padding-top: 38px;
  }

  .hero h1 {
    font-size: clamp(34px, 11vw, 46px);
    letter-spacing: -.035em;
  }

  .lead {
    font-size: 17px;
  }

  h1 {
    font-size: 34px;
  }

  .section h2,
  h2 {
    font-size: 30px;
  }

  .hero-card {
    padding: 12px;
    border-radius: 24px;
  }

  .hero-card img {
    max-height: 470px;
    border-radius: 18px;
  }

  .card {
    padding: 16px;
    border-radius: 20px;
  }

  .story-card {
    gap: 4px;
  }

  .story-card h3 {
    font-size: 24px;
  }

  .story-card img {
    width: 100%;
    max-height: 520px;
  }

  .actions {
    width: 100%;
    align-items: stretch;
  }

  .actions .btn,
  .actions .btn.secondary,
  .actions .btn.ghost {
    width: 100%;
  }

  .reader .actions .btn,
  .reader .actions .btn.secondary,
  .reader .actions .btn.ghost {
    width: 100%;
  }

  .btn,
  .icon-btn,
  .chapter-item {
    min-height: 44px;
  }

  .chapter-item {
    font-size: 15px;
    padding: 12px;
  }

  .reader {
    padding: 18px;
  }

  .reader h1 {
    font-size: 29px;
  }

  .reader p[data-body] {
    font-size: var(--reader-size, 16px);
  }

  .carousel {
    grid-auto-columns: minmax(240px, 86vw);
  }

  .form {
    gap: 12px;
  }

  .input,
  textarea,
  select {
    font-size: 16px;
    padding: 12px 13px;
  }

  .sidebar {
    padding: 18px;
  }

  .sidebar a,
  .sidebar .btn {
    width: 100%;
    justify-content: flex-start;
  }

  .admin-main {
    padding: 18px;
  }

  .stats .card h2 {
    font-size: 28px;
  }
}

/* Celulares pequeños */
@media (max-width: 430px) {
  .container {
    width: 91%;
  }

  .brand {
    font-size: 20px;
  }

  .mobile-menu-toggle {
    font-size: 13px;
    padding: 8px 10px;
  }

  .nav-links {
    border-radius: 18px;
  }

  .hero h1 {
    font-size: 32px;
  }

  .lead {
    font-size: 16px;
  }

  .section {
    padding: 32px 0;
  }

  .section h2,
  h2 {
    font-size: 28px;
  }

  main h1,
  .admin-main h1 {
    font-size: 31px;
  }

  .hero-card img {
    max-height: 405px;
  }

  .reader {
    padding: 15px;
  }

  .reader h1 {
    font-size: 26px;
  }

  .reader p[data-body] {
    line-height: 1.8;
  }

  .carousel {
    grid-auto-columns: 88vw;
  }

  .toast {
    left: 14px;
    right: 14px;
    max-width: none;
  }
}

/* Dispositivos touch */
@media (hover: none) {
  .btn,
  .icon-btn,
  .chapter-item,
  .nav-links a {
    min-height: 44px;
  }
}

.terms{
    display:flex;
    align-items:center;
    gap:8px;
    font-size:.95rem;
    margin:15px 0;
    padding-top: 15px;
}

.terms a{
    color:var(--primary);
    text-decoration:none;
    font-weight:600;
}

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

.modal{
    display:none;
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.75);
    z-index:9999;
    justify-content:center;
    align-items:center;
    backdrop-filter:blur(4px);
}

.modal.show{
    display:flex;
}

.modal-content{
    width:min(900px,92vw);
    max-height:85vh;
    overflow:hidden;
    background:#fff;
    border-radius:18px;
    box-shadow:0 20px 70px rgba(0,0,0,.35);
    position:relative;
}

.modal-body{
    padding:30px;
    overflow-y:auto;
    max-height:75vh;
}

.modal-close{
    position:absolute;
    top:18px;
    right:18px;
    width:40px;
    height:40px;
    border:none;
    border-radius:50%;
    cursor:pointer;
    font-size:22px;
}

.TerminosHeader{
  margin: 20px;
}

a {
    color: #0066cc;              /* Azul */
    text-decoration: underline;  /* Subrayado */
    margin-right: 20px;          /* Espacio entre enlaces */
}

a:visited {
    color: #800080;              /* Morado cuando ya fue visitado */
}

a:hover {
    color: #004999;              /* Azul más oscuro al pasar el mouse */
}

a:active {
    color: #ff6600;              /* Mientras se hace clic */
}

.password-container{
    position:relative;
}

.password-container input{
    width:100%;
    padding-right:45px;
    box-sizing:border-box;
}

.toggle-password{

    position:absolute;

    top:50%;
    right:12px;

    transform:translateY(-50%);

    border:none;
    background:none;

    cursor:pointer;

    font-size:18px;

    padding:0;

}

.portadas-wrapper {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin: 20px 0;
}

.portada-box {
  border: 1px solid #ccc;
  border-radius: 10px;
  padding: 16px;
  width: fit-content;
  text-align: center;
  background: #fff;
}

.portada-box h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.portada-box img {
  width: 204px;
  height: 308px;
  object-fit: cover;
  display: block;
  margin: 0 auto;
  border: 1px solid #ddd;
}

.btn-cambiar-imagen {
  margin-top: 14px;
  display: inline-block;
}

@media (max-width: 600px) {
  .portadas-wrapper {
    flex-direction: column;
    align-items: center;
  }
}