/* Lectura: usa los colores de app.css (tema claro / oscuro) */
:root { --vfs: 20px; --hl-amarillo: #FFF1A8; --hl-verde: #CDEFD2; --hl-azul: #CFE3FF; --hl-rosa: #FFD6E0; --hl-morado: #E5D9FF; --sel: #E6F2E7; }
:root[data-theme="dark"] { --hl-amarillo: #5A4B12; --hl-verde: #1F4A2A; --hl-azul: #1E3657; --hl-rosa: #5A2333; --hl-morado: #3B2B5E; --sel: #1E2B24; }
body.lectura { background: var(--surface); }

/* Barra superior que se esconde al leer */
.lbar { position: fixed; top: 0; left: 0; right: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px; transition: transform .28s ease; }
.lbar.oculta { transform: translateY(-110%); }
.lbar .in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 4px; }
.lpill { height: 40px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg); color: var(--text); display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; white-space: nowrap; min-width: 0; }
.lpill span { overflow: hidden; text-overflow: ellipsis; }
.lpill.ver { font-size: 13px; font-weight: 600; padding: 0 10px; flex-shrink: 1; max-width: 38vw; }
.lib { width: 42px; height: 44px; flex-shrink: 0; border: 0; background: transparent; color: var(--text); display: grid; place-items: center; padding: 0; cursor: pointer; font: inherit; font-weight: 700; font-size: 17px; border-radius: 22px; }
.lib:focus-visible, .lpill:focus-visible, .v:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Texto */
.lector { max-width: 680px; margin: 0 auto; padding: calc(84px + env(safe-area-inset-top, 0px)) 24px calc(170px + env(safe-area-inset-bottom, 0px)); }
.cap-t { font-family: 'Literata', Georgia, serif; font-weight: 600; font-size: calc(var(--vfs) * 1.5); line-height: 1.2; margin: 6px 0 18px; }
.cap-t small { display: block; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.texto { font-family: 'Literata', Georgia, serif; font-size: var(--vfs); line-height: 1.75; color: var(--text); }
.texto p { margin: 0 0 14px; }
/* El título de la perícopa crece junto con el tamaño de letra elegido (un poco más grande que el texto) */
.peri { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: calc(var(--vfs) * 1.05); font-weight: 700; color: var(--accent); margin: 1.1em 0 .3em; line-height: 1.35; }
.peri:first-of-type { margin-top: 4px; }
.peri button { all: unset; cursor: pointer; display: inline; border-radius: 4px; }
.peri button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.peri button::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 8px; vertical-align: 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: .6; }
.v { cursor: pointer; border-radius: 4px; -webkit-box-decoration-break: clone; box-decoration-break: clone; transition: background-color .3s; -webkit-tap-highlight-color: transparent; }
.vn { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: .58em; font-weight: 700; color: var(--accent); vertical-align: super; margin: 0 3px 0 2px; line-height: 0; }
.vi { display: inline-grid; place-items: center; width: 1.2em; height: 1.2em; vertical-align: -.15em; color: var(--accent); margin-right: 2px; border: 0; background: none; padding: 0; cursor: pointer; }
.vi svg { width: .8em; height: .8em; }
.v.sel { text-decoration: underline dotted var(--accent); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.hl-amarillo { background: var(--hl-amarillo); } .hl-verde { background: var(--hl-verde); } .hl-azul { background: var(--hl-azul); }
.hl-rosa { background: var(--hl-rosa); } .hl-morado { background: var(--hl-morado); }
.v.destello { animation: destello 2.6s ease-out; }
@keyframes destello { 0%, 35% { background-color: var(--accent-soft); box-shadow: 0 0 0 3px var(--accent-soft); } 100% { box-shadow: 0 0 0 0 transparent; } }
.cmp-v { display: block; margin: 4px 0 16px; padding: 8px 12px; border-left: 3px solid var(--border); font-size: .86em; color: var(--text-2); border-radius: 0 8px 8px 0; background: var(--bg); }
.cmp-v b { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 12px; display: block; color: var(--text-2); }
.texto.comparando p { margin-bottom: 4px; }
.cargando-txt { color: var(--text-2); font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 15px; padding: 40px 0; text-align: center; }

/* Fin del capítulo */
.fin { display: flex; gap: 10px; margin-top: 28px; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; }
.fin a { flex: 1; min-height: 52px; border-radius: 16px; border: 1px solid var(--border); background: var(--bg); color: var(--text); display: flex; flex-direction: column; justify-content: center; padding: 8px 14px; font-weight: 700; font-size: 15px; }
.fin a small { color: var(--text-2); font-weight: 500; font-size: 12px; }
.fin a.sig { text-align: right; }

/* Modo lectura: al deslizar hacia abajo se esconde la barra de abajo y las flechas */
.lectura .tabbar { transition: transform .28s ease; }
.lectura.leyendo .tabbar { transform: translateY(110%); }
.lectura.leyendo .fab { opacity: 0; transform: translateY(24px); pointer-events: none; }

/* Flechas flotantes */
.fab { position: fixed; z-index: 30; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); width: 48px; height: 48px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 4px 14px rgba(0,0,0,.14); display: grid; place-items: center; color: var(--text); cursor: pointer; padding: 0; transition: opacity .25s, transform .25s; }
.fab.ant { left: max(16px, calc(50% - 360px)); } .fab.sig { right: max(16px, calc(50% - 360px)); }
.fab[hidden] { display: none; }

