/* The Body Freedom Protocol: member portal.
   Tokens match bodyfreedomprotocol.com. Mobile-first at 390px; on wider
   screens the app is a 480px column centred on ivory. */
:root {
  --bg-primary: #FAF8F5; --bg-secondary: #F2EFE9; --bg-card: #FFFFFF; --bg-dark: #1E2421;
  --text-primary: #1C1C1A; --text-secondary: #52514E; --text-muted: #6B6964;
  --accent: #3D5448; --accent-hover: #2E4137; --accent-soft: #E5ECE8; --accent-pale: #B9C6BE;
  --border: #E4E0D8; --brass: #9A7B4F; --brass-text: #86683C;
  --on-dark: #FAF8F5; --on-dark-muted: #AEB8B2; --dark-line: #55695E;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 12px; --radius-lg: 18px;
  --shadow-md: 0 12px 36px rgba(28, 28, 26, .07);
  --col: 480px; --tabs-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg-primary); color: var(--text-primary);
  font-family: var(--sans); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
svg { width: 24px; height: 24px; display: block; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.dark :focus-visible { outline-color: var(--on-dark); }
h1:focus, h2:focus { outline: none; }

h1, h2, .wordmark { font-family: var(--serif); font-weight: 500; }
h1 { font-size: 38px; line-height: 1.12; letter-spacing: -.005em; text-wrap: balance; }
h2 { font-size: 25px; line-height: 1.2; }
.eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--text-muted);
}
.eyebrow.brass { color: var(--brass-text); }
.lead { color: var(--text-secondary); font-size: 16px; }
.meta { color: var(--text-muted); font-size: 13px; }
.soft { color: var(--text-secondary); font-size: 15px; }
.italic { font-family: var(--serif); font-style: italic; font-size: 20px; line-height: 1.4; }
.center { text-align: center; }

/* ---------- shell ---------- */
.app { max-width: var(--col); margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 24px); }
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 20px; }
.wordmark { font-size: 19px; letter-spacing: .01em; color: var(--text-primary); }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; color: var(--text-primary); }
.icon-btn:hover { background: var(--bg-secondary); }
.main { padding: 8px 20px 0; display: flex; flex-direction: column; gap: 20px; }
.hero { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.block { display: flex; flex-direction: column; gap: 10px; }
.sec { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text-muted); }
.foot { padding: 32px 20px 8px; text-align: center; font-size: 12px; color: var(--text-muted); }
.foot a { color: inherit; }

