.layout {
  display: grid;
  width: min(calc(100% - clamp(2rem, 6vw, 6rem)), 82rem);
  margin-inline: auto;
  padding-block: clamp(1.75rem, 3.5vw, 3rem) clamp(3.5rem, 7vw, 6.5rem);
  grid-template-columns: minmax(12.5rem, 15rem) minmax(0, 48rem);
  gap: clamp(1.75rem, 4.5vw, 4.25rem);
}

.layout main,
.docs-menu,
.reader-toc {
  min-width: 0;
}

.docs-menu {
  align-self: start;
}
.docs-menu summary {
  display: none;
}

.docs-menu nav {
  padding-inline-end: 1.15rem;
  border-inline-end: 1px solid var(--rule-subtle);
}

.docs-menu h2 {
  margin: 1.5rem 0.65rem 0.4rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.docs-menu h2:first-child {
  margin-top: 0;
}
.docs-menu ul {
  padding: 0;
  margin: 0;
  list-style: none;
}
.docs-menu li + li {
  margin-top: 0.1rem;
}
.docs-menu nav a {
  display: block;
  padding: 0.36rem 0.65rem;
  border-radius: 0.35rem;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.38;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    color 140ms ease;
}
.docs-menu nav a:hover {
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.docs-menu nav a[aria-current="page"] {
  background: var(--accent-surface);
  color: var(--accent);
  font-weight: 620;
  box-shadow: inset 2px 0 0 var(--accent);
}

.reader-toc {
  display: none;
  align-self: start;
}
.reader-toc-title {
  margin: 0 0 0.7rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.reader-toc ul {
  margin: 0;
  padding: 0;
  list-style: none;
  border-inline-start: 1px solid var(--rule-subtle);
}
.reader-toc li {
  margin: 0;
}
.reader-toc a {
  display: block;
  padding: 0.32rem 0 0.32rem 0.9rem;
  margin-inline-start: -1px;
  border-inline-start: 2px solid transparent;
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.4;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition:
    color 140ms ease,
    border-color 140ms ease;
}
.reader-toc a:hover {
  color: var(--ink);
  text-decoration: none;
}
.reader-toc a[aria-current="location"] {
  border-inline-start-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

dialog.search-dialog {
  width: min(calc(100% - 2rem), 38rem);
  max-width: 38rem;
  max-height: min(36rem, calc(100dvh - 5rem));
  margin: clamp(3rem, 11vh, 6.5rem) auto auto;
  padding: 0;
  border: 1px solid var(--control-border);
  border-radius: 0.7rem;
  background: var(--surface);
  color: var(--ink);
  box-shadow:
    0 24px 64px rgb(0 0 0 / 0.62),
    0 0 0 1px rgb(255 255 255 / 0.04) inset;
  overflow: hidden;
}
dialog.search-dialog[open] {
  display: flex;
  flex-direction: column;
}
dialog.search-dialog:modal {
  overscroll-behavior: contain;
}
dialog.search-dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgb(7 10 13 / 0.72);
  backdrop-filter: blur(6px);
}

.search {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin: 0;
}
.search-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: none;
  border-bottom: 1px solid var(--rule-subtle);
  background: var(--surface-subtle);
}
.search-icon {
  position: absolute;
  inset-inline-start: 1rem;
  color: var(--muted);
  pointer-events: none;
  transition: color 140ms ease;
}
.search-field:focus-within .search-icon {
  color: var(--accent);
}
.search input {
  width: 100%;
  min-height: 3.35rem;
  padding: 0.75rem 4.4rem 0.75rem 2.75rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.98rem;
}
.search input::-webkit-search-cancel-button {
  appearance: none;
}
.search input:focus {
  outline: none;
}
.search input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.search input::placeholder {
  color: var(--muted);
}
.search-close {
  position: absolute;
  inset-inline-end: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.75rem;
  padding: 0.16rem 0.48rem;
  border: 1px solid var(--rule);
  border-radius: 0.32rem;
  background: var(--surface);
  color: var(--muted);
  font: 500 0.72rem/1.2 var(--mono);
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease;
}
.search-close kbd {
  font: inherit;
}
.search-close:hover {
  border-color: var(--control-border);
  background: var(--surface-elevated);
  color: var(--ink);
}
.search p:empty,
.search ul:empty {
  display: none;
}
.search #search-status {
  flex: none;
  margin: 0;
  padding: 0.65rem 1.05rem 0.25rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.search #search-results {
  display: grid;
  gap: 0.2rem;
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  padding: 0.45rem 0.55rem 0.65rem;
  margin: 0;
  scrollbar-width: thin;
  scrollbar-color: #465359 transparent;
}
.search li a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.62rem 0.8rem;
  border: 1px solid transparent;
  border-radius: 0.42rem;
  color: var(--ink-secondary);
  font-size: 0.94rem;
  font-weight: 520;
  text-decoration: none;
  transition:
    border-color 120ms ease,
    background-color 120ms ease,
    color 120ms ease;
}
.search li a::after {
  content: "↵";
  flex: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.76rem;
  opacity: 0;
  transition: opacity 120ms ease;
}
.search li a:hover,
.search li a[data-active="true"] {
  border-color: var(--accent-muted);
  background: var(--accent-surface);
  color: var(--accent);
  text-decoration: none;
}
.search li a:hover::after,
.search li a[data-active="true"]::after {
  opacity: 1;
}
.search-hint {
  display: none;
  margin: 0;
  padding: 2rem 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}
