{ config, pkgs, ... }: {
  home.packages = with pkgs; [
    gruvbox-gtk-theme
    gruvbox-plus-icons
  ];

  gtk = {
    enable = true;
    theme = {
      name = "Gruvbox-Dark";
      package = pkgs.gruvbox-gtk-theme;
    };
    iconTheme = {
      name = "Gruvbox-Plus-Dark";
      package = pkgs.gruvbox-plus-icons;
    };
    gtk4.theme = config.gtk.theme;
  };

  qt = {
    enable = true;
    # KDE platform theme: reads kdeglobals for colors, handles KDE app integration.
    # qtct has a known bug where qt6ct can't access Kvantum, making it wrong for Dolphin.
    platformTheme.name = "kde";
    # QT_STYLE_OVERRIDE=kvantum is set automatically by home-manager.
    # Uses qt6Packages.qtstyleplugin-kvantum + libsForQt5.qtstyleplugin-kvantum.
    style.name = "kvantum";
  };

  # Kvantum themes must live in ~/.config/Kvantum/ (capital K, capital V).
  # The nix user-environment strips share/Kvantum from the profile merge, so the
  # package alone is not enough — the theme directory must be linked explicitly.
  xdg.configFile."Kvantum/Gruvbox-Dark-Brown".source =
    "${pkgs.gruvbox-kvantum}/share/Kvantum/Gruvbox-Dark-Brown";

  xdg.configFile."Kvantum/kvantum.kvconfig".text = ''
    [General]
    theme=Gruvbox-Dark-Brown
  '';

  # KDE color scheme aligned to gruvbox-gtk-theme's Gruvbox Dark palette so
  # Dolphin and other KDE apps share the same background and accent colors as
  # GTK apps like qalculate-gtk.
  xdg.configFile."kdeglobals".text = ''
    [Colors:Window]
    BackgroundNormal=#282828
    BackgroundAlternate=#32302f
    ForegroundNormal=#ebdbb2
    ForegroundInactive=#a89984
    ForegroundActive=#ebdbb2
    DecorationHover=#7daea3
    DecorationFocus=#7daea3

    [Colors:Button]
    BackgroundNormal=#3c3836
    BackgroundAlternate=#32302f
    ForegroundNormal=#ebdbb2
    ForegroundInactive=#a89984
    DecorationHover=#7daea3
    DecorationFocus=#7daea3

    [Colors:View]
    BackgroundNormal=#1d2021
    BackgroundAlternate=#282828
    ForegroundNormal=#ebdbb2
    ForegroundInactive=#a89984
    ForegroundActive=#7daea3
    ForegroundLink=#83a598
    ForegroundVisited=#b16286
    DecorationHover=#7daea3
    DecorationFocus=#7daea3

    [Colors:Selection]
    BackgroundNormal=#7daea3
    BackgroundAlternate=#689d6a
    ForegroundNormal=#1d2021
    ForegroundInactive=#1d2021

    [Colors:Tooltip]
    BackgroundNormal=#32302f
    ForegroundNormal=#fbf1c7

    [Colors:Complementary]
    BackgroundNormal=#1d2021
    ForegroundNormal=#ebdbb2

    [Icons]
    Theme=Gruvbox-Plus-Dark

    [General]
    ColorScheme=GruvboxDark
    Name=Gruvbox Dark

    [KDE]
    contrast=5
  '';

  home.sessionVariables = {
    SSH_ASKPASS = "${pkgs.kdePackages.ksshaskpass}/bin/ksshaskpass";
    SSH_ASKPASS_REQUIRE = "prefer";
  };
}
