/* LiftMate v2 — CoachRx-inspired design system.
   Near-black teal-navy base, cyan primary actions, green reserved for success/compliance. */
:root {
  --bg: #04131b;
  --surface: #0b2430;
  --surface2: #123240;
  --line: rgba(96, 175, 205, 0.16);
  --text: #f2f7f9;
  --dim: #8fa8b3;
  --faint: #869eab;
  --blue: #3bb3e4;
  --blue-deep: #1b5e7a;
  --blue-soft: rgba(59, 179, 228, 0.14);
  --green: #2ee08a;
  --green-soft: rgba(46, 224, 138, 0.13);
  --amber: #f5a623;
  --amber-soft: rgba(245, 166, 35, 0.14);
  --red: #ef5350;
  --r-lg: 14px;
  --r-sm: 10px;
  --r-xs: 8px;
  --r-xl: 20px;
  /* type scale — use these for new rules; sizes within 0.3px were folded into them */
  --fs-xs: 0.72rem;
  --fs-sm: 0.8rem;
  --fs-md: 0.85rem;
  --fs-base: 0.9rem;
  --fs-lg: 0.95rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 96px);
}
.loading { text-align: center; color: var(--dim); padding: 40vh 0; }

h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
h2 {
  font-size: var(--fs-lg); font-weight: 800; letter-spacing: 0.09em; text-transform: uppercase;
  margin: 24px 0 10px;
}
h3 { font-size: 1.05rem; font-weight: 700; }
.dim { color: var(--dim); font-size: var(--fs-md); }
.small { font-size: var(--fs-sm); }

/* ---------------- cards ---------------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  margin-bottom: 12px;
  animation: rise 0.2s ease both;
}
.card.tappable { cursor: pointer; transition: transform 0.12s ease, background 0.12s ease; }
.card.tappable:active { transform: scale(0.985); background: var(--surface2); }

/* icon-tile list rows (CoachRx profile style) */
.tile-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}
.tile-row:active { background: var(--surface2); }
.tile-icon {
  width: 44px; height: 44px; border-radius: var(--r-sm); flex-shrink: 0;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; color: var(--text);
}
.tile-row .chev { margin-left: auto; color: var(--dim); font-size: 1.1rem; }

