/* ---------- Fuentes ---------- */

/* Ranade (Indian Type Foundry, gratis vía fontshare.com). Se guarda en /fonts para que ande offline. */
@font-face {
  font-family: 'Ranade';
  src: url('../fonts/ranade-700.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  color-scheme: dark;
  /* Negro con gris claro / blanco. Siempre oscuro, sin importar el tema del sistema. */
  --bg: #000000;
  --surface: #121212;
  --surface-2: #1e1e1e;
  --border: #2a2a2a;
  --text: #f5f5f5;
  --muted: #8c8c8c;
  --accent: #ececec;
  --accent-text: #ececec;
  --on-accent: #000000;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --danger: #ff6b6b;
  --go: #4ade80; /* fin del descanso */
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  --font-brand: 'Ranade', Georgia, serif;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

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

h1,
h2,
p {
  margin: 0;
}

/* ---------- Layout ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 60px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.topbar-title {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
}

.topbar-title h1 {
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-sub {
  display: block;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-brand);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--on-accent);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
  stroke-width: 2.6;
}

.content {
  flex: 1;
  padding: 8px 16px 24px;
}

.bottombar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 20px 0 10px;
}

.hint {
  color: var(--muted);
  padding: 20px 0;
  text-align: center;
}

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

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 16px;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:disabled {
  background: var(--surface-2);
  color: var(--muted);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--text);
  flex-shrink: 0;
}

.icon-btn:active {
  background: var(--surface-2);
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-weight: 600;
  font-size: 15px;
  color: var(--accent-text);
}

.link-btn svg {
  width: 18px;
  height: 18px;
}

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

.link-btn:disabled {
  opacity: 0.35;
}

/* ---------- Inicio ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 18vh 12px 0;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: var(--accent-soft);
  color: var(--accent-text);
  margin-bottom: 8px;
}

.empty-icon svg {
  width: 36px;
  height: 36px;
}

.empty h2 {
  font-size: 22px;
  letter-spacing: -0.01em;
}

.empty p {
  color: var(--muted);
  max-width: 300px;
  margin-bottom: 12px;
}

.routine-list,
.ex-list,
.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.routine {
  display: flex;
  align-items: center;
  padding-right: 6px;
}

.btn-danger {
  margin-top: 28px;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}

.btn-danger svg {
  width: 20px;
  height: 20px;
}

.routine-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  text-align: left;
  border-radius: var(--radius);
}

.routine-main:active {
  background: var(--surface-2);
}

.routine-name {
  font-size: 18px;
  font-weight: 700;
}

.routine-groups {
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
}

.routine-sub {
  color: var(--muted);
  font-size: 14px;
}

.resume {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  margin-top: 4px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  text-align: left;
}

.resume-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.resume-text span {
  color: var(--muted);
  font-size: 14px;
}

.resume-cta {
  font-weight: 700;
  color: var(--accent-text);
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 1.8s infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 8px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

/* ---------- Editor de rutina ---------- */

.field {
  display: block;
  margin-top: 8px;
  margin-bottom: 16px;
}

.label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 16px;
}

input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 600;
  font-size: 15px;
}

.chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.ex-list {
  gap: 8px;
}

.ex-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.ex-item.selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.ex-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  text-align: left;
}

.ex-check {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 2px solid var(--border);
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}

