/* ============================================================
   پهلوان — تمرین فعال (active workout)
   ------------------------------------------------------------
   The screen used dozens of times per session, one-handed in the gym.
   Full-screen overlay above the app (and above its bottom dock), below
   the app's modals (so the product's weekly share card can open on top).

   Token values: docs/design/tokens.md
   Layout / states: docs/design/screen-specs.md §۳ (+ mockups/03)
   ============================================================ */

#workout {
  /* ---- spacing — tokens.md §2 ---- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;

  /* ---- type — tokens.md §3 ---- */
  --fs-h2: 22px;
  --fs-title: 17px;
  --fs-body: 15px;
  --fs-label: 13px;
  --fs-meta: 11.5px;
  --fs-eyebrow: 10.5px;
  --fs-micro: 9.5px;
  --fs-num-lg: 28px;
  --fs-num-md: 24px;
  --fs-num-sm: 18px;

  /* ---- colours — tokens.md §4 (new tokens; originals are in styles.css) ---- */
  --surface-0: #0b1320;
  --surface-1: #0f1724;
  --surface-2: #162033;
  --line-strong: #2b3c58;
  --ink-3: #5d6d86;
  --on-accent: #04121a;
  --teal-deep: #1f8f9b;
  --warn: #d19a3a;
  --focus: 0 0 0 2px rgba(53, 208, 186, .45);

  /* ---- radius — tokens.md §5 ---- */
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 20px;
  --r-xl: 24px;
  --r-full: 999px;

  /* ---- layout & touch — tokens.md §7 ---- */
  --gutter: 20px;
  --gutter-sm: 16px;
  --content-max: 560px;
  --header-h: 56px;
  --cta-h: 56px;
  --cta-mini: 52px;
  --mob-bar: 84px;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  /* ---- elevation — tokens.md §6 ---- */
  --e-2: 0 20px 50px rgba(0, 0, 0, .55);
  --glow-teal: 0 8px 24px rgba(53, 208, 186, .22);

  /* ---- gradients — tokens.md §9 ---- */
  --grad-panel: linear-gradient(180deg, rgba(18, 26, 41, .82), rgba(11, 17, 28, .82));
  --grad-panel-2: linear-gradient(180deg, #121a29, #0d1421);
  --grad-cyan: linear-gradient(145deg, var(--cyan), var(--teal-deep));

  /* ---- motion — tokens.md §8 ---- */
  --dur-2: 180ms;
  --dur-3: 280ms;
  --ease-out: cubic-bezier(.2, .8, .2, 1);

  /* ---- component values fixed by screen-specs §۳ ---- */
  --wk-numbox-h: 68px;
  --wk-numbox-h-sm: 62px;
  --wk-num-xl: 34px;
  --wk-num-xl-sm: 30px;
  --wk-bw-num: 40px;
  --wk-step: 40px;
  --wk-step-sm: 38px;
  --wk-progress-h: 3px;

  /* ---- alphas of the three semantic colours (tokens.md §4) ---- */
  --wk-teal-06: rgba(53, 208, 186, .06);
  --wk-teal-08: rgba(53, 208, 186, .08);
  --wk-teal-10: rgba(53, 208, 186, .10);
  --wk-teal-16: rgba(53, 208, 186, .16);
  --wk-teal-18: rgba(53, 208, 186, .18);
  --wk-teal-22: rgba(53, 208, 186, .22);
  --wk-teal-28: rgba(53, 208, 186, .28);
  --wk-teal-30: rgba(53, 208, 186, .30);
  --wk-teal-35: rgba(53, 208, 186, .35);
  --wk-teal-50: rgba(53, 208, 186, .50);
  --wk-gold-12: rgba(231, 184, 75, .12);
  --wk-red-12: rgba(224, 85, 95, .12);
  --wk-red-35: rgba(224, 85, 95, .35);
}

/* ============================== shell ============================== */

