/* E Fit — soft pastel green, light, mobile-first. */

:root {
  color-scheme: light;

  --bg:        #f3faf5;
  --surface:   #ffffff;
  --surface-2: #ecf7f0;
  --surface-3: #dcefe4;
  --line:      #cfe7d9;
  --text:      #23392d;
  --dim:       #6f8a7a;
  --faint:     #a2b9aa;

  --accent:    #8ed7b0;
  --accent-d:  #74c99c;
  --ink:       #16382a;

  --protein:   #8fb5ef;
  --carbs:     #f0c187;
  --fat:       #f0a2c0;

  --good:      #6fc99a;
  --warn:      #e8b061;
  --bad:       #e88a9c;

  /* Pastels are for fills. Text and icons need these darker twins to stay
     readable on a light background. */
  --accent-t:  #2c8e63;
  --good-t:    #2f8f63;
  --warn-t:    #a1700f;
  --bad-t:     #c4415e;
  --protein-t: #4472bb;

  --shadow:    0 8px 24px rgba(58, 106, 80, .13);
  --scrim:     rgba(40, 78, 58, .34);

  --r:   16px;
  --r-s: 12px;
  --pad: 16px;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
        system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body { padding-bottom: calc(64px + var(--safe-b)); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-t); }

/* Inline icons size to the surrounding text unless a component overrides it. */
svg { width: 1em; height: 1em; vertical-align: -0.14em; flex: none; }

/* Component display rules (block/flex/grid) otherwise beat the UA rule for
   [hidden], which silently breaks every toggle in the app. */
[hidden] { display: none !important; }

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ---------------------------------------------------------------- layout */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(var(--safe-t) + 12px) var(--pad) 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
}
.brand svg { width: 20px; height: 20px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--dim);
  transition: .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--surface-3); }
.icon-btn svg { width: 18px; height: 18px; }

main { padding: 18px var(--pad) 32px; max-width: 720px; margin: 0 auto; }
.view[hidden] { display: none; }

/* ------------------------------------------------------------------- nav */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.tab {
  border: 0;
  background: none;
  color: var(--faint);
  padding: 9px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .2px;
  transition: color .15s;
}
.tab svg { width: 21px; height: 21px; }
.tab.on { color: var(--accent-t); }

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--pad);
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(58, 106, 80, .05);
}
.card.tight { padding: 12px 14px; }
.card.flush { padding: 0; overflow: hidden; }

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h2 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--dim);
  margin-right: auto;
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--dim);
  margin: 22px 0 10px;
}

/* --------------------------------------------------------------- buttons */

.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--r-s);
  padding: 11px 15px;
  font-weight: 600;
  font-size: 14px;
  transition: .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn:hover  { background: var(--surface-3); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 700;
}
.btn.primary:hover { background: var(--accent-d); border-color: var(--accent-d); }

.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad-t); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.wide  { width: 100%; }
.btn.sm    { padding: 7px 11px; font-size: 13px; border-radius: 8px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- inputs */

label.field {
  display: block;
  margin-bottom: 12px;
}
label.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 5px;
}

input[type=text], input[type=number], input[type=search], input[type=password],
input[type=date], select, textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 76px; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 4.5 6 8.5l4-4' stroke='%236f8a7a' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 12px;
  padding-right: 32px;
}
::placeholder { color: var(--faint); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--dim);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  transition: .15s;
}
.chip.on {
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  border-color: var(--accent-d);
  color: var(--accent-t);
}

/* ------------------------------------------------------------ calorie hub */

.hub { display: flex; align-items: center; gap: 18px; }
.ring { position: relative; flex: none; width: 128px; height: 128px; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring-track { stroke: var(--surface-3); }
.ring-fill  { stroke: var(--accent-d); stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.ring-fill.over { stroke: var(--warn); }
.ring-label {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
}
.ring-label b { display: block; font-size: 30px; font-weight: 750; letter-spacing: -1px; line-height: 1; }
.ring-label span { font-size: 10.5px; color: var(--dim); font-weight: 600;
                   text-transform: uppercase; letter-spacing: .6px; }

.macros { flex: 1; min-width: 0; display: grid; gap: 12px; }
.macro-row { display: grid; gap: 5px; }
.macro-top { display: flex; justify-content: space-between; font-size: 12.5px; }
.macro-top b { font-weight: 700; }
.macro-top span { color: var(--dim); }
.bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; transition: width .45s ease; }
.bar i.p { background: var(--protein); }
.bar i.c { background: var(--carbs); }
.bar i.f { background: var(--fat); }

.hub-foot {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--dim);
}
.hub-foot b { color: var(--text); font-size: 15px; }

