/* ===========================================================================
   WeightLab — design system.
   A calm, precise daily-weight instrument. One pink/red signal accent on
   tinted neutral surfaces (OKLCH); restraint is the differentiator against a
   loud category. Numbers are the content, so every readout is tabular
   monospace; everything else is a clean humanist sans. Mobile-first,
   one-handed, glanceable. Tokens swap by data-theme. No texture, no chrome
   competing with data.
   ========================================================================== */

/* ---- Vendored type (self-hosted, latin subset) -------------------------- */
@font-face {
  font-family: "Saira";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/vendor/fonts/saira-500.woff2") format("woff2");
}
@font-face {
  font-family: "Saira";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/vendor/fonts/saira-600.woff2") format("woff2");
}
@font-face {
  font-family: "Saira Condensed";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/vendor/fonts/saira-cond-700.woff2") format("woff2");
}
@font-face {
  font-family: "Saira Condensed";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/static/vendor/fonts/saira-cond-800.woff2") format("woff2");
}
@font-face {
  font-family: "Spline Sans Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/vendor/fonts/spline-mono-500.woff2") format("woff2");
}
@font-face {
  font-family: "Spline Sans Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/vendor/fonts/spline-mono-700.woff2") format("woff2");
}

/* ---- Tokens (OKLCH, tinted toward the brand hue ~15) --------------------- */
:root {
  --bg: oklch(0.165 0.012 15);
  --surface: oklch(0.205 0.013 15);
  --raised: oklch(0.245 0.014 15);
  --border: oklch(1 0 0 / 0.08);
  --text: oklch(0.965 0.006 15);
  --muted: oklch(0.72 0.02 15);
  --faint: oklch(0.56 0.02 15);
  --accent: oklch(0.72 0.19 12);
  --accent-soft: oklch(0.72 0.19 12 / 0.14);
  --accent-ink: oklch(0.99 0.01 12);
  --ok: oklch(0.82 0.16 152);
  --warn: oklch(0.82 0.13 80);
  --danger: oklch(0.62 0.21 25);

  --radius: 16px;
  --radius-sm: 11px;
  --tap: 50px;
  --gap: 12px;
  --shadow: 0 1px 2px oklch(0 0 0 / 0.3), 0 8px 24px oklch(0 0 0 / 0.22);
  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.25);

  --font: "Saira", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Saira Condensed", "Saira", system-ui, sans-serif;
  --font-mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: oklch(0.975 0.012 15);
  --surface: oklch(0.995 0.005 15);
  --raised: oklch(0.955 0.012 15);
  --border: oklch(0.2 0.03 15 / 0.12);
  --text: oklch(0.26 0.02 15);
  --muted: oklch(0.5 0.02 15);
  --faint: oklch(0.64 0.02 15);
  --accent: oklch(0.6 0.21 12);
  --accent-soft: oklch(0.6 0.21 12 / 0.12);
  --accent-ink: oklch(0.99 0.01 12);
  --ok: oklch(0.55 0.14 152);
  --warn: oklch(0.58 0.12 70);
  --danger: oklch(0.55 0.18 25);
  --shadow: 0 1px 2px oklch(0.3 0.02 15 / 0.08), 0 10px 28px oklch(0.3 0.02 15 / 0.1);
  --shadow-sm: 0 1px 2px oklch(0.3 0.02 15 / 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: calc(var(--tap) + env(safe-area-inset-bottom) + 40px);
  min-height: 100dvh;
  /* Native-app feel: no text selection or iOS long-press callout on chrome. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* …but text entry must keep caret + selection (iOS Safari inherits the body rule). */
input,
textarea,
[contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

.wrap {
  max-width: 552px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
}

/* ---- Typography --------------------------------------------------------- */
h1 {
  font-family: var(--font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1;
  font-size: 2.15rem;
  margin: 0 0 0.1em;
}
h2 {
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em;
}
.muted {
  color: var(--muted);
}
.sub {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.45;
}

/* Section eyebrow — small, quiet, sans (not mono, not gimmicky) */
.kick {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 4px;
}
[data-theme="light"] .kick {
  color: var(--accent);
}

/* Hero readout — the one big number. Mono, tabular. */
.hero-num {
  font-family: var(--font-mono);
  font-size: 2.7rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.hero-num.signal {
  color: var(--accent);
}
.unit {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

/* ---- Surfaces (single level — never nested) ----------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: var(--gap);
  box-shadow: var(--shadow-sm);
  animation: rise 0.32s var(--ease) backwards;
}
.card.tight {
  padding: 14px 16px;
}
.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .card {
    animation: none;
  }
}

/* ---- Lists (flattened rows inside one surface) -------------------------- */
.list > * + * {
  border-top: 1px solid var(--border);
}
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 0;
}
.list-row:first-child {
  padding-top: 2px;
}
.list-row .name {
  font-weight: 600;
  font-size: 1.02rem;
}
/* Whole-row tap target → edit in config */
a.list-row.tappable {
  text-decoration: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s var(--ease);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  margin: 0 -12px;
}
a.list-row.tappable:first-child {
  margin-top: -14px;
}
a.list-row.tappable:hover {
  background: var(--raised);
}
a.list-row.tappable:active {
  background: var(--border);
}
.list-row .center {
  display: flex;
  align-items: center;
  gap: 8px;
}
.list-row .chev {
  color: var(--faint);
  font-size: 1.2rem;
  line-height: 1;
}

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.98rem;
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s var(--ease), background 0.18s var(--ease),
    border-color 0.18s var(--ease), filter 0.18s var(--ease);
  text-decoration: none;
}
.btn:hover {
  border-color: oklch(1 0 0 / 0.16);
}
[data-theme="light"] .btn:hover {
  border-color: oklch(0.2 0.02 150 / 0.22);
}
.btn:active {
  transform: scale(0.985);
}
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}
.btn.primary:hover {
  filter: brightness(1.05);
  border-color: transparent;
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.danger {
  color: var(--danger);
}
.btn.block {
  width: 100%;
}
.btn.lg {
  min-height: 58px;
  font-size: 1.05rem;
}
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}
.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row > * {
  flex: 1;
}

/* ---- Rep stepper -------------------------------------------------------- */
.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--raised);
}
.stepper button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text);
  width: var(--tap);
  min-height: var(--tap);
  font-size: 1.35rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s var(--ease);
}
.stepper button:active {
  background: var(--accent-soft);
}
.stepper .val {
  min-width: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- Set row ------------------------------------------------------------ */
.set-row {
  display: grid;
  grid-template-columns: 22px 1fr 1fr 54px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
}
.set-row + .set-row {
  border-top: 1px solid var(--border);
}
.set-row .idx {
  color: var(--faint);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.set-row.done {
  opacity: 0.5;
}
.set-row.done span:not(.idx):not(.pill) {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
}
input[type="number"],
input[type="text"],
select {
  font-family: var(--font-mono);
  font-size: 1rem;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  padding: 0 13px;
  width: 100%;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
select {
  font-family: var(--font);
  font-weight: 500;
}
input:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 19px) calc(50% - 2px),
    calc(100% - 14px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

/* ---- Rest timer bar (bottom, mirrors .nav) ------------------------------ */
.rest-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(516px, calc(100vw - 32px));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  background: color-mix(in oklab, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(18px);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.35);
  padding: 8px 10px 8px 8px;
}
.rest-bar .rest-bar-label {
  flex: 1 1 auto;
  min-width: 0;
}
.rest-bar .rest-bar-sub {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.rest-bar .btn {
  flex: none;
}
.ring {
  --pct: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(
    var(--accent) calc(var(--pct) * 1%),
    var(--raised) 0
  );
  position: relative;
  flex: none;
}
.ring::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--surface);
}
.ring .t {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* ---- Status note (no side stripe) --------------------------------------- */
.nudge {
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: var(--gap);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 11px;
  align-items: flex-start;
  font-size: 0.9rem;
  line-height: 1.45;
}
.nudge .dot {
  font-size: 0.6rem;
  line-height: 1.9;
  flex: none;
}
.nudge.warn {
  border-color: oklch(0.82 0.13 80 / 0.4);
  background: oklch(0.82 0.13 80 / 0.08);
}
.nudge.warn .dot {
  color: var(--warn);
}
.nudge.ok {
  border-color: oklch(0.82 0.16 152 / 0.4);
  background: oklch(0.82 0.16 152 / 0.08);
}
.nudge.ok .dot {
  color: var(--ok);
}
[data-theme="light"] .nudge.warn {
  border-color: oklch(0.58 0.12 70 / 0.45);
  background: oklch(0.58 0.12 70 / 0.08);
}
[data-theme="light"] .nudge.ok {
  border-color: oklch(0.55 0.14 152 / 0.45);
  background: oklch(0.55 0.14 152 / 0.08);
}

/* ---- Pills / badges (sans, terse) --------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 4px 10px;
  border-radius: 7px;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill.accent {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: transparent;
}
.pill.pr {
  color: var(--accent);
  border-color: transparent;
  background: var(--accent-soft);
}
/* ---- Sticky action bar (e.g. Start session) ----------------------------- */
.startbar {
  position: sticky;
  bottom: calc(var(--tap) + env(safe-area-inset-bottom) + 18px);
  z-index: 40;
  margin-top: 16px;
}
.readout-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ---- Chart -------------------------------------------------------------- */
.chart {
  width: 100%;
  height: 220px;
}
.uplot {
  font-family: var(--font-mono) !important;
}

/* ---- Bottom nav --------------------------------------------------------- */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-around;
  gap: 2px;
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  backdrop-filter: saturate(1.4) blur(18px);
  -webkit-backdrop-filter: saturate(1.4) blur(18px);
  border-top: 1px solid var(--border);
  padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  z-index: 50;
}
.nav a {
  flex: 1;
  max-width: 96px;
  color: var(--faint);
  text-decoration: none;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: color 0.18s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.nav .ic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 30px;
  border-radius: 999px;
  transition: background 0.22s var(--ease);
}
.nav .ic svg {
  width: 23px;
  height: 23px;
}
.nav a:active .ic {
  background: var(--border);
}
.nav a.active {
  color: var(--accent);
}
.nav a.active .ic {
  background: var(--accent-soft);
}

/* ---- Layout utilities --------------------------------------------------- */
.stack > * + * {
  margin-top: 10px;
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.row.wrap {
  flex-wrap: wrap;
}
.spread {
  justify-content: space-between;
}
.grow {
  flex: 1;
}
.center {
  text-align: center;
}
.mt {
  margin-top: 18px;
}
.mt-sm {
  margin-top: 10px;
}
.hidden {
  display: none;
}
.page-head {
  padding: 2px 2px 18px;
}

/* Disclosure (config exercise rows) */
details > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
}
details > summary::-webkit-details-marker {
  display: none;
}
details + details > summary {
  border-top: 1px solid var(--border);
}
.chev {
  color: var(--faint);
  transition: transform 0.2s var(--ease);
  font-size: 1.15rem;
}
details[open] .chev {
  transform: rotate(180deg);
}

/* ---- Auth screen -------------------------------------------------------- */
.auth {
  min-height: 72vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}
.auth .glyph {
  font-size: 2.4rem;
  color: var(--accent);
}
.auth .btn {
  width: 100%;
  max-width: 320px;
}

/* ---- Phase 2 components ------------------------------------------------- */

/* Segmented sub-tab strip (hub sub-tabs + program-editor day tabs) */
.seg {
  display: flex;
  gap: 4px;
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 14px;
}
.seg a {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  padding: 8px 6px;
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.seg a.on {
  color: var(--accent-ink);
  background: var(--accent);
}

/* Stat grid (session-complete + dashboards) */
.statgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}
.stat .v {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.stat .k {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 5px;
}

/* Volume bars (sets per day-type) */
.vbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
}
.vbar + .vbar {
  border-top: 1px solid var(--border);
}
.vbar .lbl {
  width: 78px;
  font-size: 0.84rem;
  font-weight: 600;
}
.vbar .track {
  flex: 1;
  height: 10px;
  border-radius: 6px;
  background: var(--raised);
  overflow: hidden;
}
.vbar .fill {
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
}
.vbar .num {
  width: 54px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.84rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Adherence heatmap (single hue, intensity = session volume) */
.dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  margin-bottom: 6px;
}
.dow span {
  text-align: center;
  font-size: 0.6rem;
  color: var(--faint);
  font-family: var(--font-mono);
}
.heat {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.heat a,
.heat i {
  position: relative;
  aspect-ratio: 1;
  border-radius: 5px;
  background: var(--raised);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--accent-ink);
  font-style: normal;
  text-decoration: none;
}
.heat .l1 {
  background: color-mix(in oklab, var(--accent) 48%, var(--raised));
}
.heat .l2 {
  background: color-mix(in oklab, var(--accent) 74%, var(--raised));
}
.heat .l3 {
  background: var(--accent);
}
.heat a.l1:hover,
.heat a.l2:hover,
.heat a.l3:hover {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}
.heat .pr::after {
  content: "★";
  position: absolute;
  top: -2px;
  right: 0;
  font-size: 0.74rem;
  line-height: 1;
  color: var(--accent-ink);
  text-shadow: 0 0 2px oklch(0 0 0 / 0.35);
}
.heat-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.heat-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--muted);
}
.heat-legend b {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

/* Session feel rating (rough → great) + notes */
.faces {
  display: flex;
  gap: 8px;
}
.faces button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--muted);
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 52px;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.14s var(--ease);
}
.faces button svg {
  width: 26px;
  height: 26px;
}
.faces button.on {
  opacity: 1;
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.faces-cap {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--faint);
  margin-top: 6px;
}
textarea {
  font-family: var(--font);
  font-weight: 500;
  font-size: 1rem;
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  width: 100%;
  min-height: 78px;
  resize: none;
}
textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Greyed unit suffix inside a numeric input */
.ufield {
  position: relative;
  display: block;
  width: 100%;
}
.ufield > input {
  padding-right: 40px;
}
.ufield .usuf {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--faint);
  pointer-events: none;
}

