:root {
  --bg: #0b1220;
  --bg-soft: #0f172a;
  --panel: #131d33;
  --panel-2: #182440;
  --line: #24334f;
  --text: #e8eefb;
  --muted: #93a6c7;
  --accent: #38bdf8;
  --prep: #f59e0b;
  --work: #10b981;
  --rest: #ef4444;
  --danger: #dc2626;
  --phase: var(--prep);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.75);
  color-scheme: dark;
}

body[data-phase='prep'] { --phase: var(--prep); }
body[data-phase='work'] { --phase: var(--work); }
body[data-phase='rest'] { --phase: var(--rest); }
body[data-phase='done'] { --phase: var(--accent); }

/* ───────────────────────── Paletas de color ───────────────────────── */

/* Neon Verde (por defecto, definida en :root) */

/* Cyber Blue */
html[data-palette='blue'] {
  --bg: #050a18;
  --bg-soft: #081226;
  --panel: #0b1a33;
  --panel-2: #102444;
  --line: #1c3a63;
  --text: #e6f3ff;
  --muted: #8fb3dd;
  --accent: #22d3ee;
  --prep: #fbbf24;
  --work: #00a8ff;
  --rest: #ff2d78;
}

/* Neon Pink */
html[data-palette='pink'] {
  --bg: #150a1c;
  --bg-soft: #1d0d27;
  --panel: #261232;
  --panel-2: #331a44;
  --line: #4b2763;
  --text: #fdeaf9;
  --muted: #c9a3d9;
  --accent: #ff2ec4;
  --prep: #ffb703;
  --work: #ff2ec4;
  --rest: #8b5cf6;
}

* { box-sizing: border-box; }

/* El atributo hidden siempre gana a cualquier display de clase. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(1100px 520px at 50% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%),
    var(--bg);
  transition: background 0.3s ease, color 0.3s ease;
}

body.drawer-locked { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 700; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.95rem; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; line-height: 1.45; }

/* ───────────────────────── Menú flotante + drawer ───────────────────────── */
.menu-fab {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 12px;
  z-index: 45;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(19, 29, 51, 0.82);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
}
.menu-fab:active { transform: scale(0.95); }

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 8, 16, 0.62);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.drawer-overlay.visible { opacity: 1; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 70;
  width: min(82vw, 330px);
  padding: calc(16px + env(safe-area-inset-top, 0px)) 18px calc(16px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border-right: 1px solid var(--line);
  box-shadow: 20px 0 50px -20px rgba(0, 0, 0, 0.85);
  transform: translateX(-105%);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.drawer.open { transform: none; }

.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: conic-gradient(var(--prep) 0 33%, var(--work) 33% 66%, var(--rest) 66% 100%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08) inset;
}
.brand-name { font-weight: 800; }

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  font-size: 0.95rem;
  cursor: pointer;
}

.drawer-nav { display: grid; gap: 6px; margin-top: 6px; }
.drawer-nav button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  padding: 14px 12px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  min-height: 52px;
}
.drawer-nav button.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.drawer-nav .nav-icon { font-size: 1.15rem; width: 24px; text-align: center; }

.drawer-hint { margin-top: 4px; font-size: 0.74rem; color: var(--muted); }

.drawer-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ───────────────────────── Layout ───────────────────────── */
.app-main { max-width: 680px; margin: 0 auto; padding: 14px 14px 8px; }
.view { animation: fade-in 0.22s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin: calc(4px + env(safe-area-inset-top, 0px)) 2px 14px;
  padding-left: 54px;
  text-align: right;
}

.row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ───────────────────────── Entrenar ───────────────────────── */
#view-train { padding-top: calc(2px + env(safe-area-inset-top, 0px)); }

.empty-prompt {
  position: relative;
  min-height: 74vh;
  display: grid;
  place-items: center;
  padding: 24px 14px;
  background:
    radial-gradient(circle at 18% 18%, color-mix(in srgb, var(--accent) 24%, transparent), transparent 55%),
    radial-gradient(circle at 82% 26%, color-mix(in srgb, var(--work) 20%, transparent), transparent 55%),
    radial-gradient(circle at 50% 92%, color-mix(in srgb, var(--prep) 18%, transparent), transparent 60%);
  border-radius: 20px;
  overflow: hidden;
}
.empty-prompt::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('icons/logo-figure.svg') center / 52% no-repeat;
  opacity: 0.1;
  pointer-events: none;
}
.empty-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
  padding: 32px 24px;
  border-radius: 26px;
  border: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  background: color-mix(in srgb, var(--panel) 74%, transparent);
  box-shadow:
    0 0 28px color-mix(in srgb, var(--accent) 40%, transparent),
    0 0 70px color-mix(in srgb, var(--accent) 14%, transparent) inset;
  backdrop-filter: blur(6px);
  max-width: 380px;
}
.empty-prompt h2 {
  font-size: clamp(1.9rem, 8.5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
}
.empty-menu-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 1.12rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 6px;
  min-height: 44px;
}
.empty-install { margin-top: 2px; }

