/* ===========================================================
   Pulse mobile shell — loads AFTER style.css.
   1) Warm light theme via CSS variable override (cascades to all).
   2) Adds the bottom tab bar, view router, and new Home/Flow UI.
   =========================================================== */

:root {
  --bg-obsidian: #FBF6F0;       /* warm cream page */
  --bg-sapphire-dark: #F4EAE0;  /* soft sand */
  --bg-sapphire-card: #FFFFFF;  /* clean warm white card */
  --color-text-primary: #2C2422;/* deep warm espresso */
  --color-text-muted: #8A7A6E;  /* warm taupe */
  --color-border: rgba(196, 154, 120, 0.22);
  --color-border-focus: rgba(233, 122, 90, 0.55);
  --color-clay: #E97A5A;        /* primary -> warm coral */
  --color-gold: #F0A93B;        /* accent -> warm amber */
  --color-gold-hover: #F6BE62;
  --color-sage: #C98A5E;
  --color-teal: #E08A52;
  --pulse-violet: #E97A5A;      /* coral */
  --pulse-cyan: #F0A93B;        /* amber */
  --pulse-amber: #D9654B;       /* deep terracotta */
  --tab-h: 64px;
  --hdr-h: 52px;
}

html, body { background: var(--bg-obsidian); color: var(--color-text-primary); }
body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
* { -webkit-tap-highlight-color: transparent; }

/* ---------- Header ---------- */
header.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  height: calc(var(--hdr-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 16px 0;
  background: rgba(251, 246, 240, 0.85);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--color-border);
}
.app-header .logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; }
.app-header .logo-img { border-radius: 8px; display: block; }
.gradient-text {
  background: linear-gradient(120deg, var(--pulse-violet), var(--pulse-cyan));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.header-controls { display: flex; align-items: center; gap: 8px; }
#reader-controls-group { display: none; gap: 8px; align-items: center; }

/* ---------- Scroll body + view router ---------- */
.app-body {
  padding: calc(var(--hdr-h) + env(safe-area-inset-top) + 12px) 14px
           calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px);
  max-width: 640px; margin: 0 auto;
}
/* Override style.css ID rules (specificity-safe): hide all views by default */
body #dashboard-view, body #view-read, body #view-pray, body #view-flow, body #view-me {
  display: none;
}
body #dashboard-view.active, body #view-read.active, body #view-pray.active,
body #view-flow.active, body #view-me.active {
  display: block;
}
.tab-view { animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Bottom tab bar ---------- */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-top: 1px solid var(--color-border);
}
.tab-bar-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; background: none; border: none; cursor: pointer;
  color: var(--color-text-muted); font-size: 0.66rem; font-weight: 600; letter-spacing: .2px;
  padding: 8px 0; transition: color .15s;
}
.tab-bar-btn .tb-ico { width: 23px; height: 23px; display: block; }
.tab-bar-btn .tb-ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab-bar-btn.active { color: var(--color-clay); }
body.no-scroll .tab-bar { display: none; }

/* ---------- Cards ---------- */
.card, .hero-card, .daily-card, .financial-prayer-card, .quest-panel, .quest-actions, .mood-container {
  background: var(--bg-sapphire-card);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 18px;
  margin: 0 0 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-head h2 { font-size: 1.05rem; margin: 0; }
.eyebrow { font-size: .72rem; letter-spacing: 1.4px; text-transform: uppercase; color: var(--color-text-muted); margin: 0 0 10px; }
.muted-sm { font-size: .85rem; color: var(--color-text-muted); line-height: 1.5; margin: 6px 0 0; }
.daily-label { font-size: .72rem; letter-spacing: 1px; text-transform: uppercase; color: var(--color-text-muted); margin: 0 0 4px; }

/* ---------- Home: balance radar ---------- */
.hero-card { text-align: center; padding-top: 16px; }
.balance-wrap { display: flex; justify-content: center; }
#smb-canvas { max-width: 100%; }
.balance-legend { display: flex; justify-content: center; gap: 16px; margin-top: 6px; font-size: .82rem; color: var(--color-text-muted); }
.balance-legend strong { color: var(--color-text-primary); margin-left: 4px; }
.leg::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.leg-spirit::before { background: var(--pulse-violet); }
.leg-mind::before { background: var(--pulse-amber); }
.leg-body::before { background: var(--pulse-cyan); }

/* ---------- Energy bar ---------- */
.energy-level-label { font-size: .82rem; font-weight: 700; color: var(--pulse-cyan); }
.energy-range {
  -webkit-appearance: none; appearance: none; width: 100%; height: 10px; border-radius: 999px; margin: 14px 0 6px;
  background: linear-gradient(90deg, var(--pulse-violet) var(--fill, 50%), rgba(150,160,190,0.18) var(--fill, 50%));
}
.energy-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, var(--pulse-cyan));
  border: 2px solid #0B0D17; box-shadow: 0 2px 10px rgba(34,211,238,.5); cursor: pointer;
}
.energy-range::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--pulse-cyan); border: 2px solid #0B0D17; }
.energy-scale-ends { display: flex; justify-content: space-between; font-size: .72rem; color: var(--color-text-muted); }

