devpage 0.2.2

Live documents from a repository: sites, docs and slides from Markdown, and UI designs drawn from code — with comments, link checking and PDF
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
/* devpage's built-in light and dark themes. Every color comes from these tokens,
   diagrams included, so a theme is a set of token values. An embedded
   design's backdrop that its own switch turned carries data-theme too, and
   takes that theme's tokens whatever the page's. */
:root, .design-embed[data-theme="light"] {
  --background: #ffffff;
  --surface: #f5f5f7;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --border: #d2d2d7;
  --accent: #0066cc;
  --code: #f5f5f7;
  --syntax-keyword: #9b2393;
  --syntax-string: #c41a16;
  --syntax-number: #1c00cf;
  --syntax-comment: #5d6c79;
  --syntax-type: #0b4f79;
  --syntax-function: #326d74;
  --syntax-attribute: #815f03;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light dark;
}

/* Dark: chosen with the theme selector (data-theme, set before the page
   paints), or — with no choice made and no script — by the system setting. */
:root[data-theme="dark"], .design-embed[data-theme="dark"] {
    --background: #000000;
    --surface: #1d1d1f;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --border: #424245;
    --accent: #2997ff;
    --code: #1d1d1f;
    --syntax-keyword: #ff7ab2;
    --syntax-string: #ff8170;
    --syntax-number: #d9c97c;
    --syntax-comment: #7f8c98;
    --syntax-type: #dabaff;
    --syntax-function: #67b7a4;
    --syntax-attribute: #fd8f3f;
  }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --background: #000000;
    --surface: #1d1d1f;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --border: #424245;
    --accent: #2997ff;
    --code: #1d1d1f;
    --syntax-keyword: #ff7ab2;
    --syntax-string: #ff8170;
    --syntax-number: #d9c97c;
    --syntax-comment: #7f8c98;
    --syntax-type: #dabaff;
    --syntax-function: #67b7a4;
    --syntax-attribute: #fd8f3f;
  }
}
:root[data-theme="light"], .design-embed[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"], .design-embed[data-theme="dark"] { color-scheme: dark; }


* { box-sizing: border-box; }

body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font: 17px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* Navigation */

#devpage-nav {
  position: sticky;
  top: 0;
  align-self: flex-start;
  width: 280px;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 28px 16px 40px 24px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  line-height: 1.4;
}

#devpage-nav .document-title {
  display: block;
  margin-bottom: 18px;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

#devpage-nav ul { list-style: none; margin: 0; padding: 0; }
#devpage-nav ul ul { padding-left: 14px; border-left: 1px solid var(--border); margin: 2px 0 6px 6px; }
#devpage-nav li { margin: 0; }
#devpage-nav a { display: block; padding: 4px 8px; border-radius: 6px; color: var(--text); text-decoration: none; }
#devpage-nav a:hover { background: var(--border); }
#devpage-nav a.current { background: var(--accent); color: #fff; }

/* A sidebar entry with children: its link and a chevron on one row, its
   children shown while it is open. */
#devpage-nav .entry { display: flex; align-items: center; gap: 2px; }
#devpage-nav .entry > a { flex: 1; min-width: 0; }
#devpage-nav .chevron {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
#devpage-nav .chevron:hover { background: var(--border); color: var(--text); }
#devpage-nav .chevron::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateX(-1px) rotate(-45deg);
}
#devpage-nav li.open > .entry > .chevron::before { transform: translateY(-1px) rotate(45deg); }
#devpage-nav li.branch:not(.open) > ul { display: none; }

/* The sidebar's search box, between the title and the tree, and its hits,
   which take the tree's place while the box holds text. */
#devpage-nav .search { position: relative; margin: 0 0 16px; }
#devpage-nav .search::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  background: var(--muted);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") center / contain no-repeat;
  pointer-events: none;
}
#devpage-nav .search input {
  display: block;
  width: 100%;
  height: 32px;
  margin: 0;
  padding: 0 30px 0 31px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  color: var(--text);
  font: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#devpage-nav .search input::placeholder { color: var(--muted); }
