···11+# Theme System Documentation
22+33+The color theme system is now centralized and easy to extend. All theme definitions are managed through a single configuration file.
44+55+## Architecture
66+77+- **`/src/lib/config/themes.config.ts`** - Central theme configuration (add new themes here)
88+- **`/src/lib/stores/colorTheme.ts`** - Theme state management
99+- **`/src/lib/components/layout/ColorThemeToggle.svelte`** - Theme picker UI
1010+- **`/src/lib/styles/themes/*.css`** - Individual theme CSS files
1111+- **`/src/lib/styles/themes.css`** - Theme CSS imports
1212+1313+## Adding a New Theme
1414+1515+To add a new theme, follow these steps:
1616+1717+### 1. Add Theme Definition to Config
1818+1919+Edit `/src/lib/config/themes.config.ts` and add your theme to the `THEMES` array:
2020+2121+```typescript
2222+{
2323+ value: 'midnight', // Unique identifier (used in CSS and localStorage)
2424+ label: 'Midnight', // Display name in dropdown
2525+ description: 'Deep night', // Short description
2626+ color: 'oklch(20% 0.05 240)', // Preview color (shown in dropdown)
2727+ category: 'cool' // 'neutral' | 'warm' | 'cool' | 'vibrant'
2828+}
2929+```
3030+3131+### 2. Create Theme CSS File
3232+3333+Create `/src/lib/styles/themes/midnight.css` with your color definitions:
3434+3535+```css
3636+/* ============================================================================
3737+ MIDNIGHT THEME - Deep night
3838+ Primary: Dark blue
3939+ Secondary: Navy
4040+ Accent: Steel
4141+ Hue: 240° (blue)
4242+ ============================================================================ */
4343+[data-color-theme='midnight'] {
4444+ /* Define your CSS custom properties here */
4545+ --color-primary-500: oklch(20% 0.05 240);
4646+ /* ... other color definitions ... */
4747+}
4848+```
4949+5050+### 3. Import Theme CSS
5151+5252+Add the import to `/src/lib/styles/themes.css`:
5353+5454+```css
5555+@import './themes/midnight.css';
5656+```
5757+5858+## That's It!
5959+6060+The theme will automatically:
6161+- ✅ Appear in the color theme dropdown
6262+- ✅ Be type-safe in TypeScript
6363+- ✅ Work with the theme switcher
6464+- ✅ Persist in localStorage
6565+6666+## Configuration API
6767+6868+### `THEMES`
6969+Array of all available themes. Each theme has:
7070+- `value`: Unique identifier (string)
7171+- `label`: Display name (string)
7272+- `description`: Short description (string)
7373+- `color`: Preview color in OKLCH format (string)
7474+- `category`: Theme category (string)
7575+7676+### `ColorTheme`
7777+TypeScript type automatically generated from theme values.
7878+7979+### `DEFAULT_THEME`
8080+The default theme used when no preference is stored.
8181+8282+### `getThemesByCategory()`
8383+Returns themes organized by category for UI rendering.
8484+8585+### `getTheme(value)`
8686+Get a specific theme definition by its value.
8787+8888+## Example: Adding Multiple Themes
8989+9090+```typescript
9191+// In themes.config.ts
9292+export const THEMES: readonly ThemeDefinition[] = [
9393+ // ... existing themes ...
9494+9595+ // New themes
9696+ {
9797+ value: 'midnight',
9898+ label: 'Midnight',
9999+ description: 'Deep night',
100100+ color: 'oklch(20% 0.05 240)',
101101+ category: 'cool'
102102+ },
103103+ {
104104+ value: 'sunrise',
105105+ label: 'Sunrise',
106106+ description: 'Morning glow',
107107+ color: 'oklch(75% 0.15 50)',
108108+ category: 'warm'
109109+ }
110110+] as const;
111111+```
112112+113113+Then create `midnight.css` and `sunrise.css` in the themes folder, and import them in `themes.css`.