/* Collapsible book navigation */
.book-rail .book-navigation {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 0 16px;
  scrollbar-color: rgba(255, 255, 255, .24) transparent;
  scrollbar-width: thin;
}

.rail-primary,
.rail-utility {
  display: grid;
}

.rail-parts {
  margin: 10px 0;
  border-block: 1px solid rgba(255, 255, 255, .11);
}

.rail-part + .rail-part {
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.rail-part-toggle {
  position: relative;
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 5px;
  padding: 9px 11px 9px 5px;
  border: 0;
  border-left: 3px solid transparent;
  background: rgba(3, 20, 47, .12);
  color: #c2d1df;
  cursor: pointer;
  text-align: left;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}

.rail-part-toggle:hover,
.rail-part-toggle:focus-visible,
.rail-part.contains-current > .rail-part-toggle {
  border-left-color: var(--amber);
  background: rgba(255, 255, 255, .07);
  color: #fff;
}

.rail-part-toggle > span {
  color: var(--amber);
  font: 750 .62rem var(--sans);
  letter-spacing: .06em;
  text-align: center;
}

.rail-part-toggle > b {
  min-width: 0;
  display: grid;
  gap: 2px;
  letter-spacing: .01em;
}

.rail-part-toggle > b small {
  color: #88a7c2;
  font: 720 .49rem/1 var(--sans);
  letter-spacing: .13em;
  text-transform: uppercase;
}

.rail-part-toggle > b strong {
  color: currentColor;
  font: 650 .62rem/1.24 var(--sans);
}

.rail-part-toggle > b em {
  margin-top: 2px;
  color: #7898b4;
  font: 570 .48rem/1.2 var(--sans);
  font-style: normal;
  letter-spacing: .025em;
}

.rail-part.contains-current > .rail-part-toggle > b em {
  color: #a8bed1;
}

.rail-part-toggle > i {
  color: var(--cyan);
  font: 400 1rem/1 var(--sans);
  font-style: normal;
  text-align: center;
  transform: rotate(0deg);
  transition: transform .18s ease;
}

.rail-part.open > .rail-part-toggle > i {
  transform: rotate(90deg);
}

.rail-chapters {
  padding: 4px 0 8px;
  background: rgba(2, 17, 41, .22);
}

.rail-chapters[hidden] {
  display: none;
}

.rail-chapter {
  width: 100%;
  min-height: 49px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  padding: 7px 11px 7px 5px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: #94abc0;
  cursor: pointer;
  text-align: left;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.rail-chapter > span {
  color: #6f91ad;
  font: 720 .56rem/1 var(--sans);
  letter-spacing: .05em;
  text-align: center;
}

.rail-chapter > b {
  min-width: 0;
  font: 570 .58rem/1.28 var(--sans);
  letter-spacing: .01em;
  overflow-wrap: normal;
  word-break: normal;
}

.rail-chapter:hover,
.rail-chapter.active {
  border-left-color: var(--cyan);
  background: rgba(255, 255, 255, .075);
  color: #fff;
}

.rail-chapter.active > span {
  color: var(--amber);
}

.rail-utility {
  padding-top: 3px;
}

@media (min-width: 761px) {
  .rail-collapsed .rail-part-toggle {
    grid-template-columns: 1fr;
    padding-inline: 0;
  }

  .rail-collapsed .rail-part-toggle > b,
  .rail-collapsed .rail-part-toggle > i,
  .rail-collapsed .rail-chapters {
    display: none;
  }
}

@media (max-width: 760px) {
  .book-rail .book-navigation {
    padding-top: 4px;
  }

  .rail-part-toggle {
    grid-template-columns: 50px minmax(0, 1fr) 24px;
    min-height: 62px;
    padding-right: 18px;
  }

  .rail-part-toggle > b {
    font-size: .68rem;
  }

  .rail-part-toggle > b strong {
    font-size: .68rem;
  }

  .rail-part-toggle > b em {
    font-size: .54rem;
  }

  .rail-chapter {
    grid-template-columns: 50px minmax(0, 1fr);
    min-height: 52px;
    padding-right: 18px;
  }

  .rail-chapter > b {
    font-size: .64rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rail-part-toggle,
  .rail-part-toggle > i,
  .rail-chapter {
    transition: none;
  }
}

/* Global sidebar legibility: enlarge every text label by 2pt. */
.book-rail .rail-link b { font-size:calc(.63rem + 2pt); }
.book-rail .rail-part-toggle > b small { font-size:calc(.49rem + 2pt); }
.book-rail .rail-part-toggle > b strong { font-size:calc(.62rem + 2pt); }
.book-rail .rail-part-toggle > b em { font-size:calc(.48rem + 2pt); }
.book-rail .rail-chapter > b { font-size:calc(.58rem + 2pt); }
