:root {
  --bg: #f4f1ec;
  --bg-2: #ebe6df;
  --surface: #ffffff;
  --surface-2: #faf8f5;
  --ink: #1c1917;
  --muted: #6f6861;
  --line: #e4ded6;
  --accent: #f0532b;
  --accent-2: #ff8a3d;
  --accent-ink: #ffffff;
  --accent-soft: #fde9e1;
  --teal: #0f8f83;
  --teal-soft: #dcf2ef;
  --ok: #16834d;
  --warn: #b85c00;
  --danger: #c0352b;
  --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 6px 20px -8px rgba(28, 25, 23, .12);
  --r-card: 16px;
  --r-btn: 8px;
  --fast: 120ms cubic-bezier(.2, .8, .2, 1);
  --font: "Inter", "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121110; --bg-2: #1a1817; --surface: #1d1b19; --surface-2: #232120;
    --ink: #f2eee9; --muted: #a39b93; --line: #302c29;
    --accent: #ff6a42; --accent-2: #ff9a52; --accent-ink: #1a0d08; --accent-soft: #3a1f16;
    --teal: #3fd1c0; --teal-soft: #14302d;
    --ok: #5fd68f; --warn: #ffb35c; --danger: #ff7b70;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -10px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
html { overflow-x: hidden; overscroll-behavior-x: none; }
html { scroll-padding-top: 72px; scroll-padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.4;
  font-feature-settings: "tnum" 1, "cv11" 1;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
  overflow-x: clip; overscroll-behavior-x: none;
}
/* Horizontal pans belong to the tab pager; the browser keeps vertical scroll and pinch. */
.view { touch-action: pan-y pinch-zoom; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; transition: transform var(--fast), background-color var(--fast), color var(--fast), border-color var(--fast), box-shadow var(--fast); }
button:active { transform: scale(.97); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* top bar */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
.brand { font-weight: 800; letter-spacing: -.01em; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand i {
  width: 22px; height: 22px; border-radius: 7px; display: inline-block;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--accent) 70%, transparent);
}
.top-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rest {
  display: flex; align-items: center; gap: 2px; height: 40px; padding: 0 2px; border-radius: var(--r-btn);
  background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ok);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok) 28%, transparent);
}
.rest-time {
  font-family: var(--mono); font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums;
  min-width: 7ch; text-align: center; padding: 0 4px; opacity: .55; transition: opacity var(--fast);
}
.rest.running .rest-time { opacity: 1; }
.rest-btn {
  width: 36px; height: 36px; border: 0; border-radius: 6px; background: transparent; color: var(--ok);
  display: grid; place-items: center; padding: 0;
}
.rest-btn:active { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.rest-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.rest-btn .i-play { fill: currentColor; stroke-width: 1.5; }
.rest-btn .i-pause { display: none; }
.rest.running .rest-btn .i-play { display: none; }
.rest.running .rest-btn .i-pause { display: inline; }
.rest-auto {
  width: 30px; height: 26px; margin: 0 3px; font-size: 13px; font-weight: 800; font-family: var(--mono);
  border-radius: 6px; color: var(--muted); box-shadow: inset 0 0 0 1.5px var(--line);
}
.rest-auto[aria-pressed="true"] { background: var(--ok); color: #fff; box-shadow: none; }
@media (max-width: 430px) {
  .top.with-rest .brand span { display: none; }
  .top.with-rest .status { font-size: 0; gap: 0; padding: 0 8px; }
}
.status {
  min-height: 44px; padding: 0 4px 0 10px; border: 0; background: transparent;
  font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.status.ok { color: var(--muted); }
.status.ok::before { background: var(--ok); }
.status.wait { color: var(--accent); font-weight: 600; }
.status.wait::before { animation: pulse 1s ease-in-out infinite; }
.status.warn { color: var(--warn); font-weight: 600; }
@keyframes pulse { 50% { opacity: .3; } }

.view {
  max-width: 640px; margin: 0 auto; display: grid; gap: 12px;
  padding: 6px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.pane-next {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; overflow: hidden; background: var(--bg);
  will-change: transform; pointer-events: none; align-content: start;
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}
.pane-next .fill { animation: none; }

.card { background: var(--surface); border-radius: var(--r-card); padding: 16px; display: grid; gap: 12px; min-width: 0; box-shadow: var(--shadow); }
.hint { margin: 0; color: var(--muted); font-size: 14px; }
h2 { font-size: 20px; margin: 0; letter-spacing: -.01em; font-weight: 750; }
h3 { font-size: 16px; margin: 0; font-weight: 700; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

.kind-picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) minmax(0, 1.25fr); gap: 2px; }
.kind-button {
  min-width: 0; min-height: 38px; padding: 2px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1px solid transparent; border-radius: var(--r-btn); background: var(--surface-2);
  color: var(--muted); font-size: .6875rem; font-weight: 650; line-height: 1.2;
}
.kind-button svg {
  width: 18px; height: 18px; fill: none; stroke: currentColor;
  stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round;
}
.kind-button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
@media (max-width: 359px) {
  .kind-button { font-size: .625rem; }
}

/* Meal type chips */
.chip {
  min-height: 44px; padding: 8px 14px; border-radius: var(--r-btn); border: 1px solid var(--line);
  background: var(--surface-2); font-size: 15px; font-weight: 600; color: var(--ink);
}
.chip[aria-pressed="true"] {
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}
.meals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.meals .chip { min-width: 0; min-height: 32px; padding: 3px 2px; font-size: .75rem; }
.meals .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

textarea, input[type="text"], input[type="datetime-local"], input:not([type]) {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-btn); background: var(--surface-2);
  padding: 12px; font-size: 16px; min-height: 48px; transition: border-color var(--fast), box-shadow var(--fast);
}
textarea:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; min-height: 110px; }
.field-error { color: var(--danger); font-size: 14px; margin-top: -6px; }

.primary, .ghost, .text {
  min-height: 48px; border-radius: var(--r-btn); padding: 10px 16px; font-weight: 700; font-size: 16px;
}
.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border: 0;
  box-shadow: 0 6px 16px -8px color-mix(in srgb, var(--accent) 80%, transparent);
}
.primary:active { box-shadow: 0 2px 6px -4px color-mix(in srgb, var(--accent) 80%, transparent); }
.ghost { background: var(--surface-2); border: 1px solid var(--line); }
.text { background: transparent; border: 0; color: var(--accent); padding-inline: 8px; }
.danger { color: var(--danger); }
.primary.danger-fill { background: var(--danger); color: #fff; box-shadow: none; }
.small { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* today */
.today { gap: 14px; }
.today-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.today-kcal { display: flex; align-items: baseline; gap: 6px; }
.today-kcal b { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.today-kcal span { color: var(--muted); font-size: 14px; }
.bar { position: relative; height: 10px; border-radius: 6px; background: var(--bg-2); overflow: hidden; }
.bar .band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--ok) 22%, transparent); }
.bar .fill {
  position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transform-origin: left; animation: grow 260ms cubic-bezier(.2, .8, .2, 1) both;
}
.bar .fill.still { animation: none; }
.bar.ok .fill { background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 70%, var(--teal)), var(--ok)); }
.bar.over .fill { background: var(--warn); }
@keyframes grow { from { transform: scaleX(0); } }
.today-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.metric { display: grid; gap: 6px; min-width: 0; }
.metric .m-top { display: flex; justify-content: space-between; gap: 6px; font-size: 13px; color: var(--muted); }
.metric .m-top b { color: var(--ink); font-size: 15px; }
.metric .bar { height: 6px; }
.today-foot { font-size: 12px; color: var(--muted); }

