2.22 Theme System & CSS Variables Reference
The Theme System is how RAIA's documentation stays consistent and adaptive. Instead of hardcoding colors like #4f46e5 everywhere, we use CSS variables like var(--blue). This means if we want to change the brand color site-wide, we update one line instead of hunting through 50 files. It also powers dark mode automatically.
The Theme System is how RAIA's documentation stays consistent and adaptive. Instead of hardcoding colors like #4f46e5 everywhere, we use CSS variables like var(--blue). This means if we want to change the brand color site-wide, we update one line instead of hunting through 50 files. It also powers dark mode automatically.
The unified CSS variable system powering adaptive theming, dark mode support, and consistent visual identity across all RAIA (Real estate Artificial Intelligence Agent) documentation and portal surfaces.
Section A What Is the Theme System?
The Theme System is RAIA's centralized approach to styling. Instead of hardcoding colors, fonts, and spacing values throughout the codebase, we define them once as CSS custom properties (variables) and reference them everywhere. This creates a single source of truth for the entire visual identity.
Why CSS Variables?
CSS variables solve three critical problems that plague traditional styling approaches:
- Hardcoded hex colors scattered everywhere
- Find-and-replace nightmares on rebrand
- Dark mode requires duplicate stylesheets
- Impossible to maintain consistency
- One definition, infinite references
- Update once, propagates everywhere
- Dark mode is just variable swapping
- Enforced consistency by design
Section B Using Themes
Color Palette
RAIA (Real estate Artificial Intelligence Agent) uses a carefully curated color system built around three brand colors:
| Variable | Value | Usage | Sample |
|---|---|---|---|
--blue |
#4f46e5 | Primary brand color, CTAs, links | |
--sky |
#0ea5e9 | Info states, data visualization | |
--green |
#059669 | Success states, verified badges | |
--amber |
#d97706 | Warnings, dev-only sections | |
--red |
#dc2626 | Errors, critical alerts |
Typography
Two font stacks power all RAIA (Real estate Artificial Intelligence Agent) surfaces:
/* Body Text */ --font-body: 'Inter', system-ui, sans-serif; /* Code & Monospace */ --font-mono: 'JetBrains Mono', 'Menlo', monospace;
Write font-family: var(--font-body), not font-family: 'Inter'. This ensures fallback fonts work correctly and future font changes propagate automatically.
Spacing & Layout
Surface colors create visual hierarchy and depth:
-
1
--bg— Page BackgroundThe base canvas. Usually
#ffffffin light mode,#0d1117in dark mode. -
2
--bg-card— Card SurfacesSlightly elevated surfaces for content cards. Creates subtle depth on top of
--bg. -
3
--bg-elev— Elevated SurfacesHeaders, sticky nav, modals. The highest layer in the surface hierarchy.
Section C Architecture
Complete Variable Reference
| Category | Variable | Light Value | Dark Value |
|---|---|---|---|
| Surfaces | --bg |
#ffffff | #0d1117 |
--bg-card |
#f9fafb | #161b22 | |
--bg-elev |
#f3f4f6 | #1c2128 | |
| Text | --text |
#111827 | #e6edf3 |
--text-dim |
#6b7280 | #7d8590 | |
--text-faint |
#9ca3af | #484f58 | |
| Borders | --border |
#e5e7eb | #30363d |
--border-bright |
#c7d2fe | #6366f1 |
Dark Mode Implementation
Dark mode is implemented via theme.js, which runs before first paint:
// theme.js
(function() {
const savedTheme = localStorage.getItem('theme');
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = savedTheme || (prefersDark ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', theme);
})();
Always load theme.js in <head> before any CSS. If it loads after, users see a white flash on dark mode loads.
Migration Guide: Hardcoded Colors → Variables
When auditing old files, use these regex patterns to find and replace hardcoded colors:
# Find all hex colors
grep -rn "#[0-9a-fA-F]\{6\}" docs/raw/*.html
# Replace common patterns
sed -i 's/color:#4f46e5/color:var(--blue)/g' file.html
sed -i 's/background:#ffffff/background:var(--bg)/g' file.html
sed -i 's/border.*#e5e7eb/border-color:var(--border)/g' file.html
The unify_docs.py compiler includes a linter that warns when hardcoded hex colors are found in raw HTML files. These warnings appear during compilation but don't block the build.