:root {
  --night: #0f1226;
  --deep: #1a1e3d;
  --line: #2c3158;
  --text: #ebe8f3;
  --muted: #9a9dbd;
  --dawn: #f2b48b;
  --dawn-soft: #c9a6d9;
  --bone: #ece5d6;
  --ink: #1f1b2e;
  --ink-muted: #5b5670;
  --bg: var(--night);
  --fg: var(--text);
  --fg-muted: var(--muted);
  --rule: var(--line);
  --accent: var(--dawn);
  --accent-fg: #1a1226;
  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --read: "Literata", Georgia, "Times New Roman", serif;
}

[data-theme="claro"] {
  --bg: var(--bone);
  --fg: var(--ink);
  --fg-muted: var(--ink-muted);
  --rule: #cfc6b2;
  --accent: #3b2f6b;
  --accent-fg: #f6f1e6;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--read);
  font-size: 1.0625rem;
  line-height: 1.7;
}

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

.wrap { max-width: 68rem; margin: 0 auto; padding: 0 1rem; }

/* Cabecera */
.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 0; gap: 1rem;
}
.brand { font-family: var(--display); font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: 0.01em; }
.top nav { display: flex; align-items: center; gap: 1.25rem; font-family: var(--display); font-size: 0.95rem; }
.top nav a { text-decoration: none; color: var(--fg-muted); }
.top nav a:hover { color: var(--fg); }
.lang { display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.lang button {
  font: inherit; background: none; color: var(--fg-muted); border: 0;
  padding: 0.3rem 0.7rem; cursor: pointer; min-height: 2.25rem;
}
.lang button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }

/* Portada: la puerta entreabierta */
.hero { position: relative; overflow: hidden; padding: 4rem 0 5rem; }
.hero .wrap { display: grid; grid-template-columns: 1fr; gap: 2.5rem; }
.hero h1 {
  font-family: var(--display); font-weight: 800;
  font-size: clamp(2.6rem, 9vw, 5.6rem); line-height: 0.98; margin: 0 0 1.25rem;
  letter-spacing: -0.02em; max-width: 14ch;
}
.hero p.lead { font-size: 1.2rem; max-width: 34rem; color: var(--fg-muted); margin: 0 0 2rem; }
.hero .cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.door {
  position: absolute; top: 0; bottom: 0; right: 12%;
  width: clamp(10px, 2.2vw, 28px);
  background: linear-gradient(180deg, var(--dawn-soft), var(--dawn) 70%, #fff3e4);
  box-shadow: 0 0 60px 20px rgba(242, 180, 139, 0.28), 0 0 160px 60px rgba(201, 166, 217, 0.14);
  transform-origin: center; animation: open 1.6s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes open { from { transform: scaleX(0); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }
.hero .wrap > div { position: relative; z-index: 1; }

.btn {
  display: inline-block; font-family: var(--display); font-weight: 600; font-size: 1rem;
  padding: 0.8rem 1.4rem; border-radius: 0.4rem; text-decoration: none;
  background: var(--accent); color: var(--accent-fg); border: 2px solid var(--accent);
  cursor: pointer; min-height: 2.75rem;
}
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--rule); }
.btn:hover { filter: brightness(1.08); }
.btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }

/* Secciones */
section { padding: 3.5rem 0; border-top: 1px solid var(--rule); }
h2 { font-family: var(--display); font-weight: 700; font-size: clamp(1.7rem, 4vw, 2.4rem); margin: 0 0 0.5rem; line-height: 1.1; }
.sub { color: var(--fg-muted); margin: 0 0 2rem; max-width: 38rem; }

