Index: _source/plugins/menu/plugin.js
===================================================================
--- _source/plugins/menu/plugin.js	(revision 4137)
+++ _source/plugins/menu/plugin.js	(working copy)
@@ -232,6 +232,8 @@
 					this.parent._.panel.showAsChild( panel, this.id, offsetParent, corner, offsetX, offsetY );
 				else
 					panel.showBlock( this.id, offsetParent, corner, offsetX, offsetY );
+				
+				editor.fire( 'menuShow', [ panel ] );
 			},
 
 			hide : function()
Index: _source/skins/kama/skin.js
===================================================================
--- _source/skins/kama/skin.js	(revision 4137)
+++ _source/skins/kama/skin.js	(working copy)
@@ -25,15 +25,9 @@
 			if ( editor.config.width && !isNaN( editor.config.width ) )
 				editor.config.width -= 12;
 
-			var menuHead;
-			function menuSetUiColor( color )
-			{
-				if ( !menuHead )
-					return null;
-
-				var uiStyle = menuHead.append('style');
-
-				var cssSrc = "/* UI Color Support */\
+			var uiColorMenus = [];
+			var uiColorRegex = /\$color/g;
+			var uiColorMenuCss = "/* UI Color Support */\
 .cke_skin_kama .cke_menuitem .cke_icon_wrapper\
 {\
 	background-color: $color !important;\
@@ -87,40 +81,58 @@
 {\
 	background-color: $color !important;\
 }";
+			// We have to split CSS declarations for webkit.
+			if ( CKEDITOR.env.webkit )
+			{
+				uiColorMenuCss = uiColorMenuCss.split( '}' ).slice( 0, -1 );
+				for ( var i in uiColorMenuCss )
+						uiColorMenuCss[ i ] = uiColorMenuCss[ i ].split( '{' );
+			}
 
-				uiStyle.setAttribute( "type", "text/css" );
-				var regex = /\$color/g;
-
-				// We have to split CSS declarations for webkit.
-				if ( CKEDITOR.env.webkit )
+			function addStylesheet( document )
+			{
+				var node = document.getHead().append( 'style' );
+				node.setAttribute( "id", "cke_ui_color" );
+				node.setAttribute( "type", "text/css" );
+				
+				return node;
+			}
+			
+			function updateStylesheets( styleNodes, styleContent, replace )
+			{
+				for ( var id in styleNodes )
 				{
-					cssSrc = cssSrc.split( '}' ).slice( 0, -1 );
-					for ( var i in cssSrc )
-							cssSrc[ i ] = cssSrc[ i ].split( '{' );
-				}
-
-				return ( menuSetUiColor =
-					function( color )
+					if ( CKEDITOR.env.webkit )
 					{
-						if ( CKEDITOR.env.webkit )
+						// Truncate manually.
+						for ( var i = 0 ; i < styleNodes[ id ].$.sheet.rules.length ; i++ )
+							styleNodes[ id ].$.sheet.removeRule( i );
+
+						for ( var i in styleContent )
 						{
-							for ( var i in cssSrc )
-								uiStyle.$.sheet.addRule(
-									cssSrc[ i ][ 0 ], cssSrc[ i ][ 1 ].replace( regex, color )
-								);
-						}
-						else
-						{
-							var css = cssSrc.replace( regex, color );
+							var content = styleContent[ i ][ 1 ];
+							for ( var r in replace )
+								content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );
 
-							if ( CKEDITOR.env.ie )
-								uiStyle.$.styleSheet.cssText = css;
-							else
-								uiStyle.setHtml( css );
+							styleNodes[ id ].$.sheet.addRule( styleContent[ i ][ 0 ], content );
 						}
-					})( color );
+					}
+					else
+					{
+						var content = styleContent;
+						for ( var r in replace )
+							content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] );
+
+						if ( CKEDITOR.env.ie )
+							styleNodes[ id ].$.styleSheet.cssText = content;
+						else
+							styleNodes[ id ].setHtml( content );
+					}
+				}
 			}
 
