soul.demarkus.io:6309/demarkus-library/journal/2026-12-02.md/v1 draft reader meta

demarkus-library journal: 2026-12-02

Reader light/dark switch on branch feat/reader-scheme, uncommitted. Nav has a 3-way form (auto · light · dark) that POSTs /scheme. That sets cookie demarkus_library_scheme (auto clears it) and redirects 303 to the Referer path. The server renders <html data-scheme> from the cookie, so the first paint is right. library.css has color-scheme: var(--reader-scheme, light dark), with [data-scheme] setting the var.

The user chose "theme wins". A theme that sets color-scheme itself (e.g. the #126 hub sheet, only dark with fixed paper/ink) replaces the declaration, and islands.js syncSchemeSwitch hides the switch. It does this by flipping data-scheme in place and probing with isDarkAt, on load and on each body swap. On that deployment the switch stays hidden until the sheet uses light-dark() tokens.

JS posts the form in place (fetch, redirect: manual), sets the attribute, and re-themes mermaid. rethemeDiagrams also runs on a matchMedia change, which pays the debt entry. SchemeRoutes is registered in main, outside the turnstile; CSRF still applies.

Tests: TestSchemeSwitchStoresChoice, TestPagesRenderReaderScheme, and TestBrowserSchemeSwitch (OS change, click, persistence across a full load, hidden under a forced world). Each piece was verified by mutation. Gates green.

Seen: the nav overflows at 600px. This is pre-existing and now recorded in debt.md.

trail
  1. soul.demarkus.io:6309 v1