#devpage-nav .search input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
#devpage-nav .search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
#devpage-nav .search kbd {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 18px;
  line-height: 16px;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
}
#devpage-nav .search .clear {
  position: absolute;
  right: 7px;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  transform: translateY(-50%);
  background: var(--muted);
  cursor: pointer;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cmask id='x'%3E%3Ccircle cx='12' cy='12' r='12' fill='white'/%3E%3Cpath d='m8 8 8 8m0-8-8 8' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/mask%3E%3Ccircle cx='12' cy='12' r='12' mask='url(%23x)'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cmask id='x'%3E%3Ccircle cx='12' cy='12' r='12' fill='white'/%3E%3Cpath d='m8 8 8 8m0-8-8 8' stroke='black' stroke-width='2.4' stroke-linecap='round'/%3E%3C/mask%3E%3Ccircle cx='12' cy='12' r='12' mask='url(%23x)'/%3E%3C/svg%3E") center / contain no-repeat;
}
#devpage-nav .search .clear:hover { background: var(--text); }
#devpage-nav .search:focus-within kbd,
#devpage-nav .search input:not(:placeholder-shown) + kbd { display: none; }

/* The results, grouped by page: the page's row, then its sections and the
   more row under it, indented on a rule as the tree's children are. */
#devpage-nav .search-page + .search-page { margin-top: 6px; }
#devpage-nav .search-sections { margin: 0 0 2px 6px; padding-left: 8px; border-left: 1px solid var(--border); }
#devpage-nav a.hit { padding: 5px 8px; scroll-margin: 8px; }
#devpage-nav a.hit:hover { background: none; }
#devpage-nav a.hit.selected { background: var(--border); }
#devpage-nav .hit-place,
#devpage-nav .hit-label { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#devpage-nav .hit-place { font-size: 12px; color: var(--muted); }
#devpage-nav .hit-page .hit-label { font-weight: 600; }
#devpage-nav .hit-section .hit-label { font-weight: 500; }
#devpage-nav .hit-more .hit-label { font-size: 13px; color: var(--muted); }
#devpage-nav .hit-snippet,
#devpage-nav .hit-lede {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  margin-top: 1px;
  font-size: 13px;
  color: var(--muted);
}
#devpage-nav .hit-snippet mark {
  padding: 0 1px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--text);
}
#devpage-nav .search-empty { margin: 0; padding: 4px 8px; color: var(--muted); }

/* Content */

main { flex: 1; min-width: 0; padding: 56px 48px 120px; }
article { max-width: 780px; margin: 0 auto; }

h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.015em; }
h1 { font-size: 40px; font-weight: 700; margin: 0 0 24px; }
h2 { font-size: 28px; font-weight: 600; margin: 48px 0 16px; }
h3 { font-size: 21px; font-weight: 600; margin: 32px 0 12px; }
p, ul, ol, table, pre, blockquote, .diagram { margin: 0 0 20px; }
li { margin: 4px 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }
hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

blockquote {
  margin-left: 0;
  padding: 4px 20px;
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}

code { font: 0.88em var(--font-mono); background: var(--code); padding: 2px 5px; border-radius: 5px; }
pre { background: var(--code); padding: 16px 20px; border-radius: 10px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; padding: 0; font-size: 14px; }

table { border-collapse: collapse; width: 100%; font-size: 15px; }
/* A wide table scrolls inside its own box, never the page. */
.table-scroll { overflow-x: auto; margin: 0 0 20px; }
.table-scroll > table { margin: 0; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; }

/* Diagrams: pele draws with its own variables, mapped to the theme tokens. */

.diagram {
  --pele-bg: var(--background);
  --pele-fg: var(--text);
  --pele-muted: var(--muted);
  --pele-line: var(--muted);
  --pele-surface: var(--surface);
  --pele-surface-alt: var(--border);
  --pele-border: var(--border);
  --pele-accent: var(--accent);
  --pele-font: var(--font);
  --pele-font-mono: var(--font-mono);
  --pele-radius: 8px;
  padding: 8px 0;
  text-align: center;
}

.diagram svg { max-width: 100%; height: auto; }

