Skip to content

See how your app actually fits together. An interactive, plain-English map of your codebase, drawn by Claude or Codex.

Add a light theme and a Theme button (Auto, Light, Dark)

Menachem Kurkus843b45bedeee
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba59b2f..e38b0a4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## Unreleased
+
+- **Light mode:** a new **Theme** button in the top bar cycles **Auto → Light → Dark**. Auto follows your device's light or dark setting and changes with it. Your choice is remembered on this device, and the map shows the right colours from the first moment, with no flash. The button is a 44 px target, works from the keyboard with a visible focus ring, and the change is instant (nothing animates, so Reduce Motion is respected). Dark looks exactly as before.
+
## 0.2.1 (2026-10-28)
- **Firebase Cloud Functions:** callable (`onCall`) and `onRequest` functions now show up as endpoints, named the way your functions entry file exports them, and the website's `httpsCallable` calls and requests reach them, including through a helper of your own that wraps `httpsCallable`. So a React + Firebase app's website and server are connected on the map, Screens shows the server code behind each page, and Ask can follow the links. Callables are shown as `CALL /name`. Reported by @omardlr-aviv in #8.
diff --git a/docs/development.md b/docs/development.md
index 6b16c62..b4be09b 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -30,7 +30,7 @@ skills/floorplan/
lib/ extraction, import resolution, route matching, Health, screens, which agent is running, helpers
assets/
viewer.html the map (template the build fills in)
- ui/ viewer extensions: glossary, Health, recent work, screens, tour, waitlist card
+ ui/ viewer extensions: Theme button, glossary, Health, recent work, screens, tour, waitlist card
graph-query.js shared map lookups (viewer, query.mjs, Ask instructions)
serve.mjs copied into each project's floorplan/ folder; answers through Claude Code or Codex
query-cli.mjs becomes floorplan/query.mjs
diff --git a/skills/floorplan/assets/ui/05-theme.js b/skills/floorplan/assets/ui/05-theme.js
new file mode 100644
index 0000000..8693336
--- /dev/null
+++ b/skills/floorplan/assets/ui/05-theme.js
@@ -0,0 +1,54 @@
+// The Theme button: Auto (follows your device) -> Light -> Dark -> Auto. The choice is remembered on this
+// device. The theme itself is picked by a tiny script at the top of viewer.html, before anything is drawn,
+// so the page never flashes the wrong colours; this file only adds the button and keeps it in step.
+(() => {
+ const SC = window.Floorplan;
+ const T = window.floorplanTheme;
+ if (!SC || !T) return;
+
+ const ICON = {
+ auto: '<circle cx="12" cy="12" r="8"/><path d="M12 4a8 8 0 0 1 0 16z" fill="currentColor"/>',
+ light: '<circle cx="12" cy="12" r="4"/><path d="M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6 7 7M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"/>',
+ dark: '<path d="M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z"/>',
+ };
+ const NAME = { auto: 'Auto (follows your device)', light: 'Light', dark: 'Dark' };
+ const WORD = { auto: 'Auto', light: 'Light', dark: 'Dark' };
+ const NEXT = { auto: 'light', light: 'dark', dark: 'auto' };
+
+ const style = document.createElement('style');
+ style.textContent = `
+ /* a 44 px target; the round hover shape stays 36 px like the buttons beside it */
+ #theme-toggle { position: relative; flex: none; width: 44px; height: 44px; padding: 0; background: none; }
+ #theme-toggle::before { content: ""; position: absolute; inset: 4px; border-radius: 999px; transition: background .2s var(--ease); }
+ #theme-toggle:hover { background: none; }
+ #theme-toggle:hover::before { background: rgba(var(--ink), .07); }
+ #theme-toggle svg { position: relative; width: 18px; height: 18px; }
+ #theme-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: -3px; }
+ .theme-status { position: fixed; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
+ @media (prefers-reduced-motion: reduce) { #theme-toggle, #theme-toggle::before { transition: none; } #theme-toggle:active { transform: none; } }`;
+ document.head.appendChild(style);
+
+ // read out by screen readers when the theme changes
+ const status = document.createElement('span');
+ status.className = 'theme-status';
+ status.setAttribute('role', 'status');
+ document.body.appendChild(status);
+
+ const btn = SC.addHeaderButton({ id: 'theme-toggle', svg: ICON.auto, onClick: () => {
+ const next = NEXT[T.get()];
+ T.set(next);
+ status.textContent = `Theme is now ${next === 'auto' ? 'Auto, following your device' : WORD[next]}.`;
+ } });
+
+ const show = () => {
+ const c = T.get();
+ btn.querySelector('svg').innerHTML = ICON[c];
+ const text = `Theme: ${NAME[c]}. Press for ${WORD[NEXT[c]]}.`;
+ btn.title = text;
+ btn.setAttribute('aria-label', text);
+ };
+ // Enter and Space press this button; they must not also run the page's own "open the selected box" key
+ btn.addEventListener('keydown', (ev) => { if (ev.key === 'Enter' || ev.key === ' ') ev.stopPropagation(); });
+ window.addEventListener('floorplan-theme-change', show);
+ show();
+})();
diff --git a/skills/floorplan/assets/ui/10-glossary.js b/skills/floorplan/assets/ui/10-glossary.js
index 6026c5f..6a20228 100644
--- a/skills/floorplan/assets/ui/10-glossary.js
+++ b/skills/floorplan/assets/ui/10-glossary.js
@@ -138,7 +138,7 @@
const style = document.createElement('style');
style.textContent = `
.sc-term { pointer-events: auto; cursor: help; border-radius: 4px; text-decoration-line: underline; text-decoration-style: dotted; text-decoration-thickness: 1px; text-underline-offset: 3px;
- text-decoration-color: rgba(255, 255, 255, .32); text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); transition: text-decoration-color .2s var(--ease), color .2s var(--ease); }
+ text-decoration-color: rgba(var(--ink), .32); text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); transition: text-decoration-color .2s var(--ease), color .2s var(--ease); }
.sc-term:hover, .sc-term.on { text-decoration-color: currentColor; color: var(--text); }
.callout .sc-term:hover, .callout .sc-term.on { color: inherit; }
.sc-term:focus { outline: none; }
diff --git a/skills/floorplan/assets/ui/20-health.js b/skills/floorplan/assets/ui/20-health.js
index 3663032..443548c 100644
--- a/skills/floorplan/assets/ui/20-health.js
+++ b/skills/floorplan/assets/ui/20-health.js
@@ -9,9 +9,9 @@
const issues = (SC.graph.health && SC.graph.health.issues) || [];
const SEV = {
- high: { color: '#f28b8b', group: 'Fix these first', word: 'important' },
- medium: { color: '#f0c36b', group: 'Worth fixing soon', word: 'worth fixing' },
- low: { color: '#8b8b8b', group: 'Good to tidy up', word: 'minor' },
+ high: { color: 'var(--sev-high)', group: 'Fix these first', word: 'important' },
+ medium: { color: 'var(--sev-medium)', group: 'Worth fixing soon', word: 'worth fixing' },
+ low: { color: 'var(--sev-low)', group: 'Good to tidy up', word: 'minor' },
};
const ORDER = ['high', 'medium', 'low'];
const count = (sev) => issues.filter((i) => i.severity === sev).length;
@@ -22,7 +22,7 @@
const style = document.createElement('style');
style.textContent = `
- .hc-issue { padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, .04); margin-bottom: 8px; }
+ .hc-issue { padding: 12px 14px; border-radius: 16px; background: rgba(var(--ink), .04); margin-bottom: 8px; }
.hc-issue:last-child { margin-bottom: 0; }
.hc-t { display: flex; gap: 9px; align-items: flex-start; font-weight: 500; line-height: 1.4; }
.hc-t .dot { margin-top: 6px; }
@@ -32,11 +32,11 @@
.hc-a { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 0 17px; }
.hc-a .btn { height: 30px; padding: 0 12px; font-size: 12.5px; gap: 6px; }
.hc-a .btn svg.i { width: 14px; height: 14px; }
- .hc-calm { margin-top: 14px; padding: 11px 13px; border-radius: 14px; background: rgba(111, 215, 168, .08); color: #a9e5c9; font-size: 13px; line-height: 1.55; }
+ .hc-calm { margin-top: 14px; padding: 11px 13px; border-radius: 14px; background: var(--ok-bg); color: var(--ok-text); font-size: 13px; line-height: 1.55; }
.hc-sub { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; font-size: 12px; color: var(--text-2); }
.hc-sub span { display: inline-flex; align-items: center; gap: 6px; }
- #btn-health .badge { background: var(--hc-badge, #ececec); }
- #btn-health.calm svg.i { color: #6fd7a8; }
+ #btn-health .badge { background: var(--hc-badge, var(--on)); color: var(--hc-badge-text, var(--on-text)); }
+ #btn-health.calm svg.i { color: var(--ok); }
#modal .hc-hint { margin: 0; }
#modal .hc-hint b { color: var(--text); font-weight: 500; }
`;
@@ -86,7 +86,7 @@
function listHtml() {
const top = `<div class="sec">
- <div class="ph"><span class="ico" style="--c:${urgent ? SEV[count('high') ? 'high' : 'medium'].color : '#6fd7a8'}">${SC.icon('health')}</span><span class="kindlabel">Health check</span></div>
+ <div class="ph"><span class="ico" style="--c:${urgent ? SEV[count('high') ? 'high' : 'medium'].color : 'var(--ok)'}">${SC.icon('health')}</span><span class="kindlabel">Health check</span></div>
<h2 class="pt">${h(headline())}</h2>
<p class="pd">We looked for passwords and keys left in the code, parts of your app anyone on the internet can use, leftover files and files too big to edit safely.</p>
${issues.length ? breakdown() : `<div class="hc-calm">Nothing stood out. This is a quick automatic check, not a full security review.</div>`}
@@ -119,6 +119,7 @@
b.className = 'badge';
b.textContent = urgent > 99 ? '99+' : String(urgent);
btn.style.setProperty('--hc-badge', count('high') ? SEV.high.color : SEV.medium.color);
+ btn.style.setProperty('--hc-badge-text', 'var(--on-sev-text)');
btn.appendChild(b);
} else btn.classList.add('calm');
@@ -127,7 +128,7 @@
SC.addPanelSection('overview', () => ({
html: `<div class="sec"><h3>Health</h3><div class="list"><a class="row" data-hc-open>
- <span class="dot" style="background:${urgent ? SEV[count('high') ? 'high' : 'medium'].color : '#6fd7a8'}"></span>
+ <span class="dot" style="background:${urgent ? SEV[count('high') ? 'high' : 'medium'].color : 'var(--ok)'}"></span>
<span class="rt"><div class="rn">${h(headline())}</div><div class="rd">${issues.length ? ORDER.filter(count).map((s) => `${count(s)} ${SEV[s].word}`).join(' · ') : 'Quick automatic check of secrets, open endpoints and leftover files'}</div></span>
<span class="rc">${SC.iconI('right')}</span></a></div></div>`,
bind: (el) => el.querySelector('[data-hc-open]')?.addEventListener('click', (ev) => { ev.preventDefault(); openList(); }),
diff --git a/skills/floorplan/assets/ui/25-recent.js b/skills/floorplan/assets/ui/25-recent.js
index 02cb769..e960517 100644
--- a/skills/floorplan/assets/ui/25-recent.js
+++ b/skills/floorplan/assets/ui/25-recent.js
@@ -16,7 +16,7 @@
const style = document.createElement('style');
style.textContent = `
#btn-recent svg.i { color: var(--recent); }
- #btn-recent .badge { background: var(--recent); color: #0b1f12; }
+ #btn-recent .badge { background: var(--recent); color: var(--on-recent-text); }
.rw-task { padding: 12px 14px; border-radius: 16px; background: color-mix(in srgb, var(--recent) 6%, transparent); margin-bottom: 8px; }
.rw-task:last-child { margin-bottom: 0; }
.rw-tt { display: flex; gap: 9px; align-items: center; font-weight: 600; line-height: 1.4; }
diff --git a/skills/floorplan/assets/ui/30-screens.js b/skills/floorplan/assets/ui/30-screens.js
index bdd1d0f..b9df518 100644
--- a/skills/floorplan/assets/ui/30-screens.js
+++ b/skills/floorplan/assets/ui/30-screens.js
@@ -13,12 +13,12 @@
const style = document.createElement('style');
style.textContent = `
#sc-menu { position: fixed; width: 340px; max-height: min(70vh, 580px); overflow: auto; transform-origin: top right; overscroll-behavior: contain; }
-#sc-menu .sc-f { position: sticky; top: -6px; margin: -6px -6px 4px; padding: 10px 10px 6px; background: rgba(26, 26, 26, .94); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); z-index: 1; border-radius: 18px 18px 0 0; }
-#sc-menu .sc-f input { width: 100%; height: 34px; border: 0; border-radius: 12px; padding: 0 12px; background: rgba(255, 255, 255, .06); color: var(--text); outline: none; transition: background .2s var(--ease), box-shadow .2s var(--ease); }
-#sc-menu .sc-f input:focus { background: rgba(255, 255, 255, .08); box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
+#sc-menu .sc-f { position: sticky; top: -6px; margin: -6px -6px 4px; padding: 10px 10px 6px; background: var(--menu-solid); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); z-index: 1; border-radius: 18px 18px 0 0; }
+#sc-menu .sc-f input { width: 100%; height: 34px; border: 0; border-radius: 12px; padding: 0 12px; background: rgba(var(--ink), .06); color: var(--text); outline: none; transition: background .2s var(--ease), box-shadow .2s var(--ease); }
+#sc-menu .sc-f input:focus { background: rgba(var(--ink), .08); box-shadow: 0 0 0 1px rgba(var(--ink), .14); }
#sc-menu .sc-g { padding: 10px 12px 4px; font-size: 12px; color: var(--text-3); }
#sc-menu .sc-r { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text); padding: 9px 12px; border-radius: 12px; cursor: pointer; transition: background .15s var(--ease); }
-#sc-menu .sc-r:hover, #sc-menu .sc-r.on { background: rgba(255, 255, 255, .07); }
+#sc-menu .sc-r:hover, #sc-menu .sc-r.on { background: rgba(var(--ink), .07); }
#sc-menu .sc-r b { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sc-menu .sc-r span { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
#sc-menu .sc-none { padding: 14px 12px; color: var(--text-3); font-size: 12.5px; }
diff --git a/skills/floorplan/assets/ui/40-tour.js b/skills/floorplan/assets/ui/40-tour.js
index 2520ae9..37e34f2 100644
--- a/skills/floorplan/assets/ui/40-tour.js
+++ b/skills/floorplan/assets/ui/40-tour.js
@@ -19,8 +19,8 @@
#tour .tip { color: var(--text-3); font-size: 12px; line-height: 1.5; margin-top: 10px; }
#tour .tf { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
#tour .dots { display: flex; gap: 4px; flex: 1; }
-#tour .dots i { width: 14px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .12); transition: background .3s var(--ease); }
-#tour .dots i.on { background: #ececec; }
+#tour .dots i { width: 14px; height: 3px; border-radius: 2px; background: rgba(var(--ink), .12); transition: background .3s var(--ease); }
+#tour .dots i.on { background: var(--on); }
#tour .tf .btn { height: 32px; }
#tour .tf .btn.icon { width: 32px; }
#tour .tx { position: absolute; top: 10px; right: 10px; width: 28px; height: 28px; }
diff --git a/skills/floorplan/assets/ui/50-cloud.js b/skills/floorplan/assets/ui/50-cloud.js
index 83ecc90..72fed84 100644
--- a/skills/floorplan/assets/ui/50-cloud.js
+++ b/skills/floorplan/assets/ui/50-cloud.js
@@ -25,15 +25,15 @@
#cloud-card .cl { background: none; border: 0; padding: 0; color: var(--text-3); font: inherit; font-size: 12px; cursor: pointer; margin-left: auto; }
#cloud-card .cl:hover { color: var(--text-2); }
#cloud-card .co { display: grid; gap: 6px; margin-top: 12px; }
- #cloud-card .co button { text-align: left; border: 0; border-radius: 14px; padding: 10px 12px; background: rgba(255, 255, 255, .05); color: var(--text); cursor: pointer; font: inherit; transition: background .2s var(--ease); }
- #cloud-card .co button:hover { background: rgba(255, 255, 255, .1); }
+ #cloud-card .co button { text-align: left; border: 0; border-radius: 14px; padding: 10px 12px; background: rgba(var(--ink), .05); color: var(--text); cursor: pointer; font: inherit; transition: background .2s var(--ease); }
+ #cloud-card .co button:hover { background: rgba(var(--ink), .1); }
#cloud-card .co b { display: block; font-size: 13.5px; font-weight: 500; }
#cloud-card .co span { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; }
#cloud-card input { width: 100%; box-sizing: border-box; margin-top: 12px; height: 38px; padding: 0 12px; border-radius: var(--r-ctl); border: 1px solid var(--hair-2);
- background: rgba(0, 0, 0, .25); color: var(--text); font: inherit; font-size: 13.5px; outline: none; }
- #cloud-card input:focus { border-color: rgba(255, 255, 255, .3); }
+ background: var(--well); color: var(--text); font: inherit; font-size: 13.5px; outline: none; }
+ #cloud-card input:focus { border-color: rgba(var(--ink), .3); }
#cloud-card .cm { margin-top: 8px; font-size: 12px; color: var(--text-3); min-height: 0; }
- #cloud-card .cm.err { color: #f28b8b; }
+ #cloud-card .cm.err { color: var(--sev-high); }
#cloud-card .cf { margin-top: 12px; font-size: 11.5px; line-height: 1.5; color: var(--text-3); }
#cloud-card .cf a { color: var(--text-2); }
`;
diff --git a/skills/floorplan/assets/viewer.html b/skills/floorplan/assets/viewer.html
index 97ddd3d..09b856d 100644
--- a/skills/floorplan/assets/viewer.html
+++ b/skills/floorplan/assets/viewer.html
@@ -3,6 +3,29 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
+<script>
+/* Theme: runs before anything is drawn so the page never flashes the wrong colours. "auto" follows the device. */
+(() => {
+ const KEY = 'floorplan-theme', root = document.documentElement, mq = matchMedia('(prefers-color-scheme: light)');
+ let mem = 'auto';
+ const valid = (v) => v === 'auto' || v === 'light' || v === 'dark';
+ const get = () => { try { const v = localStorage.getItem(KEY); if (valid(v)) return v; } catch (e) {} return mem; };
+ const apply = () => {
+ const c = get();
+ root.setAttribute('data-theme', c === 'auto' ? (mq.matches ? 'light' : 'dark') : c);
+ window.dispatchEvent(new Event('floorplan-theme-change'));
+ };
+ apply();
+ if (mq.addEventListener) mq.addEventListener('change', apply); else if (mq.addListener) mq.addListener(apply);
+ addEventListener('storage', (e) => { if (e.key === KEY || e.key === null) apply(); }); // changed in another tab
+ window.floorplanTheme = { get, set: (c) => {
+ if (!valid(c)) return;
+ mem = c; try { localStorage.setItem(KEY, c); } catch (e) {}
+ root.classList.add('theme-switching'); apply();
+ requestAnimationFrame(() => requestAnimationFrame(() => root.classList.remove('theme-switching')));
+ } };
+})();
+</script>
<title>__FLOORPLAN_TITLE__</title>
<link rel="icon" type="image/png" href="__FLOORPLAN_FAVICON__">
<style>/*__FONTS__*/</style>
@@ -10,16 +33,27 @@
:root {
--sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
--mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
- --bg: #0f0f0f; --grid: #1f1f1f;
+ --bg: #0f0f0f; --bg-rgb: 15, 15, 15; --grid: #1f1f1f;
+ --ink: 255, 255, 255; /* the colour the page tints with: white on dark, black on light */
--surface: #191919; --surface-hover: #1e1e1e; --raise: #232323; --raise-2: #2b2b2b;
- --elev: rgba(26, 26, 26, .86); --hair: rgba(255, 255, 255, .06); --hair-2: rgba(255, 255, 255, .1);
+ --elev: rgba(26, 26, 26, .86); --hair: rgba(var(--ink), .06); --hair-2: rgba(var(--ink), .1);
--text: #ececec; --text-2: #b4b4b4; --text-3: #8b8b8b; --text-4: #5c5c5c;
- --recent: #4ade80;
- --ring: rgba(255, 255, 255, .88); --focus: rgba(255, 255, 255, .16);
+ --recent: #4ade80; --on-recent-text: #0b1f12;
+ --on: #ececec; --on-hover: #fff; --on-text: #0f0f0f; /* solid buttons, badges and dots */
+ --on-sev-text: #0f0f0f; /* text on a red or amber chip */
+ --ok: #6fd7a8; --sev-high: #f28b8b; --sev-medium: #f0c36b; --sev-low: #8b8b8b;
+ --warn-bg: rgba(240, 195, 107, .08); --warn-text: #f3d79b; --warn-sheet: rgba(46, 38, 18, .9);
+ --ok-bg: rgba(111, 215, 168, .08); --ok-text: #a9e5c9; --err-text: #f6a5a5;
+ --dir-bg: rgba(25, 25, 25, .7); --menu-solid: rgba(26, 26, 26, .94); --well: rgba(0, 0, 0, .3);
+ --palette-bg: rgba(30, 30, 30, .96); --modal-bg: rgba(30, 30, 30, .97);
+ --scrim: rgba(0, 0, 0, .45); --scrim-2: rgba(0, 0, 0, .5);
+ --shadow-lift: 0 18px 40px -20px rgba(0, 0, 0, 1);
+ --shadow-deep: 0 24px 64px -24px rgba(0, 0, 0, .9);
+ --ring: rgba(var(--ink), .88); --focus: rgba(var(--ink), .16);
--r-card: 20px; --r-panel: 24px; --r-ctl: 12px;
--ease: cubic-bezier(.16, 1, .3, 1); --ease-io: cubic-bezier(.65, 0, .35, 1);
- --shadow-card: 0 1px 0 rgba(255, 255, 255, .035) inset, 0 12px 32px -20px rgba(0, 0, 0, .95);
- --shadow-float: 0 0 0 1px rgba(255, 255, 255, .05), 0 24px 64px -24px rgba(0, 0, 0, .9);
+ --shadow-card: 0 1px 0 rgba(var(--ink), .035) inset, 0 12px 32px -20px rgba(0, 0, 0, .95);
+ --shadow-float: 0 0 0 1px rgba(var(--ink), .05), 0 24px 64px -24px rgba(0, 0, 0, .9);
--k-import: #6e6e6e; --k-http: #7aa7ff; --k-call: #b49cff; --k-rpc: #8f9bff; --k-event: #f19ac7; --k-queue: #f0c36b; --k-data: #63d2b8; --k-config: #6b7280; --k-contains: #4a4a4a;
--n-ui: #7cc4ff; --n-service: #b49cff; --n-worker: #f0c36b; --n-library: #6fd7a8; --n-feature: #8fb4ff; --n-data: #63d2b8; --n-config: #a3a3a3;
--n-test: #f19ac7; --n-script: #f5a66b; --n-infra: #f28b8b; --n-external: #e3a6f0; --n-misc: #8b8b8b; --n-dir: #a3a3a3; --n-file: #a3a3a3;
@@ -28,19 +62,48 @@
--panel-w: 360px; --pw: calc(var(--panel-w) + 32px); --gutter: 28px;
color-scheme: dark;
}
+/* ---------- light theme: same variables, new values. Chosen by the Theme button (see ui/05-theme.js) ---------- */
+:root[data-theme="light"] {
+ color-scheme: light;
+ --bg: #f3f3f1; --bg-rgb: 243, 243, 241; --grid: #d2d2ce; --ink: 0, 0, 0;
+ --surface: #ffffff; --surface-hover: #fbfbfa; --raise: #ebebe8; --raise-2: #e0e0dc;
+ --elev: rgba(255, 255, 255, .92); --hair: rgba(0, 0, 0, .09); --hair-2: rgba(0, 0, 0, .15);
+ --text: #161616; --text-2: #3f3f3f; --text-3: #595959; --text-4: #666666;
+ --recent: #157a3a; --on-recent-text: #fff;
+ --on: #161616; --on-hover: #000; --on-text: #fff; --on-sev-text: #fff;
+ --ok: #1a8a5b; --sev-high: #c94a4a; --sev-medium: #946000; --sev-low: #666666;
+ --warn-bg: rgba(217, 160, 40, .16); --warn-text: #6b4500; --warn-sheet: rgba(255, 244, 214, .97);
+ --ok-bg: rgba(26, 138, 91, .12); --ok-text: #14603f; --err-text: #b42323;
+ --dir-bg: rgba(255, 255, 255, .7); --menu-solid: rgba(255, 255, 255, .96); --well: rgba(0, 0, 0, .06);
+ --palette-bg: rgba(255, 255, 255, .98); --modal-bg: rgba(255, 255, 255, .98);
+ --scrim: rgba(20, 20, 20, .32); --scrim-2: rgba(20, 20, 20, .38);
+ --ring: rgba(0, 0, 0, .85); --focus: rgba(0, 0, 0, .14);
+ --shadow-card: 0 0 0 1px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06), 0 12px 28px -18px rgba(0, 0, 0, .3);
+ --shadow-float: 0 0 0 1px rgba(0, 0, 0, .1), 0 20px 48px -22px rgba(0, 0, 0, .4);
+ --shadow-lift: 0 16px 32px -18px rgba(0, 0, 0, .4);
+ --shadow-deep: 0 20px 48px -22px rgba(0, 0, 0, .4);
+ --k-import: #50555c; --k-http: #1f5fd6; --k-call: #6a45d6; --k-rpc: #4450cf; --k-event: #c43a85; --k-queue: #a8710c; --k-data: #0b7f6b; --k-config: #4f5661; --k-contains: #8d8d8d;
+ --n-ui: #1f7ac4; --n-service: #7a5ad8; --n-worker: #a8710c; --n-library: #1a8a5b; --n-feature: #3b6fd1; --n-data: #0f8a76; --n-config: #666666;
+ --n-test: #c43c86; --n-script: #c06a1d; --n-infra: #c94a4a; --n-external: #a24dbb; --n-misc: #666666; --n-dir: #666666; --n-file: #666666;
+ --n-module: #666666; --n-symbol: #6a55c4; --n-route: #2f6fe0; --n-connector: #666666;
+ --m-GET: #1a8a5b; --m-POST: #2f6fe0; --m-PUT: #a8710c; --m-PATCH: #7a4fd0; --m-DELETE: #c94a4a; --m-CALL: #0d7f8c; --m-ANY: #666666;
+}
+:root[data-theme="light"] .mark { filter: invert(1); } /* the logo image is white, so it is inverted to black */
+:root[data-theme="light"] #search::placeholder { color: var(--text-3); } /* the browser's default grey is too faint on white */
+html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: none !important; } /* a change of theme is instant, never animated */
body.no-panel { --pw: 0px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13.5px; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
-::selection { background: rgba(255, 255, 255, .2); }
+::selection { background: rgba(var(--ink), .2); }
svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.glass { background: var(--elev); backdrop-filter: blur(20px) saturate(1.2); -webkit-backdrop-filter: blur(20px) saturate(1.2); box-shadow: var(--shadow-float); }
-.kbd { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); background: rgba(255, 255, 255, .06); border-radius: 6px; padding: 1px 6px; line-height: 17px; }
+.kbd { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); background: rgba(var(--ink), .06); border-radius: 6px; padding: 1px 6px; line-height: 17px; }
/* ---------- top bar: brand + path left, search centered, actions right ---------- */
header { position: fixed; inset: 0 0 auto 0; height: 64px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 0 16px; z-index: 10; pointer-events: none;
- background: linear-gradient(to bottom, rgba(15, 15, 15, .96) 35%, rgba(15, 15, 15, 0)); }
+ background: linear-gradient(to bottom, rgba(var(--bg-rgb), .96) 35%, rgba(var(--bg-rgb), 0)); }
header > * { pointer-events: auto; }
.hl { display: flex; align-items: center; gap: 4px; min-width: 0; }
.hc { display: flex; justify-content: center; }
@@ -50,21 +113,23 @@ header > * { pointer-events: auto; }
#crumbs { display: flex; align-items: center; min-width: 0; overflow: hidden; }
#crumbs .sep { color: var(--text-4); padding: 0 1px; }
#crumbs button { background: none; border: 0; padding: 6px 10px; border-radius: 999px; cursor: pointer; color: var(--text-3); white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; transition: background .2s var(--ease), color .2s var(--ease); }
-#crumbs button:hover { background: rgba(255, 255, 255, .06); color: var(--text); }
+#crumbs button:hover { background: rgba(var(--ink), .06); color: var(--text); }
#crumbs button.cur { color: var(--text); }
.btn { height: 36px; display: inline-flex; align-items: center; gap: 8px; padding: 0 14px; border-radius: 999px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; white-space: nowrap; text-decoration: none; font-size: 13px;
transition: background .2s var(--ease), color .2s var(--ease), transform .2s var(--ease); }
-.btn:hover { background: rgba(255, 255, 255, .07); color: var(--text); }
+.btn:hover { background: rgba(var(--ink), .07); color: var(--text); }
.btn:active { transform: scale(.97); }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
-.btn.soft { background: rgba(255, 255, 255, .06); color: var(--text); }
-.btn.soft:hover { background: rgba(255, 255, 255, .1); }
-.btn.primary { background: #ececec; color: #0f0f0f; }
-.btn.primary:hover { background: #fff; }
+.btn.soft { background: rgba(var(--ink), .06); color: var(--text); }
+.btn.soft:hover { background: rgba(var(--ink), .1); }
+.btn.primary { background: var(--on); color: var(--on-text); }
+.btn.primary:hover { background: var(--on-hover); }
.btn:disabled { opacity: .35; cursor: default; }
-.btn .badge { min-width: 16px; height: 16px; border-radius: 999px; background: #ececec; color: #0f0f0f; font-size: 10px; font-weight: 600; display: grid; place-items: center; padding: 0 4px; }
+.btn .badge { min-width: 16px; height: 16px; border-radius: 999px; background: var(--on); color: var(--on-text); font-size: 10px; font-weight: 600; display: grid; place-items: center; padding: 0 4px; }
#btn-up[hidden] { display: none; }
#search-btn { width: min(460px, 36vw); height: 40px; justify-content: flex-start; gap: 10px; padding: 0 8px 0 16px; background: var(--raise); color: var(--text-3); }
+/* the Theme button adds 48px (44px and a gap) to the right side, so the search box gives up the same, and the project name and buttons fit as before. Under 701px the bar is the phone layout's job and is left as it was. */
+@media (min-width: 701px) { #search-btn { width: min(460px, max(calc(36vw - 48px), 250px)); } }
#search-btn:hover { background: var(--raise-2); color: var(--text-2); }
#search-btn .kbd { margin-left: auto; }
.rel { position: relative; }
@@ -80,7 +145,7 @@ header > * { pointer-events: auto; }
body.in-flow #context { opacity: 0; }
#context .k { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); }
#context .k .ico { width: 20px; height: 20px; border-radius: 7px; }
-#context::before { content: ""; position: absolute; inset: -28px -60px -28px -40px; background: radial-gradient(closest-side, rgba(15, 15, 15, .9), rgba(15, 15, 15, 0)); z-index: -1; }
+#context::before { content: ""; position: absolute; inset: -28px -60px -28px -40px; background: radial-gradient(closest-side, rgba(var(--bg-rgb), .9), rgba(var(--bg-rgb), 0)); z-index: -1; }
#context h1 { margin: 6px 0 4px; font-size: 24px; font-weight: 600; letter-spacing: -.025em; }
#context p { margin: 0; color: var(--text-2); line-height: 1.55; font-size: 14px; }
@@ -93,12 +158,12 @@ body.in-flow #context { opacity: 0; }
animation: cardIn .55s var(--ease) both; animation-delay: var(--d, 0ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px) scale(.985); } }
.card > * { flex-shrink: 0; }
-.node:hover .card { background: var(--surface-hover); transform: translateY(-2px); box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 18px 40px -20px rgba(0, 0, 0, 1); }
+.node:hover .card { background: var(--surface-hover); transform: translateY(-2px); box-shadow: 0 1px 0 rgba(var(--ink), .05) inset, var(--shadow-lift); }
/* selected: a soft ring that follows the card's radius, plus a faint halo */
-.node.sel .card { background: var(--surface-hover); box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .5), 0 0 0 6px rgba(255, 255, 255, .05), 0 18px 40px -20px rgba(0, 0, 0, 1); }
-.node.sel .card.external { box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .1), 0 0 0 1.5px rgba(255, 255, 255, .5), 0 0 0 6px rgba(255, 255, 255, .05); }
+.node.sel .card { background: var(--surface-hover); box-shadow: 0 0 0 1.5px rgba(var(--ink), .5), 0 0 0 6px rgba(var(--ink), .05), var(--shadow-lift); }
+.node.sel .card.external { box-shadow: inset 0 0 0 1.5px rgba(var(--ink), .1), 0 0 0 1.5px rgba(var(--ink), .5), 0 0 0 6px rgba(var(--ink), .05); }
.node.flash .card { animation: flash 1.2s var(--ease) 2; }
-@keyframes flash { 50% { box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .6), 0 0 0 10px rgba(255, 255, 255, .08); } }
+@keyframes flash { 50% { box-shadow: 0 0 0 1.5px rgba(var(--ink), .6), 0 0 0 10px rgba(var(--ink), .08); } }
.head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ico { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex: none; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.ico svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@@ -109,19 +174,19 @@ body.in-flow #context { opacity: 0; }
.foot .meta { align-self: center; }
svg.lod-low .foot .meta { visibility: hidden; }
.title.mono { font-family: var(--mono); font-size: 13px; font-weight: 500; }
-.meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; background: rgba(255, 255, 255, .05); border-radius: 999px; padding: 2px 8px; }
+.meta { font-size: 11.5px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; background: rgba(var(--ink), .05); border-radius: 999px; padding: 2px 8px; }
.desc { color: var(--text-2); font-size: 13px; line-height: 19px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: var(--lines, 2); overflow: hidden; max-height: calc(var(--lines, 2) * 19px); }
.desc[style*="--lines:1"] { -webkit-line-clamp: 1; } .desc[style*="--lines:2"] { -webkit-line-clamp: 2; } .desc[style*="--lines:3"] { -webkit-line-clamp: 3; }
.desc.empty { color: var(--text-4); }
.method { font-family: var(--mono); font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 8px; color: var(--m); background: color-mix(in srgb, var(--m) 14%, transparent); letter-spacing: .02em; flex: none; }
.rpath { font-family: var(--mono); font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
-.card.external { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .1); }
-.node:hover .card.external { background: rgba(255, 255, 255, .03); }
-.card.dir { background: rgba(25, 25, 25, .7); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .05); }
+.card.external { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(var(--ink), .1); }
+.node:hover .card.external { background: rgba(var(--ink), .03); }
+.card.dir { background: var(--dir-bg); box-shadow: inset 0 0 0 1px rgba(var(--ink), .05); }
.card.module { background: var(--raise); }
/* recent work: cards Claude just changed (green ring + tag), and the parts that contain them (soft ring + count) */
.card.recent { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--recent) 62%, transparent), var(--shadow-card); }
-.node:hover .card.recent { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--recent) 85%, transparent), 0 18px 40px -20px rgba(0, 0, 0, 1); }
+.node:hover .card.recent { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--recent) 85%, transparent), var(--shadow-lift); }
.card.recent-in { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--recent) 30%, transparent), var(--shadow-card); }
.rw { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; line-height: 1; color: var(--recent); background: color-mix(in srgb, var(--recent) 13%, transparent); border-radius: 999px; padding: 4px 8px 4px 7px; white-space: nowrap; }
.rw::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
@@ -129,14 +194,14 @@ svg.lod-low .foot .meta { visibility: hidden; }
body.no-recent .rw { display: none; }
body.no-recent .card.recent, body.no-recent .card.recent-in { box-shadow: var(--shadow-card); }
svg.lod-low .rw { font-size: 18px; padding: 6px 12px; }
-.card.has-note .title::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #f0c36b; margin-left: 8px; vertical-align: middle; }
+.card.has-note .title::after { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--sev-medium); margin-left: 8px; vertical-align: middle; }
.card.connector { flex-direction: row; align-items: center; gap: 10px; padding: 0 14px 0 10px; border-radius: var(--r-card); background: var(--raise); }
.card.connector .ico { width: 26px; height: 26px; border-radius: 9px; }
.card.connector .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); font-weight: 500; font-size: 13px; flex: 1; }
.card.connector .dir-ico { color: var(--text-4); display: grid; }
.card.connector .dir-ico svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
-.anote { margin-top: 4px; display: flex; gap: 9px; align-items: flex-start; padding: 9px 11px; border-radius: 14px; background: rgba(255, 255, 255, .05); font-size: 12.5px; line-height: 1.45; color: var(--text); }
-.anote b { flex: none; width: 19px; height: 19px; border-radius: 999px; background: #ececec; color: #0f0f0f; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; }
+.anote { margin-top: 4px; display: flex; gap: 9px; align-items: flex-start; padding: 9px 11px; border-radius: 14px; background: rgba(var(--ink), .05); font-size: 12.5px; line-height: 1.45; color: var(--text); }
+.anote b { flex: none; width: 19px; height: 19px; border-radius: 999px; background: var(--on); color: var(--on-text); display: grid; place-items: center; font-size: 10.5px; font-weight: 700; }
.anote span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
svg.lod-mid .desc { -webkit-line-clamp: 1 !important; max-height: 19px; }
svg.lod-low .meta, svg.lod-low .anote { visibility: hidden; }
@@ -150,7 +215,7 @@ svg.dim .node:not(.hl) .card > * { opacity: .28; transition: opacity .3s var(--e
.edges { animation: fadeIn .7s var(--ease) .12s both; }
/* column brackets over a view: what uses this part · what's inside it · what it uses */
.cols { animation: fadeIn .7s var(--ease) .2s both; pointer-events: none; }
-.cols path { fill: none; stroke: rgba(255, 255, 255, .16); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
+.cols path { fill: none; stroke: rgba(var(--ink), .16); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.cols text { fill: var(--text-3); font: 500 13px Inter, system-ui, sans-serif; letter-spacing: -.005em; dominant-baseline: central; text-anchor: middle; }
@keyframes fadeIn { from { opacity: 0; } }
.edge { color: var(--k-import); }
@@ -165,54 +230,54 @@ svg.dim .node:not(.hl) .card > * { opacity: .28; transition: opacity .3s var(--e
@keyframes flow { to { stroke-dashoffset: -24; } }
svg.dim .edge:not(.hl) { opacity: .1; }
.edge { transition: opacity .3s var(--ease); }
-.pulse { fill: #fff; filter: drop-shadow(0 0 6px rgba(255, 255, 255, .8)); }
-.flowlink { fill: none; stroke: #ececec; stroke-opacity: .7; stroke-width: 2; stroke-dasharray: 5 7; animation: flow 1.1s linear infinite; }
+.pulse { fill: var(--on-hover); filter: drop-shadow(0 0 6px rgba(var(--ink), .8)); }
+.flowlink { fill: none; stroke: var(--on); stroke-opacity: .7; stroke-width: 2; stroke-dasharray: 5 7; animation: flow 1.1s linear infinite; }
/* ---------- floating chrome ---------- */
#zoom { position: absolute; left: 16px; bottom: 16px; display: flex; padding: 4px; gap: 2px; border-radius: 999px; }
#zoom button { width: 34px; height: 34px; border: 0; background: none; color: var(--text-2); border-radius: 999px; cursor: pointer; display: grid; place-items: center; transition: background .2s var(--ease), color .2s var(--ease); }
-#zoom button:hover { background: rgba(255, 255, 255, .08); color: var(--text); }
+#zoom button:hover { background: rgba(var(--ink), .08); color: var(--text); }
.menu { position: absolute; z-index: 30; min-width: 230px; padding: 6px; border-radius: 18px; display: none; transform-origin: top right; }
.menu.open { display: block; animation: menuIn .22s var(--ease); }
@keyframes menuIn { from { opacity: 0; transform: translateY(-4px) scale(.97); } }
#flowmenu, #legend { top: 44px; right: 0; width: 320px; }
#flowmenu .r { padding: 10px 12px; border-radius: 12px; cursor: pointer; transition: background .15s var(--ease); }
-#flowmenu .r:hover { background: rgba(255, 255, 255, .07); }
+#flowmenu .r:hover { background: rgba(var(--ink), .07); }
#flowmenu .r b { font-weight: 500; display: block; }
#flowmenu .r span { color: var(--text-3); font-size: 12.5px; }
#flowmenu .r.custom { display: flex; gap: 8px; align-items: flex-start; }
#flowmenu .r.custom .rt { flex: 1; min-width: 0; }
#flowmenu .r .del { border: 0; background: none; color: var(--text-4); border-radius: 999px; width: 26px; height: 26px; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s var(--ease), background .15s var(--ease); flex: none; }
#flowmenu .r:hover .del { opacity: 1; }
-#flowmenu .r .del:hover { background: rgba(255, 255, 255, .1); color: var(--text); }
-#flowmenu .yours { font-size: 11px; color: var(--text-3); background: rgba(255, 255, 255, .06); border-radius: 999px; padding: 1px 7px; margin-left: 6px; font-weight: 400; }
+#flowmenu .r .del:hover { background: rgba(var(--ink), .1); color: var(--text); }
+#flowmenu .yours { font-size: 11px; color: var(--text-3); background: rgba(var(--ink), .06); border-radius: 999px; padding: 1px 7px; margin-left: 6px; font-weight: 400; }
#flowmenu .new { display: flex; align-items: center; gap: 10px; color: var(--text); }
#flowmenu .new svg { color: var(--text-3); }
.ff { padding: 8px 6px 6px; }
.ff label { display: block; font-size: 12.5px; color: var(--text-3); padding: 2px 6px 8px; }
-.ff textarea { width: 100%; min-height: 84px; resize: none; background: rgba(255, 255, 255, .05); border: 0; border-radius: 14px; padding: 11px 13px; color: var(--text); outline: none; font: inherit; line-height: 1.5; transition: background .2s var(--ease), box-shadow .2s var(--ease); }
-.ff textarea:focus { background: rgba(255, 255, 255, .07); box-shadow: 0 0 0 1px rgba(255, 255, 255, .14); }
+.ff textarea { width: 100%; min-height: 84px; resize: none; background: rgba(var(--ink), .05); border: 0; border-radius: 14px; padding: 11px 13px; color: var(--text); outline: none; font: inherit; line-height: 1.5; transition: background .2s var(--ease), box-shadow .2s var(--ease); }
+.ff textarea:focus { background: rgba(var(--ink), .07); box-shadow: 0 0 0 1px rgba(var(--ink), .14); }
.ff .ffa { display: flex; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.ff .ffa .btn { height: 34px; }
.ff .note { font-size: 12px; color: var(--text-4); padding: 8px 6px 0; }
#legend { width: 250px; }
#legend .lh { padding: 8px 12px 6px; font-size: 12px; color: var(--text-3); }
#legend label { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px; cursor: pointer; color: var(--text); user-select: none; transition: background .15s var(--ease); }
-#legend label:hover { background: rgba(255, 255, 255, .07); }
+#legend label:hover { background: rgba(var(--ink), .07); }
#legend label.off { color: var(--text-4); }
#legend label.off .sw { opacity: .25; }
#legend input { display: none; }
#legend .sw { width: 16px; height: 3px; border-radius: 2px; }
#legend .n { margin-left: auto; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 12px; }
-#legend .tog { width: 28px; height: 16px; border-radius: 999px; background: rgba(255, 255, 255, .12); position: relative; transition: background .2s var(--ease); flex: none; }
-#legend .tog::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #8b8b8b; transition: transform .25s var(--ease), background .2s var(--ease); }
-#legend label:not(.off) .tog { background: rgba(255, 255, 255, .28); }
-#legend label:not(.off) .tog::after { transform: translateX(12px); background: #fff; }
+#legend .tog { width: 28px; height: 16px; border-radius: 999px; background: rgba(var(--ink), .12); position: relative; transition: background .2s var(--ease); flex: none; }
+#legend .tog::after { content: ""; position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--text-3); transition: transform .25s var(--ease), background .2s var(--ease); }
+#legend label:not(.off) .tog { background: rgba(var(--ink), .28); }
+#legend label:not(.off) .tog::after { transform: translateX(12px); background: var(--on-hover); }
#ctxmenu { position: fixed; display: block; transform-origin: top left; }
#ctxmenu[hidden] { display: none; }
#ctxmenu:not([hidden]) { animation: menuIn .18s var(--ease); }
.mi { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 0; border-radius: 12px; background: none; cursor: pointer; color: var(--text); text-align: left; font-size: 13px; transition: background .15s var(--ease); }
-.mi:hover { background: rgba(255, 255, 255, .08); }
+.mi:hover { background: rgba(var(--ink), .08); }
.mi svg { color: var(--text-3); }
.mi .hint { margin-left: auto; color: var(--text-4); font-size: 12px; }
.mi-sep { height: 1px; background: var(--hair); margin: 5px 8px; }
@@ -224,8 +289,8 @@ svg.dim .edge:not(.hl) { opacity: .1; }
#flowbar .ft b { font-weight: 600; }
#flowbar .ft span { color: var(--text-2); }
#flowbar .dots { display: flex; gap: 4px; margin-top: 8px; }
-#flowbar .dots i { width: 18px; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .12); transition: background .3s var(--ease); }
-#flowbar .dots i.on { background: #ececec; }
+#flowbar .dots i { width: 18px; height: 3px; border-radius: 2px; background: rgba(var(--ink), .12); transition: background .3s var(--ease); }
+#flowbar .dots i.on { background: var(--on); }
#tooltip { position: absolute; pointer-events: none; padding: 11px 13px; max-width: 320px; z-index: 6; font-size: 12.5px; line-height: 1.5; border-radius: 16px; animation: tipIn .2s var(--ease); }
@keyframes tipIn { from { opacity: 0; transform: translateY(3px); } }
#tooltip[hidden] { display: none; }
@@ -248,13 +313,13 @@ svg.dim .edge:not(.hl) { opacity: .1; }
transition: transform .45s var(--ease), opacity .3s var(--ease); }
body.no-panel #panel { transform: translateX(24px) scale(.98); opacity: 0; pointer-events: none; }
#panel-resize { position: fixed; top: 84px; bottom: 32px; right: calc(var(--panel-w) + 16px - 6px); width: 12px; cursor: ew-resize; z-index: 6; display: grid; place-items: center; transition: opacity .3s var(--ease); }
-#panel-resize::after { content: ""; width: 4px; height: 40px; border-radius: 999px; background: rgba(255, 255, 255, .14); opacity: 0; transition: opacity .2s var(--ease), height .25s var(--ease), background .2s var(--ease); }
+#panel-resize::after { content: ""; width: 4px; height: 40px; border-radius: 999px; background: rgba(var(--ink), .14); opacity: 0; transition: opacity .2s var(--ease), height .25s var(--ease), background .2s var(--ease); }
#panel-resize:hover::after, body.resizing #panel-resize::after { opacity: 1; height: 64px; }
-body.resizing #panel-resize::after { background: rgba(255, 255, 255, .4); }
+body.resizing #panel-resize::after { background: rgba(var(--ink), .4); }
body.resizing, body.resizing * { cursor: ew-resize !important; user-select: none; }
body.resizing #panel, body.resizing #ask, body.resizing #flowbar { transition: none; }
body.no-panel #panel-resize { opacity: 0; pointer-events: none; }
-#panel::-webkit-scrollbar { width: 12px; } #panel::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .1); border-radius: 10px; border: 4px solid transparent; background-clip: padding-box; }
+#panel::-webkit-scrollbar { width: 12px; } #panel::-webkit-scrollbar-thumb { background: rgba(var(--ink), .1); border-radius: 10px; border: 4px solid transparent; background-clip: padding-box; }
#panel > * { animation: panelIn .4s var(--ease) both; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } }
.sec { padding: 18px 20px 6px; }
@@ -267,13 +332,13 @@ body.no-panel #panel-resize { opacity: 0; pointer-events: none; }
.pt { margin: 0 0 6px; font-size: 20px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; word-break: break-word; }
.pd { margin: 0; color: var(--text-2); line-height: 1.6; }
.pd.empty { color: var(--text-4); }
-.pp { display: flex; align-items: center; gap: 6px; margin-top: 14px; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); background: rgba(255, 255, 255, .04); border-radius: 12px; padding: 8px 10px 8px 12px; word-break: break-all; }
+.pp { display: flex; align-items: center; gap: 6px; margin-top: 14px; font-family: var(--mono); font-size: 11.5px; color: var(--text-3); background: rgba(var(--ink), .04); border-radius: 12px; padding: 8px 10px 8px 12px; word-break: break-all; }
.pp button { margin-left: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; padding: 4px; display: grid; border-radius: 8px; transition: background .2s var(--ease), color .2s var(--ease); }
-.pp button:hover { color: var(--text); background: rgba(255, 255, 255, .08); }
+.pp button:hover { color: var(--text); background: rgba(var(--ink), .08); }
.actions { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.actions .btn { height: 34px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
-.stats div { background: rgba(255, 255, 255, .04); border-radius: 14px; padding: 10px 12px; }
+.stats div { background: rgba(var(--ink), .04); border-radius: 14px; padding: 10px 12px; }
.stats b { display: block; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stats span { font-size: 12px; color: var(--text-3); }
.bar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; margin: 14px 0 10px; gap: 3px; }
@@ -283,7 +348,7 @@ body.no-panel #panel-resize { opacity: 0; pointer-events: none; }
.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; flex: none; }
.list { display: flex; flex-direction: column; gap: 2px; margin: 0 -10px; }
.row { display: flex; align-items: flex-start; gap: 12px; padding: 9px 10px; border-radius: 14px; cursor: pointer; text-decoration: none; color: inherit; transition: background .15s var(--ease); }
-.row:hover { background: rgba(255, 255, 255, .06); }
+.row:hover { background: rgba(var(--ink), .06); }
.row .dot { margin-top: 6px; }
.row .rt { flex: 1; min-width: 0; }
.row .rn { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@@ -292,61 +357,61 @@ body.no-panel #panel-resize { opacity: 0; pointer-events: none; }
.row .rc { font-size: 12px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.more { color: var(--text-4); font-size: 12.5px; padding: 6px 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
-.tag { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); background: rgba(255, 255, 255, .05); border-radius: 999px; padding: 3px 10px; }
-.callout { margin-top: 14px; padding: 11px 13px; border-radius: 14px; background: rgba(240, 195, 107, .08); color: #f3d79b; font-size: 13px; line-height: 1.55; }
+.tag { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); background: rgba(var(--ink), .05); border-radius: 999px; padding: 3px 10px; }
+.callout { margin-top: 14px; padding: 11px 13px; border-radius: 14px; background: var(--warn-bg); color: var(--warn-text); font-size: 13px; line-height: 1.55; }
/* ---------- command palette ---------- */
-#palette { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); backdrop-filter: blur(4px); display: none; align-items: flex-start; justify-content: center; padding-top: 14vh; }
+#palette { position: fixed; inset: 0; z-index: 40; background: var(--scrim); backdrop-filter: blur(4px); display: none; align-items: flex-start; justify-content: center; padding-top: 14vh; }
#palette.open { display: flex; animation: fadeIn .2s var(--ease); }
-#palette .box { width: min(640px, calc(100% - 32px)); overflow: hidden; border-radius: var(--r-panel); animation: menuIn .3s var(--ease); background: rgba(30, 30, 30, .96); }
+#palette .box { width: min(640px, calc(100% - 32px)); overflow: hidden; border-radius: var(--r-panel); animation: menuIn .3s var(--ease); background: var(--palette-bg); }
#palette .in { display: flex; align-items: center; gap: 12px; padding: 0 20px; color: var(--text-3); }
#palette input { flex: 1; height: 58px; background: none; border: 0; outline: none; font-size: 16px; color: var(--text); }
#results { max-height: 52vh; overflow: auto; padding: 0 8px 8px; }
#results .r { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px; cursor: pointer; }
-#results .r.active { background: rgba(255, 255, 255, .07); }
+#results .r.active { background: rgba(var(--ink), .07); }
#results .r .rt { flex: 1; min-width: 0; }
#results .r .rn { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#results .r .rd { color: var(--text-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#results .r .rk { font-size: 12px; color: var(--text-4); white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
#results .empty { padding: 22px; color: var(--text-3); text-align: center; }
-#palette .hint { display: flex; gap: 16px; padding: 12px 20px; color: var(--text-4); font-size: 12px; background: rgba(255, 255, 255, .02); }
+#palette .hint { display: flex; gap: 16px; padding: 12px 20px; color: var(--text-4); font-size: 12px; background: rgba(var(--ink), .02); }
/* ---------- ask ---------- */
#ask { position: absolute; left: calc((100% - var(--pw)) / 2); bottom: 20px; transform: translateX(-50%); width: min(700px, calc(100% - var(--pw) - 320px)); min-width: 320px; z-index: 4; display: flex; flex-direction: column; gap: 10px; transition: left .45s var(--ease), width .45s var(--ease); }
#ask-form { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 18px; border-radius: 28px; transition: box-shadow .25s var(--ease); flex-wrap: wrap; }
-#ask-form:focus-within { box-shadow: 0 0 0 1px rgba(255, 255, 255, .16), 0 24px 64px -24px rgba(0, 0, 0, .9); }
+#ask-form:focus-within { box-shadow: 0 0 0 1px rgba(var(--ink), .16), var(--shadow-deep); }
#ask-chips { display: contents; }
-.chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 6px 0 8px; border-radius: 999px; background: rgba(255, 255, 255, .08); font-size: 12.5px; max-width: 220px; animation: chipIn .3s var(--ease); }
+.chip { display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 6px 0 8px; border-radius: 999px; background: rgba(var(--ink), .08); font-size: 12.5px; max-width: 220px; animation: chipIn .3s var(--ease); }
@keyframes chipIn { from { opacity: 0; transform: scale(.9); } }
.chip .ico { width: 20px; height: 20px; border-radius: 999px; }
.chip .ico svg { width: 11px; height: 11px; }
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip button { border: 0; background: none; color: var(--text-3); cursor: pointer; width: 20px; height: 20px; border-radius: 999px; display: grid; place-items: center; flex: none; }
-.chip button:hover { background: rgba(255, 255, 255, .1); color: var(--text); }
+.chip button:hover { background: rgba(var(--ink), .1); color: var(--text); }
#ask-input { flex: 1; min-width: 160px; height: 38px; background: none; border: 0; outline: none; font-size: 15px; color: var(--text); }
#ask-input::placeholder { color: var(--text-3); }
#ask-input:disabled { cursor: not-allowed; }
-.engine { font-size: 12px; color: var(--text-3); background: rgba(255, 255, 255, .05); border-radius: 999px; padding: 4px 10px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
+.engine { font-size: 12px; color: var(--text-3); background: rgba(var(--ink), .05); border-radius: 999px; padding: 4px 10px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.engine i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-4); }
-.engine.ok i { background: #6fd7a8; box-shadow: 0 0 8px rgba(111, 215, 168, .8); }
-.engine.warn { color: #f3d79b; background: rgba(240, 195, 107, .1); }
-.engine.warn i { background: #f0c36b; }
+.engine.ok i { background: var(--ok); box-shadow: 0 0 8px color-mix(in srgb, var(--ok) 80%, transparent); }
+.engine.warn { color: var(--warn-text); background: var(--warn-bg); }
+.engine.warn i { background: var(--sev-medium); }
.einfo { background: none; border: 0; padding: 0; margin-left: 1px; color: var(--text-3); cursor: pointer; display: grid; }
.einfo:hover { color: var(--text); }
.einfo svg { width: 14px; height: 14px; }
-#ask-send { width: 38px; height: 38px; border-radius: 999px; border: 0; background: #ececec; color: #0f0f0f; cursor: pointer; display: grid; place-items: center; flex: none; transition: transform .2s var(--ease), background .2s var(--ease), opacity .2s; }
-#ask-send:hover:not(:disabled) { transform: scale(1.06); background: #fff; }
-#ask-send:disabled { background: rgba(255, 255, 255, .1); color: var(--text-4); cursor: default; }
-#ask-send.stop { background: rgba(255, 255, 255, .14); color: var(--text); }
-#ask-warn { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; border-radius: 20px; font-size: 13px; line-height: 1.5; color: #f3d79b; background: rgba(46, 38, 18, .9); backdrop-filter: blur(16px); animation: sheetIn .35s var(--ease); }
+#ask-send { width: 38px; height: 38px; border-radius: 999px; border: 0; background: var(--on); color: var(--on-text); cursor: pointer; display: grid; place-items: center; flex: none; transition: transform .2s var(--ease), background .2s var(--ease), opacity .2s; }
+#ask-send:hover:not(:disabled) { transform: scale(1.06); background: var(--on-hover); }
+#ask-send:disabled { background: rgba(var(--ink), .1); color: var(--text-4); cursor: default; }
+#ask-send.stop { background: rgba(var(--ink), .14); color: var(--text); }
+#ask-warn { display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; border-radius: 20px; font-size: 13px; line-height: 1.5; color: var(--warn-text); background: var(--warn-sheet); backdrop-filter: blur(16px); animation: sheetIn .35s var(--ease); }
#ask-warn[hidden] { display: none; }
#ask-warn.info { color: var(--text-2); background: var(--elev); box-shadow: var(--shadow-float); }
-#ask-warn code { font-family: var(--mono); font-size: 12px; background: rgba(0, 0, 0, .3); padding: 1px 7px; border-radius: 7px; color: var(--text); }
-#ask-warn.info code { background: rgba(255, 255, 255, .07); }
+#ask-warn code { font-family: var(--mono); font-size: 12px; background: var(--well); padding: 1px 7px; border-radius: 7px; color: var(--text); }
+#ask-warn.info code { background: rgba(var(--ink), .07); }
#ask-warn a { color: inherit; text-underline-offset: 3px; }
#ask-warn.info a { color: var(--text); }
-#ask-warn button { margin-left: auto; background: rgba(255, 255, 255, .08); border: 0; color: inherit; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; white-space: nowrap; }
-#ask-warn button:hover { background: rgba(255, 255, 255, .14); }
+#ask-warn button { margin-left: auto; background: rgba(var(--ink), .08); border: 0; color: inherit; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 12.5px; white-space: nowrap; }
+#ask-warn button:hover { background: rgba(var(--ink), .14); }
#ask-sheet { max-height: min(46vh, 480px); display: flex; flex-direction: column; overflow: hidden; border-radius: var(--r-panel); animation: sheetIn .45s var(--ease); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(12px) scale(.985); } }
#ask-sheet[hidden] { display: none; }
@@ -357,30 +422,30 @@ body.no-panel #panel-resize { opacity: 0; pointer-events: none; }
#ask-sheet .sb p { margin: 0 0 10px; }
#ask-sheet .sb ul, #ask-sheet .sb ol { margin: 0 0 10px; padding-left: 20px; }
#ask-sheet .sb li { margin: 3px 0; }
-#ask-sheet .sb code { font-family: var(--mono); font-size: 12.5px; background: rgba(255, 255, 255, .07); padding: 1px 6px; border-radius: 6px; }
+#ask-sheet .sb code { font-family: var(--mono); font-size: 12.5px; background: rgba(var(--ink), .07); padding: 1px 6px; border-radius: 6px; }
#ask-sheet .sb strong { font-weight: 600; }
-.ref { display: inline-flex; align-items: center; gap: 6px; padding: 0 9px 0 7px; border-radius: 999px; background: rgba(255, 255, 255, .08); color: var(--text); cursor: pointer; font-weight: 500; font-size: 13px; line-height: 23px; white-space: nowrap; vertical-align: 1px; transition: background .2s var(--ease); }
-.ref:hover { background: rgba(255, 255, 255, .15); }
+.ref { display: inline-flex; align-items: center; gap: 6px; padding: 0 9px 0 7px; border-radius: 999px; background: rgba(var(--ink), .08); color: var(--text); cursor: pointer; font-weight: 500; font-size: 13px; line-height: 23px; white-space: nowrap; vertical-align: 1px; transition: background .2s var(--ease); }
+.ref:hover { background: rgba(var(--ink), .15); }
.ref i { width: 7px; height: 7px; border-radius: 999px; background: var(--c); }
.progress { display: flex; flex-direction: column; gap: 7px; font-size: 13px; color: var(--text-3); }
.progress div { display: flex; align-items: center; gap: 10px; animation: chipIn .3s var(--ease); }
.progress div:last-child { color: var(--text); }
-.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .15); border-top-color: #ececec; animation: spin .8s linear infinite; flex: none; }
+.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(var(--ink), .15); border-top-color: var(--on); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.followups { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
-.followups button { background: rgba(255, 255, 255, .06); border: 0; color: var(--text-2); border-radius: 999px; padding: 7px 13px; cursor: pointer; font-size: 12.5px; text-align: left; transition: background .2s var(--ease), color .2s var(--ease); }
-.followups button:hover { background: rgba(255, 255, 255, .11); color: var(--text); }
+.followups button { background: rgba(var(--ink), .06); border: 0; color: var(--text-2); border-radius: 999px; padding: 7px 13px; cursor: pointer; font-size: 12.5px; text-align: left; transition: background .2s var(--ease), color .2s var(--ease); }
+.followups button:hover { background: rgba(var(--ink), .11); color: var(--text); }
.sheet-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
-.err { color: #f6a5a5; }
+.err { color: var(--err-text); }
/* ---------- extension chrome: header slot, modal, toast, grouped lists ---------- */
.hr-ext { display: contents; }
-#modal { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .5); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 24px; }
+#modal { position: fixed; inset: 0; z-index: 45; background: var(--scrim-2); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; padding: 24px; }
#modal.open { display: flex; animation: fadeIn .2s var(--ease); }
-#modal .box { width: min(620px, 100%); max-height: min(80vh, 760px); overflow: auto; border-radius: var(--r-panel); background: rgba(30, 30, 30, .97); animation: menuIn .3s var(--ease); padding: 22px 24px 20px; }
+#modal .box { width: min(620px, 100%); max-height: min(80vh, 760px); overflow: auto; border-radius: var(--r-panel); background: var(--modal-bg); animation: menuIn .3s var(--ease); padding: 22px 24px 20px; }
#modal h2 { margin: 0 0 8px; font-size: 18px; font-weight: 600; letter-spacing: -.015em; }
#modal .mb { color: var(--text-2); line-height: 1.6; }
-#modal pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; line-height: 1.55; background: rgba(255, 255, 255, .05); border-radius: 14px; padding: 14px 16px; color: var(--text); margin: 12px 0 0; max-height: 46vh; overflow: auto; }
+#modal pre { white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12px; line-height: 1.55; background: rgba(var(--ink), .05); border-radius: 14px; padding: 14px 16px; color: var(--text); margin: 12px 0 0; max-height: 46vh; overflow: auto; }
#modal .ma { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
#toast { position: fixed; left: calc((100% - var(--pw)) / 2); bottom: 96px; transform: translateX(-50%); z-index: 50; padding: 10px 16px; border-radius: 999px; font-size: 13px; pointer-events: none; opacity: 0; transition: opacity .25s var(--ease), transform .3s var(--ease); }
#toast.on { opacity: 1; transform: translateX(-50%) translateY(-4px); }
@@ -1206,7 +1271,7 @@ function applySelection() {
// ======================= chrome: context, crumbs, legend =======================
function renderContext() {
if (state.container === 'q:answer') {
- $('#context').innerHTML = `<div class="k"><span class="ico" style="--c:#ececec">${icon(state.answer.icon || 'spark')}</span>${h(state.answer.kind || 'Answer')} · ${plural(state.answer.items.length, 'card')}</div><h1>${h(state.answer.title)}</h1><p>${h(state.answer.question)}</p>`;
+ $('#context').innerHTML = `<div class="k"><span class="ico" style="--c:var(--on)">${icon(state.answer.icon || 'spark')}</span>${h(state.answer.kind || 'Answer')} · ${plural(state.answer.items.length, 'card')}</div><h1>${h(state.answer.title)}</h1><p>${h(state.answer.question)}</p>`;
return;
}
const i = info(state.container);
diff --git a/tests/theme.test.mjs b/tests/theme.test.mjs
new file mode 100644
index 0000000..ddec98f
--- /dev/null
+++ b/tests/theme.test.mjs
@@ -0,0 +1,107 @@
+// Light and dark: the built map carries both themes, picks one before anything is drawn, and has one Theme button.
+// The boot script is run here against a pretend browser, so the choice logic is checked without a real one.
+import { test, before, after } from 'node:test';
+import assert from 'node:assert/strict';
+import fs from 'node:fs';
+import path from 'node:path';
+import vm from 'node:vm';
+import { shopApp, scanAndBuild, cleanup } from './helpers.mjs';
+
+let root, html;
+before(() => { root = shopApp(); scanAndBuild(root); html = fs.readFileSync(path.join(root, 'floorplan', 'index.html'), 'utf8'); });
+after(() => cleanup(root));
+
+const bootScript = () => html.match(/<script>\s*\/\* Theme: runs before[\s\S]*?<\/script>/)[0].replace(/^<script>|<\/script>$/g, '');
+
+/** Runs the boot script with a pretend device and returns what it did to the page. */
+function boot({ saved, deviceLight = false, storageThrows = false } = {}) {
+ const attrs = {}, classes = new Set(), store = new Map(saved ? [['floorplan-theme', saved]] : []);
+ const listeners = {}, events = [];
+ const mq = { matches: deviceLight, addEventListener: (_, f) => { mq.change = f; } };
+ const win = {
+ document: { documentElement: { setAttribute: (k, v) => { attrs[k] = v; }, classList: { add: (c) => classes.add(c), remove: (c) => classes.delete(c) } } },
+ matchMedia: () => mq,
+ localStorage: { getItem: (k) => { if (storageThrows) throw new Error('blocked'); return store.get(k) ?? null; }, setItem: (k, v) => { if (storageThrows) throw new Error('blocked'); store.set(k, v); } },
+ addEventListener: (t, f) => { listeners[t] = f; },
+ dispatchEvent: (e) => { events.push(e.type); },
+ Event: class { constructor(type) { this.type = type; } },
+ requestAnimationFrame: (f) => f(),
+ };
+ win.window = win;
+ vm.runInNewContext(bootScript(), Object.assign(win, { Event: win.Event }));
+ return { attrs, store, mq, events, theme: win.floorplanTheme, classes };
+}
+
+test('the page has a dark and a light set of colours, and dark stays the default', () => {
+ assert.match(html, /:root \{[^}]*--bg: #0f0f0f;/);
+ assert.match(html, /:root\[data-theme="light"\] \{[^}]*--bg: #f3f3f1;/);
+ assert.match(html, /:root\[data-theme="light"\] \{[^}]*color-scheme: light;/);
+ // every colour variable dark defines is also given a light value
+ const vars = (block) => new Set([...block.matchAll(/(--[\w-]+):/g)].map((m) => m[1]));
+ const dark = vars(html.match(/\n:root \{([\s\S]*?)\n\}/)[1]);
+ const light = vars(html.match(/:root\[data-theme="light"\] \{([\s\S]*?)\n\}/)[1]);
+ const sameInBoth = new Set(['--sans', '--mono', '--r-card', '--r-panel', '--r-ctl', '--ease', '--ease-io', '--panel-w', '--pw', '--gutter', '--m-ANY', '--focus']);
+ for (const v of dark) assert.ok(light.has(v) || sameInBoth.has(v), `${v} has no light value`);
+});
+
+test('the page no longer paints with fixed white tints that would vanish on light', () => {
+ // the light block itself may use white (white boxes); everywhere else tints go through --ink
+ const outsideLight = html.replace(/:root\[data-theme="light"\] \{[\s\S]*?\n\}/, '');
+ const left = outsideLight.match(/rgba\(255, 255, 255, [.\d]+\)/g) || [];
+ assert.equal(left.length, 0, `fixed white tints left: ${left.join(' ')}`);
+});
+
+test('the boot script is in the head, before the page is drawn', () => {
+ assert.ok(html.indexOf('Theme: runs before') < html.indexOf('<style>'), 'script comes before the styles');
+ assert.ok(html.indexOf('Theme: runs before') < html.indexOf('<body>'));
+});
+
+test('Auto follows the device, live', () => {
+ const dark = boot({ deviceLight: false });
+ assert.equal(dark.attrs['data-theme'], 'dark');
+ const light = boot({ deviceLight: true });
+ assert.equal(light.attrs['data-theme'], 'light');
+ dark.mq.matches = true; dark.mq.change();
+ assert.equal(dark.attrs['data-theme'], 'light');
+});
+
+test('a saved choice wins over the device, and a new choice is saved', () => {
+ assert.equal(boot({ saved: 'dark', deviceLight: true }).attrs['data-theme'], 'dark');
+ assert.equal(boot({ saved: 'light', deviceLight: false }).attrs['data-theme'], 'light');
+ const b = boot({ deviceLight: false });
+ b.theme.set('light');
+ assert.equal(b.store.get('floorplan-theme'), 'light');
+ assert.equal(b.attrs['data-theme'], 'light');
+ assert.equal(b.theme.get(), 'light');
+ assert.ok(b.events.length >= 2, 'the button is told');
+});
+
+test('an unknown saved value is ignored, and blocked storage still works for this visit', () => {
+ assert.equal(boot({ saved: 'purple', deviceLight: false }).attrs['data-theme'], 'dark');
+ const b = boot({ storageThrows: true, deviceLight: false });
+ b.theme.set('light');
+ assert.equal(b.attrs['data-theme'], 'light');
+ assert.equal(b.theme.get(), 'light');
+});
+
+test('the Theme button is in the built page with a plain label, a 44 px target and a visible focus ring', () => {
+ assert.match(html, /\/\* ui\/05-theme\.js \*\//);
+ assert.ok(html.includes('Theme: ${NAME[c]}. Press for ${WORD[NEXT[c]]}.'));
+ assert.ok(html.includes("auto: 'Auto (follows your device)'"));
+ assert.match(html, /#theme-toggle \{[^}]*width: 44px; height: 44px;/);
+ assert.match(html, /#theme-toggle:focus-visible \{ outline: 2px solid/);
+ assert.match(html, /prefers-reduced-motion: reduce\) \{ #theme-toggle/);
+});
+
+test('in Light, text on the red and amber Health chip is readable (4.5:1 or better)', () => {
+ const light = html.match(/:root\[data-theme="light"\] \{([\s\S]*?)\n\}/)[1];
+ const get = (name) => light.match(new RegExp(`${name}: (#[0-9a-f]{3,6})`, 'i'))[1].replace(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/i, '#$1$1$2$2$3$3');
+ const lum = (hex) => { const c = [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255).map((v) => (v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4)); return 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]; };
+ const ratio = (a, b) => { const [hi, lo] = [lum(a), lum(b)].sort((x, y) => y - x); return (hi + 0.05) / (lo + 0.05); };
+ for (const chip of ['--sev-high', '--sev-medium']) assert.ok(ratio(get('--on-sev-text'), get(chip)) >= 4.5, `${chip} chip is too faint`);
+ assert.ok(ratio(get('--text-3'), get('--raise')) >= 4.5, 'the search box text is too faint');
+});
+
+test("the search box gives up the Theme button's room so the project name and buttons fit as before", () => {
+ assert.match(html, /@media \(min-width: 701px\) \{ #search-btn \{ width: min\(460px, max\(calc\(36vw - 48px\), 250px\)\); \} \}/);
+});