/* ---------------- buttons & inputs ---------------- */
button, .btn {
  display: inline-block;
  font: inherit;
  border: none;
  border-radius: var(--r-sm);
  padding: 13px 18px;
  background: var(--surface2);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
button:active, .btn:active { transform: scale(0.97); opacity: 0.85; }
.btn-primary {
  width: 100%; padding: 16px; font-size: 0.98rem;
  background: var(--blue);
  color: var(--bg);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.btn-danger { background: transparent; color: var(--red); border: 1px solid rgba(239, 83, 80, 0.4); }
.btn-ghost { background: transparent; color: var(--dim); border: 1px solid var(--line); }
.btn-small { padding: 8px 13px; font-size: var(--fs-md); font-weight: 600; min-height: 44px; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row > * { flex: 1; }

input, select, textarea {
  font: inherit;
  background: rgba(11, 36, 48, 0.7);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  padding: 12px 13px;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
label { display: block; font-size: var(--fs-sm); color: var(--dim); margin: 12px 0 5px; font-weight: 700; }

.chip {
  display: inline-block;
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.03em;
  padding: 4px 10px; border-radius: var(--r-xs);
  background: var(--surface2); color: var(--dim);
  vertical-align: middle;
}
.chip-blue { background: var(--blue-soft); color: var(--blue); }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-red { background: rgba(239, 83, 80, 0.14); color: var(--red); }

/* ---------------- header ---------------- */
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.topbar .who { display: flex; align-items: center; gap: 12px; }
.topbar .gear {
  background: var(--surface2); border-radius: var(--r-sm);
  width: 44px; height: 44px; padding: 0; font-size: 1.2rem; color: var(--text); flex-shrink: 0;
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface2); color: var(--blue);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.1rem;
}
.avatar.sm { width: 40px; height: 40px; font-size: var(--fs-lg); }

.date-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.date-row .date { font-size: 1.3rem; font-weight: 800; }
.streak-chip {
  background: var(--green-soft); color: var(--green);
  font-size: var(--fs-sm); font-weight: 800; padding: 5px 11px; border-radius: var(--r-xs);
}

/* ---------------- week strip (CoachRx day chips) ---------------- */
.week-nav { display: flex; align-items: center; justify-content: space-between; margin: 0 0 2px; color: var(--dim); font-size: var(--fs-sm); font-weight: 700; }
.week-nav button { background: none; color: var(--blue); font-size: 1.6rem; line-height: 1; min-width: 44px; min-height: 40px; padding: 0 8px; }
.week-nav button:disabled { color: transparent; }
.week-strip { display: flex; justify-content: space-between; margin: 4px 0 8px; }
.day { text-align: center; width: 44px; }
.day .d-circ {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; margin-bottom: 6px;
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
}
.day .d-mark { font-size: 0.6rem; height: 0.7rem; line-height: 0.7rem; color: var(--green); font-weight: 900; }
.day .d-num { font-size: var(--fs-base); font-weight: 700; }
.day .d-letter { font-size: var(--fs-xs); font-weight: 700; color: var(--dim); }
.day.today .d-circ { background: var(--blue); color: var(--bg); }
.day.today .d-mark { color: var(--bg); }

/* ---------------- session card (Daily Rx style) ---------------- */
.rx-card { padding: 16px; }
.rx-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.rx-head .rx-title { font-size: 1.25rem; font-weight: 800; }
.rx-ex {
  background: var(--surface2);
  border-radius: var(--r-sm);
  padding: 13px 14px;
  margin-top: 10px;
  display: flex; gap: 13px;
}
.letter {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  border: 1.6px solid var(--blue); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: var(--fs-lg);
  background: rgba(59, 179, 228, 0.08);
}
.rx-ex .rx-name { font-weight: 800; font-size: 1rem; margin-bottom: 3px; }
.rx-ex .rx-line { color: var(--dim); font-size: var(--fs-base); line-height: 1.45; white-space: pre-line; }

/* ---------------- stats & compliance ---------------- */
.statrow { display: flex; gap: 10px; margin-bottom: 12px; }
.stat { flex: 1; padding: 14px 14px; }
.stat .big { font-size: 1.6rem; font-weight: 800; display: block; font-variant-numeric: tabular-nums; }
.stat .big .ico { font-size: 1.1rem; vertical-align: 2px; margin-right: 4px; }
.ringrow { display: flex; gap: 10px; margin-bottom: 12px; }
.ringcard { flex: 1; text-align: center; padding: 14px 6px 12px; }
.ring { width: 84px; height: 84px; margin: 0 auto 6px; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums;
}
.ring-sm { width: 52px; height: 52px; position: relative; flex-shrink: 0; }
.ring-sm svg { transform: rotate(-90deg); }
.ring-sm .ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: var(--fs-xs); }

/* ---------------- workout player ---------------- */
.player-top {
  position: sticky; top: 0; z-index: 30;
  background: rgba(4, 19, 27, 0.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  margin: 0 -16px 14px; padding: calc(var(--safe-top) + 10px) 16px 12px;
}
.player-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.player-meta .exit { background: none; color: var(--text); font-weight: 800; letter-spacing: 0.06em; padding: 6px 10px; font-size: var(--fs-md); min-height: 44px; }
.player-meta .pm-info { color: var(--dim); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.segs { display: flex; gap: 6px; }
.segs .segbar { flex: 1; height: 3px; border-radius: 2px; background: var(--surface2); cursor: pointer; padding: 0; }
.segs .segbar.done { background: var(--blue-deep); }
.segs .segbar.cur { background: var(--blue); }

.px-head { display: flex; align-items: center; gap: 13px; margin-bottom: 10px; }
.px-head h1 { font-size: 1.35rem; }
.px-chips { display: flex; gap: 8px; margin: 4px 0 10px; }
.px-chips button {
  background: var(--surface2); color: var(--blue);
  font-size: var(--fs-sm); font-weight: 700; padding: 8px 13px; border-radius: var(--r-xs); min-height: 44px;
}
.px-rx { color: var(--text); font-size: var(--fs-lg); line-height: 1.5; margin: 4px 0 14px; white-space: pre-line; }
.px-nav { display: flex; gap: 10px; margin-top: 16px; }
.px-nav button { flex: 1; }
.px-skip { text-align: center; margin-top: 12px; }
.px-skip button { background: none; color: var(--faint); font-size: var(--fs-sm); font-weight: 600; }

/* set grid */
.set-head, .set-grid {
  display: grid;
  grid-template-columns: 26px 1fr 66px 66px 46px;
  gap: 8px; align-items: center;
}
.set-head {
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.08em;
  color: var(--faint); text-transform: uppercase;
  padding: 2px 0 6px; text-align: center;
}
.set-head span:first-child { text-align: left; }
.set-grid { padding: 3px 0; }
.sg-num { color: var(--dim); font-size: var(--fs-md); font-weight: 700; padding-left: 4px; }
.sg-prev {
  background: none; border: none; padding: 8px 0; text-align: center;
  color: var(--faint); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums;
}
.set-grid input { text-align: center; padding: 10px 4px; font-weight: 700; }
.set-grid.done input { color: var(--green); background: var(--green-soft); border-color: transparent; }
.set-grid.done .sg-num { color: var(--green); }
.ex-foot { display: flex; gap: 18px; padding: 8px 2px 2px; }
.ex-foot button { background: none; color: var(--dim); font-size: var(--fs-sm); padding: 4px 8px; font-weight: 600; min-height: 44px; }

/* rest pill */
@keyframes slideup { from { opacity: 0; transform: translate(-50%, 14px); } }
#restbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 78px);
  z-index: 70;
  width: min(340px, calc(100vw - 32px));
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid rgba(59, 179, 228, 0.45);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: slideup 0.25s ease;
}
#restbar .rest-fill { position: absolute; inset: 0; background: var(--blue-soft); transition: width 0.4s linear; }
#restbar .rest-inner { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 11px 8px 11px 18px; }
#restbar .rest-time { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--blue); }
#restbar .rest-skip { background: none; padding: 4px 12px; color: var(--dim); font-size: var(--fs-sm); font-weight: 700; }
#restbar.overdue { border-color: rgba(46, 224, 138, 0.55); }
#restbar.overdue .rest-time { color: var(--green); }
#restbar.overdue .rest-fill { background: var(--green-soft); }

/* ---------------- history & charts ---------------- */
.wo-summary { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.wo-detail table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.wo-detail td { padding: 5px 6px 5px 0; font-size: var(--fs-md); border-bottom: 1px solid var(--line); }
.wo-detail td:last-child { text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.trend-svg { width: 100%; height: 110px; margin: 6px 0 2px; display: block; }

.seg-ctl {
  display: flex; border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.seg-ctl button {
  flex: 1; background: none; border-radius: 0; padding: 11px; font-size: var(--fs-base);
  color: var(--dim); font-weight: 700; border-bottom: 2px solid transparent;
}
.seg-ctl button.on { color: var(--text); border-bottom-color: var(--blue); }

/* comments */
.cmt { display: flex; gap: 9px; margin-top: 10px; align-items: flex-start; }
.cmt .cmt-body { background: var(--surface2); border-radius: var(--r-sm); padding: 9px 12px; flex: 1; }
.cmt .cmt-who { font-size: var(--fs-xs); font-weight: 800; color: var(--blue); margin-bottom: 2px; }
.cmt.coach .cmt-who { color: var(--green); }
.cmt .cmt-text { font-size: var(--fs-base); line-height: 1.45; }
.cmt-input { display: flex; gap: 8px; margin-top: 12px; }
.cmt-input input { flex: 1; }
.cmt-input button { background: var(--blue); color: var(--bg); font-weight: 800; padding: 0 16px; }

/* ---------------- chat ---------------- */
.chat-screen {
  position: fixed; left: 0; right: 0; top: 0; z-index: 30;
  bottom: calc(var(--safe-bottom) + 62px);   /* leave room for the lifter's tab bar */
  max-width: 520px; margin: 0 auto;
  display: flex; flex-direction: column;
  padding-top: var(--safe-top);
  background: var(--bg);
}
.cs-head { flex-shrink: 0; padding: 10px 16px 8px; }
.cs-head .who { display: flex; align-items: center; gap: 12px; }
.cs-head h1 { font-size: 1.15rem; }
.cs-head .hub-head { margin-bottom: 8px; }
.chat-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; display: flex; flex-direction: column; padding: 6px 14px 4px; }
.msgs { margin-top: auto; width: 100%; }
.bubble-day {
  text-align: center; color: var(--dim); font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: 0.04em; margin: 18px 0 6px; text-transform: uppercase;
}
.bubble {
  position: relative;
  max-width: 80%; padding: 10px 14px 7px; border-radius: var(--r-xl); margin-top: 11px;
  font-size: var(--fs-lg); line-height: 1.42; white-space: pre-wrap; word-break: break-word;
  animation: rise 0.15s ease both;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.bubble.grp { margin-top: 3px; }
.bubble.me { background: linear-gradient(135deg, #3aa7dc, #1f6f95); color: #fff; margin-left: auto; border-bottom-right-radius: 6px; }
.bubble.them { background: #17303c; margin-right: auto; border-bottom-left-radius: 6px; }
.bubble.me.grp { border-top-right-radius: 8px; }
.bubble.them.grp { border-top-left-radius: 8px; }
.bubble-receipt { text-align: right; font-size: var(--fs-xs); color: var(--faint); font-weight: 700; margin: 2px 6px 4px; letter-spacing: 0.02em; }
.bubble-receipt.read { color: var(--blue); }
.bubble-text { margin-bottom: 2px; }
.bubble-time { display: block; text-align: right; font-size: var(--fs-xs); opacity: 0.6; margin-top: 2px; font-variant-numeric: tabular-nums; }
.bubble.has-media { padding: 5px 5px 6px; overflow: hidden; }
.bubble.has-media .bubble-text { padding: 2px 8px 0; }
.bubble.has-media .bubble-time { padding: 0 8px; }
.chat-img {
  display: block; width: 100%; max-width: 240px; max-height: 300px; object-fit: cover;
  border-radius: var(--r-lg); cursor: pointer;
}
.chat-audio { display: flex; align-items: center; gap: 8px; padding: 4px 6px; min-width: 210px; }
.chat-audio .mic-ico { font-size: 1.05rem; flex-shrink: 0; }
.chat-audio audio { height: 34px; max-width: 100%; }

.chat-input {
  position: relative; flex-shrink: 0; padding: 9px 12px;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; gap: 7px; align-items: center;
}
.chat-input textarea#chat-text {
  flex: 1; border-radius: var(--r-xl); padding: 10px 15px;
  resize: none; height: 42px; max-height: 130px; overflow-y: hidden; overscroll-behavior: contain;
  line-height: 1.35; font-family: inherit;
}
.chat-input { align-items: flex-end; }
.chat-input .ci-btn {
  background: var(--surface2); color: var(--blue); border-radius: 50%;
  width: 42px; height: 42px; padding: 0; font-size: 1.3rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.chat-input .ci-mic { font-size: 1.15rem; }
.chat-input .ci-send {
  background: var(--blue); color: var(--bg); border-radius: 50%;
  width: 42px; height: 42px; padding: 0; font-size: 1.15rem; flex-shrink: 0;
}
.chat-input.recording > *:not(.rec-overlay) { visibility: hidden; }
.rec-overlay {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; background: var(--surface); z-index: 2;
}
.rec-overlay .rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--red); animation: recpulse 1s infinite; }
@keyframes recpulse { 50% { opacity: 0.25; } }
.rec-overlay #rec-time { font-weight: 800; font-variant-numeric: tabular-nums; }
.rec-overlay .rec-cancel { margin-left: auto; background: none; color: var(--dim); padding: 6px 10px; font-size: var(--fs-md); }
.rec-overlay .rec-stop { background: var(--blue); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-weight: 800; }
.inbox-last { color: var(--dim); font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px; }
.unread-dot {
  min-width: 20px; height: 20px; border-radius: var(--r-sm); background: var(--blue);
  color: var(--bg); font-size: var(--fs-xs); font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}

/* ---------------- lifter rows / admin ---------------- */
.lifter-row { display: flex; gap: 12px; align-items: center; }
.lifter-row .lifter-info { min-width: 0; flex: 1; }

.sess-btns { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.sess-btns button {
  padding: 3px 10px; font-size: 0.75rem; border-radius: var(--r-xs);
  background: var(--surface2); color: var(--dim); border: 1px solid var(--line);
}
.sess-btns .del { color: var(--red); }


/* ---------------- sheet ---------------- */
@keyframes fadein { from { opacity: 0; } }
@keyframes sheetup { from { transform: translateY(40px); opacity: 0.4; } }
#sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.68); z-index: 80; animation: fadein 0.2s ease; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--surface);
  border: 1px solid var(--line); border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 20px 18px calc(var(--safe-bottom) + 20px);
  max-width: 520px; margin: 0 auto;
  max-height: 82vh; overflow-y: auto;
  animation: sheetup 0.25s ease;
}

/* ---------------- tab bar ---------------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  background: rgba(4, 19, 27, 0.94);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
#tabbar a {
  flex: 1; text-align: center; padding: 10px 0 8px;
  color: var(--faint); text-decoration: none; font-size: var(--fs-xs); font-weight: 700;
  position: relative;
}
#tabbar a.on { color: var(--blue); }
#tabbar svg { width: 23px; height: 23px; display: block; margin: 0 auto 3px; }
#tabbar .tab-badge {
  position: absolute; top: 4px; left: calc(50% + 8px);
  min-width: 16px; height: 16px; border-radius: var(--r-xs); background: var(--red);
  color: #fff; font-size: 0.68rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

#offline-banner {
  background: var(--amber); color: #3a2400; font-size: var(--fs-sm); font-weight: 800;
  text-align: center; padding: calc(var(--safe-top) + 6px) 10px 7px;
}

/* ---------------- coach note ---------------- */
.note-card { border-color: rgba(46, 224, 138, 0.35); }
.note-card p { margin: 7px 0 5px; line-height: 1.5; font-size: var(--fs-lg); }
.ann-card { border-color: rgba(59, 130, 246, 0.5); }
.ann-card p { white-space: pre-line; }
.guide-steps { padding-left: 22px; margin: 4px 0 12px; }
.guide-steps li { margin: 9px 0; line-height: 1.45; font-size: var(--fs-md); color: var(--text); }
.eyebrow {
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--green);
}
.eyebrow.blue { color: var(--blue); }

/* ---------------- login ---------------- */
.login-wrap { padding-top: 13vh; text-align: center; }
.login-wrap .logo-mark { margin-bottom: 14px; }
.login-wrap form { text-align: left; margin-top: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px 18px 20px; }
.logo { font-size: 2.1rem; font-weight: 900; letter-spacing: -0.04em; }
.logo em { color: var(--blue); font-style: normal; }
.err-msg { color: var(--red); font-size: var(--fs-md); margin: 10px 0; min-height: 1.2em; }

/* ---------------- v2.3 set blocks: big readable logging controls ---------------- */
.set-block { border-top: 1px solid var(--line); padding: 11px 0 13px; }
.set-block:first-child { border-top: none; }
.sb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sb-num {
  font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--dim);
}
.sb-prev {
  background: none; padding: 4px 0; color: var(--faint);
  font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums;
  min-height: 44px; display: inline-flex; align-items: center;
}
.sb-controls { display: flex; gap: 8px; align-items: stretch; }
.sb-step {
  width: 48px; border-radius: var(--r-sm); flex-shrink: 0; padding: 0;
  background: var(--surface2); border: 1px solid var(--line);
  font-size: 1.35rem; color: var(--text);
}
.sb-field { position: relative; flex: 1.15; min-width: 0; }
.sb-field.sb-reps { flex: 1; }
.sb-field input {
  width: 100%; height: 56px; text-align: center;
  font-size: 1.25rem; font-weight: 800; padding: 0 4px 14px;
}
.sb-unit {
  position: absolute; bottom: 6px; left: 0; right: 0; text-align: center;
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.1em;
  color: var(--faint); pointer-events: none;
}
.set-block.done input { color: var(--green); background: var(--green-soft); border-color: transparent; }
.set-block.done .sb-num { color: var(--green); }
.set-block.done .sb-step { opacity: 0.4; }

/* ---------------- v2.4: dots, month calendar, smooth swipe ---------------- */
.day .d-dot { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--faint); display: block; }
.day.trained .d-dot { background: #fff; border-color: #fff; }
.day.today .d-circ .d-dot { border-color: var(--bg); }
.day.today.trained .d-circ .d-dot { background: var(--bg); }
.cal-link { background: none; color: var(--dim); font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.1em; padding: 6px 8px; margin-left: auto; min-height: 44px; }

.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cal-head button { background: none; font-size: 1.6rem; color: var(--dim); padding: 2px 16px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font-size: 0.6rem; font-weight: 800; color: var(--faint); letter-spacing: 0.05em; padding: 6px 0; }
.cal-cell {
  background: none; border-radius: var(--r-sm); padding: 6px 0 7px; min-height: 46px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text);
}
.cal-cell.today { background: var(--blue); color: var(--bg); }
.cal-cell.today .cal-dot { border-color: var(--bg); }
.cal-cell.today .cal-dot.on { background: var(--bg); }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--faint); }
.cal-dot.on { background: #fff; border-color: #fff; }
.cal-num { font-size: var(--fs-base); font-weight: 700; font-variant-numeric: tabular-nums; }

@keyframes swipeL { from { opacity: 0.25; transform: translateX(48px); } }
@keyframes swipeR { from { opacity: 0.25; transform: translateX(-48px); } }


/* ---------------- v2.5: day states, selected day, training-day picker ---------------- */
.day .d-mark { font-size: 0.66rem; height: 0.75rem; line-height: 0.75rem; font-weight: 900; }
.day .d-mark.ok { color: var(--green); }
.day .d-mark.miss { color: var(--red); }
.day.sel .d-circ { background: var(--blue); color: var(--bg); }
.day.sel .d-mark.ok, .day.sel .d-mark.miss { color: var(--bg); }
.day.sel .d-dot { border-color: var(--bg); }
.day.sel .d-dot.on { background: var(--bg); border-color: var(--bg); }
.day.today:not(.sel) .d-circ { border-color: var(--blue); }
.cal-cell .d-mark { font-size: 0.62rem; height: 0.7rem; line-height: 0.7rem; font-weight: 900; }
.cal-cell .d-mark.ok { color: var(--green); }
.cal-cell .d-mark.miss { color: var(--red); }
.cal-cell.today .d-mark.ok, .cal-cell.today .d-mark.miss { color: var(--bg); }
.cal-cell .d-dot { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--faint); display: block; }
.cal-cell .d-dot.on { background: #fff; border-color: #fff; }
.cal-cell.today .d-dot { border-color: var(--bg); }
.cal-cell.today .d-dot.on { background: var(--bg); }
.missed-card { border-color: rgba(239, 83, 80, 0.4); }
.dayspick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.daypick { flex: 1; min-width: 54px; padding: 12px 0; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-xs); font-size: var(--fs-sm); font-weight: 700; }
.daypick.on { background: var(--blue); color: var(--bg); border-color: transparent; }


/* pending (planned) day = solid white dot on the strip too */
.day .d-dot.on { background: #fff; border-color: #fff; }
.day.sel .d-dot.on { background: var(--bg); border-color: var(--bg); }


/* chat badge must actually hide when there are no unread messages */
#tabbar .tab-badge[hidden] { display: none; }


/* pull-to-refresh indicator */
#ptr {
  position: fixed; top: 0; left: 50%; z-index: 95;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; color: var(--dim);
  transform: translate(-50%, -50px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
#ptr[hidden] { display: none; }
#ptr.ready { color: var(--blue); border-color: rgba(59, 179, 228, 0.55); }
@keyframes ptrspin {
  from { transform: translate(-50%, 24px) rotate(0deg); }
  to { transform: translate(-50%, 24px) rotate(360deg); }
}
#ptr.spinning { animation: ptrspin 0.7s linear infinite; }


/* unplanned days: no dot at all (invisible spacer keeps the numbers aligned) */
.d-dot.off { border-color: transparent !important; background: none !important; }


/* profile photos */
.avatar { background-size: cover; background-position: center; overflow: hidden; }
.avatar.big { width: 104px; height: 104px; font-size: 2.2rem; margin: 0 auto; }

/* completed-day compact breakdown on Home */
.day-brief { list-style: none; margin: 10px 0 8px; }
.day-brief li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
  font-size: var(--fs-base);
}
.day-brief li:last-child { border-bottom: none; }
.day-brief .dim { flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ---------------- in-app toasts & modal dialogs ---------------- */
#toast-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 78px);
  z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  max-width: 460px; width: fit-content;
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--line); border-left: 3px solid var(--blue);
  border-radius: 12px; padding: 12px 16px;
  font-size: var(--fs-base); font-weight: 600; line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  opacity: 0; transform: translateY(12px); transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }

#modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.68);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fadein 0.18s ease;
}
#modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 20px 18px 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: modalpop 0.2s ease;
}
@keyframes modalpop { from { transform: scale(0.94); opacity: 0.4; } }
.modal h3 { margin-bottom: 4px; }
.modal .modal-msg { color: var(--dim); font-size: var(--fs-base); line-height: 1.45; margin: 6px 0 0; }
.modal input { margin-top: 14px; }
.modal .btn-row { margin-top: 16px; }

