/* css/training-redesign.css
   Redesign primitives (ported from prototype tokens.css). Additive + reversible:
   remove the <link> to fully revert. Reuses css/theme.css variables. */

:root {
  --rl-train: #22c55e;        --rl-train-dark: #16a34a;
  --rl-preset: #7c3aed;       --rl-preset-soft: #a78bfa;
  --rl-warm: #f59e0b;         --rl-work: var(--gradient-app-start, #667eea);  --rl-cool: #11998e;
}
.dark-mode {
  --rl-train: #34d399;        --rl-train-dark: #22c55e;
  --rl-preset: #a78bfa;       --rl-preset-soft: #c4b5fd;
  --rl-warm: #fbbf24;         --rl-work: var(--gradient-app-start, #8093f0); --rl-cool: #2dd4bf;
}

/* Value tiles — scannable read-state */
.rl-vrow { display: flex; flex-wrap: wrap; gap: 7px; }
.rl-vtile { display: flex; flex-direction: column; gap: 1px; min-width: 52px; padding: 6px 11px; border-radius: 10px;
  background: var(--bg-surface-raised); border: 1.5px solid var(--border-light); }
.rl-vtile .vl { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.rl-vtile .vv { font-size: 14px; font-weight: 800; color: var(--text-heading); font-variant-numeric: tabular-nums; }
.rl-vtile--target { background: color-mix(in srgb, var(--rl-warm) 11%, transparent); border-color: color-mix(in srgb, var(--rl-warm) 30%, transparent); }
.rl-vtile--target .vv { color: var(--warning, #d97706); }

/* Grouped value-fields — edit-state */
.rl-fgset { display: flex; flex-wrap: wrap; gap: 16px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-surface-raised); border: 1.5px solid var(--border-light); }
.rl-fg { display: inline-flex; flex-direction: column; gap: 4px; }
.rl-fg > span { font-size: 9.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.rl-fg-inputs { display: inline-flex; align-items: center; gap: 5px; }
.rl-fg input, .rl-fg select { width: 56px; text-align: center; padding: 8px 6px; border: 1.5px solid var(--border-medium);
  border-radius: 9px; background: var(--bg-surface); color: var(--text-heading); font: inherit; font-size: 13px; font-weight: 700; outline: none; }
.rl-fg input.w { width: 70px; }
.rl-fg input:focus, .rl-fg select:focus { border-color: var(--gradient-app-start); }
.rl-fg .sep { color: var(--text-hint); font-weight: 800; }
.rl-reps-max-wrap { display: inline-flex; }
.rl-reps-max-wrap.hidden,
.rl-reps-range-only.hidden { display: none !important; }

/* Technique pills + add / advanced toggle */
.rl-tadd { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 99px; font-size: 11px; font-weight: 800;
  border: 1.5px dashed color-mix(in srgb, var(--rl-preset) 40%, var(--border-medium)); background: transparent; color: var(--rl-preset); cursor: pointer; font-family: inherit; }
.rl-tadd:hover { background: color-mix(in srgb, var(--rl-preset) 9%, transparent); }
.rl-adv-toggle { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; color: var(--text-secondary);
  font: inherit; font-weight: 700; font-size: 11.5px; cursor: pointer; }
.rl-adv-toggle:hover { color: var(--text-heading); }
.rl-adv { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 11px; }
@media (max-width: 600px) { .rl-adv { grid-template-columns: 1fr; } }

/* Chips + segmented control */
.rl-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 99px; border: 1.5px solid var(--border-medium);
  background: var(--bg-surface); color: var(--text-secondary); font-size: 12.5px; font-weight: 700; cursor: pointer; transition: .15s; font-family: inherit; }
.rl-chip:hover { color: var(--text-heading); border-color: var(--border-dark); }
.rl-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ex-color, var(--gradient-app-start)); }
.rl-chip .cnt { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px;
  background: var(--bg-surface-sunken); color: var(--text-muted); font-size: 11px; font-weight: 800; }
