:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #ddd8d0;
  --card: #ffffff;
  --accent: #2b6b3f;
  --miss: #a3271f;
  --miss-bg: #fbe9e7;
  --plan: #6b6b6b;
  --max: #9a4d00;
}

/* Dark follows the OS until the topbar toggle (theme.js) saves a choice on
   <html data-theme>; hence the same values twice — once for the OS, once for
   an explicit "dark" that has to win even on a light-mode OS. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #16171a;
    --fg: #e9e9e6;
    --muted: #9a9a94;
    --border: #33342f;
    --card: #202126;
    --accent: #6fbf85;
    --miss: #ff6b60;
    --miss-bg: #3a1d1a;
    --plan: #9a9a94;
    --max: #f0a95a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16171a;
  --fg: #e9e9e6;
  --muted: #9a9a94;
  --border: #33342f;
  --card: #202126;
  --accent: #6fbf85;
  --miss: #ff6b60;
  --miss-bg: #3a1d1a;
  --plan: #9a9a94;
  --max: #f0a95a;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.4;
}

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar h1 { margin: 0; font-size: 1.25rem; }
.brand { text-decoration: none; color: var(--fg); }

/* Title (the home link) + two icon dropdowns (Schedule, Progress) — the same
   header as recipe-planner. app.js wires one document listener for open/close/
   click-outside and marks the current page. Inline SVG rather than emoji so the
   icons share one stroke weight and take their color from the theme. */
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-group { position: relative; }
.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
button.nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
button.nav-toggle:hover { background: var(--card); color: var(--accent); }
button.nav-toggle.current { color: var(--fg); }
button.nav-toggle[aria-expanded="true"] {
  background: var(--card);
  border-color: var(--border);
  color: var(--accent);
}
.nav-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  min-width: 11rem;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}
.nav-menu[hidden] { display: none; }
.nav-menu a {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}
.nav-menu a:hover { color: var(--accent); }
.nav-menu a.current { color: var(--fg); background: var(--bg); }

main#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

.loading { color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.stat { min-width: 8rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 0.85rem; }

.failure-banner {
  background: var(--miss-bg);
  color: var(--miss);
  border: 1px solid var(--miss);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

ul.checklist { list-style: none; margin: 0; padding: 0; }
ul.checklist > li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
ul.checklist > li:last-child { border-bottom: none; }
ul.checklist input[type="checkbox"] { width: 1.15rem; height: 1.15rem; }
ul.checklist .exercise-name { font-weight: 600; }
ul.checklist .target { color: var(--muted); font-size: 0.85rem; }
ul.checklist > li.done .exercise-name { text-decoration: line-through; color: var(--muted); }

button {
  font: inherit;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
}
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: default; }

table.history { width: 100%; border-collapse: collapse; }
table.history th, table.history td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
}
tr.status-missed td { color: var(--miss); font-weight: 600; }
tr.status-completed td.status-cell { color: var(--accent); font-weight: 600; }
tr.status-planned td.status-cell { color: var(--plan); }

/* ---- Quick Log: minimal mobile page for mid-workout use ---- */

.quick-body {
  padding-left: max(0.75rem, env(safe-area-inset-left));
  padding-right: max(0.75rem, env(safe-area-inset-right));
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
}

.quick-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: max(0.75rem, env(safe-area-inset-top)) 0 0.75rem;
  border-bottom: 1px solid var(--border);
}
.quick-topbar h1 { font-size: 1.2rem; margin: 0; }
.quick-back { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.95rem; }

#quick-app { max-width: 30rem; margin: 0 auto; padding: 1rem 0; }

ul.quick-checklist { list-style: none; margin: 0 0 1rem; padding: 0; }
ul.quick-checklist li { border-bottom: 1px solid var(--border); }
ul.quick-checklist li:last-child { border-bottom: none; }
ul.quick-checklist li.done .quick-exercise-name { text-decoration: line-through; color: var(--muted); }

ul.quick-checklist label {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.85rem 0.25rem;
  cursor: pointer;
}
ul.quick-checklist input[type="checkbox"] {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
}
.quick-exercise-name { font-weight: 600; font-size: 1.05rem; }
.quick-target { color: var(--muted); font-size: 0.9rem; }

button.quick-complete { width: 100%; min-height: 3.25rem; font-size: 1.05rem; }

/* ---- Sign-in ---- */

