-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
1302 lines (1232 loc) · 80.1 KB
/
Copy pathapp.js
File metadata and controls
1302 lines (1232 loc) · 80.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// MusculApp - Diego Flores - Premium Fitness Tracker PWA
// ======================================================
const App = (() => {
// ---- SVG ICONS (Lucide-style, strokeWidth 1.5) ----
const ICONS = {
dumbbell: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14.4 14.4L9.6 9.6"/><path d="M18.657 21.485a2 2 0 01-2.829 0l-.707-.707a2 2 0 010-2.829l3.535-3.535a2 2 0 012.829 0l.707.707a2 2 0 010 2.829l-3.535 3.535z"/><path d="M5.343 2.515a2 2 0 012.829 0l.707.707a2 2 0 010 2.829L5.343 9.586a2 2 0 01-2.829 0l-.707-.707a2 2 0 010-2.829l3.536-3.535z"/></svg>',
leg: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 16v-2.38C4 11.5 2.97 10.5 3 8c.03-2.72 1.49-6 4.5-6C9.37 2 10 3.8 10 5.5c0 3.11-2 5.66-2 8.68V16a2 2 0 11-4 0z"/><path d="M20 20v-2.38c0-2.12 1.03-3.12 1-5.62-.03-2.72-1.49-6-4.5-6C14.63 6 14 7.8 14 9.5c0 3.11 2 5.66 2 8.68V20a2 2 0 104 0z"/><path d="M16 17h4"/><path d="M4 13h4"/></svg>',
muscle: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M12.409 13.017A5 5 0 0122 15c0 3.866-4 7-9 7-4.077 0-8.153-.82-10.371-2.462-.426-.316-.631-.832-.62-1.362C2.118 12.723 2.627 2 10 2a3 3 0 013 3 2 2 0 01-2 2c-1.105 0-1.64-.444-2-1"/><path d="M15 14a5 5 0 00-7.584 2"/><path d="M9.964 6.825C8.019 7.977 9.5 13 8 15"/></svg>',
flame: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8.5 14.5A2.5 2.5 0 0011 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 11-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 002.5 2.5z"/></svg>',
zap: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>',
target: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><circle cx="12" cy="12" r="6"/><circle cx="12" cy="12" r="2"/></svg>',
trophy: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9H4.5a2.5 2.5 0 010-5H6"/><path d="M18 9h1.5a2.5 2.5 0 000-5H18"/><path d="M4 22h16"/><path d="M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"/><path d="M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"/><path d="M18 2H6v7a6 6 0 0012 0V2z"/></svg>',
star: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>',
heart: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M20.42 4.58a5.4 5.4 0 00-7.65 0L12 5.36l-.77-.78a5.4 5.4 0 00-7.65 7.65l.77.77L12 20.65l7.65-7.65.77-.77a5.4 5.4 0 000-7.65z"/></svg>',
chevronRight: '<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M9 18l6-6-6-6"/></svg>',
chevronLeft: '<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M15 19l-7-7 7-7"/></svg>',
plus: '<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M12 5v14M5 12h14"/></svg>',
edit: '<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',
trash: '<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2"/></svg>',
copy: '<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/></svg>',
x: '<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M18 6L6 18M6 6l12 12"/></svg>',
check: '<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path d="M5 13l4 4L19 7"/></svg>',
checkCircle: '<svg class="w-6 h-6 check-pop" fill="none" viewBox="0 0 24 24" stroke="#10b981" stroke-width="1.5"><path d="M22 11.08V12a10 10 0 11-5.93-9.14"/><path d="M22 4L12 14.01l-3-3" stroke-width="2"/></svg>',
circle: '<svg class="w-6 h-6" fill="none" viewBox="0 0 24 24" stroke="#52525b" stroke-width="1.5"><circle cx="12" cy="12" r="10"/></svg>',
chart: '<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M3 3v18h18"/><path d="M18.7 8l-5.1 5.2-2.8-2.7L7 14.3"/></svg>',
download: '<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',
upload: '<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>',
clock: '<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>',
arrowUp: '<svg class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path d="M18 15l-6-6-6 6"/></svg>',
arrowDown: '<svg class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>',
user: '<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>',
};
const ROUTINE_ICONS = [
{ key: 'dumbbell', label: 'Pesas' },
{ key: 'leg', label: 'Pierna' },
{ key: 'muscle', label: 'Fuerza' },
{ key: 'flame', label: 'Fuego' },
{ key: 'zap', label: 'Rayo' },
{ key: 'target', label: 'Target' },
{ key: 'trophy', label: 'Trofeo' },
{ key: 'star', label: 'Estrella' },
{ key: 'heart', label: 'Cardio' },
];
// ---- EXERCISE DATABASE ----
// Each entry: { nombre, grupo, video (YouTube ID) }
// Videos from: Harbiz, JEFIT, ScottHermanFitness, Jeff Nippard, Renaissance Periodization
const EXERCISE_DB = [
// PECHO
{ nombre: 'Press Plano con Barra', grupo: 'Pecho', video: 'S7NrsueBHhA' },
{ nombre: 'Press Plano con Mancuernas', grupo: 'Pecho', video: 'VmB1G1K7v94' },
{ nombre: 'Press Inclinado con Barra', grupo: 'Pecho', video: 'SrqOu55lrYU' },
{ nombre: 'Press Inclinado con Mancuernas', grupo: 'Pecho', video: '8iPEnn-ltC8' },
{ nombre: 'Press Inclinado en Barra Smith', grupo: 'Pecho', video: 'gRVjAtPip0Y' },
{ nombre: 'Press Declinado con Barra', grupo: 'Pecho', video: 'LfyQBUKR8SE' },
{ nombre: 'Aperturas con Mancuernas', grupo: 'Pecho', video: 'eozdVDA78K0' },
{ nombre: 'Aperturas en Polea', grupo: 'Pecho', video: 'Iwe6AmxVf7o' },
{ nombre: 'Fondos en Paralelas', grupo: 'Pecho', video: '2z8JmcrW-As' },
{ nombre: 'Crossover en Polea Alta', grupo: 'Pecho', video: 'taI4XduLpTk' },
{ nombre: 'Crossover en Polea Baja', grupo: 'Pecho', video: 'oUEdlT7G0Uc' },
// ESPALDA
{ nombre: 'Dorsalera', grupo: 'Espalda', video: 'CAwf7n6Luuc' },
{ nombre: 'Dominadas', grupo: 'Espalda', video: 'eGo4IYlbE5g' },
{ nombre: 'Dominadas colgado pasivas', grupo: 'Espalda', video: 'bRLuyiF0OMg' },
{ nombre: 'Remo con Barra', grupo: 'Espalda', video: 'FWJR5Ve8bnQ' },
{ nombre: 'Remo con Pecho Apoyado', grupo: 'Espalda', video: 'oKNjFM1bxAs' },
{ nombre: 'Remo Unilateral en Cable Medio', grupo: 'Espalda', video: 'RYPM7ipvQn8' },
{ nombre: 'Remo en Polea Baja', grupo: 'Espalda', video: 'GZbfZ033f74' },
{ nombre: 'Pullover en Polea', grupo: 'Espalda', video: 'geenhiHju-o' },
{ nombre: 'Face Pull', grupo: 'Espalda', video: 'rep-qVOkqgk' },
// HOMBROS
{ nombre: 'Press Militar con Barra', grupo: 'Hombros', video: 'zoN5EH50Dro' },
{ nombre: 'Press Militar con Mancuernas', grupo: 'Hombros', video: 'qEwKCR5JCog' },
{ nombre: 'Vuelos Laterales con Mancuernas', grupo: 'Hombros', video: '3VcKaXpzqRo' },
{ nombre: 'Vuelos Frontales', grupo: 'Hombros', video: 'jk7YrK79ciA' },
{ nombre: 'Pajaros con Mancuernas', grupo: 'Hombros', video: 'ttvfGg9d76c' },
{ nombre: 'Elevaciones Laterales en Polea', grupo: 'Hombros', video: 'XPPfnSEATJA' },
{ nombre: 'Movilidad completa de hombro', grupo: 'Hombros', video: 'v2xy1HsqlKk' },
// BICEPS
{ nombre: 'Curl con Barra', grupo: 'Bíceps', video: 'WnDxMH-adp8' },
{ nombre: 'Curl con Mancuernas', grupo: 'Bíceps', video: 'ykJmrZ5v0Oo' },
{ nombre: 'Curl Martillo', grupo: 'Bíceps', video: 'Xfp9_TCvba0' },
{ nombre: 'Bicep en Cable', grupo: 'Bíceps', video: 'NFzTWp2qpiE' },
{ nombre: 'Bicep con Mancuernas en Banco 45°', grupo: 'Bíceps', video: 'soxrZlIl35U' },
{ nombre: 'Curl en Banco Scott', grupo: 'Bíceps', video: 'YUhSi_sUGmM' },
// TRICEPS
{ nombre: 'Tricep Pushdown', grupo: 'Tríceps', video: '2-LAMcpzODU' },
{ nombre: 'Press Frances con Barra', grupo: 'Tríceps', video: 'd_KZxkY_0cM' },
{ nombre: 'Press Frances con Mancuernas', grupo: 'Tríceps', video: 'ir5PsbniVSc' },
{ nombre: 'Extensión de Tríceps en Polea', grupo: 'Tríceps', video: '3ZTTSka2Niw' },
{ nombre: 'Patada de Tríceps', grupo: 'Tríceps', video: '6SS6K3lAwZ8' },
// PIERNAS - CUÁDRICEPS
{ nombre: 'Sentadilla con Barra', grupo: 'Piernas', video: 'ultWZbUMPL8' },
{ nombre: 'Sentadilla con Barra Smith', grupo: 'Piernas', video: 'gRVjAtPip0Y' },
{ nombre: 'Sentadilla Bulgara con Mancuernas', grupo: 'Piernas', video: 'bbHPPlQeu6Y' },
{ nombre: 'Hack Squat', grupo: 'Piernas', video: '8Gk8snrY8u4' },
{ nombre: 'Prensa de Piernas', grupo: 'Piernas', video: 'IZxyjW7MPJQ' },
{ nombre: 'Prensa Unilateral', grupo: 'Piernas', video: 'd-RBtJKPU_g' },
{ nombre: 'Camilla de Cuadriceps', grupo: 'Piernas', video: 'YyvSfVjQeL0' },
{ nombre: 'Estocadas con Mancuernas', grupo: 'Piernas', video: 'D7KaRcUTQeE' },
// PIERNAS - ISQUIOTIBIALES
{ nombre: 'Camilla de Isquiotibiales', grupo: 'Piernas', video: '1Tq3QdYUuHs' },
{ nombre: 'Camilla de Isquiotibiales 2', grupo: 'Piernas', video: '1Tq3QdYUuHs' },
{ nombre: 'Peso Muerto Rumano', grupo: 'Piernas', video: 'dsbcodMtZ1E' },
{ nombre: 'Peso Muerto Convencional', grupo: 'Piernas', video: 'op9kVnSso6Q' },
{ nombre: 'Hip Thrust', grupo: 'Piernas', video: 'OSOP3JAApGk' },
// PIERNAS - GEMELOS
{ nombre: 'Gemelos en prensa', grupo: 'Piernas', video: 'JbyjNymZOt0' },
{ nombre: 'Gemelos de pie', grupo: 'Piernas', video: 'gwLzBJYoWlI' },
{ nombre: 'Gemelos sentado', grupo: 'Piernas', video: 'JDfWLEipMOc' },
// ZONA MEDIA
{ nombre: 'Crunch en Banco Declinado', grupo: 'Core', video: 'FkeT5dO4GOg' },
{ nombre: 'Anti Rotacional con Barra', grupo: 'Core', video: 'JsTuKeMJeFU' },
{ nombre: 'Ruedita Abdominal', grupo: 'Core', video: 'iaEeVHea3Fc' },
{ nombre: 'Twist Sovietico con Disco', grupo: 'Core', video: 'wkD8rjkodUI' },
{ nombre: 'Plancha', grupo: 'Core', video: 'ASdvN_XEl_c' },
{ nombre: 'Plancha Lateral', grupo: 'Core', video: 'K2VljzCC16g' },
// MOVILIDAD / CALENTAMIENTO
{ nombre: 'Extensiones torácicas con FoamRoller', grupo: 'Movilidad', video: '_KVE3qEytJ4' },
{ nombre: 'Estiramiento Gluteo', grupo: 'Movilidad', video: 'ygmc99i-rss' },
{ nombre: 'Cadera + Isquio Estiramiento', grupo: 'Movilidad', video: '6kdaxLiSLkU' },
{ nombre: 'Estiramiento de la cobra', grupo: 'Movilidad', video: 'JDcdhTuycOI' },
{ nombre: 'Estiramiento caderas 90/90', grupo: 'Movilidad', video: 'Jc9UMQOSA7Y' },
{ nombre: 'Estiramiento de flexor de cadera', grupo: 'Movilidad', video: 'YQmpO9VT2X4' },
];
function getExerciseVideo(nombre) {
const ex = EXERCISE_DB.find(e => e.nombre.toLowerCase() === nombre.toLowerCase());
return ex ? ex.video : null;
}
function getExerciseGroup(nombre) {
const ex = EXERCISE_DB.find(e => e.nombre.toLowerCase() === nombre.toLowerCase());
return ex ? ex.grupo : null;
}
function searchExercises(query) {
if (!query || query.length < 2) return [];
const q = query.toLowerCase();
return EXERCISE_DB.filter(e => e.nombre.toLowerCase().includes(q)).slice(0, 8);
}
// ---- DEFAULT DATA ----
const defaultRoutines = [
{
id: 'r1', nombre: "Full Body", descripcion: "Trabajo de cuerpo completo", icono: "dumbbell",
bloques: [
{ id:'b1', tipo:"Movilidad", series_total:1, ejercicios:[
{nombre:"Extensiones torácicas con FoamRoller",objetivo:'30"',descanso:0},
{nombre:"Estiramiento Gluteo",objetivo:'30"',descanso:0},
{nombre:"Cadera + Isquio Estiramiento",objetivo:'30"',descanso:60}
]},
{ id:'b2', tipo:"Zona Media - Superserie x3", series_total:3, es_superserie:true, ejercicios:[
{nombre:"Crunch en Banco Declinado",objetivo:"15-20 reps",descanso:0},
{nombre:"Anti Rotacional con Barra",objetivo:"10 por lado",descanso:60}
]},
{ id:'b3', tipo:"Tren Inferior", ejercicios:[
{nombre:"Hack Squat",series:3,objetivo:"6-8 reps",descanso:120},
{nombre:"Sentadilla Bulgara con Mancuernas",series:2,objetivo:"8-10 reps",descanso:90}
]},
{ id:'b4', tipo:"Tren Superior", ejercicios:[
{nombre:"Press Plano con Barra",series:3,objetivo:"8-10 reps",descanso:120},
{nombre:"Remo con Pecho Apoyado",series:3,objetivo:"10-12 reps",descanso:90}
]},
{ id:'b5', tipo:"Brazos - Superserie x3", series_total:3, es_superserie:true, ejercicios:[
{nombre:"Tricep Pushdown",objetivo:"12-15 reps",descanso:15},
{nombre:"Bicep en Cable",objetivo:"10-12 reps",descanso:90},
{nombre:"Vuelos Laterales con Mancuernas",objetivo:"12-15 reps",descanso:90}
]}
]
},
{
id: 'r2', nombre: "Pierna 1", descripcion: "Día de pierna completo", icono: "leg",
bloques: [
{ id:'b6', tipo:"Movilidad - Superserie x2", series_total:2, es_superserie:true, ejercicios:[
{nombre:"Estiramiento de la cobra",objetivo:"30s",descanso:0},
{nombre:"Estiramiento caderas 90/90",objetivo:"30s",descanso:0},
{nombre:"Estiramiento de flexor de cadera",objetivo:"20s",descanso:45}
]},
{ id:'b7', tipo:"Zona Media - Superserie x3", series_total:3, es_superserie:true, ejercicios:[
{nombre:"Ruedita Abdominal",objetivo:"10-12 reps",descanso:0},
{nombre:"Twist Sovietico con Disco",objetivo:"10-15 por lado",descanso:60}
]},
{ id:'b8', tipo:"Trabajo Principal", ejercicios:[
{nombre:"Camilla de Isquiotibiales 2",series:3,objetivo:"10-12 reps",descanso:90},
{nombre:"Sentadilla con Barra Smith",series:3,objetivo:"6-8 reps",descanso:120},
{nombre:"Prensa Unilateral",series:3,objetivo:"8-10 reps",descanso:120},
{nombre:"Camilla de Cuadriceps",series:3,objetivo:"10-12 reps",descanso:90},
{nombre:"Gemelos en prensa",series:3,objetivo:"12-15 reps",descanso:90}
]}
]
},
{
id: 'r3', nombre: "Tren Superior 1", descripcion: "Torso completo", icono: "muscle",
bloques: [
{ id:'b9', tipo:"Movilidad - Superserie x2", series_total:2, es_superserie:true, ejercicios:[
{nombre:"Movilidad completa de hombro",objetivo:"10 reps",descanso:0},
{nombre:"Face Pull",objetivo:"12 reps",descanso:0},
{nombre:"Dominadas colgado pasivas",objetivo:"30s",descanso:60}
]},
{ id:'b10', tipo:"Trabajo Principal", ejercicios:[
{nombre:"Press Inclinado en Barra Smith",series:3,objetivo:"8-10 reps",descanso:120},
{nombre:"Dorsalera",series:3,objetivo:"10-12 reps",descanso:120},
{nombre:"Press Plano con Mancuernas",series:3,objetivo:"8-10 reps",descanso:120},
{nombre:"Remo Unilateral en Cable Medio",series:3,objetivo:"10-12 reps",descanso:120}
]},
{ id:'b11', tipo:"Finalizador - Superserie x3", series_total:3, es_superserie:true, ejercicios:[
{nombre:"Press Frances con Mancuernas",objetivo:"10-12 reps",descanso:15},
{nombre:"Bicep con Mancuernas en Banco 45°",objetivo:"10-12 reps",descanso:90}
]},
{ id:'b12', tipo:"Aislado", ejercicios:[
{nombre:"Vuelos Laterales con Mancuernas",series:3,objetivo:"12-15 reps",descanso:90}
]}
]
}
];
// ---- STATE ----
let state = {
screen: 'home',
tab: 'train',
activeRoutine: null,
workoutData: {},
workoutStart: null,
editingRoutine: null,
editingIndex: -1,
};
let timerInterval = null, timerSeconds = 0, chartInstance = null;
let idCounter = Date.now();
const uid = () => 'id_' + (idCounter++);
// ---- STORAGE ----
const HISTORY_KEY = 'musculapp_history';
const SESSIONS_KEY = 'musculapp_sessions';
const ROUTINES_KEY = 'musculapp_routines';
const USER_KEY = 'musculapp_user';
const getHistory = () => JSON.parse(localStorage.getItem(HISTORY_KEY) || '{}');
const saveHistory = (h) => localStorage.setItem(HISTORY_KEY, JSON.stringify(h));
const getSessions = () => JSON.parse(localStorage.getItem(SESSIONS_KEY) || '[]');
const saveSessions = (s) => localStorage.setItem(SESSIONS_KEY, JSON.stringify(s));
function getUserName() { return localStorage.getItem(USER_KEY) || 'Diego Flores'; }
function saveUserName(n) { localStorage.setItem(USER_KEY, n); }
function getRoutines() {
const s = localStorage.getItem(ROUTINES_KEY);
if (s) return JSON.parse(s);
saveRoutines(defaultRoutines);
return JSON.parse(JSON.stringify(defaultRoutines));
}
const saveRoutines = (r) => localStorage.setItem(ROUTINES_KEY, JSON.stringify(r));
function getLastSession(name) {
const r = (getHistory()[name] || []);
return r.length ? r[r.length - 1] : null;
}
function getLatestWeight(exerciseName) {
const records = getHistory()[exerciseName] || [];
if (!records.length) return null;
const last = records[records.length - 1];
return last.series.length ? last.series[last.series.length - 1].kg : null;
}
function getSessionCount() {
const sessions = getSessions();
if (sessions.length > 0) return sessions.length;
const h = getHistory();
const dates = new Set();
for (const records of Object.values(h)) {
records.forEach(r => dates.add(r.fecha ? r.fecha.slice(0, 10) : ''));
}
dates.delete('');
return dates.size;
}
function saveWorkoutToHistory() {
const h = getHistory(), date = new Date().toISOString();
const sessionId = 'ses_' + Date.now();
const sessionExercises = [];
for (const [name, sets] of Object.entries(state.workoutData)) {
const done = sets.filter(s => s.done);
if (!done.length) continue;
if (!h[name]) h[name] = [];
h[name].push({ fecha: date, rutina: state.activeRoutine.nombre, sessionId, series: done.map(s => ({ kg: s.kg, reps: s.reps })) });
if (h[name].length > 30) h[name] = h[name].slice(-30);
sessionExercises.push({ nombre: name, series: done.map(s => ({ kg: s.kg, reps: s.reps })) });
}
saveHistory(h);
if (sessionExercises.length) {
const sessions = getSessions();
sessions.push({
id: sessionId,
fecha: date,
rutina: state.activeRoutine.nombre,
duracion: state.workoutStart ? Math.floor((Date.now() - state.workoutStart) / 1000) : 0,
ejercicios: sessionExercises
});
if (sessions.length > 100) sessions.splice(0, sessions.length - 100);
saveSessions(sessions);
}
}
// ---- HELPERS ----
const $ = id => document.getElementById(id);
const html = (el, c) => { el.innerHTML = c; };
const esc = s => s.replace(/'/g, "\\'").replace(/"/g, '"');
const escId = s => s.replace(/[^a-zA-Z0-9]/g, '_');
function epley1RM(kg, reps) { if (reps <= 0 || kg <= 0) return 0; if (reps === 1) return kg; return Math.round(kg * (1 + reps / 30) * 10) / 10; }
function totalVolume(sets) { return sets.reduce((s, x) => s + (x.kg || 0) * (x.reps || 0), 0); }
function formatTime(secs) { return `${String(Math.floor(secs / 60)).padStart(2, '0')}:${String(secs % 60).padStart(2, '0')}`; }
function getSeriesCount(b, e) { return (b.es_superserie && b.series_total) ? b.series_total : (e.series || b.series_total || 1); }
function getIcon(key) { return ICONS[key] || ICONS.dumbbell; }
// ---- TIMER ----
let timerEndTime = 0;
function startTimer(seconds) {
stopTimer();
timerEndTime = Date.now() + seconds * 1000;
timerSeconds = seconds;
$('timer-banner').classList.remove('hidden');
$('timer-text').textContent = formatTime(timerSeconds);
timerInterval = setInterval(tickTimer, 250);
}
function tickTimer() {
const remaining = Math.ceil((timerEndTime - Date.now()) / 1000);
if (remaining <= 0) {
stopTimer();
if (navigator.vibrate) navigator.vibrate([200, 100, 200]);
return;
}
if (remaining !== timerSeconds) {
timerSeconds = remaining;
const el = $('timer-text');
if (el) el.textContent = formatTime(timerSeconds);
}
}
function stopTimer() { if (timerInterval) clearInterval(timerInterval); timerInterval = null; timerEndTime = 0; const b = $('timer-banner'); if (b) b.classList.add('hidden'); }
function skipTimer() { stopTimer(); }
document.addEventListener('visibilitychange', () => { if (!document.hidden && timerEndTime > 0) tickTimer(); });
// ---- TAB BAR ----
function updateTabBar(activeTab, visible = true) {
const bar = $('tab-bar');
if (!visible) { bar.classList.add('hidden'); return; }
bar.classList.remove('hidden');
['train', 'evolution', 'profile'].forEach(t => {
const el = $(`tab-${t}`);
if (t === activeTab) { el.className = el.className.replace('tab-inactive', '').replace('tab-active', '') + ' tab-active'; }
else { el.className = el.className.replace('tab-active', '').replace('tab-inactive', '') + ' tab-inactive'; }
});
}
function switchTab(tab) {
state.tab = tab;
if (tab === 'train') renderHome();
else if (tab === 'evolution') renderEvolution();
else if (tab === 'profile') renderProfile();
}
// ===========================================================
// HOME (Entrenar)
// ===========================================================
function renderHome() {
state.screen = 'home'; state.activeRoutine = null; state.workoutData = {}; state.editingRoutine = null; stopTimer();
updateTabBar('train');
const rutinas = getRoutines();
const h = getHistory();
const sessCount = getSessionCount();
html($('app'), `
<div class="fade-in pb-24" style="padding-top: calc(var(--safe-top, 0px) + 20px);">
<div class="px-6 pb-6">
<p class="text-zinc-500 text-xs font-medium tracking-widest uppercase">Bienvenido</p>
<h1 class="text-[26px] font-bold tracking-tight mt-1">${getUserName()}</h1>
${sessCount > 0 ? `<p class="text-zinc-600 text-xs font-light mt-2">${sessCount} sesiones · ${Object.keys(h).length} ejercicios trackeados</p>` : ''}
</div>
<div class="px-6">
<div class="flex items-center justify-between mb-4">
<h2 class="text-zinc-500 text-[11px] font-semibold tracking-[.15em] uppercase">Mis Rutinas</h2>
<button onclick="App.newRoutine()" class="flex items-center gap-1.5 text-emerald-400 text-xs font-medium min-h-[44px] active:opacity-70 transition-opacity">
${ICONS.plus} Nueva
</button>
</div>
<div class="space-y-3">
${rutinas.map((r, i) => `
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl card-depth overflow-hidden fade-in stagger-${Math.min(i + 1, 3)}">
<button onclick="App.showRoutineDetail(${i})" class="w-full p-5 text-left active:bg-white/[.02] transition-colors">
<div class="flex items-center gap-4">
<div class="w-11 h-11 rounded-xl bg-zinc-800/80 flex items-center justify-center text-zinc-400 flex-shrink-0">
${getIcon(r.icono)}
</div>
<div class="flex-1 min-w-0">
<h3 class="font-semibold text-[15px] tracking-tight">${r.nombre}</h3>
<p class="text-zinc-500 text-xs font-light mt-0.5">${r.descripcion}</p>
<p class="text-zinc-600 text-[11px] font-light mt-1.5">${r.bloques.length} bloques · ${r.bloques.reduce((s, b) => s + b.ejercicios.length, 0)} ejercicios</p>
</div>
<div class="text-zinc-700">${ICONS.chevronRight}</div>
</div>
</button>
<div class="flex items-center justify-end gap-1 px-4 pb-3 -mt-1">
<button onclick="App.editRoutine(${i})" class="p-2.5 rounded-lg text-zinc-600 active:bg-zinc-800 transition min-h-[44px] min-w-[44px] flex items-center justify-center" aria-label="Editar">${ICONS.edit}</button>
<button onclick="App.duplicateRoutine(${i})" class="p-2.5 rounded-lg text-zinc-600 active:bg-zinc-800 transition min-h-[44px] min-w-[44px] flex items-center justify-center" aria-label="Duplicar">${ICONS.copy}</button>
<button onclick="App.deleteRoutineConfirm(${i})" class="p-2.5 rounded-lg text-zinc-600 active:bg-zinc-800 transition min-h-[44px] min-w-[44px] flex items-center justify-center" aria-label="Eliminar">${ICONS.trash}</button>
</div>
</div>
`).join('')}
</div>
</div>
${getRecentExercises().length > 0 ? `
<div class="px-6 mt-8">
<h2 class="text-zinc-500 text-[11px] font-semibold tracking-[.15em] uppercase mb-3">Reciente</h2>
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl card-depth divide-y divide-zinc-800/40">
${getRecentExercises().map(ex => `
<button onclick="App.showHistoryModal('${esc(ex.nombre)}')" class="w-full px-4 py-3.5 flex items-center justify-between text-left active:bg-white/[.02] transition first:rounded-t-2xl last:rounded-b-2xl">
<div>
<p class="text-sm font-medium">${ex.nombre}</p>
<p class="text-zinc-600 text-[11px] font-light">${new Date(ex.fecha).toLocaleDateString('es-AR', { day:'numeric', month:'short' })} · ${ex.series.length} series</p>
</div>
<div class="text-zinc-700">${ICONS.chevronRight}</div>
</button>
`).join('')}
</div>
</div>
` : ''}
</div>
`);
}
function getRecentExercises() {
const h = getHistory(), all = [];
for (const [name, records] of Object.entries(h)) {
if (records.length) all.push({ nombre: name, ...records[records.length - 1] });
}
return all.sort((a, b) => new Date(b.fecha) - new Date(a.fecha)).slice(0, 5);
}
// ===========================================================
// EVOLUTION (Progreso)
// ===========================================================
function renderEvolution() {
state.screen = 'evolution'; updateTabBar('evolution');
const h = getHistory();
const exercises = Object.entries(h).filter(([, r]) => r.length > 0).map(([name, records]) => {
const last = records[records.length - 1];
let best1RM = 0;
records.forEach(r => r.series.forEach(s => { const rm = epley1RM(s.kg, s.reps); if (rm > best1RM) best1RM = rm; }));
const maxKg = Math.max(...records.flatMap(r => r.series.map(s => s.kg)));
const prevMax = records.length >= 2 ? Math.max(...records.slice(0, -1).flatMap(r => r.series.map(s => s.kg))) : maxKg;
const trend = maxKg > prevMax ? 'up' : maxKg < prevMax ? 'down' : 'same';
const grupo = getExerciseGroup(name);
return { name, records, last, best1RM, maxKg, trend, grupo, sessions: records.length };
});
const totalVol = exercises.reduce((s, e) => s + e.records.reduce((ss, r) => ss + totalVolume(r.series), 0), 0);
const sessCount = getSessionCount();
// Weekly activity: last 7 days
const today = new Date(); today.setHours(0, 0, 0, 0);
const weekDays = [];
for (let i = 6; i >= 0; i--) {
const d = new Date(today); d.setDate(d.getDate() - i);
const dateStr = d.toISOString().slice(0, 10);
const dayExercises = [];
for (const [name, records] of Object.entries(h)) {
records.forEach(r => { if (r.fecha && r.fecha.slice(0, 10) === dateStr) dayExercises.push(name); });
}
weekDays.push({ date: d, dateStr, count: dayExercises.length, names: [...new Set(dayExercises)] });
}
const dayLabels = ['D', 'L', 'M', 'X', 'J', 'V', 'S'];
// Group exercises by muscle group
const groups = {};
exercises.forEach(ex => {
const g = ex.grupo || 'Otro';
if (!groups[g]) groups[g] = [];
groups[g].push(ex);
});
// Sort groups by most exercises, sort exercises within by best1RM
const sortedGroups = Object.entries(groups)
.sort((a, b) => b[1].length - a[1].length)
.map(([g, exs]) => [g, exs.sort((a, b) => b.best1RM - a.best1RM)]);
// Personal records (top 5 by maxKg)
const prs = [...exercises].sort((a, b) => b.maxKg - a.maxKg).slice(0, 5);
html($('app'), `
<div class="fade-in pb-24" style="padding-top: calc(var(--safe-top, 0px) + 20px);">
<div class="px-6 pb-4">
<h1 class="text-[26px] font-bold tracking-tight">Progreso</h1>
<p class="text-zinc-500 text-xs font-light mt-1">Tu evolución en el tiempo</p>
</div>
${exercises.length === 0 ? `
<div class="px-6 py-20 text-center">
<div class="text-zinc-700 mb-4 flex justify-center">${ICONS.chart.replace('w-4 h-4', 'w-12 h-12')}</div>
<p class="text-zinc-500 text-sm">Aún no hay datos de entrenamiento</p>
<p class="text-zinc-600 text-xs mt-1">Completá tu primera sesión para ver tu progreso</p>
</div>
` : `
<!-- Weekly Activity -->
<div class="px-6 mb-6">
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl card-depth p-4">
<div class="flex items-center justify-between mb-3">
<h2 class="text-zinc-500 text-[11px] font-semibold tracking-[.15em] uppercase">Esta semana</h2>
<span class="text-zinc-600 text-[11px] font-light">${weekDays.filter(d => d.count > 0).length}/7 días</span>
</div>
<div class="grid grid-cols-7 gap-2">
${weekDays.map(d => {
const isToday = d.dateStr === today.toISOString().slice(0, 10);
const active = d.count > 0;
return `<div class="flex flex-col items-center gap-1.5">
<div class="w-9 h-9 rounded-xl flex items-center justify-center text-xs font-semibold transition
${active ? 'bg-emerald-500/20 text-emerald-400 border border-emerald-500/30' : isToday ? 'bg-zinc-800/60 text-zinc-400 border border-zinc-700/50' : 'bg-zinc-800/30 text-zinc-700'}">
${d.count > 0 ? d.count : ''}
</div>
<span class="text-[9px] ${isToday ? 'text-zinc-300 font-semibold' : 'text-zinc-600'}">${dayLabels[d.date.getDay()]}</span>
</div>`;
}).join('')}
</div>
</div>
</div>
<!-- KPIs -->
<div class="px-6 grid grid-cols-3 gap-3 mb-6">
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl p-4 text-center card-depth">
<p class="text-xl font-bold tracking-tight text-emerald-400">${sessCount}</p>
<p class="text-zinc-600 text-[10px] font-medium uppercase tracking-wider mt-1">Sesiones</p>
</div>
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl p-4 text-center card-depth">
<p class="text-xl font-bold tracking-tight">${exercises.length}</p>
<p class="text-zinc-600 text-[10px] font-medium uppercase tracking-wider mt-1">Ejercicios</p>
</div>
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl p-4 text-center card-depth">
<p class="text-xl font-bold tracking-tight">${totalVol > 9999 ? (totalVol/1000).toFixed(1) + 'k' : totalVol}</p>
<p class="text-zinc-600 text-[10px] font-medium uppercase tracking-wider mt-1">Vol. total</p>
</div>
</div>
<!-- Personal Records -->
${prs.length > 0 ? `
<div class="px-6 mb-6">
<h2 class="text-zinc-500 text-[11px] font-semibold tracking-[.15em] uppercase mb-3">Records Personales</h2>
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl card-depth overflow-hidden divide-y divide-zinc-800/30">
${prs.map((ex, i) => `
<button onclick="App.showHistoryModal('${esc(ex.name)}')" class="w-full px-4 py-3 flex items-center gap-3 text-left active:bg-white/[.02] transition">
<span class="text-zinc-700 text-xs font-bold w-5 text-center">${i + 1}</span>
<div class="flex-1 min-w-0">
<p class="text-[13px] font-medium truncate">${ex.name}</p>
<p class="text-zinc-600 text-[10px] font-light mt-0.5">max ${ex.maxKg}kg · ${ex.sessions} ${ex.sessions === 1 ? 'vez' : 'veces'}</p>
</div>
<div class="flex items-center gap-2 flex-shrink-0">
<span class="text-emerald-400 text-sm font-bold tabular-nums">${ex.maxKg}<span class="text-[10px] font-normal text-zinc-500 ml-0.5">kg</span></span>
</div>
</button>
`).join('')}
</div>
</div>` : ''}
<!-- By Muscle Group -->
<div class="px-6">
<h2 class="text-zinc-500 text-[11px] font-semibold tracking-[.15em] uppercase mb-3">Por grupo muscular</h2>
<div class="space-y-3">
${sortedGroups.map(([grupo, exs]) => `
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl card-depth overflow-hidden">
<div class="px-4 py-3 border-b border-zinc-800/30 flex items-center justify-between">
<h3 class="text-[13px] font-semibold text-zinc-300">${grupo}</h3>
<span class="text-zinc-600 text-[10px]">${exs.length} ejercicio${exs.length > 1 ? 's' : ''}</span>
</div>
<div class="divide-y divide-zinc-800/20">
${exs.map(ex => `
<button onclick="App.showHistoryModal('${esc(ex.name)}')" class="w-full px-4 py-3 flex items-center justify-between text-left active:bg-white/[.02] transition">
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2">
<p class="text-[13px] font-medium truncate">${ex.name}</p>
${ex.trend === 'up' ? '<span class="text-emerald-400 flex-shrink-0">' + ICONS.arrowUp + '</span>' : ex.trend === 'down' ? '<span class="text-red-400/60 flex-shrink-0">' + ICONS.arrowDown + '</span>' : ''}
</div>
<p class="text-zinc-600 text-[10px] font-light mt-0.5">Último: ${new Date(ex.last.fecha).toLocaleDateString('es-AR', { day:'numeric', month:'short' })} · ${ex.last.series.map(s => s.kg + '×' + s.reps).join(', ')}</p>
</div>
<div class="text-zinc-700 ml-2">${ICONS.chevronRight}</div>
</button>
`).join('')}
</div>
</div>
`).join('')}
</div>
</div>
`}
</div>
`);
}
// ===========================================================
// PROFILE (Perfil)
// ===========================================================
function renderProfile() {
state.screen = 'profile'; updateTabBar('profile');
const h = getHistory();
const totalSets = Object.values(h).reduce((s, a) => s + a.reduce((ss, r) => ss + r.series.length, 0), 0);
const totalSessions = getSessionCount();
html($('app'), `
<div class="fade-in pb-40" style="padding-top: calc(var(--safe-top, 0px) + 20px);">
<div class="px-6 pb-6 text-center">
<div class="w-20 h-20 rounded-full bg-zinc-800/80 border border-zinc-700/50 flex items-center justify-center mx-auto mb-4 text-zinc-400">
${ICONS.user.replace('w-5 h-5', 'w-8 h-8')}
</div>
<h1 class="text-xl font-bold tracking-tight">${getUserName()}</h1>
<p class="text-zinc-500 text-xs font-light mt-1">Fitness Tracker Personal</p>
<button onclick="App.editProfileName()" class="mt-3 text-emerald-400/70 text-xs font-medium active:text-emerald-400 transition min-h-[44px] inline-flex items-center gap-1">
${ICONS.edit} Editar nombre
</button>
</div>
<div class="px-6 grid grid-cols-2 gap-3 mb-6">
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl p-4 text-center card-depth">
<p class="text-2xl font-bold">${totalSessions}</p>
<p class="text-zinc-600 text-[10px] font-medium uppercase tracking-wider mt-1">Sesiones</p>
</div>
<div class="bg-zinc-900/40 border border-zinc-800/60 rounded-2xl p-4 text-center card-depth">
<p class="text-2xl font-bold">${totalSets}</p>
<p class="text-zinc-600 text-[10px] font-medium uppercase tracking-wider mt-1">Series totales</p>
</div>
</div>
<div class="px-6 space-y-2">
<h2 class="text-zinc-500 text-[11px] font-semibold tracking-[.15em] uppercase mb-3">Datos</h2>
<button onclick="App.showExportModal()" class="w-full bg-zinc-900/40 border border-zinc-800/60 rounded-xl card-depth px-4 py-4 text-left active:bg-white/[.02] transition flex items-center gap-4">
<div class="text-zinc-400">${ICONS.download}</div>
<div>
<p class="text-sm font-medium">Exportar Datos</p>
<p class="text-zinc-600 text-[11px] font-light">Descargar backup JSON completo</p>
</div>
</button>
<button onclick="App.importData()" class="w-full bg-zinc-900/40 border border-zinc-800/60 rounded-xl card-depth px-4 py-4 text-left active:bg-white/[.02] transition flex items-center gap-4">
<div class="text-zinc-400">${ICONS.upload}</div>
<div>
<p class="text-sm font-medium">Importar Datos</p>
<p class="text-zinc-600 text-[11px] font-light">Restaurar desde archivo JSON</p>
</div>
</button>
</div>
<div class="px-6 mt-10 mb-6 text-center">
<p class="text-zinc-600 text-[10px] font-light">© ${new Date().getFullYear()} Diego Flores. Todos los derechos reservados.</p>
<a href="mailto:dfv1663@gmail.com" class="text-zinc-500 text-[10px] font-light hover:text-emerald-400 transition">dfv1663@gmail.com</a>
</div>
</div>
`);
}
// ===========================================================
// EDITOR (Create / Edit Routine)
// ===========================================================
function newRoutine() {
state.editingIndex = -1;
state.editingRoutine = { id: uid(), nombre: '', descripcion: '', icono: 'dumbbell', bloques: [] };
state.screen = 'editor'; renderEditor();
}
function editRoutine(i) {
state.editingIndex = i;
state.editingRoutine = JSON.parse(JSON.stringify(getRoutines()[i]));
state.editingRoutine.bloques.forEach(b => { if (!b.id) b.id = uid(); });
state.screen = 'editor'; renderEditor();
}
function duplicateRoutine(i) {
const r = getRoutines(), c = JSON.parse(JSON.stringify(r[i]));
c.id = uid(); c.nombre += ' (copia)'; c.bloques.forEach(b => { b.id = uid(); });
r.push(c); saveRoutines(r); renderHome();
}
function deleteRoutineConfirm(i) {
showConfirmModal(`Eliminar "${getRoutines()[i].nombre}"`, 'El historial se mantiene.', () => { const r = getRoutines(); r.splice(i, 1); saveRoutines(r); renderHome(); }, null, 'Eliminar');
}
function renderEditor() {
const r = state.editingRoutine, isNew = state.editingIndex === -1;
updateTabBar('train', false);
html($('app'), `
<div class="fade-in" style="padding-top: calc(var(--safe-top, 0px) + 8px);">
<div class="px-4 flex items-center justify-between sticky top-0 bg-zinc-950/90 backdrop-blur-xl z-30 py-3 border-b border-zinc-800/30">
<button onclick="App.cancelEditor()" class="w-10 h-10 rounded-xl flex items-center justify-center active:bg-zinc-800 transition min-h-[44px] min-w-[44px] text-zinc-400">${ICONS.chevronLeft}</button>
<h1 class="font-semibold text-base tracking-tight">${isNew ? 'Nueva Rutina' : 'Editar Rutina'}</h1>
<button onclick="App.saveEditor()" class="text-emerald-400 font-semibold text-sm min-h-[44px] px-2 active:opacity-70 transition-opacity">Guardar</button>
</div>
<div class="px-5 py-6 space-y-6 pb-32">
<!-- Info -->
<div class="flex gap-4 items-start">
<button onclick="App.toggleIconPicker()" id="icon-btn" class="w-14 h-14 rounded-2xl bg-zinc-900/60 border border-zinc-800/60 card-depth flex items-center justify-center text-zinc-400 flex-shrink-0 active:bg-zinc-800 transition">
${getIcon(r.icono)}
</button>
<div class="flex-1 space-y-3">
<input type="text" id="ed-nombre" value="${esc(r.nombre)}" placeholder="Nombre de la rutina"
class="w-full bg-transparent border-b border-zinc-700/50 px-1 py-2.5 text-base font-semibold placeholder:text-zinc-700 focus:border-emerald-500/50 focus:outline-none transition min-h-[44px]">
<input type="text" id="ed-desc" value="${esc(r.descripcion)}" placeholder="Descripción (opcional)"
class="w-full bg-transparent border-b border-zinc-800/40 px-1 py-2 text-sm font-light text-zinc-400 placeholder:text-zinc-700 focus:border-emerald-500/50 focus:outline-none transition min-h-[44px]">
</div>
</div>
<div id="icon-picker" class="hidden">
<div class="grid grid-cols-5 gap-2 bg-zinc-900/60 border border-zinc-800/60 rounded-2xl p-4">
${ROUTINE_ICONS.map(ic => `
<button onclick="App.pickIcon('${ic.key}')" class="flex flex-col items-center gap-1 p-2.5 rounded-xl transition ${r.icono === ic.key ? 'bg-emerald-500/10 ring-1 ring-emerald-500/50' : 'active:bg-zinc-800'}">
<span class="text-zinc-400">${getIcon(ic.key)}</span>
<span class="text-[9px] text-zinc-600">${ic.label}</span>
</button>
`).join('')}
</div>
</div>
<!-- Blocks -->
<div class="space-y-4">
<h2 class="text-zinc-500 text-[11px] font-semibold tracking-[.15em] uppercase">Bloques</h2>
${r.bloques.map((b, bi) => renderEditorBloque(b, bi)).join('')}
<button onclick="App.addBlock()" class="w-full border border-dashed border-zinc-700/40 rounded-2xl py-4 flex items-center justify-center gap-2 text-zinc-500 text-sm font-light active:bg-zinc-900/30 transition min-h-[44px]">
${ICONS.plus} Agregar Bloque
</button>
</div>
${!isNew ? `<button onclick="App.deleteFromEditor()" class="w-full py-4 text-red-400/60 text-sm font-light active:text-red-400 transition min-h-[44px]">Eliminar esta rutina</button>` : ''}
</div>
</div>
`);
}
function renderEditorBloque(b, bi) {
const isSS = b.es_superserie;
return `
<div class="bg-zinc-900/40 border ${isSS ? 'border-sky-500/20' : 'border-zinc-800/60'} rounded-2xl card-depth overflow-hidden ${isSS ? 'ss-accent' : ''}" id="block-${bi}">
<div class="px-4 py-3 border-b border-zinc-800/30">
<div class="flex items-center gap-2 mb-3">
<input type="text" value="${esc(b.tipo)}" placeholder="Nombre del bloque" onchange="App.updateBlock(${bi},'tipo',this.value)"
class="flex-1 bg-transparent border-b border-zinc-700/30 px-1 py-2 text-sm font-semibold placeholder:text-zinc-700 focus:border-sky-500/50 focus:outline-none transition min-h-[44px]">
<button onclick="App.removeBlock(${bi})" class="w-10 h-10 rounded-lg flex items-center justify-center text-red-400/40 active:text-red-400 active:bg-red-500/10 transition min-h-[44px] min-w-[44px]">${ICONS.trash}</button>
</div>
<div class="flex items-center gap-4">
<label class="flex items-center gap-2 min-h-[44px] cursor-pointer">
<input type="checkbox" ${isSS ? 'checked' : ''} onchange="App.updateBlock(${bi},'es_superserie',this.checked)"
class="w-4 h-4 rounded bg-zinc-800 border-zinc-600 text-sky-500 focus:ring-sky-500 focus:ring-offset-0">
<span class="text-xs text-zinc-500 font-light">Superserie</span>
</label>
${isSS ? `<div class="flex items-center gap-2">
<span class="text-[11px] text-zinc-600">Series:</span>
<input type="number" inputmode="numeric" value="${b.series_total || 3}" min="1" max="10" onchange="App.updateBlock(${bi},'series_total',parseInt(this.value)||3)"
class="w-12 input-minimal text-xs">
</div>` : ''}
</div>
</div>
<div class="divide-y divide-zinc-800/20">
${b.ejercicios.map((e, ei) => renderEditorExercise(bi, e, ei, b)).join('')}
</div>
<button onclick="App.addExercise(${bi})" class="w-full py-3 flex items-center justify-center gap-1.5 text-emerald-400/70 text-xs font-medium active:bg-zinc-800/30 transition min-h-[44px] border-t border-zinc-800/20">
${ICONS.plus.replace('w-5 h-5', 'w-3.5 h-3.5')} Ejercicio
</button>
</div>`;
}
function renderEditorExercise(bi, e, ei, b) {
const showS = !b.es_superserie;
const videoId = getExerciseVideo(e.nombre);
const thumbUrl = videoId ? `https://img.youtube.com/vi/${videoId}/mqdefault.jpg` : '';
return `<div class="px-4 py-3 space-y-2">
<div class="flex items-center gap-2">
<div class="flex flex-col gap-0.5 mr-0.5">
${ei > 0 ? `<button onclick="App.moveExercise(${bi},${ei},-1)" class="w-7 h-7 rounded flex items-center justify-center text-zinc-600 active:text-zinc-300 transition">${ICONS.arrowUp}</button>` : '<div class="w-7 h-7"></div>'}
${ei < b.ejercicios.length - 1 ? `<button onclick="App.moveExercise(${bi},${ei},1)" class="w-7 h-7 rounded flex items-center justify-center text-zinc-600 active:text-zinc-300 transition">${ICONS.arrowDown}</button>` : '<div class="w-7 h-7"></div>'}
</div>
${thumbUrl ? `<img src="${thumbUrl}" class="ac-thumb" alt="" loading="lazy">` : ''}
<div class="flex-1 relative">
<input type="text" value="${esc(e.nombre)}" placeholder="Buscar ejercicio..." id="exinp-${bi}-${ei}"
oninput="App.onExerciseInput(${bi},${ei},this.value)" onchange="App.updateExercise(${bi},${ei},'nombre',this.value)"
onfocus="App.onExerciseInput(${bi},${ei},this.value)"
onblur="setTimeout(()=>{const d=document.getElementById('ac-${bi}-${ei}');if(d)d.remove();},200)"
class="w-full bg-transparent border-b border-zinc-800/30 px-1 py-2 text-sm font-medium placeholder:text-zinc-700 focus:border-emerald-500/50 focus:outline-none transition min-h-[44px]" autocomplete="off">
<div id="ac-${bi}-${ei}"></div>
</div>
<button onclick="App.removeExercise(${bi},${ei})" class="w-8 h-8 rounded-lg flex items-center justify-center text-zinc-700 active:text-red-400 transition min-h-[44px] min-w-[44px]">${ICONS.x}</button>
</div>
<div class="grid ${showS ? 'grid-cols-3' : 'grid-cols-2'} gap-3 pl-9">
<div><label class="text-[9px] text-zinc-600 uppercase tracking-widest font-medium">Objetivo</label>
<input type="text" value="${esc(e.objetivo || '')}" placeholder="8-10 reps" onchange="App.updateExercise(${bi},${ei},'objetivo',this.value)" class="input-minimal text-xs"></div>
<div><label class="text-[9px] text-zinc-600 uppercase tracking-widest font-medium">Descanso</label>
<input type="number" inputmode="numeric" value="${e.descanso || 0}" min="0" step="5" onchange="App.updateExercise(${bi},${ei},'descanso',parseInt(this.value)||0)" class="input-minimal text-xs"></div>
${showS ? `<div><label class="text-[9px] text-zinc-600 uppercase tracking-widest font-medium">Series</label>
<input type="number" inputmode="numeric" value="${e.series || 3}" min="1" max="10" onchange="App.updateExercise(${bi},${ei},'series',parseInt(this.value)||3)" class="input-minimal text-xs"></div>` : ''}
</div>
</div>`;
}
// Editor actions
function readEditorFields() { const n = $('ed-nombre'), d = $('ed-desc'); if (n) state.editingRoutine.nombre = n.value; if (d) state.editingRoutine.descripcion = d.value; }
function toggleIconPicker() { $('icon-picker').classList.toggle('hidden'); }
function pickIcon(key) { readEditorFields(); state.editingRoutine.icono = key; renderEditor(); }
function updateBlock(bi, f, v) {
readEditorFields(); state.editingRoutine.bloques[bi][f] = v;
if (f === 'es_superserie' && v && !state.editingRoutine.bloques[bi].series_total) state.editingRoutine.bloques[bi].series_total = 3;
if (f === 'es_superserie' || f === 'series_total') renderEditor();
}
function addBlock() { readEditorFields(); state.editingRoutine.bloques.push({ id: uid(), tipo: '', ejercicios: [{ nombre: '', objetivo: '', descanso: 60, series: 3 }] }); renderEditor(); setTimeout(() => { const bs = document.querySelectorAll('[id^="block-"]'); if (bs.length) bs[bs.length - 1].scrollIntoView({ behavior: 'smooth', block: 'center' }); }, 100); }
function removeBlock(bi) { readEditorFields(); state.editingRoutine.bloques.splice(bi, 1); renderEditor(); }
function addExercise(bi) { readEditorFields(); state.editingRoutine.bloques[bi].ejercicios.push({ nombre: '', objetivo: '', descanso: 60, series: 3 }); renderEditor(); }
function removeExercise(bi, ei) { readEditorFields(); const b = state.editingRoutine.bloques[bi]; b.ejercicios.length <= 1 ? state.editingRoutine.bloques.splice(bi, 1) : b.ejercicios.splice(ei, 1); renderEditor(); }
function moveExercise(bi, ei, dir) { readEditorFields(); const ex = state.editingRoutine.bloques[bi].ejercicios, ni = ei + dir; if (ni < 0 || ni >= ex.length) return; [ex[ei], ex[ni]] = [ex[ni], ex[ei]]; renderEditor(); }
function updateExercise(bi, ei, f, v) { readEditorFields(); state.editingRoutine.bloques[bi].ejercicios[ei][f] = v; }
function onExerciseInput(bi, ei, val) {
const dropId = `ac-${bi}-${ei}`;
const existing = document.getElementById(dropId);
if (existing) existing.innerHTML = '';
const results = searchExercises(val);
if (!results.length) return;
let drop = document.getElementById(dropId);
if (!drop) return;
drop.innerHTML = `<div class="ac-dropdown">${results.map(ex => {
const thumb = ex.video ? `https://img.youtube.com/vi/${ex.video}/mqdefault.jpg` : '';
return `<div class="ac-item" onmousedown="App.pickExercise(${bi},${ei},'${esc(ex.nombre)}')">
${thumb ? `<img src="${thumb}" class="ac-thumb" alt="" loading="lazy">` : '<div class="ac-thumb"></div>'}
<div><div class="ac-name">${ex.nombre}</div><div class="ac-group">${ex.grupo}</div></div>
</div>`;
}).join('')}</div>`;
}
function pickExercise(bi, ei, nombre) {
readEditorFields();
state.editingRoutine.bloques[bi].ejercicios[ei].nombre = nombre;
renderEditor();
}
function cancelEditor() { updateTabBar('train'); renderHome(); }
function saveEditor() {
readEditorFields(); const r = state.editingRoutine;
if (!r.nombre.trim()) { showToast('Ingresá un nombre'); $('ed-nombre')?.focus(); return; }
r.bloques = r.bloques.filter(b => { b.ejercicios = b.ejercicios.filter(e => e.nombre.trim()); return b.ejercicios.length > 0 && b.tipo.trim(); });
if (!r.bloques.length) { showToast('Agregá al menos un bloque'); return; }
const all = getRoutines();
state.editingIndex === -1 ? all.push(r) : (all[state.editingIndex] = r);
saveRoutines(all); showToast(state.editingIndex === -1 ? 'Rutina creada' : 'Guardado'); updateTabBar('train'); renderHome();
}
function deleteFromEditor() { showConfirmModal(`Eliminar "${state.editingRoutine.nombre}"`, 'No se puede deshacer.', () => { if (state.editingIndex >= 0) { const r = getRoutines(); r.splice(state.editingIndex, 1); saveRoutines(r); } updateTabBar('train'); renderHome(); }, null, 'Eliminar'); }
// ===========================================================
// ROUTINE DETAIL (Preview before workout)
// ===========================================================
function showRoutineDetail(i) {
const r = getRoutines()[i];
state.screen = 'detail';
updateTabBar('train', false);
const totalEx = r.bloques.reduce((s, b) => s + b.ejercicios.length, 0);
html($('app'), `
<div class="fade-in" style="padding-top: calc(var(--safe-top, 0px) + 8px);">
<div class="px-4 flex items-center justify-between sticky top-0 bg-zinc-950/90 backdrop-blur-xl z-30 py-3 border-b border-zinc-800/30">
<button onclick="App.renderHome()" class="w-10 h-10 rounded-xl flex items-center justify-center active:bg-zinc-800 transition min-h-[44px] min-w-[44px] text-zinc-400">${ICONS.chevronLeft}</button>
<div class="flex items-center gap-2">
<button onclick="App.editRoutine(${i})" class="p-2.5 rounded-lg text-zinc-500 active:bg-zinc-800 transition min-h-[44px] min-w-[44px] flex items-center justify-center">${ICONS.edit}</button>
</div>
</div>
<div class="px-5 pt-4 pb-2">
<div class="flex items-center gap-3 mb-2">
<div class="w-12 h-12 rounded-xl bg-zinc-800/80 flex items-center justify-center text-zinc-400 flex-shrink-0">${getIcon(r.icono)}</div>
<div>
<h1 class="text-xl font-bold tracking-tight">${r.nombre}</h1>
<p class="text-zinc-500 text-xs font-light mt-0.5">${r.descripcion}</p>
</div>
</div>
<p class="text-zinc-600 text-[11px] font-light mt-2">${r.bloques.length} bloques · ${totalEx} ejercicios</p>
</div>
<div class="px-4 py-3 space-y-4 pb-32">
${r.bloques.map(b => {
const isSS = b.es_superserie;
return `
<div>
<div class="flex items-center justify-between px-1 mb-2">
<h3 class="text-zinc-400 text-xs font-semibold uppercase tracking-wider">${b.tipo}</h3>
${isSS ? `<span class="text-[9px] bg-sky-500/10 text-sky-400/80 px-2 py-0.5 rounded-full font-medium">SS ×${b.series_total || 3}</span>` : ''}
</div>
<div class="bg-zinc-900/40 border ${isSS ? 'border-sky-500/15 ss-accent' : 'border-zinc-800/50'} rounded-2xl card-depth overflow-hidden divide-y ${isSS ? 'divide-sky-500/5' : 'divide-zinc-800/20'}">
${b.ejercicios.map(e => {
const vid = getExerciseVideo(e.nombre);
const thumb = vid ? `https://img.youtube.com/vi/${vid}/mqdefault.jpg` : '';
const series = isSS ? '' : (e.series ? `${e.series} series | ` : '');
return `
<div class="flex items-center gap-3 px-3 py-3">
${thumb ? `
<div class="vid-thumb relative flex-shrink-0" onclick="App.openVideo('${vid}')">
<img src="${thumb}" class="w-full h-full object-cover rounded-[10px]" alt="" loading="lazy">
<svg class="vid-play" viewBox="0 0 24 24" fill="white" opacity="0.9"><polygon points="8,5 19,12 8,19"/></svg>
</div>` : '<div class="w-14 h-14 rounded-[10px] bg-zinc-800/50 flex-shrink-0"></div>'}
<div class="flex-1 min-w-0">
<p class="text-sm font-medium text-zinc-200 truncate">${e.nombre}</p>
<p class="text-zinc-600 text-[11px] font-light mt-0.5">${series}${e.objetivo}</p>
</div>
${vid ? `<button onclick="App.openVideo('${vid}')" class="text-zinc-700 active:text-zinc-400 transition p-1">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="1.5"><path d="M7 17L17 7M17 7H7M17 7v10"/></svg>
</button>` : ''}
</div>`;
}).join('')}
</div>
</div>`;
}).join('')}
</div>
<div class="fixed bottom-0 left-0 right-0 z-30 px-5 pb-6 pt-3 bg-gradient-to-t from-zinc-950 via-zinc-950/95 to-transparent" style="padding-bottom: calc(var(--safe-bottom, 0px) + 24px);">
<button onclick="App.confirmStartWorkout(${i})" class="w-full bg-zinc-200 text-zinc-950 font-semibold rounded-2xl py-4 text-[15px] active:bg-zinc-300 transition min-h-[52px] shadow-lg">
Iniciar entrenamiento
</button>
</div>
</div>
`);
}
// ===========================================================
// WORKOUT
// ===========================================================
function startWorkout(i) {
const r = getRoutines()[i]; state.screen = 'workout'; state.activeRoutine = r; state.workoutStart = Date.now(); state.workoutData = {};
updateTabBar('train', false);
r.bloques.forEach(b => b.ejercicios.forEach(e => {
const c = getSeriesCount(b, e), ls = getLastSession(e.nombre), sets = [];
for (let j = 0; j < c; j++) {
const p = ls && ls.series[j];
const fallback = ls && ls.series.length ? ls.series[ls.series.length - 1] : null;
const ghost = p || fallback;
sets.push({ kg: 0, reps: 0, done: false, ph_kg: ghost ? ghost.kg : '', ph_reps: ghost ? ghost.reps : '' });
}
state.workoutData[e.nombre] = sets;
}));
renderWorkout();
}
function renderWorkout() {
const r = state.activeRoutine;
html($('app'), `
<div class="fade-in" style="padding-top: calc(var(--safe-top, 0px) + 8px);">
<div class="px-4 flex items-center justify-between sticky top-0 bg-zinc-950/90 backdrop-blur-xl z-30 py-3 border-b border-zinc-800/30">
<button onclick="App.confirmExit()" class="w-10 h-10 rounded-xl flex items-center justify-center active:bg-zinc-800 transition min-h-[44px] min-w-[44px] text-zinc-400">${ICONS.chevronLeft}</button>
<div class="text-center">
<h1 class="font-semibold text-base tracking-tight">${r.nombre}</h1>
<p class="text-zinc-600 text-[11px] font-light" id="workout-elapsed">${getElapsed()}</p>
</div>
<button onclick="App.finishWorkout()" class="text-emerald-400 font-semibold text-sm min-h-[44px] px-2 active:opacity-70 transition-opacity">Finalizar</button>
</div>
<div class="px-4 py-4 space-y-4 pb-28">
${r.bloques.map((b, bi) => renderWorkoutBlock(b, bi)).join('')}
</div>
</div>
`);
tickElapsed();
}
function tickElapsed() { if (state.screen !== 'workout') return; const el = $('workout-elapsed'); if (el) el.textContent = getElapsed(); setTimeout(tickElapsed, 1000); }
function getElapsed() { if (!state.workoutStart) return ''; const e = Math.floor((Date.now() - state.workoutStart) / 1000); return `${Math.floor(e / 60)}:${String(e % 60).padStart(2, '0')}`; }
function renderWorkoutBlock(b, bi) {
const isSS = b.es_superserie;
return `
<div class="bg-zinc-900/40 border ${isSS ? 'border-sky-500/15' : 'border-zinc-800/50'} rounded-2xl card-depth overflow-hidden ${isSS ? 'ss-accent' : ''}">
<div class="px-4 py-3 border-b border-zinc-800/20 flex items-center gap-2">
<h2 class="font-medium text-[13px] text-zinc-400 tracking-tight">${b.tipo}</h2>
${isSS ? '<span class="text-[9px] bg-sky-500/10 text-sky-400/80 px-2 py-0.5 rounded-full font-medium tracking-wider">SS</span>' : ''}
</div>
<div class="${isSS ? 'divide-y divide-sky-500/5' : 'divide-y divide-zinc-800/20'}">
${b.ejercicios.map(e => renderWorkoutExercise(b, e)).join('')}
</div>
</div>`;
}
function openVideo(videoId) {
window.open(`https://www.youtube.com/watch?v=${videoId}`, '_blank');
}
function renderWorkoutExercise(b, e) {
const sets = state.workoutData[e.nombre] || [], allDone = sets.length > 0 && sets.every(s => s.done);
const videoId = getExerciseVideo(e.nombre);
const thumbUrl = videoId ? `https://img.youtube.com/vi/${videoId}/mqdefault.jpg` : '';
return `
<div class="px-4 py-4">
<div class="flex items-center gap-3 mb-3">
${thumbUrl ? `
<div class="vid-thumb relative" onclick="App.openVideo('${videoId}')">
<img src="${thumbUrl}" class="w-full h-full object-cover rounded-[10px]" alt="" loading="lazy">
<svg class="vid-play" viewBox="0 0 24 24" fill="white" opacity="0.9"><polygon points="8,5 19,12 8,19"/></svg>
</div>` : ''}
<div class="flex-1 min-w-0">
<p class="font-medium text-[13px] tracking-tight ${allDone ? 'text-emerald-400/80' : 'text-zinc-200'}">${e.nombre}</p>
<p class="text-zinc-600 text-[11px] font-light mt-0.5">${e.objetivo}${e.descanso > 0 ? ` · ${e.descanso}s` : ''}</p>
</div>
<button onclick="App.showHistoryModal('${esc(e.nombre)}')" class="p-2 rounded-lg text-zinc-600 active:text-zinc-300 active:bg-zinc-800 transition min-h-[44px] min-w-[44px] flex items-center justify-center">${ICONS.chart}</button>
</div>
${sets.length > 0 ? `
<div class="space-y-2">
<div class="grid grid-cols-[28px_1fr_1fr_36px] gap-3 text-[9px] text-zinc-700 uppercase tracking-[.2em] font-medium pl-1">
<span>Set</span><span class="text-center">Reps</span><span class="text-center">Kg</span><span></span>
</div>
${sets.map((s, si) => `
<div class="grid grid-cols-[28px_1fr_1fr_36px] gap-3 items-center ${s.done ? 'opacity-40' : ''}">
<span class="text-[11px] text-zinc-600 font-light text-center">${si + 1}</span>
<input type="number" inputmode="numeric" id="reps-${escId(e.nombre)}-${si}" value="${s.reps || ''}" placeholder="${s.ph_reps || '—'}" tabindex="${si * 2 + 1}"
onchange="App.updateSet('${esc(e.nombre)}',${si},'reps',this.value)" class="input-minimal ${s.done ? 'done' : ''}">
<input type="number" inputmode="decimal" step="0.5" id="kg-${escId(e.nombre)}-${si}" value="${s.kg || ''}" placeholder="${s.ph_kg || '—'}" tabindex="${si * 2 + 2}"
onchange="App.updateSet('${esc(e.nombre)}',${si},'kg',this.value)" class="input-minimal ${s.done ? 'done' : ''}">
<button onclick="App.toggleSet('${esc(e.nombre)}',${si},${e.descanso || 0})"
class="w-9 h-9 rounded-full flex items-center justify-center transition-all mx-auto min-h-[44px] min-w-[44px]">${s.done ? ICONS.checkCircle : ICONS.circle}</button>