/* Layout: one narrow column you work down on your phone; tabs switch Today / Routine / History. */
:root {
  --bg: #eef1f4; --surface: #ffffff; --ink: #17212b; --muted: #5b6874; --line: #d5dbe1;
  --band: #c94c18; --band-soft: #fbe4d9; --done: #2f6f5e; --done-soft: #d8ebe4; --warn: #9a5b00;
  --k-release: #6a5acd; --k-stretch: #2f7fb3; --k-mobility: #2f6f5e; --k-activation: #9a6a00; --k-strength: #c94c18;
  --f-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-data: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11171d; --surface: #1a222a; --ink: #e6ebef; --muted: #98a5b1; --line: #2c3742;
    --band: #f07a45; --band-soft: #3a2419; --done: #6cc3a6; --done-soft: #1d3830; --warn: #e5a54b;
    --k-release: #a99cf0; --k-stretch: #7cbde6; --k-mobility: #6cc3a6; --k-activation: #e0b04a; --k-strength: #f07a45;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.5; }
[hidden] { display: none !important; }
.wrap {
  max-width: 720px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(20px, env(safe-area-inset-top, 0px)); padding-bottom: max(48px, env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 22px;
}
#app, .view { display: flex; flex-direction: column; gap: 16px; }
#app { gap: 22px; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; line-height: 1.15; }
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
.eyebrow, .label { font-family: var(--f-data); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.label { display: block; margin-bottom: 6px; }
.muted, .lead { color: var(--muted); margin: 0; }
a { color: var(--band); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--band); outline-offset: 2px; }
.status { font-size: 0.85rem; color: var(--muted); min-height: 1.3em; margin: 0; }
.status.warn { color: var(--warn); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.who { font-size: 0.85rem; color: var(--muted); }
.link { background: none; border: 0; padding: 0; color: var(--band); text-decoration: underline; cursor: pointer; }
.signin { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }

/* Header with a menu button; the menu drops down under it. */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); padding-block: 8px; align-items: center; flex-wrap: nowrap; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 11; background: var(--bg); }
.top .title { min-width: 0; }
.top h1 { font-size: 1.75rem; }
.top .eyebrow { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: relative; flex: none; }
.menu-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 10px 16px; font-weight: 700; cursor: pointer; min-height: 44px; }
.menu-btn[aria-expanded="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.menu-icon { display: grid; gap: 3px; width: 16px; }
.menu-icon i { display: block; height: 2px; border-radius: 1px; background: currentColor; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); width: min(260px, calc(100vw - 32px)); list-style: none; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgb(0 0 0 / 0.18); }
.menu-list li.sep { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; }
.menu-list a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 700; }
.menu-list a span { display: block; font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.menu-list a:hover, .menu-list a:focus-visible { background: var(--bg); }
.menu-list a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.menu-list a[aria-current="page"] span { color: var(--bg); opacity: 0.75; }
.stats.two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.signed-in { font-size: 0.85rem; }

.day-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.day-nav .date { font-family: var(--f-display); font-size: 1.25rem; font-weight: 700; }
.arrows { display: flex; gap: 6px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 1.1rem; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.progress { display: flex; align-items: center; gap: 10px; font-family: var(--f-data); font-size: 0.85rem; }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--done); transition: width .25s; }

