diff --git a/inc/html.php b/inc/html.php
index a20ee5c3970cc7e4bf480abec0ee14adc311343f..738b1f1b4b4229bc26c6696e8c96300aa86606e1 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -229,12 +229,12 @@ function html_show($txt=null){
         //PreviewHeader
         echo '<br id="scroll__here" />';
         echo p_locale_xhtml('preview');
-        echo '<div class="preview">';
+        echo '<div class="preview"><div class="pad">';
         $html = html_secedit(p_render('xhtml',p_get_instructions($txt),$info),$secedit);
         if($INFO['prependTOC']) $html = tpl_toc(true).$html;
         echo $html;
         echo '<div class="clearer"></div>';
-        echo '</div>';
+        echo '</div></div>';
 
     }else{
         if ($REV) print p_locale_xhtml('showrev');
diff --git a/lib/tpl/dokuwiki/css/design.css b/lib/tpl/dokuwiki/css/design.css
index 9466481c5f4189fa36d81d87502803e1bf90dd79..d1a00ce0a3743f118fc8a73a509a12fdb7a9b334 100644
--- a/lib/tpl/dokuwiki/css/design.css
+++ b/lib/tpl/dokuwiki/css/design.css
@@ -426,7 +426,17 @@
 
 .dokuwiki div.preview {
     margin: 0 -2em;
-    padding: 1.556em 2em 2em;
+    padding: 0 2em;
+}
+.dokuwiki.hasSidebar div.preview {
+    border-right: __sidebar_width__ solid __background_alt__;
+}
+[dir=rtl] .dokuwiki.hasSidebar div.preview {
+    border-right-width: 0;
+    border-left: __sidebar_width__ solid __background_alt__;
+}
+.dokuwiki div.preview div.pad {
+    padding: 1.556em 0 2em;
 }
 
 
@@ -440,7 +450,7 @@
     color: inherit;
 }
 [dir=rtl] #dw__toc {
-    margin: -2em 1.4em .5em -2em;
+    margin: -1.556em 1.4em .5em -2em;
     border-left-width: 0;
     border-right: 1px solid __border__;
 }
diff --git a/lib/tpl/dokuwiki/css/mobile.css b/lib/tpl/dokuwiki/css/mobile.css
index 4d18113ac6ab5d0c17e0f4590d00f47f2e56df8d..5a72ed095c9ca12382e81c75ee008e0a7807dde6 100644
--- a/lib/tpl/dokuwiki/css/mobile.css
+++ b/lib/tpl/dokuwiki/css/mobile.css
@@ -28,17 +28,17 @@
     margin-bottom: .5em;
 }
 
-.hasSidebar #dokuwiki__content {
+.showSidebar #dokuwiki__content {
     float: none;
     margin-left: 0;
     width: 100%;
 }
-.hasSidebar #dokuwiki__content > .pad {
+.showSidebar #dokuwiki__content > .pad {
     margin-left: 0;
 }
 
-[dir=rtl] .hasSidebar #dokuwiki__content,
-[dir=rtl] .hasSidebar #dokuwiki__content > .pad {
+[dir=rtl] .showSidebar #dokuwiki__content,
+[dir=rtl] .showSidebar #dokuwiki__content > .pad {
     margin-right: 0;
 }
 
diff --git a/lib/tpl/dokuwiki/css/structure.css b/lib/tpl/dokuwiki/css/structure.css
index 5e2eab3bcfaca456cd8eb4148e214581e806823b..00642e90b505b3a73c13008335c88a1c3baffcfc 100644
--- a/lib/tpl/dokuwiki/css/structure.css
+++ b/lib/tpl/dokuwiki/css/structure.css
@@ -56,20 +56,20 @@ body {
         margin: 0 0 0 1.5em;
     }
 
-    .hasSidebar #dokuwiki__content {
+    .showSidebar #dokuwiki__content {
         float: right;
         margin-left: -__sidebar_width__;
         width: 100%;
     }
-    [dir=rtl] .hasSidebar #dokuwiki__content {
+    [dir=rtl] .showSidebar #dokuwiki__content {
         float: left;
         margin-left: 0;
         margin-right: -__sidebar_width__;
     }
-    .hasSidebar #dokuwiki__content > .pad {
+    .showSidebar #dokuwiki__content > .pad {
         margin-left: __sidebar_width__;
     }
-    [dir=rtl] .hasSidebar #dokuwiki__content > .pad {
+    [dir=rtl] .showSidebar #dokuwiki__content > .pad {
         margin-left: 0;
         margin-right: __sidebar_width__;
     }
diff --git a/lib/tpl/dokuwiki/main.php b/lib/tpl/dokuwiki/main.php
index e0b046574b82ec1192ca0a33257408638895eba2..effbad64c1a923adfa20600abc8afe6825bb902f 100644
--- a/lib/tpl/dokuwiki/main.php
+++ b/lib/tpl/dokuwiki/main.php
@@ -10,7 +10,8 @@
 
 if (!defined('DOKU_INC')) die(); /* must be run from within DokuWiki */
 
-$showSidebar = page_findnearest($conf['sidebar']) && ($ACT=='show');
+$hasSidebar = page_findnearest($conf['sidebar']);
+$showSidebar = $hasSidebar && ($ACT=='show');
 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang'] ?>"
@@ -28,7 +29,8 @@ $showSidebar = page_findnearest($conf['sidebar']) && ($ACT=='show');
 <body>
     <!--[if lte IE 7 ]><div id="IE7"><![endif]--><!--[if IE 8 ]><div id="IE8"><![endif]-->
     <div id="dokuwiki__site"><div id="dokuwiki__top"
-        class="dokuwiki site mode_<?php echo $ACT ?> <?php echo ($showSidebar) ? 'hasSidebar' : ''; ?>">
+        class="dokuwiki site mode_<?php echo $ACT ?> <?php echo ($showSidebar) ? 'showSidebar' : '';
+        ?> <?php echo ($hasSidebar) ? 'hasSidebar' : ''; ?>">
 
         <?php include('tpl_header.php') ?>