.rl-chip.is-active { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--rl-train-dark), var(--rl-train)); }
.rl-chip.is-active .cnt { background: rgba(255,255,255,.25); color: #fff; }
.rl-chip.m-active { color: var(--ex-color); border-color: color-mix(in srgb, var(--ex-color) 50%, transparent); background: color-mix(in srgb, var(--ex-color) 12%, transparent); }
.rl-seg { display: inline-flex; background: var(--bg-surface-raised); border: 1.5px solid var(--border-light); border-radius: 99px; padding: 3px; gap: 2px; }
.rl-seg button { border: none; background: transparent; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); padding: 6px 15px; border-radius: 99px; cursor: pointer; }
.rl-seg button.is-active { background: var(--bg-surface); color: var(--text-heading); box-shadow: 0 2px 8px var(--shadow-sm, rgba(0,0,0,.08)); }

/* Command-center stat tiles */
.rl-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 12px; }
.rl-stat { position: relative; padding: 15px 16px; border: 1.5px solid var(--border-medium); border-radius: 16px; background: var(--bg-surface); overflow: hidden; }
.rl-stat::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--acc, var(--gradient-app-start)); }
.rl-stat-v { font-size: 25px; font-weight: 800; line-height: 1.05; color: var(--text-heading); font-variant-numeric: tabular-nums; }
.rl-stat-l { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); margin-top: 3px; }
@media (max-width: 720px) { .rl-stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* Library grid + card (Esercizi) */
.rl-libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(252px, 1fr)); grid-auto-rows: 1fr; gap: 14px; align-items: stretch; }
.rl-exlib { text-align: left; cursor: pointer; border: 1.5px solid var(--border-light); border-left: 4px solid var(--ex-color, var(--border-medium)); border-radius: 16px;
  background: var(--bg-surface); padding: 15px 16px; transition: .16s; font-family: inherit; display: flex; flex-direction: column; gap: 11px; width: 100%; height: 100%; }
.rl-exlib:hover { box-shadow: 0 8px 26px var(--shadow-md, rgba(0,0,0,.12)); transform: translateY(-2px); }
.rl-new-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 132px;
  border: 1.5px dashed var(--border-dark); border-radius: 16px; background: transparent; color: var(--text-secondary); cursor: pointer; font: inherit; font-weight: 700; }
.rl-new-tile:hover { border-color: var(--rl-train); color: var(--rl-train-dark); }

