body, html { 
  overscroll-behavior: none;
  touch-action: none ;
  margin: 0; 
  padding: 0; 
  height: 100%; 
  overflow: hidden;
}
#container { 
  display: flex; 
  height: 100vh; 
  flex-wrap: nowrap; /* スクロール防止 */ 
}
/* サイドバーの高さをブラウザ上の安全領域に合わせる */
#sidebar {
  display: flex;
  flex-direction: column;
  height: 100svh;   /* モバイル対応の新しい単位: safe viewport height */
  width: 33%;
  min-width: 200px;
  max-width: 400px;
  min-height: 0;    /* ← これも重要 */
  
  background: #f4f4f4;
  transition: transform 0.3s, width 0.3s;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  z-index: 2;
  position: relative;
}
#sidebar.closed {
  /* 完全に消す場合 */
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  padding: 0;
  border: none;
  overflow: hidden;
}

#controlButtons {             /* ボタン群は高さ固定しない */
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5em;              /* ボタン間の隙間 */
    padding: 0.5em;
    box-sizing: border-box;
}

#controlButtons button {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1em;         
    line-height: 38px;        /* 縦方向の中央揃え（paddingではなくline-heightを使用） */
    border: none;
    background-color: #4285f4;
    color: white;
    border-radius: 19px;      /* 高さの半分でスイッチと同じ角丸 */
    cursor: pointer;
    transition: background 0.2s;
    padding: 0;               /* 高さ固定なので余計なpaddingは削除 */
    text-align: center;
    white-space: nowrap;
}

#controlButtons button:hover {
    background-color: #3367d6;
}

/* ===== スマホ対応 ===== */
@media (max-width: 600px) {
    #controlButtons {
        flex-direction: column;  /* 縦並び */
    }
    #controlButtons button {
        width: 100%;             /* 幅いっぱいに */
        font-size: 0.9em;         /* 少し文字を小さく */
        line-height: 32px;        /* 高さを小さく */
        border-radius: 16px;
    }

    /* 時間スライダーコンテナ */
    #timeSliderContainer {
      height: auto !important;
      padding: 10px;
    }
}

@media (max-width: 600px) and (orientation: landscope) {

    #mapWithSlider {
      flex-direction: column !important; 
    }

    /* 時間スライダーコンテナ */
    #timeSliderContainer {
      height: 35px !important;
      padding: 2px 10px !important;
    }

    /* スライダー本体は幅100%でOK */
    #timeSlider {
      height: 10px !important;
      margin: 0 auto !important;
    }

    /* 選択時刻表示 */
    #selectedTime {
      margin-top: 2px !important;
      font-size: 0.6em !important;
    }

}

#list {
    flex: 1 1 auto;    /* リストをスクロール可能に */
    min-height: 0;     /* ← これが重要！スマホでスクロール領域を確保する */
    overflow-y: auto;  /* 縦方向スクロールを有効化 */
    padding: 0.2em;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;  /* iOSでスムーズスクロール */
}

    .list-item {             /* リスト項目の下marginをpaddingに変更して相殺回避 */
        font-size: 1em;      /* 文字サイズ */
        margin:  0;          /* margin-bottomの代わりに #list の padding-bottom を使う */
        padding: 0.5em;
        background: #fff;
        border-radius: 6px;
        box-shadow: 0 1px 4px #ccc;
        display: flex;           /* フレックスボックスを利用 */
        align-items: center;     /* 垂直方向で中央揃え */
        justify-content: flex-start; /* 左寄せで揃える */
        white-space: nowrap;     /* 折り返しを禁止 */
        overflow: hidden;        /* はみ出した部分を非表示 */
        text-overflow: ellipsis; /* 省略記号を表示 */
        touch-action: manipulation;
    }
   .switch {
     position: relative;
     display: inline-block;
     flex-shrink: 0;          /* 幅を固定 */
     width: 80px;    /* 幅を大きく */
     height: 38px;   /* 高さを大きく */
     margin-right: 1em;
     vertical-align: middle;
   }
   .switch input {
     opacity: 0;
     width: 0;
     height: 0;
   }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 44px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 32px;   /* 丸部分も大きく */
  width: 32px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
/* #listに下方向の余白を確保して最後の要素が切れないようにする */
#list::after {
  content: "";
  display: block;
  height: 0.5em;   /* 最後の行の下の余白 */

}

input:checked + .slider {
  background-color: #2196F3;
}
input:checked + .slider:before {
  transform: translateX(36px); /* 幅に合わせて移動量も調整 */
}


#mapWithSlider {
  display: flex;
  flex-direction: row; /* 水平方向に並べる */
  height: 100vh;       /* 高さを画面いっぱいに */
  width: 100%;
}

#mapArea {
  touch-action: pan-x pan-y  pinch-zoom; /* 地図部分のみパン・ピンチズームを許可 */
  overflow: hidden;                      /* スクロールを非表示にする */
  height: 100%;                          /* 必要に応じて高さを固定 */
  transition: width 0.3s;
  min-width: 0;
}

#toggleBtn {
    position: absolute;
    left: 4px;
    top: 88px;
    width: 48px;
    height: 48px;
    background: #2196f3;
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10000 !important; /* Leafletのコントロールより高く */
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* 時間スライダーコンテナ */
#timeSliderContainer {
  /* flex: 0 0 10%;   */    /* 横幅30%、縮小はしない */
  padding: 8px;
  box-sizing: border-box;
  background: #fafafa;
  border-left: 1px solid #ddd; /* 左側に境界線 */
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* スライダー本体は幅100%でOK */
#timeSlider {
  width: 100%;
  height: 20px;
  margin: 0 auto;
  cursor: pointer;
}

.ui-slider .ui-slider-handle {
  width: 0.8em;
  height: 0.8em;
}

#timeSlider .ui-slider-handle {
  background: #3498db; /* 好きな色 */
  border: 2px solid #2980b9;
}

/* 選択時刻表示 */
#selectedTime {
  text-align: center;
  font-size: 0.7em;
  color: #333;
  margin-top: 8px;
  user-select: none;
}
