/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f0f0f;
  --bg2:       #1a1a1a;
  --bg3:       #242424;
  --border:    #333;
  --accent:    #3498db;   /* main colour: actions, highlights, progress */
  --red:       #e94560;   /* only for missed, the running rest timer, and Reset */
  --accent2:   #f5a623;
  --text:      #f0f0f0;
  --text2:     #999;
  --green:     #2ecc71;
  --blue:      #3498db;   /* "get ready / do this next" (timer's last 5 s, today, Start) */
  --radius:    12px;
  --nav-h:     68px;
  --header-h:  52px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-t:    env(safe-area-inset-top, 0px);   /* iPhone status bar / notch */
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 16px; }

#app { display: flex; flex-direction: column; height: 100dvh; }

/* ── Header ── */
#app-header {
  /* Sit below the status bar: the app draws under it (viewport-fit=cover + black-translucent) */
  height: calc(var(--header-h) + var(--safe-t));
  padding-top: var(--safe-t) !important;
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#screen-title { font-size: 1.1rem; font-weight: 700; }

/* ── Main scroll area ── */
#screen-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 14px;
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
}

/* ── Bottom nav ── */
#bottom-nav {
  display: flex;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; border: none; background: none; color: var(--text2);
  font-size: 0.65rem; cursor: pointer; -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-btn .nav-icon { width: 24px; height: 24px; }
#weight-btn { gap: 6px; }
#demo-btn { margin-right: 6px; color: var(--accent2); border-color: var(--accent2); } /* temporary */
#reset-btn { margin-right: 8px; color: var(--red); border-color: var(--red); } /* temporary */
.nav-btn.active { color: var(--accent); }

/* ── Cards ── */
.card {
  background: var(--bg2); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 14px; margin-bottom: 10px;
}
.card-title { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); margin-bottom: 8px; }
.card h2 { font-size: 1rem; margin-bottom: 4px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: none; cursor: pointer; font-size: 0.95rem; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.85rem; border-radius: 8px; }
.btn-icon { width: 44px; height: 44px; padding: 0; border-radius: 50%; background: var(--bg3); color: var(--text); border: 1px solid var(--border); font-size: 1.2rem; }
.btn-full { width: 100%; }