.timer-card {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid color-mix(in srgb, var(--phase) 45%, var(--line));
  background:
    radial-gradient(120% 90% at 50% -20%, color-mix(in srgb, var(--phase) 26%, transparent), transparent 62%),
    linear-gradient(180deg, var(--panel), var(--bg-soft));
  padding: 18px 16px 16px;
  transition: border-color 0.35s ease, background 0.35s ease;
  box-shadow: var(--shadow);
}

.exercise-title {
  font-size: clamp(2.15rem, 10vw, 3.7rem);
  font-weight: 800;
  line-height: 1.08;
  margin-bottom: 8px;
  padding: 0 84px 0 46px;
  text-align: center;
  overflow-wrap: anywhere;
}
/* Título de una sola línea (p. ej. "¡Completado!") */
.exercise-title.compact {
  white-space: nowrap;
  font-size: clamp(1.5rem, 7.5vw, 2.6rem);
  padding: 0 10px;
}

.time-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

/* Reloj, banner de ejercicio y contador de repeticiones comparten el mismo hueco */
.time-stack { display: grid; min-width: 0; flex: 1 1 200px; }
.time-stack > * {
  grid-area: 1 / 1;
  align-self: center;
  justify-self: center;
  min-width: 0;
  max-width: 100%;
}

/* Banner del ejercicio: ocupa el lugar del reloj con efecto de ticketing */
.time-banner {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}
.time-banner .banner-track {
  display: inline-block;
  will-change: transform;
  animation: ticker 7s linear infinite;
}
/* Textos cortos (p. ej. "Serie 2 de 3"): centrados, sin desplazamiento y a un
   tamaño que quepa completo en una línea. */