#search-status:empty + #search-results:empty + .search-hint {
  display: block;
}
.search-footer {
  display: flex;
  flex: none;
  align-items: center;
  gap: 1.15rem;
  padding: 0.55rem 1.05rem;
  border-top: 1px solid var(--rule-subtle);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 0.76rem;
}
.search-footer span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.search-footer kbd {
  padding: 0.08rem 0.34rem;
  border: 1px solid var(--rule);
  border-radius: 0.25rem;
  background: var(--surface);
  color: var(--ink-secondary);
  font: 500 0.7rem/1.3 var(--mono);
}

article {
  font-size: 1.015rem;
  line-height: 1.68;
  color: var(--ink-secondary);
  overflow-wrap: anywhere;
}
article strong {
  color: var(--ink);
}
article h1,
.standalone h1 {
  color: var(--ink);
  font-size: clamp(2rem, 4.2vw, 2.95rem);
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: -0.04em;
  margin: 0 0 0.65em;
  text-wrap: balance;
}
article h2 {
  color: var(--ink);
  margin: 2.15em 0 0.55em;
  padding-top: 1.15rem;
  border-top: 1px solid var(--rule-subtle);
  font-size: clamp(1.35rem, 2.5vw, 1.72rem);
  font-weight: 620;
  line-height: 1.2;
  letter-spacing: -0.028em;
}
article h1 + h2,
article .reader-outline + h2 {
  margin-top: 1.35em;
  padding-top: 0;
  border-top: 0;
}
article h3,
article h4 {
  color: var(--ink);
  margin: 1.6em 0 0.45em;
  line-height: 1.3;
  font-weight: 600;
}
article h3 {
  font-size: 1.16rem;
  letter-spacing: -0.015em;
}
article h4 {
  font-size: 1.02rem;
}
article p,
article li {
  max-width: 72ch;
}
article p {
  margin-block: 0.9em;
}
article a,
.standalone a {
  color: var(--accent);
  text-decoration-color: var(--accent-muted);
  transition:
    color 140ms ease,
    text-decoration-color 140ms ease;
}
article a:hover,
.standalone a:hover {
  color: var(--accent-hover);
  text-decoration-color: var(--accent-hover);
}
article li + li {
  margin-top: 0.32em;
}
article ul,
article ol {
  padding-inline-start: 1.4rem;
}
article img {
  max-width: 100%;
  height: auto;
  border-radius: 0.45rem;
}
article blockquote {
  max-width: 72ch;
  margin: 1.35rem 0;
  padding: 0.85rem 1.15rem;
  border: 1px solid var(--rule-subtle);
  border-inline-start: 3px solid var(--accent-muted);
  border-radius: 0.2rem 0.5rem 0.5rem 0.2rem;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
}
article blockquote > :first-child {
  margin-top: 0;
}
article blockquote > :last-child {
  margin-bottom: 0;
}
article hr {
  border: 0;
  border-top: 1px solid var(--rule-subtle);
  margin-block: 2rem;
}
article h1,
article h2,
article h3,
article h4 {
  scroll-margin-top: 5.25rem;
}
article :target {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.18em;
}

