File size: 71,565 Bytes
18768dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d9aa04
 
 
 
 
 
 
 
 
 
18768dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d9aa04
18768dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4425a4f
18768dd
 
 
 
 
 
 
 
 
 
 
 
 
4425a4f
18768dd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
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
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Ramsey Graph Visualizer</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"></script>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Fraunces:opsz,wght@9..144,300;9..144,600&display=swap" rel="stylesheet">
    <style>
        :root {
            --bg-primary: #0a0a0a;
            --bg-secondary: #1a1a1a;
            --border-color: #2a2a2a;
            --text-primary: #e8e8e8;
            --text-secondary: #888888;
            --accent-red: #ff3366;
            --accent-blue: #00d4ff;
            --accent-green: #00ff88;
            --mono: 'JetBrains Mono', monospace;
            --serif: 'Fraunces', serif;
        }

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

        html, body {
            height: 100%;
            overflow: hidden;
        }

        body {
            background: var(--bg-primary);
            color: var(--text-primary);
            font-family: var(--mono);
            font-size: 13px;
            display: flex;
            flex-direction: column;
        }

        body::before {
            content: '';
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            background-image:
                linear-gradient(rgba(255, 51, 102, 0.03) 1px, transparent 1px),
                linear-gradient(90deg, rgba(255, 51, 102, 0.03) 1px, transparent 1px);
            background-size: 40px 40px;
            pointer-events: none;
            z-index: 0;
            animation: gridPulse 8s ease-in-out infinite;
        }

        @keyframes gridPulse {
            0%, 100% { opacity: 0.3; }
            50% { opacity: 0.6; }
        }

        .app {
            position: relative;
            z-index: 1;
            display: flex;
            flex-direction: column;
            height: 100vh;
            padding: 16px 24px;
            gap: 12px;
        }

        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-bottom: 12px;
            border-bottom: 1px solid var(--border-color);
            flex-shrink: 0;
        }

        .title-area {
            display: flex;
            align-items: baseline;
            gap: 16px;
        }

        h1 {
            font-family: var(--serif);
            font-size: 28px;
            font-weight: 600;
            background: linear-gradient(135deg, var(--text-primary), var(--accent-red));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }

        .subtitle {
            font-size: 11px;
            color: var(--text-secondary);
            text-transform: uppercase;
            letter-spacing: 0.1em;
        }

        .header-actions {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .action-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 8px 14px;
            font-size: 12px;
            border: 1px solid var(--border-color);
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            font-family: var(--mono);
            transition: all 0.2s ease;
        }

        .action-btn:hover {
            border-color: var(--accent-green);
            color: var(--accent-green);
        }

        .btn-icon {
            width: 16px;
            height: 16px;
            flex-shrink: 0;
        }

        .lang-toggle {
            display: flex;
            gap: 4px;
        }

        .lang-btn {
            display: flex;
            align-items: center;
            gap: 6px;
            padding: 6px 12px;
            font-size: 12px;
            border: 1px solid var(--border-color);
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            font-family: var(--mono);
            transition: all 0.2s ease;
        }

        .lang-icon {
            width: 14px;
            height: 14px;
            flex-shrink: 0;
        }

        .lang-btn.active {
            border-color: var(--accent-blue);
            background: var(--accent-blue);
            color: var(--bg-primary);
        }

        .lang-btn:hover:not(.active) {
            border-color: var(--accent-blue);
            color: var(--accent-blue);
        }

        .main-content {
            display: flex;
            gap: 16px;
            flex: 1;
            min-height: 0;
        }

        .sidebar {
            width: 280px;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            gap: 12px;
        }

        .panel {
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            padding: 16px;
        }

        .panel-title {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 0.15em;
            color: var(--text-secondary);
            margin-bottom: 12px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .panel-title::before {
            content: '';
            width: 8px;
            height: 8px;
            background: var(--accent-red);
        }

        .selector-grid {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr;
            gap: 8px;
            margin-bottom: 12px;
        }

        .selector-item label {
            display: block;
            font-size: 10px;
            color: var(--text-secondary);
            margin-bottom: 4px;
            text-transform: uppercase;
            letter-spacing: 0.1em;
        }

        select {
            width: 100%;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 8px;
            font-family: var(--mono);
            font-size: 13px;
            cursor: pointer;
        }

        select:focus {
            outline: none;
            border-color: var(--accent-red);
        }

        select:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        .btn {
            width: 100%;
            padding: 10px;
            font-family: var(--mono);
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            border: 1px solid var(--border-color);
            background: var(--bg-primary);
            color: var(--text-primary);
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn:hover:not(:disabled) {
            border-color: var(--accent-red);
            background: var(--accent-red);
            color: var(--bg-primary);
        }

        .btn:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }

        .btn-primary {
            border-color: var(--accent-red);
            background: rgba(255, 51, 102, 0.1);
        }

        .input-row {
            display: flex;
            gap: 8px;
            margin-bottom: 8px;
        }

        input[type="text"] {
            flex: 1;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            color: var(--text-primary);
            padding: 8px 10px;
            font-family: var(--mono);
            font-size: 12px;
        }

        input[type="text"]:focus {
            outline: none;
            border-color: var(--accent-red);
        }

        input[type="file"] {
            display: none;
        }

        .file-label {
            display: block;
            padding: 10px;
            text-align: center;
            border: 1px dashed var(--border-color);
            color: var(--text-secondary);
            cursor: pointer;
            font-size: 11px;
            transition: all 0.2s ease;
        }

        .file-label:hover {
            border-color: var(--accent-red);
            color: var(--accent-red);
        }

        .file-label.has-file {
            border-style: solid;
            border-color: var(--accent-green);
            color: var(--accent-green);
        }

        .divider {
            text-align: center;
            color: var(--text-secondary);
            font-size: 10px;
            margin: 8px 0;
            position: relative;
        }

        .divider::before, .divider::after {
            content: '';
            position: absolute;
            top: 50%;
            width: 40%;
            height: 1px;
            background: var(--border-color);
        }

        .divider::before { left: 0; }
        .divider::after { right: 0; }

        .status {
            padding: 8px 10px;
            font-size: 11px;
            border-left: 3px solid var(--accent-blue);
            background: rgba(0, 212, 255, 0.05);
            display: none;
        }

        .status.show { display: block; }
        .status.error {
            border-color: var(--accent-red);
            background: rgba(255, 51, 102, 0.05);
            color: var(--accent-red);
        }
        .status.success {
            border-color: var(--accent-green);
            background: rgba(0, 255, 136, 0.05);
            color: var(--accent-green);
        }

        .canvas-area {
            flex: 1;
            display: flex;
            flex-direction: column;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            min-width: 0;
        }

        .canvas-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 12px 16px;
            border-bottom: 1px solid var(--border-color);
            flex-shrink: 0;
            flex-wrap: wrap;
            gap: 12px;
        }

        .header-left {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .header-right {
            display: flex;
            align-items: center;
            gap: 16px;
        }

        .graph-info {
            display: flex;
            gap: 20px;
        }

        .info-item {
            text-align: center;
        }

        .info-value {
            font-size: 18px;
            font-weight: 700;
            color: var(--accent-red);
        }

        .info-label {
            font-size: 9px;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            color: var(--text-secondary);
        }

        .toggle-group {
            display: flex;
            gap: 4px;
        }

        .toggle-btn {
            padding: 6px 12px;
            font-size: 10px;
            text-transform: uppercase;
            border: 1px solid var(--border-color);
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
            font-family: var(--mono);
        }

        .toggle-btn.active {
            border-color: var(--accent-red);
            background: var(--accent-red);
            color: var(--bg-primary);
        }

        .toggle-btn:hover:not(.active) {
            border-color: var(--accent-red);
            color: var(--accent-red);
        }

        #canvas {
            flex: 1;
            position: relative;
            overflow: hidden;
        }

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

        .empty-state {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            color: var(--text-secondary);
        }

        .empty-icon {
            font-size: 48px;
            opacity: 0.3;
            margin-bottom: 8px;
            font-family: var(--serif);
        }

        .pagination {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 10px;
            border-top: 1px solid var(--border-color);
            flex-shrink: 0;
        }

        .pagination button {
            padding: 6px 12px;
            font-family: var(--mono);
            font-size: 11px;
            border: 1px solid var(--border-color);
            background: transparent;
            color: var(--text-secondary);
            cursor: pointer;
        }

        .pagination button:hover:not(:disabled) {
            border-color: var(--accent-red);
            color: var(--accent-red);
        }

        .pagination button:disabled {
            opacity: 0.3;
            cursor: not-allowed;
        }

        .page-info {
            min-width: 100px;
            text-align: center;
            color: var(--text-secondary);
            font-size: 12px;
        }

        .page-info span {
            color: var(--accent-red);
            font-weight: 700;
        }

        .node { cursor: pointer; }
        .node:hover { filter: brightness(1.3); }
        .link { stroke-opacity: 0.6; }
        .node-label {
            font-family: var(--mono);
            font-size: 10px;
            fill: var(--text-primary);
            text-anchor: middle;
            pointer-events: none;
        }

        .legend {
            display: flex;
            gap: 16px;
            font-size: 10px;
            color: var(--text-secondary);
        }

        .legend-item {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .legend-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
        }

        .legend-dot.red { background: var(--accent-red); }
        .legend-dot.blue { background: var(--accent-blue); }

        .loading {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: var(--text-secondary);
        }

        .loading::after {
            content: '';
            display: inline-block;
            width: 16px;
            height: 16px;
            border: 2px solid var(--border-color);
            border-top-color: var(--accent-red);
            border-radius: 50%;
            animation: spin 0.8s linear infinite;
            margin-left: 8px;
            vertical-align: middle;
        }

        @keyframes spin {
            to { transform: rotate(360deg); }
        }

        /* Matrix styles */
        .matrix-container {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            overflow: auto;
            padding: 20px;
        }

        .matrix-wrapper {
            display: flex;
            flex-direction: column;
            align-items: center;
        }

        .matrix-labels-top {
            display: flex;
            margin-left: 30px;
        }

        .matrix-label {
            width: var(--cell-size, 24px);
            height: 20px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            color: var(--text-secondary);
        }

        .matrix-row {
            display: flex;
            align-items: center;
        }

        .matrix-row-label {
            width: 30px;
            height: var(--cell-size, 24px);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            color: var(--text-secondary);
        }

        .matrix-cell {
            width: var(--cell-size, 24px);
            height: var(--cell-size, 24px);
            border: 1px solid var(--border-color);
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 10px;
            transition: all 0.15s ease;
        }

        .matrix-cell.edge {
            background: var(--accent-red);
            color: var(--bg-primary);
            font-weight: 700;
        }

        .matrix-cell.complement {
            background: var(--accent-blue);
            color: var(--bg-primary);
            font-weight: 700;
        }

        .matrix-cell.diagonal {
            background: var(--bg-primary);
            color: var(--text-secondary);
        }

        .matrix-cell.empty {
            background: transparent;
            color: var(--text-secondary);
        }

        .matrix-cell:hover:not(.diagonal) {
            transform: scale(1.1);
            z-index: 10;
            box-shadow: 0 0 10px rgba(255, 51, 102, 0.5);
        }

        /* Modal styles */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            z-index: 1000;
            align-items: center;
            justify-content: center;
        }

        .modal.show {
            display: flex;
        }

        .modal-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.8);
        }

        .modal-content {
            position: relative;
            background: var(--bg-secondary);
            border: 1px solid var(--border-color);
            max-width: 600px;
            max-height: 80vh;
            width: 90%;
            display: flex;
            flex-direction: column;
        }

        .modal-content.modal-large {
            max-width: 900px;
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px 20px;
            border-bottom: 1px solid var(--border-color);
        }

        .modal-header h2 {
            font-family: var(--serif);
            font-size: 20px;
            font-weight: 600;
            color: var(--text-primary);
        }

        .modal-close {
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--border-color);
            background: transparent;
            color: var(--text-secondary);
            font-size: 20px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .modal-close:hover {
            border-color: var(--accent-red);
            color: var(--accent-red);
        }

        .modal-body {
            padding: 20px;
            overflow-y: auto;
            font-size: 13px;
            line-height: 1.7;
            color: var(--text-secondary);
        }

        .modal-body p {
            margin-bottom: 12px;
        }

        .modal-body strong {
            color: var(--text-primary);
        }

        .modal-body .highlight {
            color: var(--accent-red);
            font-weight: 700;
        }

        .modal-body .challenge {
            padding: 16px;
            margin: 16px 0;
            background: rgba(255, 51, 102, 0.1);
            border-left: 3px solid var(--accent-red);
        }

        .modal-body .significance {
            padding: 16px;
            margin: 16px 0;
            background: rgba(0, 212, 255, 0.1);
            border-left: 3px solid var(--accent-blue);
        }

        /* Progress table */
        .ramsey-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 11px;
            margin-top: 12px;
        }

        .ramsey-table th,
        .ramsey-table td {
            padding: 8px 6px;
            border: 1px solid var(--border-color);
            text-align: center;
        }

        .ramsey-table th {
            background: var(--bg-primary);
            color: var(--accent-red);
            font-weight: 700;
        }

        .ramsey-table td.exact {
            background: rgba(0, 255, 136, 0.1);
            color: var(--accent-green);
        }

        .ramsey-table td.range {
            background: rgba(0, 212, 255, 0.1);
            color: var(--accent-blue);
        }

        .ramsey-table td.trivial {
            color: var(--text-secondary);
        }

        .table-legend {
            display: flex;
            gap: 20px;
            margin-top: 16px;
            font-size: 11px;
        }

        .table-legend-item {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .legend-box {
            width: 16px;
            height: 16px;
        }

        .legend-box.exact {
            background: rgba(0, 255, 136, 0.1);
            border: 1px solid var(--accent-green);
        }

        .legend-box.range {
            background: rgba(0, 212, 255, 0.1);
            border: 1px solid var(--accent-blue);
        }

        /* Links panel */
        .panel-links {
            margin-top: auto;
        }

        .link-list {
            display: flex;
            flex-direction: column;
            gap: 6px;
        }

        .link-list a {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 8px 10px;
            background: var(--bg-primary);
            border: 1px solid var(--border-color);
            color: var(--text-secondary);
            text-decoration: none;
            font-size: 11px;
            transition: all 0.2s ease;
        }

        .link-list a:hover {
            border-color: var(--accent-red);
            color: var(--text-primary);
        }

        .link-icon {
            width: 28px;
            height: 28px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--border-color);
            color: var(--text-primary);
            flex-shrink: 0;
            padding: 5px;
        }

        .link-icon svg {
            width: 100%;
            height: 100%;
        }

        .link-list a:hover .link-icon {
            background: var(--accent-red);
            color: var(--bg-primary);
        }

        .link-text {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        @media (max-width: 900px) {
            .main-content {
                flex-direction: column;
            }
            .sidebar {
                width: 100%;
                flex-direction: row;
                flex-wrap: wrap;
            }
            .sidebar .panel {
                flex: 1;
                min-width: 200px;
            }
            .panel-links {
                margin-top: 0;
            }
            .canvas-header {
                flex-direction: column;
                align-items: flex-start;
            }
        }
    </style>
</head>
<body>
    <div class="app">
        <header>
            <div class="title-area">
                <h1>Ramsey Graph</h1>
                <span class="subtitle" data-i18n="subtitle">Interactive Visualizer</span>
            </div>
            <div class="header-actions">
                <button class="action-btn" id="introBtn">
                    <svg class="btn-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20"></path>
                        <path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"></path>
                    </svg>
                    <span data-i18n="introduction">Introduction</span>
                </button>
                <button class="action-btn" id="progressBtn">
                    <svg class="btn-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                        <path d="M18 20V10"></path>
                        <path d="M12 20V4"></path>
                        <path d="M6 20v-6"></path>
                    </svg>
                    <span data-i18n="progress">Progress</span>
                </button>
                <div class="lang-toggle">
                    <button class="lang-btn active" data-lang="en">
                        <svg class="lang-icon" viewBox="0 0 24 24" fill="currentColor">
                            <circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.5"/>
                            <path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" fill="none" stroke="currentColor" stroke-width="1.5"/>
                        </svg>
                        EN
                    </button>
                    <button class="lang-btn" data-lang="zh">
                        <svg class="lang-icon" viewBox="0 0 24 24" fill="currentColor">
                            <circle cx="12" cy="12" r="10" fill="none" stroke="currentColor" stroke-width="1.5"/>
                            <path d="M2 12h20M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" fill="none" stroke="currentColor" stroke-width="1.5"/>
                        </svg>
                        中文
                    </button>
                </div>
            </div>
        </header>

        <div class="main-content">
            <div class="sidebar">
                <div class="panel">
                    <div class="panel-title" data-i18n="selectDataset">Select Dataset</div>
                    <div class="selector-grid">
                        <div class="selector-item">
                            <label>s</label>
                            <select id="selectS"></select>
                        </div>
                        <div class="selector-item">
                            <label>t</label>
                            <select id="selectT"></select>
                        </div>
                        <div class="selector-item">
                            <label>n</label>
                            <select id="selectN"></select>
                        </div>
                    </div>
                    <button class="btn btn-primary" id="loadDatasetBtn" data-i18n="loadDataset">Load Ramsey(s,t,n)</button>
                    <div id="datasetInfo" style="margin-top: 8px; font-size: 10px; color: var(--text-secondary);"></div>
                </div>

                <div class="panel">
                    <div class="panel-title" data-i18n="customSource">Custom Source</div>
                    <div class="input-row">
                        <input type="text" id="urlInput" data-i18n-placeholder="urlPlaceholder" placeholder="Enter .g6 file URL...">
                    </div>
                    <button class="btn" id="loadUrlBtn" data-i18n="loadUrl">Load URL</button>
                    <div class="divider" data-i18n="or">or</div>
                    <input type="file" id="fileInput" accept=".g6">
                    <label class="file-label" id="fileLabel" for="fileInput" data-i18n="uploadFile">
                        Drop or click to upload .g6 file
                    </label>
                </div>

                <div id="status" class="status"></div>

                <div class="panel panel-links">
                    <div class="panel-title" data-i18n="links">Links</div>
                    <div class="link-list">
                        <a href="https://huggingface.co/datasets/linxy/RamseyGraph" target="_blank">
                            <span class="link-icon">
                                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                                    <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"></path>
                                    <polyline points="3.27 6.96 12 12.01 20.73 6.96"></polyline>
                                    <line x1="12" y1="22.08" x2="12" y2="12"></line>
                                </svg>
                            </span>
                            <span class="link-text" data-i18n="hfDataset">HuggingFace Dataset</span>
                        </a>
                        <a href="https://github.com/LinXueyuanStdio/RamseyGraph" target="_blank">
                            <span class="link-icon">
                                <svg viewBox="0 0 24 24" fill="currentColor">
                                    <path d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"/>
                                </svg>
                            </span>
                            <span class="link-text" data-i18n="ghRepo">GitHub Repository</span>
                        </a>
                        <a href="https://users.cecs.anu.edu.au/~bdm/data/ramsey.html" target="_blank">
                            <span class="link-icon">
                                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                                    <ellipse cx="12" cy="5" rx="9" ry="3"></ellipse>
                                    <path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path>
                                    <path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path>
                                </svg>
                            </span>
                            <span class="link-text" data-i18n="originDb">Origin Database</span>
                        </a>
                        <a href="mailto:linxy59@mail2.sysu.edu.cn">
                            <span class="link-icon">
                                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                                    <path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"></path>
                                    <polyline points="22,6 12,13 2,6"></polyline>
                                </svg>
                            </span>
                            <span class="link-text" data-i18n="contact">Contact</span>
                        </a>
                        <a href="https://www.combinatorics.org" target="_blank">
                            <span class="link-icon">
                                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                                    <path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path>
                                    <path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path>
                                </svg>
                            </span>
                            <span class="link-text" data-i18n="wiki">E-JC Survey</span>
                        </a>
                        <a href="https://en.wikipedia.org/wiki/Ramsey%27s_theorem" target="_blank" id="wikiLink">
                            <span class="link-icon">
                                <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
                                    <circle cx="12" cy="12" r="10"></circle>
                                    <path d="M12 16v-4"></path>
                                    <path d="M12 8h.01"></path>
                                </svg>
                            </span>
                            <span class="link-text" data-i18n="wikiLink">Wikipedia</span>
                        </a>
                    </div>
                </div>
            </div>

            <div class="canvas-area">
                <div class="canvas-header">
                    <div class="header-left">
                        <div class="graph-info">
                            <div class="info-item">
                                <div class="info-value" id="nodeCount">-</div>
                                <div class="info-label" data-i18n="nodes">Nodes</div>
                            </div>
                            <div class="info-item">
                                <div class="info-value" id="edgeCount">-</div>
                                <div class="info-label" data-i18n="edges">Edges</div>
                            </div>
                        </div>
                        <div class="legend">
                            <div class="legend-item"><div class="legend-dot red"></div><span data-i18n="graphG">Graph G</span></div>
                            <div class="legend-item"><div class="legend-dot blue"></div><span data-i18n="complement">Complement</span></div>
                        </div>
                    </div>
                    <div class="header-right">
                        <div class="toggle-group" id="displayToggle">
                            <button class="toggle-btn active" data-display="force" data-i18n="force">Force</button>
                            <button class="toggle-btn" data-display="matrix" data-i18n="matrix">Matrix</button>
                        </div>
                        <div class="toggle-group" id="viewToggle">
                            <button class="toggle-btn active" data-mode="graph">G</button>
                            <button class="toggle-btn" data-mode="complement">G'</button>
                            <button class="toggle-btn" data-mode="both" data-i18n="both">Both</button>
                        </div>
                    </div>
                </div>
                <div id="canvas">
                    <div class="empty-state">
                        <div class="empty-icon">R</div>
                        <div data-i18n="emptyState">Select a dataset or upload a file</div>
                    </div>
                </div>
                <div class="pagination" id="pagination" style="display: none;">
                    <button id="prevBtn" data-i18n="prev">&lt; Prev</button>
                    <div class="page-info">
                        <span data-i18n="graph">Graph</span> <span id="currentPage">1</span> / <span id="totalPages">1</span>
                    </div>
                    <button id="nextBtn" data-i18n="next">Next &gt;</button>
                </div>
            </div>
        </div>

        <!-- Introduction Modal -->
        <div class="modal" id="introModal">
            <div class="modal-overlay"></div>
            <div class="modal-content">
                <div class="modal-header">
                    <h2 data-i18n="introTitle">What is a Ramsey Graph?</h2>
                    <button class="modal-close">&times;</button>
                </div>
                <div class="modal-body" id="introBody">
                </div>
            </div>
        </div>

        <!-- Progress Modal -->
        <div class="modal" id="progressModal">
            <div class="modal-overlay"></div>
            <div class="modal-content modal-large">
                <div class="modal-header">
                    <h2 data-i18n="progressTitle">Known Ramsey Numbers</h2>
                    <button class="modal-close">&times;</button>
                </div>
                <div class="modal-body" id="progressBody">
                </div>
            </div>
        </div>

    </div>

    <script>
        // i18n translations
        const i18n = {
            en: {
                subtitle: 'Interactive Visualizer',
                selectDataset: 'Select Dataset',
                loadDataset: 'Load Ramsey(s,t,n)',
                customSource: 'Custom Source',
                urlPlaceholder: 'Enter .g6 file URL...',
                loadUrl: 'Load URL',
                or: 'or',
                uploadFile: 'Drop or click to upload .g6 file',
                links: 'Links',
                hfDataset: 'HuggingFace Dataset',
                ghRepo: 'GitHub Repository',
                originDb: 'Origin Database',
                contact: 'Contact',
                wiki: 'E-JC Survey',
                nodes: 'Nodes',
                edges: 'Edges',
                graphG: 'Graph G',
                complement: 'Complement',
                force: 'Force',
                matrix: 'Matrix',
                both: 'Both',
                emptyState: 'Select a dataset or upload a file',
                prev: '< Prev',
                next: 'Next >',
                graph: 'Graph',
                loading: 'Loading',
                loadedGraphs: 'Loaded {0} graph(s)',
                noValidGraphs: 'No valid graphs found',
                errorLoading: 'Error: {0}',
                failedToLoad: 'Failed to load',
                graphCount: '{0} graph(s)',
                compressed: '(compressed)',
                introduction: 'Introduction',
                progress: 'Progress',
                introTitle: 'What is a Ramsey Graph?',
                progressTitle: 'Known Ramsey Numbers',
                exactValue: 'Exact value known',
                rangeValue: 'Only bounds known',
                wikiLink: 'Wikipedia'
            },
            zh: {
                subtitle: '交互式可视化工具',
                selectDataset: '选择数据集',
                loadDataset: '加载 Ramsey(s,t,n)',
                customSource: '自定义来源',
                urlPlaceholder: '输入 .g6 文件 URL...',
                loadUrl: '加载 URL',
                or: '或',
                uploadFile: '拖放或点击上传 .g6 文件',
                links: '链接',
                hfDataset: 'HuggingFace 数据集',
                ghRepo: 'GitHub 仓库',
                originDb: '原始数据库',
                contact: '联系方式',
                wiki: '电子组合学期刊',
                nodes: '节点',
                edges: '边',
                graphG: '图 G',
                complement: '补图',
                force: '力导向',
                matrix: '矩阵',
                both: '两者',
                emptyState: '选择数据集或上传文件',
                prev: '< 上一个',
                next: '下一个 >',
                graph: '图',
                loading: '加载中',
                loadedGraphs: '已加载 {0} 个图',
                noValidGraphs: '未找到有效的图',
                errorLoading: '错误: {0}',
                failedToLoad: '加载失败',
                graphCount: '{0} 个图',
                compressed: '(压缩)',
                introduction: '介绍',
                progress: '进展',
                introTitle: '什么是拉姆齐图?',
                progressTitle: '已知拉姆齐数',
                exactValue: '精确值已知',
                rangeValue: '仅知道上下界',
                wikiLink: '维基百科'
            }
        };

        const wikiUrls = {
            en: 'https://en.wikipedia.org/wiki/Ramsey%27s_theorem',
            zh: 'https://zh.wikipedia.org/wiki/%E6%8B%89%E5%A7%86%E9%BD%90%E5%AE%9A%E7%90%86'
        };

        let currentLang = localStorage.getItem('lang') || 'en';

        function t(key, ...args) {
            let text = i18n[currentLang][key] || i18n['en'][key] || key;
            args.forEach((arg, i) => {
                text = text.replace(`{${i}}`, arg);
            });
            return text;
        }

        function applyLanguage() {
            document.querySelectorAll('[data-i18n]').forEach(el => {
                const key = el.getAttribute('data-i18n');
                el.textContent = t(key);
            });
            document.querySelectorAll('[data-i18n-placeholder]').forEach(el => {
                const key = el.getAttribute('data-i18n-placeholder');
                el.placeholder = t(key);
            });
            // Update wiki link URL based on language
            const wikiLink = document.getElementById('wikiLink');
            if (wikiLink) {
                wikiLink.href = wikiUrls[currentLang] || wikiUrls.en;
            }
            // Update dataset info if loaded
            if (selectS.value) updateDatasetInfo();
        }

        function setLanguage(lang) {
            currentLang = lang;
            localStorage.setItem('lang', lang);
            document.querySelectorAll('.lang-btn').forEach(btn => {
                btn.classList.toggle('active', btn.dataset.lang === lang);
            });
            applyLanguage();
        }

        // Dataset configuration based on data/ folder
        const DATASETS = {
            '3,4': [1,2,3,4,5,6,7,8],
            '3,5': [1,2,3,4,5,6,7,8,9,10,11,12,13],
            '3,6': [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],
            '3,7': [21,22],
            '3,8': [27],
            '3,9': [35],
            '4,4': [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],
            '4,5': [24],
            '4,6': [35],
            '5,5': [42]
        };

        // Files that are compressed (gzipped)
        const COMPRESSED = new Set([
            'r36_11', 'r36_12', 'r36_13', 'r36_14', 'r36_15', 'r36_16',
            'r37_21', 'r38_27',
            'r44_10', 'r44_11', 'r44_12', 'r44_13', 'r44_14'
        ]);

        // Approximate graph counts for info display
        const GRAPH_COUNTS = {
            'r34_1':1,'r34_2':2,'r34_3':3,'r34_4':6,'r34_5':9,'r34_6':15,'r34_7':9,'r34_8':3,
            'r35_1':1,'r35_2':2,'r35_3':3,'r35_4':7,'r35_5':13,'r35_6':32,'r35_7':71,'r35_8':179,'r35_9':290,'r35_10':313,'r35_11':105,'r35_12':12,'r35_13':1,
            'r36_1':1,'r36_2':2,'r36_3':3,'r36_4':7,'r36_5':14,'r36_6':37,'r36_7':100,'r36_8':356,'r36_9':1407,'r36_10':6657,'r36_11':30395,'r36_12':116792,'r36_13':275086,'r36_14':263520,'r36_15':64732,'r36_16':2576,'r36_17':7,
            'r37_21':1118436,'r37_22':191,
            'r38_27':477142,
            'r39_35':1,
            'r44_1':1,'r44_2':2,'r44_3':4,'r44_4':9,'r44_5':24,'r44_6':84,'r44_7':362,'r44_8':2079,'r44_9':14701,'r44_10':103706,'r44_11':546356,'r44_12':1449166,'r44_13':1184231,'r44_14':130816,'r44_15':640,'r44_16':2,'r44_17':1,
            'r45_24':352366,
            'r46_35some':37,
            'r55_42some':328
        };

        // State
        let graphs = [];
        let currentIndex = 0;
        let viewMode = 'graph';
        let displayMode = 'force';
        let simulation = null;

        // DOM
        const selectS = document.getElementById('selectS');
        const selectT = document.getElementById('selectT');
        const selectN = document.getElementById('selectN');
        const loadDatasetBtn = document.getElementById('loadDatasetBtn');
        const datasetInfo = document.getElementById('datasetInfo');
        const urlInput = document.getElementById('urlInput');
        const loadUrlBtn = document.getElementById('loadUrlBtn');
        const fileInput = document.getElementById('fileInput');
        const fileLabel = document.getElementById('fileLabel');
        const status = document.getElementById('status');
        const canvas = document.getElementById('canvas');
        const pagination = document.getElementById('pagination');
        const prevBtn = document.getElementById('prevBtn');
        const nextBtn = document.getElementById('nextBtn');
        const currentPage = document.getElementById('currentPage');
        const totalPages = document.getElementById('totalPages');
        const nodeCount = document.getElementById('nodeCount');
        const edgeCount = document.getElementById('edgeCount');

        // Initialize selectors
        function initSelectors() {
            const sValues = [...new Set(Object.keys(DATASETS).map(k => k.split(',')[0]))].sort((a,b) => a-b);
            selectS.innerHTML = sValues.map(s => `<option value="${s}">${s}</option>`).join('');
            updateTOptions();
        }

        function updateTOptions() {
            const s = selectS.value;
            const tValues = [...new Set(Object.keys(DATASETS).filter(k => k.startsWith(s+',')).map(k => k.split(',')[1]))].sort((a,b) => a-b);
            selectT.innerHTML = tValues.map(t => `<option value="${t}">${t}</option>`).join('');
            updateNOptions();
        }

        function updateNOptions() {
            const key = `${selectS.value},${selectT.value}`;
            const nValues = DATASETS[key] || [];
            selectN.innerHTML = nValues.map(n => `<option value="${n}">${n}</option>`).join('');
            updateDatasetInfo();
        }

        function updateDatasetInfo() {
            const s = selectS.value, tVal = selectT.value, n = selectN.value;
            const fileKey = `r${s}${tVal}_${n}`;
            const count = GRAPH_COUNTS[fileKey] || GRAPH_COUNTS[fileKey + 'some'] || '?';
            const isCompressed = COMPRESSED.has(fileKey);
            const countText = t('graphCount', count.toLocaleString());
            datasetInfo.innerHTML = `${countText}${isCompressed ? ` <span style="color:var(--accent-blue)">${t('compressed')}</span>` : ''}`;
        }

        function getDatasetUrl() {
            const s = selectS.value, t = selectT.value, n = selectN.value;
            let fileKey = `r${s}${t}_${n}`;
            if (['4,6', '5,5'].includes(`${s},${t}`)) {
                fileKey += 'some';
            }
            const ext = COMPRESSED.has(fileKey.replace('some','')) ? '.g6.gz' : '.g6';
            return `https://huggingface.co/datasets/linxy/RamseyGraph/resolve/main/data/${fileKey}${ext}?download=true`;
        }

        selectS.addEventListener('change', updateTOptions);
        selectT.addEventListener('change', updateNOptions);
        selectN.addEventListener('change', updateDatasetInfo);

        // Status helper
        function showStatus(msg, type = 'info') {
            status.textContent = msg;
            status.className = `status show ${type}`;
            if (type !== 'error') {
                setTimeout(() => status.className = 'status', 3000);
            }
        }

        // Parse graph6
        function parseGraph6(line) {
            line = line.trim();
            if (!line) return null;

            let pos = 0;
            let n;
            const firstByte = line.charCodeAt(pos) - 63;

            if (firstByte < 63) {
                n = firstByte;
                pos++;
            } else if (line.charCodeAt(pos + 1) - 63 < 63) {
                n = ((line.charCodeAt(pos + 1) - 63) << 12) |
                    ((line.charCodeAt(pos + 2) - 63) << 6) |
                    (line.charCodeAt(pos + 3) - 63);
                pos += 4;
            } else {
                n = ((line.charCodeAt(pos + 2) - 63) << 30) |
                    ((line.charCodeAt(pos + 3) - 63) << 24) |
                    ((line.charCodeAt(pos + 4) - 63) << 18) |
                    ((line.charCodeAt(pos + 5) - 63) << 12) |
                    ((line.charCodeAt(pos + 6) - 63) << 6) |
                    (line.charCodeAt(pos + 7) - 63);
                pos += 8;
            }

            const edges = [];
            let bitPos = 0;
            let currentByte = 0;

            for (let j = 1; j < n; j++) {
                for (let i = 0; i < j; i++) {
                    if (bitPos === 0) {
                        if (pos >= line.length) break;
                        currentByte = line.charCodeAt(pos) - 63;
                        pos++;
                    }
                    const bit = (currentByte >> (5 - bitPos)) & 1;
                    bitPos = (bitPos + 1) % 6;
                    if (bit === 1) edges.push([i, j]);
                }
            }

            return { nodes: n, edges };
        }

        // Load functions
        async function loadFromUrl(url) {
            showStatus(t('loading') + '...', 'info');
            canvas.innerHTML = `<div class="loading">${t('loading')}</div>`;

            try {
                const response = await fetch(url);
                if (!response.ok) throw new Error(`HTTP ${response.status}`);

                let text;
                if (url.includes('.gz')) {
                    const buffer = await response.arrayBuffer();
                    const decompressed = await decompress(buffer);
                    text = new TextDecoder().decode(decompressed);
                } else {
                    text = await response.text();
                }

                parseAndDisplay(text);
                showStatus(t('loadedGraphs', graphs.length), 'success');
            } catch (err) {
                showStatus(t('errorLoading', err.message), 'error');
                canvas.innerHTML = `<div class="empty-state"><div class="empty-icon">!</div><div>${t('failedToLoad')}</div></div>`;
            }
        }

        async function decompress(buffer) {
            const ds = new DecompressionStream('gzip');
            const decompressedStream = new Response(new Blob([buffer]).stream().pipeThrough(ds)).arrayBuffer();
            return new Uint8Array(await decompressedStream);
        }

        function loadFromFile(file) {
            showStatus(t('loading') + '...', 'info');
            const reader = new FileReader();

            reader.onload = async (e) => {
                let text;
                if (file.name.endsWith('.gz')) {
                    const decompressed = await decompress(e.target.result);
                    text = new TextDecoder().decode(decompressed);
                } else {
                    text = e.target.result;
                }
                parseAndDisplay(text);
                showStatus(t('loadedGraphs', graphs.length), 'success');
            };

            reader.onerror = () => showStatus(t('errorLoading', 'File read error'), 'error');

            if (file.name.endsWith('.gz')) {
                reader.readAsArrayBuffer(file);
            } else {
                reader.readAsText(file);
            }
        }

        function parseAndDisplay(text) {
            graphs = [];
            const lines = text.split('\n');
            for (const line of lines) {
                const g = parseGraph6(line);
                if (g) graphs.push(g);
            }

            if (graphs.length > 0) {
                currentIndex = 0;
                updatePagination();
                visualize(0);
            } else {
                showStatus(t('noValidGraphs'), 'error');
            }
        }

        function updatePagination() {
            pagination.style.display = graphs.length > 1 ? 'flex' : 'none';
            currentPage.textContent = currentIndex + 1;
            totalPages.textContent = graphs.length;
            prevBtn.disabled = currentIndex === 0;
            nextBtn.disabled = currentIndex === graphs.length - 1;
        }

        function getComplement(n, edges) {
            const set = new Set(edges.map(e => `${e[0]}-${e[1]}`));
            const comp = [];
            for (let i = 0; i < n; i++) {
                for (let j = i + 1; j < n; j++) {
                    if (!set.has(`${i}-${j}`)) comp.push([i, j]);
                }
            }
            return comp;
        }

        // Build adjacency matrix
        function buildAdjMatrix(n, edges) {
            const matrix = Array.from({ length: n }, () => Array(n).fill(0));
            for (const [i, j] of edges) {
                matrix[i][j] = 1;
                matrix[j][i] = 1;
            }
            return matrix;
        }

        // Main visualization dispatcher
        function visualize(index) {
            if (index < 0 || index >= graphs.length) return;
            currentIndex = index;
            const g = graphs[index];

            nodeCount.textContent = g.nodes;
            edgeCount.textContent = g.edges.length;
            updatePagination();

            if (displayMode === 'force') {
                visualizeForce(g);
            } else {
                visualizeMatrix(g);
            }
        }

        // Force-directed graph visualization
        function visualizeForce(g) {
            canvas.innerHTML = '';

            const nodes = Array.from({ length: g.nodes }, (_, i) => ({ id: i }));
            let links = [];

            if (viewMode === 'graph') {
                links = g.edges.map(e => ({ source: e[0], target: e[1], type: 'graph' }));
            } else if (viewMode === 'complement') {
                links = getComplement(g.nodes, g.edges).map(e => ({ source: e[0], target: e[1], type: 'complement' }));
            } else {
                links = g.edges.map(e => ({ source: e[0], target: e[1], type: 'graph' }));
                links = links.concat(getComplement(g.nodes, g.edges).map(e => ({ source: e[0], target: e[1], type: 'complement' })));
            }

            const rect = canvas.getBoundingClientRect();
            const width = rect.width;
            const height = rect.height;

            const svg = d3.select('#canvas').append('svg').attr('width', width).attr('height', height);

            simulation = d3.forceSimulation(nodes)
                .force('link', d3.forceLink(links).id(d => d.id).distance(60))
                .force('charge', d3.forceManyBody().strength(-150))
                .force('center', d3.forceCenter(width / 2, height / 2))
                .force('collision', d3.forceCollide().radius(16));

            const link = svg.append('g')
                .selectAll('line')
                .data(links)
                .join('line')
                .attr('class', 'link')
                .attr('stroke', d => d.type === 'graph' ? '#ff3366' : '#00d4ff')
                .attr('stroke-width', 2);

            const node = svg.append('g')
                .selectAll('circle')
                .data(nodes)
                .join('circle')
                .attr('class', 'node')
                .attr('r', 8)
                .attr('fill', '#e8e8e8')
                .call(drag(simulation));

            const label = svg.append('g')
                .selectAll('text')
                .data(nodes)
                .join('text')
                .attr('class', 'node-label')
                .text(d => d.id);

            simulation.on('tick', () => {
                link.attr('x1', d => d.source.x).attr('y1', d => d.source.y)
                    .attr('x2', d => d.target.x).attr('y2', d => d.target.y);
                node.attr('cx', d => d.x).attr('cy', d => d.y);
                label.attr('x', d => d.x).attr('y', d => d.y + 20);
            });
        }

        // Matrix visualization
        function visualizeMatrix(g) {
            canvas.innerHTML = '';

            const n = g.nodes;
            const edgeMatrix = buildAdjMatrix(n, g.edges);
            const compMatrix = buildAdjMatrix(n, getComplement(n, g.edges));

            // Calculate cell size based on available space
            const rect = canvas.getBoundingClientRect();
            const availableSize = Math.min(rect.width - 80, rect.height - 60);
            const cellSize = Math.max(16, Math.min(32, Math.floor(availableSize / n)));

            const container = document.createElement('div');
            container.className = 'matrix-container';

            const wrapper = document.createElement('div');
            wrapper.className = 'matrix-wrapper';
            wrapper.style.setProperty('--cell-size', `${cellSize}px`);

            // Top labels
            const topLabels = document.createElement('div');
            topLabels.className = 'matrix-labels-top';
            for (let j = 0; j < n; j++) {
                const label = document.createElement('div');
                label.className = 'matrix-label';
                label.textContent = j;
                topLabels.appendChild(label);
            }
            wrapper.appendChild(topLabels);

            // Matrix rows
            for (let i = 0; i < n; i++) {
                const row = document.createElement('div');
                row.className = 'matrix-row';

                // Row label
                const rowLabel = document.createElement('div');
                rowLabel.className = 'matrix-row-label';
                rowLabel.textContent = i;
                row.appendChild(rowLabel);

                // Cells
                for (let j = 0; j < n; j++) {
                    const cell = document.createElement('div');
                    cell.className = 'matrix-cell';

                    if (i === j) {
                        cell.classList.add('diagonal');
                        cell.textContent = '-';
                    } else {
                        const isEdge = edgeMatrix[i][j] === 1;
                        const isComp = compMatrix[i][j] === 1;

                        if (viewMode === 'graph') {
                            if (isEdge) {
                                cell.classList.add('edge');
                                cell.textContent = '1';
                            } else {
                                cell.classList.add('empty');
                                cell.textContent = '0';
                            }
                        } else if (viewMode === 'complement') {
                            if (isComp) {
                                cell.classList.add('complement');
                                cell.textContent = '1';
                            } else {
                                cell.classList.add('empty');
                                cell.textContent = '0';
                            }
                        } else { // both
                            if (isEdge) {
                                cell.classList.add('edge');
                                cell.textContent = '1';
                            } else if (isComp) {
                                cell.classList.add('complement');
                                cell.textContent = '1';
                            } else {
                                cell.classList.add('empty');
                                cell.textContent = '0';
                            }
                        }
                    }

                    cell.title = `(${i}, ${j})`;
                    row.appendChild(cell);
                }

                wrapper.appendChild(row);
            }

            container.appendChild(wrapper);
            canvas.appendChild(container);
        }

        function drag(sim) {
            return d3.drag()
                .on('start', e => { if (!e.active) sim.alphaTarget(0.3).restart(); e.subject.fx = e.subject.x; e.subject.fy = e.subject.y; })
                .on('drag', e => { e.subject.fx = e.x; e.subject.fy = e.y; })
                .on('end', e => { if (!e.active) sim.alphaTarget(0); e.subject.fx = null; e.subject.fy = null; });
        }

        // Event listeners
        loadDatasetBtn.addEventListener('click', () => loadFromUrl(getDatasetUrl()));

        loadUrlBtn.addEventListener('click', () => {
            const url = urlInput.value.trim();
            if (url) loadFromUrl(url);
        });

        urlInput.addEventListener('keypress', e => {
            if (e.key === 'Enter') loadUrlBtn.click();
        });

        fileInput.addEventListener('change', e => {
            if (e.target.files[0]) {
                fileLabel.textContent = e.target.files[0].name;
                fileLabel.classList.add('has-file');
                loadFromFile(e.target.files[0]);
            }
        });

        prevBtn.addEventListener('click', () => { if (currentIndex > 0) visualize(currentIndex - 1); });
        nextBtn.addEventListener('click', () => { if (currentIndex < graphs.length - 1) visualize(currentIndex + 1); });

        // Display mode toggle (Force / Matrix)
        document.querySelectorAll('#displayToggle .toggle-btn').forEach(btn => {
            btn.addEventListener('click', e => {
                document.querySelectorAll('#displayToggle .toggle-btn').forEach(b => b.classList.remove('active'));
                e.target.classList.add('active');
                displayMode = e.target.dataset.display;
                if (graphs.length > 0) visualize(currentIndex);
            });
        });

        // View mode toggle (G / G' / Both)
        document.querySelectorAll('#viewToggle .toggle-btn').forEach(btn => {
            btn.addEventListener('click', e => {
                document.querySelectorAll('#viewToggle .toggle-btn').forEach(b => b.classList.remove('active'));
                e.target.classList.add('active');
                viewMode = e.target.dataset.mode;
                if (graphs.length > 0) visualize(currentIndex);
            });
        });

        // Keyboard navigation
        document.addEventListener('keydown', e => {
            if (graphs.length === 0) return;
            if (e.key === 'ArrowLeft' || e.key === 'a') prevBtn.click();
            if (e.key === 'ArrowRight' || e.key === 'd') nextBtn.click();
            if (e.key === 'm') {
                displayMode = displayMode === 'force' ? 'matrix' : 'force';
                document.querySelectorAll('#displayToggle .toggle-btn').forEach(b => {
                    b.classList.toggle('active', b.dataset.display === displayMode);
                });
                visualize(currentIndex);
            }
        });

        // Language toggle
        document.querySelectorAll('.lang-btn').forEach(btn => {
            btn.addEventListener('click', () => setLanguage(btn.dataset.lang));
        });

        // Modal content
        const trophyIcon = '<svg style="width:16px;height:16px;vertical-align:middle;margin-right:4px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9H4.5a2.5 2.5 0 0 1 0-5H6"></path><path d="M18 9h1.5a2.5 2.5 0 0 0 0-5H18"></path><path d="M4 22h16"></path><path d="M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"></path><path d="M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"></path><path d="M18 2H6v7a6 6 0 0 0 12 0V2Z"></path></svg>';
        const lightbulbIcon = '<svg style="width:16px;height:16px;vertical-align:middle;margin-right:4px;" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"></path><path d="M9 18h6"></path><path d="M10 22h4"></path></svg>';
        const introContent = {
            en: `
                <p><strong>A Ramsey(s,t,n) graph</strong> is a graph with <span class="highlight">n vertices</span> that contains no clique of size s and no independent set of size t.</p>
                <p>The <strong>Ramsey Theorem</strong> states that for given s and t, the number of Ramsey(s,t) graphs is finite. The minimum number of vertices for which no such graph exists is called the <strong>Ramsey Number R(s,t)</strong>.</p>
                <p>For given s and t, as the number of vertices n increases, there exists a <span class="highlight">critical threshold</span>—once n exceeds this threshold, a clique of size s or an independent set of size t <strong>must</strong> exist in any graph. Finding Ramsey graphs means finding this critical vertex count: the exact point where we can still find at least one special graph that contains neither a clique of size s nor an independent set of size t.</p>
                <div class="significance">
                    <strong>${lightbulbIcon}Why It Matters:</strong> If we had an algorithm to determine the exact Ramsey number in advance, we would know precisely when certain substructures <strong>must</strong> appear in a system. This knowledge could help avoid maintaining excess nodes, potentially saving significant costs in network design, distributed systems, and other applications.
                </div>
                <p>Finding all such graphs, or even determining the maximum n for which they exist, is a famous problem in combinatorics. Most Ramsey numbers are still unknown—we only know upper and lower bounds.</p>
                <div class="challenge">
                    <strong>${trophyIcon}Open Challenge:</strong> Find a <span class="highlight">Ramsey(5,5) graph with 43 vertices</span>!<br><br>
                    All 42-vertex Ramsey(5,5) graphs have been found, but it's unknown if a 43-vertex one exists. The lower bound of R(5,5) hasn't been improved since <strong>1989</strong>. Finding just one such graph would be a major breakthrough—${new Date().getFullYear() - 1989} years in the making!
                </div>
                <p>For the latest research on Ramsey graphs, see <strong>Radziszowski's</strong> dynamic survey published in the <a href="https://www.combinatorics.org" target="_blank" style="color: var(--accent-blue);">Electronic Journal of Combinatorics</a>.</p>
            `,
            zh: `
                <p><strong>Ramsey(s,t,n) 图</strong>是具有 <span class="highlight">n 个顶点</span>的图,它不包含大小为 s 的团,也不包含大小为 t 的独立集。</p>
                <p><strong>拉姆齐定理</strong>表明,对于给定的 s 和 t,Ramsey(s,t) 图的数量是有限的。满足这种图存在的最小顶点数称为<strong>拉姆齐数 R(s,t)</strong>。</p>
                <p>对于给定的 s 和 t,当节点数量 n 增加时,存在一个<span class="highlight">临界数量</span>——一旦节点数超过这个临界值,大小为 s 的团或大小为 t 的独立集就<strong>一定</strong>存在于任意图中。寻找 Ramsey 图就是在寻找这个临界节点数:在这个节点数量下,我们恰好至少能找到一个很特殊的图,它既不包含大小为 s 的团,也不包含大小为 t 的独立集。</p>
                <div class="significance">
                    <strong>${lightbulbIcon}重要意义:</strong>如果我们能有一种算法提前知道拉姆齐数的具体值,就相当于知道系统中某种子结构在什么时候<strong>必然</strong>开始存在。这样就不用保持过量的节点,从而在网络设计、分布式系统等应用中节省成本。
                </div>
                <p>找到所有这样的图,甚至确定它们存在的最大 n,都是组合数学中的著名难题。大多数拉姆齐数仍然未知——我们只知道它们的上界和下界。</p>
                <div class="challenge">
                    <strong>${trophyIcon}开放挑战:</strong>找到一个 <span class="highlight">43 顶点的 Ramsey(5,5) 图</span>!<br><br>
                    目前所有 42 顶点的 Ramsey(5,5) 图都已被找到,但不确定是否存在 43 顶点的图。R(5,5) 的下界自 <strong>1989 年</strong>以来就没有被改进过。只要找到一个这样的图,就是这个领域 ${new Date().getFullYear() - 1989} 年来的重大突破!
                </div>
                <p>有关 Ramsey 图的最新研究,请参见 <strong>Radziszowski</strong> 的动态综述,持续更新刊登于<a href="https://www.combinatorics.org" target="_blank" style="color: var(--accent-blue);">电子组合学期刊</a>。</p>
            `
        };

        const ramseyTable = [
            ['s\\t', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
            ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],
            ['2', '-', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
            ['3', '-', '-', '6', '9', '14', '18', '23', '28', '36', '40-41'],
            ['4', '-', '-', '-', '18', '25', '36-40', '49-58', '59-79', '73-106', '92-136'],
            ['5', '-', '-', '-', '-', '43-48', '59-85', '80-133', '101-194', '133-282', '149-381'],
            ['6', '-', '-', '-', '-', '-', '102-161', '115-273', '134-427', '183-656', '204-949'],
            ['7', '-', '-', '-', '-', '-', '-', '205-497', '219-840', '252-1379', '292-2134'],
            ['8', '-', '-', '-', '-', '-', '-', '-', '282-1532', '329-2683', '343-4432'],
            ['9', '-', '-', '-', '-', '-', '-', '-', '-', '565-5366', '581-9797'],
            ['10', '-', '-', '-', '-', '-', '-', '-', '-', '-', '798-17730']
        ];

        function generateProgressTable() {
            let html = '<table class="ramsey-table"><thead><tr>';
            ramseyTable[0].forEach(h => html += `<th>${h}</th>`);
            html += '</tr></thead><tbody>';

            for (let i = 1; i < ramseyTable.length; i++) {
                html += '<tr>';
                ramseyTable[i].forEach((cell, j) => {
                    if (j === 0) {
                        html += `<th>${cell}</th>`;
                    } else if (cell === '-') {
                        html += `<td class="trivial">-</td>`;
                    } else if (cell.includes('-')) {
                        html += `<td class="range">${cell}</td>`;
                    } else {
                        html += `<td class="exact">${cell}</td>`;
                    }
                });
                html += '</tr>';
            }

            html += '</tbody></table>';
            html += `<div class="table-legend">
                <div class="table-legend-item"><div class="legend-box exact"></div><span data-i18n="exactValue">${t('exactValue')}</span></div>
                <div class="table-legend-item"><div class="legend-box range"></div><span data-i18n="rangeValue">${t('rangeValue')}</span></div>
            </div>`;
            return html;
        }

        function openModal(modalId) {
            const modal = document.getElementById(modalId);
            if (modalId === 'introModal') {
                document.getElementById('introBody').innerHTML = introContent[currentLang];
            } else if (modalId === 'progressModal') {
                document.getElementById('progressBody').innerHTML = generateProgressTable();
            }
            modal.classList.add('show');
        }

        function closeModal(modal) {
            modal.classList.remove('show');
        }

        // Modal event listeners
        document.getElementById('introBtn').addEventListener('click', () => openModal('introModal'));
        document.getElementById('progressBtn').addEventListener('click', () => openModal('progressModal'));

        document.querySelectorAll('.modal-overlay, .modal-close').forEach(el => {
            el.addEventListener('click', (e) => {
                const modal = e.target.closest('.modal');
                if (modal) closeModal(modal);
            });
        });

        document.addEventListener('keydown', e => {
            if (e.key === 'Escape') {
                document.querySelectorAll('.modal.show').forEach(m => closeModal(m));
            }
        });

        // Init
        initSelectors();
        // Apply saved language
        setLanguage(currentLang);
    </script>
</body>
</html>