.time-banner.static { text-align: center; }
.time-banner.static .banner-track { animation: none; }
.time-banner.static .banner-name { font-size: clamp(2rem, 8.5vw, 3.4rem); }
.banner-name {
  font-size: clamp(3.2rem, 20vw, 8.5rem);
  font-weight: 800;
  line-height: 1;
  color: var(--prep);
  text-shadow: 0 10px 40px color-mix(in srgb, var(--prep) 45%, transparent);
}
@keyframes ticker {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

.rep-display {
  font-size: clamp(4rem, 24vw, 10rem);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 10px 40px color-mix(in srgb, var(--phase) 35%, transparent);
}
.rep-display.pop { animation: rep-pop 0.5s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes rep-pop {
  0% { transform: scale(0.55); opacity: 0.15; }
  55% { transform: scale(1.14); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.time {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: clamp(3.2rem, 20vw, 8.5rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
  padding: 2px 0 0;
  overflow: hidden;
  text-shadow: 0 10px 40px color-mix(in srgb, var(--phase) 35%, transparent);
}
.time.pulse { animation: time-pulse 1s ease-in-out infinite; }
@keyframes time-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* Reloj naranja durante la cuenta regresiva de inicio */
body[data-phase='prep'] .time { color: var(--prep); }

/* Respiración pausada durante el descanso */
.time.breathing { animation: breathe 4.2s ease-in-out infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.07); opacity: 1; }
}

/* Verde en el tramo final (últimos 10 s o últimas 3 repeticiones) */
.time.final,
.rep-display.final {
  color: color-mix(in srgb, var(--work) 86%, white);
}

.progress-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0 8px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--phase);
  border-radius: 999px;
  transition: width 0.12s linear, background 0.35s ease;
  /* --p (0..1) lo actualiza la app: el brillo crece con el avance. */
  box-shadow:
    0 0 calc(3px + var(--p, 0) * 36px) color-mix(in srgb, var(--phase) 95%, transparent),
    0 0 calc(1px + var(--p, 0) * 14px) #fff;
}

/* Pastillas de información de la rutina (bajo la barra de avance) */
.pills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 6px;
  margin-top: 2px;
}
.pill {
  font-size: clamp(0.82rem, 3.4vw, 1.05rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 8px 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  text-align: center;
  min-width: 0;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
/* Dos puntos más grandes que las de tiempo para leerse desde lejos */
.pills .pill {
  font-size: clamp(0.98rem, 4.1vw, 1.32rem);
  padding: 10px 6px;
}

/* Total y tiempo restante: 3× el tamaño anterior, apilados junto al contador */
.time-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 0 auto;
}
.time-summary .pill {
  padding: 8px 12px;
  font-size: clamp(2.16rem, 8.4vw, 2.82rem);
  white-space: nowrap;
}
.pill-accent {
  color: color-mix(in srgb, var(--accent) 85%, var(--text));
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.pill-prep {
  color: color-mix(in srgb, var(--prep) 88%, var(--text));
  border-color: color-mix(in srgb, var(--prep) 45%, var(--line));
  background: color-mix(in srgb, var(--prep) 12%, transparent);
}
.pill-work {
  color: color-mix(in srgb, var(--work) 88%, var(--text));
  border-color: color-mix(in srgb, var(--work) 45%, var(--line));
  background: color-mix(in srgb, var(--work) 12%, transparent);
}
.pill-phase {
  color: var(--text);
  border-color: color-mix(in srgb, var(--phase) 55%, var(--line));
  background: color-mix(in srgb, var(--phase) 16%, transparent);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.controls .btn-primary { grid-column: 1 / -1; }
.controls .btn-reset { grid-column: 1 / -1; }
.controls .btn:not(.btn-primary) {
  font-size: clamp(0.78rem, 3.4vw, 0.95rem);
  padding: 10px 8px;
  white-space: nowrap;
}

/* ───────────────────────── Botones ───────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease;
  min-height: 48px;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--phase); border-color: transparent; color: #08101f; }
.btn-primary:active { filter: brightness(0.94); }
.btn-secondary { background: var(--panel-2); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 65%, var(--line)); color: #fca5a5; }
.btn-sm { padding: 8px 12px; min-height: 38px; font-size: 0.82rem; }
.btn-xl { font-size: 1.18rem; padding: 16px; }

.version-chip {
  appearance: none;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  padding: 6px 10px;
  min-height: 32px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.version-chip.update { color: #6ee7b7; border-color: rgba(16, 185, 129, 0.6); }
.version-chip.checking { color: var(--accent); border-color: rgba(56, 189, 248, 0.55); }
.version-chip.error { color: #fcd34d; border-color: rgba(245, 158, 11, 0.55); }

/* ───────────────────────── Listas ───────────────────────── */
.card-list { display: grid; gap: 10px; margin-bottom: 14px; }
.item-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  min-width: 0;
}
.item-card.active { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.item-card .info { min-width: 0; flex: 1 1 auto; }
.item-card .info strong { display: block; font-size: 0.98rem; }
.item-card .info span { font-size: 0.76rem; color: var(--muted); display: block; margin-top: 3px; line-height: 1.4; }
.item-card .info .use-btn { margin-top: 10px; }
.item-card .actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; max-width: 55%; min-width: 0; }
.use-btn.active { background: var(--work); border-color: transparent; color: #08101f; }

/* ───────────────────────── Formularios ───────────────────────── */
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; font-size: 0.84rem; color: var(--muted); }
.field > span { font-weight: 600; }
.field input[type='text'],
.field input[type='number'],
.field select,
input[type='text'],
textarea {
  width: 100%;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  min-height: 46px;
}
textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field select:focus, input:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.range input[type='range'] { width: 100%; accent-color: var(--accent); min-height: 32px; }
output { color: var(--text); font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; min-width: 0; }
.grid-2 > *, .item-grid > *, .item-edit > *, .form > * { min-width: 0; }
.field input, .field select, .field textarea { max-width: 100%; min-width: 0; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 0.86rem; color: var(--text); line-height: 1.4; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin-top: 1px; }

.segment-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
}
.segment-control button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px;
  border-radius: 9px;
  cursor: pointer;
  min-height: 44px;
}
.segment-control button.active { background: var(--panel-2); color: var(--text); box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.5); }

