.nouri-v2 #workoutLive[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
}

.nouri-v2 #workoutLive [hidden],
.nouri-v2 #workoutBestDialog [hidden] { display: none !important; }

.nouri-v2 #workoutLive .live-inner {
  min-height: 0;
  margin: 0;
  padding-bottom: 14px;
  overscroll-behavior: contain;
}

.nouri-v2 #workoutLive .set-rows { margin-bottom: 0; }
.nouri-v2 #workoutLive .set-row {
  grid-template-columns: minmax(38px, .46fr) minmax(0, 1fr) minmax(0, 1fr) 16px;
  gap: clamp(5px, 2vw, 12px);
  align-items: start;
  margin-inline: -8px;
  padding-inline: 8px;
}
.nouri-v2 #workoutLive .set-row[data-current-set] {
  background: rgba(216, 250, 119, .10);
  border-radius: 12px;
  box-shadow: inset 0 0 0 2px #d8fa77;
}
.nouri-v2 #workoutLive .set-row[data-current-set]:focus { outline: none; }
.nouri-v2 #workoutLive .set-row[data-current-set] > b,
.nouri-v2 #workoutLive .set-row[data-current-set] > span { color: #d8fa77; }
@media (forced-colors: active) {
  .nouri-v2 #workoutLive .set-row[data-current-set],
  .nouri-v2 #workoutLive .set-row[data-current-set]:focus {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
  .nouri-v2 #workoutLive .set-row[data-current-set] > b,
  .nouri-v2 #workoutLive .set-row[data-current-set] > span { color: CanvasText; }
}
.workout-set-field { min-width: 0; }
.nouri-v2 .private-workout-badge {
  display: inline-block;
  margin: 5px 0 8px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #b9efd9;
  font-size: .8rem;
  font-weight: 800;
}
.nouri-v2 .private-workout-badge[hidden] { display: none; }
.private-workout-prescription {
  display: block;
  margin: 6px 0 10px;
  color: #b9efd9;
  font-weight: 750;
  overflow-wrap: anywhere;
}
.private-workout-status { color: #b9efd9; font-size: .9rem; }
.private-workout-status:empty { display: none; }
.nouri-v2 #workoutLive .set-row > b { overflow-wrap: normal; }
.workout-set-field input {
  appearance: textfield;
  font-variant-numeric: tabular-nums;
}
.workout-set-field input::-webkit-inner-spin-button,
.workout-set-field input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.nouri-v2 .set-row .workout-set-field input { padding-inline: 4px; }
.workout-set-field input[data-keypad-active] { outline: 2px solid #b9efd9; outline-offset: 2px; }
.workout-set-field small { display: block; margin: 4px 0 0; text-align: center; }
.nouri-v2 .set-row .workout-set-field .field-error { position: static; text-wrap: balance; }

.workout-set-controls,
.workout-keypad {
  border-top: 1px solid var(--line);
  background: var(--surface, #172a20);
  padding: 9px max(16px, var(--dialog-safe-right, 0px), calc((100vw - 640px)/2)) calc(9px + var(--dialog-safe-bottom, 0px)) max(16px, var(--dialog-safe-left, 0px), calc((100vw - 640px)/2));
}
.nouri-v2 #workoutLive.has-workout-keypad .workout-set-controls { display: none; }
.nouri-v2 .workout-set-controls .live-nav { margin-top: 3px; }
.nouri-v2 .workout-set-controls .live-nav button { min-height: 44px; }
.nouri-v2 .workout-set-controls .live-nav .primary {
  color: #14271c;
  background: #d8fa77;
  padding-inline: 14px;
}
.workout-exercise-done {
  margin: 0 0 4px;
  color: #b9efd9;
  font-weight: 850;
}
.workout-rest { position: relative; text-align: center; }
.workout-rest-clock { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; }
.workout-rest-clock span { align-self: center; font-size: 1rem; font-weight: 850; }
.workout-rest-clock b {
  display: block;
  color: #fff;
  font-size: clamp(2.8rem, 11vw, 4.6rem);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.workout-rest-clock[data-countdown="final"] b { color: #ffa39d; animation: nouri-rest-final 1s ease-in-out infinite; }
@keyframes nouri-rest-final {
  0%, 100% { color: #ffa39d; transform: translateY(0); }
  50% { color: #fff; transform: translateY(-4px); }
}
.workout-rest p { margin: 5px 0 8px; }
.workout-rest p:empty { display: none; }
.nouri-v2 #skipWorkoutRest { min-height: 44px; padding-block: 6px; }

.workout-keypad { padding-top: 9px; }
.workout-keypad-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 7px; }
.workout-keypad-top b { display: block; font-size: .84rem; }
.workout-keypad output { color: #b9efd9; font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.nouri-v2 #workoutKeypadDone { min-height: 44px; padding: 7px 15px; }
.workout-keys { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.workout-keys button {
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #223a2c;
  color: #f2f8ee;
  font-size: 1.25rem;
  font-weight: 800;
  touch-action: manipulation;
}
.workout-keys button:disabled { opacity: .45; }
.workout-keys button:active { background: #365944; }

.nouri-v2 #workoutBestDialog {
  width: min(calc(100% - 28px), 430px);
  max-height: calc(100dvh - max(28px, var(--dialog-safe-top, 0px)) - max(22px, var(--dialog-safe-bottom, 0px)));
  margin: auto;
  overflow-y: auto;
  position: fixed;
}
.workout-best-content {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: linear-gradient(145deg, #224333, #16271e 74%);
  color: #f2f8ed;
  text-align: center;
  padding: clamp(15px, 5vw, 28px);
}
#workoutBestBuddy { width: min(106px, 26vw); aspect-ratio: 1; margin: 0 auto; }
#workoutBestBuddy svg { display: block; width: 100%; height: 100%; }
#workoutBestTitle { margin: 5px 0 13px; }
#workoutBestRecords { display: grid; gap: 7px; list-style: none; padding: 0; margin: 0 0 14px; }
#workoutBestRecords li {
  display: grid;
  gap: 3px;
  border: 1px solid #5a745c;
  border-radius: 10px;
  background: #1e3428;
  padding: 9px;
}
#workoutBestRecords li small { color: #d8fa77; }
.workout-best-confetti {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  color: #dafa82;
}
.workout-best-confetti::before,
.workout-best-confetti::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 13%;
  width: 6px;
  height: 9px;
  background: currentColor;
  box-shadow: 24px 30px #9edae9, -16px 54px #d6b5ed, 38px 74px #f3d293, 7px 100px #b9efd9, 24px 119px #dafa82;
  animation: nouri-best-confetti 1.6s ease-out both;
}
.workout-best-confetti::after { left: auto; right: 17%; transform: scaleX(-1); animation-delay: .15s; }
@keyframes nouri-best-confetti {
  from { translate: 0 -100px; opacity: 0; }
  28% { opacity: 1; }
  to { translate: 10px 52px; opacity: .5; }
}

@media (max-height: 420px) {
  .workout-keypad-top { margin-bottom: 3px; }
  .workout-keys { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
  .workout-rest-clock[data-countdown="final"] b,
  .workout-best-confetti::before,
  .workout-best-confetti::after { animation: none; }
}

[data-nouri-motion-paused] .workout-rest-clock[data-countdown="final"] b,
[data-nouri-motion-paused] .workout-best-confetti::before,
[data-nouri-motion-paused] .workout-best-confetti::after { animation: none; }


/* Stable touch targets: 1–9 stay in a three-column grid; zero has its own wider row. */
.nouri-v2 #workoutKeypad {
  padding-top: 12px;
  padding-bottom: calc(18px + var(--dialog-safe-bottom, 0px));
}
.nouri-v2 #workoutKeypad .workout-keypad-top {
  display: flex;
  height: 56px;
  min-height: 56px;
  margin-bottom: 10px;
  gap: 12px;
}
.nouri-v2 #workoutKeypad .workout-keypad-top > div { min-width: 0; }
.nouri-v2 #workoutKeypad .workout-keypad-top b {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  line-height: 1.2;
}
.nouri-v2 #workoutKeypad output { display: block; line-height: 1.2; }
.nouri-v2 #workoutKeypadDone { min-height: 48px; flex-shrink: 0; }
.nouri-v2 #workoutKeypad .workout-keys {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.nouri-v2 #workoutKeypad .workout-keypad-bottom {
  display: grid;
  grid-template-columns: minmax(48px, 1fr) minmax(96px, 2fr) minmax(48px, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.nouri-v2 #workoutKeypad :is(.workout-keys, .workout-keypad-bottom) button {
  min-width: 0;
  min-height: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #223a2c;
  color: #f2f8ee;
  font-size: 1.4rem;
  font-weight: 850;
  line-height: 1;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transform: none;
  translate: none;
  scale: none;
}
.nouri-v2 #workoutKeypad .workout-keypad-bottom [data-workout-key="0"] {
  background: #35543d;
  border-color: #94ab73;
}
.nouri-v2 #workoutKeypad :is(.workout-keys, .workout-keypad-bottom) button:disabled {
  opacity: .35;
  visibility: visible;
}
.nouri-v2 #workoutKeypad :is(.workout-keys, .workout-keypad-bottom) button:active:not(:disabled) {
  background: #d8fa77;
  color: #14271c;
  transform: none;
  translate: none;
  scale: none;
}
.nouri-v2 #workoutKeypad :is(.workout-keys, .workout-keypad-bottom) button:focus-visible {
  outline: 2px solid #d8fa77;
  outline-offset: 2px;
}
@media (max-height: 520px) {
  .nouri-v2 #workoutKeypad {
    padding-top: 6px;
    padding-bottom: calc(12px + var(--dialog-safe-bottom, 0px));
  }
  .nouri-v2 #workoutKeypad .workout-keypad-top {
    height: 44px;
    min-height: 44px;
    margin-bottom: 6px;
  }
  .nouri-v2 #workoutKeypadDone { min-height: 44px; }
  .nouri-v2 #workoutKeypad .workout-keys { gap: 6px; }
  .nouri-v2 #workoutKeypad .workout-keypad-bottom { gap: 6px; margin-top: 12px; }
  .nouri-v2 #workoutKeypad .workout-keys button { height: 44px; min-height: 44px; }
  .nouri-v2 #workoutKeypad .workout-keypad-bottom button { height: 48px; min-height: 48px; }
}
@media (min-width: 600px) and (max-height: 420px) {
  .nouri-v2 #workoutKeypad {
    display: grid;
    grid-template-columns: clamp(100px, 16vw, 140px) minmax(0, 1fr);
    gap: 12px 16px;
    padding-top: 8px;
    padding-bottom: calc(18px + var(--dialog-safe-bottom, 0px));
  }
  .nouri-v2 #workoutKeypad .workout-keypad-top {
    grid-column: 1;
    grid-row: 1 / span 2;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    min-height: 0;
    height: auto;
    margin: 0;
  }
  .nouri-v2 #workoutKeypad .workout-keys { grid-column: 2; grid-row: 1; }
  .nouri-v2 #workoutKeypad .workout-keypad-bottom { grid-column: 2; grid-row: 2; margin-top: 0; }
}
@media (forced-colors: active) {
  .nouri-v2 #workoutKeypad :is(.workout-keys, .workout-keypad-bottom) button,
  .nouri-v2 #workoutKeypad .workout-keypad-bottom [data-workout-key="0"] {
    background: ButtonFace;
    color: ButtonText;
    border-color: ButtonText;
  }
  .nouri-v2 #workoutKeypad :is(.workout-keys, .workout-keypad-bottom) button:focus-visible {
    outline-color: Highlight;
  }
}
