/* Life — dark-first, sporty. One bold accent (volt) plus a colour per muscle group. */

:root {
  --bg: #0b0b0d;
  --surface: #151518;
  --surface-2: #1d1d22;
  --line: rgba(255, 255, 255, 0.07);
  --text: #f4f4f5;
  --muted: #8b8b95;
  --faint: #55555e;
  --accent: #d4ff3a;          /* volt */
  --accent-ink: #d4ff3a;      /* accent used as text */
  --on-accent: #0b0b0d;
  --danger: #ff5a5f;

  --push: #ff7a50;
  --pull: #4cb8ff;
  --legs: #b18cff;
  --core: #ffc53d;
  --cardio: #3ddc97;
  --other: #8b8b95;

  --radius: 22px;
  --radius-sm: 14px;
  --tabbar-h: 64px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f2f5;
    --surface: #ffffff;
    --surface-2: #f1f1f4;
    --line: rgba(0, 0, 0, 0.07);
    --text: #111114;
    --muted: #6b6b75;
    --faint: #a9a9b2;
    --accent: #d4ff3a;
    --accent-ink: #4f7a00;
    --push: #f2602f;
    --pull: #1f97e6;
    --legs: #8c5cf6;
    --core: #e0a100;
    --cardio: #13b072;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: calc(env(safe-area-inset-top) + 18px) 16px calc(env(safe-area-inset-bottom) + var(--tabbar-h) + 28px);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 560px; margin: 0 auto; }
.num { font-variant-numeric: tabular-nums; }

/* Group colour hooks: set --g on any element. */
.g-push { --g: var(--push); } .g-pull { --g: var(--pull); } .g-legs { --g: var(--legs); }
.g-core { --g: var(--core); } .g-cardio { --g: var(--cardio); } .g-rest, .g-other { --g: var(--other); }

/* ---------- headings ---------- */
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.page-title { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin: 2px 0 18px; }
.section-label { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 26px 4px 10px; display: flex; align-items: center; gap: 8px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; border: 1px solid var(--line); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }

/* ---------- week strip ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 14px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.day .dow { font-size: 11px; font-weight: 600; color: var(--faint); }
.day .dot {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); position: relative; overflow: hidden;
}
.day .dot .fill { position: absolute; inset: 0; }
.day.today .dow { color: var(--text); }
.day.today .dot { border: 2px solid var(--text); }
.day .dot svg { position: relative; width: 16px; height: 16px; color: var(--bg); }

/* ---------- hero (today's focus) ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 28px; padding: 22px 20px 20px; margin-bottom: 12px;
  background:
    radial-gradient(120% 80% at 100% 0%, color-mix(in srgb, var(--g) 42%, transparent) 0%, transparent 60%),
    radial-gradient(90% 60% at 0% 100%, color-mix(in srgb, var(--g) 14%, transparent) 0%, transparent 70%),
    var(--surface);
  border: 1px solid color-mix(in srgb, var(--g) 25%, var(--line));
}
.hero .focus { font-size: 52px; line-height: 1; font-weight: 850; letter-spacing: -0.045em; margin: 8px 0 10px; text-transform: capitalize; }
.hero .reason { color: color-mix(in srgb, var(--text) 75%, transparent); font-size: 15px; max-width: 34ch; }
.progress { margin-top: 18px; }
.progress .bar { height: 6px; border-radius: 99px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; }
.progress .bar span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.progress .meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-top: 8px; }
.progress .meta b { color: var(--text); font-weight: 700; }

/* ---------- exercise target rows ---------- */
.targets { list-style: none; margin: 0; padding: 0; }
.targets li { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.targets li:first-child { border-top: 0; padding-top: 4px; }
.targets .pip { width: 10px; height: 10px; border-radius: 50%; background: var(--g, var(--other)); }
.targets .name { font-weight: 650; }
.targets .note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.targets .nums { text-align: right; font-variant-numeric: tabular-nums; }
.targets .nums .big { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.targets .nums .unit { font-size: 13px; color: var(--muted); }

/* ---------- recovery grid ---------- */
.recovery { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.rec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 8px; text-align: center; }
.rec .label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--g); }
.rec .val { font-size: 17px; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }
.rec .val.none { color: var(--faint); font-weight: 600; font-size: 15px; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
input, textarea, select {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming in */
  color: var(--text); background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 12px 14px;
  outline: none; transition: border-color 0.15s, background 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: color-mix(in srgb, var(--accent-ink) 70%, transparent); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 84px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

/* ---------- buttons ---------- */
button {
  font: inherit; font-weight: 650; border: 0; border-radius: 14px; padding: 14px 16px; min-height: 48px;
  background: var(--surface-2); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.08s ease, opacity 0.15s;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; }
button svg { width: 18px; height: 18px; flex: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); width: 100%; font-size: 17px; font-weight: 750; min-height: 54px; border-radius: 16px; }
.btn-block { width: 100%; }
.btn-text { background: transparent; color: var(--muted); min-height: 40px; padding: 8px 10px; }
.btn-icon { background: transparent; color: var(--faint); min-height: 36px; width: 36px; padding: 0; border-radius: 10px; }
.btn-icon:active { background: var(--surface-2); }
.actions { display: flex; gap: 10px; margin-top: 16px; }
.actions > * { flex: 1; }

/* ---------- Claude card ---------- */
.claude-head { display: flex; align-items: center; gap: 10px; }
.claude-badge {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #e8845b, #c4553a); color: #fff; flex: none;
}
.claude-badge svg { width: 18px; height: 18px; }
.claude-head h2 { font-size: 18px; margin: 0; }
.plan-result { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.plan-result .plan-title { display: flex; align-items: baseline; gap: 10px; }
.plan-result .plan-title h3 { margin: 0; font-size: 26px; letter-spacing: -0.03em; font-weight: 800; }
.plan-result .summary { margin: 8px 0 12px; color: color-mix(in srgb, var(--text) 80%, transparent); }
.warning { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }

/* ---------- log ---------- */
.title-input { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; background: transparent; padding: 0; border-radius: 0; border: 0; }
.title-input:focus { border: 0; }
.when-pill { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 18px; }
.when-pill input { width: auto; padding: 8px 12px; font-size: 15px; border-radius: 99px; color: var(--muted); }

.ex-card { padding: 16px 14px 12px; }
.ex-head { display: flex; align-items: center; gap: 10px; }
.ex-head .pip { width: 10px; height: 10px; border-radius: 50%; background: var(--g, var(--other)); flex: none; margin-left: 4px; }
.ex-head input { flex: 1; font-size: 18px; font-weight: 700; background: transparent; padding: 6px 4px; border-radius: 8px; }
.ex-hint { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px 4px; font-size: 13px; color: var(--muted); }
.ex-hint .target { color: var(--accent-ink); font-weight: 650; }

.sets { display: grid; grid-template-columns: 34px 1fr 1fr 48px; gap: 8px; align-items: center; margin-top: 10px; }
.sets .th { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); text-align: center; }
.sets .idx { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); background: var(--surface-2); justify-self: center; }
.sets input { text-align: center; font-weight: 700; font-size: 18px; padding: 10px 6px; font-variant-numeric: tabular-nums; }
.check {
  width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 12px; justify-self: center;
  background: var(--surface-2); color: var(--faint);
}
.check.on { background: var(--accent); color: var(--on-accent); }
.sets input.done { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); }
.set-tools { display: flex; gap: 6px; margin-top: 10px; }
.set-tools button { flex: 1; min-height: 40px; padding: 8px; font-size: 14px; color: var(--muted); }

