/* Couch to Strength — design system.
   Calm, mainstream, trustworthy health-app look: warm off-white, calm teal,
   soft green completion, charcoal text. Mobile-first, WCAG-conscious.
   Buttons ALWAYS set an explicit color (button text does not inherit). */

:root {
  --bg: #FAF8F4;            /* warm off-white */
  --surface: #FFFFFF;
  --surface-2: #F1EDE6;
  --ink: #26313A;           /* charcoal with a blue tint */
  --ink-2: #56626C;         /* AA on bg + white */
  --ink-3: #6C7780;
  --line: #E6E1D7;
  --teal: #146C7E;          /* main colour — AA on white (5.5:1) */
  --teal-dark: #0F5563;
  --teal-soft: #E3F0F2;
  --green: #2E7D4F;         /* completion */
  --green-soft: #E6F2EA;
  --amber: #9A6B22;         /* reminders — AA on soft bg */
  --amber-soft: #F7EEDD;
  --red: #A94436;
  --red-soft: #F8E9E5;
  --radius: 18px;
  --radius-sm: 14px;
  --shadow: 0 1px 2px rgba(38,49,58,.05), 0 6px 20px -8px rgba(38,49,58,.12);
  --shadow-lg: 0 2px 4px rgba(38,49,58,.06), 0 14px 36px -10px rgba(38,49,58,.18);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --sat-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151A1E; --surface: #1E2529; --surface-2: #29323A;
    --ink: #E8EDF0; --ink-2: #A7B2BA; --ink-3: #8B959D; --line: #313B43;
    --teal: #5FB4C4; --teal-dark: #7CC5D3; --teal-soft: #1C333A;
    --green: #6FBE93; --green-soft: #1F2F26;
    --amber: #D9A863; --amber-soft: #33291A;
    --red: #E08A7A; --red-soft: #3A2420;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px -8px rgba(0,0,0,.4);
    --shadow-lg: 0 2px 4px rgba(0,0,0,.35), 0 14px 36px -10px rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
html[data-textsize="large"] { font-size: 19px; }
body {
  margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink);
  line-height: 1.5; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}

/* motion: everything off for prefers-reduced-motion OR in-app setting */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
html[data-reduce="1"] *, html[data-reduce="1"] *::before, html[data-reduce="1"] *::after {
  animation: none !important; transition: none !important;
}

/* ---------- layout shell ---------- */
#app { max-width: 560px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
header.top { padding: 18px 20px 6px; display: flex; align-items: center; gap: 10px; }
header.top .mark { width: 34px; height: 34px; border-radius: 10px; flex: none; display: block; }
header.top b { font-size: 1.05rem; letter-spacing: -.01em; }
main { flex: 1; padding: 10px 20px calc(96px + var(--sat-b)); }
.screen { display: none; }
.screen.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

