/* Android Firefox (3-button navbar) のための局所修正
   - ui.js が body.android-firefox-navbar を付与し --android-firefox-navbar-height を設定する前提
   - 影響を最小にするため .scenes の下部余白 / max-height のみに適用 */
body.android-firefox-navbar #sceneList .scenes {
  /* nav bar 高さ（検出失敗時は安全側の 56px）を下部余白に加える */
  padding-bottom: calc(var(--sidebar-bottom-offset) + var(--android-firefox-navbar-height, 56px)) !important;
  /* 内部スクロール領域の高さを nav bar を考慮して縮める（モバイル／デスクトップ共通の調整を上書きしない） */
  max-height: calc(100vh - (66px + var(--sidebar-top-offset) + var(--sidebar-bottom-offset) + var(--android-firefox-navbar-height, 56px))) !important;
}

/* モバイル専用（safe-area 等を既に使っている領域）にも同様の補正を付与 */
@media (max-width: 520px) {
  body.android-firefox-navbar #sceneList.enabled .scenes,
  body.android-firefox-navbar #sceneList .scenes {
    padding-bottom: calc(var(--sidebar-bottom-offset) + var(--android-firefox-navbar-height, 56px)) !important;
    max-height: calc(100vh - (66px + var(--sidebar-top-offset) + var(--sidebar-bottom-offset) + var(--android-firefox-navbar-height, 56px))) !important;
  }
}

/* デスクトップ専用補正：
   サイドバー内部のスクロール領域(.scenes)が画面下の固定要素に被らないよう
   追加の下部余白を確保し max-height を縮める */
@media (min-width: 521px) {
  body.desktop #sceneList .scenes,
  body:not(.mobile) #sceneList .scenes {
    /* 内部余白は既存のオフセットのみ（謎のスペースを防ぐ） */
    padding-bottom: var(--sidebar-bottom-offset) !important;
    /* 高さ制限には固定要素分（56px）を追加して画面下に被らないようにする */
    max-height: calc(100vh - (56px + var(--sidebar-top-offset) + var(--sidebar-bottom-offset) + 56px)) !important;
  }

  /* 有効時（展開中）も同様に考慮 */
  body.desktop #sceneList.enabled .scenes,
  body:not(.mobile) #sceneList.enabled .scenes {
    padding-bottom: var(--sidebar-bottom-offset) !important;
    max-height: calc(100vh - (56px + var(--sidebar-top-offset) + var(--sidebar-bottom-offset) + 56px)) !important;
  }
}