/* Editable per-exercise working weight, in the exercise header. */
.wfield {
  text-align: center;
  font-weight: 600;
}
/* Sequential set logging: live weight mirror, locked + editable rows */
.set-row .wread {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
}
.set-row .dreps {
  text-align: center;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.95rem;
}
.set-row.locked {
  opacity: 0.38;
}
.set-row.locked input,
.set-row.locked button {
  pointer-events: none;
}
.set-row.done span.pill {
  justify-self: center;
}
.set-row.done.editable {
  cursor: pointer;
  border-radius: 8px;
}
.set-row.done.editable:hover {
  opacity: 0.7;
  background: var(--raised);
}
.set-row.done .edit {
  justify-self: center;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
}

/* Program editor: draggable exercise rows */
.erow {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
}
.erow + .erow {
  border-top: 1px solid var(--border);
}
.erow {
  cursor: pointer;
}
.erow .grip {
  color: var(--faint);
  cursor: grab;
  font-size: 1.1rem;
  line-height: 1;
  touch-action: none; /* let the grip own touch drags instead of scrolling */
  padding: 4px 2px;
  margin: -4px -2px; /* bigger touch target without shifting layout */
}
/* Drag-to-reorder state */
.slot.drag {
  position: relative;
  z-index: 5;
  opacity: 0.92;
}
.slot.drag .erow {
  background: var(--card-2, var(--border));
  border-radius: 10px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
}
body.dragging {
  user-select: none;
}
/* Click-to-edit editor pane (hidden until the row's .slot is .open) */
.erow .chev {
  color: var(--faint);
  transition: transform 0.15s ease;
}
.slot.open .erow .chev {
  transform: rotate(180deg);
}
.slot .editor {
  display: none;
  padding: 0 0 6px;
}
.slot.open .editor {
  display: block;
}
.erow .nm {
  font-weight: 600;
  font-size: 0.98rem;
}
.erow .meta {
  font-size: 0.74rem;
  color: var(--muted);
  font-family: var(--font-mono);
  margin-top: 2px;
}
.erow .ctl {
  display: flex;
  align-items: center;
  gap: 12px;
}
.erow .x {
  color: var(--danger);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0 2px;
}
/* Rotation count tag in a slot's collapsed header. */
.erow .nm .rot {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--font-mono);
}
/* One rotating exercise inside the slot editor: its form + a remove button. */
.slot .vrow {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
}
.slot .vrow + .vrow {
  border-top: 1px solid var(--line);
}
.slot .vrow .vdel {
  padding-top: 22px;
}
.slot .vrow .vdel .x {
  color: var(--danger);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0 2px;
}
/* "next up" tag on the variant the upcoming session will resolve to. */
.badge {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}
.slot .vadd {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  align-items: flex-end;
}
.dlab {
  font-size: 0.66rem;
  color: var(--faint);
  text-align: center;
}
.sw {
  width: 40px;
  height: 23px;
  border-radius: 12px;
  background: var(--raised);
  border: 1px solid var(--border);
  position: relative;
  flex: none;
  cursor: pointer;
}
.sw.on {
  background: var(--accent);
  border-color: transparent;
}
.sw i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--muted);
  transition: left 0.15s;
}
.sw.on i {
  left: 19px;
  background: var(--accent-ink);
}

