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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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MAGNET DATASETS by webXOS 2026</title>
    <link rel="manifest" href="manifest.json">
    <script src="https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/jszip@3.10.1/dist/jszip.min.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-user-select: none;
            user-select: none;
        }
        
        body {
            background: #000;
            color: #0f0;
            font-family: 'VT323', monospace;
            font-size: 16px;
            line-height: 1.2;
            overflow: hidden;
            height: 100vh;
        }
        
        /* CRT Screen Effect */
        .crt::before {
            content: " ";
            display: block;
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
                        linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
            background-size: 100% 2px, 3px 100%;
            pointer-events: none;
            z-index: 999;
        }
        
        .crt::after {
            content: " ";
            display: block;
            position: fixed;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            background: rgba(18, 16, 16, 0.1);
            opacity: 0.3;
            pointer-events: none;
            animation: flicker 0.15s infinite;
            z-index: 998;
        }
        
        @keyframes flicker {
            0% { opacity: 0.27861; }
            5% { opacity: 0.34769; }
            10% { opacity: 0.23604; }
            15% { opacity: 0.90626; }
            20% { opacity: 0.18128; }
            25% { opacity: 0.83891; }
            30% { opacity: 0.65583; }
            35% { opacity: 0.67807; }
            40% { opacity: 0.26559; }
            45% { opacity: 0.84693; }
            50% { opacity: 0.96019; }
            55% { opacity: 0.08594; }
            60% { opacity: 0.20313; }
            65% { opacity: 0.71988; }
            70% { opacity: 0.53455; }
            75% { opacity: 0.37288; }
            80% { opacity: 0.71428; }
            85% { opacity: 0.70419; }
            90% { opacity: 0.7003; }
            95% { opacity: 0.36108; }
            100% { opacity: 0.24387; }
        }
        
        /* Main Terminal Grid */
        .terminal-grid {
            display: grid;
            grid-template-columns: 2fr 1fr;
            grid-template-rows: auto 1fr;
            height: 100vh;
            padding: 15px;
            gap: 10px;
            background: #000;
        }
        
        /* System Header */
        .system-header {
            grid-column: 1 / -1;
            border: 1px solid #0f0;
            padding: 8px 15px;
            background: rgba(0, 10, 0, 0.3);
            position: relative;
            overflow: hidden;
        }
        
        .system-header::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 1px;
            background: linear-gradient(90deg, transparent, #0f0, transparent);
            animation: scanline 3s linear infinite;
        }
        
        @keyframes scanline {
            0% { transform: translateX(-100%); }
            100% { transform: translateX(100%); }
        }
        
        .system-title {
            font-size: 1.8em;
            text-shadow: 0 0 8px #0f0;
            letter-spacing: 2px;
            text-transform: uppercase;
            text-align: center;
        }
        
        .system-status {
            display: flex;
            justify-content: space-between;
            margin-top: 5px;
            font-size: 0.9em;
        }
        
        .status-led {
            display: inline-block;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-right: 5px;
        }
        
        .led-online { background: #0f0; box-shadow: 0 0 5px #0f0; animation: blink 1s infinite; }
        .led-active { background: #0f0; box-shadow: 0 0 5px #0f0; }
        .led-standby { background: #333; }
        
        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.3; }
        }
        
        /* Main Control Panel */
        .control-panel {
            border: 1px solid #0f0;
            background: rgba(0, 5, 0, 0.8);
            padding: 10px;
            overflow-y: auto;
            position: relative;
        }
        
        .control-panel::before {
            content: "CONTROL";
            position: absolute;
            top: -8px;
            left: 15px;
            background: #000;
            padding: 0 8px;
            font-size: 0.9em;
            color: #0f0;
        }
        
        /* Visualization Panel */
        .visualization-panel {
            border: 1px solid #0f0;
            background: #000;
            position: relative;
            overflow: hidden;
        }
        
        .visualization-panel::before {
            content: "VISUALIZER";
            position: absolute;
            top: -8px;
            left: 15px;
            background: #000;
            padding: 0 8px;
            font-size: 0.9em;
            color: #0f0;
            z-index: 2;
        }
        
        #visual-canvas {
            width: 100%;
            height: 100%;
            background: #000;
        }
        
        /* Data Log Panel */
        .log-panel {
            grid-column: 1 / -1;
            border: 1px solid #0f0;
            background: rgba(0, 8, 0, 0.7);
            height: 180px;
            padding: 8px;
            font-family: 'VT323', monospace;
            font-size: 0.8em;
            overflow-y: scroll;
            position: relative;
        }
        
        .log-panel::before {
            content: "SYSTEM LOG";
            position: absolute;
            top: -8px;
            left: 15px;
            background: #000;
            padding: 0 8px;
            font-size: 0.9em;
            color: #0f0;
        }
        
        .log-entry {
            margin-bottom: 2px;
            padding-left: 5px;
            border-left: 1px solid #0f0;
            animation: logAppear 0.2s ease-out;
        }
        
        @keyframes logAppear {
            from { opacity: 0; transform: translateY(3px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .log-time {
            color: #080;
            margin-right: 8px;
        }
        
        .log-info { color: #0f0; }
        .log-warning { color: #ff0; }
        .log-error { color: #f00; }
        .log-success { color: #0f0; }
        
        /* Terminal Input */
        .terminal-input {
            display: flex;
            margin-top: 5px;
            border-top: 1px solid #0f0;
            padding-top: 5px;
        }
        
        .prompt {
            color: #0f0;
            margin-right: 5px;
        }
        
        #commandInput {
            background: transparent;
            border: none;
            color: #0f0;
            font-family: 'VT323', monospace;
            font-size: 0.9em;
            flex: 1;
            outline: none;
        }
        
        /* Retro Buttons */
        .btn-retro {
            background: #000;
            border: 1px solid #0f0;
            color: #0f0;
            font-family: 'VT323', monospace;
            font-size: 1em;
            padding: 5px 10px;
            margin: 3px;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .btn-retro:hover {
            background: #001100;
            box-shadow: 0 0 8px rgba(0, 255, 0, 0.3);
        }
        
        .btn-retro:active {
            background: #002200;
        }
        
        /* Progress Bar */
        .progress-bar {
            height: 12px;
            background: rgba(0, 10, 0, 0.5);
            border: 1px solid #0f0;
            margin: 8px 0;
            overflow: hidden;
        }
        
        .progress-fill {
            height: 100%;
            background: linear-gradient(90deg, #080, #0f0);
            width: 0%;
            transition: width 0.3s;
        }
        
        /* Fullscreen Button */
        .btn-fullscreen {
            position: fixed;
            bottom: 10px;
            right: 10px;
            z-index: 1000;
            background: rgba(0, 0, 0, 0.9);
            border: 1px solid #0f0;
            color: #0f0;
            font-size: 1.2em;
            width: 40px;
            height: 40px;
            cursor: pointer;
            transition: all 0.3s;
            opacity: 0.7;
        }
        
        .btn-fullscreen:hover {
            opacity: 1;
            box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
        }
        
        /* Export Modal */
        .export-modal {
            position: fixed;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 600px;
            background: rgba(0, 8, 0, 0.95);
            border: 1px solid #0f0;
            padding: 15px;
            z-index: 2000;
            box-shadow: 0 0 30px rgba(0, 255, 0, 0.3);
            display: none;
        }
        
        .export-header {
            font-size: 1.2em;
            color: #0f0;
            margin-bottom: 15px;
            text-align: center;
        }
        
        .file-structure {
            background: rgba(0, 0, 0, 0.5);
            border: 1px solid #0f0;
            padding: 10px;
            margin: 15px 0;
            font-size: 0.8em;
            max-height: 200px;
            overflow-y: auto;
        }
        
        .file-item {
            margin: 3px 0;
            padding-left: 15px;
        }
        
        .file-item::before {
            content: ">";
            margin-right: 5px;
            color: #080;
        }
        
        .btn-export {
            background: #000;
            border: 1px solid #0f0;
            color: #0f0;
            padding: 8px 20px;
            font-size: 1em;
            cursor: pointer;
            width: 100%;
            margin-top: 15px;
            text-transform: uppercase;
        }
        
        .btn-export:hover {
            background: #001100;
            box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
        }
        
        /* Overlay */
        .overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.8);
            z-index: 1000;
            display: none;
        }
        
        /* Stats */
        .stats {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
            margin: 10px 0;
        }
        
        .stat-item {
            background: rgba(0, 10, 0, 0.3);
            border: 1px solid #0f0;
            padding: 6px;
        }
        
        .stat-label {
            font-size: 0.8em;
            color: #080;
        }
        
        .stat-value {
            font-size: 1.1em;
            color: #0f0;
        }
        
        /* Command Groups */
        .command-group {
            margin: 10px 0;
            padding: 8px;
            border: 1px solid rgba(0, 255, 0, 0.2);
            background: rgba(0, 10, 0, 0.2);
        }
        
        .command-group-title {
            color: #0f0;
            font-size: 1em;
            margin-bottom: 8px;
            padding-bottom: 3px;
            border-bottom: 1px solid #0f0;
        }
        
        /* Scrollbar */
        ::-webkit-scrollbar {
            width: 8px;
        }
        
        ::-webkit-scrollbar-track {
            background: rgba(0, 10, 0, 0.3);
        }
        
        ::-webkit-scrollbar-thumb {
            background: rgba(0, 255, 0, 0.2);
            border: 1px solid #0f0;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: rgba(0, 255, 0, 0.3);
        }
        
        /* Responsive */
        @media (max-width: 1024px) {
            .terminal-grid {
                grid-template-columns: 1fr;
                grid-template-rows: auto 300px 250px 150px;
            }
            
            .control-panel {
                max-height: 250px;
            }
            
            .export-modal {
                width: 90%;
            }
        }
    </style>
</head>
<body class="crt">
    <!-- Minimal Fullscreen Button -->
    <button class="btn-fullscreen" onclick="toggleFullscreen()" title="FULLSCREEN"></button>
    
    <!-- Main Terminal -->
    <div class="terminal-grid">
        <!-- System Header -->
        <div class="system-header">
            <div class="system-title">
                MAGNET DATASETS by webXOS 2026
            </div>
            <div class="system-status">
                <div>
                    <span class="status-led led-online"></span>SYSTEM: <span id="sysStatus">ONLINE</span>
                    <span class="status-led" style="margin-left: 15px;"></span>SAMPLES: <span id="sampleCount">0</span>
                    <span class="status-led" style="margin-left: 15px;"></span>BUFFER: <span id="bufferSize">0KB</span>
                </div>
                <div>
                    <span class="status-led led-active"></span>TIME: <span id="systemTime">00:00:00</span>
                    <span class="status-led" style="margin-left: 15px;"></span>WORKERS: <span id="workerCount">0/8</span>
                </div>
            </div>
        </div>
        
        <!-- Control Panel -->
        <div class="control-panel">
            <div class="command-group">
                <div class="command-group-title">DATASET GENERATORS</div>
                <div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px;">
                    <button class="btn-retro" onclick="toggleWorker('dipole')">
                        <span class="status-led" id="dipoleLed"></span> DIPOLE
                    </button>
                    <button class="btn-retro" onclick="toggleWorker('solenoid')">
                        <span class="status-led" id="solenoidLed"></span> SOLENOID
                    </button>
                    <button class="btn-retro" onclick="toggleWorker('permanent')">
                        <span class="status-led" id="permanentLed"></span> PERMANENT
                    </button>
                    <button class="btn-retro" onclick="toggleWorker('electro')">
                        <span class="status-led" id="electroLed"></span> ELECTRO
                    </button>
                    <button class="btn-retro" onclick="toggleWorker('toroid')">
                        <span class="status-led" id="toroidLed"></span> TOROIDAL
                    </button>
                    <button class="btn-retro" onclick="toggleWorker('anisotropic')">
                        <span class="status-led" id="anisotropicLed"></span> ANISOTROPIC
                    </button>
                    <button class="btn-retro" onclick="toggleWorker('halbach')">
                        <span class="status-led" id="halbachLed"></span> HALBACH
                    </button>
                    <button class="btn-retro" onclick="toggleWorker('custom')">
                        <span class="status-led" id="customLed"></span> CUSTOM
                    </button>
                </div>
            </div>
            
            <div class="command-group">
                <div class="command-group-title">CONTROLS</div>
                <div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px;">
                    <button class="btn-retro" onclick="startCollection()">
                        ▶ START
                    </button>
                    <button class="btn-retro" onclick="stopCollection()">
                        ⏸ STOP
                    </button>
                    <button class="btn-retro" onclick="clearData()">
                        CLEAR
                    </button>
                    <button class="btn-retro" onclick="showExportModal()">
                        EXPORT
                    </button>
                </div>
                <div class="progress-bar">
                    <div class="progress-fill" id="collectionProgress" style="width: 0%"></div>
                </div>
            </div>
            
            <div class="stats">
                <div class="stat-item">
                    <div class="stat-label">DATA POINTS</div>
                    <div class="stat-value" id="dataPoints">0</div>
                </div>
                <div class="stat-item">
                    <div class="stat-label">THROUGHPUT</div>
                    <div class="stat-value" id="throughput">0/s</div>
                </div>
                <div class="stat-item">
                    <div class="stat-label">MEM USAGE</div>
                    <div class="stat-value" id="memory">64KB</div>
                </div>
                <div class="stat-item">
                    <div class="stat-label">FILE SIZE</div>
                    <div class="stat-value" id="fileSize">0MB</div>
                </div>
            </div>
        </div>
        
        <!-- Visualization Panel -->
        <div class="visualization-panel">
            <div id="visual-canvas"></div>
            <div style="position: absolute; bottom: 5px; left: 10px; color: #0f0; font-size: 0.7em;">
                WIREFRAME VISUALIZER @ 60FPS
            </div>
        </div>
        
        <!-- System Log with Terminal Input -->
        <div class="log-panel" id="logPanel">
            <div class="log-entry">
                <span class="log-time">[00:00:00]</span>
                <span class="log-success">SYSTEM INITIALIZED</span>
            </div>
            <div class="log-entry">
                <span class="log-time">[00:00:01]</span>
                <span class="log-info">MAGNET DATASETS v1.0 READY</span>
            </div>
            <div class="log-entry">
                <span class="log-time">[00:00:02]</span>
                <span class="log-info">TYPE /help FOR COMMANDS</span>
            </div>
        </div>
    </div>
    
    <!-- Terminal Input -->
    <div class="terminal-input" style="position: fixed; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.9); padding: 5px 15px; border-top: 1px solid #0f0;">
        <span class="prompt">webXOS></span>
        <input type="text" id="commandInput" placeholder="Type /help for commands..." onkeypress="handleCommand(event)">
    </div>
    
    <!-- Export Modal -->
    <div class="overlay" id="exportOverlay" onclick="hideExportModal()"></div>
    <div class="export-modal" id="exportModal">
        <div class="export-header">EXPORT HUGGING FACE DATASET</div>
        
        <div style="margin: 10px 0;">
            <div style="color: #0f0; margin-bottom: 5px;">DATASET NAME:</div>
            <input type="text" id="datasetName" value="magnet_dataset" 
                   style="background: #000; color: #0f0; border: 1px solid #0f0; padding: 5px; width: 100%;">
        </div>
        
        <div style="margin: 10px 0;">
            <div style="color: #0f0; margin-bottom: 5px;">FORMAT:</div>
            <select id="exportFormat" style="background: #000; color: #0f0; border: 1px solid #0f0; padding: 5px; width: 100%;">
                <option value="jsonl">JSON Lines (.jsonl) - Recommended</option>
                <option value="parquet">Apache Parquet (.parquet)</option>
                <option value="csv">CSV (.csv)</option>
            </select>
        </div>
        
        <div class="file-structure" id="fileStructure">
            <div class="file-item">magnet_dataset.zip</div>
            <div class="file-item">README.md</div>
            <div class="file-item">data/</div>
            <div class="file-item" style="padding-left: 30px;">train-00001-of-00001.jsonl</div>
            <div class="file-item">dataset_infos.json</div>
        </div>
        
        <div style="margin: 10px 0; color: #080; font-size: 0.9em;">
            <div>📁 <strong>Hugging Face Compatible Structure:</strong></div>
            <div style="margin-top: 5px;">• Uses correct sharded JSONL format</div>
            <div>• Proper dataset_infos.json with correct splits</div>
            <div>• Follows HF dataset library standards</div>
        </div>
        
        <button class="btn-export" onclick="exportDataset()">
            GENERATE .ZIP FOR HUGGING FACE
        </button>
    </div>
    
    <script>
        // Global State
        const systemState = {
            workers: {},
            datasets: {},
            isCollecting: false,
            startTime: Date.now(),
            totalSamples: 0,
            activeWorkers: 0
        };
        
        // Three.js Visualization
        let scene, camera, renderer;
        let animationId;
        
        function initVisualization() {
            scene = new THREE.Scene();
            camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
            renderer = new THREE.WebGLRenderer({ antialias: false });
            renderer.setSize(document.getElementById('visual-canvas').clientWidth, 
                           document.getElementById('visual-canvas').clientHeight);
            renderer.setClearColor(0x000000);
            document.getElementById('visual-canvas').appendChild(renderer.domElement);
            
            camera.position.z = 15;
            
            // Simple wireframe grid
            const gridSize = 20;
            const gridDivisions = 20;
            const gridGeometry = new THREE.PlaneGeometry(gridSize, gridSize, gridDivisions, gridDivisions);
            const gridMaterial = new THREE.MeshBasicMaterial({ 
                color: 0x002200,
                wireframe: true,
                transparent: true,
                opacity: 0.3
            });
            const grid = new THREE.Mesh(gridGeometry, gridMaterial);
            grid.rotation.x = -Math.PI / 2;
            scene.add(grid);
            
            // Simple points
            const pointsGeometry = new THREE.BufferGeometry();
            const pointsCount = 200;
            const positions = new Float32Array(pointsCount * 3);
            
            for (let i = 0; i < pointsCount * 3; i++) {
                positions[i] = (Math.random() - 0.5) * 15;
            }
            
            pointsGeometry.setAttribute('position', new THREE.BufferAttribute(positions, 3));
            
            const pointsMaterial = new THREE.PointsMaterial({
                color: 0x00ff00,
                size: 0.05,
                transparent: true,
                opacity: 0.5
            });
            
            const points = new THREE.Points(pointsGeometry, pointsMaterial);
            scene.add(points);
            
            // Start animation
            animateVisualization();
        }
        
        function animateVisualization() {
            animationId = requestAnimationFrame(animateVisualization);
            
            scene.children.forEach(child => {
                if (child.isPoints) {
                    child.rotation.y += 0.001;
                    child.rotation.x += 0.0005;
                }
            });
            
            renderer.render(scene, camera);
        }
        
        // Initialize Web Workers
        function initWorkers() {
            const workerTypes = [
                'dipole', 'solenoid', 'permanent', 'electro',
                'toroid', 'anisotropic', 'halbach', 'custom'
            ];
            
            workerTypes.forEach(type => {
                const workerCode = `
                    self.onmessage = function(e) {
                        const { command, params } = e.data;
                        
                        if (command === 'start') {
                            this.interval = setInterval(() => {
                                const data = generateData('${type}');
                                self.postMessage({ type: 'data', data });
                            }, 50);
                        }
                        
                        if (command === 'stop') {
                            clearInterval(this.interval);
                        }
                    };
                    
                    function generateData(type) {
                        const timestamp = Date.now();
                        const x = (Math.random() - 0.5) * 10;
                        const y = (Math.random() - 0.5) * 10;
                        const z = (Math.random() - 0.5) * 10;
                        
                        let field = [0, 0, 0];
                        let strength = 0;
                        
                        switch(type) {
                            case 'dipole':
                                field = [
                                    (Math.random() - 0.5) * 2,
                                    (Math.random() - 0.5) * 2,
                                    (Math.random() - 0.5) * 2
                                ];
                                strength = Math.sqrt(field[0]**2 + field[1]**2 + field[2]**2);
                                break;
                                
                            case 'solenoid':
                                field = [
                                    (Math.random() - 0.5) * 0.5,
                                    (Math.random() - 0.5) * 1.5,
                                    (Math.random() - 0.5) * 0.5
                                ];
                                strength = Math.abs(field[1]);
                                break;
                                
                            case 'permanent':
                                field = [
                                    (Math.random() - 0.5) * 3,
                                    (Math.random() - 0.5) * 3,
                                    (Math.random() - 0.5) * 3
                                ];
                                strength = Math.sqrt(field[0]**2 + field[1]**2 + field[2]**2);
                                break;
                                
                            case 'electro':
                                const current = 1 + Math.random();
                                field = [
                                    (Math.random() - 0.5) * current,
                                    (Math.random() - 0.5) * current,
                                    (Math.random() - 0.5) * current
                                ];
                                strength = current;
                                break;
                                
                            case 'toroid':
                                field = [
                                    (Math.random() - 0.5) * 0.3,
                                    (Math.random() - 0.5) * 0.8,
                                    (Math.random() - 0.5) * 0.3
                                ];
                                strength = Math.sqrt(field[0]**2 + field[1]**2 + field[2]**2);
                                break;
                                
                            case 'anisotropic':
                                field = [
                                    (Math.random() - 0.5) * 2.5,
                                    (Math.random() - 0.5) * 1.0,
                                    (Math.random() - 0.5) * 0.5
                                ];
                                strength = Math.abs(field[0]);
                                break;
                                
                            case 'halbach':
                                field = [
                                    (Math.random() - 0.5) * 4,
                                    (Math.random() - 0.5) * 4,
                                    (Math.random() - 0.5) * 4
                                ];
                                strength = Math.sqrt(field[0]**2 + field[1]**2 + field[2]**2) * 1.5;
                                break;
                                
                            case 'custom':
                                field = [
                                    Math.sin(x) * Math.cos(z),
                                    Math.cos(x) * Math.sin(z),
                                    Math.sin(y) * Math.cos(x)
                                ];
                                strength = Math.sqrt(field[0]**2 + field[1]**2 + field[2]**2);
                                break;
                        }
                        
                        return {
                            timestamp: timestamp,
                            type: type,
                            position: [x, y, z],
                            field: field,
                            strength: strength
                        };
                    }
                `;
                
                const blob = new Blob([workerCode], { type: 'application/javascript' });
                const worker = new Worker(URL.createObjectURL(blob));
                
                worker.onmessage = (e) => {
                    if (e.data.type === 'data' && systemState.isCollecting) {
                        handleWorkerData(type, e.data.data);
                    }
                };
                
                systemState.workers[type] = {
                    worker: worker,
                    active: false,
                    data: []
                };
            });
        }
        
        // Handle data from workers
        function handleWorkerData(type, data) {
            if (!systemState.datasets[type]) {
                systemState.datasets[type] = [];
            }
            
            systemState.datasets[type].push(data);
            systemState.totalSamples++;
            
            if (systemState.totalSamples % 100 === 0) {
                updateStats();
                logData(`${type}: ${systemState.datasets[type].length} samples`);
            }
        }
        
        // Toggle worker on/off
        function toggleWorker(type) {
            const worker = systemState.workers[type];
            const led = document.getElementById(`${type}Led`);
            
            if (worker.active) {
                worker.worker.postMessage({ command: 'stop' });
                worker.active = false;
                led.className = 'status-led';
                systemState.activeWorkers--;
                logInfo(`${type} stopped`);
            } else {
                worker.worker.postMessage({ command: 'start' });
                worker.active = true;
                led.className = 'status-led led-active';
                systemState.activeWorkers++;
                logInfo(`${type} started`);
            }
            
            document.getElementById('workerCount').textContent = `${systemState.activeWorkers}/8`;
            updateStats();
        }
        
        // Start data collection
        function startCollection() {
            systemState.isCollecting = true;
            systemState.startTime = Date.now();
            document.getElementById('sysStatus').textContent = 'COLLECTING';
            logSuccess('Collection started');
            
            Object.keys(systemState.workers).forEach(type => {
                if (systemState.workers[type].active) {
                    systemState.workers[type].worker.postMessage({ command: 'start' });
                }
            });
        }
        
        // Stop data collection
        function stopCollection() {
            systemState.isCollecting = false;
            document.getElementById('sysStatus').textContent = 'ONLINE';
            logWarning('Collection stopped');
            
            Object.keys(systemState.workers).forEach(type => {
                systemState.workers[type].worker.postMessage({ command: 'stop' });
            });
        }
        
        // Clear all data
        function clearData() {
            Object.keys(systemState.datasets).forEach(type => {
                systemState.datasets[type] = [];
            });
            systemState.totalSamples = 0;
            systemState.startTime = Date.now();
            updateStats();
            logInfo('Data cleared');
        }
        
        // Update statistics
        function updateStats() {
            document.getElementById('dataPoints').textContent = systemState.totalSamples.toLocaleString();
            document.getElementById('sampleCount').textContent = systemState.totalSamples.toLocaleString();
            
            const elapsed = (Date.now() - systemState.startTime) / 1000;
            const throughput = elapsed > 0 ? Math.round(systemState.totalSamples / elapsed) : 0;
            document.getElementById('throughput').textContent = `${throughput}/s`;
            
            const avgSampleSize = 128;
            const totalSize = systemState.totalSamples * avgSampleSize;
            const sizeMB = (totalSize / (1024 * 1024)).toFixed(2);
            document.getElementById('fileSize').textContent = `${sizeMB}MB`;
            document.getElementById('bufferSize').textContent = `${Math.round(totalSize / 1024)}KB`;
            
            const progress = Math.min((systemState.totalSamples / 50000) * 100, 100);
            document.getElementById('collectionProgress').style.width = `${progress}%`;
            
            const memory = 64 + Math.floor(totalSize / 1024);
            document.getElementById('memory').textContent = `${Math.min(memory, 1024)}KB`;
        }
        
        // Logging functions
        function logInfo(message) {
            addLog(message, 'info');
        }
        
        function logWarning(message) {
            addLog(message, 'warning');
        }
        
        function logError(message) {
            addLog(message, 'error');
        }
        
        function logSuccess(message) {
            addLog(message, 'success');
        }
        
        function logData(message) {
            if (Math.random() < 0.1) {
                addLog(message, 'info');
            }
        }
        
        function addLog(message, type) {
            const logPanel = document.getElementById('logPanel');
            const time = new Date().toLocaleTimeString();
            const entry = document.createElement('div');
            entry.className = 'log-entry';
            entry.innerHTML = `<span class="log-time">[${time}]</span> <span class="log-${type}">${message}</span>`;
            
            logPanel.appendChild(entry);
            logPanel.scrollTop = logPanel.scrollHeight;
            
            const entries = logPanel.querySelectorAll('.log-entry');
            if (entries.length > 30) {
                entries[0].remove();
            }
        }
        
        // Export Modal Functions
        function showExportModal() {
            if (systemState.totalSamples === 0) {
                logError('No data to export');
                return;
            }
            
            document.getElementById('exportOverlay').style.display = 'block';
            document.getElementById('exportModal').style.display = 'block';
            updateFileStructure();
        }
        
        function hideExportModal() {
            document.getElementById('exportOverlay').style.display = 'none';
            document.getElementById('exportModal').style.display = 'none';
        }
        
        function updateFileStructure() {
            const structure = document.getElementById('fileStructure');
            const name = document.getElementById('datasetName').value || 'magnet_dataset';
            const format = document.getElementById('exportFormat').value;
            
            let html = `<div class="file-item">${name}.zip</div>`;
            html += `<div class="file-item">README.md</div>`;
            html += `<div class="file-item">data/</div>`;
            
            if (format === 'jsonl') {
                html += `<div class="file-item" style="padding-left: 30px;">train-00001-of-00001.jsonl</div>`;
            } else if (format === 'parquet') {
                html += `<div class="file-item" style="padding-left: 30px;">train-00001-of-00001.parquet</div>`;
            } else {
                html += `<div class="file-item" style="padding-left: 30px;">train.csv</div>`;
            }
            
            html += `<div class="file-item">dataset_infos.json</div>`;
            
            structure.innerHTML = html;
        }
        
        // Convert to JSON Lines format (one JSON object per line)
        function convertToJSONL(data) {
            return data.map(item => JSON.stringify(item)).join('\n');
        }
        
        // Convert to CSV format
        function convertToCSV(data) {
            if (data.length === 0) return '';
            
            const headers = ['timestamp', 'type', 'position_x', 'position_y', 'position_z', 'field_x', 'field_y', 'field_z', 'strength'];
            const rows = data.map(item => {
                return [
                    item.timestamp,
                    item.type,
                    item.position[0],
                    item.position[1],
                    item.position[2],
                    item.field[0],
                    item.field[1],
                    item.field[2],
                    item.strength
                ].join(',');
            });
            
            return [headers.join(','), ...rows].join('\n');
        }
        
        // Export dataset as .zip - FIXED Hugging Face Compatibility v4.0
        async function exportDataset() {
            logInfo('Generating Hugging Face compatible dataset...');
            
            const zip = new JSZip();
            const datasetName = document.getElementById('datasetName').value || 'magnet_dataset';
            const format = document.getElementById('exportFormat').value;
            
            // Create data directory
            const dataFolder = zip.folder("data");
            
            // Combine all data from all workers
            const allData = [];
            Object.keys(systemState.datasets).forEach(type => {
                if (systemState.datasets[type].length > 0) {
                    allData.push(...systemState.datasets[type]);
                }
            });
            
            // Shuffle data for better distribution
            const shuffledData = [...allData].sort(() => Math.random() - 0.5);
            
            // Create train split file based on format
            if (format === 'jsonl') {
                // JSON Lines format (recommended for HF)
                const jsonlContent = convertToJSONL(shuffledData);
                dataFolder.file("train-00001-of-00001.jsonl", jsonlContent);
            } else if (format === 'parquet') {
                // Parquet format would require a library, using JSONL for now
                const jsonlContent = convertToJSONL(shuffledData);
                dataFolder.file("train-00001-of-00001.jsonl", jsonlContent);
            } else {
                // CSV format
                const csvContent = convertToCSV(shuffledData);
                dataFolder.file("train.csv", csvContent);
            }
            
            // Create README.md with dataset card format
            const readme = `---
language: en
license: apache-2.0
task_categories:
- physics
- machine-learning
tags:
- physics
- magnetic-fields
- simulation
- science
---

# Dataset Card for ${datasetName.toUpperCase()}

## Dataset Description

- **Homepage:** https://github.com/webxos/magnet-datasets
- **Repository:** https://huggingface.co/datasets/webxos/${datasetName}
- **Paper:** N/A
- **Point of Contact:** webXOS Team

### Dataset Summary

Magnetic field simulation dataset generated by webXOS MAGNET DATASETS v4.0. This dataset contains simulated magnetic field measurements for various magnet configurations.

### Supported Tasks and Leaderboards

- Magnetic field prediction
- Physics simulation
- Scientific machine learning
- Sensor calibration

### Languages

English

## Dataset Structure

### Data Instances

Each instance contains:
- timestamp: Generation timestamp
- type: Magnet type (dipole, solenoid, etc.)
- position: [x, y, z] coordinates in meters
- field: [Bx, By, Bz] magnetic field vector in Tesla
- strength: Magnitude of magnetic field in Tesla

### Data Splits

The dataset has only a train split with ${shuffledData.length.toLocaleString()} examples.

## Dataset Creation

### Curation Rationale

This dataset was created to provide high-quality simulated magnetic field data for machine learning research in physics and engineering.

### Source Data

Synthetic data generated using physics-based simulations.

### Annotations

No annotations, only raw simulation data.

### Personal and Sensitive Information

None.

## Considerations for Using the Data

### Social Impact of Dataset

This dataset enables research in electromagnetic field prediction and physics-informed machine learning.

### Discussion of Biases

The data is synthetic and evenly distributed across magnet types.

### Other Known Limitations

Data is simulated and may not match real-world measurements exactly.

## Additional Information

### Dataset Curators

webXOS Team

### Licensing Information

Apache 2.0

### Citation Information

\`\`\`bibtex
@dataset{webxos_magnet_2026,
  title = {Magnetic Field Dataset},
  author = {webXOS},
  year = {2026},
  publisher = {Hugging Face},
  version = {4.0.0}
}
\`\`\`

### Contributions

Thanks to the webXOS team for creating this dataset.`;
            
            zip.file("README.md", readme);
            
            // Create CORRECT dataset_infos.json - FIXED FORMAT v4.0
            const datasetInfos = {
                [datasetName]: {
                    description: "Magnetic field simulation dataset",
                    citation: "@dataset{webxos_magnet_2026,\n  title = {Magnetic Field Dataset},\n  author = {webXOS},\n  year = {2026}\n}",
                    homepage: "https://huggingface.co/datasets/webxos/" + datasetName,
                    license: "apache-2.0",
                    features: {
                        timestamp: {
                            dtype: "int64",
                            id: null,
                            _type: "Value"
                        },
                        type: {
                            dtype: "string",
                            id: null,
                            _type: "Value"
                        },
                        position: {
                            feature: {
                                dtype: "float64",
                                id: null,
                                _type: "Value"
                            },
                            id: null,
                            _type: "Sequence"
                        },
                        field: {
                            feature: {
                                dtype: "float64",
                                id: null,
                                _type: "Value"
                            },
                            id: null,
                            _type: "Sequence"
                        },
                        strength: {
                            dtype: "float64",
                            id: null,
                            _type: "Value"
                        }
                    },
                    post_processed: null,
                    supervised_keys: null,
                    task_templates: [],
                    builder_name: "webxos_magnet",
                    config_name: datasetName,
                    version: {
                        version_str: "4.0.0",
                        major: 4,
                        minor: 0,
                        patch: 0
                    },
                    splits: {
                        train: {
                            name: "train",
                            num_bytes: shuffledData.length * 128,
                            num_examples: shuffledData.length,
                            dataset_name: datasetName
                        }
                    },
                    download_size: shuffledData.length * 128,
                    dataset_size: shuffledData.length * 128
                }
            };
            
            zip.file("dataset_infos.json", JSON.stringify(datasetInfos, null, 2));
            
            // Create a simple metadata file
            const metadata = {
                dataset_name: datasetName,
                version: "4.0.0",
                created_at: new Date().toISOString(),
                total_samples: shuffledData.length,
                magnet_types: Object.keys(systemState.datasets).filter(type => systemState.datasets[type].length > 0),
                data_format: format === 'jsonl' ? 'jsonl' : format,
                huggingface_compatible: true,
                fix_applied: "v4.0 - Fixed dataset_infos.json structure for HF compatibility"
            };
            
            zip.file("metadata.json", JSON.stringify(metadata, null, 2));
            
            // Generate and download zip
            const content = await zip.generateAsync({ type: "blob" });
            const blobUrl = URL.createObjectURL(content);
            const a = document.createElement('a');
            a.href = blobUrl;
            a.download = `${datasetName}_hf_v4_${Date.now()}.zip`;
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            URL.revokeObjectURL(blobUrl);
            
            const sizeMB = (content.size / (1024*1024)).toFixed(2);
            logSuccess(`✅ Hugging Face dataset exported: ${datasetName}.zip (${sizeMB} MB)`);
            logInfo(`📁 Files: README.md, dataset_infos.json, data/train-*.jsonl`);
            logInfo(`✅ Fixed HF compatibility issues - v4.0`);
            logInfo(`✅ post_processed set to null`);
            logInfo(`✅ supervised_keys set to null`);
            logInfo(`✅ Removed length from Sequence features`);
            hideExportModal();
        }
        
        // Terminal Commands
        function handleCommand(event) {
            if (event.key === 'Enter') {
                const input = document.getElementById('commandInput');
                const command = input.value.trim().toLowerCase();
                input.value = '';
                
                if (!command) return;
                
                logInfo(`> ${command}`);
                
                const parts = command.split(' ');
                const cmd = parts[0];
                
                switch(cmd) {
                    case '/help':
                        showHelp();
                        break;
                    case '/start':
                        startCollection();
                        break;
                    case '/stop':
                        stopCollection();
                        break;
                    case '/clear':
                        clearData();
                        break;
                    case '/export':
                        showExportModal();
                        break;
                    case '/hfexport':
                        showExportModal();
                        break;
                    case '/workers':
                        if (parts[1] === 'list') {
                            listWorkers();
                        } else if (parts[1] === 'start') {
                            if (parts[2]) toggleWorker(parts[2]);
                        } else if (parts[1] === 'stop') {
                            if (parts[2]) {
                                const worker = systemState.workers[parts[2]];
                                if (worker && worker.active) {
                                    toggleWorker(parts[2]);
                                }
                            }
                        } else {
                            logInfo('Usage: /workers [list|start|stop] [type]');
                        }
                        break;
                    case '/status':
                        showStatus();
                        break;
                    case '/samples':
                        logInfo(`Total samples: ${systemState.totalSamples}`);
                        break;
                    case '/fixhf':
                        logInfo('Hugging Face export FIXED in v4.0');
                        logInfo('Fixed post_processed: null');
                        logInfo('Fixed supervised_keys: null');
                        logInfo('Fixed Sequence features (removed length)');
                        break;
                    default:
                        logError(`Unknown command: ${cmd}. Type /help for commands.`);
                }
            }
        }
        
        function showHelp() {
            logInfo('=== AVAILABLE COMMANDS ===');
            logInfo('/help - Show this help');
            logInfo('/start - Start data collection');
            logInfo('/stop - Stop data collection');
            logInfo('/clear - Clear all data');
            logInfo('/export - Export Hugging Face dataset (FIXED v4.0)');
            logInfo('/hfexport - Same as /export');
            logInfo('/workers list - List available workers');
            logInfo('/workers start [type] - Start worker type');
            logInfo('/workers stop [type] - Stop worker type');
            logInfo('/status - Show system status');
            logInfo('/samples - Show sample count');
            logInfo('/fixhf - Info about HF fixes');
        }
        
        function listWorkers() {
            logInfo('=== WORKER TYPES ===');
            const types = ['dipole', 'solenoid', 'permanent', 'electro', 'toroid', 'anisotropic', 'halbach', 'custom'];
            types.forEach(type => {
                const worker = systemState.workers[type];
                const status = worker && worker.active ? 'ACTIVE' : 'STANDBY';
                logInfo(`${type}: ${status}`);
            });
        }
        
        function showStatus() {
            logInfo('=== SYSTEM STATUS ===');
            logInfo(`Active workers: ${systemState.activeWorkers}/8`);
            logInfo(`Total samples: ${systemState.totalSamples}`);
            logInfo(`Collection: ${systemState.isCollecting ? 'RUNNING' : 'STOPPED'}`);
            
            const elapsed = (Date.now() - systemState.startTime) / 1000;
            const throughput = elapsed > 0 ? Math.round(systemState.totalSamples / elapsed) : 0;
            logInfo(`Throughput: ${throughput}/s`);
            
            const totalSize = systemState.totalSamples * 128;
            const sizeMB = (totalSize / (1024 * 1024)).toFixed(2);
            logInfo(`Estimated size: ${sizeMB} MB`);
            logInfo(`HF Export: FIXED v4.0 (dataset_infos.json corrected)`);
        }
        
        // Fullscreen toggle
        function toggleFullscreen() {
            if (!document.fullscreenElement) {
                document.documentElement.requestFullscreen().catch(err => {
                    logError(`Fullscreen error: ${err.message}`);
                });
            } else {
                document.exitFullscreen();
            }
        }
        
        // System clock
        function updateClock() {
            const now = new Date();
            const timeStr = now.toLocaleTimeString();
            document.getElementById('systemTime').textContent = timeStr;
        }
        
        // Initialize system
        function initSystem() {
            // Initialize visualization
            initVisualization();
            
            // Initialize workers
            initWorkers();
            
            // Start system clock
            setInterval(updateClock, 1000);
            updateClock();
            
            // Update stats every 2 seconds
            setInterval(updateStats, 2000);
            
            // Start with dipole worker
            setTimeout(() => {
                toggleWorker('dipole');
                toggleWorker('solenoid');
            }, 1000);
            
            logInfo("System initialized v4.0");
            logInfo("Type /help for commands");
            logInfo("✅ Hugging Face export FIXED v4.0");
            logInfo("Fixed dataset_infos.json structure");
            logInfo("post_processed: null, supervised_keys: null");
        }
        
        // Window resize handler
        window.addEventListener('resize', () => {
            if (camera && renderer) {
                camera.aspect = document.getElementById('visual-canvas').clientWidth / 
                               document.getElementById('visual-canvas').clientHeight;
                camera.updateProjectionMatrix();
                renderer.setSize(document.getElementById('visual-canvas').clientWidth,
                               document.getElementById('visual-canvas').clientHeight);
            }
        });
        
        // Start system when page loads
        window.addEventListener('load', initSystem);
        
        // Export modal event delegation
        document.getElementById('exportModal').addEventListener('click', (e) => {
            e.stopPropagation();
        });
        
        // Focus command input on click
        document.getElementById('commandInput').focus();
        
        // Make functions globally available
        window.toggleWorker = toggleWorker;
        window.startCollection = startCollection;
        window.stopCollection = stopCollection;
        window.clearData = clearData;
        window.showExportModal = showExportModal;
        window.hideExportModal = hideExportModal;
        window.exportDataset = exportDataset;
        window.toggleFullscreen = toggleFullscreen;
        window.handleCommand = handleCommand;
    </script>
</body>
</html>