main {
  position: relative;
  display: flex;
  padding: 25px 0;
}

#table-of-contents-wrapper-2 {
  position: sticky;
  left: -25px;
  top: 95px;
  width: 300px;
  background-color: #fff;
  z-index: 3;
  transform-style: preserve-3d;
}
@media screen and (max-width: 944px) {
  #table-of-contents-wrapper-2 {
    position: absolute;
    left: -25px;
    top: 0;
    width: 300px;
    height: 100%;
    background-color: #fff;
    z-index: 3;
    transform-style: preserve-3d;
  }
}
#table-of-contents-wrapper-2::after {
  content: "";
  position: absolute;
  left: 0;
  top: 15px;
  width: calc(100% - 10px);
  height: calc(100% - 30px);
  box-shadow: 10px 0 15px 0 rgba(0, 0, 0, 0.25);
  clip-path: inset(-15px -9999px -15px 0);
  transform: translateZ(-1px);
}

#table-of-contents-wrapper {
  position: sticky;
  top: 95px;
  max-width: 300px;
  flex: 0 0 20vw;
  align-self: flex-start;
  background-color: #fff;
  /* overflow-y: auto; */
  /* box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.33); */
  /* clip-path: polygon(0 0, calc(100%) + 10px 0, calc(100% + 10px) 100%, 0 ); */
}

#expand-table-of-contents {
  display: none;
}

#table-of-contents {
  /* width: calc(100% + 3px); */
  height: 100%;
  overflow-y: auto; 
}
@supports (overflow-y: overlay) {
  #table-of-contents {
    overflow-y: overlay;
  }
}

#table-of-contents > h1 {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 9px 13px 12px;
  /* background-color: #fff; */
  border-radius: 10px 0 0 10px;
  font-size: 20px;
  font-weight: 400;
  /* z-index: 1; */
  z-index: 7;
  cursor: pointer;
}
#table-of-contents > h1.table-of-contents-item-active {
  /* border-right: 3px solid rgb(0, 90, 230); */
  /* background-color: rgba(0, 107, 255, 0.2); */
  background-color: rgba(220, 0, 0, 0.1);
  /* color: rgb(0, 90, 230); */
  color: var(--theme-bright-red);
  font-weight: 600;
}
#table-of-contents > h1.table-of-contents-item-active::after {
  content: "";
  position: absolute;
  /* right: -3px; */
  right: 0;
  top: 0;
  width: 3px;
  height: 100%;
  border-radius: 0 100px 100px 0;
  /* background-color: rgb(0, 90, 230); */
  background-color: var(--theme-bright-red);
}

#table-of-contents::-webkit-scrollbar {
  width: 3px;
  z-index: 6;
}
#table-of-contents::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.3);
  /* border-left: 3px solid red; */
  /* box-shadow: 0 0 10px 10px #bbb inset; */
  /* border-radius: 5px; */
  /* border-right: 5px solid transparent; */

}
#table-of-contents::-webkit-scrollbar-track {
  /* overflow: hidden; */
  /* box-shadow: 0 0 10px 10px green inset; */
  /* border-right: 3px solid transparent; */
  background-color: transparent;
}
#table-of-contents::-webkit-scrollbar-track-piece {
  background-color: transparent;
}
#table-of-contents:is(::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track) {
  /* border-right: 10px solid transparent; */
}

#main-content {
  flex: 1;
  max-width: 100%;
  padding-left: 31px;
}

#main-content > h1:first-child {
  margin-top: 0.2em;
}

@media screen and (max-width: 944px) {
  main {
    display: grid;
    grid-template-columns: calc(100vw - 50px);
    padding-bottom: 20px;
  }

  #table-of-contents-wrapper-2 {
    transition: transform 0.4s;
    transform: translateX(calc(-100% - 1px));
  }
  #table-of-contents-wrapper-2.table-of-contents-expanded {
    transform: translateX(0);
  }

  #table-of-contents-wrapper-2::after {
    box-shadow: none;
    transition: box-shadow 0.4s;
  }
  #table-of-contents-wrapper-2.table-of-contents-expanded::after {
    box-shadow: 10px 0 70px 0 rgba(0, 0, 0, 0.5);
  }

  #table-of-contents-wrapper, #main-content {
    grid-column-start: 1;
    grid-row-start: 1;
  }

  #table-of-contents-wrapper {
    top: 70px;
    /* height: calc(100vh - 70px); */
    /* margin: -25px 0 0 -25px; */
    padding: 13px;
    z-index: 2;
  }

  #expand-table-of-contents {
    position: absolute;
    display: inline;
    display: flex;
    align-items: center;
    right: 1px;
    top: 30px;
    padding: 15px 20px 15px 16px;
    transform: translateX(100%);
    background-color: #fff;
    border-radius: 0 999px 999px 0;
    border: none;
    box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.25);
    clip-path: inset(-9999px -9999px -9999px 1px);
    outline: none;
    color: #777;
    font-size: 36px;
    opacity: 0;
    z-index: 1;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.3s;
  }
  #expand-table-of-contents:active {
    background-color: #dadada;
  }
  
  #expand-table-of-contents.expand-contents-button-visible {
    opacity: 1;
    pointer-events: all;
  }

  #table-of-contents > h1.table-of-contents-item-active {
    border-radius: 10px;
  }
  #table-of-contents > h1.table-of-contents-item-active::after {
    display: none;
  }

  #main-content {
    padding-left: 0;
  }
}
