:root {
  /* Household palette — same values as Segments and the meal planner. */
  --bg: #14161b; --card: #1a1d23; --card2: #21252d;
  --line: #2b303a; --line-soft: #23272f;
  --ink: #d7dbe3; --dim: #a8aeba; --muted: #7c8494;
  --accent: #7c83d9; --accent2: #7c83d9; --accent-hover: #8f95e2; --accent-soft: rgba(124, 131, 217, .14);
  --grad: linear-gradient(var(--accent), var(--accent)); /* flat: kept as a token for background shorthands */
  --ok: #6fbf8e; --warn: #cfa46a; --err: #d98b8b; --radius: 12px;
  --mp: #6f9be8; --ms: #9d86e0; /* muscle figure: primary / secondary */
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; background: var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.view { max-width: 560px; margin: 0 auto; padding: 18px 16px calc(120px + env(safe-area-inset-bottom)); }
#view-login { display: flex; min-height: 100dvh; align-items: center; justify-content: center; padding-bottom: 18px; }

/* ---------- buttons & inputs ---------- */
.btn { border: none; border-radius: 8px; padding: 14px 20px; font: inherit; font-weight: 700;
  cursor: pointer; transition: transform .12s, filter .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.wide { width: 100%; }
.ghost-sm { background: var(--card); color: var(--muted); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer; }
input, select { width: 100%; background: var(--card2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 11px 12px; font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent2); outline-offset: -1px; }
input::placeholder { color: var(--muted); }

/* ---------- login ---------- */
.login-box { width: 100%; max-width: 360px; text-align: center; animation: rise .5s ease both; }
.logo { font-size: 26px; font-weight: 800; }
.logo span { color: var(--accent); }
.tagline { color: var(--muted); margin: 6px 0 22px; }
.profiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 18px; }
.profile { background: var(--card); border: 1px solid var(--line); color: var(--ink);
  border-radius: var(--radius); padding: 18px 10px 14px; font: inherit; font-weight: 700;
  cursor: pointer; transition: transform .15s, border-color .15s; }
.profile:active { transform: scale(.96); }
.profile.on { border-color: var(--accent); background: var(--accent-soft); }
.avatar { display: block; width: 58px; height: 58px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 24px; font-weight: 800; line-height: 58px; }
.avatar.a { background: #e07bb0; }
.pw-label { font-size: 14px; color: var(--muted); margin: 4px 0 8px; }
#pwArea input { margin-bottom: 10px; }
.err { color: var(--err); font-size: 14px; min-height: 20px; margin: 8px 0 0; }

/* ---------- layout / header ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.top .center { text-align: center; flex: 1; }
.top h2 { margin: 0; font-size: 18px; }
.hello { font-size: 22px; font-weight: 800; margin: 0; }
.date { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.glow { position: relative; overflow: hidden; animation: rise .5s ease both; }
.glow::before { content: none; }
.suggest-head { display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; position: relative; z-index: 1; }
.suggest-kicker { text-transform: uppercase; letter-spacing: .12em; font-size: 11px;
  color: var(--accent); margin: 0; font-weight: 700; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
  color: #fff; font-weight: 800; font-size: 15px; display: grid; place-items: center; flex: none; }
.avatar-sm.a { background: #e07bb0; }
.suggest h2 { margin: 0 0 6px; font-size: 22px; }
.suggest p { margin: 0 0 14px; font-size: 14px; }
.section-h { font-size: 13px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); margin: 24px 0 10px; }

/* ---------- track tab ---------- */
.day-list { display: flex; flex-direction: column; gap: 8px; }
.day-item { display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; cursor: pointer;
  font: inherit; color: var(--ink); text-align: left; transition: transform .12s; }
.day-item:active { transform: scale(.98); }
.day-num { width: 34px; height: 34px; border-radius: 8px; background: var(--card2);
  display: grid; place-items: center; font-weight: 800; color: var(--accent); flex: none; }
.day-item .lab { flex: 1; font-weight: 600; font-size: 15px; }
.day-item .sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.done-tick { color: var(--ok); font-weight: 800; }
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.wd { font: inherit; width: 100%; cursor: pointer; text-align: center; padding: 10px 0 8px; border-radius: 8px; background: var(--card);
  border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.wd b { display: block; font-size: 15px; color: var(--ink); margin-top: 2px; }
.wd.done { border-color: var(--ok); } .wd.done b { color: var(--ok); }
.wd.today { outline: 2px solid var(--accent2); outline-offset: -2px; }
.streak { text-align: center; color: var(--muted); font-size: 14px; margin-top: 14px; }
.settings-row { margin-top: 22px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px; }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.switch { position: relative; width: 46px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; background: var(--card2); border: 1px solid var(--line);
  border-radius: 999px; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch input:checked + i { background: var(--accent2); border-color: var(--accent2); }
.switch input:checked + i::after { transform: translateX(20px); background: #fff; }

/* ---------- routines ---------- */
.routines-card { width: 100%; display: flex; align-items: center; gap: 12px; margin-top: 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  cursor: pointer; font: inherit; color: var(--ink); text-align: left; transition: transform .12s; }
.routines-card:active { transform: scale(.98); }
.routines-card .r-ic { font-size: 24px; flex: none; }
.routines-card .r-t { flex: 1; font-weight: 600; font-size: 15px; }
.routines-card .r-sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.routines-card .r-go { color: var(--muted); font-size: 20px; }
.routine-link { width: 100%; background: var(--card2); border: 1px solid var(--line);
  color: var(--accent); border-radius: 10px; padding: 12px; font: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; margin: 2px 0 12px; }
.routine-link:active { transform: scale(.98); }
.r-h { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent);
  font-weight: 700; margin: 16px 0 2px; }
.r-note { font-size: 13px; margin: 0 0 10px; }
.routine-item { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.routine-item:first-of-type { border-top: none; }
.routine-item img { width: 80px; height: 80px; object-fit: contain; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; flex: none; }
.routine-item .ri-n { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.routine-item ol { margin: 0 0 0 16px; padding: 0; font-size: 13px; color: var(--muted); }
.routine-item li { margin-bottom: 2px; }

/* ---------- plan tab ---------- */
#planMethod { margin-bottom: 14px; font-size: 14px; }
#planMethod b { color: var(--accent); }
.plan-day { margin-bottom: 14px; }
.plan-day h3 { margin: 0 0 4px; font-size: 16px; }
.plan-day .wu { font-size: 12px; color: var(--muted); margin: 0 0 10px; }
.plan-row { display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-top: 1px solid var(--line); cursor: pointer; }
.plan-row img { width: 48px; height: 48px; object-fit: contain; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; flex: none; }
.plan-row .t { flex: 1; min-width: 0; }
.plan-row .n { font-weight: 600; font-size: 14px; }
.plan-row .tg { font-size: 12px; color: var(--accent); }
.muscle { font-size: 10px; background: var(--card2); color: var(--muted); border-radius: 999px;
  padding: 2px 8px; flex: none; text-transform: capitalize; }

/* ---------- exercises tab ---------- */
.ex-grid-all { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ex-tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  overflow: hidden; cursor: pointer; transition: transform .12s; animation: rise .4s ease both; }
.ex-tile:active { transform: scale(.97); }
.ex-tile img { width: 100%; height: 130px; object-fit: contain; background: #fff; display: block; }
.ex-tile .t { padding: 8px 10px 10px; }
.ex-tile .n { font-weight: 600; font-size: 13px; line-height: 1.3; }
.ex-tile .m { font-size: 11px; color: var(--muted); text-transform: capitalize; }

/* ---------- workout ---------- */
.warmup { font-size: 13px; color: var(--warn); background: rgba(207, 164, 106, .10);
  border: 1px solid rgba(207, 164, 106, .28); border-radius: 8px; padding: 8px 12px; }
.counter { font-size: 13px; color: var(--accent); font-weight: 700; min-width: 44px; text-align: right; }
.ex-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 12px; transition: border-color .25s; animation: rise .4s ease both; overflow: hidden; }
.ex-card.logged { border-color: var(--ok); }
.ex-head { display: flex; gap: 12px; align-items: center; padding: 12px 14px; cursor: pointer; }
.ex-head img { width: 64px; height: 64px; object-fit: contain; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; flex: none; }
.ex-head .t { flex: 1; min-width: 0; }
.ex-name { font-weight: 700; font-size: 15px; margin: 0; }
.ex-target { color: var(--accent); font-size: 13px; font-weight: 600; margin: 2px 0 0; }
.ex-last { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.ex-state { flex: none; font-size: 20px; color: var(--line); transition: transform .2s; }
.ex-card.logged .ex-state { color: var(--ok); animation: pop .35s cubic-bezier(.2, 2, .4, 1) both; }
.ex-card.open .ex-state.chev { transform: rotate(180deg); }
.ex-body { display: none; padding: 0 14px 14px; border-top: 1px solid var(--line); }
.ex-card.open .ex-body { display: block; animation: rise .25s ease both; }
.ex-body .frow { margin-top: 12px; }
.ex-body label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }

/* set rows */
.set-row { display: grid; grid-template-columns: 52px 1fr 1fr 46px; gap: 8px; align-items: center;
  margin-top: 8px; }
.set-row .sn { font-size: 13px; color: var(--muted); font-weight: 700; }
.set-row.done .sn { color: var(--ok); }
.set-row input { padding: 9px 10px; }
.set-check { height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--card2);
  color: var(--muted); font-size: 16px; font-weight: 800; cursor: pointer; transition: all .15s; }
.set-row.done .set-check { background: rgba(111, 191, 142, .16); border-color: var(--ok); color: var(--ok); }
.add-set { margin-top: 10px; background: none; border: 1px dashed var(--line); color: var(--muted);
  border-radius: 8px; padding: 8px; width: 100%; font: inherit; font-size: 13px; cursor: pointer; }

/* rpe band */
.rpe-band { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 4px; }
.rpe-band button { border: none; border-radius: 6px; padding: 10px 0; font: inherit; font-size: 12px;
  font-weight: 800; color: rgba(10, 14, 20, .85); cursor: pointer; opacity: .38;
  transition: opacity .15s, transform .15s; }
.rpe-band button.sel { opacity: 1; transform: scale(1.12); box-shadow: 0 0 0 2px var(--ink); }
.rpe-cap { font-size: 12px; color: var(--muted); margin-top: 5px; min-height: 18px; }

.cardio-done { margin-top: 12px; width: 100%; background: var(--card2); border: 1px solid var(--line);
  color: var(--ink); border-radius: 8px; padding: 12px; font: inherit; font-weight: 700; cursor: pointer; }
.ex-card.logged .cardio-done { background: rgba(111, 191, 142, .15); border-color: var(--ok); color: var(--ok); }

.finish-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 35%); max-width: 560px; margin: 0 auto; z-index: 20; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid;
  grid-template-columns: repeat(5, 1fr); max-width: 560px; margin: 0 auto;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); }
.tabbar button { background: none; border: none; color: var(--muted); font: inherit; font-size: 11px;
  font-weight: 700; padding: 6px 0; border-radius: 10px; cursor: pointer; }
.tabbar button span { display: block; font-size: 20px; margin-bottom: 1px; filter: grayscale(1) opacity(.7); }
.tabbar button.on { color: var(--accent); }
.tabbar button.on span { filter: none; transform: scale(1.1); }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; background: rgba(10, 11, 14, .72);
  z-index: 55; display: flex; align-items: flex-end; justify-content: center; }
.lb-card { background: var(--card); box-shadow: 0 20px 50px rgba(0, 0, 0, .45); border: 1px solid var(--line); border-radius: 14px 14px 0 0;
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; position: relative;
  animation: slideup .3s ease both; }
.lb-close { position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px;
  border-radius: 50%; border: none; background: rgba(20, 22, 27, .7); color: #fff; font-size: 15px; cursor: pointer; }
.lb-media { background: #fff; text-align: center; border-radius: 14px 14px 0 0; padding: 8px 0 4px; }
.lb-media img { width: 100%; max-width: 300px; aspect-ratio: 1; display: block; margin: 0 auto; }
.lb-media .credit { color: #6b7280; margin: 0; }
.lb-body { padding: 16px 18px calc(20px + env(safe-area-inset-bottom)); }
.lb-body h3 { margin: 0; }
.lb-h { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--accent);
  font-weight: 700; margin: 14px 0 4px; }
.lb-h.warn { color: var(--warn); }
.lb-body ol, .lb-body ul { margin: 0 0 0 18px; padding: 0; font-size: 14px; color: var(--ink); }
.lb-body li { margin-bottom: 4px; }
.lb-body ul li { color: var(--muted); }

/* ---------- muscle figure ---------- */
.fig2 { display: flex; gap: 14px; justify-content: center; margin: 6px 0 2px; }
.fig2 svg { width: 42%; max-width: 150px; }
.fmn { fill: #343a46; stroke: var(--bg); stroke-width: .35; }
.fmp { fill: var(--mp); stroke: var(--bg); stroke-width: .35; }
.fms { fill: var(--ms); stroke: var(--bg); stroke-width: .35; }
.figcaps { display: flex; gap: 14px; justify-content: center; font-size: 11px;
  color: var(--muted); margin-bottom: 8px; }
.figcaps span { width: 42%; max-width: 150px; text-align: center; }
.muscle-names { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 8px; }
.mchip { font-size: 11px; border-radius: 999px; padding: 2px 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .03em; }
.mp-t { background: rgba(111, 155, 232, .16); color: #9dbbf0; }
.ms-t { background: rgba(157, 134, 224, .16); color: #bfb0ec; }
.muscle-legend { text-align: center; font-size: 11px; color: var(--muted); }
.muscle-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin: 0 3px 0 10px; }
.muscle-legend i.lp { background: var(--mp); }
.muscle-legend i.ls { background: var(--ms); }

/* ---------- day detail sheet ---------- */
.ds-entry { border-top: 1px solid var(--line); padding: 10px 0; }
.ds-entry:first-child { border-top: none; }
.ds-n { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ds-d { font-size: 13px; color: var(--muted); margin-top: 3px; line-height: 1.6; }
.rpe-chip { font-size: 11px; font-weight: 800; color: rgba(10, 14, 20, .85);
  border-radius: 999px; padding: 2px 9px; }

/* ---------- rest timer ---------- */
.rest-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-width: 560px;
  margin: 0 auto; background: var(--card2); border: 1px solid var(--accent2); border-bottom: none;
  border-radius: 12px 12px 0 0; padding: 0 0 calc(10px + env(safe-area-inset-bottom));
  animation: slideup .25s ease both; box-shadow: 0 -10px 30px rgba(0, 0, 0, .35); }
.rest-bar { height: 5px; background: var(--card); border-radius: 999px 999px 0 0; overflow: hidden; }
.rest-bar i { display: block; height: 100%; width: 100%; background: var(--grad); transition: width .25s linear; }
.rest-row { display: flex; align-items: center; gap: 14px; padding: 10px 16px 4px; }
.rest-label { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
.rest-time { flex: 1; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- celebration ---------- */
.celebrate { position: fixed; inset: 0; background: rgba(10, 11, 14, .72);
  display: grid; place-items: center; z-index: 50; }
.celebrate-card { background: var(--card); box-shadow: 0 20px 50px rgba(0, 0, 0, .45); border: 1px solid var(--line); border-radius: 14px;
  padding: 30px 26px; text-align: center; max-width: 320px; width: 88%;
  animation: pop .45s cubic-bezier(.2, 1.8, .4, 1) both; }
.big-emoji { font-size: 56px; animation: bounce 1s ease infinite alternate; }
.celebrate-card h2 { margin: 10px 0 6px; }
.celebrate-card p { margin: 0 0 18px; font-size: 14px; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-8px); } }
@keyframes slideup { from { transform: translateY(100%); } to { transform: none; } }

/* ---------- track header ---------- */
.hello-row { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 16px; }
.wd:disabled { cursor: default; color: var(--muted); }
.wd.done:not(:disabled):active { transform: scale(.95); }
.small { font-size: 13px; }
.credit { font-size: 11px; color: var(--muted); text-align: center; margin: 16px 0 0; }
.credit a { color: inherit; }
.card-h { margin: 0 0 4px; font-size: 16px; }

/* ---------- history calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.cal-head .center { flex: 1; text-align: center; }
.cal-head h3 { margin: 0; font-size: 17px; }
.cal-head .ghost-sm { width: 38px; height: 38px; font-size: 20px; padding: 0; }
.cal-head .ghost-sm:disabled { opacity: .3; }
.cal-dow, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-dow span { text-align: center; font-size: 11px; color: var(--muted); font-weight: 700; padding-bottom: 4px; }
.cal-d { aspect-ratio: 1; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; padding: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; cursor: pointer; }
.cal-d b { font-size: 14px; font-weight: 600; }
.cal-d i { font-style: normal; font-size: 10px; font-weight: 800; color: var(--bg); background: var(--ok);
  border-radius: 999px; padding: 0 5px; }
.cal-d:disabled { cursor: default; color: var(--muted); background: transparent; }
.cal-d.future { opacity: .35; }
.cal-d.done { border-color: var(--ok); background: rgba(111, 191, 142, .10); }
.cal-d.done:active { transform: scale(.94); }
.cal-d.today { outline: 2px solid var(--accent2); outline-offset: -2px; }
.ds-muscles { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 4px; }

/* ---------- body tab: heatmap ---------- */
.fig2.big svg { width: 46%; max-width: 190px; }
.figcaps.big span { width: 46%; max-width: 190px; }
.hm { stroke: var(--bg); stroke-width: .35; transition: fill .4s; }
.heat-legend { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11px; color: var(--muted); }
.heat-legend i { width: 90px; height: 8px; border-radius: 4px; }
.heat-legend b { width: 10px; height: 10px; border-radius: 50%; margin-left: 8px; }
.heat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; margin-top: 14px; }
.hl-row { display: flex; align-items: center; gap: 7px; font-size: 13px; padding: 4px 0; border-top: 1px solid var(--line); }
.hl-row i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.hl-n { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hl-w { color: var(--muted); font-size: 11px; white-space: nowrap; }
.hl-row.gap .hl-n { color: var(--warn); }

/* ---------- body tab: measurements ---------- */
.latest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  text-align: left; font: inherit; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
button.stat { cursor: pointer; }
.stat.on { border-color: var(--accent); }
.st-l { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.st-v { font-size: 20px; font-weight: 800; }
.st-v small { font-size: 12px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.st-d { font-size: 11px; color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; scrollbar-width: none; }
.chip { flex: none; background: var(--card2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.chip.on { color: #fff; background: var(--accent); border-color: var(--accent); }
.chip:disabled { opacity: .35; cursor: default; }
.chart { position: relative; touch-action: pan-y; }
.chart svg { width: 100%; display: block; overflow: visible; }
.chart-empty { text-align: center; margin: 6px 0; }
.c-grid { stroke: var(--line); stroke-width: 1; }
.c-ax { fill: var(--muted); font-size: 10px; }
.c-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.c-dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.c-hot { fill: var(--accent); stroke: var(--ink); stroke-width: 2; pointer-events: none; }
.c-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.c-lbl { fill: var(--ink); font-size: 12px; font-weight: 800; }
.c-hit { fill: transparent; }
.c-cross.hidden, .c-hot.hidden { display: none; }
.c-tip { position: absolute; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 9px; font-size: 12px; color: var(--muted); text-align: center;
  pointer-events: none; white-space: nowrap; }
.c-tip b { color: var(--ink); }
.m-table summary { font-size: 13px; color: var(--accent); cursor: pointer; margin-top: 10px; }
.mt-row { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 7px 0; border-top: 1px solid var(--line); }
.mt-row span:first-child { flex: 1; color: var(--muted); }
.mt-row .ghost-sm { padding: 4px 10px; font-size: 12px; }
.m-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 14px; }
.m-form label { font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.m-form label:first-child { grid-column: 1 / -1; }

/* ---------- form checks ---------- */
.fc-feel { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.fc-feel b { color: var(--ink); }
.fc-pair { border-top: 1px solid var(--line); padding: 7px 0; }
.fc-pair p { margin: 0; font-size: 13px; display: flex; gap: 8px; line-height: 1.4; }
.fc-pair p + p { margin-top: 3px; }
.fc-pair span { flex: none; width: 16px; font-weight: 800; text-align: center; }
.fc-ok span { color: var(--ok); }
.fc-bad { color: var(--muted); }
.fc-bad span { color: var(--err); }
.fc-wrap { margin-top: 12px; }
.fc-wrap summary { font-size: 13px; font-weight: 700; color: var(--accent); cursor: pointer; }
.fc-wrap .lb-h { display: none; }
.fc-wrap .form-check { margin-top: 8px; }

/* ---------- unsaved workout banner ---------- */
.draft-banner { border-color: var(--warn); margin-bottom: 12px; padding: 14px 16px; }
.draft-banner p { margin: 0 0 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.draft-banner b { color: var(--warn); }
.draft-actions { display: flex; gap: 8px; align-items: center; }
.draft-actions .btn { flex: 1; padding: 10px; }

/* ---------- backdated logging ---------- */
.w-date { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: -6px 0 12px; }
.w-date input { width: auto; font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; color-scheme: dark; }
.w-date.past input { border-color: var(--warn); }
.w-date.past #wDateNote { color: var(--warn); font-weight: 600; }
.ds-log { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 10px; }
.ds-log-h { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; }
.ds-log-btn { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.ds-log-btn b { color: var(--accent2); margin-right: 4px; }
.cal-d:not(.done):not(:disabled):active, .wd:not(.done):not(:disabled):active { transform: scale(.95); }

/* ---------- timed holds & assisted machines ---------- */
.set-row.timed { grid-template-columns: 52px 1fr 46px; }
.r-hold { display: flex; align-items: center; gap: 8px; }
.r-hold em { font-style: normal; font-size: 13px; color: var(--muted); }
.assist-note { font-size: 12px; color: var(--muted); background: var(--card2); border-left: 3px solid var(--accent2);
  border-radius: 6px; padding: 8px 10px; margin: 0 0 10px; line-height: 1.45; }
.assist-note b { color: var(--ink); }

/* ================= desktop (≥1100px): top bar, left nav, side-by-side panes ================= */
.desk-only, .desk-top, .desk-ex, .desk-last { display: none; }
@media (min-width: 1100px) {
  html, body { font-size: 14px; }
  .card { backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; padding: 16px; }
  .desk-only { display: block; }
  .desk-top:not(.hidden) { display: flex; }
  .desk-top { position: fixed; top: 0; left: 0; right: 0; z-index: 40; height: 52px; align-items: center; gap: 16px;
    padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line); }
  .dt-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15px; }
  .dt-brand img { width: 24px; height: 24px; border-radius: 6px; }
  .dt-date { color: var(--muted); font-size: 13px; flex: 1; }
  .dt-user { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 13px; }

  /* bottom tab bar becomes the left nav column */
  .tabbar { top: 52px; bottom: 0; right: auto; width: 200px; max-width: none; margin: 0; display: flex; flex-direction: column; gap: 2px;
    padding: 14px 10px; border-top: none; border-right: 1px solid var(--line); background: var(--card); }
  .tabbar button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
    font-size: 14px; font-weight: 600; text-align: left; }
  .tabbar button span { font-size: 17px; margin: 0; }
  .tabbar button.on { background: var(--accent-soft); color: var(--ink); }
  .tabbar button:hover:not(.on) { background: var(--card); color: var(--ink); }

  #view-main { max-width: 1480px; margin: 0 0 0 200px; padding: 76px 28px 48px; }
  #view-workout { max-width: 880px; padding: 76px 24px 120px; }
  #view-workout .top { position: sticky; top: 52px; z-index: 5; background: var(--bg); padding: 10px 0; margin-top: -10px; }
  .section-h { font-size: 12px; letter-spacing: .08em; margin: 22px 0 10px; }
  .sh-note { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); margin-left: 8px; }
  .hello-row .avatar-sm, .settings-row #logout { display: none; }

  /* track = dashboard */
  .dash { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
  .dash-side { position: sticky; top: 76px; }
  .dash-side > .section-h:first-child { margin-top: 4px; }
  .stat-tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .stat-tiles .stat { cursor: default; }
  .stat-tiles .st-v small { margin-left: 3px; }
  .day-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
  .day-item { align-items: flex-start; padding: 14px 16px; }
  .day-item:hover { border-color: var(--accent2); }
  .desk-ex { display: block; font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
  .desk-last { display: block; font-weight: 600; font-size: 11px; color: var(--accent); margin-top: 6px; }
  .routines-card { margin-bottom: 4px; }
  .side-card { margin-top: 14px; padding: 14px 16px; }
  .sc-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
  .sc-head .card-h { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
  .link-btn { background: none; border: none; color: var(--accent); font: inherit; font-size: 12px; cursor: pointer; padding: 0; }
  #miniHeat .fig2 svg { width: 40%; max-width: 120px; }
  .mini-heat-list p { margin: 8px 0 0; font-size: 12px; line-height: 1.5; }
  .mh-k { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ok); }
  .mh-k.warn { color: var(--warn); }
  .mb-row { display: grid; grid-template-columns: 70px 1fr 96px; grid-template-rows: auto auto; column-gap: 10px;
    align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
  .mb-row:first-child { border-top: none; }
  .mb-l { font-size: 12px; color: var(--muted); }
  .mb-v { font-weight: 700; font-size: 16px; }
  .mb-v small, .tbl small { color: var(--muted); font-weight: 400; font-size: 11px; }
  .mb-d { grid-column: 2 / 4; font-size: 11px; color: var(--muted); }

  /* tables */
  .tbl-card { padding: 4px 6px; overflow-x: auto; }
  .tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
  .tbl th { text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: 10px 10px 8px; white-space: nowrap; }
  .tbl td { padding: 9px 10px; border-top: 1px solid var(--line); vertical-align: middle; }
  .tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
  .tbl .nowrap { white-space: nowrap; }
  .tbl tbody tr:hover td { background: var(--line-soft); }
  #recentTable tr[data-date] { cursor: pointer; }
  .tbl .hl { color: var(--muted); font-size: 12px; }
  .tbl .hl b { color: var(--ink); }
  .tbl .rpe-chip { margin-left: 6px; display: inline-block; white-space: nowrap; }
  .tbl-foot { margin: 8px 10px 10px; }
  .ch-good { color: var(--ok); font-weight: 700; }
  .ch-bad { color: var(--err); font-weight: 700; }
  .tag { font-size: 10px; font-weight: 700; color: var(--accent2); border: 1px solid var(--accent2); border-radius: 5px;
    padding: 0 5px; margin-left: 4px; white-space: nowrap; }
  .spark { display: block; overflow: visible; }
  .spark polyline { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  .spark circle { fill: var(--muted); }
  .spark.sp-good polyline { stroke: var(--ok); } .spark.sp-good circle { fill: var(--ok); }
  .spark.sp-bad polyline { stroke: var(--err); } .spark.sp-bad circle { fill: var(--err); }

  /* history: calendar + docked day detail */
  .hist-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start; }
  .hist-side { position: sticky; top: 76px; }
  #histDetail { max-height: calc(100vh - 100px); overflow-y: auto; }
  #histDetail .lb-body { padding: 0; }
  .cal-d.sel { box-shadow: 0 0 0 2px var(--accent2); }
  .cal-d { aspect-ratio: auto; height: 58px; }
  .cal-grid { gap: 6px; }
  .cal-d:not(:disabled):hover { border-color: var(--accent2); }

  /* body: heatmap beside measurements */
  .body-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
  .body-heat { position: sticky; top: 76px; }
  .body-meas > .section-h:first-child { margin-top: 0; }
  .latest-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }

  /* plan & exercises: use the width */
  #planView { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; align-items: start; }
  #planView .plan-day { margin: 0; }
  .plan-row:hover { background: var(--card); }
  .ex-grid-all { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .lightbox { align-items: center; }
  .lb-card { border-radius: 14px; max-width: 560px; }
}
@media (min-width: 1100px) and (max-width: 1350px) {
  .stat-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash { grid-template-columns: minmax(0, 1fr) 320px; }
}
