diff --git a/apps/web/src/lib/stores/auth-store.ts b/apps/web/src/lib/stores/auth-store.ts index dbb2f55..026b004 100644 --- a/apps/web/src/lib/stores/auth-store.ts +++ b/apps/web/src/lib/stores/auth-store.ts @@ -20,17 +20,25 @@ interface AuthState { function applyAccentColor(color: string | null | undefined) { if (typeof document === 'undefined') return; + const root = document.documentElement; if (color) { - document.documentElement.style.setProperty('--primary', color); - document.documentElement.style.setProperty('--ring', color); + root.style.setProperty('--primary', color); + root.style.setProperty('--ring', color); // Sidebar active state: accent color with 15% opacity (#rrggbbaa, 0x26 ≈ 15%) - document.documentElement.style.setProperty('--sidebar-accent', `${color}26`); - document.documentElement.style.setProperty('--sidebar-accent-foreground', color); + root.style.setProperty('--sidebar-accent', `${color}26`); + // Full-saturation accent text only reads well against the dark-mode sidebar's + // tinted-dark background; in light mode it's near-white behind it, so keep + // the theme's default (dark, high-contrast) foreground there instead. + if (root.classList.contains('dark')) { + root.style.setProperty('--sidebar-accent-foreground', color); + } else { + root.style.removeProperty('--sidebar-accent-foreground'); + } } else { - document.documentElement.style.removeProperty('--primary'); - document.documentElement.style.removeProperty('--ring'); - document.documentElement.style.removeProperty('--sidebar-accent'); - document.documentElement.style.removeProperty('--sidebar-accent-foreground'); + root.style.removeProperty('--primary'); + root.style.removeProperty('--ring'); + root.style.removeProperty('--sidebar-accent'); + root.style.removeProperty('--sidebar-accent-foreground'); } }