/* Colors. Dark is the default. Light follows the phone setting ("Auto")
   or a choice in Settings, saved on that phone as data-theme. */
:root {
  color-scheme: dark;
  --bg: #12151d;
  --bg2: #1a1f2b;
  --card: #202634;
  --line: #2e3546;
  --gold: #d4a537;
  --gold2: #f2cd6b;
  --gold-dim: #6b5a2c;
  --text: #ede7d8;
  --muted: #9aa1b0;
  --red: #e0675a;
  --glow: #232a3a;
  --bar-bg: rgba(18,21,29,.94);
  --crisis-line: #5a3a36;
  --crisis-text: #f3b2a9;
  --shade: rgba(0,0,0,.55);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f5f1e8; --bg2: #ece6d8; --card: #ffffff; --line: #dcd3c1;
    --gold: #b8871c; --gold2: #8a6410; --gold-dim: #d6c18c;
    --text: #1f2430; --muted: #5d6471; --red: #b23b2c;
    --glow: #fffaf0; --bar-bg: rgba(245,241,232,.95);
    --crisis-line: #e2b3ab; --crisis-text: #9e3226; --shade: rgba(20,24,32,.35);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f1e8; --bg2: #ece6d8; --card: #ffffff; --line: #dcd3c1;
  --gold: #b8871c; --gold2: #8a6410; --gold-dim: #d6c18c;
  --text: #1f2430; --muted: #5d6471; --red: #b23b2c;
  --glow: #fffaf0; --bar-bg: rgba(245,241,232,.95);
  --crisis-line: #e2b3ab; --crisis-text: #9e3226; --shade: rgba(20,24,32,.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; }
body { min-height: 100vh; background: radial-gradient(120% 60% at 50% -10%, var(--glow) 0%, var(--bg) 60%) fixed; }
main { max-width: 520px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 32px); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: .01em; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; color: var(--gold2); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }
p { line-height: 1.5; margin: 0 0 1em; }
a { color: var(--gold2); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.gold { color: var(--gold2); }
.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.spacer { height: 16px; }

.brand { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 24px 0 20px; }
.brand svg { width: 56px; height: 56px; }
.brand .name { font-family: var(--serif); font-size: 1.7rem; color: var(--gold2); letter-spacing: .08em; text-transform: uppercase; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.card.gold-edge { border-color: var(--gold-dim); }

label { display: block; font-size: .9rem; color: var(--muted); margin: 0 0 6px; }
input[type=text], input[type=password], input[type=date], input[type=time], select, textarea {
  width: 100%; padding: 13px 14px; font-size: 16px; color: var(--text);
  background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; outline: none; font-family: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: .95rem; }
.check input { width: 22px; height: 22px; accent-color: var(--gold); flex: none; margin-top: 1px; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; font-size: 1rem; font-weight: 600; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); cursor: pointer; text-decoration: none; font-family: inherit;
}
button.primary, .btn.primary { background: transparent; color: var(--gold2); border: 2px solid var(--gold); font-weight: 600; }
button.ghost { background: transparent; }
button.danger { color: var(--red); }
button.block, .btn.block { width: 100%; }
button:disabled { opacity: .5; }
button.sm { padding: 8px 12px; font-size: .85rem; border-radius: 10px; }

.tabs { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 10px; }
.tabs button.on { background: var(--card); color: var(--gold2); }

.error { color: var(--red); font-size: .9rem; min-height: 1.2em; }

/* top bar */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.topbar .title { font-family: var(--serif); color: var(--gold2); letter-spacing: .08em; text-transform: uppercase; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.topbar .title svg { width: 22px; height: 22px; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat .n { font-family: var(--serif); font-size: 1.6rem; color: var(--gold2); line-height: 1.1; }
.stat .l { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }
.stat.warn .n { color: var(--red); }

.dayswitch { display: flex; gap: 8px; margin-bottom: 12px; }
.dayswitch button { flex: 1; padding: 10px; font-size: .9rem; }
.dayswitch button.on { border-color: var(--gold); color: var(--gold2); }

/* tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  position: relative; aspect-ratio: 1 / .86; border-radius: 18px; padding: 14px; text-align: left;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  display: flex; flex-direction: column; justify-content: space-between; align-items: stretch;
  transition: transform .15s ease, background .3s ease;
}
.tile:active { transform: scale(.97); }
.tile .pname { font-family: var(--serif); font-size: 1.2rem; }
.tile .pcount { font-size: .85rem; color: var(--muted); }
.tile .bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.tile .bar i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.tile .glyph { position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; opacity: .45; }
.tile.gold {
  background: linear-gradient(150deg, #f6d77e 0%, #d4a537 55%, #a87d1f 100%);
  border-color: #f6d77e; color: #1d1606; box-shadow: 0 6px 24px rgba(212,165,55,.25);
}
.tile.gold .pcount { color: #3b2c08; }
.tile.gold .glyph { opacity: .8; }
.tile.gold .bar { background: rgba(0,0,0,.15); }
.tile.gold .bar i { background: #1d1606; }

.verse { margin-top: 18px; text-align: center; font-family: var(--serif); font-style: italic; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.verse b { display: block; font-style: normal; font-weight: 600; color: var(--gold); font-size: .8rem; letter-spacing: .08em; margin-top: 4px; }

/* crisis card (Help page only) */
.crisis { padding: 12px 14px; }
.crisis .inner { display: flex; gap: 8px; align-items: center; }
.crisis .txt { flex: 1; font-size: .8rem; color: var(--muted); line-height: 1.3; }
.crisis a { padding: 9px 12px; font-size: .85rem; border-radius: 10px; border: 1px solid var(--crisis-line); color: var(--crisis-text); text-decoration: none; font-weight: 600; white-space: nowrap; }

/* bottom sheet */
.overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: var(--shade); z-index: 30; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; background: var(--bg2); border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px); animation: up .25s ease; }
.sheet .grab { width: 40px; height: 4px; background: var(--line); border-radius: 4px; margin: -6px auto 14px; }
.action { display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px 14px; margin-bottom: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-align: left; font-weight: 500; }
.action .box { width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--gold-dim); flex: none; display: grid; place-items: center; }
.action.done { border-color: var(--gold-dim); }
.action.done .box { background: #d4a537; border-color: #c8952a; }
.action.done .box::after { content: ""; width: 7px; height: 13px; border: solid #1a1406; border-width: 0 3px 3px 0; transform: rotate(45deg) translate(-1px,-1px); }
.modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 40; background: var(--shade); display: grid; place-items: center; padding: 16px; animation: fade .2s ease; }
.modal .card { max-width: 420px; width: 100%; }

/* crown celebration */
.crown-burst { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(circle, rgba(58,44,14,.97), rgba(10,12,18,.98) 60%); animation: fade .3s ease; padding: 24px; }
.crown-burst .inner { text-align: center; max-width: 360px; }
.crown-burst svg { width: 120px; height: 120px; animation: crown 1.1s cubic-bezier(.2,1.4,.4,1) both; filter: drop-shadow(0 0 24px rgba(242,205,107,.6)); }
.crown-burst h2 { color: var(--gold2); font-size: 1.8rem; margin-top: 14px; animation: rise .6s .4s both; }
.crown-burst p { animation: rise .6s .55s both; }

@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(40px); opacity: .4 } }
@keyframes crown { 0% { transform: scale(.2) rotate(-20deg); opacity: 0 } 100% { transform: none; opacity: 1 } }
@keyframes rise { from { transform: translateY(12px); opacity: 0 } }

