:root {
  --bilingual-zh-main: var(--fg);
  --bilingual-zh-heading: var(--fg);
  --bilingual-zh-sidebar: var(--fg);
  --bilingual-en-main: color-mix(in srgb, var(--fg) 72%, #6b7280 28%);
  --bilingual-en-sidebar: color-mix(in srgb, var(--fg) 58%, #7c8798 42%);
}

@media (min-width: 1024px) {
  :root {
    --sidebar-target-width: 330px;
  }
}

html.coal,
html.navy,
html.ayu {
  --bilingual-zh-main: #f2f5f7;
  --bilingual-zh-heading: #ffffff;
  --bilingual-zh-sidebar: #edf2f7;
  --bilingual-en-main: color-mix(in srgb, var(--fg) 68%, #8f98a8 32%);
  --bilingual-en-sidebar: color-mix(in srgb, var(--fg) 54%, #8f98a8 46%);
}

html.rust {
  --bilingual-zh-sidebar: #f6eee6;
  --bilingual-en-sidebar: color-mix(in srgb, #f6eee6 64%, #d1b39c 36%);
}

main .zh-inline,
main .bi-main-zh {
  display: block;
  margin-bottom: 0.24rem;
  color: var(--bilingual-zh-main);
  opacity: 0.96;
  font-size: 1.04em;
  line-height: 1.7;
  font-weight: 600;
}

main h1 .zh-inline,
main h2 .zh-inline,
main h3 .zh-inline,
main h4 .zh-inline,
main h1 .bi-main-zh,
main h2 .bi-main-zh,
main h3 .bi-main-zh,
main h4 .bi-main-zh {
  margin-bottom: 0.3rem;
  color: var(--bilingual-zh-heading);
  opacity: 1;
  font-size: 0.8em;
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: 0.01em;
}

main .bi-main-en {
  display: block;
  color: var(--bilingual-en-main);
  opacity: 0.8;
  font-size: 0.96em;
  line-height: 1.72;
}

main .bi-main-zh-alt {
  display: block;
  margin-top: 0.04rem;
  color: var(--bilingual-zh-main);
  opacity: 0.78;
  font-size: 0.95em;
  line-height: 1.7;
  font-weight: 500;
}

main h1 .bi-main-en,
main h2 .bi-main-en,
main h3 .bi-main-en,
main h4 .bi-main-en {
  font-size: 0.64em;
  line-height: 1.2;
  opacity: 0.72;
  font-weight: 600;
  letter-spacing: 0.015em;
}

main h1 .bi-main-zh-alt,
main h2 .bi-main-zh-alt,
main h3 .bi-main-zh-alt,
main h4 .bi-main-zh-alt {
  margin-top: 0.08rem;
  color: var(--bilingual-zh-main);
  opacity: 0.82;
  font-size: 0.68em;
  line-height: 1.26;
  font-weight: 600;
  letter-spacing: 0.01em;
}

main li .zh-inline,
main li .bi-main-zh {
  margin-bottom: 0.12rem;
}

main blockquote .zh-inline,
main blockquote .bi-main-zh {
  opacity: 0.9;
}

main td .zh-inline,
main th .zh-inline,
main td .bi-main-zh,
main th .bi-main-zh {
  margin-bottom: 0.12rem;
  font-size: 1em;
}

main td .bi-main-en,
main th .bi-main-en {
  font-size: 0.92em;
}

.sidebar .chapter-link-wrapper > a,
.sidebar-scrollbox .chapter-link-wrapper > a {
  display: block;
  padding-top: 0.18rem;
  padding-bottom: 0.18rem;
  line-height: 1.48;
}

.sidebar .sidebar-scrollbox {
  padding: 18px 16px 28px;
}

.sidebar .chapter,
.sidebar-scrollbox .chapter {
  padding-right: 0.42rem;
}

.sidebar .chapter li.chapter-item,
.sidebar-scrollbox .chapter li.chapter-item {
  margin-bottom: 0.78rem;
}

.sidebar .chapter > li.chapter-item,
.sidebar-scrollbox .chapter > li.chapter-item {
  margin-bottom: 0.92rem;
}

.sidebar .chapter ul,
.sidebar-scrollbox .chapter ul {
  margin-top: 0.38rem;
  margin-bottom: 0.46rem;
}

.sidebar .chapter li.chapter-item > .chapter,
.sidebar-scrollbox .chapter li.chapter-item > .chapter {
  margin-top: 0.44rem;
  padding-left: 0.58rem;
}

.sidebar .chapter li.chapter-item > .chapter > li.chapter-item,
.sidebar-scrollbox .chapter li.chapter-item > .chapter > li.chapter-item {
  margin-bottom: 0.64rem;
}

.sidebar .chapter .part-title,
.sidebar-scrollbox .chapter .part-title {
  margin-top: 1rem;
  margin-bottom: 0.54rem;
}

.sidebar .chapter-link-wrapper > a .bi-zh,
.sidebar-scrollbox .chapter-link-wrapper > a .bi-zh,
.sidebar .chapter .part-title .bi-zh,
.sidebar-scrollbox .chapter .part-title .bi-zh,
.menu-title .bi-zh {
  display: block;
  color: var(--bilingual-zh-sidebar);
  font-size: 0.98em;
  line-height: 1.4;
  font-weight: 600;
  opacity: 0.96;
}

.sidebar .chapter-link-wrapper > a .bi-en,
.sidebar-scrollbox .chapter-link-wrapper > a .bi-en,
.sidebar .chapter .part-title .bi-en,
.sidebar-scrollbox .chapter .part-title .bi-en,
.menu-title .bi-en {
  display: block;
  margin-top: 0.28rem;
  color: var(--bilingual-en-sidebar);
  font-size: 0.88em;
  line-height: 1.4;
  opacity: 0.76;
}

.sidebar .chapter-link-wrapper > a .bi-zh-alt,
.sidebar-scrollbox .chapter-link-wrapper > a .bi-zh-alt,
.sidebar .chapter .part-title .bi-zh-alt,
.sidebar-scrollbox .chapter .part-title .bi-zh-alt,
.menu-title .bi-zh-alt {
  display: block;
  margin-top: 0.28rem;
  color: var(--bilingual-zh-sidebar);
  font-size: 0.88em;
  line-height: 1.4;
  font-weight: 500;
  opacity: 0.78;
}

.sidebar .chapter-link-wrapper > a .bi-zh strong,
.sidebar-scrollbox .chapter-link-wrapper > a .bi-zh strong,
.sidebar .chapter-link-wrapper > a .bi-en strong,
.sidebar-scrollbox .chapter-link-wrapper > a .bi-en strong {
  margin-right: 0.38rem;
}

.menu-title {
  line-height: 1.22;
  margin-bottom: 0.4rem;
}

.menu-title .bi-en {
  font-size: 0.74em;
  opacity: 0.72;
}

.menu-title .bi-zh {
  font-size: 0.86em;
  opacity: 0.98;
}

main .bi-image-shell {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}

main .bi-image-shell > img,
main .bi-image-shell > svg {
  display: block;
  max-width: 100%;
  height: auto;
}

main .bi-image-zoom-button {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
  width: 2.15rem;
  height: 2.15rem;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.74);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(6px);
  transition: transform 0.18s ease, background-color 0.18s ease, opacity 0.18s ease;
  opacity: 0.94;
}

main .bi-image-zoom-button:hover,
main .bi-image-zoom-button:focus-visible {
  background: rgba(31, 41, 55, 0.92);
  transform: scale(1.05);
}

body.bi-image-modal-open {
  overflow: hidden;
}

.bi-image-modal[hidden] {
  display: none;
}

.bi-image-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.bi-image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
}

.bi-image-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(96vw, 1440px);
  max-height: 92vh;
  margin: 4vh auto;
  padding: 3.2rem 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bi-image-modal-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-height: calc(92vh - 5.4rem);
}

.bi-image-modal-content {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 5.4rem);
  object-fit: contain;
  border-radius: 14px;
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.46);
  background: rgba(15, 23, 42, 0.9);
}

.bi-image-modal-svg {
  width: auto;
  height: auto;
  padding: 1rem;
  overflow: visible;
}

.bi-image-modal-caption {
  margin-top: 0.9rem;
  max-width: min(92vw, 980px);
  color: #e8edf5;
  text-align: center;
  font-size: 0.96rem;
  line-height: 1.6;
}

.bi-image-modal-close {
  position: absolute;
  top: 0.25rem;
  right: 0.3rem;
  width: 2.4rem;
  height: 2.4rem;
  border: 0;
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.84);
  color: #fff;
  font-size: 1.35rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
}

.bi-image-modal-close:hover,
.bi-image-modal-close:focus-visible {
  background: rgba(31, 41, 55, 0.96);
}

@media (max-width: 768px) {
  main .bi-image-zoom-button {
    top: 0.45rem;
    right: 0.45rem;
    width: 1.95rem;
    height: 1.95rem;
    font-size: 0.92rem;
  }

  .bi-image-modal-dialog {
    width: 100vw;
    margin: 2vh auto;
    padding: 3rem 0.6rem 1rem;
  }

  .bi-image-modal-stage,
  .bi-image-modal-content {
    max-height: calc(96vh - 5rem);
  }
}
