:root {
  --bg: #f6f3ec; --surface: #ffffff; --surface-2: #efe9dd; --ink: #1b2233; --muted: #5d6475; --line: #e2dccf;
  --brand: #123a6b; --brand-2: #1d5aa3; --brand-ink: #ffffff; --gold: #d99a1e; --gold-soft: #fbefd3;
  --ok: #1f7a4d; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 6px 24px rgba(20, 30, 50, .07);
  --radius: 14px; --maxw: 1180px;
  --font: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Literata', Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1420; --surface: #171e2d; --surface-2: #1f2839; --ink: #eef1f7; --muted: #a2abbd; --line: #2a3447;
    --brand: #8db8f0; --brand-2: #a9cbf6; --brand-ink: #0f1420; --gold: #f0b440; --gold-soft: #3a2f16;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35); color-scheme: dark; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.55 var(--font); }
a { color: var(--brand-2); }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- cabecera ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 700; letter-spacing: .01em; }
.logo svg { width: 36px; height: 36px; flex: none; }
.logo small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; letter-spacing: .02em; }
.top nav { margin-left: auto; display: flex; gap: 6px; }
.top nav a { text-decoration: none; color: var(--ink); padding: 8px 12px; border-radius: 10px; font-size: 15px; }
.top nav a:hover { background: var(--surface-2); }
.top nav a.yt { display: inline-flex; align-items: center; gap: 6px; }
.top nav a.yt svg { width: 20px; height: 20px; fill: #e62117; }

/* ---------- portada ---------- */
.hero { background: linear-gradient(135deg, #123a6b 0%, #1d5aa3 60%, #2b6fb8 100%); color: #fff; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -80px; top: -60px; width: 420px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.14), transparent 65%); }
.hero .wrap { padding-top: 54px; padding-bottom: 58px; position: relative; z-index: 1; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 13px; font-weight: 700; color: #ffd37a; margin: 0 0 10px; }
.hero h1 { font: 600 clamp(30px, 5vw, 50px)/1.1 var(--serif); margin: 0 0 12px; max-width: 760px; }
.hero p.lead { font-size: 19px; opacity: .92; max-width: 640px; margin: 0 0 26px; }
.search { display: flex; gap: 10px; max-width: 560px; flex-wrap: wrap; }
.search input { flex: 1; min-width: 220px; height: 52px; border-radius: 12px; border: 0; padding: 0 18px; font: inherit; font-size: 17px; color: #1b2233; background: #fff; }
.stats { display: flex; gap: 28px; margin-top: 30px; flex-wrap: wrap; }
.stats div { font-size: 14px; opacity: .85; }
.stats b { display: block; font: 600 28px/1.1 var(--serif); opacity: 1; }

.section { padding: 36px 0 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head h2 { font: 600 26px/1.2 var(--serif); margin: 0; }
.chip-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; color: var(--muted); cursor: pointer; user-select: none; }
.chip-toggle input { width: 18px; height: 18px; accent-color: var(--brand-2); }

.books { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.book { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 14px 12px;
  text-decoration: none; color: var(--ink); min-height: 96px; display: flex; flex-direction: column; justify-content: space-between; transition: transform .12s, box-shadow .12s; }
.book .name { font-weight: 700; font-size: 17px; line-height: 1.25; }
.book .meta { font-size: 13.5px; color: var(--muted); margin-top: 8px; }
.book .bar { height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.book .bar i { display: block; height: 100%; background: var(--gold); border-radius: 3px; }
.book.on { box-shadow: var(--shadow); border-color: transparent; }
.book.on::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand-2); }
.book.on:hover { transform: translateY(-2px); }
.book.off { opacity: .55; background: transparent; cursor: default; }
.book.off .meta { font-style: italic; }
.featured { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.feat { background: var(--surface); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: transform .12s; display: flex; flex-direction: column; }
.feat:hover { transform: translateY(-3px); }
.feat .thumb { aspect-ratio: 16/9; background: var(--surface-2) center/cover; display: block; }
.feat .body { padding: 12px 16px 15px; display: block; }
.feat .tm { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--gold); font-weight: 700; }
.feat .name { display: block; font: 600 24px/1.2 var(--serif); margin: 2px 0 4px; }
.feat .meta { display: block; font-size: 14px; color: var(--muted); }
.empty-msg { color: var(--muted); padding: 20px 0; }

.about { margin: 44px 0 0; background: var(--surface); border-top: 1px solid var(--line); }
.about .wrap { padding-top: 34px; padding-bottom: 40px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 28px; }
.about h2 { font: 600 24px/1.2 var(--serif); margin: 0 0 10px; }
.about p { margin: 0 0 10px; color: var(--muted); }
.cta { display: inline-flex; align-items: center; gap: 10px; background: var(--brand); color: var(--brand-ink); text-decoration: none; padding: 12px 18px; border-radius: 12px; font-weight: 700; }
.cta svg { width: 22px; height: 22px; fill: currentColor; }
footer { text-align: center; color: var(--muted); font-size: 14px; padding: 22px 0 34px; }

/* ---------- libro ---------- */
.crumbs { font-size: 14.5px; color: var(--muted); padding: 18px 0 0; }
.crumbs a { color: var(--muted); }
.book-head { padding: 12px 0 8px; }
.book-head .eyebrow { color: var(--gold); }
.book-head h1 { font: 600 clamp(32px, 5vw, 48px)/1.1 var(--serif); margin: 0 0 10px; }
.book-head p { max-width: 760px; color: var(--muted); margin: 0; white-space: pre-line; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.vcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; transition: transform .12s, box-shadow .12s; }
.vcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.vcard .thumb { aspect-ratio: 16/9; background: #000 center/cover; position: relative; }
.vcard .thumb::after { content: ''; position: absolute; inset: 0; margin: auto; width: 54px; height: 54px; border-radius: 50%;
  background: rgba(0,0,0,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E") center/26px no-repeat; }
.vcard .t { padding: 10px 14px 13px; font-weight: 700; }

.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; }
.chap { height: 64px; border-radius: 12px; display: grid; place-items: center; font: 700 21px/1 var(--font); text-decoration: none; border: 1px solid var(--line); }
.chap.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; box-shadow: var(--shadow); }
.chap.on:hover { background: var(--brand-2); }
.chap.off { color: var(--muted); opacity: .45; }
.legend { display: flex; gap: 18px; font-size: 14px; color: var(--muted); margin: 12px 0 0; flex-wrap: wrap; }
.legend span::before { content: ''; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--brand); }
.legend span.off::before { background: transparent; border: 1px solid var(--muted); }

.resources { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.res { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); }
.res:hover { border-color: var(--brand-2); }
.res .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--gold-soft); display: grid; place-items: center; flex: none; font-size: 12px; font-weight: 700; color: var(--gold); text-transform: uppercase; }
.res small { display: block; color: var(--muted); font-size: 13px; }
.credits { white-space: pre-line; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }

/* ---------- capítulo ---------- */
.reader { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 22px; padding: 14px 0 10px; align-items: start; }
.reader-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 8px; }
.reader-title h1 { font: 600 clamp(26px, 4vw, 38px)/1.15 var(--serif); margin: 0; flex: 1; min-width: 200px; }
.nav-btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 700; font-size: 15px; }
.nav-btn:hover { border-color: var(--brand-2); }
.nav-btn[aria-disabled=true] { opacity: .4; pointer-events: none; }
.player { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; box-shadow: var(--shadow); }
.player iframe, .player > div { width: 100%; height: 100%; border: 0; display: block; }
.blocked { display: grid; place-items: center; width: 100%; height: 100%; background: #000 center/cover; text-decoration: none; position: relative; }
.blocked::before { content: ''; position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.blocked span { position: relative; text-align: center; color: #fff; }
.blocked b { display: inline-block; background: #e62117; padding: 14px 22px; border-radius: 14px; font-size: 19px; }
.blocked small { display: block; margin-top: 10px; font-size: 14px; opacity: .9; }
.now { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 4px; flex-wrap: wrap; }
.now h2 { margin: 0; font-size: 21px; }
.now .count { color: var(--muted); font-size: 14.5px; }
.ctrl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 700; font-size: 15px; }
.btn:hover { border-color: var(--brand-2); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }

.side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: sticky; top: 80px; max-height: calc(100vh - 100px); display: flex; flex-direction: column; }
.side h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 14px 16px 8px; }
.side .list { overflow: auto; padding: 0 8px 10px; }
.seg { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px; border-radius: 10px; cursor: pointer; }
.seg:hover { background: var(--surface-2); }
.seg.cur { background: var(--gold-soft); }
.seg .mini { width: 92px; aspect-ratio: 16/9; border-radius: 7px; background: #000 center/cover; flex: none; position: relative; }
.seg.cur .mini::after { content: 'Viendo'; position: absolute; left: 4px; bottom: 4px; background: var(--gold); color: #1b2233; font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 4px; }
.seg .lbl { font-weight: 700; font-size: 15px; line-height: 1.3; }
.seg .n { color: var(--muted); font-size: 12.5px; font-weight: 400; display: block; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 22px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab[aria-selected=true] { color: var(--ink); border-color: var(--gold); }
.panel { padding: 16px 0; }
.panel p { white-space: pre-line; margin: 0; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 18px; }
.chip-row a { min-width: 42px; height: 38px; padding: 0 8px; display: grid; place-items: center; border-radius: 9px; text-decoration: none; font-weight: 700; font-size: 15px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.chip-row a.cur { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .reader { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; }
  .about .wrap { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .wrap { padding: 0 16px; }
  .top nav a.txt { display: none; }
  .logo small { display: none; }
  .books { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .chapters { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); }
  .chap { height: 54px; font-size: 18px; }
  .hero .wrap { padding-top: 36px; padding-bottom: 40px; }
}