h1 { font-size: 1.65rem; font-weight: 750; letter-spacing: -.02em; margin: 10px 0 6px; line-height: 1.22; }
h2 { font-size: 1.12rem; font-weight: 700; margin: 26px 0 10px; letter-spacing: -.01em; }
p { margin: 0 0 12px; }
.sub { color: var(--ink-2); font-size: .95rem; margin: 0 0 16px; }
.hint { color: var(--ink-2); font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card.tight { padding: 14px 16px; }

/* ---------- buttons: explicit colours everywhere ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 54px; padding: 14px 20px; border: none; border-radius: var(--radius-sm);
  background: var(--teal); color: #fff; font-family: var(--font); font-size: 1.02rem; font-weight: 700;
  cursor: pointer; transition: transform .12s ease, background .15s ease;
}
.btn:hover { background: var(--teal-dark); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--teal); border: 1.5px solid var(--teal); }
.btn.secondary:hover { background: var(--teal-soft); }
.btn.ghost { background: transparent; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.small { min-height: 44px; padding: 9px 16px; font-size: .92rem; width: auto; }
.btn.quiet { background: var(--surface-2); color: var(--ink); }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.linkbtn { background: none; border: none; color: var(--teal); font-family: var(--font); font-size: .95rem; font-weight: 650; cursor: pointer; padding: 10px; min-height: 44px; }
button:focus-visible, .opt:focus-visible, a:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 8px; }
@media (prefers-color-scheme: dark) { .btn { color: #0E1A1E; } .btn.secondary { color: var(--teal); background: var(--surface); } .btn.ghost { color: var(--ink-2); background: transparent; } .btn.quiet { color: var(--ink); } }

/* ---------- option buttons (onboarding etc.) — matte, always readable ---------- */
.opt {
  display: block; width: 100%; text-align: left; background: var(--surface); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 15px 16px;
  margin-bottom: 10px; cursor: pointer; font-family: var(--font); font-size: .98rem; min-height: 54px;
  transition: border-color .15s ease, background .15s ease;
}
.opt b { font-weight: 750; }
.opt .desc { display: block; color: var(--ink-2); font-size: .85rem; margin-top: 2px; }
.opt:hover { border-color: var(--teal); }
.opt[aria-pressed="true"] { border-color: var(--teal); background: var(--teal-soft); }

/* ---------- bottom navigation ---------- */
nav.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; display: flex; background: var(--surface);
  border-top: 1px solid var(--line); padding: 6px 8px calc(8px + var(--sat-b)); z-index: 40;
}
nav.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; padding: 8px 4px; border-radius: 12px; cursor: pointer;
  color: var(--ink-3); font-family: var(--font); font-size: .72rem; font-weight: 650; min-height: 52px;
}
nav.tabs button svg { width: 23px; height: 23px; }
nav.tabs button[aria-current="page"] { color: var(--teal); background: var(--teal-soft); }

/* ---------- progress ring + bars ---------- */
.ringwrap { position: relative; width: 74px; height: 74px; flex: none; }
.ringwrap svg { transform: rotate(-90deg); }
.ringwrap .mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem; }
.ringwrap .mid small { font-size: .62rem; color: var(--ink-2); font-weight: 600; }
.meter { height: 8px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--teal); border-radius: 5px; transition: width .5s ease; }