/* Preset Allenamento */
.rl-preset-eyebrow { margin-bottom: 14px; color: var(--rl-preset); font-size: 12px; font-weight: 900; letter-spacing: 0; text-transform: uppercase; }
.rl-preset-page-title { margin-bottom: 10px; font-size: 30px; line-height: 1.08; font-weight: 900; letter-spacing: 0; }
#presets-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 20px; align-items: start; }
#presets-list .rl-preset-card { margin: 0; border: none; border-radius: 18px; background: var(--bg-surface); box-shadow: 0 1px 0 rgba(15,23,42,.04), 0 18px 38px rgba(15,23,42,.08); overflow: hidden; }
.rl-preset-head { min-height: 67px; padding: 16px 20px; border: none; background: linear-gradient(135deg, var(--rl-preset), #9b5cf6); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.rl-preset-titlewrap { min-width: 0; display: flex; align-items: center; gap: 12px; }
.rl-preset-title { min-width: 0; color: #fff; font-size: 18px; font-weight: 900; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rl-preset-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 11px; border-radius: 99px; background: rgba(255,255,255,.22); color: #fff; font-size: 11.5px; font-weight: 800; white-space: nowrap; }
.rl-preset-tools { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.rl-preset-count { color: rgba(255,255,255,.94); font-size: 13.5px; font-weight: 900; white-space: nowrap; }
.rl-preset-action { width: 34px; height: 34px; padding: 0; border: none; border-radius: 10px; background: rgba(255,255,255,.19); display: inline-grid; place-items: center; cursor: pointer; transition: background-color .15s, transform .15s; }
.rl-preset-action:hover { background: rgba(255,255,255,.3); transform: translateY(-1px); }
.rl-preset-action .ui-icon { width: 15px; height: 15px; filter: brightness(0) invert(1); opacity: .95; }
.rl-preset-body { padding: 18px 20px 20px; background: var(--bg-surface); }
.rl-preset-desc { margin: 0 0 17px; color: var(--text-secondary); font-size: 14px; line-height: 1.45; }
#presets-list .preset-summary-list { display: flex; flex-direction: column; gap: 0; }
#presets-list .preset-summary-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border-light); font-size: 14px; }
#presets-list .preset-summary-row:first-child { padding-top: 0; }
#presets-list .preset-summary-row:last-child { padding-bottom: 0; border-bottom: none; }
.rl-preset-row-main { min-width: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
#presets-list .preset-summary-name { color: var(--text-heading); font-weight: 900; }
.rl-preset-tech { color: var(--rl-preset); font-size: 11px; font-weight: 900; white-space: nowrap; }
#presets-list .preset-summary-params { color: #7f8a9f; font-size: 13.5px; font-weight: 900; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rl-preset-empty { color: var(--text-muted); font-size: 13px; }

.dark-mode #presets-list .rl-preset-card { box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 18px 38px rgba(0,0,0,.22); }
.dark-mode #presets-list .preset-summary-params { color: var(--text-muted); }

@media (max-width: 720px) {
  .rl-preset-page-title { font-size: 26px; }
  #presets-list { grid-template-columns: 1fr; gap: 14px; }
  .rl-preset-head { align-items: flex-start; flex-direction: column; }
  .rl-preset-tools { width: 100%; justify-content: flex-end; }
  #presets-list .preset-summary-row { grid-template-columns: 1fr; gap: 4px; }
  #presets-list .preset-summary-params { white-space: normal; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Esercizi — dialoghi "Nuovo" e "Modifica" (mockup 1b)
   Sostituisce in css/training-redesign.css il blocco "Center modal (Esercizi
   edit)" — dalla riga `.rl-scrim {` fino alla chiusura del
   `@media (max-width: 640px)` che segue `#exercise-drawer`.

   Tutto è scoped su #new-exercise-form e #exercise-drawer: le regole base
   .tmgmt-* restano intatte e continuano a servire il modale dei preset e le
   card caricate. Nessuna modifica a js/training/gestione-esercizi.js.

   Due tecniche, per non toccare il renderer:
   1. la testata del drawer riceve il colore del gruppo come `style="background:#ef4444"`.
      È background-color: il CSS gli sovrappone una velatura di superficie via
      background-image (!important, perché la shorthand inline dichiara anche
      background-image:none) e le lascia scoperti solo 5px in basso → striscia piena.
   2. le righe volume ripetono le tre etichette: restano visibili sulla prima riga
      (che diventa l'intestazione di colonna) e si spengono sulle successive.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Scrim ─────────────────────────────────────────────────────────────── */
.rl-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.42); backdrop-filter: blur(2px); z-index: 90;
  opacity: 0; pointer-events: none; transition: .2s; }
.rl-scrim.open { opacity: 1; pointer-events: auto; }
body:has(#exercise-scrim.open) { overflow: hidden; }

/* Utilizzi del catalogo: il delete deve portare direttamente a scheda e cliente. */
.exercise-usage-warning {
  position: fixed;
  inset: 0;
  z-index: 500000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--modal-backdrop, rgba(15, 23, 42, .58));
}
.exercise-usage-warning__panel {
  width: min(560px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-light);
  border-radius: 18px;
  background: var(--bg-surface);
  box-shadow: 0 28px 80px var(--shadow-lg, rgba(15, 23, 42, .3));
}
.exercise-usage-warning__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  color: #fff;
  background: linear-gradient(135deg, #b45309, #dc2626);
}
.exercise-usage-warning__eyebrow {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .78;
}
.exercise-usage-warning__header h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}
.exercise-usage-warning__close {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.34);
  border-radius: 10px;
  color: #fff;
  background: rgba(255,255,255,.12);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.exercise-usage-warning__body {
  min-height: 0;
  overflow-y: auto;
  padding: 22px 24px 8px;
}
.exercise-usage-warning__body p {
  margin: 0 0 16px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.exercise-usage-warning__list {
  display: grid;
  gap: 8px;
}
.exercise-usage-warning__item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  text-align: left;
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.exercise-usage-warning__item:hover {
  border-color: var(--brand);
  background: var(--brand-bg-light);
  transform: translateY(-1px);
}
.exercise-usage-warning__item-main { font-weight: 750; }
.exercise-usage-warning__item-client { color: var(--text-secondary); font-size: 12px; }
.exercise-usage-warning__item-arrow {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--brand);
  font-size: 20px;
  font-weight: 800;
}
.exercise-usage-warning__footer {
  display: flex;
  justify-content: flex-end;
  padding: 14px 24px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
}

/* ── Conchiglia comune ai due dialoghi ─────────────────────────────────── */
#new-exercise-form,
.rl-drawer {
  position: fixed;
  top: 50%;
  left: 50%;
  height: auto;
  max-height: calc(100dvh - 40px);
  margin: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface-card-light);
  border: 1px solid var(--border-medium);
  border-radius: 16px;
  box-shadow: 0 26px 70px var(--shadow-lg, rgba(0,0,0,.24));
}
.dark-mode #new-exercise-form,
.dark-mode .rl-drawer { background: var(--bg-surface-sunken); }

#new-exercise-form { width: min(640px, calc(100vw - 32px)); transform: translate(-50%, -50%); }
.rl-drawer { width: min(740px, calc(100vw - 32px)); transform: translate(-50%, -48%) scale(.96);
  opacity: 0; pointer-events: none;
  transition: transform .24s cubic-bezier(.4,0,.2,1), opacity .18s ease; }
.rl-drawer.open { transform: translate(-50%, -50%) scale(1); opacity: 1; pointer-events: auto; }

/* ── Testata: due righe (kicker + titolo) + chiusura a destra ──────────── */
#new-exercise-form .tmgmt-modal-header,
#exercise-drawer .tmgmt-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 16px;
  align-items: center;
  padding: 15px 22px;
  color: var(--text-heading);
}
#new-exercise-form .tmgmt-modal-header::before,
#exercise-drawer .tmgmt-card-kicker {
  grid-column: 1; grid-row: 1;
  min-width: 0;
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: color-mix(in srgb, var(--text-heading) 62%, transparent);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#new-exercise-form .tmgmt-modal-header::before { content: "Nuovo · personale"; }

#new-exercise-form .tmgmt-modal-header > span,
#exercise-drawer .tmgmt-card-title {
  grid-column: 1; grid-row: 2;
  min-width: 0;
  font-size: 19px; font-weight: 800; line-height: 1.2; letter-spacing: -.01em;
  color: var(--text-heading);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* l'icona nel titolo non serve: il kicker dice già di che dialogo si tratta */
#new-exercise-form .tmgmt-modal-header > span > .ui-icon { display: none; }

#new-exercise-form .tmgmt-close-btn,
#exercise-drawer .tmgmt-card-close {
  grid-column: 2; grid-row: 1 / span 2;
  justify-self: end;
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border: 1.5px solid color-mix(in srgb, var(--text-heading) 16%, transparent);
  border-radius: 11px;
  background: color-mix(in srgb, var(--bg-surface) 70%, transparent);
  color: var(--text-heading);
  font-size: 15px; line-height: 1;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease;
}
#new-exercise-form .tmgmt-close-btn:hover,
#exercise-drawer .tmgmt-card-close:hover {
  background: var(--bg-surface);
  border-color: color-mix(in srgb, var(--text-heading) 30%, transparent);
  color: var(--text-heading);
}
#new-exercise-form .tmgmt-close-btn .ui-icon,
#exercise-drawer .tmgmt-card-close .ui-icon { width: 15px; height: 15px; }