/* ───────────────────────── Selector de paleta ───────────────────────── */
.palette-control { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.palette-control button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 12px 6px;
  border-radius: 14px;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 84px;
}
.palette-control button.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent) inset;
}
.palette-control .swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: 0 0 12px -2px rgba(0, 0, 0, 0.6);
}
.palette-control .swatch-green { background: conic-gradient(#f59e0b 0 33%, #10b981 33% 66%, #ef4444 66% 100%); }
.palette-control .swatch-blue { background: conic-gradient(#fbbf24 0 33%, #00a8ff 33% 66%, #ff2d78 66% 100%); }
.palette-control .swatch-pink { background: conic-gradient(#ffb703 0 33%, #ff2ec4 33% 66%, #8b5cf6 66% 100%); }

.subhead { margin-top: 6px; color: var(--text); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

details.card { padding: 0; overflow: hidden; }
details.card > summary {
  cursor: pointer;
  padding: 15px 16px;
  font-weight: 700;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
details.card > summary::after { content: '▾'; color: var(--muted); }
details.card[open] > summary::after { content: '▴'; }
details.card > .form { padding: 0 16px 16px; }

.info-list, .capability-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.84rem; }
.info-list li, .capability-list li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; }
.capability-list .ok { color: #6ee7b7; }
.capability-list .no { color: #fca5a5; }

/* ───────────────────────── Editor de rutina ───────────────────────── */
.routine-items { display: grid; gap: 12px; }
.item-edit {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--bg-soft);
  display: grid;
  gap: 10px;
}
.item-edit .item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-edit .item-head strong { font-size: 0.9rem; }
.item-edit .item-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 0;
  flex: 1 1 auto;
  min-width: 0;
}
.item-edit .item-chevron { color: var(--muted); font-size: 0.78rem; width: 14px; flex-shrink: 0; }
.item-edit.collapsed .item-body { display: none; }
.item-edit .item-actions { display: flex; gap: 4px; flex-shrink: 0; }
.item-edit .item-actions .icon-btn { width: 38px; height: 38px; border-radius: 10px; }
.item-edit .drag-handle { cursor: grab; touch-action: none; font-size: 1.05rem; color: var(--muted); }
.item-edit.dragging {
  opacity: 0.7;
  border-color: color-mix(in srgb, var(--accent) 70%, var(--line));
  box-shadow: 0 10px 26px -12px rgba(0, 0, 0, 0.8);
}
body.dragging { user-select: none; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 10px; }
.add-item-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.add-item-row .btn { flex: 1 1 auto; }

/* ───────────────────────── Cuenta ───────────────────────── */
.session-line { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }
.google-slot { display: flex; justify-content: center; margin: 12px 0 4px; min-height: 44px; }
.account-divider { text-align: center; margin: 10px 0 4px; }
.share-list { display: grid; gap: 8px; margin: 10px 0; }
.share-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--bg-soft);
}
.share-item strong { font-size: 0.9rem; display: block; }
.share-item span { display: block; margin-top: 2px; }

/* ───────────────────────── Notices ───────────────────────── */
.notices { display: grid; gap: 10px; }
.notice {
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--panel);
  padding: 12px 14px;
}
.notice.warning { border-left-color: var(--prep); }
.notice strong { display: block; margin-bottom: 3px; font-size: 0.88rem; }
.notice p { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }

/* ───────────────────────── Filtros por deporte y deportes ───────────────────────── */
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 10px 2px 2px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
}
.chip.active {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 60%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.sport-icon { font-size: 1.5rem; line-height: 1; margin-right: 4px; }

/* ───────────────────────── Buscadores y selector de ejercicios ───────────────────────── */
.search-card { padding: 10px; margin-bottom: 12px; }
.search-card input[type='search'] {
  width: 100%;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  min-height: 46px;
}
.picker-list {
  display: grid;
  gap: 6px;
  max-height: min(46vh, 340px);
  overflow-y: auto;
  padding-right: 2px;
}
.picker-item {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  min-height: 48px;
}
.picker-item strong { display: block; font-size: 0.95rem; }
.picker-item span { display: block; font-size: 0.74rem; color: var(--muted); margin-top: 2px; }
.picker-item.selected {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--bg-soft));
}
.picker-empty { color: var(--muted); font-size: 0.85rem; padding: 10px 4px; }

/* ───────────────────────── Modal ───────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 8, 16, 0.72);
  backdrop-filter: blur(4px);
}
.modal-card {
  width: min(100%, 460px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

/* ───────────────────────── Patrocinador (Sponsor) ───────────────────────── */
.timer-sponsor-badge,
.empty-sponsor-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  line-height: 0;
  text-decoration: none;
}
.timer-sponsor-badge:hover,
.empty-sponsor-badge:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.timer-sponsor-badge:active,
.empty-sponsor-badge:active {
  transform: scale(0.96);
}
.sponsor-logo-16-9 {
  display: block;
  width: auto;
  height: 28px;
  max-width: 80px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
}