/* ------------------------------------------------------------ date strip */

.weekbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 10px 12px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(58, 106, 80, .05);
  position: relative;
}
.weekbar-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.monthbtn {
  flex: 1; border: 0; background: none; color: var(--text);
  font-size: 14.5px; font-weight: 700; letter-spacing: -.2px;
  padding: 6px 4px; border-radius: 8px;
}
.monthbtn:hover { background: var(--surface-2); }
.weekbar-head .icon-btn { width: 32px; height: 32px; }
.weekbar-head .icon-btn svg { width: 15px; height: 15px; }
.weekbar-head .icon-btn:disabled { opacity: .3; pointer-events: none; }

.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }

.daycell {
  border: 1px solid transparent;
  background: none;
  border-radius: 11px;
  padding: 7px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: .15s;
  min-height: 56px;
}
.daycell .dow {
  font-size: 10.5px; font-weight: 700; color: var(--faint);
  text-transform: uppercase; letter-spacing: .3px;
}
.daycell .dnum { font-size: 16px; font-weight: 650; color: var(--text); line-height: 1.1; }
.daycell:hover:not(:disabled) { background: var(--surface-2); }
.daycell:disabled { opacity: .3; pointer-events: none; }

.daycell.today .dnum { color: var(--accent-t); }
.daycell.today .dow  { color: var(--accent-t); }

.daycell.on {
  background: var(--accent);
  border-color: var(--accent-d);
}
.daycell.on .dnum, .daycell.on .dow { color: var(--ink); }

.daycell.planned {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  border-color: var(--accent-d);
}
.daycell.planned .dnum { color: var(--accent-t); }

.daycell .dots { display: flex; gap: 3px; height: 5px; align-items: center; }
.daycell .dot { width: 5px; height: 5px; border-radius: 50%; display: block; }
.dot.food  { background: var(--accent-d); }
.dot.train { background: var(--protein-t); }
.daycell.on .dot.food  { background: var(--ink); }
.daycell.on .dot.train { background: var(--ink); opacity: .55; }

.weekbar-foot {
  text-align: center; font-size: 12px; color: var(--dim);
  margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line);
  font-weight: 600;
}

/* ----------------------------------------------------------- food & sets */

.meal { margin-bottom: 6px; }
.meal-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 2px 6px;
}
.meal-head h3 {
  margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .3px;
  text-transform: capitalize; margin-right: auto;
}
.meal-head span { font-size: 12px; color: var(--dim); }

.entry {
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 1px 2px rgba(58, 106, 80, .04);
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  margin-bottom: 6px;
}
.entry .body { flex: 1; min-width: 0; }
.entry .body b { display: block; font-weight: 600; font-size: 14px;
                 white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry .body small { color: var(--dim); font-size: 12px; }
.entry .kcal { font-weight: 700; font-size: 15px; }
.entry .kcal small { display: block; font-size: 10.5px; color: var(--faint);
                     font-weight: 500; text-align: right; }
.entry img.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; flex: none; }
.entry .del {
  border: 0; background: none; color: var(--faint); padding: 4px; line-height: 0;
  border-radius: 6px;
}
.entry .del:hover { color: var(--bad-t); background: var(--surface-2); }
.entry .del svg { width: 15px; height: 15px; }

/* Drag handle. touch-action:none stops the browser stealing the gesture for
   scrolling — without it, dragging on a phone just scrolls the page. */
.grip {
  border: 0; background: none; color: var(--faint);
  padding: 6px 2px; margin: -6px 0 -6px -4px; line-height: 0;
  cursor: grab; touch-action: none; flex: none;
  border-radius: 6px;
}
.grip:hover { color: var(--dim); background: var(--surface-2); }
.grip:active { cursor: grabbing; }
.grip svg { width: 17px; height: 17px; }