.group-h { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; }
.kind { font-family: var(--f-data); font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.kind.release { color: var(--k-release); } .kind.stretch { color: var(--k-stretch); } .kind.mobility { color: var(--k-mobility); }
.kind.activation { color: var(--k-activation); } .kind.strength { color: var(--k-strength); }

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.ex { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.ex:first-child { border-top: 0; }
.ex input { position: absolute; opacity: 0; pointer-events: none; }
.tick { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; cursor: pointer; }
.tick svg { width: 18px; height: 18px; opacity: 0; }
.ex input:checked + .tick { background: var(--done); border-color: var(--done); }
.ex input:checked + .tick svg { opacity: 1; }
.ex input:focus-visible + .tick { outline: 2px solid var(--band); outline-offset: 2px; }
.ex .txt { cursor: pointer; }
.name { font-weight: 700; }
.dose { font-family: var(--f-data); font-size: 0.8rem; color: var(--muted); }
.notes { font-size: 0.85rem; color: var(--muted); }
.vid { font-size: 0.85rem; white-space: nowrap; }
.ex.is-done .name { color: var(--done); }

.extras { display: grid; gap: 14px; }
.pain-row, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pain-row button { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-family: var(--f-data); cursor: pointer; }
.pain-row button[aria-pressed="true"] { background: var(--band); border-color: var(--band); color: #fff; }
.chip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 0.9rem; }
.chip[aria-pressed="true"] { background: var(--band-soft); border-color: var(--band); }
textarea, input[type="text"], #ask-q { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
textarea { min-height: 70px; resize: vertical; }

/* Routine */
.current h2 { font-size: 1.05rem; }
.count-pill { font-family: var(--f-data); font-size: 0.8rem; background: var(--done-soft); color: var(--done); padding: 2px 10px; border-radius: 999px; }
.picked { margin: 10px 0 0; padding-left: 22px; display: grid; gap: 4px; }
.picked li span { color: var(--muted); font-family: var(--f-data); font-size: 0.75rem; }
.prog { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.prog > summary { list-style: none; cursor: pointer; padding: 14px; display: grid; gap: 4px; }
.prog > summary::-webkit-details-marker { display: none; }
.prog-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.prog-date { font-family: var(--f-data); font-size: 0.8rem; color: var(--muted); }
.phase { font-family: var(--f-data); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.prog-body { padding: 0 14px 14px; display: grid; gap: 10px; }
.pick { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.pick input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--done); }
.pick .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.pick .elsewhere { font-size: 0.8rem; color: var(--warn); }
.btn { border: 0; border-radius: 8px; padding: 10px 16px; background: var(--band); color: #fff; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* History */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.stat .v { font-family: var(--f-display); font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 0.8rem; color: var(--muted); }
.grid-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.hgrid { border-collapse: separate; border-spacing: 3px; font-size: 0.75rem; }
.hgrid th { font-weight: 400; color: var(--muted); text-align: right; padding-right: 6px; white-space: nowrap; }
.hgrid thead th { text-align: center; padding: 0; font-family: var(--f-data); font-size: 0.65rem; }
.hgrid td { width: 14px; height: 14px; min-width: 14px; border-radius: 3px; background: var(--line); padding: 0; }
.hgrid td.on { background: var(--done); }
.hgrid td.off { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.hgrid td.today { outline: 2px solid var(--band); outline-offset: -1px; }
.hgrid tr.pain td { background: transparent; box-shadow: none; text-align: center; font-family: var(--f-data); font-size: 0.65rem; color: var(--band); }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 6px; }
.empty { padding: 18px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }
.days { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.days li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; }
.days .d { font-weight: 700; }

.ask { display: grid; gap: 10px; }
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1; min-width: 0; }
@media (max-width: 420px) { .stats .v { font-size: 1.3rem; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Programme editor */
.editor { display: grid; gap: 12px; }
.editor .field { display: grid; gap: 4px; }
.editor .two { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.editor input, .editor select, .editor textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.editor .ex-edit { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; gap: 8px; }
.editor .ex-edit .ex-id { font-family: var(--f-data); font-size: 0.75rem; color: var(--muted); }
.editor .danger { color: var(--warn); border-color: var(--warn); }
.prog-notes { white-space: pre-wrap; font-size: 0.9rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: 10px; margin: 0; }
.tokens > summary { cursor: pointer; list-style: none; }
.tokens > summary::-webkit-details-marker { display: none; }
.tokens { display: grid; gap: 10px; }

.contents { display: contents; }
.sub-h { margin: 8px 0; }

/* Food & drink */
.dry { display: grid; gap: 8px; }
.dry.kept { border-color: var(--done); background: var(--done-soft); }
.dry.broken { border-color: var(--band); }
.note-input { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }
.meal-grid { display: grid; gap: 8px; }
.meal-row { display: grid; grid-template-columns: 90px repeat(3, minmax(0, 1fr)); gap: 6px; align-items: center; }
.meal-row .slot { font-weight: 700; }
.rate { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 8px 4px; cursor: pointer; font-size: 0.9rem; }
.rate.healthy:hover, .rate.healthy:focus-visible { border-color: var(--done); }
.rate.treat:hover, .rate.treat:focus-visible { border-color: var(--band); }
.entries { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.entries li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; border-top: 1px solid var(--line); padding-top: 6px; }
.tag { font-family: var(--f-data); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.tag.healthy { color: var(--done); } .tag.ok { color: var(--muted); } .tag.treat { color: var(--band); }
.wchart { width: 100%; height: auto; margin-top: 10px; }
.wchart text { fill: var(--muted); font-family: var(--f-data); font-size: 10px; }
.wchart .line { fill: none; stroke: var(--ink); stroke-width: 2; }
.wchart .pt { fill: var(--ink); }
.wchart .target { stroke: var(--done); stroke-dasharray: 4 4; }
.wchart .grid { stroke: var(--line); }
@media (max-width: 420px) { .meal-row { grid-template-columns: 70px repeat(3, minmax(0, 1fr)); } }

.sync { margin: 0; padding: 8px 12px; border-radius: 8px; background: var(--band-soft); border: 1px solid var(--band); font-size: 0.85rem; }

/* Plans made with the coach: one tap to log */
.plans { display: grid; gap: 8px; margin: 8px 0; }
.plan { display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px dashed var(--done); border-radius: 8px; padding: 8px 10px; background: var(--done-soft); }
.plan .eyebrow { color: var(--done); }
.plan-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; flex: none; }
.entries li .grow, .plan .grow { flex: 1; min-width: 0; }
.entries li { align-items: center; }
.plan.photo { border-color: var(--band); background: var(--band-soft); flex-wrap: wrap; }
.plan.photo .plan-actions .rate { padding: 6px 10px; }

/* Recipes */
.recipes { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recipes li button { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; cursor: pointer; }
.recipe-icon { width: 52px; height: 52px; border-radius: 8px; display: grid; place-items: center; background: var(--band-soft); font-size: 1.5rem; flex: none; }
.stars { color: var(--band); letter-spacing: 1px; white-space: nowrap; }
.photo-link { display: block; flex: none; }
.cooks li { display: flex; gap: 10px; align-items: flex-start; }
.recipe-photo { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--r); }
.recipe-detail ol, .recipe-detail ul { padding-left: 20px; display: grid; gap: 6px; }
.cook { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 8px; }
.star-pick, .again-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.star-pick button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); font-size: 1.1rem; cursor: pointer; }
.star-pick button[aria-pressed="true"] { background: var(--band); color: #fff; border-color: var(--band); }

/* Sign-in page: one centred card */
body.signin-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left, 0px)); }
.signin-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px 24px; display: grid; justify-items: center; gap: 14px; text-align: center; box-shadow: 0 12px 40px rgb(0 0 0 / 0.08); }
.signin-icon { width: 72px; height: 72px; border-radius: 18px; }
.signin-card h1 { font-size: 1.8rem; }
.signin-card p.muted { max-width: 30ch; }
.gsi-slot { min-height: 44px; display: grid; place-items: center; }
.gsi-slot > div { margin: 0 auto; }
.recipe-add { margin-bottom: 16px; }
.file-btn { cursor: pointer; display: inline-flex; align-items: center; }