/* Plate calculator visuals */
.note {
  font-size: 0.74rem;
  color: var(--faint);
  padding: 4px;
  line-height: 1.5;
}
.barbell {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 18px 0;
  flex-wrap: nowrap;
}
.plate {
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 14px 4px;
}
.bar-rod {
  height: 6px;
  width: 46px;
  background: var(--faint);
  border-radius: 3px;
}
.db {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}
.db .end {
  width: 15px;
  height: 52px;
  border-radius: 5px;
  background: var(--accent);
  margin: 0 1px;
}
.db .end.s {
  height: 40px;
  opacity: 0.6;
}
.db .handle {
  height: 9px;
  width: 40px;
  background: var(--faint);
  border-radius: 3px;
}
.wstack {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 60px;
}
.wstack i {
  height: 12px;
  border-radius: 3px;
  background: var(--raised);
  display: block;
}
.wstack i.sel {
  background: var(--accent);
}
.fbar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}
.fbar .col {
  width: 8px;
  height: 30px;
  background: var(--faint);
  border-radius: 2px;
}
.fbar .rod {
  height: 11px;
  width: 150px;
  background: var(--accent);
  border-radius: 5px;
}

[x-cloak] {
  display: none !important;
}

/* ---- htmx in-flight feedback ------------------------------------------- */
.htmx-request,
.htmx-request.btn {
  opacity: 0.7;
}
[data-loading] {
  display: none;
}
.htmx-request [data-loading] {
  display: inline;
}

