/* FitCoach. Dark, one cyan accent, built for a phone held in a sweaty hand. */

:root {
  --bg: oklch(0.13 0.012 230);
  --surface: oklch(0.175 0.014 230);
  --surface-2: oklch(0.215 0.016 230);
  --border: oklch(0.28 0.016 230);
  --ink: oklch(0.94 0.005 230);
  --ink-2: oklch(0.74 0.012 230);
  --muted: oklch(0.58 0.014 230);
  --accent: oklch(0.8 0.125 200);
  --accent-dim: oklch(0.45 0.08 200);
  --on-accent: oklch(0.16 0.02 230);
  --good: oklch(0.8 0.14 150);
  --warn: oklch(0.82 0.12 80);
  --bad: oklch(0.72 0.16 25);
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* z scale: sheet backdrop < sheet < toast */
  --z-backdrop: 30; --z-sheet: 40; --z-toast: 50;
}

* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
.num { font-variant-numeric: tabular-nums; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 92px);
}

/* ---------- tab bar ---------- */
#tabbar[hidden] { display: none; }
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: center; gap: 4px;
  background: color-mix(in oklab, var(--bg) 82%, black);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 12px calc(env(safe-area-inset-bottom) + 6px);
}
.tab {
  flex: 0 1 120px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 10px;
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  transition: color 150ms var(--ease);
}
.tab.active { color: var(--accent); }
.tab:active { transform: translateY(1px); }

/* ---------- shared ---------- */
.screen-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.screen-sub { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.section-h { font-size: 13px; font-weight: 600; color: var(--muted); margin: 24px 0 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 12px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 14px 20px;
  border-radius: var(--radius);
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: 17px;
  transition: transform 120ms var(--ease), opacity 150ms var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; }
.btn.ghost { background: var(--surface-2); color: var(--ink); border: 1px solid var(--border); }
.btn.small { min-height: 44px; font-size: 15px; width: auto; padding: 10px 16px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 13px 14px; font-size: 17px; color: var(--ink); width: 100%;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; }

/* ---------- login ---------- */
.login-wrap { min-height: 78dvh; display: grid; place-content: center; }
.login-wrap .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; color: var(--accent); font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.login-wrap form { width: min(320px, 86vw); }

/* ---------- today ---------- */
.day-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }
.day-date { color: var(--muted); font-size: 13px; font-weight: 600; }

.checkin { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkin .card { margin: 0; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; margin-top: 2px; }
.stat-value small { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.stat-note { font-size: 12px; color: var(--ink-2); margin-top: 4px; }

.weigh-entry { display: flex; gap: 8px; margin-top: 10px; }
.weigh-entry input {
  width: 0; flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font-size: 17px;
}
.weigh-entry input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.nutri-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.nutri-btn {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 8px;
  background: var(--surface-2); font-weight: 600; font-size: 14px;
  display: grid; gap: 2px; justify-items: center;
  transition: background 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease);
}
.nutri-btn span { font-size: 11px; color: var(--muted); font-weight: 600; }
.nutri-btn.hit { background: color-mix(in oklab, var(--good) 16%, var(--surface)); border-color: var(--good); }
.nutri-btn.hit span { color: var(--good); }
.nutri-btn.miss { background: color-mix(in oklab, var(--bad) 12%, var(--surface)); border-color: var(--bad); }
.nutri-btn.miss span { color: var(--bad); }

/* exercise rows */
.ex-row {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center;
  width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px 10px 10px; margin-top: 10px;
  transition: background 150ms var(--ease);
}
.ex-row:active { background: var(--surface-2); }
.ex-thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: #fff; }
.ex-name { font-weight: 650; font-size: 15px; }
.ex-rx { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.ex-rx b { color: var(--accent); font-weight: 700; }
.ex-dots { display: flex; gap: 4px; }
.ex-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); }
.ex-dots i.done { background: var(--good); border-color: var(--good); }
.ex-done-check { color: var(--good); font-weight: 700; font-size: 13px; }

.rest-card { text-align: center; padding: 36px 20px; }
.rest-card h2 { font-size: 20px; margin-bottom: 6px; }
.rest-card p { color: var(--ink-2); font-size: 14px; }

