 (unless (>= emacs-major-version 24)
   (error "Requires Emacs 24 or later"))
 
+(defcustom gruvbox-contrast 'medium
+  "Contrast level for the theme background."
+  :options '(soft medium hard))
+
 (deftheme gruvbox "A retro-groove colour theme")
-(let ((gruvbox-dark0_hard  (if (display-graphic-p) "#1d2021" "color-234"))
+(let* ((gruvbox-dark0_hard  (if (display-graphic-p) "#1d2021" "color-234"))
       (gruvbox-dark0       (if (display-graphic-p) "#282828" "color-235"))
       (gruvbox-dark0_soft  (if (display-graphic-p) "#32302f" "color-236"))
       (gruvbox-dark1       (if (display-graphic-p) "#3c3836" "color-237"))

      (gruvbox-lightblue4       (if (display-graphic-p) "#66999D" "LightBlue4"))
      (gruvbox-burlywood4       (if (display-graphic-p) "#BBAA97" "burlywood4"))
      (gruvbox-aquamarine4      (if (display-graphic-p) "#83A598" "aquamarine4"))
      (gruvbox-turquoise4       (if (display-graphic-p) "#61ACBB" "turquoise4")))

  (custom-theme-set-faces
    'gruvbox

    ;; UI
    `(default                           ((t (:background ,gruvbox-dark0 :foreground ,gruvbox-light0))))
    `(cursor                            ((t (:background ,gruvbox-light0))))
    `(mode-line                         ((t (:box nil :background ,gruvbox-dark2 :foreground ,gruvbox-light2))))
    `(mode-line-inactive                ((t (:box nil :background ,gruvbox-dark1 :foreground ,gruvbox-light4))))
    `(fringe                            ((t (:background ,gruvbox-dark0))))
    `(linum                             ((t (:background ,gruvbox-dark0 :foreground ,gruvbox-dark4))))
    `(hl-line                           ((t (:background ,gruvbox-dark1))))
    `(region                            ((t (:background ,gruvbox-dark2)))) ;;selection
    `(secondary-selection               ((t (:background ,gruvbox-dark1))))
    `(minibuffer-prompt                 ((t (:background ,gruvbox-dark0 :foreground ,gruvbox-neutral_green :bold t))))
    `(vertical-border                   ((t (:foreground ,gruvbox-dark2))))

    ;; Built-in syntax

    `(sp-show-pair-mismatch-face        ((t (:background ,gruvbox-neutral_red)))) ;; Highlight for bracket without pair

    ;; elscreen
    `(elscreen-tab-background-face      ((t (:box nil :background ,gruvbox-bg)))) ;; Tab bar, not the tabs
    `(elscreen-tab-control-face         ((t (:box nil :background ,gruvbox-dark2 :foreground ,gruvbox-neutral_red :underline nil)))) ;; The controls
    `(elscreen-tab-current-screen-face  ((t (:box nil :background ,gruvbox-dark4 :foreground ,gruvbox-dark0)))) ;; Current tab
    `(elscreen-tab-other-screen-face    ((t (:box nil :background ,gruvbox-dark2 :foreground ,gruvbox-light4 :underline nil)))) ;; Inactive tab
