const KEY = 'grid-cols'; const MIN = 2; const MAX = 8; class DensityStore { cols = $state(5); init() { if (typeof window === 'undefined') return; const v = parseInt(localStorage.getItem(KEY) ?? '', 10); if (v >= MIN && v <= MAX) this.cols = v; } set(value: number) { this.cols = Math.min(MAX, Math.max(MIN, Math.round(value))); if (typeof window !== 'undefined') localStorage.setItem(KEY, String(this.cols)); } } export const density = new DensityStore();