/* Mostly taken from Tufte CSS. --- */

.tufte-content {
  counter-reset: sidenote-counter;
  position: relative;
  max-width: 800px;
  margin: 0 auto;
}

.tufte-content p,
.tufte-content dl,
.tufte-content h1,
.tufte-content h2,
.tufte-content h3,
.tufte-content blockquote {
  width: 70%;
}

.tufte-content>div>ul,
.tufte-content>div>ol {
  max-width: 65%;
}

.tufte-content p:has(> img) {
  width: 100%;
}

.sidenote,
.marginnote {
  float: right;
  clear: right;
  margin-right: -55%;
  width: 50%;
  margin-top: 0.3rem;
  margin-bottom: 0;
  font-size: 0.9rem;
  line-height: 1.3;
  vertical-align: baseline;
  position: relative;
}

.sidenote-number {
  counter-increment: sidenote-counter;
}

.sidenote-number:after,
.sidenote:before {
  position: relative;
  vertical-align: baseline;
}

.sidenote-number:after {
  content: counter(sidenote-counter);
  font-size: 0.8rem;
  top: -0.3rem;
  left: 0.1rem;
}

.sidenote:before {
  content: counter(sidenote-counter) " ";
  font-size: 0.8rem;
  top: -0.3rem;
}

input.margin-toggle {
  display: none;
}

label.sidenote-number {
  display: inline;
  max-height: 2rem;
}

label.margin-toggle:not(.sidenote-number) {
  display: none;
}

#sn-zig-io {
  top: -10rem;
}

@media (max-width: 992px) {

  body,
  .tufte-content {
    width: 100%;
    box-sizing: border-box;
  }

  .tufte-content p,
  .tufte-content dl,
  .tufte-content h1,
  .tufte-content h2,
  .tufte-content h3,
  .tufte-content blockquote {
    width: 100%;
  }

  .tufte-content>div>ul,
  .tufte-content>div>ol {
    max-width: 100%;
  }


  label.margin-toggle:not(.sidenote-number) {
    display: inline;
  }

  .sidenote,
  .marginnote {
    display: none;
  }

  .margin-toggle:checked+.sidenote,
  .margin-toggle:checked+.marginnote {
    display: block;
    float: left;
    left: 1rem;
    clear: both;
    width: 95%;
    margin: 1rem 2.5%;
    position: relative;
  }

  label {
    cursor: pointer;
  }

  #sn-zig-io {
    top: 0;
  }
}