Break up the 4000-line monolithic styles.css into component-scoped CSS modules that work with React's rendering model instead of fighting it. Eliminate all !important rules that conflict with React state, remove dead CSS from the legacy migration, and organize styles by component. The site uses React 19 + Vite + TypeScript with Tailwind configured but mostly unused. The goal is CSS that is maintainable, doesn't cause bugs when React re-renders, and is co-located with the components it styles.
User notes and answers:
Run autonomously through the full critique loop until gate passes. Key context: (1) The site was recently migrated from vanilla JS to React 19 components. The old styles.css was kept wholesale during migration. (2) The loading-element opacity:0 !important bug was the worst example — CSS !important rules hiding elements that React re-renders caused persistent disappearing content. Fixed by switching to data attributes. (3) There's also an existing CSS/Tailwind megaplan (design-a-sensible-well-20260323-0631) that planned incremental Tailwind adoption — this plan should be compatible with that. (4) CSS modules (.module.css) are the natural fit since Vite supports them natively. (5) Tailwind is configured but barely used — the plan should decide what gets Tailwind utilities vs CSS modules vs stays global. (6) Many CSS rules are dead code from features that were rewritten as React components (the legacy JS was deleted). (7) There are duplicate/conflicting declarations in styles.css (e.g., transition: all on line 374 overridden on line 384).
User preference: Use Tailwind utilities for one-off styling (margins, padding, simple layout). Use well-structured CSS (modules or scoped files) for repeated patterns, animations, and complex component styles. This is the pragmatic hybrid approach — Tailwind for utility, CSS for design system patterns.
Current state: A 4,096-line monolithic styles.css containing 100% of the site's styling, 193 !important declarations, dead CSS from a completed vanilla-JS-to-React migration, and duplicate/conflicting rules. Tailwind v3.4 is configured but unused. No CSS modules exist.
Goal: Co-locate styles with React components using CSS modules (.module.css), eliminate rules that fight React state, remove dead code, and establish a pragmatic hybrid where Tailwind handles one-off utility styling and CSS modules handle complex/repeated patterns.
Key constraint: The existing megaplan (design-a-sensible-well-20260323-0631) planned incremental Tailwind adoption. That plan assumed dangerouslySetInnerHTML on Home and legacy JS — both are now gone. This plan supersedes the classification phase of that plan, since CSS modules are the primary extraction target, with Tailwind as the utility layer. The two plans are compatible: this one does the structural decomposition, and Tailwind adoption can continue incrementally afterward.
Important discovery: The v2 megaplan's "frozen classes" list (classes queried by legacy JS) is stale — src/legacy/script.ts no longer exists. All DOM manipulation is now in React hooks (useCardExpansion, useFilterSystem, useLoadingStagger, useTruncationDetector). Class names are still used in React component JSX, but they can be renamed via CSS modules since the same component controls both the className and the CSS.
Step 1: Audit — Identify Dead CSS and Map Selectors to Components
Scope: Small (research only, no code changes)
Grep every CSS class selector in styles.css and cross-reference against all className= usage in src/**/*.tsx. Any selector with zero JSX references is a dead-code candidate.
Special cases: .post-content descendant selectors target rendered markdown HTML (via dangerouslySetInnerHTML in Post.tsx:51) — these are NOT dead even if no JSX uses those class names directly.
Data-attribute selectors ([data-stagger-pending], [data-filter], [data-position], [data-tooltip]) must be checked against JSX props.
Catalog the 193 !important rules into categories:
React-conflicting: Rules that override React-managed state (like the opacity: 0 !important / opacity: 1 !important pattern on lines 763-774 for loading elements, and visibility toggles on lines 2381-2414 for expanded chart/data tiles).
Specificity wars: Rules that use !important to win over other rules in the same file (link underlines lines 446-542, post content links lines 1297-1333).
Media query overrides:!important in responsive blocks to override base styles (POM border positioning lines 945-980, 1054-1057).
Identify duplicate/conflicting declarations. Known: .card defined at line 366 AND ~3882; transition: all on line 374 overridden on line 384. Systematic scan for others.
Produce a classification spreadsheet (can be a markdown table in a working doc) mapping each major CSS block to its target component and migration strategy:
→ module = extract to ComponentName.module.css
→ global = keep in a slimmed global.css (resets, body, design tokens, keyframes)
→ tailwind = replace with utility classes in JSX
→ delete = dead code
Output: A css-audit.md working document in .megaplan/ with the full classification. This is the map for all subsequent steps.
Step 2: Infrastructure — Set Up CSS Modules + Global CSS + Design Tokens
Scope: Small
Create src/styles/global.css containing only truly global styles extracted from styles.css:
:root design tokens (CSS custom properties for colors, fonts, shadows, radii — aligning with the existing tailwind.config.ts theme values)
html and body base styles (background, font, grid pattern)
All @keyframes definitions (animations are referenced across components)
The .inner-border decorative frame (used by SiteFrame.tsx, truly site-global)
Update tailwind.config.ts to reference CSS custom properties: colors: { background: 'var(--color-background)', ... } so Tailwind utilities and CSS modules share the same tokens.
Update index.html to import src/styles/global.css instead of /styles.css. Keep the old styles.css in place temporarily — components will still reference it until migrated.
Verify Vite CSS module support — Vite handles *.module.css natively with no config changes. Confirm by creating a trivial test module and importing it.
Update postcss.config.js if needed (should work as-is since CSS modules go through the same PostCSS pipeline).
Validation: Site renders identically with the new global.css import + the old styles.css still linked. No visual change.
Step 3: Delete Dead CSS
Scope: Small
Using the audit from Step 1, remove all dead rules from styles.css before starting the module extraction. This reduces the migration surface and prevents extracting dead code into modules.
Remove unused keyframes:@keyframes letter-pulse, @keyframes letter-vibrate — verify no element references them.
Remove duplicate rule blocks: Merge the two .card definitions; resolve the transition conflict on lines 374/384.
Remove selectors with zero references identified in Step 1.
Validation: Full visual check of all routes at 480/768/1024/1440px widths. No visible change.
Step 4: Extract Component CSS Modules — Leaf Components First
Scope: Large (this is the bulk of the work)
Migrate bottom-up: leaf components with self-contained styles first, then containers, then pages. For each component:
Per-component process:
Create ComponentName.module.css adjacent to the component file.
Copy relevant CSS rules from styles.css into the module, renaming selectors to camelCase module names (e.g., .image-container → .imageContainer).
Update the component's JSX: import styles from './ComponentName.module.css' and replace className="image-container" with className={styles.imageContainer}.
For selectors that must remain global (targeted by dangerouslySetInnerHTML output), use :global(.post-content) within the module or keep in global.css.
Remove the migrated rules from styles.css.
Eliminate !important during extraction — restructure specificity by scoping to the module. CSS modules' generated class names have flat specificity, so !important wars disappear.
Replace inline style={{ border: 'none' }} overrides (7 instances in cards.tsx) with proper module rules.
Migration order (leaf → container → page):
Order
Component
Key CSS Sections
!important Count
Notes
4a
SocialLinks.tsx
.social-links, .social-link (~69 lines)
0
Simplest, good first module. Good candidate for Tailwind flex utilities.
Largest extraction. The link !important rules (lines 446-542) exist because global link styles conflict with card-scoped links — modules fix this by scoping. Split into Card.module.css for base card + type-specific modules or sections.
Container for cards. The stagger/loading !important rules (lines 763-774) are the known React-conflicting pattern — replace with data-attribute approach or React-controlled classes.
Create src/styles/tailwind.css with @tailwind base; @tailwind components; @tailwind utilities; and import it in the app entry point.
Sweep each module for simple layout rules that are better as utilities. Example: if a module has .wrapper { display: flex; align-items: center; gap: 1rem; } and it's the only use, replace with className="flex items-center gap-4" in JSX and delete from module.
Do NOT convert complex selectors, animations, pseudo-elements, or multi-state styles to Tailwind.
Validation: Visual check all routes. Tailwind classes should produce identical layouts.
Step 6: Responsive CSS Consolidation
Scope: Small
Consolidate media queries from the scattered responsive blocks in the old styles.css into the appropriate CSS modules. Each module handles its own responsive rules.
Standardize breakpoints: Align to Tailwind's breakpoint system for new code (640/768/1024/1280px). For CSS modules, use matching @media queries. Merge the non-standard 600px breakpoint to 640px after visual verification.
Remove !important from media query overrides (POM border positioning lines 945-980, 1054-1057) — with styles scoped to modules, specificity issues that required !important in the flat global file disappear.
Step 7: Final Cleanup and Validation
Scope: Small
Delete styles.css once all rules are either in CSS modules, global.css, or replaced by Tailwind utilities. Remove the <link> from index.html.
Verify zero !important rules across all CSS files (or document any that genuinely require it with a comment explaining why).
Run full visual regression across all routes and viewports.
Check React re-render behavior: Specifically test the scenarios that were buggy:
Filter cards → verify no elements disappear on re-render
Expand/collapse cards → verify transitions work
Navigate between routes → verify no stale styles
Update the existing megaplan (design-a-sensible-well-20260323-0631) to note that Phase 1 (classification) and Phase 5 (cleanup) are complete, and Phase 2 (Tailwind migration) can now target CSS module files instead of the monolith.
Execution Order
Step 1 (Audit) first — the map drives everything else.
Step 2 (Infrastructure) — set up the target structure.
Step 3 (Dead code) — shrink the migration surface before extracting.
Step 4 (CSS Modules) — the core work, done leaf-to-container-to-page. Each component is an independent commit.
Step 5 (Tailwind) — only after modules are stable, as a refinement pass.
Step 6 (Responsive) — can overlap with Step 4 (handle responsive rules during extraction).
Step 7 (Cleanup) — final gate.
Validation Order
After Step 2: site renders identically with new global.css.
After Step 3: visual check confirms no regressions from dead code removal.
After each component in Step 4: visual check of the specific route(s) that use that component at multiple viewport widths.
After Step 5: full-site visual check.
After Step 7: zero !important grep, full visual regression, React re-render smoke tests for filter/expand/navigate flows.
code
Plan metadata:
{
"version": 1,
"timestamp": "2026-03-23T15:31:42Z",
"hash": "sha256:97f2e2f0c8935136cdf9bf064f667e238cc2fb2e7004ddb683b78de1b78c11c4",
"questions": [
"The .post-content descendant selectors style rendered markdown HTML via dangerouslySetInnerHTML. Should these become (a) a dedicated prose.module.css imported by Post.tsx using :global() for the child selectors, (b) stay in global.css as a prose stylesheet, or (c) be replaced by @tailwindcss/typography plugin? Option (a) co-locates with the component but requires :global for every child selector. Option (b) is simpler. Option (c) is cleanest long-term but may need customization to match current look.",
"Several CSS rules use element IDs (#plantCanvas, #pom-letters, #about-section). Should these be converted to class-based selectors in CSS modules, or kept as-is? ID selectors have higher specificity which can cause issues, but they're currently working.",
"The WeightsChart section has ~30 !important rules, many for mobile expanded states. These appear to be specificity hacks to override the card system's base styles when a data tile expands. The clean fix is CSS module scoping, but should this component get a more thorough UX review while we're restructuring its CSS, or strictly keep visual parity?"
],
"success_criteria": [
"styles.css is deleted \u2014 all CSS lives in component-scoped .module.css files, a slim global.css, or Tailwind utility classes",
"Zero or near-zero !important declarations across all CSS files (any remaining are documented with justification)",
"Every React component imports its own CSS module \u2014 styles are co-located with components",
"No visual regressions across all routes (/, /posts, /posts/:slug, /projects, /assorted, /accountability, /crypto-conversations) at viewport widths 480, 768, 1024, and 1440px",
"React re-render scenarios that previously caused bugs (filter toggling, card expansion, route navigation) work without CSS conflicts",
"Tailwind utilities are used for one-off layout/spacing; CSS modules handle animations, pseudo-elements, and complex component patterns",
"No duplicate CSS declarations across modules (each rule exists in exactly one place)",
"Design tokens (colors, fonts, shadows) are defined as CSS custom properties in global.css and consumed by both CSS modules and Tailwind config"
],
"assumptions": [
"The legacy JS migration is complete \u2014 there is no src/legacy/script.ts and no dangerouslySetInnerHTML on the home page. The v2 megaplan's 'frozen classes' constraint is stale. All class names can be renamed via CSS modules since React components control both the markup and the styles.",
"The only dangerouslySetInnerHTML surface is Post.tsx rendering markdown HTML. All other pages use JSX-owned markup that can use CSS module class names directly.",
"CSS modules with Vite require zero configuration \u2014 *.module.css files are handled natively. No need for additional dependencies.",
"Visual regression testing will be done manually (screenshot comparison at key viewports) rather than setting up Playwright automation, since the megaplan's Phase 0 visual regression harness has not been built yet. If that harness exists by the time this plan executes, use it.",
"The 7 inline style={{ ... }} overrides in cards.tsx exist to fight global CSS specificity. Once styles are in modules, these can be removed.",
"Keyframe animations (@keyframes) will stay in global.css since they may be referenced by multiple components. Component-specific keyframes (e.g., watering can) can optionally move to the component's module.",
"The existing megaplan's design token and Tailwind configuration recommendations (Phase 0, Step 0.2) are compatible with this plan and will be incorporated in Step 2."
],
"structure_warnings": []
}
code
Plan structure warnings from validator:
[]
Existing flags:
[]
Requirements:
- Consider whether the plan is at the right level of abstraction.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids` should list previously addressed flags that now appear resolved.
- Focus on concrete issues that would cause real problems.
- Robustness level: standard. Use balanced judgment. Flag significant risks, but do not spend flags on minor polish or executor-obvious boilerplate.
- Verify that the plan remains aligned with the user's original intent.
- Verify that the plan follows the expected structure: one H1 title, `## Overview`, numbered `## Step N:` sections with file references and numbered substeps, plus `## Execution Order` or `## Validation Order`. Missing structure should be flagged as category `completeness` with severity_hint `likely-significant`.
- Flag scope creep explicitly when the plan grows beyond the original idea or recorded user notes. Use the phrase "Scope creep:" in the concern.
- Assign severity_hint carefully. Implementation details the executor will naturally resolve should usually be `likely-minor`.
{"flags":[{"id":"css-pipeline-step2-broken","concern":"Step 2's CSS handoff is internally inconsistent with the actual repo: replacing the only /styles.css link cannot also 'keep the old styles.css in place temporarily', so the claimed no-op validation would fail. Tailwind is already wired into the app, so Step 5's create/import work is stale.","category":"correctness","severity_hint":"likely-significant","evidence":"index.html:15 is the only stylesheet link for the monolith, src/server.ts:52 explicitly serves /styles.css, and src/entry-client.tsx:5 already imports ./tailwind.css."},{"id":"dead-css-audit-misses-runtime-selectors","concern":"Step 1's dead-CSS audit method is unsafe for this codebase. Grepping selectors against static className= usage will produce false positives because several live selectors are added, queried, or composed at runtime instead of appearing as plain JSX literals.","category":"correctness","severity_hint":"likely-significant","evidence":"src/hooks/useLoadingStagger.ts:8-15 queries .loading-element:not(.removed) and adds data-stagger-pending; src/hooks/useTruncationDetector.ts:8-14 queries .card p and toggles .truncated; src/hooks/useCardExpansion.ts:19-23 uses closest('.card'); src/hooks/useDetailsFromHash.ts:9-17 toggles .highlight; src/data/home-cards.tsx:19-25 and repeated entries from :125 onward store card class strings in data."},{"id":"selector-contract-migration-missing","concern":"The plan assumes selectors can be renamed freely under CSS modules, but the repository has explicit DOM and test contracts around current IDs/classes. Add a contract-preservation or contract-migration step before renaming selectors or converting IDs to classes.","category":"correctness","severity_hint":"likely-significant","evidence":"src/contracts/dom-contracts.ts:7-15 asserts #about-section, .square-image-container, .filter-btn, #weights-chart-container, #weights-title, #initialBud, and #plantCanvas. Tests also query current selectors directly in src/pages/__tests__/Home.test.tsx:16-28 and src/components/__tests__/Header.test.tsx:25-77."},{"id":"route-coverage-incomplete","concern":"The migration inventory does not cover all currently styled routes/components, so the success criterion 'delete styles.css' is incomplete against the actual app. AssortedPage and NotFoundPage are both real routes with unique selectors but are missing from the extraction order.","category":"completeness","severity_hint":"likely-significant","evidence":"Routes exist in src/App.tsx:46-53 (/assorted) and src/App.tsx:94-95 (/404 and wildcard). Their unique markup lives in src/pages/Assorted.tsx:5-31 and src/pages/NotFound.tsx:1-22, but neither page appears in Step 4."}],"verified_flag_ids":[],"disputed_flag_ids":[]}
You are an independent reviewer. Critique the plan against the actual repository.
Break up the 4000-line monolithic styles.css into component-scoped CSS modules that work with React's rendering model instead of fighting it. Eliminate all !important rules that conflict with React state, remove dead CSS from the legacy migration, and organize styles by component. The site uses React 19 + Vite + TypeScript with Tailwind configured but mostly unused. The goal is CSS that is maintainable, doesn't cause bugs when React re-renders, and is co-located with the components it styles.
User notes and answers:
Run autonomously through the full critique loop until gate passes. Key context: (1) The site was recently migrated from vanilla JS to React 19 components. The old styles.css was kept wholesale during migration. (2) The loading-element opacity:0 !important bug was the worst example — CSS !important rules hiding elements that React re-renders caused persistent disappearing content. Fixed by switching to data attributes. (3) There's also an existing CSS/Tailwind megaplan (design-a-sensible-well-20260323-0631) that planned incremental Tailwind adoption — this plan should be compatible with that. (4) CSS modules (.module.css) are the natural fit since Vite supports them natively. (5) Tailwind is configured but barely used — the plan should decide what gets Tailwind utilities vs CSS modules vs stays global. (6) Many CSS rules are dead code from features that were rewritten as React components (the legacy JS was deleted). (7) There are duplicate/conflicting declarations in styles.css (e.g., transition: all on line 374 overridden on line 384).
User preference: Use Tailwind utilities for one-off styling (margins, padding, simple layout). Use well-structured CSS (modules or scoped files) for repeated patterns, animations, and complex component styles. This is the pragmatic hybrid approach — Tailwind for utility, CSS for design system patterns.
Current state: A 4,096-line monolithic styles.css containing 100% of the site's styling, 193 !important declarations, dead CSS from a completed vanilla-JS-to-React migration, and duplicate/conflicting rules. Tailwind v3.4 is configured with src/tailwind.css already imported in src/entry-client.tsx:5. No CSS modules exist.
Goal: Co-locate styles with React components using CSS modules (.module.css), eliminate !important rules that fight React state, remove dead code, and establish a pragmatic hybrid where Tailwind handles one-off utility styling and CSS modules handle complex/repeated patterns.
Key constraint: The existing megaplan (design-a-sensible-well-20260323-0631) planned incremental Tailwind adoption. This plan supersedes its classification phase — CSS modules are the primary extraction target, with Tailwind as the utility layer. The two plans are compatible.
CSS pipeline (actual state):
index.html:15 links /styles.css — loaded at SSR/first-paint via src/server.ts:52 serving the static file
src/entry-client.tsx:5 imports ./tailwind.css which contains @tailwind components; @tailwind utilities; (no @tailwind base — preflight is disabled in tailwind.config.ts)
Vite processes CSS modules natively; PostCSS + Autoprefixer + Tailwind are wired
Selector contracts that constrain renaming:
DOM contracts (src/contracts/dom-contracts.ts): #about-section, .square-image-container, .filter-btn, #weights-chart-container, #weights-title, #initialBud, #plantCanvas — these are asserted at runtime
Data-driven class composition (src/data/home-cards.tsx): cardClassName strings like 'card story-tile loading-element' are composed at runtime in Dashboard.tsx:76
Test selectors (src/components/__tests__/Header.test.tsx): .toggle-btn.active, a.toggle-btn, #pom-letters
Strategy for contracted selectors: Keep contracted class names as stable string literals. CSS modules for these components will use :global(.card) etc. for contracted selectors, while module-scoping non-contracted selectors. The hooks and data files continue to use the same string selectors. This avoids a risky cross-cutting refactor while still getting module scoping benefits for the majority of selectors.
Step 1: Audit — Identify Dead CSS and Map Selectors to Components
Scope: Small (research only, no code changes)
Grep every CSS class selector in styles.css and cross-reference against all className= usage in src/**/*.tsx AND:
DOM contracts: All selectors in src/contracts/dom-contracts.ts. Known set: #about-section, .square-image-container, .filter-btn, #weights-chart-container, #weights-title, #initialBud, #plantCanvas
Test selectors: Scan src/**/__tests__/*.tsx for querySelector/querySelectorAll string arguments. Known set: .toggle-btn.active, a.toggle-btn, #pom-letters, a#pom-letters
Special cases:.post-content descendant selectors target rendered markdown HTML (via dangerouslySetInnerHTML in Post.tsx:51) — these are NOT dead.
Data-attribute selectors ([data-stagger-pending], [data-filter], [data-position], [data-tooltip]) must be checked against JSX props and hook usage.
Catalog the 193 !important rules into categories:
React-conflicting: Rules that override React-managed state (e.g., opacity: 0 !important / opacity: 1 !important on lines 763-774 for loading elements; visibility toggles on lines 2381-2414 for expanded chart/data tiles)
Specificity wars: Rules using !important to win over other rules in the same flat file (link underlines lines 446-542, post content links lines 1297-1333)
Output: A css-audit.md working document with the full classification.
Step 2: Infrastructure — Set Up Global CSS and Design Tokens
Scope: Small
Create src/styles/global.css containing only truly global styles extracted from styles.css:
:root design tokens (CSS custom properties for colors, fonts, shadows, radii — aligning with existing tailwind.config.ts theme values)
html and body base styles (background, font, grid pattern)
All @keyframes definitions (referenced across components)
Update tailwind.config.ts to reference CSS custom properties: colors: { background: 'var(--color-background)', ... } so Tailwind utilities and CSS modules share the same tokens.
Add global.css import — import src/styles/global.css in src/entry-client.tsx alongside the existing ./tailwind.css import. This makes it part of the Vite-processed bundle rather than a static file.
Keep /styles.css and its index.html link and server.ts static route intact during migration. The old monolith stays in place — as components migrate to modules, their rules get deleted from styles.css, progressively emptying it. This ensures no intermediate state breaks the site.
No changes needed for Tailwind setup — src/tailwind.css already exists with @tailwind components; @tailwind utilities; and is already imported in src/entry-client.tsx:5. The postcss.config.js pipeline is already wired.
Validation: Site renders identically. global.css adds tokens/resets that duplicate what's in styles.css — no visual change because identical rules.
Step 3: Delete Dead CSS
Scope: Small
Using the audit from Step 1, remove dead rules from styles.css before starting module extraction.
Remove unused keyframes:@keyframes letter-pulse, @keyframes letter-vibrate — verify no element references them.
Remove duplicate rule blocks: Merge the two .card definitions; resolve the transition conflict on lines 374/384.
Remove selectors with zero references identified in Step 1 (cross-referenced against hooks, data files, contracts, and tests — not just static JSX).
Validation: Visual check of all routes at 480/768/1024/1440px widths. No visible change.
Step 4: Extract Component CSS Modules — Leaf Components First
Scope: Large (bulk of the work)
Migrate bottom-up: leaf components first, then containers, then pages. For each component:
Per-component process:
Create ComponentName.module.css adjacent to the component file.
Copy relevant CSS rules from styles.css into the module.
For non-contracted selectors: rename to camelCase module names (e.g., .image-hover-text → .imageHoverText). Update JSX to className={styles.imageHoverText}.
For contracted selectors (from Step 1 audit — DOM contracts, hook queries, data-driven classes, test selectors): use :global(.selectorName) in the module file. The JSX keeps the plain string className="selectorName". This preserves all contracts without cross-cutting changes.
Remove migrated rules from styles.css.
Eliminate !important during extraction — module scoping resolves specificity wars. For React-conflicting !important rules (loading/visibility), replace with the data-attribute pattern already established in the codebase ([data-stagger-pending]).
Replace inline style={{ border: 'none' }} overrides (7 instances in cards.tsx) with proper module rules.
Contracted selector reference (do NOT module-scope these):
Selector
Used By
Reason
.card
useCardExpansion.ts:21, useTruncationDetector.ts:9, Dashboard.tsx:76 via cardClassName, home-cards.tsx
#weights-chart-container, #weights-title are contracted → keep as IDs. Major !important cleanup — module scoping resolves specificity wars with card base styles.
4g
cards.tsx + card types
.card, .story-tile, .work-tile, .project-tile, .data-tile, .art-card, link underlines (~800+ lines)
~60
Many contracted selectors → :global. Non-contracted selectors (, , , , , ) get module-scoped. The link rules exist because global styles conflict with card links — modules fix this.
Sweep each module for simple layout rules that are better as utilities. Example: if a module has .wrapper { display: flex; align-items: center; gap: 1rem; } and it's the only use, replace with className="flex items-center gap-4" in JSX and delete from module.
For components with contracted selectors, Tailwind utilities can be composed alongside: className={\card ${styles.cardExtra} flex`}— contracted names stay as strings, module-scoped names usestyles.*`, Tailwind utilities are plain strings.
Do NOT convert complex selectors, animations, pseudo-elements, or multi-state styles to Tailwind.
Validation: Visual check all routes. Tailwind classes produce identical layouts.
Step 6: Responsive CSS Consolidation
Scope: Small
Consolidate media queries into the appropriate CSS modules. Each module handles its own responsive rules.
Standardize breakpoints: Align to Tailwind's breakpoint system for new code (640/768/1024/1280px). Merge the non-standard 600px breakpoint to 640px after visual verification.
Remove !important from media query overrides — with styles scoped to modules, the flat-file specificity issues that required !important disappear.
Step 7: Final Cleanup and Validation
Scope: Small
Delete styles.css once all rules are in CSS modules, global.css, or Tailwind utilities. Remove the <link rel="stylesheet" href="/styles.css" /> from index.html:15 and the app.use('/styles.css', ...) static route from src/server.ts:52.
Verify zero !important rules across all CSS files (or document any that genuinely require it with a comment).
Run full visual regression across all routes and viewports.
Run existing tests — npm test to verify Header tests and any other test suites pass with the new CSS module structure. Tests that use querySelector('.toggle-btn.active') etc. will work because those selectors are preserved via :global.
Check React re-render behavior: Specifically test scenarios that were buggy:
Filter cards → verify no elements disappear on re-render
Expand/collapse cards → verify transitions work
Navigate between routes → verify no stale styles
Verify DOM contracts — ensure src/contracts/dom-contracts.ts assertions still pass (all contracted IDs/classes are preserved).
Update the existing megaplan (design-a-sensible-well-20260323-0631) to note that its Phase 1 (classification) and Phase 5 (cleanup) are complete.
Execution Order
Step 1 (Audit) — the map drives everything. Must include hooks, data files, contracts, and tests in the cross-reference.
Step 2 (Infrastructure) — set up global.css and tokens alongside the existing monolith.
Step 3 (Dead code) — shrink the migration surface.
Step 4 (CSS Modules) — core work, leaf-to-container-to-page. Each component is an independent commit.
Step 5 (Tailwind) — refinement pass after modules are stable.
Step 6 (Responsive) — can overlap with Step 4 (handle responsive rules during extraction).
Step 7 (Cleanup) — final gate: delete monolith, run tests, visual check.
Validation Order
After Step 2: site renders identically with global.css added alongside styles.css.
After Step 3: visual check confirms no regressions from dead code removal.
After each component in Step 4: visual check + npm test to catch contracted selector breakage immediately.
After Step 5: full-site visual check.
After Step 7: zero !important grep, full visual regression, npm test passes, DOM contracts pass, React re-render smoke tests for filter/expand/navigate flows.
code
Plan metadata:
{
"version": 2,
"timestamp": "2026-03-23T15:39:59Z",
"hash": "sha256:5e8c0042c89ed20e2a7780d4e64fb26743c52c4bbcd4a0390874da77b708d76c",
"changes_summary": "Revised plan to address all 4 significant flags:\n\n1. css-pipeline-step2-broken: Completely rewrote Step 2. Now adds global.css as a parallel import in entry-client.tsx (not replacing the index.html link). The old styles.css + its index.html link + server.ts static route all stay in place during migration, progressively emptying as modules extract rules. Step 7 now explicitly removes the link and static route. Removed the stale Step 5 instruction to create/import tailwind.css (already exists at src/tailwind.css, already imported in entry-client.tsx:5).\n\n2. dead-css-audit-misses-runtime-selectors: Expanded Step 1 audit to explicitly include 4 additional sources beyond static className=: hook querySelector/classList strings, data-driven cardClassName fields in home-cards.tsx, DOM contract selectors from dom-contracts.ts, and test querySelector strings. Listed all known selectors from each source.\n\n3. selector-contract-migration-missing: Added a comprehensive contracted-selector strategy. New section in Overview documents all contracts. New table in Step 4 lists every contracted selector, where it's used, and why it can't be module-scoped. Per-component migration table now notes which selectors are contracted. Strategy: use :global(.name) in CSS modules for contracted selectors, keeping them as plain strings in JSX/hooks/data/tests. Step 7 now includes DOM contract verification and test suite run.\n\n4. route-coverage-incomplete: Added Assorted.tsx (4s) and NotFound.tsx (4t) to the Step 4 migration inventory with their specific CSS selectors listed.",
"flags_addressed": [
"css-pipeline-step2-broken",
"dead-css-audit-misses-runtime-selectors",
"selector-contract-migration-missing",
"route-coverage-incomplete"
],
"questions": [
"The .post-content descendant selectors style rendered markdown HTML via dangerouslySetInnerHTML. The plan uses :global(.post-content) as a wrapper inside Post.module.css with descendant selectors \u2014 this co-locates prose styles with the Post component while keeping them globally-scoped for the HTML output. Alternative: @tailwindcss/typography plugin. Which approach do you prefer?",
"The WeightsChart section has ~30 !important rules, many for mobile expanded states that override card base styles. Module scoping will resolve the specificity issues, but should this component get a UX review while restructuring, or strictly keep visual parity?"
],
"success_criteria": [
"styles.css is deleted \u2014 all CSS lives in component-scoped .module.css files, a slim global.css, or Tailwind utility classes. The index.html link and server.ts static route are also removed.",
"Zero or near-zero !important declarations across all CSS files (any remaining are documented with justification)",
"Every React component imports its own CSS module \u2014 styles are co-located with components",
"No visual regressions across all routes (/, /posts, /posts/:slug, /projects, /assorted, /accountability, /crypto-conversations, /404) at viewport widths 480, 768, 1024, and 1440px",
"React re-render scenarios that previously caused bugs (filter toggling, card expansion, route navigation) work without CSS conflicts",
"Tailwind utilities are used for one-off layout/spacing; CSS modules handle animations, pseudo-elements, and complex component patterns",
"No duplicate CSS declarations across modules (each rule exists in exactly one place)",
"Design tokens (colors, fonts, shadows) are defined as CSS custom properties in global.css and consumed by both CSS modules and Tailwind config",
"All contracted selectors (DOM contracts, hook queries, data-driven classes, test selectors) remain functional \u2014 passes, DOM contract assertions pass",
"All routes are covered in the migration: Home, Posts, Post, Projects, Assorted, Accountability, CryptoConversations, CryptoConversation, MuteList, NotFound"
],
"assumptions": [
"The legacy JS migration is complete \u2014 there is no . All DOM manipulation is in React hooks.",
"The only surface is Post.tsx:51 rendering markdown HTML. All other pages use JSX-owned markup.",
"CSS modules with Vite require zero configuration \u2014 files are handled natively.",
"Visual regression testing will be done manually (screenshot comparison) plus for the existing test suite. If a Playwright harness is built before execution, use it.",
"The 7 inline overrides in cards.tsx exist to fight global CSS specificity and can be removed once styles are in modules.",
"Keyframe animations stay in global.css since they're referenced across components. Component-specific keyframes (watering can) can optionally move to the component's module.",
"Contracted selectors (from hooks, data files, DOM contracts, and tests) will use in CSS modules rather than refactoring all consumers. This is a deliberate trade-off: it preserves all existing contracts without cross-cutting changes, at the cost of those selectors not getting module-scoping benefits. A future pass can refactor hooks/data/tests to use module-scoped names if desired.",
"The existing (containing ) and its import in are kept as-is \u2014 no changes needed to the Tailwind pipeline."
],
"structure_warnings": [],
"delta_from_previous_percent": 47.36
}
code
Plan structure warnings from validator:
[]
Existing flags:
[
{
"id": "css-pipeline-step2-broken",
"concern": "Step 2's CSS handoff is internally inconsistent with the actual repo: replacing the only /styles.css link cannot also 'keep the old styles.css in place temporarily', so the claimed no-op validation would fail. Tailwind is already wired into the app, so Step 5's create/import work is stale.",
"status": "addressed",
"severity": "significant"
},
{
"id": "dead-css-audit-misses-runtime-selectors",
"concern": "Step 1's dead-CSS audit method is unsafe for this codebase. Grepping selectors against static className= usage will produce false positives because several live selectors are added, queried, or composed at runtime instead of appearing as plain JSX literals.",
"status": "addressed",
"severity": "significant"
},
{
"id": "selector-contract-migration-missing",
"concern": "The plan assumes selectors can be renamed freely under CSS modules, but the repository has explicit DOM and test contracts around current IDs/classes. Add a contract-preservation or contract-migration step before renaming selectors or converting IDs to classes.",
"status": "addressed",
"severity": "significant"
},
{
"id": "route-coverage-incomplete",
"concern": "The migration inventory does not cover all currently styled routes/components, so the success criterion 'delete styles.css' is incomplete against the actual app. AssortedPage and NotFoundPage are both real routes with unique selectors but are missing from the extraction order.",
"status": "addressed",
"severity": "significant"
}
]
code
Requirements:
- Consider whether the plan is at the right level of abstraction.
- Reuse existing flag IDs when the same concern is still open.
- `verified_flag_ids` should list previously addressed flags that now appear resolved.
- Focus on concrete issues that would cause real problems.
- Robustness level: standard. Use balanced judgment. Flag significant risks, but do not spend flags on minor polish or executor-obvious boilerplate.
- Verify that the plan remains aligned with the user's original intent.
- Verify that the plan follows the expected structure: one H1 title, `## Overview`, numbered `## Step N:` sections with file references and numbered substeps, plus `## Execution Order` or `## Validation Order`. Missing structure should be flagged as category `completeness` with severity_hint `likely-significant`.
- Flag scope creep explicitly when the plan grows beyond the original idea or recorded user notes. Use the phrase "Scope creep:" in the concern.
- Assign severity_hint carefully. Implementation details the executor will naturally resolve should usually be `likely-minor`.
Not yet included in a published release.
Media query overrides:!important in responsive blocks to override base styles (POM border positioning lines 945-980, 1054-1057)
Identify duplicate/conflicting declarations. Known: .card defined at line 366 AND ~3882; transition: all on line 374 overridden on line 384. Systematic scan for others.
Produce a classification table mapping each CSS block to its target:
→ module = extract to ComponentName.module.css
→ module-global = extract to module but keep selector as :global(.name) (contracted selectors)
→ global = keep in global.css (resets, body, tokens, keyframes)