.entry.dragging { opacity: .35; }

.drag-ghost {
  position: fixed; z-index: 300; pointer-events: none;
  margin: 0; box-shadow: 0 12px 32px rgba(58, 106, 80, .28);
  border-color: var(--accent-d); transform: rotate(-1deg) scale(1.02);
}

.meal.drop-target {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: var(--r);
  outline: 2px dashed var(--accent-d);
  outline-offset: 2px;
}
.meal { transition: background .12s; }

.empty {
  text-align: center; color: var(--faint); padding: 26px 14px; font-size: 13.5px;
  border: 1px dashed var(--line); border-radius: var(--r-s);
}

/* ------------------------------------------------------------- exercises */

.exercise { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 12px;
            background: var(--surface); overflow: hidden;
            box-shadow: 0 1px 2px rgba(58, 106, 80, .05); }
.ex-head { padding: 13px 14px; display: flex; align-items: flex-start; gap: 10px; }
.ex-head .body { flex: 1; min-width: 0; }
.ex-head b { font-size: 15px; font-weight: 700; }
.ex-head .meta { font-size: 12px; color: var(--dim); margin-top: 2px; }
.ex-head .tag {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 3px 7px; border-radius: 5px; white-space: nowrap;
}
.tag.up     { background: color-mix(in srgb, var(--good) 28%, transparent); color: var(--good-t); }
.tag.hold   { background: var(--surface-3); color: var(--dim); }
.tag.deload { background: color-mix(in srgb, var(--warn) 28%, transparent); color: var(--warn-t); }
.tag.new    { background: color-mix(in srgb, var(--protein) 28%, transparent); color: var(--protein-t); }

.coach {
  font-size: 12.5px; color: var(--dim); padding: 0 14px 12px;
  display: flex; gap: 7px; align-items: flex-start;
}
.coach svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--faint); }

.setgrid { border-top: 1px solid var(--line); }
.setrow {
  display: grid;
  grid-template-columns: 26px 1fr 1fr 44px;
  gap: 8px; align-items: center;
  padding: 8px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}
.setrow:last-child { border-bottom: 0; }
.setrow.done { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.setrow .n { font-size: 12px; color: var(--faint); font-weight: 700; text-align: center; }
.setrow input {
  padding: 8px 6px; text-align: center; font-weight: 650; font-size: 15px;
  border-radius: 8px;
}
.setrow .check {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--faint);
}
.setrow.done .check { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.setrow .check svg { width: 17px; height: 17px; }
.set-head {
  display: grid; grid-template-columns: 26px 1fr 1fr 44px; gap: 8px;
  padding: 7px 14px 4px; font-size: 10px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--faint); text-align: center;
}
.set-head span:first-child { text-align: center; }

.ex-foot { padding: 8px 14px 12px; display: flex; gap: 8px; }

/* Import review rows carry an extra seconds column. */
.x-head, .setrow.x-row {
  grid-template-columns: 22px 1fr 1fr 1fr 38px;
  padding-left: 0; padding-right: 0;
}
.setrow.x-row { padding-top: 5px; padding-bottom: 5px; }
.setrow.assumed .x-w {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}

/* ---------------------------------------------------------------- sheets */

.sheet-wrap {
  position: fixed; inset: 0; z-index: 100;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.sheet-wrap[hidden] { display: none; }
.sheet {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 -8px 40px rgba(58, 106, 80, .16);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
  padding: 8px var(--pad) calc(24px + var(--safe-b));
  animation: rise .24s cubic-bezier(.2,.9,.3,1);
  -webkit-overflow-scrolling: touch;
}
/* Sticky header on every sheet: the grip stays centred, the Back button sits
   on the left and remains reachable however far you've scrolled. */
.sheet-top {
  position: sticky; top: 0; z-index: 6;
  display: flex; align-items: center;
  margin: -8px calc(var(--pad) * -1) 12px;
  padding: 6px var(--pad) 8px;
  background: var(--surface);
  transition: box-shadow .16s ease;
}
.sheet-top.lifted { box-shadow: 0 4px 12px rgba(58, 106, 80, .09); }
.sheet-back {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 40px; padding: 8px 14px 8px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
}
.sheet-back:active { background: var(--surface-3); }
.sheet-back svg { width: 1.05em; height: 1.05em; }

.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--surface-3);
              position: absolute; left: 50%; transform: translateX(-50%); top: 9px;
              margin: 0; pointer-events: none; }