/* ---------------- v3.0 coach redesign: roster + lifter hub ---------------- */

.att-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; -webkit-overflow-scrolling: touch; }
.att-strip::-webkit-scrollbar { display: none; }
.att-chip {
  flex-shrink: 0; background: var(--amber-soft); color: var(--amber);
  border: 1px solid rgba(245, 166, 35, 0.35); border-radius: 999px;
  padding: 8px 14px; font-size: var(--fs-sm); font-weight: 700; min-height: 44px; display: inline-flex; align-items: center;
}

.mini-strip { display: flex; gap: 7px; margin: 8px 0 6px; }
.ms-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 22px; padding: 4px 0 3px; border-radius: var(--r-xs);
}
.ms-day.today { background: var(--blue-soft); }
.ms-day .ms-l { font-size: 0.66rem; font-weight: 700; color: var(--faint); }
.ms-day .d-mark { font-size: 0.6rem; height: 0.66rem; line-height: 0.66rem; font-weight: 900; }
.ms-day .d-dot { width: 6px; height: 6px; margin: 2px 0; }

.hub-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.hub-head h1 { font-size: 1.3rem; }
.hub-back {
  color: var(--dim); text-decoration: none; font-size: 1.7rem; line-height: 1;
  width: 44px; height: 44px; border-radius: var(--r-sm); flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.hub-tabs {
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: 2px; margin: 0 -16px 14px; padding: 8px 16px 0;
  background: rgba(4, 19, 27, 0.96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.hub-tabs a {
  flex: 1; text-align: center; padding: 10px 2px 11px;
  color: var(--dim); text-decoration: none; font-size: var(--fs-md); font-weight: 700;
  border-bottom: 2px solid transparent; position: relative; cursor: pointer;
}
.hub-tabs a.on { color: var(--text); border-bottom-color: var(--blue); }
.hub-tabs .tab-dot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; border-radius: var(--r-xs); margin-left: 5px; padding: 0 5px;
  background: var(--red); color: #fff; font-size: 0.68rem; font-weight: 800;
  vertical-align: 1px;
}
.hub-tabs .dot-blue {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue); margin-left: 5px; vertical-align: 6px;
}

/* ---------------- v3.0 programme editor ---------------- */
.prog-banner p { margin: 0; font-size: var(--fs-base); line-height: 1.5; }
.banner-blue { border-color: rgba(59, 179, 228, 0.4); }
.banner-green { border-color: rgba(46, 224, 138, 0.4); }
.banner-amber { border-color: rgba(245, 166, 35, 0.4); }

.prog-sess { padding: 0; overflow: hidden; }
.ps-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.ps-head:active { background: var(--surface2); }
.ps-chev { color: var(--dim); font-size: 1.3rem; transition: transform 0.18s ease; }
.ps-chev.open { transform: rotate(90deg); }
.ps-body { padding: 0 16px 16px; border-top: 1px solid var(--line); }

.ex-edit {
  background: var(--surface2); border-radius: var(--r-sm);
  padding: 12px 12px 10px; margin-top: 12px;
}
.ex-edit label { margin: 10px 0 4px; font-size: var(--fs-xs); }
.ex-edit input { background: rgba(4, 19, 27, 0.55); }
.ex-edit .exe-name { font-weight: 700; font-size: 1rem; height: 48px; }
.exe-grid { display: flex; gap: 8px; margin-top: 10px; }
.exf { flex: 1; position: relative; }
.exf input {
  width: 100%; height: 52px; text-align: center;
  font-size: 1.15rem; font-weight: 800; padding: 0 4px 14px;
}
.exf span {
  position: absolute; bottom: 6px; left: 0; right: 0; text-align: center;
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em;
  color: var(--faint); pointer-events: none;
}
.exe-foot { display: flex; gap: 8px; margin-top: 12px; }
.exe-foot button {
  flex: 1; background: none; border: 1px solid var(--line); border-radius: var(--r-xs);
  color: var(--dim); font-size: var(--fs-sm); font-weight: 600; padding: 9px 4px; min-height: 44px;
}
.exe-foot button:disabled { opacity: 0.3; }
.exe-foot .del { color: var(--red); border-color: rgba(239, 83, 80, 0.35); }

.save-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 16px); z-index: 70;
  width: min(480px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 10px;
  background: var(--surface2); border: 1px solid rgba(59, 179, 228, 0.45);
  border-radius: var(--r-lg); padding: 10px 12px 10px 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  animation: slideup 0.25s ease;
}
.save-bar[hidden] { display: none; }
.save-bar .sb-msg { flex: 1; font-size: var(--fs-md); font-weight: 700; }
.save-bar .save-btn { background: var(--blue); color: var(--bg); font-weight: 800; padding: 10px 22px; }