/* Hojas (paneles que suben desde abajo) */
.velo { position: fixed; inset: 0; z-index: 60; background: rgba(15,20,18,.42); opacity: 0; pointer-events: none; transition: opacity .3s ease; }
.velo.on { opacity: 1; pointer-events: auto; }
.hoja { position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 640px; max-height: 88vh; overflow: auto; background: var(--surface); color: var(--text);
  border-radius: 24px 24px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 30px rgba(0,0,0,.16);
  transform: translateY(105%); transition: transform .38s cubic-bezier(.2,.9,.25,1.06); visibility: hidden; }
.hoja.on { transform: translateY(0); visibility: visible; }
.grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 14px; }
.hoja-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.hoja-top h2 { margin: 0; font-size: 18px; font-weight: 700; }
.hoja-top small { display: block; color: var(--text-2); font-size: 14px; }
.cerrar { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--bg); color: var(--text); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.colores { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.color { width: 40px; height: 40px; border-radius: 20px; border: 2px solid transparent; padding: 0; cursor: pointer; display: grid; place-items: center; color: var(--text); }
.color.on { border-color: var(--text); }
.color.quitar { background: var(--surface); border: 1.5px solid var(--border); }
.acciones { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 8px; }
.accion { display: flex; flex-direction: column; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: center; padding: 0;
  opacity: 0; transform: translateY(10px); transition: opacity .3s, transform .3s; }
.hoja.on .accion { opacity: 1; transform: none; }
.accion .c { width: 56px; height: 56px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.accion.on .c { background: var(--accent-fill); color: var(--on-accent); }
.fila { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; border-bottom: 1px solid var(--border); font-size: 16px; }
.fila:last-child { border-bottom: 0; }
.fila button.s { min-width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.selector { min-height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 15px; padding: 0 10px; max-width: 60%; }
.interruptor { width: 50px; height: 30px; border-radius: 15px; border: 0; background: var(--border); position: relative; cursor: pointer; flex-shrink: 0; padding: 0; }
.interruptor::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 12px; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.interruptor[aria-checked="true"] { background: var(--accent-fill); }
.interruptor[aria-checked="true"]::after { transform: translateX(20px); }
.btn-l { min-height: 48px; border-radius: 24px; border: 0; background: var(--accent-fill); color: var(--on-accent); font: inherit; font-size: 16px; font-weight: 700; padding: 0 20px; cursor: pointer; }
.btn-l.sec { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-l.peligro { background: transparent; color: #C62828; border: 1px solid #EF9A9A; }
:root[data-theme="dark"] .btn-l.peligro { color: #FF8A80; border-color: #7F3B3B; }
.area { width: 100%; min-height: 140px; border-radius: 14px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; padding: 12px 14px; resize: vertical; }
.lista-v { display: flex; flex-direction: column; }
.lista-v button { display: flex; align-items: center; justify-content: space-between; min-height: 52px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; font-size: 16px; text-align: left; cursor: pointer; padding: 0 4px; }
.cmp-res { margin-top: 12px; padding: 12px 14px; border-radius: 14px; background: var(--bg); font-family: 'Literata', Georgia, serif; font-size: 17px; line-height: 1.6; }

/* Pantallas completas (pasaje, búsqueda, notas, perícopas) */
.pantalla { position: fixed; inset: 0; z-index: 80; background: var(--surface); color: var(--text); display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .35s cubic-bezier(.2,.9,.25,1); visibility: hidden; }
.pantalla.on { transform: none; visibility: visible; }
.p-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px; border-bottom: 1px solid var(--border); }
.p-top h2 { margin: 0; font-size: 17px; font-weight: 700; flex: 1; text-align: center; }
.p-body { flex: 1; overflow: auto; padding: 12px 20px calc(24px + env(safe-area-inset-bottom, 0px)); max-width: 680px; width: 100%; margin: 0 auto; }
.buscador { display: flex; align-items: center; gap: 8px; height: 46px; border-radius: 23px; border: 1px solid var(--border); background: var(--bg); padding: 0 6px 0 14px; color: var(--text-2); }
.buscador input { flex: 1; min-width: 0; height: 44px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; outline: none; }
.seg2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg); border: 1px solid var(--border); margin: 12px 0; }
.seg2 button { height: 40px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.seg2 button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.libro { border-bottom: 1px solid var(--border); }
.libro > button { width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: space-between; border: 0; background: none; color: var(--text); font: inherit; font-size: 16px; cursor: pointer; padding: 0 2px; }
.libro.abierto > button { color: var(--accent); font-weight: 700; }
.caps { display: none; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 2px 0 14px; }
.libro.abierto .caps { display: grid; }
.caps button { height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; }
.caps button.on { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.res-n { font-size: 14px; color: var(--text-2); margin: 12px 2px; }
.res { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; padding: 12px 2px; cursor: pointer; }
.res b { display: block; color: var(--accent); font-size: 14px; margin-bottom: 4px; }
.res span { font-family: 'Literata', Georgia, serif; font-size: 16px; line-height: 1.55; }
.res mark { background: var(--hl-amarillo); color: inherit; border-radius: 3px; }
.peri-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--text); font: inherit; font-size: 15px; padding: 12px 2px; cursor: pointer; }
.peri-item small { color: var(--text-2); display: block; font-size: 13px; }
.peri-item.actual { color: var(--accent); font-weight: 700; }
.peri-item.tocada { background: var(--accent-soft); border-radius: 12px; padding-left: 10px; padding-right: 10px; }
.peri-cap { position: sticky; top: -12px; background: var(--surface); padding: 14px 2px 6px; font-size: 13px; font-weight: 700; color: var(--text-2); z-index: 1; }

/* Notas */
.n-tit { width: 100%; height: 48px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 17px; font-weight: 700; padding: 0 14px; }
.n-tools { display: flex; align-items: center; gap: 2px; padding: 4px; border-radius: 14px; background: var(--bg); border: 1px solid var(--border); margin: 10px 0; overflow-x: auto; }
.n-tools button { min-width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 17px; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.n-tools .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; flex-shrink: 0; }
.n-editor { min-height: 300px; border-radius: 14px; border: 1px solid var(--border); padding: 14px 16px; font-family: 'Literata', Georgia, serif; font-size: 17px; line-height: 1.65; color: var(--text); outline: none; overflow-wrap: anywhere; }
.n-editor:empty::before { content: attr(data-ph); color: var(--text-2); }
.n-editor img { max-width: 100%; height: auto; border-radius: 10px; }
.n-editor blockquote { margin: 0 0 12px; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 10px 10px 0; padding: 8px 12px; font-size: 15px; }
.n-pie { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 calc(8px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; }
.n-pie .btn-l { flex: 1; }
.nota { display: block; width: 100%; text-align: left; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); font: inherit; padding: 14px 16px; margin-bottom: 10px; cursor: pointer; }
.nota b { display: block; font-size: 16px; margin-bottom: 2px; }
.nota small { color: var(--text-2); font-size: 13px; }
.nota p { margin: 6px 0 0; color: var(--text-2); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Aviso flotante */
.aviso { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px); z-index: 90; background: var(--text); color: var(--surface);
  padding: 12px 18px; border-radius: 14px; font-size: 15px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; max-width: 90vw; text-align: center; }
.aviso.on { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .hoja, .velo, .pantalla, .lbar, .accion, .aviso { transition: none !important; }
  .v.destello { animation: none; background-color: var(--accent-soft); }
}

/* Escuchar el capítulo desde la lectura */
.escuchar-pill { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  height: 44px; padding: 0 18px; border-radius: 22px; border: 0; background: var(--accent-fill); color: var(--on-accent); font: inherit; font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 6px 18px rgba(46,125,50,.3); cursor: pointer; transition: opacity .25s, transform .25s; white-space: nowrap; }
.escuchar-pill[hidden] { display: none; }
.lectura.leyendo .escuchar-pill { opacity: 0; transform: translate(-50%, 24px); pointer-events: none; }
.mini { position: fixed; z-index: 35; left: 12px; right: 12px; margin: 0 auto; max-width: 640px; bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 8px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,.16); transition: bottom .28s ease; }
.mini[hidden] { display: none; }
.lectura.leyendo .mini { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.mini-b { width: 44px; height: 44px; border-radius: 22px; border: 0; background: transparent; color: var(--text); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; padding: 0; }
#mini-play { background: var(--accent-fill); color: var(--on-accent); }
.mini-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 0 4px; }
.mini-t b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-barra { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; }
.mini-barra i { display: block; height: 100%; width: 0; background: var(--accent-fill); }
.con-mini .fab { bottom: calc(158px + env(safe-area-inset-bottom, 0px)); }
.lectura.leyendo.con-mini .fab { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }

.chip-cmp { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.chip-cmp[aria-checked="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }

/* Referencias cruzadas */
.xr { border: 0; background: none; color: var(--accent); font: inherit; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-weight: 800; font-size: .8em;
  vertical-align: super; line-height: 0; padding: 0 3px; margin-left: 1px; cursor: pointer; min-width: 24px; min-height: 24px; }
.xr[aria-expanded="true"] { color: var(--on-accent); background: var(--accent-fill); border-radius: 6px; }
.xr-box { display: block; margin: 8px 0 14px; padding: 6px 12px; border-left: 3px solid var(--accent-fill); background: var(--bg); border-radius: 0 12px 12px 0;
  font-size: .82em; line-height: 1.55; animation: xr-in .25s ease; }
@keyframes xr-in { from { opacity: 0; transform: translateY(-4px); } }
.xr-item { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
.xr-item b { display: block; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 13px; color: var(--accent); margin-bottom: 2px; }
.xr-ir { display: inline-block; margin-top: 6px; min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: inherit; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; }
.xr-pie { display: block; padding: 6px 0 2px; font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 11px; color: var(--text-2); }
@media (prefers-reduced-motion: reduce) { .xr-box { animation: none; } }

/* Un versículo por línea: el número va en una columna a la izquierda */
.texto.separado p { position: relative; margin: 0 0 12px; padding-left: 2em; }
.texto.separado .vn { position: absolute; left: 0; top: .5em; width: 1.6em; text-align: right; vertical-align: baseline; line-height: 1; font-size: .62em; margin: 0; }
.texto.separado .xr-box { margin-left: 0; }
/* El * más discreto hasta que se toca */
.xr { color: var(--text-2); opacity: .75; font-weight: 700; }
.xr:hover, .xr:focus-visible { opacity: 1; color: var(--accent); }