/* Controls that can only fail for a guest. `!important` because they carry
   classes of their own that may set display, and this has to win — the same
   fight as the [hidden] trap. The server refuses the write regardless; this
   only stops the page offering it. <html data-role> starts as "guest" in the
   HTML, so nothing flashes up. */
html:not([data-role='member']):not([data-role='admin']) .needs-member { display: none !important; }

/* Sign in / the account avatar, pushed to the far end of the topbar. */
.auth-control { margin-left: auto; display: flex; align-items: center; font-size: 0.9rem; }

/* Light/dark switch (theme.js). It takes over pushing to the far end, so the
   avatar after it sits beside it rather than splitting the free space. */
.theme-toggle {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--fg);
  font-family: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle + .auth-control { margin-left: 0; }
.auth-control:empty { display: none; }
.auth-btn {
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  font-weight: 600;
  text-decoration: none;
}
.auth-btn:hover { border-color: var(--accent); color: var(--accent); }

.user-menu-wrap { position: relative; }
button.avatar-btn { padding: 0; border: none; border-radius: 50%; background: none; }
button.avatar-btn:hover,
button.avatar-btn[aria-expanded="true"] { box-shadow: 0 0 0 3px var(--border); }
button.avatar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* The initial is always there; a photo, when there is one, covers it. If the
   photo fails to load, auth.js removes the <img> and the initial shows. */
.avatar-circle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  line-height: 1;
}
.avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-circle.large { width: 42px; height: 42px; font-size: 1.15rem; }