/* ---------------- v3 coach week planner ---------------- */
.week-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.week-nav button {
  width: 46px; height: 46px; padding: 0; font-size: 1.5rem; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--text);
}
.wn-mid { flex: 1; text-align: center; line-height: 1.35; }
.wn-mid strong { font-size: 1rem; }

/* planner: the day each session lands on */
.ps-day { font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; color: var(--blue); margin-bottom: 2px; }
.ps-day.warn { color: var(--amber); }

/* profile metadata + photo-in-tab */
.tab-ava { display: block; width: 26px; height: 26px; border-radius: 50%; background-size: cover; background-position: center; margin: 0 auto 2px; box-shadow: 0 0 0 1.5px var(--faint); }
#tabbar a.on .tab-ava { box-shadow: 0 0 0 2px var(--blue); }
.meta-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-base); }
.meta-row:last-of-type { border-bottom: none; }
.meta-val { font-weight: 700; font-variant-numeric: tabular-nums; }

/* sub-section label inside a tab section */
.acc-sub { font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); margin: 4px 2px 8px; }

/* drag-to-reorder sessions (coach programme / week editor) */
.sess-list { position: relative; }
.drag-grip {
  touch-action: none; cursor: grab; flex-shrink: 0;
  color: var(--faint); font-size: 1.15rem; line-height: 1;
  padding: 8px 8px 8px 2px; letter-spacing: -3px;
  user-select: none; -webkit-user-select: none;
}
.drag-grip:active { cursor: grabbing; color: var(--blue); }
.prog-sess.dragging { z-index: 1000; box-shadow: 0 16px 34px rgba(0, 0, 0, 0.6); pointer-events: none; }
.sess-placeholder { border: 2px dashed rgba(96, 175, 205, 0.4); background: rgba(59, 179, 228, 0.06); border-radius: var(--r-lg); box-sizing: border-box; }

