.toc {
  width: 100%;
  max-width: $sidebar-width;
  position: fixed;
  overflow-y: auto;
  top: 7rem;
  font-size: 0.85rem;
  z-index: z("toc");

  @include themify($themes) {
    @include webkit-scrollbars(
      themed("custom-scrollbar-foreground-color"),
      themed("custom-scrollbar-background-color")
    );
    @include moz-scrollbars(themed("custom-scrollbar-foreground-color"), themed("custom-scrollbar-background-color"));
  }

  &[data-dir="rtl"] {
    padding-right: 0.5rem;
  }
  &[data-dir="ltr"] {
    padding-left: 0.5rem;
  }

  &[data-ani="true"] {
    @include animation("slide-in-down-little .2s .3s 1 ease-in backwards");
  }

  @include no-select;

  #TableOfContents {
    position: relative;
  }

  &__flexbox[data-position="fixed"] {
    @include flexbox();
    @include align-items(center);
    position: fixed;

    .toc__title {
      margin-top: 0.75rem;
      margin-left: 0.5rem;
    }
  }

  &__flexbox[data-position="absolute"] {
    @include flexbox();
    @include align-items(center);
    position: absolute;
  }

  &__flexbox--outer[data-position="fixed"] {
    @include flexbox();
    @include align-items(center);
    top: 4.2rem;
    left: 1rem;
    position: absolute;

    @media only screen and (max-width: 1300px) {
      display: none;
    }

    &[data-ani="true"] {
      @include animation("slide-in-down-little .2s .3s 1 ease-in backwards");
    }
  }

  &__flexbox--outer[data-dir="ltr"] {
    top: 4.2rem;
    left: 1rem;
  }

  &__flexbox--outer[data-dir="rtl"] {
    top: 4.2rem;
    right: 1rem;

    .toc__title {
      margin-top: 0.75rem;
      margin-left: 0.5rem;
    }
  }

  &__title {
    font-size: 0.9rem;
    margin-top: 0.5rem;

    &[data-ani="true"] {
      @include animation("slide-in-down-little .2s .3s 1 ease-in backwards");
    }

    @include themify($themes) {
      color: themed("toc-label-color");
    }

    &--outer {
      @media only screen and (max-width: 1300px) {
        display: none;
      }
    }
  }

  &[data-dir="ltr"] {
    &[data-folding="true"] {
      @include themify($themes) {
        a {
          color: themed("toc-vertical-line");
          position: relative;
          padding-left: 0.25rem;

          &::before {
            content: "";
            height: 100%;
            left: -0.5rem;
            position: absolute;
            width: 2px;
            background-color: themed("toc-vertical-line");
            &:last-child {
              background-color: transparent;
            }
          }
        }

        .active {
          color: themed("toc-vertical-line-active");
          font-weight: 700;
          &::before {
            background-color: themed("toc-vertical-line-active");
          }
        }
      }
    }

    &[data-folding="false"] {
      @include themify($themes) {
        a {
          color: themed("toc-vertical-line");

          &.active {
            color: themed("toc-vertical-line-active");

            &::before {
              background-color: themed("toc-vertical-line-active");
              content: "";
              height: 0.95rem;
              left: -0.5rem;
              margin-top: 2px;
              position: absolute;
              width: 2px;
              &:last-child {
                background-color: transparent;
              }
            }
          }
        }
      }
    }

    ul {
      @include themify($themes) {
        li {
          li {
            margin-left: 1rem;
            color: themed("sidebar-li-color");
          }
        }
      }
    }
  }

  &[data-dir="rtl"] {
    &[data-folding="true"] {
      @include themify($themes) {
        a {
          color: themed("toc-vertical-line");
          position: relative;
          padding-right: 0.25rem;

          &::before {
            content: "";
            height: 100%;
            right: -0.5rem;
            position: absolute;
            width: 2px;
            background-color: themed("toc-vertical-line");
            &:last-child {
              background-color: transparent;
            }
          }
        }

        .active {
          color: themed("toc-vertical-line-active");
          font-weight: 700;
          &::before {
            background-color: themed("toc-vertical-line-active");
          }
        }
      }
    }

    &[data-folding="false"] {
      @include themify($themes) {
        a {
          color: themed("toc-vertical-line");

          &.active {
            color: themed("toc-vertical-line-active");

            &::before {
              background-color: themed("toc-vertical-line-active");
              content: "";
              height: 0.95rem;
              right: -0.5rem;
              margin-top: 2px;
              position: absolute;
              width: 2px;
              &:last-child {
                background-color: transparent;
              }
            }
          }
        }
      }
    }

    ul {
      @include themify($themes) {
        li {
          li {
            margin-right: 1rem;
            color: themed("sidebar-li-color");
          }
        }
      }
    }
  }

  ul {
    @include themify($themes) {
      a {
        color: themed("toc-title-color");
        &.active {
          color: themed("toc-vertical-line-active");
        }
      }
    }
  }

  &__outer {
    padding-right: 1rem;
    padding-left: 2.5rem;
    max-width: calc((100vw - 980px) / 2);

    @media only screen and (max-width: 1300px) {
      display: none;
    }
  }
}

.expand__content {
  #TableOfContents {
    ul {
      list-style-type: circle;
    }
  }
}