:root {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  color-scheme: light dark;

  --text: #000;
  --text-muted: #555;
  --background: #fff;
  --border: #ccc;
  --accent: #ff4c4c;
  --navbar: #ff4c4c;
  --link: #0000ee;
  --link-visited: #551a8b;
  --code-background: #eee;
  --code-title-background: #f3f3f3;
  --hover: rgba(0, 0, 0, 0.05);
  --sidebar-current: rgba(255, 76, 76, 0.12);
  --highlighted-line: rgba(255, 215, 0, 0.25);
  --search-match: rgba(255, 215, 0, 0.35);
  --search-input-background: rgba(255, 255, 255, 0.9);

  --note: #4493f8;
  --tip: #1f883d;
  --warning: #bf8700;
  --danger: #d1242f;

  --sidebar-width: 250px;
  --layout-gap: 2.5rem;
  --content-width: 800px;
  --layout-padding: 1rem;
  --navbar-height: 3rem;
  /* Exactly fits the sidebar and content, so the navbar lines up with both edges */
  --layout-width: calc(var(--sidebar-width) + var(--layout-gap) + var(--content-width) + 2 * var(--layout-padding));
}
@media (prefers-color-scheme: dark) {
  :root {
    --text: #eee;
    --text-muted: #aaa;
    --background: #131313;
    --border: #444;
    --navbar: #333;
    --link: #56b2ff;
    --link-visited: #f192ff;
    --code-background: #2a2a2a;
    --code-title-background: #252525;
    --hover: rgba(255, 255, 255, 0.07);
    --sidebar-current: rgba(255, 76, 76, 0.18);
    --highlighted-line: rgba(255, 255, 255, 0.1);
    --search-match: rgba(255, 215, 0, 0.3);
    --search-input-background: var(--background);

    --tip: #3fb950;
    --warning: #d29922;
    --danger: #f85149;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--background);
  line-height: 1.5;
}

a {
  color: var(--link);
}
a:where(:visited) {
  color: var(--link-visited);
}

.navbar {
  background: var(--navbar);
  color: white;
}
.navbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.25rem;
  max-width: var(--layout-width);
  margin: 0 auto;
  padding: 0.5rem var(--layout-padding);
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
  font-size: 1.1em;
  color: inherit;
  text-decoration: none;
}
.navbar-brand:hover {
  text-decoration: underline;
}
.navbar-brand img {
  flex-shrink: 0;
}
.navbar-search {
  position: relative;
  margin-left: auto;
}
.navbar-search input {
  font: inherit;
  width: 12rem;
  padding: 0.25rem 0.6rem;
  border: none;
  border-radius: 4px;
  color: var(--text);
  background: var(--search-input-background);
}

.layout {
  display: flex;
  gap: var(--layout-gap);
  max-width: var(--layout-width);
  margin: 0 auto;
  padding: 0 var(--layout-padding);
}
.sidebar {
  flex-shrink: 0;
  width: var(--sidebar-width);
  position: sticky;
  top: 0;
  align-self: flex-start;
  max-height: 100vh;
  overflow-y: auto;
  padding: 1rem 0;
}
.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sidebar a {
  display: block;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
}
.sidebar a:hover {
  background: var(--hover);
}
.sidebar a[aria-current="page"] {
  font-weight: bold;
  color: var(--accent);
  background: var(--sidebar-current);
}
.sidebar-category > :first-child {
  display: block;
  margin-top: 0.75rem;
  padding: 0.3rem 0.6rem;
  font-weight: bold;
}
.sidebar-category ul {
  margin: 0 0 0.75rem 0.6rem;
  padding-left: 0.4rem;
  border-left: 1px solid var(--border);
}
.sidebar-category .sidebar-category > :first-child {
  margin-top: 0;
}
.sidebar-category .sidebar-category ul {
  margin-bottom: 0;
}
.sidebar-toggle {
  display: none;
}

