import re

with open("/tmp/nezha-config-raw.yaml") as f:
    content = f.read()

content = re.sub(r"custom_code:.*\n?", "", content)

css = (
    '<style>'
    # 背景图
    'body{background:url(/static/bg.jpg) no-repeat center center fixed!important;background-size:cover!important}'
    # 透明层
    '#root,.loaded,.bg-background,.flex.min-h-screen{background:transparent!important}'
    'main{background:transparent!important}'
    # iOS玻璃卡片
    '[class*="bg-card"],button[class*="rounded-full"]{background-color:rgba(255,255,255,0.01)!important;'
    'backdrop-filter:blur(5px) saturate(100%)!important;'
    '-webkit-backdrop-filter:blur(5px) saturate(100%)!important;'
    'border-radius:16px!important;'
    'border:1px solid rgba(255,255,255,0.2)!important;'
    'transition:all 0.3s ease!important;'
    'position:relative!important;overflow:hidden!important}'
    # header/footer透明
    'header,nav,footer{background:transparent!important}'
    # 文字颜色
    '.text-stone-400,.text-stone-500,.opacity-50,.text-muted-foreground,p.text-xs,span.text-xs{color:rgba(40,40,40,0.8)!important;opacity:1!important;font-weight:500!important}'
    '[class*="bg-card"] p,[class*="bg-card"] span,.font-medium,.font-semibold{color:#2a2a2a!important}'
    '.text-sm.font-medium{color:#2a2a2a!important;opacity:1!important}'
    # tablist
    'div[role="tablist"]{background:rgba(0,0,0,0.05)!important;border:1px solid rgba(0,0,0,0.08)!important;backdrop-filter:blur(15px)!important}'
    '</style>'
)

content = content.rstrip() + '\ncustom_code: "' + css + '"\n'

with open("/tmp/nezha-config-fixed.yaml", "w") as f:
    f.write(content)

print("done")
