:root {
  --bg: #f7f3ea; --card: #ffffff; --ink: #1d2233; --muted: #6b6f7d; --line: #e6dfcf;
  --navy: #1f2a44; --gold: #b8892b; --gold-soft: #f3e6c4; --green: #2f7d4f; --red: #b23a3a;
  --shadow: 0 1px 3px rgba(30,30,50,.08), 0 4px 14px rgba(30,30,50,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151f; --card: #1c2130; --ink: #ecebe6; --muted: #9a9eab; --line: #2c3245;
    --navy: #0d111b; --gold: #d9ad55; --gold-soft: #3a3220; --green: #5cc38a; --red: #e07373;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
/* --badge-h: room reserved under the tab bar for the host's "Powered by" badge (set by app.js when present) */
:root { --badge-h: 0px; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom) + var(--badge-h)); }
.serif { font-family: Georgia, "Times New Roman", serif; }

.topbar { position: sticky; top: 0; z-index: 5; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); }
.topbar h1 { font-size: 19px; margin: 0; font-weight: 600; letter-spacing: .2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { background: none; border: 0; color: #fff; font-size: 22px; padding: 4px 6px; cursor: pointer; }
.sync-dot { width: 9px; height: 9px; border-radius: 50%; background: #777; display: inline-block; }
.sync-dot.ok { background: #5cc38a; } .sync-dot.pending { background: #e0b44a; } .sync-dot.err { background: #e07373; }

main { max-width: 680px; margin: 0 auto; padding: 14px 16px 24px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: calc(env(safe-area-inset-bottom) + var(--badge-h)); }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); font-size: 11px; padding: 8px 2px 9px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabs button span { font-size: 20px; line-height: 1; }
.tabs button.active { color: var(--gold); font-weight: 600; }

.fab { position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom) + var(--badge-h)); z-index: 7; width: 58px; height: 58px;
  border-radius: 50%; border: 0; background: var(--gold); color: #fff; font-size: 26px; box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; }

.card { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--gold); margin: 0 0 8px; font-weight: 700; }
.card h3 { font-size: 17px; margin: 0 0 6px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.verse { font-family: Georgia, serif; font-size: 18px; line-height: 1.6; margin: 6px 0; white-space: pre-wrap; }
.ref { font-weight: 700; color: var(--navy); }
@media (prefers-color-scheme: dark) { .ref { color: var(--gold); } }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--gold-soft); color: var(--ink); }
.pill.green { background: rgba(47,125,79,.15); color: var(--green); }

button.btn, a.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); border-radius: 10px; padding: 9px 14px; font-size: 15px; cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
@media (prefers-color-scheme: dark) { .btn.primary { background: var(--gold); color: #111; border-color: var(--gold); } }
.btn.gold { background: var(--gold); color: #fff; border-color: var(--gold); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

textarea, input, select { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.field-row { display: flex; gap: 8px; } .field-row > * { flex: 1; }

.list-item { padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: 0; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pre { white-space: pre-wrap; }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet.hidden { display: none; }
.sheet-card { background: var(--card); width: 100%; max-width: 680px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom) + var(--badge-h)); }
.sheet-card h3 { margin-top: 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom) + var(--badge-h)); z-index: 30;
  background: #222; color: #fff; padding: 9px 16px; border-radius: 99px; font-size: 14px; max-width: 90vw; }
.toast.hidden { display: none; }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--gold); }
.reading { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.reading input[type=checkbox] { width: 22px; height: 22px; flex: none; }
.reading .what { flex: 1; }

/* memorisation */
.words { font-family: Georgia, serif; font-size: 19px; line-height: 2; }
.w { display: inline-block; margin-right: 5px; }
.w.blank { min-width: 2.2em; border-bottom: 2px solid var(--gold); color: transparent; cursor: pointer; user-select: none; }
.w.blank.shown { color: var(--muted); }
.w.ok { color: var(--green); } .w.miss { color: var(--red); }
.score { font-size: 28px; font-weight: 700; }
.mic.on { background: var(--red); color: #fff; border-color: var(--red); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; color: var(--muted); font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button.on { background: var(--gold); color: #111; } }
/* Bible reader */
.vs { cursor: pointer; border-radius: 4px; }
.vs sup { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 11px; color: var(--gold); font-weight: 700; margin-right: 3px; }
.vs.hl { background: var(--gold-soft); }
.vs.reading { background: rgba(47,125,79,.18); }
.vs.sel { background: rgba(31,42,68,.12); text-decoration: underline; text-decoration-color: var(--gold); }
@media (prefers-color-scheme: dark) { .vs.sel { background: rgba(217,173,85,.18); } }
details.month { padding: 6px 0; border-bottom: 1px solid var(--line); }
details.month summary { cursor: pointer; padding: 6px 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* Meditation journey: the five stages */
.stages { display: flex; gap: 4px; margin-top: 10px; }
.stages button { flex: 1; border: 1px solid var(--line); background: none; border-radius: 10px; padding: 6px 2px; font-size: 18px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stages button span { font-size: 10px; line-height: 1.1; }
.stages button.past { color: var(--ink); background: var(--gold-soft); border-color: transparent; }
.stages button.on { color: #fff; background: var(--gold); border-color: var(--gold); font-weight: 700; }
.guide p { line-height: 1.6; }
.guide h4 { margin: 16px 0 4px; color: var(--gold); }
.pill.green-time { background: rgba(47,125,79,.15); color: var(--green); }

/* Today: one-tap shortcuts */
.shortcuts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.shortcuts button { background: none; border: 0; color: var(--ink); font: inherit; font-size: 12px; padding: 6px 2px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.shortcuts button span { font-size: 22px; width: 44px; height: 44px; border-radius: 50%; background: var(--gold-soft); display: flex; align-items: center; justify-content: center; }
.shortcuts button:active { background: var(--line); }
mark { background: var(--gold-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