/* schedule control in the programme-blueprint editor */
.sched-opt { padding: 12px 14px; margin-bottom: 8px; border: 1px solid var(--line); }
.sched-opt.on { border-color: var(--blue); background: var(--blue-soft); }
.sched-body { margin-top: 8px; font-size: var(--fs-base); color: var(--dim); }
.sched-inp { width: 46px !important; text-align: center; padding: 5px 4px !important; display: inline-block; margin: 0 2px; }
.daypick-row { display: flex; gap: 6px; flex-wrap: wrap; }
.sched-day { flex: 1; min-width: 44px; min-height: 44px; padding: 10px 0; background: var(--surface2); border: 1px solid var(--line); border-radius: var(--r-xs); font-size: var(--fs-sm); font-weight: 700; color: var(--text); }
.sched-day.on { background: var(--blue); color: var(--bg); border-color: transparent; }

/* collapsible movement groups in the "change exercise" picker */
.lift-group { border-top: 1px solid var(--line); }
.lift-group summary { padding: 11px 4px; font-weight: 700; font-size: var(--fs-md); color: var(--text); cursor: pointer; list-style: none; }
.lift-group summary::-webkit-details-marker { display: none; }
.lift-group summary::after { content: "＋"; float: right; color: var(--dim); font-weight: 400; }
.lift-group[open] summary::after { content: "－"; }

