from pathlib import Path
import re
ROOT=Path('/opt/struktur')
EXT={'.py','.html','.css','.js'}
SKIP_PARTS={'backups','backup','venv','node_modules','__pycache__'}
SKIP_NAMES=('bak','before-','prechange','patch_')
colors=('64748b','94a3b8','cbd5e1','9ca3af','a1a1aa','6b7280')
changed=[]
for p in ROOT.rglob('*'):
if not p.is_file() or p.suffix.lower() not in EXT: continue
low=str(p).lower()
if any('/'+x+'/' in low for x in SKIP_PARTS): continue
if any(x in p.name.lower() for x in SKIP_NAMES): continue
try: s=p.read_text(errors='ignore')
except Exception: continue
old=s
for c in colors:
s=re.sub(r'(?i)(color\s*:\s*)#'+c+r'\b', r'\1#fff', s)
s=re.sub(r'(?i)(--(?:muted|text-muted|text-secondary|secondary-text)\s*:\s*)#[0-9a-f]{6}\b', r'\1#fff', s)
if s!=old:
changed.append((str(p), sum(1 for a,b in zip(old,s) if a!=b)))
p.write_text(s)
print('CHANGED_FILES',len(changed))
for p,_ in changed: print(p)