:root {
  --bg: #eef2ef; --surface: #ffffff; --ink: #0f2a26; --muted: #55706a; --line: #cbd8d2;
  --green: #0d6b57; --green-soft: #d8ebe4; --amber: #d98b00; --danger: #b3261e; --focus: #1d4ed8;
  --radius: 10px;
  font-family: "Avenir Next", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b1a18; --surface: #122623; --ink: #e6f1ed; --muted: #93aca5; --line: #2a423d; --green: #3bb08f; --green-soft: #17382f; --amber: #f0b429; --danger: #ff8a80; --focus: #8ab4ff; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; font-size: 16px; padding-bottom: env(safe-area-inset-bottom); }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .75rem; max-width: 62ch; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 64px; }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0 14px; }
.brand { font-weight: 850; font-size: 1.15rem; letter-spacing: -0.02em; }
.link { background: none; border: 0; padding: 8px 4px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }

.btn { border: 2px solid var(--ink); background: var(--ink); color: var(--bg); border-radius: var(--radius); padding: 12px 18px; font-weight: 700; min-height: 48px; }
.btn.alt { background: transparent; color: var(--ink); }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn[disabled] { opacity: .55; cursor: wait; }
.btn.block { width: 100%; }

/* auth */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth h1 { margin-bottom: 8px; }
.field { display: block; margin: 14px 0; }
.field span { display: block; font-weight: 650; margin-bottom: 6px; }
.field input { width: 100%; padding: 12px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); min-height: 48px; }
.error { color: var(--danger); font-weight: 600; min-height: 1.4em; margin: 6px 0; }

