:root {
  --iq-brand: #0787f7;
  --iq-brand-strong: #006fdb;
  --iq-brand-soft: rgba(7, 135, 247, 0.1);
  --iq-border: rgba(128, 142, 157, 0.24);
  --iq-font-sans:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --iq-header-height: 72px;
  --iq-heading: var(--fg);
  --iq-outline-marker: 140;
  --iq-shadow: 0 10px 30px rgba(24, 39, 58, 0.1);
  --content-max-width: 800px;
  --menu-bar-height: var(--iq-header-height);
  --page-padding: clamp(24px, 4vw, 64px);
  --sidebar-width: 320px;
}

.light,
html:not(.js) {
  --bg: #ffffff;
  --fg: #30343b;
  --icons: #69717c;
  --icons-hover: #17191d;
  --iq-heading: #17191d;
  --sidebar-active: var(--iq-brand);
  --sidebar-bg: #fbfcfd;
  --sidebar-fg: #68717d;
  --theme-hover: #f0f4f8;
}

.rust {
  --iq-brand: #98502f;
  --iq-brand-strong: #7d4127;
  --iq-brand-soft: rgba(152, 80, 47, 0.12);
}

.rust .sidebar {
  --iq-brand: var(--sidebar-active);
  --iq-brand-soft: rgba(183, 146, 54, 0.16);
  --theme-hover: rgba(199, 164, 74, 0.1);
}

.rust #mdbook-menu-bar {
  --icons: #765f54;
  --icons-hover: var(--iq-brand);
  --iq-border: rgba(125, 65, 39, 0.24);
  --sidebar-fg: #765f54;
  --theme-hover: #eee9d8;
}

.rust .iq-page-outline {
  --iq-border: rgba(125, 65, 39, 0.24);
  --sidebar-fg: #765f54;
}

html {
  font-family: var(--iq-font-sans);
  scroll-padding-top: calc(var(--iq-header-height) + 24px);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-size: 1.6rem;
}

*:focus-visible {
  outline: 3px solid rgba(7, 135, 247, 0.38);
  outline-offset: 3px;
}

/* Header */

#mdbook-menu-bar {
  position: fixed !important;
  top: 0 !important;
  right: 0;
  left: 0;
  z-index: 210;
  box-sizing: border-box;
  height: var(--iq-header-height);
  margin: 0;
  padding: 0 16px;
  flex-wrap: nowrap;
  gap: 8px;
  background: var(--bg);
  border-block-end: 1px solid var(--iq-border);
  box-shadow: 0 1px 0 rgba(24, 39, 58, 0.02);
}

#mdbook-menu-bar-hover-placeholder {
  height: var(--iq-header-height);
  margin: 0;
}

#mdbook-menu-bar .menu-title {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  min-width: 0;
  margin: 0;
  color: var(--fg);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: var(--iq-header-height);
  letter-spacing: -0.02em;
  text-align: start;
  cursor: default;
}

#mdbook-menu-bar .menu-title::before {
  display: block;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  margin-inline-end: 14px;
  border-radius: 8px;
  background-image: url("../images/logo.png");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  content: "";
}

#mdbook-menu-bar > #mdbook-sidebar-toggle {
  align-self: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  margin: 0;
}

#mdbook-sidebar-toggle > .fa-svg {
  display: inline-flex;
  align-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 1;
}

#mdbook-sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

#mdbook-menu-bar .left-buttons {
  order: 0;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
  margin: 0;
}

#mdbook-menu-bar .right-buttons {
  order: 1;
  display: flex;
  align-items: center;
  margin: 0;
}

#mdbook-theme-list {
  right: 16px;
  left: auto;
}

#mdbook-menu-bar .icon-button,
#mdbook-menu-bar .right-buttons a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 8px;
  line-height: 1;
}

#mdbook-menu-bar .icon-button:hover,
#mdbook-menu-bar .right-buttons a:hover {
  background: var(--theme-hover);
}