/* Nuovo esercizio: tinta brand + striscia piena */
#new-exercise-form .tmgmt-modal-header {
  background: var(--brand-bg);
  border-bottom: 5px solid var(--brand);
}

/* Modifica: velatura sul colore del gruppo muscolare (inline background-color),
   scoperti gli ultimi 5px → striscia piena. !important obbligatorio: la
   shorthand inline dichiara anche background-image: none. */
#exercise-drawer .tmgmt-card-header {
  background-image: linear-gradient(
      color-mix(in srgb, var(--bg-surface) 86%, transparent),
      color-mix(in srgb, var(--bg-surface) 86%, transparent)) !important;
  background-repeat: no-repeat !important;
  background-position: 0 0 !important;
  background-size: 100% calc(100% - 5px) !important;
  border-bottom: none;
}
.dark-mode #exercise-drawer .tmgmt-card-header {
  background-image: linear-gradient(
      color-mix(in srgb, var(--bg-surface-sunken) 80%, transparent),
      color-mix(in srgb, var(--bg-surface-sunken) 80%, transparent)) !important;
}

/* ── Corpo scrollabile ─────────────────────────────────────────────────── */
#exercise-drawer .tmgmt-card-body {
  padding: 20px;
  min-height: 0;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#exercise-drawer .tmgmt-card-body::-webkit-scrollbar { width: 0; height: 0; display: none; }

