   join G.map (g) ->
     if h = scheme[g.t]
       g.c.split(',').map((x) -> rp + ' ' + x).join(',') + '{' +
-        (h.fg && "color:#{h.fg};"             || '') +
-        (h.bg && "background-color:#{h.bg};"  || '') +
-        (h.B  && 'font-weight:bold;'          || '') +
-        (h.I  && 'font-style:italic;'         || '') +
-        (h.U  && 'text-decoration:underline;' || '') +
-        (h.lb && "border-left-color:#{h.lb};" || '') +
+        (h.fg && "color:#{expandColour h.fg};"             || '') +
+        (h.bg && "background-color:#{expandColour h.bg};"  || '') +
+        (h.B  && 'font-weight:bold;'                       || '') +
+        (h.I  && 'font-style:italic;'                      || '') +
+        (h.U  && 'text-decoration:underline;'              || '') +
+        (h.lb && "border-left-color:#{expandColour h.lb};" || '') +
         '}'
     else
       ''
+
+expandColour = (s) ->
+  switch (s || '').length
+    when 6 then '#'+s; when 3 then [r,g,b]=s;'#'+r+r+g+g+b+b; when 1 then '#'+s+s+s+s+s+s; else s
+
+shrinkColour = (s) ->
+  if !/^#.{6}$/.test s then s
+  else [_,r,R,g,G,b,B]=s; if r==R==g==G==b==B then r else if r==R && g==G && b==B then r+g+b else s[1..]
 
 $ updateStyle = -> # update global style from what's in localStorage; do it on "document ready"
   name = prefs.colourScheme()

    $("#col-#{p}").change -> (scheme[sel] ?= {})[p] = @value; updateSampleStyle(); return
    $("#col-#{p}-cb").click ->
      $("#col-#{p}").toggle @checked
      h = scheme[sel] ?= {}; if @checked then h[p] = $("#col-#{p}").val() else delete h[p]
      updateSampleStyle(); return
    return
  qw('B I U').forEach (p) ->

selectGroup = (t, forceRefresh) ->
  if sel != t || forceRefresh
    i = H[t]; h = scheme[t] || {}; $('#col-group').val i
    qw('fg bg lb').forEach (p) ->
      $("#col-#{p}-cb").prop 'checked', !!h[p]; $("#col-#{p}").val(expandColour h[p]).toggle !!h[p]; return
    qw('B I U').forEach (p) -> $("#col-#{p}").prop 'checked', !!h[p]; return
    c = (G[i] || G[0]).controls || {}
    $('#col-fg-p' ).toggle !!(c.fg ? 1)
