/* sweatsheet — mobile-first, light/dark via prefers-color-scheme */

:root {
  /* Colours: shared/tokens.css */
  --radius: 22px;
  --radius-sm: 14px;
  --tabbar-h: 68px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { opacity: .3; cursor: default; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.view {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-area-inset-top, env(safe-area-inset-top)) + 12px) 16px calc(var(--tabbar-h) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)) + 28px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.page-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 2px; }
.page-head h1 { font-size: 28px; letter-spacing: -.02em; }
.section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 4px 0; }

/* ---------- buttons ---------- */
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text);
  transition: background .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn.soft { background: var(--surface-2); }
.icon-btn.accent { background: var(--accent-soft); color: var(--accent); }
.icon-btn.accent:hover { background: var(--accent); color: var(--accent-ink); }
.icon-btn svg { width: 20px; height: 20px; }

/* Touch targets: small controls keep their look but get a hit area of at least 44 × 44 px. */
.icon-btn, .btn.sm, .pill, .chip, .link-btn { position: relative; }
.icon-btn::after, .btn.sm::after, .pill::after, .chip::after, .link-btn::after {
  content: ""; position: absolute; left: 50%; top: 50%; translate: -50% -50%;
  width: max(100%, 44px); height: max(100%, 44px);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px;
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 600;
  transition: transform .1s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn svg { width: 18px; height: 18px; }

.pill {
  height: 32px; padding: 0 12px; border-radius: 999px;
  background: var(--surface-2); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill.on { background: var(--c, var(--steps)); color: #fff; }
.pill.on::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 5px 0; margin: -3px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 14px; font-weight: 500;
  transition: all .15s;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button {
  height: 38px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button svg { width: 17px; height: 17px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }

/* ---------- inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: 12px; }
.input, .field input {
  height: 48px; width: 100%; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface);
  outline: none; transition: border-color .15s;
}
.input:focus, .field input:focus { border-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 42px; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; }

/* ---------- today: date bar ---------- */
.datebar { display: flex; align-items: center; justify-content: space-between; }
.date-title { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.date-title strong { font-size: 20px; letter-spacing: -.01em; }
.date-title span { font-size: 13px; color: var(--muted); }
.brand { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; letter-spacing: -.02em; font-size: 14px; color: var(--brand-navy); vertical-align: -3px; }
.logo-mark { width: 18px; height: 18px; stroke: none; }

/* ---------- today: summary ---------- */
.summary-top { display: flex; align-items: center; gap: 20px; }
.ring-wrap { position: relative; width: 132px; height: 132px; flex: none; }
.ring { width: 132px; height: 132px; rotate: -90deg; }
.ring circle { fill: none; stroke-width: 11; }
.ring-track { stroke: var(--surface-2); }
.ring-fill { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2,.8,.2,1); }
.ring.over .ring-fill { stroke: var(--danger); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label strong { font-size: 28px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.ring-label span { font-size: 12px; color: var(--muted); margin-top: 4px; }
.summary-stats { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat strong { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.stat strong small { font-size: 13px; font-weight: 500; color: var(--muted); }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.macro .lbl { font-size: 13px; font-weight: 600; }
.macro .val { font-size: 12px; color: var(--muted); margin-top: 6px; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.m-protein { --c: var(--protein); }
.m-carbs { --c: var(--carbs); }
.m-fat { --c: var(--fat); }
.m-steps { --c: var(--steps); }
.m-train { --c: var(--train); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }

/* ---------- today: steps ---------- */
.steps-head { display: flex; align-items: center; gap: 12px; }
.steps-icon { width: 42px; height: 42px; border-radius: 14px; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--steps)) 14%, transparent); color: var(--c, var(--steps)); }
.steps-main { flex: 1; min-width: 0; }
.steps-main .lbl { display: block; font-size: 13px; color: var(--muted); }
.steps-main strong { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.steps-meta { margin-top: 8px; }

/* ---------- today: meals ---------- */
.meal { padding: 14px 14px 14px 18px; }
.meal header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.meal h3 { font-size: 17px; font-weight: 650; }
.entries { list-style: none; margin: 10px -6px 0 -10px; padding: 0; }
.row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: var(--radius-sm); text-align: left;
  transition: background .15s;
}
.row:hover { background: var(--surface-2); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-end { font-weight: 600; white-space: nowrap; }
.row-end small { font-weight: 500; color: var(--muted); font-size: 12px; }

.thumb {
  width: 42px; height: 42px; border-radius: 12px; flex: none;
  background: var(--surface-2); object-fit: cover;
  display: grid; place-items: center; font-weight: 700; color: var(--muted); font-size: 15px;
}
.thumb.lg { width: 64px; height: 64px; border-radius: 16px; font-size: 22px; }
img.thumb { background: #fff; object-fit: contain; }

.list { list-style: none; margin: 0; padding: 6px; }
.list.card { padding: 6px; }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty svg { width: 34px; height: 34px; opacity: .6; }

/* ---------- history ---------- */
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.chart-head h3 { font-size: 16px; }
.chart { position: relative; height: 140px; display: flex; align-items: flex-end; gap: 6px; }
.chart.dense { gap: 2px; }
.chart .col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart .bw { flex: 1; min-height: 0; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart .b { width: 100%; max-width: 30px; border-radius: 6px 6px 3px 3px; background: var(--c); min-height: 3px; opacity: .9; transition: height .5s cubic-bezier(.2,.8,.2,1); }
.chart .b.zero { background: var(--surface-2); }
.chart .b.over { background: var(--danger); }
.chart .d { font-size: 11px; color: var(--muted); height: 14px; }
.chart .goal { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--muted); opacity: .45; pointer-events: none; }
.chart .goal span { position: absolute; right: 0; top: -17px; font-size: 11px; color: var(--muted); }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
  padding: 0 max(8px, calc((100vw - 520px) / 2)) var(--safe-area-inset-bottom, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(1.6);
  -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border-top: 1px solid var(--line);
}
.tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 8px 0; transition: color .15s; }
.badge {
  position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.tab.active { color: var(--text); }
.tab.active svg { stroke-width: 2.4; }
.fab {
  justify-self: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform .15s;
}
.fab:active { transform: scale(.94); }
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / .35); opacity: 0; transition: opacity .25s; }
.sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 92dvh;
  background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 8px 16px calc(20px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; overscroll-behavior: contain;
  translate: 0 100%; transition: translate .3s cubic-bezier(.2,.8,.2,1);
}
.sheet.tall { height: 92dvh; }
/* The sheet scrolls, its parts keep their size (a row with overflow-x, like .chips, would otherwise shrink to nothing in a full sheet). */
.sheet > * { flex-shrink: 0; }
.sheet-wrap.open .backdrop { opacity: 1; }
.sheet-wrap.open .sheet { translate: 0 0; }
.grabber { width: 38px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head > div { min-width: 0; }
.sheet:focus { outline: none; }
.sheet-head h2 { font-size: 20px; letter-spacing: -.01em; }
.sheet-actions {
  display: flex; gap: 10px; margin: 4px -16px 0; padding: 18px 16px 0; position: sticky; bottom: calc(-20px - var(--safe-area-inset-bottom, env(safe-area-inset-bottom))); padding-bottom: calc(20px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));
  background: linear-gradient(to bottom, transparent, var(--bg) 18px);
}
.form .sheet-actions { margin-bottom: calc(-20px - var(--safe-area-inset-bottom, env(safe-area-inset-bottom))); }
.link-btn { display: block; margin: 10px auto 0; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.rest { box-shadow: 0 6px 16px rgb(0 0 0 / .18); }
.sheet-actions .btn.primary { flex: 1; }
@media (min-width: 560px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 26px; translate: 0 40px; opacity: 0; transition: translate .25s, opacity .2s; padding-bottom: 20px; }
  .sheet.tall { height: min(780px, 92dvh); }
  .sheet-wrap.open .sheet { opacity: 1; }
  .grabber { display: none; }
}

/* ---------- scanner ---------- */
.scanner {
  position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden;
  background: #000; flex: none;
}
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame {
  position: absolute; left: 12%; right: 12%; top: 30%; bottom: 30%;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / .35);
}
.scan-frame::before, .scan-frame::after { content: ""; position: absolute; inset: 0; border-radius: inherit; border: 3px solid #fff; }
.scan-frame::after { border: 0; height: 2px; top: 50%; left: 8%; right: 8%; inset-inline: 8%; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: sweep 1.8s ease-in-out infinite; }
@keyframes sweep { 0%, 100% { translate: 0 -28px; } 50% { translate: 0 28px; } }
.scan-status {
  position: absolute; left: 50%; bottom: 14px; translate: -50% 0;
  background: rgb(0 0 0 / .6); color: #fff; font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: 999px; white-space: nowrap; max-width: 92%; overflow: hidden; text-overflow: ellipsis;
}
.scanner.idle .scan-frame::after { display: none; }
.scan-alt { display: flex; gap: 8px; }
.scan-alt .inline-form { flex: 1; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- portion ---------- */
.product { display: flex; gap: 14px; align-items: center; }
.product h3 { font-size: 18px; line-height: 1.25; }
.amount { display: flex; gap: 10px; align-items: stretch; }
.amount .input { height: 56px; font-size: 24px; font-weight: 700; text-align: center; flex: 1; min-width: 0; }
.amount .seg { flex: none; width: 168px; align-content: center; }
.amount .unit { display: grid; place-items: center; padding: 0 18px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); }
.nutri { display: grid; grid-template-columns: 1.2fr 1fr 1fr 1fr; gap: 8px; }
.nutri div { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 10px; text-align: center; box-shadow: var(--shadow); }
.nutri strong { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.nutri span { font-size: 12px; color: var(--muted); }
.nutri .kcal strong { color: var(--accent); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)) + 14px); z-index: 50;
  translate: -50% 20px; opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg);
  padding: 11px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  transition: all .25s; max-width: calc(100vw - 32px); text-align: center;
}
#toast.show { translate: -50% 0; opacity: 1; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 24px auto; }
@keyframes spin { to { rotate: 360deg; } }
.footnote { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 0; }
.footnote a { color: inherit; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- workouts ---------- */
.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 99px; background: color-mix(in srgb, var(--train) 16%, transparent); color: var(--train); vertical-align: middle; }
.note { display: block; color: var(--text); opacity: .75; font-style: italic; margin-top: 2px; }
.title-sm { font-size: 17px !important; letter-spacing: -.01em !important; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row-sub.wrap { white-space: normal; }
.row.static { cursor: default; }
.row.static:hover { background: none; }
.check-line { display: flex; gap: 10px; align-items: center; font-size: 14px; }
.check-line input { width: 20px; height: 20px; accent-color: var(--accent); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.block-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -6px 10px; }
.block-head strong { font-size: 17px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.wd { display: block; width: 100%; min-height: 44px; padding: 0; }
.block-done { margin: -2px 0 12px; padding: 8px 12px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--train) 14%, transparent); color: var(--text); }
.wd span { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.wd i { width: 36px; height: 36px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 14px; font-weight: 600; border: 2px solid transparent; }
.wd.planned i { border-color: color-mix(in srgb, var(--train) 55%, transparent); }
.wd.did i { background: var(--train); color: #fff; }
.wd.did i svg { width: 18px; height: 18px; stroke-width: 3; }
.wd.today span { color: var(--text); }
.wd.today i { box-shadow: inset 0 0 0 2px var(--text); }
.hero .plan + .plan { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.hero .lbl { margin-bottom: 10px; }
.routine { display: flex; align-items: center; gap: 4px; padding-right: 6px; }
.routine .row { flex: 1; min-width: 0; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; }
/* Thin bars, tall tap area: each one tells its day on tap. */
.dots button { flex: 1; min-width: 6px; max-width: 34px; height: 30px; position: relative; }
.dots button::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 10px; border-radius: 99px; background: var(--surface-2); }
.dots button.on::before { background: var(--train); }
.chart button.col { padding: 0; border-radius: 6px; }

/* session logger */
.ex { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ex header { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.ex header > div { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.ex h3 { font-size: 17px; }
.ex.ss { margin-top: -10px; border-top-left-radius: 8px; border-top-right-radius: 8px; box-shadow: inset 3px 0 0 var(--train), var(--shadow); }
.sets { display: flex; flex-direction: column; gap: 6px; }
.set { display: grid; grid-template-columns: 30px 1fr 1fr 44px; gap: 8px; align-items: center; }
.set.head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: center; }
.set .n { text-align: center; font-weight: 700; color: var(--muted); }
.set .input { height: 44px; text-align: center; font-weight: 650; font-size: 17px; padding: 0 6px; background: var(--surface-2); border-color: transparent; }
/* The suggestion (last time / target) must stay readable: lighter weight tells it apart, not low contrast. */
.set .input::placeholder { color: var(--muted); opacity: 1; font-weight: 450; }
.check { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); transition: all .15s; }
.check svg { width: 20px; height: 20px; stroke-width: 2.6; }
.set.done .check { background: var(--accent); color: var(--accent-ink); }
.set.done .input { background: var(--accent-soft); }
.ex-foot { display: flex; gap: 8px; align-items: center; }
.note-in { font-size: 14px; }
.rest {
  position: sticky; top: -8px; z-index: 2; overflow: hidden;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--text); color: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px 10px 16px;
}
.rest[hidden] { display: none; }
.rest strong { font-size: 18px; margin-left: 4px; }
.rest .pill { background: color-mix(in srgb, var(--bg) 18%, transparent); color: var(--bg); }
.rest-actions { display: flex; gap: 6px; }
.rest i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transition: width .5s linear; }

/* routine editor */
.ex-row { background: var(--surface); border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); }
.ex-row-top { display: flex; gap: 4px; align-items: center; }
.ex-row-top .input { flex: 1; min-width: 0; }
.ex-row-fields { display: flex; gap: 8px; align-items: center; }
.ex-row-fields .seg { flex: none; width: 150px; }
.ex-row-fields .input { width: 0; flex: 1; text-align: center; height: 44px; }
.ex-more summary { font-size: 13px; color: var(--muted); cursor: pointer; padding: 2px 0; }
.ex-more[open] { display: flex; flex-direction: column; gap: 10px; }
.ex-more .input { height: 42px; }

/* focus-mode logger */
.progress { height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: -6px; flex: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.ex-list { gap: 10px; }
.ex.compact { padding: 4px; }
.ex.compact.ss { margin-top: -6px; }
.ex-line { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 10px; text-align: left; border-radius: var(--radius-sm); }
.ex-dot { width: 30px; height: 30px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.ex-dot svg { width: 16px; height: 16px; stroke-width: 3; }
.ex.complete .ex-dot { background: var(--accent); color: var(--accent-ink); }
.ex.complete .row-title { color: var(--muted); }
.ex.current { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }
.ex.current.ss { box-shadow: inset 3px 0 0 var(--train), 0 0 0 2px var(--accent), var(--shadow); }
.set.next .check { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.set.next .n { color: var(--accent); }
.ex-foot { gap: 18px; padding: 0 4px; }
.ex-foot .link-btn { margin: 0; font-size: 14px; font-weight: 600; text-decoration: none; color: var(--text); }
.ex-foot .link-btn.danger { color: var(--danger); margin-left: auto; font-weight: 500; }
.note-in { height: 40px !important; }


/* coach connection */
.coach-box { display: flex; flex-direction: column; gap: 12px; }
.m-coach { --c: var(--accent); }
.coach-actions { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.coach-actions .link-btn { margin: 0; font-size: 13px; }
.link-btn.danger { color: var(--danger); }
.error-text { color: var(--danger); }
.code-input { font-size: 22px; font-weight: 700; letter-spacing: .18em; text-align: center; text-transform: uppercase; height: 56px; }
.consent { align-items: flex-start; line-height: 1.4; }
.consent input { margin-top: 2px; flex: none; }

/* program pushed by the coach */
.program-banner { box-shadow: 0 0 0 2px var(--accent), var(--shadow); }

/* goals and comments from the coach */
.coach-set { color: var(--accent) !important; font-weight: 600; }
.field input[readonly] { background: var(--surface-2); color: var(--muted); }
.coach-comments h2, .coach-comments h3 { font-size: 13px; font-weight: 600; color: var(--muted); }
.comment-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.comment-list li + li { padding-top: 12px; border-top: 1px solid var(--line); }
.coach-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; margin-top: 4px; }
.comment-list .link-btn { margin: 6px 0 0; }
.tag.new { background: var(--accent-soft); color: var(--accent); }

/* backup reminder and the error screen */
.nudge-actions, .fallback-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.fallback { display: flex; flex-direction: column; gap: 10px; }
.fallback h1 { font-size: 22px; }
.fallback-actions { justify-content: flex-start; }

.coach-note { white-space: pre-wrap; font-size: 15px; line-height: 1.5; border-left: 3px solid var(--accent); }

.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; }

/* rest timer while the logger is closed: just above the tab bar, on every tab */
.restbar {
  position: fixed; top: auto; left: 50%; translate: -50% 0; z-index: 15;
  bottom: calc(var(--tabbar-h) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)) + 10px);
  width: min(488px, calc(100vw - 32px));
}
.restbar .pill { min-width: 44px; justify-content: center; }
body.resting .view { padding-bottom: calc(var(--tabbar-h) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)) + 92px); }
body.resting #toast { bottom: calc(var(--tabbar-h) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)) + 78px); }

/* toast with an action (Undo) */
#toast.has-action { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 18px; pointer-events: auto; }
.toast-action {
  flex: none; min-height: 36px; min-width: 64px; padding: 0 14px; border-radius: 999px; position: relative;
  background: color-mix(in srgb, var(--bg) 20%, transparent); color: var(--bg); font-weight: 700;
}
.toast-action::after { content: ""; position: absolute; inset: -4px; }
.toast-action:focus-visible { outline: 2px solid var(--bg); outline-offset: 2px; }

/* pinned foods: a filled star, not only a colour change */
.star { color: var(--muted); }
.star[aria-pressed="true"] { color: var(--carbs); }
.star[aria-pressed="true"] svg { fill: currentColor; }
.food-li { display: flex; align-items: center; }
.food-li .row { flex: 1; min-width: 0; }
.product > div { flex: 1; min-width: 0; }

.copy-btn { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; text-decoration: none; font-weight: 600; color: var(--accent); min-height: 32px; }
.copy-btn svg { width: 16px; height: 16px; }
.meal-links { display: flex; flex-wrap: wrap; column-gap: 18px; }

/* saved meals */
.saved-chips { margin-top: 10px; }
.saved-chips .chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.saved-chips .chip svg { width: 15px; height: 15px; color: var(--accent); }
.saved-chips .chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.saved-chips .chip small { color: var(--muted); font-size: 12px; }
.section-row { display: flex; align-items: center; justify-content: space-between; }
.section-row .link-btn { display: inline-flex; align-items: center; gap: 4px; margin: 10px 4px 0; min-height: 32px; font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; }
.section-row .link-btn svg { width: 16px; height: 16px; }

/* water */
.m-water { --c: var(--water); }
.water-actions { display: flex; gap: 6px; flex: none; }
.water-actions .pill { min-width: 44px; justify-content: center; }

/* body weight */
.m-weight { --c: #8b5cf6; }
.weight-form { display: flex; align-items: center; gap: 12px; }
.weight-form .steps-main label { display: block; font-size: 15px; font-weight: 650; color: var(--text); }
.weight-form .input { width: 84px; flex: none; height: 44px; padding: 0 8px; text-align: center; font-weight: 650; font-size: 17px; }

/* last week */
.week-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; }
.week-stats div:last-child:nth-child(odd) { grid-column: 1 / -1; }
.week-stats dt { font-size: 13px; color: var(--muted); }
.week-stats dd { margin: 2px 0 0; font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.week-stats dd small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

/* line charts (exercise history, body weight) */
.line-chart { margin: 0; }
.line-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.line-chart polyline { fill: none; stroke-width: 2.2; }
.line-chart .s1 { stroke: var(--c, var(--accent)); }
.line-chart .s2 { stroke: var(--train); stroke-dasharray: 5 4; }
.line-chart circle { stroke: none; }
.line-chart circle.s1 { fill: var(--c, var(--accent)); }
.line-chart circle.s2 { fill: var(--train); }
.line-chart .grid { stroke: var(--line); stroke-width: 1; }
.line-chart text { fill: var(--muted); stroke: none; font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 0; border-top: 2.5px solid var(--c, var(--accent)); }
.legend .s2 i { border-top: 2.5px dashed var(--train); }
.seg.seg-sm { width: 112px; padding: 3px; }
.seg.seg-sm button { height: 30px; font-size: 13px; position: relative; }
.seg.seg-sm button::after { content: ""; position: absolute; inset: -7px 0; }
.table-toggle { margin-top: 10px; }
.table-toggle summary { font-size: 13px; color: var(--muted); cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.table-card { padding: 6px 14px; overflow-x: auto; }
.hist-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.hist-table th, .hist-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hist-table thead th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.hist-table tr:last-child > * { border-bottom: 0; }
.hist-table .link-btn { margin: 0; font-size: 14px; font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap; }
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* progression and PRs */
.prog { color: var(--muted); }
.prog.up { color: color-mix(in srgb, var(--protein) 70%, var(--text)); font-weight: 650; }
.tag.pr { background: var(--accent-soft); color: var(--accent); }
.pr-text { color: var(--accent); font-weight: 600; }
.row-end svg { width: 16px; height: 16px; color: var(--muted); vertical-align: middle; margin-left: 4px; }
.pr-list .row-sub + .row-sub { margin-top: 2px; }