.tabs {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 20;
  width: 100%; max-width: var(--col); display: flex;
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs button {
  flex: 1; min-height: var(--tabs-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
}
.tabs button svg { width: 22px; height: 22px; }
.tabs button[aria-current] { color: var(--accent); font-weight: 600; }

/* ---------- cards, buttons ---------- */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.btn {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 54px; padding: 0 24px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 16px; font-weight: 600; text-align: center;
  transition: background .15s ease;
}
.btn:hover { background: var(--accent-hover); }
.btn-quiet { background: var(--accent-soft); color: var(--accent); min-height: 46px; }
.btn-quiet:hover { background: var(--accent-pale); }
.btn-sm { width: auto; min-height: 44px; padding: 0 22px; font-size: 14px; }
.btn-light { background: var(--on-dark); color: var(--bg-dark); }
.btn-light:hover { background: #fff; }
.link { min-height: 44px; display: inline-flex; align-items: center; color: var(--accent); font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.link.center { width: 100%; justify-content: center; }
.dark .link { color: var(--on-dark-muted); }

.cover { background: var(--dark-line); color: var(--on-dark); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-family: var(--serif); font-weight: 500; font-variant-numeric: lining-nums; }
.cover-sm { width: 52px; height: 52px; font-size: 26px; }
.cover-md { width: 76px; height: 76px; font-size: 40px; }
.cover-lg { width: min(62vw, 240px); height: min(62vw, 240px); font-size: 120px; border-radius: var(--radius-lg); }
.cover-lg svg { width: 72px; height: 72px; stroke-width: 1.1; }
.cover-md svg { width: 32px; height: 32px; }

/* ---------- Today ---------- */
.pbar { display: flex; gap: 8px; margin-top: 8px; }
.pgroup { flex: 1; display: flex; gap: 3px; }
.pgroup.wide { margin: 12px 0 8px; }
.seg { flex: 1; height: 6px; border-radius: 3px; background: var(--border); }
.seg.done { background: var(--accent); }
.seg.cur { background: var(--brass); }
.plabels { display: flex; gap: 8px; font-size: 12px; color: var(--text-muted); }
.plabels span { flex: 1; }

.session-card { display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-md); }
.sc-top { display: flex; gap: 16px; align-items: center; }
.sc-top h2 { margin: 3px 0 2px; }
.sc-desc { color: var(--text-secondary); font-size: 15px; }
.passnote { font-size: 15px; color: var(--text-secondary); background: var(--bg-secondary); border-radius: var(--radius); padding: 14px 16px; }
.passnote span { display: block; font-size: 11px; font-weight: 600; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; }
.prompt { display: flex; flex-direction: column; gap: 12px; background: var(--accent-soft); border-color: var(--accent-pale); }
.prompt p { font-size: 15px; }
.prompt .btn-quiet { background: var(--bg-card); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  min-height: 104px; padding: 14px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); color: var(--accent);
}
.tile:hover { border-color: var(--accent-pale); }
.tile-l { font-size: 15px; font-weight: 500; color: var(--text-primary); line-height: 1.3; margin-top: auto; }
.tile-m { font-size: 12px; color: var(--text-muted); }

.pair + .pair { margin-top: 16px; }
.pair-n { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.pair-row { display: flex; align-items: center; gap: 10px; min-height: 22px; }
.pair-k { width: 48px; font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.pair-v { width: 20px; text-align: right; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.track { flex: 1; height: 8px; border-radius: 4px; background: var(--bg-secondary); overflow: hidden; }
.bar { height: 100%; border-radius: 4px; background: var(--accent); }
.bar.pale { background: var(--accent-pale); }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--text-muted); margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.dot.pale { background: var(--accent-pale); }
.next { margin: 18px 0 10px; font-size: 14px; color: var(--text-secondary); }
.note { display: flex; flex-direction: column; gap: 8px; }
.note-t { font-family: var(--serif); font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
.notes { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Journey ---------- */
.phase { padding: 18px 20px 6px; }
.phase-head { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px; }
.phase-t h2 { margin-top: 2px; }
.phase-x { color: var(--text-muted); transition: transform .15s ease; }
.phase-x.open { transform: rotate(90deg); }
.phase.upcoming { background: transparent; }
.phase.upcoming h2, .phase.upcoming .eyebrow { color: var(--text-muted); }
.days { margin-top: 10px; }
.day { display: flex; align-items: center; gap: 12px; min-height: 56px; border-top: 1px solid var(--border); }
.day-n { width: 26px; font-family: var(--serif); font-variant-numeric: lining-nums; font-size: 21px; color: var(--text-muted); text-align: center; flex-shrink: 0; }
.day-name { flex: 1; font-size: 15px; font-weight: 500; }
.day.later .day-name { color: var(--text-muted); font-weight: 400; }
.day.cur .day-n { color: var(--brass-text); }
.day-when { font-size: 13px; color: var(--text-muted); }
.day-act { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-size: 13px; }
.day-act .again { text-decoration: underline; text-underline-offset: 3px; }
.tick svg { width: 20px; height: 20px; }
.day-fallback .link { font-size: 13px; color: var(--text-muted); padding-left: 38px; }
.mile { display: flex; align-items: center; gap: 10px; min-height: 52px; border-top: 1px solid var(--border); margin-top: 10px; font-size: 14px; color: var(--text-muted); }
.mile-t { flex: 1; }
.mile-d { color: var(--border); display: inline-flex; }
.mile-d svg { width: 16px; height: 16px; }
.mile.reached .mile-d, .mile-d.big { color: var(--brass); }
.mile.reached .mile-t { color: var(--text-primary); }
.mile-d.big svg { width: 26px; height: 26px; }
.mile-ok { color: var(--accent); }
.mile-ok svg { width: 20px; height: 20px; }
.after21 { display: flex; flex-direction: column; gap: 8px; background: var(--bg-secondary); }

/* ---------- Toolkit ---------- */
.tool { display: flex; gap: 14px; align-items: flex-start; width: 100%; padding: 16px; }
.tool:hover { border-color: var(--accent-pale); }
.tool-b { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tool-l { font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1.2; }
.tool-d { font-size: 14px; color: var(--text-secondary); }
.tool-lock { font-size: 13px; font-weight: 500; color: var(--brass-text); }
.tool.locked { cursor: default; background: transparent; }
.tool.locked .cover { background: var(--bg-secondary); color: var(--text-muted); }
.tool.locked .tool-l { color: var(--text-muted); }
.cover-sm svg { width: 24px; height: 24px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.overlay.light { background: var(--bg-primary); }
.overlay.dark { background: var(--bg-dark); color: var(--on-dark); }
.overlay.scrim { background: rgba(28, 28, 26, .45); display: flex; align-items: flex-end; justify-content: center; }
.ov-in { max-width: var(--col); margin: 0 auto; min-height: 100%; padding: 28px 24px calc(32px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 18px; position: relative; }
.scrim .ov-in { min-height: 0; width: 100%; padding: 0; }
.ov-close { margin: -14px 0 0 -10px; }
.dark .icon-btn { color: var(--on-dark); }
.dark .icon-btn:hover { background: rgba(250, 248, 245, .08); }
.dark .eyebrow { color: var(--on-dark-muted); }
.dark .eyebrow.brass { color: #C4A77A; }
.light .ov-in > h1, .steps + h1 { margin-top: 6px; }
.ov-in > .btn { margin-top: 6px; }

.steps { display: flex; gap: 6px; justify-content: center; margin: 2px 0 14px; }
.steps i { width: 28px; height: 3px; border-radius: 2px; background: var(--border); }
.steps i.on { background: var(--accent); }
.inline-audio { display: flex; flex-direction: column; gap: 12px; }
.tones .tile { min-height: 96px; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); font-size: 16px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input, .check input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; margin: 0; }
.check { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 0; font-size: 15px; color: var(--text-secondary); cursor: pointer; }

.rates { display: flex; flex-direction: column; gap: 6px; }
.rate { padding: 12px 0 14px; border-bottom: 1px solid var(--border); }
.rate-h { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.rate-h label { font-size: 16px; font-weight: 500; }
.rate-h output { font-family: var(--serif); font-size: 26px; font-weight: 500; color: var(--accent); min-width: 28px; text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.rate input[type=range] { width: 100%; height: 44px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.rate-a { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

.field { width: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: 16px; }
textarea.field { resize: vertical; min-height: 120px; }
.field:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field-err { color: #9B3A2E; font-size: 14px; }
.refl-l { display: block; font-family: var(--serif); font-size: 22px; line-height: 1.25; margin-bottom: 12px; }
#reflect { display: flex; flex-direction: column; gap: 10px; }
.thanks { font-family: var(--serif); font-size: 22px; }

/* session mode */
.session .ov-in { text-align: center; align-items: center; }
.session .ov-close { align-self: flex-start; }
.session-body { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; flex: 1; }
.session-body h1 { font-size: 36px; margin-top: 8px; }
.session-body .italic { color: var(--on-dark-muted); max-width: 30ch; }
.session-line { font-size: 13px; color: var(--on-dark-muted); max-width: 32ch; margin-top: auto; padding-top: 12px; }
#pl { width: 100%; }
.after { width: 100%; margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.after h2 { font-size: 32px; }
.dark .field { background: rgba(250, 248, 245, .06); border-color: var(--dark-line); color: var(--on-dark); }
.dark .field::placeholder { color: var(--on-dark-muted); }
.dark .field:focus { outline-color: var(--on-dark); }

/* milestone */
.milestone .ov-in { justify-content: center; }
.milestone .body { color: var(--on-dark-muted); font-size: 16px; line-height: 1.65; }
.shift { border-top: 1px solid var(--dark-line); border-bottom: 1px solid var(--dark-line); padding: 16px 0; }
.shift ul { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.shift li { display: flex; justify-content: space-between; gap: 16px; font-size: 15px; }
.shift-v { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* menu sheet, how to listen */
.sheet { background: var(--bg-card); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 12px 12px calc(20px + env(safe-area-inset-bottom, 0px)) 20px; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; }
.menu { display: flex; flex-direction: column; padding-right: 8px; }
.menu a, .menu button { min-height: 56px; display: flex; align-items: center; font-size: 17px; color: var(--text-primary); text-decoration: none; border-top: 1px solid var(--border); }
.howto { display: flex; flex-direction: column; gap: 18px; }
.howto li { display: flex; gap: 14px; }
.howto-n { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--accent-pale); color: var(--accent); display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 18px; flex-shrink: 0; }
.howto h3 { font-size: 16px; font-weight: 600; }
.howto p { font-size: 15px; color: var(--text-secondary); }

/* ---------- player ---------- */
.pl { width: 100%; }
.pl-bar { position: relative; height: 6px; border-radius: 3px; background: var(--border); cursor: pointer; touch-action: none; }
.pl-bar::after { content: ''; position: absolute; left: 0; right: 0; top: -19px; bottom: -19px; }
.pl-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; background: var(--accent); pointer-events: none; }
.pl-times { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pl-controls { display: flex; align-items: center; justify-content: center; gap: 28px; margin-top: 10px; }
.pl-play { width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.pl-play svg { width: 30px; height: 30px; }
.pl-ghost { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text-secondary); }
.pl-ghost svg { width: 28px; height: 28px; }
.pl-volrow { margin-top: 8px; }
.pl-volume { width: 60%; height: 44px; accent-color: var(--accent); }
.pl-status { min-height: 20px; margin-top: 8px; font-size: 13px; color: var(--text-muted); text-align: center; }
.dark .pl-bar { background: var(--dark-line); }
.dark .pl-fill { background: var(--on-dark); }
.dark .pl-times, .dark .pl-status { color: var(--on-dark-muted); }
.dark .pl-play { background: var(--on-dark); color: var(--bg-dark); }
.dark .pl-ghost { color: var(--on-dark); }
.dark .pl-volume { accent-color: var(--on-dark); }
.inline-audio .pl-play { width: 56px; height: 56px; }
.inline-audio .pl-play svg { width: 24px; height: 24px; }

/* ---------- loader, login ---------- */
.loader { position: fixed; inset: 0; z-index: 60; background: var(--bg-primary); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.loader .wordmark { font-size: 24px; }
.loader-msg { font-size: 15px; color: var(--text-secondary); }
.login { max-width: 420px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 48px 24px 32px; display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.login .wordmark { font-size: 21px; margin-bottom: 20px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.login label { font-size: 14px; font-weight: 500; }
.login .code { text-align: center; letter-spacing: 8px; font-size: 22px; }
.login .foot { margin-top: 24px; padding: 0; }
.msg { font-size: 15px; color: var(--text-secondary); min-height: 22px; }
.msg.err { color: #9B3A2E; }

/* ---------- preview toolbar (preview build only) ---------- */
.pv { max-width: var(--col); margin: 0 auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; background: var(--bg-dark); color: var(--on-dark); font-size: 12px; position: relative; z-index: 50; }
.pv b { font-size: 11px; letter-spacing: 1.6px; text-transform: uppercase; color: #C4A77A; font-weight: 600; }
.pv select, .pv button { min-height: 32px; padding: 0 8px; border: 1px solid var(--dark-line); border-radius: 8px; background: transparent; color: var(--on-dark); font-size: 12px; }
.pv option { color: #1C1C1A; }
body.has-pv .overlay, body.has-pv .loader { top: var(--pv-h, 48px); }

@media (min-width: 560px) {
  body { background: var(--bg-primary); }
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
  .tabs { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
@media (max-width: 359px) {
  h1 { font-size: 34px; }
  .main { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
