/* 默认宽屏不显示按钮 */
.mobile-toc-button {
  display: none;
}

/* 窄屏显示；此处选用约 1220px 的切换宽度 */
@media (max-width: 76.234375em) {
  .mobile-toc-button {
    display: block;
    position: fixed;
    right: 16px;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 4;
    padding: 12px 18px;
    border: none;
    border-radius: 24px;
    background: var(--md-primary-fg-color);
    color: var(--md-primary-bg-color);
    box-shadow: 0 3px 12px #0003;
    font: inherit;
    cursor: pointer;
  }
}

/* 弹出的目录面板 */
.mobile-toc-dialog {
  box-sizing: border-box;
  width: min(90vw, 440px);
  max-height: 75vh;
  max-height: 75dvh;
  margin: auto;
  padding: 20px;
  border: none;
  border-radius: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  font-size: 16px;
}

.mobile-toc-dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.mobile-toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.mobile-toc-header button {
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--md-code-bg-color);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.mobile-toc-list,
.mobile-toc-list ul {
  margin: 0;
  padding-left: 18px;
  list-style: none;
}

.mobile-toc-list {
  padding-left: 0;
}

.mobile-toc-list a {
  display: block;
  padding: 9px 0;
  color: var(--md-typeset-a-color);
  line-height: 1.5;
  overflow-wrap: anywhere;
}