.sheet h2 { margin: 0 0 4px; font-size: 19px; font-weight: 750; letter-spacing: -.3px; }
.sheet .sub { color: var(--dim); font-size: 13.5px; margin: 0 0 16px; }

@keyframes fade { from { opacity: 0 } }
@keyframes rise { from { transform: translateY(22px); opacity: .6 } }

@media (min-width: 620px) {
  .sheet-wrap { align-items: center; }
  .sheet { border-radius: 20px; max-height: 86vh; padding-bottom: 24px; }
}

/* --------------------------------------------------------------- results */

.result {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--surface-2);
  margin-bottom: 6px; text-align: left; width: 100%;
}
.result:hover { border-color: var(--surface-3); background: var(--surface-3); }
.result .body { flex: 1; min-width: 0; }
.result .body b { display: block; font-weight: 600; font-size: 14px;
                  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .body small { color: var(--dim); font-size: 12px; }
.result .kcal { font-weight: 700; font-size: 14px; white-space: nowrap; }

.src {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 2px 5px; border-radius: 4px; background: var(--surface-3); color: var(--faint);
  margin-left: 6px;
}

/* ------------------------------------------------------- exercise figure */

.figure-wrap {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: grid; place-items: center;
  padding: 10px;
  margin: 4px 0 16px;
}
/* Height fixed, width free: cropped floor poses are wider than tall. */
.figure { width: 100%; max-width: 190px; height: 150px; }
.fig-body, .fig-limb {
  fill: none; stroke: var(--accent-t);
  stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
}
.fig-limb   { stroke: var(--accent-d); }
.fig-head   { fill: var(--accent-t); }
.fig-kit    { stroke: var(--text); stroke-width: 4.5; stroke-linecap: round; }
.fig-ground { stroke: var(--surface-3); stroke-width: 3.5; stroke-linecap: round; }
.fig-bench  { fill: var(--surface-3); }
/* Trailing leg sits behind the near one so the split stance reads. */
.fig-limb.back { stroke: color-mix(in srgb, var(--accent-d) 55%, var(--surface-2)); }

.cues { list-style: none; margin: 0; padding: 0; }
.cues li {
  position: relative;
  padding: 9px 12px 9px 34px;
  margin-bottom: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  font-size: 14px; line-height: 1.4;
}
.cues li::before {
  content: "";
  position: absolute; left: 13px; top: 15px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-d);
}
.cues.warn li { background: color-mix(in srgb, var(--warn) 11%, transparent);
                border-color: color-mix(in srgb, var(--warn) 32%, transparent); }
.cues.warn li::before { background: var(--warn-t); }

/* ----------------------------------------------------------------- charts */

.chart { width: 100%; height: 160px; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .goal { stroke: var(--accent-t); stroke-width: 1; stroke-dasharray: 3 4; opacity: .55; }
.chart .lbl  { fill: var(--faint); font-size: 10px; font-weight: 600; }
.chart .barv { fill: var(--surface-3); }
.chart .barv.hit  { fill: var(--accent-d); }
.chart .barv.over { fill: var(--warn); }
.chart .band.premenstrual { fill: color-mix(in srgb, var(--fat) 16%, transparent); }
.chart .band.period       { fill: color-mix(in srgb, var(--fat) 32%, transparent); }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px;
          margin-right: 5px; vertical-align: 0; }
.swatch.premenstrual { background: color-mix(in srgb, var(--fat) 30%, var(--surface-3)); }
.swatch.period       { background: color-mix(in srgb, var(--fat) 55%, var(--surface-3)); }
.chart .line { fill: none; stroke: var(--protein-t); stroke-width: 2.2;
               stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: color-mix(in srgb, var(--protein) 22%, transparent); }
.chart .dot  { fill: var(--protein-t); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 13px 12px;
}
.stat b { display: block; font-size: 22px; font-weight: 750; letter-spacing: -.6px;
          line-height: 1.1; }
