Nanoscale morphology tailoring in plasma deposited CN x layers

Magnetron discharge plasma was applied for the synthesis of CN x thin layers using methane and nitrogen gas precursors. The incorporation of nitrogen in the carbon network resulted in the dramatic evolution of growth morphology: from a ‘buried’ porous layer observed at low nitrogen incorporation to aligned bundles of nanorods grown perpendicular to the substrate surface at maximum discharge power and nitrogen flow. The films deposited at the low discharge power and high nitrogen incorporation exhibited a mesoporous sponge-like morphology after vacuum annealing. Relevant physical mechanisms responsible for the formation of nano- and mesoshaped morphology are discussed in terms of the effects of internal mechanical stresses and plasma etching. In addition, the sensing properties of the sponge-like layer were preliminarily examined in water vapor and ammonia ambients. The CN x films showed enhanced sensitivity to ammonia and reverse electrical response to moisture in comparison with a nitrogen-free nanoporous carbon film, which were assigned to modification of the electronic properties of the nitridated surface.

(Some figures may appear in colour only in the online journal) * Author to whom any correspondence should be addressed.
Original content from this work may be used under the terms of the Creative Commons Attribution 4.0 licence. Any further distribution of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.

Introduction
Nanoporous materials attract tremendous scientific and technological interest due to their broad applicability, particularly in addressing environmental issues, including reduction of energy consumption, waste utilization, water purification, and health protection. A special and significant segment of the huge family of porous materials is occupied by carbonaceous porous materials with their versatile implementations [1][2][3][4]. Porous carbon in the form of thin layers/films on proper substrates is of particular interest (reviewed in [4,5]). Plasma deposition methods of amorphous carbon thin films are among the well-developed technologies, including plasma-enhanced chemical vapor deposition, magnetron sputtering, laser ablation, and vacuum arc deposition. A great advantage of plasma deposition methods is the compatibility with semiconductor device processing, which is a critical issue for the fabrication of microsensors and microdetectors. However, plasma deposition methods, well-developed for the deposition of hard and dense 'diamond-like' amorphous carbon films, are rarely used for the deposition of low-density porous carbon films because of some principal physical restrictions. In common plasma processes, the carbon layer is formed by highly energetic particles under intense ultraviolet (UV) radiation of a plasma. Such 'energetic' growth conditions enhance surface and subsurface particle kinetics that favor the formation of amorphous but dense structures that are commonly under compressive stress. On the contrary, the growth of a low-density porous carbon network needs low kinetic energy of the deposited particles, which is not easy to implement in a highly non-equilibrium plasma deposition process. Recently, a novel approach for plasma deposition of low-density nanoporous amorphous carbon films from methane and acetylene gas precursors was suggested [6,7]. The method uses a radio frequency planar magnetron system in chemical vapor deposition mode and therefore was called 'magnetron plasma enhanced chemical vapor deposition' (MPECVD). Low discharge power and high working pressure provide stable low-density plasma near the substrateanode and eliminate the flux of energetic particles that are localized near the cathode surface. It was demonstrated that such deposition conditions enable the growth of carbon films with nanoscale porosity up to 60% [6] and with good sensing properties [7].
In the present work, the MPECVD method was applied for the deposition of nitridated amorphous carbon films. Nitrogen in small concentrations is commonly used to modify the electronic properties of carbon nanomaterials such as nanotubes, graphene, or graphene oxide [8,9]. However, at large concentrations, nitrogen has to be considered as a component of the carbon-nitrogen compound. Porous carbon-nitrogen compounds, both in the form of stochiometric carbon nitride and nonstoichiometric CN x amorphous alloys compose a large subdomain of the family of porous carbonaceous materials [10,11]. It was found unexpectedly that the incorporation of nitrogen during the MPECVD process has a dramatic structuring effect on the nanoscale morphology shaping. The effect of growth conditions on nanoscale morphological evolution in low-density CN x is under focus in the present research.