#new-exercise-form .tmgmt-form-grid {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#new-exercise-form .tmgmt-form-grid::-webkit-scrollbar { width: 0; height: 0; display: none; }

#exercise-drawer .tmgmt-readonly-notice {
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
}

/* ── Pannello "Dati esercizio" ─────────────────────────────────────────── */
#new-exercise-form .tmgmt-form-grid:not(.ex-volume-muscle-row),
#exercise-drawer .tmgmt-form-grid:not(.ex-volume-muscle-row) {
  gap: 15px;
  padding: 16px 18px 18px;
  border: 1.5px solid var(--border-light);

  background: var(--bg-surface);
}

#exercise-drawer .tmgmt-form-grid:not(.ex-volume-muscle-row) { margin: 0;border-radius: 14px;}

#new-exercise-form .tmgmt-form-grid:not(.ex-volume-muscle-row)::before,
#exercise-drawer .tmgmt-form-grid:not(.ex-volume-muscle-row)::before {
  content: "Dati esercizio";
  grid-column: 1 / -1;
  margin-bottom: -1px;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted);
}

/* Nome a piena larghezza e un filo più grande: è il campo che si compila sempre */
#new-exercise-form .tmgmt-form-group:has(> #new-ex-nome) { grid-column: 1 / -1; }
#new-exercise-form .tmgmt-form-group:has(> #new-ex-nome) .tmgmt-input { height: 46px; font-size: 16px; }
/* Tipo esercizio: riga propria, controllo non stiracchiato — in entrambi i dialoghi,
   qualunque sia la posizione del campo nella griglia */
#new-exercise-form .tmgmt-form-group:has(> #new-ex-tipo),
#exercise-drawer .tmgmt-form-group:has(> [data-field="tipo_esercizio"]) { grid-column: 1 / -1; }
#new-exercise-form .tmgmt-form-group:has(> #new-ex-tipo) .tmgmt-input,
#exercise-drawer .tmgmt-form-group:has(> [data-field="tipo_esercizio"]) .tmgmt-input { max-width: 320px; }

/* La modalita cardio appartiene solo al tipo esercizio `cardio`.
   Il controllo JS aggiorna `hidden`; questi selettori tengono il vincolo anche
   quando il valore del select cambia senza passare dall'handler inline. */