.user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 10;
  width: max-content;
  max-width: min(20rem, calc(100vw - 32px));
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.15);
}
.user-menu[hidden] { display: none; }
.user-menu-who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-menu-id { min-width: 0; }
.user-menu-email { font-weight: 600; overflow-wrap: anywhere; }
.user-menu-role { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
button.user-menu-item {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: left;
}
button.user-menu-item:hover { color: var(--accent); }

/* What a guest gets instead of the dashboard (auth.js signedOutHTML). */
.signed-out { max-width: 30rem; margin: 3rem auto; text-align: center; }
.signed-out .auth-btn { display: inline-block; }
.landing-points { text-align: left; display: inline-block; margin: 0.25rem 0 1rem; padding-left: 1.2rem; line-height: 1.6; }

/* The page a sign-in failure lands on (server.js sendAuthPage). */
.auth-message { max-width: 36rem; margin: 3rem auto; padding: 0 16px; }

/* ---- Shared bits for the weekly views ---- */

.muted { color: var(--muted); }

main#app.wide { max-width: 1480px; }

a.button {
  display: inline-block;
  font: inherit;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  text-decoration: none;
  line-height: 1.4;
}
a.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { background: var(--miss); border-color: var(--miss); color: #fff; }
button.danger-outline { color: var(--miss); border-color: var(--miss); background: transparent; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.page-head h2 { margin: 0; }
.crumb { margin: 0 0 0.25rem; font-size: 0.9rem; }
.crumb a { color: var(--muted); text-decoration: none; }

.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: middle;
  border: 1px solid currentColor;
}
.badge.status-completed { color: var(--accent); }
.badge.status-missed { color: #fff; background: var(--miss); border-color: var(--miss); }
.badge.status-planned { color: var(--fg); }
.badge.status-upcoming { color: var(--muted); }

.flash { position: sticky; top: 0.5rem; z-index: 5; }

/* ---- Exercise photo + card ---- */

.ex-media {
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: 6px;
  overflow: hidden;
  background: var(--border);
}
.ex-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* Two frames — start and end of the movement — cross-faded so the photo
   shows the motion. Held on the start frame for anyone who asks for less motion. */
.ex-media.animated .frame-1 { animation: ex-frame 3s ease-in-out infinite; opacity: 0; }
@keyframes ex-frame { 0%, 35% { opacity: 0; } 50%, 85% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ex-media.animated .frame-1 { animation: none; } }
.ex-media-empty { display: flex; align-items: center; justify-content: center; }
.ex-media-empty span { color: var(--muted); font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.ex-media.thumb { width: 72px; flex: none; }

.ex-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.ex-card .ex-media { border-radius: 0; }
.ex-body { padding: 0.6rem 0.7rem 0.7rem; min-width: 0; }
.ex-name { margin: 0; font-size: 1rem; }
.ex-target { font-size: 1.05rem; font-weight: 700; color: var(--accent); margin-top: 0.15rem; }
.ex-equip, .ex-notes { color: var(--muted); font-size: 0.8rem; margin-top: 0.15rem; }
.ex-help { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 0.9rem; margin-top: 0.4rem; font-size: 0.85rem; }
.form-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.form-link:hover { text-decoration: underline; }
.how-to summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.how-to ol { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.how-to li { margin-bottom: 0.3rem; }
.how-to[open] { flex-basis: 100%; }

/* Today checklist rows with a thumbnail. */
ul.checklist > li { align-items: flex-start; }
ul.checklist > li > input[type="checkbox"] { margin-top: 0.35rem; flex: none; }
.checklist-text { min-width: 0; }

/* ---- Week grid: #/week, a plan's view, and the builder ---- */

.week-toolbar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.week-toolbar h2 { margin: 0 0.25rem; font-size: 1.25rem; }
.plan-line { margin: 0.5rem 0 1rem; }

.week-grid { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
/* Seven columns only where each still fits a readable card; below that the
   days stack, and each card lays out photo-beside-text instead. */
@media (min-width: 1100px) {
  .week-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}
@media (max-width: 1099px) {
  .week-grid .ex-card { display: grid; grid-template-columns: minmax(110px, 32%) 1fr; }
  .week-grid .ex-card .ex-media { aspect-ratio: auto; min-height: 100%; }
}

.day-col {
  background: color-mix(in srgb, var(--card) 55%, var(--bg));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.day-col.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.day-col.past .day-body { opacity: 0.8; }
.day-head { display: flex; justify-content: space-between; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.day-name { font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; }
.day-date { color: var(--muted); }
.day-meta { display: flex; align-items: center; gap: 0.4rem; }
.day-time { font-size: 0.85rem; font-weight: 600; }
.day-body { display: flex; flex-direction: column; gap: 0.6rem; }
.rest-day { color: var(--muted); margin: 0; font-style: italic; }

/* ---- Plans list ---- */

.plan-card.is-active { border-color: var(--accent); }
.plan-card-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.plan-card-head h3 { margin: 0; }
.plan-card-head h3 a { text-decoration: none; }
.plan-card p { margin: 0.5rem 0; }
.plan-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.weekday-dots { display: flex; gap: 0.3rem; margin-top: 0.5rem; }
.weekday-dots span {
  width: 1.6rem;
  height: 1.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--muted);
}
.weekday-dots span.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---- Builder ---- */

.builder-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 0.75rem 1rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; font-weight: 600; font-size: 0.9rem; }
input[type="text"], input[type="search"], input[type="date"], input[type="time"], input[type="number"] {
  font: inherit;
  font-weight: normal;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  min-width: 0;
}
.day-time-input input { padding: 0.2rem 0.3rem; font-size: 0.85rem; }

ul.b-items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.b-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.b-item-head { display: flex; align-items: center; gap: 0.45rem; }
.b-item-head .ex-media.thumb { width: 48px; }
.b-item-name { font-weight: 700; font-size: 0.9rem; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.b-item-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(3.6rem, 1fr)); gap: 0.3rem; }
.b-item-fields label { display: flex; flex-direction: column; font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.b-item-fields input { padding: 0.3rem 0.35rem; width: 100%; }
.b-item-order { display: flex; gap: 0.25rem; justify-content: flex-end; }
button.icon-btn { padding: 0.1rem 0.5rem; line-height: 1.3; }
button.add-ex { border-style: dashed; color: var(--accent); font-weight: 600; }

.builder-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding: 0.75rem 0 max(0.75rem, env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.builder-error { color: var(--miss); font-weight: 600; margin-right: auto; }
.draft-note { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---- Dialogs (confirm + exercise picker) ---- */

dialog {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
  padding: 1rem;
  width: min(34rem, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h3 { margin: 0 0 0.5rem; }
.dialog-body p { margin: 0 0 0.6rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.75rem; }

.picker-dialog[open] { display: flex; flex-direction: column; gap: 0.5rem; height: min(40rem, calc(100dvh - 32px)); }
.picker-head { display: flex; flex-direction: column; gap: 0.5rem; }
.picker-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
button.chip { padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.85rem; text-transform: capitalize; }
button.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
ul.picker-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; }
ul.picker-list li[hidden] { display: none; }
button.picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 0.5rem 0.25rem;
  background: none;
}
button.picker-item:hover { background: var(--bg); }
button.picker-item .ex-media.thumb { width: 64px; }
.picker-text { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 0.85rem; }
.picker-name { font-weight: 700; font-size: 0.95rem; }
.picker-count { color: var(--accent); font-weight: 700; font-size: 0.85rem; white-space: nowrap; }

/* ---- Effort (easy / max) on a plan item or session exercise ---- */

.effort-badge {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
}
.effort-badge.effort-max { color: var(--max); }
.effort-badge.effort-easy { color: var(--muted); }
.b-item-effort { display: flex; flex-direction: column; font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.b-item-effort select { padding: 0.3rem 0.35rem; width: 100%; text-transform: none; font-weight: 400; }

/* ---- Exercises & limits (#/exercises) ---- */

.page-sub { margin: 0.35rem 0 0; max-width: 46rem; }
.limit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 0.9rem; align-items: start; }
.limit-card { padding: 0; overflow: hidden; margin: 0; display: grid; grid-template-columns: 8.5rem minmax(0, 1fr); }
/* The category filter hides cards with [hidden]; .card's display would win otherwise. */
.limit-card[hidden] { display: none; }
/* Pinned to the top so opening a panel below does not stretch the photo. */
.limit-side { min-width: 0; align-self: start; }
/* The body map is unreadable at photo width, so the column widens while it's open. */
.limit-card:has(.muscles[open]) { grid-template-columns: minmax(8.5rem, 45%) minmax(0, 1fr); }
.limit-card .ex-media { border-radius: 0 0 6px 0; aspect-ratio: auto; height: 8.5rem; }

/* Body map under the photo (public/muscles.js). */
.muscles { padding: 0.45rem 0.5rem 0.5rem 0.6rem; font-size: 0.85rem; }
.muscles summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.muscle-map { display: block; width: 100%; height: auto; margin-top: 0.4rem; }
.muscle-map .base, .muscle-map .m { fill: var(--border); stroke: var(--card); stroke-width: 0.6; }
.muscle-map .m.secondary { fill: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.muscle-map .m.primary { fill: var(--accent); }
.muscle-map text { fill: var(--muted); font-size: 9px; }
ul.muscle-legend { list-style: none; margin: 0.3rem 0 0; padding: 0; font-size: 0.75rem; color: var(--muted); }
ul.muscle-legend li { margin-top: 0.15rem; }
.swatch { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 2px; margin-right: 0.3rem; vertical-align: -0.05rem; }
.swatch.primary { background: var(--accent); }
.swatch.secondary { background: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.limit-card.just-saved { outline: 2px solid var(--accent); }
.limit-body { padding: 0.7rem 0.85rem 0.85rem; }
.limit-stats { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-top: 0.6rem; }
.limit-stats .stat { min-width: 0; }
.limit-stats .value { font-size: 1.25rem; }
.limit-stats .value.default { color: var(--accent); }
.limit-stats .value.untested { color: var(--muted); }
.limit-basis, .limit-hint { font-size: 0.8rem; margin: 0.3rem 0 0; }
ul.limit-history { list-style: none; margin: 0.4rem 0 0; padding: 0; }
ul.limit-history li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.6rem; padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
ul.limit-history li button { margin-left: auto; }
.record-limit { margin-top: 0.7rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.record-limit summary { cursor: pointer; font-weight: 700; color: var(--accent); }
.limit-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)); gap: 0.5rem 0.75rem; margin-top: 0.6rem; }
.limit-form .notes { grid-column: 1 / -1; }
.limit-form-actions { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 0.6rem; }

/* #/admin (admin.js) — access requests. */
a.user-menu-item {
  display: block;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}
a.user-menu-item:hover { color: var(--accent); }
.pending-badge { color: #fff; background: var(--miss); border-color: var(--miss); margin-left: 4px; }
.access-list { list-style: none; margin: 0; padding: 0; }
.access-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.access-row:first-child { border-top: none; }
.access-who { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.access-dates { font-size: 0.8rem; margin-top: 2px; }
.access-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 520px) {
  .access-row { flex-wrap: wrap; }
  .access-actions { width: 100%; justify-content: flex-start; padding-left: 46px; }
}

/* Exclusions: #/my-equipment (equipment.js) and the flags elsewhere. */
.excluded-flag { margin: 0.25rem 0 0; font-size: 0.8rem; font-weight: 600; color: var(--max); }
.excluded-flag a { color: inherit; }
.excluded-note { border-color: var(--max); }
.ex-card.is-excluded .ex-media, .b-item.is-excluded .ex-media, .limit-card.is-excluded .ex-media { opacity: 0.5; }
.b-item.is-excluded { border-color: var(--max); }
.show-excluded { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); margin-left: 0.3rem; }
.picker-hidden-note { margin: 0; font-size: 0.85rem; }

.eq-groups { display: flex; flex-direction: column; }
.eq-group h3 { margin: 0; font-size: 1.05rem; }
.eq-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.eq-title { flex: 1; min-width: 10rem; }
.eq-title .muted { font-size: 0.85rem; }
.eq-off { margin: 0.5rem 0 0; }
ul.eq-exercises { list-style: none; margin: 0.5rem 0 0; padding: 0; }
ul.eq-exercises > li { padding: 0.4rem 0; border-top: 1px solid var(--border); }
ul.eq-exercises .ex-media.thumb { width: 44px; }
.eq-ex-name { flex: 1; min-width: 8rem; font-size: 0.95rem; overflow-wrap: anywhere; }
ul.eq-exercises > li.is-excluded .eq-ex-name { color: var(--muted); text-decoration: line-through; }
ul.eq-exercises > li.is-excluded .ex-media { opacity: 0.5; }

/* "Have it" switch: a checkbox styled as a sliding toggle. */
.switch { display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; flex-shrink: 0; position: relative; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { width: 2.6rem; height: 1.5rem; border-radius: 999px; background: var(--border); position: relative; transition: background 0.15s; }
.switch-track::after { content: ''; position: absolute; top: 0.15rem; left: 0.15rem; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(1.1rem); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.6; }
.switch-label { font-size: 0.9rem; font-weight: 600; }
.switch input:not(:checked) ~ .switch-label { color: var(--muted); }

/* A three-way segmented control built from radios, so it keys like one. */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; flex-shrink: 0; }
.seg-opt { position: relative; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-opt span { display: block; padding: 0.25rem 0.7rem; font-size: 0.82rem; white-space: nowrap; color: var(--muted); }
.seg-opt + .seg-opt span { border-left: 1px solid var(--border); }
.seg-opt input:checked + span { background: var(--accent); color: var(--card); font-weight: 600; }
.seg-opt.seg-unavailable input:checked + span, .seg-opt.seg-dislike input:checked + span { background: var(--max); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg-opt input:disabled + span { opacity: 0.6; }
@media (max-width: 520px) {
  .eq-row .seg { width: 100%; }
  .seg-opt { flex: 1; text-align: center; }
  .seg-opt span { padding: 0.35rem 0.3rem; }
}

/* ---- Profile (#/profile) ---- */

.profile-card h3 { margin-top: 0; }
.profile-form { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 0.5rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0.75rem 1rem; }
.profile-form select, .profile-form textarea {
  font: inherit;
  font-weight: normal;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--fg);
  min-width: 0;
}
.profile-form textarea { resize: vertical; }
.height-field { border: none; margin: 0; padding: 0; min-width: 0; }
.height-field legend { padding: 0; margin-bottom: 0.25rem; }
.height-inputs { display: flex; gap: 0.5rem; }
.height-inputs label { display: flex; align-items: center; gap: 0.3rem; font-weight: normal; flex: 1; min-width: 0; }
.height-inputs input { width: 100%; }
.profile-form p { margin: 0; font-size: 0.85rem; }
.form-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.form-saved { color: var(--accent); font-weight: 600; }
.goal-title { margin-bottom: 0.25rem; }
.goal-new, .goal-history { margin-top: 0.75rem; }
.goal-new summary, .goal-history summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.goal-history ul { padding-left: 1.2rem; }
.goal-history li { margin: 0.4rem 0; }
.profile table.history { margin-top: 1rem; }

/* ---- First-run checklist (Today) ---- */

.getting-started h2 { margin-top: 0; }
ol.gs-steps { list-style: none; margin: 0; padding: 0; counter-reset: gs; }
ol.gs-steps > li { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
ol.gs-steps > li:last-child { border-bottom: none; }
.gs-mark {
  flex: none;
  width: 1.3rem;
  height: 1.3rem;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 0.1rem;
}
ol.gs-steps > li.done .gs-mark { background: var(--accent); border-color: var(--accent); color: #fff; }
ol.gs-steps > li.done a { color: var(--muted); text-decoration: line-through; }
ol.gs-steps .muted { font-size: 0.85rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
