make this way better

private void Theme(Color mainStart, Color mainEnd, Color accentsStart, Color accentsEnd, Color textcolor)
{
    void SetGradient(Control control, Color startColor, Color endColor)
    {
        if (control == null || control.Width == 0 || control.Height == 0)
            return;

        Bitmap bmp = new Bitmap(control.Width, control.Height);
        using (Graphics g = Graphics.FromImage(bmp))
        {
            using (var brush = new System.Drawing.Drawing2D.LinearGradientBrush(
                new Rectangle(0, 0, bmp.Width, bmp.Height),
                startColor,
                endColor,
                System.Drawing.Drawing2D.LinearGradientMode.Vertical))
            {
                g.FillRectangle(brush, 0, 0, bmp.Width, bmp.Height);
            }
        }
        control.BackgroundImage = bmp;
        control.BackgroundImageLayout = ImageLayout.Stretch;
    }

    Color GetContrastingTextColor(Color background, Color fallback)
    {
        double luminance = (0.2126 * background.R + 0.7152 * background.G + 0.0722 * background.B) / 255;

        if (luminance > 0.7)
            return Color.FromArgb(255, 30, 30, 30);
        else if (luminance < 0.15)
            return Color.White;
        else
            return fallback;
    }

    // Clear all backgrounds and images first

    var allPanels = new Panel[]
    {
        panel1, panel2, panel3, panel4, panel5, panel6, panel7, panel8, panel9, panel10, indexpnl, panel11, MusicNode,
        ReverbNode, ReverbNodeTwo, MusicNodeTwo, MusicModeP3
    };
    foreach (var pnl in allPanels)
    {
        if (pnl != null)
        {
            pnl.BackgroundImage = null;
            pnl.BackColor = Color.Transparent;
        }
    }

    var labels = new Label[]
    {
        label1, label2, label3, label4, label5, label6, label7, label8,
        label9, label10, label11, label12, label13, label14, label15,
        label16, label17, label18, label19, label20, label21, label22,
        label23, label24, label25, label26, label27, label28, label29,
        label30, label31, label32, label33, label34, label35, label36,
        label41, MyLink, UIT9, label37, label40, UIT1, UIT2, UIT3, UIT4,
        UIT5, UIT6, UIT7, UIT8, UIT10, UIT11, UIT12, UIT13, WGT,
        label38, label42, label43, label44
    };
    foreach (var lbl in labels)
    {
        if (lbl != null)
        {
            lbl.BackgroundImage = null;
            lbl.BackColor = Color.Transparent;
        }
    }

    var pictures = new PictureBox[]
    {
        pictureBox1, pictureBox2, pictureBox3, pictureBox4, ATTB,
        ATTB2, pictureBox7, pictureBox8, pictureBox9, pictureBox10,
        OffMap, pictureBox12, pictureBox11, RN1TB, RN2TB, MMTB,
        pictureBox5
    };
    foreach (var pb in pictures)
    {
        if (pb != null)
        {
            pb.Image = null;
            pb.BackgroundImage = null;
            pb.BackColor = Color.Transparent;
        }
    }

    if (menuStrip1 != null)
    {
        menuStrip1.BackgroundImage = null;
        menuStrip1.BackColor = Color.Transparent;
    }

    var menuItems = new ToolStripMenuItem[]
    {
        fileToolStripMenuItem, serverToolStripMenuItem, fishSpeechToolStripMenuItem, sTARTToolStripMenuItem,
        whisperTurboToolStripMenuItem, sTARTToolStripMenuItem1, editToolStripMenuItem, settingsToolStripMenuItem,
        formSettingsToolStripMenuItem, topmostToolStripMenuItem, yESToolStripMenuItem, nOToolStripMenuItem,
        commSettingsToolStripMenuItem, chatComboToolStripMenuItem, oNToolStripMenuItem, oFFToolStripMenuItem,
        partyModeToolStripMenuItem, oNToolStripMenuItem1, oFFToolStripMenuItem1, helpToolStripMenuItem,
        pushToTalkToolStripMenuItem, enableToolStripMenuItem, disableToolStripMenuItem, aboutToolStripMenuItem,
        toolsToolStripMenuItem, importToolStripMenuItem, voiceToolStripMenuItem, matchRecordToolStripMenuItem,
        voiceToolStripMenuItem1, recordToolStripMenuItem, stopRecordToolStripMenuItem, keypadderToolStripMenuItem,
        confirmModeToolStripMenuItem, tTSBaseToolStripMenuItem, fishSpeechToolStripMenuItem1, zonosToolStripMenuItem,
        viewToolStripMenuItem, tTSToolStripMenuItem, fishSpeechToolStripMenuItem2, zonosToolStripMenuItem1,
        constructiveChunksToolStripMenuItem, constructiveTokensToolStripMenuItem, ollamaToolStripMenuItem,
        longGenerationsModeToolStripMenuItem, translationModeToolStripMenuItem, spellCheckModeToolStripMenuItem,
        debugToolStripMenuItem, sTTToolStripMenuItem, oNToolStripMenuItem2, oFFToolStripMenuItem2,
        portableChatboxToolStripMenuItem, oNToolStripMenuItem3, oFFToolStripMenuItem3, indexTTSToolStripMenuItem,
        sTARTToolStripMenuItem2, recentPlayersToolStripMenuItem, incrementalSeedingToolStripMenuItem,
        stateToolStripMenuItem, oFFToolStripMenuItem4, previewModeToolStripMenuItem, oNToolStripMenuItem4,
        oFFToolStripMenuItem5, finetuneModelToolStripMenuItem, fishSpeechToolStripMenuItem3, toolStripMenuItem3,
        makeToolStripMenuItem, startTrainToolStripMenuItem, outputsToolStripMenuItem, cacheOutputsToolStripMenuItem,
        setDirectorytToolStripMenuItem,extrasToolStripMenuItem, themeToolStripMenuItem, rollDiceToolStripMenuItem,
        musicalTTSToolStripMenuItem
    };
    foreach (var item in menuItems)
    {
        if (item != null)
        {
            item.BackgroundImage = null;
            item.BackColor = Color.Transparent;
        }
    }

    if (statusStrip1 != null)
    {
        statusStrip1.BackgroundImage = null;
        statusStrip1.BackColor = Color.Transparent;
    }
    if (DebugTXT != null)
        DebugTXT.BackgroundImage = null;
    if (toolStripStatusLabel2 != null)
        toolStripStatusLabel2.BackgroundImage = null;
    if (GeneralProgress != null)
        GeneralProgress.BackgroundImage = null;

    if (VoicesList != null)
    {
        VoicesList.BackgroundImage = null;
    }

    var textBoxes = new TextBox[]
    {
        textBox1, textBox2, RepBox, TopPBox, MaxTokenBox, ChunkBox, TempBox,
        HappyBox, AngryBox, ShockedBox, ScaredBox, GrossBox, SadBox, NeutralBox,
        OtherBox, SpeechSpeedBox, CFGBox, SearchBox, GenrePromptBox, LyricBox, Reverberance,
        HFDamp, RoomScale, StereoD, PreD, WetG, VCQuality, MusicGenDuration, MusicGenQuality,
        SoxPath, GSTBox, GSLTBox, CFGSTBox
    };
    foreach (var tb in textBoxes)
    {
        if (tb != null)
        {
            tb.BackgroundImage = null;
            tb.BackColor = Color.White;
        }
    }

    var combos = new ComboBox[]
    {
        Previews, comboBox1, comboBox2, comboBox4, comboBoxModels, TranslationMdl, SpellCheckMdl, comboBoxOutputDevices, comboBoxInputDevices,
        GenreCombo
    };
    foreach (var cb in combos)
    {
        if (cb != null)
        {
            cb.BackgroundImage = null;
            cb.BackColor = Color.White;
        }
    }

    var buttons = new Button[]
    {
        F3B, button2, button4, button3, ListenButton, button7, button6,
        Key_1_NUM, F2B, Key_16_ZERO, Key_15, Key_8_PLUS, Key_14_THREE,
        Key_13_TWO, Key_12_ONE, Key_11_SIX, Key_FIVE, Key_9_FOUR,
        Key_7_NINE, Key_6_EIGHT, Key_5_SEVEN, Key_4_MIN, Key_3_MULTI,
        Key_2_SLASH, button5, F3BB, F8B, F7B, F6B, F5B, F4B, F12B,
        F11B, F10B, F9B, F1B, button1, button13, button12, button8,
        button10, button11, HP, SP, SN, HN, SHN, SHP, GN, GP, NN,
        NP, AN, AP, SCN, SCP, ON, OP, button9, CFGN, CFGP, SPSN,
        SPSP, button16, button17, SpeakerAP, Bum, button14,
        LookButton, ReNew, button31, button19, GenerateSong,
        VerbSettings, EnableVerb, CB1, CB2, CB3, CB4, BCK1, BCK2,
        MMB, MBS, ATS, GenrePrompDD, button22, button21, button23,
        button18, DisplayEmo, SoxPathButton
    };
    foreach (var btn in buttons)
    {
        if (btn != null)
        {
            btn.BackgroundImage = null;
            btn.Image = null;
            btn.FlatAppearance.BorderColor = Color.Empty;
            btn.FlatAppearance.BorderSize = 0;
            btn.BackColor = Color.Transparent;
        }
    }

    var checkBoxes = new CheckBox[]
    {
EnabPrefix, AutoEmote, checkBox3
    };
    foreach (var cb in checkBoxes)
    {
        if (cb != null)
        {
            cb.BackgroundImage = null;
            cb.BackColor = Color.Transparent;
        }
    }

    // Re-apply colors and gradients

    foreach (var lbl in labels)
    {
        if (lbl != null)
        {
            lbl.ForeColor = textcolor;
        }
    }

    foreach (var pnl in allPanels)
    {
        if (pnl != null)
        {
            SetGradient(pnl, mainStart, mainEnd);
        }
    }

    foreach (var pb in pictures)
    {
        if (pb != null)
        {
            pb.BackColor = Color.Transparent;
        }
    }

    if (menuStrip1 != null)
    {
        menuStrip1.BackColor = accentsStart;
        menuStrip1.ForeColor = GetContrastingTextColor(accentsStart, textcolor);
    }
    foreach (var item in menuItems)
    {
        if (item != null)
        {
            item.BackColor = accentsStart;
            item.ForeColor = GetContrastingTextColor(accentsStart, textcolor);
        }
    }

    if (statusStrip1 != null)
    {
        statusStrip1.BackColor = accentsEnd;
        statusStrip1.ForeColor = GetContrastingTextColor(accentsEnd, textcolor);
    }
    if (DebugTXT != null)
        DebugTXT.ForeColor = textcolor;
    if (toolStripStatusLabel2 != null)
        toolStripStatusLabel2.ForeColor = textcolor;
    if (GeneralProgress != null)
    {
        GeneralProgress.BackColor = accentsStart;
        GeneralProgress.ForeColor = textcolor;
    }

    if (VoicesList != null)
    {
        VoicesList.BackColor = mainStart;
        VoicesList.ForeColor = GetContrastingTextColor(mainStart, textcolor);
    }

    foreach (var tb in textBoxes)
    {
        if (tb != null)
        {
            tb.BackColor = mainEnd;
            tb.ForeColor = GetContrastingTextColor(mainEnd, textcolor);
            tb.BorderStyle = BorderStyle.FixedSingle;
        }
    }

    foreach (var cb in combos)
    {
        if (cb != null)
        {
            cb.BackColor = mainEnd;
            cb.ForeColor = GetContrastingTextColor(mainEnd, textcolor);
        }
    }

    foreach (var btn in buttons)
    {
        if (btn == null) continue;

        var btnStart = ShiftColorRandomly(accentsStart, 10);
        var btnEnd = ShiftColorRandomly(accentsEnd, 20);
        SetGradient(btn, btnStart, btnEnd);

        Color midColor = Color.FromArgb(
            (btnStart.R + btnEnd.R) / 2,
            (btnStart.G + btnEnd.G) / 2,
            (btnStart.B + btnEnd.B) / 2);

        btn.ForeColor = GetContrastingTextColor(midColor, textcolor);
        btn.FlatAppearance.BorderColor = DarkenColor(midColor, 0.3f);
        btn.FlatAppearance.BorderSize = 1;
        btn.FlatStyle = FlatStyle.Flat;
    }

    foreach (var cb in checkBoxes)
    {
        if (cb != null)
        {
            cb.ForeColor = textcolor;
            cb.BackColor = Color.Transparent;
        }
    }

    Bitmap formBmp = new Bitmap(this.Width, this.Height);
    using (Graphics g = Graphics.FromImage(formBmp))
    {
        var angleOptions = new[]
        {
    System.Drawing.Drawing2D.LinearGradientMode.Vertical,
    System.Drawing.Drawing2D.LinearGradientMode.Horizontal,
    System.Drawing.Drawing2D.LinearGradientMode.ForwardDiagonal,
    System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal
};
        var angle = angleOptions[_rand.Next(angleOptions.Length)];
        Color start = ShiftColorRandomly(mainStart, 15);
        Color end = ShiftColorRandomly(accentsStart, 25);

        using (var brush = new System.Drawing.Drawing2D.LinearGradientBrush(
            new Rectangle(0, 0, formBmp.Width, formBmp.Height),
            start,
            end,
            angle))
        {
            g.FillRectangle(brush, 0, 0, formBmp.Width, formBmp.Height);
        }
    }
    this.BackgroundImage = formBmp;
    this.BackgroundImageLayout = ImageLayout.Stretch;
}