#workout {
  position: fixed;
  inset: 0;
  z-index: 45; /* above the bottom dock (40), below app modals (50) */
  overflow: hidden;
  overscroll-behavior: contain;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", system-ui, -apple-system, sans-serif;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#workout[hidden] {
  display: none;
}

/* the tab bar does not exist on this screen */
body.workout-open {
  overflow: hidden;
}

body.workout-open .bottom-nav {
  opacity: 0;
  pointer-events: none;
}

#workout button,
#workout input {
  font-family: inherit;
}

#workout button {
  color: inherit;
}

#workout :focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  box-shadow: var(--focus);
}

#workout .wk-bar b:focus,
#workout .wk-bar b:focus-visible,
#workout .wk-sheet h2:focus,
#workout .wk-sheet h2:focus-visible {
  outline: none;
  box-shadow: none;
}

.wk-screen {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(700px 400px at 88% -8%, var(--wk-teal-10), transparent 62%),
    var(--bg);
}

@keyframes wk-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes wk-sheet-up {
  from {
    transform: translateY(24px);
    opacity: .4;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes wk-pulse {
  0% {
    box-shadow: 0 0 0 0 var(--wk-teal-50);
  }
  100% {
    box-shadow: 0 0 0 16px transparent;
  }
}

@keyframes wk-pop {
  0% {
    transform: scale(.9);
  }
  60% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

/* ============================== header ============================== */

.wk-bar {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex: 0 0 auto;
  min-height: var(--header-h);
  padding: calc(var(--s-2) + var(--safe-t)) var(--gutter) 0;
}

.wk-close,
.wk-end {
  flex: 0 0 auto;
  min-width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.wk-close {
  display: grid;
  place-items: center;
}

.wk-close svg {
  width: 22px;
  height: 22px;
}

.wk-end {
  padding: 0 var(--s-2);
  font-size: var(--fs-meta);
  font-weight: 600;
}

.wk-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  padding: 0 var(--s-1);
}

.wk-title b {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.wk-title span {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-micro);
  font-weight: 500;
  letter-spacing: .2px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-offline {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 var(--s-2);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--warn);
  font-size: var(--fs-micro);
  font-weight: 600;
  margin-inline-start: var(--s-1);
}

/* ============================== progress + meta ============================== */

.wk-progress {
  display: flex;
  gap: 3px;
  flex: 0 0 auto;
  padding: 0 var(--gutter);
}

.wk-progress i {
  flex: 1;
  height: var(--wk-progress-h);
  border-radius: var(--r-full);
  background: var(--line);
}

.wk-progress i.done {
  background: var(--teal-deep);
}

.wk-progress i.now {
  background: var(--cyan);
}

.wk-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--s-3);
  flex: 0 0 auto;
  padding: var(--s-2) var(--gutter) 0;
  font-size: var(--fs-meta);
  color: var(--muted);
}

.wk-meta b {
  color: var(--text);
  font-weight: 600;
}

.wk-entry {
  margin: var(--s-1) 0 0;
  padding: 0 var(--gutter);
  text-align: center;
  font-size: var(--fs-meta);
  line-height: 1.5;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-dot {
  width: 3px;
  height: 3px;
  border-radius: var(--r-full);
  background: var(--line-strong);
}

/* ============================== page ============================== */

.wk-page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: var(--s-4) var(--gutter) calc(var(--mob-bar) + var(--s-4) + var(--safe-b));
  animation: wk-in var(--dur-3) var(--ease-out) both;
}

.wk-page::-webkit-scrollbar {
  display: none;
}

.wk-stack {
  display: flex;
  flex-direction: column;
}

/* ============================== cards / text ============================== */

.wk-eyebrow {
  display: block;
  margin: 0;
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: .5px;
  line-height: 1.4;
  color: var(--muted);
}

.wk-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.wk-card {
  margin-top: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--grad-panel);
}

/* ============================== rest timer ============================== */