/* ---------------------------------------------------------------- v3.7 login refresh */
.login-wrap { padding-top: 12vh; text-align: center; position: relative; }
.login-wrap::before {
  content: ""; position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 520px; max-width: 130vw; height: 360px; z-index: 0;
  background: radial-gradient(50% 55% at 50% 0%, rgba(59, 179, 228, 0.18), transparent 72%);
  pointer-events: none;
}
.login-wrap > * { position: relative; z-index: 1; }
.brand-badge {
  width: 86px; height: 86px; margin: 0 auto 20px; overflow: hidden;
  border-radius: 24px; position: relative;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(158deg, #163b4d 0%, #0a2029 100%);
  border: 1px solid rgba(96, 175, 205, 0.24);
  box-shadow: 0 14px 34px rgba(4, 19, 27, 0.65), 0 0 0 7px rgba(59, 179, 228, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.brand-badge::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 60%;
  background: radial-gradient(70% 100% at 50% 0%, rgba(59, 179, 228, 0.3), transparent 70%);
  pointer-events: none;
}
.brand-badge svg { position: relative; z-index: 1; }
.logo { font-size: 2.45rem; font-weight: 900; letter-spacing: -0.045em; line-height: 1; }
.login-title { font-size: 1.75rem; font-weight: 900; letter-spacing: -0.03em; }
.logo em, .login-title em { color: var(--blue); font-style: normal; }
.brand-tag { color: var(--dim); font-size: var(--fs-lg); margin-top: 8px; }
.login-wrap form {
  text-align: left; margin: 30px auto 0; max-width: 360px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 18px 22px;
  box-shadow: 0 10px 30px rgba(4, 19, 27, 0.45);
}
.login-wrap form .btn-primary { margin-top: 20px; }
/* Lives inside the card, right under the PIN field, so the keyboard can't hide it. */
.login-hint { color: var(--dim); font-size: var(--fs-sm); line-height: 1.5; margin: 8px 2px 0; text-align: left; }
/* When a field takes focus the browser scrolls it into view; leave room below it so the hint
   and the Log in button come up above the keyboard too. */
.login-wrap input { scroll-margin: 24px 0 180px; }
/* Short viewports (keyboard open on Android, small phones): compact the brand block. */
@media (max-height: 640px) {
  .login-wrap { padding-top: 4vh; }
  .brand-badge { transform: scale(0.8); margin-bottom: 0; }
  .brand-tag { display: none; }
}
.login-wrap .brand { animation: loginRise 0.5s ease both; }
.login-wrap form { animation: loginRise 0.5s ease 0.07s both; }
.login-hint { animation: none; }
@keyframes loginRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* coach backfill: log-what-he-did set rows */
.log-setrow { display: flex; align-items: center; gap: 6px; margin: 5px 0; }
.log-setrow .ls-n { flex: 0 0 42px; color: var(--faint); font-size: var(--fs-sm); font-weight: 700; }
.log-setrow .ls-u { color: var(--faint); font-size: var(--fs-xs); }
.log-setrow input { width: 62px; text-align: center; padding: 8px 4px; font-weight: 700; }

/* exercise demo video (sheet) */
.demo-wrap {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: var(--r-sm); overflow: hidden; background: #000;
  border: 1px solid var(--line);
}
.demo-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------------- accessibility: focus rings + reduced motion ---------------- */
/* Keyboard / switch-access users get a clear ring; touch and mouse users don't. */
button:focus-visible, a:focus-visible, .tile-row:focus-visible, .card.tappable:focus-visible,
[data-action]:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
}
