иземени цвет Background3 и ещё tabs
local InterfaceBuild = '3K3W'
local Release = "Build 1.67"
local RayfieldFolder = "Rayfield"
local ConfigurationFolder = RayfieldFolder.."/Configurations"
local ConfigurationExtension = ".rfld"
local settingsTable = {
	General = {
		-- if needs be in order just make getSetting(name)
		rayfieldOpen = {Type = 'bind', Value = 'K', Name = 'Rayfield Keybind'},
		-- buildwarnings
		-- rayfieldprompts

	},
}

local HttpService = game:GetService("HttpService")
local RunService = game:GetService("RunService")

-- Environment Check
local useStudio = RunService:IsStudio() or false

local settingsCreated = false
local cachedSettings
local prompt = useStudio and require(script.Parent.prompt) or loadstring(game:HttpGet('https://raw.githubusercontent.com/SiriusSoftwareLtd/Sirius/refs/heads/request/prompt.lua'))()
local request = (syn and syn.request) or (fluxus and fluxus.request) or (http and http.request) or http_request or request



local function loadSettings()
	local file = nil

	if isfolder and isfolder(RayfieldFolder) then
		if isfile and isfile(RayfieldFolder..'/settings'..ConfigurationExtension) then
			file = readfile(RayfieldFolder..'/settings'..ConfigurationExtension)
		end
	end

	if file then
		local success, decodedFile = pcall(function() return HttpService:JSONDecode(file) end)
		if success then
			file = decodedFile
		else
			file = {}
		end
	else
		file = {}
	end


	if not settingsCreated then 
		cachedSettings = file
		return
	end

	if file ~= {} then
		for categoryName, settingCategory in pairs(settingsTable) do
			if file[categoryName] then
				for settingName, setting in pairs(settingCategory) do
					if file[categoryName][settingName] then
						setting.Value = file[categoryName][settingName].Value
						setting.Element:Set(setting.Value)
					end
				end
			end
		end
	end
end

if debugX then
	warn('Now Loading Settings Configuration')
end

loadSettings()

if debugX then
	warn('Settings Loaded')
end

local RayfieldLibrary = {
	Flags = {},
	Theme = {
		Default = {
			TextColor = Color3.fromRGB(240, 240, 240),

			Background = Color3.fromRGB(25, 25, 25),
			Topbar = Color3.fromRGB(34, 34, 34),
			Shadow = Color3.fromRGB(20, 20, 20),

			NotificationBackground = Color3.fromRGB(20, 20, 20),
			NotificationActionsBackground = Color3.fromRGB(230, 230, 230),

			TabBackground = Color3.fromRGB(80, 80, 80),
			TabStroke = Color3.fromRGB(85, 85, 85),
			TabBackgroundSelected = Color3.fromRGB(210, 210, 210),
			TabTextColor = Color3.fromRGB(240, 240, 240),
			SelectedTabTextColor = Color3.fromRGB(50, 50, 50),

			ElementBackground = Color3.fromRGB(35, 35, 35),
			ElementBackgroundHover = Color3.fromRGB(40, 40, 40),
			SecondaryElementBackground = Color3.fromRGB(25, 25, 25),
			ElementStroke = Color3.fromRGB(50, 50, 50),
			SecondaryElementStroke = Color3.fromRGB(40, 40, 40),

			SliderBackground = Color3.fromRGB(50, 138, 220),
			SliderProgress = Color3.fromRGB(50, 138, 220),
			SliderStroke = Color3.fromRGB(58, 163, 255),

			ToggleBackground = Color3.fromRGB(30, 30, 30),
			ToggleEnabled = Color3.fromRGB(0, 146, 214),
			ToggleDisabled = Color3.fromRGB(100, 100, 100),
			ToggleEnabledStroke = Color3.fromRGB(0, 170, 255),
			ToggleDisabledStroke = Color3.fromRGB(125, 125, 125),
			ToggleEnabledOuterStroke = Color3.fromRGB(100, 100, 100),
			ToggleDisabledOuterStroke = Color3.fromRGB(65, 65, 65),

			DropdownSelected = Color3.fromRGB(40, 40, 40),
			DropdownUnselected = Color3.fromRGB(30, 30, 30),

			InputBackground = Color3.fromRGB(30, 30, 30),
			InputStroke = Color3.fromRGB(65, 65, 65),
			PlaceholderColor = Color3.fromRGB(178, 178, 178)
		},
	}
}


