/* =========================================================
   Biblie · App para los hermanos
   ========================================================= */
:root {
  --bg: #FFFFFF;
  --wash: #F4F6F8;
  --card: #FFFFFF;
  --ink: #17202A;
  --ink-2: #3E4954;
  --muted: #5A6573;
  --line: #DDE2E8;
  --line-strong: #C9D1DA;
  --accent: #1D5C78;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6F0F4;
  --accent-hover: #164A61;
  --warn-bg: #F7ECD9; --warn-ink: #6A430C;
  --info-bg: #E6F0F4; --info-ink: #1D4A5E;
  --ok-bg: #E3F1E7; --ok-ink: #23573A;
  --wa: #1E7A47;
  --read-size: 18px;
  --serif: 'Literata', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 16px;
  --tabbar-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11171D; --wash: #0C1116; --card: #18212A; --ink: #E8ECF0; --ink-2: #C3CBD3; --muted: #A3AEBA;
    --line: #2B3641; --line-strong: #3A4754; --accent: #7FC1DD; --accent-ink: #0B1A22; --accent-soft: #1C3340; --accent-hover: #9BD0E6;
    --warn-bg: #3A2C14; --warn-ink: #F0D3A0; --info-bg: #1C3340; --info-ink: #BFE0EE; --ok-bg: #1B3324; --ok-ink: #B5E0C2; --wa: #6CD39A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11171D; --wash: #0C1116; --card: #18212A; --ink: #E8ECF0; --ink-2: #C3CBD3; --muted: #A3AEBA;
  --line: #2B3641; --line-strong: #3A4754; --accent: #7FC1DD; --accent-ink: #0B1A22; --accent-soft: #1C3340; --accent-hover: #9BD0E6;
  --warn-bg: #3A2C14; --warn-ink: #F0D3A0; --info-bg: #1C3340; --info-ink: #BFE0EE; --ok-bg: #1B3324; --ok-ink: #B5E0C2; --wa: #6CD39A;
  color-scheme: dark;
}
:root[data-size="0"] { --read-size: 16px; }
:root[data-size="1"] { --read-size: 18px; }
:root[data-size="2"] { --read-size: 21px; }
:root[data-size="3"] { --read-size: 24px; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 17px; line-height: 1.5;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
img, svg { vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.topbar__inner { max-width: 720px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); min-width: 0; min-height: 44px; }
.brand__logo { display: block; height: 30px; width: auto; }
.brand__logo--ondark { display: none; }
.brand__tag { font-size: 13px; color: var(--muted); line-height: 1.15; padding-left: 12px; border-left: 1px solid var(--line-strong); white-space: nowrap; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand__logo--onlight { display: none; }
  :root:not([data-theme="light"]) .brand__logo--ondark { display: block; }
}
:root[data-theme="dark"] .brand__logo--onlight { display: none; }
:root[data-theme="dark"] .brand__logo--ondark { display: block; }
@media (max-width: 340px) { .brand__tag { display: none; } }
.topbar__actions { display: flex; gap: 6px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 44px; height: 44px; padding: 0 8px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-btn--big { font-size: 19px; font-weight: 700; }
.icon-btn--lg { width: 50px; height: 50px; }
.icon-btn--ghost { border-color: transparent; background: transparent; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-weight: 700; font-size: 16px;
  text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--line-strong); color: var(--ink); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn--whatsapp { color: var(--wa); }
.btn--whatsapp:hover { color: var(--wa); }
.btn--ghost { background: transparent; }
.btn--small { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Estructura ---------- */
.page { max-width: 720px; margin: 0 auto; padding: 20px 16px 32px; }
.page-title { font-family: var(--serif); font-weight: 700; font-size: 28px; margin: 0 0 16px; letter-spacing: -0.01em; }
.section-label { font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 24px 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card__title { font-size: 19px; margin: 0 0 4px; }

.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card); color: var(--ink); font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip--on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip--on:hover { color: var(--accent-ink); }
.chip--accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); min-height: 30px; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; font-weight: 700; }

/* ---------- Devocional ---------- */
.devotional { display: flex; flex-direction: column; gap: 18px; }
.eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0; color: var(--muted); font-size: 15px; }
.devotional__title { font-family: var(--serif); font-weight: 700; font-size: calc(var(--read-size) * 1.7); line-height: 1.15; letter-spacing: -0.01em; margin: 0; }
.verse { margin: 0; padding: 20px; border-radius: var(--radius); background: var(--wash); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.verse blockquote { margin: 0; font-family: var(--serif); font-style: italic; font-size: calc(var(--read-size) * .98); line-height: 1.6; }
.verse figcaption { font-weight: 700; color: var(--accent); font-size: 16px; }
/* ---------- Imágenes, audio y archivos ---------- */
.hero { margin: 0; }
.hero__link { display: block; border-radius: var(--radius); overflow: hidden; background: var(--wash); }
.hero img { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: cover; }
.hero figcaption, .gallery figcaption { font-size: 14px; color: var(--muted); margin-top: 6px; }
.audio-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--card); display: flex; flex-direction: column; gap: 10px; }
.audio-card__head { display: flex; gap: 12px; align-items: center; }
.audio-card__icon { flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.audio-card__text { display: flex; flex-direction: column; min-width: 0; }
.audio-card__text strong { font-size: 17px; }
.audio-card__text small { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-card audio { width: 100%; height: 44px; }
.gallery { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gallery--1 { grid-template-columns: minmax(0, 1fr); }
.gallery--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.gallery figure { margin: 0; min-width: 0; }
.gallery__link { display: block; border-radius: 12px; overflow: hidden; background: var(--wash); aspect-ratio: 1; }
.gallery--1 .gallery__link { aspect-ratio: auto; }
.gallery img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 420px) { .gallery--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); text-decoration: none; min-height: 60px; }
.file:hover { border-color: var(--line-strong); color: var(--ink); }
.file > svg { flex: none; color: var(--accent); }
.file__ext { flex: none; width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; letter-spacing: .04em; background: var(--wash); color: var(--ink-2); }
.file__ext--pdf { background: #FBEDEA; color: #9B2F22; }
.file__ext--doc, .file__ext--docx { background: #E6EEF9; color: #1F4E8C; }
.file__ext--xls, .file__ext--xlsx { background: #E3F1E7; color: #23573A; }
.file__ext--ppt, .file__ext--pptx { background: #F7ECD9; color: #7A4E0E; }
.file__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__meta { font-size: 14px; color: var(--muted); }
.lightbox { border: 0; padding: 0; max-width: 100vw; max-height: 100vh; width: 100vw; height: 100vh; background: rgba(0,0,0,.92); color: #fff; }
.lightbox::backdrop { background: rgba(0,0,0,.92); }
.lightbox[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.lightbox img { max-width: 100vw; max-height: calc(100vh - 110px); object-fit: contain; }
.lightbox__close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.lightbox__close:hover { color: #fff; background: rgba(255,255,255,.22); }
.lightbox__caption { margin: 0; padding: 0 16px; text-align: center; font-size: 15px; color: #E8ECF0; max-width: 640px; }
.entry__thumb { flex: none; width: 54px; height: 54px; border-radius: 10px; object-fit: cover; }
.entry__icons { display: inline-flex; gap: 6px; color: var(--muted); vertical-align: middle; margin-left: 4px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 130px; }
#ttsBtn .when-on { display: none; }
#ttsBtn[aria-pressed="true"] .when-on { display: inline-flex; align-items: center; gap: 8px; }
#ttsBtn[aria-pressed="true"] .when-off { display: none; }
#ttsBtn .when-off { display: inline-flex; align-items: center; gap: 8px; }
.fav-btn[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.fav-btn[aria-pressed="true"] svg { fill: currentColor; }

.reading { font-family: var(--serif); font-size: var(--read-size); line-height: 1.7; }
.reading .section-label { font-family: var(--sans); margin-top: 8px; }
.reading p { margin: 0 0 1em; }
.reading p:last-child { margin-bottom: 0; }
.prayer__box { padding: 18px 20px; border-radius: var(--radius); background: var(--accent-soft); }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.devotional__footer { border-top: 1px solid var(--line); padding-top: 14px; color: var(--muted); font-size: 15px; }
.prevnext { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.prevnext__item { display: flex; flex-direction: column; gap: 4px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); background: var(--card); }
.prevnext__item:hover { color: var(--ink); border-color: var(--line-strong); }
.prevnext__item--next { text-align: right; grid-column: 2; }
.prevnext__dir { font-size: 14px; font-weight: 700; color: var(--accent); display: inline-flex; align-items: center; gap: 4px; }
.prevnext__item--next .prevnext__dir { justify-content: flex-end; }
.prevnext__title { font-family: var(--serif); font-weight: 600; font-size: 16px; line-height: 1.3; }
[data-reading-now] { background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 6px; }

/* ---------- Historial ---------- */
.search__field { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--card); color: var(--muted); }
.search__field input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--ink); font-size: 17px; }
.search__field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chips-row { display: flex; gap: 8px; overflow-x: auto; padding: 14px 0 4px; scrollbar-width: none; }
.chips-row::-webkit-scrollbar { display: none; }
.calendar { margin-top: 12px; }
.calendar__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calendar__head h2 { margin: 0; font-size: 19px; }
.calendar__grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendar__dow { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.day { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; max-height: 52px; border-radius: 12px; color: var(--muted); font-weight: 600; text-decoration: none; position: relative; }
.day--has { color: var(--ink); }
.day--has::after { content: ''; position: absolute; bottom: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.day--has:hover { background: var(--accent-soft); color: var(--ink); }
.day--today { outline: 2px solid var(--accent); outline-offset: -2px; }
.entries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.entry { display: flex; gap: 14px; align-items: center; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-decoration: none; color: var(--ink); }
.entry:hover { border-color: var(--line-strong); color: var(--ink); }
.entry__date { flex: none; width: 54px; text-align: center; display: flex; flex-direction: column; line-height: 1.1; }
.entry__day { font-size: 26px; font-weight: 700; color: var(--accent); }
.entry__month { font-size: 13px; font-weight: 700; color: var(--muted); }
.entry__year { font-size: 12px; color: var(--muted); }
.entry__body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.entry__title { font-family: var(--serif); font-weight: 600; font-size: 18px; line-height: 1.3; }
.entry__meta { font-size: 15px; color: var(--muted); }
.entry__snippet { font-size: 15px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { color: var(--muted); padding: 16px 0; }

/* ---------- Ajustes ---------- */
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.row-between--line { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.row-label { display: flex; flex-direction: column; cursor: pointer; }
.switch { flex: none; width: 58px; height: 34px; border-radius: 999px; border: 0; padding: 3px; cursor: pointer; background: #8A949F; display: flex; align-items: center; justify-content: flex-start; transition: background .15s; }
.switch span { width: 28px; height: 28px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] span { transform: translateX(24px); }
.switch[disabled] { opacity: .5; cursor: not-allowed; }
.field { border: 0; padding: 0; margin: 16px 0 0; }
.field legend { font-weight: 700; font-size: 16px; margin-bottom: 8px; padding: 0; }
.segmented { display: grid; gap: 6px; padding: 4px; border-radius: 12px; background: var(--wash); border: 1px solid var(--line); }
.segmented--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.segmented button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); font-weight: 700; cursor: pointer; font-size: 15px; }
.segmented button[aria-pressed="true"] { background: var(--card); color: var(--accent); box-shadow: 0 1px 3px rgba(23,32,42,.18); }
.segmented--sizes button { font-family: var(--serif); }
.segmented--sizes button:nth-child(1) { font-size: 15px; }
.segmented--sizes button:nth-child(2) { font-size: 18px; }
.segmented--sizes button:nth-child(3) { font-size: 21px; }
.segmented--sizes button:nth-child(4) { font-size: 24px; }
.sample { font-family: var(--serif); font-size: var(--read-size); margin: 12px 0 0; }
.custom-hour { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.custom-hour input { height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card); }
.preview-notif { display: flex; gap: 12px; padding: 12px; border-radius: 16px; background: var(--wash); margin: 16px 0 12px; }
.preview-notif img { border-radius: 10px; flex: none; }
.preview-notif > div { display: flex; flex-direction: column; min-width: 0; font-size: 15px; }
.preview-notif__top { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.preview-notif span { color: var(--ink-2); }
.notice { padding: 12px 14px; border-radius: 12px; margin-top: 12px; font-size: 15px; line-height: 1.45; }
.notice--info { background: var(--info-bg); color: var(--info-ink); }
.notice--warn { background: var(--warn-bg); color: var(--warn-ink); }
.steps h3 { font-size: 16px; margin: 16px 0 6px; }
.steps ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.about { text-align: center; color: var(--muted); font-size: 14px; margin-top: 24px; }

/* ---------- Estados vacíos ---------- */
.empty-state { text-align: center; padding: 40px 8px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty-state img { border-radius: 16px; }
.empty-state h1 { font-family: var(--serif); font-size: 24px; margin: 0; }
.empty-state p { color: var(--muted); max-width: 420px; margin: 0; }
.empty-state .entries { width: 100%; text-align: left; }

/* ---------- Barra inferior ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 600; }
.tabbar a[aria-current="page"] { color: var(--accent); font-weight: 700; }
@media (min-width: 760px) {
  .tabbar { left: 50%; right: auto; width: 420px; transform: translateX(-50%); bottom: 16px; height: var(--tabbar-h); padding: 0; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 6px 24px rgba(23,32,42,.12); }
  body { padding-bottom: calc(var(--tabbar-h) + 40px); }
}

/* ---------- Banner instalar / toast ---------- */
.install-banner__icon { border-radius: 10px; flex: none; }
.install-banner > div:nth-child(2) { flex: 1; display: flex; flex-direction: column; font-size: 15px; min-width: 0; }
.install-banner { max-width: 720px; margin: 12px auto 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--ink); width: calc(100% - 32px); }
.install-banner div:first-child { display: flex; flex-direction: column; font-size: 15px; }
.install-banner span { color: var(--ink-2); }
.install-banner__actions { display: flex; align-items: center; gap: 6px; }
.install-banner .icon-btn { border: 0; background: transparent; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); z-index: 40; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 6px 24px rgba(0,0,0,.2); }

@media print {
  .topbar, .tabbar, .actions, .prevnext, .install-banner { display: none !important; }
  body { padding: 0; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
