:root {
  --bg: #f7f1e5;
  --surface: #fffdf8;
  --surface-2: #f1e9d6;
  --ink: #2b2a33;
  --muted: #6b6558;
  --accent: #1d3b5c;
  --accent-ink: #ffffff;
  --gold: #a87a22;
  --gold-soft: #f1e2b8;
  --border: #e6dcc6;
  --ok: #2f6b4f;
  --shadow: 0 1px 2px rgba(60, 45, 10, .06), 0 6px 18px rgba(60, 45, 10, .06);
  --fs: 18px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c; --surface: #172030; --surface-2: #1d2a3e; --ink: #ece6d8; --muted: #a79f8d;
    --accent: #8fb4de; --accent-ink: #0f141c; --gold: #d8ae5a; --gold-soft: #3a3118; --border: #26334a;
    --ok: #7fcaa0; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141c; --surface: #172030; --surface-2: #1d2a3e; --ink: #ece6d8; --muted: #a79f8d;
  --accent: #8fb4de; --accent-ink: #0f141c; --gold: #d8ae5a; --gold-soft: #3a3118; --border: #26334a;
  --ok: #7fcaa0; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 var(--sans);
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  overscroll-behavior-y: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { max-width: 640px; margin: 0 auto; padding-inline: 16px; padding-top: env(safe-area-inset-top, 0px); }
main { outline: none; padding-bottom: 24px; }

/* Barra superior */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 10px; }
.topbar h1 { margin: 0; font: 600 13px/1.2 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.topbar .sub { margin: 2px 0 0; font: 600 20px/1.2 var(--serif); color: var(--ink); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font: 600 13px/1 var(--sans); white-space: nowrap; }
.chip svg { width: 15px; height: 15px; }

/* Navegación por día */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 14px; }
.daynav .label { text-align: center; flex: 1; font: 600 15px/1.3 var(--sans); color: var(--muted); }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; color: var(--ink); }
.iconbtn svg { width: 20px; height: 20px; }
.iconbtn:active { transform: scale(.96); }
.backtoday { display: block; margin: -6px auto 12px; background: none; border: 0; color: var(--accent); font: 600 14px var(--sans); text-decoration: underline; text-underline-offset: 3px; padding: 8px 12px; }