/* workout */
.sheet-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sheet-btn {
  text-align: left; background: var(--surface); border: 0; border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 14px; min-height: 100px; display: grid; gap: 4px; align-content: start; position: relative; overflow: hidden;
}
.sheet-btn::after {
  content: ""; position: absolute; right: -18px; top: -18px; width: 64px; height: 64px; border-radius: 50%;
  background: var(--accent-soft);
}
.sheet-btn b { font-size: 20px; position: relative; z-index: 1; }
.sheet-btn span { color: var(--muted); font-size: 13px; position: relative; z-index: 1; }
.quick { border: 1.5px dashed color-mix(in srgb, var(--teal) 55%, var(--line)); box-shadow: none; background: color-mix(in srgb, var(--teal-soft) 45%, var(--surface)); }
.quick h2 { display: flex; align-items: center; gap: 8px; }
.quick .primary { background: linear-gradient(135deg, var(--teal), color-mix(in srgb, var(--teal) 70%, #6be3c6)); box-shadow: 0 6px 16px -8px var(--teal); color: #fff; }

.w-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.w-head > div { min-width: 0; }
.w-head > button { flex: none; }
.w-head .meta { color: var(--muted); font-size: 14px; }

.ex { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 12px; display: grid; gap: 8px; min-width: 0; }
.ex-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ex-name { font-size: 15px; font-weight: 700; line-height: 1.3; }
.ex-head .meta, .ex .meta { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.ex-tools .ghost.small { min-height: 36px; padding: 4px 10px; font-size: 13px; }
.ex-tools .icon-btn { min-width: 40px; min-height: 40px; }
.ex-close { justify-self: center; min-height: 40px; color: var(--muted); }
.ex.fold { cursor: pointer; gap: 8px; padding: 12px 14px; }
.ex.fold:active { transform: scale(.99); }
.fold-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chev { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg) translate(-2px, -2px); flex: none; }
.routine { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 8px; display: grid; gap: 0; }
.routine .tgl { border-radius: var(--r-btn); }
details.how summary { min-height: 44px; display: flex; align-items: center; padding: 0 8px; font-size: 14px; font-weight: 650; color: var(--teal); cursor: pointer; }
details.how ol { margin: 0 0 8px; padding: 0 8px 0 28px; display: grid; gap: 6px; font-size: 14px; }
details.how b { font-weight: 650; }
details.how .dose { font-family: var(--mono); color: var(--accent); font-size: 13px; }
.tgl > span { white-space: nowrap; }
.tgl b { text-align: right; }
.last { font-size: 14px; color: var(--teal); font-weight: 600; }
.cues { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink); display: grid; gap: 2px; }
.alt-note { font-size: 13px; color: var(--muted); }
.sets { display: grid; gap: 6px; }
.set { display: grid; grid-template-columns: 22px minmax(0, 1fr) 16px minmax(0, 1fr) 44px; gap: 6px; align-items: center; }
.set .num { font-family: var(--mono); color: var(--muted); font-size: 14px; text-align: right; }
.set .x { color: var(--muted); text-align: center; }
.set input { min-height: 48px; padding: 8px 10px; text-align: center; font-size: 18px; font-weight: 600; }
.set .bw { color: var(--muted); font-size: 14px; text-align: center; }
.set .del { min-height: 44px; border: 0; background: transparent; color: var(--muted); font-size: 18px; border-radius: var(--r-btn); }
/* sets: done chips + one current row + progress */
.sbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.sbar .bar { height: 12px; }
.sbar .fill { animation: none; transition: width 240ms cubic-bezier(.2, .8, .2, 1), background-color 160ms; background: linear-gradient(90deg, color-mix(in srgb, var(--ok) 70%, var(--teal)), var(--ok)); }
.sbar .bar { height: 10px; }
.sbar .scount { font-size: 14px; font-weight: 750; color: var(--muted); min-width: 52px; text-align: right; }
.sbar.ok .scount { color: var(--ok); }
.sbar.over .fill { background: var(--danger); }
.sbar.over .scount { color: var(--danger); }
.sbar.shake { animation: shake 320ms cubic-bezier(.36, .07, .19, .97) both; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.done-sets { display: flex; flex-wrap: wrap; gap: 6px; }
.dset {
  min-height: 40px; padding: 6px 12px; border-radius: var(--r-btn); border: 0; font-size: 15px; font-weight: 700;
  background: color-mix(in srgb, var(--ok) 14%, var(--surface)); color: var(--ok);
}
.dset.extra { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); color: var(--danger); }
.dset.pop { animation: pop-set 300ms cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pop-set {
  0% { transform: scale(.4); opacity: 0; box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }
  60% { transform: scale(1.08); opacity: 1; box-shadow: 0 0 0 8px color-mix(in srgb, var(--ok) 0%, transparent); }
  100% { transform: scale(1); }
}
.cur { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 8px; }
.cur .done-btn { flex: 1 0 100%; }
.cur .x { color: var(--muted); font-size: 15px; }
.stepper { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cur .stepper input {
  width: 66px; height: 36px; min-height: 0; padding: 0 6px; text-align: center;
  font-size: 18px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--ink);
  background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--ok) 30%, var(--line)); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(28, 25, 23, .06);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.cur .stepper input:focus { border-color: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.cur .stepper input::placeholder { color: color-mix(in srgb, var(--muted) 45%, transparent); font-weight: 500; }
.cur .stepper input[type="text"]:not([inputmode]) { width: 120px; font-size: 15px; font-weight: 650; text-align: left; padding: 0 10px; }
.steps { display: flex; flex-direction: column; gap: 2px; flex: none; }
.steps button {
  position: relative; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 0;
  background: color-mix(in srgb, var(--ok) 14%, var(--surface)); color: var(--ok);
  font-size: 13px; font-weight: 800; line-height: 1; display: grid; place-items: center; touch-action: manipulation;
}
/* the visible circle is small, the tap target is not */
.steps button::after { content: ""; position: absolute; inset: -8px -12px; }
.steps button:first-child::after { bottom: -1px; }
.steps button:last-child::after { top: -1px; }
.steps button:active { transform: scale(.85); background: var(--ok); color: #fff; }
.stepper .u { flex: none; font-size: 13px; font-weight: 650; color: var(--muted); }
.load-fixed { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-height: 32px; }
.load-fixed b { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.unit { position: relative; display: block; min-width: 0; }
.unit input { width: 100%; text-align: right; padding-left: 10px; padding-right: 48px; }
.cur .unit input { text-align: right; }
.unit.u-reps input { padding-right: 58px; }
.unit input:not(.u-reps *) { padding-right: 42px; }
.unit > span {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%); pointer-events: none;
  font-size: 13px; font-weight: 650; color: var(--muted);
}
.unit input::placeholder { color: color-mix(in srgb, var(--muted) 55%, transparent); }
.cur .x { color: var(--muted); text-align: center; }
.cur .bw { color: var(--muted); font-size: 14px; text-align: center; }
.done-btn {
  min-height: 46px; padding: 0 18px; border: 0; border-radius: var(--r-btn); font-weight: 800; font-size: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ok) 80%, var(--teal)), var(--ok)); color: #fff;
  box-shadow: 0 6px 14px -8px var(--ok);
}
.done-btn.quiet { background: var(--bg-2); color: var(--muted); box-shadow: none; }
.nudge { animation: shake 280ms both; border-color: var(--accent) !important; }
.ex.full { box-shadow: var(--shadow), inset 0 0 0 1.5px color-mix(in srgb, var(--ok) 55%, transparent); }
.ex.over { box-shadow: var(--shadow), inset 0 0 0 1.5px color-mix(in srgb, var(--danger) 45%, transparent); }
.ex-tools { display: flex; gap: 4px; align-items: center; flex: none; }
.icon-btn { min-width: 44px; min-height: 44px; border: 0; border-radius: var(--r-btn); background: var(--surface-2); color: var(--muted); font-size: 17px; }
.tgl {
  width: 100%; min-height: 54px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 0 16px; border: 1.5px dashed var(--line); border-radius: var(--r-btn); background: var(--surface);
  font-size: 16px; font-weight: 750; text-align: left;
}
.tgl b { font-size: 13px; font-weight: 600; color: var(--muted); }
.tgl[aria-pressed="true"] {
  border: 1.5px solid transparent; color: #fff;
  background: linear-gradient(135deg, color-mix(in srgb, var(--ok) 80%, var(--teal)), var(--ok));
  animation: pop 160ms cubic-bezier(.2, .8, .2, 1) both;
}
.tgl[aria-pressed="true"] b { color: rgba(255, 255, 255, .9); }
.ed-body { display: grid; gap: 10px; }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; gap: 10px; }
.ed-field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.ed-field input { font-size: 18px; font-weight: 700; color: var(--ink); }
.modal-box h3 { font-size: 18px; }
.modal-actions .grow { display: none; }
#editor .modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#editor .modal-actions .ghost, #editor .modal-actions .primary { width: 100%; }
#editor #edDel { grid-column: 1 / -1; order: 3; justify-self: center; }
.sets-box { display: grid; gap: 8px; }

