:root {
  --bg: #f3f6fa; --card: #ffffff; --ink: #1d2533; --muted: #5b6678; --line: #e3e9f1;
  --navy: #14305a; --blue: #2f6fb3; --sky: #eaf2fb; --green: #2e8b57; --greenbg: #e8f5ee;
  --amber: #b7791f; --amberbg: #fdf3e1; --red: #c0392b; --redbg: #fbe9e7;
  --mon: #2f6fb3; --wed: #2e8b57; --fri: #7b4fb8; --sat: #d9822b;
  --tabh: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1724; --card: #1a2433; --ink: #e8edf5; --muted: #9aa6b8; --line: #2a3546;
    --sky: #1d2c44; --greenbg: #16302a; --amberbg: #3a2e17; --redbg: #3b1f1c; --navy: #1e3f70;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  padding-bottom: calc(var(--tabh) + var(--safe-b));
}
main { padding: calc(12px + var(--safe-t)) 16px 24px; max-width: 560px; margin: 0 auto; }
h1 { font-size: 26px; margin: 4px 0 2px; letter-spacing: -.3px; }
h2 { font-size: 19px; margin: 22px 0 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.card { background: var(--card); border-radius: 18px; padding: 16px; margin: 12px 0; box-shadow: 0 1px 2px rgba(20,48,90,.06); }
.hero { background: var(--navy); color: #fff; display: flex; gap: 14px; align-items: center; }
.hero .muted { color: #c6d6ee; }
.ring { width: 64px; height: 64px; flex: none; }
.ring circle { fill: none; stroke-width: 7; }
.ring .bg { stroke: rgba(255,255,255,.18); }
.ring .fg { stroke: #fff; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; }
.ring text { fill: #fff; font-size: 15px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }

.daystrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.daystrip div { text-align: center; border-radius: 10px; padding: 6px 0; font-size: 12px; background: var(--card); color: var(--muted); border: 2px solid transparent; }
.daystrip div b { display: block; font-size: 13px; color: var(--ink); }
.daystrip .train { color: #fff; } .daystrip .train b { color: #fff; }
.daystrip .today { border-color: var(--ink); }

.session-head { border-radius: 18px 18px 0 0; color: #fff; padding: 14px 16px; margin-top: 12px; }
.session-head h2 { margin: 0; color: #fff; }
.session-head p { margin: 2px 0 0; opacity: .9; font-size: 14px; }
.session-body { background: var(--card); border-radius: 0 0 18px 18px; padding: 4px 12px 8px; }
.item { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); min-height: 64px; }
.item:last-child { border-bottom: 0; }
.item .pic-wrap { width: 72px; height: 60px; flex: none; background: #fff; border-radius: 10px; }
.item .pic { width: 72px; height: 60px; display: block; }
.item .txt { flex: 1; min-width: 0; }
.item .name { font-weight: 600; }
.item .dose { font-weight: 700; color: var(--blue); }
.item .note { font-size: 13px; color: var(--muted); }
.tag { display: inline-block; font-size: 12px; border: 1px solid var(--blue); color: var(--blue); border-radius: 8px; padding: 0 6px; margin-left: 4px; }
.notice { background: var(--amberbg); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 8px 0; }

label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=date], input[type=number] {
  width: 100%; font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink); min-height: 48px;
}
.btn { display: block; width: 100%; min-height: 52px; border: 0; border-radius: 14px; font: inherit; font-weight: 700; font-size: 17px; background: var(--blue); color: #fff; margin-top: 18px; }
.btn:active { transform: scale(.99); opacity: .9; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 10; }
.tabs[hidden] { display: none; }
.tabs button { border: 0; background: none; color: var(--muted); font: inherit; font-size: 12px; min-height: var(--tabh);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.tabs svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--blue); font-weight: 700; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }

/* ---------- buttons & small bits */
.btn.big { min-height: 58px; font-size: 18px; margin-top: 12px; }
.btn.ghost { background: var(--sky); color: var(--blue); }
.linkbtn { border: 0; background: none; color: var(--blue); font: inherit; font-weight: 600; padding: 12px 4px; min-height: 44px; }
.done-banner { background: var(--greenbg); color: var(--green); font-weight: 700; border-radius: 14px; padding: 6px 14px; margin-top: 12px; display: flex; align-items: center; justify-content: space-between; }
.q { font-weight: 600; margin: 14px 0 6px; }
label.mini { font-size: 14px; font-weight: 600; margin: 10px 0; }
label.mini .in { margin-top: 4px; }

/* ---------- workout screen */
.wk-top { color: #fff; margin: calc(-12px - var(--safe-t)) -16px 12px; padding: calc(10px + var(--safe-t)) 16px 14px; }
.wk-top h1 { color: #fff; margin: 2px 0; }
.wk-top p { margin: 0; opacity: .9; }
.back { border: 0; background: rgba(255,255,255,.18); color: #fff; font: inherit; font-weight: 600; border-radius: 10px; padding: 8px 12px; min-height: 44px; }
.ex { background: var(--card); border-radius: 16px; margin: 10px 0; overflow: hidden; border: 2px solid transparent; }
.ex.open { border-color: var(--line); }
.ex.done .ex-head { opacity: .75; }
.ex-head { width: 100%; display: flex; gap: 12px; align-items: center; padding: 8px 12px; border: 0; background: none; color: inherit; font: inherit; text-align: left; min-height: 72px; }
.ex-head .pic-wrap { width: 72px; height: 60px; flex: none; background: #fff; border-radius: 10px; }
.ex-head .pic { width: 72px; height: 60px; display: block; }
.ex-head .txt { flex: 1; display: flex; flex-direction: column; }
.ex-head .name { font-weight: 600; }
.ex-head .dose { font-weight: 700; color: var(--blue); }
.badge { font-size: 13px; font-weight: 700; border-radius: 8px; padding: 3px 8px; white-space: nowrap; }
.badge.ok { background: var(--greenbg); color: var(--green); }
.badge.skip { background: var(--line); color: var(--muted); }
.ex-body { padding: 0 12px 12px; }
.cue { font-weight: 600; margin: 4px 0; }
.note { color: var(--amber); font-weight: 600; font-size: 14px; margin: 4px 0; }
.last { font-size: 14px; background: var(--sky); border-radius: 10px; padding: 6px 10px; margin: 8px 0; }
.hint { font-size: 14px; background: var(--greenbg); border-radius: 10px; padding: 6px 10px; }
details.how { margin: 6px 0; }
details.how summary { color: var(--blue); font-weight: 600; min-height: 36px; display: flex; align-items: center; }
details.how ol { padding-left: 20px; margin: 6px 0; }
.tip { font-size: 14px; background: var(--greenbg); border-radius: 8px; padding: 4px 8px; margin: 4px 0; }
.setrow { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.setrow > span { width: 52px; font-weight: 600; font-size: 14px; flex: none; }
.setrow.done .in { background: var(--greenbg); }
.in { font: inherit; font-size: 18px; padding: 10px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); min-height: 48px; width: 100%; min-width: 0; }
.setrow .in { flex: 1; text-align: center; }
.in.wide { width: 100%; margin: 8px 0; text-align: left; }
.tickbtn, .sw { flex: none; width: 52px; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font-size: 22px; }
.tickbtn[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.sw { font-size: 16px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-width: 44px; min-height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; }
.chip.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.row2 { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }
.row2 .btn { margin-top: 8px; }
.btn.finish { background: var(--green); margin-top: 16px; }
.linkbtn[data-act="discard"] { display: block; margin: 8px auto 70px; color: var(--muted); }
.light { border-radius: 12px; padding: 8px 12px; margin: 10px 0; font-size: 15px; }
.light.g { background: var(--greenbg); } .light.a { background: var(--amberbg); } .light.r { background: var(--redbg); }
.restbar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); background: var(--navy); color: #fff; border-radius: 16px;
  display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; z-index: 20; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.restbar span { flex: 1; font-size: 17px; } .restbar b { font-size: 22px; font-variant-numeric: tabular-nums; }
.restbar button { min-width: 52px; min-height: 44px; border: 0; border-radius: 10px; background: rgba(255,255,255,.18); color: #fff; font: inherit; font-weight: 700; }

/* ---------- feedback */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabh) + 16px + var(--safe-b)); background: #1d2533; color: #fff;
  padding: 10px 16px; border-radius: 12px; z-index: 50; font-weight: 600; max-width: 90vw; pointer-events: none; }
.toast.bad { background: var(--red); }
.celebrate { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: rgba(15,23,36,.55); color: #fff; z-index: 60; padding: 24px; animation: fade .25s ease; }
.celebrate b { font-size: 24px; } .celebrate p { max-width: 280px; }
.tick { width: 88px; height: 88px; border-radius: 50%; background: var(--green); display: flex; align-items: center; justify-content: center;
  font-size: 48px; margin-bottom: 12px; animation: pop .4s ease; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .celebrate, .tick { animation: none; } }

/* ---------- infographic viewer */
.viewer { position: fixed; inset: 0; background: #0f1724; z-index: 40; display: flex; flex-direction: column; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; color: #fff; padding: calc(8px + var(--safe-t)) 12px 8px; }
.viewer-bar button { min-height: 44px; min-width: 64px; margin-left: 6px; border: 0; border-radius: 10px; background: rgba(255,255,255,.18); color: #fff; font: inherit; font-weight: 600; }
.viewer-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--safe-b); }
.viewer-body img { width: 100%; display: block; }
.viewer.zoomed .viewer-body img { width: 280%; max-width: none; }

/* ---------- run timer */
.seglist { padding-left: 22px; margin: 8px 0; }
.seglist li { padding: 2px 0; }
.seglist li.run { font-weight: 700; color: var(--sat); }
.runface { border-radius: 22px; text-align: center; padding: 22px 12px; margin: 12px 0; color: #fff; background: var(--navy); }
.runface.run { background: var(--sat); }
.runface.walk { background: var(--blue); }
.runface.done { background: var(--green); }
.segname { font-size: 34px; font-weight: 800; letter-spacing: 2px; }
.seglabel { font-size: 17px; opacity: .92; }
.bigtime { font-size: 84px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; margin: 8px 0; }
.segnext { font-size: 16px; opacity: .92; min-height: 22px; }
.runprog { height: 8px; background: rgba(255,255,255,.25); border-radius: 4px; margin-top: 14px; overflow: hidden; }
.runprog div { height: 100%; background: #fff; }
.card.morning { border: 2px solid var(--blue); }

/* ---------- settings */
.topline { display: flex; justify-content: space-between; align-items: center; }
.gear { border: 0; background: var(--card); border-radius: 12px; width: 44px; height: 44px; font-size: 20px; }
.filebtn { display: flex; align-items: center; justify-content: center; text-align: center; margin-top: 12px; cursor: pointer; }
.card.backup { border: 2px solid var(--amber); }

/* ---------- progress */
.goals { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.goal { background: var(--card); border-radius: 14px; padding: 10px 12px; font-size: 14px; border: 2px solid transparent; }
.goal.wide { grid-column: 1 / -1; }
.goal.achieved { border-color: var(--green); }
.g-title { font-weight: 700; margin-bottom: 4px; }
.g-row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.g-row span { color: var(--muted); }
.goal.wide .g-row { justify-content: flex-start; }
table.att { border-collapse: separate; border-spacing: 3px; width: 100%; font-size: 14px; text-align: center; }
table.att th { font-weight: 600; color: var(--muted); font-size: 12px; }
table.att td { height: 30px; border-radius: 8px; background: var(--line); font-weight: 700; }
table.att td.done { background: var(--greenbg); color: var(--green); }
table.att td.missed { background: var(--card); color: var(--muted); border: 1px dashed var(--line); }
table.att td.today { background: var(--sky); color: var(--blue); }
table.att tr.lighter th { color: var(--amber); }
.win { background: var(--greenbg); border-radius: 12px; padding: 10px 12px; font-weight: 700; }
figure.chart { margin: 8px 0 14px; }
figure.chart figcaption { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
figure.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .val { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .line { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; }
.chart .plan { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 5; }
.chart .dot { fill: var(--blue); stroke: var(--card); stroke-width: 2; }
.chart .goalline { stroke: var(--green); stroke-width: 1.5; stroke-dasharray: 2 4; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.legend i { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--blue); vertical-align: middle; margin-right: 6px; }
.legend i.k-plan { border-top: 2px dashed var(--muted); }
details.tbl summary { font-size: 13px; color: var(--blue); min-height: 32px; display: flex; align-items: center; }
details.tbl table, table.quad { width: 100%; border-collapse: collapse; font-size: 14px; }
details.tbl td, details.tbl th, table.quad td, table.quad th { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.pill { display: inline-block; border-radius: 8px; padding: 1px 8px; font-size: 12px; font-weight: 700; }
.pill.g { background: var(--greenbg); color: var(--green); } .pill.a { background: var(--amberbg); color: var(--amber); } .pill.r { background: var(--redbg); color: var(--red); }

/* ---------- history */
.hdate { font-size: 15px; color: var(--muted); margin: 16px 0 6px; }
.hist { width: 100%; display: flex; align-items: center; gap: 12px; background: var(--card); border: 0; border-radius: 14px; padding: 12px; margin: 6px 0;
  font: inherit; color: inherit; text-align: left; min-height: 60px; }
.hicon { font-size: 24px; }
.htxt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chev { color: var(--muted); font-size: 22px; }

/* ---------- plan + guide */
.phase-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.phase-btns .btn { margin-top: 0; font-size: 14px; padding: 6px 4px; min-height: 56px; }
details.week { background: var(--card); border-radius: 16px; margin: 10px 0; padding: 0 10px 8px; }
details.week summary { min-height: 52px; display: flex; align-items: center; gap: 8px; }
details.week[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.small-head { border-radius: 12px 12px 0 0; padding: 8px 12px; margin-top: 10px; }
details.week .session-body { border: 1px solid var(--line); border-top: 0; }
.linkrow { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; }
.linkrow .pic-wrap { width: 72px; height: 60px; flex: none; background: #fff; border-radius: 10px; }
.linkrow .pic { width: 72px; height: 60px; display: block; }
.linkrow .txt { display: flex; flex-direction: column; }
.sheet { position: fixed; inset: 0; background: rgba(15,23,36,.5); z-index: 45; display: flex; align-items: flex-end; }
.sheet-card { background: var(--card); width: 100%; max-height: 88vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 14px 16px calc(20px + var(--safe-b)); }
.sheet-top { display: flex; justify-content: space-between; align-items: center; }
.sheet-top h2 { margin: 0; }
.back.dark { background: var(--sky); color: var(--blue); }
.guide-pic { background: #fff; border-radius: 14px; margin: 10px 0 4px; }
.guide-pic .pic { width: 100%; height: 200px; display: block; }

/* ---------- today: swaps, start card */
.picks { display: grid; gap: 6px; margin-top: 8px; }
.pick { display: flex; gap: 10px; align-items: center; min-height: 48px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card);
  color: var(--ink); font: inherit; text-align: left; padding: 8px 12px; }
.pick span { width: 22px; text-align: center; font-weight: 700; color: var(--blue); }
.pick.done { opacity: .6; } .pick.done span { color: var(--green); }
details.swap summary { font-weight: 600; color: var(--blue); min-height: 40px; display: flex; align-items: center; }
.start-card { border: 2px solid var(--blue); }

/* ---------- which session? */
.choice { background: var(--card); border-radius: 16px; margin: 12px 0; overflow: hidden; }
.choice-head { color: #fff; padding: 10px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.choice-head b { font-size: 17px; flex: 1 1 100%; }
.choice-head span { font-size: 13px; opacity: .9; }
.choice-head .badge { margin-left: auto; opacity: 1; }
.badge.sug { background: #fff; color: var(--navy); }
.choice-body { padding: 4px 12px 12px; }
.choice-body .btn { margin-top: 10px; }
details.preview summary { color: var(--blue); font-weight: 600; min-height: 40px; display: flex; align-items: center; }

/* Coach tab */
.focus { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.focus:last-child { border-bottom: 0; }
.focus .badge { margin-left: 6px; }
.tick { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 10px; border: 2px solid var(--line); background: var(--card);
  color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 17px; }
.tick.on { background: var(--green); border-color: var(--green); }
button.tick { min-width: 44px; min-height: 44px; flex-basis: 44px; }
.coachnote { border-left: 4px solid var(--blue); }
.habit .light { margin: 8px 0 4px; }
.habit table { width: 100%; margin-top: 10px; border-collapse: collapse; }
.habit td { padding: 4px 0; border-bottom: 1px solid var(--line); }
.win + .win { margin-top: 8px; }

/* Activities outside the plan, calendar events and your own goals */
.act-ex b { display: block; margin-bottom: 4px; }
.act-ex .linkbtn { margin-right: 12px; }
.cal-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding: 4px 0; }
.cal-form { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
.card.cal-today { border: 2px solid var(--blue); }
.card.cal-today p { margin: 4px 0; }
.cal-week { background: var(--sky); }
.bar { height: 14px; border-radius: 7px; background: var(--line); overflow: hidden; margin: 10px 0 4px; }
.bar span { display: block; height: 100%; background: var(--green); border-radius: 7px; min-width: 4px; }
.step { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: none;
  color: var(--ink); font: inherit; padding: 10px 2px; min-height: 44px; }
.step > span:first-child { font-weight: 700; color: var(--muted); width: 18px; }
.step.on > span:first-child { color: var(--green); }
.card.owngoal.achieved { border: 2px solid var(--green); }

/* Sign-in: short wait while the password is turned into keys */
.si-working { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line, #dde3ec); border-top-color: var(--blue, #2f6fb5);
  animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* App lock: covers the whole app until the phone confirms it's you */
.applock { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom)); }
.applock-box { max-width: 360px; width: 100%; text-align: center; }
.applock-icon { font-size: 44px; margin-bottom: 8px; }
.applock h1 { margin: 0 0 8px; }
.applock .btn { margin-top: 16px; }
.lock-grace { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