.wk-rest {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--wk-teal-22);
  border-radius: var(--r-md);
  background: var(--wk-teal-06);
}

.wk-rest-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.wk-rest-label {
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: .4px;
  color: var(--muted);
}

.wk-rest-acts {
  display: flex;
  gap: var(--s-2);
}

/* visible 32px, hit area 44px via the pseudo element */
.wk-mini {
  position: relative;
  height: 32px;
  padding: 0 var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-micro);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.wk-mini::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: var(--r-full);
}

.wk-rest-body {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin: 2px 0 var(--s-2);
}

.wk-rest-time {
  direction: ltr;
  font-size: var(--fs-num-lg);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.wk-rest-next {
  font-size: var(--fs-meta);
  color: var(--muted);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-rest-next b {
  color: var(--text);
  font-weight: 600;
}

.wk-restbar {
  height: 3px;
  border-radius: var(--r-full);
  background: var(--wk-teal-18);
  overflow: hidden;
}

.wk-restbar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--cyan);
  transition: width var(--dur-3) linear;
}

/* ============================== previous performance ============================== */

.wk-prev .wk-row1 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}

.wk-prev .wk-pr {
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
}

.wk-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.wk-chip {
  display: inline-flex;
  align-items: baseline;
  height: 30px;
  padding: 0 var(--s-3);
  border-radius: var(--r-full);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-meta);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  align-items: center;
}

.wk-hint {
  margin: var(--s-2) 0 0;
  font-size: var(--fs-meta);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-first {
  margin: var(--s-2) 0 0;
  font-size: var(--fs-meta);
  color: var(--muted);
}

/* ============================== logged sets ============================== */

.wk-logged {
  margin: var(--s-4) 0 0;
  padding: 0;
  list-style: none;
}

.wk-lrow {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: var(--tap);
  padding: var(--s-2) var(--s-3);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-0);
  font-size: var(--fs-label);
  text-align: start;
  cursor: pointer;
}

.wk-lrow + .wk-lrow {
  margin-top: 6px;
}

.wk-lrow .wk-check {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: var(--r-full);
  background: var(--wk-teal-16);
  color: var(--cyan);
  flex: 0 0 auto;
}

.wk-lrow .wk-check svg {
  width: 11px;
  height: 11px;
}

.wk-lrow .wk-lbl {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: var(--fs-meta);
}

.wk-lrow .wk-val {
  font-size: var(--fs-label);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ============================== set block ============================== */

.wk-setblock {
  margin-top: var(--s-4);
}

.wk-sbhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}

.wk-sbhead b {
  font-size: var(--fs-title);
  font-weight: 700;
}

.wk-sbhead span {
  font-size: var(--fs-meta);
  color: var(--muted);
}

.wk-numgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

.wk-numgrid--bw {
  grid-template-columns: minmax(0, 1fr);
}

.wk-numbox {
  min-width: 0;
}

.wk-nl {
  display: block;
  margin-bottom: 7px;
  text-align: center;
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: .4px;
  color: var(--muted);
}

.wk-nb {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  height: var(--wk-numbox-h);
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-0);
}

/* the big number is a tap target that opens the keyboard sheet */
.wk-numval {
  direction: ltr;
  flex: 1;
  min-width: 0;
  height: var(--tap);
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--wk-num-xl);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.5px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-numval--sm {
  font-size: 27px;
}

.wk-numval--xs {
  font-size: 22px;
}

.wk-numgrid--bw .wk-numval {
  font-size: var(--wk-bw-num);
}

/* visible 40px, hit area 46px via the pseudo element */
.wk-step {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--wk-step);
  height: var(--wk-step);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-1);
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.wk-step svg {
  width: 15px;
  height: 15px;
}

.wk-step::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: var(--r-full);
}

.wk-step--plus {
  color: var(--cyan);
  border-color: var(--wk-teal-35);
  background: var(--wk-teal-08);
}

