.calendar {
  max-width: 800px;
  height: 100%;
  position: relative;
  margin: auto;
}
.calendar__container {
  height: 100%;
}
.calendar__legend-list {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  -ms-flex-wrap: wrap;
      flex-wrap: wrap;
  gap: 15px;
}
.calendar__legend-item {
  cursor: pointer;
  border-radius: 5px;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: center;
      -ms-flex-pack: center;
          justify-content: center;
  background: #f7f7f7;
  padding: 4px 10px;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  gap: 10px;
}
.calendar__legend-item--active {
  background: darkgray;
  -webkit-transform: scale(1.1);
          transform: scale(1.1);
  -webkit-transition: 0.2s all;
  transition: 0.2s all;
}
.calendar__legend-icon {
  border-radius: 50%;
  background: purple;
  width: 20px;
  height: 20px;
}
.calendar__period {
  margin: 20px auto;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  width: -webkit-fit-content;
  width: -moz-fit-content;
  width: fit-content;
  padding: 4px;
  gap: 4px;
  background: #f7f7f7;
  border-radius: 10px;
}
.calendar__period-btn {
  cursor: pointer;
  padding: 10px;
}
.calendar__period-btn--active {
  border-radius: 10px;
  -webkit-transition: 0.2s all;
  transition: 0.2s all;
  background: #4a90e2;
  color: white;
}
.calendar__body {
  width: 100%;
  height: 100%;
}
.calendar__period-bar {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
}
.calendar__period-bar-current, .calendar__period-bar-last, .calendar__period-bar-next {
  background: #4a90e2;
  border-radius: 10px;
  color: white;
  padding: 10px;
}
.calendar__period-year {
  margin: auto;
  text-align: center;
}
.calendar__period-bar-last, .calendar__period-bar-next {
  cursor: pointer;
}
.calendar__period-bar-current {
  background: lightgray;
  color: black;
}
.calendar__block {
  width: 100%;
  height: 100%;
  padding: 10px;
  border-radius: 10px;
  margin: 10px 0;
}
.calendar__week {
  margin: 0 0 10px 0;
  display: -ms-grid;
  display: grid;
  gap: 15px;
  -ms-grid-columns: 2fr 15px 2fr 15px 2fr 15px 2fr 15px 2fr 15px 2fr 15px 2fr;
  grid-template-columns: repeat(7, 2fr);
  -webkit-box-pack: justify;
      -ms-flex-pack: justify;
          justify-content: space-between;
}
.calendar__week div {
  background: gray;
  color: white;
  padding: 5px 0;
  text-align: center;
  border-radius: 5px;
}
.calendar__days {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: (1fr)[7];
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: auto; /* equal height rows */
}
.calendar__days .day__block {
  border: 1px black solid;
  border-radius: 8px;
  padding: 5px;
  max-width: 100%;
  min-height: min(14.2857142857vw, 114.2857142857px);
  position: relative;
}
.calendar__days .day__block-number {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-pack: end;
      -ms-flex-pack: end;
          justify-content: flex-end;
  -webkit-box-align: center;
      -ms-flex-align: center;
          align-items: center;
  border: 0;
  width: 100%;
  border-radius: 50%;
  padding: 0;
  z-index: 10;
}
.calendar__days .day__block-number--today {
  background: blue;
  aspect-ratio: 1/1;
  width: -webkit-fit-content;
  width: -moz-fit-content;
  width: fit-content;
  color: white;
  padding: 2px;
  right: 0;
  position: static;
  margin-left: auto;
}
.calendar__days .day__block-marks {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
      -ms-flex-direction: column;
          flex-direction: column; /* stack one per row */
  gap: 5px;
  width: 100%;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}
.calendar__days .mark {
  cursor: pointer;
  background: purple;
  color: white;
  border-radius: 5px;
  padding: 3px;
  font-size: 10px;
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calendar__days .mark:active {
  max-width: -webkit-fit-content !important;
  max-width: -moz-fit-content !important;
  max-width: fit-content !important;
  width: 100% !important;
  background: gray !important;
}
.calendar__days .mark--empty {
  background: gray;
}
.calendar .calendar__days .day__block-number {
  font-weight: 900;
}
.calendar .calendar__days div:nth-child(7n) .day__block-number, .calendar .calendar__days div:nth-child(7n-1) .day__block-number {
  color: red;
}

.unvisibleDay .day__block-number {
  display: none;
}

.unvisible {
  display: none;
}

.calendar.calendar--day .calendar__days {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  width: 100%;
}
.calendar.calendar--day .day__block {
  width: 100%;
}
.calendar.calendar--day .calendar__week {
  position: relative;
  padding: 20px 0;
}
.calendar.calendar--day .calendar__week div {
  padding: 5px 40px;
  position: absolute;
  left: 50%;
  -webkit-transform: translateX(-50%);
          transform: translateX(-50%);
}

@media (max-width: 800px) {
  main {
    padding: 20px 2px !important;
  }
  .calendar.calendar--week .calendar__block {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 10px;
    padding: 10px 0;
  }
  .calendar.calendar--week .calendar__week {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    width: 30%;
    gap: 5px;
    margin: 0;
    -ms-flex-pack: distribute;
        justify-content: space-around;
  }
  .calendar.calendar--week .calendar__days {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
        -ms-flex-direction: column;
            flex-direction: column;
    width: 100%;
    gap: 5px;
  }
  .calendar.calendar--week .day__block {
    width: 100%;
  }
  .calendar.calendar--week .day__block-number {
    -webkit-box-pack: center;
        -ms-flex-pack: center;
            justify-content: center;
  }
  .calendar.calendar--week .mark {
    max-width: 100% !important;
  }
}
.calendar.calendar--day .mark {
  max-width: 100% !important;
}
.calendar.calendar--day .day__block {
  width: 100%;
  aspect-ratio: 1/1;
}