.stat span { font-size: 10.5px; color: var(--dim); font-weight: 600;
             text-transform: uppercase; letter-spacing: .3px;
             white-space: nowrap; display: block; }
.stat small { font-size: 11.5px; color: var(--faint); }

/* ---------------------------------------------------------------- misc UI */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; color: var(--dim);
  font-weight: 600;
}
.pill.accent { color: var(--accent-t); border-color: var(--accent-d);
              background: color-mix(in srgb, var(--accent) 18%, transparent); }

.note {
  background: color-mix(in srgb, var(--protein) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--protein) 30%, transparent);
  border-radius: var(--r-s); padding: 11px 13px; font-size: 13px; color: var(--text);
  margin-bottom: 12px;
}
.note.warn {
  background: color-mix(in srgb, var(--warn) 10%, transparent);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}
.note.bad {
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  border-color: color-mix(in srgb, var(--bad) 30%, transparent);
}

.spinner {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--ink) 30%, transparent);
  border-top-color: var(--ink);
  animation: spin .7s linear infinite;
}
.spinner.light { border-color: var(--surface-3); border-top-color: var(--accent-t); }
@keyframes spin { to { transform: rotate(360deg) } }

.loading { display: flex; align-items: center; gap: 11px; color: var(--dim);
           font-size: 13.5px; padding: 22px 6px; justify-content: center; }

#toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-b));
  transform: translate(-50%, 14px);
  z-index: 200; pointer-events: none;
  background: #2f5344; border: 1px solid #2f5344;
  color: #f3faf5; padding: 11px 17px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; transition: .25s;
  max-width: min(90vw, 420px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { border-color: color-mix(in srgb, var(--bad) 50%, var(--line)); }

/* -------------------------------------------------------------- coach chat */

.msg {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
  margin-bottom: 9px;
  font-size: 14.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.msg.me {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  border-color: var(--accent-d);
  border-radius: 14px 14px 4px 14px;
  margin-left: 32px;
  font-weight: 550;
}
.msg.thinking { color: var(--faint); letter-spacing: 3px; }

.shots { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.shots:empty { margin-bottom: 0; }
.shot { position: relative; width: 76px; height: 76px; }
.shot img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--r-s); border: 1px solid var(--line); display: block;
}
.shot-n {
  position: absolute; left: 4px; bottom: 4px;
  background: color-mix(in srgb, var(--ink) 78%, transparent);
  color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 5px; border-radius: 5px;
}
.shot-x {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--dim); display: grid; place-items: center; padding: 0;
  box-shadow: var(--shadow);
}
.shot-x svg { width: 12px; height: 12px; }
.shot-x:hover { color: var(--bad-t); }

.photo-preview {
  width: 100%; border-radius: var(--r-s); border: 1px solid var(--line);
  max-height: 260px; object-fit: cover; margin-bottom: 14px; display: block;
}

.rest-timer {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(76px + var(--safe-b)); z-index: 60;
  background: var(--surface); border: 1px solid var(--accent-d);
  border-radius: 999px; padding: 9px 16px;
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow);
}
.rest-timer[hidden] { display: none; }
.rest-timer button { border: 0; background: none; color: var(--dim); padding: 0; line-height: 0; }
.rest-timer svg { width: 15px; height: 15px; }

/* ----------------------------------------------------------- onboarding */

#onboard { position: fixed; inset: 0; z-index: 500; background: var(--bg);
           overflow-y: auto; padding: calc(var(--safe-t) + 28px) var(--pad)
           calc(28px + var(--safe-b)); }
#onboard[hidden] { display: none; }
.ob-inner { max-width: 480px; margin: 0 auto; }
.ob-step h1 { font-size: 27px; font-weight: 780; letter-spacing: -.8px; margin: 0 0 6px; }
.ob-step p.lede { color: var(--dim); margin: 0 0 24px; font-size: 14.5px; }
.ob-dots { display: flex; gap: 6px; margin-bottom: 26px; }
.ob-dots i { height: 3px; flex: 1; border-radius: 2px; background: var(--surface-3); }
.ob-dots i.on { background: var(--accent); }