@media (min-width: 801px) {
  /* Not scroll-padding on html because then browsers think the search box is hidden under the navbar and
  scroll the page every time you type in it */
  .content [id] {
    scroll-margin-top: calc(var(--navbar-height) + 0.75rem);
  }
  .navbar {
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .navbar-inner {
    height: var(--navbar-height);
    padding-block: 0;
  }
  .sidebar {
    top: var(--navbar-height);
    max-height: calc(100vh - var(--navbar-height));
  }
}

@media (max-width: 800px) {
  .layout {
    display: block;
  }
  .navbar-search {
    margin-left: 0;
    width: 100%;
  }
  .navbar-search input {
    width: 100%;
  }
  .search-dropdown {
    width: 100%;
  }
  .sidebar {
    position: static;
    width: auto;
    max-height: none;
    border-bottom: 1px solid var(--border);
  }
  .js .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin: 0.75rem 0 0;
    padding: 0.5rem;
    font: inherit;
    font-weight: bold;
    color: inherit;
    background: var(--hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
  }
  .js .sidebar:not(.open) {
    display: none;
  }
}

.content {
  flex: 1;
  min-width: 0;
  max-width: var(--content-width);
  padding-top: 0.5rem;
  padding-bottom: 3rem;
  overflow-wrap: break-word;
}
.content h1 {
  font-size: 2.25rem;
  line-height: 1.2;
}
.content h1,
.content h2 {
  padding-bottom: 0.2em;
  border-bottom: 1px solid var(--border);
}
.content h2 {
  margin-top: 2rem;
}
.hash-link {
  margin-left: 0.3em;
  color: var(--text-muted);
  text-decoration: none;
  opacity: 0;
}
:is(h2, h3, h4, h5, h6):hover > .hash-link,
.hash-link:focus {
  opacity: 1;
}
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}
img {
  max-width: 100%;
}
li + li {
  margin-top: 0.25em;
}
table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1rem 0;
}
th,
td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.7rem;
}
thead th,
tr:has(> th) {
  background: var(--hover);
}
details {
  margin: 1rem 0;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}
summary {
  cursor: pointer;
  font-weight: bold;
}
details[open] > summary {
  margin-bottom: 0.5rem;
}
iframe {
  max-width: 100%;
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.875em;
}
:not(pre) > code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--code-background);
}
.code-block {
  position: relative;
  margin: 1rem 0;
}
.code-block pre {
  margin: 0;
  padding: 0.75rem 0;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.45;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.code-block code {
  display: inline-block;
  min-width: 100%;
  padding: 0 1rem;
  font-size: inherit;
  counter-reset: line;
}
.code-block .line {
  display: block;
}
.code-block .line.highlighted {
  margin: 0 -1rem;
  padding: 0 1rem;
  background: var(--highlighted-line);
}
.line-numbers .line::before {
  counter-increment: line;
  content: counter(line);
  display: inline-block;
  width: 2em;
  margin-right: 1.25em;
  text-align: right;
  color: var(--text-muted);
  opacity: 0.6;
  user-select: none;
}
.code-title {
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: var(--code-title-background);
}
.code-title + pre {
  border-radius: 0 0 4px 4px;
}
.copy-button {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  padding: 0.2rem 0.5rem;
  font: inherit;
  font-size: 0.8rem;
  color: inherit;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.code-block:hover .copy-button,
.copy-button:focus {
  opacity: 1;
}
@media (hover: none) {
  .copy-button {
    opacity: 1;
  }
}

pre.blocks {
  margin: 1rem 0;
  overflow-x: auto;
}
pre.blocks svg {
  display: block;
}

.admonition {
  --color: var(--note);
  margin: 1rem 0;
  padding: 0.6rem 1rem;
  border-left: 0.25rem solid var(--color);
  border-radius: 0 4px 4px 0;
  background: color-mix(in srgb, var(--color) 8%, transparent);
}
.admonition-tip {
  --color: var(--tip);
}
.admonition-warning,
.admonition-caution {
  --color: var(--warning);
}
.admonition-danger {
  --color: var(--danger);
}
.admonition-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
  color: var(--color);
}
.admonition-title {
  margin: 0 0 0.25rem;
}
.admonition > :last-child {
  margin-bottom: 0;
}
.admonition-title + * {
  margin-top: 0;
}
.admonition > h2 {
  margin-top: 0.5rem;
  border-bottom: none;
}

.js .spoiler:not(.revealed) {
  color: transparent;
  background: var(--text);
  border-radius: 2px;
  cursor: pointer;
}
.js .spoiler:not(.revealed) * {
  visibility: hidden;
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  right: 0;
  z-index: 10;
  width: min(32rem, calc(100vw - 2rem));
  max-height: min(32rem, 70vh);
  overflow-y: auto;
  padding: 0.25rem;
  color: var(--text);
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.search-dropdown:not(:has(a)) {
  padding: 0.5rem 0.75rem;
}
.search-result {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  color: inherit;
  text-decoration: none;
}
.search-result:hover,
.search-result.active {
  background: var(--hover);
}
.search-result-title {
  display: block;
  font-weight: bold;
}
.search-result-text {
  display: block;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.search-result mark {
  color: inherit;
  background: var(--search-match);
}
.search-result-all {
  color: var(--link);
}
.search-page-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0 -0.6rem;
}
