diff --git a/src/app/globals.css b/src/app/globals.css
index 9a573ca..52dd1b6 100644
--- a/src/app/globals.css
+++ b/src/app/globals.css
@@ -1,128 +1,61 @@
-:root { --red: #E8202A; --ink: #111; --grey: #6b6b6b; --line: #d9d9d9; --bg: #f5f5f5; }
-* { box-sizing: border-box; }
-body { margin: 0; font-family: Roboto, system-ui, sans-serif; color: var(--ink); background: var(--bg); }
-.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
-.card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 32px 24px; display: flex; flex-direction: column; gap: 8px; }
-.card h1 { font-size: 22px; margin: 12px 0 8px; }
-label { font-size: 14px; font-weight: 500; margin-top: 8px; }
-input { font: inherit; padding: 12px; border: 1px solid #999; border-radius: 8px; background: #fff; color: var(--ink); }
-input:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
-button { font: inherit; font-weight: 500; margin-top: 16px; padding: 12px; border: 0; border-radius: 8px; background: var(--red); color: #fff; cursor: pointer; }
-button:disabled { opacity: .5; cursor: not-allowed; }
-.error { margin: 0 0 4px; padding: 10px 12px; border: 1px solid var(--red); border-radius: 8px; color: #a8141b; background: #fff3f3; font-size: 14px; }
-.shell header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line); }
-.shell header div { display: flex; flex-direction: column; font-size: 14px; }
-.shell header span { color: var(--grey); }
-.shell header { position: sticky; top: 0; z-index: 5; }
-.shell header button { margin: 0 0 0 auto; padding: 8px 14px; background: #fff; color: var(--ink); border: 1px solid var(--ink); }
-.feed { max-width: 640px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
-.post { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
-.post-head { display: flex; align-items: center; gap: 12px; }
-.avatar { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
-.avatar-initials { display: grid; place-items: center; background: var(--ink); color: #fff; font-weight: 500; font-size: 14px; }
-.post-who { display: flex; flex-direction: column; font-size: 14px; min-width: 0; }
-.post-who time { color: var(--grey); font-size: 13px; }
-.post-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
-.post-media img { display: block; width: 100%; height: auto; border-radius: 8px; }
-.post-video { background: #000; border-radius: 8px; overflow: hidden; }
-.post-video-pending { color: #fff; padding: 48px 12px; text-align: center; }
-.post-video video { display: block; width: 100%; max-height: 520px; background: #000; }
-.post-stats { display: flex; gap: 16px; color: var(--grey); font-size: 14px; }
-.heart { color: var(--red); }
-.feed-message { text-align: center; color: var(--grey); padding: 32px 16px; }
-.feed-message button { margin-top: 8px; }
-.feed-center { display: grid; place-items: center; padding: 16px; }
-.spinner { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
-@keyframes spin { to { transform: rotate(360deg); } }
-.new-posts { position: sticky; top: 68px; z-index: 4; align-self: center; margin: 0; padding: 8px 16px; border-radius: 999px; }
-.sentinel { height: 1px; }
-.like-btn { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 4px 8px; background: transparent; color: var(--grey); border-radius: 8px; font-size: 14px; font-weight: 400; }
-.like-btn:hover:not(:disabled) { color: var(--red); background: #fff3f3; }
-.like-btn.liked { color: var(--red); }
-.like-btn:disabled { opacity: 1; cursor: default; }
-.like-btn:disabled:not(.liked) { color: var(--grey); }
-.like-error { color: #a8141b; font-size: 13px; align-self: center; }
-.post-stats { align-items: center; }
-.composer { background: #fff; border: 1px solid var(--line); border-radius: 0; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
-.composer-label { margin: 0; }
-.composer textarea { font: inherit; width: 100%; padding: 12px; border: 1px solid #999; border-radius: 0; resize: vertical; background: #fff; color: var(--ink); }
-.composer textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
-.composer .composer-post { align-self: flex-end; margin: 0; padding: 10px 24px; border-radius: 0; }
-.composer-media { display: flex; flex-direction: column; gap: 8px; }
-.composer-image { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; cursor: pointer; }
-.composer-image span { padding: 6px 12px; border: 1px solid #999; background: #fafafa; }
-.composer-image input[type="file"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
-.composer-preview { display: flex; align-items: center; gap: 10px; }
-.composer-preview video { width: 96px; height: 64px; object-fit: cover; border: 1px solid var(--line); background: #000; }
-.composer-preview img { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--line); }
-.composer-filename { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.composer-remove { margin: 0; padding: 6px 12px; border-radius: 0; }
+/* Global styles only (ADR 0001, section 6): layer order, tokens, reset, focus ring. */
+@layer reset, base;
-.comments { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px solid #eee; }
-.comment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
-.comment p { margin: 2px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
-.comment-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
-.comment-head time { color: var(--grey); font-size: 12px; }
-.comment.removed .comment-removed { color: var(--grey); font-style: italic; }
-.comments-empty { margin: 0; color: var(--grey); font-size: 14px; }
-.comment-error { margin: 0; color: #a8141b; font-size: 13px; }
-.comment-form { display: flex; gap: 8px; }
-.comment-form input { flex: 1; margin: 0; }
-.comment-form button { margin: 0; }
-.link-btn { background: transparent; color: inherit; text-decoration: underline; padding: 0; margin: 0; font-size: inherit; width: auto; }
-.comments-toggle { background: transparent; color: var(--grey); padding: 4px 8px; margin: 0; font-size: 14px; font-weight: 400; width: auto; }
-
-.post-menu { position: relative; margin-left: auto; }
-.menu-btn { margin: 0; padding: 2px 10px; background: transparent; color: var(--grey); border-radius: 8px; font-size: 18px; line-height: 1; letter-spacing: 1px; }
-.menu { position: absolute; right: 0; top: 100%; z-index: 5; display: flex; flex-direction: column; gap: 2px; min-width: 150px; padding: 6px; background: #fff; border: 1px solid #e3e3e3; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.12); }
-.menu button { margin: 0; text-align: left; background: transparent; color: inherit; padding: 6px 8px; border-radius: 6px; font-size: 14px; font-weight: 400; }
-.menu button:hover { background: #f4f4f4; }
-.menu .menu-danger { color: #a8141b; }
-.menu-ask { font-size: 13px; color: var(--grey); padding: 4px 8px; }
-
-/* 3-column signed-in layout: nav | feed | rails. Wraps on narrow widths. */
-.columns { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
-.col-left { flex: 0 0 180px; position: sticky; top: 72px; padding-top: 16px; }
-.col-left > ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
-.col-left a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
-.col-left a[aria-current="page"] { background: var(--ink); color: #fff; }
-.col-center { flex: 1 1 400px; min-width: 0; }
-.col-center .feed { padding-left: 0; padding-right: 0; }
-.col-right { flex: 0 0 300px; position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 20px; }
-.rail h2 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
-.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
-.rail-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; gap: 10px; }
-.expert-card { align-items: center; }
-.minnect-card { flex-direction: column; }
-.rail-text { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
-.rail-name { font-size: 14px; }
-.rail-byline { color: var(--grey); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
-.rail-meta { color: var(--grey); font-size: 13px; }
-.minnect-who { display: flex; align-items: center; gap: 8px; }
-.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
-.minnect-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--line); }
-.minnect-question { margin: 0; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
-.minnect-video { background: #000; border-radius: 0; }
-.minnect-audio { width: 100%; height: 36px; }
-@media (max-width: 959px) {
- .col-left { flex: 1 1 100%; position: static; padding-top: 8px; }
- .col-left > ul { flex-direction: row; }
- .col-center { flex: 1 1 100%; order: 3; }
- .col-right { flex: 1 1 100%; order: 2; position: static; max-height: none; overflow: visible; padding-top: 0; }
- .col-right .rail-list { flex-direction: row; overflow-x: auto; padding-bottom: 8px; }
- .col-right .rail-card { flex: 0 0 260px; }
+/* Tokens. Dark is the default, so it applies even without data-theme. */
+:root,
+:root[data-theme="dark"] {
+ --bg: #09090B;
+ --tile: #121215;
+ --tile-2: #19191D;
+ --tile-3: #232328;
+ --line: rgba(255,255,255,.07);
+ --line-2: rgba(255,255,255,.15);
+ --ink: #F4F2EE;
+ --ink-2: #BFBDB8;
+ --ink-3: #95938E;
+ --accent: #C8141C;
+ --danger: #FF6B70;
+ --glass: rgba(18,18,21,.72);
+ --shadow-pop: 0 10px 28px rgba(0,0,0,.5);
+ color-scheme: dark;
}
-/* Expert search + category chips (left column). Squared corners, monochrome + red. */
-.expert-search { margin-top: 16px; }
-.expert-search summary { font-weight: 700; font-size: 16px; cursor: pointer; padding: 4px 0; }
-.expert-search form { display: flex; flex-direction: column; }
-.expert-search input { border-radius: 0; width: 100%; }
-.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
-.chip { margin: 0; padding: 6px 10px; border-radius: 0; background: #fff; color: var(--ink); border: 1px solid var(--ink); font-size: 13px; }
-.chip[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
-.search-results { margin-top: 12px; }
-.search-note { margin: 0; font-size: 14px; color: var(--grey); }
-@media (max-width: 959px) {
- .col-left .expert-search { flex-basis: 100%; }
+:root[data-theme="light"] {
+ --bg: #EFEDE9;
+ --tile: #FBFAF8;
+ --tile-2: #F3F1EE;
+ --tile-3: #E8E5E0;
+ --line: rgba(26,28,31,.08);
+ --line-2: rgba(26,28,31,.16);
+ --ink: #1A1C1F;
+ --ink-2: #46484D;
+ --ink-3: #686A70;
+ --accent: #C8141C;
+ --danger: #B3121A;
+ --glass: rgba(251,250,248,.74);
+ --shadow-pop: 0 10px 28px rgba(26,28,31,.14);
+ color-scheme: light;
+}
+
+:root {
+ /* Crimson shades, derived from --accent (spec "Design tokens"). */
+ --accent-hi: color-mix(in srgb, var(--accent), white 26%);
+ --accent-lo: color-mix(in srgb, var(--accent), black 30%);
+ --accent-soft: color-mix(in srgb, var(--accent), transparent 88%);
+
+ /* Shape and motion. */
+ --r-panel: 18px;
+ --r-card: 16px;
+ --r-ctl: 12px;
+ --ease: cubic-bezier(.2,.8,.2,1);
+}
+
+@layer reset {
+ *, *::before, *::after { box-sizing: border-box; }
+ body { margin: 0; }
+}
+
+@layer base {
+ body { color: var(--ink); background: var(--bg); }
+ :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
}
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 0e5fac5..db848f2 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -1,7 +1,9 @@
import type { Metadata } from "next";
import type { ReactNode } from "react";
import { Roboto } from "next/font/google";
+import { DEFAULT_THEME, THEME_SCRIPT } from "@/lib/theme";
import "./globals.css";
+import "../styles/legacy.css";
const roboto = Roboto({ subsets: ["latin"], weight: ["400", "500", "700"] });
@@ -12,7 +14,11 @@ export const metadata: Metadata = {
export default function RootLayout({ children }: { children: ReactNode }) {
return (
-
+
+
+ {/* Applies the stored theme before first paint (ADR 0001, section 5). */}
+
+
{children}
);
diff --git a/src/components/Logo.tsx b/src/components/Logo.tsx
index 79ba50c..80ae0f0 100644
--- a/src/components/Logo.tsx
+++ b/src/components/Logo.tsx
@@ -1,8 +1,8 @@
export function Logo({ size = 44 }: { size?: number }) {
return (
);
}
diff --git a/src/lib/theme.ts b/src/lib/theme.ts
new file mode 100644
index 0000000..90258ce
--- /dev/null
+++ b/src/lib/theme.ts
@@ -0,0 +1,51 @@
+// Theme helper (ADR 0001, section 5). The theme is `data-theme` on ,
+// stored in localStorage under THEME_KEY. Dark is the default.
+
+export type Theme = "dark" | "light";
+
+export const THEME_KEY = "theme";
+export const DEFAULT_THEME: Theme = "dark";
+
+type ReadableStorage = Pick;
+type WritableStorage = Pick;
+type ThemeRoot = { dataset: DOMStringMap; style: { colorScheme: string } };
+
+export function isTheme(value: unknown): value is Theme {
+ return value === "dark" || value === "light";
+}
+
+/** The stored theme, or dark when nothing valid is stored or storage throws. */
+export function readStoredTheme(storage: ReadableStorage | null | undefined): Theme {
+ try {
+ const value = storage?.getItem(THEME_KEY);
+ return isTheme(value) ? value : DEFAULT_THEME;
+ } catch {
+ return DEFAULT_THEME;
+ }
+}
+
+/** The theme currently on the root element, or dark when it is missing. */
+export function currentTheme(root: ThemeRoot | null | undefined): Theme {
+ const value = root?.dataset.theme;
+ return isTheme(value) ? value : DEFAULT_THEME;
+}
+
+/**
+ * Set the theme on the root element and store it. A failed write still
+ * changes the theme for this session.
+ */
+export function applyTheme(theme: Theme, root: ThemeRoot, storage: WritableStorage | null | undefined): void {
+ root.dataset.theme = theme;
+ root.style.colorScheme = theme;
+ try {
+ storage?.setItem(THEME_KEY, theme);
+ } catch {
+ // Storage blocked or full: keep the theme for this session only.
+ }
+}
+
+/**
+ * Inline script for the first child of . It runs before first paint, so
+ * a stored light theme never flashes dark. Fixed string, no user input.
+ */
+export const THEME_SCRIPT = `(function(){var t="${DEFAULT_THEME}";try{var s=localStorage.getItem("${THEME_KEY}");if(s==="light"||s==="dark")t=s;}catch(e){}var r=document.documentElement;r.dataset.theme=t;r.style.colorScheme=t;})();`;
diff --git a/src/lib/use-theme.ts b/src/lib/use-theme.ts
new file mode 100644
index 0000000..11ac027
--- /dev/null
+++ b/src/lib/use-theme.ts
@@ -0,0 +1,44 @@
+"use client";
+
+import { useCallback, useSyncExternalStore } from "react";
+import { applyTheme, currentTheme, DEFAULT_THEME, THEME_KEY, type Theme } from "./theme";
+
+const listeners = new Set<() => void>();
+
+function subscribe(listener: () => void): () => void {
+ listeners.add(listener);
+ const onStorage = (event: StorageEvent) => {
+ // Another tab changed the theme: follow it.
+ if (event.key !== THEME_KEY) return;
+ const next = event.newValue === "light" || event.newValue === "dark" ? event.newValue : DEFAULT_THEME;
+ applyTheme(next, document.documentElement, null);
+ listeners.forEach((l) => l());
+ };
+ window.addEventListener("storage", onStorage);
+ return () => {
+ listeners.delete(listener);
+ window.removeEventListener("storage", onStorage);
+ };
+}
+
+const getSnapshot = (): Theme => currentTheme(document.documentElement);
+const getServerSnapshot = (): Theme => DEFAULT_THEME;
+
+function safeStorage(): Storage | null {
+ try {
+ return window.localStorage;
+ } catch {
+ return null;
+ }
+}
+
+/** Shared theme state for every toggle: the current theme and a setter. */
+export function useTheme(): { theme: Theme; setTheme: (theme: Theme) => void; toggleTheme: () => void } {
+ const theme = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
+ const setTheme = useCallback((next: Theme) => {
+ applyTheme(next, document.documentElement, safeStorage());
+ listeners.forEach((l) => l());
+ }, []);
+ const toggleTheme = useCallback(() => setTheme(getSnapshot() === "dark" ? "light" : "dark"), [setTheme]);
+ return { theme, setTheme, toggleTheme };
+}
diff --git a/src/styles/legacy.css b/src/styles/legacy.css
new file mode 100644
index 0000000..0d6898f
--- /dev/null
+++ b/src/styles/legacy.css
@@ -0,0 +1,130 @@
+/* Pre-redesign component rules, recolored with the tokens so the current
+ screens stay readable in both themes. Each redesign component task moves its
+ rules into its own file in src/styles/ (ADR 0001, section 6) and deletes them
+ here; the file goes when it is empty. Do not add new rules here.
+ Literal white and black are only text on crimson and video letterboxing. */
+.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
+.card { width: 100%; max-width: 400px; background: var(--tile); border: 1px solid var(--line); border-radius: 8px; padding: 32px 24px; display: flex; flex-direction: column; gap: 8px; }
+.card h1 { font-size: 22px; margin: 12px 0 8px; }
+label { font-size: 14px; font-weight: 500; margin-top: 8px; }
+input { font: inherit; padding: 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--tile-2); color: var(--ink); }
+input:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
+button { font: inherit; font-weight: 500; margin-top: 16px; padding: 12px; border: 0; border-radius: 8px; background: var(--accent); color: white; cursor: pointer; }
+button:disabled { opacity: .5; cursor: not-allowed; }
+.error { margin: 0 0 4px; padding: 10px 12px; border: 1px solid var(--accent); border-radius: 8px; color: var(--danger); background: var(--accent-soft); font-size: 14px; }
+.shell header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--tile); border-bottom: 1px solid var(--line); }
+.shell header div { display: flex; flex-direction: column; font-size: 14px; }
+.shell header span { color: var(--ink-3); }
+.shell header { position: sticky; top: 0; z-index: 5; }
+.shell header button { margin: 0 0 0 auto; padding: 8px 14px; background: transparent; color: var(--ink); border: 1px solid var(--ink); }
+.feed { max-width: 640px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
+.post { background: var(--tile); border: 1px solid var(--line); border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
+.post-head { display: flex; align-items: center; gap: 12px; }
+.avatar { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
+.avatar-initials { display: grid; place-items: center; background: var(--ink); color: var(--bg); font-weight: 500; font-size: 14px; }
+.post-who { display: flex; flex-direction: column; font-size: 14px; min-width: 0; }
+.post-who time { color: var(--ink-3); font-size: 13px; }
+.post-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
+.post-media img { display: block; width: 100%; height: auto; border-radius: 8px; }
+.post-video { background: black; border-radius: 8px; overflow: hidden; }
+.post-video-pending { color: white; padding: 48px 12px; text-align: center; }
+.post-video video { display: block; width: 100%; max-height: 520px; background: black; }
+.post-stats { display: flex; gap: 16px; color: var(--ink-3); font-size: 14px; }
+.heart { color: var(--accent); }
+.feed-message { text-align: center; color: var(--ink-3); padding: 32px 16px; }
+.feed-message button { margin-top: 8px; }
+.feed-center { display: grid; place-items: center; padding: 16px; }
+.spinner { width: 24px; height: 24px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
+@keyframes spin { to { transform: rotate(360deg); } }
+.new-posts { position: sticky; top: 68px; z-index: 4; align-self: center; margin: 0; padding: 8px 16px; border-radius: 999px; }
+.sentinel { height: 1px; }
+.like-btn { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 4px 8px; background: transparent; color: var(--ink-3); border-radius: 8px; font-size: 14px; font-weight: 400; }
+.like-btn:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
+.like-btn.liked { color: var(--accent); }
+.like-btn:disabled { opacity: 1; cursor: default; }
+.like-btn:disabled:not(.liked) { color: var(--ink-3); }
+.like-error { color: var(--danger); font-size: 13px; align-self: center; }
+.post-stats { align-items: center; }
+.composer { background: var(--tile); border: 1px solid var(--line); border-radius: 0; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
+.composer-label { margin: 0; }
+.composer textarea { font: inherit; width: 100%; padding: 12px; border: 1px solid var(--line-2); border-radius: 0; resize: vertical; background: var(--tile-2); color: var(--ink); }
+.composer textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
+.composer .composer-post { align-self: flex-end; margin: 0; padding: 10px 24px; border-radius: 0; }
+.composer-media { display: flex; flex-direction: column; gap: 8px; }
+.composer-image { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; cursor: pointer; }
+.composer-image span { padding: 6px 12px; border: 1px solid var(--line-2); background: var(--tile-2); }
+.composer-image input[type="file"] { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }
+.composer-preview { display: flex; align-items: center; gap: 10px; }
+.composer-preview video { width: 96px; height: 64px; object-fit: cover; border: 1px solid var(--line); background: black; }
+.composer-preview img { width: 64px; height: 64px; object-fit: cover; border: 1px solid var(--line); }
+.composer-filename { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.composer-remove { margin: 0; padding: 6px 12px; border-radius: 0; }
+
+.comments { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
+.comment-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
+.comment p { margin: 2px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
+.comment-head { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
+.comment-head time { color: var(--ink-3); font-size: 12px; }
+.comment.removed .comment-removed { color: var(--ink-3); font-style: italic; }
+.comments-empty { margin: 0; color: var(--ink-3); font-size: 14px; }
+.comment-error { margin: 0; color: var(--danger); font-size: 13px; }
+.comment-form { display: flex; gap: 8px; }
+.comment-form input { flex: 1; margin: 0; }
+.comment-form button { margin: 0; }
+.link-btn { background: transparent; color: inherit; text-decoration: underline; padding: 0; margin: 0; font-size: inherit; width: auto; }
+.comments-toggle { background: transparent; color: var(--ink-3); padding: 4px 8px; margin: 0; font-size: 14px; font-weight: 400; width: auto; }
+
+.post-menu { position: relative; margin-left: auto; }
+.menu-btn { margin: 0; padding: 2px 10px; background: transparent; color: var(--ink-3); border-radius: 8px; font-size: 18px; line-height: 1; letter-spacing: 1px; }
+.menu { position: absolute; right: 0; top: 100%; z-index: 5; display: flex; flex-direction: column; gap: 2px; min-width: 150px; padding: 6px; background: var(--tile); border: 1px solid var(--line-2); border-radius: 10px; box-shadow: var(--shadow-pop); }
+.menu button { margin: 0; text-align: left; background: transparent; color: inherit; padding: 6px 8px; border-radius: 6px; font-size: 14px; font-weight: 400; }
+.menu button:hover { background: var(--tile-2); }
+.menu .menu-danger { color: var(--danger); }
+.menu-ask { font-size: 13px; color: var(--ink-3); padding: 4px 8px; }
+
+/* 3-column signed-in layout: nav | feed | rails. Wraps on narrow widths. */
+.columns { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
+.col-left { flex: 0 0 180px; position: sticky; top: 72px; padding-top: 16px; }
+.col-left > ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
+.col-left a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 500; }
+.col-left a[aria-current="page"] { background: var(--ink); color: var(--bg); }
+.col-center { flex: 1 1 400px; min-width: 0; }
+.col-center .feed { padding-left: 0; padding-right: 0; }
+.col-right { flex: 0 0 300px; position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 20px; }
+.rail h2 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
+.rail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
+.rail-card { background: var(--tile); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; gap: 10px; }
+.expert-card { align-items: center; }
+.minnect-card { flex-direction: column; }
+.rail-text { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
+.rail-name { font-size: 14px; }
+.rail-byline { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.rail-meta { color: var(--ink-3); font-size: 13px; }
+.minnect-who { display: flex; align-items: center; gap: 8px; }
+.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
+.minnect-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: var(--line); }
+.minnect-question { margin: 0; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
+.minnect-video { background: black; border-radius: 0; }
+.minnect-audio { width: 100%; height: 36px; }
+@media (max-width: 959px) {
+ .col-left { flex: 1 1 100%; position: static; padding-top: 8px; }
+ .col-left > ul { flex-direction: row; }
+ .col-center { flex: 1 1 100%; order: 3; }
+ .col-right { flex: 1 1 100%; order: 2; position: static; max-height: none; overflow: visible; padding-top: 0; }
+ .col-right .rail-list { flex-direction: row; overflow-x: auto; padding-bottom: 8px; }
+ .col-right .rail-card { flex: 0 0 260px; }
+}
+
+/* Expert search + category chips (left column). Squared corners, monochrome + red. */
+.expert-search { margin-top: 16px; }
+.expert-search summary { font-weight: 700; font-size: 16px; cursor: pointer; padding: 4px 0; }
+.expert-search form { display: flex; flex-direction: column; }
+.expert-search input { border-radius: 0; width: 100%; }
+.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
+.chip { margin: 0; padding: 6px 10px; border-radius: 0; background: transparent; color: var(--ink); border: 1px solid var(--ink); font-size: 13px; }
+.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: white; }
+.search-results { margin-top: 12px; }
+.search-note { margin: 0; font-size: 14px; color: var(--ink-3); }
+@media (max-width: 959px) {
+ .col-left .expert-search { flex-basis: 100%; }
+}
diff --git a/tests/theme.test.ts b/tests/theme.test.ts
new file mode 100644
index 0000000..efaac74
--- /dev/null
+++ b/tests/theme.test.ts
@@ -0,0 +1,103 @@
+import { describe, expect, it } from "vitest";
+import { readFileSync, readdirSync, statSync } from "node:fs";
+import path from "node:path";
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { applyTheme, currentTheme, readStoredTheme, THEME_KEY, THEME_SCRIPT } from "@/lib/theme";
+import { useTheme } from "@/lib/use-theme";
+
+const memoryStorage = (initial: Record = {}) => {
+ const data = new Map(Object.entries(initial));
+ return {
+ data,
+ getItem: (k: string) => data.get(k) ?? null,
+ setItem: (k: string, v: string) => void data.set(k, v),
+ };
+};
+const throwingStorage = {
+ getItem: () => {
+ throw new Error("blocked");
+ },
+ setItem: () => {
+ throw new Error("blocked");
+ },
+};
+const fakeRoot = () => ({ dataset: {} as DOMStringMap, style: { colorScheme: "" } });
+
+describe("readStoredTheme", () => {
+ it("is dark on a first visit", () => {
+ expect(readStoredTheme(memoryStorage())).toBe("dark");
+ expect(readStoredTheme(null)).toBe("dark");
+ });
+ it("returns a stored light or dark choice", () => {
+ expect(readStoredTheme(memoryStorage({ [THEME_KEY]: "light" }))).toBe("light");
+ expect(readStoredTheme(memoryStorage({ [THEME_KEY]: "dark" }))).toBe("dark");
+ });
+ it("ignores junk values and storage that throws", () => {
+ expect(readStoredTheme(memoryStorage({ [THEME_KEY]: "neon" }))).toBe("dark");
+ expect(readStoredTheme(throwingStorage)).toBe("dark");
+ });
+});
+
+describe("applyTheme", () => {
+ it("sets the attribute and color-scheme and stores the choice", () => {
+ const root = fakeRoot();
+ const storage = memoryStorage();
+ applyTheme("light", root, storage);
+ expect(root.dataset.theme).toBe("light");
+ expect(root.style.colorScheme).toBe("light");
+ expect(storage.data.get(THEME_KEY)).toBe("light");
+ expect(currentTheme(root)).toBe("light");
+ });
+ it("still changes the theme when storage throws", () => {
+ const root = fakeRoot();
+ expect(() => applyTheme("light", root, throwingStorage)).not.toThrow();
+ expect(root.dataset.theme).toBe("light");
+ });
+ it("reads a missing attribute as dark", () => {
+ expect(currentTheme(fakeRoot())).toBe("dark");
+ });
+});
+
+describe("THEME_SCRIPT (pre-paint)", () => {
+ const run = (storage: unknown) => {
+ const documentElement = fakeRoot();
+ new Function("localStorage", "document", THEME_SCRIPT)(storage, { documentElement });
+ return documentElement;
+ };
+ it("applies a stored light theme", () => {
+ expect(run(memoryStorage({ [THEME_KEY]: "light" })).dataset.theme).toBe("light");
+ });
+ it("falls back to dark for nothing stored, junk, or throwing storage", () => {
+ expect(run(memoryStorage()).dataset.theme).toBe("dark");
+ expect(run(memoryStorage({ [THEME_KEY]: "x" })).dataset.theme).toBe("dark");
+ expect(run(throwingStorage).dataset.theme).toBe("dark");
+ });
+});
+
+describe("useTheme", () => {
+ it("renders dark on the server", () => {
+ let seen = "";
+ const Probe = () => {
+ seen = useTheme().theme;
+ return null;
+ };
+ renderToStaticMarkup(createElement(Probe));
+ expect(seen).toBe("dark");
+ });
+});
+
+describe("no raw colors outside the token definitions", () => {
+ const files = (dir: string): string[] =>
+ readdirSync(dir).flatMap((f) => {
+ const p = path.join(dir, f);
+ return statSync(p).isDirectory() ? files(p) : [p];
+ });
+ it("has no hex color in any source file except globals.css", () => {
+ const src = path.resolve(__dirname, "../src");
+ const offenders = files(src)
+ .filter((f) => /\.(tsx?|css)$/.test(f) && !f.endsWith(path.join("app", "globals.css")))
+ .filter((f) => /#[0-9a-fA-F]{3,8}\b|rgba?\(/.test(readFileSync(f, "utf8")));
+ expect(offenders).toEqual([]);
+ });
+});