.package-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.1rem;
  margin-block-end: 1.15rem;
  font-size: 0.88rem;
}
.package-links a {
  color: var(--accent);
  text-decoration: none;
}
.package-links a:hover {
  text-decoration: underline;
}
.package-index > ul {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 0.85rem;
  padding: 0;
  list-style: none;
}
.package-index > ul > li {
  margin: 0;
  padding: 0.9rem 1rem;
  border: 1px solid var(--rule-subtle);
  border-radius: 0.5rem;
  background: var(--surface-subtle);
  font-size: 0.9rem;
  transition:
    border-color 140ms ease,
    background-color 140ms ease;
}
.package-index > ul > li:hover {
  border-color: var(--accent-muted);
  background: var(--surface);
}
.package-index > ul > li + li {
  margin: 0;
}
.package-index > ul > li > a {
  display: block;
  margin-bottom: 0.2rem;
  font-size: 0.98rem;
  font-weight: 650;
  text-decoration: none;
}
.package-index > ul > li > a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: var(--mono);
  font-size: 0.84em;
  border-radius: 0.3rem;
}
code {
  background: var(--surface);
  border: 1px solid var(--rule-subtle);
  color: #dcece6;
  padding: 0.1em 0.32em;
  white-space: nowrap;
}
article pre {
  overflow-x: auto;
  margin-block: 1.2rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 0.55rem;
  background: var(--surface);
  color: #e4edf2;
  line-height: 1.62;
}
article pre code {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: 1em;
  white-space: pre;
}
article table {
  border-collapse: collapse;
  font-size: 0.9rem;
}
article td,
article th {
  border-bottom: 1px solid var(--rule-subtle);
  padding: 0.65rem 0.8rem;
  text-align: start;
}
article td code {
  white-space: nowrap;
}
article tbody tr:last-child td {
  border-bottom: 0;
}
article tbody tr:hover {
  background: rgb(255 255 255 / 0.02);
}
article th {
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.layout main > footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
  margin-block-start: 2.5rem;
  padding-block-start: 1rem;
  border-block-start: 1px solid var(--rule-subtle);
  color: var(--muted);
  font-size: 0.84rem;
}
.layout main > footer a {
  color: var(--muted);
}
.layout main > footer a:hover {
  color: var(--accent);
}

.standalone {
  min-height: 54vh;
  padding-block: clamp(3rem, 8vw, 7rem);
}
.standalone p {
  max-width: 65ch;
  color: var(--ink-secondary);
}
.standalone ul {
  padding-inline-start: 1.25rem;
}

@media (min-width: 52.01rem) {
  .docs-menu {
    position: sticky;
    top: 5.25rem;
    max-height: calc(100dvh - 6.5rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #465359 transparent;
  }
}

@media (min-width: 74rem) {
  .layout {
    width: min(calc(100% - clamp(2rem, 6vw, 6rem)), 86rem);
    grid-template-columns: minmax(13rem, 15rem) minmax(0, 1fr) minmax(
        11.5rem,
        13.75rem
      );
    gap: clamp(2rem, 3.2vw, 3.5rem);
  }
  .reader-outline {
    display: none;
  }
  .reader-toc {
    display: block;
    position: sticky;
    top: 5.25rem;
    max-height: calc(100dvh - 6.5rem);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #465359 transparent;
  }
}

@media (max-width: 52rem) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.35rem;
  }
  .docs-menu {
    border: 1px solid var(--rule);
    border-radius: 0.5rem;
    background: var(--surface-subtle);
  }
  .docs-menu summary {
    display: list-item;
    cursor: pointer;
    min-height: 2.75rem;
    padding: 0.65rem 0.9rem;
    font-size: 0.92rem;
    font-weight: 620;
  }
  .docs-menu[open] summary {
    border-bottom: 1px solid var(--rule-subtle);
  }
  .docs-menu nav {
    border: 0;
    padding: 0.75rem;
  }
  .docs-menu nav a {
    padding-block: 0.58rem;
  }
}

.reader-outline {
  max-width: 72ch;
  margin-block: 0 1.6rem;
  padding: 0.6rem 0.95rem;
  border: 1px solid var(--rule-subtle);
  border-radius: 0.5rem;
  background: var(--surface-subtle);
  font-size: 0.9rem;
}
.reader-outline summary {
  min-height: 1.8rem;
  cursor: pointer;
  color: var(--ink);
  font-weight: 620;
}
.reader-outline a {
  text-underline-offset: 0.22em;
}
.reader-outline ul {
  margin: 0.55rem 0 0.25rem;
}