#new-exercise-form .tmgmt-form-group[hidden],
#exercise-drawer .tmgmt-form-group[hidden] { display: none !important; }

#new-exercise-form:not(:has(#new-ex-tipo option:checked[value="cardio"])) #new-ex-cardio-wrap,
#exercise-drawer:not(:has([data-field="tipo_esercizio"] option:checked[value="cardio"])) [id^="cardio-modalita-wrap-"] {
  display: none !important;
}

/* ── Campi: 15px in controlli da 42px, etichette in tondo ──────────────── */
#new-exercise-form .tmgmt-form-group > label,
#exercise-drawer .tmgmt-form-group > label {
  font-size: 12px; font-weight: 700;
  text-transform: none; letter-spacing: normal;
  color: var(--text-secondary);
}
#new-exercise-form .tmgmt-form-group,
#exercise-drawer .tmgmt-form-group { gap: 6px; min-width: 0; }

#new-exercise-form .tmgmt-input,
#exercise-drawer .tmgmt-input {
  height: 42px;
  padding: 0 13px;
  border: 1.5px solid var(--border-medium);
  border-radius: 10px;
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.dark-mode #new-exercise-form .tmgmt-input,
.dark-mode #exercise-drawer .tmgmt-input { background: var(--bg-input); }

#new-exercise-form .tmgmt-input::placeholder,
#exercise-drawer .tmgmt-input::placeholder { color: var(--text-placeholder); }

#new-exercise-form .tmgmt-input:focus,
#exercise-drawer .tmgmt-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-bg-hover);
}
#new-exercise-form select.tmgmt-input,
#exercise-drawer select.tmgmt-input { padding-right: 10px; cursor: pointer; }

/* Dropdown confinati ai modal/drawer di Gestione Esercizi */
#new-exercise-form select,
#exercise-drawer select,
.preset-editor-workspace select {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-input);
}

.dark-mode #new-exercise-form select,
.dark-mode #exercise-drawer select,
.dark-mode .preset-editor-workspace select {
  color-scheme: dark;
}

.dark-mode #new-exercise-form select option,
.dark-mode #exercise-drawer select option,
.dark-mode .preset-editor-workspace select option {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
}

/* ── Pannello "Volume muscolare" ───────────────────────────────────────── */
#exercise-drawer .tmgmt-card-body > .tmgmt-form-group--full {
  margin-top: 16px !important;
  padding: 16px 18px 18px;
  border: 1.5px solid var(--border-light);
  border-radius: 14px;
  background: var(--bg-surface);
  gap: 12px;
}
#exercise-drawer .tmgmt-volume-label {
  justify-content: space-between;
  gap: 12px;
}
#exercise-drawer .tmgmt-volume-label > label {
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted);
}
#exercise-drawer .tmgmt-volume-label .progress-info-popover {
  right: 0;
  left: auto;
  max-width: calc(100vw - 64px);
}

/* Righe: colonne fisse, etichette di colonna scritte una volta sola */
#exercise-drawer .ex-volume-muscle-row {
  grid-template-columns: minmax(0, 1.7fr) 92px minmax(0, 1fr) 40px !important;
  gap: 10px !important;
  align-items: center !important;
  margin-bottom: 0 !important;
  padding: 7px 0 !important;
  border: none;
  border-top: 1px solid var(--border-light);
  background: none;
  border-radius: 0;
}
#exercise-drawer .ex-volume-muscle-row:first-of-type { border-top: none; padding-top: 0 !important; }
#exercise-drawer .ex-volume-muscle-row:not(:first-of-type) label { display: none; }
#exercise-drawer .ex-volume-muscle-row:first-of-type > .tmgmt-form-group > label {
  font-size: 11.5px; font-weight: 700; color: var(--text-muted);
}
#exercise-drawer .ex-volume-muscle-row .ex-volume-factor {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-heading);
}
/* rimozione riga: quadrato 40×40, glifo al posto della "x" minuscola */
#exercise-drawer .ex-volume-muscle-row > .btn {
  align-self: end;
  width: 40px; height: 40px !important;
  padding: 0 !important;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  font-size: 0;
}
#exercise-drawer .ex-volume-muscle-row > .btn::before {
  content: "✕";
  font-size: 14px; font-weight: 700; line-height: 1;
  margin-top: 10px;
}
#exercise-drawer .ex-volume-muscle-row > .btn:hover {
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  color: var(--danger);
}
#exercise-drawer .ex-volume-muscle-list:empty::before {
  content: "Nessun muscolo assegnato: il volume di questo esercizio non entra nei conteggi.";
  display: block;
  padding: 2px 0 4px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
