-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel.html
More file actions
2631 lines (2505 loc) · 145 KB
/
Copy pathkernel.html
File metadata and controls
2631 lines (2505 loc) · 145 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">
<head>
<script>try{document.documentElement.dataset.theme=localStorage.getItem("ut-theme")||"light"}catch(e){document.documentElement.dataset.theme="light"}</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>KERNEL v7 — a Python notebook in a single file</title>
<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=Space+Grotesk:wght@400;500;600;700&family=Hanken+Grotesk:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
<style>
:root{
--paper:#E9E7E0; --sheet-line:rgba(26,27,24,.05);
--surface:#FBFAF6; --surface-2:#E7EBED; --surface-3:#E4E9EC;
--ink:#1A1B18; --ink-2:#55574E; --ink-3:#83857B; --ink-4:#A9AB9F;
--line:#D3D9DD; --line-2:#C9C6BA;
--accent:#4A33D6; --accent-2:#3A28B0; --on-accent:#FFFDF8; --accent-weak:#DCD5F7; --accent-ghost:rgba(74,51,214,.10);
--err:#AE4530; --err-weak:#F5E2DB; --err-line:#E5C2B6;
--busy:#2A0CA3; --ok:#44734E;
--t-kw:#6B4E85; --t-str:#44734E; --t-num:#32189C; --t-com:#83857B; --t-bif:#4A33D6; --t-dec:#2F6E73;
--r:4px; --r-sm:3px;
--code-fs:13.5px; --code-lh:1.62; --code-pad-y:13px; --code-pad-x:15px;
--gutter-w:54px;
--mono:'Space Mono',ui-monospace,Menlo,Consolas,monospace;
--sans:'Hanken Grotesk',-apple-system,BlinkMacSystemFont,sans-serif;
--disp:'Space Grotesk','Hanken Grotesk',sans-serif;
--shadow:0 1px 2px rgba(20,22,40,.06),0 2px 8px rgba(20,22,40,.05);
--shadow-sel:0 0 0 1px rgba(74,51,214,.45);
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{
font-family:var(--sans); color:var(--ink); background:var(--paper);
-webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility;
display:flex; flex-direction:column; min-height:100%;
}
::selection{background:color-mix(in srgb,var(--accent) 20%,transparent)}
/* ---------- top bar ---------- */
.topbar{
position:sticky; top:0; z-index:40;
display:flex; align-items:center; gap:18px;
padding:11px 22px; background:color-mix(in srgb,var(--paper) 86%,white);
backdrop-filter:saturate(1.4) blur(8px);
border-bottom:1px solid var(--line-2);
}
.brand{display:flex; align-items:baseline; gap:11px; flex:0 0 auto}
.brand .mark{width:13px; height:13px; background:var(--accent); border-radius:2px; transform:translateY(1px);
box-shadow:0 0 0 3px var(--accent-ghost)}
.brand h1{font-family:var(--disp); font-weight:800; font-size:18px; letter-spacing:.16em; margin:0; color:var(--ink)}
.brand .tag{font-family:var(--mono); font-size:10.5px; letter-spacing:.08em; color:var(--ink-3); text-transform:uppercase}
@media(max-width:760px){.brand .tag{display:none}}
.status{
display:inline-flex; align-items:center; gap:8px; flex:0 1 auto; min-width:0;
max-width:min(46ch,36vw);
font-family:var(--mono); font-size:11.5px; font-weight:500; letter-spacing:.02em;
padding:5px 11px 5px 9px; border:1px solid var(--line-2); border-radius:3px;
background:var(--surface); color:var(--ink-2); white-space:nowrap;
}
#status #statusText,#statusText{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.status .dot{width:7px; height:7px; border-radius:50%; background:var(--ink-4); flex:0 0 auto}
.status[data-s="boot"] .dot{background:var(--busy); animation:pulse 1.1s ease-in-out infinite}
.status[data-s="busy"] .dot{background:var(--accent); animation:pulse .8s ease-in-out infinite}
.status[data-s="ok"] .dot{background:var(--ok)}
.status[data-s="err"]{color:var(--err); border-color:var(--err-line)}
.status[data-s="err"] .dot{background:var(--err)}
@keyframes pulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.35;transform:scale(.78)}}
.toolbar{display:flex; align-items:center; gap:6px; margin-left:auto; flex-wrap:wrap; justify-content:flex-end}
.btn{
font-family:var(--sans); font-size:12.5px; font-weight:500; color:var(--ink-2);
display:inline-flex; align-items:center; gap:6px; cursor:pointer;
padding:6px 11px; border:1px solid var(--line-2); border-radius:var(--r-sm);
background:var(--surface); transition:.13s ease; white-space:nowrap;
}
.btn:hover{color:var(--ink); border-color:var(--ink-4); background:var(--surface)}
.btn:active{transform:translateY(.5px)}
.btn svg{width:14px; height:14px}
.btn.primary{color:var(--accent); border-color:color-mix(in srgb,var(--accent) 30%,var(--line-2))}
.btn.primary:hover{background:var(--accent); color:var(--on-accent); border-color:var(--accent)}
.btn.danger:hover{color:var(--err); border-color:var(--err-line)}
.btn[disabled]{opacity:.42; cursor:not-allowed; pointer-events:none}
.tb-sep{width:1px; height:20px; background:var(--line-2); margin:0 3px}
.btn-chip{font-family:var(--mono); font-size:11px; font-weight:600; padding:4px 9px}
/* ---------- sheet / notebook ---------- */
.sheet{
flex:1 1 auto; min-width:0; overflow-y:auto;
background-color:var(--paper);
background-image:
linear-gradient(var(--sheet-line) 1px,transparent 1px),
linear-gradient(90deg,var(--sheet-line) 1px,transparent 1px);
background-size:28px 28px; background-position:-1px -1px;
padding:40px 22px 120px;
}
.notebook{max-width:900px; margin:0 auto; display:flex; flex-direction:column; gap:14px}
.cell{
position:relative; display:grid; grid-template-columns:var(--gutter-w) 1fr;
background:var(--surface); border:1px solid var(--line); border-radius:var(--r);
box-shadow:var(--shadow); transition:box-shadow .15s ease,border-color .15s ease;
}
.cell.selected{border-color:color-mix(in srgb,var(--accent) 38%,var(--line)); box-shadow:var(--shadow-sel)}
.cell.md.rendered{background:transparent; border-color:transparent; box-shadow:none}
.cell.md.rendered.selected{background:var(--surface); border-color:color-mix(in srgb,var(--accent) 30%,var(--line)); box-shadow:var(--shadow-sel)}
.cell::before{ /* run rail */
content:""; position:absolute; left:0; top:0; bottom:0; width:2px; border-radius:2px 0 0 2px;
background:transparent; transition:background .15s ease;
}
.cell.selected::before{background:var(--accent)}
.cell.running::before{background:var(--accent); animation:rail 1s ease-in-out infinite}
@keyframes rail{0%,100%{opacity:1}50%{opacity:.3}}
.gutter{
padding:var(--code-pad-y) 8px 0 0; text-align:right;
font-family:var(--mono); font-size:11.5px; font-weight:500; color:var(--ink-4);
user-select:none; line-height:var(--code-lh);
}
.cell.code .gutter .exec{color:var(--ink-4)}
.cell.code.done .gutter .exec{color:var(--accent)}
.cell.running .gutter .exec{color:var(--accent)}
.cell.md .gutter .exec{font-size:12px; color:var(--ink-4)}
.body{position:relative; min-width:0; padding:0}
/* ---------- editor (highlight overlay) ---------- */
.editor{position:relative; min-width:0}
.hl, .ta{
margin:0; border:0; width:100%;
font-family:var(--mono); font-size:var(--code-fs); line-height:var(--code-lh);
font-weight:450; letter-spacing:0; tab-size:4;
padding:var(--code-pad-y) var(--code-pad-x) calc(var(--code-pad-y) + 2px);
white-space:pre-wrap; word-break:break-word; overflow-wrap:break-word;
}
.hl{
color:var(--ink); background:transparent; pointer-events:none;
min-height:calc(var(--code-fs) * var(--code-lh) + var(--code-pad-y)*2);
}
.hl code{font:inherit; white-space:inherit}
.ta{
position:absolute; inset:0; height:100%; resize:none; overflow:hidden;
color:transparent; background:transparent; caret-color:var(--ink); outline:none;
}
.ta::selection{background:color-mix(in srgb,var(--accent) 22%,transparent)}
.cell.md .editor .hl{color:var(--ink)}
.t-kw{color:var(--t-kw); font-weight:600} .t-str{color:var(--t-str)} .t-num{color:var(--t-num)}
.t-com{color:var(--t-com); font-style:italic} .t-bif{color:var(--t-bif)} .t-dec{color:var(--t-dec)}
/* placeholder hint */
.editor .ph{position:absolute; top:var(--code-pad-y); left:var(--code-pad-x); font-family:var(--mono);
font-size:var(--code-fs); line-height:var(--code-lh); color:var(--ink-4); pointer-events:none; user-select:none}
/* ---------- markdown rendered ---------- */
.md-rendered{padding:6px 18px 8px; font-family:var(--sans); font-size:15px; line-height:1.62; color:var(--ink); min-width:0}
.md-rendered:empty::before{content:"Empty markdown — press ⏎ to edit"; color:var(--ink-3); font-style:italic; font-size:13.5px}
.md-rendered h1,.md-rendered h2,.md-rendered h3,.md-rendered h4{font-family:var(--disp); line-height:1.22; margin:1.1em 0 .5em; font-weight:700}
.md-rendered h1{font-size:1.7em; letter-spacing:-.01em} .md-rendered h2{font-size:1.36em} .md-rendered h3{font-size:1.14em} .md-rendered h4{font-size:1em}
.md-rendered h1:first-child,.md-rendered h2:first-child,.md-rendered h3:first-child{margin-top:.2em}
.md-rendered p{margin:.6em 0} .md-rendered ul,.md-rendered ol{margin:.6em 0; padding-left:1.5em}
.md-rendered li{margin:.22em 0}
.md-rendered a{color:var(--accent); text-decoration:none; border-bottom:1px solid var(--accent-weak)}
.md-rendered a:hover{border-bottom-color:var(--accent)}
.md-rendered code{font-family:var(--mono); font-size:.86em; background:var(--surface-3); padding:.12em .4em; border-radius:2px; color:var(--accent-2)}
.md-rendered pre{background:var(--surface-2); border:1px solid var(--line); border-radius:3px; padding:13px 15px; overflow:auto; margin:.7em 0}
.md-rendered pre code{background:none; padding:0; font-size:13px; color:var(--ink)}
.md-rendered blockquote{margin:.7em 0; padding:.2em 1em; border-left:3px solid var(--line-2); color:var(--ink-2)}
.md-rendered hr{border:0; border-top:1px solid var(--line-2); margin:1.2em 0}
.md-rendered img{max-width:100%; border-radius:3px}
.md-rendered table{border-collapse:collapse; margin:.7em 0; font-size:14px}
.md-rendered th,.md-rendered td{border:1px solid var(--line-2); padding:5px 10px; text-align:left}
.md-rendered th{background:var(--surface-2); font-weight:600}
/* ---------- outputs ---------- */
.outputs{border-top:1px solid var(--line); padding:4px 0 6px; display:flex; flex-direction:column}
.out{padding:9px 15px; min-width:0; overflow:auto}
.out + .out{border-top:1px dashed var(--line)}
.out-stream pre,.out-text pre,.out-err pre{
margin:0; font-family:var(--mono); font-size:12.8px; line-height:1.55; white-space:pre-wrap; word-break:break-word;
}
.out-text pre{color:var(--ink)}
.out-stream pre{color:var(--ink)}
.out-stream.stderr{background:#FFF8EC}
.out-stream.stderr pre{color:var(--busy)}
.out-err{background:var(--err-weak)}
.out-err pre{color:var(--err)}
.out-img{text-align:center; background:var(--surface)}
.out-img img{max-width:100%; height:auto; border:1px solid var(--line); border-radius:3px; background:#fff}
.out-frame{background:var(--surface); text-align:left}
.out-html{font-family:var(--sans); font-size:13.5px; color:var(--ink); contain:content; max-width:100%; overflow-x:auto}
.out-html table.dataframe{border-collapse:collapse; font-family:var(--mono); font-size:12px; line-height:1.4}
.out-html table.dataframe th,.out-html table.dataframe td{border:1px solid var(--line-2); padding:4px 9px; text-align:right; white-space:nowrap}
.out-html table.dataframe thead th{background:var(--surface-2); font-weight:600; color:var(--ink)}
.out-html table.dataframe tbody th{background:var(--surface-2); color:var(--ink-2); font-weight:500; text-align:right}
/* ---------- cell tools ---------- */
.cell-tools{
position:absolute; top:7px; right:8px; display:flex; gap:2px; padding:3px;
background:color-mix(in srgb,var(--surface) 92%,transparent); border:1px solid var(--line);
border-radius:3px; box-shadow:var(--shadow); opacity:0; transform:translateY(-2px);
transition:.13s ease; pointer-events:none; backdrop-filter:blur(4px);
}
.cell:hover .cell-tools,.cell.selected .cell-tools{opacity:1; transform:none; pointer-events:auto}
.ct{display:inline-flex; align-items:center; justify-content:center; width:25px; height:25px; border:0; border-radius:3px;
background:transparent; color:var(--ink-3); cursor:pointer; transition:.1s}
.ct:hover{background:var(--surface-3); color:var(--ink)}
.ct.run:hover{background:var(--accent); color:var(--on-accent)}
.ct.del:hover{background:var(--err-weak); color:var(--err)}
.ct svg{width:14px; height:14px}
.ct.type{width:auto; padding:0 8px; font-family:var(--mono); font-size:10.5px; font-weight:600; letter-spacing:.04em; text-transform:uppercase}
/* ---------- add-cell ---------- */
.add-row{max-width:900px; margin:14px auto 0; display:flex; gap:8px; justify-content:center; opacity:.6; transition:.15s}
.add-row:hover{opacity:1}
.add-btn{font-family:var(--sans); font-size:12.5px; color:var(--ink-2); display:inline-flex; align-items:center; gap:6px;
padding:7px 16px; border:1px dashed var(--line-2); border-radius:3px; background:transparent; cursor:pointer; transition:.13s}
.add-btn:hover{border-color:var(--accent); color:var(--accent); background:var(--accent-ghost)}
.add-btn svg{width:13px;height:13px}
/* ---------- footer ---------- */
.foot{position:sticky; bottom:0; z-index:30; display:flex; align-items:center; gap:16px;
padding:7px 22px; font-family:var(--mono); font-size:11px; color:var(--ink-3);
background:color-mix(in srgb,var(--paper) 88%,white); border-top:1px solid var(--line-2); backdrop-filter:blur(8px)}
.foot .sp{flex:1}
.foot b{color:var(--ink-2); font-weight:600}
.foot .lnk{color:var(--ink-2); cursor:pointer; border-bottom:1px dotted var(--ink-4)}
.foot .lnk:hover{color:var(--accent); border-color:var(--accent)}
.data-chips{display:flex; gap:5px; flex-wrap:wrap}
.data-chip{font-size:10.5px; color:var(--ink-2); background:var(--surface); border:1px solid var(--line-2); border-radius:2px; padding:1px 7px}
/* ---------- toast ---------- */
.toast-host{position:fixed; bottom:46px; left:50%; transform:translateX(-50%); z-index:80; display:flex; flex-direction:column; gap:8px; align-items:center}
.toast{font-family:var(--sans); font-size:13px; color:#fff; background:#1B1E26; padding:9px 16px; border-radius:3px;
box-shadow:0 8px 30px rgba(0,0,0,.22); opacity:0; transform:translateY(8px); transition:.22s ease; max-width:80vw}
.toast.show{opacity:1; transform:none}
.toast.err{background:var(--err)} .toast.ok{background:var(--ok)}
.toast code{font-family:var(--mono); font-size:12px; background:rgba(255,255,255,.16); padding:.05em .35em; border-radius:4px}
/* ---------- modal ---------- */
.scrim{position:fixed; inset:0; z-index:90; background:rgba(20,22,30,.34); backdrop-filter:blur(3px); display:none; align-items:center; justify-content:center; padding:24px}
.scrim.show{display:flex}
.modal{background:var(--surface); border:1px solid var(--line-2); border-radius:4px; box-shadow:0 24px 70px rgba(0,0,0,.28); max-width:540px; width:100%; max-height:84vh; overflow:auto}
.modal-h{display:flex; align-items:center; justify-content:space-between; padding:18px 22px 14px; border-bottom:1px solid var(--line)}
.modal-h h2{font-family:var(--disp); font-size:16px; font-weight:700; letter-spacing:.04em; margin:0}
.modal-x{border:0; background:transparent; cursor:pointer; color:var(--ink-3); font-size:20px; line-height:1; padding:2px 6px; border-radius:3px}
.modal-x:hover{background:var(--surface-3); color:var(--ink)}
.modal-b{padding:16px 22px 22px}
.kbd-grid{display:grid; grid-template-columns:1fr 1fr; gap:18px 26px}
.kbd-grid h3{font-family:var(--mono); font-size:11px; letter-spacing:.08em; text-transform:uppercase; color:var(--ink-3); margin:0 0 8px}
.kbd-row{display:flex; justify-content:space-between; align-items:baseline; gap:12px; padding:3px 0; font-size:13px; color:var(--ink-2)}
kbd{font-family:var(--mono); font-size:11px; background:var(--surface-2); border:1px solid var(--line-2); border-bottom-width:2px; border-radius:2px; padding:2px 6px; color:var(--ink); white-space:nowrap}
@media(max-width:560px){.kbd-grid{grid-template-columns:1fr}}
::-webkit-scrollbar{width:11px; height:11px}
::-webkit-scrollbar-thumb{background:var(--line-2); border-radius:3px; border:3px solid transparent; background-clip:padding-box}
::-webkit-scrollbar-thumb:hover{background:var(--ink-4); background-clip:padding-box; border:3px solid transparent}
/* ===== v2 additions ===== */
.nb-pill{display:inline-flex; align-items:center; gap:6px; font-family:var(--sans); font-size:12.5px; font-weight:600; color:var(--ink-2); background:var(--surface); border:1px solid var(--line-2); border-radius:3px; padding:4px 8px; cursor:pointer; margin-left:8px; max-width:230px}
.nb-pill:hover{color:var(--accent); border-color:color-mix(in srgb,var(--accent) 32%,var(--line-2)); background:var(--accent-ghost)}
.nb-pill svg{width:13px; height:13px; flex:0 0 auto}
.nb-pill .chev{width:11px; height:11px; opacity:.7}
.nb-pill #nbTitleText{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.drawer{position:fixed; top:0; right:0; height:100vh; width:312px; max-width:86vw; background:var(--surface); border-left:1px solid var(--line); box-shadow:-18px 0 40px -28px rgba(20,22,30,.4); transform:translateX(106%); transition:transform .26s cubic-bezier(.4,0,.2,1); z-index:70; display:flex; flex-direction:column}
.drawer.open{transform:none}
.drawer-h{display:flex; align-items:center; justify-content:space-between; padding:16px 18px 12px; border-bottom:1px solid var(--line)}
.drawer-h h2{font-family:var(--disp); font-size:15px; font-weight:700; color:var(--ink); margin:0; letter-spacing:.01em}
.drawer-x{font-size:20px; line-height:1; color:var(--ink-3); background:none; border:0; cursor:pointer; padding:0 4px}
.drawer-x:hover{color:var(--ink)}
.drawer-b{flex:1; overflow:auto; padding:8px 0}
.drawer-f{padding:9px 18px; border-top:1px solid var(--line); display:flex; justify-content:space-between; font-family:var(--mono); font-size:10.5px; color:var(--ink-3)}
.var-row{display:flex; align-items:baseline; gap:9px; padding:6px 18px; cursor:pointer; border-left:2px solid transparent}
.var-row:hover{background:var(--surface-2); border-left-color:var(--accent)}
.var-name{font-family:var(--mono); font-size:12.5px; color:var(--ink); font-weight:600}
.var-type{font-family:var(--mono); font-size:10.5px; color:var(--accent-2); background:var(--surface-3); border-radius:4px; padding:1px 5px}
.var-info{font-family:var(--mono); font-size:11px; color:var(--ink-3); margin-left:auto; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:128px; text-align:right}
.var-empty{padding:22px 18px; font-family:var(--sans); font-size:13px; color:var(--ink-3); font-style:italic}
.findbar{position:fixed; top:62px; right:26px; z-index:80; display:none; align-items:center; gap:6px; background:var(--surface); border:1px solid var(--line-2); border-radius:4px; padding:7px 8px; box-shadow:0 14px 36px -22px rgba(20,22,30,.5)}
.findbar.open{display:flex}
.findbar input{font-family:var(--mono); font-size:12px; color:var(--ink); background:var(--surface-2); border:1px solid var(--line-2); border-radius:3px; padding:5px 8px; width:150px; outline:none}
.findbar input:focus{border-color:color-mix(in srgb,var(--accent) 40%,var(--line-2)); background:var(--surface)}
.fb-case{font-family:var(--mono); font-size:11px; font-weight:700; color:var(--ink-3); background:var(--surface-2); border:1px solid var(--line-2); border-radius:3px; padding:4px 7px; cursor:pointer}
.fb-case.on{color:var(--on-accent); background:var(--accent); border-color:var(--accent)}
.fb-count{font-family:var(--mono); font-size:11px; color:var(--ink-3); min-width:36px; text-align:center}
.fb-btn{font-family:var(--mono); font-size:11.5px; color:var(--ink-2); background:var(--surface-2); border:1px solid var(--line-2); border-radius:3px; padding:4px 8px; cursor:pointer}
.fb-btn:hover{color:var(--accent); border-color:color-mix(in srgb,var(--accent) 32%,var(--line-2))}
.fb-x{font-size:17px; line-height:1; color:var(--ink-3); background:none; border:0; cursor:pointer; padding:0 4px}
.fb-x:hover{color:var(--ink)}
.modal.lib{max-width:460px}
.lib-list{display:flex; flex-direction:column; gap:2px; max-height:48vh; overflow:auto; margin:-4px 0 12px}
.lib-row{display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:3px; cursor:pointer; border:1px solid transparent}
.lib-row:hover{background:var(--surface-2)}
.lib-row.current{border-color:color-mix(in srgb,var(--accent) 32%,var(--line)); background:var(--accent-ghost)}
.lib-dot{width:7px; height:7px; border-radius:50%; background:var(--line-2); flex:0 0 auto}
.lib-row.current .lib-dot{background:var(--accent)}
.lib-meta{display:flex; flex-direction:column; gap:1px; min-width:0; flex:1}
.lib-name{font-family:var(--sans); font-size:14px; font-weight:600; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.lib-sub{font-family:var(--mono); font-size:10.5px; color:var(--ink-3)}
.lib-acts{display:flex; gap:4px; opacity:0; transition:opacity .12s}
.lib-row:hover .lib-acts,.lib-row.current .lib-acts{opacity:1}
.lib-act{font-family:var(--mono); font-size:10.5px; color:var(--ink-3); background:var(--surface); border:1px solid var(--line-2); border-radius:2px; padding:2px 6px; cursor:pointer}
.lib-act:hover{color:var(--accent); border-color:var(--accent)}
.lib-act.danger:hover{color:var(--err); border-color:var(--err-line)}
.lib-new{font-family:var(--sans); font-size:13px; font-weight:600; color:var(--accent); background:var(--accent-ghost); border:1px dashed color-mix(in srgb,var(--accent) 34%,var(--line-2)); border-radius:3px; padding:10px; width:100%; cursor:pointer}
.lib-new:hover{background:var(--accent); color:var(--on-accent); border-style:solid; border-color:var(--accent)}
.cmp-pop{position:absolute; z-index:95; display:none; min-width:200px; max-width:340px; max-height:236px; overflow:auto; background:var(--surface); border:1px solid var(--line-2); border-radius:3px; box-shadow:0 16px 40px -20px rgba(20,22,30,.55); padding:4px}
.cmp-pop.open{display:block}
.cmp-item{display:flex; align-items:center; gap:8px; padding:5px 9px; border-radius:3px; cursor:pointer; font-family:var(--mono); font-size:12.5px; color:var(--ink)}
.cmp-item.sel{background:var(--accent); color:var(--on-accent)}
.cmp-item .cmp-k{font-size:9.5px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--ink-3); min-width:30px}
.cmp-item.sel .cmp-k{color:var(--on-accent); opacity:.78}
.cmp-item .cmp-n{overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.cell.collapsed .editor,.cell.collapsed .md-rendered,.cell.collapsed .outputs{display:none !important}
.cell .collapsed-peek{display:none; font-family:var(--mono); font-size:12px; color:var(--ink-3); padding:11px 18px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer}
.cell .collapsed-peek:hover{color:var(--accent)}
.cell.collapsed .collapsed-peek{display:block}
.ct.col-on{color:var(--accent)}
.btn.active{color:var(--accent); border-color:color-mix(in srgb,var(--accent) 36%,var(--line-2)); background:var(--accent-ghost)}
/* ===== v6 QoL ===== */
.progress{position:fixed; top:0; left:0; right:0; height:2px; z-index:200; opacity:0; transition:opacity .25s; pointer-events:none; overflow:hidden}
.progress.active{opacity:1}
.progress::before{content:""; position:absolute; top:0; height:100%; width:32%; border-radius:2px; background:linear-gradient(90deg,transparent,var(--accent),transparent); animation:progslide 1.1s ease-in-out infinite}
@keyframes progslide{0%{left:-32%}100%{left:100%}}
.menu-wrap{position:relative; display:inline-flex}
.btn-more{font-weight:700; letter-spacing:.04em}
.menu{position:absolute; top:calc(100% + 6px); right:0; z-index:90; min-width:200px; background:var(--surface); border:1px solid var(--line-2); border-radius:4px; box-shadow:0 16px 40px -22px rgba(20,22,30,.5); padding:5px; display:none}
.menu.open{display:block}
.menu-item{display:block; width:100%; text-align:left; font-family:var(--sans); font-size:12.5px; color:var(--ink-2); background:none; border:0; border-radius:3px; padding:7px 9px; cursor:pointer}
.menu-item:hover{background:var(--surface-2); color:var(--ink)}
.menu-sep{height:1px; background:var(--line); margin:4px 6px}
.save-state{font-family:var(--mono); font-size:10.5px; color:var(--ink-3)}
.save-state[data-s="saving"]{color:var(--ink-4)}
.gutter .exec-time{display:block; font-family:var(--mono); font-size:9.5px; color:var(--ink-4); margin-top:3px; letter-spacing:.02em}
.drawer-search{padding:8px 14px 4px}
.drawer-search input{width:100%; box-sizing:border-box; font-family:var(--mono); font-size:12px; color:var(--ink); background:var(--surface-2); border:1px solid var(--line-2); border-radius:3px; padding:6px 9px; outline:none}
.drawer-search input:focus{border-color:color-mix(in srgb,var(--accent) 40%,var(--line-2)); background:var(--surface)}
.var-row{position:relative}
.var-size{font-family:var(--mono); font-size:9.5px; color:var(--ink-4); margin-left:6px; flex:0 0 auto}
.var-del{position:absolute; right:8px; top:50%; transform:translateY(-50%); font-size:14px; line-height:1; color:var(--ink-4); background:var(--surface-2); border:0; border-radius:4px; padding:0 5px; cursor:pointer; opacity:0; transition:opacity .12s}
.var-row:hover .var-del{opacity:1}
.var-del:hover{color:var(--err)}
.modal.data{max-width:520px}
.data-list{display:flex; flex-direction:column; gap:2px; max-height:50vh; overflow:auto; margin:-4px 0 10px}
.data-row{border:1px solid transparent; border-radius:3px; padding:9px 11px}
.data-row:hover{background:var(--surface-2)}
.data-top{display:flex; align-items:center; gap:10px}
.data-meta{display:flex; flex-direction:column; gap:1px; min-width:0; flex:1}
.data-name{font-family:var(--mono); font-size:13px; font-weight:600; color:var(--ink); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.data-sub{font-family:var(--mono); font-size:10.5px; color:var(--ink-3)}
.data-acts{display:flex; gap:4px; flex:0 0 auto}
.data-act{font-family:var(--mono); font-size:10.5px; color:var(--ink-3); background:var(--surface); border:1px solid var(--line-2); border-radius:2px; padding:3px 7px; cursor:pointer}
.data-act:hover{color:var(--accent); border-color:var(--accent)}
.data-act.danger:hover{color:var(--err); border-color:var(--err-line)}
.data-preview{margin-top:8px; font-family:var(--mono); font-size:11px; color:var(--ink-2); background:var(--surface-3); border-radius:3px; padding:8px 10px; max-height:160px; overflow:auto; white-space:pre; display:none}
.data-preview.open{display:block}
.data-empty{padding:22px 6px; font-family:var(--sans); font-size:13px; color:var(--ink-3); font-style:italic; text-align:center}
.data-hint{font-family:var(--sans); font-size:11.5px; color:var(--ink-3); margin:12px 2px 0; line-height:1.5}
.data-hint code{font-family:var(--mono); font-size:11px; background:var(--surface-3); padding:1px 4px; border-radius:4px}
/* ===== v7 composable panels ===== */
.workspace{flex:1 1 auto; display:flex; align-items:stretch; min-height:0; overflow:hidden}
.panel{position:relative; flex:0 0 auto; background:var(--surface); display:none; min-height:0}
.panel.open{display:flex; flex-direction:column}
.panel-left{border-right:1px solid var(--line-2)}
.panel-right{border-left:1px solid var(--line-2)}
.panel-inner{flex:1 1 auto; overflow-y:auto; min-height:0; display:flex; flex-direction:column}
.panel-section{border-bottom:1px solid var(--line); display:flex; flex-direction:column; flex:0 0 auto}
.panel-section:last-child{border-bottom:0}
.panel-h{display:flex; align-items:center; gap:6px; padding:11px 12px 9px; flex:0 0 auto}
.panel-toggle{display:flex; align-items:center; gap:7px; flex:1; min-width:0; background:none; border:0; cursor:pointer; padding:0; font-family:var(--disp); font-size:11px; font-weight:700; letter-spacing:.09em; text-transform:uppercase; color:var(--ink-2)}
.panel-toggle:hover{color:var(--ink)}
.panel-toggle .caret{width:11px; height:11px; flex:0 0 auto; transition:transform .16s ease; color:var(--ink-3)}
.panel-section.collapsed .panel-toggle .caret{transform:rotate(-90deg)}
.panel-add{font-size:14px; line-height:1; color:var(--ink-3); background:var(--surface); border:1px solid var(--line-2); border-radius:3px; width:22px; height:22px; flex:0 0 auto; cursor:pointer; display:flex; align-items:center; justify-content:center}
.panel-add:hover{color:var(--accent); border-color:var(--accent)}
.panel-count{font-family:var(--mono); font-size:10px; color:var(--ink-3); flex:0 0 auto}
.panel-search{padding:0 12px 9px}
.panel-search input{width:100%; box-sizing:border-box; font-family:var(--mono); font-size:12px; color:var(--ink); background:var(--surface-2); border:1px solid var(--line-2); border-radius:3px; padding:6px 9px; outline:none}
.panel-search input:focus{border-color:color-mix(in srgb,var(--accent) 40%,var(--line-2)); background:var(--surface)}
.panel-b{padding:0 8px 12px; overflow-y:auto}
.panel-section.collapsed .panel-b,.panel-section.collapsed .panel-search{display:none}
.panel-grip{position:absolute; top:0; bottom:0; width:8px; cursor:col-resize; z-index:6}
.panel-left .panel-grip{right:-4px}
.panel-right .panel-grip{left:-4px}
.panel-grip:hover{background:var(--accent-ghost)}
body.resizing{cursor:col-resize; user-select:none}
.nb-pill.active,.btn.active{color:var(--accent); border-color:color-mix(in srgb,var(--accent) 38%,var(--line-2)); background:var(--accent-ghost)}
.panel-hint{font-family:var(--sans); font-size:11px; color:var(--ink-3); line-height:1.5; padding:2px 6px 4px}
/* ===== v7 Phase 2: split outputs ===== */
.out-card{border:1px solid var(--line); border-radius:3px; background:var(--surface); margin:0 0 8px; overflow:hidden; transition:box-shadow .12s, border-color .12s}
.out-card-h{display:flex; align-items:center; gap:8px; padding:6px 9px; border-bottom:1px solid var(--line); cursor:pointer; background:var(--surface-2)}
.out-card-h:hover{background:var(--surface-3)}
.out-card-ex{font-family:var(--mono); font-size:10.5px; color:var(--ink-4); flex:0 0 auto}
.out-card-lbl{font-family:var(--mono); font-size:11px; color:var(--ink-2); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; flex:1; min-width:0}
.out-card .outputs{padding:8px 9px; margin:0}
.out-card.linked{border-color:color-mix(in srgb,var(--accent) 45%,var(--line)); box-shadow:inset 3px 0 0 var(--accent)}
.cell.linked::before{background:var(--accent)}
.cell.linked{border-color:color-mix(in srgb,var(--accent) 26%,var(--line))}
.out-empty{padding:20px 8px; font-family:var(--sans); font-size:12.5px; color:var(--ink-3); font-style:italic; text-align:center; line-height:1.5}
.outputs-hint{padding:4px 6px 8px}
.outputs-hint p{font-family:var(--sans); font-size:11.5px; color:var(--ink-3); line-height:1.5; margin:0 0 8px}
.outputs-hint button{font-family:var(--sans); font-size:12px; color:var(--accent); background:var(--accent-ghost); border:1px solid color-mix(in srgb,var(--accent) 30%,var(--line-2)); border-radius:3px; padding:6px 11px; cursor:pointer}
.outputs-hint button:hover{background:var(--accent); color:#fff; border-color:var(--accent)}
/* ===== v7 Phase 3: mini-cards + variable detail ===== */
.lib-map{display:flex; gap:2px; margin-top:7px; align-items:flex-end; overflow:hidden; height:12px}
.lib-tick{width:4px; flex:0 0 auto; border-radius:1px; background:var(--ink-4)}
.lib-tick.code{height:12px; background:color-mix(in srgb,var(--accent) 50%,var(--ink-4))}
.lib-tick.md{height:7px; background:var(--ink-4)}
.lib-row.current .lib-tick.code{background:var(--accent)}
.lib-more{font-family:var(--mono); font-size:9px; color:var(--ink-4); align-self:center; margin-left:3px; flex:0 0 auto}
.var-item{border-radius:3px}
.var-item.open{background:var(--surface-2)}
.var-detail{display:none; padding:2px 10px 10px 22px}
.var-item.open .var-detail{display:block}
.var-ins{position:absolute; right:30px; top:50%; transform:translateY(-50%); font-size:12px; line-height:1; color:var(--ink-4); background:var(--surface-2); border:0; border-radius:4px; padding:1px 5px; cursor:pointer; opacity:0; transition:opacity .12s}
.var-row:hover .var-ins{opacity:1}
.var-ins:hover{color:var(--accent)}
.vd-shape{font-family:var(--mono); font-size:10.5px; color:var(--ink-3); margin:4px 0 7px}
.vd-dtypes{display:flex; flex-direction:column; gap:1px; margin-bottom:8px}
.vd-dtype{display:flex; justify-content:space-between; gap:10px; font-family:var(--mono); font-size:11px; color:var(--ink-2)}
.vd-dtype .vd-dt{color:var(--ink-3)}
.vd-more{font-family:var(--mono); font-size:9.5px; color:var(--ink-4); margin-top:3px}
.vd-table{border-collapse:collapse; width:100%; font-family:var(--mono); font-size:10.5px; display:block; overflow-x:auto}
.vd-table th,.vd-table td{border:1px solid var(--line); padding:2px 6px; text-align:left; white-space:nowrap; color:var(--ink-2)}
.vd-table th{background:var(--surface-3); color:var(--ink-3); font-weight:600}
.statlist{display:flex; flex-direction:column; gap:2px}
.stat{display:flex; justify-content:space-between; gap:10px; font-family:var(--mono); font-size:11px}
.stat .sk{color:var(--ink-3)} .stat .sv{color:var(--ink); text-align:right}
.vd-chips{display:flex; flex-wrap:wrap; gap:4px; margin-top:7px}
.vd-chip{font-family:var(--mono); font-size:10px; color:var(--ink-2); background:var(--surface-3); border-radius:4px; padding:2px 6px}
.vd-repr{font-family:var(--mono); font-size:11px; color:var(--ink-2); background:var(--surface-3); border-radius:3px; padding:8px 10px; margin:2px 0 0; white-space:pre-wrap; word-break:break-word; max-height:200px; overflow:auto}
.var-loading{font-family:var(--mono); font-size:10.5px; color:var(--ink-4); padding:4px 0}
</style>
<style id="v7-polish">
/* ── v7 polish · the left panel adapts to its width ── */
.panel-left{container-type:inline-size}
.lib-sub,.data-sub{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@container (max-width:330px){
.panel-left .lib-row{flex-wrap:wrap}
.panel-left .lib-meta{flex:1 1 calc(100% - 17px)}
.panel-left .lib-acts{flex:0 0 100%;margin-left:17px;margin-top:7px;opacity:1}
.panel-left .data-top{flex-wrap:wrap}
.panel-left .data-meta{flex:1 1 100%}
.panel-left .data-acts{flex:0 0 100%;margin-top:7px}
}
@container (max-width:215px){
.panel-left .lib-map{display:none}
}
/* ── v7 polish · in-app prompt dialog ── */
.prompt-input{width:100%;box-sizing:border-box;font-family:var(--mono);font-size:13px;color:var(--ink);background:var(--surface-2);border:1px solid var(--line-2);border-radius:3px;padding:9px 11px;outline:none;caret-color:var(--accent)}
.prompt-input:focus{border-color:color-mix(in srgb,var(--accent) 45%,var(--line-2))}
.prompt-acts{display:flex;justify-content:flex-end;gap:8px;margin-top:14px}
</style>
<style id="dna-suite">
/* ── USEFUL TOOLS · suite DNA (light default · dark via html[data-theme="dark"] · Alt+T) ── */
:root{--dna-page:#E9E7E0;--dna-panel:#FBFAF6;--dna-ink:#1A1B18;--dna-mid:#83857B;--dna-line:rgba(26,27,24,.18);--dna-gmaj:rgba(26,27,24,.05);--dna-gmin:rgba(26,27,24,.028);--dna-accent:#4A33D6;--dna-accent-line:rgba(74,51,214,.45);--dna-sel:rgba(74,51,214,.25);--dna-thumb:#C4C3B7;--dna-thumb-h:#ABA89C}
html[data-theme="dark"]{--dna-page:#0E0F0D;--dna-panel:#1C1C15;--dna-ink:#E8E6DE;--dna-mid:#6E6F65;--dna-line:rgba(232,230,222,.17);--dna-gmaj:rgba(232,230,222,.030);--dna-gmin:rgba(232,230,222,.016);--dna-accent:#7B68FF;--dna-accent-line:rgba(123,104,255,.40);--dna-sel:rgba(123,104,255,.30);--dna-thumb:#33312C;--dna-thumb-h:#4A4B43}
html{color-scheme:light;scrollbar-color:var(--dna-thumb) var(--dna-page)}
html[data-theme="dark"]{color-scheme:dark}
#dna-grid{position:fixed;inset:0;z-index:-1;pointer-events:none;background-image:linear-gradient(var(--dna-gmaj) 1px,transparent 1px),linear-gradient(90deg,var(--dna-gmaj) 1px,transparent 1px),linear-gradient(var(--dna-gmin) 1px,transparent 1px),linear-gradient(90deg,var(--dna-gmin) 1px,transparent 1px);background-size:140px 140px,140px 140px,28px 28px,28px 28px}
::selection{background:var(--dna-sel)}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--dna-thumb);border:2px solid var(--dna-page)}
::-webkit-scrollbar-thumb:hover{background:var(--dna-thumb-h)}
/* ── suite dock — persistent navigation ── */
#dna-dock{position:fixed;right:14px;bottom:14px;z-index:2147483000;display:flex;align-items:stretch;font:500 10px/1 'Space Mono',ui-monospace,monospace;letter-spacing:.08em;background:var(--dna-panel);border:1px solid var(--dna-line);border-radius:2px;opacity:.85;transition:opacity 160ms cubic-bezier(.25,.6,.25,1)}
#dna-dock:hover,#dna-dock:focus-within{opacity:1}
#dna-dock>*{display:flex;align-items:center;gap:5px;padding:8px 10px;margin:0;color:var(--dna-mid);background:none;border:0;border-right:1px solid var(--dna-line);cursor:pointer;text-decoration:none;font:inherit;letter-spacing:inherit;white-space:nowrap}
#dna-dock>*:last-child{border-right:0}
#dna-dock>*:hover{color:var(--dna-accent)}
#dna-dock .dd-mark{color:var(--dna-accent)}
#dna-switch{position:fixed;right:14px;bottom:52px;z-index:2147483001;width:300px;display:none;flex-direction:column;background:var(--dna-panel);border:1px solid var(--dna-line);border-radius:2px;box-shadow:0 0 0 4px var(--dna-page);font:500 11px/1 'Space Mono',ui-monospace,monospace}
#dna-switch.open{display:flex}
#dna-switch input{font:inherit;font-size:12px;color:var(--dna-ink);background:transparent;border:0;outline:0;border-bottom:1px solid var(--dna-line);padding:10px 12px;caret-color:var(--dna-accent);letter-spacing:.04em}
#dna-switch input::placeholder{color:var(--dna-mid);opacity:.7}
#dna-switch ul{list-style:none;margin:0;padding:0;max-height:340px;overflow:auto}
#dna-switch li{display:flex;align-items:center;gap:10px;padding:9px 12px;border-top:1px solid var(--dna-line);color:var(--dna-mid);cursor:pointer}
#dna-switch li:first-child{border-top:0}
#dna-switch li .n{color:var(--dna-ink);letter-spacing:.10em;width:96px;flex:none}
#dna-switch li .f{flex:1;text-align:right;font-size:9px;opacity:.75;overflow:hidden;text-overflow:ellipsis}
#dna-switch li.sel{box-shadow:inset 2px 0 0 var(--dna-accent);background:var(--dna-sel)}
#dna-switch li.cur .n{color:var(--dna-accent)}
#dna-switch .ft{display:flex;justify-content:space-between;padding:8px 12px;border-top:1px solid var(--dna-line);color:var(--dna-mid);font-size:9px;letter-spacing:.10em}
/* per-instrument dark palette */
html[data-theme="dark"]{--on-accent:#141008;--paper:#0E0F0D;--sheet-line:rgba(232,230,222,.045);--surface:#1C1C15;--surface-2:#181815;--surface-3:#1D1D19;--ink:#E8E6DE;--ink-2:#A6A79C;--ink-3:#6E6F65;--ink-4:#4A4B43;--line:#232320;--line-2:#2E2E27;--accent:#7B68FF;--accent-2:#9686FF;--accent-weak:#1C172E;--accent-ghost:rgba(123,104,255,.08);--err:#C8796C;--err-weak:#332420;--err-line:#54302C;--busy:#5E3FD9;--ok:#8CAE8A;--t-kw:#B3A0BD;--t-str:#8CAE8A;--t-num:#6D55CC;--t-com:#6E6F65;--t-bif:#7B68FF;--t-dec:#7FB0B0;--shadow:0 1px 2px rgba(0,0,0,.45);--shadow-sel:0 0 0 1px rgba(123,104,255,.40)}
/* ===== KaTeX + Mermaid in markdown cells ===== */
.md-rendered .katex-display{overflow-x:auto; overflow-y:hidden; padding:2px 0; margin:.6em 0}
.md-rendered .katex{font-size:1.04em}
.md-rendered .mermaid{margin:14px 0; text-align:center; line-height:initial}
.md-rendered .mermaid svg{max-width:100%; height:auto}
.md-rendered .mermaid:not([data-done]){font-family:var(--mono); font-size:11px; color:var(--ink-3); white-space:pre-wrap; background:var(--surface-2); border:1px dashed var(--line-2); border-radius:8px; padding:10px 12px; text-align:left}
.md-rendered .mermaid.mermaid-err{color:var(--err); border-color:var(--err-line)}
</style>
</head>
<body>
<div id="progress" class="progress" aria-hidden="true"></div>
<header class="topbar">
<div class="brand"><span class="mark"></span><h1>KERNEL</h1>
<button class="nb-pill" id="nbTitle" title="Notebooks (switch / rename / new)">
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.4"><path d="M1.8 4.2c0-.6.5-1.1 1.1-1.1h3l1.3 1.4h5c.6 0 1.1.5 1.1 1.1v6.1c0 .6-.5 1.1-1.1 1.1H2.9c-.6 0-1.1-.5-1.1-1.1z"/></svg>
<span id="nbTitleText">Untitled</span>
<svg class="chev" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l4 4 4-4"/></svg>
</button>
</div>
<div class="status" id="status" data-s="boot"><span class="dot"></span><span id="statusText">Booting…</span></div>
<div class="toolbar">
<button class="btn" id="btnNew" title="New notebook">New</button>
<button class="btn" id="btnOpen" title="Open .ipynb">Open</button>
<button class="btn" id="btnSave" title="Download .ipynb (⌘/Ctrl+S)">Save .ipynb</button>
<button class="btn" id="btnData" title="Mount data files into the kernel">+ Data</button>
<span class="tb-sep"></span>
<button class="btn primary btn-chip" id="btnRunAll" title="Run every cell">Run all</button>
<button class="btn btn-chip" id="btnRestart" title="Restart kernel (clear all variables)">Restart</button>
<button class="btn btn-chip" id="btnClear" title="Clear all outputs">Clear</button>
<span class="tb-sep"></span>
<button class="btn btn-chip" id="btnVars" title="Toggle the variable inspector">Variables</button>
<div class="menu-wrap">
<button class="btn btn-chip btn-more" id="btnMore" title="More actions" aria-haspopup="true">⋯</button>
<div class="menu" id="moreMenu" aria-hidden="true">
<button class="menu-item" data-mi="restartRun">Restart & run all</button>
<button class="menu-item" data-mi="splitOut" id="miSplit">Move outputs to panel</button>
<button class="menu-item" data-mi="collapseAll">Collapse all cells</button>
<button class="menu-item" data-mi="expandAll">Expand all cells</button>
<div class="menu-sep"></div>
<button class="menu-item" data-mi="clearOutputs">Clear all outputs</button>
<button class="menu-item" data-mi="downloadPy">Download as .py</button>
</div>
</div>
</div>
</header>
<div class="workspace" id="workspace">
<aside class="panel panel-left" id="leftPanel" aria-hidden="true">
<div class="panel-inner">
<section class="panel-section" id="secNotebooks">
<div class="panel-h">
<button class="panel-toggle" data-sec="nb"><svg class="caret" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l4 4 4-4"/></svg><span>Notebooks</span></button>
<button class="panel-add" id="libNew" title="New notebook">+</button>
</div>
<div class="panel-b" id="libList"></div>
</section>
<section class="panel-section" id="secData">
<div class="panel-h">
<button class="panel-toggle" data-sec="data"><svg class="caret" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l4 4 4-4"/></svg><span>Data</span></button>
<button class="panel-add" id="dataUpload" title="Upload files">+</button>
</div>
<div class="panel-b" id="dataList"></div>
</section>
</div>
<div class="panel-grip" data-side="left" title="Drag to resize"></div>
</aside>
<main class="sheet">
<div class="notebook" id="notebook"></div>
<div class="add-row">
<button class="add-btn" data-add="code"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M8 3v10M3 8h10"/></svg>Code cell</button>
<button class="add-btn" data-add="markdown"><svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6"><path d="M8 3v10M3 8h10"/></svg>Markdown cell</button>
</div>
</main>
<aside class="panel panel-right" id="rightPanel" aria-hidden="true">
<div class="panel-grip" data-side="right" title="Drag to resize"></div>
<div class="panel-inner">
<section class="panel-section" id="secOutputs">
<div class="panel-h">
<button class="panel-toggle" data-sec="out"><svg class="caret" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l4 4 4-4"/></svg><span>Outputs</span></button>
<span class="panel-count" id="outCount"></span>
</div>
<div class="panel-b" id="outBody">
<div class="outputs-hint" id="outHint"><p>Push cell outputs into this panel, synced to each cell.</p><button id="outEnable">Move outputs here</button></div>
<div id="outList"></div>
</div>
</section>
<section class="panel-section" id="secVars">
<div class="panel-h">
<button class="panel-toggle" data-sec="vars"><svg class="caret" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"><path d="M4 6l4 4 4-4"/></svg><span>Variables</span></button>
<span class="panel-count" id="varsCount">0 names</span>
</div>
<div class="panel-search"><input id="varsFilter" placeholder="Filter variables" autocomplete="off" spellcheck="false"></div>
<div class="panel-b" id="varsList"></div>
</section>
</div>
</aside>
</div>
<footer class="foot">
<span><b id="cellCount">0</b> cells</span>
<span class="data-chips" id="dataChips"></span>
<span class="sp"></span>
<span id="saveState" class="save-state"></span>
<span id="kernelInfo">Pyodide · loading</span>
<span class="lnk" id="btnHelp">⌘ shortcuts</span>
</footer>
<div class="toast-host" id="toastHost"></div>
<div class="findbar" id="findbar" aria-hidden="true">
<input id="findInput" placeholder="Find across cells" autocomplete="off" spellcheck="false">
<input id="replaceInput" placeholder="Replace" autocomplete="off" spellcheck="false">
<button class="fb-case" id="findCase" title="Match case">Aa</button>
<span class="fb-count" id="findCount">0/0</span>
<button class="fb-btn" id="findPrev" title="Previous (⇧⏎)">↑</button>
<button class="fb-btn" id="findNext" title="Next (⏎)">↓</button>
<button class="fb-btn" id="findRepl" title="Replace current">Repl</button>
<button class="fb-btn" id="findAll" title="Replace all">All</button>
<button class="fb-x" id="findX" title="Close (Esc)">×</button>
</div>
<div class="cmp-pop" id="cmpPop" aria-hidden="true"></div>
<div class="scrim" id="promptScrim">
<div class="modal" style="max-width:380px" role="dialog" aria-modal="true">
<div class="modal-h"><h2 id="promptTitle">Rename</h2><button class="modal-x" id="promptX">×</button></div>
<div class="modal-b">
<input id="promptInput" class="prompt-input" type="text" autocomplete="off" spellcheck="false">
<div class="prompt-acts"><button class="btn" id="promptCancel">Cancel</button><button class="btn primary" id="promptOk">Rename</button></div>
</div>
</div>
</div>
<div class="scrim" id="helpScrim">
<div class="modal" role="dialog" aria-modal="true">
<div class="modal-h"><h2>Keyboard</h2><button class="modal-x" id="helpX">×</button></div>
<div class="modal-b">
<div class="kbd-grid">
<div>
<h3>Edit mode</h3>
<div class="kbd-row"><span>Run & select next</span><kbd>⇧ Enter</kbd></div>
<div class="kbd-row"><span>Run, stay</span><kbd>⌘ Enter</kbd></div>
<div class="kbd-row"><span>Run & insert below</span><kbd>⌥ Enter</kbd></div>
<div class="kbd-row"><span>Autocomplete</span><kbd>Ctrl Space</kbd></div>
<div class="kbd-row"><span>Indent / dedent</span><kbd>Tab</kbd></div>
<div class="kbd-row"><span>Leave cell</span><kbd>Esc</kbd></div>
</div>
<div>
<h3>Command mode</h3>
<div class="kbd-row"><span>Edit cell</span><kbd>Enter</kbd></div>
<div class="kbd-row"><span>Move selection</span><kbd>↑ ↓ / j k</kbd></div>
<div class="kbd-row"><span>Insert above / below</span><kbd>a</kbd> <kbd>b</kbd></div>
<div class="kbd-row"><span>Delete cell</span><kbd>d d</kbd></div>
<div class="kbd-row"><span>To markdown / code</span><kbd>m</kbd> <kbd>y</kbd></div>
</div>
</div>
<div class="kbd-row" style="margin-top:16px;border-top:1px solid var(--line);padding-top:14px"><span>Save notebook (.ipynb)</span><kbd>⌘ / Ctrl + S</kbd></div>
<div class="kbd-row"><span>Find & replace across cells</span><kbd>⌘ / Ctrl + F</kbd></div>
<div class="kbd-row"><span>Install a PyPI package</span><kbd>%pip install <i>name</i></kbd></div>
<div class="kbd-row"><span>Interactive output (iframe)</span><kbd>display_html(html, height)</kbd></div>
<div class="kbd-row"><span>Interactive Plotly chart</span><kbd>display_plotly(fig)</kbd></div>
</div>
</div>
</div>
<input type="file" id="fileIpynb" accept=".ipynb,application/json" hidden>
<input type="file" id="fileData" multiple hidden>
<script>
"use strict";
(function(){
const PYODIDE_BASE = "https://cdn.jsdelivr.net/pyodide/v0.29.4/full/";
const STORE_KEY = "kernel.notebook.v1";
const LIB_KEY = "kernel.library.v1";
const nbKey = id => "kernel.nb." + id;
/* ===== Python kernel harness (runs once at boot) ===== */
const HARNESS = `
import sys, io, ast, base64, json, os, traceback, warnings
from pyodide.code import eval_code_async
os.environ.setdefault("MPLBACKEND", "AGG")
warnings.filterwarnings("ignore", message=r".*non-interactive.*cannot be shown.*", category=UserWarning)
warnings.filterwarnings("ignore", message=r".*non-GUI backend.*", category=UserWarning)
# ---- ordered output stream: prints, figures, displays and the cell result appear in execution order ----
_OUT = []
_PENDING = []
class _StreamCap:
def __init__(self, name): self._name = name
def write(self, s):
if s: _PENDING.append((self._name, s))
return len(s) if s else 0
def writelines(self, lines):
for s in lines: self.write(s)
def flush(self): pass
def isatty(self): return False
def _flush_streams():
if not _PENDING: return
name, buf = None, []
for n, t in _PENDING:
if n != name and buf:
_OUT.append({"kind":"stream", "name":name, "text":"".join(buf)}); buf = []
name = n; buf.append(t)
if buf: _OUT.append({"kind":"stream", "name":name, "text":"".join(buf)})
_PENDING.clear()
def _emit_fig(fig):
b = io.BytesIO()
fig.savefig(b, format="png", bbox_inches="tight", dpi=110)
_OUT.append({"kind":"image", "mime":"image/png", "b64":base64.b64encode(b.getvalue()).decode("ascii")})
def _capture_open_figs(close=True):
if "matplotlib" not in sys.modules: return 0
try:
import matplotlib.pyplot as plt
except Exception:
return 0
nums = plt.get_fignums()
if not nums: return 0
_flush_streams()
for num in nums:
try: _emit_fig(plt.figure(num))
except Exception: pass
if close: plt.close("all")
return len(nums)
def _emit_obj(o):
_flush_streams()
rh = getattr(o, "_repr_html_", None)
if callable(rh):
try:
h = rh()
if h:
_OUT.append({"kind":"html", "html":str(h)}); return
except Exception:
pass
try: _OUT.append({"kind":"text", "text":repr(o)})
except Exception: _OUT.append({"kind":"text", "text":"<unrepresentable object>"})
# ---- display helpers available inside user cells ----
def display(*objs):
"""Render objects inline, in order (uses _repr_html_ when available)."""
for o in objs: _emit_obj(o)
def display_html(html, height=480):
"""Display trusted interactive HTML in a sandboxed iframe output."""
try: h = int(height)
except Exception: h = 480
h = max(140, min(1400, h))
_flush_streams()
_OUT.append({"kind":"iframe_html", "html":str(html), "height":h})
def display_iframe(html, height=480):
"""Alias for display_html (handy for Plotly / Bokeh standalone documents)."""
display_html(html, height)
def display_plotly(fig, height=520):
"""One-liner for Plotly figures: render an interactive chart via the CDN build."""
try:
html = fig.to_html(include_plotlyjs="cdn", full_html=True,
config={"responsive": True, "displaylogo": False})
except Exception as e:
raise TypeError("display_plotly expects a Plotly figure; got %s (%s)" % (type(fig).__name__, e))
display_html(html, height)
def _new_kernel_ns():
return {
"__name__": "__main__",
"display": display,
"display_html": display_html,
"display_iframe": display_iframe,
"display_plotly": display_plotly,
}
_KNS = _new_kernel_ns()
def _kernel_reset():
global _KNS
_KNS = _new_kernel_ns()
if "matplotlib" in sys.modules:
try:
import matplotlib.pyplot as plt
plt.close("all")
except Exception:
pass
return "ok"
def _fmt_exc():
et, ev, tb = sys.exc_info()
cur, user = tb, tb
while cur is not None:
if cur.tb_frame.f_code.co_filename in ("<cell>", "<exec>"):
user = cur
break
cur = cur.tb_next
return "".join(traceback.format_exception(et, ev, user))
def _install_mpl_hooks():
# Make plt.show()/fig.show() flush pending output + capture the figure in place:
# correct ordering AND no Agg "non-interactive" warning (we never reach the real backend).
if "matplotlib" not in sys.modules:
return
try:
import matplotlib.pyplot as plt
import matplotlib.figure as _mfig
except Exception:
return
if not getattr(plt, "_kernel_patched", False):
def _show(*a, **k): _capture_open_figs(close=True)
plt.show = _show
try: plt._kernel_patched = True
except Exception: pass
if not getattr(_mfig.Figure, "_kernel_patched", False):
def _fig_show(self, *a, **k):
_flush_streams()
try: _emit_fig(self)
except Exception: pass
try:
import matplotlib.pyplot as _plt; _plt.close(self)
except Exception: pass
try:
_mfig.Figure.show = _fig_show
_mfig.Figure._kernel_patched = True
except Exception:
pass
async def _kernel_run(src):
global _OUT, _PENDING
_OUT, _PENDING = [], []
error = None
_install_mpl_hooks()
old_out, old_err = sys.stdout, sys.stderr
sys.stdout, sys.stderr = _StreamCap("stdout"), _StreamCap("stderr")
try:
val = await eval_code_async(src, globals=_KNS, filename="<cell>")
_install_mpl_hooks()
_flush_streams()
_capture_open_figs(close=True)
if val is not None:
_KNS["_"] = val
_emit_obj(val)
except Exception:
error = _fmt_exc()
finally:
_flush_streams()
_capture_open_figs(close=True)
sys.stdout, sys.stderr = old_out, old_err
return json.dumps({"outputs": _OUT, "error": error})
def _human_bytes(n):
try:
n = float(n)
except Exception:
return ""
for unit in ("B", "KB", "MB", "GB"):
if n < 1024 or unit == "GB":
return ("%d B" % int(n)) if unit == "B" else ("%.1f %s" % (n, unit))
n /= 1024.0
return ""
def _var_bytes(v, tn):
try:
if tn == "DataFrame":
return int(v.memory_usage(deep=True).sum())
if tn == "Series":
return int(v.memory_usage(deep=True))
if tn == "ndarray":
return int(v.nbytes)
except Exception:
return None
return None
def _inspect_ns():
import types as _t
skip = (_t.ModuleType, _t.FunctionType, _t.BuiltinFunctionType, _t.MethodType, type)
rows = []
for k in list(_KNS.keys()):
if k.startswith("_"):
continue
v = _KNS.get(k)
if isinstance(v, skip):
continue
tn = type(v).__name__
info = ""
try:
if tn == "DataFrame":
info = "%d rows x %d cols" % (v.shape[0], v.shape[1])
elif tn in ("Series", "ndarray"):
sh = getattr(v, "shape", None)
info = ("shape " + str(tuple(sh))) if sh is not None else ""
elif tn in ("list", "tuple", "set", "dict", "frozenset"):
info = "%d items" % len(v)
elif tn in ("str", "bytes"):
info = "%d chars" % len(v)
else:
r = repr(v)
info = r if len(r) <= 60 else (r[:59] + "\u2026")
except Exception:
info = ""
b = _var_bytes(v, tn)
rows.append({"name": k, "type": tn, "info": info, "size": _human_bytes(b) if b is not None else ""})
rows.sort(key=lambda r: r["name"].lower())
return json.dumps(rows)
def _del_var(name):
_KNS.pop(name, None)
return "ok"
def _short(x):
try:
if isinstance(x, float):
return "%.4g" % x
s = str(x)
except Exception:
s = "?"
return s if len(s) <= 40 else (s[:39] + "\u2026")
def _var_detail(name):
v = _KNS.get(name, None)
tn = type(v).__name__
out = {"name": name, "type": tn, "kind": "other", "lines": [], "repr": ""}
try:
if tn == "DataFrame":
out["kind"] = "dataframe"
out["shape"] = [int(v.shape[0]), int(v.shape[1])]
cols = list(v.columns)[:8]
out["columns"] = [str(c) for c in cols]
out["dtypes"] = [[str(c), str(v[c].dtype)] for c in cols]
if v.shape[1] > 8:
out["dtypes_more"] = int(v.shape[1] - 8)
rows = []
for _, r in v.head(8)[cols].iterrows():
rows.append([_short(r[c]) for c in cols])
out["head"] = rows
elif tn == "Series":
out["kind"] = "series"
out["lines"].append(["dtype", str(v.dtype)])
out["lines"].append(["length", str(len(v))])
try:
out["lines"].append(["nulls", str(int(v.isna().sum()))])
except Exception:
pass
import pandas as _pd
if _pd.api.types.is_numeric_dtype(v):
for lbl, fn in (("min", v.min), ("max", v.max), ("mean", v.mean), ("std", v.std)):
try:
out["lines"].append([lbl, _short(fn())])
except Exception:
pass
else:
try:
out["lines"].append(["unique", str(int(v.nunique()))])
vc = v.value_counts().head(3)
out["lines"].append(["top", ", ".join("%s (%d)" % (_short(i), int(c)) for i, c in vc.items())])
except Exception:
pass
elif tn == "ndarray":
out["kind"] = "ndarray"
out["lines"].append(["dtype", str(v.dtype)])
out["lines"].append(["shape", str(tuple(v.shape))])
try:
import numpy as _np
if _np.issubdtype(v.dtype, _np.number):
out["lines"].append(["min", _short(v.min())])
out["lines"].append(["max", _short(v.max())])
out["lines"].append(["mean", _short(v.mean())])
except Exception:
pass
elif tn == "dict":
out["kind"] = "mapping"
out["lines"].append(["keys", str(len(v))])
out["keys"] = [_short(k) for k in list(v.keys())[:12]]
if len(v) > 12:
out["keys_more"] = int(len(v) - 12)
elif tn in ("list", "tuple", "set", "frozenset"):
out["kind"] = "sequence"
out["lines"].append(["length", str(len(v))])
out["items"] = [_short(x) for x in list(v)[:12]]
if len(v) > 12:
out["items_more"] = int(len(v) - 12)
else:
out["kind"] = "scalar"
r = repr(v)
out["repr"] = r if len(r) <= 600 else (r[:600] + "\u2026")
except Exception as e:
out["kind"] = "other"
out["repr"] = "detail unavailable: %s" % e
return json.dumps(out)
def _complete(src, line, col):
try:
import jedi
except Exception:
return json.dumps({"ready": False, "items": []})
try:
script = jedi.Interpreter(src, [_KNS])
comps = script.complete(line, col)
items = [{"name": c.name, "complete": c.complete, "type": c.type} for c in comps[:60]]
return json.dumps({"ready": True, "items": items})
except Exception:
return json.dumps({"ready": True, "items": []})