+			var uiColorRegexp = /\$color/g;
+
 			CKEDITOR.tools.extend( editor,
 			{
 				uiColor: null,
@@ -132,7 +144,7 @@
 
 				setUiColor : function( color )
 				{
-					var uiStyle = CKEDITOR.document.getHead().append('style'),
+					var uiStyle = addStylesheet( CKEDITOR.document ),
 						cssId = '#cke_' + editor.name.replace('.', '\\.');
 
 					var cssSelectors =
@@ -144,76 +156,47 @@
 						].join( ',' );
 					var cssProperties = "background-color: $color !important;";
 
-					uiStyle.setAttribute("type", "text/css");
+					if ( CKEDITOR.env.webkit )
+						var cssContent = [ [ cssSelectors, cssProperties ] ];
+					else
+						var cssContent = cssSelectors + '{' + cssProperties + '}';
 
 					return ( this.setUiColor =
 						function( color )
 						{
-							var css = cssProperties.replace( '$color', color );
+							var replace = [ [ uiColorRegexp, color ] ];
 							editor.uiColor = color;
 
-							if ( CKEDITOR.env.ie )
-								uiStyle.$.styleSheet.cssText = cssSelectors + '{' + css + '}';
-							else if ( CKEDITOR.env.webkit )
-								uiStyle.$.sheet.addRule( cssSelectors, css );
-							else
-								uiStyle.setHtml( cssSelectors + '{' + css + '}' );
+							// Update general style.
+							updateStylesheets( [ uiStyle ], cssContent, replace );
 
-							menuSetUiColor( color );
+							// Update menu styles.
+							updateStylesheets( uiColorMenus, uiColorMenuCss, replace );
 						})( color );
 				}
 			});
 
-			// If the "menu" plugin is loaded, register the listeners.
-			if ( CKEDITOR.menu )
+			editor.on( 'menuShow', function( event )
 			{
-				var old = CKEDITOR.menu.prototype.show;
+				var panel = event.data[ 0 ];
+				var iframe = panel.element.getElementsByTag( 'iframe' ).getItem( 0 ).getFrameDocument();
 
-				CKEDITOR.menu.prototype.show = function()
+				// Add stylesheet if missing.
+				if ( !iframe.getById( 'cke_ui_color' ) )
 				{
-					old.apply( this, arguments );
+					var node = addStylesheet( iframe );
+					uiColorMenus.push( node );
 
-					if ( !menuHead && editor == this.editor )
-					{
-						// Save reference.
-						menuHead = this._.element.getDocument().getHead();
-						menuSetUiColor( editor.getUiColor() );
-					}
-				};
-			}
+					var color = editor.getUiColor();
+					// Set uiColor for new menu.
+					if ( color )
+						updateStylesheets( [ node ], uiColorMenuCss, [ [ uiColorRegexp, color ] ] );
+				}
+			});
 
 			// Apply UI color if specified in config.
 			if ( editor.config.uiColor )
 				editor.setUiColor( editor.config.uiColor );
-
-			// Fix editor's width. HPadding and 100% width iframe issue.
-//			if ( CKEDITOR.env.ie && CKEDITOR.env.quirks )
-//			{
-//				editor.on( 'mode', function( event )
-//				{
-//					var container = editor.getResizable();
-//					editor.resize( container.$.offsetWidth-10, container.$.offsetHeight );
-//					event.removeListener();
-//				});
-//			}
-
-//			if ( CKEDITOR.env.ie && ( CKEDITOR.env.quirks || CKEDITOR.env.version < 7 ) )
-//			{
-//				editor.on( 'themeLoaded', function( event )
-//				{
-//					var toolbars = editor.container.getChild( [0, 0, 0, 0, 0, 0, 0] ).getChildren();
-//					for ( var i = 0 ; i < toolbars.count() ; i++ )
-//					{
-//						var toolbar = toolbars.getItem( i );
-
-//						var last = toolbar.getLast();
-//						if ( !last || !last.getPrevious().hasClass( 'cke_rcombo' ) )
-//							continue;
-//
-//						last.addClass( 'cke_toolbar_end_last' );
-//					}
-//				});
-//			}
 		}
 	};
 })() );
Index: CHANGES.html
===================================================================
--- CHANGES.html	(revision 4137)
+++ CHANGES.html	(working copy)
@@ -47,6 +47,7 @@
 		<li><a href="http://dev.fckeditor.net/ticket/3898">#3898</a> : Added validation for URL presentance in Image dialog.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/3528">#3528</a> : Fixed Context Menu issue when triggered using Shift+F10.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/4028">#4028</a> : Maximize control's tool tip was wrong once it is maximized.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/4048">#4048</a> : Context submenu was lacking uiColor.</li>
 	</ul>
 	<h3>
 		CKEditor 3.0</h3>

