aside {
  position: sticky;
  width: 280px;
  height: 100svh;
  background-color: var(--gray-primary);
  border-right: 1px solid var(--border-primary);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  overflow-y: scroll;
  z-index: 100;
  transition: transform 0.3s ease;
  top: 72px;
  height: calc(100svh - 72px);
}

/* ナビヘッダー部分 - aside内のdiv要素 */
aside>.aside-header:first-child {
  padding: 20px;
  border-bottom: 1px solid var(--border-primary);
  background-color: var(--brand-primary);
}

aside>.aside-header:first-child h1,
aside>.aside-header:first-child h2,
aside>.aside-header:first-child h3 {
  font-size: var(--text-lg);
  color: var(--text-primary);
  border: none;
  padding: 0;
  background: none;
}

/* メニューリスト */
aside ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: var(--text-sm);
}

aside li {
  margin: 0;
  padding: 0;
}

aside a {
  display: block;
  padding: 10px 15px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--border-primary);
  transition: all 0.1s ease;
  line-height: 1.2;
}

aside a:hover {
  background-color: var(--text-secondary);
  text-decoration: none;
  color: var(--gray-primary) !important;
}

aside a:visited {
  color: inherit;
}

/* ネストされたメニュー */
aside ul ul {
  padding-left: 20px;
  background-color: var(--border-secondary);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

aside ul ul.expanded {
  max-height: fit-content;
}

aside ul ul a {
  padding: 10px 15px;
  border-bottom: 1px solid var(--border-primary);
}

/* 折りたたみ可能なメニューアイテム */
aside li.has-submenu>a {
  position: relative;
  padding-right: 40px;
}

aside li.has-submenu>a::after {
  content: '▼';
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.2s ease;
  font-size: var(--text-sm);
}

aside li.has-submenu.collapsed>a::after {
  transform: translateY(-50%) rotate(-90deg);
}

/* 非表示状態のメインコンテンツ - bodyにクラスが付いた場合 */
body.nav-hidden main {
  margin-left: 0;
}

/* レスポンシブ対応 */
@media screen and (max-width: 1250px) {
  aside {
    width: 280px;
    transform: translateX(-100%);
  }

  /* モバイルでナビが開いている状態 */
  body.nav-open aside {
    transform: translateX(0);
  }
}

/* ナビゲーション非表示状態（デスクトップ） */
@media screen and (min-width: 769px) {
  body.nav-hidden aside {
    transform: translateX(-100%);
  }
}

/* 右側配置バリエーション */
aside.right {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border-primary);
}

@media screen and (max-width: 1250px) {
  aside.right {
    transform: translateX(100%);
  }

  body.nav-open aside.right {
    transform: translateX(0);
  }
}

@media screen and (min-width: 769px) {
  body.right-nav.nav-hidden aside.right {
    transform: translateX(100%);
  }
}

/* 右側配置時のトグルボタン位置調整 */
@media screen and (max-width: 1250px) {
  body.right-nav button.nav-toggle {
    left: auto;
    right: 10px;
  }
}

/* オーバーレイ（モバイル用） - 追加のdiv要素として */
.nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

body.nav-open .nav-overlay {
  opacity: 1;
  visibility: visible;
}

/* ボタン要素をナビゲーションコントロールとして使用 */
button.nav-toggle {
  display: none;
  top: 20px;
  left: 20px;
  z-index: 101;
  background-color: var(--brand-secondary);
  color: var(--gray-primary);
  border: none;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.3s ease;
}

button.nav-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

@media screen and (max-width: 1250px) {
  button.nav-toggle {
    display: block;
    position: fixed;
    left: 10px;
    top: 15px;
    z-index: 2001;
  }

  aside {
    position: fixed;
    /* stickyからfixedに変更 */
    width: 280px;
    height: 100svh;
    /* 画面全体の高さ */
    transform: translateX(-100%);
    z-index: 101;
    min-height: calc(100svh - 72px);
  }
}