From 0dc48a137f907886d84046b06af596058994ac9b Mon Sep 17 00:00:00 2001 From: Andrew S Erwin Date: Wed, 28 Oct 2026 21:54:16 -0500 Subject: [PATCH] Dark-mode readability pass: soften the palette, bump the root type scale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A user reported dark mode (white-on-black) is harder to read than light mode. Root cause is halation, not size alone: the dark tokens ran 98% foreground on a 3.9%-lightness background (~19:1 contrast), and bright text on near-black visually bleeds — worst for astigmatic readers, and light-on-dark renders perceptually thinner at the same size. Palette (web/app/globals.css .dark tokens): background 3.9% -> 10%, foreground 98% -> 92% (body contrast ~13:1, still ~2x WCAG AAA), card/popover 6% -> 13%, sidebar 5.5% -> 8% (stays darker than content), secondary/muted/border/input 15.9% -> 19% so surface steps survive the lighter base; muted-foreground unchanged at ~7.4:1 (AAA). Type scale: html root 106.25% (16 -> 17px) — a global bump, so every rem-based text AND spacing scales proportionally in both themes. Deliberately not per-theme: a dark-only font size would reflow layouts on every theme toggle. Font-smoothing left untouched (the antialiased-off trick is a pre-Mojave artifact and risks blur). STYLE_GUIDE.md records both decisions, including a dark-theme readability rule (keep body copy ~11:1-14:1; never reintroduce pure white on <5% backgrounds) so future token work cannot silently undo this. Web lint/SSR-eslint/build clean. CI browser regressions are the gate to watch for the 6.25% global scale-up. --- web/STYLE_GUIDE.md | 12 ++++++++++++ web/app/globals.css | 36 ++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/web/STYLE_GUIDE.md b/web/STYLE_GUIDE.md index f4bed6c..0f5048d 100644 --- a/web/STYLE_GUIDE.md +++ b/web/STYLE_GUIDE.md @@ -22,6 +22,10 @@ The root layout, `app/layout.tsx`, is the single place for app-wide providers an **Size hierarchy:** Use Tailwind's scale. Headings: `text-4xl`→`text-3xl`→`text-2xl`→`text-xl`. Body: `text-base`→`text-sm`. Captions: `text-xs`. +The root font size is `106.25%` (17px) in `globals.css` — a deliberate global +bump; every rem-based size and spacing scales with it. Change it there only, +never per-theme (a per-theme font size reflows layouts on every toggle). + Always use `tracking-tight` on large headings (`text-2xl` and above). --- @@ -45,6 +49,14 @@ All colors use CSS variables — **never hardcode color values**. Usage: `bg-primary`, `text-muted-foreground`, `border-border`, etc. +**Dark-theme readability rule:** the `.dark` tokens target ~13:1 body-text +contrast, not maximum. The original near-black bg (3.9% lightness) with +near-white text (98%) measured ~19:1 and caused halation (bright-on-black +text visually bleeds, worst for astigmatic readers) — user-reported +2026-10-29. When adding dark tokens keep body copy between ~11:1 and 14:1 +(WCAG AAA is 7:1); never reintroduce pure `0 0% 100%` foreground on +`<5%` backgrounds. + --- ## Spacing Scale diff --git a/web/app/globals.css b/web/app/globals.css index 84831f7..fc8abc8 100644 --- a/web/app/globals.css +++ b/web/app/globals.css @@ -50,24 +50,28 @@ } .dark { - --background: 240 10% 3.9%; - --foreground: 0 0% 98%; - --card: 240 10% 6%; - --card-foreground: 0 0% 98%; - --popover: 240 10% 6%; - --popover-foreground: 0 0% 98%; + /* Readability pass (2026-10-29): the previous near-black bg (3.9%) with + near-white text (98%) hit ~19:1 contrast — halation made body text + bleed for a meaningful share of readers (esp. astigmatism). These + values land body copy at ~13:1, still far above WCAG AAA (7:1). */ + --background: 240 6% 10%; + --foreground: 0 0% 92%; + --card: 240 5% 13%; + --card-foreground: 0 0% 92%; + --popover: 240 5% 13%; + --popover-foreground: 0 0% 92%; --primary: 245 60% 60%; --primary-foreground: 0 0% 100%; - --secondary: 240 3.7% 15.9%; - --secondary-foreground: 0 0% 98%; - --muted: 240 3.7% 15.9%; + --secondary: 240 4% 19%; + --secondary-foreground: 0 0% 92%; + --muted: 240 4% 19%; --muted-foreground: 240 5% 64.9%; - --accent: 245 30% 18%; + --accent: 245 30% 20%; --accent-foreground: 245 60% 75%; --destructive: 0 62.8% 30.6%; --destructive-foreground: 0 0% 98%; - --border: 240 3.7% 15.9%; - --input: 240 3.7% 15.9%; + --border: 240 4% 19%; + --input: 240 4% 19%; --ring: 245 60% 60%; --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.15), 0 1px 2px -1px rgb(0 0 0 / 0.15); --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.2), 0 2px 4px -2px rgb(0 0 0 / 0.15); @@ -77,13 +81,17 @@ --chart-3: 30 80% 55%; --chart-4: 280 65% 60%; --chart-5: 340 75% 55%; - --sidebar: 240 10% 5.5%; + --sidebar: 240 6% 8%; --sidebar-foreground: 0 0% 85%; } } @layer base { - html { scroll-behavior: smooth; } + /* 17px root (106.25%): a modest global type bump — every rem-based size + and spacing scales proportionally in BOTH themes. Deliberately not + dark-mode-only: a per-theme font size would reflow layouts on every + theme toggle. */ + html { scroll-behavior: smooth; font-size: 106.25%; } * { border-color: hsl(var(--border)); } body { background-color: hsl(var(--background));