.lfihm-toc {
  --toc-navy: var(--navy, #071d49);
  --toc-blue: var(--blue, #0839a8);
  --toc-cyan: var(--cyan, #23b5c5);
  --toc-gold: var(--gold, #e2aa4f);
  --toc-muted: var(--muted, #647087);
  position: fixed;
  z-index: 950;
  right: 22px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.lfihm-toc[hidden],
.lfihm-toc [hidden] {
  display: none !important;
}

.lfihm-toc--left {
  right: auto;
  left: 22px;
  align-items: flex-start;
}

.lfihm-toc__progress {
  position: absolute;
  right: 0;
  bottom: -5px;
  width: 100%;
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(7, 29, 73, .17);
}

.lfihm-toc__progress span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--toc-gold), var(--toc-cyan));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform .12s linear;
}

.lfihm-toc__toggle {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(226, 170, 79, .58);
  border-radius: 999px;
  background: var(--toc-navy);
  color: #fff;
  box-shadow: 0 14px 35px rgba(7, 29, 73, .25);
  font: inherit;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}

.lfihm-toc__toggle:hover {
  background: #0b2a65;
  box-shadow: 0 17px 40px rgba(7, 29, 73, .3);
  transform: translateY(-2px);
}

.lfihm-toc__toggle b {
  display: grid;
  min-width: 35px;
  min-height: 26px;
  place-items: center;
  border-radius: 999px;
  background: rgba(35, 181, 197, .17);
  color: #a9ebf0;
  font-size: .66rem;
}

.lfihm-toc__toggle-icon {
  display: grid;
  width: 19px;
  gap: 3px;
}

.lfihm-toc__toggle-icon i {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: var(--toc-gold);
}

.lfihm-toc__toggle-icon i:nth-child(2) { width: 14px; }
.lfihm-toc__toggle-icon i:nth-child(3) { width: 10px; }

.lfihm-toc__panel {
  width: min(365px, calc(100vw - 32px));
  max-height: min(610px, calc(100vh - 115px));
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid rgba(226, 170, 79, .38);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 25px 70px rgba(7, 29, 73, .25);
  animation: lfihm-toc-enter .22s ease both;
}

.lfihm-toc__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 20px 17px;
  background:
    radial-gradient(circle at 93% 8%, rgba(35, 181, 197, .18), transparent 31%),
    var(--toc-navy);
  color: #fff;
}

.lfihm-toc__head p {
  margin: 0 0 5px;
  color: #98e1e8;
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .17em;
  text-transform: uppercase;
}

.lfihm-toc__head h2 {
  margin: 0;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.42rem;
  line-height: 1.15;
}

.lfihm-toc__close {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0 0 3px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: #fff;
  font: 300 1.45rem/1 Arial, sans-serif;
  cursor: pointer;
}

.lfihm-toc__panel nav {
  max-height: min(405px, calc(100vh - 270px));
  padding: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.lfihm-toc__list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lfihm-toc__list a {
  position: relative;
  display: block;
  padding: 9px 11px 9px 27px;
  border-radius: 9px;
  color: #32425b;
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.38;
  text-decoration: none;
  transition: background .18s ease, color .18s ease;
}

.lfihm-toc__list a::before {
  position: absolute;
  top: 15px;
  left: 11px;
  width: 6px;
  height: 6px;
  border: 1px solid var(--toc-gold);
  content: "";
  transform: rotate(45deg);
}

.lfihm-toc__list a:hover {
  background: #f1f6fb;
  color: var(--toc-blue);
}

.lfihm-toc__list a[aria-current="location"] {
  background: #eaf7f8;
  color: var(--toc-navy);
}

.lfihm-toc__list a[aria-current="location"]::before {
  border-color: var(--toc-cyan);
  background: var(--toc-cyan);
  box-shadow: 0 0 0 4px rgba(35, 181, 197, .13);
}

.lfihm-toc__level-3 a { padding-left: 41px; color: #69768a; font-size: .73rem; }
.lfihm-toc__level-3 a::before { left: 25px; width: 5px; height: 5px; }
.lfihm-toc__level-4 a { padding-left: 54px; color: #7c8798; font-size: .7rem; }
.lfihm-toc__level-4 a::before { left: 38px; width: 4px; height: 4px; }

.lfihm-toc__top {
  display: flex;
  width: calc(100% - 20px);
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0 10px 10px;
  border: 0;
  border-radius: 10px;
  background: #f3f6fa;
  color: var(--toc-blue);
  font: inherit;
  font-size: .72rem;
  font-weight: 850;
  cursor: pointer;
}

.lfihm-toc__top span {
  color: var(--toc-gold);
  font-size: 1rem;
}

.lfihm-toc__toggle:focus-visible,
.lfihm-toc__close:focus-visible,
.lfihm-toc__list a:focus-visible,
.lfihm-toc__top:focus-visible {
  outline: 3px solid var(--toc-cyan);
  outline-offset: 3px;
}

.lfihm-toc-target {
  scroll-margin-top: 125px;
}

@keyframes lfihm-toc-enter {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 767px) {
  .lfihm-toc,
  .lfihm-toc--left {
    right: 12px;
    bottom: 14px;
    left: auto;
    align-items: flex-end;
  }

  .lfihm-toc__toggle {
    min-height: 50px;
    padding: 9px 12px;
    font-size: .8rem;
  }

  .lfihm-toc__panel {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 85px);
    margin-bottom: 12px;
  }

  .lfihm-toc__panel nav {
    max-height: calc(100dvh - 265px);
  }

  .lfihm-toc__list a {
    min-height: 44px;
    font-size: .82rem;
  }

  .lfihm-toc__level-3 a { font-size: .77rem; }
  .lfihm-toc-target { scroll-margin-top: 105px; }
}

@media print {
  .lfihm-toc { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .lfihm-toc__panel { animation: none; }
  .lfihm-toc__toggle,
  .lfihm-toc__progress span,
  .lfihm-toc__list a { transition: none; }
}
