diff --git less.module less.module
index 296b551..c8c3818 100644
--- less.module
+++ less.module
@@ -5,6 +5,8 @@
  * Builds the less cache
  */
 function _less_build(&$vars, $hook) {
+  global $theme_key;
+  $themes = _system_theme_data();
   
   $css = $vars['css'];
   
@@ -36,7 +38,17 @@ function _less_build(&$vars, $hook) {
             
             $less = new lessc();
             
-            $contents = drupal_load_stylesheet($input_file, false);
+            // Pre-process the LESS to transform 'base-theme-url()' declarations
+            $contents = file_get_contents($input_file);
+            if ($type == 'theme' && $themes[$theme_key]->info['base theme']) {
+              $base = drupal_get_path('theme', $themes[$theme_key]->info['base theme']) .'/';
+              _drupal_build_css_path(NULL, $base);
+              // Prefix all base-theme-url() paths within this LESS file.
+              $data = preg_replace_callback('/base-theme-url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_drupal_build_css_path', $contents);
+            }
+
+            // Now load the stylesheet and resolve @imports as usual.
+            $contents = less_load_stylesheet($data);
             
             $base = base_path() . dirname($input_file) .'/';
             _drupal_build_css_path(NULL, $base);
@@ -80,6 +92,20 @@ function _less_build(&$vars, $hook) {
 }
 
 /**
+ * A stripped-down version of drupal_load_stylesheet() that takes
+ * stylesheet contents rather than a stylesheet file name.
+ */
+function less_load_stylesheet($contents) {
+  // Replaces @import commands with the actual stylesheet content.
+  // This happens recursively but omits external files.
+  $contents = preg_replace_callback('/@import\s*(?:url\()?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\)?;/', '_drupal_load_stylesheet', $contents);
+  // Remove multiple charset declarations for standards compliance (and fixing Safari problems).
+  $contents = preg_replace('/^@charset\s+[\'"](\S*)\b[\'"];/i', '', $contents);
+
+  return $contents;
+}
+
+/**
  * Implements MODULE_preprocess_page().
  */
 function less_preprocess_page(&$vars, $hook) {
