local API = rawget(_G, "LIDCOUNCIL_API")
local INTERNAL_API = type(API) == "table" and type(API.__internal) == "table" and API.__internal or nil
if type(INTERNAL_API) ~= "table" then
  error("LidCouncil missing internal API registry.")
end

local DEVELOPER_TOOL_PANEL_BACKDROP = {
  bgFile = "Interface/Buttons/WHITE8x8",
  edgeFile = "Interface/Buttons/WHITE8x8",
  edgeSize = 1,
}

local function SetDeveloperToolPanelExpanded(panel, expanded)
  if not panel then
    return
  end
  panel.__expanded = expanded ~= false
  if panel.__content and panel.__content.SetShown then
    panel.__content:SetShown(panel.__expanded)
  end
  if panel.__toggleText then
    panel.__toggleText:SetText(panel.__expanded and "v" or ">")
  end
end

local function SetDeveloperToolPanelStatus(panel, text, r, g, b)
  if not panel or not panel.__statusText then
    return
  end
  panel.__statusText:SetText(tostring(text or ""))
  panel.__statusText:SetTextColor(tonumber(r) or 0.72, tonumber(g) or 0.76, tonumber(b) or 0.82, 1)
end

local function CreateDeveloperToolPanel(parent, title, editor)
  local panel = CreateFrame("Frame", nil, parent, "BackdropTemplate")
  panel:SetBackdrop(DEVELOPER_TOOL_PANEL_BACKDROP)
  panel:SetBackdropColor(0.035, 0.045, 0.060, 0.94)
  panel:SetBackdropBorderColor(0.24, 0.31, 0.40, 0.90)
  panel.__expanded = true
  panel.SetToolStatus = SetDeveloperToolPanelStatus

  panel.__header = CreateFrame("Button", nil, panel)
  panel.__header:SetPoint("TOPLEFT", panel, "TOPLEFT", 1, -1)
  panel.__header:SetPoint("TOPRIGHT", panel, "TOPRIGHT", -1, -1)
  panel.__header:SetHeight(34)

  panel.__toggleText = panel.__header:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  panel.__toggleText:SetPoint("LEFT", panel.__header, "LEFT", 12, 0)
  panel.__toggleText:SetTextColor(0.96, 0.78, 0.24, 1)

  panel.__titleText = panel.__header:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  panel.__titleText:SetPoint("LEFT", panel.__toggleText, "RIGHT", 10, 0)
  panel.__titleText:SetText(tostring(title or "Developer Tool"))
  panel.__titleText:SetTextColor(0.92, 0.94, 0.98, 1)

  panel.__statusText = panel.__header:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  panel.__statusText:SetPoint("RIGHT", panel.__header, "RIGHT", -12, 0)
  panel.__statusText:SetJustifyH("RIGHT")

  panel.__content = CreateFrame("Frame", nil, panel)
  panel.__content:SetPoint("TOPLEFT", panel, "TOPLEFT", 14, -42)
  panel.__content:SetPoint("BOTTOMRIGHT", panel, "BOTTOMRIGHT", -14, 12)

  panel.__header:SetScript("OnClick", function()
    SetDeveloperToolPanelExpanded(panel, not panel.__expanded)
    if editor and type(editor.UpdateAboutDeveloperLayout) == "function" then
      editor:UpdateAboutDeveloperLayout()
    end
  end)
  SetDeveloperToolPanelExpanded(panel, true)
  return panel
end

local function ApplyDeveloperToolActionStyle(button, variant)
  if not button then
    return
  end
  if variant == "primary" then
    button.__lid_customBg = { 0.05, 0.12, 0.20, 0.96 }
    button.__lid_customHover = { 0.16, 0.38, 0.66, 0.24 }
    button.__lid_customPushed = { 0.08, 0.20, 0.34, 0.98 }
    button.__lid_customBorder = { 0.34, 0.62, 0.92, 0.92 }
    button.__lid_customText = { 0.92, 0.96, 1.00, 1.00 }
  elseif variant == "clear" then
    button.__lid_customBg = { 0.11, 0.085, 0.045, 0.92 }
    button.__lid_customHover = { 0.42, 0.30, 0.10, 0.26 }
    button.__lid_customPushed = { 0.20, 0.14, 0.05, 0.98 }
    button.__lid_customBorder = { 0.62, 0.48, 0.22, 0.76 }
    button.__lid_customText = { 0.92, 0.82, 0.58, 1.00 }
  else
    button.__lid_customBg = { 0.055, 0.065, 0.085, 0.90 }
    button.__lid_customHover = { 0.16, 0.24, 0.34, 0.24 }
    button.__lid_customPushed = { 0.08, 0.12, 0.18, 0.98 }
    button.__lid_customBorder = { 0.34, 0.42, 0.52, 0.68 }
    button.__lid_customText = { 0.82, 0.86, 0.92, 1.00 }
  end
end