#mdbook-search-toggle {
  justify-content: flex-start !important;
  width: auto !important;
  height: 40px !important;
  margin-inline-start: auto;
  padding-inline: 12px !important;
  gap: 5px;
  color: var(--sidebar-fg) !important;
  border: 1px solid var(--iq-border) !important;
  background: transparent !important;
  box-shadow: none;
}

#mdbook-search-toggle::after {
  color: var(--sidebar-fg);
  font: 600 1.4rem/1 var(--iq-font-sans);
  content: "Search";
}

#mdbook-search-toggle:hover {
  color: var(--iq-brand) !important;
  border-color: var(--iq-brand) !important;
  background: var(--theme-hover) !important;
}

.rust #mdbook-search-toggle:hover {
  color: #713a25 !important;
  border-color: #98502f !important;
  background: #eee9d8 !important;
}

.rust #mdbook-search-toggle:hover::after {
  color: #713a25;
}

#mdbook-search-wrapper {
  position: fixed;
  z-index: 205;
  inset: var(--iq-header-height) 0 auto 0;
  box-sizing: border-box;
  max-height: calc(100dvh - var(--iq-header-height));
  padding: 24px var(--page-padding) 28px;
  overflow-y: auto;
  background: var(--bg);
  border-block-end: 1px solid var(--iq-border);
  box-shadow: var(--iq-shadow);
}

@media only screen and (min-width: 620px) {
  #mdbook-sidebar-toggle-anchor:checked
    ~ .page-wrapper
    #mdbook-search-wrapper {
    inset-inline-start: var(--sidebar-width);
  }
}

.searchbar-outer,
.searchresults-outer {
  max-width: 920px;
}

#mdbook-searchbar {
  box-sizing: border-box;
  padding: 14px 18px;
  border-color: var(--iq-border);
  border-radius: 10px;
  background: var(--sidebar-bg);
  font: 500 1.6rem/1.4 var(--iq-font-sans);
}

#mdbook-searchbar:focus,
#mdbook-searchbar.active {
  border-color: var(--iq-brand);
  box-shadow: 0 0 0 3px var(--iq-brand-soft);
}

.rust #mdbook-search-wrapper {
  --searchresults-header-fg: #624c42;
  --searchresults-li-bg: rgba(166, 130, 43, 0.1);
}

.rust #mdbook-searchbar {
  color: #392a25;
  caret-color: #7d4127;
  border-color: rgba(125, 65, 39, 0.42);
  background: #f3f0e3;
}

.rust #mdbook-searchbar::placeholder {
  color: #765f54;
  opacity: 1;
}

.rust #mdbook-searchbar:focus,
.rust #mdbook-searchbar.active {
  color: #392a25;
  border-color: #98502f;
  background: #fbf8ec;
  box-shadow: 0 0 0 3px rgba(152, 80, 47, 0.18);
}

.rust #mdbook-searchbar-outer .spinner-wrapper {
  background: #fbf8ec;
}

.navy #mdbook-searchbar {
  color: #f0f2f8;
  caret-color: #f0f2f8;
  border-color: #59637b;
  background: #22283a;
}

.navy #mdbook-searchbar::placeholder {
  color: #b7bed1;
  opacity: 1;
}

.navy #mdbook-searchbar-outer .spinner-wrapper {
  background: #22283a;
}

.coal #mdbook-searchbar {
  color: #eef2f5;
  caret-color: #eef2f5;
  border-color: #59636b;
  background: #24282b;
}

.coal #mdbook-searchbar::placeholder {
  color: #b6c0c8;
  opacity: 1;
}

.coal #mdbook-searchbar-outer .spinner-wrapper {
  background: #24282b;
}

.searchresults-outer {
  border-block-end: 0;
}

ul#mdbook-searchresults {
  padding: 0;
}

ul#mdbook-searchresults li {
  margin: 4px 0;
  padding: 10px 12px;
  border-radius: 8px;
}

/* Sidebar */

.sidebar {
  top: var(--iq-header-height);
  z-index: 120;
  border-inline-end: 1px solid var(--iq-border);
}

