
/* ---- UIパネル（地理院地図/Q地図スタイル） ---- */
/* ===== サイドバー ===== */
#sidebar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  z-index: 10;
  pointer-events: none;
  /* 子要素にのみイベントを通す */
}

#sidebar>* {
  pointer-events: auto;
}

/* アイコンバー（常時表示） */
#sidebar-icon-bar {
  width: 52px;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  gap: 0;
  flex-shrink: 0;
}

/* ロゴ（SVGアイコン）*/
#sidebar-logo {
  width: 52px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
  user-select: none;
}

#sidebar-logo img {
  width: 28px;
  height: 28px;
  display: block;
}

/* ナビゲーションボタン */
.sidebar-nav-btn {
  width: 100%;
  height: 56px;
  border: none;
  background: transparent;
  color: var(--text-main);
  border-radius: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background var(--transition), color var(--transition);
  position: relative;
  flex-shrink: 0;
  padding: 0;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  display: block;
}

.nav-label {
  font-size: var(--font-xs);
  font-weight: var(--font-semi);
  line-height: 1;
  letter-spacing: 0.04em;
  display: block;
}

.sidebar-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* アクティブ時: 左アクセントバー + プライマリカラー */
.sidebar-nav-btn.active {
  background: var(--primary-light);
  color: var(--text-main);
}

.sidebar-nav-btn.active .nav-label {
  color: var(--text-main);
}

/* 左端の縦アクセントバー */
.sidebar-nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
  display: block;
}

/* パネルコンテンツ */
#sidebar-panel {
  flex: 0 0 var(--panel-w);
  /* flex-grow:0 flex-shrink:0 でコンテンツ幅に関わらず固定 */
  width: var(--panel-w);
  max-width: var(--panel-w);
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-muted);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-panel.sb-hidden {
  display: none;
}

/* セクション（各パネル） */
.sidebar-section {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.sidebar-section.active {
  display: flex;
}

/* セクションヘッダー */
.sidebar-section-header {
  background: var(--bg-panel);
  color: var(--primary);
  padding: 0 12px;
  height: 44px;
  font-size: var(--font-md);
  font-weight: var(--font-bold);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}

/* パネル閉じるボタン */
.sidebar-close-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-lg);
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transform: none !important;
  transition: background var(--transition), color var(--transition), transform 0s;
}

.sidebar-close-btn svg {
  width: 12px;
  height: 12px;
  pointer-events: none;
}

.sidebar-close-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: none !important;
}

/* ================================================================
   スクロールバー共通スタイル（ここで一括管理）
   追加する場合はこのセレクターリストに追記する
   ================================================================ */
.sidebar-scroll,
.terrain-upper,
.terrain-lower {
  scrollbar-width: thin;
  scrollbar-color: var(--border-input) transparent;
}

/* スクロール可能エリア */
.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
}

/* ========================================================
   テレインパネル 上下分割レイアウト
   ======================================================== */
#panel-terrain {
  overflow: hidden;
  /* 子要素のスクロールを独立させる */
}

/* 上部: カタログ（最大45%・独立スクロール） */
.terrain-upper {
  flex: 0 1 45%;
  min-height: 80px;
  overflow-y: auto;
  border-bottom: 2px solid var(--border-light);
}

/* 下部: ツリー + GPX（残余スペースを占有） */
.terrain-lower {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding-top: 12px;
}