/* ---------- exercise sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgb(0 0 0 / 0.5); z-index: var(--z-backdrop);
  opacity: 0; transition: opacity 200ms var(--ease);
}
.sheet-backdrop.show { opacity: 1; }
.sheet {
  position: fixed; inset: 0; z-index: var(--z-sheet);
  background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateY(24px); opacity: 0;
  transition: transform 240ms var(--ease), opacity 200ms var(--ease);
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 24px);
}
.sheet.show { transform: none; opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-backdrop { transition: none; }
}
.sheet-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-close {
  min-width: 44px; min-height: 44px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-content: center; font-size: 15px; font-weight: 600; color: var(--ink-2);
}
.demo { border-radius: var(--radius); overflow: hidden; background: #fff; position: relative; }
.demo img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; }
.demo .frame-tag {
  position: absolute; right: 10px; bottom: 10px;
  background: rgb(0 0 0 / 0.55); color: #fff; font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 999px;
}
.rx-strip { display: flex; gap: 10px; margin-top: 12px; }
.rx-box { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.rx-box .stat-value { font-size: 22px; }
.plates-line { margin-top: 10px; color: var(--accent); font-size: 14px; font-weight: 600; }
.warmup-list { margin-top: 4px; }
.warmup-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); color: var(--ink-2); font-size: 14px; list-style: none; }
.warmup-list li:last-child { border-bottom: 0; }
.warmup-list .w { color: var(--ink); font-weight: 600; }

.setgrid { margin-top: 8px; }
.set-row {
  display: grid; grid-template-columns: 34px 1fr 1fr 56px; gap: 8px; align-items: center;
  padding: 8px 0;
}
.set-row .set-no { color: var(--muted); font-weight: 700; font-size: 14px; }
.stepper { display: grid; grid-template-columns: 40px 1fr 40px; align-items: stretch; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.stepper button { font-size: 20px; font-weight: 600; color: var(--ink-2); min-height: 46px; }
.stepper button:active { background: var(--border); }
.stepper .val { display: grid; place-content: center; font-weight: 700; font-size: 16px; }
.stepper .val small { font-size: 10px; color: var(--muted); text-align: center; font-weight: 600; }
.log-btn {
  min-height: 46px; border-radius: 10px; font-weight: 700; font-size: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-2);
  transition: background 150ms var(--ease), color 150ms var(--ease);
}
.log-btn.done { background: color-mix(in oklab, var(--good) 18%, var(--surface)); border-color: var(--good); color: var(--good); }

.coach-note {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in oklab, var(--accent) 10%, var(--surface));
  border: 1px solid var(--accent-dim);
  color: var(--ink); font-size: 14px;
}
.instructions { margin-top: 8px; color: var(--ink-2); font-size: 14px; line-height: 1.55; }
.instructions li { margin: 0 0 8px 18px; }
.muscle-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.muscle-tags i { font-style: normal; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }

/* ---------- summary ---------- */
.decision { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); }
.decision:last-child { border-bottom: 0; }
.decision .tag { flex: 0 0 auto; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; margin-top: 1px; }
.tag.up { background: color-mix(in oklab, var(--good) 18%, var(--surface)); color: var(--good); }
.tag.hold, .tag.calibrated { background: var(--surface-2); color: var(--ink-2); }
.tag.hold-miss { background: color-mix(in oklab, var(--warn) 16%, var(--surface)); color: var(--warn); }
.tag.deload { background: color-mix(in oklab, var(--bad) 16%, var(--surface)); color: var(--bad); }
.decision .d-name { font-weight: 650; font-size: 14px; }
.decision .d-note { color: var(--ink-2); font-size: 13px; }

/* ---------- progress ---------- */
.chart-card svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 5px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.stat-row .card { margin: 0; padding: 12px; }
.adherence-grid { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; margin-top: 10px; }
.adherence-grid i { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); }
.adherence-grid i.full { background: var(--good); border-color: var(--good); }
.adherence-grid i.half { background: color-mix(in oklab, var(--good) 40%, var(--surface-2)); border-color: color-mix(in oklab, var(--good) 40%, var(--border)); }
.adherence-grid i.miss { background: color-mix(in oklab, var(--bad) 30%, var(--surface-2)); border-color: color-mix(in oklab, var(--bad) 35%, var(--border)); }
.lift-row { display: grid; grid-template-columns: 1fr auto 84px; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.lift-row:last-child { border-bottom: 0; }
.lift-name { font-weight: 650; font-size: 14px; }
.lift-sub { color: var(--muted); font-size: 12px; }
.lift-w { font-weight: 700; font-size: 16px; text-align: right; }
.lift-w small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.spark { width: 84px; height: 30px; }

/* ---------- plan ---------- */
.plan-day { margin-top: 12px; }
.plan-day summary {
  list-style: none; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
}
.plan-day summary::-webkit-details-marker { display: none; }
.plan-day[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.plan-day .pd-title { font-weight: 700; }
.plan-day .pd-sub { color: var(--muted); font-size: 12px; }
.plan-day .pd-dow { color: var(--accent); font-size: 12px; font-weight: 700; }
.plan-items { border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: 4px 14px; background: color-mix(in oklab, var(--surface) 60%, var(--bg)); }
.plan-item { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.plan-item:last-child { border-bottom: 0; }
.plan-item .pi-rx { color: var(--muted); white-space: nowrap; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px);
  transform: translate(-50%, 8px); z-index: var(--z-toast);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; white-space: nowrap; color: var(--ink);
  transform: translate(-50%, -110%);
}
