A comprehensive guide to the modular CSS architecture for the Tasks-v2 PWA
The Tasks-v2 project uses a modular CSS architecture that replaces the previous monolithic approach. Instead of one large CSS file, we now have 12 focused modules that are easier to maintain, debug, and scale.
- ✅ Separation of Concerns: Each file has a specific purpose
- ✅ Easy Debugging: Know exactly where to look for issues
- ✅ Scalable: Add new features without breaking existing code
- ✅ Team-Friendly: Multiple developers can work on different files
- ✅ Performance: Better browser caching and load optimization
css/
├── core/ ← Foundational styles
│ ├── variables.css ← CSS custom properties (colors, fonts, etc.)
│ ├── base.css ← Typography, resets, general styles
│ └── animations.css ← Keyframes and animation utilities
├── themes/ ← Theme variations
│ ├── modern.css ← Modern theme (default Bootstrap-style)
│ └── retro.css ← Retro theme (terminal/hacker aesthetic)
├── components/ ← Reusable UI components
│ ├── buttons.css ← All button variants and states
│ ├── cards.css ← Card layouts and containers
│ ├── forms.css ← Form controls, inputs, validation
│ ├── navigation.css ← Header, navbar, navigation elements
│ └── tasks.css ← Task-specific components
├── pages/ ← Page-specific styles
│ ├── index.css ← Main page layouts and sections
│ └── about.css ← About page specific styling
├── utilities/ ← Helper utilities
│ ├── responsive.css ← Media queries and responsive utilities
│ └── accessibility.css ← Focus states, a11y, reduced motion
├── styles.css ← 🎯 MAIN FILE (imports all others)
└── styles-monolithic-backup.css ← Backup of old monolithic file
| What you're working on | File to modify | Example |
|---|---|---|
| Colors, fonts, theme variables | core/variables.css |
Changing accent color, adding new theme variable |
| Typography, general layout | core/base.css |
Font sizes, line heights, container styles |
| Animations, transitions | core/animations.css |
Adding new keyframes, transition effects |
| Button styling | components/buttons.css |
Button colors, hover effects, new button variants |
| Form inputs, validation | components/forms.css |
Input styling, error states, form layouts |
| Header, navbar, navigation | components/navigation.css |
Logo styling, menu items, navigation behavior |
| Task items, task list | components/tasks.css |
Task cards, completion states, task actions |
| Card containers, layouts | components/cards.css |
Card shadows, borders, card layouts |
| Home page specific layout | pages/index.css |
Welcome section, task input area, page structure |
| About page specific layout | pages/about.css |
Hero section, feature grid, README container |
| Mobile responsiveness | utilities/responsive.css |
Breakpoints, mobile layouts, responsive utilities |
| Focus states, accessibility | utilities/accessibility.css |
Keyboard navigation, screen reader support |
| Modern theme styling | themes/modern.css |
Professional, Bootstrap-style overrides |
| Retro theme styling | themes/retro.css |
Terminal, neon, hacker aesthetic |
- Variables (
core/variables.css) define colors for both themes - Theme files (
themes/modern.css,themes/retro.css) override these variables - Components use CSS custom properties that adapt automatically
/* 1. Add theme variables in core/variables.css */
[data-theme="dark"] {
--primary-bg: #1a1a1a;
--text-primary: #ffffff;
--accent-color: #6366f1;
/* ... more variables */
}
/* 2. Create themes/dark.css with theme-specific overrides */
[data-theme="dark"] .card {
box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1);
}
/* 3. Import in styles.css */
@import url('themes/dark.css');- HTML:
<html data-theme="modern">or<html data-theme="retro"> - JavaScript:
document.documentElement.setAttribute('data-theme', 'retro')
- Create the component file (e.g.,
components/modals.css) - Follow the naming pattern:
/* Modal Component Styles for Tasks-v2 */ /* Modal dialogs, overlays, and popup styling */ /* ===== BASE MODAL STYLES ===== */ .modal { /* Base styles using CSS custom properties */ } /* ===== THEME OVERRIDES ===== */ [data-theme="retro"] .modal { /* Retro-specific styling */ } /* ===== RESPONSIVE ===== */ @media (max-width: 768px) { .modal { /* Mobile adjustments */ } }
- Import in
styles.css:@import url('components/modals.css');
- ✅ Use CSS custom properties (
var(--accent-color)) instead of hardcoded values - ✅ Include both modern and retro theme overrides
- ✅ Add responsive breakpoints
- ✅ Follow the established naming conventions
- ✅ Include accessibility considerations
/* Mobile First Approach */
.component { /* Mobile styles (default) */ }
@media (min-width: 576px) { /* Small tablets */ }
@media (min-width: 768px) { /* Tablets */ }
@media (min-width: 992px) { /* Desktop */ }
@media (min-width: 1200px) { /* Large desktop */ }- Component-specific responsive: Add to the component file
- Global responsive utilities: Add to
utilities/responsive.css - Page-specific responsive: Add to the appropriate page file
- Focus States: Clear, visible focus indicators
- High Contrast: Support for
prefers-contrast: high - Reduced Motion: Respect
prefers-reduced-motion: reduce - Touch Targets: Minimum 44px for touch devices
- Screen Readers: Proper ARIA labels and semantic HTML
- Global a11y utilities:
utilities/accessibility.css - Component-specific a11y: Within the component file
- Theme-specific a11y: Within the theme file
1. Open components/buttons.css
2. Find the relevant button class (.btn, .btn-primary, etc.)
3. Make changes
4. Test in both Modern and Retro themes
5. Check responsive behavior1. Create pages/new-page.css
2. Add page-specific styles following the pattern
3. Import in styles.css: @import url('pages/new-page.css');
4. Test across all themes and breakpoints1. Open core/variables.css
2. Modify CSS custom properties in :root (modern) or [data-theme="retro"]
3. Changes will automatically apply across all components
4. Test thoroughly across all pages and components1. Identify what type of element has the issue
2. Use the Quick Decision Guide to find the right file
3. Use browser dev tools to confirm which file contains the styles
4. Make targeted changes in the appropriate file- Single import chain:
styles.cssimports all modules - Browser caching: Individual modules can be cached separately
- Critical path: Core styles load first, utilities last
- ✅ Keep individual files under 500 lines
- ✅ Avoid deep nesting (max 3 levels)
- ✅ Use CSS custom properties instead of repeated values
- ✅ Group related styles together
- ✅ Comment complex sections
- Check browser dev tools Network tab for failed imports
- Verify file paths in
styles.cssare correct - Check for syntax errors in individual files
- Ensure server is serving
.cssfiles properly
- Check CSS specificity (avoid
!important) - Verify theme attribute:
<html data-theme="modern"> - Check if styles are in the right file according to the architecture
- Use browser dev tools to see which styles are being overridden
- Check JavaScript theme switching logic
- Verify CSS custom properties are defined for both themes
- Check that theme-specific overrides use correct selectors
- Test with browser dev tools by manually changing
data-theme
- Right file: Changes are in the appropriate file according to architecture
- CSS variables: Used custom properties instead of hardcoded values
- Both themes: Tested in both Modern and Retro themes
- Responsive: Works across all breakpoints (mobile, tablet, desktop)
- Accessibility: Includes proper focus states and a11y considerations
- Performance: No unnecessary
!importantdeclarations - Comments: Complex sections are well-documented
- Consistency: Follows established patterns and naming conventions
- Start here: Review
styles.cssto understand the import structure - Study patterns: Look at existing component files for structure examples
- CSS Custom Properties: Learn how our theming system works
- Responsive Design: Understand our mobile-first approach
core/variables.css- Understand the theming systemcore/base.css- See foundational stylescomponents/buttons.css- Good example of component structurethemes/retro.css- Understanding theme overridesutilities/responsive.css- Responsive patterns
Q: "Where do I add global styles?"
A: core/base.css for typography and layout, core/variables.css for colors and theme variables.
Q: "How do I add a new color?"
A: Add CSS custom property in core/variables.css for both themes, then use var(--your-color) in components.
Q: "My responsive styles aren't working."
A: Check if you're using mobile-first approach and that breakpoints match our standard breakpoints.
Q: "How do I test both themes?"
A: Use browser dev tools to change data-theme attribute, or use the theme toggle button in the app.
Q: "Can I modify the import order in styles.css?"
A: Only with careful consideration - the order prevents specificity conflicts and ensures proper cascade.
styles.css→ Main import file (don't add styles here)core/*→ Foundation (variables, base styles, animations)themes/*→ Theme variations (modern, retro)components/*→ UI components (buttons, forms, cards, etc.)pages/*→ Page-specific layoutsutilities/*→ Helper utilities (responsive, accessibility)
--primary-bg→ Background colors--text-primary→ Text colors--accent-color→ Interactive elements--border-color→ Borders and lines--success-color→ Status colors
Remember: When in doubt, check existing patterns in similar files! 🎯
Last updated: July 2025 | Tasks-v2 Modular CSS Architecture