diff --git a/csscompressor/__init__.py b/csscompressor/__init__.py
index e1ae16b..e34af04 100644
--- a/csscompressor/__init__.py
+++ b/csscompressor/__init__.py
@@ -113,6 +113,7 @@ def _preserve_call_tokens(css, regexp, preserved_tokens, remove_ws=False):
     max_idx = len(css) - 1
     append_idx = 0
     sb = []
+    nest_term = None
 
     for match in regexp.finditer(css):
         name = match.group(1)
@@ -121,17 +122,29 @@ def _preserve_call_tokens(css, regexp, preserved_tokens, remove_ws=False):
         term = match.group(2) if match.lastindex > 1 else None
         if not term:
             term = ')'
+            nest_term = '('
 
         found_term = False
         end_idx = match.end(0) - 1
+        nest_idx = end_idx if nest_term else 0
+        nested = False
         while not found_term and (end_idx + 1) <= max_idx:
+            if nest_term:
+                nest_idx = css.find(nest_term, nest_idx + 1)
             end_idx = css.find(term, end_idx + 1)
 
             if end_idx > 0:
+                if nest_idx > 0 and nest_idx < end_idx and \
+                                css[nest_idx - 1] != '\\':
+                    nested = True
+
                 if css[end_idx - 1] != '\\':
-                    found_term = True
-                    if term != ')':
-                        end_idx = css.find(')', end_idx)
+                    if nested:
+                        nested = False
+                    else:
+                        found_term = True
+                        if term != ')':
+                            end_idx = css.find(')', end_idx)
             else:
                 raise ValueError('malformed css')
 
@@ -139,7 +152,7 @@ def _preserve_call_tokens(css, regexp, preserved_tokens, remove_ws=False):
 
         assert found_term
 
-        token = css[start_idx:end_idx]
+        token = css[start_idx:end_idx].strip()
 
         if remove_ws:
             token = _ws_re.sub('', token)

Major breakage when using some calc statements
I noticed csscompressor completely breaks some css rules with + in them. For example:

`>>> csscompressor.compress("calc( (10vh - 100px) + 30px )");
'calc( (10vh - 100px)+30px)'

> > > csscompressor.compress("calc( (10vh - 100px) / 4 + 30px )");
> > > 'calc( (10vh - 100px) / 4+30px)'
> > > `

The + and - operators must always be surrounded by whitespace, according to the [spec](https://developer.mozilla.org/en-US/docs/Web/CSS/calc), and when compressed, this rule is now broken and doesn't work in the browser.

Considering calc should be well-supported by just about every browser updated in the last 4 years, calc is super handy... but unfortunately breaks if you decide to compress with csscompress.

diff --git a/csscompressor/tests/test_compress.py b/csscompressor/tests/test_compress.py
index 8d11e01..e65768a 100644
--- a/csscompressor/tests/test_compress.py
+++ b/csscompressor/tests/test_compress.py
@@ -52,3 +52,16 @@ class Tests(unittest.TestCase):
             a {content: calc(10px-10%}
         '''
         self.assertRaises(ValueError, compress, input)
+
+    def test_nested_1(self):
+        input = '''
+            a { width: calc( (10vh - 100px) / 4 + 30px ) }
+        '''
+        output = compress(input)
+        assert output == "a{width:calc((10vh - 100px) / 4 + 30px)}"
+
+    def test_nested_2(self):
+        input = '''
+            a { width: calc( ((10vh - 100px) / 4 + 30px ) }
+        '''
+        self.assertRaises(ValueError, compress, input)

pip install -e .
parse_log_pytest
pytest
pytest
3.5
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
certifi==2021.5.30
-e git+https://github.com/sprymix/csscompressor.git@bec3e582cb5ab7182a0ca08ba381e491b94ed10c#egg=csscompressor
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1631916693255/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: csscompressor
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib-metadata=4.8.1=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
prefix: /opt/conda/envs/csscompressor

csscompressor/tests/test_compress.py::Tests::test_nested_1 csscompressor/tests/test_compress.py::Tests::test_nested_2
csscompressor/tests/test_compress.py::Tests::test_compress_1 csscompressor/tests/test_compress.py::Tests::test_compress_2 csscompressor/tests/test_compress.py::Tests::test_linelen_1 csscompressor/tests/test_compress.py::Tests::test_linelen_2 csscompressor/tests/test_compress.py::Tests::test_linelen_3
csscompressor/__init__.py
csscompressor/__init__.py