/* ───────────────────────── Splash de cortesía (Patrocinio) ───────────────────────── */
.splash {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 520px at 50% 18%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
    var(--bg);
  transition: opacity 0.55s ease;
}
.splash.hidden { opacity: 0; pointer-events: none; }
.splash-inner { display: grid; justify-items: center; gap: 22px; text-align: center; padding: 28px; }
.splash-logo {
  width: 156px;
  height: 156px;
  object-fit: contain;
  background: #ffffff;
  padding: 16px;
  border-radius: 26px;
  box-shadow: 0 16px 48px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.splash-courtesy {
  font-size: 0.84rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.splash-phrase {
  font-size: 1.12rem;
  font-weight: 700;
  max-width: 340px;
  line-height: 1.5;
}
.splash-url {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 5px;
  padding: 6px 10px;
  transition: color 0.2s ease;
}
.splash-url:hover {
  color: #ffffff;
}

.legal-text { line-height: 1.6; }
.legal-text strong { color: var(--text); }

/* ───────────────────────── Toast ───────────────────────── */
.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  z-index: 200;
  max-width: min(88vw, 400px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.noscript {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: var(--bg); padding: 30px; text-align: center; color: var(--text);
}

@media (min-width: 560px) {
  .controls {
    grid-template-columns: 1fr 1fr 1.35fr 1fr 1fr;
    align-items: stretch;
  }
  .controls #btn-prev-ex { order: 1; }
  .controls #btn-prev-series { order: 2; }
  .controls #btn-start { order: 3; grid-column: auto; }
  .controls #btn-next-series { order: 4; }
  .controls #btn-next-ex { order: 5; }
  .controls #btn-reset { order: 6; grid-column: 1 / -1; }
}

/* ───────────────────────── Horizontal: entrenamiento a pantalla completa ───────────────────────── */
@media (orientation: landscape) and (max-height: 560px) {
  body { padding-bottom: 0; overflow: hidden; }
  .menu-fab { display: none; }
  .app-main { padding: 0; max-width: none; height: 100vh; height: 100dvh; }
  #view-train { height: 100%; }
  .timer-card {
    height: 100%;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto auto;
    grid-template-areas:
      'title'
      'timerow'
      'progress'
      'pills'
      'controls';
    align-items: center;
    gap: 3px;
    padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .timer-sponsor-badge {
    top: 8px;
    right: 12px;
    padding: 3px 6px;
    border-radius: 8px;
  }
  .sponsor-logo-16-9 {
    height: 22px;
    max-width: 62px;
  }
  .exercise-title {
    grid-area: title;
    margin: 0;
    padding: 0 76px 0 56px;
    align-self: center;
    font-size: clamp(1.5rem, 6.4vh, 2.6rem);
  }
  .time-row { grid-area: timerow; width: 100%; }
  .time {
    padding: 0;
    font-size: clamp(4rem, 44vh, 13rem);
  }
  .rep-display { font-size: clamp(4rem, 42vh, 13rem); }
  .banner-name { font-size: clamp(4rem, 42vh, 13rem); }
  .time-banner.static .banner-name { font-size: clamp(2rem, 12vh, 4rem); }
  .progress-track { grid-area: progress; margin: 0; height: 10px; }
  .pills {
    grid-area: pills;
    align-self: center;
    margin: 0;
    gap: 6px;
    width: 100%;
  }
  .pill {
    border-radius: 10px;
    padding: 6px 10px;
  }
  .pills .pill { font-size: clamp(0.85rem, 3.2vh, 1.15rem); }
  .time-summary { margin-left: auto; }
  .time-summary .pill { font-size: clamp(2.04rem, 6.6vh, 2.58rem); }
  .controls {
    grid-area: controls;
    margin: 0;
    grid-template-columns: 1fr 1fr 1.3fr 1fr 1fr 1.15fr;
    gap: 8px;
    align-self: center;
    justify-content: center;
    width: 100%;
  }
  .controls #btn-prev-ex { order: 1; }
  .controls #btn-prev-series { order: 2; }
  .controls #btn-start { order: 3; grid-column: auto; }
  .controls #btn-next-series { order: 4; }
  .controls #btn-next-ex { order: 5; }
  .controls #btn-reset { order: 6; grid-column: auto; }
  .controls .btn {
    min-height: clamp(36px, 9vh, 54px);
    padding: 8px 12px;
    font-size: clamp(0.74rem, 2.2vh, 0.9rem);
  }
}
