-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructure-inspector.html
More file actions
1064 lines (994 loc) · 98.7 KB
/
Copy pathstructure-inspector.html
File metadata and controls
1064 lines (994 loc) · 98.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" class="light">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Structure Inspector | WebGL Molecular Viewer | STEMKit</title>
<meta name="description" content="Free browser-based 3D molecular viewer. Load PDB, GRO, XYZ, CIF, MOL2 or CUBE files, select atoms by chain, residue, element or distance, measure bonds and angles, and export publication-quality images, all rendered locally with WebGL.">
<link rel="icon" type="image/x-icon" href="https://stemkit.net/assets/favicon.ico">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/all.min.css">
<script src="js/dependencies/3Dmol-min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
<script>tailwind.config = { darkMode: 'class' }</script>
<style>
@keyframes slideIn{from{transform:translateY(100%);opacity:0}to{transform:translateY(0);opacity:1}}
@keyframes fadeIn{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}
@keyframes pulse-dot{0%,100%{opacity:1}50%{opacity:.4}}
.custom-scroll::-webkit-scrollbar{width:6px}
.custom-scroll::-webkit-scrollbar-track{background:transparent}
.custom-scroll::-webkit-scrollbar-thumb{background-color:#cbd5e1;border-radius:20px}
.dark .custom-scroll::-webkit-scrollbar-thumb{background-color:#475569}
.toggle-track{position:relative;width:36px;height:20px;border-radius:999px;background:#cbd5e1;transition:background .2s;cursor:pointer;flex-shrink:0}
.dark .toggle-track{background:#475569}
.toggle-track.active{background:#6366f1}
.toggle-track::after{content:'';position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:transform .2s;box-shadow:0 1px 3px rgba(0,0,0,.2)}
.toggle-track.active::after{transform:translateX(16px)}
#atomInfo{position:absolute;bottom:12px;left:12px;z-index:20;background:rgba(15,23,42,.88);color:#f1f5f9;backdrop-filter:blur(8px);padding:8px 14px;border-radius:10px;font-size:12px;font-family:'Inter',monospace;pointer-events:none;opacity:0;transition:opacity .2s;line-height:1.6;max-width:300px;border:1px solid rgba(255,255,255,.1)}
#atomInfo.visible{opacity:1}
#measureInfo{position:absolute;top:12px;right:12px;z-index:20;background:rgba(15,23,42,.88);color:#f1f5f9;backdrop-filter:blur(8px);padding:8px 14px;border-radius:10px;font-size:11px;font-family:'Inter',monospace;transition:opacity .2s;line-height:1.6;max-width:240px;border:1px solid rgba(255,255,255,.1)}
#measureInfo:empty{display:none}
input[type="range"]{-webkit-appearance:none;appearance:none;width:100%;height:6px;border-radius:4px;background:#e2e8f0;outline:none}
.dark input[type="range"]{background:#334155}
input[type="range"]::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;border-radius:50%;background:#6366f1;cursor:pointer;box-shadow:0 1px 4px rgba(0,0,0,.3)}
input[type="range"]::-moz-range-thumb{width:16px;height:16px;border:none;border-radius:50%;background:#6366f1;cursor:pointer}
.section-label{display:block;font-size:10px;font-weight:700;color:#64748b;text-transform:uppercase;letter-spacing:.05em;margin-bottom:4px}
.dark .section-label{color:#94a3b8}
.sidebar-btn{background:#f1f5f9;border:none;cursor:pointer;padding:6px 0;border-radius:8px;font-size:12px;font-weight:600;color:#475569;transition:all .15s;box-shadow:0 1px 2px rgba(0,0,0,.04)}
.dark .sidebar-btn{background:#1e293b;color:#cbd5e1}
.sidebar-btn:hover{background:#e0e7ff;color:#4f46e5}
.dark .sidebar-btn:hover{background:#312e81;color:#a5b4fc}
.sidebar-select{width:100%;background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;padding:6px 8px;font-size:12px;outline:none;transition:border-color .15s}
.sidebar-select:focus{box-shadow:0 0 0 2px rgba(99,102,241,.3);border-color:#6366f1}
.dark .sidebar-select{background:#0f172a;border-color:#334155;color:#e2e8f0}
.sidebar-input{width:100%;background:#f8fafc;border:1px solid #e2e8f0;border-radius:8px;padding:6px 8px;font-size:12px;outline:none;transition:border-color .15s}
.dark .sidebar-input{background:#0f172a;border-color:#334155;color:#e2e8f0}
.sidebar-input:focus{border-color:#6366f1;box-shadow:0 0 0 2px rgba(99,102,241,.3)}
.tab-btn{padding:4px 10px;border-radius:6px;font-size:11px;font-weight:700;cursor:pointer;border:none;transition:all .15s}
.tab-btn.active{background:#6366f1;color:#fff}
.tab-btn:not(.active){background:#f1f5f9;color:#64748b}
.dark .tab-btn:not(.active){background:#1e293b;color:#94a3b8}
.mode-badge{position:absolute;top:12px;left:12px;z-index:20;padding:4px 10px;border-radius:8px;font-size:11px;font-weight:700;backdrop-filter:blur(8px);pointer-events:none;transition:opacity .2s}
.mode-badge.measure{background:rgba(245,158,11,.85);color:#fff}
.perf-warning{display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:8px;font-size:10px;font-weight:600;background:#fef3c7;color:#92400e;border:1px solid #fde68a;animation:fadeIn .2s}
.dark .perf-warning{background:rgba(146,64,14,.15);color:#fcd34d;border-color:rgba(253,230,138,.2)}
.range-group{display:flex;flex-direction:column;gap:4px}
.range-row{display:flex;align-items:center;gap:8px}
.range-row span.range-label{font-size:10px;color:#64748b;width:40px;flex-shrink:0}
.dark .range-row span.range-label{color:#94a3b8}
.range-row span.range-val{font-size:10px;color:#64748b;width:48px;text-align:right;font-variant-numeric:tabular-nums}
.dark .range-row span.range-val{color:#94a3b8}
.spatial-mode-card{border:1.5px solid #e2e8f0;border-radius:10px;padding:10px;cursor:pointer;transition:all .15s;background:#fafbfc}
.spatial-mode-card:hover{border-color:#a5b4fc;background:#eef2ff}
.spatial-mode-card.selected{border-color:#6366f1;background:#eef2ff;box-shadow:0 0 0 2px rgba(99,102,241,.2)}
/* Busy overlay for unavoidable synchronous work (surface meshing) */
#busyOverlay{position:absolute;inset:0;z-index:40;display:flex;align-items:center;justify-content:center;
background:rgba(15,23,42,.55);backdrop-filter:blur(2px)}
/* The id selector above outranks the .hidden utility class, so the
hidden state needs id+class specificity or the overlay can never be
dismissed and sits over the viewer reading "Working…" forever. */
#busyOverlay.hidden{display:none}
#busyOverlay .busy-card{display:flex;align-items:center;gap:.7rem;background:rgba(15,23,42,.94);
color:#e2e8f0;padding:.85rem 1.2rem;border-radius:.8rem;font-size:.8rem;font-weight:600;
border:1px solid rgba(255,255,255,.12);box-shadow:0 10px 30px rgba(0,0,0,.35)}
.busy-spin{width:16px;height:16px;border-radius:50%;border:2px solid rgba(255,255,255,.25);
border-top-color:#818cf8;animation:busySpin .7s linear infinite;flex-shrink:0}
@keyframes busySpin{to{transform:rotate(360deg)}}
/* Label build progress */
#labelProgress{position:absolute;bottom:12px;right:12px;z-index:25;background:rgba(67,56,202,.92);
color:#e0e7ff;padding:5px 11px;border-radius:8px;font-size:10px;font-weight:700;
font-variant-numeric:tabular-nums;pointer-events:none;border:1px solid rgba(255,255,255,.15)}
/* Measurement readout rows */
.measure-row{display:flex;align-items:center;justify-content:space-between;gap:8px}
.measure-del{background:none;border:none;color:#fca5a5;cursor:pointer;font-size:13px;
line-height:1;padding:0 2px;flex-shrink:0}
.measure-del:hover{color:#ef4444}
.dark .spatial-mode-card{border-color:#334155;background:#0f172a}
.dark .spatial-mode-card:hover{border-color:#6366f1;background:#1e1b4b}
.dark .spatial-mode-card.selected{border-color:#818cf8;background:#1e1b4b}
</style>
<style>
/* STEMKit docs / how-to / FAQ | self-contained styles */
.stk-section { padding: 3rem 0; border-top: 1px solid rgba(148,163,184,.2); }
.stk-wrap { max-width: 80rem; margin: 0 auto; padding-left: 1.5rem; padding-right: 1.5rem; }
.stk-chip { display:inline-flex; align-items:center; gap:.45rem; font-size:.68rem; font-weight:800;
text-transform:uppercase; letter-spacing:.12em; padding:.3rem .7rem; border-radius:9999px;
background:#eef2ff; color:#4338ca; border:1px solid #e0e7ff; }
.dark .stk-chip { background:rgba(67,56,202,.18); color:#a5b4fc; border-color:rgba(99,102,241,.3); }
.stk-h2 { font-size:1.6rem; font-weight:800; letter-spacing:-.02em; margin:.75rem 0 .5rem; }
.stk-lead { max-width:48rem; color:#64748b; line-height:1.6; }
.dark .stk-lead { color:#94a3b8; }
.stk-grid { display:grid; gap:1rem; grid-template-columns:1fr; margin-top:1.5rem; }
@media (min-width:768px){ .stk-grid-3{grid-template-columns:repeat(3,1fr);} .stk-grid-2{grid-template-columns:repeat(2,1fr);} }
.stk-card { border-radius:1rem; border:1px solid rgba(148,163,184,.25); padding:1.4rem; background:#fff; }
.dark .stk-card { background:#0f172a; border-color:rgba(51,65,85,.8); }
.stk-card h3 { font-weight:700; margin-bottom:.4rem; }
.stk-card p { font-size:.88rem; color:#64748b; line-height:1.6; }
.dark .stk-card p { color:#94a3b8; }
.stk-step { display:flex; gap:.85rem; align-items:flex-start; }
.stk-num { width:2rem; height:2rem; border-radius:9999px; display:inline-flex; align-items:center;
justify-content:center; font-weight:800; font-size:.85rem; flex-shrink:0;
background:#4f46e5; color:#fff; }
.stk-step h3 { font-weight:700; font-size:.95rem; margin-bottom:.15rem; }
.stk-step p { font-size:.85rem; color:#64748b; line-height:1.5; }
.dark .stk-step p { color:#94a3b8; }
.stk-note { display:flex; gap:.6rem; align-items:flex-start; font-size:.82rem; line-height:1.55;
background:#fffbeb; border:1px solid #fde68a; color:#92400e; border-radius:.75rem; padding:.9rem 1rem; }
.dark .stk-note { background:rgba(120,53,15,.15); border-color:rgba(180,83,9,.4); color:#fcd34d; }
.stk-faq { border-bottom:1px solid rgba(148,163,184,.22); }
.stk-faq > summary { list-style:none; cursor:pointer; padding:1rem 0; font-weight:600; font-size:.95rem;
display:flex; justify-content:space-between; align-items:center; gap:1rem; }
.stk-faq > summary::-webkit-details-marker { display:none; }
.stk-faq > summary::after { content:"+"; font-weight:700; color:#6366f1; font-size:1.2rem; line-height:1; }
.stk-faq[open] > summary::after { content:"\2212"; }
.stk-faq > div { padding:0 0 1.1rem; font-size:.88rem; line-height:1.6; color:#475569; }
.dark .stk-faq > div { color:#94a3b8; }
.stk-refs { display:flex; flex-wrap:wrap; gap:.6rem; margin-top:1rem; }
.stk-refs a { display:inline-flex; align-items:center; gap:.4rem; font-size:.82rem; font-weight:600;
color:#4f46e5; text-decoration:none; border:1px solid #e0e7ff; background:#eef2ff;
padding:.4rem .8rem; border-radius:.6rem; }
.dark .stk-refs a { color:#a5b4fc; background:rgba(67,56,202,.15); border-color:rgba(99,102,241,.3); }
.stk-refs a:hover { text-decoration:underline; }
.stk-byline { font-size:.8rem; color:#94a3b8; margin-top:.35rem; }
.stk-credit { margin-top:2rem; font-size:.8rem; color:#94a3b8; }
.stk-refs-h { font-weight:700; font-size:1rem; margin-top:1.9rem; margin-bottom:.5rem; }
.stk-refs-list { font-size:.82rem; color:#64748b; line-height:1.75; padding-left:1.2rem; }
.dark .stk-refs-list { color:#94a3b8; }
.stk-refs-list li { margin-bottom:.45rem; }
.stk-refs-list a { color:#4f46e5; text-decoration:none; }
.dark .stk-refs-list a { color:#a5b4fc; }
.stk-refs-list a:hover { text-decoration:underline; }
/* Syntax reference table */
.stk-syntax { width:100%; border-collapse:collapse; font-size:.85rem; margin-top:.75rem; }
.stk-syntax th { text-align:left; font-size:.7rem; text-transform:uppercase; letter-spacing:.08em;
color:#64748b; padding:.5rem .6rem; border-bottom:2px solid rgba(148,163,184,.3); }
.dark .stk-syntax th { color:#94a3b8; }
.stk-syntax td { padding:.55rem .6rem; border-bottom:1px solid rgba(148,163,184,.18); vertical-align:top; }
.stk-syntax td:first-child { white-space:nowrap; }
.stk-syntax code { font-family:ui-monospace,SFMono-Regular,Menlo,monospace; font-size:.82rem;
font-weight:700; color:#4338ca; background:#eef2ff; padding:.15rem .4rem;
border-radius:.35rem; border:1px solid #e0e7ff; }
.dark .stk-syntax code { color:#a5b4fc; background:rgba(67,56,202,.18); border-color:rgba(99,102,241,.3); }
.stk-syntax p { color:#64748b; line-height:1.5; }
.dark .stk-syntax p { color:#94a3b8; }
.stk-kbd { display:inline-block; font-family:ui-monospace,monospace; font-size:.72rem; font-weight:700;
padding:.15rem .45rem; border-radius:.35rem; background:#f1f5f9; color:#475569;
border:1px solid #cbd5e1; border-bottom-width:2px; }
.dark .stk-kbd { background:#1e293b; color:#cbd5e1; border-color:#475569; }
/* Clickable query example chips */
.query-example { cursor:pointer; transition:all .15s; }
.query-example:hover { background:#6366f1 !important; color:#fff !important; border-color:#6366f1 !important; }
</style>
<script type="application/ld+json">
{"@context": "https://schema.org", "@type": "HowTo", "name": "How to inspect a molecular structure in 3D", "totalTime": "PT2M", "step": [{"@type": "HowToStep", "position": 1, "name": "Load a structure", "text": "Drag in a PDB, GRO, XYZ, CIF, MOL2 or CUBE coordinate file, or enter a four-character PDB ID to fetch it from RCSB."}, {"@type": "HowToStep", "position": 2, "name": "Pick a representation", "text": "Choose cartoon, stick, ball-and-stick, sphere, cross or wireframe, then colour by element, chain, residue, B-factor or secondary structure."}, {"@type": "HowToStep", "position": 3, "name": "Narrow the selection", "text": "Filter by chain, residue and element, add a within-distance radius for binding pockets, or slice along an axis with the spatial sliders, then Isolate or Highlight."}, {"@type": "HowToStep", "position": 4, "name": "Measure and export", "text": "Enable measure mode and click two atoms for a distance or three for an angle, then export a high-resolution PNG or save the selection as a PDB fragment."}]}
</script>
<script type="application/ld+json">
{"@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [{"@type": "Question", "name": "Is my structure uploaded anywhere?", "acceptedAnswer": {"@type": "Answer", "text": "No. Files are read with the browser's FileReader and rendered by 3Dmol.js on your own GPU. The only network request is the optional PDB ID fetch, which asks RCSB for that one public entry."}}, {"@type": "Question", "name": "Which file formats are supported?", "acceptedAnswer": {"@type": "Answer", "text": "PDB, ENT, CIF/mmCIF, SDF, MOL, MOL2, XYZ, GRO, PQR, PRMTOP, MMTF, CDJSON, CUBE and VASP/POSCAR/CONTCAR. Multi-frame files load as a trajectory with a frame slider."}}, {"@type": "Question", "name": "Why does the cartoon style show nothing?", "acceptedAnswer": {"@type": "Answer", "text": "Cartoon rendering needs backbone connectivity and secondary-structure information, which only protein and nucleic-acid formats carry. Use stick or ball-and-stick for small molecules and bare XYZ files."}}, {"@type": "Question", "name": "Why are my labels capped or disabled?", "acceptedAnswer": {"@type": "Answer", "text": "Each label is an individual sprite and costs far more than an atom. Above 5,000 atoms the tool warns and exposes a cap; above 50,000 it disables labels to stop the tab freezing."}}, {"@type": "Question", "name": "My high-resolution export came out smaller than I asked for.", "acceptedAnswer": {"@type": "Answer", "text": "WebGL contexts have a maximum texture size, commonly 4096, 8192 or 16384 pixels. Requests beyond that limit would black out the canvas, so exports are clamped to the largest safe size."}}, {"@type": "Question", "name": "What is the difference between Isolate and Highlight?", "acceptedAnswer": {"@type": "Answer", "text": "Isolate hides everything outside the selection for a clean figure. Highlight keeps the rest of the structure as a faint wireframe so the selection stays in context."}}, {"@type": "Question", "name": "Which surface type should I use?", "acceptedAnswer": {"@type": "Answer", "text": "Van der Waals is fastest and shows atomic radii. Solvent-accessible traces a rolling probe centre and is used for buried-area calculations. Solvent-excluded hugs the molecule tightly and looks best in figures but costs the most."}}, {"@type": "Question", "name": "Can I script the same selections elsewhere?", "acceptedAnswer": {"@type": "Answer", "text": "Yes. The query box compiles to a 3Dmol AtomSelectionSpec object, so chain:A resn:HEM is simply {chain:'A', resn:'HEM'} in the library's API."}}, {"@type": "Question", "name": "Turning on labels used to freeze the tab. What changed?", "acceptedAnswer": {"@type": "Answer", "text": "Labels are built in small slices spread across animation frames instead of one blocking loop, so the browser keeps painting and shows a live progress count. They are scoped to the current selection by default, and when a scope exceeds the limit the atoms nearest the centre of the view are kept."}}, {"@type": "Question", "name": "How do I make a clean measurement figure?", "acceptedAnswer": {"@type": "Answer", "text": "Enable Figure mode in the Tools tab. Everything except the measured atoms drops to a faint wireframe, thin stick, cartoon or hidden at an opacity you control, while the picked atoms keep full representation. Measurement appearance controls line colour, thickness, dash, marker size, label size and colour, decimals and units."}}, {"@type": "Question", "name": "Can I get the measurement numbers out as data?", "acceptedAnswer": {"@type": "Answer", "text": "Copy data puts every measurement on the clipboard as tab-separated text with type, atoms, value and unit columns, which pastes directly into a spreadsheet."}}, {"@type": "Question", "name": "Why does building a surface still pause the viewer?", "acceptedAnswer": {"@type": "Answer", "text": "Surface meshing is a single synchronous call inside 3Dmol.js and cannot be sliced across frames. The tool paints a busy indicator and starts work on the next frame so you get feedback, refuses above 100,000 atoms, and can scope the surface to your current selection."}}]}
</script>
<link rel="stylesheet" href="src/home.css">
<link rel="stylesheet" href="src/output.css">
</head>
<body class="bg-slate-50 dark:bg-slate-950 text-slate-900 dark:text-slate-100 min-h-screen flex flex-col transition-colors duration-300">
<!-- NAV -->
<nav class="sticky top-0 z-50 w-full bg-white/80 dark:bg-slate-950/80 backdrop-blur-md border-b border-slate-200 dark:border-slate-800 transition-colors duration-300">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between items-center h-16 sm:h-20">
<a href="index.html" class="flex items-center gap-2 hover:opacity-80 transition-opacity">
<div class="bg-indigo-600 text-white p-2 sm:p-2.5 rounded-lg shadow-sm flex items-center justify-center"><i class="fa-solid fa-flask text-lg sm:text-xl"></i></div>
<span class="text-xl sm:text-2xl font-black tracking-tighter text-slate-900 dark:text-white">STEMKit</span>
</a>
<div class="hidden md:flex items-center gap-6 text-sm font-semibold text-slate-600 dark:text-slate-300">
<a href="index.html#data-tools" class="hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors">Data</a>
<a href="index.html#comp-tools" class="hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors">Compute</a>
<a href="index.html#pub-tools" class="hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors">Writing & Citations</a>
<a href="index.html#focus-tools" class="hover:text-indigo-600 dark:hover:text-indigo-400 transition-colors">Focus</a>
<div class="h-5 w-px bg-slate-200 dark:bg-slate-700"></div>
<button class="themeToggle p-2 rounded-full hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors" aria-label="Toggle dark mode">
<i class="fa-solid fa-moon dark:hidden text-lg"></i><i class="fa-solid fa-sun hidden dark:block text-yellow-400 text-lg"></i>
</button>
<a href="plot-digitizer.html" class="bg-indigo-600 hover:bg-indigo-700 text-white px-5 py-2.5 rounded-full text-sm font-bold transition-all shadow-md hover:shadow-lg"><i class="fa-solid fa-crosshairs mr-1"></i> Plot Digitizer</a>
</div>
<div class="flex items-center gap-2 md:hidden">
<button class="themeToggle p-2 rounded-full hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors text-slate-600 dark:text-slate-300"><i class="fa-solid fa-moon dark:hidden text-lg"></i><i class="fa-solid fa-sun hidden dark:block text-yellow-400 text-lg"></i></button>
<button id="mobile-menu-btn" class="text-slate-600 dark:text-slate-300 hover:text-indigo-600 p-2 focus:outline-none"><i class="fa-solid fa-bars text-2xl" id="menu-icon"></i></button>
</div>
</div>
</div>
<div id="mobile-menu" class="hidden md:hidden bg-white/95 dark:bg-slate-900/95 backdrop-blur-md border-b border-slate-200 dark:border-slate-800 absolute w-full shadow-xl">
<div class="px-4 pt-2 pb-6 space-y-2 text-base font-semibold text-slate-600 dark:text-slate-300">
<a href="index.html#data-tools" class="mobile-link block py-3 px-4 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-indigo-600 transition-colors">Data & Stats</a>
<a href="index.html#comp-tools" class="mobile-link block py-3 px-4 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-indigo-600 transition-colors">Compute</a>
<a href="index.html#pub-tools" class="mobile-link block py-3 px-4 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-indigo-600 transition-colors">Writing & Citations</a>
<a href="index.html#focus-tools" class="mobile-link block py-3 px-4 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-800 hover:text-indigo-600 transition-colors">Focus & Flow</a>
<div class="pt-4 mt-2 border-t border-slate-100 dark:border-slate-800">
<a href="plot-digitizer.html" class="block text-center bg-indigo-600 hover:bg-indigo-700 text-white py-3 rounded-xl shadow-md transition-colors">Digitizer Pro</a>
</div>
</div>
</div>
</nav>
<main class="flex-grow max-w-7xl mx-auto px-4 sm:px-6 py-6 w-full flex flex-col gap-6">
<!-- UPLOAD ZONE -->
<section id="uploadZone" class="flex-grow flex flex-col items-center justify-center border-2 border-dashed border-indigo-300 dark:border-indigo-700 rounded-3xl bg-indigo-50/50 dark:bg-indigo-900/10 hover:bg-indigo-50 dark:hover:bg-indigo-900/20 transition-all cursor-pointer p-10 text-center group">
<input type="file" id="fileInput" accept=".pdb,.xyz,.gro,.sdf,.mol,.mol2,.cif,.mcif,.cdjson,.json,.mmtf,.prmtop,.pqr,.cube,.vasp,.poscar,.contcar,.ent" class="hidden" aria-label="Upload molecular structure file">
<div class="w-20 h-20 bg-indigo-100 dark:bg-indigo-900/50 rounded-2xl flex items-center justify-center mb-5 text-indigo-600 dark:text-indigo-400 group-hover:scale-110 transition-transform"><i class="fa-solid fa-microscope text-4xl"></i></div>
<h1 class="text-3xl font-bold mb-3">3D Structure Inspector</h1>
<p class="text-slate-500 dark:text-slate-400 mb-4 max-w-md">Render PDB, SDF, MOL2, XYZ, CIF, GRO, CUBE, MMTF, VASP, and more.</p>
<button class="bg-indigo-600 hover:bg-indigo-700 text-white px-8 py-3 rounded-xl font-medium transition-colors shadow-sm">Select Coordinate File</button>
<div class="mt-5 flex items-center gap-2">
<span class="text-xs text-slate-400 font-semibold">or</span>
<input id="pdbIdInput" type="text" maxlength="6" placeholder="PDB ID (e.g. 4N8T)" class="sidebar-input w-40 text-center text-xs" onclick="event.stopPropagation()">
<button id="fetchPdbBtn" class="bg-indigo-600 hover:bg-indigo-700 text-white px-4 py-2 rounded-lg text-xs font-bold transition-colors" onclick="event.stopPropagation()"><i class="fa-solid fa-download mr-1"></i>Fetch</button>
</div>
<p class="text-[10px] text-slate-400 dark:text-slate-500 mt-3">PDB · SDF · MOL · MOL2 · XYZ · CIF · CDJSON · MMTF · PRMTOP · GRO · PQR · CUBE · VASP</p>
</section>
<!-- WORKSPACE -->
<section id="workspace" class="hidden flex-col lg:flex-row gap-4 w-full" style="min-height:720px">
<!-- SIDEBAR -->
<aside id="sidebar" class="w-full lg:w-[320px] flex flex-col gap-3 bg-white dark:bg-slate-950 p-4 rounded-2xl border border-slate-200 dark:border-slate-800 shadow-sm overflow-y-auto custom-scroll shrink-0" style="max-height:88vh">
<div>
<h2 id="fileName" class="font-bold text-base truncate">structure.pdb</h2>
<p id="structureMeta" class="text-xs text-slate-500 dark:text-slate-400 mb-0.5">0 Atoms</p>
<p id="formatBadge" class="text-[10px] text-indigo-600 dark:text-indigo-400 font-semibold mb-2"></p>
<div id="perfWarning" class="hidden perf-warning mb-2">
<i class="fa-solid fa-triangle-exclamation"></i>
<span id="perfWarningText">Large structure, labels may cause lag.</span>
</div>
<button id="resetBtn" class="text-[11px] text-red-600 hover:text-red-700 font-medium"><i class="fa-solid fa-rotate-left mr-1"></i>Close viewer</button>
</div>
<hr class="border-slate-200 dark:border-slate-800">
<div class="flex gap-1 flex-wrap">
<button class="tab-btn active" data-tab="tabStyle">Style</button>
<button class="tab-btn" data-tab="tabDisplay">Display</button>
<button class="tab-btn" data-tab="tabTools">Tools</button>
<button class="tab-btn" data-tab="tabExport">Export</button>
</div>
<!-- TAB: Style -->
<div id="tabStyle" class="tab-content flex flex-col gap-3">
<div class="flex flex-col gap-1">
<label class="section-label">Rendering style</label>
<select id="styleSelect" class="sidebar-select">
<option value="stick">Stick</option>
<option value="ballstick">Ball & Stick</option>
<option value="sphere">Sphere (vdW)</option>
<option value="cross">Cross</option>
<option value="line">Wireframe</option>
<option value="cartoon">Cartoon (Protein/NA)</option>
</select>
</div>
<div class="flex flex-col gap-1">
<label class="section-label">Color scheme</label>
<select id="colorSelect" class="sidebar-select">
<option value="element">By Element (Jmol)</option>
<option value="chain">By Chain</option>
<option value="residue">By Residue</option>
<option value="bFactor">By B-Factor</option>
<option value="spectrum">Spectrum (Rainbow)</option>
<option value="ss">By Secondary Structure</option>
<option value="custom">Custom Color</option>
</select>
</div>
<div id="perElementColorContainer" class="hidden flex flex-col gap-2 mt-2 p-2 bg-slate-50 dark:bg-slate-900/50 rounded-lg border border-slate-200 dark:border-slate-800 max-h-48 overflow-y-auto custom-scroll"></div>
<hr class="border-slate-200 dark:border-slate-800">
<div class="flex flex-col gap-2">
<label class="section-label">Selection styling</label>
<p class="text-[10px] text-slate-400 leading-tight mb-1">Apply a different style to a subset of atoms.</p>
<div class="flex flex-col gap-2 p-3 bg-slate-50 dark:bg-slate-900/80 rounded-xl border border-slate-200 dark:border-slate-800">
<div class="grid grid-cols-2 gap-2">
<div>
<span class="text-[10px] font-semibold text-slate-500 mb-1 block">Chain</span>
<select id="selChain" class="sidebar-select text-[11px]">
<option value="">All Chains</option>
</select>
</div>
<div>
<span class="text-[10px] font-semibold text-slate-500 mb-1 block">Element</span>
<select id="selElem" class="sidebar-select text-[11px]">
<option value="">All Elements</option>
</select>
</div>
</div>
<div>
<span class="text-[10px] font-semibold text-slate-500 mb-1 block">Residue</span>
<select id="selResn" class="sidebar-select text-[11px]">
<option value="">All Residues</option>
</select>
</div>
<!-- Advanced text query (collapsible) -->
<div class="border border-slate-200 dark:border-slate-700 rounded-lg overflow-hidden mt-1">
<button id="selAdvancedToggle" class="w-full text-left px-2.5 py-1.5 bg-slate-100 dark:bg-slate-800 text-[10px] font-bold text-slate-500 dark:text-slate-400 flex justify-between items-center hover:bg-slate-200 dark:hover:bg-slate-700 transition-colors">
<span><i class="fa-solid fa-terminal mr-1"></i>Advanced query</span>
<i class="fa-solid fa-chevron-down text-[8px] transition-transform duration-200" id="selAdvancedIcon"></i>
</button>
<div id="selAdvancedPanel" class="hidden px-2.5 py-2 border-t border-slate-200 dark:border-slate-700">
<input id="selQuery" type="text" placeholder="e.g. resi:1-50 atom:CA ss:h" class="sidebar-input text-[11px]">
<p class="text-[9px] text-slate-400 mt-1">Overrides dropdowns when filled. Uses same syntax as Tools tab.</p>
</div>
</div>
</div>
<div class="flex gap-1 mt-1">
<select id="selStyle" class="sidebar-select flex-grow text-[11px]">
<option value="stick">Stick</option>
<option value="ballstick">Ball & Stick</option>
<option value="sphere">Sphere</option>
<option value="cartoon">Cartoon</option>
<option value="cartoontube">Cartoon (Tube/Trace)</option>
<option value="line">Wireframe</option>
<option value="hidden">Hide</option>
</select>
<button id="applySelStyle" class="sidebar-btn px-3 text-[11px]">Apply</button>
</div>
<label class="flex items-center gap-1.5 cursor-pointer mt-1">
<input type="checkbox" id="selStyleUseColor" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-bold text-slate-600 dark:text-slate-300">Override colour</span>
<input type="color" id="selStyleColor" value="#f59e0b" class="hidden w-6 h-6 rounded cursor-pointer border-0 p-0">
</label>
<button id="clearSelStyles" class="text-[10px] text-red-500 hover:text-red-600 font-medium mt-1 text-left">Clear selection styles</button>
</div>
</div>
<!-- TAB: Display -->
<div id="tabDisplay" class="tab-content hidden flex flex-col gap-3">
<label class="section-label">Overlays</label>
<div class="flex flex-col gap-2.5">
<div class="flex items-center justify-between">
<div class="flex items-center gap-1.5">
<span class="text-xs text-slate-700 dark:text-slate-300">Atom labels</span>
<span id="atomLabelWarn" class="hidden text-[9px] text-amber-600 dark:text-amber-400 font-bold">(slow)</span>
</div>
<div id="toggleAtomLabels" class="toggle-track" role="switch" aria-checked="false" tabindex="0"></div>
</div>
<div class="flex items-center justify-between">
<div class="flex items-center gap-1.5">
<span class="text-xs text-slate-700 dark:text-slate-300">Residue labels</span>
<span id="resLabelWarn" class="hidden text-[9px] text-amber-600 dark:text-amber-400 font-bold">(slow)</span>
</div>
<div id="toggleResLabels" class="toggle-track" role="switch" aria-checked="false" tabindex="0"></div>
</div>
<div class="flex items-center gap-2">
<span class="text-[10px] text-slate-500 w-20 shrink-0">Label scope</span>
<select id="labelScope" class="sidebar-select text-[11px] flex-grow">
<option value="selection" selected>Current selection</option>
<option value="visible">Visible atoms</option>
<option value="all">Everything</option>
</select>
</div>
<p class="text-[9px] text-slate-400 leading-tight -mt-1">Scoping to a selection is what keeps labels usable on big systems. Over the limit, the atoms nearest the camera win.</p>
<div id="labelLimitRow" class="hidden">
<div class="flex items-center gap-2">
<span class="text-[10px] text-slate-500 w-20 shrink-0">Label limit</span>
<input type="range" id="labelLimit" min="100" max="10000" step="100" value="1500" class="flex-grow">
<span id="labelLimitVal" class="text-[10px] text-slate-500 w-12 text-right">1,500</span>
</div>
<label class="flex items-center gap-1.5 cursor-pointer mt-1">
<input type="checkbox" id="labelForce" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-bold text-amber-600 dark:text-amber-400">Allow labels above 50k atoms (risky)</span>
</label>
</div>
<div class="flex items-center justify-between"><span class="text-xs text-slate-700 dark:text-slate-300">Show hydrogens</span><div id="toggleHydrogens" class="toggle-track active" role="switch" aria-checked="true" tabindex="0"></div></div>
<div class="flex items-center justify-between"><span class="text-xs text-slate-700 dark:text-slate-300">Axis indicator</span><div id="toggleAxis" class="toggle-track" role="switch" aria-checked="false" tabindex="0"></div></div>
<div class="flex items-center justify-between"><span class="text-xs text-slate-700 dark:text-slate-300">Spin animation</span><div id="toggleSpin" class="toggle-track" role="switch" aria-checked="false" tabindex="0"></div></div>
<div class="flex items-center justify-between"><span class="text-xs text-slate-700 dark:text-slate-300">Click to inspect</span><div id="toggleClickInspect" class="toggle-track active" role="switch" aria-checked="true" tabindex="0"></div></div>
<div class="flex items-center justify-between"><span class="text-xs text-slate-700 dark:text-slate-300">Outline</span><div id="toggleOutline" class="toggle-track" role="switch" aria-checked="false" tabindex="0"></div></div>
</div>
<hr class="border-slate-200 dark:border-slate-800">
<label class="section-label">Solvent surface</label>
<div class="flex items-center gap-1.5">
<button id="surfaceBtn" class="sidebar-btn px-3 text-[11px] whitespace-nowrap">Toggle</button>
<select id="surfaceType" class="sidebar-select text-[11px] flex-grow">
<option value="VDW">Van der Waals</option>
<option value="SAS">Solvent Accessible</option>
<option value="SES">Solvent Excluded</option>
<option value="MS">Molecular</option>
</select>
</div>
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="surfaceSelOnly" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-bold text-slate-600 dark:text-slate-300">Only current selection</span>
</label>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-12 shrink-0">Opacity</span><input type="range" id="surfaceOpacity" min="0.05" max="1" step="0.05" value="0.6" class="flex-grow"><span id="surfaceOpacityVal" class="text-[10px] text-slate-500 w-7 text-right">0.6</span></div>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-12 shrink-0">Color</span>
<select id="surfaceColorScheme" class="sidebar-select text-[11px] flex-grow">
<option value="white">White</option>
<option value="element">By Element</option>
<option value="chain">By Chain</option>
<option value="bFactor">By B-Factor</option>
<option value="spectrum">Spectrum</option>
<option value="custom">Custom</option>
</select>
<input type="color" id="surfaceCustomColor" value="#ffffff" class="w-6 h-6 rounded cursor-pointer border-0 p-0 hidden">
</div>
<hr class="border-slate-200 dark:border-slate-800">
<label class="section-label">Slab / clipping</label>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-12 shrink-0">Near</span><input type="range" id="slabNear" min="-100" max="0" step="1" value="-100" class="flex-grow"><span id="slabNearVal" class="text-[10px] text-slate-500 w-7 text-right">Off</span></div>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-12 shrink-0">Far</span><input type="range" id="slabFar" min="0" max="100" step="1" value="100" class="flex-grow"><span id="slabFarVal" class="text-[10px] text-slate-500 w-7 text-right">Off</span></div>
<button id="resetSlab" class="text-[10px] text-slate-500 hover:text-indigo-500 font-medium text-left">Reset slab</button>
<hr class="border-slate-200 dark:border-slate-800">
<label class="section-label">Background</label>
<select id="bgSelect" class="sidebar-select">
<option value="theme">Match theme</option>
<option value="black">Black</option>
<option value="white">White</option>
<option value="grey">Grey</option>
</select>
<hr class="border-slate-200 dark:border-slate-800">
<label class="section-label">Camera presets</label>
<button id="centerBtn" class="sidebar-btn text-xs"><i class="fa-solid fa-compress mr-1"></i>Recenter</button>
<div class="grid grid-cols-3 gap-1.5">
<button data-axis="xy-pos" class="axis-btn sidebar-btn text-[10px]">XY <span class="opacity-40">+Z</span></button>
<button data-axis="xz-pos" class="axis-btn sidebar-btn text-[10px]">XZ <span class="opacity-40">+Y</span></button>
<button data-axis="yz-pos" class="axis-btn sidebar-btn text-[10px]">YZ <span class="opacity-40">+X</span></button>
<button data-axis="xy-neg" class="axis-btn sidebar-btn text-[10px]">XY <span class="opacity-40">-Z</span></button>
<button data-axis="xz-neg" class="axis-btn sidebar-btn text-[10px]">XZ <span class="opacity-40">-Y</span></button>
<button data-axis="yz-neg" class="axis-btn sidebar-btn text-[10px]">YZ <span class="opacity-40">-X</span></button>
</div>
</div>
<!-- TAB: Tools -->
<div id="tabTools" class="tab-content hidden flex flex-col gap-3">
<label class="section-label">Distance measurement</label>
<p class="text-[10px] text-slate-400 leading-tight">Click two atoms to measure a distance, or enable angle mode and pick three.</p>
<div class="flex gap-1.5">
<button id="measureModeBtn" class="sidebar-btn flex-grow text-[11px]"><i class="fa-solid fa-ruler mr-1"></i>Measure Mode</button>
<button id="clearMeasures" class="sidebar-btn px-3 text-[11px]">Clear All</button>
</div>
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="measureMode3" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-bold text-slate-600 dark:text-slate-300">Angle mode (pick 3 atoms)</span>
</label>
<div class="flex gap-1.5">
<button id="measureZoomBtn" class="sidebar-btn flex-grow text-[11px]"><i class="fa-solid fa-magnifying-glass-plus mr-1"></i>Zoom to picks</button>
<button id="measureCopyBtn" class="sidebar-btn flex-grow text-[11px]"><i class="fa-solid fa-clipboard mr-1"></i>Copy data</button>
</div>
<!-- FIGURE MODE -->
<div class="p-3 bg-amber-50/60 dark:bg-amber-900/10 rounded-xl border border-amber-200 dark:border-amber-900/40 flex flex-col gap-2">
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="measureFocusToggle" class="rounded border-slate-300 text-amber-600 focus:ring-amber-600">
<span class="text-[11px] font-bold text-amber-800 dark:text-amber-300"><i class="fa-solid fa-wand-magic-sparkles mr-1"></i>Figure mode</span>
</label>
<p class="text-[9px] text-slate-500 dark:text-slate-400 leading-tight -mt-1">Fades everything except the atoms you measured, so the geometry reads clearly in a paper.</p>
<div id="measureFocusPanel" class="hidden flex flex-col gap-2 pt-1">
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="measureFocusRes" checked class="rounded border-slate-300 text-amber-600 focus:ring-amber-600">
<span class="text-[10px] font-semibold text-slate-600 dark:text-slate-300">Keep whole residues in focus</span>
</label>
<div class="flex items-center gap-1.5">
<span class="text-[10px] text-slate-500 w-14 shrink-0">Context</span>
<select id="measureContextStyle" class="sidebar-select text-[10px] flex-grow">
<option value="wire" selected>Wireframe</option>
<option value="stick">Thin stick</option>
<option value="cartoon">Cartoon</option>
<option value="hide">Hide entirely</option>
</select>
<input type="color" id="measureContextColor" value="#94a3b8" class="w-6 h-6 rounded cursor-pointer border-0 p-0 shrink-0" title="Context colour">
</div>
<div class="flex items-center gap-2">
<span class="text-[10px] text-slate-500 w-14 shrink-0">Fade</span>
<input type="range" id="measureContextOpacity" min="0.03" max="1" step="0.01" value="0.15" class="flex-grow">
<span id="measureContextOpacityVal" class="text-[10px] text-slate-500 w-8 text-right">0.15</span>
</div>
</div>
</div>
<!-- APPEARANCE -->
<div class="border border-slate-200 dark:border-slate-800 rounded-lg overflow-hidden">
<button class="sel-guide-btn w-full text-left px-3 py-2 bg-slate-50 dark:bg-slate-900 text-[11px] font-bold text-slate-600 dark:text-slate-300 flex justify-between items-center transition-colors hover:bg-slate-100 dark:hover:bg-slate-800">
<span><i class="fa-solid fa-palette mr-1"></i>Measurement appearance</span>
<i class="fa-solid fa-chevron-down transition-transform duration-200"></i>
</button>
<div class="hidden p-3 bg-slate-50 dark:bg-slate-900/50 flex flex-col gap-2 border-t border-slate-200 dark:border-slate-800">
<div class="flex items-center gap-2">
<span class="text-[10px] text-slate-500 w-14 shrink-0">Line</span>
<input type="color" id="measureLineColor" value="#facc15" class="w-6 h-6 rounded cursor-pointer border-0 p-0 shrink-0">
<input type="range" id="measureLineWidth" min="0.01" max="0.3" step="0.01" value="0.04" class="flex-grow">
<span id="measureLineWidthVal" class="text-[10px] text-slate-500 w-8 text-right">0.04</span>
</div>
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="measureDashed" checked class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-semibold text-slate-600 dark:text-slate-300">Dashed line</span>
</label>
<div class="flex items-center gap-2">
<span class="text-[10px] text-slate-500 w-14 shrink-0">Markers</span>
<input type="range" id="measureMarkerSize" min="0" max="1.2" step="0.05" value="0.4" class="flex-grow">
<span id="measureMarkerSizeVal" class="text-[10px] text-slate-500 w-8 text-right">0.40</span>
</div>
<hr class="border-slate-200 dark:border-slate-800">
<div class="flex items-center gap-2">
<span class="text-[10px] text-slate-500 w-14 shrink-0">Label</span>
<input type="color" id="measureLabelColor" value="#fef08a" class="w-6 h-6 rounded cursor-pointer border-0 p-0 shrink-0">
<input type="range" id="measureLabelSize" min="8" max="28" step="1" value="11" class="flex-grow">
<span id="measureLabelSizeVal" class="text-[10px] text-slate-500 w-8 text-right">11</span>
</div>
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="measureLabelBg" checked class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-semibold text-slate-600 dark:text-slate-300">Label background</span>
</label>
<div class="flex items-center gap-1.5">
<span class="text-[10px] text-slate-500 w-14 shrink-0">Decimals</span>
<select id="measureDecimals" class="sidebar-select text-[10px] flex-grow">
<option value="0">0</option>
<option value="1">1</option>
<option value="2" selected>2</option>
<option value="3">3</option>
</select>
<label class="flex items-center gap-1 cursor-pointer shrink-0">
<input type="checkbox" id="measureShowUnit" checked class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-semibold text-slate-600 dark:text-slate-300">Units</span>
</label>
</div>
</div>
</div>
<hr class="border-slate-200 dark:border-slate-800">
<label class="section-label">Interactive selection builder</label>
<p class="text-[10px] text-slate-400 leading-tight mb-2">Build a selection to isolate or zoom. Updates live when auto-isolate is on.</p>
<div class="flex flex-col gap-2 p-3 bg-slate-50 dark:bg-slate-900/80 rounded-xl border border-slate-200 dark:border-slate-800">
<div class="grid grid-cols-2 gap-2">
<div>
<span class="text-[10px] font-semibold text-slate-500 mb-1 block">Residue</span>
<select id="buildResn" class="sidebar-select text-[11px] interactive-select">
<option value="">All Residues</option>
</select>
</div>
<div>
<span class="text-[10px] font-semibold text-slate-500 mb-1 block">Element</span>
<select id="buildElem" class="sidebar-select text-[11px] interactive-select">
<option value="">All Elements</option>
</select>
</div>
</div>
<div class="grid grid-cols-2 gap-2">
<div>
<span class="text-[10px] font-semibold text-slate-500 mb-1 block">Chain</span>
<select id="buildChain" class="sidebar-select text-[11px] interactive-select">
<option value="">All Chains</option>
</select>
</div>
<div>
<span class="text-[10px] font-semibold text-slate-500 mb-1 block">Residue ID</span>
<input id="buildResi" type="text" placeholder="e.g. 1-50" class="sidebar-input text-[11px]">
</div>
</div>
<div class="flex flex-wrap gap-x-3 gap-y-1">
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="buildNot" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-bold text-slate-600 dark:text-slate-300">Invert (NOT)</span>
</label>
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="buildByres" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-bold text-slate-600 dark:text-slate-300">Whole residues</span>
</label>
</div>
<div id="buildWithinRow" class="range-row">
<span class="range-label">Within</span>
<input type="range" id="buildWithin" min="0" max="20" step="0.5" value="0" class="flex-grow">
<span id="buildWithinVal" class="range-val">off</span>
</div>
<p class="text-[9px] text-slate-400 leading-tight -mt-1">Expands to every atom within this distance of the selection above | ideal for binding pockets.</p>
<hr class="border-slate-200 dark:border-slate-800 my-1">
<!-- SPATIAL SELECTION -->
<div>
<span class="text-[10px] font-semibold text-slate-500 mb-2 block"><i class="fa-solid fa-layer-group mr-1"></i>Spatial region</span>
<div class="flex gap-1 mb-2">
<select id="spatialAxis" class="sidebar-select text-[11px] w-16">
<option value="z">Z axis</option>
<option value="y">Y axis</option>
<option value="x">X axis</option>
</select>
<select id="spatialMode" class="sidebar-select text-[11px] flex-grow">
<option value="">No spatial filter</option>
<option value="range">Range (from → to)</option>
<option value="center">Center ± width</option>
<option value="top">Top surface</option>
<option value="bottom">Bottom surface</option>
</select>
</div>
<div id="spatialControls" class="hidden flex flex-col gap-2 mt-1">
<!-- Range mode controls -->
<div id="spatialRangeControls" class="hidden range-group">
<div class="range-row">
<span class="range-label">From</span>
<input type="range" id="spatialFrom" min="0" max="100" step="0.1" value="0" class="flex-grow">
<span id="spatialFromVal" class="range-val">0.0</span>
</div>
<div class="range-row">
<span class="range-label">To</span>
<input type="range" id="spatialTo" min="0" max="100" step="0.1" value="100" class="flex-grow">
<span id="spatialToVal" class="range-val">100.0</span>
</div>
</div>
<!-- Center mode controls -->
<div id="spatialCenterControls" class="hidden range-group">
<div class="range-row">
<span class="range-label">Center</span>
<input type="range" id="spatialCenter" min="0" max="100" step="0.1" value="50" class="flex-grow">
<span id="spatialCenterVal" class="range-val">50.0</span>
</div>
<div class="range-row">
<span class="range-label">± Width</span>
<input type="range" id="spatialWidth" min="0.5" max="50" step="0.5" value="5" class="flex-grow">
<span id="spatialWidthVal" class="range-val">5.0</span>
</div>
</div>
<!-- Surface mode controls -->
<div id="spatialSurfaceControls" class="hidden range-group">
<div class="range-row">
<span class="range-label">Depth</span>
<input type="range" id="spatialDepth" min="0.5" max="30" step="0.5" value="5" class="flex-grow">
<span id="spatialDepthVal" class="range-val">5.0 Å</span>
</div>
</div>
<!-- Cross-axis width clamp (available for all modes) -->
<div class="flex items-center mt-2">
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="enableCrossAxis" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-bold text-slate-600 dark:text-slate-300">Clamp cross-axes (width)</span>
</label>
</div>
<div id="crossAxisControls" class="hidden range-group mt-1 p-2 bg-white dark:bg-slate-950 rounded-lg border border-dashed border-slate-300 dark:border-slate-700">
<span class="text-[9px] font-bold text-slate-400 uppercase tracking-wider mb-1 block" id="crossAxisLabel">Perpendicular axes</span>
<!-- Axis A -->
<div class="range-row">
<span class="range-label" id="crossA_label">X from</span>
<input type="range" id="crossA_from" min="0" max="100" step="0.1" class="flex-grow">
<span id="crossA_fromVal" class="range-val">0.0</span>
</div>
<div class="range-row">
<span class="range-label" id="crossA_toLabel">X to</span>
<input type="range" id="crossA_to" min="0" max="100" step="0.1" class="flex-grow">
<span id="crossA_toVal" class="range-val">100.0</span>
</div>
<hr class="border-slate-200 dark:border-slate-700 my-1">
<!-- Axis B -->
<div class="range-row">
<span class="range-label" id="crossB_label">Y from</span>
<input type="range" id="crossB_from" min="0" max="100" step="0.1" class="flex-grow">
<span id="crossB_fromVal" class="range-val">0.0</span>
</div>
<div class="range-row">
<span class="range-label" id="crossB_toLabel">Y to</span>
<input type="range" id="crossB_to" min="0" max="100" step="0.1" class="flex-grow">
<span id="crossB_toVal" class="range-val">100.0</span>
</div>
</div>
<div class="flex items-center gap-2 mt-1">
<span class="text-[10px] font-semibold text-slate-500">Unit:</span>
<select id="spatialUnit" class="sidebar-select text-[10px] w-auto py-0.5 px-1 bg-slate-100 dark:bg-slate-800 border-none">
<option value="A" selected>Å (Ångström)</option>
<option value="nm">nm (Nanometer)</option>
</select>
</div>
</div>
</div>
<div class="flex items-center mt-1">
<label class="flex items-center gap-1.5 cursor-pointer">
<input type="checkbox" id="autoUpdateView" checked class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-600">
<span class="text-[10px] font-bold text-slate-600 dark:text-slate-300">Auto-isolate on change</span>
</label>
</div>
</div>
<div class="flex gap-1.5 mt-2">
<button id="guiIsolateBtn" class="sidebar-btn flex-grow text-[11px] bg-indigo-100 text-indigo-700 dark:bg-indigo-900 dark:text-indigo-300 hover:bg-indigo-200"><i class="fa-solid fa-filter mr-1"></i>Isolate</button>
<button id="guiHighlightBtn" class="sidebar-btn flex-grow text-[11px]"><i class="fa-solid fa-highlighter mr-1"></i>Highlight</button>
<button id="guiZoomBtn" class="sidebar-btn flex-grow text-[11px]"><i class="fa-solid fa-crosshairs mr-1"></i>Zoom</button>
</div>
<div id="selectionCount" class="text-[10px] text-slate-400 mt-1 hidden"><i class="fa-solid fa-atom mr-1"></i><span id="selCountText">0 atoms selected</span></div>
<button class="reset-view-btn text-[10px] text-slate-500 hover:text-indigo-500 font-medium text-left mt-1 mb-2">Reset view (Show all)</button>
<hr class="border-slate-200 dark:border-slate-800">
<div class="flex items-center justify-between mb-1">
<label class="section-label mb-0">Advanced syntax query</label>
<select id="queryUnit" class="sidebar-select w-auto text-[10px] py-0.5 px-1 bg-slate-100 dark:bg-slate-800 border-none outline-none">
<option value="nm">Nanometers (nm)</option>
<option value="A" selected>Ångströms (Å)</option>
</select>
</div>
<input id="focusQuery" type="text" placeholder="e.g. z:>4.8 resn:HOH or chain:A elem:Fe" class="sidebar-input text-[11px]">
<div class="flex gap-1.5 mt-1">
<button id="focusBtn" class="sidebar-btn flex-grow text-[11px]"><i class="fa-solid fa-crosshairs mr-1"></i>Zoom Query</button>
<button id="isolateBtn" class="sidebar-btn px-3 text-[11px]">Isolate</button>
<button id="exportSelBtn" class="sidebar-btn px-3 text-[11px]" title="Save the current selection as a PDB file"><i class="fa-solid fa-file-export"></i></button>
</div>
<button class="reset-view-btn text-[10px] text-slate-500 hover:text-indigo-500 font-medium text-left mt-1 mb-2">Reset view (Show all)</button>
<div class="border border-slate-200 dark:border-slate-800 rounded-lg overflow-hidden">
<button class="sel-guide-btn w-full text-left px-3 py-2 bg-slate-50 dark:bg-slate-900 text-[11px] font-bold text-slate-600 dark:text-slate-300 flex justify-between items-center transition-colors hover:bg-slate-100 dark:hover:bg-slate-800">
<span>Syntax guide & examples</span>
<i class="fa-solid fa-chevron-down transition-transform duration-200"></i>
</button>
<div class="hidden p-3 bg-slate-50 dark:bg-slate-900/50 text-[10px] text-slate-600 dark:text-slate-400 space-y-2 border-t border-slate-200 dark:border-slate-800">
<p class="text-[9px] text-slate-400 mb-1">Click any example to load it into the query box. Tokens are combined with AND.</p>
<div class="grid grid-cols-2 gap-x-2 gap-y-1.5">
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">chain:A</span><br>Chain ID</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">resn:HOH</span><br>Residue name</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">resi:1-50</span><br>Residue range</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">elem:Fe</span><br>Element symbol</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">atom:CA</span><br>Atom name</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">ss:h</span><br>Sec. struct</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">b:>30</span><br>B-factor filter</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">serial:1-99</span><br>Serial range</div>
</div>
<div class="pt-2 mt-1 border-t border-slate-200 dark:border-slate-700">
<p class="font-semibold text-slate-700 dark:text-slate-300 mb-1">Named groups:</p>
<div class="grid grid-cols-2 gap-x-2 gap-y-1.5">
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">protein:1</span><br>Amino acids</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">nucleic:1</span><br>DNA / RNA</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">solvent:1</span><br>Water</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">ion:1</span><br>Common ions</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">backbone:1</span><br>N, CA, C, O</div>
<div><span class="font-mono text-indigo-600 dark:text-indigo-400 font-bold bg-indigo-50 dark:bg-indigo-900/30 px-1 py-0.5 rounded query-example">sidechain:1</span><br>Non-backbone</div>
</div>
</div>
<div class="pt-2 mt-1 border-t border-slate-200 dark:border-slate-700">
<p class="font-semibold text-slate-700 dark:text-slate-300 mb-1">Logic & distance:</p>
<code class="block bg-white dark:bg-slate-950 p-1.5 rounded border border-slate-200 dark:border-slate-800 text-indigo-600 dark:text-indigo-400 query-example" data-query="within:5,resn:HEM">within:5,resn:HEM</code>
<p class="mt-1 mb-2 leading-tight">Everything within 5 Å of the haem group, a binding pocket.</p>
<code class="block bg-white dark:bg-slate-950 p-1.5 rounded border border-slate-200 dark:border-slate-800 text-indigo-600 dark:text-indigo-400 query-example" data-query="not:solvent:1">not:solvent:1</code>
<p class="mt-1 mb-2 leading-tight">Strip the water. Prefix any token with <b>not:</b> or <b>!</b> to invert it.</p>
<code class="block bg-white dark:bg-slate-950 p-1.5 rounded border border-slate-200 dark:border-slate-800 text-indigo-600 dark:text-indigo-400 query-example" data-query="or:chain:A|chain:B">or:chain:A|chain:B</code>
<p class="mt-1 mb-2 leading-tight">Union of clauses separated by <b>|</b>.</p>
<code class="block bg-white dark:bg-slate-950 p-1.5 rounded border border-slate-200 dark:border-slate-800 text-indigo-600 dark:text-indigo-400 query-example" data-query="within:5,chain:A not:chain:A byres:1">within:5,chain:A not:chain:A byres:1</code>
<p class="mt-1 leading-tight">The interface: whole residues near chain A but not part of it.</p>
</div>
<div class="pt-2 mt-1 border-t border-slate-200 dark:border-slate-700">
<p class="font-semibold text-slate-700 dark:text-slate-300 mb-1">Spatial filters (Å or nm):</p>
<code class="block bg-white dark:bg-slate-950 p-1.5 rounded border border-slate-200 dark:border-slate-800 text-indigo-600 dark:text-indigo-400 query-example" data-query="z:>4.8 resn:HOH">z:>4.8 resn:HOH</code>
<p class="mt-1 mb-2 leading-tight">Atoms above z = 4.8 that are water.</p>
<code class="block bg-white dark:bg-slate-950 p-1.5 rounded border border-slate-200 dark:border-slate-800 text-indigo-600 dark:text-indigo-400 query-example" data-query="x:20-30 y:20-30">x:20-30 y:20-30</code>
<p class="mt-1 leading-tight">Cross-section patch in the XY plane.</p>
</div>
</div>
</div>
</div>
<!-- Trajectory panel (conditional) -->
<div id="trajectoryPanel" class="hidden flex flex-col gap-2">
<label class="section-label">Trajectory / frames</label>
<div class="flex items-center gap-2">
<button id="trajPrev" class="sidebar-btn px-2 text-xs"><i class="fa-solid fa-backward-step"></i></button>
<button id="trajPlay" class="sidebar-btn px-3 text-xs flex-grow"><i class="fa-solid fa-play mr-1"></i>Play</button>
<button id="trajNext" class="sidebar-btn px-2 text-xs"><i class="fa-solid fa-forward-step"></i></button>
</div>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-12 shrink-0">Frame</span><input type="range" id="trajSlider" min="0" max="0" step="1" value="0" class="flex-grow"><span id="trajFrame" class="text-[10px] text-slate-500 w-10 text-right">0/0</span></div>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-12 shrink-0">Speed</span>
<select id="trajSpeed" class="sidebar-select text-[11px] flex-grow">
<option value="200">Slow</option>
<option value="100" selected>Normal</option>
<option value="50">Fast</option>
<option value="20">Very Fast</option>
</select>
</div>
</div>
<!-- Isosurface panel (conditional, for cube files) -->
<div id="isoPanel" class="hidden flex flex-col gap-2 mt-2 pt-3 border-t border-slate-200 dark:border-slate-800">
<label class="section-label" style="color:#8b5cf6"><i class="fa-solid fa-cloud mr-1"></i>Isosurface (Cube data)</label>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-14 shrink-0">+ Isoval</span><input type="range" id="isoPosVal" min="0.001" max="0.2" step="0.001" value="0.02" class="flex-grow"><span id="isoPosDisplay" class="text-[10px] text-slate-500 w-10 text-right">0.02</span></div>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-14 shrink-0">- Isoval</span><input type="range" id="isoNegVal" min="-0.2" max="-0.001" step="0.001" value="-0.02" class="flex-grow"><span id="isoNegDisplay" class="text-[10px] text-slate-500 w-10 text-right">-0.02</span></div>
<div class="flex items-center gap-2"><span class="text-[10px] text-slate-500 w-14 shrink-0">Opacity</span><input type="range" id="isoOpacity" min="0.1" max="1" step="0.05" value="0.7" class="flex-grow"><span id="isoOpacityDisplay" class="text-[10px] text-slate-500 w-7 text-right">0.7</span></div>
<div class="flex gap-1.5">
<button id="applyIso" class="sidebar-btn flex-grow text-[11px]" style="background:#8b5cf6;color:#fff">Render Isosurface</button>
<button id="clearIso" class="sidebar-btn px-3 text-[11px]">Clear</button>
</div>
</div>
<!-- TAB: Export -->
<div id="tabExport" class="tab-content hidden flex flex-col gap-3">
<label class="section-label">Export image (PNG)</label>
<div class="flex items-center gap-1.5">
<span class="text-[10px] text-slate-500 w-16 shrink-0">Resolution</span>
<select id="exportQuality" class="sidebar-select text-[11px] flex-grow">
<option value="1">1x (Standard)</option>
<option value="2" selected>2x (High)</option>
<option value="4">4x (Print)</option>
<option value="6">6x (Ultra)</option>
<option value="8">8x (Poster)</option>
<option value="10">10x (Extreme)</option>
</select>
</div>
<p id="exportNote" class="text-[10px] text-slate-400 leading-tight"></p>
<button id="downloadBtn" class="sidebar-btn text-xs mt-2" style="background:#6366f1;color:#fff"><i class="fa-solid fa-download mr-1"></i>Download PNG</button>
<p class="text-[9px] text-slate-400 leading-tight mt-1">Very large multipliers are clamped automatically to your GPU's maximum texture size, so exports can't crash the viewer.</p>
</div>
</aside>
<!-- VIEWER -->
<div class="flex-grow bg-white dark:bg-slate-950 border border-slate-200 dark:border-slate-800 rounded-2xl shadow-sm relative overflow-hidden" style="min-height:500px">
<div id="viewerCanvas" class="absolute inset-0 w-full h-full cursor-move"></div>
<div id="atomInfo"></div>
<div id="measureInfo"></div>
<div id="modeBadge" class="mode-badge hidden"></div>
<div id="labelProgress" class="hidden"></div>
<div id="busyOverlay" class="hidden">
<div class="busy-card"><span class="busy-spin"></span><span id="busyText">Working…</span></div>
</div>
</div>
</section>
<section class="stk-section" id="how-to-use" aria-label="How to use this tool">
<div class="stk-wrap">
<span class="stk-chip"><i class="fa-solid fa-microscope"></i> How-To Guide</span>
<h2 class="stk-h2">How to inspect a molecular structure</h2>
<p class="stk-lead">Load a coordinate file, choose how it should be drawn, then carve out the part you actually care about, all rendered locally by your GPU, with no upload step.</p>
<div class="stk-grid stk-grid-2">
<div class="stk-step"><span class="stk-num">1</span><div><h3>Load a structure</h3><p>Drag in a <strong>PDB, GRO, XYZ, CIF, MOL2, CUBE</strong> or other coordinate file, or type a four-character <strong>PDB ID</strong> to pull it straight from RCSB.</p></div></div>
<div class="stk-step"><span class="stk-num">2</span><div><h3>Pick a representation</h3><p>Choose cartoon for proteins, stick or ball-and-stick for small molecules, sphere for packing. Colour by element, chain, B-factor, secondary structure, or set every element by hand.</p></div></div>
<div class="stk-step"><span class="stk-num">3</span><div><h3>Narrow the selection</h3><p>Use the builder dropdowns for chain, residue and element, add a <strong>within</strong> radius for binding pockets, or slice along an axis with the spatial sliders. <strong>Isolate</strong> hides everything else; <strong>Highlight</strong> keeps the context as a faint wireframe.</p></div></div>
<div class="stk-step"><span class="stk-num">4</span><div><h3>Measure and export</h3><p>Click two atoms for a distance or three for an angle, switch on <strong>Figure mode</strong> to fade the surrounding structure, restyle the lines and labels to taste, then save a high-resolution PNG or copy the numbers as a table.</p></div></div>
</div>
<div class="stk-note" style="margin-top:1.5rem;">
<i class="fa-solid fa-keyboard" style="margin-top:.15rem;"></i>
<div><strong>Keyboard shortcuts.</strong> <span class="stk-kbd">R</span> recentre · <span class="stk-kbd">M</span> measure mode · <span class="stk-kbd">H</span> hydrogens · <span class="stk-kbd">L</span> labels · <span class="stk-kbd">S</span> spin · <span class="stk-kbd">Esc</span> cancel. Shortcuts are ignored while you are typing in a field.</div>
</div>
</div>
</section>
<section class="stk-section" id="how-it-works" aria-label="How it works">
<div class="stk-wrap">
<h2 class="stk-h2">How the viewer works</h2>
<div class="stk-grid stk-grid-3">
<div class="stk-card">
<h3>WebGL rendering</h3>
<p>Geometry is built and rasterised by <strong>3Dmol.js</strong> on your graphics card. Because the whole scene lives in GPU memory, rotation and zoom stay smooth on structures with hundreds of thousands of atoms, but every style change has to rebuild that geometry, which is why very large systems take a moment to re-draw.</p>
</div>
<div class="stk-card">
<h3>Selections are JSON, not strings</h3>
<p>3Dmol filters atoms with plain JavaScript objects such as <code>{chain:'A', resn:'HEM'}</code>. The query box compiles your text into exactly that shape, so anything you type here maps directly onto the library's own API, useful if you later script the same selection yourself.</p>
</div>
<div class="stk-card">
<h3>Neighbour search</h3>
<p>Distance queries (<code>within:</code>) index the target atoms into a uniform grid first, then test only the cells that could fall inside the radius. That keeps a pocket selection near-instant instead of comparing every atom against every other atom.</p>
</div>
</div>
<div class="stk-grid stk-grid-2" style="margin-top:1rem;">
<div class="stk-card">
<h3>Labels are built across frames</h3>
<p>Placing thousands of labels in one synchronous loop is what freezes a tab, nothing paints until the last one is done. Labels here are added in slices of about 150 per animation frame, with a progress readout, so the viewer stays interactive and you can watch them fill in. Starting a new label pass cancels the one in flight rather than queueing a second.</p>
</div>
<div class="stk-card">
<h3>Scope beats capping</h3>
<p>A cap alone still labels whichever atoms happen to come first in the file, which is rarely what you are looking at. Set <strong>Label scope</strong> to <em>Current selection</em> to label only what you isolated; when a scope still exceeds the limit, the atoms nearest the centre of the view are kept in preference to the rest.</p>
</div>
</div>
<div class="stk-note" style="margin-top:1rem;">
<i class="fa-solid fa-circle-info" style="margin-top:.15rem;"></i>
<div><strong>Labels are the usual bottleneck.</strong> Each label is a separate textured sprite, so tens of thousands of them will stall the browser long before the atoms themselves do. Labels are capped by default, warned about above 5,000 atoms, and disabled entirely above 50,000, raise the cap only when you have isolated a small region.</div>
</div>
</div>
</section>
<section class="stk-section" id="selection-syntax" aria-label="Selection syntax reference">
<div class="stk-wrap" style="max-width:56rem;">
<span class="stk-chip"><i class="fa-solid fa-terminal"></i> Selection Syntax</span>
<h2 class="stk-h2">The selection language</h2>
<p class="stk-lead">Every token is <code>key:value</code>, separated by spaces. Tokens are combined with <strong>AND</strong>, <code>chain:A elem:Fe</code> means iron atoms in chain A. Prefix any token with <code>not:</code> (or <code>!</code>) to invert just that token.</p>
<h3 class="stk-refs-h">Atom attributes</h3>
<table class="stk-syntax">
<thead><tr><th>Token</th><th>Selects</th></tr></thead>
<tbody>
<tr><td><code>chain:A</code></td><td><p>Chain identifier as written in the file.</p></td></tr>
<tr><td><code>resn:HOH</code></td><td><p>Residue name. Accepts comma lists: <code>resn:ALA,GLY</code>.</p></td></tr>
<tr><td><code>resi:1-50</code></td><td><p>Residue number: a single value, a comma list, or an inclusive range.</p></td></tr>
<tr><td><code>elem:Fe</code></td><td><p>Element symbol, case sensitive as stored in the file.</p></td></tr>
<tr><td><code>atom:CA</code></td><td><p>Atom name | more specific than element (<code>CA</code> is the alpha carbon).</p></td></tr>
<tr><td><code>ss:h</code></td><td><p>Secondary structure: <code>h</code> helix, <code>s</code> sheet, <code>c</code> coil.</p></td></tr>
<tr><td><code>b:>30</code></td><td><p>B-factor. Supports <code>></code>, <code><</code>, <code>>=</code>, <code><=</code> and ranges like <code>b:20-50</code>.</p></td></tr>
<tr><td><code>serial:1-99</code></td><td><p>Atom serial number range.</p></td></tr>
</tbody>
</table>
<h3 class="stk-refs-h">Named groups</h3>
<table class="stk-syntax">
<thead><tr><th>Token</th><th>Selects</th></tr></thead>
<tbody>
<tr><td><code>protein:1</code></td><td><p>Standard amino-acid residues.</p></td></tr>
<tr><td><code>nucleic:1</code></td><td><p>DNA and RNA residues.</p></td></tr>
<tr><td><code>solvent:1</code></td><td><p>Water under its common names (HOH, WAT, SOL, TIP3…).</p></td></tr>
<tr><td><code>ion:1</code></td><td><p>Frequently seen monatomic ions.</p></td></tr>
<tr><td><code>backbone:1</code></td><td><p>Protein backbone atoms N, CA, C, O.</p></td></tr>
<tr><td><code>sidechain:1</code></td><td><p>Amino-acid atoms that are not backbone.</p></td></tr>
<tr><td><code>hetero:1</code></td><td><p>Atoms flagged as HETATM | ligands, cofactors, solvent.</p></td></tr>
</tbody>
</table>
<h3 class="stk-refs-h">Geometry and logic</h3>
<table class="stk-syntax">
<thead><tr><th>Token</th><th>Selects</th></tr></thead>
<tbody>
<tr><td><code>x:>4.8</code></td><td><p>Cartesian coordinate filter on <code>x</code>, <code>y</code> or <code>z</code>. Ranges work too: <code>z:10-20</code>. Values follow the unit dropdown (Å or nm).</p></td></tr>
<tr><td><code>within:5,chain:A</code></td><td><p>Every atom within 5 Å of anything matching the inner selection. The radius comes first, then a comma, then a nested query.</p></td></tr>
<tr><td><code>not:resn:HOH</code></td><td><p>Inverts the token that follows. <code>!resn:HOH</code> is equivalent.</p></td></tr>
<tr><td><code>or:chain:A|chain:B</code></td><td><p>Union of the pipe-separated clauses.</p></td></tr>
<tr><td><code>byres:1</code></td><td><p>Expands the result so that any residue with one selected atom is selected entirely.</p></td></tr>
</tbody>
</table>
<h3 class="stk-refs-h">Worked examples</h3>
<table class="stk-syntax">
<thead><tr><th>Query</th><th>Meaning</th></tr></thead>
<tbody>
<tr><td><code>within:5,resn:HEM byres:1</code></td><td><p>The complete residues lining the haem pocket, the standard way to picture a binding site.</p></td></tr>
<tr><td><code>within:5,chain:A not:chain:A byres:1</code></td><td><p>The protein–protein interface: residues close to chain A that belong to a different chain.</p></td></tr>
<tr><td><code>protein:1 not:solvent:1 b:>60</code></td><td><p>The most mobile parts of the protein | often loops and termini.</p></td></tr>
<tr><td><code>ss:h chain:A</code></td><td><p>Helices of chain A only.</p></td></tr>
<tr><td><code>z:>30 not:solvent:1</code></td><td><p>The upper leaflet of a membrane system with water stripped out.</p></td></tr>
</tbody>
</table>
<h3 class="stk-refs-h">References & documentation</h3>
<ol class="stk-refs-list">
<li>Rego, N., & Koes, D. (2015). 3Dmol.js: molecular visualization with WebGL. <em>Bioinformatics</em>, 31(8), 1322–1324. <a href="https://doi.org/10.1093/bioinformatics/btu829" target="_blank" rel="noopener">doi:10.1093/bioinformatics/btu829</a></li>
<li>3Dmol.js API, <a href="https://3dmol.csb.pitt.edu/doc/AtomSelectionSpec.html" target="_blank" rel="noopener">AtomSelectionSpec reference</a> (University of Pittsburgh).</li>
<li>Berman, H. M., et al. (2000). The Protein Data Bank. <em>Nucleic Acids Research</em>, 28(1), 235–242. <a href="https://www.rcsb.org/" target="_blank" rel="noopener">rcsb.org</a></li>
<li>Wikipedia: <a href="https://en.wikipedia.org/wiki/Accessible_surface_area" target="_blank" rel="noopener">Accessible surface area</a> · <a href="https://en.wikipedia.org/wiki/Debye%E2%80%93Waller_factor" target="_blank" rel="noopener">B-factor</a>.</li>
</ol>
</div>
</section>
<section class="stk-section" id="faq" aria-label="Frequently asked questions">
<div class="stk-wrap" style="max-width:52rem;">
<h2 class="stk-h2">Frequently asked questions</h2>
<div style="margin-top:1rem;">
<details class="stk-faq"><summary>Is my structure uploaded anywhere?</summary><div>No. Files are read with the browser's FileReader and rendered by 3Dmol.js on your own GPU. The only network request the tool ever makes is the optional PDB ID fetch, which asks RCSB for that one public entry.</div></details>
<details class="stk-faq"><summary>Which file formats are supported?</summary><div>PDB, ENT, CIF/mmCIF, SDF, MOL, MOL2, XYZ, GRO, PQR, PRMTOP, MMTF, CDJSON, CUBE and VASP/POSCAR/CONTCAR. Multi-frame files load as a trajectory and expose the frame slider automatically.</div></details>
<details class="stk-faq"><summary>Why does the cartoon style show nothing?</summary><div>Cartoon rendering needs backbone connectivity and secondary-structure information, which only protein and nucleic-acid formats carry. A bare XYZ file or a small organic molecule has no backbone to trace, use stick or ball-and-stick instead.</div></details>
<details class="stk-faq"><summary>Why are my labels capped or disabled?</summary><div>Every label is an individual sprite, so they cost far more than the atoms do. Above 5,000 atoms the tool warns you and exposes a cap; above 50,000 it refuses labels outright to stop the tab freezing. Isolate a smaller region first, then label it.</div></details>
<details class="stk-faq"><summary>My high-resolution export came out smaller than I asked for.</summary><div>WebGL contexts have a maximum texture size, commonly 4,096, 8,192 or 16,384 pixels depending on the GPU. Requesting a multiplier beyond that limit would black out the canvas, so the export is clamped to the largest safe size and the panel tells you what you actually got.</div></details>
<details class="stk-faq"><summary>What is the difference between Isolate and Highlight?</summary><div>Isolate hides everything outside the selection, giving you a clean figure. Highlight keeps the rest of the structure as a faint wireframe so the selection stays in context, usually the better choice when you are explaining where something sits.</div></details>
<details class="stk-faq"><summary>Which surface type should I use?</summary><div>Van der Waals is fastest and shows atomic radii. Solvent-accessible traces the centre of a rolling probe and is what most buried-area calculations use. Solvent-excluded (Connolly) hugs the molecule more tightly and looks best in figures, but costs the most to compute.</div></details>
<details class="stk-faq"><summary>Turning on labels used to freeze the tab. What changed?</summary><div>Labels are now built in small slices spread across animation frames instead of one blocking loop, so the browser keeps painting and you get a live progress count. They are also scoped (by default to your current selection) and when a scope exceeds the limit the atoms nearest the centre of the view are kept. Above 50,000 atoms labels stay off unless you explicitly opt in, and even then the same chunking applies.</div></details>
<details class="stk-faq"><summary>How do I make a clean measurement figure?</summary><div>Take your measurements, then enable <strong>Figure mode</strong> in the Tools tab. Everything except the measured atoms drops to a faint wireframe (or thin stick, cartoon, or hidden entirely) at an opacity you control, while the picked atoms keep the full representation. Open <em>Measurement appearance</em> to set the line colour, thickness and dash, marker size, label size and colour, decimal places and whether units are shown. Use <em>Zoom to picks</em> to frame the shot, then export at 4× or higher.</div></details>
<details class="stk-faq"><summary>Can I get the measurement numbers out as data?</summary><div>Yes, <strong>Copy data</strong> puts every measurement on the clipboard as tab-separated text with type, atoms, value and unit columns, which pastes straight into a spreadsheet. Individual measurements can be removed with the × beside each row in the readout.</div></details>
<details class="stk-faq"><summary>Why does building a surface still pause the viewer?</summary><div>Surface meshing happens inside a single synchronous call in 3Dmol.js, so unlike labels it cannot be sliced across frames. What the tool does instead is paint a busy indicator first and start the work on the next frame, so you get feedback rather than a dead tab, and it refuses outright above 100,000 atoms. Scope the surface to your selection with <em>Only current selection</em> to keep it fast.</div></details>
<details class="stk-faq"><summary>Can I script the same selections elsewhere?</summary><div>Yes, the query box compiles to a 3Dmol AtomSelectionSpec object, so a query like <code>chain:A resn:HEM</code> is simply <code>{chain:'A', resn:'HEM'}</code> in the library's own API. Open the console and call <code>app.select('within:5,resn:HEM')</code> to get the matching atoms back as an array.</div></details>
</div>
<div class="stk-refs">
<a href="https://3dmol.csb.pitt.edu/doc/AtomSelectionSpec.html" target="_blank" rel="noopener"><i class="fa-solid fa-book"></i> AtomSelectionSpec reference</a><a href="https://doi.org/10.1093/bioinformatics/btu829" target="_blank" rel="noopener"><i class="fa-solid fa-quote-right"></i> Cite 3Dmol.js</a><a href="https://www.rcsb.org/" target="_blank" rel="noopener"><i class="fa-solid fa-database"></i> RCSB Protein Data Bank</a>
</div>
<p class="stk-credit">Runs entirely in your browser, no data leaves your device. Rendering by <a href="https://3dmol.csb.pitt.edu/" target="_blank" rel="noopener" style="color:#4f46e5;text-decoration:none;">3Dmol.js</a> (Rego & Koes, 2015).</p>
</div>
</section>
</main>