/* ---------- Body chips ---------- */
.body-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.body-chip {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; min-width: 0;
  border-radius: 14px; border: 1px solid var(--color-border); background: var(--bg-sapphire-dark);
  color: var(--color-text-muted); font-size: .72rem; font-weight: 600; cursor: pointer; transition: all .15s;
}
.body-chip .bc-ico { display: block; width: 22px; height: 22px; }
.body-chip .bc-ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.body-chip.on { color: var(--color-clay); border-color: var(--color-clay); background: rgba(233,122,90,.10); box-shadow: 0 0 0 1px rgba(233,122,90,.22); }

/* ---------- Growth ---------- */
.growth-streak { font-size: .9rem; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; color: var(--color-clay); }
.streak-ico { width: 16px; height: 16px; fill: var(--color-clay); }
.growth-visual { display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px; margin: 10px 0; }
.gv-dot { width: 100%; aspect-ratio: 1; border-radius: 50%; background: rgba(150,160,190,0.14); transition: background .3s; }
.gv-dot.on { box-shadow: 0 0 8px rgba(124,92,255,.5); }

/* ---------- Tonight passage / stats ---------- */
.daily-card-top { display: flex; justify-content: space-between; gap: 12px; }
.daily-card h2 { margin: 2px 0 0; font-size: 1.5rem; }
.level-pill { align-self: flex-start; font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(124,92,255,.15); color: var(--pulse-violet); white-space: nowrap; }
.btn-large { width: 100%; margin-top: 14px; padding: 14px; font-size: 1rem; }
.quest-panel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; text-align: center; }
.stat-card { display: flex; flex-direction: column; gap: 2px; }
.stat-card .stat-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .6px; color: var(--color-text-muted); }
.stat-card strong { font-size: 1.5rem; color: var(--pulse-cyan); }
.stat-card span:last-child { font-size: .7rem; color: var(--color-text-muted); }
.week-track { display: flex; gap: 3px; justify-content: center; margin-top: 8px; }
.quest-actions { display: flex; flex-direction: column; gap: 10px; }
.quest-buttons { display: flex; gap: 10px; }
.quest-buttons .btn { flex: 1; }
.btn-sm { font-size: .82rem; padding: 8px 12px; }
.storage-note { font-size: .72rem; color: var(--color-text-muted); margin: 0; }

/* ---------- Read: theme grid (equal-width, equal-height cards) ---------- */
.mood-title { font-size: 1rem; margin: 0 0 12px; }
.mood-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mood-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  min-width: 0; height: 100%;
  background: var(--bg-sapphire-card); border: 1px solid var(--color-border);
  border-radius: 16px; padding: 14px; box-shadow: 0 2px 10px rgba(180,120,80,.05);
}
.mood-card:hover { transform: none; box-shadow: 0 4px 16px rgba(180,120,80,.1); }
.mood-card .mood-icon { width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--color-clay), var(--color-gold)); flex-shrink: 0; }
.mood-card .mood-info h3 { font-size: .92rem; margin: 0 0 2px; }
.mood-card .mood-info h4 { font-size: .76rem; color: var(--color-text-muted); margin: 0 0 4px; font-weight: 500; }
.mood-card .mood-info p { font-size: .76rem; color: var(--color-text-muted); line-height: 1.45; margin: 0; }

