div.body {
  padding: 10px;
}

.revision-toc {
  float: right;
  font-size: .9em;
  border: solid 1px #aaa;
  border-radius: 5px;
  max-width: 250px;
  overflow: hidden;

  .revision-toc-head {
    display: inline-block;
    float: right;
    border-left: solid 1px #aaa;
    border-bottom: solid 1px #aaa;
    border-radius: 0 5px;
    padding: 3px 11px;
    font-weight: bold;
    background: #f0f0f0;
    margin-left: 5px;
    margin-bottom: 5px;

    &.collapsed {
      border: none;
      margin: 0;
    }
  }
  .revision-toc-content {
    background: #fcfcfc;
    padding: 10px;

    > ul {
      margin: 4px 4px 4px 15px;
      padding: 5px;
    }
  }
}

.revision-head {

  .revision-head-link {
    display: none;
    font-size: 0.6em;
    padding-top: 4px;
    padding-left: 10px;
  }
  &:hover .revision-head-link {
    display: inline-block;
  }
}

.wiki {
  line-height: 1.6em;
  font-size: 15px;
  word-break: break-word;

  h1, h2, h3, h4, h5, h6 {
    margin-top: 1.6em;
    margin-bottom: .8em;

    &:first-child {
      margin-top: 0;
    }
  }

  h1 {
    padding-bottom: 0.3em;
    font-size: 2.3em;
    font-weight: bold;
    border-bottom: solid 1px #ccc;
  }
  h2 {
    padding-bottom: 0.3em;
    font-size: 1.8em;
    line-height: 1.225;
    font-weight: bold;
    border-bottom: 1px solid #eee;
  }
  h3 {
    font-size: 1.5em;
    font-weight: bold;
  }
  h4 {
    font-size: 1.3em;
    font-weight: normal;
  }
  h5 {
    font-size: 1.1em;
    font-weight: normal;
  }

  p {
    font-weight: normal;
    margin-bottom: 9px;
  }

  // Imported from bootstrap3
  // Ref: https://github.com/twbs/bootstrap/blob/v3.3.7/dist/css/bootstrap.css#L1477-L1487
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 0.9em;
    border-left: 5px solid #eeeeee;

    p, ul, ol {
      &:last-child {
        margin-bottom: 0;
      }
    }
  }

  a {
    text-decoration: underline;
    color: #38ad9e;
    word-break: break-all;

    &:hover {
      text-decoration: none;
      color: darken(#38ad9e, 10%);
    }
  }

  pre {
    line-height: 1.4em;
    font-size: .9em;
    border: none;
    background: #444;
    color: #f0f0f0;
    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
    padding: 9.5px;
    border-radius: 4px;
    word-wrap: break-word;
    white-space: pre-wrap;

    code {
      background: transparent;
      word-break: break-all;
    }
  }

  img {
    margin: 5px 0;
    box-shadow: 0 0 5px 0px rgba(0,0,0,.2);
    border: solid 1px #ccc;
    max-width: 100%;
  }
  .noborder img, .img.noborder {
    box-shadow: none;
    border: none;
  }

  img.emoji {
    width: 1.1em;
    margin: 1px;
    border: none;
    box-shadow: none;
    vertical-align: middle;
    display: inline;
  }

  ul, ol {
    padding-left: 30px;

    li {
      line-height: 1.8em;

      p {
        margin-top: 10px;
        margin-bottom: 0;

        &:first-child {
          margin-top: 0;
        }
      }
    }
  }

  .wiki-code {
    position: relative;

    cite {
      position: absolute;
      top: 0;
      right: 0;
      padding: 0 4px;
      background: #ccc;
      color: #333;
      font-size: .8em;
    }
  };

  .page-template-builder {
    position: relative;

    .template-create-button {
      position: absolute;
      top: 8px;
      right: 8px;
    }
  }

  .highlighted {
    &em {
      padding: 2px;
      margin: 0 -2px;
      font-weight: bold;
    }
    font-style: normal;
    color: #333;
    background-color: rgba(255,255,140,0.5);
    border-radius: 3px;
  }

  // {{{ table (copied from bootstrap .table
  table {
    width: 100%;
    margin-bottom: 20px;
    // Cells
    > thead,
    > tbody,
    > tfoot {
      > tr {
        > th,
        > td {
          padding: $table-cell-padding;
          line-height: $line-height-base;
          vertical-align: top;
          border-top: 1px solid $table-border-color;
        }
      }
    }
    // Bottom align for column headings
    > thead > tr > th {
      vertical-align: bottom;
      border-bottom: 2px solid $table-border-color;
    }
    // Remove top border from thead by default
    > caption + thead,
    > colgroup + thead,
    > thead:first-child {
      > tr:first-child {
        > th,
        > td {
          border-top: 0;
        }
      }
    }
    // Account for multiple tbody instances
    > tbody + tbody {
      border-top: 2px solid $table-border-color;
    }

    // Nesting
    table {
      background-color: $body-bg;
    }

    // .table-bordered
    border: 1px solid $table-border-color;
    > thead,
    > tbody,
    > tfoot {
      > tr {
        > th,
        > td {
          border: 1px solid $table-border-color;
        }
      }
    }
    > thead > tr {
      > th,
      > td {
        border-bottom-width: 2px;
      }
    }
  }
  // }}}
}

// Smartphone and Tablet
@include media-breakpoint-down(sm) {
  .crowi.main-container .main .wiki {
    img {
      max-width: 100%;
    }
  }
}
