:root {
  --content-max-width: 920px;
  --mono-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.light,
.rust,
html:not(.js) {
  --bg: #fff9ed;
  --fg: #1d211f;
  --sidebar-bg: #eaf4df;
  --sidebar-fg: #1d211f;
  --sidebar-non-existant: #59615b;
  --sidebar-active: #17643d;
  --sidebar-spacer: #d0d7ce;
  --scrollbar: #949e97;
  --icons: #59615b;
  --icons-hover: #1d211f;
  --links: #17643d;
  --inline-code-color: #1d211f;
  --theme-popup-bg: #ffffff;
  --theme-popup-border: #949e97;
  --theme-hover: #e7eae6;
  --quote-bg: #fff0c3;
  --quote-border: #e5a91f;
  --table-border-color: #d0d7ce;
  --table-header-bg: #dceefa;
  --table-alternate-bg: #f3f8ec;
  --searchbar-border-color: #949e97;
  --searchbar-bg: #ffffff;
  --searchbar-fg: #1d211f;
  --sidebar-header-border-color: #17643d;
  --code-bg: #ffffff;
  --code-border: #949e97;
}

.ayu,
.coal,
.navy {
  --bg: #252b33;
  --fg: #faf1df;
  --sidebar-bg: #303a43;
  --sidebar-fg: #faf1df;
  --sidebar-non-existant: #c6d3c9;
  --sidebar-active: #b9ed9e;
  --sidebar-spacer: #526b65;
  --scrollbar: #79928d;
  --icons: #c6d3c9;
  --icons-hover: #faf1df;
  --links: #b9ed9e;
  --inline-code-color: #faf1df;
  --theme-popup-bg: #303a43;
  --theme-popup-border: #79928d;
  --theme-hover: #3b4b44;
  --quote-bg: #494431;
  --quote-border: #e5a91f;
  --table-border-color: #526b65;
  --table-header-bg: #344d5b;
  --table-alternate-bg: #2e3c39;
  --searchbar-border-color: #79928d;
  --searchbar-bg: #303a43;
  --searchbar-fg: #faf1df;
  --sidebar-header-border-color: #b9ed9e;
  --code-bg: #303a43;
  --code-border: #79928d;
}

/* Without JavaScript, mdBook cannot apply a theme class, so follow the system preference. */
@media (prefers-color-scheme: dark) {
  html:not(.js) {
    --bg: #252b33;
    --fg: #faf1df;
    --sidebar-bg: #303a43;
    --sidebar-fg: #faf1df;
    --sidebar-non-existant: #c6d3c9;
    --sidebar-active: #b9ed9e;
    --sidebar-spacer: #526b65;
    --scrollbar: #79928d;
    --icons: #c6d3c9;
    --icons-hover: #faf1df;
    --links: #b9ed9e;
    --inline-code-color: #faf1df;
    --theme-popup-bg: #303a43;
    --theme-popup-border: #79928d;
    --theme-hover: #3b4b44;
    --quote-bg: #494431;
    --quote-border: #e5a91f;
    --table-border-color: #526b65;
    --table-header-bg: #344d5b;
    --table-alternate-bg: #2e3c39;
    --searchbar-border-color: #79928d;
    --searchbar-bg: #303a43;
    --searchbar-fg: #faf1df;
    --sidebar-header-border-color: #b9ed9e;
    --code-bg: #303a43;
    --code-border: #79928d;
  }

  html:not(.js) code.nohighlight span {
    color: var(--shiki-dark);
  }
}

/* Code blocks highlighted at build time carry both palettes as custom properties. */
code.nohighlight span {
  color: var(--shiki-light);
}

:is(.ayu, .coal, .navy) code.nohighlight span {
  color: var(--shiki-dark);
}

html {
  font-family: system-ui, -apple-system, sans-serif;
}

body {
  font-size: 1.5rem;
  line-height: 1.55;
}

.menu-title {
  font-weight: 700;
  letter-spacing: -0.01em;
}

.content main h1 {
  font-size: 2.8rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-block: 1.6rem 1rem;
}

.content main h2 {
  font-size: 1.9rem;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--table-border-color);
  padding-bottom: 0.35rem;
}

.content main h3 {
  font-size: 1.55rem;
}

.content a {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

pre {
  background: var(--code-bg) !important;
  border: 1px solid var(--code-border);
  border-radius: 2px;
  padding: 1.1rem;
}

pre > code,
.hljs {
  background: transparent !important;
  color: var(--fg) !important;
  font-size: 1.3rem;
  line-height: 1.6;
}

:not(pre) > code {
  background: var(--table-header-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  font-size: 0.88em;
}

table {
  width: 100%;
  margin: 1.4rem 0;
  font-size: 1.38rem;
}

table th,
table td {
  padding: 0.65rem 1rem;
  text-align: left;
  vertical-align: top;
}

.chapter li.part-title {
  font: 700 1.1rem/1.4 var(--mono-font);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-non-existant);
  margin: 1.8rem 0 0.4rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--sidebar-spacer);
}

.chapter > li.chapter-item {
  margin-block-start: 0.45em;
}

.chapter > li.chapter-item > .chapter-link-wrapper > a {
  font-weight: 600;
  font-size: 1.45rem;
}

.on-this-page {
  margin: 0.35rem 0 0.65rem 0.8rem;
  border-inline-start: 2px solid var(--sidebar-spacer);
  padding-left: 1rem;
}

.chapter li.header-item {
  margin-block-end: 0.3em;
  line-height: 1.35em;
}

.chapter li.header-item a.header-in-summary {
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--sidebar-non-existant);
}

.chapter li.header-item a.header-in-summary.current-header,
.chapter li.header-item a.header-in-summary:hover {
  color: var(--sidebar-active);
  font-weight: 600;
}

.pw-site-nav {
  display: inline-flex;
  gap: 1.2rem;
  margin-inline-end: 1.2rem;
  font-size: 1.4rem;
}

.pw-site-nav a {
  color: var(--icons);
  text-decoration: none;
}

.pw-site-nav a:hover {
  color: var(--links);
}