/* Tarjetas */
.title { margin: 6px 0 16px; font: 700 calc(var(--fs) * 1.55)/1.2 var(--serif); letter-spacing: -.01em; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px 18px 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 10px; font: 700 12px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); display: flex; align-items: center; gap: 8px; }
.card h2 svg { width: 16px; height: 16px; }
.card p { margin: 0 0 .7em; }
.card p:last-child { margin-bottom: 0; }
.read { font: calc(var(--fs)) / 1.65 var(--serif); }
.ref { font: 700 calc(var(--fs) * .95)/1.3 var(--sans); color: var(--accent); margin: 0 0 8px !important; }
.verses { font: var(--fs)/1.7 var(--serif); }
.verses sup { font: 700 .62em var(--sans); color: var(--gold); margin-right: 3px; vertical-align: super; }
.verses .sep { text-align: center; color: var(--muted); letter-spacing: .3em; margin: .4em 0; }
.verses.clamped { max-height: 11.5em; overflow: hidden; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.linkbtn { background: none; border: 0; padding: 10px 0 0; color: var(--accent); font: 600 14px var(--sans); text-decoration: underline; text-underline-offset: 3px; }
.source { margin-top: 10px !important; font: 12px/1.4 var(--sans); color: var(--muted); }
.prayer { font: italic calc(var(--fs) * 1.02)/1.65 var(--serif); }

/* Acciones */
.amen { width: 100%; min-height: 56px; border: 0; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font: 700 18px var(--sans); letter-spacing: .02em; display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: var(--shadow); margin: 6px 0 12px; }
.amen svg { width: 22px; height: 22px; stroke-width: 2.4; }
.amen.done { background: transparent; color: var(--ok); border: 2px solid var(--ok); box-shadow: none; }
.amen:active { transform: translateY(1px); }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.act { min-height: 52px; padding: 8px 6px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font: 600 12px var(--sans); color: var(--ink); }
.act svg { width: 20px; height: 20px; }
.act[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.act[aria-pressed="true"] svg { fill: currentColor; }

/* Banner de instalación */
.install { display: flex; gap: 12px; align-items: flex-start; background: var(--accent); color: var(--accent-ink); border-radius: 16px; padding: 14px 14px 14px 16px; margin-bottom: 14px; }
.install p { margin: 0; font-size: 14px; line-height: 1.4; }
.install strong { display: block; font-size: 15px; margin-bottom: 2px; }
.install .go { margin-top: 10px; background: var(--accent-ink); color: var(--accent); border: 0; border-radius: 10px; padding: 9px 14px; font: 700 14px var(--sans); }
.install .x { margin-left: auto; background: none; border: 0; color: inherit; opacity: .8; font-size: 22px; line-height: 1; padding: 0 4px; }

/* Aviso de pago, modal y bono */
a.amen { text-decoration: none; }
.pay { background: var(--gold-soft); border: 1px solid var(--gold); border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; }
.pay strong { display: block; font: 700 16px var(--sans); color: var(--ink); margin-bottom: 2px; }
.pay p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; color: var(--ink); }
.payrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.paybtn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 12px; background: #1f8f4e; color: #fff; text-decoration: none; font: 700 14px var(--sans); }
.paybtn svg { width: 20px; height: 20px; }
.paylink { background: none; border: 0; padding: 10px 2px; color: var(--accent); font: 600 14px var(--sans); text-decoration: underline; text-underline-offset: 3px; }
.amen svg + * { margin-left: 0; }
.bonus { border-color: var(--ok); }
.bonus h2 { color: var(--ok); }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(15, 20, 28, .62); display: grid; place-items: end center; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); overflow-y: auto; }
.modal[hidden] { display: none; }
.sheet { width: 100%; max-width: 520px; background: var(--surface); color: var(--ink); border-radius: 22px; padding: 24px 20px 18px; box-shadow: var(--shadow); display: grid; gap: 10px; animation: up .25s ease both; }
.sheet h2 { margin: 0; font: 700 22px/1.25 var(--serif); }
.sheet p { margin: 0 0 4px; font-size: 16px; line-height: 1.5; }
.sheet .btn, .sheet .amen { margin: 0; }
.sheet .linkbtn { text-align: center; padding: 12px; }
.codeinput { width: 100%; padding: 14px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg); color: var(--ink); font: 700 20px/1.2 var(--sans); letter-spacing: .04em; text-align: center; }
.codeinput:focus { border-color: var(--accent); outline: none; }
.err { color: #b3261e; font-size: 14px !important; min-height: 1.2em; margin: 0 !important; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 700px) { .modal { place-items: center; } }

/* Calendario */
.monthnav { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.monthnav h2 { margin: 0; font: 700 22px var(--serif); text-transform: capitalize; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow { text-align: center; font: 700 11px var(--sans); color: var(--muted); padding: 4px 0; letter-spacing: .06em; }
.day { position: relative; aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; font: 600 15px var(--sans); color: var(--ink); padding: 0; }
.day.empty { visibility: hidden; border: 0; }
.day.today { border: 2px solid var(--accent); }
.day.done { background: var(--gold-soft); color: var(--gold); }
.day.sel { outline: 2px solid var(--gold); outline-offset: 1px; }
.day .dot { position: absolute; bottom: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--ok); }
.day .fav { position: absolute; top: 4px; right: 5px; width: 9px; height: 9px; fill: var(--gold); stroke: none; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 14px 0 0; font: 13px var(--sans); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 6px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font: 700 24px var(--serif); color: var(--accent); }
.stat span { font: 12px var(--sans); color: var(--muted); }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.item { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; display: block; box-shadow: var(--shadow); }
.item .when { font: 700 12px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.item .name { font: 700 18px/1.3 var(--serif); margin-top: 2px; }
.item .ref2 { font: 14px var(--sans); color: var(--muted); margin-top: 2px; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 12px; }
.empty-state svg { width: 44px; height: 44px; color: var(--gold); margin-bottom: 8px; }

/* Ajustes */
.setting { padding: 14px 0; border-bottom: 1px solid var(--border); }
.setting:last-child { border-bottom: 0; }
.setting h3 { margin: 0 0 4px; font: 700 16px var(--sans); }
.setting p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.seg button { background: var(--surface); border: 0; padding: 12px 6px; font: 600 14px var(--sans); border-right: 1px solid var(--border); color: var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.btn { border: 1px solid var(--border); background: var(--surface); padding: 12px 16px; border-radius: 12px; font: 600 15px var(--sans); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: #b3261e; border-color: #b3261e66; }
.preview { font: var(--fs)/1.6 var(--serif); margin: 12px 0 0; padding: 12px 14px; background: var(--surface-2); border-radius: 12px; }
.about { font-size: 14px; color: var(--muted); }
.about p { margin: 0 0 .8em; }

/* Navegación inferior */
.tabs { position: fixed; inset: auto 0 0 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
.tabs button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; min-height: 52px; color: var(--muted); font: 600 11px var(--sans); border-radius: 12px; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs button[aria-current="page"] svg { stroke-width: 2.3; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  main > * { animation: in .28s ease both; }
  @keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}
@media (min-width: 700px) {
  body { padding-bottom: 96px; }
  .app { padding-inline: 24px; }
}
