Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add a three-state theme preference with a pre-paint boot script and tests

Bitti3d6afc9ea21b
diff --git a/index.html b/index.html
index ad609d2..898d848 100644
--- a/index.html
+++ b/index.html
@@ -6,6 +6,12 @@
<meta name="theme-color" content="#080a0f" />
<meta name="description" content="PolStudio — an agentic video creation workspace." />
<title>PolStudio</title>
+ <!-- Parser-blocking on purpose: it paints the saved theme's ground before
+ anything reaches the screen, so a light-theme user never sees the dark
+ window flash through. Must stay a classic same-origin script — the
+ app's CSP forbids inline script, and a module would be deferred past
+ the first paint. See public/theme-boot.js. -->
+ <script src="/theme-boot.js"></script>
</head>
<body>
<div id="root"></div>
diff --git a/public/theme-boot.js b/public/theme-boot.js
new file mode 100644
index 0000000..f65eaec
--- /dev/null
+++ b/public/theme-boot.js
@@ -0,0 +1,40 @@
+/* Applies the saved theme BEFORE the first paint.
+ *
+ * Why a separate file rather than an inline <script> in index.html: the app's
+ * CSP (src-tauri/tauri.conf.json) is `script-src 'self'` with no
+ * 'unsafe-inline', so an inline snippet silently does nothing inside the
+ * desktop app and every light-theme user gets a black flash on launch. A
+ * same-origin file satisfies 'self'.
+ *
+ * Why a CLASSIC script and not a module: <script type="module"> is deferred,
+ * which is after the first paint. A plain <script src> in <head> blocks the
+ * parser, so this runs before anything is on screen.
+ *
+ * It writes the same attribute and ground colour that src/lib/theme.ts writes,
+ * and deliberately duplicates the storage key and the two --bg values, because
+ * nothing here may depend on the bundle having loaded. theme.test.ts pins both
+ * copies against tokens.css so they cannot drift apart in silence.
+ */
+(function () {
+ var GROUND = { dark: "#080a0f", light: "#eef1f6" };
+ var choice = "system";
+ try {
+ var stored = localStorage.getItem("polstudio.theme.v1");
+ if (stored === "light" || stored === "dark" || stored === "system") choice = stored;
+ } catch (error) {
+ /* Private mode, or storage disabled: fall through to following the OS. */
+ }
+
+ var root = document.documentElement;
+ if (choice === "system") root.removeAttribute("data-theme");
+ else root.setAttribute("data-theme", choice);
+
+ var resolved = choice;
+ if (choice === "system") {
+ resolved =
+ typeof matchMedia === "function" && matchMedia("(prefers-color-scheme: light)").matches
+ ? "light"
+ : "dark";
+ }
+ root.style.backgroundColor = GROUND[resolved];
+})();
diff --git a/src/components/SettingsView.tsx b/src/components/SettingsView.tsx
index 3785c08..7bb13df 100644
--- a/src/components/SettingsView.tsx
+++ b/src/components/SettingsView.tsx
@@ -1,4 +1,4 @@
-import { AlertCircle, Check, FolderSearch, RotateCcw, X } from "lucide-react";
+import { AlertCircle, Check, FolderSearch, Monitor, Moon, RotateCcw, Sun, X } from "lucide-react";
import { useCallback, useEffect, useState } from "react";
import { isTauri } from "../lib/persistence";
import { chooseEnginePath, getEngineStatus, type ModelStatus, type VidfabStatus } from "../lib/runtime";
@@ -7,6 +7,10 @@ import {
loadEngineSettings, saveEngineSettings,
type EnginePathField, type EnginePathId, type EngineSettings,
} from "../lib/settings";
+import {
+ applyTheme, loadTheme, saveTheme, systemTheme, watchSystemTheme,
+ type ResolvedTheme, type ThemeChoice,
+} from "../lib/theme";
type PathState = "unset" | "checking" | "found" | "missing";
@@ -28,6 +32,60 @@ const stateLabel: Record<PathState, string> = {
missing: "Not found on disk",
};
+/* The system option has to say what the computer is currently set to, or
+ "Match this computer" is a promise the user cannot check. */
+const themeOptions: { id: ThemeChoice; label: string; icon: typeof Sun; detail: (system: ResolvedTheme) => string }[] = [
+ {
+ id: "system",
+ label: "Match this computer",
+ icon: Monitor,
+ detail: (system) => `Currently ${system}. Follows along when you change it.`,
+ },
+ { id: "light", label: "Light", icon: Sun, detail: () => "Always light, whatever this computer is set to." },
+ { id: "dark", label: "Dark", icon: Moon, detail: () => "Always dark, whatever this computer is set to." },
+];
+
+function AppearanceSetting() {
+ const [choice, setChoice] = useState<ThemeChoice>(loadTheme);
+ const [system, setSystem] = useState<ResolvedTheme>(systemTheme);
+
+ /* The app repaints itself through prefers-color-scheme; this listener only
+ keeps the "Currently dark/light" line honest while the screen is open. */
+ useEffect(() => watchSystemTheme(setSystem), []);
+
+ const pick = (next: ThemeChoice) => {
+ setChoice(next);
+ saveTheme(next);
+ applyTheme(next);
+ };
+
+ return (
+ <div className="theme-choice" role="radiogroup" aria-labelledby="appearance-heading">
+ {themeOptions.map((option) => {
+ const Icon = option.icon;
+ const selected = choice === option.id;
+ return (
+ <label
+ key={option.id}
+ className={`theme-choice__option${selected ? " theme-choice__option--selected" : ""}`}
+ >
+ <input
+ type="radio"
+ name="polstudio-theme"
+ value={option.id}
+ checked={selected}
+ onChange={() => pick(option.id)}
+ />
+ <Icon size={18} aria-hidden="true" />
+ <b>{option.label}</b>
+ <small>{option.detail(system)}</small>
+ </label>
+ );
+ })}
+ </div>
+ );
+}
+
export function SettingsView({ onClose }: { onClose: () => void }) {
const [settings, setSettings] = useState<EngineSettings>(() => loadEngineSettings());
const [status, setStatus] = useState<VidfabStatus | null>(null);
@@ -85,24 +143,33 @@ export function SettingsView({ onClose }: { onClose: () => void }) {
<header className="settings-view__head">
<div>
<p className="eyebrow">Settings</p>
- <h1 id="settings-heading">Video engine</h1>
+ <h1 id="settings-heading">This computer</h1>
</div>
<button className="icon-button icon-button--strong" onClick={onClose} aria-label="Close settings"><X size={18} /></button>
</header>
<p className="settings-view__lead">
- PolStudio needs the model files to render a shot. Where they live is a property of this
- computer, not of a project, so the paths are remembered here and used by every project you
- open. The engine itself ships with the app and needs no setting.
+ Everything here belongs to this computer rather than to a project, so it stays behind when
+ you copy a project folder somewhere else and it applies to every project you open.
</p>
- <div className={`settings-status settings-status--${status?.state ?? "checking"}`} role="status">
- <span><i />{engineHeadline(status, desktop)}</span>
- <p>{engineDetail(status, desktop, missing.length)}</p>
- </div>
+ <section className="settings-section" aria-labelledby="appearance-heading">
+ <h2 id="appearance-heading">Appearance</h2>
+ <AppearanceSetting />
+ </section>
<section className="settings-section" aria-labelledby="paths-heading">
- <h2 id="paths-heading">Model weights</h2>
+ <h2 id="paths-heading">Video engine</h2>
+ <p className="settings-section__note">
+ PolStudio needs the model files to render a shot. Where they live is a property of this
+ computer, not of a project, so the paths are remembered here and used by every project
+ you open. The engine itself ships with the app and needs no setting.
+ </p>
+
+ <div className={`settings-status settings-status--${status?.state ?? "checking"}`} role="status">
+ <span><i />{engineHeadline(status, desktop)}</span>
+ <p>{engineDetail(status, desktop, missing.length)}</p>
+ </div>
{ENGINE_PATH_FIELDS.map((field) => {
const value = settings[field.id];
const state = pathState(field, value, status);
diff --git a/src/lib/node-builtins.d.ts b/src/lib/node-builtins.d.ts
new file mode 100644
index 0000000..331f580
--- /dev/null
+++ b/src/lib/node-builtins.d.ts
@@ -0,0 +1,13 @@
+/* PolStudio ships a browser bundle, so @types/node is deliberately NOT a
+ dependency: pulling it in would let application code reach for `process`,
+ `Buffer` and `fs` and still type-check, and none of those exist inside the
+ Tauri webview.
+
+ theme.test.ts nevertheless has to read the stylesheets it is asserting
+ about — Vitest stubs `*.css?raw` to an empty string (test.css defaults to
+ false), so an import cannot do it, and jsdom implements no cascade, so
+ getComputedStyle cannot either. Declaring the single function that test
+ needs keeps the reach into Node exactly that wide. */
+declare module "node:fs" {
+ export function readFileSync(path: string | URL, encoding: "utf8"): string;
+}
diff --git a/src/lib/settings.ts b/src/lib/settings.ts
index ef21d0c..fe68577 100644
--- a/src/lib/settings.ts
+++ b/src/lib/settings.ts
@@ -16,6 +16,10 @@ import type { ProjectConfig, ProviderSetting } from "./project";
// Type-only: erased at build time, so this does not close a cycle with runtime.ts.
import type { ProviderId } from "./runtime";
+/* Light/dark appearance is machine-level for the same reason and lives in
+ * ./theme.ts, which is separate only because index.html has to read the same
+ * value from a classic script before the bundle exists. */
+
export type EnginePathId = "transformer" | "textEncoder" | "tokenizer" | "videoVae" | "audioVae";
export interface EnginePathField {
diff --git a/src/lib/theme.test.ts b/src/lib/theme.test.ts
new file mode 100644
index 0000000..1c947b0
--- /dev/null
+++ b/src/lib/theme.test.ts
@@ -0,0 +1,205 @@
+// @vitest-environment jsdom
+
+import { readFileSync } from "node:fs";
+import { beforeEach, describe, expect, it } from "vitest";
+import {
+ applyTheme, loadTheme, resolveTheme, saveTheme, systemTheme,
+ THEME_BACKGROUND, THEME_KEY, watchSystemTheme,
+} from "./theme";
+
+/* The stylesheets are read as TEXT, not applied. jsdom implements no cascade
+ and no custom-property resolution, so the only way to prove the palette holds
+ together is to read what is actually in the file. `?raw` cannot do it either:
+ Vitest stubs every CSS request to an empty string unless test.css is on.
+
+ Paths are relative to the project root because that is where Vitest runs;
+ a file:// URL would be resolved by jsdom's URL rather than Node's and comes
+ back as a path that does not exist.
+
+ The repo checks out with CRLF on Windows, so everything is normalised first
+ or the selector searches silently find nothing. */
+const read = (fromProjectRoot: string) =>
+ readFileSync(fromProjectRoot, "utf8").replace(/\r\n/g, "\n");
+
+/* Comments are stripped before anything is parsed. tokens.css documents its own
+ contrast ratios in prose like "--accent is 4.2:1 on --panel: borders only",
+ and a declaration scanner that trusts prose reads that colon as a declaration
+ and swallows the real --accent that follows it. */
+const readCss = (fromProjectRoot: string) =>
+ read(fromProjectRoot).replace(/\/\*[\s\S]*?\*\//g, "");
+
+/* jsdom's matchMedia is not implemented at all, so every test that cares about
+ the OS setting installs its own. `light` is what the query asks for, mirroring
+ `(prefers-color-scheme: light)` in tokens.css. */
+function stubMatchMedia(light: boolean) {
+ const listeners = new Set<() => void>();
+ const query = {
+ matches: light,
+ media: "(prefers-color-scheme: light)",
+ addEventListener: (_: string, handler: () => void) => listeners.add(handler),
+ removeEventListener: (_: string, handler: () => void) => listeners.delete(handler),
+ addListener: (handler: () => void) => listeners.add(handler),
+ removeListener: (handler: () => void) => listeners.delete(handler),
+ };
+ Object.defineProperty(window, "matchMedia", { configurable: true, writable: true, value: () => query });
+ return {
+ flipTo(next: boolean) {
+ query.matches = next;
+ for (const handler of listeners) handler();
+ },
+ listenerCount: () => listeners.size,
+ };
+}
+
+describe("theme preference", () => {
+ beforeEach(() => {
+ localStorage.clear();
+ document.documentElement.removeAttribute("data-theme");
+ document.documentElement.style.backgroundColor = "";
+ stubMatchMedia(false);
+ });
+
+ it("defaults to system and refuses anything it does not recognise", () => {
+ expect(loadTheme()).toBe("system");
+ localStorage.setItem(THEME_KEY, "sepia");
+ expect(loadTheme()).toBe("system");
+ saveTheme("light");
+ expect(loadTheme()).toBe("light");
+ });
+
+ it("writes an attribute for an explicit choice and none at all for system", () => {
+ expect(applyTheme("light")).toBe("light");
+ expect(document.documentElement.getAttribute("data-theme")).toBe("light");
+
+ expect(applyTheme("dark")).toBe("dark");
+ expect(document.documentElement.getAttribute("data-theme")).toBe("dark");
+
+ /* No attribute is the point: it hands the decision back to the media query
+ so the OS can flip it live without JavaScript. */
+ applyTheme("system");
+ expect(document.documentElement.hasAttribute("data-theme")).toBe(false);
+ });
+
+ it("resolves system against the computer, in both directions", () => {
+ stubMatchMedia(true);
+ expect(systemTheme()).toBe("light");
+ expect(resolveTheme("system")).toBe("light");
+ expect(resolveTheme("dark")).toBe("dark"); /* explicit beats the OS */
+
+ stubMatchMedia(false);
+ expect(systemTheme()).toBe("dark");
+ expect(resolveTheme("light")).toBe("light"); /* and in the other direction */
+ });
+
+ it("repaints the document ground so a stale inline colour cannot outlive a switch", () => {
+ stubMatchMedia(true);
+ applyTheme("system");
+ expect(document.documentElement.style.backgroundColor).toBe("rgb(238, 241, 246)");
+ applyTheme("dark");
+ expect(document.documentElement.style.backgroundColor).toBe("rgb(8, 10, 15)");
+ });
+
+ it("reports OS changes and unsubscribes cleanly", () => {
+ const media = stubMatchMedia(false);
+ const seen: string[] = [];
+ const stop = watchSystemTheme((theme) => seen.push(theme));
+ media.flipTo(true);
+ media.flipTo(false);
+ expect(seen).toEqual(["light", "dark"]);
+ stop();
+ expect(media.listenerCount()).toBe(0);
+ });
+});
+
+/* --- The stylesheet is the other half of the contract ---------------------- */
+
+/** Everything between a selector and its matching close brace. */
+function block(css: string, selector: string): string {
+ const start = css.indexOf(selector);
+ if (start < 0) throw new Error(`no such selector: ${selector}`);
+ let depth = 0;
+ for (let i = css.indexOf("{", start); i < css.length; i += 1) {
+ if (css[i] === "{") depth += 1;
+ else if (css[i] === "}") {
+ depth -= 1;
+ if (depth === 0) return css.slice(css.indexOf("{", start) + 1, i);
+ }
+ }
+ throw new Error(`unterminated block: ${selector}`);
+}
+
+const declarations = (css: string): Map<string, string> => {
+ const found = new Map<string, string>();
+ for (const match of css.matchAll(/(--[a-z0-9-]+)\s*:\s*([^;]+);/g)) {
+ found.set(match[1], match[2].trim().replace(/\s+/g, " "));
+ }
+ return found;
+};
+
+describe("tokens.css", () => {
+ const css = readCss("src/styles/tokens.css");
+ const dark = declarations(block(css, "\n:root {"));
+ const mediaLight = declarations(block(css, ':root:not([data-theme="dark"]) {'));
+ const explicitLight = declarations(block(css, ':root[data-theme="light"] {'));
+
+ it("guards the media block so an explicit dark choice beats a light computer", () => {
+ /* Drop this guard and picking Dark on a light-theme computer silently
+ repaints light: same specificity, and the media block wins on order. */
+ expect(css).toContain("@media (prefers-color-scheme: light)");
+ expect(css).toContain(':root:not([data-theme="dark"])');
+ });
+
+ it("never introduces a colour for the first time in a media or attribute block", () => {
+ /* This is the bug the whole structure exists to prevent: a token defined
+ only under light leaves dark painting with an unresolved var(), which
+ falls back to inherit/initial and puts one theme's ink on the other
+ theme's ground. */
+ const orphans = [...mediaLight.keys(), ...explicitLight.keys()].filter((name) => !dark.has(name));
+ expect(orphans).toEqual([]);
+ });
+
+ it("keeps the two light blocks identical", () => {
+ expect([...explicitLight.entries()].sort()).toEqual([...mediaLight.entries()].sort());
+ });
+
+ it("flips color-scheme with the palette so platform menus follow", () => {
+ /* Without this the <select> dropdown, the scrollbars and the caret stay
+ dark on a light page — chrome the stylesheet cannot reach. */
+ expect(block(css, "\n:root {")).toContain("color-scheme: dark");
+ expect(block(css, ':root:not([data-theme="dark"]) {')).toContain("color-scheme: light");
+ expect(block(css, ':root[data-theme="light"] {')).toContain("color-scheme: light");
+ });
+
+ it("agrees with the two copies of --bg that have to exist outside it", () => {
+ /* theme.ts and public/theme-boot.js both hard-code the grounds because they
+ run before any stylesheet is available. Drift shows up as a one-frame
+ flash of a colour that is in no palette, which nobody would ever notice
+ by looking. */
+ expect(dark.get("--bg")).toBe(THEME_BACKGROUND.dark);
+ expect(mediaLight.get("--bg")).toBe(THEME_BACKGROUND.light);
+
+ const boot = read("public/theme-boot.js");
+ expect(boot).toContain(`dark: "${THEME_BACKGROUND.dark}"`);
+ expect(boot).toContain(`light: "${THEME_BACKGROUND.light}"`);
+ expect(boot).toContain(THEME_KEY);
+ });
+});
+
+describe("every stylesheet resolves through the palette", () => {
+ const sheets = [
+ "base", "controls", "shell", "library", "workspace",
+ "generator", "timeline", "references", "export",
+ ];
+ const known = new Set(declarations(block(readCss("src/styles/tokens.css"), "\n:root {")).keys());
+ /* Declared locally by the sheet that uses them, not by the palette. */
+ const local = new Set(["--track-column", "--clip-color"]);
+
+ for (const name of sheets) {
+ it(`${name}.css uses no undefined token`, () => {
+ const css = readCss(`src/styles/${name}.css`);
+ const used = [...css.matchAll(/var\((--[a-z0-9-]+)/g)].map((match) => match[1]);
+ const missing = [...new Set(used)].filter((token) => !known.has(token) && !local.has(token));
+ expect(missing).toEqual([]);
+ });
+ }
+});
diff --git a/src/lib/theme.ts b/src/lib/theme.ts
new file mode 100644
index 0000000..c538bf8
--- /dev/null
+++ b/src/lib/theme.ts
@@ -0,0 +1,114 @@
+/* Light / dark appearance.
+ *
+ * Which theme this computer shows is a property of THIS computer and of the
+ * person sitting at it — not of a project. It therefore lives in localStorage
+ * next to the engine paths (see settings.ts for why machine-level settings
+ * never go into polstudio.json), and a project folder copied here from another
+ * machine does not bring somebody else's appearance with it.
+ *
+ * THREE states, not two:
+ *
+ * "system" follow the computer, LIVE. No attribute is written, so
+ * `@media (prefers-color-scheme: light)` in tokens.css does the
+ * work and an OS flip while the app is open repaints with no JS
+ * involved at all.
+ * "light" <html data-theme="light">
+ * "dark" <html data-theme="dark">
+ *
+ * An explicit choice beats the OS in BOTH directions. That is a property of
+ * the CSS, not of this file: the light rules are guarded by
+ * `:root:not([data-theme="dark"])`, so "dark" on a light computer really does
+ * fall back to the bare `:root` dark palette. Do not "simplify" that guard.
+ */
+
+export type ThemeChoice = "system" | "light" | "dark";
+
+/** What actually gets painted once the choice is resolved against the OS. */
+export type ResolvedTheme = "light" | "dark";
+
+export const THEME_KEY = "polstudio.theme.v1";
+
+export const THEME_CHOICES: readonly ThemeChoice[] = ["system", "light", "dark"];
+
+/* The two grounds, duplicated from tokens.css (--bg). They are needed BEFORE
+ any stylesheet exists — the boot snippet in index.html paints the document
+ with one of them so the window never flashes the other theme — so this is
+ the one place a raw colour is allowed outside tokens.css. Keep them in step
+ with `--bg`; the test in theme.test.ts reads tokens.css and fails if they
+ drift. */
+export const THEME_BACKGROUND: Record<ResolvedTheme, string> = {
+ dark: "#080a0f",
+ light: "#eef1f6",
+};
+
+const isChoice = (value: unknown): value is ThemeChoice =>
+ value === "system" || value === "light" || value === "dark";
+
+/** Anything unrecognised — a hand-edited entry, a value from a future version
+ * — reads as "system" rather than taking the whole app down. */
+export function loadTheme(): ThemeChoice {
+ try {
+ const value = localStorage.getItem(THEME_KEY);
+ return isChoice(value) ? value : "system";
+ } catch {
+ return "system";
+ }
+}
+
+export function saveTheme(choice: ThemeChoice): void {
+ try {
+ localStorage.setItem(THEME_KEY, choice);
+ } catch {
+ /* A full or disabled localStorage costs the preference next launch, not
+ the session: applyTheme has already repainted. */
+ }
+}
+
+/** What the computer itself is set to, right now. */
+export function systemTheme(): ResolvedTheme {
+ return typeof matchMedia === "function" && matchMedia("(prefers-color-scheme: light)").matches
+ ? "light"
+ : "dark";
+}
+
+export function resolveTheme(choice: ThemeChoice): ResolvedTheme {
+ return choice === "system" ? systemTheme() : choice;
+}
+
+/** Writes the choice onto <html> and repaints the document ground.
+ *
+ * The ground is set inline as well as by CSS because index.html sets it that
+ * way before the stylesheet has loaded; leaving a stale inline colour behind
+ * would out-specify the stylesheet and strand the old theme's background
+ * under the new theme's panels. */
+export function applyTheme(choice: ThemeChoice): ResolvedTheme {
+ const root = document.documentElement;
+ if (choice === "system") root.removeAttribute("data-theme");
+ else root.setAttribute("data-theme", choice);
+
+ const resolved = resolveTheme(choice);
+ root.style.backgroundColor = THEME_BACKGROUND[resolved];
+
+ const meta = document.querySelector('meta[name="theme-color"]');
+ if (meta) meta.setAttribute("content", THEME_BACKGROUND[resolved]);
+
+ return resolved;
+}
+
+/** Calls back whenever the COMPUTER's setting changes. Returns an unsubscribe.
+ * Only "system" needs it — the CSS repaints on its own, but the settings
+ * screen has to keep saying which one the computer is currently on, and the
+ * inline ground colour above has to be rewritten. */
+export function watchSystemTheme(onChange: (theme: ResolvedTheme) => void): () => void {
+ if (typeof matchMedia !== "function") return () => {};
+ const query = matchMedia("(prefers-color-scheme: light)");
+ const handler = () => onChange(query.matches ? "light" : "dark");
+ /* Safari below 14 only has the deprecated form; a desktop webview that lacks
+ addEventListener would otherwise throw on startup. */
+ if (typeof query.addEventListener === "function") {
+ query.addEventListener("change", handler);
+ return () => query.removeEventListener("change", handler);
+ }
+ query.addListener(handler);
+ return () => query.removeListener(handler);
+}
diff --git a/src/main.tsx b/src/main.tsx
index 1c754d5..6b039e8 100644
--- a/src/main.tsx
+++ b/src/main.tsx
@@ -1,8 +1,22 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
+import { applyTheme, loadTheme, watchSystemTheme } from "./lib/theme";
import "./styles/index.css";
+/* public/theme-boot.js already did this before the first paint; running it
+ again is idempotent and covers the paths where that file never ran (a test
+ renderer, a stripped index.html). */
+applyTheme(loadTheme());
+
+/* Only "system" needs watching, and only for the inline ground colour and the
+ theme-color meta — tokens.css repaints the app itself through
+ `@media (prefers-color-scheme)` with no JavaScript involved. The listener is
+ never torn down because it lives exactly as long as the window does. */
+watchSystemTheme(() => {
+ if (loadTheme() === "system") applyTheme("system");
+});
+
/* PolStudio is an application window, not a web page. The browser's own
context menu offers Back, Reload, View source and Inspect — none of which
mean anything here, and Reload throws away unsaved project edits. Text
diff --git a/src/styles/shell.css b/src/styles/shell.css
index 6a9b2a9..8731db3 100644
--- a/src/styles/shell.css
+++ b/src/styles/shell.css
@@ -283,6 +283,98 @@
letter-spacing: var(--tracking-tight);
}
+/* What a section is for, under its own heading rather than in one lead
+ paragraph that had to speak for every unrelated setting on the screen. */
+.settings-section__note {
+ max-width: 70ch;
+ margin: calc(var(--space-4) * -1) 0 var(--space-4);
+ color: var(--text-muted);
+ font-size: var(--text-sm);
+ line-height: var(--leading-normal);
+}
+
+.settings-section .settings-status {
+ margin-bottom: var(--space-2);
+}
+
+/* --- Appearance -------------------------------------------------------------
+ Three options, always all three visible: "system" is a real choice, not the
+ absence of one, and a two-state toggle cannot say so. */
+
+.theme-choice {
+ display: grid;
+ grid-template-columns: repeat(3, minmax(0, 1fr));
+ gap: var(--space-3);
+}
+
+.theme-choice__option {
+ min-height: var(--control-lg);
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr);
+ align-items: center;
+ gap: var(--space-1) var(--space-3);
+ padding: var(--space-4);
+ border: 1px solid var(--line-strong);
+ border-radius: var(--radius-lg);
+ color: var(--text-muted);
+ background: var(--wash-1);
+ cursor: pointer;
+ transition: 0.16s ease;
+}
+
+/* The radio still exists and still takes focus — it is only invisible, so the
+ arrow keys, the label click and the screen reader all keep working. The ring
+ is drawn on the card, which is what reads as the control. */
+.theme-choice__option input {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ opacity: 0;
+ pointer-events: none;
+}
+
+.theme-choice__option:has(input:focus-visible) {
+ outline: var(--focus-ring-width) solid var(--focus-ring-color);
+ outline-offset: 2px;
+}
+
+.theme-choice__option > svg {
+ grid-row: 1;
+ flex: 0 0 auto;
+}
+
+.theme-choice__option b {
+ grid-row: 1;
+ color: var(--text-primary);
+ font-size: var(--text-base);
+ font-weight: var(--weight-semibold);
+ line-height: var(--leading-snug);
+}
+
+.theme-choice__option small {
+ grid-column: 2;
+ grid-row: 2;
+ font-size: var(--text-xs);
+ line-height: var(--leading-normal);
+}
+
+.theme-choice__option:hover {
+ border-color: var(--line-hover);
+ color: var(--text-secondary);
+ background: var(--wash-2);
+}
+
+.theme-choice__option--selected,
+.theme-choice__option--selected:hover {
+ border-color: var(--accent);
+ color: var(--text-secondary);
+ background: var(--accent-soft);
+}
+
+.theme-choice__option--selected > svg {
+ color: var(--accent-bright);
+}
+
.settings-path {
padding: var(--space-4) 0;
border-top: 1px solid var(--line);
@@ -403,4 +495,8 @@
align-items: flex-start;
}
+ .theme-choice {
+ grid-template-columns: 1fr;
+ }
+
}