.selected .ex-check {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.ex-name {
  flex: 1;
  font-weight: 500;
}

.tag {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}

.targets {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 0 14px 14px 52px;
}

.times {
  color: var(--muted);
  padding-bottom: 10px;
}

.stepper-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.stepper-ctrl {
  display: flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.stepper-ctrl button {
  width: 42px;
  height: 40px;
  font-size: 20px;
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.stepper-ctrl button:active {
  background: var(--border);
}

.stepper-ctrl output {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.group-block .link-btn {
  margin-top: 4px;
}

.add-ex {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.add-ex input {
  min-height: 44px;
}

/* ---------- Entrenar ---------- */

.ex-card {
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s ease;
}

.ex-card.complete {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.ex-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}

.ex-title {
  font-size: 18px;
  font-weight: 700;
}

.ex-target {
  font-size: 14px;
  color: var(--muted);
}

.last-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 14px;
  color: var(--muted);
  text-align: left;
}

.last-btn strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.last-use {
  font-weight: 700;
  color: var(--accent-text);
}

.last-btn:active {
  background: var(--border);
}

.last-none {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
}

.set-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr 52px;
  gap: 8px;
  align-items: center;
  padding: 4px 0;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.set-head {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding-bottom: 0;
}

.set-head span:not(:first-child) {
  text-align: center;
}

.set-num {
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.set-head .set-num,
.set-head span:first-child {
  text-align: center;
}

.num {
  min-height: 48px;
  padding: 0 8px;
  text-align: center;
  font-weight: 600;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.check-btn {
  display: grid;
  place-items: center;
  width: 52px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.check-btn:active {
  transform: scale(0.94);
}

.check-btn svg {
  stroke-width: 3;
}

.set-row.done {
  background: var(--accent-soft);
}

.set-row.done .num {
  background: transparent;
  border-color: transparent;
}

.set-row.done .set-num {
  color: var(--accent-text);
}

.set-row.done .check-btn {
  background: var(--accent);
  color: var(--on-accent);
}

.set-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}

/* ---------- Resumen ---------- */

.hero {
  text-align: center;
  padding: 20px 0 8px;
}

.hero-check {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
}

.hero-check svg {
  width: 32px;
  height: 32px;
  stroke-width: 3;
}

.hero h2 {
  font-size: 22px;
}

.hero p {
  color: var(--muted);
  margin-top: 4px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.summary-item {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-name {
  font-weight: 700;
}

.summary-sets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}

/* ---------- Hoja de opciones y avisos ---------- */

.sheet {
  width: 100%;
  max-width: 560px;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.sheet[open] {
  animation: slide-up 0.2s ease-out;
}

@keyframes slide-up {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
}

.sheet-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 16px calc(env(safe-area-inset-bottom) + 16px);
  background: var(--surface);
  border-radius: 20px 20px 0 0;
}

.sheet-title {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 0 8px;
}

.sheet-message {
  text-align: center;
  font-size: 16px;
  font-weight: 500;
  padding: 8px 8px 12px;
}

.sheet-btn {
  min-height: 52px;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-weight: 600;
}

.sheet-btn.danger {
  color: var(--danger);
}

.sheet-btn.cancel {
  background: transparent;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  transform: translate(-50%, 20px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  font-size: 15px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Menú del inicio ---------- */

.brand {
  flex: 1;
  min-width: 0;
}

/* ---------- Grupos propios y orden de la rutina ---------- */

.chip-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-style: dashed;
  color: var(--muted);
}

.chip-add svg {
  width: 16px;
  height: 16px;
}

.add-group {
  margin-top: 12px;
}

.order-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 4px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.order-num {
  width: 22px;
  text-align: center;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.order-name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-weight: 500;
}

.order-name small {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

.order-item .icon-btn svg {
  width: 20px;
  height: 20px;
}

.order-item .icon-btn:disabled {
  opacity: 0.25;
}

/* ---------- Temporizador de descanso (isla flotante) ---------- */

.rest-island {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 64px);
  left: 50%;
  z-index: 50;
  width: min(calc(100% - 32px), 380px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  border-radius: 999px;
  background: #0b0b0b;
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  transform: translateX(-50%);
  animation: island-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.rest-island[hidden] {
  display: none;
}

@keyframes island-in {
  from {
    opacity: 0;
    transform: translate(-50%, -16px) scale(0.92);
  }
}

.rest-ring {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  transform: rotate(-90deg);
}

.rest-ring circle {
  fill: none;
  stroke-width: 4;
}

.rest-ring-track {
  stroke: var(--surface-2);
}

.rest-ring-fill {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dashoffset: 0;
  transition: stroke 0.3s ease;
}

@keyframes rest-ring {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: 113.1;
  }
}

.rest-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.rest-time {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.rest-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.rest-btn {
  display: grid;
  place-items: center;
  min-width: 48px;
  height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface-2);
  font-weight: 700;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.rest-btn:active {
  background: var(--border);
}

.rest-close {
  width: 44px;
  min-width: 44px;
  padding: 0;
  color: var(--muted);
}

.rest-close svg {
  width: 18px;
  height: 18px;
}

/* Terminó el descanso: todo en verde. */
.rest-island.over {
  border-color: color-mix(in srgb, var(--go) 60%, transparent);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7), 0 0 24px color-mix(in srgb, var(--go) 35%, transparent);
}

.rest-island.over .rest-ring-fill {
  stroke: var(--go);
  animation: none !important;
  stroke-dashoffset: 0;
}

.rest-island.over .rest-time {
  font-size: 22px;
  color: var(--go);
}

/* ---------- Título de ejercicio → progreso ---------- */

.ex-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 18px;
  font-weight: 700;
  text-align: left;
}

.ex-title-btn svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
}

/* ---------- Progreso ---------- */

.progress-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 12px 14px 16px;
  text-align: left;
  border-radius: var(--radius);
}

.progress-item:active {
  background: var(--surface-2);
}

.progress-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.progress-item > svg {
  color: var(--muted);
}

.chart-card {
  padding: 14px 12px 8px;
}

.chart-title {
  font-size: 13px;
  color: var(--muted);
  margin: 0 4px 6px;
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  fill: none;
  stroke: none;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.chart-line {
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.chart-dot {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 2;
}

.chart-dot.last {
  fill: var(--accent);
}

.chart-label {
  fill: var(--muted);
  stroke: none;
  font-size: 11px;
  font-family: var(--font);
  font-variant-numeric: tabular-nums;
}

.stat-value {
  text-align: center;
}

/* ---------- Rutina para hoy ---------- */

.gen-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-top: 8px;
  padding: 16px;
  text-align: left;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #1c1c1c, #0f0f0f);
  border: 1px solid var(--border);
}

.gen-card:active {
  background: var(--surface-2);
}

.gen-card > svg {
  color: var(--muted);
}

.gen-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  flex-shrink: 0;
}

.gen-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.gen-text strong {
  font-size: 17px;
}

.gen-text span {
  font-size: 14px;
  color: var(--muted);
}

.empty .link-btn {
  margin-top: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip svg {
  width: 16px;
  height: 16px;
}

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

.seg-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 15px;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-btn small {
  font-size: 12px;
  font-weight: 500;
  opacity: 0.8;
}

.seg-btn[aria-pressed='true'] {
  background: var(--accent);
  color: var(--on-accent);
}

.plan {
  padding: 18px 16px 8px;
  margin-top: 8px;
}

.plan-reason {
  display: flex;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

.plan-reason svg {
  width: 18px;
  height: 18px;
  color: var(--accent-text);
  margin-top: 1px;
}

.plan-title {
  font-size: 22px;
  letter-spacing: -0.01em;
}

.plan-meta {
  font-size: 14px;
  color: var(--muted);
  margin: 4px 0 12px;
}

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

.plan-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.plan-sets {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
}

.bottombar-split {
  display: flex;
  gap: 10px;
}

.bottombar-split .btn {
  flex: 1;
}

/* Zona del músculo debajo del nombre del ejercicio (editor de rutina). */
.ex-name small {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Reps distintas por serie (editor de rutina) ---------- */

.targets {
  flex-wrap: wrap;
}

.rps {
  flex-basis: 100%; /* fila propia, debajo de "Series" */
  min-width: 0;
}

.rps-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.rps-input {
  width: 46px;
  min-height: 40px;
  padding: 0;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  border-color: transparent;
}

.rps-input:focus {
  border-color: var(--accent);
}

.rps-sep {
  color: var(--muted);
  font-weight: 600;
}

.rps-toggle {
  min-height: 40px;
  margin: -6px 0 6px 52px;
  font-size: 15px;
  color: var(--accent-text);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 4px;
}

/* ---------- Aviso de backup ---------- */

.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 8px 4px 8px 14px;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  font-size: 14px;
  color: var(--muted);
}

.notice-text {
  flex: 1;
  min-width: 0;
}

.notice-btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
}

.notice-close {
  width: 36px;
  height: 36px;
  color: var(--muted);
}

.notice-close svg {
  width: 18px;
  height: 18px;
}

/* ---------- Última vez + sugerencia de progresión ---------- */

.last-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.last-row .last-btn {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

.up-btn {
  flex-shrink: 0;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--go) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--go) 40%, transparent);
  color: var(--go);
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.up-btn:active {
  background: color-mix(in srgb, var(--go) 24%, transparent);
}

/* ---------- Récords ---------- */

.hero-pr {
  margin-top: 10px !important;
  color: var(--text) !important;
  font-weight: 700;
}

.pill-pr {
  background: color-mix(in srgb, var(--go) 16%, transparent);
  color: var(--text);
}

/* ---------- Entrenamiento pasado ---------- */

.hint-left {
  text-align: left;
  padding: 0 0 12px;
  font-size: 14px;
}

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

.remove-btn svg {
  stroke-width: 2.2;
  width: 18px;
  height: 18px;
}

.content > .segmented {
  margin: 4px 0 14px;
}

/* ---------- Menú y nota de cada ejercicio (entrenar) ---------- */

.ex-head {
  position: relative;
  padding-right: 40px;
}

.ex-menu {
  position: absolute;
  top: -8px;
  right: -10px;
  color: var(--muted);
}

.ex-note {
  display: block;
  margin-top: 4px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  font-size: 14px;
  color: var(--text);
}

.ex-note-page {
  margin: 4px 0 14px;
}

/* Campo de texto dentro de la hoja (notas) */
.sheet-body input {
  margin-bottom: 4px;
}

/* ---------- Ajustar la rutina generada ---------- */

.plan-remove {
  width: 36px;
  height: 36px;
  margin-right: -8px;
  color: var(--muted);
}

.plan-remove svg {
  width: 16px;
  height: 16px;
}

.plan-remove:disabled {
  opacity: 0.25;
}

.plan-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 4px;
}

/* Hojas con muchas opciones (ej. ejercicios de un grupo): que se puedan desplazar. */
.sheet-body {
  max-height: 85dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Avisos largos: que bajen de renglón en vez de salirse de la pantalla. */
.toast {
  white-space: normal;
  width: max-content;
  max-width: calc(100% - 32px);
  text-align: center;
  border-radius: 18px;
}
