File size: 28,622 Bytes
105b526
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Nexus Command Center</title>
    <!-- Importing FontAwesome for Icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap" rel="stylesheet">
    
    <style>
        /* 
         * MODERN CSS VARIABLES & RESET 
         */
        :root {
            --bg-dark: #0f172a;
            --bg-panel: rgba(30, 41, 59, 0.7);
            --primary: #6366f1; /* Indigo */
            --primary-hover: #4f46e5;
            --accent: #06b6d4; /* Cyan */
            --success: #10b981;
            --danger: #ef4444;
            --text-main: #f8fafc;
            --text-muted: #94a3b8;
            --glass-border: 1px solid rgba(255, 255, 255, 0.1);
            --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
            --radius: 16px;
            --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        }

        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: 'Outfit', sans-serif;
            background-color: var(--bg-dark);
            background-image: 
                radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
                radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.15) 0px, transparent 50%);
            background-attachment: fixed;
            color: var(--text-main);
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            overflow-x: hidden;
        }

        /* 
         * UTILITIES 
         */
        .glass {
            background: var(--bg-panel);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: var(--glass-border);
            box-shadow: var(--shadow);
        }

        .btn {
            border: none;
            outline: none;
            cursor: pointer;
            padding: 0.6rem 1.2rem;
            border-radius: 8px;
            font-weight: 600;
            font-family: inherit;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
        }

        .btn-primary {
            background: linear-gradient(135deg, var(--primary), var(--accent));
            color: white;
        }

        .btn-primary:hover {
            transform: translateY(-2px);
            box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
        }

        .btn-icon {
            background: rgba(255,255,255,0.05);
            color: var(--text-main);
            padding: 0.5rem;
            border-radius: 50%;
        }

        .btn-icon:hover {
            background: rgba(255,255,255,0.15);
            color: var(--accent);
        }

        /* 
         * HEADER 
         */
        header {
            padding: 1rem 2rem;
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: sticky;
            top: 0;
            z-index: 100;
            border-bottom: var(--glass-border);
        }

        .logo {
            font-size: 1.5rem;
            font-weight: 700;
            background: linear-gradient(to right, var(--primary), var(--accent));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            letter-spacing: -0.5px;
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        .header-controls {
            display: flex;
            align-items: center;
            gap: 1.5rem;
        }

        .credit-link {
            font-size: 0.85rem;
            color: var(--text-muted);
            text-decoration: none;
            transition: var(--transition);
        }

        .credit-link:hover {
            color: var(--accent);
        }

        .user-avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 2px solid var(--primary);
            object-fit: cover;
        }

        /* 
         * MAIN LAYOUT 
         */
        main {
            flex: 1;
            padding: 2rem;
            max-width: 1400px;
            margin: 0 auto;
            width: 100%;
            display: grid;
            grid-template-columns: repeat(12, 1fr);
            grid-template-rows: auto auto;
            gap: 1.5rem;
        }

        /* 
         * CARDS & WIDGETS 
         */
        .card {
            padding: 1.5rem;
            border-radius: var(--radius);
            display: flex;
            flex-direction: column;
            position: relative;
            overflow: hidden;
            animation: fadeIn 0.6s ease-out;
        }

        .card-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem;
        }

        .card-title {
            font-size: 1.1rem;
            font-weight: 600;
            color: var(--text-main);
            display: flex;
            align-items: center;
            gap: 0.5rem;
        }

        /* 
         * WIDGET: CLOCK & DATE 
         */
        .widget-welcome {
            grid-column: span 12;
        }

        .welcome-text h1 {
            font-size: 2rem;
            margin-bottom: 0.25rem;
        }
        
        .date-display {
            color: var(--text-muted);
            font-size: 1rem;
        }

        /* 
         * WIDGET: FOCUS TIMER 
         */
        .widget-timer {
            grid-column: span 12;
            md: span 4;
            lg: span 4;
            align-items: center;
            justify-content: center;
            min-height: 300px;
        }

        .timer-circle {
            position: relative;
            width: 200px;
            height: 200px;
        }

        .timer-circle svg {
            transform: rotate(-90deg);
            width: 100%;
            height: 100%;
        }

        .timer-circle circle {
            fill: none;
            stroke-width: 8;
            stroke-linecap: round;
        }

        .circle-bg {
            stroke: rgba(255,255,255,0.05);
        }

        .circle-progress {
            stroke: var(--accent);
            stroke-dasharray: 565; /* 2 * PI * 90 */
            stroke-dashoffset: 0;
            transition: stroke-dashoffset 1s linear;
        }

        .timer-text {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
        }

        .time-display {
            font-size: 2.5rem;
            font-weight: 700;
            font-variant-numeric: tabular-nums;
        }

        .timer-controls {
            margin-top: 1.5rem;
            display: flex;
            gap: 1rem;
        }

        /* 
         * WIDGET: TASKS 
         */
        .widget-tasks {
            grid-column: span 12;
            md: span 8;
            lg: span 5;
            height: 400px;
        }

        .task-input-group {
            display: flex;
            gap: 0.5rem;
            margin-bottom: 1rem;
        }

        .task-input {
            flex: 1;
            background: rgba(0,0,0,0.2);
            border: 1px solid rgba(255,255,255,0.1);
            padding: 0.8rem;
            border-radius: 8px;
            color: white;
            font-family: inherit;
        }

        .task-input:focus {
            outline: none;
            border-color: var(--primary);
        }

        .task-list {
            list-style: none;
            overflow-y: auto;
            flex: 1;
            padding-right: 0.5rem;
        }

        /* Scrollbar styling */
        .task-list::-webkit-scrollbar {
            width: 6px;
        }
        .task-list::-webkit-scrollbar-thumb {
            background: rgba(255,255,255,0.1);
            border-radius: 3px;
        }

        .task-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0.8rem;
            background: rgba(255,255,255,0.03);
            margin-bottom: 0.5rem;
            border-radius: 8px;
            transition: var(--transition);
            border-left: 3px solid transparent;
        }

        .task-item:hover {
            background: rgba(255,255,255,0.06);
            transform: translateX(4px);
        }

        .task-item.completed {
            opacity: 0.5;
            text-decoration: line-through;
            border-left-color: var(--success);
        }

        .task-item.pending {
            border-left-color: var(--accent);
        }

        .task-actions button {
            background: none;
            border: none;
            color: var(--text-muted);
            cursor: pointer;
            padding: 0.4rem;
            transition: color 0.2s;
        }

        .task-actions button:hover {
            color: var(--danger);
        }

        /* 
         * WIDGET: ANALYTICS (CANVAS) 
         */
        .widget-analytics {
            grid-column: span 12;
            lg: span 3;
            height: 300px;
        }

        canvas {
            width: 100%;
            height: 100%;
        }

        /* 
         * WIDGET: QUICK NOTES 
         */
        .widget-notes {
            grid-column: span 12;
            lg: span 6;
            height: 250px;
        }

        .notes-area {
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.2);
            border: 1px solid rgba(255,255,255,0.1);
            border-radius: 8px;
            padding: 1rem;
            color: var(--text-muted);
            font-family: inherit;
            resize: none;
            font-size: 0.95rem;
            line-height: 1.5;
        }

        .notes-area:focus {
            outline: none;
            border-color: var(--primary);
            color: var(--text-main);
        }

        /* 
         * TOAST NOTIFICATION 
         */
        .toast-container {
            position: fixed;
            bottom: 2rem;
            right: 2rem;
            z-index: 1000;
            display: flex;
            flex-direction: column;
            gap: 0.5rem;
        }

        .toast {
            background: var(--bg-panel);
            backdrop-filter: blur(16px);
            border-left: 4px solid var(--accent);
            color: white;
            padding: 1rem 1.5rem;
            border-radius: 8px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            display: flex;
            align-items: center;
            gap: 0.8rem;
            animation: slideIn 0.3s ease-out forwards;
            min-width: 250px;
        }

        .toast.success { border-left-color: var(--success); }
        .toast.error { border-left-color: var(--danger); }

        @keyframes slideIn {
            from { transform: translateX(100%); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }

        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* 
         * RESPONSIVE MEDIA QUERIES 
         */
        @media (min-width: 768px) {
            .widget-timer { grid-column: span 6; }
            .widget-tasks { grid-column: span 6; }
            .widget-analytics { grid-column: span 12; }
            .widget-notes { grid-column: span 12; }
        }

        @media (min-width: 1024px) {
            .widget-welcome { grid-column: span 8; }
            .widget-timer { grid-column: span 4; }
            .widget-tasks { grid-column: span 5; }
            .widget-analytics { grid-column: span 3; }
            .widget-notes { grid-column: span 4; }
        }

    </style>
</head>
<body>

    <!-- Header -->
    <header class="glass">
        <div class="logo">
            <i class="fa-solid fa-cube"></i> NEXUS
        </div>
        <div class="header-controls">
            <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="credit-link">
                Built with anycoder <i class="fa-solid fa-arrow-up-right-from-square" style="font-size: 0.7em;"></i>
            </a>
            <button class="btn-icon" id="theme-toggle" title="Toggle Theme (Demo)">
                <i class="fa-solid fa-moon"></i>
            </button>
            <img src="https://picsum.photos/seed/nexusUser/100/100" alt="User" class="user-avatar">
        </div>
    </header>

    <!-- Main Content -->
    <main>
        <!-- Welcome Widget -->
        <section class="card glass widget-welcome">
            <div class="welcome-text">
                <h1 id="greeting">Welcome back, Operator.</h1>
                <p class="date-display" id="current-date">Loading date...</p>
            </div>
        </section>

        <!-- Timer Widget -->
        <section class="card glass widget-timer">
            <div class="card-header" style="width: 100%;">
                <div class="card-title"><i class="fa-solid fa-hourglass-half"></i> Focus Flow</div>
            </div>
            
            <div class="timer-circle">
                <svg>
                    <circle class="circle-bg" cx="50%" cy="50%" r="90"></circle>
                    <circle class="circle-progress" cx="50%" cy="50%" r="90" id="progress-ring"></circle>
                </svg>
                <div class="timer-text">
                    <div class="time-display" id="timer-display">25:00</div>
                    <div style="font-size: 0.8rem; color: var(--text-muted);">FOCUS MODE</div>
                </div>
            </div>

            <div class="timer-controls">
                <button class="btn btn-primary" id="start-btn"><i class="fa-solid fa-play"></i> Start</button>
                <button class="btn btn-icon" id="reset-btn"><i class="fa-solid fa-rotate-right"></i></button>
            </div>
        </section>

        <!-- Task List Widget -->
        <section class="card glass widget-tasks">
            <div class="card-header">
                <div class="card-title"><i class="fa-solid fa-list-check"></i> Mission Tasks</div>
                <span style="font-size: 0.8rem; color: var(--text-muted);" id="task-count">0 Active</span>
            </div>
            
            <form id="task-form" class="task-input-group">
                <input type="text" class="task-input" id="task-input" placeholder="Enter new directive..." autocomplete="off">
                <button type="submit" class="btn btn-primary"><i class="fa-solid fa-plus"></i></button>
            </form>

            <ul class="task-list" id="task-list">
                <!-- Tasks injected via JS -->
            </ul>
        </section>

        <!-- Analytics Widget -->
        <section class="card glass widget-analytics">
            <div class="card-header">
                <div class="card-title"><i class="fa-solid fa-chart-line"></i> Efficiency</div>
            </div>
            <div style="flex: 1; position: relative;">
                <canvas id="productivityChart"></canvas>
            </div>
        </section>

        <!-- Notes Widget -->
        <section class="card glass widget-notes">
            <div class="card-header">
                <div class="card-title"><i class="fa-regular fa-note-sticky"></i> Quick Log</div>
                <button class="btn-icon" id="clear-notes" title="Clear Notes"><i class="fa-solid fa-trash"></i></button>
            </div>
            <textarea class="notes-area" id="quick-notes" placeholder="Type your observations here..."></textarea>
        </section>
    </main>

    <!-- Toast Container -->
    <div class="toast-container" id="toast-container"></div>

    <script>
        /**
         * NEXUS COMMAND CENTER LOGIC
         * Pure Vanilla JavaScript - No Frameworks
         */

        document.addEventListener('DOMContentLoaded', () => {
            initClock();
            initTimer();
            initTasks();
            initNotes();
            initChart();
        });

        /* --- 1. UTILITY FUNCTIONS --- */
        const $ = (selector) => document.querySelector(selector);
        
        function showToast(message, type = 'info') {
            const container = $('#toast-container');
            const toast = document.createElement('div');
            toast.className = `toast ${type}`;
            
            let icon = 'fa-info-circle';
            if (type === 'success') icon = 'fa-check-circle';
            if (type === 'error') icon = 'fa-triangle-exclamation';

            toast.innerHTML = `<i class="fa-solid ${icon}"></i> <span>${message}</span>`;
            
            container.appendChild(toast);

            // Remove after 3 seconds
            setTimeout(() => {
                toast.style.animation = 'slideIn 0.3s ease-out reverse forwards';
                setTimeout(() => toast.remove(), 300);
            }, 3000);
        }

        /* --- 2. CLOCK & DATE --- */
        function initClock() {
            const dateEl = $('#current-date');
            const greetingEl = $('#greeting');
            const hours = new Date().getHours();
            
            // Dynamic Greeting
            let greet = 'Welcome back, Operator.';
            if (hours < 12) greet = 'Good morning, Operator.';
            else if (hours < 18) greet = 'Good afternoon, Operator.';
            else greet = 'Good evening, Operator.';
            greetingEl.textContent = greet;

            const updateTime = () => {
                const now = new Date();
                dateEl.textContent = now.toLocaleDateString('en-US', { 
                    weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' 
                }) + ' • ' + now.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
            };

            updateTime();
            setInterval(updateTime, 1000);
        }

        /* --- 3. FOCUS TIMER --- */
        function initTimer() {
            let timeLeft = 25 * 60; // 25 minutes
            let timerId = null;
            let isRunning = false;

            const display = $('#timer-display');
            const ring = $('#progress-ring');
            const startBtn = $('#start-btn');
            const resetBtn = $('#reset-btn');
            
            // Circle circumference for dashoffset calculation
            const radius = ring.r.baseVal.value;
            const circumference = 2 * Math.PI * radius;
            ring.style.strokeDasharray = `${circumference} ${circumference}`;
            
            function setProgress(percent) {
                const offset = circumference - (percent / 100) * circumference;
                ring.style.strokeDashoffset = offset;
            }

            function updateDisplay() {
                const m = Math.floor(timeLeft / 60);
                const s = timeLeft % 60;
                display.textContent = `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
                
                const totalTime = 25 * 60;
                const percent = ((totalTime - timeLeft) / totalTime) * 100;
                setProgress(100 - percent); // Inverse progress (draining)
            }

            function toggleTimer() {
                if (isRunning) {
                    clearInterval(timerId);
                    startBtn.innerHTML = '<i class="fa-solid fa-play"></i> Resume';
                    startBtn.classList.remove('btn-danger'); // Hypothetical class
                } else {
                    timerId = setInterval(() => {
                        if (timeLeft > 0) {
                            timeLeft--;
                            updateDisplay();
                        } else {
                            clearInterval(timerId);
                            isRunning = false;
                            startBtn.innerHTML = '<i class="fa-solid fa-play"></i> Start';
                            showToast('Focus session complete!', 'success');
                        }
                    }, 1000);
                    startBtn.innerHTML = '<i class="fa-solid fa-pause"></i> Pause';
                }
                isRunning = !isRunning;
            }

            function resetTimer() {
                clearInterval(timerId);
                isRunning = false;
                timeLeft = 25 * 60;
                startBtn.innerHTML = '<i class="fa-solid fa-play"></i> Start';
                updateDisplay();
                setProgress(100);
            }

            startBtn.addEventListener('click', toggleTimer);
            resetBtn.addEventListener('click', resetTimer);
            
            // Initial set
            updateDisplay();
        }

        /* --- 4. TASK MANAGER (Local Storage) --- */
        function initTasks() {
            const form = $('#task-form');
            const input = $('#task-input');
            const list = $('#task-list');
            const countEl = $('#task-count');

            let tasks = JSON.parse(localStorage.getItem('nexus_tasks')) || [
                { id: 1, text: 'Review system logs', completed: false },
                { id: 2, text: 'Update security protocols', completed: true }
            ];

            function save() {
                localStorage.setItem('nexus_tasks', JSON.stringify(tasks));
                render();
            }

            function render() {
                list.innerHTML = '';
                let activeCount = 0;

                tasks.forEach(task => {
                    if (!task.completed) activeCount++;

                    const li = document.createElement('li');
                    li.className = `task-item ${task.completed ? 'completed' : 'pending'}`;
                    li.innerHTML = `
                        <span>${task.text}</span>
                        <div class="task-actions">
                            <button onclick="toggleTask(${task.id})"><i class="fa-solid fa-check"></i></button>
                            <button onclick="deleteTask(${task.id})"><i class="fa-solid fa-xmark"></i></button>
                        </div>
                    `;
                    list.appendChild(li);
                });

                countEl.textContent = `${activeCount} Active`;
            }

            window.toggleTask = (id) => {
                tasks = tasks.map(t => t.id === id ? {...t, completed: !t.completed} : t);
                save();
            };

            window.deleteTask = (id) => {
                tasks = tasks.filter(t => t.id !== id);
                save();
                showToast('Task removed', 'info');
            };

            form.addEventListener('submit', (e) => {
                e.preventDefault();
                const text = input.value.trim();
                if (!text) return;

                tasks.unshift({
                    id: Date.now(),
                    text,
                    completed: false
                });
                input.value = '';
                save();
                showToast('New directive added', 'success');
            });

            render();
        }

        /* --- 5. QUICK NOTES --- */
        function initNotes() {
            const area = $('#quick-notes');
            const clearBtn = $('#clear-notes');

            // Load saved notes
            area.value = localStorage.getItem('nexus_notes') || '';

            // Auto-save on input
            area.addEventListener('input', () => {
                localStorage.setItem('nexus_notes', area.value);
            });

            clearBtn.addEventListener('click', () => {
                if(confirm('Clear all notes?')) {
                    area.value = '';
                    localStorage.removeItem('nexus_notes');
                    showToast('Notes cleared', 'info');
                }
            });
        }

        /* --- 6. CANVAS CHART (Custom Drawing) --- */
        function initChart() {
            const canvas = $('#productivityChart');
            const ctx = canvas.getContext('2d');
            
            // Handle high DPI displays
            const dpr = window.devicePixelRatio || 1;
            const rect = canvas.getBoundingClientRect();
            canvas.width = rect.width * dpr;
            canvas.height = rect.height * dpr;
            ctx.scale(dpr, dpr);

            // Mock Data
            const dataPoints = [20, 45, 30, 60, 55, 80, 70];
            const labels = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
            const maxVal = 100;

            function draw() {
                const width = rect.width;
                const height = rect.height;
                const padding = 20;
                const chartHeight = height - padding * 2;
                const chartWidth = width - padding * 2;
                const stepX = chartWidth / (dataPoints.length - 1);

                ctx.clearRect(0, 0, width, height);

                // Gradient Fill
                const gradient = ctx.createLinearGradient(0, 0, 0, height);
                gradient.addColorStop(0, 'rgba(6, 182, 212, 0.5)'); // Cyan
                gradient.addColorStop(1, 'rgba(6, 182, 212, 0.0)');

                // Draw Area
                ctx.beginPath();
                ctx.moveTo(padding, height - padding);
                
                dataPoints.forEach((val, index) => {
                    const x = padding + index * stepX;
                    const y = height - padding - (val / maxVal) * chartHeight;
                    if (index === 0) ctx.lineTo(x, y);
                    else {
                        // Bezier curve for smoothness
                        const prevX = padding + (index - 1) * stepX;
                        const prevY = height - padding - (dataPoints[index - 1] / maxVal) * chartHeight;
                        const cp1x = prevX + (x - prevX) / 2;
                        const cp1y = prevY;
                        const cp2x = prevX + (x - prevX) / 2;
                        const cp2y = y;
                        ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
                    }
                });

                ctx.lineTo(width - padding, height - padding);
                ctx.closePath();
                ctx.fillStyle = gradient;
                ctx.fill();

                // Draw Line
                ctx.beginPath();
                dataPoints.forEach((val, index) => {
                    const x = padding + index * stepX;
                    const y = height - padding - (val / maxVal) * chartHeight;
                    if (index === 0) ctx.moveTo(x, y);
                    else {
                        const prevX = padding + (index - 1) * stepX;
                        const prevY = height - padding - (dataPoints[index - 1] / maxVal) * chartHeight;
                        const cp1x = prevX + (x - prevX) / 2;
                        const cp1y = prevY;
                        const cp2x = prevX + (x - prevX) / 2;
                        const cp2y = y;
                        ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
                    }
                });
                ctx.strokeStyle = '#06b6d4';
                ctx.lineWidth = 3;
                ctx.stroke();

                // Draw Points
                dataPoints.forEach((val, index) => {
                    const x = padding + index * stepX;
                    const y = height - padding - (val / maxVal) * chartHeight;
                    
                    ctx.beginPath();
                    ctx.arc(x, y, 4, 0, Math.PI * 2);
                    ctx.fillStyle = '#fff';
                    ctx.fill();

                    // Labels
                    ctx.fillStyle = '#94a3b8';
                    ctx.font = '10px Outfit';
                    ctx.textAlign = 'center';
                    ctx.fillText(labels[index], x, height - 5);
                });
            }

            draw();
            
            // Redraw on resize
            window.addEventListener('resize', () => {
                const newRect = canvas.getBoundingClientRect();
                canvas.width = newRect.width * dpr;
                canvas.height = newRect.height * dpr;
                ctx.scale(dpr, dpr);
                draw();
            });
        }
    </script>
</body>
</html>