body.boxed {
  --box-line: var(--line);
  --box-bg: rgba(255, 255, 255, 0.02);
  --box-head: rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] body.boxed {
  --box-bg: #fafafa;
  --box-head: #efefef;
}

body.boxed .content .page-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 450;
  letter-spacing: -0.01em;
  color: var(--text);
}

body.boxed #overview h2 {
  margin-top: 14px;
}

body.boxed .content h2 {
  margin-left: -48px;
  margin-right: -48px;
  padding-left: 48px;
  padding-right: 48px;
  font-size: 18px;
  font-weight: 450;
  letter-spacing: -0.01em;
}

@media (max-width: 880px) {
  body.boxed .content h2 {
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
  }
}

body.boxed .content article {
  margin: 24px 0;
  border: 1px solid var(--box-line);
  background: var(--box-bg);
}

body.boxed .content article > h3 {
  margin: 0;
  padding: 9px 14px;
  border-bottom: 1px solid var(--box-line);
  background: var(--box-head);
}

body.boxed .content article > *:not(h3) {
  margin: 0;
  padding: 10px 14px;
  border-left: 0;
}

body.boxed:not(.coc) .content article > p + p,
body.boxed:not(.coc) .content article > pre + p,
body.boxed:not(.coc) .content article > ul + p,
body.boxed:not(.coc) .content article > ol + p {
  border-top: 1px solid var(--box-line);
}

body.boxed .content article > pre:not(h3) {
  margin: 10px 14px;
  padding: 10px 12px;
  border: 1px solid var(--box-line);
  background: var(--code-bg);
}

body.boxed .content a.rule-ref {
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

body.boxed .content h2 a.rule-ref {
  color: inherit;
}

body.boxed .content a.rule-ref:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.boxed .content article > pre + ul,
body.boxed .content article > pre + p {
  border-top: 0;
}

body.boxed .content section > p,
body.boxed .content section > ul,
body.boxed .content section > ol,
body.boxed .content section > blockquote,
body.boxed .content .panel > * {
  max-width: 78ch;
}

body.boxed .content section > p,
body.boxed .content .panel > p {
  margin-bottom: 18px;
}

body.boxed .content section > p:last-child,
body.boxed .content .panel > p:last-child {
  margin-bottom: 0;
}

body.boxed .content section > blockquote {
  margin: 22px 0;
}

body.coc #scope > article:first-child {
  margin-top: 0;
}

body.coc .content article > blockquote {
  background: none;
}

:root {
  --z: 1.21;
}

@media (min-width: 881px) {
  html,
  body {
    overflow: hidden;
  }

  body.boxed .layout {
    height: calc(100vh - var(--nav-h));
    height: calc(100dvh - var(--nav-h));
    min-height: 0;
  }

  body.boxed .content {
    height: 100%;
    overflow-y: auto;
    scroll-padding-top: 0;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--dim) transparent;
  }

  body.boxed .content::-webkit-scrollbar {
    width: 6px;
  }

  body.boxed .content::-webkit-scrollbar-track {
    background: transparent;
  }

  body.boxed .content::-webkit-scrollbar-thumb {
    background: var(--dim);
    border-radius: 0;
  }

  body.boxed .content::-webkit-scrollbar-thumb:hover {
    background: var(--text);
  }

  body.boxed .sidebar,
  body.boxed .aside {
    position: static;
    height: 100%;
  }
}

@media (min-width: 1100px) {
  html {
    zoom: var(--z);
  }

  body {
    min-height: calc(100vh / var(--z));
  }

  body.boxed .layout {
    height: calc(100vh / var(--z) - var(--nav-h));
    height: calc(100dvh / var(--z) - var(--nav-h));
  }
}

body.coc .content article > ol > li {
  position: relative;
  padding-left: 3.6em;
}

body.coc .content article > ol > li::before {
  content: var(--rule, "") counter(item);
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

body.coc section#enforcement h2 {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

body.coc .content section > blockquote {
  max-width: none;
  margin: 24px 0;
  padding: 16px 20px 16px 22px;
  border: 1px solid var(--box-line);
  border-left: 3px solid var(--accent-dim);
  background: rgba(255, 255, 255, 0.035);
}

:root[data-theme="light"] body.coc .content section > blockquote {
  background: #f6f6f6;
}

body.coc .content section > blockquote p {
  color: var(--body);
}

body.boxed .content .content-foot {
  margin-left: -48px;
  margin-right: -48px;
  padding-left: 48px;
  padding-right: 48px;
}

@media (max-width: 880px) {
  body.boxed .content .content-foot {
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
  }
}

body.boxed .content article > pre.md:not(h3) {
  position: relative;
  margin: 10px;
  padding: 12px;
  border: 1px solid var(--box-line);
  background: var(--code-bg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

body.boxed .content article > h3 {
  position: relative;
}

body.boxed .copy-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--dim);
  cursor: pointer;
  border-radius: 0;
}

body.boxed .copy-btn svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
}

body.boxed .copy-btn:hover,
body.boxed .copy-btn.done {
  color: var(--text);
}

html::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.14);
  opacity: 0;
  transition: opacity 0.2s ease;
}

html[data-theme="light"]::after {
  opacity: 1;
}

@media print {
  html::after {
    display: none;
  }
}

html:has(body.boxed) {
  scroll-padding-top: var(--nav-h);
}

body.boxed .content section[id] {
  scroll-margin-top: 0;
}
