claude-scriptorium 0.1.2

Render Claude Code sessions as self-contained HTML
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
/*
 * illumination: the theme layer for a folio.
 *
 * A parchment leaf with an illuminated border: rubricated initials, vine
 * ornaments in the outer margins, and fleuron dividers, all drawn in CSS and
 * inline SVG so the folio stays self-contained. A single light palette lives
 * in the token block, so the dark variant (M3) is a swap of those values.
 *
 * Syntax colors target the canonical TextMate scope roots (comment, string,
 * keyword, ...) that syntect emits as the first class on every span, so the
 * palette covers every language without enumerating their finer scopes.
 */

:root {
  /* Every colour is a light-dark() pair, resolved by `color-scheme`. System
   * preference is the default (`light dark`); the theme toggle forces one side
   * by setting color-scheme to `light` or `dark` on <html> (see [data-theme]
   * below), so the whole palette swaps without a duplicated token block. */
  color-scheme: light dark;

  --page: light-dark(#e7dcc0, #171310);
  --leaf: light-dark(#f7f1e1, #201a14);
  --leaf-sunk: light-dark(#f1e9d4, #29221a);
  --ink: light-dark(#2b2620, #ece2cf);
  --ink-soft: light-dark(#6f6656, #b6ab93);
  --ink-faint: light-dark(#9a9080, #857b66);
  --rule: light-dark(#d8ccae, #3b3327);
  --rule-soft: light-dark(#e6dcc3, #2e2820);

  /* The mineral pigments a scribe actually ground: vermilion and red lead,
   * lapis lazuli, malachite, Tyrian purple, ochre, and burnished gold. The
   * dark side lifts each hue so it holds its chroma against a dark vellum. */
  --rubric: light-dark(#b0281d, #e0715f); /* vermilion / red lead */
  --sienna: light-dark(#9a6410, #cf9a4c); /* yellow ochre / raw sienna */
  --gold: light-dark(#b8860b, #d9ad4e); /* solid gold, for small marks */

  /* Burnished gold leaf: the 135° sheen gilded ornaments take by clipping it to
   * their glyph. Metal reads as gold on either ground, so this is one value,
   * not a light-dark pair. */
  --gold-leaf: linear-gradient(
    135deg,
    #f6e08f 0%,
    #d9ad4e 28%,
    #b8860b 50%,
    #916a12 64%,
    #d9ad4e 82%,
    #f6e08f 100%
  );
  --verdigris: light-dark(#2f7a4d, #58b783); /* malachite green */
  --lapis: light-dark(#274690, #7f9fe6); /* lapis lazuli / ultramarine */
  --tyrian: light-dark(#6b2f74, #bd83c8); /* Tyrian purple / folium */

  /* Not a manuscript pigment, but the assistant's own hue. */
  --claude: light-dark(#d97757, #e08a6a);

  --user-edge: var(--lapis);
  --assistant-edge: var(--claude);
  --sidechain-edge: var(--tyrian);
  --error-edge: var(--rubric);

  --measure: 44rem;
  --radius: 4px;

  /* Junicode, Fira Code, and UnifrakturCook are embedded as @font-face rules
   * (see render.rs); the stacks behind them are fallbacks for glyphs the
   * bundled faces lack, since transcripts carry arbitrary Unicode. */
  --serif: "Junicode", "Iowan Old Style", "Palatino Linotype", Palatino,
    "Book Antiqua", Georgia, serif;
  --mono: "Fira Code", ui-monospace, "SF Mono", "Cascadia Code",
    "JetBrains Mono", Menlo, Consolas, monospace;
  --display: "UnifrakturCook", var(--serif);

  /* Syntax tokens, all resolved against the parchment ground. */
  --syn-comment: light-dark(#948a74, #7f765f);
  --syn-string: var(--verdigris);
  --syn-keyword: var(--rubric);
  --syn-storage: var(--rubric);
  --syn-constant: var(--sienna);
  --syn-entity: var(--lapis);
  --syn-variable: var(--tyrian);
  --syn-support: var(--lapis);
  --syn-inserted: var(--verdigris);
  --syn-deleted: var(--rubric);
}

/* The theme toggle forces one side of every light-dark() pair by pinning
 * color-scheme; absent the attribute (or with data-theme="system") the :root
 * default of `light dark` follows the OS. */
:root[data-theme="light"] {
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 17px;
  /* Parchment ground with faint mottling, so the page isn't a flat fill. */
  background-color: var(--page);
  /* The parchment mottling inverts for dark: a warm highlight and a deepening
   * shadow rather than the light page's bright bloom. */
  background-image:
    radial-gradient(
      ellipse at 20% 15%,
      light-dark(rgba(255, 255, 255, 0.35), rgba(255, 244, 214, 0.06)),
      transparent 55%
    ),
    radial-gradient(
      ellipse at 85% 80%,
      light-dark(rgba(120, 96, 48, 0.12), rgba(0, 0, 0, 0.28)),
      transparent 60%
    );
}

/* The body is the leaf itself: a centered parchment page. */
body {
  position: relative;
  max-width: var(--measure);
  margin: 2.5rem auto 3rem;
  padding: 3rem 3.25rem 2.5rem;
  background: var(--leaf);
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.6;
  border: 1px solid var(--rule);
  box-shadow:
    0 0 0 1px var(--leaf) inset,
    0 0 0 4px var(--rule-soft) inset,
    0 6px 26px rgba(60, 46, 20, 0.18);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Illuminated borders down the outer margins: a per-session strip of vine
 * sections with drolleries seated among them (composed in render.rs, its data
 * URI set inline), tiled to fill the leaf however tall it grows. Each creature
 * is mirrored at random within the strip, so neither margin faces a consistent
 * way; the left copy is flipped whole so the two vines curl as a mirrored
 * frame around the text. */
.margin {
  position: absolute;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 90px;
  background-repeat: repeat-y;
  background-position: center top;
  opacity: 0.9;
  pointer-events: none;
}

.margin--left {
  right: 100%;
  margin-right: 0.5rem;
  transform: scaleX(-1);
}

.margin--right {
  left: 100%;
  margin-left: 0.5rem;
}

@media (max-width: 62rem) {
  .margin {
    display: none;
  }
}

@media (max-width: 34rem) {
  body {
    padding: 1.75rem 1.25rem;
  }
}

/* --- Search: a fixed widget that steps through matches --------------- */

.search {
  position: fixed;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.34rem 0.5rem;
  background: var(--leaf);
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.search__bar {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.search__scopes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
}

.search__scope {
  --scope-hue: var(--ink-soft);
  padding: 0.05rem 0.4rem;
  border: 1px solid color-mix(in srgb, var(--scope-hue) 45%, transparent);
  border-radius: 999px;
  background: transparent;
  color: var(--scope-hue);
  font: inherit;
  line-height: 1.4;
  cursor: pointer;
}

.search__scope--user {
  --scope-hue: var(--user-edge);
}

.search__scope--assistant {
  --scope-hue: var(--assistant-edge);
}

.search__scope[aria-pressed="true"] {
  background: color-mix(in srgb, var(--scope-hue) 20%, transparent);
  border-color: var(--scope-hue);
}

/* Off reads as struck out: dimmed and no longer searched. */
.search__scope[aria-pressed="false"] {
  opacity: 0.5;
  text-decoration: line-through;
}

.search__input {
  width: 9rem;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  outline: none;
}

.search__input::placeholder {
  color: var(--ink-faint);
}

.search__count {
  min-width: 3.4rem;
  text-align: right;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

.search__nav {
  padding: 0 0.25rem;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.search__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

mark.search__hit {
  color: inherit;
  background: color-mix(in srgb, var(--gold) 34%, transparent);
  border-radius: 2px;
}

mark.search__hit.is-current {
  background: color-mix(in srgb, var(--gold) 68%, transparent);
  outline: 1px solid var(--gold);
}

/* On narrow screens the widget would crowd the leaf; let it shrink. */
@media (max-width: 34rem) {
  .search__input {
    width: 6rem;
  }
}

/* --- Dock: fixed jump / fold controls -------------------------------- */

.dock {
  position: fixed;
  right: 0.8rem;
  bottom: 0.8rem;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.3rem;
  background: var(--leaf);
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}

/* Three columns of up/down arrows: a user (blue) and assistant (orange)
 * column seeking one speaker, flanking the middle column that steps all. */
.dock__nav {
  display: grid;
  grid-template-columns: repeat(3, 2.2rem);
  gap: 0.2rem;
}

.dock__fold,
.dock__tail {
  display: flex;
  justify-content: center;
  gap: 0.2rem;
}

/* The follow toggle lights gold while active, so a live "tailing" reads at a
 * glance and is told apart from the plain jump-to-end beside it. */
.dock__btn--tail[aria-pressed="true"] {
  --dock-hue: var(--gold);
  background: var(--leaf-sunk);
}

.dock__btn {
  --dock-hue: var(--ink-soft);
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--dock-hue);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}

.dock__btn--user {
  --dock-hue: var(--user-edge);
}

.dock__btn--assistant {
  --dock-hue: var(--assistant-edge);
}

/* The fold buttons stack two chevrons: outward to unfold, inward to fold. */
/* The chevron glyphs hug the direction they point, so outward and inward need
 * different box gaps to read as the same visual separation. */
.dock__btn--fold {
  display: flex;
  flex-direction: column;
}

.dock__btn--fold[data-fold="expand"] {
  gap: 0.08rem;
}

.dock__btn--fold[data-fold="collapse"] {
  gap: 0.32rem;
}

.dock__chevron {
  font-size: 0.8rem;
  line-height: 0.85;
}

/* Hover brightens each arrow's own hue rather than recolouring it, so a user
 * (blue) or assistant (orange) arrow never flashes the other speaker's colour. */
.dock__btn:hover,
.dock__btn:focus-visible {
  background: var(--leaf-sunk);
  color: color-mix(in srgb, var(--dock-hue), white 30%);
}

/* --- Plaque: title, facts, and colophon on demand -------------------- */
/* A disclosure in the top corner, opposite the search widget: the reading
 * column stays pure transcript, and the folio's metadata is a click away. */

.plaque {
  position: fixed;
  top: 0.8rem;
  left: 0.8rem;
  z-index: 10;
}

.plaque__seal {
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  padding: 0;
  background: var(--leaf);
  border: 1px solid var(--rule);
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  color: var(--gold);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.plaque:hover .plaque__seal,
.plaque:focus-within .plaque__seal {
  color: var(--rubric);
}

.plaque__panel {
  position: absolute;
  display: none;
  top: calc(100% + 0.4rem);
  left: 0;
  width: max-content;
  max-width: min(22rem, 80vw);
  padding: 0.9rem 1.1rem;
  background: var(--leaf);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 6px 26px rgba(60, 46, 20, 0.22);
}

/* The panel shows while the seal is hovered or focused. A click focuses the
 * seal (keeping :focus-within true), so it stays open until focus moves away;
 * on touch, a tap focuses it the same way. */
.plaque:hover .plaque__panel,
.plaque:focus-within .plaque__panel {
  display: block;
}

/* A transparent bridge across the seal-to-panel gap so the pointer can travel
 * into the panel without the hover lapsing. */
.plaque__panel::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  height: 0.5rem;
}

.plaque__title {
  margin: 0 0 0.7rem;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 400;
  line-height: 1.1;
  color: var(--rubric);
  word-break: break-word;
}

.plaque__facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 1rem;
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.plaque__facts dt {
  font-variant: small-caps;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

.plaque__facts dd {
  margin: 0;
  word-break: break-word;
}

.plaque__colophon {
  margin: 0.7rem 0 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* --- Turns ----------------------------------------------------------- */

.turn {
  position: relative;
  margin: 1.6rem 0;
  padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 2px solid var(--rule);
  scroll-margin-top: 1rem;
}

/* A deep-linked turn (its number followed, or the page opened at #turn-N) takes
 * a faint gilt wash so the reader sees where they landed. The wash reaches as
 * far right of the turn number as the left padding sets the text in from the
 * border bar, so it sits symmetric; the negative margin lets the box grow
 * rightward (into the leaf's own margin) without reflowing its content. */
.turn:target {
  background: color-mix(in srgb, var(--gold) 9%, transparent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding-right: 1.1rem;
  margin-right: -1.1rem;
}

/* Hold the copy button on the turn number as the wash widens the box. */
.turn:target .copy-button--meta {
  right: 1.1rem;
}

.turn--user {
  border-left-color: var(--user-edge);
}

.turn--assistant {
  border-left-color: var(--assistant-edge);
}

.turn[data-sidechain] {
  border-left-color: var(--sidechain-edge);
  border-left-style: dashed;
  margin-left: 1.5rem;
}

/* Harness-injected turns (command caveats, skill scaffolding, context dumps)
 * carry no reader value and are always hidden. */
.turn[data-meta] {
  display: none;
}

/* --- Controls: the presentation cluster, opposite the dock ----------- */
/* Bottom-left, mirroring the navigation dock at bottom-right. A bare anchor;
 * the theme toggle inside carries its own floating pill. */
.controls {
  position: fixed;
  left: 0.8rem;
  bottom: 0.8rem;
  z-index: 10;
}

/* A segmented light / dark / system control, wired by the app script. */
.theme-toggle {
  display: inline-flex;
  background: var(--leaf);
  border: 1px solid var(--rule);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.theme-toggle button {
  padding: 0.28rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.theme-toggle button + button {
  border-left: 1px solid var(--rule);
}

.theme-toggle button[aria-pressed="true"] {
  background: var(--leaf-sunk);
  color: var(--rubric);
}

.turn__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.9rem;
  margin-bottom: 0.3rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  color: var(--ink-faint);
}

/* The turn number is a permalink to its own panel: click it to put #turn-N in
 * the address bar and share the exact spot. Muted until hovered so it reads as
 * chrome, not prose. The two-class selector outranks the .folio a link rule. */
.turn__meta .turn__index {
  color: var(--ink-faint);
  text-decoration: none;
}

.turn__meta .turn__index:hover,
.turn__meta .turn__index:focus-visible {
  color: var(--gold);
  text-decoration: underline;
}

.turn__role {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-soft);
}

.turn--user .turn__role {
  color: var(--user-edge);
}

.turn--assistant .turn__role {
  color: var(--assistant-edge);
}

/* Tool and thinking labels are secondary to prose, so mute them and reserve
 * the role colour for panels that actually speak to the reader. */
.turn[data-kind="tool"] .turn__role,
.turn[data-kind="thinking"] .turn__role {
  color: var(--ink-faint);
}

/* Push the timestamp and turn number to the panel's top-right corner. */
.turn__time {
  margin-left: auto;
}

/* --- Blocks ---------------------------------------------------------- */

.block {
  margin: 0.7rem 0;
}

.block--text > :first-child,
.block--thinking > :first-child {
  margin-top: 0;
}

.block--text > :last-child,
.block--thinking > :last-child {
  margin-bottom: 0;
}

/* Rubricated versal: the first letter of a speaker's opening paragraph, set as
 * a dropped blackletter initial in the speaker's own colour. It opens each turn
 * of the conversation the way a manuscript opens a division, doubling as a
 * visual anchor for where the exchange turns. The renderer tags the leading
 * text block of a speech panel with data-versal, so only that paragraph is
 * decorated (and tool and thinking panels never are). The drop is two lines
 * uniformly: enough to read as an initial, shallow enough to keep turns
 * vertically compact and to never dangle far past a one-line message. The
 * `> p:first-child` guard means an opener that leads with a heading or list
 * (no paragraph) simply goes without. */
.block--text[data-versal] > p:first-child::first-letter {
  -webkit-initial-letter: 2 2;
  initial-letter: 2 2;
  margin-right: 0.4rem;
  font-family: var(--display);
  font-weight: 400;
  /* Uppercase the displayed initial so a lowercased opener still gets a
   * full-height capital; the DOM text stays as written, so copy and search
   * still see the original letter. */
  text-transform: uppercase;
  /* Gild the initial by laying a slightly-expanded gold silhouette behind it:
   * a ring of gold text-shadows traces the glyph a pixel or two out on every
   * side (::first-letter ignores text-stroke, so the shadow ring stands in). The
   * ring is lit diagonally, pale gold at the upper-left fading to deep gold at
   * the lower-right, so the gilt reads as the 135° gold-leaf sheen following the
   * glyph's own shape. The letter keeps its speaker colour on top. The golds are
   * baked, not var(--gold): metal reads as gold on either parchment. */
  text-shadow:
    -2px -2px 0 #f6e08f, -1px -1px 0 #f6e08f,
    -2px -1px 0 #ecd074, -1px -2px 0 #ecd074,
    0 -2px 0 #dcb45a, -2px 0 0 #dcb45a,
    1px -1px 0 #cfa347, -1px 1px 0 #cfa347,
    2px 0 0 #b98d22, 0 2px 0 #b98d22,
    1px 1px 0 #916a12, 2px 2px 0 #916a12,
    0 0 3px #b8860b;
}

.turn--user .block--text[data-versal] > p:first-child::first-letter {
  color: var(--user-edge);
}

.turn--assistant .block--text[data-versal] > p:first-child::first-letter {
  color: var(--assistant-edge);
}

.block--thinking {
  padding: 0.6rem 1rem;
  border-left: 2px solid var(--rule-soft);
  background: var(--leaf-sunk);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--ink-soft);
  font-style: italic;
}

/* A slim note where extended reasoning was redacted from the transcript. */
.block--redacted {
  margin: 0.5rem 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-variant: small-caps;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.block--redacted::before {
  content: "";
  color: var(--gold);
}

.block--image {
  margin: 1rem 0;
}

.block--image img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.block--unknown {
  font-family: var(--mono);
  font-size: 0.82rem;
}

.block--unknown > summary {
  color: var(--ink-faint);
  font-style: italic;
}

/* --- Marginalia: collapsible tool calls and their results ------------ */

.marginalia {
  margin: 0.55rem 0;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--leaf-sunk);
  font-size: 0.86rem;
}

.marginalia > summary {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-soft);
  list-style: none;
}

.marginalia > summary::-webkit-details-marker {
  display: none;
}

.marginalia > summary::before {
  content: "";
  color: var(--gold);
  font-size: 0.9em;
}

.marginalia[open] > summary::before {
  content: "";
  transform: rotate(90deg);
}

/* Gild the fold-marker fleurons and section dividers in the 135° gold leaf by
 * clipping the gradient to the glyph. A lone ::before glyph has no competing
 * background, so the sheen shows cleanly; where the clip is unsupported the
 * solid var(--gold) above remains. */
@supports (background-clip: text) or (-webkit-background-clip: text) {
  .marginalia > summary::before,
  .folio hr::before {
    background: var(--gold-leaf);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

.marginalia[open] > summary {
  border-bottom: 1px solid var(--rule-soft);
}

.marginalia__tool {
  font-weight: 600;
  color: var(--sienna);
}

.marginalia__gist {
  overflow: hidden;
  color: var(--ink-faint);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.marginalia--result > summary {
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.marginalia[data-error] {
  border-color: var(--error-edge);
  background: color-mix(in srgb, var(--rubric) 7%, var(--leaf-sunk));
}

.marginalia[data-error] > summary {
  color: var(--rubric);
}

.marginalia__body {
  margin: 0;
  padding: 0.6rem 0.8rem;
  background: transparent;
  border-radius: 0;
}

/* On wide viewports, an open marginalia that holds a code, diff, or JSON block
 * unfurls past the reading measure, so wide content (diffs especially) fits
 * without sideways scrolling. Prose keeps the narrow column; only these panels
 * break out, lifting above the marginal vines on their own shadow. Scoped with
 * :has(pre) so a short text result stays in column. */
@media (min-width: 64rem) {
  .marginalia[open]:has(pre) {
    position: relative;
    z-index: 1;
    width: min(66rem, 92vw);
    margin-inline: calc((100% - min(66rem, 92vw)) / 2);
    box-shadow: 0 3px 20px rgba(40, 30, 12, 0.16);
  }
}

/* --- Tool bodies: the bespoke views for common tools ----------------- */

.tool {
  padding: 0.55rem 0.7rem;
}

/* The highlighted code a tool body emits is the body itself; drop its default
 * block margins so it sits flush inside the marginalia. */
.tool > pre {
  margin: 0;
}

.tool__caption {
  margin: 0 0 0.45rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-style: italic;
  color: var(--ink-faint);
}

.tool--todos {
  margin: 0;
  padding: 0.3rem 0.8rem;
  list-style: none;
}

.tool__todo {
  display: flex;
  gap: 0.55rem;
  padding: 0.12rem 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink);
}

.tool__todo::before {
  content: "";
  color: var(--ink-faint);
}

.tool__todo[data-status="in_progress"]::before {
  content: "";
  color: var(--sienna);
}

.tool__todo[data-status="completed"]::before {
  content: "";
  color: var(--verdigris);
}

.tool__todo[data-status="completed"] {
  color: var(--ink-faint);
  text-decoration: line-through;
}

/* --- Copy buttons: injected by the app script ------------------------ */

.folio pre {
  position: relative;
}

.copy-button {
  padding: 0.1rem 0.42rem;
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: var(--leaf);
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease;
}

/* A code / output block clips its own scroll overflow (overflow-x: auto forces
 * overflow-y to auto), so its copy button can't ride outside the top border the
 * way a thinking block's does. It sits just inside the top-right corner instead,
 * over the block's top padding, always visible for discovery. */
.folio pre > .copy-button {
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  opacity: 0.6;
}

.folio pre:hover > .copy-button,
.copy-button:focus-visible {
  opacity: 1;
}

/* The turn's copy button rides the panel's top edge, flush-right under the turn
 * number (which keeps the corner). It stays visible for discovery, muted until
 * the panel is hovered. The leading block's clearance below keeps it off text. */
.copy-button--meta {
  position: absolute;
  top: 2.3rem;
  right: 0;
  z-index: 2;
  opacity: 0.6;
  transform: translateY(-50%);
}

.turn:hover .copy-button--meta,
.copy-button--meta:focus-visible {
  opacity: 1;
}

/* Seat the always-on copy button centred on the leading block's top edge: the
 * shaded top border of a thinking block, or the (invisible) top of a prose
 * block, which land in the same place. The block drops by one button-height so
 * its edge sits under the button's centre, which makes the turn-number-to-button
 * gap equal the button-to-edge gap. A prose block also takes the same top
 * padding a thinking block has, so its first line lands where thinking text
 * would and never runs under the button. */
.turn:has(.copy-button--meta) > .turn__meta + * {
  margin-top: 1rem;
}

.turn:has(.copy-button--meta) > .turn__meta + .block--text {
  padding-top: 0.6rem;
}

.copy-button.is-done {
  color: var(--verdigris);
  border-color: var(--verdigris);
  opacity: 1;
}

/* --- Prose the markdown renderer emits ------------------------------- */

.folio :is(h1, h2, h3, h4, h5, h6) {
  margin: 1.3em 0 0.5em;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}

/* Blackletter is a display face at one weight: reserve it for the larger
 * headings and let it stand at its native weight rather than faux-bolded. */
.folio :is(h1, h2, h3) {
  font-family: var(--display);
  font-weight: 400;
}

.folio h1 {
  font-size: 1.6rem;
}

.folio h2 {
  font-size: 1.2rem;
}

.folio h3 {
  font-size: 1.05rem;
}

.folio :is(h4, h5, h6) {
  font-size: 1rem;
}

.folio p {
  margin: 0.6em 0;
}

.folio a {
  color: var(--lapis);
  text-underline-offset: 0.15em;
  text-decoration-color: color-mix(in srgb, var(--lapis) 40%, transparent);
}

.folio a:hover {
  text-decoration-color: currentColor;
}

.folio blockquote {
  margin: 0.9em 0;
  padding: 0.1em 1rem;
  border-left: 3px solid var(--rule);
  color: var(--ink-soft);
}

.folio ul,
.folio ol {
  padding-left: 1.4rem;
}

.folio li {
  margin: 0.15em 0;
}

.folio li::marker {
  color: var(--gold);
}

.folio hr {
  margin: 1.5em 0;
  border: none;
  text-align: center;
}

.folio hr::before {
  content: "";
  color: var(--gold);
  font-size: 0.95rem;
}

.folio table {
  margin: 1em 0;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.folio :is(th, td) {
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--rule);
  text-align: left;
}

.folio th {
  background: var(--leaf-sunk);
  font-weight: 600;
}

/* Inline code, distinct from fenced blocks. */
.folio :not(pre) > code {
  padding: 0.1em 0.35em;
  background: var(--leaf-sunk);
  border: 1px solid var(--rule-soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.85em;
}

.folio pre {
  overflow-x: auto;
  padding: 0.7rem 0.9rem;
  background: var(--leaf-sunk);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  font-size: 0.82rem;
  line-height: 1.5;
}

.folio pre code {
  font-family: var(--mono);
}

.marginalia__body {
  border: none;
}

/* --- Syntax highlighting: the canonical scope roots ------------------ */

pre.syntax-highlighting {
  color: var(--ink);
}

.ink-comment {
  color: var(--syn-comment);
  font-style: italic;
}

.ink-string {
  color: var(--syn-string);
}

.ink-constant {
  color: var(--syn-constant);
}

.ink-keyword {
  color: var(--syn-keyword);
}

.ink-storage {
  color: var(--syn-storage);
}

.ink-entity {
  color: var(--syn-entity);
}

.ink-variable {
  color: var(--syn-variable);
}

.ink-support {
  color: var(--syn-support);
}

/* Operators and structural punctuation read as ink, not as color. */
.ink-keyword.ink-operator,
.ink-punctuation {
  color: var(--ink-soft);
}

/* Markup scopes (Markdown, diff) carry weight and hue rather than a palette. */
.ink-markup.ink-bold {
  font-weight: 700;
}

.ink-markup.ink-italic {
  font-style: italic;
}

.ink-markup.ink-heading {
  color: var(--rubric);
  font-weight: 700;
}

.ink-markup.ink-raw {
  color: var(--sienna);
}

.ink-markup.ink-inserted {
  color: var(--syn-inserted);
}

.ink-markup.ink-deleted {
  color: var(--syn-deleted);
}