/* aggiungi riga: tratteggio a piena larghezza, 44px di bersaglio */
#exercise-drawer .ex-volume-muscle-list + .btn {
  width: 100%;
  height: 44px;
  margin-top: 12px;
  border: 1.5px dashed var(--border-dark);
  border-radius: 11px;
  background: transparent;
  color: var(--text-secondary);
}
#exercise-drawer .ex-volume-muscle-list + .btn:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-bg-light);
}

/* ── Piede ancorato ────────────────────────────────────────────────────── */
#new-exercise-form .tmgmt-form-actions,
#exercise-drawer .tmgmt-card-footer {
  flex-shrink: 0;
  gap: 10px;
  padding: 15px 22px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-surface);
}
/* Elimina a sinistra, Salva a destra (con o senza il bottone di eliminazione) */
#exercise-drawer .tmgmt-card-footer { justify-content: space-between; align-items: center; }
#new-exercise-form .tmgmt-form-actions .btn,
#exercise-drawer .tmgmt-card-footer .btn { height: 42px; }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #new-exercise-form { max-height: calc(100dvh - 24px); width: min(100vw - 16px, 640px); border-radius: 14px; }
  .rl-drawer { max-height: calc(100dvh - 24px); width: min(100vw - 16px, 640px); border-radius: 14px; }
  #exercise-drawer .tmgmt-card-body { padding: 16px; }
  #new-exercise-form .tmgmt-form-grid:not(.ex-volume-muscle-row) { margin: 16px; }
}
@media (max-width: 560px) {
  /* colonne troppo strette: si torna a un campo per riga, etichetta compresa */
  #exercise-drawer .ex-volume-muscle-row {
    grid-template-columns: minmax(0, 1fr) 44px !important;
    row-gap: 10px !important;
    padding: 12px 0 !important;
    border-top: 1px solid var(--border-light);
  }
  #exercise-drawer .ex-volume-muscle-row:first-of-type { padding-top: 0 !important; }
  #exercise-drawer .ex-volume-muscle-row > .tmgmt-form-group { grid-column: 1 / 2; }
  #exercise-drawer .ex-volume-muscle-row label { display: flex !important; font-size: 12px; }
  #exercise-drawer .ex-volume-muscle-row > .btn { grid-column: 2 / 3; grid-row: 1 / 2; align-self: end; }
}


/* Plan-card volume preview (lista schede) — light at-a-glance days + muscle volume */
.plan-prev { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.plan-prevmeta { display: flex; align-items: center; gap: 9px; font-size: 11.5px; font-weight: 800; color: var(--text-muted); }
.plan-prevmeta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--text-hint); }
.rl-volbar { display: flex; height: 7px; border-radius: 99px; overflow: hidden; background: var(--bg-surface-sunken); max-width: 380px; }
.rl-volbar > span { display: block; height: 100%; }
.rl-vol-legend { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.rl-vol-legend .lg { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 700; color: var(--text-secondary); }
.rl-vol-legend .lg .d { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; }
.rl-vol-legend .lg .n { color: var(--text-muted); font-weight: 800; }