/* Lista de libros */
.shelf { list-style: none; margin: 0; padding: 0; }
.shelf li { border-top: 1px solid var(--rule); }
.shelf li:last-child { border-bottom: 1px solid var(--rule); }
.shelf a.row {
  display: grid; grid-template-columns: 1fr; gap: 0.25rem 1.5rem;
  padding: 1.25rem 0.25rem; text-decoration: none;
}
.shelf .t { font-family: var(--display); font-weight: 700; font-size: clamp(1.3rem, 3vw, 1.8rem); line-height: 1.15; }
.shelf .m { color: var(--fg-muted); font-size: 0.95rem; }
.shelf .s { font-family: var(--display); font-size: 0.95rem; color: var(--accent); }
.shelf a.row:hover .t { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
@media (min-width: 46rem) {
  .shelf a.row { grid-template-columns: 1fr auto; align-items: baseline; }
  .shelf .s { text-align: right; }
}

/* Teología: panel claro dentro de la portada oscura */
.panel-claro {
  background: var(--bone); color: var(--ink);
  --fg: var(--ink); --fg-muted: var(--ink-muted); --rule: #cfc6b2; --accent: #3b2f6b; --accent-fg: #f6f1e6;
  border-top: 0;
}

/* Formulario */
.form { max-width: 34rem; display: grid; gap: 1rem; }
label { display: grid; gap: 0.35rem; font-family: var(--display); font-weight: 600; font-size: 0.95rem; }
input, select {
  font: inherit; font-family: var(--read); padding: 0.75rem 0.85rem;
  background: transparent; color: inherit; border: 1.5px solid var(--rule); border-radius: 0.4rem; min-height: 2.9rem;
}
select option { color: #111; }
.note { font-size: 0.9rem; color: var(--fg-muted); margin: 0; }
.hidden { position: absolute; left: -9999px; }

/* Página de libro */
.book-head { padding: 3rem 0 2rem; }
.book-head h1 { font-family: var(--display); font-weight: 800; font-size: clamp(2.2rem, 7vw, 4rem); line-height: 1.02; margin: 0 0 0.75rem; letter-spacing: -0.015em; }
.byline { color: var(--fg-muted); margin: 0 0 1rem; }
.editions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.reader { max-width: 38rem; margin: 0 auto; padding: 3rem 1rem; }
.reader p { margin: 0 0 1.15em; font-size: 1.15rem; line-height: 1.8; }
.reader .empty { color: var(--fg-muted); font-style: italic; }
.reader h2 { font-size: 1.1rem; font-family: var(--display); color: var(--fg-muted); font-weight: 600; margin-bottom: 1.5rem; }
.back { display: inline-block; margin: 1rem 0 0; font-family: var(--display); text-decoration: none; color: var(--fg-muted); }

/* Pie */
footer { padding: 2.5rem 0 3rem; border-top: 1px solid var(--rule); color: var(--fg-muted); font-size: 0.95rem; }

@media (max-width: 40rem) {
  .hero { padding-top: 2.5rem; }
  .door { right: 4%; opacity: 0.8; width: 8px; }
  .hero .wrap { padding-right: 2.25rem; }
  .top nav a.hide-sm { display: none; }
}

/* Marca */
.brand { display: inline-flex; align-items: center; gap: 0.6rem; }
.brand .mark { flex: none; }

/* Portadas (reales o tentativas) */
.cover {
  position: relative; flex: none; overflow: hidden; border-radius: 3px 6px 6px 3px;
  aspect-ratio: 2 / 3; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 4px 6px 18px rgba(0,0,0,.35);
  border-left: 5px solid rgba(0,0,0,.28);
}
.cover.g-libros { background: radial-gradient(120% 70% at 70% 100%, rgba(242,180,139,.38), transparent 60%), linear-gradient(180deg, #1a1e3d, #0b0d1d); color: #ebe8f3; }
.cover.g-teologia { background: linear-gradient(180deg, #f4ecd8, #e3d8bd); color: #2b2250; border-left-color: rgba(59,47,107,.35); }
.cover .pt { font-family: var(--display); font-weight: 800; line-height: 1.02; letter-spacing: -0.01em; padding: 12% 10% 0; overflow: hidden; }
.cover .pp { font-family: var(--display); font-weight: 600; opacity: .75; padding: 0 10% 10%; display: flex; align-items: center; gap: .4em; }
.cover .pp i { display: inline-block; width: .35em; height: 1.1em; border-radius: 1em; background: linear-gradient(#c9a6d9, #f2b48b); }
.cover.g-teologia .pp i { background: #3b2f6b; }
.cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.sm { width: 64px; }
.cover.sm .pt { font-size: .5rem; }
.cover.sm .pp { font-size: .4rem; }
.cover.lg { width: min(220px, 60vw); }
.cover.lg .pt { font-size: 1.5rem; }
.cover.lg .pp { font-size: .8rem; }
.tentative { font-size: .85rem; color: var(--fg-muted); margin: .6rem 0 0; }

.shelf a.row { grid-template-columns: auto 1fr; align-items: center; gap: 0.25rem 1.1rem; }
.shelf .txt { display: grid; gap: .15rem; }
.shelf .s { grid-column: 2; }
@media (min-width: 46rem) {
  .shelf a.row { grid-template-columns: auto 1fr auto; }
  .shelf .s { grid-column: auto; }
}

.book-top { display: grid; gap: 1.5rem; padding-top: 1rem; }
@media (min-width: 46rem) { .book-top { grid-template-columns: auto 1fr; gap: 2.5rem; align-items: start; } }

.reader h2.chap { font-size: 1.5rem; color: var(--fg); margin: 0 0 1.5rem; }
.reader h3.scene { font-family: var(--display); font-size: 1rem; font-weight: 600; color: var(--accent); margin: 2.5rem 0 1rem; letter-spacing: .02em; }

.gallery { margin-top: 2rem; }
.gal-row { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: .5rem; }
.gal-row img { height: 16rem; width: auto; border-radius: 4px; flex: none; }
