:root {
  --bg: #f6f5f1; --surface: #fff; --text: #1d1f1c; --muted: #6b6f69; --line: #e4e2dc; --soft: #efede7;
  --accent: #1f7a5a; --accent-soft: #dcefe6; --key: #d9652b; --key-soft: #fbe6da; --info: #3b6ea8;
  --z1: #9fb8c8; --z2: #5aa36f; --z3: #e0b43a; --z4: #e8743b; --z5: #c8412f;
  --pA: #b8322a; --pB: #d9652b; --pC: #3b6ea8; --pT: #7d837b;
  --c0: #8fb996; --c1: #6fa3c7; --c2: #e0b43a; --c3: #d9652b; --c4: #a58bc4; --c5: #9aa097;
  --radius: 16px; --shadow: 0 1px 2px rgb(0 0 0 / 5%), 0 2px 8px rgb(0 0 0 / 4%);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121412; --surface: #1c1f1c; --text: #ecebe6; --muted: #9aa097; --line: #2e332e; --soft: #252925;
    --accent: #4fbf8f; --accent-soft: #1f3a2e; --key: #f08a52; --key-soft: #3d2a1f; --info: #7aa6d8;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
h1 { font-size: 1.65rem; line-height: 1.2; margin: .15em 0 .2em; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6em; }
h3 { font-size: .95rem; margin: 1em 0 .4em; color: var(--muted); }
p { margin: .45em 0; }
a { color: var(--info); }
code { font-size: .88em; background: var(--soft); padding: 0 .3em; border-radius: 4px; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; }
.scroll { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.eyebrow { color: var(--muted); font-size: .85rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin: 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.context { color: var(--muted); margin: 0 0 12px; }
.sub { color: var(--muted); margin-top: 0; }
.lead { font-size: 1.05rem; }
footer { color: var(--muted); font-size: .8rem; text-align: center; margin-top: 32px; }

/* cards */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); border: 1px solid var(--line); }
.today-card { border-top: 4px solid var(--accent); padding-top: 14px; }
.today-card.rest { border-top-color: var(--c1); }
.today-card h1 { font-size: 1.8rem; }
.purpose { margin: 10px 0; }
.big { font-size: 1.15rem; margin: 0; }
.banner { background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; margin: 8px 0; font-size: .95rem; }
.done-line { background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; margin: 10px 0; font-weight: 500; }
.kept { color: var(--accent); font-weight: 600; }

/* buttons, chips, badges */
.btn { display: block; text-align: center; background: var(--accent); color: #fff; text-decoration: none; font-weight: 600; padding: 13px 16px; border-radius: 12px; margin: 14px 0 4px; }
@media (prefers-color-scheme: dark) { .btn { color: #0d1a14; } }
.btn.small { display: inline-block; padding: 9px 14px; margin: 8px 0 0; font-size: .95rem; }
.next { display: block; margin-top: 10px; padding: 10px 0 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .95rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { background: var(--soft); border-radius: 999px; padding: 4px 10px; font-size: .88rem; white-space: nowrap; }
.chip.hr { background: #e8f1ea; }
.chip.gym { background: #ece7f5; }
@media (prefers-color-scheme: dark) { .chip.hr { background: #203026; } .chip.gym { background: #2a2536; } }
.badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 999px; }
.badge.key { background: var(--key-soft); color: var(--key); }
.badge.support { background: var(--soft); color: var(--muted); }
.badge.optional { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.status { font-size: .8rem; font-weight: 600; white-space: nowrap; border-radius: 999px; padding: 2px 8px; }
.status.done { background: var(--accent-soft); color: var(--accent); }
.status.partial, .status.swapped { background: var(--accent-soft); color: var(--accent); }
.status.dropped { color: var(--muted); border: 1px dashed var(--line); }
.status.rest { color: var(--muted); }
.status.today { background: var(--key-soft); color: var(--key); }
.status.planned { color: var(--muted); }
.status.recorded { color: var(--accent); border: 1px solid var(--line); }
.status.unconfirmed { color: var(--muted); }
.star { color: var(--key); }

/* week strip */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 12px 0; }
.cell { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--text); min-height: 76px; }
.cell .wd { font-size: .72rem; color: var(--muted); text-transform: uppercase; }
.cell .dn { font-weight: 700; }
.cell .ic { font-size: .9rem; line-height: 1.2; }
.cell .code { font-size: .62rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.cell.done, .cell.partial, .cell.swapped { background: var(--accent-soft); border-color: transparent; }
.cell.done .ic, .cell.partial .ic, .cell.swapped .ic { color: var(--accent); }
.cell.dropped { opacity: .6; border-style: dashed; }
.cell.recorded .ic { color: var(--accent); }
.cell.rest { background: transparent; }
.cell.key { box-shadow: inset 0 -3px 0 var(--key); }
.cell.is-today { outline: 2px solid var(--key); outline-offset: 1px; }

/* progress */
.prow { display: grid; grid-template-columns: 56px 1fr; gap: 2px 10px; align-items: center; margin: 10px 0; }
.plabel { color: var(--muted); font-size: .85rem; }
.pval { font-weight: 600; font-size: .95rem; }
.prow .bar, .prow .dots { grid-column: 2; }
.bar { position: relative; height: 10px; background: var(--soft); border-radius: 999px; overflow: visible; }
.bar .band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 999px; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 999px; }
.bar .tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .55; }
.dots { display: flex; gap: 6px; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); }
.dot.on { background: var(--accent); }
.legend { font-size: .78rem; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; }
.lg { display: inline-block; width: 14px; height: 8px; border-radius: 4px; }
.lg.band { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.lg.fill { background: var(--accent); }
.lg.tick { width: 2px; height: 12px; background: var(--text); opacity: .55; }

/* streak + race */
.streak, .race { display: flex; gap: 14px; align-items: center; }
.streak-num { font-size: 2rem; }
.weeks { display: flex; gap: 4px; margin-top: 6px; }
.wk { width: 18px; height: 18px; border-radius: 5px; background: var(--soft); border: 1px solid var(--line); }
.wk.on { background: var(--accent); border-color: var(--accent); }
.wk.now { outline: 2px solid var(--key); outline-offset: 1px; }
.prio { display: inline-grid; place-items: center; min-width: 30px; height: 30px; border-radius: 8px; color: #fff; font-weight: 800; flex: none; }
.prio.sm { min-width: 20px; height: 20px; font-size: .72rem; border-radius: 5px; }
.pA { background: var(--pA); } .pB { background: var(--pB); } .pC { background: var(--pC); } .pT { background: var(--pT); }

/* folds (progressive disclosure) */
details.fold { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin: 8px 0; }
details.fold > summary { list-style: none; cursor: pointer; padding: 13px 40px 13px 14px; position: relative; font-weight: 600; display: flex; gap: 10px; align-items: center; min-height: 48px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: ""; position: absolute; right: 16px; top: 50%; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-70%) rotate(45deg); transition: transform .15s; }
details.fold[open] > summary::after { transform: translateY(-30%) rotate(-135deg); }
.fold-body { padding: 0 14px 12px; }
details.fold.inner { background: var(--soft); border: 0; }
details.fold.inner > summary { font-weight: 500; font-size: .92rem; min-height: 40px; padding-top: 9px; padding-bottom: 9px; }
.dmain, .exmain { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.dtitle { font-weight: 600; }
.dsub { font-weight: 400; color: var(--muted); font-size: .88rem; }

/* week days */
details.day { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin: 8px 0; }
details.day > summary { list-style: none; cursor: pointer; padding: 10px 12px; display: flex; gap: 12px; align-items: center; min-height: 56px; }
details.day > summary::-webkit-details-marker { display: none; }
details.day .dname { display: flex; flex-direction: column; align-items: center; width: 34px; font-size: .75rem; text-transform: uppercase; color: var(--muted); flex: none; }
details.day .dname small { font-size: 1.05rem; font-weight: 700; color: var(--text); }
details.day.done, details.day.partial, details.day.swapped { border-left: 4px solid var(--accent); }
details.day.dropped { opacity: .75; }
details.day.rest { background: transparent; }
details.day.is-today { border-color: var(--key); box-shadow: 0 0 0 1px var(--key); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: .95rem; }
.pager a { text-decoration: none; padding: 6px 0; }

/* workout */
.how ol, .how ul { padding-left: 1.3em; }
.how li { margin: 4px 0; }
.activity + .activity { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.aname { margin-top: 0; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.grid .k, .tiles .k { display: block; font-size: .75rem; color: var(--muted); }
.grid .v { font-weight: 700; font-size: 1.05rem; }
.zbar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; margin: 8px 0 2px; }
.zbar .z1 { background: var(--z1); } .zbar .z2 { background: var(--z2); } .zbar .z3 { background: var(--z3); } .zbar .z4 { background: var(--z4); } .zbar .z5 { background: var(--z5); }
.gym h2 { margin-top: 20px; }
.dose { font-size: 1.05rem; margin-bottom: 0; }
details.ex > summary { align-items: center; }
.exn { flex: none; display: inline-grid; place-items: center; min-width: 34px; height: 34px; border-radius: 10px; background: #ece7f5; font-weight: 700; font-size: .88rem; }
@media (prefers-color-scheme: dark) { .exn { background: #2a2536; } }
.yt { position: relative; display: block; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; background: #000; margin: 6px 0; }
.yt img { width: 100%; height: 100%; object-fit: cover; opacity: .85; display: block; }
.yt .play { position: absolute; inset: auto auto 12px 12px; background: rgb(0 0 0 / 72%); color: #fff; padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .9rem; }
.yt-frame { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 12px; margin: 6px 0; }

/* season */
.hero h1 { margin-bottom: 4px; }
.timeline { margin: 16px 0 8px; }
.track { position: relative; height: 34px; background: var(--soft); border-radius: 10px; }
.ph { position: absolute; top: 0; bottom: 0; opacity: .85; }
.ph:first-child { border-radius: 10px 0 0 10px; }
.ph:last-of-type { border-radius: 0 10px 10px 0; }
.c0 { background: var(--c0); } .c1 { background: var(--c1); } .c2 { background: var(--c2); } .c3 { background: var(--c3); } .c4 { background: var(--c4); } .c5 { background: var(--c5); }
.rm { position: absolute; top: -8px; transform: translateX(-50%); font-size: .65rem; font-weight: 800; color: #fff; min-width: 16px; height: 16px; border-radius: 4px; display: grid; place-items: center; }
.today-line { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); }
.today-line em { position: absolute; top: 100%; left: -2px; font-size: .7rem; font-style: normal; font-weight: 700; padding-top: 2px; }
.months { position: relative; height: 38px; font-size: .7rem; color: var(--muted); }
.months span { position: absolute; top: 22px; transform: translateX(-2px); }
.swatch { width: 12px; height: 32px; border-radius: 4px; flex: none; }
details.phase.current { border-color: var(--key); }
.weeks-list { margin: 10px 0; }
.wrow { display: grid; grid-template-columns: 38px 76px 1fr 44px 16px auto; gap: 6px; align-items: center; padding: 5px 0; font-size: .85rem; border-bottom: 1px solid var(--line); }
.wrow.current { font-weight: 700; }
.wrow .wt { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrow .wh { text-align: right; }
.wk-kept { color: var(--accent); text-align: center; }

/* stats */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.tiles .v { display: block; font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.heatmap { display: flex; flex-direction: column; gap: 4px; }
.hmrow { display: flex; gap: 3px; align-items: center; }
.hml { width: 46px; font-size: .7rem; color: var(--muted); flex: none; }
.hm { flex: 1; aspect-ratio: 1; max-width: 22px; border-radius: 4px; background: var(--soft); display: inline-block; }
.legend .hm { width: 12px; height: 12px; flex: none; }
.hm.l1 { background: color-mix(in srgb, var(--accent) 25%, var(--soft)); }
.hm.l2 { background: color-mix(in srgb, var(--accent) 55%, var(--soft)); }
.hm.l3 { background: color-mix(in srgb, var(--accent) 80%, var(--soft)); }
.hm.l4 { background: var(--accent); }
.hm.now { outline: 2px solid var(--key); outline-offset: 1px; }
.chart { width: 100%; height: auto; display: block; }
.chart .b { fill: var(--accent); opacity: .75; }
.chart .b.cur { fill: var(--key); opacity: 1; }
.chart .sband, .spark .sband { fill: color-mix(in srgb, var(--accent) 16%, transparent); }
.chart text { font-size: 9px; fill: var(--muted); text-anchor: middle; }
.spark { width: 100%; height: 48px; display: block; }
.spark path { fill: none; stroke: var(--info); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark circle { fill: var(--info); }
.marker + .marker { margin-top: 10px; }
.wins ul { list-style: none; padding: 0; margin: 0; }
.wins li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.wins li:last-child { border-bottom: 0; }
.wins li small { display: block; color: var(--muted); font-size: .78rem; }
.wi { width: 26px; text-align: center; flex: none; }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.tabs a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; }
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current] { color: var(--accent); }

/* small celebration */
.celebrate { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.96); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .celebrate { animation: none; } details.fold > summary::after { transition: none; } }
[hidden] { display: none !important; }