/* ── Week strip ── */
.week-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.week-strip::-webkit-scrollbar { display: none; }
.day-chip {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center;
  min-width: 0; min-height: 64px; padding: 8px 2px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--bg3);
  cursor: pointer; gap: 3px; -webkit-tap-highlight-color: transparent;
}
.day-chip.today { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, var(--bg3)); }
.day-chip.today .dc-dow { color: var(--blue); }
#start-btn { background: var(--blue); }
.day-chip.done { background: color-mix(in srgb, var(--green) 15%, var(--bg3)); border-color: var(--green); }
.day-chip .dc-dow { font-size: 0.65rem; text-transform: uppercase; color: var(--text2); }
.day-chip .dc-date { font-size: 0.85rem; font-weight: 700; }
.day-chip .dc-label { font-size: 0.55rem; color: var(--text2); text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-chip.done .dc-label { color: var(--green); }
.dc-label.planned { font-style: italic; opacity: 0.7; }
.dc-label.moved { color: var(--accent2); opacity: 1; }
.day-chip { position: relative; overflow: hidden; }
.dc-mark { width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.day-chip.done .dc-mark { background: var(--green); color: #fff; }
.dc-mark .icon { width: 11px; height: 11px; stroke-width: 3.5; }
.day-chip.missed { border-color: color-mix(in srgb, var(--red) 60%, var(--border)); }
.day-chip.missed .dc-label { color: var(--red); }
.day-chip.missed::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top right, transparent calc(50% - 1.5px), var(--red) calc(50% - 1.5px),
    var(--red) calc(50% + 1.5px), transparent calc(50% + 1.5px));
}
.wo-option {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 10px;
  background: none; border: 1.5px solid transparent; border-bottom-color: var(--border); border-radius: 0;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.wo-option.selected { border: 1.5px solid var(--accent); border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.wo-option .radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; }
.wo-option.selected .radio { border-color: var(--accent); box-shadow: inset 0 0 0 4px var(--bg2); background: var(--accent); }
.wo-name { font-weight: 600; }
.done-pill { width: 36px; height: 36px; border-radius: 50%; background: var(--green); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.done-pill .icon { width: 20px; height: 20px; stroke-width: 3; }
#toggle-done-btn { gap: 6px; }
.catchup { padding: 10px 12px; border-radius: 10px; background: var(--bg3); border: 1px dashed var(--border); }

/* ── Progress bar ── */
.progress-bar { height: 8px; border-radius: 4px; background: var(--bg3); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.3s; }

/* ── Checklist ── */
.checklist-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.checklist-item:last-child { border-bottom: none; }
.check-box {
  width: 26px; height: 26px; border-radius: 6px; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 1rem;
}
.checklist-item.checked .check-box { background: var(--green); border-color: var(--green); }
.checklist-item.checked .check-box::after { content: '✓'; color: #fff; font-weight: 700; }
.checklist-item.checked .check-label { text-decoration: line-through; color: var(--text2); }

/* ── Meals ── */
.meal-summary { display: block; width: 100%; text-align: left; color: var(--text); font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.meal-summary .chevron { width: 22px; height: 22px; color: var(--text2); transition: transform 0.2s; }
.meal-summary[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.meal-card.next { border-color: var(--accent); }
.meal-card.done { opacity: 0.6; }
.meal-head { display: flex; align-items: center; gap: 12px; }
.meal-title { flex: 1; font-weight: 700; }
.meal-title .badge { font-size: .6rem; vertical-align: middle; }
.meal-time { align-self: flex-start; font-size: .75rem; color: var(--text2); white-space: nowrap; padding-top: 2px; }
.meal-check {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); background: var(--bg3); color: transparent;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.meal-check .icon { width: 24px; height: 24px; stroke-width: 2.5; }
.meal-card.next .meal-check { border-color: var(--accent); }
.meal-card.done .meal-check { background: var(--green); border-color: var(--green); color: #fff; }
.meal-items { margin-top: 10px; }
.meal-item {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 54px;
  background: none; border: none; border-top: 1px solid var(--border); color: var(--text); font: inherit; font-size: 1rem;
  text-align: left; padding: 8px 4px; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.meal-item:active { background: var(--bg2); }
.meal-item.optional { color: var(--text2); font-style: italic; }
.mini-check {
  width: 30px; height: 30px; border-radius: 7px; border: 2px solid var(--text2);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: transparent;
}
.mini-check .icon { width: 20px; height: 20px; stroke-width: 3; }
.meal-item.checked .mini-check { background: var(--green); border-color: var(--green); color: #fff; }
.meal-item.checked > span:last-child { text-decoration: line-through; color: var(--text2); }
.meal-item.skipped > span:last-child { color: var(--text2); opacity: .6; }
.meal-item.skipped > span:last-child::after { content: " · skipped"; font-size: .75rem; font-style: italic; }
.btn-icon:disabled { opacity: 0.3; }

/* ── Water counter ── */
.water-row { display: flex; align-items: center; gap: 10px; }
.water-glasses { display: flex; flex-wrap: wrap; gap: 6px; }
.water-glass {
  width: 36px; height: 36px; border-radius: 8px;
  border: 2px solid var(--border); background: var(--bg3);
  cursor: pointer; font-size: 1.1rem; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
select.select-sm { width: auto; padding: 4px 8px; font-size: 0.82rem; min-height: 32px; }
.water-glass { color: var(--text2); padding: 0; }
.water-glass.extra { border-style: dashed; }
.water-plus { color: var(--text); }
.link-btn { background: none; border: none; color: var(--text); font: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; padding: 6px 0; display: inline-flex; align-items: center; gap: 4px; }
.water-glass .icon { width: 18px; height: 18px; }
.water-glass.filled { background: var(--text); border-color: var(--text); color: var(--bg); }
.water-glass.filled .icon { fill: currentColor; }

/* ── Exercise log ── */
.exercise-card { background: var(--bg3); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
.exercise-name { font-weight: 700; font-size: 0.95rem; margin-bottom: 2px; }
.exercise-meta { font-size: 0.75rem; color: var(--text2); margin-bottom: 8px; }
.set-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-num { width: 24px; color: var(--text2); font-size: 0.8rem; }
.set-input {
  flex: 1; min-height: 40px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); font-size: 0.9rem; text-align: center;
  padding: 4px 6px;
}
.set-input::placeholder { color: #6a6a78; opacity: 1; }
.set-input:focus::placeholder { color: #45454f; }
.set-done-btn {
  width: 40px; height: 40px; border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--bg2); color: var(--text2); cursor: pointer; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.set-done-btn.done { background: color-mix(in srgb, var(--green) 20%, var(--bg2)); border-color: var(--green); color: var(--green); }
.set-grid { display: grid; grid-template-columns: 24px 76px 1fr 40px; gap: 8px; align-items: center; }
.set-head { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); padding: 8px 0 2px; }
.clear-sets {
  background: none; border: none; color: var(--text2); font: inherit; font-size: 0.68rem;
  text-transform: uppercase; letter-spacing: .05em; text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer; padding: 6px 0; -webkit-tap-highlight-color: transparent;
}
.set-head span:nth-child(2) { white-space: nowrap; overflow: visible; }
.set-row.set-grid { display: grid; }
.set-grid .set-input { min-width: 0; width: 100%; }
.last-cell {
  min-height: 40px; border-radius: 8px; border: 1px dashed var(--border); background: none;
  color: var(--text2); font: inherit; font-size: 0.85rem; cursor: pointer; padding: 0 4px; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.last-cell.empty { border: none; text-align: center; cursor: default; display: flex; align-items: center; justify-content: center; }
.target-line {
  display: flex; flex-direction: column; gap: 2px; width: 100%; margin: 4px 0 8px; padding: 8px 10px;
  font: inherit; font-size: 0.85rem; line-height: 1.4; text-align: left; color: var(--text); cursor: pointer;
  background: color-mix(in srgb, var(--accent2) 8%, transparent); border: 1px solid color-mix(in srgb, var(--accent2) 40%, transparent);
  border-radius: 8px; -webkit-tap-highlight-color: transparent;
}
.target-line:active { background: color-mix(in srgb, var(--accent2) 18%, transparent); }
.target-fill { font-size: 0.72rem; color: var(--accent2); font-weight: 600; }
/* Numbers entered but set not ticked yet (e.g. filled from target) */
.set-row:not(.is-done) .set-input:not(:placeholder-shown) { color: var(--accent2); border-style: dashed; border-color: color-mix(in srgb, var(--accent2) 50%, var(--border)); }
.set-row.is-done .set-input { border-color: color-mix(in srgb, var(--green) 50%, var(--border)); }
.target-tag { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent2); border: 1px solid var(--accent2); border-radius: 4px; padding: 1px 5px; margin-right: 4px; }
.section-toggle {
  display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 32px;
  background: none; border: none; padding: 0; color: var(--text); font: inherit; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.section-toggle .chevron { width: 22px; height: 22px; color: var(--text2); transition: transform 0.2s; }
.section-toggle[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.warmup-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 48px;
  padding: 8px 0; background: none; border: none; border-bottom: 1px solid var(--border);
  color: var(--text); font: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.warmup-item .icon { color: var(--text2); }
.wu-name { font-size: 0.92rem; }
/* Black-on-white line art, inverted to light-on-dark to match the app */
.wu-figure { margin: 0 0 12px; border-radius: 10px; overflow: hidden; background: #000; }
.wu-figure img { display: block; width: 100%; height: auto; filter: invert(1) grayscale(1); mix-blend-mode: screen; }
.wu-figure figcaption { display: flex; justify-content: space-around; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text2); padding: 6px 0 8px; background: var(--bg2); }
.wu-steps { padding-left: 20px; margin: 12px 0; line-height: 1.5; font-size: 0.9rem; }
.wu-steps li { margin-bottom: 6px; }
a.btn { text-decoration: none; }
.tempo-chip {
  font: inherit; font-weight: 700; color: var(--text); background: var(--bg2); cursor: pointer;
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; min-height: 26px;
  text-decoration: underline dotted; text-underline-offset: 3px; -webkit-tap-highlight-color: transparent;
}
.tempo-phase { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.tempo-num { width: 44px; height: 44px; border-radius: 10px; background: var(--bg3); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 800; flex-shrink: 0; }
.pr-badge { font-size: 0.65rem; color: var(--accent2); font-weight: 700; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--accent2); }
.last-session { font-size: 0.72rem; color: var(--text2); }

/* ── Timer ── */
/* Pinned pill under the header, shown when the inline countdown is scrolled away */
#rest-timer-bar {
  position: fixed; top: calc(var(--header-h) + var(--safe-t) + 8px); left: 50%; z-index: 150;
  transform: translate(-50%, -8px); opacity: 0; visibility: hidden;
  display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 6px;
  background: var(--bg3); border: 1px solid var(--red); border-radius: 999px;
  box-shadow: 0 6px 20px rgba(0,0,0,.5); max-width: calc(100vw - 24px);
  transition: opacity .2s, transform .2s, visibility .2s;
}
#rest-timer-bar.visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
#rest-timer-bar.work { border-color: var(--accent2); }
#rest-timer-bar.go { background: var(--green); border-color: var(--green); animation: ti-pulse .6s ease-in-out infinite alternate; }
.tp-main { background: none; border: 0; color: var(--text); font-weight: 800; font-size: 1rem; padding: 4px 8px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.tp-label { font-weight: 400; font-size: .72rem; color: var(--text2); margin-left: 6px; }
#rest-timer-bar.go .tp-label { color: rgba(255,255,255,.85); }
.tp-btn { background: var(--bg2); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; font-size: .8rem; font-weight: 600; min-height: 34px; }

/* Inline countdown inside the exercise card, under the set you just ticked */
.timer-slot:empty { display: none; }
.timer-slot.active { margin: 6px 0; padding: 10px 12px; border-radius: 10px; background: rgba(233,69,96,.12); border: 1px solid var(--red); }
.timer-slot.work { background: rgba(245,166,35,.12); border-color: var(--accent2); }
.timer-slot.go { background: rgba(46,204,113,.18); border-color: var(--green); animation: ti-pulse .6s ease-in-out infinite alternate; }
.ti-row { display: flex; align-items: center; gap: 8px; }
.ti-time { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 72px; }
.timer-slot.go .ti-time { color: var(--green); }
.ti-sub { flex: 1; color: var(--text2); line-height: 1.2; }
.ti-bar { height: 4px; background: var(--bg3); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.ti-fill { height: 100%; background: var(--red); transition: width .1s linear; }
.timer-slot.work .ti-fill { background: var(--accent2); }
.work-btn { background: none; border: 1px solid var(--accent2); color: var(--accent2); border-radius: 999px; padding: 2px 10px; font-size: .75rem; font-weight: 700; margin-left: 4px; }
@keyframes ti-pulse { from { filter: brightness(1); } to { filter: brightness(1.35); } }

/* ── Modal ── */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 200;
  display: flex; align-items: flex-end; padding-bottom: var(--safe-b);
}
#modal-overlay.hidden { display: none; }
#modal-box {
  background: var(--bg2); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-height: 80dvh; overflow-y: auto; padding: 20px 16px 32px;
  position: relative;
}
#modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 50%; border: none;
  background: var(--bg3); color: var(--text); font-size: 1rem; cursor: pointer;
}

/* ── Toast ── */
#toast {
  position: fixed; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); left: 50%;
  transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: 10px 18px; border-radius: 20px; font-size: 0.85rem;
  z-index: 300; pointer-events: none; opacity: 1; transition: opacity 0.4s;
}
#toast.hidden { opacity: 0; }

/* ── Chart canvas ── */
.chart-wrap { position: relative; width: 100%; height: 200px; }
canvas.chart { width: 100%; height: 100%; }

/* ── Misc ── */
.section-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--text2); margin: 14px 0 6px; }
.row { display: flex; gap: 8px; align-items: center; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.mt8 { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.text-sm { font-size: 0.82rem; }
.text-muted { color: var(--text2); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-red { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }
.badge-green { background: color-mix(in srgb, var(--green) 20%, transparent); color: var(--green); }
.divider { height: 1px; background: var(--border); margin: 12px 0; }
input[type=number], input[type=text], .field input {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 1rem; padding: 8px 12px;
}
select {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 1rem; padding: 8px 12px; width: 100%;
}
.macro-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.macro-name { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); }
.macro-val { font-size: .95rem; margin: 2px 0 6px; white-space: nowrap; }
.macro-val strong { font-size: 1.15rem; }
.meal-macros { font-size: .72rem; font-weight: 400; color: var(--text2); margin-top: 1px; }
.extra-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border, #2a2a2a); margin-top: 8px; }
.preset-list { display: flex; flex-wrap: wrap; gap: 6px; }
.preset { background: var(--bg3, #2a2a2a); color: inherit; border: 1px solid var(--border, #333); border-radius: 999px; padding: 6px 10px; font-size: .8rem; }
.field { display: block; font-size: .75rem; color: var(--text2); margin-top: 8px; }
.field input { display: block; width: 100%; margin-top: 4px; box-sizing: border-box; }
.xf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ti-clock { min-width: 72px; }
.ti-range { font-size: .65rem; color: var(--text2); margin-top: -2px; }
.ti-sub { overflow: hidden; text-align: center; }
.ti-tip { display: inline-block; }
.ti-tip.in { animation: ti-tip-in .35s ease-out; }
@keyframes ti-tip-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
.ti-tip { color: var(--text); font-size: .85rem; }
/* Last 5 seconds: blue "get ready" */
.timer-slot.soon { background: rgba(52,152,219,.18); border-color: var(--blue); transition: background .3s, border-color .3s; }
.timer-slot.soon .ti-time { color: #5dade2; }
.timer-slot.soon .ti-fill { background: var(--blue); }
#rest-timer-bar.soon { border-color: var(--blue); background: #1b3a52; }
#build-tag { font-size: .7rem; color: var(--text2); opacity: .9; margin-left: 6px; margin-right: auto; align-self: center; font-weight: 400; }
.past-banner { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg2)); }
.day-chip.skipped .dc-label { color: var(--text2); font-style: italic; }
.day-chip.viewing { outline: 2px solid var(--accent); outline-offset: -2px; }
.mt16 { margin-top: 16px; }
/* Completed but some exercises left out */
.day-chip.done.partial { background: color-mix(in srgb, var(--accent2) 15%, var(--bg3)); border-color: var(--accent2); }
.day-chip.done.partial .dc-label { color: var(--accent2); }
.day-chip.done.partial .dc-mark { background: var(--accent2); }
.ex-count { text-align: right; color: var(--accent2); line-height: 1.1; }
.ex-count strong { display: block; font-size: 1.1rem; }
.ex-count span { font-size: .7rem; }
/* History: long view */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-row > div { background: var(--bg3); border-radius: 10px; padding: 8px; text-align: center; }
.stat-row strong { display: block; font-size: 1.25rem; }
.stat-row strong span { font-size: .8rem; color: var(--text2); font-weight: 400; }
.stat-row em { font-style: normal; font-size: .65rem; color: var(--text2); }
.cg { display: flex; flex-direction: column; gap: 4px; }
.cg-row { display: grid; grid-template-columns: 38px repeat(7, 1fr) 30px; gap: 4px; align-items: center; }
.cg-head span { font-size: .6rem; color: var(--text2); text-align: center; }
.cg-wk { font-size: .65rem; color: var(--text2); }
.cg-n { font-size: .65rem; color: var(--text2); text-align: right; }
.cg-cell { display: block; height: 18px; border-radius: 4px; background: var(--bg3); }
.cg-cell.done { background: var(--green); }
.cg-cell.partial { background: var(--accent2); }
.cg-cell.missed { background: var(--red); }
.cg-cell.skipped { background: #555; }
.cg-cell.rest { background: var(--bg3); }
.cg-cell.upcoming { background: transparent; border: 1px dashed var(--border); }
.cg-key { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.cg-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.seg { display: inline-flex; background: var(--bg3); border-radius: 999px; padding: 2px; }
.seg button { background: none; border: 0; color: var(--text2); font-size: .72rem; padding: 4px 10px; border-radius: 999px; }
.seg button.on { background: var(--accent); color: #fff; }
.mb { display: flex; gap: 6px; align-items: flex-end; margin-top: 10px; }
.mb-col { flex: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.mb-val { font-size: .58rem; color: var(--text2); height: 14px; white-space: nowrap; }
.mb-track { position: relative; width: 100%; height: 110px; background: var(--bg3); border-radius: 6px; overflow: hidden; }
.mb-bar { position: absolute; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--accent) 55%, var(--bg3)); border-radius: 6px 6px 0 0; }
.mb-bar.ok { background: var(--accent); }
.mb-goal { position: absolute; left: -2px; right: -2px; height: 2px; background: var(--text); }
.mb-wk { font-size: .6rem; color: var(--text2); margin-top: 4px; }
.mb-days { font-size: .58rem; color: var(--text2); }
.mb-days.gap { color: var(--accent2); }
.mb-key-goal { background: var(--text); height: 2px !important; vertical-align: 3px !important; }
.mb-key-bar { background: color-mix(in srgb, var(--accent) 55%, var(--bg3)); }
.mb-key-bar.ok { background: var(--accent); }
/* Meals page */
.mp-meal { border-top: 1px solid var(--border); padding: 10px 0 4px; margin-top: 8px; }
.mp-item { display: flex; justify-content: space-between; gap: 8px; font-size: .82rem; padding: 3px 0; }
.mp-item span:last-child { white-space: nowrap; font-size: .72rem; }
.mp-item.optional span:first-child { color: var(--text2); font-style: italic; }
.mp-in { background: var(--bg3); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 8px; font-size: .85rem; width: 100%; font-family: inherit; }
.mp-num { width: 58px; flex: none; text-align: center; padding: 8px 4px; }
/* Timer pause */
.tp-pause { background: var(--accent); border-color: var(--accent); color: #fff; }
.tp-icon { width: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.tp-icon svg { width: 16px; height: 16px; fill: currentColor; }
.tp-x { padding: 6px 10px; color: var(--text2); }
.timer-slot.paused { background: var(--bg3); border-color: var(--text2); animation: none; }
.timer-slot.paused .ti-time { color: var(--text2); }
.timer-slot.paused .ti-fill { background: var(--text2); }
#rest-timer-bar.paused { border-color: var(--text2); }
.set-input.missing { border-color: var(--red) !important; background: color-mix(in srgb, var(--red) 12%, var(--bg3)) !important; }
/* Workout: exercise strip + collapsible exercises */
.ex-strip { position: sticky; top: -12px; z-index: 20; padding: 8px 0 8px 8px; margin: 0 -2px 10px; box-shadow: 0 6px 14px rgba(0,0,0,.45); }
.xs-row { display: flex; gap: 6px; align-items: stretch; overflow-x: auto; scroll-snap-type: x proximity; padding-right: 8px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.xs-row::-webkit-scrollbar { display: none; }
.xs-group { display: flex; gap: 4px; flex: none; }
.xs-group.ss { padding-top: 4px; border-top: 3px solid var(--text2); border-radius: 6px 6px 0 0; }
.xs-tile { flex: none; width: 74px; min-height: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 4px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--bg3); color: var(--text2); scroll-snap-align: start; }
.xs-tile b { font-size: 1.15rem; color: var(--text); white-space: nowrap; line-height: 1.1; }
.xs-tile span { font-size: .68rem; line-height: 1.15; text-align: center; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.xs-tile em { font-style: normal; font-size: .8rem; font-weight: 600; }
.xs-tile.next { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 14%, var(--bg3)); }
.xs-tile.next b, .xs-tile.next em { color: var(--blue); }
.xs-tile.some { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 14%, var(--bg3)); }
.xs-tile.some em { color: var(--accent2); }
.xs-tile.done { border-color: var(--green); background: color-mix(in srgb, var(--green) 18%, var(--bg3)); }
.xs-tile.done b, .xs-tile.done em { color: var(--green); }
.ex-head { cursor: pointer; gap: 8px; }
.ex-head .exercise-name { flex: 1; }
.ex-prog { font-size: .75rem; color: var(--text2); white-space: nowrap; }
.ex-prog.some { color: var(--accent2); } .ex-prog.done { color: var(--green); }
.ex-head .chevron { width: 18px; height: 18px; color: var(--text2); transition: transform .2s; transform: rotate(180deg); }
.exercise-card.collapsed .chevron { transform: none; }
.exercise-card.collapsed .ex-body { display: none; }
.exercise-card.collapsed .exercise-name { margin-bottom: 0; }
.exercise-card, .warmup-card, #workout-exercise-list > .card { scroll-margin-top: 112px; }
.xs-tile.cur { border-color: var(--blue); box-shadow: inset 0 0 0 2px var(--blue); }

.md-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.md-tile { width: auto; min-height: 72px; padding: 6px 2px; }
.md-tile span { font-size: .66rem; text-transform: uppercase; }
.md-tile.future { opacity: .45; }
/* Meal plan: squares + collapsible meals (same pattern as Workouts) */
.mp-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mp-tile { width: auto; min-height: 68px; }
.mp-head { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; color: var(--text); text-align: left; padding: 0; cursor: pointer; }
.mp-name { flex: 1; }
.mp-head .chevron { width: 18px; height: 18px; color: var(--text2); transform: rotate(180deg); transition: transform .2s; }
.mp-meal.collapsed .chevron { transform: none; }
.mp-meal.collapsed .mp-body { display: none; }
.mp-body { margin-top: 6px; }
/* Today's meals: collapsible like Workouts */
.meal-card .meal-head { cursor: pointer; }
.meal-card .meal-head .chevron { width: 18px; height: 18px; color: var(--text2); flex: none; transform: rotate(180deg); transition: transform .2s; }
.meal-card.collapsed .chevron { transform: none; }
.meal-card.collapsed .meal-items { display: none; }
.mp-tile.some { border-color: var(--accent2); background: color-mix(in srgb, var(--accent2) 14%, var(--bg3)); }
.mp-tile.some em { color: var(--accent2); }

/* Today: section edges (blue = workout, green = food) */
.card.sec-workout, .card.sec-food, .sec-food-group > .card { border-left: 4px solid var(--accent); }
.card.sec-food, .sec-food-group > .card { border-left-color: var(--green); }

/* Text size setting: scale the scrolling page and modals as a whole */
#screen-container > *, #modal-content { zoom: var(--ui-zoom, 1.15); }
.nav-btn span { font-size: 0.8rem; }

/* Exercise name opens the coach's instructions */
.ex-info-btn { background: none; border: none; padding: 4px 0; color: var(--text); font: inherit; font-weight: 700; font-size: 0.95rem; text-align: left; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; -webkit-tap-highlight-color: transparent; }
.ex-info-i { width: 17px; height: 17px; color: var(--accent); }
.info-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.info-chips span { background: var(--bg3); border-radius: 8px; padding: 6px 10px; font-size: .8rem; color: var(--text2); }
.info-chips strong { color: var(--text); font-size: .95rem; margin-right: 3px; }
.ex-head .ex-info-btn { flex: 0 1 auto; margin-right: auto; }

/* Superset as rounds */
.ss-card .set-grid { grid-template-columns: 30px 72px 1fr 40px; }
.ss-how { font-size: .85rem; background: color-mix(in srgb, var(--accent) 12%, var(--bg2)); border-radius: 8px; padding: 8px 10px; margin: 4px 0 10px; }
.ss-ex { border-top: 1px solid var(--border); padding-top: 8px; margin-bottom: 8px; }
.ss-ex .ex-info-btn { margin-right: auto; }
.set-tag { color: var(--accent); font-weight: 700; font-size: .8rem; width: auto; background: none; border: none; padding: 6px 0; font-family: inherit; text-decoration: underline dotted; text-underline-offset: 3px; cursor: pointer; }
.ss-round { border-top: 1px solid var(--border); padding: 6px 0 4px; }
.ss-round-title { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--text2); margin-bottom: 2px; }
.ss-rest { text-align: center; font-size: .75rem; color: var(--text2); padding-top: 2px; }
.set-row.ss-cur { background: color-mix(in srgb, var(--accent) 14%, transparent); border-radius: 8px; box-shadow: inset 3px 0 0 var(--accent); }
/* More room for the weight/reps boxes: thinner outer card around exercises, narrower Last column */
#workout-exercise-list > .card:has(> .exercise-card) { padding: 4px; }
.set-grid { grid-template-columns: 24px 62px 1fr 40px; gap: 6px; }
.ss-card .set-grid { grid-template-columns: 28px 62px 1fr 40px; }
/* Inline timer: use the card's full width so "Up next" has room */
.exercise-card .timer-slot.active { margin: 6px -8px; padding: 10px 8px; }
.exercise-card .ti-time, .exercise-card .ti-clock { min-width: 62px; }
.ti-sub { min-width: 0; font-size: .85rem; }
.ss-round .set-row { padding-left: 10px; padding-right: 4px; }
/* Expanded exercise/superset card gets the same grey outline as the superset bracket in the strip */
.exercise-card { border: 2px solid transparent; }
.exercise-card:not(.collapsed) { border-color: var(--text2); }
/* Superset heading band: title + "how to" line share a slightly lighter background */
.ss-card:not(.collapsed) > .ex-head { background: color-mix(in srgb, #fff 6%, var(--bg3)); margin: -12px -12px 0; padding: 12px 12px 4px; border-radius: 8px 8px 0 0; }
.ss-card:not(.collapsed) .ss-how { background: color-mix(in srgb, #fff 6%, var(--bg3)); margin: 0 -12px 10px; padding: 2px 12px 12px; border-radius: 0; color: var(--text2); }
#account-btn.signed-in { border-color: var(--green); color: var(--green); }
#signin-code-row.hidden { display: none; }
