/* ─── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  --bg: #FBF9F4;
  --card: #FFFFFF;
  --text: #2E2B28;
  --muted: #6F6A63;
  --border: #E6E0D6;

  --sage: #4F6B49;
  --sage-tint: #E3EADB;
  --sage-ink: #3B5236;

  --rose: #8E4A50;
  --rose-tint: #F4E4E3;
  --rose-wash: #FBF1F0;

  --track: #F3F0E9;

  --radius: 14px;
  --radius-sm: 10px;
  --tap: 44px;
  --shell: 480px;

  --shadow: 0 1px 2px rgba(46, 43, 40, 0.04), 0 4px 16px rgba(46, 43, 40, 0.05);
  --shadow-lift: 0 8px 28px rgba(46, 43, 40, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 600; margin: 0; }

button { font: inherit; color: inherit; cursor: pointer; }

input, textarea, select { font: inherit; color: inherit; }

/* Remove the number-input spinners so the numeric keypad is the only affordance. */
input[type='number'] { -moz-appearance: textfield; }
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.icon { display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon svg { display: block; }

/* ─── Shell ──────────────────────────────────────────────────────────────── */

/* Safe areas: in standalone mode (Add to Home Screen) the page runs edge to
   edge under viewport-fit=cover, so the notch, home indicator and rounded
   corners are padded with env(safe-area-inset-*). Outside standalone these
   are 0 and nothing changes. */
/* ─── Owner banner ───────────────────────────────────────────────────────── */

/* With OWNER_NAME set, "Dan's Vessel" sits fixed above every screen and above
   the sheet scrim, so whose site this is never scrolls or dims out of view.
   --owner-h is 0 without an owner, so nothing else moves. */
:root { --owner-h: 0px; }
body.has-owner { --owner-h: 30px; }

.owner-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 55;
  height: calc(var(--owner-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  display: flex; align-items: center; justify-content: center;
  background: var(--sage); color: #fff;
  font-family: Fraunces, Georgia, serif; font-size: 15px; font-weight: 600; letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.owner-bar[hidden] { display: none; }

.app {
  max-width: var(--shell);
  margin: 0 auto;
  padding:
    calc(var(--owner-h) + env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    calc(84px + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  min-height: 100vh;
}

.app.no-tabs { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text);
  font-weight: 500; text-decoration: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-primary { background: var(--sage); border-color: var(--sage); color: #fff; font-weight: 600; }
.btn-tint { background: var(--sage-tint); border-color: transparent; color: var(--sage-ink); font-weight: 600; }
.btn-danger { background: var(--rose-wash); border-color: var(--rose-tint); color: var(--rose); font-weight: 600; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; }
.btn-lg { min-height: 52px; font-size: 17px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--tap); height: var(--tap); flex: none;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted);
}

.icon-btn:active { background: var(--track); }
.icon-btn.danger { color: var(--rose); }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); padding: 0 4px;
  border: 0; background: transparent; color: var(--sage);
  font-weight: 600; font-size: 15px;
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 12px; }

/* ─── Login ──────────────────────────────────────────────────────────────── */

.login-body {
  min-height: 100vh;
  display: grid; place-items: center;
  padding:
    max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.login-card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.login-mark {
  width: 44px; height: 44px; margin: 0 auto 18px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--sage-tint); color: var(--sage-ink);
}

.login-title { font-size: 24px; line-height: 1.2; text-align: center; margin-bottom: 24px; }

.field-label {
  display: block; margin-bottom: 6px;
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted);
}

.input {
  width: 100%; min-height: var(--tap); padding: 0 14px;
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}

.input:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 3px var(--sage-tint); }

.form-error {
  margin: 12px 0 0; padding: 10px 12px;
  background: var(--rose-wash); border: 1px solid var(--rose-tint); border-radius: var(--radius-sm);
  color: var(--rose); font-size: 14px;
}

.login-card .btn { margin-top: 16px; }

/* ─── Day header ─────────────────────────────────────────────────────────── */

.day-header { display: flex; align-items: center; gap: 4px; padding: 10px 0 2px; }

.day-title {
  flex: 1; min-height: var(--tap); padding: 4px 8px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  text-align: center;
}

.day-title:active { background: var(--track); }
.day-title-main { display: block; font-family: Fraunces, Georgia, serif; font-size: 21px; font-weight: 600; line-height: 1.15; }
/* "Mandira · Wed Oct 7" has to fit between the arrows at 320px wide. */
.has-owner .day-title { min-width: 0; }
.has-owner .day-title-main { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-title-sub {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 1px;
  color: var(--muted); font-size: 13px;
}

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin: 6px 0 16px; }