.diagram-error { color: #d70015; text-align: left; white-space: pre-wrap; font: 13px var(--font-mono); }

@media (max-width: 860px) {
  body { display: block; }
  #devpage-nav { position: static; width: auto; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  main { padding: 32px 20px 80px; }
}

/* Sidebar groups: the ### headings of a Topics section. */
#devpage-nav li.group { margin: 14px 0 4px; padding: 0 8px; }
#devpage-nav li.group:first-child { margin-top: 0; }
#devpage-nav li.group span { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

/* Syntax highlighting: classes name syntax scopes (see src/highlight.rs); colors
   come from the --syntax-* tokens, Xcode's default palettes. */
pre code { color: var(--text); }
.hl-comment { color: var(--syntax-comment); font-style: italic; }
.hl-string { color: var(--syntax-string); }
.hl-constant.hl-numeric, .hl-constant.hl-language { color: var(--syntax-number); }
.hl-keyword, .hl-storage { color: var(--syntax-keyword); font-weight: 600; }
.hl-storage.hl-type.hl-primitive, .hl-support.hl-type, .hl-entity.hl-name.hl-type, .hl-entity.hl-name.hl-class,
.hl-entity.hl-name.hl-struct, .hl-entity.hl-name.hl-enum, .hl-entity.hl-other.hl-inherited-class { color: var(--syntax-type); font-weight: 400; }
.hl-entity.hl-name.hl-function, .hl-support.hl-function, .hl-variable.hl-function { color: var(--syntax-function); }
.hl-entity.hl-name.hl-tag, .hl-entity.hl-other.hl-attribute-name, .hl-meta.hl-attribute, .hl-support.hl-other.hl-macro { color: var(--syntax-attribute); }

/* Diagram nodes with a `click … href` line are links: no underline; on hover the
   node's border takes the accent color. */
.diagram a { cursor: pointer; text-decoration: none; }
.diagram a:hover rect, .diagram a:hover polygon, .diagram a:hover circle,
.diagram a:hover ellipse, .diagram a:hover path { stroke: var(--accent); stroke-width: 2.5px; }

/* A doc: one long page, its outline beside it. */

.outline li.h2 { padding-left: 14px; font-size: 14px; }
.doc .chapter + .chapter { margin-top: 48px; }

/* Print mode, and the browser's own print: the page alone, in the light theme. */

@media print {
  :root { color-scheme: light; }
  #devpage-nav { display: none; }
  body { display: block; }
}
.print #devpage-nav { display: none; }

.doc-title { color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 8px; }

/* Slides: each slide a 1920 × 1080 stage, scaled whole to the window. */

body.slides { display: block; background: var(--background); overflow: hidden; }
.deck .slide {
  position: absolute; top: 0; left: 0;
  width: 1920px; height: 1080px;
  transform-origin: 0 0;
  background: var(--background);
  display: none;
  overflow: hidden;
}
.deck .slide.shown { display: block; }
.slide-body { padding: 96px 128px; font-size: 48px; line-height: 1.4; }
.slide-body h1 { font-size: 104px; }
.slide-body h2 { font-size: 72px; }
.slide-body h3 { font-size: 56px; }
.slide-body pre code { font-size: 30px; }
.slide-body table { font-size: 34px; }
.slide-body .diagram { font-size: 28px; }
/* Widgets on a slide look as they do on a page, magnified for the stage. */
.slide-body :is(.callout, .tabs, .example, .filetree, .terminal, .kind-cards, .steps, .cards) { font-size: 16px; line-height: 1.5; zoom: 2.2; }
.slide-body :is(.callout, .tabs, .example, .filetree, .terminal, .kind-cards, .steps, .cards) :is(table, pre code) { font-size: 14px; }
.slide-body :is(.callout, .tabs, .example, .filetree, .terminal, .kind-cards, .steps, .cards) :is(.callout, .tabs, .example, .filetree, .terminal, .kind-cards, .steps, .cards) { zoom: 1; font-size: 16px; }
.slide-body .kind-cards { zoom: 1.7; margin: 0; }
.slide-body .example { zoom: 2; margin: 0; }
.slide-body .example .example-source code { font-size: 19px; }
/* A diagram fills the room it is given. */
.slide-body .diagram svg { width: 100%; height: auto; max-height: 760px; }
.slide-body .diagram { margin: 0; padding: 0; }

@media print {
  body.slides { background: none; overflow: visible; }
  .deck .slide {
    display: block; position: relative; transform: none !important;
  }
  .deck .slide:not(:last-child) { break-after: page; }
  body.slides, .deck { margin: 0; padding: 0; }
}

/* The words a search result matched, marked in its section where it lands
   until Escape or the next navigation: one yellow, half seen through, in
   both themes. */
mark.devpage-found {
  --found: color-mix(in srgb, #ffd60a 55%, transparent);
  background: var(--found);
  color: inherit;
  border-radius: 2px;
  box-shadow: 0 0 0 1px var(--found);
}

/* Comments: highlighted anchors, and threads beside the text on a wide page
   (each card level with its anchor) or, on narrow screens and decks, in a
   panel the reader opens. Never printed. */

mark.comment { background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; cursor: pointer; border-radius: 2px; }
#devpage-comments { flex-shrink: 0; font-size: 14px; line-height: 1.45; }
#devpage-comments:empty { display: none; }
#devpage-comments.beside { position: relative; width: 300px; margin: 56px 16px 0 0; }
#devpage-comments.beside > * { position: absolute; left: 0; right: 0; }
#devpage-comments:not(.beside) {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(360px, 100vw);
  overflow: auto; padding: 16px; z-index: 5; display: none;
  background: var(--background); border-left: 1px solid var(--border);
}
body.show-comments #devpage-comments:not(.beside):not(:empty) { display: block; }
#devpage-comments-toggle { position: fixed; right: 16px; bottom: 16px; z-index: 6; display: none; }
#devpage-comments-toggle.shown { display: block; }
:fullscreen #devpage-comments-toggle { display: none; }
#devpage-comments .thread { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; background: var(--surface); }
#devpage-comments .composer { border-color: var(--accent); }
#devpage-comments blockquote { margin: 0 0 6px; padding: 0 0 0 8px; background: none; border-left: 3px solid var(--accent); color: var(--muted); max-height: 4.4em; overflow: hidden; }
#devpage-comments p { margin: 4px 0; overflow-wrap: anywhere; }
#devpage-comments time { color: var(--muted); font-size: 12px; }
#devpage-comments h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.comment-editor textarea { width: 100%; margin: 6px 0 2px; font: inherit; color: inherit; background: var(--background); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; resize: vertical; }
.comment-editor button { margin: 4px 6px 0 0; }
.comment-error { color: #d70015; font-size: 13px; }
.comment-error:empty { display: none; }
.comment-button, #devpage-comments-toggle, .comment-editor button { font: 13px var(--font); border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 6px; padding: 3px 9px; cursor: pointer; z-index: 4; }
.comment-button { display: inline-flex; align-items: center; gap: 6px; }
.comment-button.comment-icon { width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 50%; color: var(--muted); background: var(--background); box-shadow: 0 2px 8px -4px color-mix(in srgb, var(--text) 35%, transparent); transition: color 0.15s, border-color 0.15s; }
.comment-button.comment-icon:hover { color: var(--accent); border-color: var(--accent); }
@media print { #devpage-comments, #devpage-comments-toggle, .comment-button { display: none !important; } mark.comment { background: none; } }

/* Problems: broken links found while the page is previewed. */

.problems { max-width: 780px; margin: 0 auto 24px; border: 1px solid #d70015; border-radius: 10px; padding: 10px 14px; font-size: 14px; color: #d70015; }
.problems ul { margin: 4px 0 0; padding-left: 18px; }
a.broken { color: #d70015; text-decoration: underline wavy #d70015; }
img.broken { outline: 2px dashed #d70015; }
.diagram a.broken rect, .diagram a.broken polygon, .diagram a.broken circle, .diagram a.broken ellipse, .diagram a.broken path { stroke: #d70015; stroke-dasharray: 6 4; }
body.slides .problems { position: fixed; top: 8px; left: 8px; right: 8px; z-index: 3; background: var(--background); }
@media print { .problems { display: none; } }
/* Soft shadows are left out on paper: PDF viewers draw Chrome's blurred
   shadows as grey boxes. */
@media print { * { box-shadow: none !important; } }
@media print { h1, h2, h3 { break-after: avoid; } pre, .diagram, table { break-inside: avoid; } }

/* Designs: the canvas page fills the window; an embedded design sits at its
   own size, centred on a backdrop, with a link to its canvas page; an overlay
   sits over the design it dims; problems sit over the last valid drawing. */
body.design-page { margin: 0; height: 100vh; overflow: hidden; background: var(--surface); }
body.design-page > canvas.design { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; }
.design-embed { display: flex; justify-content: center; align-items: center; position: relative; margin: 24px 0; padding: 40px 24px; min-height: 120px; box-sizing: border-box; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.design-embed > canvas.design { display: block; flex: none; border-radius: 2px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 8px 28px rgb(0 0 0 / 0.08); }
/* The backdrop's corner: a themed design's own theme switch, then the link
   to its canvas page. */
.design-embed > .design-corner { position: absolute; top: 8px; right: 12px; z-index: 1; display: flex; align-items: center; gap: 4px; }
.design-embed a.design-open { padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--background); color: var(--muted); font: 500 12px/1.5 var(--font); text-decoration: none; opacity: 0.85; transition: opacity 0.15s, color 0.15s; }
.design-embed a.design-open::after { content: " ↗"; }
.design-embed a.design-open:hover, .design-embed a.design-open:focus-visible { opacity: 1; color: var(--accent); }
@media print { .design-embed { padding: 16px; border-radius: 8px; } .design-embed > canvas.design { box-shadow: none; } .design-embed > .design-corner { display: none; } }
.design-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(15 23 42 / 0.4); }
.design-overlay.design-overlay-page { position: fixed; z-index: 2; }
.design-problems { position: absolute; top: 8px; left: 8px; right: 8px; z-index: 3; margin: 0; padding: 10px 14px 10px 32px; border: 1px solid #d70015; border-radius: 10px; background: var(--background); color: #d70015; font: 13px var(--font-mono); }
/* On the canvas page the light/dark switch holds the top-right corner; the
   bars stop short of it. */
body.design-page > .design-problems { position: fixed; right: 60px; }
.design-failed { margin: 0; padding: 10px 14px; border: 1px solid #d70015; border-radius: 10px; background: var(--background); color: #d70015; font: 13px var(--font-mono); }
body.design-page > .design-failed { position: fixed; top: 8px; left: 8px; right: 60px; z-index: 3; }

/* ---- Widgets ---------------------------------------------------------- */
.callout { display: block; margin: 1rem 0; padding: 0.75rem 1rem; border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 6px; }
.callout-warning { border-left-color: #d29922; }
.callout-danger { border-left-color: #cf222e; }
.callout-tip { border-left-color: #1a7f37; }
.callout-head { display: flex; gap: 0.5rem; align-items: center; }
.callout-icon { font-weight: bold; }
.callout-body > :first-child { margin-top: 0.25rem; }
.callout-body > :last-child { margin-bottom: 0; }
.tabs { margin: 1rem 0 20px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.tabs-bar { display: flex; border-bottom: 1px solid var(--border); }
.tabs-bar button { background: none; border: 0; padding: 0.5rem 1rem; color: inherit; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs-bar button.current { border-bottom-color: var(--accent); font-weight: 600; }
.tabs-panel { padding: 16px; }
.tabs-panel > .tab > :first-child, .tabs-panel > :first-child { margin-top: 0; }
.tabs-panel > .tab > :last-child, .tabs-panel > :last-child { margin-bottom: 0; }
.example { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin: 1rem 0; }
/* Grid items may shrink below their content, so a long source line scrolls
   inside its box instead of widening the page. */
.example > * { min-width: 0; }
.example figcaption { grid-column: 1 / -1; font-weight: 600; }
.example-source { margin: 0; }
.example-result { border: 1px solid var(--border); border-radius: 6px; padding: 0 1rem; }
@media (max-width: 800px) { .example { grid-template-columns: minmax(0, 1fr); } }
.filetree ul { list-style: none; padding-left: 1.25rem; margin: 0; }
.filetree > ul { padding-left: 0; }
.filetree { font-family: var(--font-mono); margin: 1rem 0; }
.filetree-icon { display: inline-block; width: 1rem; color: var(--muted); }
.filetree-note { margin-left: 0.75rem; color: var(--muted); font-family: var(--font); }
.terminal { margin: 1rem 0; border-radius: 8px; overflow: hidden; background: #1e1e1e; color: #e6e6e6; }
.terminal figcaption { padding: 0.35rem 0.75rem; background: #333; font-size: 0.8rem; }
.terminal pre { margin: 0; background: none; color: inherit; overflow-x: auto; }
.terminal pre > div { min-height: 1.5em; }
@media print {
  /* Paper can't scroll: long lines wrap. */
  .terminal pre, .example-source { white-space: pre-wrap; overflow-wrap: anywhere; }
}
/* A task list item shows its checkbox, not a bullet as well. */
li:has(> input[type="checkbox"]), li:has(> p > input[type="checkbox"]) { list-style: none; }
li > input[type="checkbox"], li > p > input[type="checkbox"] { margin: 0 0.4em 0 -1.3em; }
.terminal-prompt { color: #7ee787; }
kbd { display: inline-block; min-width: 1.4em; padding: 0 0.35em; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; font: inherit; font-size: 0.85em; text-align: center; }
.keys kbd + kbd { margin-left: 0.2em; }
.widget-error { color: #cf222e; white-space: pre-wrap; }
div.widget-error { margin: 0 0 20px; }

/* Navbar: a site's bar across the top — its title, then its links, dropdowns
   and icons, then the theme selector. Translucent, like the page under it. */

body.with-navbar { flex-wrap: wrap; align-content: flex-start; }
#devpage-navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  flex: 0 0 100%;
  height: 52px;
  background: color-mix(in srgb, var(--background) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.navbar-inner { height: 100%; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 24px; }
.navbar-title { font-size: 17px; font-weight: 650; letter-spacing: -0.015em; color: var(--text); white-space: nowrap; }
.navbar-title:hover { text-decoration: none; opacity: 0.8; }
/* A document's logo, before its title: sized to the title's line and centred on it. */
.navbar-title { display: inline-flex; align-items: center; gap: 9px; }
#devpage-nav .document-title { display: flex; align-items: center; gap: 9px; }
.navbar-title .logo { width: 22px; height: 22px; flex: none; }
#devpage-nav .document-title .logo { width: 20px; height: 20px; flex: none; }
.navbar-links { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.navbar-link, .navbar-entry {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 8px;
  color: var(--muted); font: 500 14px/1.2 var(--font); white-space: nowrap;
  background: none; border: 0; cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.navbar-link:hover, .navbar-entry:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.navbar-link.current, .navbar-menu.current > .navbar-link { color: var(--text); font-weight: 600; }
.navbar-link.icon-only { padding: 6px; }
.icon { width: 16px; height: 16px; flex: none; }
.navbar-link .icon:last-child:not(:first-child) { width: 13px; height: 13px; opacity: 0.6; transition: transform 0.2s; }
.navbar-menu { position: relative; }
.navbar-menu.open > .navbar-link .icon:last-child:not(:first-child) { transform: rotate(180deg); }
.navbar-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; min-width: 220px; padding: 6px;
  background: var(--background); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 16px 40px -12px color-mix(in srgb, var(--text) 30%, transparent);
}
.navbar-menu.open .navbar-dropdown { display: grid; gap: 2px; }
.navbar-entry { color: var(--text); padding: 8px 10px; }
.navbar-entry .icon { color: var(--muted); }
.navbar-entry.current { background: var(--surface); font-weight: 600; }
.navbar-end { display: flex; align-items: center; gap: 8px; padding-left: 12px; margin-left: 4px; border-left: 1px solid var(--border); height: 24px; }
.navbar-toggle { display: none; background: none; border: 0; color: var(--text); padding: 6px; border-radius: 8px; cursor: pointer; }
.navbar-toggle:hover { background: var(--surface); }

body.with-navbar #devpage-nav { top: 52px; height: calc(100vh - 52px); }

@media (max-width: 760px) {
  .navbar-inner { padding: 0 8px 0 20px; }
  .navbar-end { margin-left: auto; border-left: 0; padding-left: 0; }
  .navbar-toggle { display: inline-flex; }
  .navbar-links {
    display: none; position: absolute; top: 52px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 12px 14px;
    background: var(--background); border-bottom: 1px solid var(--border);
    box-shadow: 0 16px 30px -20px color-mix(in srgb, var(--text) 40%, transparent);
  }
  #devpage-navbar.open .navbar-links { display: flex; }
  .navbar-link, .navbar-entry { font-size: 16px; padding: 10px 12px; }
  .navbar-link.icon-only::after { content: attr(title); }
  .navbar-menu > .navbar-link { width: 100%; }
  .navbar-dropdown { display: grid; position: static; box-shadow: none; border: 0; padding: 0 0 0 14px; min-width: 0; }
  .navbar-menu > .navbar-link .icon:last-child:not(:first-child) { display: none; }
}

/* The theme selector: one quiet icon button, the size of the navbar's icons,
   showing the theme a click switches to — a moon in light, a sun in dark. In
   the navbar when a site has one, else in the top-right corner. Never printed;
   a deck hides it in fullscreen. */

.theme-toggle, .comment-mode, .design-theme {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer; transition: color 0.15s, background 0.15s;
}
.theme-toggle:hover, .comment-mode:hover { color: var(--text); background: var(--surface); }
/* An embed's own switch sits on the backdrop, which is the surface. */
.design-theme:hover { background: var(--background); }
.design-theme[hidden] { display: none; }
/* Comment mode, pressed: the accent, on a tint of it. */
.comment-mode[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
#devpage-corner { display: flex; gap: 4px; }
.theme-toggle span, .design-theme span { display: inline-flex; }
.theme-toggle .to-light, :root[data-theme="dark"] .theme-toggle .to-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .to-light { display: inline-flex; }
/* An embed's switch shows the theme a click turns it to: its own theme's
   once turned, else the page's. */
.design-theme .to-light, :root[data-theme="dark"] .design-theme .to-dark, .design-embed[data-theme="dark"] .design-theme .to-dark { display: none; }
:root[data-theme="dark"] .design-theme .to-light, .design-embed[data-theme="dark"] .design-theme .to-light { display: inline-flex; }
.design-embed[data-theme="light"] .design-theme .to-dark { display: inline-flex; }
.design-embed[data-theme="light"] .design-theme .to-light { display: none; }
#devpage-corner { position: fixed; top: 14px; right: 16px; z-index: 15; }
:root:fullscreen #devpage-corner, .print #devpage-corner { display: none; }
@media print { #devpage-navbar, #devpage-corner { display: none !important; } body.with-navbar #devpage-nav { top: 0; } }

/* Steps: numbered steps joined by a line, each a title, a body and commands. */
.steps { list-style: none; margin: 1.5rem 0 20px; padding: 0; }
.step { position: relative; display: grid; grid-template-columns: 2rem minmax(0, 1fr); column-gap: 1rem; padding-bottom: 1.75rem; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ""; position: absolute; left: calc(1rem - 1px); top: 2.5rem; bottom: 0.5rem; width: 2px; border-radius: 1px; background: var(--border); }
.step:last-child::before { display: none; }
.step-number { width: 2rem; height: 2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--background)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.step-content { min-width: 0; padding-top: 0.2rem; }
.step-title { font-weight: 600; font-size: 1.05rem; line-height: 1.6; }
.step-content > p { margin: 0.2rem 0 0; }
.step-block > :first-child { margin-top: 0.6rem; }
.step-block > :last-child { margin-bottom: 0; }
.step-commands { display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem; margin-top: 0.6rem; max-width: 100%; }
.step-command { display: block; max-width: 100%; overflow-x: auto; white-space: pre; font: 0.85rem/1.5 var(--font-mono); padding: 0.4rem 0.8rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.step-prompt { color: var(--muted); margin-right: 0.6rem; user-select: none; }

/* Cards: a grid of link cards, each an optional icon, a title and a summary. */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin: 1.5rem 0 20px; }
@media (max-width: 700px) { .cards.cards-fixed { grid-template-columns: minmax(0, 1fr) !important; } }
.card { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; padding: 1.1rem 1.25rem 1.2rem; border: 1px solid var(--border); border-radius: 14px; background: var(--background); color: inherit; transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
a.card:hover { text-decoration: none; transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: 0 12px 28px -16px color-mix(in srgb, var(--text) 40%, transparent); }
.card-icon { display: flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; margin-bottom: 0.45rem; border-radius: 10px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--background)); }
.card-icon .icon { width: 1.2rem; height: 1.2rem; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 1.05rem; font-weight: 600; color: var(--text); }
.card-arrow { color: var(--accent); opacity: 0; transform: translateX(-4px); transition: opacity 0.2s ease, transform 0.2s ease; }
a.card:hover .card-arrow { opacity: 1; transform: none; }
.card-summary { font-size: 0.92rem; line-height: 1.5; color: var(--muted); }
@media print { .card, .step { break-inside: avoid; } .card-arrow { display: none; } a.card { transform: none; box-shadow: none; } }