.pickers { display: grid; gap: 8px; margin-bottom: 18px; }
.picker {
  text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r); padding: 14px; transition: .15s;
}
.picker.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.picker b { display: block; font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.picker span { font-size: 13px; color: var(--dim); line-height: 1.4; }

/* A history row you can open — the trash button inside stays its own target. */
.entry.tappable { cursor: pointer; }
.entry.tappable:active { background: var(--surface-2); }

.hint { font-size: 12.5px; color: var(--dim); line-height: 1.45; }

/* Tick boxes follow the theme instead of the browser's default blue. */
input[type="checkbox"] { accent-color: var(--accent-d); }

/* A row of short single-word choices (the sleep rating) rather than the
   stacked description cards .pickers normally holds. */
.pickers.row { grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.pickers.row .picker { text-align: center; padding: 10px 4px; }
.pickers.row .picker b { font-size: 12.5px; margin: 0; }

/* ---- tappable charts ------------------------------------------------- */

.card.zoomable { cursor: pointer; position: relative; transition: transform .12s; }
.card.zoomable:active { transform: scale(.995); }
.zoom-hint {
  display: flex; align-items: center; gap: 5px; justify-content: center;
  margin-top: 8px; font-size: 11.5px; color: var(--faint);
}
.zoom-hint svg { width: 12px; height: 12px; }

/* The expanded chart, with a draggable readout line. */
.zoomchart {
  position: relative; touch-action: none;      /* dragging must not scroll */
  margin-bottom: 10px; -webkit-user-select: none; user-select: none;
}
.zoomchart .chart { width: 100%; }
.scrub {
  position: absolute; top: 0; bottom: 18px; width: 2px;
  background: var(--accent-t); border-radius: 1px;
  transform: translateX(-1px); pointer-events: none;
}
.scrub::before {
  content: ''; position: absolute; top: -3px; left: 50%;
  width: 9px; height: 9px; margin-left: -4.5px; border-radius: 50%;
  background: var(--accent-t);
}

.readout {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 11px 13px; min-height: 44px;
}
.readout b { font-size: 14px; }
.readout span { color: var(--dim); font-size: 13px; }
.readout .num { color: var(--text); font-size: 15px; }

.num.over  { color: var(--warn-t); }
.num.hit   { color: var(--good-t); }
.num.under { color: var(--dim); }

/* ---- supersets -------------------------------------------------------- */

.superset {
  border: 1.5px dashed var(--accent-d);
  border-radius: var(--r);
  padding: 10px 10px 2px;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.superset .exercise { margin-bottom: 8px; }
.superset-head {
  display: flex; align-items: center; gap: 6px;
  padding: 0 2px 8px; font-size: 12px; color: var(--accent-t);
}
.superset-head b { font-size: 12.5px; font-weight: 750; letter-spacing: .2px; }
.superset-head span { color: var(--dim); margin-left: auto; font-size: 11.5px; }
.superset-head svg { width: 13px; height: 13px; }

/* ---- training calendar ------------------------------------------------ */

.cal-dow {
  display: grid; grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-dow span {
  text-align: center; font-size: 10.5px; font-weight: 700;
  color: var(--faint); letter-spacing: .4px;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
  margin-bottom: 12px;
}
.cal-cell {
  position: relative; aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  border: 1px solid transparent; border-radius: 11px;
  background: none; padding: 0; cursor: pointer;
  font-size: 13px; color: var(--text); transition: .12s;
}
.cal-cell.blank { pointer-events: none; }
.cal-cell.did     { background: var(--surface-2); }
.cal-cell.did i {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-d); display: block;
}
.cal-cell.today   { border-color: var(--accent-d); font-weight: 750; }
.cal-cell.sel     { background: var(--accent); color: var(--ink); font-weight: 750; }
.cal-cell.sel i   { background: var(--ink); }
.cal-cell.future  { color: var(--faint); cursor: default; }
.cal-cell:active:not(.future) { transform: scale(.92); }

.cal-sel {
  display: flex; align-items: baseline; gap: 8px;
  padding-top: 10px; margin-top: 2px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.cal-sel b { font-weight: 700; }
.cal-sel span { color: var(--dim); margin-left: auto; text-align: right; }