-- Services
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local CoreGui = game:GetService("CoreGui")

-- Interface Management

local Rayfield = useStudio and script.Parent:FindFirstChild('Rayfield') or game:GetObjects("rbxassetid://10804731440")[1]
local buildAttempts = 0
local correctBuild = false
local warned
local globalLoaded

repeat
	if Rayfield:FindFirstChild('Build') and Rayfield.Build.Value == InterfaceBuild then
		correctBuild = true
		break
	end

	correctBuild = false

	if not warned then
		warn('Rayfield | Build Mismatch')
		print('Rayfield may encounter issues as you are running an incompatible interface version ('.. ((Rayfield:FindFirstChild('Build') and Rayfield.Build.Value) or 'No Build') ..').\n\nThis version of Rayfield is intended for interface build '..InterfaceBuild..'.')
		warned = true
	end

	toDestroy, Rayfield = Rayfield, useStudio and script.Parent:FindFirstChild('Rayfield') or game:GetObjects("rbxassetid://10804731440")[1]
	if toDestroy and not useStudio then toDestroy:Destroy() end

	buildAttempts = buildAttempts + 1
until buildAttempts >= 2

Rayfield.Enabled = false

if gethui then
	Rayfield.Parent = gethui()
elseif syn and syn.protect_gui then 
	syn.protect_gui(Rayfield)
	Rayfield.Parent = CoreGui
elseif not useStudio and CoreGui:FindFirstChild("RobloxGui") then
	Rayfield.Parent = CoreGui:FindFirstChild("RobloxGui")
elseif not useStudio then
	Rayfield.Parent = CoreGui
end

if gethui then
	for _, Interface in ipairs(gethui():GetChildren()) do
		if Interface.Name == Rayfield.Name and Interface ~= Rayfield then
			Interface.Enabled = false
			Interface.Name = "Rayfield-Old"
		end
	end
elseif not useStudio then
	for _, Interface in ipairs(CoreGui:GetChildren()) do
		if Interface.Name == Rayfield.Name and Interface ~= Rayfield then
			Interface.Enabled = false
			Interface.Name = "Rayfield-Old"
		end
	end
end


local minSize = Vector2.new(1024, 768)
local useMobileSizing

if Rayfield.AbsoluteSize.X < minSize.X and Rayfield.AbsoluteSize.Y < minSize.Y then
	useMobileSizing = true
end

if UserInputService.TouchEnabled then
	useMobilePrompt = true
end


-- Object Variables

local Main = Rayfield.Main
local MPrompt = Rayfield:FindFirstChild('Prompt')
local Topbar = Main.Topbar
local Elements = Main.Elements
local LoadingFrame = Main.LoadingFrame
local TabList = Main.TabList
local dragBar = Rayfield:FindFirstChild('Drag')
local dragInteract = dragBar and dragBar.Interact or nil
local dragBarCosmetic = dragBar and dragBar.Drag or nil

local dragOffset = 255
local dragOffsetMobile = 150

Rayfield.DisplayOrder = 100
LoadingFrame.Version.Text = Release


local Icons = useStudio and require(script.Parent.icons) or loadstring(game:HttpGet('https://raw.githubusercontent.com/SiriusSoftwareLtd/Rayfield/refs/heads/main/icons.lua'))()

-- Variables

local CFileName = nil
local CEnabled = false
local Minimised = false
local Hidden = false
local Debounce = false
local searchOpen = false
local Notifications = Rayfield.Notifications

local SelectedTheme = RayfieldLibrary.Theme.Default

