/* MyCalvary prototype v2
   Matches the original app's configured look: white theme, black accents,
   grey blocks, system font, image-led lists. Light only, as the original. */

:root {
  --bg: #ffffff;          /* theme.primary */
  --block: #edeef0;       /* theme.block */
  --line: #c8cacf;        /* theme.blockAccent */
  --muted: #747578;       /* theme.secondaryAccent */
  --ink: #000000;         /* theme.primaryAccent / brand.primary */
  --on-ink: #ffffff;      /* brand.primaryAccent */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Noto Serif", "Times New Roman", serif;
  --col: 760px;
  --bar: 52px;
  --tabs: 56px;
  --mini: 60px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.app { display: flex; flex-direction: column; height: 100%; }

/* top bar */
.topbar {
  position: relative; z-index: 6; display: flex; align-items: center; justify-content: space-between;
  min-height: var(--bar); padding: env(safe-area-inset-top) max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  background: var(--bg); border-bottom: 1px solid var(--block);
}
.tb-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 8px; }
.tb-btn svg { width: 24px; height: 24px; }
.tb-btn .i-back { display: none; }
.topbar.sub .tb-btn .i-menu { display: none; }
.topbar.sub .tb-btn .i-back { display: block; }
.tb-title {
  position: absolute; left: 56px; right: 56px; bottom: 0; height: var(--bar);
  margin: 0; display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.tb-title span { overflow: hidden; text-overflow: ellipsis; }

/* scroll area + column */
.scroll { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
#view { max-width: var(--col); margin: 0 auto; padding-bottom: 24px; }
.pad { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* image boxes */
.ph { background: var(--block); position: relative; overflow: hidden; }
.ph img { width: 100%; height: 100%; object-fit: cover; }
.ar-banner { aspect-ratio: 2.743 / 1; }
.ar-card { aspect-ratio: 2.76 / 1; }
.ar-wide { aspect-ratio: 16 / 9; }
.ar-square { aspect-ratio: 1 / 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* home: banner header + stacked image-only cards */
.stack { display: flex; flex-direction: column; gap: 6px; }
.stack a { display: block; }

/* sermons: featured carousel + image-only grid */
.featured {
  display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 12px max(16px, env(safe-area-inset-left)) 6px; scrollbar-width: none;
}
.featured::-webkit-scrollbar { display: none; }
.featured a { flex: 0 0 86%; scroll-snap-align: center; border-radius: 6px; overflow: hidden; }
.dots { display: flex; justify-content: center; gap: 6px; padding: 4px 0 10px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--ink); }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
  padding: 6px max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
}
.grid a { border-radius: 4px; overflow: hidden; }

/* rows with text below (Sermon Notes, nested lists, locations) */
.rows { display: flex; flex-direction: column; gap: 18px; padding: 16px 0; }
.rows.narrow { width: 90%; max-width: 640px; margin: 0 auto; }
.rows.square-art .ph { width: 100%; max-width: 360px; }
.rowcard { display: block; min-width: 0; }
.rowcard .ph { border-radius: 4px; }
.rowcard.shadow .ph { box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.rowcard .t { margin: 8px 0 0; font-weight: 600; font-size: 16px; line-height: 1.3; }
.rowcard .s { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }
.rowcard.textonly { border-bottom: 1px solid var(--block); padding-bottom: 14px; }
.ext-ico { display: inline-block; width: 14px; height: 14px; vertical-align: -1px; margin-left: 4px; color: var(--muted); }

/* list rows: thumb left (series, search, downloads) */
.list { display: flex; flex-direction: column; }
.li {
  display: grid; grid-template-columns: 116px 1fr auto; gap: 12px; align-items: center;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--block); min-width: 0;
}
.li .ph { border-radius: 4px; }
.li .meta { min-width: 0; }
.li .t { font-weight: 600; font-size: 15.5px; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.li .s { font-size: 13px; color: var(--muted); margin: 3px 0 0; }
.li .aside { font-size: 12px; color: var(--muted); white-space: nowrap; }
.li.noart { grid-template-columns: 1fr auto; }

/* message */
.player { background: #000; aspect-ratio: 16 / 9; position: relative; }
.player video, .player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.listen { background: var(--block); padding: 20px 16px 16px; }
.listen .cover { width: min(62%, 300px); margin: 0 auto 16px; border-radius: 6px; overflow: hidden; box-shadow: 0 4px 18px rgba(0,0,0,.18); }
.seek { width: 100%; accent-color: var(--ink); }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.transport { display: flex; justify-content: center; align-items: center; gap: 28px; margin-top: 8px; }
.transport button { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; }
.transport button svg { width: 28px; height: 28px; }
.transport .pp { width: 62px; height: 62px; background: var(--ink); color: var(--on-ink); }
.transport .pp svg { width: 30px; height: 30px; fill: currentColor; stroke: none; }
.transport .skip { position: relative; }
.transport .skip b { position: absolute; font-size: 9px; font-weight: 700; top: 50%; left: 50%; transform: translate(-50%, -40%); }

.modebar { display: flex; gap: 8px; padding: 12px max(16px, env(safe-area-inset-left)) 0; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 8px; overflow: hidden; }
.seg button { padding: 7px 16px; font-size: 14px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 13.5px; font-weight: 600; background: var(--bg);
}
.chip svg { width: 16px; height: 16px; }
.chip.dark { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }

.mtitle { font-size: 22px; font-weight: 700; line-height: 1.25; margin: 14px 0 4px; text-wrap: balance; }
.msub { color: var(--muted); font-size: 14px; margin: 0 0 12px; }
.desc { font-size: 15.5px; line-height: 1.55; margin: 0 0 6px; white-space: pre-line; max-width: 65ch; }
.groups { margin-top: 10px; border-top: 1px solid var(--block); }
.grow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px max(16px, env(safe-area-inset-right)) 15px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--block); font-weight: 600; font-size: 15.5px;
}
.grow svg { width: 18px; height: 18px; color: var(--muted); flex: none; }

/* bible */
.bseg { display: flex; margin: 14px 16px 6px; border: 1px solid var(--ink); border-radius: 8px; overflow: hidden; }
.bseg button { flex: 1; padding: 8px 0; font-weight: 600; font-size: 14px; }
.bseg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.books { display: grid; grid-template-columns: 1fr 1fr; padding: 4px 0 8px; }
.books a { padding: 12px max(16px, env(safe-area-inset-left)); border-bottom: 1px solid var(--block); font-size: 15.5px; display: flex; justify-content: space-between; gap: 8px; }
.books a span { color: var(--muted); font-size: 13px; }
.chapters { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; padding: 16px; }
.chapters a { aspect-ratio: 1; display: grid; place-items: center; background: var(--block); border-radius: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.reader { font-family: var(--serif); line-height: 1.75; padding: 8px max(18px, env(safe-area-inset-left)) 0 max(18px, env(safe-area-inset-right)); max-width: 68ch; margin: 0 auto; }
.reader h2 { font-family: var(--font); font-size: 22px; margin: 14px 0 10px; }
.reader p { margin: 0 0 10px; }
.reader sup { font-family: var(--font); font-size: .62em; font-weight: 700; color: var(--muted); margin-right: 3px; }
.reader-nav { display: flex; justify-content: space-between; gap: 10px; padding: 14px 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: 8px; font-weight: 600; font-size: 14.5px; border: 1px solid var(--ink); }
.btn.dark { background: var(--ink); color: var(--on-ink); }
.btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
.cont { margin: 14px 16px 2px; display: flex; justify-content: space-between; align-items: center; background: var(--block); border-radius: 10px; padding: 14px 16px; font-weight: 600; }
.cont span { color: var(--muted); font-weight: 500; font-size: 13px; }
.notice { color: var(--muted); font-size: 12.5px; padding: 10px 16px 0; }

/* search */
.sbox { padding: 12px max(16px, env(safe-area-inset-left)) 8px max(16px, env(safe-area-inset-right)); position: sticky; top: 0; background: var(--bg); z-index: 2; }
.sbox input { width: 100%; font: inherit; font-size: 16px; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--block); color: var(--ink); }
.shead { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: 14px 16px 6px; }
.hrow { display: flex; gap: 10px; overflow-x: auto; padding: 0 16px 4px; scrollbar-width: none; }
.hrow a { flex: 0 0 160px; }
.hrow a .ph { border-radius: 4px; }
.hrow a p { margin: 6px 0 0; font-size: 13px; font-weight: 600; line-height: 1.25; }

/* simple pages */
.page { padding: 18px max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right)); }
.page h2 { font-size: 20px; margin: 0 0 8px; }
.page p { margin: 0 0 12px; color: #222; max-width: 65ch; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14.5px; margin: 6px 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 40px 16px; text-align: center; }

/* in-app web view */
.webview { position: relative; height: calc(100dvh - var(--bar) - var(--tabs) - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.webview iframe { width: 100%; height: 100%; border: 0; display: block; }

/* mini player */
.mini {
  display: flex; align-items: center; gap: 6px; height: var(--mini);
  padding: 0 max(6px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  background: var(--bg); border-top: 1px solid var(--block); z-index: 5;
}
.mini-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.mini-art { width: 42px; height: 42px; border-radius: 4px; object-fit: cover; background: var(--block); flex: none; }
.mini-text { display: flex; flex-direction: column; min-width: 0; }
.mini-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-btn { width: 44px; height: 44px; display: grid; place-items: center; flex: none; }
.mini-btn svg { width: 24px; height: 24px; }
.mini-btn .fill { fill: currentColor; stroke: none; }

/* bottom tabs */
.tabbar {
  display: flex; background: var(--bg); border-top: 1px solid var(--block); z-index: 5;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tab { flex: 1; height: var(--tabs); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tab svg { width: 25px; height: 25px; }
.tab.active { color: var(--ink); }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(80vw, 320px); background: var(--bg); z-index: 21;
  padding: calc(env(safe-area-inset-top) + 18px) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
  box-shadow: 4px 0 24px rgba(0,0,0,.18); display: flex; flex-direction: column;
}
.drawer-head { display: flex; gap: 12px; align-items: center; padding: 0 18px 18px; border-bottom: 1px solid var(--block); }
.drawer-head img { border-radius: 12px; }
.drawer-name { font-weight: 700; font-size: 18px; }
.drawer-sub { color: var(--muted); font-size: 13px; }
.drawer-nav { display: flex; flex-direction: column; padding: 6px 0; }
.drawer-nav a { padding: 14px 18px; font-size: 16px; font-weight: 600; }
.drawer-foot { margin-top: auto; padding: 14px 18px; color: var(--muted); font-size: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: slidein .18s ease-out; }
  @keyframes slidein { from { transform: translateX(-100%); } to { transform: none; } }
}


/* notices */
.series-sub { margin-top: 12px; }
.note { font-size: 13.5px; color: var(--muted); background: var(--block); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; max-width: 65ch; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--tabs) + var(--mini) + env(safe-area-inset-bottom) + 12px);
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--on-ink); font-size: 14px; box-shadow: 0 4px 18px rgba(0,0,0,.25);
}