Methods
Deposition of amorphous CN x films was performed using a typical radio frequency (13.56 MHz) planar magnetron sputtering system with a cathode diameter of 160 mm. The deposition process was similar to that described elsewhere [6]; however, a methane/nitrogen mixture was used as the working gas. The base pressure and working pressure in the chamber were 10 −4 Pa and 1.0 Pa respectively. Silicon wafers and silicon wafers with thermally grown silicon oxide layer (200 nm thickness) were used as substrates at a deposition temperature of approximately 300 • C. The discharge power and working gas composition were varied as shown in table 1. The deposition time was fixed at about 45 min. After deposition, some of the samples were annealed at 750 • C for 15 min. The annealing was performed in a vacuum of 10 −4 Pa to avoid uncontrollable oxidation effects.
The surface and cross-section morphology of the samples was examined by scanning electron microscopy (SEM) using a field-emission Tescan Lyra3 scanning electron microscope (Tescan Orsay Holding). Surface topology was also controlled by atomic force microscopy (AFM) with NanoScope IIIa Dimension 3000 instrument. Investigation of interatomic bonds was performed by attenuated total reflection (ATR) Fourier-transform infrared spectroscopy (Bruker INVENIO-S) and Raman scattering (RS) spectroscopy (Horiba Jobin Yvon HR800). RS spectra were measured using a 325 nm UV laser for excitation. Excitation by lasers with longer wavelengths resulted in the appearance of a strong photoluminescence background making it impossible to detect the RS signal.
The chemical composition was examined by x-ray photoelectron spectroscopy (XPS) using an ESCALAB 250Xi x-ray Photoelectron Spectrometer Microprobe (Thermo Scientific) equipped with a monochromatic Al Kα (hν = 1486.68 eV) x-ray source. A pass energy of 200 eV was used for survey spectra and 20 eV for high-resolution core-level spectra (providing a spectral resolution of 0.5 eV). The linearity of the energy scale was calibrated by the positions of the Fermi edge at 0.00 ± 0.05 eV, Au4f7/2 at 83.95 eV, Ag3d5/2 at 368.20 eV, and Cu2p3/2 at 932.60 eV measured on in situ cleaned metal surfaces. To prevent charging, the samples were measured using a built-in charge compensation system. The chemical composition of selected samples was calculated by the Avantage Data System (Thermo Scientific) software based on the integral intensity of the peaks and incorporated sensitivity factors. This measurements showed monotonic increase of the nitrogen content in the films with increase of nitrogen flow rate at fixed discharge power (table S1).
X-ray reflectivity (XRR) was used to measure the density of the carbon films with PANalyticalX'Pert Pro MRD XL diffractometer using CuKα1 radiation (0.15405 nm). The sheet resistance and electrical response to the chemical environment were examined using a semiconductor parameter analyzer Agilent 4156C (USA). The influence of ammonia and water vapor (relative humidity) was investigated by pumping the air through the bubbler at room temperature (20 • C) and atmospheric pressure. The ammonia concentration and relative humidity were controlled using FECS44-100 (Figaro USA Inc.) and HIH-4000-003 (Honeywell Inc.) sensors correspondingly. Table 1 shows the sample labels, corresponding deposition parameters, and thicknesses measured by SEM. For further discussions, it is important to note the following effect of the deposition parameters on the thickness of the films. Firstly, the gradual and significant decrease in deposition rate was observed with the increase of nitrogen flow (samples ##1-4). The reduction of deposition rate can be attributed to the decrease of the partial pressure of the carbon precursor, i.e. methane. Secondly, a significant reduction in deposition rate with the increase of discharge power (samples ##4-6). The former observation seemingly has no obvious explanation, because the increase of discharge power should result in the increase of dissociation rate of molecular species and consequently to the increase of deposition rate. This 'untypical' effect will be discussed later as evidence of plasma etching during the MPECVD process.