.sidebar .sidebar-scrollbox {
  padding: 22px 18px 48px;
}

.chapter {
  line-height: 1.45;
}

.chapter li.chapter-item {
  margin-block-start: 2px;
}

.chapter-link-wrapper {
  align-items: center;
  border-radius: 6px;
}

.chapter-link-wrapper:has(> a.active) {
  background: var(--iq-brand-soft);
}

.chapter li a,
.chapter-link-wrapper > span {
  flex: 1 1 auto;
  padding: 8px 10px;
  color: var(--sidebar-fg);
  border-radius: 8px;
  font-size: 1.45rem;
  line-height: 1.35;
}

.chapter-link-wrapper:has(> .chapter-fold-toggle) > span {
  cursor: pointer;
}

.chapter li a:hover,
.chapter-link-wrapper:has(> .chapter-fold-toggle) > span:hover {
  color: var(--iq-brand);
  background: var(--theme-hover);
  text-decoration: none;
}

.chapter li a.active {
  color: var(--iq-brand);
  font-weight: 700;
}

.chapter .chapter-fold-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  min-width: 32px;
  margin-inline-end: 2px;
  padding: 0;
  color: var(--sidebar-fg);
  border-radius: 7px;
  opacity: 0.72;
}

.chapter .chapter-fold-toggle:hover {
  color: var(--iq-brand);
  background: var(--iq-brand-soft);
  opacity: 1;
}

.chapter .chapter-fold-toggle div {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  font-size: 0;
  transform: rotate(-45deg);
  transition:
    transform 160ms ease,
    color 160ms ease;
}

.chapter li.expanded > span > .chapter-fold-toggle div {
  transform: rotate(45deg);
}

.chapter li.header-item {
  margin-block: 22px 6px;
  padding-inline: 10px;
  color: var(--sidebar-fg);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.4;
  text-transform: uppercase;
}

.chapter .section {
  margin-inline-start: 13px;
  padding-inline-start: 10px;
  border-inline-start: 1px solid var(--iq-border);
}

.sidebar .sidebar-resize-handle {
  display: none;
}

/* Content */

.page {
  margin-block-start: 0;
  padding: 0;
}

#mdbook-content {
  display: grid;
  grid-template-columns: minmax(0, 800px) minmax(190px, 240px);
  gap: clamp(48px, 6vw, 88px);
  box-sizing: border-box;
  width: min(100%, 1220px);
  margin: 0 auto;
  padding: 52px var(--page-padding) 96px;
  overflow: visible;
}

#mdbook-content main {
  min-width: 0;
  max-width: none;
  margin: 0;
  color: var(--fg);
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: -0.006em;
}

.iq-page-title {
  margin: 0 0 68px;
  color: var(--iq-heading);
  font-size: clamp(3.8rem, 4vw, 4.8rem);
  font-weight: 720;
  line-height: 1.1;
  letter-spacing: -0.035em;
}

