.series-nav {
  --sn-accent: #0f766e;
  --sn-accent-strong: #115e59;
  --sn-bg: rgba(240, 253, 250, 0.96);
  --sn-panel: #ffffff;
  --sn-text: #16302d;
  --sn-muted: #5f7471;
  --sn-border: #bfe3dd;
  position: relative;
  top: auto;
  z-index: 30;
  width: min(1120px, calc(100% - 32px));
  height: auto;
  margin: 18px auto 8px;
  padding: 0;
  color: var(--sn-text);
  background: linear-gradient(135deg, var(--sn-bg), rgba(255, 255, 255, 0.96));
  border: 1px solid var(--sn-border);
  border-radius: 16px;
  box-shadow: 0 14px 38px rgba(15, 118, 110, 0.09);
  font-family: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.35;
}

.series-nav__inner {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto;
  gap: 12px 24px;
  align-items: center;
  padding: 14px 16px 12px;
}

.series-nav__eyebrow {
  margin: 0 0 3px;
  color: var(--sn-accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.series-nav__title {
  margin: 0;
  color: var(--sn-text);
  font-size: 16px;
  font-weight: 800;
}

.series-nav__facts {
  margin-top: 4px;
  color: var(--sn-muted);
  font-size: 12px;
}

.series-nav__controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.series-nav a,
.series-nav summary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 0;
  padding: 7px 11px;
  color: var(--sn-accent-strong);
  background: var(--sn-panel);
  border: 1px solid var(--sn-border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.series-nav a:hover,
.series-nav summary:hover {
  color: #ffffff;
  background: var(--sn-accent);
  border-color: var(--sn-accent);
  text-decoration: none;
}

.series-nav details {
  position: relative;
  margin: 0;
}

.series-nav summary {
  list-style: none;
}

.series-nav summary::-webkit-details-marker {
  display: none;
}

.series-nav__chapters {
  position: absolute;
  top: calc(100% + 9px);
  right: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  width: min(620px, calc(100vw - 48px));
  max-height: min(65vh, 560px);
  padding: 10px;
  overflow-y: auto;
  background: var(--sn-panel);
  border: 1px solid var(--sn-border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(18, 54, 50, 0.2);
}

.series-nav details:not([open]) .series-nav__chapters {
  display: none;
}

.series-nav__chapters a {
  justify-content: flex-start;
  min-height: 0;
  padding: 8px 10px;
  color: var(--sn-text);
  background: transparent;
  border-color: transparent;
  border-radius: 8px;
  white-space: normal;
}

.series-nav__chapters a[aria-current="page"] {
  color: #ffffff;
  background: var(--sn-accent);
}

.series-nav__progress {
  grid-column: 1 / -1;
  height: 3px;
  overflow: hidden;
  background: var(--sn-border);
  border-radius: 999px;
}

.series-nav__progress span {
  display: block;
  width: var(--series-progress, 0%);
  height: 100%;
  background: linear-gradient(90deg, var(--sn-accent), #2dd4bf);
  border-radius: inherit;
}

@media (prefers-color-scheme: dark) {
  .series-nav {
    --sn-accent: #5eead4;
    --sn-accent-strong: #99f6e4;
    --sn-bg: rgba(13, 45, 43, 0.97);
    --sn-panel: #132523;
    --sn-text: #ecfdf5;
    --sn-muted: #9bb9b4;
    --sn-border: #315b55;
    box-shadow: 0 14px 38px rgba(0, 0, 0, 0.25);
  }
}

@media (max-width: 720px) {
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .series-nav {
    width: calc(100% - 20px);
    margin-top: 10px;
    border-radius: 13px;
  }

  .series-nav__inner {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .series-nav__controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .series-nav__chapters {
    position: fixed;
    top: clamp(150px, 26vh, 210px);
    right: 10px;
    left: 10px;
    grid-template-columns: 1fr;
    width: auto;
    max-height: calc(100vh - clamp(165px, 30vh, 225px));
    margin-top: 0;
  }

  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  pre {
    max-width: 100%;
    overflow-x: auto;
  }

  nav:not(.series-nav) {
    max-width: 100%;
    overflow-x: auto;
  }

  nav:not(.series-nav) .inner {
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  [class*="diagram"] {
    max-width: 100%;
    overflow-x: auto;
  }
}

@media print {
  .series-nav {
    box-shadow: none;
  }

  .series-nav__controls,
  .series-nav__progress {
    display: none;
  }
}