/* ---------- course path ---------- */
.path { position: relative; margin: 6px 0 0; padding-left: 34px; }
.path::before { content: ''; position: absolute; left: 13px; top: 12px; bottom: 12px; width: 3px; background: var(--line); border-radius: 2px; }
.stage { position: relative; margin-bottom: 12px; }
.stage .dot {
  position: absolute; left: -34px; top: 16px; width: 29px; height: 29px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 800;
  background: var(--surface); border: 2.5px solid var(--line); color: var(--ink-3); z-index: 1;
}
.stage.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.stage.current .dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.stage .card { margin-bottom: 0; }
.stage.locked .card { opacity: .62; }
.stage .status { font-size: .78rem; font-weight: 700; }
.stage.done .status { color: var(--green); }
.stage.current .status { color: var(--teal); }
.stage.locked .status { color: var(--ink-3); }
.stage .mile { display: inline-block; margin-top: 8px; background: var(--amber-soft); color: var(--amber); font-size: .78rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.week-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.week-row .sesdots { display: flex; gap: 5px; }
.sesdot { width: 11px; height: 11px; border-radius: 50%; background: var(--surface-2); border: 1.5px solid var(--line); }
.sesdot.done { background: var(--green); border-color: var(--green); }

/* ---------- session player ---------- */
#player {
  position: fixed; inset: 0; z-index: 60; background: var(--bg); display: none;
  flex-direction: column; max-width: 560px; margin: 0 auto;
}
#player.open { display: flex; }
#player .phead { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
#player .phead .ptitle { font-weight: 750; font-size: .95rem; }
#player .pprog { display: flex; gap: 4px; padding: 0 20px 10px; }
#player .pprog i { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-2); }
#player .pprog i.done { background: var(--teal); }
#player .pbody { flex: 1; overflow-y: auto; padding: 8px 20px calc(20px + var(--sat-b)); display: flex; flex-direction: column; }
.stepcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow); text-align: center; }
.stepcard .kicker { font-size: .8rem; font-weight: 750; color: var(--teal); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.stepcard .bignum { font-size: 3.2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.stepcard .unit { color: var(--ink-2); font-weight: 650; }
.demo-figure { margin: 14px auto 6px; width: 190px; max-width: 70%; }
.demo-figure svg { width: 100%; height: auto; display: block; }
.timer { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.pctl { margin-top: auto; padding-top: 14px; }
.caption { min-height: 24px; text-align: center; color: var(--ink-2); font-size: .9rem; padding: 6px 10px; }

/* ---------- lists / rows ---------- */
.setrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  background: none; border: none; border-bottom: 1px solid var(--line); padding: 15px 4px;
  cursor: pointer; text-align: left; font-family: var(--font); font-size: .97rem; color: var(--ink); min-height: 54px;
}
.setrow:hover { background: var(--surface-2); }
.setrow .v { color: var(--ink-2); font-size: .88rem; flex: none; }
.switch { position: relative; width: 50px; height: 30px; flex: none; border-radius: 999px; background: var(--surface-2); border: 1.5px solid var(--line); transition: background .15s ease; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .15s ease; }
.setrow[aria-pressed="true"] .switch { background: var(--teal); border-color: var(--teal); }
.setrow[aria-pressed="true"] .switch::after { left: 24px; }

/* ---------- notices ---------- */
.notice { border-radius: var(--radius-sm); padding: 13px 15px; font-size: .9rem; margin: 12px 0; }
.notice.info { background: var(--teal-soft); color: var(--ink); }
.notice.warn { background: var(--amber-soft); color: var(--ink); }
.notice.err { background: var(--red-soft); color: var(--ink); }
.notice b { display: block; margin-bottom: 2px; }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 70; background: rgba(20,26,30,.45); display: none; align-items: flex-end; justify-content: center; }
#modal.open { display: flex; }
.modal-card {
  background: var(--surface); border-radius: 22px 22px 0 0; width: 100%; max-width: 560px;
  max-height: 88vh; overflow-y: auto; padding: 22px 20px calc(24px + var(--sat-b));
  animation: sheetup .25s ease;
}
@keyframes sheetup { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) {
  #modal { align-items: center; padding: 20px; }
  .modal-card { border-radius: 22px; }
}

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: calc(92px + var(--sat-b)); left: 50%; transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: 999px;
  font-size: .9rem; font-weight: 650; opacity: 0; transition: all .25s ease; z-index: 80;
  pointer-events: none; max-width: 88vw; text-align: center; box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- graduation / milestone ---------- */
.cert {
  border: 2.5px solid var(--teal); border-radius: var(--radius); padding: 26px 20px; text-align: center;
  background: var(--surface); box-shadow: var(--shadow-lg); margin: 14px 0;
}
.cert .laurel { font-size: 2rem; color: var(--teal); }
.cert h1 { margin: 8px 0 4px; }
.cert .line { width: 60px; height: 3px; background: var(--teal); border-radius: 2px; margin: 14px auto; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat b { display: block; font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { color: var(--ink-2); font-size: .78rem; }

/* ---------- coming soon course cards ---------- */
.course-card { position: relative; }
.course-card .tag { position: absolute; top: 16px; right: 16px; font-size: .72rem; font-weight: 750; padding: 4px 10px; border-radius: 999px; }
.tag.now { background: var(--green-soft); color: var(--green); }
.tag.soon { background: var(--surface-2); color: var(--ink-2); }

/* ---------- onboarding ---------- */
.ob-progress { height: 5px; background: var(--surface-2); border-radius: 3px; margin: 14px 0 24px; overflow: hidden; }
.ob-progress i { display: block; height: 100%; background: var(--teal); border-radius: 3px; transition: width .35s ease; }
.daygrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; margin: 6px 0 4px; }
.daygrid button {
  min-height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--ink); font-family: var(--font); font-weight: 700; font-size: .85rem; cursor: pointer;
}
.daygrid button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }

/* ---------- desktop ---------- */
@media (min-width: 600px) {
  body { background: var(--surface-2); }
  #app { background: var(--bg); min-height: 100vh; box-shadow: 0 0 50px rgba(0,0,0,.08); }
}
input[type="text"], select {
  width: 100%; min-height: 50px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-family: var(--font); font-size: 1rem;
}
label { display: block; font-weight: 650; font-size: .9rem; margin: 14px 0 6px; }