/* ---------- Pray ---------- */
.financial-prayer-head { display: flex; justify-content: space-between; gap: 10px; }
.weekday-pill { align-self: flex-start; font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: rgba(34,211,238,.14); color: var(--pulse-cyan); }
.financial-date-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0; }
.financial-date-row input { flex: 1; }
.financial-prayer-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: center; margin-bottom: 14px; }
.financial-prayer-stats > div { background: var(--bg-sapphire-dark); border-radius: 14px; padding: 10px; }
.financial-prayer-stats strong { display: block; font-size: 1.4rem; color: var(--pulse-cyan); }
.financial-prayer-stats span { font-size: .7rem; color: var(--color-text-muted); }
.lord-prayer-block, .daily-financial-prayer { background: var(--bg-sapphire-dark); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.prayer-block-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.prayer-block-title span { font-weight: 700; }
.prayer-block-title small, .prayer-copyright { font-size: .68rem; color: var(--color-text-muted); }
.lord-prayer-grid p, .daily-financial-prayer p { line-height: 1.7; font-size: .92rem; }
.financial-prayer-card .btn-primary { width: 100%; }
.financial-prayer-status { font-size: .8rem; color: var(--pulse-cyan); text-align: center; margin-top: 8px; }

/* ---------- Flow: calendar ---------- */
.calendar-head { margin-bottom: 12px; }
.calendar-head h2 { font-size: 1rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-size: .68rem; color: var(--color-text-muted); padding: 4px 0; }
.cal-cell { position: relative; aspect-ratio: 1; border: none; background: var(--bg-sapphire-dark); border-radius: 12px; color: var(--color-text-primary); font-size: .8rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0; }
.cal-cell.empty { background: none; }
.cal-cell.today { outline: 2px solid var(--pulse-violet); }
.cal-num { font-weight: 600; }
.cal-dots { display: flex; gap: 2px; height: 6px; }
.cd { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.cd-read { background: var(--pulse-violet); }
.cd-pray { background: var(--pulse-cyan); }
.cd-hl { background: var(--pulse-amber); }
.calendar-legend { display: flex; justify-content: center; gap: 14px; margin-top: 12px; font-size: .72rem; color: var(--color-text-muted); }
.calendar-legend .cd { width: 7px; height: 7px; margin-right: 2px; vertical-align: middle; }
.dd-row { display: flex; align-items: center; gap: 7px; font-size: .9rem; margin: 6px 0; }
.dd-row .cd { width: 8px; height: 8px; }
.hl-q { border-left: 2px solid var(--pulse-amber); margin: 8px 0; padding: 4px 0 4px 10px; font-size: .88rem; }
.hl-q cite { display: block; font-size: .72rem; color: var(--color-text-muted); margin-top: 4px; font-style: normal; }

/* ---------- Me ---------- */
.me-card .btn { width: 100%; }

/* ---------- Reader overlay (study-view) ---------- */
#study-view {
  display: none; position: fixed; inset: 0; z-index: 80;
  background: var(--bg-obsidian); overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 8px) 0 env(safe-area-inset-bottom);
}
#study-view .study-layout { display: block; max-width: 720px; margin: 0 auto; padding: 0 14px 24px; }
#study-view .reader-container, #study-view .sidebar-container { width: 100%; }
#study-view .chapter-header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 8px 0 10px; background: var(--bg-obsidian); }
#study-view .reading-stage { display: block; }
#study-view .sidebar-container { margin-top: 16px; border-top: 1px solid var(--color-border); padding-top: 12px; }
#study-view .sidebar-tabs { display: flex; gap: 6px; overflow-x: auto; }
#study-view .sidebar-tabs .tab-btn { white-space: nowrap; }

/* ---------- generic button refresh ---------- */
.btn-icon { padding: 8px; }
.chevron { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; display: inline-block; }
.chevron.left { transform: rotate(135deg); }
.chevron.right { transform: rotate(-45deg); }

/* ===========================================================
   Warm-theme overrides for legacy style.css (blue dark-mode bits)
   Placed last for highest precedence.
   =========================================================== */
body .btn-primary {
  background: linear-gradient(135deg, var(--color-clay) 0%, var(--color-gold) 100%);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  box-shadow: 0 10px 24px rgba(233,122,90,0.28);
}
body .btn-primary:hover {
  background: linear-gradient(135deg, #f08a6a 0%, var(--color-gold-hover) 100%);
  box-shadow: 0 12px 28px rgba(233,122,90,0.34);
}
body .btn {
  background: var(--bg-sapphire-card);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
body select, body input[type="date"], body input[type="text"], body input[type="password"], body textarea {
  background: var(--bg-sapphire-card);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}
body select:focus, body input:focus, body textarea:focus { border-color: var(--color-clay); outline: none; }
/* theme card icon -> warm gradient, fixed square */
body .mood-card .mood-icon, body .mood-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--color-clay), var(--color-gold)) !important;
  color: #fff;
}
/* selection / range cards inside reader */
body .reading-range-card, body .selection-bar { background: var(--bg-sapphire-dark); border: 1px solid var(--color-border); }
/* level pill / verse num warm */
body .verse-num { color: var(--color-clay); }

/* ---------- Growth milestones ---------- */
.milestone-block { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--color-border); }
.milestone-row { display: flex; justify-content: space-between; align-items: baseline; font-size: .8rem; }
.milestone-label { font-weight: 600; color: var(--color-text-primary); }
.milestone-count { color: var(--color-text-muted); }
.milestone-bar { height: 8px; border-radius: 999px; background: var(--bg-sapphire-dark); margin: 8px 0; overflow: hidden; }
.milestone-bar span { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--color-clay), var(--color-gold)); transition: width .5s ease; }
.milestone-verse { font-size: .8rem; color: var(--color-text-muted); font-style: italic; line-height: 1.5; margin: 4px 0 0; }

/* ---------- Soul trend ---------- */
.trend-card canvas { width: 100%; height: auto; display: block; }

/* ---------- Me tab ---------- */
.me-card .me-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.me-card .me-field label { font-size: .85rem; color: var(--color-text-muted); }
.me-card .me-field select { flex: 1; max-width: 62%; }
.me-buttons { display: flex; gap: 10px; margin-top: 12px; }
.me-buttons .btn { flex: 1; }
.me-data-status { font-size: .78rem; color: var(--color-clay); margin: 8px 0 0; min-height: 1em; }
.sync-pill { font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--bg-sapphire-dark); color: var(--color-text-muted); }
.sync-pill.sync-synced { background: rgba(201,138,94,.16); color: var(--color-sage); }
.sync-pill.sync-offline { background: rgba(217,101,75,.16); color: var(--pulse-amber); }
.sync-pill.sync-syncing, .sync-pill.sync-connecting { background: rgba(240,169,59,.16); color: var(--color-gold); }