Results
The surface and bulk morphology of the carbon film (a-C:H, sample #1), deposited in pure methane at a discharge power of 146 W, did not show any specific topological features in the SEM images: the surface and cross-section of the film were smooth and uniform (figures S1(a) and (b)). However, examination of the surface by AFM revealed fine granular morphology with lateral size of the granules of about 20-30 nm (figure S1(c)). SEM and AFM did not reveal noticeable changes in the morphology of the surface and crosssection of the a-C:H film after vacuum annealing. Figures 1 and 2 illustrate the effect of nitrogen flow rate and discharge power on the growth morphology of as-deposited CN x films. The addition of nitrogen to the deposition process resulted in a crucial morphological evolution. At the smallest nitrogen flow rate the film surface remained smooth, while clear evidence of a buried porous layer was observed on the CN x /Si interface (figures 1(a) and (b)). The thickness of the buried layer increased with increasing nitrogen flow, while the surface was still smooth (figures 1(c) and (d)). Finally, at the maximum nitrogen flow rate, the porous layer propagated through the whole film, and the surface morphology became fragmented (figure 1(e)).
The effect of the discharge power was examined for the series of CN x samples, deposited using a maximum nitrogen flow rate (table 1). The surface morphology of the film became more fragmented with increasing discharge power (figures 2(a), (c) and (e)). At maximal discharge power, the deposited layers grew in the form of bundles of vertically aligned nanorods with a diameter of about 50 nm (figure 3).
The effect of the vacuum annealing on the surface morphology is illustrated in figures 2(b), (d) and (f)). The main effect of annealing is the increase in the fragmentation of the film. The more fragmented surface in as-deposited films, the less additional fragmentation was observed after annealing. A specific morphology evolution was observed in the sample deposited at the lowest discharge power and highest nitrogen incorporation: the partially discontinuous as-deposited film was converted into a sponge-like porous structure after annealing (figure 2(b)). Thermally-induced fragmentation can be attributed to the cracking of the upper layer due to a mismatch of the thermal expansion coefficient of the film and substrate and/or to the shrinkage of the material due to thermally induced structural reconstruction. It is worth noting that the cracking of thin films is commonly inherent to the relaxation of tensile mechanical stress.
The more fragmented as-deposited films, the less strained and more relaxed the structure, and consequently less additional fragmentation takes place during annealing. The completely fragmented film deposited at the highest discharge power and highest nitrogen flow exhibited minor fragmentation of the bundles of the rods after annealing (figures 2(e) and (f)), The local structure of the amorphous carbon network in CN x films was characterized by UV-excited RS. RS spectra of as-deposited films are typical for amorphous carbon and are represented by the characteristic paramount features with well-defined D-and G-bands centered at about 1380 cm −1 and 1600 cm −1 correspondingly (figure 4(a)). D-and Gbands gradually broadened and shifted to lower frequency with increasing nitrogen flow rate. Such spectral evolution, accompanied by a decrease in the integral intensity of the RS signal, indicates structural disordering and a decrease in the size of carbon graphite-like domains caused by nitrogen incorporation.
The evolution of interatomic bonds with nitrogen incorporation was also examined by ATR spectroscopy (figure 4(b)). A nitrogen-free a-C:H thin film was measured as a reference (figure 4(b), spectrum 1). The ATR spectrum of a-C:H film is typical for hydrogenated amorphous carbon representing residual oxygen in the form of hydroxyl and carboxyl groups, as well as carbon-hydrogen bonds: the 1630 cm −1 and 1702 cm −1 overlapped peaks are due to O-H bending and C=O stretching vibration modes; the multicomponent band at 2800-3000 cm −1 is due to C-H stretching vibrations; and the broad band at 3000-3500 cm −1 is due to O-H stretching vibrations.   It was reported earlier that the incorporation of nitrogen in the sp 2 -bonded carbon network results in the redistribution of the electrical charge-inducing activity of originally infrared inactive C=C bonds [12]. Therefore, some contribution of conjugated carbon in IR absorption in the range of 1000-1600 cm −1 cannot be excluded.
It is important to note that C=O and C-H-related absorption bands disappeared with the increase of nitrogen incorporation. These bonds are commonly formed at the surface sites and/or associated with micro-and nano-scale pores, voids, and defects. Hence, it can be concluded that the incorporation of nitrogen resulted in the replacement of oxygenated and hydrogenated carbon atoms with surface nitrogen.
In summary, the major effects of nitrogen incorporation can be identified as follows: (a) increase of structural disorder in the carbon network, and (b) replacement of C-H and C=O surface bonds with N-H, C=N, and C≡N bonds. The presence of nitrogen atoms in trigonal coordination in the bulk of the carbon network through carbon substitution is questionable but quite realistic.
The effect of the discharge power was examined for the series of the thin film deposited at a maximum nitrogen flow rate (##4, 5, 6 see table 1). The Raman spectra of as-deposited films are presented in figure 5(a). The spectral position, width, and relative intensity of D-and G-bands are quite similar in all spectra indicating a minor effect of discharge power on the local structure of the C=C bonded carbon network. Vacuum annealing resulted in narrowing and high-frequency shift of the D-and G-bands in all samples, indicating thermally activated 'graphitization', i.e. enhancement of graphite-like structural order ( figure 5(b)).
The ATR spectra of the samples deposited at different discharge powers are also similar ( figure 6(a)). The only noticeable effect of the variation of the discharge power is the increase of the relative intensity of the 1635 cm −1 band with increasing discharge power. This band is mainly contributed by C=N-C bonds, i.e. nitrogen atoms in a pyridine-like structure. Nitrogen incorporation in the carbon network through a pyridine-like bond terminates the planar growth of a graphenelike cluster so that the increase in relative intensity of this band is related to the increase of the contribution of the nitrogen atoms terminated carbon network, for example, inner/outer surface of the pores, voids, and grains. Such interpretation is in good agreement with the increase of the film fragmentation with increasing discharge power (figure 2).
Due to our evaluation, the most intriguing morphological evolution was observed as the formation of vertically aligned nanorods in as-deposited layers (figures 2(c) and (f)), and sponge-like structure in the annealed samples ( figure 2(b)) caused by high nitrogen incorporation. For a better understanding of the chemical structure of nanoshaped materials, these samples were additionally examined by XPS after vacuum annealing. Nitrogen-free a-C:H film was also examined after annealing as a nanoporous carbon reference. The survey spectra and C1s core level spectra of annealed samples are presented in figure 7. No residual nitrogen was observed in the nitrogen-free a-C:H reference, while about 33 at.% was found in the sample deposited at low discharge power and about 20 at.% was detected in the sample deposited at high discharge power ( figure 7(a)). Taking into consideration carbon and nitrogen the composition of the films can be represented as CN 0.32 in sample #6 and CN 0.59 in sample #5. The decrease in nitrogen incorporation accompanied by the decrease in deposition rate at increased discharge power (table 1) seems quite surprising at the first glance and this important observation will be discussed in the next section. C 1s and N 1s peaks were fitted by components with Gaussian contour. Baseline corrections were made using a Shirley-type background. Spectral details of the fitting procedure can be found in table S2. A deconvolution of the C 1s core level spectra was performed with four peaks: A (283.9 eV, sp 2 C=C), B (284.8 eV, sp 3 C-C), C (286.5 eV, sp 2 C-N) and D (288 eV, C = N/ C≡N/C=O) [16]. Even though the deconvolution of the broad XPS peak into 4 components can hardly be performed unambiguously, several important features can be derived with a high degree of reliability. The first point, generally, demonstrates that carbon atoms in the annealed nitrogen-free sample are mainly sp 2 -coordinated with a minor contribution from sp 3 -bonded carbon atoms and even less contribution from polar bonds originating most likely from residual oxygen in form of carbonyl and hydroxyl groups ( figure 7(b)).
Secondly, the incorporation of nitrogen results in the formation of CN bonds at the expense of CC bonds. This confirms the ATR data presented in the previous section. Thirdly, the relative contribution of peak A in comparison with peak B, i.e. the sp 2 /sp 3 ratio of carbon-carbon bonds, is strongly decreased in CN x films in comparison with the nitrogen-free sample (figures 7(d) and (f)). As the C1s peak of the CN x sample is mainly determined by the B peak attributed to sp 3 -C bonds, it can be assumed that the nitridation stimulates fourfold coordination instead of a graphite-like structure. Fourthly, a significant contribution of C-N single bonds can be identified (component C), which is dominant in the sample deposited at lower discharge power (figure 7(f)) while component D is dominant in the sample deposited at the highest discharge power ( figure 7(d)). The most general suggestion that comes from the analysis of C 1s peak is the domination of sp 3 -coordinated carbon atoms even in thermally annealed CN x material. N1s peaks were also examined (figure 7(c) and (e)). The N1s peak of the sponge-like film is quite homogeneous and can be assigned to overlapping peaks that are originated from pyridinic, aminic and nitrile groups (figure 7(e)). Relative chemical shifts of corresponding individual N1s peaks are small so that they can be simulated as one peak [16]. The N1s peak of the film with nanorod morphology is significantly broader with a stronger contribution at the high energy (figure 7(e)). Such spectral feature can be interpreted as an enhanced contribution of nitrogen atoms in conjugated pyrrole-like sites, i.e. five-membered aromatic rings [16][17][18].

Gas sensing properties of annealed films
As shown in the previous section, the morphology of the sample deposited at minimal discharge power (96 W) and maximum nitrogen flow (N 2 /CH 4 ratio 15/4) after thermal annealing transformed into a specific sponge-like structure ( figure 2(b)). Materials with such a porous morphology are attractive to be examined as a gas sensor providing sufficient electrical conductivity. The integrated density of the nitrogenfree a-C:H reference and CN x films before and after annealing was analyzed by XRR. A brief description of the method is given in the supplementary information file (figure S2 and comments to them) and calculated densities are represented in table S3. The incorporation of nitrogen leads to a minor reduction of the density of the film from 1.45 g cm −3 in a-C:H film to 1.40 g cm −3 in CN x , while annealing of CN x films exhibited a strong reduction of the density down to 0.65 g cm −3 that is in good agreement with the morphological transformation i.e. the formation of the sponge-like network (illustrated in figure 2(a)  and (b)). The opposite annealing effect was observed in the nitrogen-free a-C:H film, which was densified after annealing.
The Raman spectra of the films before and after annealing (figure S3) show narrowing and high-frequency shift of the D-and G-bands, indicating that a typical thermally induced 'graphitization' of the amorphous carbon structure took place. The structure of a-C seems more 'graphitized' because the corresponding Raman bands are significantly narrower.
Electrically conducting Ni contacts were deposited on the top of the annealed carbon layers being deposited on a silicon wafer with a thick silicon oxide layer. The electrical response was evaluated from the electrical resistivity of the layer in the ambient of water vapor or ammonia. The layers of nanorods did not exhibit electrical conductivity even after annealing, because of their discontinuous morphology and appeared to be not appropriate for such experiments.
Both CN x and a-C:H films were electrically insulating after deposition with specific resistivities above 10 12 Ohm cm. The electrical conductivity was strongly increased after vacuum annealing at 750 • C in both samples. The measurement using the four-probe technique revealed that the sheet resistance of the annealed CN x film was ten times higher than that of annealed a-C:H film (10 4 and 10 3 Ohm (□) −1 respectively). The sweep measurements of the current-voltage characteristics in a voltage range from −3 to 3 V for both samples revealed linear behavior (figure 8). Because of the mesoporous morphology of annealed CN x film, it is not possible to evaluate and compare the specific resistivity of the material. The higher resistivity of CN x film can be assigned both to discontinuous sponge-like morphology with limited charge flow channels as well as to reduced content of electrically conductive graphitic carbon, which was demonstrated by XPS in the previous section (figure 7).
Experiments with CN x and a-C:H samples were performed in one experimental run. Both samples exhibited an electrical response to the analytes; however, the character of the response was different (figures 9(a) and (b)). The major features of the electrical response can be specified as follows: (a) the CN x film was significantly more sensitive to ammonia in comparison to the a-C:H film, (b) the samples exhibited an opposite response to water vapor: the resistivity of CN x film increased under water adsorption, while the resistivity of the a-C:H film decreased.
The increase of the resistance of the sample during ammonia adsorption was reported earlier for nanoporous a-C:H films [6,7], and could be explained by a hole-depletion process [19,20]. Adsorbed ammonia molecule donates an electron to the p-type film inducing a decrease of charge carriers. Higher sensitivity and faster response in the CN x sample are probably related to the high contribution of surface pyridine groups which have localized electrons at the nitrogen atoms and bring defects into the carbon lattice creating additional holes [21,22].
It was already shown that adsorbed moisture reduces the electrical resistivity of the porous carbon film, apparently due to the dissociation of water molecules at the porous surface, which results in the enhancement of ionic conductivity [6,7]. The opposite response of nitrated carbon is probably related to the hydrophilic nature of nitrated carbon and/or to enhanced  defects in the CN x structure. Pure carbon is well known as a hydrophobic material and adsorbed water layer is localized on the carbon surface. Chemical hydrophilicity and structural defects in the nitrated carbon material enhance penetration of water molecules deeper under the surface layers, increasing the electrical resistance through reversible band gap transition of the graphene-like material with respect to the humidity level [23,24] or by penetration into the space between the graphenelike layers and weakening of the electrical transport between the layers [25,26].
For consistency, it is worth pointing out the small signal decrease detected in the a-C:H sample on the front edge of each NH 3 exposure cycle ( figure 9(a)). These features are not well reproducible for different CN x samples and the nature of this phenomenon is not clear. However, it can be noted that the response dynamics of this temporary drop in resistivity is similar to the response to water vapor ( figure 9(b)). It can thus be suggested that this phenomenon is associated with surface chemical reactions, for example, the oxidation of NH 3 molecules by surface hydroxyl groups resulting in the formation of nitrogen and additional water molecules. Water molecules can then participate in the surface conductivity decrease until they evaporated. The concentration of hydroxyls varies from sample to sample and depends on the sample storage and pretreatment history, therefore this feature is not well reproducible from sample to sample.
Sensitivity and response time of CN x sample to ammonia were evaluated using calibrated commercial sensor installed inside experimental cell as reference. The typical curve of the CN x response and the corresponding response of the reference sensor within the same cycle are illustrated in figure S4. The CN x film shows a good sensitivity, however, the response is significantly slower than that of the reference sensor except for the first 20-30 s of the cycle. However, the former effect is because the distance from the inlet to CN x sample is smaller than the distance to the reference sensor.

Discussion
Carbon-nitrogen solid-state compounds can be specified into two large groups: stoichiometric and nonstoichiometric. Polymeric graphitic carbon nitride (g-C 3 N 4 ) with a layered structure, and inorganic α-and β-C 3 N 4 ceramics belong to stochiometric materials. Graphitic carbon nitride has attracted extensive research attention because of its virtues of a metalfree nature, feasible synthesis, and excellent photocatalytic properties [11,27,28]. C 3 N 4 ceramics is a more exotic material and was predicted theoretically in the form of a β-C 3 N 4 structure that is harder than diamond [29]. This material has been successfully synthesized in the form of nanoparticles; however, technologies for bulk crystal growth or thin film deposition have not been developed.
In amorphous nonstoichiometric CN x materials with an elemental composition x of less than 1.0, nitrogen atoms are either substituted for carbon atoms or attached as nitrogencontaining functional groups [10]. The development of plasma deposition methods of CN x thin films was mainly focused on the enhancement of the mechanical properties of protective hard coatings [30], while the soft/porous materials were basically out of the research focus. However, the analysis of the published reports on the growth morphology of CN xrelated materials revealed that the formation of morphological nanoshapes in the form of spheres, columns, nanotubes, nanorods, wires, 'onions', 'flowers', etc is more an intrinsic property of this materials than an exotic behavior in particular growth process [31][32][33][34][35]. The main question that has arisen concerns the nature and driving force for the formation of nanoshaped structural features at relatively low temperatures i.e. at a limited diffusion rate and without a catalyst. A lack of experimental data and of corresponding theoretical simulations from previous research do not allow us to readily address this question. However, some general considerations follow.
We suggest that one of the possible driving forces for the formation of nanoshaped CN x morphologies is related to tensile strains caused by the incorporation of nitrogen in the carbon structural network, followed by stress relaxation through morphological reconstruction during the deposition process and post-deposition annealing. It was widely demonstrated that the incorporation of nitrogen in amorphous carbon films during plasma deposition causes a significant reduction of the film density and compressive stress [36][37][38]; however, the physical and chemical mechanisms of such relaxation have not been fully identified. One of the most realistic hypotheses is a shortening of the interatomic bond length caused by the substitution of carbon by nitrogen in amorphous carbon. Carbon-nitrogen single and double bonds having an ionic contribution are a little shorter than the corresponding carbon-carbon bonds, therefore the shortening of the average interatomic distance relaxes the local compressive strains and integral compressive stresses. As explained earlier, our deposition method provides growth of the films free of the bombardment by energetic particles and, as a result, free of compressive stresses. Hence, the incorporation of nitrogen would presumably develop local tensile strains. The presence of tensile stresses is in good agreement with the fragmentation of the as-deposited films. The thermal annealing process stimulates the relaxation of tensile stress that takes place via the shrinkage of the material and commonly results in cracking and further fragmentation of the film (figure 2).
Another mechanism that can be considered particularly in our MPECVD process is a competition between plasmaenhanced deposition and plasma-enhanced etching. Hydrogen/nitrogen plasma is known for a long time as an effective etchant for carbon, both organic and inorganic [39,40]. Plasma etching of carbon surface can be assumed by atomic hydrogen and atomic nitrogen through the formation of volatile HCN byproduct: C(s) + H•↑ + N•↑ → HCN↑, CN(s) + H•↑ → HCN↑. The reactions are expected to be enhanced by the flux of electrons and UVradiation from plasma. Apparently, the dissociation of methane molecules is a source of atomic hydrogen in the MPECVD process. The concentration of atomic hydrogen and nitrogen as well as the intensity of UV radiation and electron flux are correlated with discharge power. Hence, the formation of CN x nanorods at maximum discharge power can be caused by the enhanced plasma etching as well ( figure 2).
The decrease of deposition rate with the increase of discharge power (table 1) approves the importance of the plasma etching effect. From the 'classical' viewpoint the increase of discharge power in the PECVD process increases plasma enhanced decomposition rate of molecular precursors thus increasing the deposition rate. However, we observed the opposite, which can be explained by the domination of the etching process over deposition at increasing discharge power. The plasma etching effect was indirectly confirmed also by reduced fragmentation of CN x films deposited on the SiO 2 surface in comparison to that deposited on the Si wafer ( figure  S5). Presumably, this effect may be assigned to negative electrical charge accumulated from plasma on the nonconductive SiO 2 surface ('floating potential'). Negative electrical potential reduces electron flux on the substrate surface by electrostatic repulsion, thus reducing the surface chemical reaction rate.
The effect of electrically insulating substrate gives an idea for an explanation of the formation of the 'buried' porous layer at low nitrogen flow (figure 1). As it is mentioned in the manuscript the as-deposited CN x film has high electrical resistance. Therefore, it is reasonable to suggest that trapped negative charge on the surface of the growing CN x film is increased with the increase of the film thickness because of increase of integral resistance. Corresponding reduction of plasma etching rate resulted in the gradual transformation of porous morphology into denser one.
In the frame of this hypothesis, the increased contribution of pyrrolic sites in nanorods can be explained by the chemical stability of this atomic configuration associated with enhanced stability of aromatic configuration of electron shell in fivemembered rings [41]. Consequently, the growth of the layer occurs in such a manner that the walls of the nanorods are covered by the most chemically stable structural sites. Chemically less stable nitrogen sites are etched off at high discharge power thus explaining the reduced nitrogen incorporation revealed by XPS ( figure 7) and reduced deposition rate. Reduction of nitrogen incorporation with increase of discharge power (sample #5 v.s. #6) is also believed to be caused by enhanced plasma etching effect, however detailed mechanism is not clear at the moment and needs further experiments.
The interplay of the relaxation of tensile stresses and plasma-chemical etching is thus suggested to determine the growth morphology of as-deposited films, while the transformation of the morphology during thermal annealing is caused solely by the relaxation of tensile stresses.

Conclusion
A modified magnetron plasma-enhanced chemical vapor deposition method was applied for the deposition of lowdensity CN x thin layers using methane and nitrogen gas precursors. The strong effect of nitrogen incorporation on the evolution of nanoscale morphology of as-deposited and annealed CN x layers was found. Low incorporation of nitrogen resulted in the formation of a 'buried' porous layer at the CN x film/substrate interface, while a specific morphology of vertically aligned nanorods was observed at maximal nitrogen incorporation and maximal discharge power. Another specific morphological effect was the transformation of the asdeposited CN x layer into sponge-like porous morphology by vacuum thermal annealing. It is suggested that the mechanism of the formation of the specific morphology is driven by the generation/relaxation of internal mechanical stresses and/or by the effect of plasma etching during the deposition process.
Gas sensing properties of the sponge-like CN x layer was examined in comparison with the nitrogen-free nanoporous carbon layer by analyzing the electrical resistivity response in water vapor or ammonia ambient. This investigation demonstrated improved sensitivity of the CN x layer to ammonia and opposite electrical response to the moisture in comparison with the pure carbon film. Reverse electrical response to the moisture was ascribed to the hydrophilic nature of the CN x layer and the specific electronic properties of the nitridated carbon surface.

Data availability statement
All data that support the findings of this study are included within the article (and any supplementary files).