.week-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 56px; padding: 6px 0 4px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
}

.week-day:active { background: var(--track); }
.week-day-name { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0.03em; }
.week-day-num { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
.week-day.is-today .week-day-num { color: var(--sage); font-weight: 600; }

.week-day.is-selected { background: var(--sage-tint); }
.week-day.is-selected .week-day-num { color: var(--sage-ink); font-weight: 600; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.week-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.week-day.has-workout .week-dot { background: var(--sage); }

.today-pill {
  display: block; margin: 0 auto 14px;
  min-height: 34px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); color: var(--sage-ink);
  font-size: 13px; font-weight: 600;
}

/* ─── Empty state ────────────────────────────────────────────────────────── */

.empty { padding: 44px 20px 32px; text-align: center; }
.empty-icon {
  width: 56px; height: 56px; margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--sage-tint); color: var(--sage-ink);
}
.empty h2 { font-size: 19px; margin-bottom: 6px; }
.empty p { margin: 0 0 22px; color: var(--muted); font-size: 15px; }

/* ─── Workout header ─────────────────────────────────────────────────────── */

.workout-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 14px 16px;
}

.workout-program { font-family: Fraunces, Georgia, serif; font-size: 18px; font-weight: 600; }
.workout-meta { color: var(--muted); font-size: 13px; }
.workout-count {
  flex: none; padding: 4px 10px; border-radius: 999px;
  background: var(--sage-tint); color: var(--sage-ink);
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.workout-count.is-complete { background: var(--sage); color: #fff; }

.save-chip {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 20px; margin: 8px 0 -4px;
  color: var(--muted); font-size: 12px;
}
.save-chip.is-error { color: var(--rose); }
.save-chip:empty { display: none; }

/* ─── Exercise list ──────────────────────────────────────────────────────── */

.block-list { margin-top: 12px; }

.block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.block + .block { margin-top: 10px; }

.ex-row { border-top: 1px solid var(--border); }
.block > .ex-row:first-child { border-top: 0; }

.ex-row-head { display: flex; align-items: stretch; }

.ex-main {
  flex: 1; display: flex; align-items: center; gap: 12px;
  min-height: 62px; padding: 10px 4px 10px 14px;
  border: 0; background: transparent; text-align: left;
}

.ex-main:active { background: var(--track); }

.label-badge {
  flex: none; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--sage-tint); color: var(--sage-ink);
  font-size: 13px; font-weight: 600; font-feature-settings: 'tnum';
}
.label-badge.is-done { background: var(--sage); color: #fff; }

.ex-text { min-width: 0; }
.ex-name { display: block; font-weight: 500; line-height: 1.3; }
.ex-summary {
  display: block; margin-top: 2px;
  color: var(--muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.ex-row.is-expanded { background: #FDFCF9; }
.ex-row.is-expanded .ex-main { min-height: 54px; }

/* ─── Expanded exercise ──────────────────────────────────────────────────── */

.ex-body { padding: 0 14px 14px; }

.last-time {
  margin-bottom: 14px; padding: 9px 12px;
  background: var(--track); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13px;
}

.ex-field { margin-bottom: 14px; }
.ex-field > .field-label { margin-bottom: 7px; }

.segmented {
  display: grid; gap: 4px; padding: 4px;
  background: var(--track); border-radius: 12px;
}
.segmented.cols-2 { grid-template-columns: repeat(2, 1fr); }
.segmented.cols-3 { grid-template-columns: repeat(3, 1fr); }

.segmented button {
  min-height: var(--tap); padding: 0 6px;
  border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font-size: 13px; font-weight: 500;
}
.segmented button[aria-pressed='true'] { background: var(--sage); color: #fff; font-weight: 600; }

.sets-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }

.set-grid { display: grid; gap: 8px; align-items: center; }
.set-grid.has-weight { grid-template-columns: 30px 1fr 1fr var(--tap); }
.set-grid.no-weight { grid-template-columns: 30px 1fr var(--tap); }
.set-grid.no-check.has-weight { grid-template-columns: 30px 1fr 1fr; }
.set-grid.no-check.no-weight { grid-template-columns: 30px 1fr; }

.set-grid + .set-grid { margin-top: 8px; }

.set-grid-head {
  font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
}
.set-grid-head > span { text-align: center; }
.set-grid-head > span:first-child { text-align: left; }

.set-num { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.num-input {
  width: 100%; min-height: var(--tap); padding: 0 6px;
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  text-align: center; font-variant-numeric: tabular-nums;
}
.num-input:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 3px var(--sage-tint); }
.num-input.is-changed { border-color: var(--rose); background: var(--rose-wash); }
.num-input.is-changed:focus { box-shadow: 0 0 0 3px var(--rose-tint); }

.check-btn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--border);
}
.check-btn[aria-pressed='true'] { background: var(--sage); border-color: var(--sage); color: #fff; }

.set-ctl { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.set-ctl-btn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--card); color: var(--text);
}
.set-ctl-label { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }

.notes-input {
  width: 100%; min-height: var(--tap); padding: 10px 12px; margin-top: 14px;
  background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  resize: none;
}
.notes-input:focus { border-color: var(--sage); outline: none; box-shadow: 0 0 0 3px var(--sage-tint); }

.diff-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 12px;
  background: var(--rose-wash); border: 1px solid var(--rose-tint); border-radius: var(--radius-sm);
}
.diff-banner p { flex: 1; min-width: 150px; margin: 0; color: var(--rose); font-size: 14px; }
.diff-banner .btn {
  background: var(--rose); border-color: var(--rose); color: #fff; font-weight: 600;
  min-height: 38px; padding: 0 14px; font-size: 14px;
}

.ex-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }

/* ─── Template editor rows ───────────────────────────────────────────────── */

.editor-head {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 0 14px;
}
.editor-title {
  flex: 1; min-width: 0; min-height: var(--tap); padding: 0 8px;
  display: flex; align-items: center; gap: 7px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  font-family: Fraunces, Georgia, serif; font-size: 19px; font-weight: 600;
}
.editor-title:active { background: var(--track); }
.editor-letter {
  flex: none; width: 30px; height: 30px;
  display: grid; place-items: center; border-radius: 9px;
  background: var(--sage); color: #fff; font-size: 16px;
}
.editor-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─── Arrange (supersets by tap) ─────────────────────────────────────────── */

.arrange-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.arrange-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.35; }
.arrange-toggle { flex: none; min-height: var(--tap); min-width: 92px; }

