-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
2703 lines (2505 loc) · 139 KB
/
index.html
File metadata and controls
2703 lines (2505 loc) · 139 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chronos — Weekly Scheduler by Aleksei Avgustin</title>
<meta name="description" content="Chronos is a beautiful weekly scheduler with drag-and-drop, recurring events, and calendar export. By Aleksei Avgustin.">
<meta name="author" content="Aleksei Avgustin">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@300;400&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap" rel="stylesheet">
<style>
*{box-sizing:border-box;margin:0;padding:0}
:root{
--bg:#0a0a09;--cal:#0d0d0c;--cgl:#1a1a17;--cln:#252420;--ctx:#5a5950;--ctm:#383730;
--pan:#f2f0eb;--pan2:#e8e5de;--pt:#1c1b17;--pm:#9a9890;
--acc:#e05a2b;--acc2:#c04e23;--accg:rgba(224,90,43,.15);
--lck:#4a9eff;--wht:#f8f6f1;--divc:#d4d0c8;
--sh:0 4px 24px rgba(0,0,0,.22);--sh2:0 10px 44px rgba(0,0,0,.38);
--r:8px;
}
html,body{height:100%}
body{font-family:'DM Sans',sans-serif;background:var(--bg);height:100vh;overflow:hidden;display:flex;flex-direction:column;color:var(--pt)}
/* ── SMALL SCREEN ─────────────────────────────────────────────────────── */
#smallscreen{display:none;position:fixed;inset:0;background:var(--bg);z-index:99999;align-items:center;justify-content:center;padding:24px}
#ss-card{background:#141412;border:1px solid var(--cln);border-radius:16px;padding:36px 32px;max-width:400px;text-align:center}
#ss-logo{font-family:'Instrument Serif',serif;font-size:28px;color:var(--wht);letter-spacing:-.5px;margin-bottom:18px}
#ss-logo em{color:var(--acc);font-style:italic}
#ss-title{font-family:'DM Sans',sans-serif;font-size:16px;font-weight:600;color:var(--wht);margin-bottom:12px}
#ss-msg{font-size:13px;color:var(--pm);line-height:1.6;margin-bottom:16px}
#ss-email{font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--acc);letter-spacing:.3px}
@media(max-width:768px){#smallscreen{display:flex}#tb,#main{display:none!important}}
/* ── TOOLBAR ──────────────────────────────────────────────────────────── */
#tb{height:52px;background:#0f0f0e;border-bottom:1px solid var(--cln);display:flex;align-items:center;padding:0 16px;gap:8px;flex-shrink:0;z-index:100}
.tb-l{display:flex;align-items:center;gap:8px;flex:1;min-width:0;overflow:hidden}
.logo{font-family:'Instrument Serif',serif;font-size:19px;color:var(--wht);letter-spacing:-.5px;white-space:nowrap;flex-shrink:0}
.logo em{color:var(--acc);font-style:italic}
.proj{background:none;border:none;border-bottom:1px solid #2e2c28;color:#666;font-family:'JetBrains Mono',monospace;font-size:10px;padding:2px 4px;outline:none;letter-spacing:.8px;text-transform:uppercase;width:130px;transition:border-color .2s;flex-shrink:0}
.proj:focus{border-color:var(--acc);color:var(--wht)}
.vsep{width:1px;height:22px;background:var(--cln);flex-shrink:0}
.xbtn{background:none;border:1px solid var(--cln);color:#666;font-size:11px;padding:5px 10px;border-radius:6px;cursor:pointer;transition:all .15s;white-space:nowrap;flex-shrink:0;display:flex;align-items:center;gap:5px}
.xbtn:hover{border-color:var(--acc);color:var(--wht);background:var(--accg)}
.xbtn:disabled{opacity:.25;pointer-events:none}
.xbtn-new{color:var(--acc)!important;border-color:rgba(224,90,43,.3)!important}
.xbtn-new:hover{background:var(--accg)!important;border-color:var(--acc)!important}
.xbtn.undo-ok{animation:flashGreen .4s ease}
@keyframes flashGreen{0%,100%{border-color:var(--cln)}50%{border-color:#5AAD8C}}
.tb-r{display:flex;align-items:center;gap:8px;flex-shrink:0}
.arr{width:28px;height:28px;background:none;border:1px solid var(--cln);border-radius:6px;color:#666;cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:16px;transition:all .15s}
.arr:hover{border-color:#555;color:var(--wht)}
.todaybtn{font-family:'JetBrains Mono',monospace;font-size:10px;background:none;border:1px solid var(--cln);border-radius:6px;color:#666;padding:5px 10px;cursor:pointer;text-transform:uppercase;letter-spacing:.5px;transition:all .15s}
.todaybtn:hover{border-color:#555;color:var(--wht)}
#wlabel{font-family:'JetBrains Mono',monospace;font-size:10px;color:#555;text-align:center;letter-spacing:.3px;white-space:nowrap}
#wlabel em{color:#666;font-style:normal;margin-left:6px}
.wtog{display:flex;background:var(--bg);border:1px solid var(--cln);border-radius:6px;overflow:hidden}
.wtog button{background:none;border:none;color:#555;font-family:'JetBrains Mono',monospace;font-size:10px;padding:5px 10px;cursor:pointer;transition:all .15s;letter-spacing:.5px}
.wtog button.on{background:#1e1d1a;color:var(--wht)}
/* ── MAIN ─────────────────────────────────────────────────────────────── */
#main{flex:1;display:flex;overflow:hidden}
#calp{flex:0 0 62%;display:flex;flex-direction:column;background:var(--cal);overflow:hidden}
#calh{display:flex;background:#090908;border-bottom:1px solid var(--cln);flex-shrink:0}
.tgut{width:52px;flex-shrink:0}
.dh{flex:1;padding:8px 6px 6px;text-align:center;border-left:1px solid var(--cln);position:relative}
.dh-n{font-family:'JetBrains Mono',monospace;font-size:9px;color:var(--ctx);text-transform:uppercase;letter-spacing:1px}
.dh-d{font-family:'Instrument Serif',serif;font-size:20px;color:#3a3930;margin-top:1px}
.dh-bar{height:3px;border-radius:2px;margin:4px 4px 0;overflow:hidden;background:var(--cln);display:flex}
.dh-bar-seg{height:100%;transition:width .3s}
.dh.today .dh-n,.dh.today .dh-d{color:var(--acc)}
#calb{flex:1;overflow-y:auto;overflow-x:hidden;scroll-behavior:smooth}
#calb::-webkit-scrollbar{width:5px}
#calb::-webkit-scrollbar-track{background:var(--cal)}
#calb::-webkit-scrollbar-thumb{background:#252420;border-radius:3px}
#calgrid{display:flex}
#tlabs{width:52px;flex-shrink:0;position:sticky;left:0;z-index:5;background:var(--cal)}
.tl{height:80px;display:flex;align-items:flex-start;justify-content:flex-end;padding:4px 8px 0 0}
.tl span{font-family:'JetBrains Mono',monospace;font-size:9px;color:var(--ctm);letter-spacing:.3px}
#dcols{flex:1;display:flex;cursor:crosshair}
.dcol{flex:1;border-left:1px solid var(--cln);position:relative;min-width:0;cursor:crosshair}
.hrow{height:80px;border-bottom:1px solid var(--cln)}
.hrow::after{content:'';display:block;height:50%;border-bottom:1px dashed var(--cgl)}
/* ── EVENT BLOCKS ─────────────────────────────────────────────────────── */
.eb{position:absolute;left:3px;right:3px;border-radius:7px;padding:5px 8px 4px;cursor:grab;overflow:hidden;z-index:2;user-select:none;transition:filter .1s,box-shadow .1s;animation:ebIn .18s ease-out}
@keyframes ebIn{from{opacity:0;transform:scaleY(.85) translateY(-4px)}to{opacity:1;transform:none}}
.eb:hover{filter:brightness(1.12);box-shadow:0 3px 14px rgba(0,0,0,.35)}
.eb.locked{cursor:default;border-left:3px solid var(--lck)!important;filter:none}
.eb.dragging{opacity:.16;pointer-events:none}
.eb.done .eb-name{text-decoration:line-through;opacity:.55}
.eb.done{filter:saturate(.35)!important;opacity:.7}
.eb-name{font-size:11px;font-weight:600;color:#fff;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none}
.eb-time{font-family:'JetBrains Mono',monospace;font-size:9px;color:rgba(255,255,255,.5);margin-top:1px;pointer-events:none}
.eb-note{font-size:9px;color:rgba(255,255,255,.4);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px;pointer-events:none;font-style:italic}
.eb-ics{position:absolute;top:4px;right:5px;font-size:9px;opacity:.8;pointer-events:none;display:flex;gap:2px}
.eb-rsz{position:absolute;bottom:0;left:0;right:0;height:7px;cursor:ns-resize;background:rgba(255,255,255,.1);border-radius:0 0 7px 7px;opacity:0;transition:opacity .12s;z-index:3}
.eb:not(.locked):hover .eb-rsz{opacity:1}
/* recurring diagonal stripe */
.eb.recurring::after{content:'';position:absolute;inset:0;background:repeating-linear-gradient(45deg,transparent,transparent 6px,rgba(255,255,255,.04) 6px,rgba(255,255,255,.04) 7px);pointer-events:none;border-radius:7px}
/* draw-to-create on calendar */
.draw-preview{position:absolute;left:3px;right:3px;border-radius:7px;border:2px solid var(--acc);background:var(--accg);pointer-events:none;z-index:3;display:none;transition:none}
.draw-preview .dp-lbl{font-family:'JetBrains Mono',monospace;font-size:10px;color:rgba(255,255,255,.85);padding:4px 7px;font-weight:600;text-shadow:0 1px 3px rgba(0,0,0,.4)}
/* drop preview */
.dp{position:absolute;left:3px;right:3px;border-radius:7px;border:2px dashed var(--acc);background:var(--accg);pointer-events:none;z-index:1;display:none;transition:background .08s}
.dp.no{background:rgba(232,93,74,.18);border-color:#E85D4A;border-style:solid}
.dp-tip{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-family:'JetBrains Mono',monospace;font-size:11px;font-weight:700;color:rgba(255,255,255,.7);letter-spacing:.5px;text-shadow:0 1px 4px rgba(0,0,0,.5)}
.dp.no .dp-tip{color:rgba(232,93,74,.8)}
/* now line */
.nwl{position:absolute;left:0;right:0;height:2px;background:var(--acc);z-index:10;pointer-events:none}
.nwl::before{content:'';position:absolute;left:-3px;top:-3px;width:8px;height:8px;border-radius:50%;background:var(--acc)}
/* ── DRAGGABLE DIVIDER ──────────────────────────────────────────────────── */
#vdiv{width:6px;background:transparent;flex-shrink:0;cursor:col-resize;position:relative;z-index:10;transition:background .15s}
#vdiv:hover,#vdiv.dragging{background:rgba(224,90,43,.35)}
#vdiv::after{content:'';position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:2px;height:32px;background:var(--cln);border-radius:1px;transition:background .15s}
#vdiv:hover::after,#vdiv.dragging::after{background:var(--acc)}
/* ── TASK PANEL ───────────────────────────────────────────────────────── */
#taskp{flex:1;background:var(--pan);display:flex;flex-direction:column;overflow:hidden;min-width:0;position:relative}
.ptabs{display:flex;border-bottom:1px solid var(--divc);flex-shrink:0}
.ptab{flex:1;padding:10px 6px;background:none;border:none;font-family:'DM Sans',sans-serif;font-size:11px;font-weight:500;color:var(--pm);cursor:pointer;border-bottom:2px solid transparent;transition:all .15s;letter-spacing:.3px;text-transform:uppercase}
.ptab.on{color:var(--pt);border-bottom-color:var(--pt)}
#tabtasks{flex:1;display:flex;flex-direction:column;overflow:hidden}
#tlist{flex:1;overflow-y:auto;padding:14px 16px;display:flex;flex-direction:column;gap:10px}
#tlist::-webkit-scrollbar{width:4px}
#tlist::-webkit-scrollbar-track{background:var(--pan)}
#tlist::-webkit-scrollbar-thumb{background:var(--divc);border-radius:2px}
.emsg{text-align:center;padding:36px 20px;color:var(--pm)}
.emsg .ei{font-size:30px;opacity:.38;margin-bottom:8px}
.emsg p{font-size:13px;line-height:1.5}
.emsg kbd{display:inline-block;background:var(--pan2);border:1px solid var(--divc);border-radius:4px;padding:1px 5px;font-size:10px;font-family:'JetBrains Mono',monospace}
/* task cards */
.tc{background:var(--pt);border-radius:12px;padding:14px 16px;cursor:grab;position:relative;transition:transform .12s,box-shadow .12s;user-select:none;overflow:hidden;animation:tcIn .2s ease-out;min-height:68px}
@keyframes tcIn{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.tc::before{content:'';position:absolute;left:0;top:0;bottom:0;width:4px;border-radius:12px 0 0 12px;background:var(--tcc,#888)}
.tc:hover{transform:translateY(-1px);box-shadow:var(--sh)}
.tc:active{cursor:grabbing}
.tc-top{display:flex;align-items:flex-start;gap:6px}
.tc-n{font-size:14px;font-weight:500;color:var(--wht);flex:1;pointer-events:none;line-height:1.3}
.tc-acts{display:flex;gap:4px;opacity:.35;transition:opacity .15s;flex-shrink:0}
.tc:hover .tc-acts{opacity:1}
.cbtn{width:24px;height:24px;background:rgba(255,255,255,.07);border:none;border-radius:5px;color:rgba(255,255,255,.4);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:11px;transition:all .15s}
.cbtn:hover{background:rgba(255,255,255,.14);color:#fff}
.cbtn.del:hover{background:rgba(232,93,74,.25);color:#E85D4A}
.tc-note{font-size:10px;color:rgba(255,255,255,.3);margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none;font-style:italic}
.tc-meta{display:flex;align-items:center;gap:7px;margin-top:8px;flex-wrap:wrap;pointer-events:none}
.tc-dur{font-family:'JetBrains Mono',monospace;font-size:11px;color:rgba(255,255,255,.45)}
.badge{font-size:10px;padding:3px 9px;border-radius:20px;font-weight:500}
.badge-rec{background:rgba(74,158,255,.15);color:rgba(120,190,255,.9)}
.badge-bw{background:rgba(140,90,220,.18);color:rgba(170,140,255,.9)}
.badge-part{background:rgba(242,160,40,.15);color:rgba(242,200,80,.9)}
.tc-grip{position:absolute;right:10px;bottom:10px;color:rgba(255,255,255,.08);font-size:11px;pointer-events:none;letter-spacing:2px}
/* addarea bottom bar */
#addarea{border-top:1px solid var(--divc);padding:10px 14px;flex-shrink:0;display:flex;gap:8px;align-items:center}
#addbtn{flex:1;padding:10px 12px;background:var(--pt);border:none;border-radius:10px;color:rgba(255,255,255,.28);font-family:'DM Sans',sans-serif;font-size:13px;cursor:pointer;text-align:left;display:flex;align-items:center;gap:8px;transition:all .15s;min-width:0}
#addbtn:hover{color:rgba(255,255,255,.6)}
#addbtn .plus{font-size:17px;opacity:.4;flex-shrink:0}
#clearbtn{width:36px;height:36px;background:var(--pt);border:none;border-radius:10px;color:rgba(255,255,255,.28);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .15s;flex-shrink:0}
#clearbtn:hover{color:#E85D4A;background:rgba(232,93,74,.15)}
#bulkbtn{width:36px;height:36px;background:var(--pt);border:none;border-radius:10px;color:rgba(255,255,255,.35);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:all .15s;flex-shrink:0}
#bulkbtn:hover{color:rgba(255,255,255,.75);background:#2a2926}
#bulkbtn svg{pointer-events:none}
/* bulk import modal textarea */
.bulk-example{background:#fff;border:1px solid var(--divc);border-radius:8px;padding:10px 13px;font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--pm);line-height:1.8;margin-top:2px}
.bulk-example span{color:var(--acc)}
.bulk-preview-list{display:flex;flex-direction:column;gap:5px;max-height:200px;overflow-y:auto;margin-top:2px}
.bulk-prev-row{display:flex;align-items:center;gap:8px;padding:6px 10px;background:#fff;border:1px solid var(--divc);border-radius:7px;font-size:12px;animation:tcIn .15s ease-out}
.bulk-prev-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}
.bulk-prev-n{flex:1;color:var(--pt);font-weight:500}
.bulk-prev-meta{font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm)}
.bulk-prev-err{background:rgba(232,93,74,.08);border-color:rgba(232,93,74,.3)}
.bulk-prev-err .bulk-prev-n{color:#E85D4A}
/* TRASH ZONE — overlays the RIGHT panel when dragging an event */
#trz{position:absolute;inset:0;display:none;flex-direction:column;z-index:50;pointer-events:none}
#trz-top{flex:0 0 70%;display:flex;flex-direction:column;align-items:center;justify-content:center;border:2px dashed rgba(90,173,140,.3);background:rgba(90,173,140,.06);transition:background .12s,border-color .12s;border-radius:0}
#trz-top.hot{background:rgba(90,173,140,.18);border-color:#5AAD8C}
#trz-top .ti{font-size:32px;opacity:.5}
#trz-top .tl2{font-family:'JetBrains Mono',monospace;font-size:10px;color:#5AAD8C;margin-top:8px;letter-spacing:.5px;text-transform:uppercase;opacity:.85;text-align:center}
#trz-bot{flex:0 0 30%;display:flex;flex-direction:column;align-items:center;justify-content:center;border:2px dashed rgba(232,93,74,.3);border-top:none;background:rgba(232,93,74,.06);transition:background .12s,border-color .12s}
#trz-bot.hot{background:rgba(232,93,74,.18);border-color:#E85D4A}
#trz-bot .ti{font-size:28px;opacity:.5}
#trz-bot .tl2{font-family:'JetBrains Mono',monospace;font-size:10px;color:#E85D4A;margin-top:6px;letter-spacing:.5px;text-transform:uppercase;opacity:.85;text-align:center}
/* bulk import */
#bulkFmt{display:none;overflow:hidden;transition:max-height .22s ease}
#bulkFmt.open{display:block}
.bulk-prev-item{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid var(--divc);border-radius:8px;padding:7px 10px;font-size:12px}
.bulk-prev-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0}
.bulk-prev-name{flex:1;font-weight:500;color:var(--pt)}
.bulk-prev-meta{font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm)}
.bulk-prev-err{background:rgba(232,93,74,.07);border-color:rgba(232,93,74,.3)}
.bulk-prev-err .bulk-prev-name{color:#E85D4A}
/* category management in stats */
.cat-mgmt-row{display:flex;align-items:center;gap:8px;padding:7px 0;border-bottom:1px solid #eceae3}
.cat-mgmt-dot{width:10px;height:10px;border-radius:50%;flex-shrink:0}
.cat-mgmt-name{font-size:13px;color:var(--pt);flex:1;font-weight:500}
.cat-mgmt-used{font-size:10px;color:var(--pm);min-width:60px;text-align:right}
.cat-mgmt-btn{width:24px;height:24px;background:none;border:1px solid var(--divc);border-radius:5px;cursor:pointer;font-size:11px;display:flex;align-items:center;justify-content:center;transition:all .12s;color:var(--pm)}
.cat-mgmt-btn:hover{background:var(--pan2);color:var(--pt)}
.cat-mgmt-btn.cat-del:hover:not(:disabled){background:rgba(232,93,74,.15);color:#E85D4A;border-color:rgba(232,93,74,.4)}
.cat-mgmt-btn:disabled{opacity:.28;pointer-events:none}
/* color swatches for cat editor */
.cat-color-grid{display:flex;flex-wrap:wrap;gap:7px;margin-top:4px}
.cat-color-sw{width:26px;height:26px;border-radius:50%;cursor:pointer;border:2.5px solid transparent;transition:all .12s}
.cat-color-sw:hover{transform:scale(1.15)}
.cat-color-sw.sel{border-color:var(--pt);transform:scale(1.15)}
/* ── OUTLINE TAB ──────────────────────────────────────────────────────── */
#tabout{display:none;flex:1;overflow-y:auto;padding:14px}
.out-sec{margin-bottom:18px}
.out-dh{font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm);text-transform:uppercase;letter-spacing:1px;padding:4px 0;border-bottom:1px solid var(--divc);margin-bottom:8px;display:flex;align-items:center;justify-content:space-between}
.out-dh-hrs{color:var(--pt);opacity:.45}
.out-item{display:flex;align-items:center;gap:8px;padding:5px 0;border-bottom:1px solid #eceae3;cursor:pointer;transition:background .1s}
.out-item:hover{background:rgba(0,0,0,.04);border-radius:4px;padding-left:4px;padding-right:4px}
.out-dot{width:7px;height:7px;border-radius:50%;flex-shrink:0}
.out-tm{font-family:'JetBrains Mono',monospace;font-size:9px;color:var(--pm);width:90px;flex-shrink:0}
.out-nm{font-size:12px;color:var(--pt);flex:1}
.out-ct{font-size:10px;color:var(--pm)}
.catleg{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:14px}
.cl-i{display:flex;align-items:center;gap:4px;font-size:10px;color:var(--pm)}
.cl-d{width:7px;height:7px;border-radius:50%}
/* ── STATS TAB ────────────────────────────────────────────────────────── */
#tabstats{display:none;flex:1;overflow-y:auto;padding:14px}
.stats-total{font-family:'Instrument Serif',serif;font-size:32px;color:var(--pt);margin-bottom:2px}
.stats-sub{font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm);margin-bottom:20px;letter-spacing:.3px}
.stats-sec-h{font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm);text-transform:uppercase;letter-spacing:1px;margin-bottom:10px;padding-bottom:4px;border-bottom:1px solid var(--divc)}
.stat-bar-row{display:flex;align-items:center;gap:10px;margin-bottom:8px}
.stat-bar-lbl{font-size:12px;color:var(--pt);width:72px;flex-shrink:0}
.stat-bar-wrap{flex:1;height:8px;background:var(--pan2);border-radius:4px;overflow:hidden}
.stat-bar-fill{height:100%;border-radius:4px;transition:width .5s cubic-bezier(.34,1.2,.64,1)}
.stat-bar-val{font-family:'JetBrains Mono',monospace;font-size:9px;color:var(--pm);width:38px;text-align:right;flex-shrink:0}
.stats-days{display:grid;grid-template-columns:repeat(7,1fr);gap:6px;margin-top:6px}
.sd{background:#fff;border:1px solid var(--divc);border-radius:8px;padding:7px 6px;text-align:center}
.sd-n{font-family:'JetBrains Mono',monospace;font-size:9px;color:var(--pm);text-transform:uppercase;letter-spacing:.5px}
.sd-v{font-family:'Instrument Serif',serif;font-size:18px;color:var(--pt);margin-top:2px}
.sd-u{font-size:9px;color:var(--pm)}
.sd.best{border-color:var(--acc);background:rgba(224,90,43,.06)}
.sd.best .sd-v{color:var(--acc)}
/* ── MODALS ───────────────────────────────────────────────────────────── */
.ov{position:fixed;inset:0;background:rgba(0,0,0,.55);backdrop-filter:blur(6px);z-index:1000;display:flex;align-items:center;justify-content:center;opacity:0;pointer-events:none;transition:opacity .2s}
.ov.vis{opacity:1;pointer-events:all}
.modal{background:var(--pan);border-radius:16px;padding:26px;width:450px;box-shadow:var(--sh2);transform:translateY(12px);transition:transform .22s cubic-bezier(.34,1.2,.64,1);max-height:90vh;overflow-y:auto}
.ov.vis .modal{transform:translateY(0)}
.modal h2{font-family:'Instrument Serif',serif;font-size:22px;color:var(--pt);margin-bottom:18px}
.modal-sub{color:var(--pm);font-size:12px;margin-bottom:16px;line-height:1.5}
.fg{margin-bottom:14px}
.fl{display:block;font-size:10px;font-weight:600;color:var(--pm);letter-spacing:.8px;text-transform:uppercase;margin-bottom:6px}
.fi{width:100%;padding:9px 13px;background:#fff;border:1px solid var(--divc);border-radius:8px;font-family:'DM Sans',sans-serif;font-size:13px;color:var(--pt);outline:none;transition:border-color .15s;resize:vertical}
.fi:focus{border-color:var(--acc)}
.frow{display:flex;gap:10px}
.frow .fg{flex:1}
.dur-row{display:flex;gap:7px;align-items:center}
.dur-sep{color:var(--pm);font-size:12px}
.fact{display:flex;gap:8px;justify-content:flex-end;margin-top:20px;flex-wrap:wrap}
.btn{padding:9px 16px;border-radius:8px;font-family:'DM Sans',sans-serif;font-size:12px;font-weight:500;cursor:pointer;border:none;transition:all .15s}
.btn-s{background:var(--pan2);color:var(--pt)}
.btn-s:hover{background:var(--divc)}
.btn-a{background:var(--acc);color:#fff}
.btn-a:hover{background:var(--acc2)}
.btn-d{background:rgba(232,93,74,.12);color:#E85D4A}
.btn-d:hover{background:rgba(232,93,74,.22)}
/* category swatches */
.cat-sw{display:flex;flex-wrap:wrap;gap:6px}
.csw{display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:8px;border:1.5px solid var(--divc);cursor:pointer;font-size:12px;background:#fff;color:var(--pt);transition:all .12s;user-select:none}
.csw:hover{border-color:#aaa}
.csw.sel{border-color:var(--pt);font-weight:600}
.csw .dot{width:9px;height:9px;border-radius:50%;flex-shrink:0}
/* recurring toggle */
.rec-tog{display:flex;border:1.5px solid var(--divc);border-radius:9px;overflow:hidden;background:#fff}
.rec-tog button{flex:1;padding:8px 4px;border:none;background:none;font-size:11px;color:var(--pm);cursor:pointer;transition:all .12s;border-right:1px solid var(--divc);white-space:nowrap}
.rec-tog button:last-child{border-right:none}
.rec-tog button.sel{background:var(--pt);color:#fff;font-weight:500}
/* day-of-week circles */
.dow-row{display:flex;gap:5px;flex-wrap:wrap;margin-top:4px}
.dcircle{width:34px;height:34px;border-radius:50%;border:1.5px solid var(--divc);background:#fff;font-size:11px;font-weight:600;cursor:pointer;color:var(--pm);transition:all .12px;display:flex;align-items:center;justify-content:center;user-select:none}
.dcircle:hover{border-color:#999;color:var(--pt)}
.dcircle.sel{background:var(--pt);border-color:var(--pt);color:#fff}
/* cut preview */
.cut-prev{display:flex;gap:8px;margin-top:10px;flex-wrap:wrap}
.cut-p{flex:1;min-width:70px;background:#fff;border:1px solid var(--divc);border-radius:8px;padding:9px;text-align:center}
.cut-pn{font-weight:600;font-size:11px;color:var(--pt)}
.cut-pd{font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm);margin-top:3px}
.cut-pi{font-size:9px;color:var(--pm);margin-top:3px}
/* code output */
.code-out{background:#111;border:1px solid #2a2926;border-radius:8px;padding:11px;font-family:'JetBrains Mono',monospace;font-size:10px;color:#88b;word-break:break-all;max-height:120px;overflow-y:auto;margin-top:8px}
/* keyboard shortcuts modal */
.kkeys{display:grid;grid-template-columns:auto 1fr;gap:6px 16px;margin-top:4px}
.kk{font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--pt)}
kbd{display:inline-block;background:var(--pan2);border:1px solid var(--divc);border-radius:4px;padding:1px 6px;font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pt)}
.kd{font-size:12px;color:var(--pm)}
/* context menu */
#evmenu{position:fixed;background:#141412;border:1px solid #2a2926;border-radius:10px;padding:5px;z-index:2000;box-shadow:var(--sh2);min-width:172px;display:none}
.mi{display:flex;align-items:center;gap:9px;padding:7px 11px;border-radius:6px;cursor:pointer;font-size:12px;color:#bbb;transition:all .1s}
.mi:hover{background:#222;color:#fff}
.mi.dg{color:#E85D4A}
.mi.dg:hover{background:rgba(232,93,74,.12)}
.mi.ok{color:#5AAD8C}
.mi.ok:hover{background:rgba(90,173,140,.1)}
.mi-i{font-size:13px;width:16px;text-align:center}
.msp{height:1px;background:#2a2926;margin:4px 0}
/* ghost */
#ghost{position:fixed;pointer-events:none;z-index:9999;display:none;opacity:.9;transform:rotate(2deg) scale(.92);background:#141412;border-radius:10px;padding:9px 13px;box-shadow:var(--sh2);max-width:220px;border-left:4px solid #888}
#gn{font-size:12px;font-weight:500;color:#fff}
#gd{font-family:'JetBrains Mono',monospace;font-size:9px;color:rgba(255,255,255,.4);margin-top:2px}
/* toasts */
#toasts{position:fixed;bottom:22px;right:22px;z-index:9990;display:flex;flex-direction:column;gap:8px;pointer-events:none}
.toast{background:#1c1b18;border:1px solid #2a2926;border-radius:9px;padding:9px 14px;font-size:12px;color:#bbb;font-family:'DM Sans',sans-serif;transform:translateX(130%);transition:transform .28s cubic-bezier(.34,1.3,.64,1);box-shadow:0 4px 22px rgba(0,0,0,.45);max-width:240px;line-height:1.4}
.toast.show{transform:translateX(0)}
.toast.ok{border-color:rgba(90,173,140,.35);color:#5AAD8C}
.toast.warn{border-color:rgba(242,160,40,.3);color:#F2A028}
.toast.err{border-color:rgba(232,93,74,.35);color:#E85D4A}
/* print */
@media print{
*{-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important}
body.printing #calb{overflow:visible!important;height:auto!important}
#tb,#taskp,#vdiv,#ghost,#evmenu,#trz,#toasts,.ov{display:none!important}
html,body{height:auto!important;overflow:visible!important;background:#fff!important}
#main{height:auto!important;overflow:visible!important}
#calp{flex:1!important;width:100%!important;background:#fff!important;overflow:visible!important}
#calb{overflow:visible!important;height:auto!important}
#calgrid{overflow:visible!important}
.dh-n{color:#999!important}.dh-d{color:#333!important}.tl span{color:#aaa!important}
.hrow,.dcol,.dh,#calh{border-color:#ddd!important}
.hrow::after{border-color:#eee!important;border-bottom-style:dotted!important}
.eb{box-shadow:none!important;border:1px solid rgba(0,0,0,.1)!important}
.eb-rsz{display:none!important}
.nwl,.draw-preview{display:none!important}
.dh-bar{display:none!important}
#calh{background:#fff!important;border-bottom:1px solid #ccc!important}
}
</style>
</head>
<body>
<!-- SMALL SCREEN BANNER -->
<div id="smallscreen">
<div id="ss-card">
<div id="ss-logo">Chron<em>os</em></div>
<div id="ss-title">Not available on this device</div>
<div id="ss-msg">Chronos by Aleksei Avgustin is designed for desktop use and requires a screen wider than 768px. Please open it on a laptop or desktop computer.</div>
<div id="ss-email">Alekseiavgustin25@gmail.com</div>
</div>
</div>
<div id="tb">
<div class="tb-l">
<div class="logo">Chron<em>os</em></div>
<div class="vsep"></div>
<input class="proj" id="projName" placeholder="PROJECT" value="MY SCHEDULE">
<div class="vsep"></div>
<button class="xbtn" id="undoBtn" title="Undo (Ctrl+Z)" onclick="undo()">↩ Undo</button>
<button class="xbtn" id="redoBtn" title="Redo (Ctrl+Y)" onclick="redo()">↪ Redo</button>
<div class="vsep"></div>
<button class="xbtn xbtn-new" onclick="confirmNew()" title="Start a fresh schedule">✦ New</button>
<div class="vsep"></div>
<button class="xbtn" id="saveBtn">💾 Save</button>
<button class="xbtn" id="loadBtn">📂 Load</button>
<button class="xbtn" id="icsBtn">📅 Apple Cal</button>
<button class="xbtn" id="pdfBtn">📄 PDF</button>
<button class="xbtn" onclick="openM('modKeys')" title="Keyboard shortcuts (?)">⌨</button>
<button class="xbtn" onclick="openM('modTut')" title="Quick tutorial">? Tutorial</button>
<button class="xbtn" onclick="openAI()" title="AI assistant guide" style="color:#7B6DD9;border-color:rgba(123,109,217,.35)">✦ AI</button>
</div>
<div class="tb-r">
<button class="todaybtn" id="todayBtn" title="Jump to today (T)">Today</button>
<button class="arr" id="prevW" title="Previous week (←)">‹</button>
<span id="wlabel"></span>
<button class="arr" id="nextW" title="Next week (→)">›</button>
<div class="wtog">
<button id="w1btn" onclick="setWV(1)">W1</button>
<button id="w2btn" onclick="setWV(2)">W2</button>
</div>
</div>
</div>
<div id="main">
<div id="calp">
<div id="calh"><div class="tgut"></div></div>
<div id="calb">
<div id="calgrid">
<div id="tlabs"></div>
<div id="dcols"></div>
</div>
</div>
</div>
<div id="vdiv" title="Drag to resize"></div>
<div id="taskp">
<div id="trz"><div id="trz-top"><div class="ti">↩</div><div class="tl2">Return to tasks</div></div><div id="trz-bot"><div class="ti">🗑</div><div class="tl2">Delete</div></div></div>
<div class="ptabs">
<button class="ptab on" onclick="switchTab('tasks',this)">Tasks</button>
<button class="ptab" onclick="switchTab('outline',this)">Outline</button>
<button class="ptab" onclick="switchTab('stats',this)">Stats</button>
</div>
<div id="tabtasks">
<div id="tlist"></div>
<div id="addarea">
<button id="addbtn" onclick="openAdd()"><span class="plus">+</span> Add task...</button>
<button id="clearbtn" onclick="confirmClearTasks()" title="Clear all tasks">
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><polyline points="1,3 13,3"/><path d="M4,3V2h6v1"/><path d="M2,3l1,9a1,1,0,0,0,1,1h6a1,1,0,0,0,1-1l1-9"/><line x1="5" y1="6" x2="5" y2="10"/><line x1="9" y1="6" x2="9" y2="10"/></svg>
</button>
<button id="bulkbtn" onclick="openBulk()" title="Add multiple tasks at once">
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round">
<line x1="3" y1="4" x2="13" y2="4"/><line x1="3" y1="8" x2="13" y2="8"/><line x1="3" y1="12" x2="10" y2="12"/>
</svg>
</button>
</div>
</div>
<div id="tabout"></div>
<div id="tabstats"></div>
</div>
</div>
<div id="ghost"><div id="gn"></div><div id="gd"></div></div>
<div id="toasts"></div>
<div id="evmenu">
<div class="mi" onclick="mAct('edit')"><span class="mi-i">✏️</span> Edit</div>
<div class="mi" onclick="mAct('dup')"><span class="mi-i">⎘</span> Duplicate</div>
<div class="mi ok" onclick="mAct('done')"><span class="mi-i" id="doneic">✓</span><span id="donetx"> Mark done</span></div>
<div class="mi" onclick="mAct('lock')"><span class="mi-i" id="lkic">🔒</span><span id="lktx"> Lock</span></div>
<div class="msp"></div>
<div class="mi dg" onclick="mAct('del')"><span class="mi-i">🗑</span> Remove</div>
</div>
<!-- HOUR RANGE MODAL -->
<div class="ov" id="modHr">
<div class="modal" style="width:340px">
<h2>Calendar Hours</h2>
<p class="modal-sub">Set which hours are visible on the calendar grid.</p>
<div class="frow">
<div class="fg">
<label class="fl">Start hour</label>
<select class="fi" id="hrStart" style="cursor:pointer"></select>
</div>
<div class="fg">
<label class="fl">End hour</label>
<select class="fi" id="hrEnd" style="cursor:pointer"></select>
</div>
</div>
<p id="hrPreview" style="font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--pm);margin-top:-6px;margin-bottom:4px"></p>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modHr')">Cancel</button>
<button class="btn btn-a" onclick="saveHrRange()">Apply</button>
</div>
</div>
</div>
<!-- CLEAR TASKS CONFIRM MODAL -->
<div class="ov" id="modClearTasks">
<div class="modal" style="width:360px">
<h2>Clear All Tasks</h2>
<p class="modal-sub">This will remove all tasks from the task list. Events already placed on the calendar will stay. This action can be undone with Ctrl+Z.</p>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modClearTasks')">Cancel</button>
<button class="btn btn-d" onclick="doClearTasks()">Clear all tasks</button>
</div>
</div>
</div>
<!-- TUTORIAL MODAL -->
<div class="ov" id="modTut">
<div class="modal" style="width:520px;max-height:88vh">
<h2>Welcome to Chronos</h2>
<p class="modal-sub" style="margin-bottom:20px">A quick walkthrough of the key features.</p>
<div style="display:flex;flex-direction:column;gap:18px;font-size:13px;line-height:1.6;color:var(--pt)">
<div style="display:flex;gap:14px;align-items:flex-start">
<div style="font-size:24px;flex-shrink:0;margin-top:2px">📋</div>
<div>
<div style="font-weight:600;margin-bottom:3px">Create tasks on the right</div>
<div style="color:var(--pm)">Hit <kbd>N</kbd> or the <strong>+ Add task</strong> button. Set a name, duration, category, and optionally a recurring schedule (weekly or every 2 weeks on specific days).</div>
</div>
</div>
<div style="display:flex;gap:14px;align-items:flex-start">
<div style="font-size:24px;flex-shrink:0;margin-top:2px">🖱</div>
<div>
<div style="font-weight:600;margin-bottom:3px">Drag tasks onto the calendar</div>
<div style="color:var(--pm)">Drag any task card from the right panel onto an empty time slot on the left. The drop preview shows the exact time. A red outline means a conflict — find a free slot.</div>
</div>
</div>
<div style="display:flex;gap:14px;align-items:flex-start">
<div style="font-size:24px;flex-shrink:0;margin-top:2px">✏️</div>
<div>
<div style="font-weight:600;margin-bottom:3px">Draw events directly on the calendar</div>
<div style="color:var(--pm)">Click and drag downward on any empty calendar space to draw a new event. A quick-create dialog will pop up when you release.</div>
</div>
</div>
<div style="display:flex;gap:14px;align-items:flex-start">
<div style="font-size:24px;flex-shrink:0;margin-top:2px">⚙️</div>
<div>
<div style="font-weight:600;margin-bottom:3px">Edit & manage events</div>
<div style="color:var(--pm)"><strong>Double-click</strong> an event to edit its name, time, category, and notes. <strong>Right-click</strong> for a context menu with duplicate, lock, mark done, and remove.</div>
</div>
</div>
<div style="display:flex;gap:14px;align-items:flex-start">
<div style="font-size:24px;flex-shrink:0;margin-top:2px">↩</div>
<div>
<div style="font-weight:600;margin-bottom:3px">Move & remove events</div>
<div style="color:var(--pm)">Drag events to reposition them. Resize by dragging the bottom edge. To remove, drag an event to the right panel — the <strong>top zone</strong> returns it to the task list; the <strong>bottom zone</strong> deletes it.</div>
</div>
</div>
<div style="display:flex;gap:14px;align-items:flex-start">
<div style="font-size:24px;flex-shrink:0;margin-top:2px">🔄</div>
<div>
<div style="font-weight:600;margin-bottom:3px">Recurring events & biweekly view</div>
<div style="color:var(--pm)">Tasks can repeat every week or every 2 weeks on chosen days. Use <strong>W1 / W2</strong> in the top-right to toggle which biweekly group is visible.</div>
</div>
</div>
<div style="display:flex;gap:14px;align-items:flex-start">
<div style="font-size:24px;flex-shrink:0;margin-top:2px">💾</div>
<div>
<div style="font-weight:600;margin-bottom:3px">Save & export</div>
<div style="color:var(--pm)"><strong>Save</strong> produces a code you can paste back into Load on any device. <strong>Apple Cal</strong> exports a date-range .ics file for import into any calendar app. <strong>PDF</strong> opens a print-ready view.</div>
</div>
</div>
<div style="display:flex;gap:14px;align-items:flex-start">
<div style="font-size:24px;flex-shrink:0;margin-top:2px">📊</div>
<div>
<div style="font-weight:600;margin-bottom:3px">Stats tab</div>
<div style="color:var(--pm)">See hours by category and by day. Adjust your daily hour target (changes the bar under each date). Manage custom categories. Set calendar display hours.</div>
</div>
</div>
<div style="background:var(--pan2);border-radius:10px;padding:12px 14px;font-size:11px;color:var(--pm);line-height:1.7">
<strong style="color:var(--pt)">Keyboard shortcuts:</strong>
<kbd>N</kbd> new task ·
<kbd>L</kbd> bulk import ·
<kbd>T</kbd> today ·
<kbd>←</kbd><kbd>→</kbd> weeks ·
<kbd>Ctrl+Z</kbd> undo ·
<kbd>?</kbd> shortcuts
</div>
</div>
<div class="fact" style="margin-top:22px">
<button class="btn btn-a" onclick="closeM('modTut')" style="width:100%">Got it — let me schedule!</button>
</div>
</div>
</div>
<!-- AI ASSISTANT MODAL -->
<div class="ov" id="modAI">
<div class="modal" style="width:560px;max-height:92vh">
<h2 style="display:flex;align-items:center;gap:10px">
<span style="background:linear-gradient(135deg,#7B6DD9,#4A8DEF);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text">✦ AI Assistant</span>
</h2>
<!-- Tabs -->
<div style="display:flex;gap:0;border-bottom:1px solid var(--divc);margin-bottom:18px">
<button class="ai-tab on" onclick="switchAITab('guide',this)" style="flex:1;padding:9px 6px;background:none;border:none;font-size:11px;font-weight:500;color:var(--pt);cursor:pointer;border-bottom:2px solid var(--pt);letter-spacing:.3px;text-transform:uppercase">Guide</button>
<button class="ai-tab" onclick="switchAITab('prompt',this)" style="flex:1;padding:9px 6px;background:none;border:none;font-size:11px;font-weight:500;color:var(--pm);cursor:pointer;border-bottom:2px solid transparent;letter-spacing:.3px;text-transform:uppercase">AI Prompt</button>
<button class="ai-tab" onclick="switchAITab('schedule',this)" style="flex:1;padding:9px 6px;background:none;border:none;font-size:11px;font-weight:500;color:var(--pm);cursor:pointer;border-bottom:2px solid transparent;letter-spacing:.3px;text-transform:uppercase">Share Schedule</button>
</div>
<!-- Guide Tab -->
<div id="aiTabGuide" style="display:flex;flex-direction:column;gap:14px;font-size:13px;line-height:1.6;color:var(--pt)">
<div style="background:rgba(123,109,217,.1);border:1px solid rgba(123,109,217,.25);border-radius:10px;padding:14px 16px">
<div style="font-weight:600;margin-bottom:6px;color:#7B6DD9">🤖 Works best with Claude</div>
<div style="font-size:12px;color:var(--pm);line-height:1.6">Chronos was built with Claude AI and the prompt format is optimised for it. Claude understands the bulk format perfectly and can analyse your pasted schedule. Any LLM works, but Claude gives the best results.</div>
</div>
<div>
<div style="font-weight:600;margin-bottom:8px">What AI can do for you:</div>
<div style="display:flex;flex-direction:column;gap:8px">
<div style="display:flex;gap:10px;align-items:flex-start">
<span style="font-size:16px;flex-shrink:0">📝</span>
<div><strong>Generate task lists</strong> — describe your week or goals, ask the AI to format them as Chronos bulk import text. Copy and paste straight into the <em>List (⋮)</em> button.</div>
</div>
<div style="display:flex;gap:10px;align-items:flex-start">
<span style="font-size:16px;flex-shrink:0">📊</span>
<div><strong>Analyse your schedule</strong> — paste your saved schedule code (from the <em>Share Schedule</em> tab) into a chat and ask AI to review it for balance, overload, or missing tasks.</div>
</div>
<div style="display:flex;gap:10px;align-items:flex-start">
<span style="font-size:16px;flex-shrink:0">🔄</span>
<div><strong>Optimise & reschedule</strong> — paste your schedule, explain constraints ("I need 2h focus time every morning"), and ask the AI to suggest a revised task list you can re-import.</div>
</div>
<div style="display:flex;gap:10px;align-items:flex-start">
<span style="font-size:16px;flex-shrink:0">💡</span>
<div><strong>Estimate durations</strong> — list your projects and ask AI to estimate realistic time blocks, then format them for import.</div>
</div>
</div>
</div>
<div style="background:var(--pan2);border-radius:10px;padding:12px 14px;font-size:11px;color:var(--pm);line-height:1.7">
<strong style="color:var(--pt)">Workflow tip:</strong> Open Claude at <a href="https://claude.ai" target="_blank" style="color:var(--acc)">claude.ai</a> side-by-side with Chronos. Paste the AI Prompt once to set context, then have a back-and-forth conversation to refine your schedule — import new lists as you iterate.
</div>
</div>
<!-- AI Prompt Tab -->
<div id="aiTabPrompt" style="display:none">
<p style="font-size:12px;color:var(--pm);margin-bottom:12px;line-height:1.5">Copy this prompt into any AI assistant (Claude recommended). It teaches the AI exactly how Chronos works so it can generate task lists you can import directly, and understand schedules you share with it.</p>
<div style="position:relative">
<textarea id="aiPromptText" readonly style="width:100%;height:240px;background:#0f0f0e;border:1px solid var(--cln);border-radius:8px;padding:12px 14px;font-family:'JetBrains Mono',monospace;font-size:10px;color:#d0cfc8;line-height:1.7;resize:none;outline:none;caret-color:var(--acc)"></textarea>
</div>
<div style="display:flex;gap:8px;margin-top:10px">
<button class="btn btn-a" onclick="copyAIPrompt()" style="flex:1">⎘ Copy prompt to clipboard</button>
<a href="https://claude.ai" target="_blank" class="btn btn-s" style="display:flex;align-items:center;gap:6px;text-decoration:none;font-size:12px;font-weight:500">Open Claude ↗</a>
</div>
<p style="font-size:10px;color:var(--pm);margin-top:8px;line-height:1.5">After pasting the prompt, describe your goals or paste your schedule. Ask for a task list and import it via the <kbd>L</kbd> button or the list icon in the task panel.</p>
</div>
<!-- Share Schedule Tab -->
<div id="aiTabSchedule" style="display:none">
<p style="font-size:12px;color:var(--pm);margin-bottom:12px;line-height:1.5">Copy your current schedule as readable text to share with AI for analysis, or paste the save code for full fidelity.</p>
<div style="margin-bottom:10px">
<label class="fl" style="margin-bottom:5px">Human-readable schedule (for pasting into chat)</label>
<textarea id="aiScheduleText" readonly style="width:100%;height:180px;background:#0f0f0e;border:1px solid var(--cln);border-radius:8px;padding:12px 14px;font-family:'JetBrains Mono',monospace;font-size:10px;color:#d0cfc8;line-height:1.7;resize:none;outline:none"></textarea>
</div>
<div style="display:flex;gap:8px">
<button class="btn btn-a" onclick="copyScheduleText()" style="flex:1">⎘ Copy readable schedule</button>
<button class="btn btn-s" onclick="refreshScheduleText()" style="font-size:12px">↻ Refresh</button>
</div>
<p style="font-size:10px;color:var(--pm);margin-top:8px;line-height:1.5">Paste this into Claude along with the AI Prompt (first tab) to get analysis, suggestions, and new task lists to import back.</p>
</div>
<div class="fact" style="margin-top:16px">
<button class="btn btn-s" onclick="closeM('modAI')">Close</button>
</div>
</div>
</div>
<!-- TASK / EVENT MODAL -->
<div class="ov" id="modTask">
<div class="modal">
<h2 id="modTitle">New Task</h2>
<input type="hidden" id="editId">
<div class="fg">
<label class="fl">Name</label>
<input type="text" class="fi" id="tName" placeholder="e.g. Deep work session" autocomplete="off">
</div>
<!-- TIME SECTION: only shown when editing a placed event -->
<div id="evTimeFg" style="display:none">
<div class="frow" style="margin-bottom:0">
<div class="fg">
<label class="fl">Start time</label>
<div style="display:flex;align-items:center;gap:6px">
<input type="number" class="fi" id="evStartH" min="0" max="23" style="width:62px" oninput="syncEvTime()">
<span class="dur-sep">:</span>
<input type="number" class="fi" id="evStartM" min="0" max="59" step="15" style="width:62px" oninput="syncEvTime()">
</div>
</div>
<div class="fg">
<label class="fl">End time</label>
<div style="display:flex;align-items:center;gap:6px">
<input type="number" class="fi" id="evEndH" min="0" max="23" style="width:62px" oninput="syncEvTimeFromEnd()">
<span class="dur-sep">:</span>
<input type="number" class="fi" id="evEndM" min="0" max="59" step="15" style="width:62px" oninput="syncEvTimeFromEnd()">
</div>
</div>
</div>
<p id="evTimeSummary" style="font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm);margin-top:6px;margin-bottom:14px"></p>
</div>
<div class="frow">
<div class="fg">
<label class="fl" id="durLabel">Duration</label>
<div class="dur-row">
<input type="number" class="fi" id="tH" min="0" max="23" value="1" style="width:62px" oninput="syncDurFromFields()">
<span class="dur-sep">h</span>
<input type="number" class="fi" id="tM" min="0" max="59" step="15" value="0" style="width:62px" oninput="syncDurFromFields()">
<span class="dur-sep">m</span>
</div>
</div>
</div>
<div class="fg">
<label class="fl">Category</label>
<div class="cat-sw" id="catSw"></div>
</div>
<div class="fg">
<label class="fl">Notes <span style="font-weight:400;letter-spacing:0;text-transform:none;font-size:9px">(optional)</span></label>
<textarea class="fi" id="tNotes" rows="2" placeholder="Add details…" style="resize:vertical;min-height:60px"></textarea>
</div>
<div class="fg">
<label class="fl">Repeats</label>
<div class="rec-tog">
<button data-v="" onclick="setRec(this)">Once</button>
<button data-v="weekly" onclick="setRec(this)">Every week</button>
<button data-v="biweekly" onclick="setRec(this)">Every 2 wks</button>
</div>
</div>
<div class="fg" id="dowFg" style="display:none">
<label class="fl">On which days</label>
<div class="dow-row" id="dowRow"></div>
<p style="font-size:10px;color:var(--pm);margin-top:6px;line-height:1.4">Once placed on the calendar, each day's time can be adjusted independently by dragging.</p>
</div>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modTask')">Cancel</button>
<button class="btn btn-a" onclick="saveForm()">Save</button>
</div>
</div>
</div>
<!-- NEW / RESET MODAL -->
<div class="ov" id="modNew">
<div class="modal">
<h2>Start Over</h2>
<p class="modal-sub">This will clear all tasks and events. Your current schedule will be lost unless you saved it first.</p>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modNew')">Cancel</button>
<button class="btn btn-a" onclick="doNew()">Start fresh</button>
</div>
</div>
</div>
<!-- QUICK CREATE MODAL (draw on calendar) -->
<div class="ov" id="modQuick">
<div class="modal">
<h2 id="qcTitle">New Event</h2>
<input type="hidden" id="qcDay">
<input type="hidden" id="qcStart">
<input type="hidden" id="qcDur">
<div class="fg">
<label class="fl">Name</label>
<input type="text" class="fi" id="qcName" placeholder="Event name…" autocomplete="off">
</div>
<div class="fg">
<label class="fl">Category</label>
<div class="cat-sw" id="qcCatSw"></div>
</div>
<div class="fg">
<label class="fl">Time & Duration</label>
<p id="qcTimeLabel" style="font-family:'JetBrains Mono',monospace;font-size:12px;color:var(--pt);background:#fff;border:1px solid var(--divc);border-radius:8px;padding:9px 13px"></p>
</div>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modQuick')">Cancel</button>
<button class="btn btn-a" onclick="saveQuick()">Add to calendar</button>
</div>
</div>
</div>
<!-- CATEGORY EDIT MODAL -->
<div class="ov" id="modCatEdit">
<div class="modal">
<h2 id="catEditTitle">New Category</h2>
<div class="fg">
<label class="fl">Name</label>
<input type="text" class="fi" id="catEditName" placeholder="e.g. Exercise" maxlength="24" autocomplete="off">
</div>
<div class="fg">
<label class="fl">Color — presets</label>
<div class="cat-color-grid" id="catEditColors"></div>
</div>
<div class="fg">
<label class="fl">Or custom hex</label>
<input type="text" class="fi" id="catEditHex" placeholder="#RRGGBB" maxlength="7" spellcheck="false"
oninput="this.style.borderColor=/^#[0-9a-fA-F]{6}$/.test(this.value.trim())?this.value.trim():'var(--divc)'">
</div>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modCatEdit')">Cancel</button>
<button class="btn btn-a" onclick="saveCatEdit()">Save</button>
</div>
</div>
</div>
<!-- ICS EXPORT MODAL -->
<div class="ov" id="modICS">
<div class="modal">
<h2>Export to Apple Calendar</h2>
<p class="modal-sub">Set the date range. Recurring events expand into individual occurrences.</p>
<div class="frow">
<div class="fg">
<label class="fl">Start date (W1 begins)</label>
<input type="date" class="fi" id="icsStart">
</div>
<div class="fg">
<label class="fl">End date</label>
<input type="date" class="fi" id="icsEnd">
</div>
</div>
<div class="fg">
<label class="fl">Quick range</label>
<div style="display:flex;flex-wrap:wrap;gap:6px">
<button class="btn btn-s" style="font-size:11px;padding:6px 11px" onclick="icsSetRange(4)">4 weeks</button>
<button class="btn btn-s" style="font-size:11px;padding:6px 11px" onclick="icsSetRange(8)">2 months</button>
<button class="btn btn-s" style="font-size:11px;padding:6px 11px" onclick="icsSetRange(13)">3 months</button>
<button class="btn btn-s" style="font-size:11px;padding:6px 11px" onclick="icsSetRange(26)">6 months</button>
<button class="btn btn-s" style="font-size:11px;padding:6px 11px" onclick="icsSetRange(52)">1 year</button>
</div>
</div>
<div class="fg">
<label class="fl">Calendar name</label>
<input type="text" class="fi" id="icsCalName" placeholder="My Schedule">
</div>
<p style="font-size:10px;color:var(--pm);line-height:1.5">
Biweekly events assigned to <b>W1</b> appear on weeks 1,3,5… from start date; <b>W2</b> on weeks 2,4,6…
</p>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modICS')">Cancel</button>
<button class="btn btn-a" onclick="doExportICS()">Download .ics</button>
</div>
</div>
</div>
<!-- DAILY GOAL MODAL -->
<div class="ov" id="modGoal">
<div class="modal" style="width:340px">
<h2>Daily Target Hours</h2>
<p class="modal-sub">This controls the fill bar below each day's date in the calendar header.</p>
<div style="display:flex;align-items:center;gap:12px;margin:4px 0 16px">
<input type="range" id="goalPopSlider" min="1" max="16" value="8" step="0.5"
style="flex:1;accent-color:var(--acc);cursor:pointer"
oninput="document.getElementById('goalPopVal').textContent=this.value+'h'">
<span id="goalPopVal" style="font-family:'JetBrains Mono',monospace;font-size:18px;color:var(--pt);min-width:40px;text-align:right;font-weight:600">8h</span>
</div>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modGoal')">Cancel</button>
<button class="btn btn-a" onclick="saveGoal()">Apply</button>
</div>
</div>
</div>
<div class="ov" id="modBulk">
<div class="modal" style="width:500px">
<h2>Add a List of Tasks</h2>
<!-- FORMAT HINT -->
<div id="bulkFmtToggle" onclick="const f=document.getElementById('bulkFmt');f.classList.toggle('open');document.getElementById('bulkFmtArrow').style.transform=f.classList.contains('open')?'rotate(90deg)':''"
style="cursor:pointer;user-select:none;display:flex;align-items:center;gap:7px;font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm);text-transform:uppercase;letter-spacing:.8px;margin-bottom:10px">
<span id="bulkFmtArrow" style="font-size:12px;transition:transform .18s">▶</span> Format guide
</div>
<div id="bulkFmt" style="background:var(--pan2);border-radius:10px;padding:14px 16px;margin-bottom:14px;font-size:12px;line-height:1.7;color:var(--pt)">
<div style="font-family:'JetBrains Mono',monospace;font-size:10px;color:var(--pm);letter-spacing:.5px;margin-bottom:8px;text-transform:uppercase">One task per line — fields separated by commas:</div>
<div style="font-family:'JetBrains Mono',monospace;font-size:11px;color:var(--pt);background:#fff;border-radius:7px;padding:10px 12px;border:1px solid var(--divc);line-height:2">
<span style="color:var(--acc)">Name</span><span style="color:var(--pm)">, </span><span style="color:#7B6DD9">duration</span><span style="color:var(--pm)">, </span><span style="color:#5AAD8C">category</span><span style="color:var(--pm)">, </span><span style="color:#4A8DEF">repeat</span><br>
<span style="color:var(--pm);font-size:9px">examples:</span><br>
<span style="color:var(--pt)">Morning run, 45m, Health</span><br>
<span style="color:var(--pt)">Deep work, 2h, Work, weekly, Mon Wed Fri</span><br>
<span style="color:var(--pt)">Team sync, 30m, Work, biweekly, Mon Wed</span><br>
<span style="color:var(--pt)">Read, 1h 30m</span>
</div>
<div style="margin-top:10px;font-size:11px;color:var(--pm);line-height:1.6">
<b style="color:var(--pt)">Duration:</b> <code style="background:#fff;padding:1px 5px;border-radius:4px;border:1px solid var(--divc)">45m</code> <code style="background:#fff;padding:1px 5px;border-radius:4px;border:1px solid var(--divc)">2h</code> <code style="background:#fff;padding:1px 5px;border-radius:4px;border:1px solid var(--divc)">1h 30m</code> <code style="background:#fff;padding:1px 5px;border-radius:4px;border:1px solid var(--divc)">90</code> (minutes)<br>
<b style="color:var(--pt)">Category:</b> Work · Personal · Health · Social · Learning · Other (or any custom)<br>
<b style="color:var(--pt)">Repeat:</b> <code style="background:#fff;padding:1px 5px;border-radius:4px;border:1px solid var(--divc)">weekly</code> or <code style="background:#fff;padding:1px 5px;border-radius:4px;border:1px solid var(--divc)">biweekly</code> — then day names (Mon, Tue, Wed…)
</div>
</div>
<!-- INPUT -->
<div class="fg">
<label class="fl">Your tasks</label>
<textarea class="fi" id="bulkInput" rows="9" placeholder="Morning run, 45m, Health Deep work, 2h, Work, weekly, Mon Wed Fri Team sync, 30m, Work, biweekly, Mon Read, 1h 30m" style="font-family:'JetBrains Mono',monospace;font-size:12px;line-height:1.7;resize:vertical;min-height:180px"></textarea>
</div>
<!-- PREVIEW -->
<div id="bulkPreview" style="display:none;margin-bottom:14px">
<div class="fl" style="margin-bottom:6px">Preview <span id="bulkCount" style="font-weight:400;color:var(--pm)"></span></div>
<div id="bulkPreviewList" style="display:flex;flex-direction:column;gap:5px;max-height:160px;overflow-y:auto"></div>
</div>
<div id="bulkErrors" style="display:none;background:rgba(232,93,74,.08);border:1px solid rgba(232,93,74,.25);border-radius:8px;padding:10px 12px;font-size:11px;color:#E85D4A;line-height:1.6;margin-bottom:10px;font-family:'JetBrains Mono',monospace"></div>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modBulk')">Cancel</button>
<button class="btn btn-a" id="bulkAddBtn" onclick="bulkCommit()" style="opacity:.35;cursor:not-allowed">Add tasks</button>
</div>
</div>
</div>
<!-- CUT MODAL -->
<div class="ov" id="modCut">
<div class="modal">
<h2>Cut Task</h2>
<p class="modal-sub">Split into equal parts to schedule separately. Parts inherit the recurring schedule.</p>
<input type="hidden" id="cutId">
<div class="fg">
<label class="fl">Parts</label>
<select class="fi" id="cutN" onchange="updCutPrev()" style="cursor:pointer">
<option value="2">2 parts</option>
<option value="3">3 parts</option>
<option value="4">4 parts</option>
</select>
</div>
<div class="cut-prev" id="cutPrev"></div>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modCut')">Cancel</button>
<button class="btn btn-a" onclick="doCut()">Cut</button>
</div>
</div>
</div>
<!-- DELETE RECURRING MODAL -->
<div class="ov" id="modDelRec">
<div class="modal">
<h2>Remove Event</h2>
<p class="modal-sub" id="delRecMsg"></p>
<input type="hidden" id="delRecEid">
<div class="fact">
<button class="btn btn-s" onclick="closeM('modDelRec')">Cancel</button>
<button class="btn btn-d" onclick="delRecThis()">This occurrence only</button>
<button class="btn btn-d" onclick="delRecAll()">All occurrences</button>
</div>
</div>
</div>
<!-- SAVE MODAL -->
<div class="ov" id="modSave">
<div class="modal">
<h2>Save Schedule</h2>
<p class="modal-sub">Copy this code. Paste it into Load to restore your schedule on any device.</p>
<div class="code-out" id="codeOut"></div>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modSave')">Close</button>
<button class="btn btn-a" id="copyBtn" onclick="copyCode()">Copy to clipboard</button>
</div>
</div>
</div>
<!-- LOAD MODAL -->
<div class="ov" id="modLoad">
<div class="modal">
<h2>Load Schedule</h2>
<p class="modal-sub">Paste your saved code below. This replaces the current schedule.</p>
<textarea class="fi" id="loadIn" rows="5" placeholder="Paste code here…"></textarea>
<div class="fact">
<button class="btn btn-s" onclick="closeM('modLoad')">Cancel</button>
<button class="btn btn-a" onclick="doLoad()">Load</button>
</div>
</div>
</div>
<!-- KEYBOARD SHORTCUTS MODAL -->
<div class="ov" id="modKeys">
<div class="modal">
<h2>Keyboard Shortcuts</h2>
<div class="kkeys">
<div class="kk"><kbd>←</kbd> <kbd>→</kbd></div><div class="kd">Navigate weeks</div>
<div class="kk"><kbd>T</kbd></div><div class="kd">Jump to today</div>
<div class="kk"><kbd>Ctrl</kbd>+<kbd>Z</kbd></div><div class="kd">Undo last action</div>
<div class="kk"><kbd>Ctrl</kbd>+<kbd>Y</kbd></div><div class="kd">Redo</div>
<div class="kk"><kbd>N</kbd></div><div class="kd">New task</div>
<div class="kk"><kbd>L</kbd></div><div class="kd">Add task list (bulk import)</div>
<div class="kk"><kbd>1</kbd> <kbd>2</kbd></div><div class="kd">Switch W1 / W2 biweekly view</div>
<div class="kk"><kbd>?</kbd></div><div class="kd">Show this help</div>
<div class="kk"><kbd>Dbl-click</kbd></div><div class="kd">Edit event on calendar</div>
<div class="kk"><kbd>Right-click</kbd></div><div class="kd">Event context menu</div>
<div class="kk"><kbd>Drag → right</kbd></div><div class="kd">Remove event from calendar</div>
</div>
<div class="fact"><button class="btn btn-s" onclick="closeM('modKeys')">Close</button></div>
</div>
</div>
<script>
// ── CONSTANTS ──────────────────────────────────────────────────────────────
const HPX=80, SNAP=15, THRESH=5;
let HS=6, HE=24; // adjustable calendar hours
const DAYS=['Mon','Tue','Wed','Thu','Fri','Sat','Sun'];
const MON=['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
let CATS=[
{id:'Work', c:'#4A8DEF'},
{id:'Personal', c:'#D96B8B'},
{id:'Health', c:'#5AAD8C'},
{id:'Social', c:'#F2A028'},
{id:'Learning', c:'#7B6DD9'},
{id:'Other', c:'#E85D4A'},
];
const DEFAULT_CATS=CATS.map(x=>({...x}));
const CC = id => { const ct=CATS.find(x=>x.id===id); if(ct) return ct.c; const oth=CATS.find(x=>x.id==='Other'); return oth?oth.c:'#888'; };
let dayGoalHours = 8; // configurable daily target
let returnToOrigPos = false; // return tasks to original list position
// ── STATE ──────────────────────────────────────────────────────────────────
// Event schema: id, name, cat, dur, notes, locked, done, tid,
// day, startMin, recurring(''/weekly/biweekly),
// recDays(int[]), recPos({dayIdx:startMin}), bwGroup(1|2)
let S={tasks:[],events:[],ws:getMon(new Date()),bwView:1,nid:1};
let drag=null,pDrag=null,resize=null,menuEid=null;
let selCat='Work',selRec='',selDow=[];
let hist=[],fut=[]; // undo/redo stacks