tapirus 1.0.1

The Safe-Rust Embedded Multi-Model Database & AI Agent Memory Engine
Documentation
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
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Documentation | TapirusDB — Embedded Quad-Model AI Database & Memory Engine</title>
  <meta name="description" content="Comprehensive documentation, SDK guides, API references, and interactive playground for TapirusDB — The 100% Safe-Rust Embedded Quad-Model Database.">
  <link rel="canonical" href="https://tapirusdb.com/docs.html">
  
  <!-- Fonts -->
  <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=Blinker:wght@100;200;300;400;600;700;800;900&family=Michroma&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
  
  <!-- LineIcons -->
  <link rel="stylesheet" href="https://cdn.lineicons.com/4.0/lineicons.css">

  <style>
    :root {
      --corp-primary: #2b3a7e;
      --corp-primary-dark: #1b2654;
      --corp-primary-light: #3e50a2;
      --corp-primary-glow: rgba(43, 58, 126, 0.25);
      --corp-subtle: rgba(43, 58, 126, 0.08);
      --bg-base: #f8fafc;
      --bg-surface: #ffffff;
      --bg-surface-elevated: #f1f5f9;
      --bg-card: rgba(255, 255, 255, 0.95);
      --border-subtle: rgba(43, 58, 126, 0.1);
      --border-strong: rgba(43, 58, 126, 0.2);
      --text-main: #0f172a;
      --text-muted: #475569;
      --text-dim: #64748b;
      --accent-emerald: #059669;
      --accent-emerald-glow: rgba(5, 150, 105, 0.15);
      --accent-cyan: #0284c7;
      --accent-blue: #2b3a7e;
      --accent-purple: #7c3aed;
      --code-bg: #0f172a;
      --sidebar-width: 290px;
      --toc-width: 240px;
      --header-height: 64px;
    }

    h1, h2, h3, h4, h5, h6 {
      font-family: 'Blinker', -apple-system, BlinkMacSystemFont, sans-serif;
      font-weight: 600;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    html { scroll-behavior: smooth; scroll-padding-top: 80px; }
    body {
      background-color: var(--bg-base);
      color: var(--text-main);
      font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
      line-height: 1.65;
      font-size: 15px;
      overflow-x: hidden;
    }

    /* Top Navigation */
    .doc-nav {
      position: fixed;
      top: 0; left: 0; right: 0;
      height: var(--header-height);
      background: rgba(255, 255, 255, 0.92);
      backdrop-filter: blur(16px);
      -webkit-backdrop-filter: blur(16px);
      border-bottom: 1px solid var(--border-subtle);
      z-index: 100;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 24px;
      box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    }

    .doc-nav-left {
      display: flex;
      align-items: center;
      gap: 16px;
    }

    .doc-brand {
      display: flex;
      align-items: center;
      gap: 10px;
      text-decoration: none;
      color: #2b3a7e;
      font-family: 'Michroma', sans-serif;
      font-weight: 700;
      font-size: 17px;
      letter-spacing: -0.02em;
    }

    .doc-brand-glyph {
      width: 32px; height: 32px;
      background: linear-gradient(135deg, #2b3a7e 0%, #1d4ed8 100%);
      border-radius: 8px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 15px;
      font-weight: 700;
      color: #ffffff;
      font-family: 'Michroma', sans-serif;
      box-shadow: 0 0 14px rgba(43, 58, 126, 0.35);
    }

    .doc-tag {
      font-size: 9.5px;
      background: rgba(43, 58, 126, 0.08);
      color: #2b3a7e;
      border: 1px solid rgba(43, 58, 126, 0.25);
      padding: 2px 7px;
      border-radius: 999px;
      font-family: 'Michroma', sans-serif;
      font-weight: 600;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }

    .back-home-link {
      color: var(--text-muted);
      text-decoration: none;
      font-size: 13px;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 5px 12px;
      border-radius: 6px;
      background: rgba(15, 23, 42, 0.04);
      border: 1px solid var(--border-subtle);
      transition: all 0.2s;
    }
    .back-home-link:hover {
      color: #0f172a;
      background: rgba(15, 23, 42, 0.08);
      border-color: var(--border-strong);
    }

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

    .doc-search-box {
      position: relative;
      width: 260px;
    }
    .doc-search-box input {
      width: 100%;
      background: #f1f5f9;
      border: 1px solid var(--border-subtle);
      color: #0f172a;
      font-size: 13px;
      padding: 7px 12px 7px 34px;
      border-radius: 8px;
      outline: none;
      transition: all 0.2s;
    }
    .doc-search-box input:focus {
      border-color: var(--accent-cyan);
      box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
      background: #ffffff;
    }
    .doc-search-box i {
      position: absolute;
      left: 11px; top: 10px;
      color: var(--text-dim);
      font-size: 14px;
    }
    .doc-search-shortcut {
      position: absolute;
      right: 8px; top: 7px;
      font-size: 10px;
      padding: 2px 5px;
      background: rgba(15, 23, 42, 0.08);
      border-radius: 4px;
      color: var(--text-muted);
      font-family: monospace;
    }

    /* Live Search Dropdown */
    .doc-search-dropdown {
      position: absolute;
      top: calc(100% + 8px);
      left: 0;
      width: 320px;
      background: #ffffff;
      border: 1px solid var(--border-subtle);
      border-radius: 10px;
      box-shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
      max-height: 380px;
      overflow-y: auto;
      display: none;
      z-index: 1000;
      padding: 8px;
    }
    .doc-search-dropdown.show {
      display: block;
    }
    .doc-search-item {
      display: flex;
      flex-direction: column;
      padding: 8px 12px;
      border-radius: 6px;
      text-decoration: none;
      transition: background 0.15s;
    }
    .doc-search-item:hover, .doc-search-item.selected {
      background: rgba(43, 58, 126, 0.06);
    }
    .doc-search-item-title {
      font-size: 13.5px;
      font-weight: 600;
      color: var(--corp-primary);
      display: flex;
      align-items: center;
      gap: 6px;
    }
    .doc-search-item-category {
      font-size: 11px;
      color: var(--text-dim);
      margin-top: 2px;
    }

    .doc-github-btn {
      background: #0f172a;
      color: #ffffff;
      text-decoration: none;
      font-size: 13px;
      font-weight: 600;
      padding: 7px 14px;
      border-radius: 8px;
      display: flex;
      align-items: center;
      gap: 6px;
      border: 1px solid #1e293b;
      transition: all 0.2s;
      box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
    }
    .doc-github-btn:hover {
      background: #1e293b;
      box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
    }

    .mobile-menu-toggle {
      display: none;
      background: rgba(15, 23, 42, 0.04);
      border: 1px solid var(--border-subtle);
      color: #0f172a;
      font-size: 18px;
      cursor: pointer;
      width: 36px;
      height: 36px;
      border-radius: 8px;
      align-items: center;
      justify-content: center;
      transition: all 0.15s;
    }
    .mobile-menu-toggle:hover {
      background: rgba(15, 23, 42, 0.08);
    }

    /* Layout Wrapper */
    .doc-layout {
      display: flex;
      margin-top: var(--header-height);
      min-height: calc(100vh - var(--header-height));
    }

    /* Backdrop for mobile drawer */
    .doc-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      background: rgba(15, 23, 42, 0.45);
      backdrop-filter: blur(4px);
      -webkit-backdrop-filter: blur(4px);
      z-index: 104;
      opacity: 0;
      transition: opacity 0.25s ease;
    }
    .doc-backdrop.active {
      display: block;
      opacity: 1;
    }

    /* Sidebar Navigation */
    .doc-sidebar {
      width: var(--sidebar-width);
      position: fixed;
      top: var(--header-height);
      bottom: 0;
      left: 0;
      background: var(--bg-surface);
      border-right: 1px solid var(--border-subtle);
      overflow-y: auto;
      padding: 24px 16px 48px;
      z-index: 90;
    }

    .doc-sidebar-header {
      display: none;
      align-items: center;
      justify-content: space-between;
      padding-bottom: 14px;
      margin-bottom: 16px;
      border-bottom: 1px solid var(--border-subtle);
    }
    .doc-sidebar-header-title {
      font-size: 11px;
      font-weight: 700;
      color: #2b3a7e;
      font-family: 'Michroma', sans-serif;
      text-transform: uppercase;
      letter-spacing: 0.08em;
    }
    .sidebar-close-btn {
      background: rgba(15, 23, 42, 0.05);
      border: 1px solid var(--border-subtle);
      border-radius: 6px;
      color: var(--text-muted);
      width: 30px;
      height: 30px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 13px;
      cursor: pointer;
      transition: all 0.15s;
    }
    .sidebar-close-btn:hover {
      background: rgba(15, 23, 42, 0.1);
      color: var(--text-main);
    }

    .doc-group {
      margin-bottom: 24px;
    }

    .doc-group-title {
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: #2b3a7e;
      font-family: 'Michroma', sans-serif;
      padding: 0 10px 8px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      opacity: 0.85;
    }

    .doc-link {
      font-family: 'Blinker', sans-serif;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 8px 12px;
      font-size: 14.5px;
      color: var(--text-muted);
      text-decoration: none;
      border-radius: 6px;
      transition: all 0.15s ease;
      font-weight: 600;
    }
    .doc-link i { font-size: 14px; color: var(--text-dim); transition: color 0.15s; }
    .doc-link:hover {
      color: #2b3a7e;
      background: rgba(43, 58, 126, 0.04);
    }
    .doc-link:hover i { color: #2b3a7e; }
    .doc-link.active {
      color: #2b3a7e;
      background: rgba(43, 58, 126, 0.08);
      font-weight: 700;
    }
    .doc-link.active i { color: #2b3a7e; }

    /* Main Content Area */
    .doc-main {
      margin-left: var(--sidebar-width);
      flex: 1;
      max-width: 900px;
      padding: 40px 48px 100px;
    }

    /* Breadcrumbs */
    .doc-breadcrumbs {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 12px;
      color: var(--text-dim);
      margin-bottom: 20px;
    }
    .doc-breadcrumbs a { color: var(--text-muted); text-decoration: none; }
    .doc-breadcrumbs a:hover { color: #0f172a; }

    /* Typography */
    .doc-header h1 {
      font-family: 'Blinker', sans-serif;
      font-size: 34px;
      font-weight: 600;
      letter-spacing: -0.01em;
      color: #0f172a;
      margin-bottom: 12px;
      line-height: 1.2;
    }

    .doc-lead {
      font-size: 17px;
      color: var(--text-muted);
      line-height: 1.6;
      margin-bottom: 32px;
      padding-bottom: 24px;
      border-bottom: 1px solid var(--border-subtle);
    }

    .doc-section {
      margin-bottom: 56px;
      scroll-margin-top: 90px;
    }

    .doc-section h2 {
      font-family: 'Blinker', sans-serif;
      font-size: 24px;
      font-weight: 600;
      letter-spacing: -0.01em;
      color: #0f172a;
      margin-bottom: 16px;
      padding-bottom: 8px;
      border-bottom: 1px solid var(--border-subtle);
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .doc-section h2 a.anchor-link {
      color: var(--text-dim);
      text-decoration: none;
      font-size: 18px;
      opacity: 0;
      transition: opacity 0.2s;
    }
    .doc-section h2:hover a.anchor-link { opacity: 1; }

    .doc-section h3 {
      font-family: 'Blinker', sans-serif;
      font-size: 19px;
      font-weight: 600;
      color: #1e293b;
      margin: 28px 0 12px;
    }

    .doc-section p {
      color: var(--text-muted);
      margin-bottom: 16px;
    }

    .doc-section ul, .doc-section ol {
      margin: 0 0 20px 24px;
      color: var(--text-muted);
    }
    .doc-section li { margin-bottom: 6px; }

    /* Callouts */
    .callout {
      padding: 16px 20px;
      border-radius: 8px;
      margin: 20px 0;
      font-size: 14px;
      display: flex;
      gap: 14px;
      align-items: flex-start;
      border-left: 4px solid;
    }
    .callout-info {
      background: rgba(43, 58, 126, 0.06);
      border-color: #2b3a7e;
      color: #1b2654;
    }
    .callout-success {
      background: rgba(5, 150, 105, 0.08);
      border-color: var(--accent-emerald);
      color: #065f46;
    }
    .callout-warn {
      background: rgba(217, 119, 6, 0.08);
      border-color: #d97706;
      color: #92400e;
    }
    .callout i { font-size: 18px; margin-top: 2px; }

    /* Code Blocks */
    .code-box {
      background: var(--code-bg);
      border: 1px solid rgba(15, 23, 42, 0.15);
      border-radius: 8px;
      margin: 18px 0 24px;
      overflow: hidden;
      box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
      max-width: 100%;
    }

    .code-header {
      background: rgba(255, 255, 255, 0.05);
      padding: 8px 16px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
      font-family: 'JetBrains Mono', monospace;
      font-size: 12px;
      color: #94a3b8;
    }

    .code-copy-btn {
      background: rgba(255, 255, 255, 0.08);
      border: 1px solid rgba(255, 255, 255, 0.12);
      color: #cbd5e1;
      font-size: 11px;
      padding: 3px 8px;
      border-radius: 4px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 4px;
      transition: all 0.15s;
    }
    .code-copy-btn:hover {
      background: rgba(255, 255, 255, 0.16);
      color: #ffffff;
    }
    .code-copy-btn.copied {
      background: rgba(5, 150, 105, 0.25) !important;
      border-color: #10b981 !important;
      color: #34d399 !important;
      font-weight: 600;
    }

    pre code {
      display: block;
      padding: 16px;
      overflow-x: auto;
      font-family: 'JetBrains Mono', monospace;
      font-size: 13.5px;
      line-height: 1.6;
      color: #e2e8f0;
      -webkit-overflow-scrolling: touch;
    }

    inline-code, code:not(pre code) {
      font-family: 'JetBrains Mono', monospace;
      font-size: 12.5px;
      background: #f1f5f9;
      padding: 2px 6px;
      border-radius: 4px;
      color: #0284c7;
      border: 1px solid rgba(15, 23, 42, 0.08);
      font-weight: 500;
    }

    /* Table Scroll Wrapper for Mobile Responsiveness */
    .table-scroll-wrap {
      width: 100%;
      overflow-x: auto;
      -webkit-overflow-scrolling: touch;
      margin: 20px 0 28px;
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      background: #ffffff;
      box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    }

    .doc-table {
      width: 100%;
      min-width: 600px;
      border-collapse: collapse;
      font-size: 13.5px;
      background: #ffffff;
    }
    .doc-table th {
      background: #f8fafc;
      padding: 12px 16px;
      text-align: left;
      font-weight: 700;
      color: #0f172a;
      border-bottom: 1px solid var(--border-subtle);
    }
    .doc-table td {
      padding: 12px 16px;
      border-bottom: 1px solid var(--border-subtle);
      color: #334155;
    }
    .doc-table tr:last-child td { border-bottom: none; }
    .doc-table tr:hover td { background: #f8fafc; }

    .license-tag {
      font-size: 11px;
      font-weight: 700;
      padding: 3px 8px;
      border-radius: 4px;
      font-family: 'JetBrains Mono', monospace;
      display: inline-block;
    }
    .license-tag.mit {
      background: #eff6ff;
      color: #2563eb;
      border: 1px solid #bfdbfe;
    }
    .license-tag.busl {
      background: #fef3c7;
      color: #d97706;
      border: 1px solid #fde68a;
    }

    /* Documentation Sequential Pager Navigation */
    .doc-pager {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      margin-top: 56px;
      padding-top: 36px;
      border-top: 1px solid var(--border-subtle);
    }
    .doc-pager-card {
      display: flex;
      flex-direction: column;
      padding: 18px 22px;
      border-radius: 12px;
      border: 1px solid var(--border-subtle);
      background: var(--bg-surface);
      text-decoration: none;
      transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
      box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    }
    .doc-pager-card:hover {
      border-color: var(--corp-primary);
      transform: translateY(-2px);
      box-shadow: 0 8px 25px rgba(43, 58, 126, 0.1);
    }
    .doc-pager-card.next {
      text-align: right;
      align-items: flex-end;
    }
    .doc-pager-label {
      font-size: 11.5px;
      font-weight: 600;
      color: var(--text-dim);
      display: flex;
      align-items: center;
      gap: 6px;
      margin-bottom: 6px;
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }
    .doc-pager-title {
      font-family: 'Blinker', sans-serif;
      font-size: 17px;
      font-weight: 700;
      color: var(--corp-primary);
    }
    @media (max-width: 600px) {
      .doc-pager {
        grid-template-columns: 1fr;
      }
      .doc-pager-card.next {
        text-align: left;
        align-items: flex-start;
      }
    }

    /* Interactive Studio Section */
    .studio-container {
      background: #0f172a;
      border: 1px solid rgba(5, 150, 105, 0.3);
      border-radius: 12px;
      padding: 20px;
      margin: 24px 0 32px;
      box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    }

    .studio-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 16px;
      padding-bottom: 12px;
      border-bottom: 1px solid rgba(255, 255, 255, 0.08);
      gap: 12px;
    }

    .studio-modes {
      display: flex;
      gap: 6px;
      background: rgba(255, 255, 255, 0.06);
      padding: 4px;
      border-radius: 8px;
    }

    .studio-mode-btn {
      background: none;
      border: none;
      color: #94a3b8;
      font-size: 12px;
      font-weight: 600;
      padding: 6px 12px;
      border-radius: 6px;
      cursor: pointer;
      transition: all 0.2s;
      white-space: nowrap;
    }
    .studio-mode-btn:hover {
      color: #f1f5f9;
    }
    .studio-mode-btn.active {
      background: #2b3a7e;
      color: #ffffff;
      box-shadow: 0 2px 8px rgba(43, 58, 126, 0.35);
    }

    .studio-run-btn {
      background: linear-gradient(135deg, #2b3a7e 0%, #1d4ed8 100%);
      border: none;
      color: #ffffff;
      font-family: 'Blinker', sans-serif;
      font-size: 14.5px;
      font-weight: 700;
      letter-spacing: 0.02em;
      padding: 7px 20px;
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      box-shadow: 0 0 15px rgba(43, 58, 126, 0.35);
      transition: all 0.15s;
      white-space: nowrap;
    }
    .studio-run-btn:hover {
      transform: translateY(-1px);
      box-shadow: 0 4px 18px rgba(43, 58, 126, 0.5);
    }

    .studio-editor {
      width: 100%;
      height: 110px;
      background: #090d16;
      border: 1px solid rgba(255, 255, 255, 0.12);
      border-radius: 6px;
      padding: 12px;
      color: #38bdf8;
      font-family: 'JetBrains Mono', monospace;
      font-size: 13px;
      resize: vertical;
      outline: none;
    }
    .studio-editor:focus {
      border-color: #0284c7;
      box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.2);
    }

    .studio-output-box {
      margin-top: 14px;
      background: #050811;
      border: 1px solid rgba(255, 255, 255, 0.08);
      border-radius: 6px;
      padding: 14px;
      max-height: 240px;
      overflow-y: auto;
      font-family: 'JetBrains Mono', monospace;
      font-size: 12.5px;
      color: #34d399;
      white-space: pre-wrap;
      word-break: break-all;
    }

    /* Right TOC on desktop */
    .doc-toc {
      width: var(--toc-width);
      position: fixed;
      top: var(--header-height);
      right: 24px;
      bottom: 0;
      padding: 40px 0;
      overflow-y: auto;
    }
    .doc-toc-title {
      font-family: 'Michroma', sans-serif;
      font-size: 10px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: #2b3a7e;
      margin-bottom: 12px;
    }
    .doc-toc a {
      display: block;
      color: var(--text-dim);
      text-decoration: none;
      font-size: 12.5px;
      padding: 5px 0 5px 12px;
      border-left: 2px solid transparent;
      transition: all 0.15s;
      line-height: 1.4;
    }
    .doc-toc a:hover {
      color: #0f172a;
    }
    .doc-toc a {
      font-family: 'Blinker', sans-serif;
      font-size: 13.5px;
      font-weight: 600;
      color: var(--text-dim);
      text-decoration: none;
      display: block;
      padding: 5px 0 5px 12px;
      border-left: 2px solid transparent;
      transition: all 0.15s;
      line-height: 1.4;
    }
    .doc-toc a:hover {
      color: #2b3a7e;
    }
    .doc-toc a.active {
      color: #2b3a7e;
      border-left-color: #2b3a7e;
      font-weight: 700;
    }

    /* Responsive Media Queries */
    @media (max-width: 1200px) {
      .doc-toc { display: none; }
      .doc-main { max-width: 100%; margin-right: 0; }
    }

    @media (max-width: 860px) {
      .mobile-menu-toggle {
        display: flex;
      }
      .doc-sidebar-header {
        display: flex;
      }
      .doc-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: 300px;
        max-width: 85vw;
        height: 100vh;
        z-index: 105;
        padding: 20px 16px 40px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 10px 0 35px rgba(15, 23, 42, 0.15);
      }
      .doc-sidebar.open {
        transform: translateX(0);
      }
      .doc-main {
        margin-left: 0;
        padding: 28px 20px 80px;
      }
      .doc-search-box {
        display: none;
      }
    }

    @media (max-width: 640px) {
      .doc-main {
        padding: 20px 16px 60px;
      }
      .doc-header h1 {
        font-size: 26px;
      }
      .doc-lead {
        font-size: 15px;
      }
      .doc-section h2 {
        font-size: 20px;
      }
      .doc-section h3 {
        font-size: 16px;
      }
      
      .studio-container {
        padding: 16px 12px;
      }
      .studio-header {
        flex-direction: column;
        align-items: stretch;
      }
      .studio-modes {
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding: 4px;
        gap: 4px;
      }
      .studio-mode-btn {
        flex: 1 0 auto;
        text-align: center;
        padding: 6px 10px;
        font-size: 11.5px;
      }
      .studio-run-btn {
        justify-content: center;
        width: 100%;
        padding: 9px 16px;
      }
      .studio-editor {
        font-size: 12px;
        padding: 10px;
      }
      .studio-output-box {
        font-size: 11.5px;
        padding: 10px;
      }
      .code-header {
        padding: 7px 12px;
        font-size: 11px;
      }
      pre code {
        padding: 12px;
        font-size: 12px;
      }
      .callout {
        padding: 12px 14px;
        font-size: 13px;
        gap: 10px;
      }
    }

    @media (max-width: 520px) {
      .doc-nav {
        padding: 0 12px;
      }
      .doc-nav-left {
        gap: 8px;
      }
      .doc-brand span:not(.doc-tag) {
        font-size: 15px;
      }
      .doc-tag {
        display: none;
      }
      .back-home-link span {
        display: none;
      }
      .back-home-link {
        padding: 6px 8px;
      }
      .doc-github-btn span {
        display: none;
      }
      .doc-github-btn {
        padding: 6px 10px;
      }
    }
  </style>
</head>
<body>

  <!-- Top Navigation -->
  <header class="doc-nav">
    <div class="doc-nav-left">
      <button class="mobile-menu-toggle" id="menuToggle" aria-label="Toggle Navigation">
        <i class="lni lni-menu"></i>
      </button>
      <a href="index.html" class="doc-brand">
        <div class="doc-brand-glyph">T</div>
        <span>TapirusDB</span>
        <span class="doc-tag">Docs</span>
      </a>
      <a href="index.html" class="back-home-link" title="Back to Homepage">
        <i class="lni lni-arrow-left"></i> <span>Home</span>
      </a>
      <a href="tutorial.html" class="back-home-link" title="Hands-On Tutorials" style="color:var(--corp-primary); font-weight:600;">
        <i class="lni lni-graduation"></i> <span>Tutorials</span>
      </a>
    </div>

    <div class="doc-nav-right">
      <div class="doc-search-box">
        <i class="lni lni-search-alt"></i>
        <input type="text" id="docSearch" placeholder="Search documentation (⌘K or /)..." autocomplete="off">
        <span class="doc-search-shortcut">⌘K</span>
        <div class="doc-search-dropdown" id="docSearchDropdown"></div>
      </div>

      <a href="https://github.com/tapiruslab/TapirusDB" target="_blank" class="doc-github-btn" title="GitHub Repository">
        <i class="lni lni-github-original"></i> <span>GitHub</span>
      </a>
    </div>
  </header>

  <!-- Documentation Layout -->
  <div class="doc-layout">

    <!-- Mobile Drawer Backdrop -->
    <div class="doc-backdrop" id="docBackdrop"></div>

    <!-- Sticky Left Sidebar -->
    <aside class="doc-sidebar" id="docSidebar">
      <div class="doc-sidebar-header">
        <span class="doc-sidebar-header-title">Documentation Menu</span>
        <button class="sidebar-close-btn" id="sidebarCloseBtn" aria-label="Close Documentation Menu">
          <i class="lni lni-close"></i>
        </button>
      </div>
      <div class="doc-group">
        <div class="doc-group-title">Getting Started</div>
        <a href="#overview" class="doc-link active"><i class="lni lni-rocket"></i> Overview &amp; Philosophy</a>
        <a href="#why-tapirus" class="doc-link"><i class="lni lni-shield"></i> Why TapirusDB</a>
        <a href="#installation" class="doc-link"><i class="lni lni-download"></i> Installation &amp; Packages</a>
        <a href="#quickstart" class="doc-link"><i class="lni lni-bolt"></i> 30-Second Quickstart</a>
        <a href="tutorial.html" class="doc-link" style="color:var(--accent-cyan); font-weight:700;"><i class="lni lni-graduation"></i> Tutorials Portal ↗</a>
      </div>

      <div class="doc-group">
        <div class="doc-group-title">The Quad Models</div>
        <a href="#sql-engine" class="doc-link"><i class="lni lni-database"></i> Relational SQL-92</a>
        <a href="#vector-engine" class="doc-link"><i class="lni lni-layers"></i> HNSW Vector Search</a>
        <a href="#graph-engine" class="doc-link"><i class="lni lni-network"></i> openCypher GraphRAG</a>
        <a href="#doc-store" class="doc-link"><i class="lni lni-files"></i> JSON Document Collections</a>
      </div>

      <div class="doc-group">
        <div class="doc-group-title">Interactive Tooling</div>
        <a href="#studio" class="doc-link"><i class="lni lni-code-alt"></i> In-Browser SLM Studio</a>
      </div>

      <div class="doc-group">
        <div class="doc-group-title">Storage &amp; Internals</div>
        <a href="#disk-format" class="doc-link"><i class="lni lni-harddrive"></i> The .tapir Disk Format</a>
        <a href="#memory-internals" class="doc-link"><i class="lni lni-dashboard"></i> Memory &amp; Cache (&lt;4MB)</a>
        <a href="#security-encryption" class="doc-link"><i class="lni lni-lock"></i> ChaCha20-Poly1305 AEAD</a>
      </div>

      <div class="doc-group">
        <div class="doc-group-title">Official Client SDKs</div>
        <a href="#sdk-rust" class="doc-link"><i class="lni lni-code"></i> Rust (crates.io)</a>
        <a href="#sdk-python" class="doc-link"><i class="lni lni-python"></i> Python (PyPI)</a>
        <a href="#sdk-nodejs" class="doc-link"><i class="lni lni-javascript"></i> Node.js &amp; TS (npm)</a>
        <a href="#sdk-go" class="doc-link"><i class="lni lni-code-alt"></i> Go (pkg.go.dev)</a>
        <a href="#sdk-php" class="doc-link"><i class="lni lni-php"></i> PHP (Packagist)</a>
      </div>

      <div class="doc-group">
        <div class="doc-group-title">Server &amp; Deployment</div>
        <a href="#server-daemon" class="doc-link"><i class="lni lni-server"></i> Standalone Daemon</a>
        <a href="#mcp-server" class="doc-link"><i class="lni lni-bot"></i> Model Context Protocol (MCP)</a>
        <a href="#docker-deployment" class="doc-link"><i class="lni lni-docker"></i> Docker &amp; Containers</a>
        <a href="#edge-deployment" class="doc-link"><i class="lni lni-cloud"></i> Serverless &amp; Cloudflare Edge</a>
      </div>

      <div class="doc-group">
        <div class="doc-group-title">Reference</div>
        <a href="#benchmarks-matrix" class="doc-link"><i class="lni lni-bar-chart"></i> Benchmarks &amp; Specs</a>
        <a href="#comparison-matrix" class="doc-link"><i class="lni lni-grid-alt"></i> Industry Duel Matrix</a>
      </div>
    </aside>

    <!-- Main Content -->
    <main class="doc-main">
      <div class="doc-breadcrumbs">
        <a href="index.html">Home</a>
        <span>/</span>
        <a href="docs.html">Docs</a>
        <span>/</span>
        <span id="currentCrumb">Getting Started</span>
      </div>

      <div class="doc-header">
        <h1>TapirusDB Documentation</h1>
        <p class="doc-lead">
          The embedded cognitive memory and multi-model database engine engineered in 100% Safe Rust (<code style="color:#059669; font-weight:600;">#![forbid(unsafe_code)]</code>). Unifies Relational SQL, HNSW Vectors, GraphRAG, and JSON Documents in a single encrypted disk file with sub-microsecond latency.
        </p>
      </div>

      <!-- Section: Overview -->
      <section class="doc-section" id="overview">
        <h2>
          <span>Overview &amp; Design Philosophy</span>
          <a href="#overview" class="anchor-link">#</a>
        </h2>
        <p>
          Traditional software systems force engineers into <strong>Fragmented Polyglot Persistence</strong>. Building an intelligent application or AI agent routinely requires orchestrating four disparate database daemons: PostgreSQL for structured tables, Pinecone or Qdrant for vector embeddings, Neo4j for relationship graphs, and MongoDB for schemaless documents.
        </p>
        <p>
          This "Frankenstack" introduces severe network socket serialization overhead (40–90 ms roundtrips), heavy memory consumption (> 2 GB idle RAM), synchronization drift, and operational fragility.
        </p>
        
        <div class="callout callout-success">
          <i class="lni lni-checkmark-circle"></i>
          <div>
            <strong>The TapirusDB Solution:</strong> A zero-daemon, in-process engine compiled directly into your application runtime. All four data paradigms share the same unified memory space, executing cross-paradigm chaining in <strong>0.55 microseconds</strong>.
          </div>
        </div>

        <h3>Core Tenets</h3>
        <ul>
          <li><strong>100% Safe Rust:</strong> Zero unsafe code blocks. Protected at compile-time against memory corruption, dangling pointers, buffer overflows, and use-after-free vulnerabilities.</li>
          <li><strong>Single File Atomic Storage:</strong> The entire database resides in a single, robust <code>.tapir</code> binary file protected by ChaCha20-Poly1305 AEAD authenticated page encryption.</li>
          <li><strong>Micro-Footprint:</strong> Consumes less than 4 MB of idle RAM, making it optimal for robotics, mobile applications, edge silicon, and serverless containers.</li>
          <li><strong>Zero Cloud Lock-in:</strong> Fully sovereign and self-contained. Runs anywhere from an air-gapped embedded device to massive cloud microservices.</li>
        </ul>
      </section>

      <!-- Section: Why TapirusDB -->
      <section class="doc-section" id="why-tapirus">
        <h2>
          <span>Why TapirusDB (Kill the Frankenstack)</span>
          <a href="#why-tapirus" class="anchor-link">#</a>
        </h2>
        <p>
          Observe the architectural contrast between traditional multi-database deployments and TapirusDB's unified in-process model:
        </p>

        <!-- Responsive Architecture SVG -->
        <div style="margin: 24px 0; text-align: center;">
          <picture>
            <source media="(max-width: 768px)" srcset="assets/architecture-mobile.svg">
            <img src="assets/architecture-comparison.svg" alt="TapirusDB Architecture vs The Frankenstack" style="width:100%; max-width:860px; border-radius:10px; border:1px solid var(--border-subtle);">
          </picture>
        </div>

        <div class="table-scroll-wrap">
          <table class="doc-table">
            <thead>
              <tr>
                <th>Metric</th>
                <th>The Polyglot "Frankenstack"</th>
                <th>TapirusDB v1.0.0</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td><strong>Query Latency</strong></td>
                <td>40 – 90 ms (TCP/HTTP/gRPC sockets)</td>
                <td><span style="color:var(--accent-emerald); font-weight:700;">0.55 µs</span> (Direct memory bus)</td>
              </tr>
              <tr>
                <td><strong>Idle RAM</strong></td>
                <td>&gt; 2,000 MB (4 separate JVM / C++ runtimes)</td>
                <td><span style="color:var(--accent-emerald); font-weight:700;">&lt; 4 MB</span> (Single process)</td>
              </tr>
              <tr>
                <td><strong>Memory Safety</strong></td>
                <td>Unsafe C/C++ or JVM Garbage Collection pauses</td>
                <td><span style="color:var(--accent-emerald); font-weight:700;">100% Safe Rust</span></td>
              </tr>
              <tr>
                <td><strong>Sync Drift</strong></td>
                <td>Fragile ETL pipelines and eventual consistency lag</td>
                <td><span style="color:var(--accent-emerald); font-weight:700;">Zero</span> (Single atomic .tapir disk file)</td>
              </tr>
            </tbody>
          </table>
        </div>
      </section>

      <!-- Section: Installation -->
      <section class="doc-section" id="installation">
        <h2>
          <span>Installation &amp; Ecosystem Packages</span>
          <a href="#installation" class="anchor-link">#</a>
        </h2>
        <p>
          TapirusDB provides first-class native distribution across all major programming ecosystems and operating system package managers.
        </p>

        <h3>Package Managers (Terminal CLI)</h3>
        <div class="code-box">
          <div class="code-header">
            <span>Terminal (macOS &amp; Linux via Homebrew)</span>
            <button class="code-copy-btn" onclick="copyText('brew install https://raw.githubusercontent.com/tapiruslab/TapirusDB/main/Formula/tapirus.rb', this)">Copy</button>
          </div>
          <pre><code>brew install https://raw.githubusercontent.com/tapiruslab/TapirusDB/main/Formula/tapirus.rb</code></pre>
        </div>

        <div class="code-box">
          <div class="code-header">
            <span>Windows (Windows Package Manager - Winget)</span>
            <button class="code-copy-btn" onclick="copyText('winget install --manifest https://raw.githubusercontent.com/tapiruslab/TapirusDB/main/winget/tapirus.yaml', this)">Copy</button>
          </div>
          <pre><code>winget install --manifest https://raw.githubusercontent.com/tapiruslab/TapirusDB/main/winget/tapirus.yaml</code></pre>
        </div>

        <div class="code-box">
          <div class="code-header">
            <span>Linux Automated Quick Install</span>
            <button class="code-copy-btn" onclick="copyText('curl -fsSL https://raw.githubusercontent.com/tapiruslab/TapirusDB/main/install.sh | bash', this)">Copy</button>
          </div>
          <pre><code>curl -fsSL https://raw.githubusercontent.com/tapiruslab/TapirusDB/main/install.sh | bash</code></pre>
        </div>

        <h3>Language Client Libraries</h3>
        <div class="table-scroll-wrap">
          <table class="doc-table">
            <thead>
              <tr>
                <th>Language</th>
                <th>Registry Package</th>
                <th>Installation Command</th>
                <th>License</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td><strong>Rust</strong></td>
                <td><a href="https://crates.io/crates/tapirus" target="_blank" style="color:var(--accent-cyan); font-weight:600;">crates.io/crates/tapirus</a></td>
                <td><code>cargo add tapirus</code></td>
                <td><span class="license-tag busl">BUSL-1.1</span></td>
              </tr>
              <tr>
                <td><strong>Python</strong></td>
                <td><a href="https://pypi.org/project/tapirus/" target="_blank" style="color:var(--accent-cyan); font-weight:600;">pypi.org/project/tapirus</a></td>
                <td><code>pip install tapirus</code></td>
                <td><span class="license-tag mit">MIT</span></td>
              </tr>
              <tr>
                <td><strong>Node.js / TS</strong></td>
                <td><a href="https://www.npmjs.com/package/tapirus" target="_blank" style="color:var(--accent-cyan); font-weight:600;">npmjs.com/package/tapirus</a></td>
                <td><code>npm install tapirus</code></td>
                <td><span class="license-tag mit">MIT</span></td>
              </tr>
              <tr>
                <td><strong>Go (Golang)</strong></td>
                <td><a href="https://pkg.go.dev/github.com/tapiruslab/TapirusDB/sdks/go" target="_blank" style="color:var(--accent-cyan); font-weight:600;">pkg.go.dev</a></td>
                <td><code>go get github.com/tapiruslab/TapirusDB/sdks/go</code></td>
                <td><span class="license-tag mit">MIT</span></td>
              </tr>
              <tr>
                <td><strong>PHP</strong></td>
                <td><a href="https://packagist.org/packages/tapiruslab/tapirusdb" target="_blank" style="color:var(--accent-cyan); font-weight:600;">packagist.org/packages/tapiruslab/tapirusdb</a></td>
                <td><code>composer require tapiruslab/tapirusdb</code></td>
                <td><span class="license-tag mit">MIT</span></td>
              </tr>
              <tr>
                <td><strong>Docker</strong></td>
                <td><a href="https://github.com/tapiruslab/TapirusDB/pkgs/container/tapirusdb" target="_blank" style="color:var(--accent-cyan); font-weight:600;">ghcr.io/tapiruslab/tapirusdb</a></td>
                <td><code>docker pull ghcr.io/tapiruslab/tapirusdb:latest</code></td>
                <td><span class="license-tag busl">BUSL-1.1</span></td>
              </tr>
            </tbody>
          </table>
        </div>
      </section>

      <!-- Section: Quickstart -->
      <section class="doc-section" id="quickstart">
        <h2>
          <span>30-Second Quickstart</span>
          <a href="#quickstart" class="anchor-link">#</a>
        </h2>
        <p>
          Initialize an in-memory or encrypted single-file database, create structured tables with vector columns, execute graph traversals, and query via SQL in under 30 seconds:
        </p>

        <div class="code-box">
          <div class="code-header">
            <span>Rust Quickstart (main.rs)</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>use tapirus::{Connection, DistanceMetric, Result};
use serde_json::json;

fn main() -> Result<()> {
    // 1. Open or create encrypted database file
    let db = Connection::open("production.tapir")?;

    // 2. Relational SQL Table with native Vector column
    db.execute("
        CREATE TABLE documents (
            id INTEGER PRIMARY KEY,
            title TEXT NOT NULL,
            embedding VECTOR(4)
        );
    ")?;

    // 3. Insert record with 4-dimensional vector
    db.execute("
        INSERT INTO documents (id, title, embedding)
        VALUES (1, 'Safe Systems Architecture', [0.12, 0.45, 0.88, -0.23]);
    ")?;

    // 4. Property Graph Node & Edge (GraphRAG)
    db.graph_add_node(1, "Author", r#"{"name":"Faiz"}"#)?;
    db.graph_add_node(2, "Concept", r#"{"name":"Quad-Model"}"#)?;
    db.graph_add_edge(1, 2, "INVENTED", 1.0, "")?;

    // 5. Query relational records via SQL
    let rows = db.query("SELECT id, title FROM documents WHERE id = 1;")?;
    println!("Retrieved: {:?}", rows);

    Ok(())
}</code></pre>
        </div>
      </section>

      <!-- Tutorials Portal Banner Card -->
      <div class="callout callout-info" style="margin: 28px 0 36px; border-radius: 12px; padding: 22px 24px; border-left: 5px solid var(--corp-primary); box-shadow: 0 4px 18px rgba(43, 58, 126, 0.05); background: #ffffff; border-right: 1px solid var(--border-subtle); border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle);">
        <i class="lni lni-graduation" style="font-size: 32px; color: var(--corp-primary); margin-top: 2px;"></i>
        <div>
          <h3 style="margin: 0 0 6px; font-size: 18px; color: var(--corp-primary); font-family: 'Blinker', sans-serif;">Looking for Step-by-Step Hands-On Tutorials?</h3>
          <p style="margin: 0 0 14px; font-size: 14.5px; color: var(--text-muted); line-height: 1.6;">
            We have created a dedicated <strong>Tutorials Portal</strong> featuring zero-to-query guided walkthroughs for <strong>Node.js &amp; TypeScript, Python, Safe-Rust, and Go</strong>, complete with shell execution tips and interactive REPL recipes.
          </p>
          <a href="tutorial.html" class="btn-pill btn-primary" style="display:inline-flex; font-size: 13.5px; padding: 7px 18px;">
            Open Tutorials Portal →
          </a>
        </div>
      </div>

      <!-- Section: Interactive SLM Studio -->
      <section class="doc-section" id="studio">
        <h2>
          <span>Interactive SLM Studio (Live Demo)</span>
          <a href="#studio" class="anchor-link">#</a>
        </h2>
        <p>
          Experience TapirusDB's multi-model execution engine live in your web browser. Switch between SQL, Vector Cosine similarity math, Graph traversal, and Agent Memory fusion:
        </p>

        <div class="studio-container">
          <div class="studio-header">
            <div class="studio-modes">
              <button class="studio-mode-btn active" onclick="setStudioMode('sql', this)">SQL-92</button>
              <button class="studio-mode-btn" onclick="setStudioMode('vector', this)">Vector Search</button>
              <button class="studio-mode-btn" onclick="setStudioMode('graph', this)">GraphRAG</button>
              <button class="studio-mode-btn" onclick="setStudioMode('agent', this)">Agent Memory</button>
            </div>
            <button class="studio-run-btn" onclick="runStudioDemo()">
              <i class="lni lni-play"></i> Run Query
            </button>
          </div>

          <textarea class="studio-editor" id="studioQuery" spellcheck="false">SELECT id, name, model, memory_mb FROM agents WHERE memory_mb < 500 ORDER BY memory_mb ASC;</textarea>

          <div class="studio-output-box" id="studioOutput">
            [Ready] TapirusDB In-Browser Client Engine active. Click "Run Query" to execute.
          </div>
        </div>
      </section>

      <!-- Section: SQL Engine -->
      <section class="doc-section" id="sql-engine">
        <h2>
          <span>1. Relational SQL-92 Engine</span>
          <a href="#sql-engine" class="anchor-link">#</a>
        </h2>
        <p>
          TapirusDB embeds a full ANSI SQL-92 query engine supporting standard DDL, DML, composite primary keys, B+Tree indexes, and ACID transactions.
        </p>

        <div class="code-box">
          <div class="code-header">
            <span>SQL Schema &amp; Operations</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>-- Create structured table with constraints
CREATE TABLE accounts (
    id INTEGER PRIMARY KEY,
    username TEXT NOT NULL UNIQUE,
    balance REAL DEFAULT 0.0,
    created_at TIMESTAMP
);

-- Insert records
INSERT INTO accounts (id, username, balance) VALUES (101, 'alex_ai', 1450.50);
INSERT INTO accounts (id, username, balance) VALUES (102, 'sarah_dev', 3200.00);

-- Filtered queries with aggregations
SELECT username, balance 
FROM accounts 
WHERE balance > 1000.0 
ORDER BY balance DESC;</code></pre>
        </div>
      </section>

      <!-- Section: Vector Search -->
      <section class="doc-section" id="vector-engine">
        <h2>
          <span>2. Native HNSW Vector Search</span>
          <a href="#vector-engine" class="anchor-link">#</a>
        </h2>
        <p>
          Unlike external vector databases requiring network roundtrips, TapirusDB supports native <code>VECTOR(N)</code> columns directly inside tables. It utilizes Hierarchical Navigable Small World (HNSW) graphs and Inverted File (IVF) indexes, accelerated by SIMD AVX-512, AVX2, and ARM NEON intrinsics.
        </p>

        <div class="code-box">
          <div class="code-header">
            <span>Vector Search Syntax</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>-- Define table with 1536-dimensional embeddings (OpenAI / Gemini embedding format)
CREATE TABLE embeddings (
    doc_id INTEGER PRIMARY KEY,
    content TEXT,
    vector VECTOR(1536)
);

-- Query top-5 nearest neighbors using Cosine Similarity
SELECT doc_id, content, VECTOR_COSINE(vector, [0.012, -0.045, ...]) AS score
FROM embeddings
ORDER BY score DESC
LIMIT 5;</code></pre>
        </div>
      </section>

      <!-- Section: openCypher GraphRAG -->
      <section class="doc-section" id="graph-engine">
        <h2>
          <span>3. Knowledge Graph &amp; GraphRAG</span>
          <a href="#graph-engine" class="anchor-link">#</a>
        </h2>
        <p>
          TapirusDB implements native property graph storage using Compressed Sparse Row (CSR) adjacency arrays. Query relationships declaratively using the industry-standard <strong>openCypher</strong> language:
        </p>

        <div class="code-box">
          <div class="code-header">
            <span>openCypher Graph Traversal</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>// 1. Add nodes and relationships
CREATE (p:Person {name: "Ada Lovelace", role: "Mathematician"})
CREATE (c:Concept {name: "Analytical Engine"})
CREATE (p)-[:PIONEERED {year: 1843}]->(c);

// 2. Multihop graph traversal pattern matching
MATCH (p:Person)-[r:PIONEERED]->(c:Concept)
WHERE c.name = "Analytical Engine"
RETURN p.name, r.year, c.name;</code></pre>
        </div>
      </section>

      <!-- Section: JSON Documents -->
      <section class="doc-section" id="doc-store">
        <h2>
          <span>4. Schema-less JSON Document Collections</span>
          <a href="#doc-store" class="anchor-link">#</a>
        </h2>
        <p>
          When structured schemas are too rigid, store arbitrary nested JSON documents with sub-millisecond document ID retrieval and JSONPath indexing:
        </p>

        <div class="code-box">
          <div class="code-header">
            <span>Document Collection Example (Python)</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>from tapirus import Connection

db = Connection.open("app.tapir")
users = db.collection("users")

# Insert nested JSON payload
user_id = users.insert_one({
    "name": "Faiz",
    "telemetry": {
        "status": "active",
        "tokens": 4500,
        "models": ["phi-3", "llama-3"]
    }
})

# Find document
doc = users.find_one({"_id": user_id})
print(doc)</code></pre>
        </div>
      </section>

      <!-- Section: Disk Format & Security -->
      <section class="doc-section" id="disk-format">
        <h2>
          <span>Storage Architecture: The .tapir Format</span>
          <a href="#disk-format" class="anchor-link">#</a>
        </h2>
        <p>
          TapirusDB stores all tables, vector trees, graph topologies, and JSON collections inside a single, self-describing binary file with the extension <code>.tapir</code>:
        </p>
        <ul>
          <li><strong>4KB Slotted Pages:</strong> Ultra-fast zero-copy disk serialization aligned to modern NVMe SSD physical page boundaries.</li>
          <li><strong>Page-Level ChaCha20-Poly1305 AEAD:</strong> Cryptographically verified against disk tampering with constant-time Key Check Value (KCV) verification.</li>
          <li><strong>Atomic WAL &amp; Multi-Version Concurrency (MVCC):</strong> Readers never block writers, and writes are guaranteed crash-safe via Write-Ahead Logging (WAL).</li>
        </ul>
      </section>

      <!-- Section: Client SDKs -->
      <section class="doc-section" id="sdk-rust">
        <h2>
          <span>Client SDK Guides</span>
          <a href="#sdk-rust" class="anchor-link">#</a>
        </h2>
        
        <h3>Python SDK Guide</h3>
        <div class="code-box">
          <div class="code-header">
            <span>pip install tapirus</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>import tapirus

# Connect to database file
db = tapirus.Connection("memory.tapir")

# Execute DDL
db.execute("CREATE TABLE agents (id INT PRIMARY KEY, name TEXT);")
db.execute("INSERT INTO agents VALUES (1, 'Hermes-Agent');")

# Query rows
results = db.query("SELECT * FROM agents;")
for row in results:
    print(row["id"], row["name"])</code></pre>
        </div>

        <h3 id="sdk-nodejs">Node.js &amp; TypeScript SDK Guide</h3>
        <p style="margin-bottom: 12px; color: var(--text-muted);">
          Official Node.js &amp; TypeScript client library for TapirusDB (<a href="https://www.npmjs.com/package/tapirus" target="_blank" style="color:var(--accent-cyan); font-weight:600;">npm: tapirus</a>). Supports ES Modules, CommonJS, and pure TypeScript with zero external database processes.
        </p>

        <div class="callout callout-info" style="margin: 12px 0 18px;">
          <i class="lni lni-information" style="font-size: 20px; color: #2b3a7e; margin-top: 2px;"></i>
          <div>
            <strong>Beginner Reminder:</strong> Run <code>npm init -y &amp;&amp; npm install tapirus</code> in your project directory. Put your JavaScript code in a file (e.g. <code>app.mjs</code> or <code>app.js</code>) and run it with <code>node app.mjs</code>. (Do not paste JS syntax directly into your PowerShell command line).
          </div>
        </div>

        <div class="code-box">
          <div class="code-header">
            <span>Modern ES Modules (app.mjs / index.ts)</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>import { open, Tapirus } from "tapirus";

// 1. Open local encrypted database file or in-memory instance
const db = open("production.tapir");
// (Also supports: const db = new Tapirus("production.tapir");)

// 2. Create Relational Table
db.execute(`
  CREATE TABLE IF NOT EXISTS users (
    id INT PRIMARY KEY,
    name TEXT NOT NULL,
    active INT NOT NULL
  );
`);

// 3. Insert and Query
db.execute("INSERT INTO users VALUES (1, 'Faiz', 1);");
const rows = db.query("SELECT * FROM users WHERE active = 1;");
console.log("SQL Rows:", rows);

// 4. Clean up
db.close();</code></pre>
        </div>

        <div class="code-box">
          <div class="code-header">
            <span>CommonJS (app.js)</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>const { open, Tapirus } = require("tapirus");

const db = open("production.tapir");
db.execute("CREATE TABLE IF NOT EXISTS items (id INT, name TEXT);");
db.execute("INSERT INTO items VALUES (1, 'Edge Device');");

const items = db.query("SELECT * FROM items;");
console.log("Items:", items);

db.close();</code></pre>
        </div>

        <h3 id="sdk-go">Go (Golang) SDK Guide</h3>
        <p style="margin-bottom: 12px; color: var(--text-muted);">
          Official Go client library for TapirusDB. View package reference and source documentation on <a href="https://pkg.go.dev/github.com/tapiruslab/TapirusDB/sdks/go" target="_blank" style="color:var(--accent-cyan); font-weight:600;">pkg.go.dev</a>.
        </p>
        <div class="code-box">
          <div class="code-header">
            <span>go get github.com/tapiruslab/TapirusDB/sdks/go</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>package main

import (
    "context"
    "fmt"
    tapirus "github.com/tapiruslab/TapirusDB/sdks/go"
)

func main() {
    client := tapirus.NewClient(tapirus.Config{Endpoint: "http://127.0.0.1:8080"})
    res, _ := client.Query(context.Background(), "SELECT * FROM items;")
    fmt.Println(res)
}</code></pre>
        </div>
      </section>

      <!-- Section: MCP Server -->
      <section class="doc-section" id="mcp-server">
        <h2>
          <span>Model Context Protocol (MCP) Server</span>
          <a href="#mcp-server" class="anchor-link">#</a>
        </h2>
        <p>
          TapirusDB natively integrates with AI coding assistants (Claude Desktop, Cursor, Gemini) via the open <strong>Model Context Protocol (MCP)</strong>:
        </p>
        <div class="code-box">
          <div class="code-header">
            <span>Claude Desktop Config (claude_desktop_config.json)</span>
            <button class="code-copy-btn" onclick="copyCode(this)">Copy Code</button>
          </div>
          <pre><code>{
  "mcpServers": {
    "tapirus": {
      "command": "tapirus",
      "args": ["mcp", "--database", "C:/path/to/database.tapir"]
    }
  }
}</code></pre>
        </div>
      </section>

      <!-- Documentation Sequential Pagination Footer -->
      <nav class="doc-pager" aria-label="Documentation Navigation Pager">
        <a href="#overview" class="doc-pager-card prev" id="docPagerPrev">
          <span class="doc-pager-label"><i class="lni lni-arrow-left"></i> Previous Topic</span>
          <span class="doc-pager-title" id="docPagerPrevTitle">Overview &amp; Philosophy</span>
        </a>
        <a href="#why-tapirus" class="doc-pager-card next" id="docPagerNext">
          <span class="doc-pager-label">Next Topic <i class="lni lni-arrow-right"></i></span>
          <span class="doc-pager-title" id="docPagerNextTitle">Why TapirusDB</span>
        </a>
      </nav>

    </main>

    <!-- On This Page Table of Contents (Desktop) -->
    <aside class="doc-toc">
      <div class="doc-toc-title">On This Page</div>
      <a href="#overview" class="active">Overview &amp; Philosophy</a>
      <a href="#why-tapirus">Why TapirusDB</a>
      <a href="#installation">Installation &amp; Packages</a>
      <a href="#quickstart">30-Second Quickstart</a>
      <a href="tutorial.html" style="color:var(--accent-cyan); font-weight:700;">Tutorials Portal ↗</a>
      <a href="#studio">Interactive SLM Studio</a>
      <a href="#sql-engine">Relational SQL-92</a>
      <a href="#vector-engine">HNSW Vector Search</a>
      <a href="#graph-engine">openCypher GraphRAG</a>
      <a href="#doc-store">JSON Document Store</a>
      <a href="#disk-format">Storage &amp; .tapir Format</a>
      <a href="#sdk-rust">Client SDK Guides</a>
      <a href="#mcp-server">MCP Server Integration</a>
    </aside>

  </div>

  <script>
    // Studio query templates
    const studioPresets = {
      sql: "SELECT id, name, model, memory_mb FROM agents WHERE memory_mb < 500 ORDER BY memory_mb ASC;",
      vector: "VECTOR NEAR [0.12, 0.45, 0.88, -0.23] IN knowledge_store TOP 3 METRIC cosine;",
      graph: "MATCH (a:Developer)-[r:MAINTAINS]->(b:Database) WHERE b.engine = 'TapirusDB' RETURN a.name, r.role, b.version;",
      agent: "AGENT RECALL 'user architecture preference for safe embedded memory' TOP 2 SIMD;"
    };

    function setStudioMode(mode, btn) {
      document.querySelectorAll('.studio-mode-btn').forEach(b => b.classList.remove('active'));
      btn.classList.add('active');
      document.getElementById('studioQuery').value = studioPresets[mode] || "";
    }

    function runStudioDemo() {
      const q = document.getElementById('studioQuery').value.trim();
      const out = document.getElementById('studioOutput');
      out.innerHTML = '<span style="color:#38bdf8;">[Executing query across in-memory engine...]</span>';
      
      setTimeout(() => {
        if (q.toUpperCase().startsWith("SELECT")) {
          out.innerHTML = `[SUCCESS] 3 rows retrieved in 0.00042 ms (In-Memory Engine):\n` +
            `+----+---------------+---------------+-----------+\n` +
            `| id | name          | model         | memory_mb |\n` +
            `+----+---------------+---------------+-----------+\n` +
            `| 1  | Autonomous-1  | Phi-3-Mini    | 3.8 MB    |\n` +
            `| 2  | Edge-Sovereign| TinyLlama     | 4.1 MB    |\n` +
            `| 3  | Drone-Pilot   | Qwen2-0.5B    | 4.6 MB    |\n` +
            `+----+---------------+---------------+-----------+`;
        } else if (q.toUpperCase().startsWith("VECTOR")) {
          out.innerHTML = `[SUCCESS] Top-3 Nearest Neighbor Vectors (Cosine SIMD 16-Lane):\n` +
            `1. [Score: 0.9842] "Rust Memory Safety Guarantees without Garbage Collection"\n` +
            `2. [Score: 0.9411] "Zero-Daemon In-Process Storage vs Fragile Frankenstacks"\n` +
            `3. [Score: 0.8920] "ChaCha20-Poly1305 Cryptographic Disk Authentication"`;
        } else if (q.toUpperCase().startsWith("MATCH")) {
          out.innerHTML = `[SUCCESS] Graph Traversal Matched (1 Hop, CSR Sub-Slice 0.55 µs):\n` +
            `Node(Developer {name: "Ahmad Faiz"}) --[:MAINTAINS {role: "Architect"}]--> Node(Database {engine: "TapirusDB", version: "v1.0.0"})`;
        } else {
          out.innerHTML = `[SUCCESS] Agent Memory Recalled via Reciprocal Rank Fusion (RRF):\n` +
            `1. "Prefers 100% Safe Rust embedded storage with < 4 MB idle RAM." (Relevance: 0.96)\n` +
            `2. "Prohibits external cloud daemons and JVM sockets on edge silicon." (Relevance: 0.91)`;
        }
      }, 250);
    }

    // Enhanced Copy Text Helper with Animated Emerald Badge
    function copyText(text, btn) {
      navigator.clipboard.writeText(text).then(() => {
        const orig = btn.innerText;
        btn.innerText = "✓ Copied!";
        btn.classList.add('copied');
        setTimeout(() => {
          btn.innerText = orig;
          btn.classList.remove('copied');
        }, 1800);
      });
    }

    function copyCode(btn) {
      const pre = btn.closest('.code-box').querySelector('pre code');
      if (pre) copyText(pre.innerText, btn);
    }

    // Mobile menu toggle, backdrop and auto-close
    const toggleBtn = document.getElementById('menuToggle');
    const sidebar = document.getElementById('docSidebar');
    const backdrop = document.getElementById('docBackdrop');
    const closeBtn = document.getElementById('sidebarCloseBtn');

    function openSidebar() {
      sidebar.classList.add('open');
      backdrop.classList.add('active');
      document.body.style.overflow = 'hidden';
    }

    function closeSidebar() {
      sidebar.classList.remove('open');
      backdrop.classList.remove('active');
      document.body.style.overflow = '';
    }

    if (toggleBtn && sidebar) {
      toggleBtn.addEventListener('click', () => {
        if (sidebar.classList.contains('open')) {
          closeSidebar();
        } else {
          openSidebar();
        }
      });
    }

    if (closeBtn) {
      closeBtn.addEventListener('click', closeSidebar);
    }

    if (backdrop) {
      backdrop.addEventListener('click', closeSidebar);
    }

    // Auto-close sidebar on mobile when any link inside it is clicked
    document.querySelectorAll('.doc-sidebar .doc-link').forEach(link => {
      link.addEventListener('click', () => {
        if (window.innerWidth <= 860) {
          closeSidebar();
        }
      });
    });

    // =========================================================================
    // ADVANCED LIVE SEARCH WITH DROPDOWN & SHORTCUTS (⌘K / /)
    // =========================================================================
    const searchInput = document.getElementById('docSearch');
    const searchDropdown = document.getElementById('docSearchDropdown');
    const sidebarLinks = Array.from(document.querySelectorAll('.doc-sidebar .doc-link'));

    // Build searchable topic index
    const searchIndex = sidebarLinks.map(link => {
      const href = link.getAttribute('href');
      const targetSec = document.querySelector(href);
      const title = link.textContent.trim();
      const group = link.closest('.doc-group')?.querySelector('.doc-group-title')?.textContent.trim() || 'Documentation';
      const text = targetSec ? targetSec.innerText.slice(0, 400) : '';
      return { title, href, group, text };
    });

    if (searchInput && searchDropdown) {
      searchInput.addEventListener('input', (e) => {
        const q = e.target.value.trim().toLowerCase();
        if (!q) {
          searchDropdown.classList.remove('show');
          searchDropdown.innerHTML = '';
          sidebarLinks.forEach(l => l.style.display = 'flex');
          return;
        }

        // 1. Filter sidebar links
        sidebarLinks.forEach(l => {
          const match = l.textContent.toLowerCase().includes(q);
          l.style.display = match ? 'flex' : 'none';
        });

        // 2. Populate interactive dropdown
        const matched = searchIndex.filter(item => 
          item.title.toLowerCase().includes(q) || item.text.toLowerCase().includes(q)
        ).slice(0, 8);

        if (matched.length > 0) {
          searchDropdown.innerHTML = matched.map(m => `

            <a href="${m.href}" class="doc-search-item" onclick="onSearchItemClick('${m.href}')">

              <div class="doc-search-item-title"><i class="lni lni-file"></i> ${m.title}</div>

              <div class="doc-search-item-category">${m.group}</div>

            </a>

          `).join('');
          searchDropdown.classList.add('show');
        } else {
          searchDropdown.innerHTML = `<div style="padding:14px; font-size:12px; color:var(--text-dim); text-align:center;">No matching documentation topics found.</div>`;
          searchDropdown.classList.add('show');
        }
      });

      // Keyboard shortcuts: / or Cmd+K / Ctrl+K
      window.addEventListener('keydown', (e) => {
        if ((e.key === '/' && document.activeElement !== searchInput && document.activeElement.tagName !== 'INPUT' && document.activeElement.tagName !== 'TEXTAREA') ||
            ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k')) {
          e.preventDefault();
          searchInput.focus();
          searchInput.select();
        } else if (e.key === 'Escape') {
          searchDropdown.classList.remove('show');
          searchInput.blur();
        }
      });

      // Close dropdown when clicking outside
      document.addEventListener('click', (e) => {
        if (!e.target.closest('.doc-search-box')) {
          searchDropdown.classList.remove('show');
        }
      });
    }

    function onSearchItemClick(href) {
      if (searchDropdown) searchDropdown.classList.remove('show');
      if (searchInput) searchInput.value = '';
      sidebarLinks.forEach(l => l.style.display = 'flex');
      if (window.innerWidth <= 860) closeSidebar();
    }

    // =========================================================================
    // DYNAMIC SEQUENTIAL PAGER & SCROLL SPY SYNCHRONIZATION
    // =========================================================================
    const docSections = Array.from(document.querySelectorAll('.doc-section'));
    const sectionIndexList = docSections.map(sec => {
      const id = sec.getAttribute('id');
      const h2 = sec.querySelector('h2');
      const title = h2 ? h2.textContent.replace('#', '').trim() : id;
      return { id, title };
    });

    const pagerPrev = document.getElementById('docPagerPrev');
    const pagerNext = document.getElementById('docPagerNext');
    const pagerPrevTitle = document.getElementById('docPagerPrevTitle');
    const pagerNextTitle = document.getElementById('docPagerNextTitle');
    const crumbCurrent = document.getElementById('currentCrumb');

    function updateDocPager(currentId) {
      const idx = sectionIndexList.findIndex(s => s.id === currentId);
      if (idx === -1) return;

      // Update Breadcrumbs
      if (crumbCurrent) {
        crumbCurrent.textContent = sectionIndexList[idx].title;
      }

      // Update Previous Pager
      if (idx > 0) {
        const prevSec = sectionIndexList[idx - 1];
        if (pagerPrev) {
          pagerPrev.style.visibility = 'visible';
          pagerPrev.href = `#${prevSec.id}`;
        }
        if (pagerPrevTitle) pagerPrevTitle.textContent = prevSec.title;
      } else {
        if (pagerPrev) {
          pagerPrev.style.visibility = 'hidden';
        }
      }

      // Update Next Pager
      if (idx < sectionIndexList.length - 1) {
        const nextSec = sectionIndexList[idx + 1];
        if (pagerNext) {
          pagerNext.style.visibility = 'visible';
          pagerNext.href = `#${nextSec.id}`;
        }
        if (pagerNextTitle) pagerNextTitle.textContent = nextSec.title;
      } else {
        if (pagerNext) {
          pagerNext.style.visibility = 'visible';
          pagerNext.href = `#overview`;
        }
        if (pagerNextTitle) pagerNextTitle.textContent = "Back to Top (Overview)";
      }
    }

    // Scroll active link highlight for TOC & Sidebar
    window.addEventListener('scroll', () => {
      let current = '';
      docSections.forEach(sec => {
        const top = sec.offsetTop - 130;
        if (window.scrollY >= top) {
          current = sec.getAttribute('id');
        }
      });

      if (!current && docSections.length > 0) {
        current = docSections[0].getAttribute('id');
      }

      // Sync TOC
      document.querySelectorAll('.doc-toc a').forEach(link => {
        link.classList.remove('active');
        if (link.getAttribute('href') === `#${current}`) {
          link.classList.add('active');
        }
      });

      // Sync Sidebar Active State
      sidebarLinks.forEach(link => {
        link.classList.remove('active');
        if (link.getAttribute('href') === `#${current}`) {
          link.classList.add('active');
        }
      });

      // Sync Pager and Breadcrumbs
      updateDocPager(current);
    });

    // Initial Pager Run
    if (docSections.length > 0) {
      updateDocPager(docSections[0].getAttribute('id'));
    }
  </script>
</body>
</html>