.arrange-row { display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; }
.arrange-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.arrange-name {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 15px;
}
.arrange-ctl { flex: none; display: grid; grid-template-columns: repeat(4, var(--tap)); gap: 2px; }
.arrange-btn { color: var(--sage-ink); }
.arrange-btn:active { background: var(--sage-tint); }
.arrange-spacer { width: var(--tap); height: var(--tap); }

/* A superset reads as one card with a sage edge. */
.block.is-superset { border-left: 3px solid var(--sage); }

.editor-foot { margin-top: 24px; }

.page-title { padding: 6px 0 2px; font-size: 24px; }
.page-sub { margin: 2px 0 18px; color: var(--muted); font-size: 14px; }

/* ─── Program cards ──────────────────────────────────────────────────────── */

.program-card {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 16px; text-align: left;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.program-card + .program-card, .program-card + .btn, .btn + .program-card { margin-top: 10px; }
.program-card:active { background: var(--track); }

.program-letter {
  flex: none; width: 42px; height: 42px;
  display: grid; place-items: center; border-radius: 12px;
  background: var(--sage); color: #fff;
  font-family: Fraunces, Georgia, serif; font-size: 19px; font-weight: 600;
}

/* Text column: one block per line, 4px apart, centered against the badge.
   min-width: 0 + overflow: hidden let the preview ellipsize inside the card. */
.program-body {
  min-width: 0; flex: 1;
  display: flex; flex-direction: column; justify-content: center; gap: 4px;
  overflow: hidden;
}
.program-name, .program-meta, .program-preview { display: block; min-width: 0; }
.program-name { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.program-meta { color: var(--muted); font-size: 13px; line-height: 1.3; }
.program-preview {
  color: var(--muted); font-size: 12.5px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.program-card > .icon { color: var(--muted); }

/* ─── Exercise rows ──────────────────────────────────────────────────────── */

/* exerciseRow(): the pickers, the Exercises library and Progress. The text
   column holds the name and meta as separate lines; trailing controls
   (chevron, Unhide) are flex: none so they never squeeze it. */
.exercise-list { overflow: hidden; }
.exercise-row { display: flex; align-items: center; border-top: 1px solid var(--border); }
.exercise-row:first-child { border-top: 0; }
.exercise-row > :not(.exercise-row-main) { flex: none; margin-right: 12px; }
.exercise-row-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 10px 14px; border: 0; background: transparent; text-align: left;
}
.exercise-row-main:active { background: var(--track); }
.exercise-row-main > .icon { flex: none; color: var(--muted); }
.exercise-row-text {
  flex: 1; min-width: 0; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px;
}
.exercise-row-name {
  display: block; font-size: 16px; font-weight: 600; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Up to two lines so the last-logged sets aren't cut off on a phone. */
.exercise-row-meta {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere;
  color: var(--muted); font-size: 13px; line-height: 1.35;
}
.exercise-row-detail {
  display: block; color: var(--muted); font-size: 12.5px; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Name + Letter sheet */
.program-details-row { display: flex; gap: 10px; align-items: flex-end; }
.program-details-name { flex: 1; min-width: 0; }
.program-details-letter { flex: none; width: 72px; }
.letter-input {
  padding: 0; text-align: center; text-transform: uppercase;
  font-family: Fraunces, Georgia, serif; font-size: 19px; font-weight: 600;
}

/* ─── Progress ───────────────────────────────────────────────────────────── */

.history-entry { padding: 13px 16px; border-top: 1px solid var(--border); }
.history-entry:first-child { border-top: 0; }
.history-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.history-date { font-weight: 600; font-size: 15px; }
.history-tag { flex: none; color: var(--muted); font-size: 12px; }
.history-sets { margin-top: 3px; color: var(--muted); font-size: 14px; }
.best-badge {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px;
  background: var(--sage); color: #fff; font-size: 11px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; vertical-align: 1px;
}

.history-entry.is-best { background: var(--sage-tint); }
.history-note { margin-top: 2px; color: var(--muted); font-size: 12.5px; font-style: italic; }

.best-card { padding: 14px 16px; margin-bottom: 12px; }
.best-line { display: flex; align-items: center; gap: 10px; }
.best-line .best-badge { margin-left: 0; }
.best-value { font-family: Fraunces, Georgia, serif; font-size: 20px; font-weight: 600; }
.best-date { margin-top: 2px; color: var(--muted); font-size: 13px; }
.best-basis { margin-top: 4px; color: var(--muted); font-size: 12px; }

/* ─── Tab bar ────────────────────────────────────────────────────────────── */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--card); border-top: 1px solid var(--border);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.tabbar-inner { max-width: var(--shell); margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 58px; border: 0; background: transparent;
  color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: 0.02em;
}
.tab.is-active { color: var(--sage); font-weight: 600; }
.tab.is-active .icon { color: var(--sage); }

/* ─── Sheets ─────────────────────────────────────────────────────────────── */

.scrim {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(46, 43, 40, 0.38);
}

.sheet {
  width: 100%; max-width: var(--shell);
  max-height: calc(88vh - env(safe-area-inset-top) - var(--owner-h)); display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-lift);
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-up 0.2s ease-out;
}

@keyframes sheet-up { from { transform: translateY(14px); opacity: 0.6; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .btn:active { transform: none; }
}

.sheet.is-centered { margin-bottom: auto; margin-top: auto; border-radius: 18px; max-width: 360px; }
.scrim.is-centered {
  align-items: center;
  padding: calc(max(20px, env(safe-area-inset-top)) + var(--owner-h)) 20px max(20px, env(safe-area-inset-bottom));
}

.sheet-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 8px 12px 18px;
  border-bottom: 1px solid var(--border);
}
.sheet-title { flex: 1; font-family: Fraunces, Georgia, serif; font-size: 18px; font-weight: 600; }
.sheet-body { padding: 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
.sheet-foot.cols-2 { grid-template-columns: 1fr 1fr; }

.sheet-search { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrap .input { padding-left: 40px; }

.menu-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 0 16px; text-align: left;
  background: transparent; border: 0;
}
.menu-row:active { background: var(--track); }
.menu-row.danger { color: var(--rose); }

.check-row {
  display: flex; align-items: flex-start; gap: 12px;
  width: 100%; padding: 12px 14px; text-align: left;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.check-row + .check-row { margin-top: 8px; }
.check-box {
  flex: none; width: 24px; height: 24px; margin-top: 2px;
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--card); color: transparent;
}
.check-row[aria-pressed='true'] .check-box { background: var(--sage); border-color: var(--sage); color: #fff; }
.check-text { min-width: 0; }
.check-name { font-weight: 500; }
.check-detail { margin-top: 1px; color: var(--muted); font-size: 13px; }

.sheet-note { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

/* ─── Calendar ───────────────────────────────────────────────────────────── */

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-month { font-family: Fraunces, Georgia, serif; font-size: 17px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow {
  text-align: center; padding-bottom: 6px;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.cal-day {
  position: relative; min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  font-variant-numeric: tabular-nums;
}
.cal-day:disabled { color: transparent; cursor: default; }
.cal-day.is-today { color: var(--sage); font-weight: 600; }
.cal-day.is-selected { background: var(--sage); color: #fff; font-weight: 600; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.cal-day.has-workout .cal-dot { background: var(--sage); }
.cal-day.is-selected .cal-dot { background: #fff; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */

.toast-root {
  position: fixed; left: 0; right: 0; bottom: calc(72px + env(safe-area-inset-bottom));
  z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; padding: 0 16px;
}
.toast {
  max-width: 340px; padding: 11px 16px; border-radius: 999px;
  background: var(--text); color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lift);
  animation: toast-in 0.18s ease-out;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.toast.has-action {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 6px 4px 18px; pointer-events: auto;
}
.toast-action {
  min-height: var(--tap); padding: 0 14px;
  border: 0; border-radius: 999px; background: transparent;
  color: var(--sage-tint); font-weight: 700; letter-spacing: 0.02em;
}
.toast-action:active { background: rgba(255, 255, 255, 0.12); }

/* ─── Offline ──────────────────────────────────────────────────────────────── */

.offline-root {
  position: fixed; left: 0; right: 0; top: calc(8px + env(safe-area-inset-top) + var(--owner-h)); z-index: 45;
  display: flex; justify-content: center; pointer-events: none; padding: 0 16px;
}
.offline-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--text); color: #fff; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-lift);
}
.offline-banner {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 12px 0 0; padding: 12px 14px;
  background: var(--track); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px;
}
.offline-banner .icon { color: var(--text); margin-top: 1px; }

/* ─── Footer ─────────────────────────────────────────────────────────────── */

.app-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--border);
}
.version-label { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.logout-btn { color: var(--muted); font-weight: 500; font-size: 14px; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */

.field-error {
  margin: 6px 0 0; color: var(--rose); font-size: 13px; font-weight: 500;
}
.field-hint { margin: -6px 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.sub-field { margin-top: 10px; }
.sub-field > .field-label { margin-bottom: 7px; }

.textarea { min-height: 84px; padding: 10px 14px; resize: vertical; line-height: 1.4; }

.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.switch-text { display: flex; flex-direction: column; min-width: 0; }
.switch-title { font-weight: 600; }
.switch-sub { color: var(--muted); font-size: 13px; }

/* 44px tap target around a 51x31 track. */
.switch {
  position: relative; flex: none; width: 56px; height: var(--tap);
  border: 0; background: transparent; padding: 0;
}
.switch::before {
  content: ''; position: absolute; left: 2px; top: 6px; width: 52px; height: 32px;
  border-radius: 999px; background: var(--border); transition: background 0.15s;
}
.switch-knob {
  position: absolute; left: 4px; top: 8px; width: 28px; height: 28px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(46, 43, 40, 0.25);
  transition: transform 0.15s;
}
.switch[aria-checked='true']::before { background: var(--sage); }
.switch[aria-checked='true'] .switch-knob { transform: translateX(20px); }

.danger-text { color: var(--rose); margin-top: 4px; }

/* ─── Exercise library ───────────────────────────────────────────────────── */

.templates-toggle { margin: 10px 0 8px; }

.library-tools { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 4px; }
.library-tools .btn { padding: 0 14px; }

.hidden-toggle {
  display: flex; align-items: center; gap: 6px; width: 100%;
  min-height: var(--tap); margin: 18px 0 8px; padding: 0 4px;
  border: 0; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}

.ex-lib-note {
  margin: 14px 0 0; padding: 8px 12px;
  border-left: 3px solid var(--sage-tint); color: var(--muted); font-size: 13px;
}

/* ─── Picker ─────────────────────────────────────────────────────────────── */

.picker-group {
  margin: 16px 0 8px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.picker-group:first-child { margin-top: 0; }

.sheet-place { padding: 12px 16px 0; }
.sheet-place:empty { display: none; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--card); color: var(--text); font-size: 14px; font-weight: 500;
}
.chip[aria-pressed='true'] { background: var(--sage); border-color: var(--sage); color: #fff; font-weight: 600; }

/* ─── Misc ───────────────────────────────────────────────────────────────── */

.loading { padding: 48px 0; text-align: center; color: var(--muted); font-size: 15px; }
.section-label {
  margin: 20px 0 8px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.divider { height: 1px; margin: 16px 0; background: var(--border); border: 0; }

/* ─── Copy for Whoop ─────────────────────────────────────────────────────── */

.whoop-btn { min-height: 48px; margin-top: 16px; font-weight: 600; }
.whoop-btn[hidden] { display: none; }
.whoop-text {
  display: block; width: 100%; margin-top: 10px; min-height: 180px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card);
  font-size: 16px; white-space: pre-wrap; /* 16px stops iOS zooming on focus */
}