.wk-setnote {
  margin: var(--s-3) 0 0;
  text-align: center;
  font-size: var(--fs-meta);
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-setnote b {
  color: var(--muted);
  font-weight: 500;
}

/* ============================== next up / upcoming ============================== */

.wk-nextup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-top: var(--s-4);
  padding: 0 2px;
}

.wk-nextup span {
  font-size: var(--fs-meta);
  color: var(--ink-3);
}

.wk-nextup b {
  font-size: var(--fs-meta);
  color: var(--muted);
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
}

.wk-card-head .wk-title-sm {
  margin: 0;
  font-size: var(--fs-title);
  font-weight: 700;
  color: var(--text);
}

.wk-card-head .wk-meta-sm {
  font-size: var(--fs-meta);
  color: var(--muted);
}

.wk-upcoming {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wk-urow {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  font-size: var(--fs-label);
}

.wk-urow + .wk-urow {
  border-top: 1px solid var(--line);
}

.wk-urow .wk-idx {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: var(--fs-micro);
  font-weight: 600;
  flex: 0 0 auto;
}

.wk-urow .wk-nm {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-urow .wk-st {
  font-size: var(--fs-meta);
  color: var(--muted);
  white-space: nowrap;
}

/* ============================== exercise-complete card ============================== */

.wk-done {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--wk-teal-30);
  border-radius: var(--r-md);
  background: var(--wk-teal-06);
  animation: wk-pop var(--dur-2) var(--ease-out) both;
}

.wk-done .wk-dtop {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.wk-done .wk-dck {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  background: var(--cyan);
  color: var(--on-accent);
  flex: 0 0 auto;
}

.wk-done .wk-dck svg {
  width: 16px;
  height: 16px;
}

.wk-done .wk-dt {
  flex: 1;
  min-width: 0;
}

.wk-done .wk-dt b {
  display: block;
  font-size: var(--fs-label);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-done .wk-dt > span {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-meta);
  color: var(--muted);
}

.wk-done .wk-dxp {
  font-size: var(--fs-label);
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

/* ============================== session stats ============================== */

.wk-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--line);
  overflow: hidden;
}

.wk-stat {
  padding: var(--s-3) var(--s-1);
  background: var(--panel);
  text-align: center;
}

.wk-stat b {
  display: block;
  direction: ltr;
  font-size: var(--fs-num-sm);
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.wk-stat--xp b {
  color: var(--gold);
}

.wk-stat span {
  font-size: var(--fs-micro);
  color: var(--muted);
}

/* ============================== fixed CTA bar ============================== */

.wk-ctabar {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  /* spec §۳: a fixed 84px bar = 12 top + 56 button + 16 bottom (+ safe area) */
  padding: var(--s-3) var(--gutter) calc(var(--s-4) + var(--safe-b));
  background: linear-gradient(180deg, rgba(7, 10, 18, 0), rgba(7, 10, 18, .92) 30%, rgba(7, 10, 18, .99));
}

.wk-clock {
  display: grid;
  place-items: center;
  width: var(--cta-mini);
  height: var(--cta-mini);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--surface-1);
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.wk-clock svg {
  width: 22px;
  height: 22px;
}

.wk-clock.wk-on {
  color: var(--cyan);
  border-color: var(--wk-teal-35);
}

.wk-cta {
  flex: 1;
  min-width: 0;
  height: var(--cta-h);
  padding: 0 var(--s-4);
  border: 0;
  border-radius: var(--r-full);
  background: var(--grad-cyan);
  color: var(--on-accent);
  font-size: var(--fs-body);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--glow-teal);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-cta:active {
  transform: translateY(1px);
}

.wk-cta[disabled] {
  opacity: .4;
  box-shadow: none;
  cursor: not-allowed;
}

.wk-cta.wk-pulse {
  animation: wk-pulse var(--dur-2) var(--ease-out);
}

/* ============================== undo bar ============================== */

.wk-undo {
  position: absolute;
  inset-inline: var(--gutter);
  bottom: calc(var(--mob-bar) + var(--s-2) + var(--safe-b));
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: var(--tap);
  padding: 0 var(--s-2) 0 var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--fs-label);
  box-shadow: var(--e-2);
  animation: wk-in var(--dur-2) var(--ease-out) both;
}

.wk-undo button {
  min-width: var(--tap);
  height: var(--tap);
  padding: 0 var(--s-3);
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--cyan);
  font-size: var(--fs-label);
  font-weight: 600;
  cursor: pointer;
}