/* ── Phase 3 — photo grid ──────────────────────────────────────────────── */
[x-cloak] {
  display: none !important;
}

/* Progress-photo timeline grid + thumbnails. */
.photos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
img.photo {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: block;
}

/* Save toast: floats just above the nav, fades in on a silent htmx save. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tap) + env(safe-area-inset-bottom) + 18px);
  transform: translate(-50%, 8px);
  z-index: 60;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px oklch(0 0 0 / 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.err {
  background: var(--danger);
  color: oklch(0.99 0.01 25);
}

/* ---- WeightLab additions ---- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); }
.stat { background: var(--raised); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat-k { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat-v { font-family: var(--font-mono); font-size: 1.35rem; font-weight: 600; color: var(--text); }
.stat-s { font-size: 0.75rem; color: var(--faint); }
.seg { display: inline-flex; background: var(--raised); border-radius: 999px; padding: 3px; }
.seg-btn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.8rem; padding: 5px 12px; border-radius: 999px; }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.hrow { border-bottom: 1px solid var(--border); padding: 4px 0; }
.hrow:last-child { border-bottom: 0; }
.hrow summary { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; list-style: none; }
.hrow summary::-webkit-details-marker { display: none; }
.hdate { color: var(--muted); font-size: 0.85rem; min-width: 96px; }
.hkg { font-family: var(--font-mono); font-weight: 600; }
.havg { margin-left: auto; color: var(--faint); font-size: 0.8rem; }