.add-ex { width: 100%; border: 1.5px dashed color-mix(in srgb, var(--text) 18%, transparent); background: transparent; color: var(--muted); min-height: 56px; border-radius: var(--radius); }

.segmented { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 4px -2px 0; padding: 2px; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { flex: none; min-height: 38px; padding: 8px 14px; border-radius: 99px; font-size: 14px; background: var(--surface-2); color: var(--muted); }
.segmented button.on { background: var(--text); color: var(--bg); }

/* ---------- history ---------- */
.hist-day { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 22px 4px 10px; }
.hist-item { position: relative; padding: 16px 16px 16px 20px; overflow: hidden; }
.hist-item::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--g, var(--other)); }
.hist-top { display: flex; align-items: flex-start; gap: 8px; }
.hist-top .t { flex: 1; min-width: 0; }
.hist-top h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.hist-top .time { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stats { display: flex; gap: 18px; margin: 12px 0 10px; }
.stat .v { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ex-lines { display: grid; gap: 4px; font-size: 14px; }
.ex-lines div { display: flex; justify-content: space-between; gap: 10px; }
.ex-lines span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.big-val { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.big-val small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 4px; }

.empty { text-align: center; padding: 40px 20px; }
.empty svg { width: 44px; height: 44px; color: var(--faint); margin-bottom: 10px; }

/* ---------- tab bar ---------- */
.tabs {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px); height: var(--tabbar-h);
  display: flex; max-width: 520px; margin: 0 auto; padding: 6px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--line); border-radius: 24px; z-index: 5;
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--faint); text-decoration: none; border-radius: 18px;
}
.tabs a svg { width: 22px; height: 22px; }
.tabs a.active { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.tabs a.active svg { color: var(--accent-ink); }

/* ---------- misc ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + var(--tabbar-h) + 24px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 99px; font-size: 15px; font-weight: 600;
  max-width: 90vw; z-index: 10; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 220px; border-radius: 28px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.error { color: var(--danger); }
.fade-in { animation: fade 0.25s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in, .skeleton { animation: none; } button:active { transform: none; } }

/* Split picker: wrap instead of scroll, selected chips take their group colour. */
#s-split { flex-wrap: wrap; overflow: visible; }
#s-split button.on { background: var(--g); color: #0b0b0d; }