local function ChangeTheme(Theme)
    if typeof(Theme) == 'string' then
        SelectedTheme = RayfieldLibrary.Theme[Theme]
    elseif typeof(Theme) == 'table' then
        SelectedTheme = Theme
    end

    -- Определяем градиент для вкладок и верхней панели
    local tabGradientColorSequence = ColorSequence.new({
        ColorSequenceKeypoint.new(0, Color3.fromRGB(170, 0, 255)),
        ColorSequenceKeypoint.new(0.5, Color3.fromRGB(120, 75, 255)),
        ColorSequenceKeypoint.new(1, Color3.fromRGB(50, 0, 120))
    })

    -- Функция для применения градиента к элементу
    local function applyGradient(element, colorSequence)
        local gradient = element:FindFirstChildOfClass("UIGradient")
        if not gradient then
            gradient = Instance.new("UIGradient")
            gradient.Name = "BackgroundGradient"
            gradient.Parent = element
        end
        gradient.Color = colorSequence
        gradient.Rotation = 90
        element.BackgroundTransparency = 1
    end

    -- Применяем градиент к верхней панели (Topbar)
    if Rayfield.Main.Topbar then
        applyGradient(Rayfield.Main.Topbar, tabGradientColorSequence)
    end

    -- Применяем градиент к вкладкам
    if Rayfield.Main.TabList then
        for _, tabButton in pairs(Rayfield.Main.TabList:GetChildren()) do
            if tabButton:IsA("Frame") and tabButton.Name ~= "Template" then
                applyGradient(tabButton, tabGradientColorSequence)
            end
        end
    end

    -- Устанавливаем однотонный фон и обводку для остальных элементов
    local elementBackground = Color3.fromRGB(40, 40, 40)  -- Тёмно-серый фон
    local elementHoverBackground = Color3.fromRGB(55, 55, 55)  -- Фон при наведении
    local elementStroke = Color3.fromRGB(70, 0, 130)      -- Фиолетовая обводка
    local textColor = Color3.fromRGB(255, 255, 255)       -- Белый цвет текста

    -- Обновляем цвета для кнопок, слайдеров и т.д.
    for _, tabPage in pairs(Rayfield.Main.Elements:GetChildren()) do
        if tabPage:IsA("ScrollingFrame") then
            for _, element in pairs(tabPage:GetChildren()) do
                if element:IsA("Frame") and element.Name ~= "Placeholder" and element.Name ~= "SectionSpacing" then

                    -- Устанавливаем фон и обводку для элемента
                    element.BackgroundTransparency = 0
                    element.BackgroundColor3 = elementBackground
                    local uiStroke = element:FindFirstChildOfClass("UIStroke")
                    if uiStroke then
                        uiStroke.Color = elementStroke
                    end

                    -- Настройка текста внутри элемента
                    for _, child in pairs(element:GetDescendants()) do
                        if child:IsA("TextLabel") or child:IsA("TextButton") or child:IsA("TextBox") then
                            child.TextColor3 = textColor
                        elseif child:IsA("ImageLabel") or child:IsA("ImageButton") then
                            child.ImageColor3 = textColor
                        end
                    end

                    -- Эффект при наведении на элемент
                    local interactArea = element:FindFirstChild("Interact")
                    if interactArea then
                        interactArea.MouseEnter:Connect(function()
                            element.BackgroundColor3 = elementHoverBackground
                        end)
                        interactArea.MouseLeave:Connect(function()
                            element.BackgroundColor3 = elementBackground
                        end)
                    end
                end
            end
        end
    end

    -- Обновляем цвет текста для всех остальных элементов
    for _, descendant in ipairs(Rayfield:GetDescendants()) do
        if descendant:IsA("TextLabel") or descendant:IsA("TextButton") or descendant:IsA("TextBox") then
            descendant.TextColor3 = textColor
        elseif descendant:IsA("UIStroke") then
            descendant.Color = elementStroke
        end
    end

    -- Обновляем цвета для кнопок на верхней панели
    for _, button in pairs(Rayfield.Main.Topbar:GetChildren()) do
        if button:IsA("ImageButton") or button:IsA("TextButton") or button:IsA("Frame") then
            -- Оставляем градиент на кнопках верхней панели
            applyGradient(button, tabGradientColorSequence)

            -- Настраиваем цвет иконок и текста
            for _, child in pairs(button:GetDescendants()) do
                if child:IsA("ImageLabel") or child:IsA("ImageButton") then
                    child.ImageColor3 = textColor
                elseif child:IsA("TextLabel") or child:IsA("TextButton") then
                    child.TextColor3 = textColor
                end
            end
        end
    end
end