local function CreateAboutUtilitySections(editor, aboutContent, deps)
  deps = deps or {}
  local MakeAboutTitle = deps.MakeAboutTitle
  local MakeYellowSubHeader = deps.MakeYellowSubHeader
  local RootDB = deps.RootDB
  local GetRuntimeDiagnostics = type(deps.GetRuntimeDiagnostics) == "function" and deps.GetRuntimeDiagnostics or nil
  local Print = type(deps.Print) == "function" and deps.Print or rawget(_G, "LIDCOUNCIL_Print")
  local CreateLootProfileApi = type(deps.CreateLootProfile) == "function" and deps.CreateLootProfile or rawget(_G, "LIDCOUNCIL_CreateLootProfile")
  local DeleteLootProfileApi = type(deps.DeleteLootProfile) == "function" and deps.DeleteLootProfile or rawget(_G, "LIDCOUNCIL_DeleteLootProfile")
  local GetLootProfileAccessInfoApi = type(deps.GetLootProfileAccessInfo) == "function" and deps.GetLootProfileAccessInfo or rawget(_G, "LIDCOUNCIL_GetLootProfileAccessInfo")
  local RepairSimulationProfileOwnershipApi = type(deps.RepairSimulationProfileOwnership) == "function" and deps.RepairSimulationProfileOwnership or rawget(_G, "LIDCOUNCIL_RepairSimulationProfileOwnership")
  local SetLootProfileEnabledApi = type(deps.SetLootProfileEnabled) == "function" and deps.SetLootProfileEnabled or rawget(_G, "LIDCOUNCIL_SetLootProfileEnabled")
  local GetActiveLootSession = type(deps.GetActiveLootSession) == "function" and deps.GetActiveLootSession or rawget(_G, "LIDCOUNCIL_GetActiveLootSession")
  local RequestEditorAboutRefresh = type(deps.RequestEditorAboutRefresh) == "function" and deps.RequestEditorAboutRefresh or nil
  local SafeHookScript = deps.SafeHookScript or function(frame, scriptName, handler)
    if frame and type(frame.HookScript) == "function" and type(handler) == "function" then
      pcall(frame.HookScript, frame, scriptName, handler)
    end
  end
  local GetTitleColor = type(deps.GetTitleColor) == "function" and deps.GetTitleColor or function()
    return 0.6588, 0.4784, 0.9098, 1.0
  end
  local function ApplyTitleColor(fontString)
    if not fontString then
      return
    end
    local r, g, b, a = GetTitleColor()
    fontString:SetTextColor(r, g, b, a)
  end

  local function RefreshAboutUtilitiesPage()
    if type(RequestEditorAboutRefresh) == "function" and RequestEditorAboutRefresh(editor) then
      return
    end
    if editor and editor.RefreshAbout then
      editor:RefreshAbout()
      return
    end
    if editor and editor.Refresh then
      editor:Refresh()
    end
  end

  local function GetSimulationProfileState(root)
    root = root or RootDB()
    local repaired = false
    local masterKey = ""
    if type(RepairSimulationProfileOwnershipApi) == "function" then
      local didRepair, resolvedMaster = RepairSimulationProfileOwnershipApi(root)
      repaired = didRepair == true
      masterKey = tostring(resolvedMaster or "")
    end

    local profile = type(root.profiles) == "table" and root.profiles.Simulation or nil
    if type(profile) ~= "table" then
      return {
        exists = false,
        repaired = repaired,
        masterKey = "",
        access = nil,
        canDelete = false,
      }
    end

    local access = type(GetLootProfileAccessInfoApi) == "function" and GetLootProfileAccessInfoApi("Simulation") or nil
    if type(access) == "table" and tostring(access.masterKey or "") ~= "" then
      masterKey = tostring(access.masterKey)
    elseif masterKey == "" and type(profile.meta) == "table" and type(profile.meta.permissions) == "table" then
      masterKey = tostring(profile.meta.permissions.master or "")
    end

    return {
      exists = true,
      repaired = repaired,
      masterKey = masterKey,
      access = access,
      canDelete = type(access) == "table" and access.canDeleteProfile == true or false,
    }
  end

  local function HasSimulationProfile(root)
    return GetSimulationProfileState(root).exists
  end

  local function HasActiveSimulationSession()
    if type(GetActiveLootSession) ~= "function" then
      return false
    end
    local activeSession, activeProfileName = GetActiveLootSession()
    return activeSession ~= nil and tostring(activeProfileName or "") == "Simulation"
  end

  local function ResolveNonSimulationFallbackProfile(root)
    root = root or RootDB()
    root.ui = type(root.ui) == "table" and root.ui or {}

    local preferredName = tostring(root.ui.lastNonSimulationProfile or "")
    if preferredName ~= "" and preferredName ~= "Simulation" and type(root.profiles) == "table" and type(root.profiles[preferredName]) == "table" then
      return preferredName
    end
    if type(root.profiles) == "table" and type(root.profiles.Default) == "table" then
      return "Default"
    end

    local candidates = {}
    for profileName in pairs(root.profiles or {}) do
      local resolvedName = tostring(profileName or "")
      if resolvedName ~= "" and resolvedName ~= "Simulation" then
        candidates[#candidates + 1] = resolvedName
      end
    end
    table.sort(candidates, function(a, b)
      return string.lower(tostring(a or "")) < string.lower(tostring(b or ""))
    end)
    return candidates[1]
  end

  local function MoveAwayFromSimulationSelection()
    local root = RootDB()
    root.ui = type(root.ui) == "table" and root.ui or {}

    local fallbackProfile = ResolveNonSimulationFallbackProfile(root)
    if fallbackProfile and fallbackProfile ~= "Simulation" and type(root.profiles) == "table" then
      local simulationProfile = root.profiles.Simulation
      if type(simulationProfile) == "table" and type(simulationProfile.settings) == "table" and simulationProfile.settings.enabled == true and type(SetLootProfileEnabledApi) == "function" then
        SetLootProfileEnabledApi(fallbackProfile, true)
      end
    end
    if tostring(root.currentProfile or "") == "Simulation" and fallbackProfile and type(root.profiles) == "table" and type(root.profiles[fallbackProfile]) == "table" then
      root.currentProfile = fallbackProfile
    end

    local fallbackSelection = fallbackProfile ~= "Simulation" and fallbackProfile or nil
    if editor then
      if editor.selectedProfileName == "Simulation" then
        editor.selectedProfileName = fallbackSelection
      end
      if editor.selectedLootProfileName == "Simulation" then
        editor.selectedLootProfileName = fallbackSelection
      end
    end
  end

  local function ResolveOptionalApiFunction(name)
    local resolvedName = tostring(name or "")
    local api = rawget(_G, "LIDCOUNCIL_API")
    if type(api) == "table" and api[resolvedName] ~= nil then
      return api[resolvedName]
    end
    return rawget(_G, resolvedName)
  end

  local function EnsureDeveloperSyncHarnessConfig(root)
    root = root or RootDB()
    root.ui = type(root.ui) == "table" and root.ui or {}
    root.ui.developerSyncHarness = type(root.ui.developerSyncHarness) == "table" and root.ui.developerSyncHarness or {}
    local harness = root.ui.developerSyncHarness
    local profileMode = string.upper(tostring(harness.profileMode or "SIMULATION"))
    if profileMode ~= "SIMULATION" and profileMode ~= "CURRENT" then
      profileMode = "SIMULATION"
    end
    local scenario = string.upper(tostring(harness.scenario or "FRESH"))
    if scenario ~= "FRESH" and scenario ~= "RETURNING" and scenario ~= "MIXED" then
      scenario = "FRESH"
    end
    local memberCount = math.floor((tonumber(harness.memberCount) or 5) + 0.5)
    if memberCount ~= 5 and memberCount ~= 10 and memberCount ~= 20 then
      memberCount = 5
    end
    harness.profileMode = profileMode
    harness.scenario = scenario
    harness.memberCount = memberCount
    return harness
  end

  local function FormatHarnessDuration(seconds)
    local value = math.max(0, tonumber(seconds) or 0)
    if value >= 60 then
      return string.format("%.1fm", value / 60)
    end
    return string.format("%.1fs", value)
  end

  local function BuildDeveloperSyncHarnessText(state)
    state = type(state) == "table" and state or {}
    local report = type(state.lastReport) == "table" and state.lastReport or nil
    if type(report) ~= "table" then
      return "Run the Sync Harness with 5, 10, or 20 raiders to build a developer-only synthetic session in Current Session and Sync Management.\n\nIt still shows the host-side shared-profile queue estimate below, but the fake joined members and their scratch profiles now let you rehearse preview, pull, and push repair flows without touching a real raid session."
    end

    local lines = {
      "Profile: " .. tostring(report.profileName or ""),
      "Source Mode: " .. tostring(report.profileMode == "SIMULATION" and "Simulation" or "Current Profile"),
      "Scenario: " .. tostring(report.scenarioLabel or report.scenario or ""),
      "Members: " .. tostring(report.memberCount or 0)
        .. " | Fresh: " .. tostring(report.freshMemberCount or 0)
        .. " | Aligned: " .. tostring(report.alignedMemberCount or 0),
      string.format(
        "Tuning: %d bytes per chunk | %.2fs queue delay",
        math.max(1, tonumber(report.tuning and report.tuning.chunkSize or 120) or 120),
        math.max(0, tonumber(report.tuning and report.tuning.intervalSeconds or 0.12) or 0.12)
      ),
      string.format(
        "Bootstrap per fresh member: %d bytes | %d chunks | %d messages | %s",
        math.max(0, tonumber(report.estimates and report.estimates.bootstrap and report.estimates.bootstrap.bytes or 0) or 0),
        math.max(0, tonumber(report.estimates and report.estimates.bootstrap and report.estimates.bootstrap.chunks or 0) or 0),
        math.max(0, tonumber(report.estimates and report.estimates.bootstrap and report.estimates.bootstrap.messages or 0) or 0),
        FormatHarnessDuration(report.estimates and report.estimates.bootstrap and report.estimates.bootstrap.seconds or 0)
      ),
      string.format(
        "Background per fresh member: %d bytes | %d chunks | %d messages | %s",
        math.max(0, tonumber(report.estimates and report.estimates.background and report.estimates.background.bytes or 0) or 0),
        math.max(0, tonumber(report.estimates and report.estimates.background and report.estimates.background.chunks or 0) or 0),
        math.max(0, tonumber(report.estimates and report.estimates.background and report.estimates.background.messages or 0) or 0),
        FormatHarnessDuration(report.estimates and report.estimates.background and report.estimates.background.seconds or 0)
      ),
      string.format(
        "Estimated last roll-ready member: %s | Full background convergence: %s",
        FormatHarnessDuration(report.totals and report.totals.rollReadyLastAt or 0),
        FormatHarnessDuration(report.totals and report.totals.fullSyncLastAt or 0)
      ),
      string.format(
        "Queued snapshot load: %d bytes | %d messages",
        math.max(0, tonumber(report.totals and report.totals.snapshotBytes or 0) or 0),
        math.max(0, tonumber(report.totals and report.totals.snapshotMessages or 0) or 0)
      ),
    }

    if tostring(report.fallbackMessage or "") ~= "" then
      lines[#lines + 1] = "Fallback: " .. tostring(report.fallbackMessage)
    end

    lines[#lines + 1] = ""
    lines[#lines + 1] = "Synthetic Member Timeline:"
    local shown = 0
    for _, member in ipairs(report.members or {}) do
      shown = shown + 1
      if shown > 20 then
        break
      end
      lines[#lines + 1] = string.format(
        "- %s | %s | ready %s | full %s",
        tostring(member.name or ""),
        tostring(member.status or ""),
        FormatHarnessDuration(member.readyAt or 0),
        FormatHarnessDuration(member.fullAt or 0)
      )
    end

    if type(report.notes) == "table" and #report.notes > 0 then
      lines[#lines + 1] = ""
      lines[#lines + 1] = "Notes:"
      for _, note in ipairs(report.notes) do
        lines[#lines + 1] = "- " .. tostring(note)
      end
    end

    if type(report.faultScenarios) == "table" and #report.faultScenarios > 0 then
      lines[#lines + 1] = ""
      lines[#lines + 1] = "Fault Rehearsals:"
      for _, scenario in ipairs(report.faultScenarios) do
        lines[#lines + 1] = "- " .. tostring(scenario.title or "Test") .. ": " .. tostring(scenario.action or "")
        lines[#lines + 1] = "  Expected: " .. tostring(scenario.expected or "")
      end
    end

    return table.concat(lines, "\n")
  end

  local function BuildDeveloperSyncValidationText(preflight)
    preflight = type(preflight) == "table" and preflight or {}
    if preflight.ran == true then
      if preflight.blocked == true then
        return "Release preflight: BLOCKED. "
          .. tostring(preflight.blockedDetail or "Stop active session and synchronization work before retrying.")
      end
      local total = math.max(0, tonumber(preflight.total) or 0)
      local passed = math.max(0, tonumber(preflight.passed) or 0)
      local failed = math.max(0, tonumber(preflight.failed) or 0)
      local warnings = math.max(0, tonumber(preflight.warnings) or 0)
      local durationSeconds = math.max(0, tonumber(preflight.durationSeconds) or 0)
      local slowSuiteCount = math.max(0, tonumber(preflight.slowSuiteCount) or 0)
      local suiteCount = math.max(0, tonumber(preflight.suiteCount) or 0)
      local slowSuiteNames = {}
      for _, suite in ipairs(type(preflight.suites) == "table" and preflight.suites or {}) do
        if type(suite) == "table" and suite.slow == true and #slowSuiteNames < 3 then
          slowSuiteNames[#slowSuiteNames + 1] = tostring(suite.label or suite.key or "unnamed suite")
        end
      end
      if preflight.ready == true then
        local summary = "Release preflight: "
          .. ((warnings > 0 or slowSuiteCount > 0) and "PASS WITH WARNINGS" or "PASS")
          .. " (" .. tostring(passed) .. "/" .. tostring(total)
          .. " checks across " .. tostring(suiteCount) .. " suites"
          .. ", " .. string.format("%.2fs", durationSeconds)
          .. (warnings > 0 and (", " .. tostring(warnings) .. " warning(s)") or "")
          .. (slowSuiteCount > 0 and (", " .. tostring(slowSuiteCount) .. " slow suite(s)") or "") .. ")."
        if #slowSuiteNames > 0 then
          summary = summary .. " Slow: " .. table.concat(slowSuiteNames, ", ") .. "."
        end
        return summary
      end
      local failedSuites = {}
      for _, suite in ipairs(type(preflight.suites) == "table" and preflight.suites or {}) do
        if type(suite) == "table" and suite.ready ~= true and #failedSuites < 3 then
          failedSuites[#failedSuites + 1] = tostring(suite.label or suite.key or "unnamed suite")
        end
      end
      return "Release preflight: FAIL (" .. tostring(passed) .. "/" .. tostring(total)
        .. ", " .. tostring(failed) .. " failed, " .. string.format("%.2fs", durationSeconds) .. ")."
        .. (#failedSuites > 0 and (" Failed suites: " .. table.concat(failedSuites, ", ") .. ".") or "")
        .. (#slowSuiteNames > 0 and (" Slow: " .. table.concat(slowSuiteNames, ", ") .. ".") or "")
    end
    return "Release preflight: Not run. Run this gate before using the synthetic rehearsal or beginning a real raid test."
  end

  local function EnsureHarnessChoiceButtonVisual(button)
    if not button then
      return
    end
    if not button.__harnessSelectionBg then
      local bg = button:CreateTexture(nil, "BORDER", nil, 1)
      bg:SetTexture("Interface/Buttons/WHITE8x8")
      bg:SetAllPoints(true)
      bg:SetVertexColor(0, 0, 0, 0)
      button.__harnessSelectionBg = bg
    end
    if not button.__harnessSelectionGlow then
      local glow = button:CreateTexture(nil, "BACKGROUND")
      glow:SetTexture("Interface/Buttons/WHITE8x8")
      glow:SetPoint("TOPLEFT", -2, 2)
      glow:SetPoint("BOTTOMRIGHT", 2, -2)
      glow:SetVertexColor(0, 0, 0, 0)
      button.__harnessSelectionGlow = glow
    end
    if not button.__harnessSelectionAccent then
      local accent = button:CreateTexture(nil, "ARTWORK", nil, 1)
      accent:SetTexture("Interface/Buttons/WHITE8x8")
      accent:SetPoint("BOTTOMLEFT", 2, 2)
      accent:SetPoint("BOTTOMRIGHT", -2, 2)
      accent:SetHeight(3)
      accent:SetVertexColor(0, 0, 0, 0)
      button.__harnessSelectionAccent = accent
    end
  end

  local function SetHarnessChoiceButtonSelected(button, selected)
    if not button then
      return
    end
    EnsureHarnessChoiceButtonVisual(button)
    local selectionBg = { 0.90, 0.74, 0.18, 0.22 }
    local selectionAccent = { 1.00, 0.88, 0.32, 0.96 }
    local selectionGlow = { 1.00, 0.82, 0.10, 0.12 }
    local label = button.GetFontString and button:GetFontString() or nil

    if button.__harnessSelectionBg then
      if selected then
        button.__harnessSelectionBg:SetVertexColor(selectionBg[1], selectionBg[2], selectionBg[3], selectionBg[4])
      else
        button.__harnessSelectionBg:SetVertexColor(0, 0, 0, 0)
      end
    end
    if button.__harnessSelectionGlow then
      if selected then
        button.__harnessSelectionGlow:SetVertexColor(selectionGlow[1], selectionGlow[2], selectionGlow[3], selectionGlow[4])
      else
        button.__harnessSelectionGlow:SetVertexColor(0, 0, 0, 0)
      end
    end
    if button.__harnessSelectionAccent then
      if selected then
        button.__harnessSelectionAccent:SetVertexColor(selectionAccent[1], selectionAccent[2], selectionAccent[3], selectionAccent[4])
      else
        button.__harnessSelectionAccent:SetVertexColor(0, 0, 0, 0)
      end
    end
    if label and label.SetTextColor then
      if selected then
        label:SetTextColor(1.00, 0.92, 0.46, 1.00)
      else
        label:SetTextColor(0.92, 0.92, 0.96, 1.00)
      end
    end
  end

  local aboutCreditsFrame = CreateFrame("Frame", nil, aboutContent)
  aboutCreditsFrame:SetAllPoints(aboutContent)
  aboutCreditsFrame:Hide()
  editor.aboutCreditsFrame = aboutCreditsFrame

  local creditsTitle = MakeAboutTitle(aboutCreditsFrame, "Credits", 0, 0)
  editor.aboutCreditsTitle = creditsTitle

  local function CreateCreditsSection(parent, titleText, bodyText)
    local header = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    header:SetJustifyH("LEFT")
    header:SetText(titleText)
    ApplyTitleColor(header)

    local body = parent:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
    body:SetJustifyH("LEFT")
    body:SetText(bodyText)
    if body.SetSpacing then body:SetSpacing(3) end

    local divider = parent:CreateTexture(nil, "ARTWORK")
    divider:SetColorTexture(1, 1, 1, 0.14)
    divider:SetHeight(1)

    return {
      header = header,
      body = body,
      divider = divider,
    }
  end

  local creditsSections = {
    CreateCreditsSection(
      aboutCreditsFrame,
      "Disclaimer",
      "This addon is an independent fan project and is not affiliated with or endorsed by Blizzard Entertainment, Inc.\n" ..
      "World of Warcraft and all related artwork are trademarks or registered trademarks of Blizzard Entertainment."
    ),
    CreateCreditsSection(
      aboutCreditsFrame,
      "Acknowledgements",
      "Special thanks to the creator of LargerMacroIconSelection - their icon list was incredibly helpful while building the icon selection features.\n\n" ..
      "Although LidCouncil does not use any code from RCLootCouncil, it has been a long-standing loot distribution tool and surely provided many ideas and workflow inspiration for LidCouncil."
    ),
    CreateCreditsSection(
      aboutCreditsFrame,
      "Testing & Feedback",
      "Special thanks to the following people for their time, feedback, and testing support:\n\n" ..
      "- Rikku\n" ..
      "- wuuusaa\n" ..
      "- Chepter\n" ..
      "- Elfeba\n" ..
      "- Inakara\n" ..
      "- Tokina\n" ..
      "- Tandonia\n" ..
      "- Neili"
    ),
    CreateCreditsSection(
      aboutCreditsFrame,
      "Development Tools",
      "This addon was developed with assistance from AI tools, including ChatGPT and Codex, which supported code generation, problem solving, and technical exploration."
    ),
    CreateCreditsSection(
      aboutCreditsFrame,
      "Graphics & Visuals",
      "Certain UI graphics and visual assets were created with the assistance of ChatGPT."
    ),
    CreateCreditsSection(
      aboutCreditsFrame,
      "Additional Support",
      "Thanks to everyone who shared suggestions, bug reports, and ideas during development <3"
    ),
  }
  editor.aboutCreditsSections = creditsSections

  local function UpdateAboutCreditsLayout()
    if not aboutContent or not creditsSections then return end
    if editor and editor.aboutSection and editor.aboutSection ~= "Credits" then return end
    local w = (aboutContent:GetWidth() or 0) - 24
    if w < 220 then w = 220 end
    if w > 620 then w = 620 end

    local y = -26
    for index, section in ipairs(creditsSections) do
      section.header:ClearAllPoints()
      section.header:SetPoint("TOPLEFT", creditsTitle, "TOPLEFT", 0, y)
      section.header:SetWidth(w)
      local hf, _, hflags = section.header:GetFont()
      if hf then section.header:SetFont(hf, 15, hflags) end
      ApplyTitleColor(section.header)

      local headerHeight = (section.header.GetStringHeight and section.header:GetStringHeight()) or 22
      y = y - headerHeight - 10

      section.body:ClearAllPoints()
      section.body:SetPoint("TOPLEFT", creditsTitle, "TOPLEFT", 0, y)
      section.body:SetWidth(w)
      local bf, _, bflags = section.body:GetFont()
      if bf then section.body:SetFont(bf, 13, bflags) end
      local bodyHeight = (section.body.GetStringHeight and section.body:GetStringHeight()) or 70
      y = y - bodyHeight

      if section.divider then
        if index < #creditsSections then
          section.divider:Show()
          section.divider:ClearAllPoints()
          section.divider:SetPoint("TOPLEFT", creditsTitle, "TOPLEFT", 0, y - 14)
          section.divider:SetWidth(w)
          y = y - 28
        else
          section.divider:Hide()
        end
      end
    end

    local h = math.max(520, math.floor((-y) + 120))
    if editor and editor.SetAboutContentHeight then
      editor:SetAboutContentHeight(h)
    end
  end
  editor.UpdateAboutCreditsLayout = UpdateAboutCreditsLayout
  SafeHookScript(aboutCreditsFrame, "OnShow", UpdateAboutCreditsLayout)
  SafeHookScript(aboutContent, "OnSizeChanged", UpdateAboutCreditsLayout)

  local aboutStressFrame = CreateFrame("Frame", nil, aboutContent)
  aboutStressFrame:SetAllPoints(aboutContent)
  aboutStressFrame:Hide()
  editor.aboutStressFrame = aboutStressFrame

  local stressTitle = MakeAboutTitle(aboutStressFrame, "Stresstest", 0, 0)
  editor.aboutStressTitle = stressTitle

  local stressContainer = CreateFrame("Frame", nil, aboutStressFrame)
  stressContainer:SetPoint("TOPLEFT", stressTitle, "BOTTOMLEFT", 0, -8)
  stressContainer:SetPoint("TOPRIGHT", aboutStressFrame, "TOPRIGHT", -10, -8)
  stressContainer:SetHeight(10)
  editor.aboutStressContainer = stressContainer

  local STRESS_ENTRIES = {
    {
      version = "Version 1.0.0 [BETA]",
      sections = {
        { title = "CPU", bullets = {
            "Base AddOn CPU usage: approximately 0.04%",
            "CPU usage with the Editor open: approximately 0.1%",
            "During profile synchronization, CPU usage can increase substantially and may reach approximately 90%, depending on the profile size and configured chunk size. Further optimization is planned for future updates.",
        } },
        { title = "FPS", bullets = {
            "During archive uploads from the host, FPS can drop significantly during some transfer windows.",
            "Archive synchronization can be paused before a boss fight and resumed afterward.",
        } },
      },
    },
  }

  local stressLines = {}
  local stressDividers = {}

  local function GetStressLine(index)
    local fs = stressLines[index]
    if not fs then
      fs = stressContainer:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
      fs:SetJustifyH("LEFT")
      stressLines[index] = fs
    end
    return fs
  end

  local function GetStressDivider(index)
    local tx = stressDividers[index]
    if not tx then
      tx = stressContainer:CreateTexture(nil, "ARTWORK")
      tx:SetColorTexture(1, 1, 1, 0.14)
      tx:SetHeight(1)
      stressDividers[index] = tx
    end
    return tx
  end

  local function HideUnusedStress(fromLine, fromDivider)
    for i = fromLine, #stressLines do stressLines[i]:Hide() end
    for i = fromDivider, #stressDividers do stressDividers[i]:Hide() end
  end

  local function UpdateStressText()
    local width = (aboutContent:GetWidth() or 560) - 14
    if width < 220 then width = 220 end
    local lineIndex, dividerIndex, y = 1, 1, 0

    for _, entry in ipairs(STRESS_ENTRIES) do
      local divider = GetStressDivider(dividerIndex); dividerIndex = dividerIndex + 1
      divider:ClearAllPoints()
      divider:SetPoint("TOPLEFT", stressContainer, "TOPLEFT", 0, y)
      divider:SetWidth(width)
      divider:Show()
      y = y - 12

      local versionLine = GetStressLine(lineIndex); lineIndex = lineIndex + 1
      versionLine:ClearAllPoints()
      versionLine:SetPoint("TOPLEFT", stressContainer, "TOPLEFT", 0, y)
      versionLine:SetWidth(width)
      versionLine:SetText(entry.version or "")
      local vf, _, vflags = versionLine:GetFont()
      versionLine:SetFont(vf, 16, vflags)
      ApplyTitleColor(versionLine)
      versionLine:Show()
      y = y - ((versionLine:GetStringHeight() or 0) + 8)

      for _, note in ipairs(entry.notes or {}) do
        local noteLine = GetStressLine(lineIndex); lineIndex = lineIndex + 1
        noteLine:ClearAllPoints()
        noteLine:SetPoint("TOPLEFT", stressContainer, "TOPLEFT", 0, y)
        noteLine:SetWidth(width)
        noteLine:SetText(note)
        local nf, _, nflags = noteLine:GetFont()
        noteLine:SetFont(nf, 13, nflags)
        noteLine:SetTextColor(0.9, 0.9, 0.9, 1)
        noteLine:Show()
        y = y - ((noteLine:GetStringHeight() or 0) + 6)
      end

      for _, section in ipairs(entry.sections or {}) do
        local sectionLine = GetStressLine(lineIndex); lineIndex = lineIndex + 1
        sectionLine:ClearAllPoints()
        sectionLine:SetPoint("TOPLEFT", stressContainer, "TOPLEFT", 0, y)
        sectionLine:SetWidth(width)
        sectionLine:SetText(section.title or "")
        local sf, _, sflags = sectionLine:GetFont()
        sectionLine:SetFont(sf, 14, sflags)
        ApplyTitleColor(sectionLine)
        sectionLine:Show()
        y = y - ((sectionLine:GetStringHeight() or 0) + 4)

        for _, bulletText in ipairs(section.bullets or {}) do
          local bulletLine = GetStressLine(lineIndex); lineIndex = lineIndex + 1
          bulletLine:ClearAllPoints()
          bulletLine:SetPoint("TOPLEFT", stressContainer, "TOPLEFT", 8, y)
          bulletLine:SetWidth(width - 8)
          bulletLine:SetText(string.char(226, 128, 162) .. " " .. tostring(bulletText))
          local bf, _, bflags = bulletLine:GetFont()
          bulletLine:SetFont(bf, 13, bflags)
          bulletLine:SetTextColor(0.9, 0.9, 0.9, 1)
          bulletLine:Show()
          y = y - ((bulletLine:GetStringHeight() or 0) + 2)
        end
        y = y - 6
      end
      y = y - 8
    end

    HideUnusedStress(lineIndex, dividerIndex)
    stressContainer:SetHeight(math.max(40, -y + 6))
  end

  local function UpdateAboutStressLayout()
    if not aboutContent or not stressContainer then return end
    if editor and editor.aboutSection and editor.aboutSection ~= "Stresstest" then return end
    UpdateStressText()
    local h = stressContainer:GetHeight() or 400
    if editor and editor.SetAboutContentHeight then
      editor:SetAboutContentHeight(math.max(520, math.floor(h + 140)))
    end
  end
  editor.UpdateAboutStressLayout = UpdateAboutStressLayout
  SafeHookScript(aboutStressFrame, "OnShow", UpdateAboutStressLayout)
  SafeHookScript(aboutContent, "OnSizeChanged", UpdateAboutStressLayout)

  local aboutTutorialImagesFrame = CreateFrame("Frame", nil, aboutContent)
  aboutTutorialImagesFrame:SetAllPoints(aboutContent)
  aboutTutorialImagesFrame:Hide()
  editor.aboutTutorialImagesFrame = aboutTutorialImagesFrame

  local aboutTutorialImagesTitle = MakeAboutTitle(aboutTutorialImagesFrame, "Disable Tutorial Images", 0, 0)
  editor.aboutTutorialImagesTitle = aboutTutorialImagesTitle

  local aboutTutorialImagesText = aboutTutorialImagesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutTutorialImagesText:SetPoint("TOPLEFT", aboutTutorialImagesTitle, "BOTTOMLEFT", 0, -8)
  aboutTutorialImagesText:SetWidth(560)
  aboutTutorialImagesText:SetJustifyH("LEFT")
  aboutTutorialImagesText:SetText(
    "Use this option if you want to save disk space by deleting tutorial images.\n\n" ..
    "Folder: Interface\\AddOns\\LidCouncil\\Media\\LidCouncil\\Tutorials\n\n" ..
    "If that folder or files are missing, WoW may show green placeholder boxes.\n" ..
    "Set mode to Disabled to stop loading tutorial images and keep cards transparent."
  )
  editor.aboutTutorialImagesText = aboutTutorialImagesText

  local aboutTutorialImagesModeHeader = MakeYellowSubHeader(aboutTutorialImagesFrame, "Mode", 0, -164)
  editor.aboutTutorialImagesModeHeader = aboutTutorialImagesModeHeader

  local aboutTutorialImagesToggleBtn = CreateFrame("Button", nil, aboutTutorialImagesFrame, "UIPanelButtonTemplate")
  aboutTutorialImagesToggleBtn:SetSize(110, 20)
  aboutTutorialImagesToggleBtn:SetPoint("TOPLEFT", aboutTutorialImagesModeHeader, "BOTTOMLEFT", 0, -8)
  editor.aboutTutorialImagesToggleBtn = aboutTutorialImagesToggleBtn

  local aboutTutorialImagesState = aboutTutorialImagesFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutTutorialImagesState:SetPoint("TOPLEFT", aboutTutorialImagesToggleBtn, "BOTTOMLEFT", 0, -8)
  aboutTutorialImagesState:SetWidth(560)
  aboutTutorialImagesState:SetJustifyH("LEFT")
  editor.aboutTutorialImagesState = aboutTutorialImagesState

  local function RefreshTutorialImagesSection()
    local root = RootDB()
    root.ui = root.ui or {}
    local disabled = root.ui.disableTutorialImages == true
    if aboutTutorialImagesToggleBtn then
      aboutTutorialImagesToggleBtn:SetText(disabled and "Disabled" or "Enabled")
    end
    if aboutTutorialImagesState then
      if disabled then
        aboutTutorialImagesState:SetText("Tutorial images are not loaded")
        aboutTutorialImagesState:SetTextColor(1.0, 0.78, 0.78, 1.0)
      else
        aboutTutorialImagesState:SetText("Tutorial images are currently shown")
        aboutTutorialImagesState:SetTextColor(0.82, 0.92, 0.82, 1.0)
      end
    end
  end
  editor.RefreshTutorialImagesSection = RefreshTutorialImagesSection

  aboutTutorialImagesToggleBtn:SetScript("OnClick", function()
    local root = RootDB()
    root.ui = root.ui or {}
    root.ui.disableTutorialImages = not (root.ui.disableTutorialImages == true)
    RefreshTutorialImagesSection()
    if editor and editor.ApplyTutorialTextureMode then editor:ApplyTutorialTextureMode() end
    if editor and editor.LayoutTutorial then editor:LayoutTutorial() end
    if editor and editor.LayoutNoPanel then editor:LayoutNoPanel() end
    if editor and editor.LayoutProfileWelcome then editor:LayoutProfileWelcome() end
  end)

  local function UpdateAboutTutorialImagesLayout()
    if not aboutContent or not aboutTutorialImagesText then return end
    if editor and editor.aboutSection and editor.aboutSection ~= "TutorialImages" then return end
    local w = (aboutContent:GetWidth() or 0) - 10
    if w < 200 then w = 200 end
    aboutTutorialImagesText:SetWidth(w)
    if aboutTutorialImagesState then
      aboutTutorialImagesState:SetWidth(math.max(220, w - 40))
    end
    local t1 = (aboutTutorialImagesText.GetStringHeight and aboutTutorialImagesText:GetStringHeight()) or 120
    local t2 = (aboutTutorialImagesState and aboutTutorialImagesState.GetStringHeight and aboutTutorialImagesState:GetStringHeight()) or 20
    if editor and editor.SetAboutContentHeight then
      editor:SetAboutContentHeight(math.max(520, math.floor(t1 + t2 + 230)))
    end
  end
  editor.UpdateAboutTutorialImagesLayout = UpdateAboutTutorialImagesLayout
  SafeHookScript(aboutTutorialImagesFrame, "OnShow", function()
    if editor and editor.RefreshTutorialImagesSection then editor:RefreshTutorialImagesSection() end
    UpdateAboutTutorialImagesLayout()
  end)
  SafeHookScript(aboutContent, "OnSizeChanged", UpdateAboutTutorialImagesLayout)

  local aboutDeveloperFrame = CreateFrame("Frame", nil, aboutContent)
  aboutDeveloperFrame:SetAllPoints(aboutContent)
  aboutDeveloperFrame:Hide()
  editor.aboutDeveloperFrame = aboutDeveloperFrame

  local DEV_SECTION_TITLE_R, DEV_SECTION_TITLE_G, DEV_SECTION_TITLE_B, DEV_SECTION_TITLE_A = 0.643, 0.804, 0.345, 1.0
  local DEV_EXPERIMENTAL_TITLE_R, DEV_EXPERIMENTAL_TITLE_G, DEV_EXPERIMENTAL_TITLE_B, DEV_EXPERIMENTAL_TITLE_A = 1.00, 0.50, 0.50, 1.0

  local function ApplyDeveloperSectionTitle(fontString, isExperimental)
    if not fontString then
      return
    end
    if isExperimental then
      fontString:SetTextColor(DEV_EXPERIMENTAL_TITLE_R, DEV_EXPERIMENTAL_TITLE_G, DEV_EXPERIMENTAL_TITLE_B, DEV_EXPERIMENTAL_TITLE_A)
    else
      fontString:SetTextColor(DEV_SECTION_TITLE_R, DEV_SECTION_TITLE_G, DEV_SECTION_TITLE_B, DEV_SECTION_TITLE_A)
    end
  end

  local function SetElementShown(element, shown)
    if not element then
      return
    end
    if element.SetShown then
      element:SetShown(shown)
    elseif shown and element.Show then
      element:Show()
    elseif not shown and element.Hide then
      element:Hide()
    end
  end

  local function ParseDeveloperNumber(value)
    local text = tostring(value or "")
    text = text:gsub(",", ".")
    return tonumber(text)
  end

  local function ResolveApiFunction(name)
    local api = rawget(_G, "LIDCOUNCIL_API")
    if type(api) == "table" and type(api[name]) == "function" then
      return api[name]
    end
    local globalValue = rawget(_G, name)
    if type(globalValue) == "function" then
      return globalValue
    end
    return nil
  end

  local function GetProfileSyncTuning()
    local getter = ResolveApiFunction("LIDCOUNCIL_GetProfileSyncTuning")
    if type(getter) == "function" then
      local ok, tuning = pcall(getter)
      if ok and type(tuning) == "table" then
        return tuning
      end
    end
    local root = RootDB()
    root.ui = root.ui or {}
    return {
      developerMode = root.ui.developerMode == true,
      chunkSize = tonumber(root.ui.profileSyncChunkSize) or 120,
      intervalSeconds = tonumber(root.ui.profileSyncDelaySeconds) or 0.12,
      defaultChunkSize = 120,
      minChunkSize = 80,
      maxChunkSize = 190,
      defaultIntervalSeconds = 0.12,
      minIntervalSeconds = 0.08,
      maxIntervalSeconds = 0.25,
      safePayloadLimit = 240,
    }
  end

  local function SetProfileSyncTuning(chunkSize, intervalSeconds)
    local setter = ResolveApiFunction("LIDCOUNCIL_SetProfileSyncTuning")
    if type(setter) == "function" then
      local ok, tuning = pcall(setter, chunkSize, intervalSeconds)
      if ok and type(tuning) == "table" then
        return tuning
      end
    end
    local root = RootDB()
    root.ui = root.ui or {}
    root.ui.profileSyncChunkSize = tonumber(chunkSize) or 120
    root.ui.profileSyncDelaySeconds = tonumber(intervalSeconds) or 0.12
    return GetProfileSyncTuning()
  end

  local function ResetProfileSyncTuning()
    local resetter = ResolveApiFunction("LIDCOUNCIL_ResetProfileSyncTuning")
    if type(resetter) == "function" then
      local ok, tuning = pcall(resetter)
      if ok and type(tuning) == "table" then
        return tuning
      end
    end
    return SetProfileSyncTuning(120, 0.12)
  end

  local function CreateDeveloperEditBox(name, parent, width)
    local editBox = CreateFrame("EditBox", name, parent, "InputBoxTemplate")
    editBox:SetSize(width or 72, 22)
    editBox:SetAutoFocus(false)
    editBox:SetJustifyH("CENTER")
    editBox:SetMaxLetters(8)
    return editBox
  end

  local aboutDeveloperTitle = MakeAboutTitle(aboutDeveloperFrame, "Developer Mode", 0, 0)
  editor.aboutDeveloperTitle = aboutDeveloperTitle

  local aboutDeveloperText = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperText:SetPoint("TOPLEFT", aboutDeveloperTitle, "BOTTOMLEFT", 0, -8)
  aboutDeveloperText:SetWidth(560)
  aboutDeveloperText:SetJustifyH("LEFT")
  aboutDeveloperText:SetText(
    "Developer Mode exposes internal testing helpers for LidCouncil.\n\n" ..
    "Activate it only when you need profile IDs, tutorial overlays, the Simulation profile, the Sync Harness, or runtime diagnostics while testing."
  )
  editor.aboutDeveloperText = aboutDeveloperText

  local aboutDeveloperModeCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutDeveloperModeCheck", aboutDeveloperFrame, "UICheckButtonTemplate")
  aboutDeveloperModeCheck:SetPoint("TOPLEFT", aboutDeveloperText, "BOTTOMLEFT", 0, -10)
  _G[aboutDeveloperModeCheck:GetName() .. "Text"]:SetText("Activate Developer Mode")
  editor.aboutDeveloperModeCheck = aboutDeveloperModeCheck

  local aboutDeveloperModeDesc = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperModeDesc:SetPoint("TOPLEFT", aboutDeveloperModeCheck, "BOTTOMLEFT", 24, -2)
  aboutDeveloperModeDesc:SetWidth(536)
  aboutDeveloperModeDesc:SetJustifyH("LEFT")
  aboutDeveloperModeDesc:SetTextColor(0.80, 0.80, 0.80, 1.00)
  aboutDeveloperModeDesc:SetText("Master switch. Turning this off disables every developer helper below.")
  editor.aboutDeveloperModeDesc = aboutDeveloperModeDesc

  local aboutDeveloperOptionsDivider = aboutDeveloperFrame:CreateTexture(nil, "ARTWORK")
  aboutDeveloperOptionsDivider:SetTexture("Interface/Buttons/WHITE8x8")
  aboutDeveloperOptionsDivider:SetVertexColor(0.25, 0.25, 0.30, 0.85)
  aboutDeveloperOptionsDivider:SetHeight(1)
  aboutDeveloperOptionsDivider:SetPoint("TOPLEFT", aboutDeveloperModeDesc, "BOTTOMLEFT", -24, -14)
  aboutDeveloperOptionsDivider:SetPoint("RIGHT", aboutDeveloperFrame, "RIGHT", -10, 0)
  editor.aboutDeveloperOptionsDivider = aboutDeveloperOptionsDivider

  local aboutDeveloperOptionsHeader = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  aboutDeveloperOptionsHeader:SetPoint("TOPLEFT", aboutDeveloperOptionsDivider, "BOTTOMLEFT", 0, -12)
  aboutDeveloperOptionsHeader:SetText("Developer Options")
  ApplyDeveloperSectionTitle(aboutDeveloperOptionsHeader, false)
  editor.aboutDeveloperOptionsHeader = aboutDeveloperOptionsHeader

  local aboutDeveloperOptionsDesc = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperOptionsDesc:SetPoint("TOPLEFT", aboutDeveloperOptionsHeader, "BOTTOMLEFT", 0, -6)
  aboutDeveloperOptionsDesc:SetWidth(560)
  aboutDeveloperOptionsDesc:SetJustifyH("LEFT")
  aboutDeveloperOptionsDesc:SetText("Enable only the helpers you need while testing.")
  editor.aboutDeveloperOptionsDesc = aboutDeveloperOptionsDesc

  local aboutShowProfileIdCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutShowProfileIdCheck", aboutDeveloperFrame, "UICheckButtonTemplate")
  aboutShowProfileIdCheck:SetPoint("TOPLEFT", aboutDeveloperOptionsDesc, "BOTTOMLEFT", 0, -10)
  _G[aboutShowProfileIdCheck:GetName() .. "Text"]:SetText("Show internal Profile ID")
  editor.aboutShowProfileIdCheck = aboutShowProfileIdCheck

  local profileIdInfo = CreateFrame("Frame", nil, aboutDeveloperFrame)
  profileIdInfo:SetSize(18, 18)
  profileIdInfo:SetPoint("LEFT", _G[aboutShowProfileIdCheck:GetName() .. "Text"], "RIGHT", 8, 0)
  profileIdInfo:EnableMouse(true)
  local profileIdInfoText = profileIdInfo:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  profileIdInfoText:SetPoint("CENTER", 0, 0)
  profileIdInfoText:SetText("(i)")
  profileIdInfo:SetScript("OnEnter", function(self)
    if not GameTooltip then return end
    GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
    GameTooltip:SetText("Show internal Profile ID", 1, 0.82, 0.28, 1, true)
    GameTooltip:AddLine("Activating this will show the Internal Profile ID on the Profile Page. The Internal ID is unique and allows profiles with the exact same name to not get into conflict with each other.", 0.92, 0.92, 0.96, true)
    GameTooltip:Show()
  end)
  profileIdInfo:SetScript("OnLeave", function()
    if GameTooltip then GameTooltip:Hide() end
  end)
  editor.aboutShowProfileIdInfo = profileIdInfo

  local aboutShowProfileSizeCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutShowProfileSizeCheck", aboutDeveloperFrame, "UICheckButtonTemplate")
  aboutShowProfileSizeCheck:SetPoint("TOPLEFT", aboutShowProfileIdCheck, "BOTTOMLEFT", 0, -6)
  _G[aboutShowProfileSizeCheck:GetName() .. "Text"]:SetText("Show Profile Size")
  editor.aboutShowProfileSizeCheck = aboutShowProfileSizeCheck

  local profileSizeInfo = CreateFrame("Frame", nil, aboutDeveloperFrame)
  profileSizeInfo:SetSize(18, 18)
  profileSizeInfo:SetPoint("LEFT", _G[aboutShowProfileSizeCheck:GetName() .. "Text"], "RIGHT", 8, 0)
  profileSizeInfo:EnableMouse(true)
  local profileSizeInfoText = profileSizeInfo:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  profileSizeInfoText:SetPoint("CENTER", 0, 0)
  profileSizeInfoText:SetText("(i)")
  profileSizeInfo:SetScript("OnEnter", function(self)
    if not GameTooltip then return end
    GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
    GameTooltip:SetText("Show Profile Size", 1, 0.82, 0.28, 1, true)
    GameTooltip:AddLine("Shows the serialized profile snapshot size in Profile Settings. This is the payload used for full profile sync.", 0.92, 0.92, 0.96, true)
    GameTooltip:AddLine("The estimate uses the current LidCouncil chunk size and queue delay. Real raid conditions can still add overhead.", 0.72, 0.82, 0.95, true)
    GameTooltip:Show()
  end)
  profileSizeInfo:SetScript("OnLeave", function()
    if GameTooltip then GameTooltip:Hide() end
  end)
  editor.aboutShowProfileSizeInfo = profileSizeInfo

  local aboutTutorialModeCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutTutorialModeCheck", aboutDeveloperFrame, "UICheckButtonTemplate")
  aboutTutorialModeCheck:SetPoint("TOPLEFT", aboutShowProfileSizeCheck, "BOTTOMLEFT", 0, -6)
  _G[aboutTutorialModeCheck:GetName() .. "Text"]:SetText("Tutorial Mode")
  editor.aboutTutorialModeCheck = aboutTutorialModeCheck

  local aboutChecklistDevCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutChecklistDevCheck", aboutDeveloperFrame, "UICheckButtonTemplate")
  aboutChecklistDevCheck:SetPoint("TOPLEFT", aboutTutorialModeCheck, "BOTTOMLEFT", 0, -6)
  _G[aboutChecklistDevCheck:GetName() .. "Text"]:SetText("Checklist Dev")
  editor.aboutChecklistDevCheck = aboutChecklistDevCheck

  local aboutChangelogDevCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutChangelogDevCheck", aboutDeveloperFrame, "UICheckButtonTemplate")
  aboutChangelogDevCheck:SetPoint("TOPLEFT", aboutChecklistDevCheck, "BOTTOMLEFT", 0, -6)
  _G[aboutChangelogDevCheck:GetName() .. "Text"]:SetText("Changelog Dev")
  editor.aboutChangelogDevCheck = aboutChangelogDevCheck

  local aboutShowSimulationCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutShowSimulationCheck", aboutDeveloperFrame, "UICheckButtonTemplate")
  aboutShowSimulationCheck:SetPoint("TOPLEFT", aboutChangelogDevCheck, "BOTTOMLEFT", 0, -6)
  _G[aboutShowSimulationCheck:GetName() .. "Text"]:SetText("Show Simulation Profile")
  editor.aboutShowSimulationCheck = aboutShowSimulationCheck

  local aboutCreateSimulationBtn = CreateFrame("Button", nil, aboutDeveloperFrame, "UIPanelButtonTemplate")
  aboutCreateSimulationBtn:SetSize(180, 22)
  aboutCreateSimulationBtn:SetPoint("TOPLEFT", aboutShowSimulationCheck, "BOTTOMLEFT", 4, -10)
  aboutCreateSimulationBtn:SetText("Create Simulation Profile")
  editor.aboutCreateSimulationBtn = aboutCreateSimulationBtn

  local aboutDeleteSimulationBtn = CreateFrame("Button", nil, aboutDeveloperFrame, "UIPanelButtonTemplate")
  aboutDeleteSimulationBtn:SetSize(180, 22)
  aboutDeleteSimulationBtn:SetPoint("LEFT", aboutCreateSimulationBtn, "RIGHT", 10, 0)
  aboutDeleteSimulationBtn:SetText("Delete Simulation Profile")
  editor.aboutDeleteSimulationBtn = aboutDeleteSimulationBtn

  local aboutRuntimeDivider = aboutDeveloperFrame:CreateTexture(nil, "ARTWORK")
  aboutRuntimeDivider:SetTexture("Interface/Buttons/WHITE8x8")
  aboutRuntimeDivider:SetVertexColor(0.25, 0.25, 0.30, 0.85)
  aboutRuntimeDivider:SetHeight(1)
  aboutRuntimeDivider:SetPoint("TOPLEFT", aboutCreateSimulationBtn, "BOTTOMLEFT", -4, -18)
  aboutRuntimeDivider:SetPoint("RIGHT", aboutDeveloperFrame, "RIGHT", -10, 0)
  editor.aboutRuntimeDivider = aboutRuntimeDivider

  local aboutRuntimeHeader = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  aboutRuntimeHeader:SetPoint("TOPLEFT", aboutRuntimeDivider, "BOTTOMLEFT", 0, -12)
  aboutRuntimeHeader:SetText("Runtime Health")
  ApplyDeveloperSectionTitle(aboutRuntimeHeader, false)
  editor.aboutRuntimeHeader = aboutRuntimeHeader

  local aboutRuntimeDesc = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutRuntimeDesc:SetPoint("TOPLEFT", aboutRuntimeHeader, "BOTTOMLEFT", 0, -6)
  aboutRuntimeDesc:SetWidth(560)
  aboutRuntimeDesc:SetJustifyH("LEFT")
  aboutRuntimeDesc:SetText("Current Simulation visibility, developer flags, and live runtime state.")
  editor.aboutRuntimeDesc = aboutRuntimeDesc

  local aboutSimulationState = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutSimulationState:SetPoint("TOPLEFT", aboutRuntimeDesc, "BOTTOMLEFT", 0, -8)
  aboutSimulationState:SetWidth(560)
  aboutSimulationState:SetJustifyH("LEFT")
  editor.aboutSimulationState = aboutSimulationState

  local aboutDeveloperState = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperState:SetPoint("TOPLEFT", aboutSimulationState, "BOTTOMLEFT", 0, -8)
  aboutDeveloperState:SetWidth(560)
  aboutDeveloperState:SetJustifyH("LEFT")
  editor.aboutDeveloperState = aboutDeveloperState

  local aboutDeveloperHealthHeader = MakeYellowSubHeader(aboutDeveloperFrame, "Detailed Diagnostics", 0, -152)
  aboutDeveloperHealthHeader:SetPoint("TOPLEFT", aboutDeveloperState, "BOTTOMLEFT", 0, -16)
  editor.aboutDeveloperHealthHeader = aboutDeveloperHealthHeader

  local aboutDeveloperHealth = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperHealth:SetPoint("TOPLEFT", aboutDeveloperHealthHeader, "BOTTOMLEFT", 0, -8)
  aboutDeveloperHealth:SetWidth(560)
  aboutDeveloperHealth:SetJustifyH("LEFT")
  editor.aboutDeveloperHealth = aboutDeveloperHealth

  local aboutDeveloperExperimentalDivider = aboutDeveloperFrame:CreateTexture(nil, "ARTWORK")
  aboutDeveloperExperimentalDivider:SetTexture("Interface/Buttons/WHITE8x8")
  aboutDeveloperExperimentalDivider:SetVertexColor(0.25, 0.25, 0.30, 0.85)
  aboutDeveloperExperimentalDivider:SetHeight(1)
  aboutDeveloperExperimentalDivider:SetPoint("TOPLEFT", aboutDeveloperHealth, "BOTTOMLEFT", 0, -18)
  aboutDeveloperExperimentalDivider:SetPoint("RIGHT", aboutDeveloperFrame, "RIGHT", -10, 0)
  editor.aboutDeveloperExperimentalDivider = aboutDeveloperExperimentalDivider

  local aboutDeveloperExperimentalHeader = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  aboutDeveloperExperimentalHeader:SetPoint("TOPLEFT", aboutDeveloperExperimentalDivider, "BOTTOMLEFT", 0, -12)
  aboutDeveloperExperimentalHeader:SetText("New Features in Development")
  ApplyDeveloperSectionTitle(aboutDeveloperExperimentalHeader, true)
  editor.aboutDeveloperExperimentalHeader = aboutDeveloperExperimentalHeader

  local aboutDeveloperExperimentalInfo = CreateFrame("Frame", nil, aboutDeveloperFrame)
  aboutDeveloperExperimentalInfo:SetSize(18, 18)
  aboutDeveloperExperimentalInfo:SetPoint("LEFT", aboutDeveloperExperimentalHeader, "RIGHT", 8, 0)
  aboutDeveloperExperimentalInfo:EnableMouse(true)
  local aboutDeveloperExperimentalInfoText = aboutDeveloperExperimentalInfo:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  aboutDeveloperExperimentalInfoText:SetPoint("CENTER", 0, 0)
  aboutDeveloperExperimentalInfoText:SetText("(i)")
  aboutDeveloperExperimentalInfo:SetScript("OnEnter", function(self)
    if not GameTooltip then return end
    local tuning = GetProfileSyncTuning()
    GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
    GameTooltip:SetText("Experimental Profile Sync Tuning", 1, 0.50, 0.50, 1, true)
    GameTooltip:AddLine("Default: 120 byte chunks and 0.12 second queue delay.", 0.92, 0.92, 0.96, true)
    GameTooltip:AddLine("First safe test: 160 byte chunks with the default 0.12 second delay.", 0.92, 0.92, 0.96, true)
    GameTooltip:AddLine("Still plausible for testing: up to 180 byte chunks, and 0.10-0.12 second delay.", 0.92, 0.92, 0.96, true)
    GameTooltip:AddLine("Most likely to break: very large chunks, or delays below 0.08 seconds. That can create oversized addon messages or Blizzard spam protection disconnects.", 1.00, 0.62, 0.52, true)
    GameTooltip:AddLine("Throttle handling: if WoW reports AddonMessageThrottle, LidCouncil keeps the message in the queue and retries it after at least 1 second. The message is not counted as sent until WoW accepts it.", 0.92, 0.92, 0.96, true)
    GameTooltip:AddLine("Testing signal: if the throttle counter in Sync Management rises, your current chunk size or queue delay is too aggressive for sustained syncing. Lower chunk size, increase delay, or both.", 1.00, 0.82, 0.42, true)
    GameTooltip:AddLine("Important: local send success only means WoW accepted the message for sending. Final profile sync still depends on the receiver applying the snapshot and sending its ACK.", 0.72, 0.82, 0.95, true)
    GameTooltip:AddLine(string.format("Recommended range: %d-%d bytes, %.2f-%.2f seconds. Developer overrides are no longer clamped; current effective values: %d bytes / %.2fs.", tonumber(tuning.minChunkSize) or 80, tonumber(tuning.maxChunkSize) or 190, tonumber(tuning.minIntervalSeconds) or 0.08, tonumber(tuning.maxIntervalSeconds) or 0.25, tonumber(tuning.chunkSize) or 120, tonumber(tuning.intervalSeconds) or 0.12), 0.72, 0.82, 0.95, true)
    GameTooltip:AddLine("These settings are only honored while Developer Mode is enabled.", 0.72, 0.82, 0.95, true)
    GameTooltip:Show()
  end)
  aboutDeveloperExperimentalInfo:SetScript("OnLeave", function()
    if GameTooltip then GameTooltip:Hide() end
  end)
  editor.aboutDeveloperExperimentalInfo = aboutDeveloperExperimentalInfo

  local aboutDeveloperExperimentalDesc = aboutDeveloperFrame:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperExperimentalDesc:SetPoint("TOPLEFT", aboutDeveloperExperimentalHeader, "BOTTOMLEFT", 0, -6)
  aboutDeveloperExperimentalDesc:SetWidth(560)
  aboutDeveloperExperimentalDesc:SetJustifyH("LEFT")
  aboutDeveloperExperimentalDesc:SetText("Developer-only previews and experiments. Each section below controls a separate unfinished feature.")
  editor.aboutDeveloperExperimentalDesc = aboutDeveloperExperimentalDesc

  local aboutImportExportFeatureCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutImportExportFeatureCheck", aboutDeveloperFrame, "UICheckButtonTemplate")
  aboutImportExportFeatureCheck:SetPoint("TOPLEFT", aboutDeveloperExperimentalDesc, "BOTTOMLEFT", 0, -8)
  _G[aboutImportExportFeatureCheck:GetName() .. "Text"]:SetText("Import / Export Feature")
  aboutImportExportFeatureCheck:SetScript("OnEnter", function(self)
    if not GameTooltip then return end
    GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
    GameTooltip:SetText("Import / Export Feature", 1, 0.50, 0.50, 1, true)
    GameTooltip:AddLine("Shows the unverified Transfer tab in Profile Settings. The underlying transfer implementation remains loaded while this navigation entry is hidden.", 0.92, 0.92, 0.96, true)
    GameTooltip:Show()
  end)
  aboutImportExportFeatureCheck:SetScript("OnLeave", function()
    if GameTooltip then GameTooltip:Hide() end
  end)
  editor.aboutImportExportFeatureCheck = aboutImportExportFeatureCheck

  editor.aboutHeaderMonitoringPreviewPanel = CreateDeveloperToolPanel(aboutDeveloperFrame, "Header Monitoring Preview", editor)
  editor.aboutHeaderMonitoringPreviewPanel:SetPoint("TOPLEFT", aboutImportExportFeatureCheck, "BOTTOMLEFT", 0, -10)
  editor.aboutHeaderMonitoringPreviewPanel:SetSize(560, 98)
  editor.aboutHeaderMonitoringPreviewHeader = editor.aboutHeaderMonitoringPreviewPanel.__titleText

  editor.aboutHeaderMonitoringPreviewDesc = editor.aboutHeaderMonitoringPreviewPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  editor.aboutHeaderMonitoringPreviewDesc:SetPoint("TOPLEFT", editor.aboutHeaderMonitoringPreviewPanel.__content, "TOPLEFT", 0, 0)
  editor.aboutHeaderMonitoringPreviewDesc:SetJustifyH("LEFT")
  editor.aboutHeaderMonitoringPreviewDesc:SetTextColor(0.72, 0.76, 0.82, 1)
  editor.aboutHeaderMonitoringPreviewDesc:SetText("Expose the unfinished Header Monitoring option in UI Settings.")

  local aboutShowHeaderMonitoringCheck = CreateFrame("CheckButton", "LIDCOUNCIL_AboutShowHeaderMonitoringCheck", editor.aboutHeaderMonitoringPreviewPanel.__content, "UICheckButtonTemplate")
  aboutShowHeaderMonitoringCheck:SetPoint("TOPLEFT", editor.aboutHeaderMonitoringPreviewDesc, "BOTTOMLEFT", 0, -6)
  _G[aboutShowHeaderMonitoringCheck:GetName() .. "Text"]:SetText("Show Header Monitoring setting in UI Settings")
  editor.aboutShowHeaderMonitoringCheck = aboutShowHeaderMonitoringCheck

  local headerMonitoringInfo = CreateFrame("Frame", nil, editor.aboutHeaderMonitoringPreviewPanel.__content)
  headerMonitoringInfo:SetSize(18, 18)
  headerMonitoringInfo:SetPoint("LEFT", _G[aboutShowHeaderMonitoringCheck:GetName() .. "Text"], "RIGHT", 8, 0)
  headerMonitoringInfo:EnableMouse(true)
  local headerMonitoringInfoText = headerMonitoringInfo:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall")
  headerMonitoringInfoText:SetPoint("CENTER", 0, 0)
  headerMonitoringInfoText:SetText("(i)")
  headerMonitoringInfo:SetScript("OnEnter", function(self)
    if not GameTooltip then return end
    GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
    GameTooltip:SetText("Header Monitoring Checkmark", 1, 0.50, 0.50, 1, true)
    GameTooltip:AddLine("Not working currently, in development.", 1.00, 0.62, 0.52, true)
    GameTooltip:Show()
  end)
  headerMonitoringInfo:SetScript("OnLeave", function()
    if GameTooltip then GameTooltip:Hide() end
  end)
  editor.aboutShowHeaderMonitoringInfo = headerMonitoringInfo

  editor.aboutProfileSyncTuningPanel = CreateDeveloperToolPanel(aboutDeveloperFrame, "Profile Sync Tuning", editor)
  editor.aboutProfileSyncTuningPanel:SetPoint("TOPLEFT", editor.aboutHeaderMonitoringPreviewPanel, "BOTTOMLEFT", 0, -10)
  editor.aboutProfileSyncTuningPanel:SetSize(560, 190)
  editor.aboutProfileSyncTuningHeader = editor.aboutProfileSyncTuningPanel.__titleText
  aboutDeveloperExperimentalInfo:ClearAllPoints()
  aboutDeveloperExperimentalInfo:SetPoint("LEFT", editor.aboutProfileSyncTuningHeader, "RIGHT", 8, 0)
  aboutDeveloperExperimentalInfo:SetParent(editor.aboutProfileSyncTuningPanel)
  aboutDeveloperExperimentalInfo:SetFrameLevel(editor.aboutProfileSyncTuningPanel:GetFrameLevel() + 3)

  editor.aboutProfileSyncTuningDesc = editor.aboutProfileSyncTuningPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  editor.aboutProfileSyncTuningDesc:SetPoint("TOPLEFT", editor.aboutProfileSyncTuningPanel.__content, "TOPLEFT", 0, 0)
  editor.aboutProfileSyncTuningDesc:SetWidth(560)
  editor.aboutProfileSyncTuningDesc:SetJustifyH("LEFT")
  editor.aboutProfileSyncTuningDesc:SetTextColor(0.72, 0.76, 0.82, 1)
  editor.aboutProfileSyncTuningDesc:SetText("Tune message chunking and queue timing for controlled sync tests.")

  local aboutSyncChunkLabel = editor.aboutProfileSyncTuningPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutSyncChunkLabel:SetPoint("TOPLEFT", editor.aboutProfileSyncTuningDesc, "BOTTOMLEFT", 0, -10)
  aboutSyncChunkLabel:SetText("Profile chunk size")
  editor.aboutSyncChunkLabel = aboutSyncChunkLabel

  local aboutSyncChunkEdit = CreateDeveloperEditBox("LIDCOUNCIL_ProfileSyncChunkEdit", editor.aboutProfileSyncTuningPanel.__content, 72)
  aboutSyncChunkEdit:SetPoint("LEFT", aboutSyncChunkLabel, "RIGHT", 12, 0)
  editor.aboutSyncChunkEdit = aboutSyncChunkEdit

  local aboutSyncChunkUnit = editor.aboutProfileSyncTuningPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutSyncChunkUnit:SetPoint("LEFT", aboutSyncChunkEdit, "RIGHT", 8, 0)
  aboutSyncChunkUnit:SetText("bytes")
  editor.aboutSyncChunkUnit = aboutSyncChunkUnit

  local aboutSyncDelayLabel = editor.aboutProfileSyncTuningPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutSyncDelayLabel:SetPoint("TOPLEFT", aboutSyncChunkLabel, "BOTTOMLEFT", 0, -12)
  aboutSyncDelayLabel:SetText("Queue delay")
  editor.aboutSyncDelayLabel = aboutSyncDelayLabel

  local aboutSyncDelayEdit = CreateDeveloperEditBox("LIDCOUNCIL_ProfileSyncDelayEdit", editor.aboutProfileSyncTuningPanel.__content, 72)
  aboutSyncDelayEdit:SetPoint("LEFT", aboutSyncDelayLabel, "RIGHT", 12, 0)
  editor.aboutSyncDelayEdit = aboutSyncDelayEdit

  local aboutSyncDelayUnit = editor.aboutProfileSyncTuningPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutSyncDelayUnit:SetPoint("LEFT", aboutSyncDelayEdit, "RIGHT", 8, 0)
  aboutSyncDelayUnit:SetText("sec")
  editor.aboutSyncDelayUnit = aboutSyncDelayUnit

  local aboutSyncTuningApplyBtn = CreateFrame("Button", nil, editor.aboutProfileSyncTuningPanel.__content, "UIPanelButtonTemplate")
  aboutSyncTuningApplyBtn:SetSize(120, 22)
  aboutSyncTuningApplyBtn:SetPoint("TOPLEFT", aboutSyncDelayLabel, "BOTTOMLEFT", 0, -12)
  aboutSyncTuningApplyBtn:SetText("Apply Changes")
  ApplyDeveloperToolActionStyle(aboutSyncTuningApplyBtn, "primary")
  editor.aboutSyncTuningApplyBtn = aboutSyncTuningApplyBtn

  local aboutSyncTuningResetBtn = CreateFrame("Button", nil, editor.aboutProfileSyncTuningPanel.__content, "UIPanelButtonTemplate")
  aboutSyncTuningResetBtn:SetSize(140, 22)
  aboutSyncTuningResetBtn:SetPoint("LEFT", aboutSyncTuningApplyBtn, "RIGHT", 10, 0)
  aboutSyncTuningResetBtn:SetText("Reset to Defaults")
  ApplyDeveloperToolActionStyle(aboutSyncTuningResetBtn, "clear")
  editor.aboutSyncTuningResetBtn = aboutSyncTuningResetBtn

  local aboutSyncTuningState = editor.aboutProfileSyncTuningPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutSyncTuningState:SetPoint("TOPLEFT", aboutSyncTuningApplyBtn, "BOTTOMLEFT", 0, -8)
  aboutSyncTuningState:SetWidth(320)
  aboutSyncTuningState:SetJustifyH("LEFT")
  aboutSyncTuningState:SetTextColor(0.72, 0.76, 0.82, 1)
  aboutSyncTuningState:SetText("")
  editor.aboutSyncTuningState = aboutSyncTuningState

  local aboutDeveloperHarnessPanel = CreateDeveloperToolPanel(aboutDeveloperFrame, "Release Preflight", editor)
  aboutDeveloperHarnessPanel:SetPoint("TOPLEFT", editor.aboutProfileSyncTuningPanel, "BOTTOMLEFT", 0, -10)
  aboutDeveloperHarnessPanel:SetSize(560, 194)
  editor.aboutDeveloperHarnessPanel = aboutDeveloperHarnessPanel

  local aboutDeveloperHarnessHeader = aboutDeveloperHarnessPanel.__titleText
  editor.aboutDeveloperHarnessHeader = aboutDeveloperHarnessHeader

  local aboutDeveloperHarnessDesc = aboutDeveloperHarnessPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperHarnessDesc:SetPoint("TOPLEFT", aboutDeveloperHarnessPanel.__content, "TOPLEFT", 0, 0)
  aboutDeveloperHarnessDesc:SetWidth(560)
  aboutDeveloperHarnessDesc:SetJustifyH("LEFT")
  aboutDeveloperHarnessDesc:SetTextColor(0.72, 0.76, 0.82, 1)
  aboutDeveloperHarnessDesc:SetText("Validate startup, communication, recovery, and release invariants locally without contacting other players.")
  editor.aboutDeveloperHarnessDesc = aboutDeveloperHarnessDesc

  editor.aboutDeveloperPreflightStatusCard = CreateFrame("Frame", nil, aboutDeveloperHarnessPanel.__content, "BackdropTemplate")
  editor.aboutDeveloperPreflightStatusCard:SetBackdrop(DEVELOPER_TOOL_PANEL_BACKDROP)
  editor.aboutDeveloperPreflightStatusCard:SetBackdropColor(0.025, 0.030, 0.040, 0.96)
  editor.aboutDeveloperPreflightStatusCard:SetBackdropBorderColor(0.32, 0.36, 0.42, 0.88)
  editor.aboutDeveloperPreflightStatusCard:SetHeight(56)

  editor.aboutDeveloperPreflightStatusTitle = editor.aboutDeveloperPreflightStatusCard:CreateFontString(nil, "OVERLAY", "GameFontNormal")
  editor.aboutDeveloperPreflightStatusTitle:SetPoint("TOPLEFT", editor.aboutDeveloperPreflightStatusCard, "TOPLEFT", 12, -9)
  editor.aboutDeveloperPreflightStatusTitle:SetText("NOT RUN")

  editor.aboutDeveloperPreflightStatusSummary = editor.aboutDeveloperPreflightStatusCard:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  editor.aboutDeveloperPreflightStatusSummary:SetPoint("TOPLEFT", editor.aboutDeveloperPreflightStatusTitle, "BOTTOMLEFT", 0, -4)
  editor.aboutDeveloperPreflightStatusSummary:SetPoint("RIGHT", editor.aboutDeveloperPreflightStatusCard, "RIGHT", -12, 0)
  editor.aboutDeveloperPreflightStatusSummary:SetJustifyH("LEFT")
  editor.aboutDeveloperPreflightStatusSummary:SetTextColor(0.72, 0.76, 0.82, 1)
  editor.aboutDeveloperPreflightStatusSummary:SetText("No validation result yet.")

  editor.aboutDeveloperRehearsalPanel = CreateDeveloperToolPanel(aboutDeveloperFrame, "Synthetic Sync Rehearsal", editor)
  editor.aboutDeveloperRehearsalPanel:SetPoint("TOPLEFT", aboutDeveloperHarnessPanel, "BOTTOMLEFT", 0, -10)
  editor.aboutDeveloperRehearsalPanel:SetSize(560, 260)
  editor.aboutDeveloperRehearsalHeader = editor.aboutDeveloperRehearsalPanel.__titleText

  editor.aboutDeveloperRehearsalDesc = editor.aboutDeveloperRehearsalPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  editor.aboutDeveloperRehearsalDesc:SetPoint("TOPLEFT", editor.aboutDeveloperRehearsalPanel.__content, "TOPLEFT", 0, 0)
  editor.aboutDeveloperRehearsalDesc:SetWidth(560)
  editor.aboutDeveloperRehearsalDesc:SetJustifyH("LEFT")
  editor.aboutDeveloperRehearsalDesc:SetWordWrap(true)
  editor.aboutDeveloperRehearsalDesc:SetTextColor(0.72, 0.76, 0.82, 1)
  editor.aboutDeveloperRehearsalDesc:SetText("Create synthetic joined raiders and scratch profiles to rehearse roll-ready and archive convergence without contacting other players.")

  local aboutDeveloperHarnessSourceLabel = editor.aboutDeveloperRehearsalPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperHarnessSourceLabel:SetPoint("TOPLEFT", editor.aboutDeveloperRehearsalDesc, "BOTTOMLEFT", 0, -12)
  aboutDeveloperHarnessSourceLabel:SetText("Profile Source")
  editor.aboutDeveloperHarnessSourceLabel = aboutDeveloperHarnessSourceLabel

  local aboutDeveloperHarnessSimulationBtn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessSimulationBtn:SetSize(120, 22)
  aboutDeveloperHarnessSimulationBtn:SetPoint("LEFT", aboutDeveloperHarnessSourceLabel, "RIGHT", 12, 0)
  aboutDeveloperHarnessSimulationBtn:SetText("Simulation")
  editor.aboutDeveloperHarnessSimulationBtn = aboutDeveloperHarnessSimulationBtn

  local aboutDeveloperHarnessCurrentBtn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessCurrentBtn:SetSize(140, 22)
  aboutDeveloperHarnessCurrentBtn:SetPoint("LEFT", aboutDeveloperHarnessSimulationBtn, "RIGHT", 10, 0)
  aboutDeveloperHarnessCurrentBtn:SetText("Current Profile")
  editor.aboutDeveloperHarnessCurrentBtn = aboutDeveloperHarnessCurrentBtn

  local aboutDeveloperHarnessScenarioLabel = editor.aboutDeveloperRehearsalPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperHarnessScenarioLabel:SetPoint("TOPLEFT", aboutDeveloperHarnessSourceLabel, "BOTTOMLEFT", 0, -12)
  aboutDeveloperHarnessScenarioLabel:SetText("Scenario")
  editor.aboutDeveloperHarnessScenarioLabel = aboutDeveloperHarnessScenarioLabel

  local aboutDeveloperHarnessFreshBtn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessFreshBtn:SetSize(110, 22)
  aboutDeveloperHarnessFreshBtn:SetPoint("LEFT", aboutDeveloperHarnessScenarioLabel, "RIGHT", 12, 0)
  aboutDeveloperHarnessFreshBtn:SetText("Fresh")
  editor.aboutDeveloperHarnessFreshBtn = aboutDeveloperHarnessFreshBtn

  local aboutDeveloperHarnessReturningBtn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessReturningBtn:SetSize(110, 22)
  aboutDeveloperHarnessReturningBtn:SetPoint("LEFT", aboutDeveloperHarnessFreshBtn, "RIGHT", 10, 0)
  aboutDeveloperHarnessReturningBtn:SetText("Returning")
  editor.aboutDeveloperHarnessReturningBtn = aboutDeveloperHarnessReturningBtn

  local aboutDeveloperHarnessMixedBtn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessMixedBtn:SetSize(110, 22)
  aboutDeveloperHarnessMixedBtn:SetPoint("LEFT", aboutDeveloperHarnessReturningBtn, "RIGHT", 10, 0)
  aboutDeveloperHarnessMixedBtn:SetText("Mixed")
  editor.aboutDeveloperHarnessMixedBtn = aboutDeveloperHarnessMixedBtn

  local aboutDeveloperHarnessRunLabel = editor.aboutDeveloperRehearsalPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperHarnessRunLabel:SetPoint("TOPLEFT", aboutDeveloperHarnessScenarioLabel, "BOTTOMLEFT", 0, -12)
  aboutDeveloperHarnessRunLabel:SetText("Raid Size")
  editor.aboutDeveloperHarnessRunLabel = aboutDeveloperHarnessRunLabel

  local aboutDeveloperHarnessRun5Btn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessRun5Btn:SetSize(64, 22)
  aboutDeveloperHarnessRun5Btn:SetPoint("LEFT", aboutDeveloperHarnessRunLabel, "RIGHT", 12, 0)
  aboutDeveloperHarnessRun5Btn:SetText("5")
  editor.aboutDeveloperHarnessRun5Btn = aboutDeveloperHarnessRun5Btn

  local aboutDeveloperHarnessRun10Btn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessRun10Btn:SetSize(64, 22)
  aboutDeveloperHarnessRun10Btn:SetPoint("LEFT", aboutDeveloperHarnessRun5Btn, "RIGHT", 10, 0)
  aboutDeveloperHarnessRun10Btn:SetText("10")
  editor.aboutDeveloperHarnessRun10Btn = aboutDeveloperHarnessRun10Btn

  local aboutDeveloperHarnessRun20Btn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessRun20Btn:SetSize(64, 22)
  aboutDeveloperHarnessRun20Btn:SetPoint("LEFT", aboutDeveloperHarnessRun10Btn, "RIGHT", 10, 0)
  aboutDeveloperHarnessRun20Btn:SetText("20")
  editor.aboutDeveloperHarnessRun20Btn = aboutDeveloperHarnessRun20Btn

  local aboutDeveloperHarnessValidateBtn = CreateFrame("Button", nil, aboutDeveloperHarnessPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessValidateBtn:SetSize(140, 24)
  aboutDeveloperHarnessValidateBtn:SetPoint("TOPLEFT", editor.aboutDeveloperPreflightStatusCard, "BOTTOMLEFT", 0, -10)
  aboutDeveloperHarnessValidateBtn:SetText("Run Preflight")
  ApplyDeveloperToolActionStyle(aboutDeveloperHarnessValidateBtn, "primary")
  editor.aboutDeveloperHarnessValidateBtn = aboutDeveloperHarnessValidateBtn

  local aboutDeveloperHarnessClearBtn = CreateFrame("Button", nil, aboutDeveloperHarnessPanel.__content, "UIPanelButtonTemplate")
  aboutDeveloperHarnessClearBtn:SetSize(130, 20)
  aboutDeveloperHarnessClearBtn:SetPoint("LEFT", aboutDeveloperHarnessValidateBtn, "RIGHT", 10, 0)
  aboutDeveloperHarnessClearBtn:SetText("Clear Last Result")
  ApplyDeveloperToolActionStyle(aboutDeveloperHarnessClearBtn, "clear")
  editor.aboutDeveloperHarnessClearBtn = aboutDeveloperHarnessClearBtn

  editor.aboutDeveloperPreflightCopyBtn = CreateFrame("Button", nil, aboutDeveloperHarnessPanel.__content, "UIPanelButtonTemplate")
  editor.aboutDeveloperPreflightCopyBtn:SetSize(110, 20)
  editor.aboutDeveloperPreflightCopyBtn:SetText("Copy Report")
  ApplyDeveloperToolActionStyle(editor.aboutDeveloperPreflightCopyBtn, "utility")

  editor.aboutDeveloperPreflightReport = aboutDeveloperHarnessPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  editor.aboutDeveloperPreflightReport:SetWidth(560)
  editor.aboutDeveloperPreflightReport:SetJustifyH("LEFT")
  editor.aboutDeveloperPreflightReport:SetWordWrap(true)

  editor.aboutDeveloperHarnessRunBtn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  editor.aboutDeveloperHarnessRunBtn:SetSize(140, 24)
  editor.aboutDeveloperHarnessRunBtn:SetText("Run Rehearsal")
  ApplyDeveloperToolActionStyle(editor.aboutDeveloperHarnessRunBtn, "primary")

  editor.aboutDeveloperHarnessCopyBtn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  editor.aboutDeveloperHarnessCopyBtn:SetSize(110, 20)
  editor.aboutDeveloperHarnessCopyBtn:SetText("Copy Results")
  ApplyDeveloperToolActionStyle(editor.aboutDeveloperHarnessCopyBtn, "utility")

  editor.aboutDeveloperHarnessClearRehearsalBtn = CreateFrame("Button", nil, editor.aboutDeveloperRehearsalPanel.__content, "UIPanelButtonTemplate")
  editor.aboutDeveloperHarnessClearRehearsalBtn:SetSize(130, 20)
  editor.aboutDeveloperHarnessClearRehearsalBtn:SetText("Clear Rehearsal")
  ApplyDeveloperToolActionStyle(editor.aboutDeveloperHarnessClearRehearsalBtn, "clear")

  local aboutDeveloperHarnessState = editor.aboutDeveloperRehearsalPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperHarnessState:SetPoint("TOPLEFT", editor.aboutDeveloperHarnessRunBtn, "BOTTOMLEFT", 0, -10)
  aboutDeveloperHarnessState:SetWidth(560)
  aboutDeveloperHarnessState:SetJustifyH("LEFT")
  editor.aboutDeveloperHarnessState = aboutDeveloperHarnessState

  local aboutDeveloperHarnessReport = editor.aboutDeveloperRehearsalPanel.__content:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
  aboutDeveloperHarnessReport:SetPoint("TOPLEFT", aboutDeveloperHarnessState, "BOTTOMLEFT", 0, -8)
  aboutDeveloperHarnessReport:SetWidth(560)
  aboutDeveloperHarnessReport:SetJustifyH("LEFT")
  editor.aboutDeveloperHarnessReport = aboutDeveloperHarnessReport

  local function RefreshDeveloperHealth()
    if not aboutDeveloperHealth then
      return
    end
    local diagnostics = GetRuntimeDiagnostics and GetRuntimeDiagnostics() or nil
    if type(diagnostics) ~= "table" then
      aboutDeveloperHealth:SetText("Runtime diagnostics unavailable.")
      return
    end

    local lines = {
      "Schema Version: " .. tostring(diagnostics.schemaVersion or 0),
      "Current Profile: " .. tostring(diagnostics.currentProfile or ""),
      "Enabled Profile: " .. tostring(diagnostics.enabledProfile or ""),
      "Active Profile ID: " .. tostring(diagnostics.activeProfileId or ""),
      "Profile Revisions: settings=" .. tostring(diagnostics.settingsRevision or 0)
        .. " | permissions=" .. tostring(diagnostics.permissionsRevision or 0)
        .. " | operational=" .. tostring(diagnostics.operationalRevision or 0),
      "Active Session ID: " .. tostring(diagnostics.activeSessionId or ""),
      "Session Host: " .. tostring(diagnostics.sessionHost or ""),
      "Local Role: " .. tostring(diagnostics.localRole or ""),
      "Local Access Summary: " .. tostring((diagnostics.localAccessSummary and diagnostics.localAccessSummary ~= "") and diagnostics.localAccessSummary or "none"),
      "Board Mode: " .. tostring(diagnostics.boardMode or ""),
      "Board ID: " .. tostring(diagnostics.boardId or ""),
      "Selected Item Key: " .. tostring(diagnostics.selectedItemKey or ""),
      "Joined Members: " .. tostring(diagnostics.joinedMemberCount or 0),
      "Tracked Items: " .. tostring(diagnostics.itemCount or 0),
      "Pending Choices: " .. tostring(diagnostics.pendingChoices or 0),
      "Unassigned Items: " .. tostring(diagnostics.unassignedItems or 0),
      "Shared Profile Sync: " .. tostring(diagnostics.sharedProfileSyncMode or "")
        .. " | " .. tostring(diagnostics.sharedProfileSyncSeverity or "")
        .. " | " .. tostring(diagnostics.sharedProfileSyncMessage or ""),
      "Shared Sync Sender: " .. tostring(diagnostics.sharedProfileSyncSender or ""),
      "Shared Sync UpdatedAt: " .. tostring(diagnostics.sharedProfileSyncUpdatedAt or 0),
      "Shared Sync Domains: remote=" .. tostring(diagnostics.sharedProfileSyncRemoteDomains or "none")
        .. " | local=" .. tostring(diagnostics.sharedProfileSyncLocalDomains or "none"),
      "Shared Sync Host Counts: newer=" .. tostring(diagnostics.sharedProfileSyncRemoteNewerCount or 0)
        .. " | conflicts=" .. tostring(diagnostics.sharedProfileSyncDivergedCount or 0)
        .. " | local-newer=" .. tostring(diagnostics.sharedProfileSyncLocalNewerCount or 0)
        .. " | same=" .. tostring(diagnostics.sharedProfileSyncSameCount or 0),
      "Permission Policy: v" .. tostring(diagnostics.permissionPolicyVersion or 0)
        .. " | overrides=" .. tostring(diagnostics.permissionPolicyHasOverrides == true and "YES" or "NO"),
      "Council Overrides: " .. tostring(diagnostics.permissionPolicyCouncilOverrideCount or 0)
        .. " | " .. tostring((diagnostics.permissionPolicyCouncilOverrides and diagnostics.permissionPolicyCouncilOverrides ~= "") and diagnostics.permissionPolicyCouncilOverrides or "none"),
      "Session Host Overrides: " .. tostring(diagnostics.permissionPolicySessionHostOverrideCount or 0)
        .. " | " .. tostring((diagnostics.permissionPolicySessionHostOverrides and diagnostics.permissionPolicySessionHostOverrides ~= "") and diagnostics.permissionPolicySessionHostOverrides or "none"),
      "Raider Overrides: " .. tostring(diagnostics.permissionPolicyRaiderOverrideCount or 0)
        .. " | " .. tostring((diagnostics.permissionPolicyRaiderOverrides and diagnostics.permissionPolicyRaiderOverrides ~= "") and diagnostics.permissionPolicyRaiderOverrides or "none"),
      "Last Board Sync Sender: " .. tostring(diagnostics.lastBoardSyncSender or ""),
      "Last Runtime Opcode: " .. tostring(diagnostics.lastOpcode or ""),
      "Last Runtime Sender: " .. tostring(diagnostics.lastSender or ""),
      "Developer Mode Flag: " .. tostring(diagnostics.developerMode == true and "ON" or "OFF"),
    }
    aboutDeveloperHealth:SetText(table.concat(lines, "\n"))
  end
  editor.RefreshDeveloperHealth = RefreshDeveloperHealth

  local function RefreshProfileSyncTuningControls()
    local tuning = GetProfileSyncTuning()
    local usesDefaults = math.abs((tonumber(tuning.chunkSize) or 120) - (tonumber(tuning.defaultChunkSize) or 120)) < 0.001
      and math.abs((tonumber(tuning.intervalSeconds) or 0.12) - (tonumber(tuning.defaultIntervalSeconds) or 0.12)) < 0.001
    if aboutSyncChunkEdit and not aboutSyncChunkEdit:HasFocus() then
      aboutSyncChunkEdit:SetText(tostring(tonumber(tuning.chunkSize) or 120))
    end
    if aboutSyncDelayEdit and not aboutSyncDelayEdit:HasFocus() then
      aboutSyncDelayEdit:SetText(string.format("%.2f", tonumber(tuning.intervalSeconds) or 0.12))
    end
    if aboutSyncTuningState then
      aboutSyncTuningState:SetText(string.format(
        "Recommended: %d-%d bytes / %.2f-%.2fs | Defaults: %d bytes / %.2fs",
        tonumber(tuning.minChunkSize) or 80,
        tonumber(tuning.maxChunkSize) or 190,
        tonumber(tuning.minIntervalSeconds) or 0.08,
        tonumber(tuning.maxIntervalSeconds) or 0.25,
        tonumber(tuning.defaultChunkSize) or 120,
        tonumber(tuning.defaultIntervalSeconds) or 0.12
      ))
    end
    if usesDefaults then
      editor.aboutProfileSyncTuningPanel:SetToolStatus("Defaults", 0.65, 0.72, 0.80)
    else
      editor.aboutProfileSyncTuningPanel:SetToolStatus("Override active", 1.00, 0.76, 0.30)
    end
  end

  local function GetDeveloperSyncHarnessStateApi()
    return ResolveOptionalApiFunction("LIDCOUNCIL_GetDeveloperProfileSyncHarnessState")
  end

  local function RefreshDeveloperSyncHarnessControls()
    local root = RootDB()
    local enabled = type(root.ui) == "table" and root.ui.developerMode == true or false
    local harnessConfig = EnsureDeveloperSyncHarnessConfig(root)
    local simulationExists = HasSimulationProfile(root)
    local getHarnessState = GetDeveloperSyncHarnessStateApi()
    local harnessState = type(getHarnessState) == "function" and getHarnessState() or nil
    local runAutomatedValidation = ResolveOptionalApiFunction("LIDCOUNCIL_RunReleasePreflight")
    local getPreflightStatus = ResolveOptionalApiFunction("LIDCOUNCIL_GetReleasePreflightStatus")
    local preflightStatus = {}
    if type(getPreflightStatus) == "function" then
      local statusOk, status = pcall(getPreflightStatus)
      if statusOk and type(status) == "table" then
        preflightStatus = status
      end
    end
    local validationText = BuildDeveloperSyncValidationText(preflightStatus)
    local harnessText = BuildDeveloperSyncHarnessText(harnessState)
    editor.aboutDeveloperHarnessCopyText = type(harnessState) == "table"
      and type(harnessState.lastReport) == "table"
      and harnessText
      or ""

    if aboutDeveloperHarnessSimulationBtn and aboutDeveloperHarnessSimulationBtn.SetText then
      aboutDeveloperHarnessSimulationBtn:SetText("Simulation")
      SetHarnessChoiceButtonSelected(aboutDeveloperHarnessSimulationBtn, harnessConfig.profileMode == "SIMULATION")
    end
    if aboutDeveloperHarnessCurrentBtn and aboutDeveloperHarnessCurrentBtn.SetText then
      aboutDeveloperHarnessCurrentBtn:SetText("Current Profile")
      SetHarnessChoiceButtonSelected(aboutDeveloperHarnessCurrentBtn, harnessConfig.profileMode == "CURRENT")
    end
    if aboutDeveloperHarnessFreshBtn and aboutDeveloperHarnessFreshBtn.SetText then
      aboutDeveloperHarnessFreshBtn:SetText("Fresh")
      SetHarnessChoiceButtonSelected(aboutDeveloperHarnessFreshBtn, harnessConfig.scenario == "FRESH")
    end
    if aboutDeveloperHarnessReturningBtn and aboutDeveloperHarnessReturningBtn.SetText then
      aboutDeveloperHarnessReturningBtn:SetText("Returning")
      SetHarnessChoiceButtonSelected(aboutDeveloperHarnessReturningBtn, harnessConfig.scenario == "RETURNING")
    end
    if aboutDeveloperHarnessMixedBtn and aboutDeveloperHarnessMixedBtn.SetText then
      aboutDeveloperHarnessMixedBtn:SetText("Mixed")
      SetHarnessChoiceButtonSelected(aboutDeveloperHarnessMixedBtn, harnessConfig.scenario == "MIXED")
    end
    if aboutDeveloperHarnessRun5Btn and aboutDeveloperHarnessRun5Btn.SetText then
      aboutDeveloperHarnessRun5Btn:SetText("5")
      SetHarnessChoiceButtonSelected(aboutDeveloperHarnessRun5Btn, harnessConfig.memberCount == 5)
    end
    if aboutDeveloperHarnessRun10Btn and aboutDeveloperHarnessRun10Btn.SetText then
      aboutDeveloperHarnessRun10Btn:SetText("10")
      SetHarnessChoiceButtonSelected(aboutDeveloperHarnessRun10Btn, harnessConfig.memberCount == 10)
    end
    if aboutDeveloperHarnessRun20Btn and aboutDeveloperHarnessRun20Btn.SetText then
      aboutDeveloperHarnessRun20Btn:SetText("20")
      SetHarnessChoiceButtonSelected(aboutDeveloperHarnessRun20Btn, harnessConfig.memberCount == 20)
    end

    if aboutDeveloperHarnessSimulationBtn and aboutDeveloperHarnessSimulationBtn.Enable then
      if enabled and simulationExists then
        aboutDeveloperHarnessSimulationBtn:Enable()
      else
        aboutDeveloperHarnessSimulationBtn:Disable()
      end
    end
    if aboutDeveloperHarnessCurrentBtn and aboutDeveloperHarnessCurrentBtn.Enable then
      if enabled then
        aboutDeveloperHarnessCurrentBtn:Enable()
      else
        aboutDeveloperHarnessCurrentBtn:Disable()
      end
    end
    for _, button in ipairs({
      aboutDeveloperHarnessFreshBtn,
      aboutDeveloperHarnessReturningBtn,
      aboutDeveloperHarnessMixedBtn,
      aboutDeveloperHarnessRun5Btn,
      aboutDeveloperHarnessRun10Btn,
      aboutDeveloperHarnessRun20Btn,
      aboutDeveloperHarnessClearBtn,
    }) do
      if button and button.Enable then
        if enabled then
          button:Enable()
        else
          button:Disable()
        end
      end
    end
    if editor.aboutDeveloperHarnessRunBtn and editor.aboutDeveloperHarnessRunBtn.Enable then
      if enabled and (harnessConfig.profileMode ~= "SIMULATION" or simulationExists) then
        editor.aboutDeveloperHarnessRunBtn:Enable()
      else
        editor.aboutDeveloperHarnessRunBtn:Disable()
      end
    end
    if editor.aboutDeveloperHarnessClearRehearsalBtn and editor.aboutDeveloperHarnessClearRehearsalBtn.Enable then
      if enabled and type(harnessState) == "table"
        and (harnessState.syntheticActive == true or type(harnessState.lastReport) == "table") then
        editor.aboutDeveloperHarnessClearRehearsalBtn:Enable()
      else
        editor.aboutDeveloperHarnessClearRehearsalBtn:Disable()
      end
    end
    if aboutDeveloperHarnessValidateBtn and aboutDeveloperHarnessValidateBtn.Enable then
      if enabled and type(runAutomatedValidation) == "function" then
        aboutDeveloperHarnessValidateBtn:Enable()
      else
        aboutDeveloperHarnessValidateBtn:Disable()
      end
    end

    if editor.aboutDeveloperPreflightStatusCard then
      local statusLabel = "NOT RUN"
      local statusHeader = "Not run"
      local statusSummary = "No validation result yet."
      local statusColor = { 0.65, 0.70, 0.78 }
      local statusBackground = { 0.025, 0.030, 0.040, 0.96 }
      if preflightStatus.blocked == true then
        statusLabel = "BLOCKED"
        statusHeader = "Blocked"
        statusSummary = "Resolve the safety gate shown in the detailed report, then retry."
        statusColor = { 1.00, 0.72, 0.30 }
        statusBackground = { 0.11, 0.07, 0.02, 0.96 }
      elseif preflightStatus.ran == true and preflightStatus.ready == true then
        local hasWarnings = (tonumber(preflightStatus.warnings) or 0) > 0
          or (tonumber(preflightStatus.slowSuiteCount) or 0) > 0
        statusLabel = hasWarnings and "PASS WITH WARNINGS" or "PASS"
        statusHeader = hasWarnings and "Warning" or "PASS"
        statusSummary = string.format(
          "%d / %d checks | %d suites | %.2f seconds",
          math.max(0, tonumber(preflightStatus.passed) or 0),
          math.max(0, tonumber(preflightStatus.total) or 0),
          math.max(0, tonumber(preflightStatus.suiteCount) or 0),
          math.max(0, tonumber(preflightStatus.durationSeconds) or 0)
        )
        statusColor = hasWarnings and { 1.00, 0.78, 0.30 } or { 0.36, 0.92, 0.48 }
        statusBackground = hasWarnings and { 0.10, 0.075, 0.02, 0.96 } or { 0.025, 0.085, 0.040, 0.96 }
      elseif preflightStatus.ran == true then
        statusLabel = "FAIL"
        statusHeader = "FAIL"
        statusSummary = string.format(
          "%d failed | %d / %d checks passed | %.2f seconds",
          math.max(0, tonumber(preflightStatus.failed) or 0),
          math.max(0, tonumber(preflightStatus.passed) or 0),
          math.max(0, tonumber(preflightStatus.total) or 0),
          math.max(0, tonumber(preflightStatus.durationSeconds) or 0)
        )
        statusColor = { 1.00, 0.36, 0.32 }
        statusBackground = { 0.105, 0.025, 0.025, 0.96 }
      end
      editor.aboutDeveloperHarnessPanel:SetToolStatus(statusHeader, statusColor[1], statusColor[2], statusColor[3])
      editor.aboutDeveloperPreflightStatusTitle:SetText(statusLabel)
      editor.aboutDeveloperPreflightStatusTitle:SetTextColor(statusColor[1], statusColor[2], statusColor[3], 1)
      editor.aboutDeveloperPreflightStatusSummary:SetText(statusSummary)
      editor.aboutDeveloperPreflightStatusCard:SetBackdropColor(
        statusBackground[1],
        statusBackground[2],
        statusBackground[3],
        statusBackground[4]
      )
      editor.aboutDeveloperPreflightStatusCard:SetBackdropBorderColor(
        statusColor[1] * 0.72,
        statusColor[2] * 0.72,
        statusColor[3] * 0.72,
        0.90
      )
    end

    if editor.aboutDeveloperPreflightReport then
      local detailLines = { validationText }
      if preflightStatus.ran == true and preflightStatus.blocked ~= true then
        for _, suite in ipairs(type(preflightStatus.suites) == "table" and preflightStatus.suites or {}) do
          if type(suite) == "table" and suite.ready ~= true then
            detailLines[#detailLines + 1] = string.format(
              "%s: %d/%d passed, %d failed",
              tostring(suite.label or suite.key or "Unnamed suite"),
              math.max(0, tonumber(suite.passed) or 0),
              math.max(0, tonumber(suite.total) or 0),
              math.max(0, tonumber(suite.failed) or 0)
            )
            for problemIndex, problem in ipairs(type(suite.problems) == "table" and suite.problems or {}) do
              if problemIndex > 5 then
                break
              end
              detailLines[#detailLines + 1] = "  - " .. tostring(problem)
            end
          end
        end
      end
      local preflightColor = { 0.82, 0.84, 0.92, 1.00 }
      if preflightStatus.blocked == true then
        preflightColor = { 1.00, 0.78, 0.62, 1.00 }
      elseif preflightStatus.ran == true and preflightStatus.ready == true then
        preflightColor = { 0.58, 0.90, 0.70, 1.00 }
      elseif preflightStatus.ran == true then
        preflightColor = { 1.00, 0.55, 0.44, 1.00 }
      end
      editor.aboutDeveloperPreflightReport:SetText(table.concat(detailLines, "\n"))
      editor.aboutDeveloperPreflightCopyText = table.concat(detailLines, "\n")
      editor.aboutDeveloperPreflightReport:SetTextColor(
        preflightColor[1],
        preflightColor[2],
        preflightColor[3],
        preflightColor[4]
      )
    end
    if editor.aboutDeveloperPreflightCopyBtn and editor.aboutDeveloperPreflightCopyBtn.Enable then
      if enabled and preflightStatus.ran == true and tostring(editor.aboutDeveloperPreflightCopyText or "") ~= "" then
        editor.aboutDeveloperPreflightCopyBtn:Enable()
      else
        editor.aboutDeveloperPreflightCopyBtn:Disable()
      end
    end
    if aboutDeveloperHarnessClearBtn and aboutDeveloperHarnessClearBtn.Enable then
      if enabled and preflightStatus.ran == true then
        aboutDeveloperHarnessClearBtn:Enable()
      else
        aboutDeveloperHarnessClearBtn:Disable()
      end
    end
    if editor.aboutDeveloperHarnessCopyBtn and editor.aboutDeveloperHarnessCopyBtn.Enable then
      if enabled and tostring(editor.aboutDeveloperHarnessCopyText or "") ~= "" then
        editor.aboutDeveloperHarnessCopyBtn:Enable()
      else
        editor.aboutDeveloperHarnessCopyBtn:Disable()
      end
    end

    if aboutDeveloperHarnessState then
      local modeLabel = harnessConfig.profileMode == "SIMULATION" and "Simulation" or "Current Profile"
      local scenarioLabel = harnessConfig.scenario == "RETURNING" and "Returning / aligned"
        or (harnessConfig.scenario == "MIXED" and "Mixed" or "Fresh joiners")
      local stateLine = "Source: " .. modeLabel .. " | Scenario: " .. scenarioLabel
      local stateColor = { 0.82, 0.84, 0.92, 1.00 }
      if harnessState and tonumber(harnessState.lastRunAt) and tonumber(harnessState.lastRunAt) > 0 then
        stateLine = stateLine .. " | Last run: " .. tostring(math.max(1, tonumber(harnessState.memberCount) or harnessConfig.memberCount)) .. " raiders"
      end
      if harnessState and harnessState.syntheticActive == true then
        stateLine = stateLine .. " | Synthetic session active"
        stateColor = { 0.58, 0.90, 0.70, 1.00 }
      end
      if harnessConfig.profileMode == "SIMULATION" and not simulationExists then
        stateLine = stateLine .. " | Simulation profile missing"
        stateColor = { 1.00, 0.55, 0.44, 1.00 }
      end
      aboutDeveloperHarnessState:SetText(stateLine)
      aboutDeveloperHarnessState:SetTextColor(stateColor[1], stateColor[2], stateColor[3], stateColor[4])
    end
    if editor.aboutDeveloperRehearsalPanel then
      if harnessState and harnessState.syntheticActive == true then
        editor.aboutDeveloperRehearsalPanel:SetToolStatus("Active", 0.36, 0.92, 0.48)
      elseif harnessConfig.profileMode == "SIMULATION" and not simulationExists then
        editor.aboutDeveloperRehearsalPanel:SetToolStatus("Profile missing", 1.00, 0.55, 0.44)
      elseif harnessState and tonumber(harnessState.lastRunAt) and tonumber(harnessState.lastRunAt) > 0 then
        editor.aboutDeveloperRehearsalPanel:SetToolStatus("Last: " .. tostring(math.max(1, tonumber(harnessState.memberCount) or harnessConfig.memberCount)) .. " raiders", 0.58, 0.76, 0.96)
      else
        editor.aboutDeveloperRehearsalPanel:SetToolStatus("Not run", 0.65, 0.70, 0.78)
      end
    end
    if aboutDeveloperHarnessReport then
      aboutDeveloperHarnessReport:SetText(harnessText)
    end
  end

  local function RefreshDeveloperSection()
    local root = RootDB()
    root.ui = root.ui or {}
    local enabled = root.ui.developerMode == true
    local headerMonitoringCheck = editor and editor.aboutShowHeaderMonitoringCheck
    local headerMonitoringInfoFrame = editor and editor.aboutShowHeaderMonitoringInfo
    local simulationState = GetSimulationProfileState(root)
    local simulationExists = simulationState.exists
    local activeSession = type(GetActiveLootSession) == "function" and GetActiveLootSession() or nil
    local hasRunningSession = activeSession and true or false
    local hasSimulationSession = HasActiveSimulationSession()

    if aboutDeveloperModeCheck then
      aboutDeveloperModeCheck:SetChecked(enabled)
    end
    if aboutShowProfileIdCheck then
      aboutShowProfileIdCheck:SetChecked(enabled and root.ui.showInternalProfileId == true or false)
    end
    if aboutShowProfileSizeCheck then
      aboutShowProfileSizeCheck:SetChecked(enabled and root.ui.showProfileSize == true or false)
    end
    if aboutTutorialModeCheck then
      aboutTutorialModeCheck:SetChecked(enabled and root.ui.tutorialMode == true or false)
    end
    if aboutChecklistDevCheck then
      aboutChecklistDevCheck:SetChecked(enabled and root.ui.checklistDev == true or false)
    end
    if aboutChangelogDevCheck then
      aboutChangelogDevCheck:SetChecked(enabled and root.ui.changelogDev == true or false)
    end
    if editor and editor.aboutImportExportFeatureCheck then
      editor.aboutImportExportFeatureCheck:SetChecked(enabled and root.ui.importExportFeature == true or false)
    end
    if aboutShowSimulationCheck then
      aboutShowSimulationCheck:SetChecked(enabled and root.ui.showSimulationProfile == true or false)
    end
    if headerMonitoringCheck then
      headerMonitoringCheck:SetChecked(enabled and root.ui.showHeaderMonitoringCheck == true or false)
    end
    if root.ui.showHeaderMonitoringCheck == true then
      editor.aboutHeaderMonitoringPreviewPanel:SetToolStatus("Visible", 0.45, 0.88, 0.58)
    else
      editor.aboutHeaderMonitoringPreviewPanel:SetToolStatus("Hidden", 0.65, 0.70, 0.78)
    end

    local showAdvanced = enabled
    SetElementShown(aboutDeveloperOptionsDivider, showAdvanced)
    SetElementShown(aboutDeveloperOptionsHeader, showAdvanced)
    SetElementShown(aboutDeveloperOptionsDesc, showAdvanced)
    SetElementShown(aboutShowProfileIdCheck, showAdvanced)
    SetElementShown(profileIdInfo, showAdvanced)
    SetElementShown(aboutShowProfileSizeCheck, showAdvanced)
    SetElementShown(profileSizeInfo, showAdvanced)
    SetElementShown(aboutTutorialModeCheck, showAdvanced)
    SetElementShown(aboutChecklistDevCheck, showAdvanced)
    SetElementShown(aboutChangelogDevCheck, showAdvanced)
    SetElementShown(aboutShowSimulationCheck, showAdvanced)
    SetElementShown(aboutCreateSimulationBtn, showAdvanced)
    SetElementShown(aboutDeleteSimulationBtn, showAdvanced)
    SetElementShown(aboutRuntimeDivider, showAdvanced)
    SetElementShown(aboutRuntimeHeader, showAdvanced)
    SetElementShown(aboutRuntimeDesc, showAdvanced)
    SetElementShown(aboutSimulationState, showAdvanced)
    SetElementShown(aboutDeveloperState, showAdvanced)
    SetElementShown(aboutDeveloperHealthHeader, showAdvanced)
    SetElementShown(aboutDeveloperHealth, showAdvanced)
    SetElementShown(aboutDeveloperExperimentalDivider, showAdvanced)
    SetElementShown(aboutDeveloperExperimentalHeader, showAdvanced)
    SetElementShown(aboutDeveloperExperimentalInfo, showAdvanced)
    SetElementShown(aboutDeveloperExperimentalDesc, showAdvanced)
    SetElementShown(editor and editor.aboutImportExportFeatureCheck, showAdvanced)
    SetElementShown(editor and editor.aboutHeaderMonitoringPreviewPanel, showAdvanced)
    SetElementShown(editor and editor.aboutHeaderMonitoringPreviewHeader, showAdvanced)
    SetElementShown(editor and editor.aboutHeaderMonitoringPreviewDesc, showAdvanced)
    SetElementShown(headerMonitoringCheck, showAdvanced)
    SetElementShown(headerMonitoringInfoFrame, showAdvanced)
    SetElementShown(editor and editor.aboutProfileSyncTuningPanel, showAdvanced)
    SetElementShown(editor and editor.aboutProfileSyncTuningHeader, showAdvanced)
    SetElementShown(editor and editor.aboutProfileSyncTuningDesc, showAdvanced)
    SetElementShown(aboutSyncChunkLabel, showAdvanced)
    SetElementShown(aboutSyncChunkEdit, showAdvanced)
    SetElementShown(aboutSyncChunkUnit, showAdvanced)
    SetElementShown(aboutSyncDelayLabel, showAdvanced)
    SetElementShown(aboutSyncDelayEdit, showAdvanced)
    SetElementShown(aboutSyncDelayUnit, showAdvanced)
    SetElementShown(aboutSyncTuningApplyBtn, showAdvanced)
    SetElementShown(aboutSyncTuningResetBtn, showAdvanced)
    SetElementShown(aboutSyncTuningState, showAdvanced)
    SetElementShown(editor.aboutDeveloperHarnessPanel, showAdvanced)
    SetElementShown(aboutDeveloperHarnessHeader, showAdvanced)
    SetElementShown(aboutDeveloperHarnessDesc, showAdvanced)
    SetElementShown(editor.aboutDeveloperPreflightStatusCard, showAdvanced)
    SetElementShown(editor.aboutDeveloperPreflightStatusTitle, showAdvanced)
    SetElementShown(editor.aboutDeveloperPreflightStatusSummary, showAdvanced)
    SetElementShown(aboutDeveloperHarnessSourceLabel, showAdvanced)
    SetElementShown(aboutDeveloperHarnessSimulationBtn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessCurrentBtn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessScenarioLabel, showAdvanced)
    SetElementShown(aboutDeveloperHarnessFreshBtn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessReturningBtn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessMixedBtn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessRunLabel, showAdvanced)
    SetElementShown(aboutDeveloperHarnessRun5Btn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessRun10Btn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessRun20Btn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessValidateBtn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessClearBtn, showAdvanced)
    SetElementShown(editor.aboutDeveloperPreflightCopyBtn, showAdvanced)
    SetElementShown(editor.aboutDeveloperPreflightReport, showAdvanced)
    SetElementShown(editor.aboutDeveloperRehearsalPanel, showAdvanced)
    SetElementShown(editor.aboutDeveloperRehearsalHeader, showAdvanced)
    SetElementShown(editor.aboutDeveloperRehearsalDesc, showAdvanced)
    SetElementShown(editor.aboutDeveloperHarnessRunBtn, showAdvanced)
    SetElementShown(editor.aboutDeveloperHarnessCopyBtn, showAdvanced)
    SetElementShown(editor.aboutDeveloperHarnessClearRehearsalBtn, showAdvanced)
    SetElementShown(aboutDeveloperHarnessState, showAdvanced)
    SetElementShown(aboutDeveloperHarnessReport, showAdvanced)

    if aboutShowSimulationCheck and aboutShowSimulationCheck.Enable then
      if enabled then
        aboutShowSimulationCheck:Enable()
      else
        aboutShowSimulationCheck:Disable()
      end
    end
    if aboutCreateSimulationBtn and aboutCreateSimulationBtn.Enable then
      if enabled and not simulationExists then
        aboutCreateSimulationBtn:Enable()
      else
        aboutCreateSimulationBtn:Disable()
      end
    end
    if aboutDeleteSimulationBtn and aboutDeleteSimulationBtn.Enable then
      if enabled and simulationExists and simulationState.canDelete and not hasRunningSession then
        aboutDeleteSimulationBtn:Enable()
      else
        aboutDeleteSimulationBtn:Disable()
      end
    end

    if aboutSimulationState then
      aboutSimulationState:SetText(
        "Simulation Profile: " .. tostring(simulationExists and "Present" or "Missing")
        .. (simulationExists and (" | Master: " .. tostring(simulationState.masterKey ~= "" and simulationState.masterKey or "Unassigned")) or "")
        .. " | Visible in Profile list: " .. tostring(root.ui.showSimulationProfile == true and "ON" or "OFF")
        .. (simulationExists and not simulationState.canDelete and simulationState.masterKey ~= "" and " | Delete locked for non-owner." or "")
        .. (hasSimulationSession and " | Stop the active Simulation session before hiding it." or "")
        .. (hasRunningSession and not hasSimulationSession and " | Stop the active session before deleting it." or "")
      )
    end
    if aboutDeveloperState then
      if enabled then
        aboutDeveloperState:SetText(
          "Developer Mode: ON\n"
          .. "Profile ID display: " .. tostring(root.ui.showInternalProfileId == true and "ON" or "OFF")
          .. " | Profile Size display: " .. tostring(root.ui.showProfileSize == true and "ON" or "OFF") .. "\n"
          .. "Header monitoring checkmark: " .. tostring(root.ui.showHeaderMonitoringCheck == true and "ON" or "OFF") .. "\n"
          .. "Tutorial Mode: " .. tostring(root.ui.tutorialMode == true and "ON" or "OFF")
          .. " | Checklist Dev: " .. tostring(root.ui.checklistDev == true and "ON" or "OFF")
          .. " | Changelog Dev: " .. tostring(root.ui.changelogDev == true and "ON" or "OFF") .. "\n"
          .. "Import / Export Feature: " .. tostring(root.ui.importExportFeature == true and "ON" or "OFF") .. "\n"
          .. "Silent-error tracing is active while Developer Mode is enabled."
        )
      else
        aboutDeveloperState:SetText(
          "Developer Mode: OFF\n"
          .. "Profile ID display: OFF | Profile Size display: OFF | Tutorial Mode: OFF | Checklist Dev: OFF | Changelog Dev: OFF\n"
          .. "Import / Export Feature: OFF\n"
          .. "Silent-error tracing is currently disabled."
        )
      end
    end

    RefreshDeveloperHealth()
    RefreshProfileSyncTuningControls()
    RefreshDeveloperSyncHarnessControls()
    if editor and editor.UpdateAboutDeveloperLayout then
      editor:UpdateAboutDeveloperLayout()
    end
  end
  editor.RefreshDeveloperSection = RefreshDeveloperSection

  aboutDeveloperModeCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    local enabled = self:GetChecked() and true or false
    if not enabled and root.ui.showSimulationProfile == true and HasActiveSimulationSession() then
      root.ui.developerMode = true
      self:SetChecked(true)
      if type(Print) == "function" then
        Print("Stop the active Simulation session before hiding the Simulation profile.")
      end
      RefreshDeveloperSection()
      RefreshAboutUtilitiesPage()
      return
    end

    root.ui.developerMode = enabled
    if not enabled then
      root.ui.showInternalProfileId = false
      root.ui.showProfileSize = false
      root.ui.tutorialMode = false
      root.ui.checklistDev = false
      root.ui.changelogDev = false
      root.ui.importExportFeature = false
      root.ui.showSimulationProfile = false
      root.ui.showHeaderMonitoringCheck = false
      if editor and string.lower(tostring(editor.__lootProfileOpenSection or "")) == "transfer" then
        editor.__lootProfileOpenSection = "overview"
      end
      MoveAwayFromSimulationSelection()
    end

    local debugStore = _G.LIDCOUNCIL_Debug
    if not enabled and debugStore then
      debugStore.silent = {}
    end
    if editor and editor.UpdateUILayout then
      editor:UpdateUILayout()
    end
    if editor and editor.RefreshTutorialChecklistNavigation then
      editor:RefreshTutorialChecklistNavigation()
    end
    if editor and editor.RequestLootProfilePageRefresh then
      editor:RequestLootProfilePageRefresh()
    end
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  aboutShowProfileIdCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      root.ui.showInternalProfileId = false
      self:SetChecked(false)
      RefreshDeveloperSection()
      return
    end
    root.ui.showInternalProfileId = self:GetChecked() and true or false
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  aboutShowProfileSizeCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      root.ui.showProfileSize = false
      self:SetChecked(false)
      RefreshDeveloperSection()
      return
    end
    root.ui.showProfileSize = self:GetChecked() and true or false
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  aboutShowHeaderMonitoringCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      root.ui.showHeaderMonitoringCheck = false
      self:SetChecked(false)
      RefreshDeveloperSection()
      return
    end
    root.ui.showHeaderMonitoringCheck = self:GetChecked() and true or false
    if editor and editor.UpdateUILayout then
      editor:UpdateUILayout()
    end
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  local function ApplyProfileSyncTuningFromInputs()
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      if type(Print) == "function" then
        Print("Activate Developer Mode before changing experimental sync tuning.")
      end
      RefreshDeveloperSection()
      return
    end

    local chunkSize = ParseDeveloperNumber(aboutSyncChunkEdit and aboutSyncChunkEdit:GetText() or "")
    local delaySeconds = ParseDeveloperNumber(aboutSyncDelayEdit and aboutSyncDelayEdit:GetText() or "")
    local tuning = SetProfileSyncTuning(chunkSize, delaySeconds)
    if type(Print) == "function" then
      Print(string.format(
        "Profile sync tuning applied: %d byte chunks, %.2fs queue delay.",
        tonumber(tuning.chunkSize) or 120,
        tonumber(tuning.intervalSeconds) or 0.12
      ))
    end
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end

  if aboutSyncTuningApplyBtn then
    aboutSyncTuningApplyBtn:SetScript("OnClick", ApplyProfileSyncTuningFromInputs)
  end
  if aboutSyncTuningResetBtn then
    aboutSyncTuningResetBtn:SetScript("OnClick", function()
      local tuning = ResetProfileSyncTuning()
      if type(Print) == "function" then
        Print(string.format(
          "Profile sync tuning reset: %d byte chunks, %.2fs queue delay.",
          tonumber(tuning.chunkSize) or 120,
          tonumber(tuning.intervalSeconds) or 0.12
        ))
      end
      RefreshDeveloperSection()
      RefreshAboutUtilitiesPage()
    end)
  end
  for _, editBox in ipairs({ aboutSyncChunkEdit, aboutSyncDelayEdit }) do
    if editBox then
      editBox:SetScript("OnEnterPressed", function(self)
        ApplyProfileSyncTuningFromInputs()
        self:ClearFocus()
      end)
      editBox:SetScript("OnEscapePressed", function(self)
        self:ClearFocus()
        RefreshProfileSyncTuningControls()
      end)
    end
  end

  local function RunDeveloperSyncHarnessForMemberCount(memberCount)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      if type(Print) == "function" then
        Print("Activate Developer Mode first.")
      end
      RefreshDeveloperSection()
      return
    end

    local harnessConfig = EnsureDeveloperSyncHarnessConfig(root)
    harnessConfig.memberCount = math.max(1, math.floor((tonumber(memberCount) or harnessConfig.memberCount or 5) + 0.5))
    local runHarness = ResolveOptionalApiFunction("LIDCOUNCIL_RunDeveloperProfileSyncHarness")
    if type(runHarness) ~= "function" then
      if type(Print) == "function" then
        Print("Sync Harness API unavailable.")
      end
      RefreshDeveloperSection()
      return
    end

    local ok, result = runHarness({
      profileMode = harnessConfig.profileMode,
      scenario = harnessConfig.scenario,
      memberCount = harnessConfig.memberCount,
    })
    if type(Print) == "function" then
      if ok then
        Print(string.format(
          "Sync Harness ran with %d synthetic raiders on profile \"%s\" and populated the developer synthetic session.",
          harnessConfig.memberCount,
          tostring(type(result) == "table" and result.profileName or "")
        ))
      else
        Print(tostring(result or "Could not run the Sync Harness."))
      end
    end
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end

  if aboutDeveloperHarnessSimulationBtn then
    aboutDeveloperHarnessSimulationBtn:SetScript("OnClick", function()
      local root = RootDB()
      local harnessConfig = EnsureDeveloperSyncHarnessConfig(root)
      if not HasSimulationProfile(root) then
        if type(Print) == "function" then
          Print("Simulation profile not found.")
        end
        RefreshDeveloperSection()
        return
      end
      harnessConfig.profileMode = "SIMULATION"
      RefreshDeveloperSection()
    end)
  end

  if aboutDeveloperHarnessCurrentBtn then
    aboutDeveloperHarnessCurrentBtn:SetScript("OnClick", function()
      local harnessConfig = EnsureDeveloperSyncHarnessConfig(RootDB())
      harnessConfig.profileMode = "CURRENT"
      RefreshDeveloperSection()
    end)
  end

  if aboutDeveloperHarnessFreshBtn then
    aboutDeveloperHarnessFreshBtn:SetScript("OnClick", function()
      local harnessConfig = EnsureDeveloperSyncHarnessConfig(RootDB())
      harnessConfig.scenario = "FRESH"
      RefreshDeveloperSection()
    end)
  end

  if aboutDeveloperHarnessReturningBtn then
    aboutDeveloperHarnessReturningBtn:SetScript("OnClick", function()
      local harnessConfig = EnsureDeveloperSyncHarnessConfig(RootDB())
      harnessConfig.scenario = "RETURNING"
      RefreshDeveloperSection()
    end)
  end

  if aboutDeveloperHarnessMixedBtn then
    aboutDeveloperHarnessMixedBtn:SetScript("OnClick", function()
      local harnessConfig = EnsureDeveloperSyncHarnessConfig(RootDB())
      harnessConfig.scenario = "MIXED"
      RefreshDeveloperSection()
    end)
  end

  if aboutDeveloperHarnessRun5Btn then
    aboutDeveloperHarnessRun5Btn:SetScript("OnClick", function()
      EnsureDeveloperSyncHarnessConfig(RootDB()).memberCount = 5
      RefreshDeveloperSection()
    end)
  end
  if aboutDeveloperHarnessRun10Btn then
    aboutDeveloperHarnessRun10Btn:SetScript("OnClick", function()
      EnsureDeveloperSyncHarnessConfig(RootDB()).memberCount = 10
      RefreshDeveloperSection()
    end)
  end
  if aboutDeveloperHarnessRun20Btn then
    aboutDeveloperHarnessRun20Btn:SetScript("OnClick", function()
      EnsureDeveloperSyncHarnessConfig(RootDB()).memberCount = 20
      RefreshDeveloperSection()
    end)
  end
  if editor.aboutDeveloperHarnessRunBtn then
    editor.aboutDeveloperHarnessRunBtn:SetScript("OnClick", function()
      RunDeveloperSyncHarnessForMemberCount(EnsureDeveloperSyncHarnessConfig(RootDB()).memberCount)
    end)
  end
  if aboutDeveloperHarnessValidateBtn then
    aboutDeveloperHarnessValidateBtn:SetScript("OnClick", function()
      if type(InCombatLockdown) == "function" and InCombatLockdown() then
        if type(Print) == "function" then
          Print("Release preflight is unavailable during combat. Run it after combat ends.")
        end
        return
      end
      local root = RootDB()
      root.ui = root.ui or {}
      if root.ui.developerMode ~= true then
        if type(Print) == "function" then
          Print("Activate Developer Mode first.")
        end
        RefreshDeveloperSection()
        return
      end
      local runAutomatedValidation = ResolveOptionalApiFunction("LIDCOUNCIL_RunReleasePreflight")
      if type(runAutomatedValidation) ~= "function" then
        if type(Print) == "function" then
          Print("Release preflight API unavailable.")
        end
        RefreshDeveloperSection()
        return
      end
      local executed, ok, validation = pcall(runAutomatedValidation)
      if type(Print) == "function" then
        if not executed then
          Print("Release preflight could not run: " .. tostring(ok))
        else
          local validationTable = type(validation) == "table" and validation or {}
          if validationTable.blocked == true then
            Print("Release preflight blocked: "
              .. tostring(validationTable.blockedDetail or validationTable.blockedReason or "safety gate"))
          else
            Print(
              "Release preflight " .. (ok and "passed" or "failed")
                .. " (" .. tostring(math.max(0, tonumber(validationTable.passed) or 0))
                .. "/" .. tostring(math.max(0, tonumber(validationTable.total) or 0))
                .. " in " .. string.format("%.2fs", math.max(0, tonumber(validationTable.durationSeconds) or 0))
                .. (math.max(0, tonumber(validationTable.slowSuiteCount) or 0) > 0
                  and (", " .. tostring(math.max(0, tonumber(validationTable.slowSuiteCount) or 0)) .. " slow suite(s)")
                  or "")
                .. ")."
            )
          end
        end
      end
      RefreshDeveloperSection()
      RefreshAboutUtilitiesPage()
    end)
  end
  if aboutDeveloperHarnessClearBtn then
    aboutDeveloperHarnessClearBtn:SetScript("OnClick", function()
      local clearPreflight = ResolveOptionalApiFunction("LIDCOUNCIL_ClearReleasePreflightStatus")
      if type(clearPreflight) == "function" then
        pcall(clearPreflight)
      end
      RefreshDeveloperSection()
      RefreshAboutUtilitiesPage()
    end)
  end
  if editor.aboutDeveloperPreflightCopyBtn then
    editor.aboutDeveloperPreflightCopyBtn:SetScript("OnClick", function()
      local reportText = tostring(editor.aboutDeveloperPreflightCopyText or "")
      if reportText == "" then
        if type(Print) == "function" then
          Print("Run Release Preflight before copying its report.")
        end
        return
      end
      local showCopyTextWindow = ResolveOptionalApiFunction("LIDCOUNCIL_ShowCopyTextWindow")
      if type(showCopyTextWindow) == "function" then
        showCopyTextWindow("Release Preflight Report", reportText)
      elseif type(Print) == "function" then
        Print("Copyable report window unavailable.")
      end
    end)
  end
  if editor.aboutDeveloperHarnessClearRehearsalBtn then
    editor.aboutDeveloperHarnessClearRehearsalBtn:SetScript("OnClick", function()
      local clearHarness = ResolveOptionalApiFunction("LIDCOUNCIL_ClearDeveloperProfileSyncHarness")
      if type(clearHarness) == "function" then
        clearHarness()
      end
      RefreshDeveloperSection()
      RefreshAboutUtilitiesPage()
    end)
  end
  if editor.aboutDeveloperHarnessCopyBtn then
    editor.aboutDeveloperHarnessCopyBtn:SetScript("OnClick", function()
      local reportText = tostring(editor.aboutDeveloperHarnessCopyText or "")
      if reportText == "" then
        if type(Print) == "function" then
          Print("Run a Synthetic Sync Rehearsal before copying its report.")
        end
        return
      end
      local showCopyTextWindow = ResolveOptionalApiFunction("LIDCOUNCIL_ShowCopyTextWindow")
      if type(showCopyTextWindow) == "function" then
        showCopyTextWindow("Synthetic Sync Rehearsal Report", reportText)
      elseif type(Print) == "function" then
        Print("Copyable report window unavailable.")
      end
    end)
  end

  aboutTutorialModeCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      root.ui.tutorialMode = false
      self:SetChecked(false)
      RefreshDeveloperSection()
      return
    end
    root.ui.tutorialMode = self:GetChecked() and true or false
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  aboutChecklistDevCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      root.ui.checklistDev = false
      self:SetChecked(false)
      if editor and editor.RefreshTutorialChecklistNavigation then
        editor:RefreshTutorialChecklistNavigation()
      end
      RefreshDeveloperSection()
      return
    end
    root.ui.checklistDev = self:GetChecked() and true or false
    if editor and editor.RefreshTutorialChecklistNavigation then
      editor:RefreshTutorialChecklistNavigation()
    end
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  aboutChangelogDevCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      root.ui.changelogDev = false
      self:SetChecked(false)
      RefreshDeveloperSection()
      return
    end
    root.ui.changelogDev = self:GetChecked() and true or false
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  editor.aboutImportExportFeatureCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      root.ui.importExportFeature = false
      self:SetChecked(false)
      RefreshDeveloperSection()
      return
    end
    root.ui.importExportFeature = self:GetChecked() and true or false
    if not root.ui.importExportFeature and editor and string.lower(tostring(editor.__lootProfileOpenSection or "")) == "transfer" then
      editor.__lootProfileOpenSection = "overview"
    end
    if editor and editor.RequestLootProfilePageRefresh then
      editor:RequestLootProfilePageRefresh()
    end
    if editor and editor.UpdateUILayout then
      editor:UpdateUILayout()
    end
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  aboutShowSimulationCheck:SetScript("OnClick", function(self)
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      root.ui.showSimulationProfile = false
      self:SetChecked(false)
      RefreshDeveloperSection()
      return
    end
    if not self:GetChecked() and HasActiveSimulationSession() then
      root.ui.showSimulationProfile = true
      self:SetChecked(true)
      if type(Print) == "function" then
        Print("Stop the active Simulation session before hiding the Simulation profile.")
      end
      RefreshDeveloperSection()
      RefreshAboutUtilitiesPage()
      return
    end
    root.ui.showSimulationProfile = self:GetChecked() and true or false
    if not root.ui.showSimulationProfile then
      MoveAwayFromSimulationSelection()
    end
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
  end)

  aboutCreateSimulationBtn:SetScript("OnClick", function()
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      if type(Print) == "function" then
        Print("Activate Developer Mode first.")
      end
      return
    end
    local simulationState = GetSimulationProfileState(root)
    if simulationState.exists then
      root.ui.showSimulationProfile = true
      RefreshDeveloperSection()
      RefreshAboutUtilitiesPage()
      if type(Print) == "function" then
        if simulationState.repaired then
          Print("Recovered the existing Simulation profile for this character.")
        else
          Print("Simulation profile already exists.")
        end
      end
      return
    end
    if type(CreateLootProfileApi) ~= "function" then
      if type(Print) == "function" then
        Print("Simulation profile API unavailable.")
      end
      return
    end
    local ok, result = CreateLootProfileApi("Simulation")
    if not ok then
      if type(Print) == "function" then
        Print(tostring(result or "Could not create the Simulation profile."))
      end
      return
    end
    local profileManagement = INTERNAL_API and INTERNAL_API.LIDCOUNCIL_EditorProfileManagement_Impl or nil
    if type(profileManagement) == "table" and type(profileManagement.InvalidateSortedProfileNames) == "function" then
      profileManagement.InvalidateSortedProfileNames(root)
    end
    root.ui.showSimulationProfile = true
    RefreshDeveloperSection()
    RefreshAboutUtilitiesPage()
    if type(StaticPopup_Show) == "function" then
      StaticPopup_Show("LIDCOUNCIL_SIMULATION_PROFILE_CREATED")
    elseif type(Print) == "function" then
      Print("Simulation Profile created - go to Profile to start using it for Simulations.")
    end
  end)

  aboutDeleteSimulationBtn:SetScript("OnClick", function()
    local root = RootDB()
    root.ui = root.ui or {}
    if root.ui.developerMode ~= true then
      if type(Print) == "function" then
        Print("Activate Developer Mode first.")
      end
      return
    end
    local simulationState = GetSimulationProfileState(root)
    if not simulationState.exists then
      if type(Print) == "function" then
        Print("Simulation profile not found.")
      end
      return
    end
    if type(simulationState.access) == "table" and not simulationState.canDelete then
      if type(Print) == "function" then
        Print("Only the Simulation profile owner can delete it.")
      end
      RefreshDeveloperSection()
      return
    end
    if type(DeleteLootProfileApi) ~= "function" then
      if type(Print) == "function" then
        Print("Simulation delete API unavailable.")
      end
      return
    end
    if type(StaticPopup_Show) == "function" then
      StaticPopup_Show("LIDCOUNCIL_DELETE_SIMULATION_PROFILE")
    end
  end)

  local function UpdateAboutDeveloperLayout()
    if not aboutContent or not aboutDeveloperText then return end
    if editor and editor.aboutSection and editor.aboutSection ~= "Developer" then return end
    local root = RootDB()
    root.ui = root.ui or {}
    local enabled = root.ui.developerMode == true
    local headerMonitoringCheck = editor and editor.aboutShowHeaderMonitoringCheck
    local headerMonitoringInfoFrame = editor and editor.aboutShowHeaderMonitoringInfo
    local w = (aboutContent:GetWidth() or 0) - 10
    if w < 200 then w = 200 end

    aboutDeveloperText:SetWidth(w)
    if aboutDeveloperModeDesc then aboutDeveloperModeDesc:SetWidth(math.max(220, w - 24)) end
    if aboutDeveloperOptionsDesc then aboutDeveloperOptionsDesc:SetWidth(w) end
    if aboutRuntimeDesc then aboutRuntimeDesc:SetWidth(w) end
    if aboutSimulationState then aboutSimulationState:SetWidth(w) end
    if aboutDeveloperState then aboutDeveloperState:SetWidth(w) end
    if aboutDeveloperHealth then aboutDeveloperHealth:SetWidth(w) end
    if aboutDeveloperExperimentalDesc then aboutDeveloperExperimentalDesc:SetWidth(w) end
    if editor and editor.aboutHeaderMonitoringPreviewDesc then editor.aboutHeaderMonitoringPreviewDesc:SetWidth(math.max(180, w - 28)) end
    if editor and editor.aboutProfileSyncTuningDesc then editor.aboutProfileSyncTuningDesc:SetWidth(math.max(180, w - 28)) end
    if aboutSyncTuningState then aboutSyncTuningState:SetWidth(math.max(180, w - 28)) end
    if aboutDeveloperHarnessDesc then aboutDeveloperHarnessDesc:SetWidth(math.max(180, w - 28)) end
    if editor.aboutDeveloperPreflightReport then editor.aboutDeveloperPreflightReport:SetWidth(math.max(180, w - 28)) end
    if editor.aboutDeveloperRehearsalDesc then editor.aboutDeveloperRehearsalDesc:SetWidth(w) end
    if aboutDeveloperHarnessState then aboutDeveloperHarnessState:SetWidth(w) end
    if aboutDeveloperHarnessReport then aboutDeveloperHarnessReport:SetWidth(w) end

    if aboutDeveloperExperimentalDivider then
      aboutDeveloperExperimentalDivider:ClearAllPoints()
      aboutDeveloperExperimentalDivider:SetPoint("TOPLEFT", aboutDeveloperHealth, "BOTTOMLEFT", 0, -18)
      aboutDeveloperExperimentalDivider:SetPoint("RIGHT", aboutDeveloperFrame, "RIGHT", -10, 0)
    end
    if aboutDeveloperExperimentalHeader then
      aboutDeveloperExperimentalHeader:ClearAllPoints()
      aboutDeveloperExperimentalHeader:SetPoint("TOPLEFT", aboutDeveloperExperimentalDivider, "BOTTOMLEFT", 0, -12)
    end
    if aboutDeveloperExperimentalDesc then
      aboutDeveloperExperimentalDesc:ClearAllPoints()
      aboutDeveloperExperimentalDesc:SetPoint("TOPLEFT", aboutDeveloperExperimentalHeader, "BOTTOMLEFT", 0, -6)
    end
    if editor and editor.aboutImportExportFeatureCheck then
      editor.aboutImportExportFeatureCheck:ClearAllPoints()
      editor.aboutImportExportFeatureCheck:SetPoint("TOPLEFT", aboutDeveloperExperimentalDesc, "BOTTOMLEFT", 0, -8)
    end
    if editor and editor.aboutHeaderMonitoringPreviewPanel then
      editor.aboutHeaderMonitoringPreviewPanel:ClearAllPoints()
      editor.aboutHeaderMonitoringPreviewPanel:SetPoint("TOPLEFT", editor.aboutImportExportFeatureCheck, "BOTTOMLEFT", 0, -10)
      editor.aboutHeaderMonitoringPreviewPanel:SetWidth(w)
      if editor.aboutHeaderMonitoringPreviewPanel.__expanded then
        editor.aboutHeaderMonitoringPreviewPanel:SetHeight(
          84 + ((editor.aboutHeaderMonitoringPreviewDesc.GetStringHeight and editor.aboutHeaderMonitoringPreviewDesc:GetStringHeight()) or 14)
        )
      else
        editor.aboutHeaderMonitoringPreviewPanel:SetHeight(36)
      end
    end
    if editor and editor.aboutHeaderMonitoringPreviewDesc then
      editor.aboutHeaderMonitoringPreviewDesc:ClearAllPoints()
      editor.aboutHeaderMonitoringPreviewDesc:SetPoint("TOPLEFT", editor.aboutHeaderMonitoringPreviewPanel.__content, "TOPLEFT", 0, 0)
    end
    if headerMonitoringCheck then
      headerMonitoringCheck:ClearAllPoints()
      headerMonitoringCheck:SetPoint("TOPLEFT", editor.aboutHeaderMonitoringPreviewDesc, "BOTTOMLEFT", 0, -6)
    end
    if headerMonitoringInfoFrame and headerMonitoringCheck then
      headerMonitoringInfoFrame:ClearAllPoints()
      headerMonitoringInfoFrame:SetPoint("LEFT", _G[headerMonitoringCheck:GetName() .. "Text"], "RIGHT", 8, 0)
    end
    if editor and editor.aboutProfileSyncTuningPanel then
      editor.aboutProfileSyncTuningPanel:ClearAllPoints()
      editor.aboutProfileSyncTuningPanel:SetPoint("TOPLEFT", editor.aboutHeaderMonitoringPreviewPanel, "BOTTOMLEFT", 0, -10)
      editor.aboutProfileSyncTuningPanel:SetWidth(w)
    end
    if aboutDeveloperExperimentalInfo then
      aboutDeveloperExperimentalInfo:ClearAllPoints()
      aboutDeveloperExperimentalInfo:SetPoint("LEFT", editor.aboutProfileSyncTuningHeader, "RIGHT", 8, 0)
    end
    if editor and editor.aboutProfileSyncTuningDesc then
      editor.aboutProfileSyncTuningDesc:ClearAllPoints()
      editor.aboutProfileSyncTuningDesc:SetPoint("TOPLEFT", editor.aboutProfileSyncTuningHeader or aboutDeveloperExperimentalDesc, "BOTTOMLEFT", 0, -6)
    end
    if aboutSyncChunkLabel then
      aboutSyncChunkLabel:ClearAllPoints()
      aboutSyncChunkLabel:SetPoint("TOPLEFT", (editor and editor.aboutProfileSyncTuningDesc) or aboutDeveloperExperimentalDesc, "BOTTOMLEFT", 0, -10)
      aboutSyncChunkLabel:SetWidth(132)
      aboutSyncChunkLabel:SetJustifyH("LEFT")
    end
    if aboutSyncChunkEdit then
      aboutSyncChunkEdit:ClearAllPoints()
      aboutSyncChunkEdit:SetPoint("LEFT", aboutSyncChunkLabel, "RIGHT", 12, 0)
    end
    if aboutSyncChunkUnit then
      aboutSyncChunkUnit:ClearAllPoints()
      aboutSyncChunkUnit:SetPoint("LEFT", aboutSyncChunkEdit, "RIGHT", 8, 0)
    end
    if aboutSyncDelayLabel then
      aboutSyncDelayLabel:ClearAllPoints()
      aboutSyncDelayLabel:SetPoint("TOPLEFT", aboutSyncChunkLabel, "BOTTOMLEFT", 0, -14)
      aboutSyncDelayLabel:SetWidth(132)
      aboutSyncDelayLabel:SetJustifyH("LEFT")
    end
    if aboutSyncDelayEdit then
      aboutSyncDelayEdit:ClearAllPoints()
      aboutSyncDelayEdit:SetPoint("LEFT", aboutSyncDelayLabel, "RIGHT", 12, 0)
    end
    if aboutSyncDelayUnit then
      aboutSyncDelayUnit:ClearAllPoints()
      aboutSyncDelayUnit:SetPoint("LEFT", aboutSyncDelayEdit, "RIGHT", 8, 0)
    end
    if aboutSyncTuningApplyBtn then
      aboutSyncTuningApplyBtn:ClearAllPoints()
      aboutSyncTuningApplyBtn:SetPoint("TOPLEFT", aboutSyncDelayLabel, "BOTTOMLEFT", 0, -14)
    end
    if aboutSyncTuningResetBtn then
      aboutSyncTuningResetBtn:ClearAllPoints()
      aboutSyncTuningResetBtn:SetPoint("LEFT", aboutSyncTuningApplyBtn, "RIGHT", 10, 0)
    end
    if aboutSyncTuningState then
      aboutSyncTuningState:ClearAllPoints()
      aboutSyncTuningState:SetPoint("TOPLEFT", aboutSyncTuningApplyBtn, "BOTTOMLEFT", 0, -8)
    end
    if editor and editor.aboutProfileSyncTuningPanel then
      if editor.aboutProfileSyncTuningPanel.__expanded then
        editor.aboutProfileSyncTuningPanel:SetHeight(
          160
          + ((editor.aboutProfileSyncTuningDesc.GetStringHeight and editor.aboutProfileSyncTuningDesc:GetStringHeight()) or 14)
          + ((aboutSyncTuningState.GetStringHeight and aboutSyncTuningState:GetStringHeight()) or 14)
        )
      else
        editor.aboutProfileSyncTuningPanel:SetHeight(36)
      end
    end
    if editor.aboutDeveloperHarnessPanel then
      editor.aboutDeveloperHarnessPanel:ClearAllPoints()
      editor.aboutDeveloperHarnessPanel:SetPoint("TOPLEFT", editor.aboutProfileSyncTuningPanel, "BOTTOMLEFT", 0, -10)
      editor.aboutDeveloperHarnessPanel:SetWidth(w)
    end
    if aboutDeveloperHarnessDesc then
      aboutDeveloperHarnessDesc:ClearAllPoints()
      aboutDeveloperHarnessDesc:SetPoint("TOPLEFT", editor.aboutDeveloperHarnessPanel.__content, "TOPLEFT", 0, 0)
    end
    if editor.aboutDeveloperPreflightStatusCard then
      editor.aboutDeveloperPreflightStatusCard:ClearAllPoints()
      editor.aboutDeveloperPreflightStatusCard:SetPoint("TOPLEFT", aboutDeveloperHarnessDesc, "BOTTOMLEFT", 0, -10)
      editor.aboutDeveloperPreflightStatusCard:SetPoint("RIGHT", editor.aboutDeveloperHarnessPanel.__content, "RIGHT", 0, 0)
    end
    if aboutDeveloperHarnessValidateBtn then
      aboutDeveloperHarnessValidateBtn:ClearAllPoints()
      aboutDeveloperHarnessValidateBtn:SetPoint("TOPLEFT", editor.aboutDeveloperPreflightStatusCard, "BOTTOMLEFT", 0, -10)
    end
    if editor.aboutDeveloperPreflightCopyBtn then
      editor.aboutDeveloperPreflightCopyBtn:ClearAllPoints()
      editor.aboutDeveloperPreflightCopyBtn:SetPoint("LEFT", aboutDeveloperHarnessValidateBtn, "RIGHT", 12, 0)
    end
    if aboutDeveloperHarnessClearBtn then
      aboutDeveloperHarnessClearBtn:ClearAllPoints()
      aboutDeveloperHarnessClearBtn:SetPoint("LEFT", editor.aboutDeveloperPreflightCopyBtn, "RIGHT", 8, 0)
    end
    if editor.aboutDeveloperPreflightReport then
      editor.aboutDeveloperPreflightReport:ClearAllPoints()
      editor.aboutDeveloperPreflightReport:SetPoint("TOPLEFT", aboutDeveloperHarnessValidateBtn, "BOTTOMLEFT", 0, -10)
    end
    if editor.aboutDeveloperHarnessPanel then
      if editor.aboutDeveloperHarnessPanel.__expanded then
        editor.aboutDeveloperHarnessPanel:SetHeight(
          166
          + ((aboutDeveloperHarnessDesc.GetStringHeight and aboutDeveloperHarnessDesc:GetStringHeight()) or 14)
          + ((editor.aboutDeveloperPreflightReport.GetStringHeight and editor.aboutDeveloperPreflightReport:GetStringHeight()) or 14)
        )
      else
        editor.aboutDeveloperHarnessPanel:SetHeight(36)
      end
    end
    if editor.aboutDeveloperRehearsalPanel then
      editor.aboutDeveloperRehearsalPanel:ClearAllPoints()
      editor.aboutDeveloperRehearsalPanel:SetPoint("TOPLEFT", editor.aboutDeveloperHarnessPanel, "BOTTOMLEFT", 0, -10)
      editor.aboutDeveloperRehearsalPanel:SetWidth(w)
    end
    if editor.aboutDeveloperRehearsalDesc then
      editor.aboutDeveloperRehearsalDesc:ClearAllPoints()
      editor.aboutDeveloperRehearsalDesc:SetPoint("TOPLEFT", editor.aboutDeveloperRehearsalPanel.__content, "TOPLEFT", 0, 0)
      editor.aboutDeveloperRehearsalDesc:SetWidth(math.max(200, w - 28))
    end
    if aboutDeveloperHarnessSourceLabel then
      aboutDeveloperHarnessSourceLabel:ClearAllPoints()
      aboutDeveloperHarnessSourceLabel:SetPoint("TOPLEFT", editor.aboutDeveloperRehearsalDesc, "BOTTOMLEFT", 0, -12)
      aboutDeveloperHarnessSourceLabel:SetWidth(92)
      aboutDeveloperHarnessSourceLabel:SetJustifyH("LEFT")
    end
    if aboutDeveloperHarnessSimulationBtn then
      aboutDeveloperHarnessSimulationBtn:ClearAllPoints()
      aboutDeveloperHarnessSimulationBtn:SetPoint("LEFT", aboutDeveloperHarnessSourceLabel, "RIGHT", 12, 0)
    end
    if aboutDeveloperHarnessCurrentBtn then
      aboutDeveloperHarnessCurrentBtn:ClearAllPoints()
      aboutDeveloperHarnessCurrentBtn:SetPoint("LEFT", aboutDeveloperHarnessSimulationBtn, "RIGHT", 10, 0)
    end
    if aboutDeveloperHarnessScenarioLabel then
      aboutDeveloperHarnessScenarioLabel:ClearAllPoints()
      aboutDeveloperHarnessScenarioLabel:SetPoint("TOPLEFT", aboutDeveloperHarnessSimulationBtn, "BOTTOMLEFT", -104, -10)
      aboutDeveloperHarnessScenarioLabel:SetWidth(92)
      aboutDeveloperHarnessScenarioLabel:SetJustifyH("LEFT")
    end
    if aboutDeveloperHarnessFreshBtn then
      aboutDeveloperHarnessFreshBtn:ClearAllPoints()
      aboutDeveloperHarnessFreshBtn:SetPoint("LEFT", aboutDeveloperHarnessScenarioLabel, "RIGHT", 12, 0)
    end
    if aboutDeveloperHarnessReturningBtn then
      aboutDeveloperHarnessReturningBtn:ClearAllPoints()
      aboutDeveloperHarnessReturningBtn:SetPoint("LEFT", aboutDeveloperHarnessFreshBtn, "RIGHT", 10, 0)
    end
    if aboutDeveloperHarnessMixedBtn then
      aboutDeveloperHarnessMixedBtn:ClearAllPoints()
      aboutDeveloperHarnessMixedBtn:SetPoint("LEFT", aboutDeveloperHarnessReturningBtn, "RIGHT", 10, 0)
    end
    if aboutDeveloperHarnessRunLabel then
      aboutDeveloperHarnessRunLabel:ClearAllPoints()
      aboutDeveloperHarnessRunLabel:SetPoint("TOPLEFT", aboutDeveloperHarnessFreshBtn, "BOTTOMLEFT", -104, -10)
      aboutDeveloperHarnessRunLabel:SetWidth(92)
      aboutDeveloperHarnessRunLabel:SetJustifyH("LEFT")
    end
    if aboutDeveloperHarnessRun5Btn then
      aboutDeveloperHarnessRun5Btn:ClearAllPoints()
      aboutDeveloperHarnessRun5Btn:SetPoint("LEFT", aboutDeveloperHarnessRunLabel, "RIGHT", 12, 0)
    end
    if aboutDeveloperHarnessRun10Btn then
      aboutDeveloperHarnessRun10Btn:ClearAllPoints()
      aboutDeveloperHarnessRun10Btn:SetPoint("LEFT", aboutDeveloperHarnessRun5Btn, "RIGHT", 10, 0)
    end
    if aboutDeveloperHarnessRun20Btn then
      aboutDeveloperHarnessRun20Btn:ClearAllPoints()
      aboutDeveloperHarnessRun20Btn:SetPoint("LEFT", aboutDeveloperHarnessRun10Btn, "RIGHT", 10, 0)
    end
    if editor.aboutDeveloperHarnessRunBtn then
      editor.aboutDeveloperHarnessRunBtn:ClearAllPoints()
      editor.aboutDeveloperHarnessRunBtn:SetPoint("TOPLEFT", aboutDeveloperHarnessRun5Btn, "BOTTOMLEFT", -104, -14)
    end
    if editor.aboutDeveloperHarnessCopyBtn then
      editor.aboutDeveloperHarnessCopyBtn:ClearAllPoints()
      editor.aboutDeveloperHarnessCopyBtn:SetPoint("LEFT", editor.aboutDeveloperHarnessRunBtn, "RIGHT", 12, 0)
    end
    if editor.aboutDeveloperHarnessClearRehearsalBtn then
      editor.aboutDeveloperHarnessClearRehearsalBtn:ClearAllPoints()
      editor.aboutDeveloperHarnessClearRehearsalBtn:SetPoint("LEFT", editor.aboutDeveloperHarnessCopyBtn, "RIGHT", 10, 0)
    end
    if aboutDeveloperHarnessState then
      aboutDeveloperHarnessState:ClearAllPoints()
      aboutDeveloperHarnessState:SetPoint("TOPLEFT", editor.aboutDeveloperHarnessRunBtn, "BOTTOMLEFT", 0, -10)
      aboutDeveloperHarnessState:SetWidth(math.max(200, w - 28))
    end
    if aboutDeveloperHarnessReport then
      aboutDeveloperHarnessReport:ClearAllPoints()
      aboutDeveloperHarnessReport:SetPoint("TOPLEFT", aboutDeveloperHarnessState, "BOTTOMLEFT", 0, -8)
      aboutDeveloperHarnessReport:SetWidth(math.max(200, w - 28))
    end
    if editor.aboutDeveloperRehearsalPanel then
      if editor.aboutDeveloperRehearsalPanel.__expanded then
        editor.aboutDeveloperRehearsalPanel:SetHeight(
          206
          + ((editor.aboutDeveloperRehearsalDesc.GetStringHeight and editor.aboutDeveloperRehearsalDesc:GetStringHeight()) or 14)
          + ((aboutDeveloperHarnessState.GetStringHeight and aboutDeveloperHarnessState:GetStringHeight()) or 14)
          + ((aboutDeveloperHarnessReport.GetStringHeight and aboutDeveloperHarnessReport:GetStringHeight()) or 14)
        )
      else
        editor.aboutDeveloperRehearsalPanel:SetHeight(36)
      end
    end

    local t1 = (aboutDeveloperText.GetStringHeight and aboutDeveloperText:GetStringHeight()) or 60
    local tMode = (aboutDeveloperModeDesc and aboutDeveloperModeDesc.GetStringHeight and aboutDeveloperModeDesc:GetStringHeight()) or 20
    local tOptions = enabled and ((aboutDeveloperOptionsDesc and aboutDeveloperOptionsDesc.GetStringHeight and aboutDeveloperOptionsDesc:GetStringHeight()) or 18) or 0
    local tState = enabled and (
      ((aboutSimulationState and aboutSimulationState.GetStringHeight and aboutSimulationState:GetStringHeight()) or 20)
      + ((aboutDeveloperState and aboutDeveloperState.GetStringHeight and aboutDeveloperState:GetStringHeight()) or 20)
    ) or 0
    local tHealth = enabled and ((aboutDeveloperHealth and aboutDeveloperHealth.GetStringHeight and aboutDeveloperHealth:GetStringHeight()) or 120) or 0
    local tExperimental = enabled and (
      (aboutDeveloperExperimentalDesc and aboutDeveloperExperimentalDesc.GetStringHeight and aboutDeveloperExperimentalDesc:GetStringHeight()) or 20
    ) or 0
    local tExperimentalControls = enabled and (
      ((editor.aboutHeaderMonitoringPreviewPanel and editor.aboutHeaderMonitoringPreviewPanel:GetHeight()) or 36)
      + ((editor.aboutProfileSyncTuningPanel and editor.aboutProfileSyncTuningPanel:GetHeight()) or 36)
      + 58
    ) or 0
    local tHarness = enabled and (
      ((editor.aboutDeveloperHarnessPanel and editor.aboutDeveloperHarnessPanel:GetHeight()) or 36)
      + ((editor.aboutDeveloperRehearsalPanel and editor.aboutDeveloperRehearsalPanel:GetHeight()) or 36)
      + 20
    ) or 0

    if editor and editor.SetAboutContentHeight then
      if enabled then
        editor:SetAboutContentHeight(math.max(640, math.floor(t1 + tMode + tOptions + tState + tHealth + tExperimental + tExperimentalControls + tHarness + 540)))
      else
        editor:SetAboutContentHeight(math.max(520, math.floor(t1 + tMode + 180)))
      end
    end
  end
  editor.UpdateAboutDeveloperLayout = UpdateAboutDeveloperLayout
  SafeHookScript(aboutDeveloperFrame, "OnShow", function()
    if editor and editor.RefreshDeveloperSection then editor:RefreshDeveloperSection() end
    UpdateAboutDeveloperLayout()
  end)
  SafeHookScript(aboutContent, "OnSizeChanged", UpdateAboutDeveloperLayout)
end

INTERNAL_API.LIDCOUNCIL_CreateAboutUtilitySections_Impl = CreateAboutUtilitySections