.content h1:not(.iq-page-title) {
  margin-block-start: 2.4em;
  color: var(--iq-heading);
  font-size: 3.6rem;
  font-weight: 720;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.content .iq-page-title + h1 {
  margin-block-start: 0;
}

.content h2 {
  margin-block-start: 2.4em;
  color: var(--iq-heading);
  font-size: 2.9rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.content h3 {
  margin-block-start: 2.2em;
  color: var(--iq-heading);
  font-size: 2.25rem;
  font-weight: 680;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.content h1,
.content h2,
.content h3,
.content h4 {
  margin-block-end: 0.72em;
}

.content p,
.content ol,
.content ul {
  line-height: 1.72;
}

.content p {
  margin-block: 0 1.35em;
}

.content ol,
.content ul {
  margin-block: 0 1.45em;
  padding-inline-start: 1.55em;
}

.content li {
  margin-block: 0.42em;
}

.content strong {
  color: var(--iq-heading);
  font-weight: 700;
}

.content a:link,
.content a:visited {
  color: var(--iq-brand-strong);
}

.content a:hover {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.content :not(pre) > code {
  padding: 0.14em 0.36em;
  border: 1px solid var(--iq-border);
  border-radius: 5px;
  background: var(--sidebar-bg);
  font-size: 0.88em;
}

.rust .content :not(pre) > code {
  color: #5f321f;
  border-color: #d6a27d;
  background: #f2d2b9;
}

.content img {
  height: auto;
  border: 1px solid var(--iq-border);
  border-radius: 10px;
}

.content table {
  width: 100%;
  margin-block: 28px;
}

.content table td,
.content table th {
  padding: 10px 14px;
  text-align: start;
}

.content blockquote {
  margin: 28px 0;
  padding: 16px 20px;
  border: 0;
  border-inline-start: 4px solid var(--iq-brand);
  border-radius: 0 8px 8px 0;
  background: var(--iq-brand-soft);
}

.content blockquote > :first-child {
  margin-block-start: 0;
}

.content blockquote > :last-child {
  margin-block-end: 0;
}

.content .blockquote-tag-tip {
  border-inline-start-color: #16a36a;
  background: rgba(22, 163, 106, 0.1);
}

.content .blockquote-tag-warning,
.content .blockquote-tag-caution {
  border-inline-start-color: #e58900;
  background: rgba(229, 137, 0, 0.11);
}

/* On-this-page outline */

.iq-page-outline {
  position: sticky;
  top: calc(var(--iq-header-height) + 30px);
  align-self: start;
  max-height: calc(100dvh - var(--iq-header-height) - 60px);
  padding-inline-start: 20px;
  overflow-y: auto;
  border-inline-start: 1px solid var(--iq-border);
}

.iq-page-outline__label {
  margin-block-end: 16px;
  color: var(--sidebar-fg);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.iq-page-outline ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.iq-page-outline li {
  margin: 0;
}

.iq-page-outline a {
  display: block;
  padding: 6px 0;
  color: var(--sidebar-fg);
  font-size: 1.35rem;
  line-height: 1.4;
  text-decoration: none;
}

.iq-page-outline a:hover,
.iq-page-outline a[aria-current="location"] {
  color: var(--iq-brand);
  text-decoration: none;
}

.iq-page-outline a[aria-current="location"] {
  font-weight: 700;
}

.iq-page-outline__level-2 {
  padding-inline-start: 12px;
}

.iq-page-outline__level-3 {
  padding-inline-start: 24px;
}

#mdbook-content > .nav-wrapper {
  grid-column: 1 / -1;
}

.nav-wide-wrapper {
  display: none;
}

@media only screen and (max-width: 1180px) {
  #mdbook-content {
    display: block;
    width: min(100%, 940px);
  }

  .iq-page-outline {
    display: none;
  }
}

@media only screen and (max-width: 760px) {
  :root {
    --iq-header-height: 64px;
    --page-padding: 20px;
  }

  #mdbook-menu-bar {
    padding: 0 12px;
    gap: 4px;
  }

  #mdbook-menu-bar .menu-title {
    max-width: min(52vw, 250px);
    font-size: 1.55rem;
  }

  #mdbook-menu-bar .menu-title::before {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
    margin-inline-end: 9px;
  }

  #mdbook-search-toggle {
    justify-content: center !important;
    width: 42px !important;
    margin-inline-start: auto;
    padding: 0 !important;
    border-color: transparent !important;
    background: transparent !important;
  }

  #mdbook-search-toggle::after {
    display: none;
  }

  #mdbook-search-wrapper {
    padding-block: 18px 22px;
  }

  .sidebar .sidebar-scrollbox {
    padding-inline: 14px;
  }

  #mdbook-content {
    padding-block: 38px 72px;
  }

  .iq-page-title {
    margin-block-end: 42px;
    font-size: 3.4rem;
  }

  .content h1:not(.iq-page-title) {
    font-size: 2.8rem;
  }

  .content h2 {
    font-size: 2.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