/* year strip */
.year-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 10px; flex-wrap: wrap; }
.count { font-size: 2.6rem; font-weight: 850; line-height: 1; letter-spacing: -0.03em; }
.count small { font-size: 1rem; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.phase { margin: 22px 0 0; }
.phase-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.phase-title .muted { font-size: .85rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.tile { position: relative; min-height: 46px; border-radius: 8px; border: 2px solid var(--line); background: transparent; font-weight: 750; color: var(--muted); padding: 0; }
.tile.open { background: var(--green); border-color: var(--green); color: #fff; }
.tile.locked::after { content: ""; position: absolute; right: 5px; bottom: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.tile.next { border-color: var(--amber); color: var(--ink); }
.tile.deload::before { content: ""; position: absolute; top: 0; left: 0; border-top: 11px solid var(--amber); border-right: 11px solid transparent; border-top-left-radius: 6px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 18px; font-size: .85rem; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; border: 2px solid var(--line); }
.legend i.o { background: var(--green); border-color: var(--green); }
.legend i.n { border-color: var(--amber); }
.legend i.d { border: 0; background: linear-gradient(135deg, var(--amber) 50%, var(--line) 50%); }

.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 0; }

/* week */
.crumb { margin-bottom: 8px; }
.week-head h1 { margin: 6px 0 6px; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.tag { border: 2px solid var(--line); border-radius: 999px; padding: 2px 12px; font-size: .85rem; font-weight: 650; }
.tag.amber { border-color: var(--amber); }
.tabs { display: flex; border-bottom: 2px solid var(--line); margin: 14px 0 16px; gap: 4px; position: sticky; top: 0; background: var(--bg); z-index: 2; }
.tab { flex: 1; background: none; border: 0; padding: 12px 6px; font-weight: 700; color: var(--muted); border-bottom: 4px solid transparent; margin-bottom: -2px; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--green); }

details.day { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); margin: 0 0 10px; }
details.day > summary { list-style: none; padding: 14px; display: flex; gap: 10px; align-items: center; min-height: 56px; cursor: pointer; }
details.day > summary::-webkit-details-marker { display: none; }
.day-n { font-weight: 850; min-width: 2.4rem; color: var(--green); }
.day-name { font-weight: 700; flex: 1; }
.day-min { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.day.done { border-color: var(--green); }
.day-body { padding: 0 14px 14px; }
.sub { font-weight: 700; margin: 14px 0 6px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 4px 0; }
.ex { border-top: 1px solid var(--line); padding: 10px 0; }
.ex:first-child { border-top: 0; }
.ex-top { display: flex; justify-content: space-between; gap: 10px; }
.ex-name { font-weight: 700; }
.ex-rx { font-weight: 750; color: var(--green); white-space: nowrap; }
.ex-cue { color: var(--muted); font-size: .9rem; margin: 2px 0 0; }
.check { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-weight: 650; min-height: 44px; }
.check input { width: 22px; height: 22px; }

.seg { display: flex; flex-wrap: wrap; max-width: 100%; border: 2px solid var(--line); border-radius: 20px; overflow: hidden; margin: 0 8px 12px 0; }
.seg button { flex: 1 1 auto; border: 0; background: none; padding: 8px 16px; font-weight: 650; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.daytabs { display: flex; gap: 8px; margin: 0 0 12px; }
.daytabs button { flex: 1; border: 2px solid var(--line); background: transparent; border-radius: var(--radius); padding: 10px 6px; font-weight: 700; color: var(--muted); }
.daytabs button[aria-selected="true"] { border-color: var(--green); color: var(--ink); background: var(--green-soft); }
.totals { margin: 0 0 12px; font-weight: 650; }
details.meal { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); margin: 0 0 8px; }
details.meal > summary { list-style: none; padding: 12px 14px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; min-height: 52px; }
details.meal > summary::-webkit-details-marker { display: none; }
.slot { color: var(--muted); font-size: .85rem; }
.mname { font-weight: 700; }
.kcal { white-space: nowrap; color: var(--muted); font-size: .9rem; }
.meal-body { padding: 0 14px 14px; }
.meal-body ol, .meal-body ul { margin: 4px 0 10px; padding-left: 20px; }
.note { background: var(--green-soft); border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; font-size: .92rem; }
.tip { background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 10px; }
.tip h3 { margin-bottom: 4px; }
.disclaimer { font-size: .8rem; color: var(--muted); margin-top: 28px; }

/* sheet */
dialog { border: 0; border-radius: 16px; padding: 0; max-width: 460px; width: calc(100% - 24px); background: var(--bg); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(5, 20, 17, .55); }
.sheet { padding: 18px; }
.sheet-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 12px; }
.offer { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 10px; min-height: 64px; }
.offer:hover { border-color: var(--green); }
.offer b { display: block; }
.offer .price { font-weight: 850; font-size: 1.2rem; white-space: nowrap; }
.save { display: inline-block; margin-left: 6px; font-size: .8rem; font-weight: 700; color: var(--green); }

#toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 650; opacity: 0; pointer-events: none; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transition: opacity .2s; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.price .was { font-weight: 500; font-size: .85rem; color: var(--muted); margin-right: 6px; }

/* ---- illustrations */
.fig { width: 100%; height: auto; display: block; }
.fig-ground { stroke: var(--line); stroke-width: 2; stroke-linecap: round; }
.fig .limb { fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.fig .fig-far .limb { stroke: var(--green); opacity: .55; }
.fig .head { fill: var(--green); }
.ex { display: flex; gap: 12px; align-items: center; }
.ex-fig { flex: 0 0 96px; background: var(--green-soft); border-radius: 8px; padding: 2px 4px; }
.ex-main { flex: 1; min-width: 0; }
.day-banner { display: flex; align-items: center; gap: 14px; border-radius: var(--radius); padding: 10px 14px; margin: 0 0 12px; background: var(--green-soft); }
.day-banner .fig { flex: 0 0 150px; width: 150px; }
.day-banner p { margin: 0; font-weight: 650; }
.day-banner small { display: block; color: var(--muted); font-weight: 500; }
.day-banner.cardio { background: color-mix(in srgb, var(--amber) 22%, var(--surface)); }
.day-banner.recovery, .day-banner.rest { background: color-mix(in srgb, var(--focus) 14%, var(--surface)); }
.ex-video { display: inline-block; margin-top: 4px; font-size: .85rem; font-weight: 650; color: var(--green); }
.plate { width: 100%; height: auto; display: block; }
.plate .p-rim { fill: #d9d4c8; }
.plate .p-in { fill: #fbfaf6; }
.plate .p-in.bowl { fill: #e8efe4; }
.plate .o { stroke: #3b2c22; stroke-width: 1.3; stroke-linejoin: round; }
.meal-thumb { flex: 0 0 64px; width: 64px; }
.meal-hero { width: 190px; margin: 4px auto 8px; }
details.meal > summary { display: flex; align-items: center; gap: 10px; }
details.meal > summary > span:nth-child(2) { flex: 1; min-width: 0; }
@media (prefers-reduced-motion: reduce) { .fig * { transition: none; } }

/* ---- gentle motion for meal pictures */
.plate .item { transform-box: fill-box; transform-origin: center; animation: plate-pop .55s cubic-bezier(.3, 1.5, .5, 1) backwards, plate-bob 3.4s ease-in-out infinite; animation-delay: var(--d, 0s), calc(var(--d, 0s) + .6s); }
.plate .egg circle:nth-of-type(1) { transform-box: fill-box; transform-origin: center; animation: plate-wobble 2.4s ease-in-out infinite; }
.plate .steam path { opacity: 0; animation: plate-steam 2.6s ease-in-out infinite; animation-delay: var(--d, 0s); }
@keyframes plate-pop { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes plate-bob { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-1.6px) rotate(1.5deg); } }
@keyframes plate-wobble { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1, .94); } }
@keyframes plate-steam { 0% { opacity: 0; transform: translateY(5px); } 35% { opacity: .75; } 100% { opacity: 0; transform: translateY(-7px); } }
@media (prefers-reduced-motion: reduce) { .plate .item, .plate .egg circle, .plate .steam path { animation: none; } .plate .steam { display: none; } }
.q { border-bottom: 2px solid var(--line); }
.q summary { cursor: pointer; padding: 14px 0; font-weight: 700; min-height: 48px; }
.q p { padding-bottom: 8px; margin: 0; }

/* ---- timers */
.stopwatch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; margin: 0 0 12px; border: 2px solid var(--line); border-radius: var(--radius); }
.sw-label { font-weight: 650; }
.sw-time { font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 800; min-width: 4.2ch; }
.sw-target { color: var(--muted); font-size: .9rem; }
.ex-timer { margin-top: 6px; padding: 8px 14px; min-height: 40px; border: 2px solid var(--green); border-radius: 999px; background: none; color: var(--green); font: inherit; font-weight: 650; cursor: pointer; }
.timer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: var(--surface); color: var(--ink); border-top: 4px solid var(--green); border-radius: 16px 16px 0 0; padding: 14px max(16px, env(safe-area-inset-left, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); text-align: center; }
.timer.rest { border-top-color: var(--amber); }
.timer.manual { border-top-color: var(--focus); }
.tm-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; text-align: left; }
.tm-label { margin: 6px 0 0; font-size: 1.25rem; font-weight: 800; }
.tm-sub { margin: 0; color: var(--muted); min-height: 1.3em; }
.tm-time { font-size: 3.4rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tm-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 6px auto 8px; max-width: 420px; }
.tm-fill { height: 100%; width: 0; background: var(--green); }
.timer.rest .tm-fill { background: var(--amber); }
.tm-step { margin: 0 0 8px; font-size: .85rem; color: var(--muted); }
.tm-btns { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.btn.small { padding: 8px 16px; min-height: 40px; font-size: .95rem; }
.btn.ghost { background: none; color: var(--ink); border: 2px solid var(--line); }

.fig .prop { fill: var(--green-soft); stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }

.shop-aisle { margin: 0 0 16px; }
.shop-aisle h3 { margin: 0 0 6px; font-size: 1rem; }
.shop-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.shop-list li { border-bottom: 1px solid var(--line); }
.shop-list li:last-child { border-bottom: 0; }
.shop-list label { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 6px 12px; }
.shop-list input { width: 22px; height: 22px; flex: none; }
.shop-n { flex: 1; min-width: 0; }
.shop-q { font-weight: 700; white-space: nowrap; }
.shop-list li.got .shop-n, .shop-list li.got .shop-q { text-decoration: line-through; color: var(--muted); }
.shop-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }

.book { display: flex; gap: 14px; align-items: stretch; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin: 0 0 12px; background: var(--surface); }
.book.open { border-color: var(--green); }
.book-art { flex: none; width: 92px; border-radius: 12px; display: flex; align-items: flex-end; justify-content: center; padding: 8px 4px; text-align: center; font-weight: 700; font-size: .75rem; line-height: 1.15; color: #3d3349; }
.book-first { background: #fde8d7; } .book-tiny { background: #e5f1dc; } .book-little { background: #fbe6ef; }
.book-body { flex: 1; min-width: 0; }
.book-body h3 { margin: 0 0 4px; font-size: 1.05rem; }
.book .cta-row { margin: 10px 0 0; }