.seg { display: flex; background: var(--bg-2); border-radius: var(--r-btn); padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 40px; border: 0; background: transparent; font-size: 14px; font-weight: 600; border-radius: 6px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

details.ref { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 0 16px; }
details.ref summary { min-height: 52px; display: flex; align-items: center; font-weight: 700; cursor: pointer; }
details.ref ol, details.ref ul { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
details.ref b { font-weight: 650; }
details.ref .dose { font-family: var(--mono); color: var(--accent); font-size: 13px; }

/* history */
.entry { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 12px 14px; display: grid; gap: 6px; min-width: 0; }
.entry.chat { background: var(--surface-2); box-shadow: none; border: 1px solid var(--line); }
.e-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.e-top .kind { font-weight: 750; }
.e-top time { color: var(--muted); }
.pill { margin-left: auto; font-size: 12px; font-weight: 650; padding: 3px 8px; border-radius: 6px; background: var(--bg-2); color: var(--muted); }
.pill.sent { color: var(--ok); }
.pill.wait { color: var(--accent); background: var(--accent-soft); }
.pill.done { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.pill.src { color: var(--teal); background: var(--teal-soft); }
.e-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.reply { font-size: 14px; background: var(--accent-soft); border-radius: var(--r-btn); padding: 8px 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.day-sep { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 2px 0; }

/* bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--line);
  padding: 4px env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
.tabs button {
  min-height: 60px; border: 0; background: transparent; font-size: 12px; font-weight: 650; color: var(--muted);
  display: grid; justify-items: center; align-content: center; gap: 3px;
}
.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform var(--fast); }
.tabs button[aria-current="page"] { color: var(--accent); }
.tabs button[aria-current="page"] svg { transform: translateY(-1px) scale(1.08); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px; font-weight: 600;
  max-width: calc(100vw - 32px); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .5);
  animation: toastIn 140ms cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px) scale(.98); } }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .45); display: grid; place-items: center; padding: 16px; animation: fade 100ms ease-out both; }
.modal-box { background: var(--surface); border-radius: var(--r-card); padding: 20px; width: min(420px, 100%); display: grid; gap: 16px; box-shadow: 0 20px 50px -12px rgba(0, 0, 0, .5); animation: pop 140ms cubic-bezier(.2, .8, .2, 1) both; }
.modal-box p { margin: 0; white-space: pre-line; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } }

/* days */
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.summary div, .metrics div { display: grid; gap: 2px; min-width: 0; }
.lbl { font-size: 12px; color: var(--muted); }
.summary b { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.summary .good { color: var(--ok); }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 10px; font-family: var(--mono); }
.chart .avg { fill: none; stroke: var(--muted); stroke-width: 2.6; stroke-linecap: round; }
.chart .avg.down { stroke: var(--ok); }
.chart .avg.up { stroke: var(--danger); }
.chart .area { fill: url(#avgFill); }
.chart .pt { fill: var(--muted); opacity: .75; }
.chart .pt.down { fill: var(--ok); }
.chart .pt.up { fill: var(--danger); }
.chart .pt.last { opacity: 1; stroke: var(--surface); stroke-width: 1.5; }
.day .dw small.down { color: var(--ok); font-weight: 700; }
.day .dw small.up { color: var(--danger); font-weight: 700; }
.day.current { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; margin-right: 6px; vertical-align: middle; }
.legend .dot { width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(90deg, var(--ok) 50%, var(--danger) 50%); }
.legend .ln { width: 16px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--ok) 50%, var(--danger) 50%); }
.day { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow); min-width: 0; overflow: hidden; }
.day-head { width: 100%; display: grid; grid-template-columns: 1.1fr 1fr 1fr 1fr; gap: 6px; align-items: baseline; text-align: left;
  background: transparent; border: 0; padding: 12px 14px; min-height: 58px; font-size: 16px; font-weight: 700; }
.day-head:active { transform: none; background: var(--surface-2); }
.day-head small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--warn); }
.day-body { border-top: 1px solid var(--line); padding: 12px 14px; display: grid; gap: 10px; min-width: 0; animation: rise 140ms cubic-bezier(.2, .8, .2, 1) both; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.metrics b { font-size: 16px; }
.metrics .ok b { color: var(--ok); }
.metrics .bad b { color: var(--warn); }
.totals { width: 100%; border-collapse: collapse; font-size: 14px; }
.totals td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.totals td:nth-child(2) { text-align: right; font-weight: 750; }
.totals tr.ok td:first-child, .totals tr.bad td:first-child { color: var(--ink); }
table.meal th:first-child { width: 52%; }
.totals td:nth-child(3) { text-align: right; color: var(--muted); font-size: 12px; }
.totals tr.ok td:nth-child(2) { color: var(--ok); }
.totals tr.bad td:nth-child(2) { color: var(--warn); }
.day-body h4 { margin: 4px 0 0; font-size: 14px; }
.tbl { overflow-x: auto; min-width: 0; }
table.meal { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
table.meal th { font-size: 11px; font-weight: 650; color: var(--muted); text-align: right; padding: 4px; border-bottom: 1px solid var(--line); }
table.meal th:first-child, table.meal td:first-child { text-align: left; }
table.meal td { padding: 5px 4px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: top; }
table.meal td:first-child { overflow-wrap: anywhere; }
table.meal td small { display: block; color: var(--muted); font-size: 11px; }
.tlog { margin: 0; padding-left: 18px; font-size: 14px; }

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

/* searchable exercise picker */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; max-height: 248px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  padding: 4px; display: grid; gap: 2px; overscroll-behavior: contain; touch-action: pan-y;
}
.combo-list button {
  min-height: 44px; padding: 8px 12px; border: 0; border-radius: 8px; background: transparent;
  text-align: left; font-size: 15px; color: var(--ink);
}
.combo-list button:active { transform: none; background: var(--bg-2); }
.combo-list mark { background: color-mix(in srgb, var(--ok) 22%, transparent); color: inherit; border-radius: 3px; }

.bands { display: flex; gap: 4px; flex: none; }
.bands button {
  width: 34px; height: 36px; padding: 0; border-radius: 10px; font-size: 16px; font-weight: 750; font-variant-numeric: tabular-nums;
  background: var(--surface); color: var(--muted); border: 1.5px solid color-mix(in srgb, var(--ok) 30%, var(--line));
  touch-action: manipulation; transition: background var(--fast), color var(--fast);
}
.bands button[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.ed-bands button { width: 44px; height: 44px; }