/* setup wizard */
.progress { display: flex; gap: 6px; margin: 4px 0 18px; }
.progress i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.progress i.on { background: var(--gold); }
.minbox { border-left: 3px solid var(--gold); padding: 10px 12px; background: var(--bg2); border-radius: 0 10px 10px 0; margin-bottom: 12px; }
.minbox .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); margin-bottom: 2px; }
.act-input { display: flex; gap: 8px; margin-bottom: 8px; }
.act-input input { flex: 1; }
.act-input button { flex: none; width: 48px; padding: 0; }
.wizard-nav { display: flex; gap: 10px; margin-top: 20px; }
.wizard-nav button { flex: 1; }
.review-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.review-row:last-child { border: 0; }
.review-row ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }

/* admin */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.code { font-family: ui-monospace, Menlo, monospace; color: var(--gold2); font-size: 1rem; letter-spacing: .04em; }
.member { padding: 12px 0; border-bottom: 1px solid var(--line); }
.member:last-child { border: 0; }
.member .btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill { display: inline-block; font-size: .7rem; padding: 2px 8px; border-radius: 20px; border: 1px solid var(--gold-dim); color: var(--gold2); vertical-align: middle; margin-left: 6px; }

/* daily or weekly choice */
.act-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.act-row:last-child { border-bottom: 0; }
.act-row .act-input { margin-bottom: 8px; }
.freq { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.freq button { padding: 7px 12px; font-size: .85rem; border-radius: 20px; color: var(--muted); }
.freq button.on { border-color: var(--gold); color: var(--gold2); background: rgba(212,165,55,.08); }
.freq select { width: auto; padding: 7px 10px; font-size: 16px; border-radius: 10px; }
.action.weekly { cursor: default; }
.action .wtext { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.action .wtext small { color: var(--muted); font-weight: 400; font-size: .8rem; }
.stepper { display: flex; gap: 6px; flex: none; }
.stepper button { width: 40px; height: 40px; padding: 0; font-size: 1.3rem; border-radius: 10px; }
.review-row li .pill { margin-left: 4px; }

/* look switch in Settings */
.theme-pick { display: flex; gap: 6px; }
.theme-pick button { flex: 1; padding: 10px; font-size: .9rem; }
.theme-pick button.on { border-color: var(--gold); color: var(--gold2); background: rgba(212,165,55,.10); }

/* Phase 2: welcome, brothers, notes, help */
.welcome p { font-size: .95rem; }
.welcome h2 { color: var(--gold2); font-size: 1.35rem; line-height: 1.3; }
.spots { text-align: center; margin: 18px 0 10px; }
.spots .n { font-family: var(--serif); font-size: 2rem; color: var(--gold2); }
.spots .l { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.spots .bar { height: 6px; background: var(--line); border-radius: 6px; overflow: hidden; max-width: 260px; margin: 8px auto 0; }
.spots .bar i { display: block; height: 100%; background: var(--gold); }
.note-banner { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; padding: 14px 16px; }
.note-banner .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); }
.note-banner button { align-self: flex-end; }
.note-banner.reach { border-color: var(--gold-dim); }
.bro { padding: 12px 0; border-bottom: 1px solid var(--line); }
.bro:last-child { border-bottom: 0; }
.bro .why { margin-top: 4px; font-family: var(--serif); font-style: italic; color: var(--muted); line-height: 1.4; }
.dots { display: inline-flex; gap: 5px; vertical-align: middle; }
.dots i { width: 16px; height: 16px; border-radius: 5px; border: 1.5px solid var(--gold-dim); display: inline-block; }
.dots i.on { background: #d4a537; border-color: #c8952a; }
.legend { display: flex; align-items: center; gap: 4px; }
.notebox { margin: 6px 0 10px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.notebox textarea { resize: vertical; }
.reply { margin-top: 6px; padding: 8px 10px; border-left: 3px solid var(--gold); background: var(--bg2); border-radius: 0 8px 8px 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-size: .9rem; margin: 0; }
.choice input { width: 20px; height: 20px; accent-color: var(--gold); flex: none; margin-top: 2px; }
.sqrow { flex-wrap: nowrap; }
.sqsel { width: auto; flex: 1 1 0; min-width: 0; max-width: 100%; padding: 8px 10px; text-overflow: ellipsis; }
/* iPhone date boxes ignore width:100% unless told not to */
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; display: block; min-height: 48px; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; }
.member textarea { margin-top: 8px; }
.row .btns { display: flex; gap: 6px; flex: none; }

/* Phase 3: money boxes in the Financial tile, My week, step back */
.money { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.money .mrow { display: flex; gap: 10px; }
.money .mrow > div { flex: 1 1 0; min-width: 0; }
.money label { font-size: .8rem; }
.dollar { display: flex; align-items: center; gap: 4px; }
.dollar span { color: var(--muted); }
.dollar input { flex: 1 1 0; min-width: 0; }
.pw { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-top: 1px solid var(--line); }
.pw .bar { height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.pw .bar i { display: block; height: 100%; background: var(--gold); }
.pw.slipping .bar i { background: var(--red); }
.pw .tag { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); margin-left: 4px; }
.pw.strong .tag { color: var(--gold2); border-color: var(--gold-dim); }
.pw.slipping .tag { color: var(--red); border-color: var(--red); }
.card .stats { grid-template-columns: repeat(2, 1fr); margin-bottom: 0; }
.card .stats .n { font-size: 1.3rem; }

/* Phase 3: wall, chat, photos, clips, review */
label.btnlike { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; margin: 0; }
.dotwrap { position: relative; }
.dotwrap .dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--gold2); }
.av { border-radius: 50%; object-fit: cover; flex: none; display: inline-block; background: var(--bg2); }
.av.none { display: inline-flex; align-items: center; justify-content: center; color: var(--gold2); border: 1px solid var(--line); font-family: var(--serif); font-size: .9rem; }
.post { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.post.me { border-color: var(--gold-dim); }
.ptag { display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); margin-top: 4px; }
.ptag.win { color: var(--gold2); border-color: var(--gold-dim); }
.ptag.prayer { color: var(--text); }
.ptag.struggle { color: var(--red); border-color: var(--red); }
.ptext { margin-top: 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pphoto { display: block; width: 100%; max-height: 420px; object-fit: cover; border-radius: 10px; margin-top: 8px; }
.pthumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; }
.reacts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.reacts button.on, .tagpick button.on { border-color: var(--gold); color: var(--gold2); }
.tagpick { display: flex; flex-wrap: wrap; gap: 6px; }
.photogrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ph { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ph img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; }
.ph .btns { flex-wrap: wrap; }
.clip { width: 100%; max-width: 100%; border-radius: 10px; background: #000; }
audio.clip { background: transparent; }
.clipcard { margin-bottom: 12px; }
.clipcard .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--gold); }
.badge { padding: 6px 0; color: var(--muted); }
.badge.on { color: var(--text); }
.badge span { color: var(--gold2); margin-right: 4px; }
.upbar { height: 8px; border-radius: 4px; background: var(--bg2); overflow: hidden; }
.upbar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }
.card .crown svg, .card.center > svg { width: 48px; height: 48px; margin: 0 auto; }
.btn.sm { padding: 8px 12px; font-size: .85rem; border-radius: 10px; }