.reader-pages {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  padding-block-start: 1.35rem;
  margin-block-start: clamp(2.25rem, 5vw, 3.5rem);
  border-top: 1px solid var(--rule-subtle);
}
.reader-page-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--rule-subtle);
  border-radius: 0.55rem;
  background: var(--surface-subtle);
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease;
}
.reader-page-link:hover {
  border-color: var(--accent-muted);
  background: var(--surface);
  color: var(--accent);
  text-decoration: none;
}
.reader-page-link[rel="next"] {
  grid-column: 2;
  align-items: flex-end;
  text-align: end;
}
.reader-page-direction {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.reader-page-link[rel="prev"] .reader-page-direction::before {
  content: "← ";
  color: var(--accent);
}
.reader-page-link[rel="next"] .reader-page-direction::after {
  content: " →";
  color: var(--accent);
}
.reader-page-title {
  font-size: 0.96rem;
}

article :is(h1, h2, h3, h4) code {
  border: 0;
  padding: 0;
  background: none;
  color: inherit;
}
article :is(ul, ol) :is(p, ul, ol) {
  margin-block: 0.25rem 0.55rem;
}
.reader-table {
  max-width: 100%;
  margin-block: 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: 0.55rem;
  background: var(--surface-subtle);
}
.reader-table table {
  width: 100%;
  min-width: 26rem;
}
.reader-table th,
.reader-table td {
  vertical-align: top;
}
.reader-table td > code {
  overflow-wrap: anywhere;
}

@media (max-width: 35rem) {
  dialog.search-dialog {
    width: calc(100% - 1.25rem);
    margin-top: 1.25rem;
    max-height: calc(100dvh - 2.5rem);
  }
  .search-footer {
    display: none;
  }
  .reader-pages {
    grid-template-columns: minmax(0, 1fr);
  }
  .reader-page-link[rel="next"] {
    grid-column: 1;
    align-items: flex-start;
    text-align: start;
  }
}

.docs-example {
  min-width: 0;
  margin-block: 1.4rem;
  border: 1px solid var(--rule);
  border-radius: 0.7rem;
  background: #11161a;
  overflow: hidden;
  box-shadow:
    0 1.25rem 2.75rem rgb(0 0 0 / 0.34),
    inset 0 1px 0 rgb(255 255 255 / 0.04);
}

.docs-example-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.5rem;
  padding: 0.36rem 0.75rem 0.36rem 1.15rem;
  border-block-end: 1px solid var(--rule-subtle);
  background: #161c21;
}

.docs-example-language {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.docs-example-controls button {
  min-height: 1.85rem;
  padding: 0.18rem 0.62rem;
  border: 1px solid var(--rule);
  border-radius: 0.32rem;
  background: #0e1215;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  transition:
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease;
}
.docs-example-controls button:hover,
.docs-example-controls button[data-copied="true"] {
  border-color: var(--accent-muted);
  background: var(--accent-surface);
  color: var(--accent);
}
.docs-example-controls button:focus:not(:focus-visible) {
  outline: none;
}

article .docs-example pre {
  margin: 0;
  padding: 1.05rem 1.2rem 1.15rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #e5ecef;
  font-size: 0.85rem;
  line-height: 1.68;
  overflow-wrap: normal;
  tab-size: 2;
}
article .docs-example pre:focus-visible {
  outline-offset: -3px;
}

article blockquote {
  margin: 1.35rem 0;
  padding: 0.85rem 1.1rem;
  border-left: 2px solid var(--accent);
  border-radius: 0 0.45rem 0.45rem 0;
  background: rgb(142 227 197 / 0.045);
  color: var(--ink-secondary);
}
article blockquote > :first-child {
  margin-top: 0;
}
article blockquote > :last-child {
  margin-bottom: 0;
}

.docs-example :is(.hljs-comment, .hljs-quote) {
  color: #7c8d93;
  font-style: italic;
}
.docs-example :is(.hljs-keyword, .hljs-selector-tag, .hljs-meta .hljs-keyword) {
  color: #93c5fd;
}
.docs-example :is(.hljs-string, .hljs-regexp, .hljs-meta .hljs-string) {
  color: #fde68a;
}
.docs-example :is(.hljs-number, .hljs-literal, .hljs-symbol, .hljs-constant) {
  color: #fca5a5;
}
.docs-example :is(.hljs-title, .hljs-title.function_, .hljs-selector-class) {
  color: #8ee3c5;
}
.docs-example :is(.hljs-type, .hljs-built_in, .hljs-title.class_) {
  color: #c4b5fd;
}
.docs-example
  :is(
    .hljs-attr,
    .hljs-attribute,
    .hljs-variable,
    .hljs-property,
    .hljs-selector-id
  ) {
  color: #dbe6eb;
}
.docs-example :is(.hljs-meta, .hljs-tag, .hljs-name, .hljs-section) {
  color: #8ee3c5;
}

@media (pointer: coarse) {
  .docs-example-controls button {
    min-height: 2.75rem;
  }
  .search-close {
    min-height: 2.4rem;
    min-width: 2.75rem;
  }
  .search-footer {
    display: none;
  }
}