/* ============================== sheets ============================== */

.wk-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
}

.wk-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 10, .62);
}

.wk-sheet {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  max-height: min(88%, 720px);
  display: flex;
  flex-direction: column;
  padding: var(--s-5) var(--gutter) calc(var(--s-5) + var(--safe-b));
  border-top: 1px solid var(--line);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--grad-panel-2);
  box-shadow: var(--e-2);
  overflow-y: auto;
  animation: wk-sheet-up var(--dur-2) var(--ease-out) both;
}

.wk-sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.wk-sheet-head h2 {
  margin: 0;
  font-size: var(--fs-h2);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.3px;
}

.wk-sheet-head .wk-sub {
  margin: 1px 0 0;
  font-size: var(--fs-meta);
  color: var(--muted);
}

.wk-x {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  margin: -4px -8px 0 0;
  padding: 0;
  border: 0;
  border-radius: var(--r-full);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
}

.wk-x svg {
  width: 20px;
  height: 20px;
}

.wk-sheet-body {
  min-height: 0;
}

.wk-sheet-actions {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-5);
}

.wk-sbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  width: 100%;
  height: 52px;
  padding: 0 var(--s-4);
  border: 0;
  border-radius: var(--r-full);
  background: var(--grad-cyan);
  color: var(--on-accent);
  font-size: var(--fs-body);
  font-weight: 700;
  cursor: pointer;
}

.wk-sbtn--ghost {
  height: 48px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-label);
  font-weight: 600;
}

.wk-sbtn--danger {
  height: 48px;
  background: var(--wk-red-12);
  color: var(--red);
  font-size: var(--fs-label);
  font-weight: 600;
}

.wk-sbtn[disabled] {
  opacity: .4;
  cursor: not-allowed;
}

.wk-linkbtn {
  display: block;
  min-height: var(--tap);
  margin: var(--s-1) auto 0;
  padding: 0 var(--s-2);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-meta);
  font-weight: 500;
  cursor: pointer;
}

/* number edit form (in a sheet) */
.wk-editgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}

.wk-editgrid--single {
  grid-template-columns: minmax(0, 1fr);
}

.wk-editable {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-1);
  height: var(--wk-numbox-h);
  padding: 0 var(--s-1);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-0);
}

.wk-editable.wk-invalid {
  border-color: var(--red);
}

/* inside the sheet the steppers can be a true 44×44 target */
.wk-sheet .wk-step {
  width: var(--tap);
  height: var(--tap);
}

/* 16px+ on every input, or iOS zooms the page on focus */
.wk-input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.wk-field-error {
  margin: var(--s-2) 0 0;
  font-size: var(--fs-meta);
  color: var(--red);
  text-align: center;
}

.wk-confirm {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--wk-red-35);
  border-radius: var(--r-md);
  background: var(--wk-red-12);
}

.wk-confirm p {
  margin: 0 0 var(--s-2);
  font-size: var(--fs-label);
  color: var(--text);
}

.wk-confirm-row {
  display: flex;
  gap: var(--s-2);
}

.wk-confirm-row .wk-sbtn {
  height: var(--tap);
  font-size: var(--fs-label);
}

/* ============================== summary sheet ============================== */

.wk-sum-lead {
  margin: 0 0 var(--s-3);
  font-size: var(--fs-label);
  line-height: 1.7;
  color: var(--muted);
}

