.rule-page-root {
  position: relative;
}

.rule-page-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.rule-page-content {
  min-width: 0;
}

.rule-toc {
  position: sticky;
  top: 50vh;
  transform: translateY(-50%);
  align-self: start;
  padding: 14px 12px;
  border: 1px solid #d2d2d7;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  z-index: 20;
}

.rule-toc__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #86868b;
  margin-bottom: 10px;
}

.rule-toc__nav,
.rule-toc-drawer__nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rule-toc__item,
.rule-toc-drawer__item {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.35;
  color: #1d1d1f;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.rule-toc__item:hover,
.rule-toc-drawer__item:hover {
  background: #f5f5f7;
}

.rule-toc__item.is-active,
.rule-toc-drawer__item.is-active {
  background: #eef6ff;
  color: #0071e3;
  font-weight: 600;
}

.rule-nav-target {
  scroll-margin-top: calc(var(--header-height, 64px) + 20px);
}

.rule-toc-toggle,
.rule-toc-drawer,
.rule-toc-backdrop {
  display: none;
}

@media (max-width: 1100px) {
  .rule-page-layout {
    display: block;
  }

  .rule-toc {
    display: none;
  }

  .rule-toc-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    top: calc(var(--header-height, 64px) + 12px);
    left: 14px;
    z-index: 1800;
    border: 1px solid #d2d2d7;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    color: #1d1d1f;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
  }

  .rule-toc-toggle__icon {
    width: 14px;
    height: 2px;
    background: #1d1d1f;
    position: relative;
    border-radius: 2px;
  }

  .rule-toc-toggle__icon::before,
  .rule-toc-toggle__icon::after {
    content: "";
    position: absolute;
    left: 0;
    width: 14px;
    height: 2px;
    background: #1d1d1f;
    border-radius: 2px;
  }

  .rule-toc-toggle__icon::before {
    top: -5px;
  }

  .rule-toc-toggle__icon::after {
    top: 5px;
  }

  .rule-toc-drawer {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 86vw);
    background: #ffffff;
    border-right: 1px solid #d2d2d7;
    z-index: 2000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding: calc(var(--header-height, 64px) + 16px) 14px 20px;
    overflow-y: auto;
  }

  .rule-toc-drawer.is-open {
    transform: translateX(0);
  }

  .rule-toc-drawer__title {
    font-size: 13px;
    font-weight: 700;
    color: #1d1d1f;
    margin-bottom: 10px;
  }

  .rule-toc-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1900;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .rule-toc-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  body.rule-toc-open {
    overflow: hidden;
  }
}