.wk-sum-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--line);
  overflow: hidden;
}

.wk-sum-stats .wk-stat {
  padding: var(--s-4) var(--s-1);
}

.wk-sum-stats .wk-stat b {
  font-size: var(--fs-num-md);
  font-weight: 800;
}

.wk-prs {
  margin: var(--s-4) 0 0;
  padding: 0;
  list-style: none;
}

.wk-prs-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
  margin: var(--s-4) 0 var(--s-1);
  font-size: var(--fs-label);
  font-weight: 600;
  color: var(--text);
}

.wk-prs-title span {
  font-size: var(--fs-meta);
  color: var(--muted);
  font-weight: 400;
}

.wk-prrow {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  font-size: var(--fs-label);
}

.wk-prrow + .wk-prrow {
  border-top: 1px solid var(--line);
}

.wk-prrow .wk-pric {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  background: var(--wk-gold-12);
  color: var(--gold);
  flex: 0 0 auto;
}

.wk-prrow .wk-pric svg {
  width: 14px;
  height: 14px;
}

.wk-prrow .wk-prnm {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-prrow .wk-prval {
  font-size: var(--fs-meta);
  font-weight: 600;
  color: var(--gold);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.wk-prs-empty {
  margin: var(--s-3) 0 0;
  font-size: var(--fs-meta);
  color: var(--ink-3);
}

/* the session share card */
.wk-sharecard {
  margin-top: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--wk-teal-28);
  border-radius: var(--r-lg);
  background:
    radial-gradient(260px 160px at 88% -24%, var(--wk-teal-16), transparent 70%),
    var(--grad-panel-2);
}

.wk-sharecard .wk-sc-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
}

.wk-sharecard .wk-sc-name {
  font-size: var(--fs-title);
  font-weight: 700;
  letter-spacing: -.2px;
}

.wk-sharecard .wk-sc-sub {
  margin-top: 2px;
  font-size: var(--fs-meta);
  color: var(--muted);
}

.wk-sharecard .wk-sc-xp {
  font-size: var(--fs-label);
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.wk-sharecard .wk-sc-line {
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  font-size: var(--fs-meta);
  color: var(--muted);
  white-space: nowrap;
}

.wk-sharecard .wk-sc-line > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wk-sharecard .wk-sc-line b {
  color: var(--text);
  font-weight: 600;
}

.wk-sharebtn svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.wk-sharebtn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  flex: 0 0 auto;
  min-height: var(--tap);
  padding: 0 var(--s-2);
  border: 0;
  background: transparent;
  color: var(--cyan);
  font-size: var(--fs-label);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.wk-note {
  margin: var(--s-3) 0 0;
  font-size: var(--fs-meta);
  color: var(--ink-3);
  text-align: center;
}

/* ============================== 320–360px ============================== */

@media (max-width: 360px) {
  #workout {
    --gutter: var(--gutter-sm);
    --wk-numbox-h: var(--wk-numbox-h-sm);
    --wk-num-xl: var(--wk-num-xl-sm);
    --wk-step: var(--wk-step-sm);
  }

  #workout .wk-title b {
    font-size: 14px;
  }

  #workout .wk-rest-time {
    font-size: 24px;
  }

  #workout .wk-stat b {
    font-size: 16px;
  }

  #workout .wk-card {
    padding: var(--s-4);
  }

  /* the two column half-width boxes cannot fit «۱۰۲٫۵» at 30px next to two
     38px steppers; stacking keeps every control, size and number intact */
  #workout .wk-numgrid {
    grid-template-columns: minmax(0, 1fr);
  }

  #workout .wk-numval--sm,
  #workout .wk-numval--xs {
    font-size: var(--wk-num-xl);
  }

  #workout .wk-sheet .wk-editgrid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ============================== reduced motion ============================== */

@media (prefers-reduced-motion: reduce) {
  #workout *,
  #workout *::before,
  #workout *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}
