/*!
 * Trailmap Viewer
 * Copyright (c) 2026 Yamatavi (https://yamatavi.com/)
 * All rights reserved.
 */

/* ===================================================
   登山地図 アナライザー - Webブラウザ完結版 スタイルシート
   docs/style.css
   =================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-panel: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #38bdf8;
  
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  
  --color-primary: #0284c7;
  --color-primary-hover: #0369a1;
  --color-accent: #059669;
  --color-accent-hover: #047857;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --color-up: #ef4444;
  --color-flat: #10b981;
  --color-down: #3b82f6;
  
  --header-height: 54px;
  --dock-height: 190px;
  --dock-min-height: 36px;
  --sidebar-width: 360px;
  --drawer-width: 380px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 8px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Meiryo", "Yu Gothic", sans-serif;
}

/* ダークモード自動連動 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-main: #090d16;
    --bg-panel: #111827;
    --bg-subtle: #1f2937;
    --border-color: #374151;
    --border-focus: #38bdf8;
    
    --text-primary: #f3f4f6;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* --- ヘッダーツールバー --- */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header-left, .header-center, .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.header-left {
  flex-shrink: 0;
}

.header-right {
  flex-shrink: 0;
  margin-right: 2px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: #0284c7;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 4px;
}

.logo-clickable {
  cursor: pointer;
  padding: 4px 6px;
  margin-left: -6px;
  border-radius: 8px;
  transition: all 0.15s ease;
  user-select: none;
}
.logo-clickable:hover {
  background-color: rgba(2, 132, 199, 0.08);
}
.logo-clickable:active {
  transform: scale(0.98);
}

.logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
}

.logo-title {
  white-space: nowrap;
  letter-spacing: -0.5px;
  font-size: 16px;
}

@media (prefers-color-scheme: dark) {
  .logo {
    color: #38bdf8;
  }
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* --- 言語セレクター（統一ミニセレクター） --- */
.lang-selector-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 4px;
  height: 28px;
  transition: all 0.15s ease;
  user-select: none;
  flex-shrink: 0;
}

.lang-selector-wrapper:hover {
  border-color: var(--border-focus);
}

.lang-selector-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.lang-select {
  background: transparent;
  border: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  padding: 2px 4px;
  font-family: inherit;
}

.lang-select option {
  background-color: var(--bg-panel);
  color: var(--text-primary);
}

/* --- コントロール＆トグル --- */
.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.control-label {
  color: var(--text-secondary);
  font-weight: 500;
}

.select-input, .text-input {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.15s ease;
}

.select-input:focus, .text-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* --- 地図選択カスタムドロップダウン --- */
.map-dropdown {
  position: relative;
  display: inline-block;
}

.map-dropdown-btn {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  outline: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  font-family: inherit;
}

.map-dropdown-btn:hover {
  background-color: rgba(2, 132, 199, 0.06);
  border-color: var(--border-focus);
}

.map-dropdown-btn:focus-visible {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.dropdown-caret {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.map-dropdown.open .dropdown-caret {
  transform: rotate(180deg);
}

.map-dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 240px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  padding: 5px;
  display: none;
  flex-direction: column;
  z-index: 1050;
}

.map-dropdown.open .map-dropdown-menu {
  display: flex;
}

.map-menu-item {
  background: none;
  border: none;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease;
  font-family: inherit;
  box-sizing: border-box;
}

.map-menu-item:hover,
.map-menu-item:focus {
  background-color: rgba(2, 132, 199, 0.08);
  color: #0284c7;
}

.map-menu-item.active {
  background-color: rgba(2, 132, 199, 0.12);
  color: #0284c7;
  font-weight: 600;
}

.map-menu-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}

.map-menu-submenu-wrapper {
  position: relative;
  width: 100%;
}

.map-menu-has-sub {
  position: relative;
}

.sub-arrow {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: auto;
  transition: transform 0.15s ease;
}

/* サブメニュー（階層フライアウト） */
.map-submenu {
  position: absolute;
  top: -5px;
  left: 100%;
  margin-left: 4px;
  min-width: 250px;
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 5px;
  display: none;
  flex-direction: column;
  z-index: 1060;
}

/* PC/マウス環境: ホバーでサブメニュー展開 */
@media (hover: hover) and (pointer: fine) {
  .map-menu-submenu-wrapper:hover .map-submenu {
    display: flex;
  }
  .map-menu-submenu-wrapper:hover .sub-arrow {
    transform: translateX(2px);
  }
}

/* クリック/タップでサブメニュー開閉クラス */
.map-menu-submenu-wrapper.submenu-open .map-submenu {
  display: flex;
}
.map-menu-submenu-wrapper.submenu-open .sub-arrow {
  transform: rotate(90deg);
}

@media (prefers-color-scheme: dark) {
  .map-dropdown-btn:hover {
    background-color: rgba(56, 189, 248, 0.1);
  }
  .map-dropdown-menu,
  .map-submenu {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6);
  }
  .map-menu-item:hover,
  .map-menu-item:focus {
    background-color: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
  }
  .map-menu-item.active {
    background-color: rgba(56, 189, 248, 0.22);
    color: #38bdf8;
  }
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  color: var(--text-secondary);
}

.toggle-item input[type="checkbox"] {
  display: none;
}

.toggle-box {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-color);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-subtle);
  transition: all 0.15s ease;
}

.toggle-item input[type="checkbox"]:checked + .toggle-box {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
}

.toggle-item input[type="checkbox"]:checked + .toggle-box::after {
  content: '✓';
  color: #ffffff;
  font-size: 11px;
  font-weight: bold;
}

.badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  background-color: #fee2e2;
  color: #b91c1c;
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .badge {
    background-color: #7f1d1d;
    color: #fca5a5;
  }
}

/* --- ボタン共通 --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

/* ボタンや見出し内に埋め込むインラインベクターアイコン */
.icon-inline {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--color-primary-hover);
}

.btn-secondary {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: #e2e8f0;
}
@media (prefers-color-scheme: dark) {
  .btn-secondary:hover {
    background-color: #374151;
  }
}

.btn-secondary.active {
  background-color: #0284c7;
  color: #ffffff;
  border-color: #0284c7;
}

.btn-accent {
  background-color: var(--color-accent);
  color: #ffffff;
}
.btn-accent:hover {
  background-color: var(--color-accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}
.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:disabled,
.btn-action:disabled {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  pointer-events: auto !important;
  filter: grayscale(0.85);
  box-shadow: none !important;
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.btn-icon:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-icon-round {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
}

.btn-danger {
  background-color: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
}
.btn-danger:hover {
  background-color: #fecaca;
}
@media (prefers-color-scheme: dark) {
  .btn-danger {
    background-color: #7f1d1d;
    color: #fca5a5;
    border-color: #991b1b;
  }
}

/* --- メインコンテナ --- */
.main-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  height: calc(100vh - var(--header-height));
}

/* --- 右側作業エリア（地図 ＋ 標高ドック） --- */
.workspace-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* --- サイドパネル --- */
.side-panel {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 500;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

/* 編集中のルート名バナー */
.current-track-banner {
  padding: 6px 12px;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}
.current-track-banner b {
  color: var(--color-primary);
  font-weight: 700;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
}

.tab-btn {
  flex: 1;
  padding: 10px 4px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--color-primary);
  background-color: var(--bg-panel);
  border-bottom-color: var(--color-primary);
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.tab-pane {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.tab-pane.active {
  display: flex;
}

/* データ一覧タブ専用：縦幅を目一杯使って下までスクロール可能にする */
.tab-pane#tab-data {
  height: 100%;
  min-height: 0;
  flex: 1;
}

.tab-pane#tab-data .section-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* --- セクションボックス --- */
.section-box {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-count {
  font-size: 11px;
  padding: 1px 6px;
  background-color: var(--bg-subtle);
  border-radius: 10px;
  font-weight: 600;
}

/* --- トラック一覧 --- */
.track-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.track-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  background-color: var(--bg-subtle);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.track-item:hover {
  border-color: var(--color-primary);
}

.track-item.active {
  background-color: rgba(2, 132, 199, 0.08);
  border-color: var(--color-primary);
}

.track-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  flex: 1;
}

.track-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* トラック個別削除ボタン（デスクトップ版同様の丸にバツデザイン） */
.btn-close-track {
  background-color: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #ef4444;
  font-size: 11px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: all 0.15s ease;
  margin-left: 6px;
  opacity: 0.9;
  flex-shrink: 0;
}
.btn-close-track:hover {
  background-color: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  opacity: 1;
  transform: scale(1.15);
  box-shadow: 0 2px 5px rgba(239, 68, 68, 0.4);
}

/* --- 統計サマリーグリッド --- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.metric-card {
  background-color: var(--bg-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.metric-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-value .unit {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.metric-value.ascent { color: var(--color-up); }
.metric-value.descent { color: var(--color-down); }
.metric-value.time { font-family: monospace; font-size: 15px; }

/* 勾配比率バー */
.slope-bar-container {
  margin-top: 10px;
}

.slope-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 4px;
}

.slope-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background-color: var(--bg-subtle);
}

.slope-seg-up { background-color: var(--color-up); transition: width 0.3s; }
.slope-seg-flat { background-color: var(--color-flat); transition: width 0.3s; }
.slope-seg-down { background-color: var(--color-down); transition: width 0.3s; }

/* ピーク・コル検出スライダー */
.slider-group {
  margin-top: 10px;
}
.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 4px;
  font-weight: 600;
}
.range-slider {
  width: 100%;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* トリミング・間引き等の共通セクションブロック */
.highlight-feature-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.highlight-feature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.highlight-feature-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.highlight-feature-badge {
  font-size: 10px;
  font-weight: 700;
  background: #e0f2fe;
  color: #0284c7;
  padding: 2px 6px;
  border-radius: 10px;
}
@media (prefers-color-scheme: dark) {
  .highlight-feature-badge {
    background: #0369a1;
    color: #e0f2fe;
  }
}

.trim-slider-block {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trim-slider-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.simplify-stat-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  margin-top: -4px;
}

/* 編集ツール群 */
.editor-tools {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.tool-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.tool-btn.active {
  background-color: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}

.tool-icon {
  font-size: 18px;
}

.editor-hint {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  background: var(--bg-subtle);
  padding: 6px 8px;
  border-radius: 4px;
  line-height: 1.4;
}

/* アクションボタンリスト */
.action-btn-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-action {
  width: 100%;
  justify-content: flex-start;
  padding: 8px 12px;
  font-size: 12px;
}

/* ポイントテーブル（下部まで目一杯広がるように改善） */
.points-table-container {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  min-height: 0;
}

.points-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.points-table th, .points-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.points-table th {
  background-color: var(--bg-subtle);
  position: sticky;
  top: 0;
  font-weight: 600;
  color: var(--text-secondary);
  z-index: 10;
}

.points-table tr:hover {
  background-color: rgba(2, 132, 199, 0.05);
}

/* --- 地図表示エリア --- */
.map-container {
  flex: 1;
  position: relative;
  background-color: #cbd5e1;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-floating-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 右側ペイン（印刷・詳細分析）が開いている時はペインの左隣に自動退避して隠れないようにする */
.map-container:has(.side-drawer.open) .map-floating-controls,
.map-floating-controls.drawer-shifted {
  right: calc(var(--drawer-width) + 16px);
}

.floating-btn {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
  transition: all 0.15s;
}

.floating-btn:hover {
  background-color: var(--bg-subtle);
  border-color: var(--color-primary);
}

/* ===================================================
   右サイドペイン共通スタイル（印刷ドロワー ＆ 詳細情報ペイン）
   =================================================== */
.side-drawer {
  position: absolute;
  top: 0;
  right: -420px;
  width: var(--drawer-width);
  height: 100%;
  background-color: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  z-index: 650;
  box-shadow: var(--shadow-lg);
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.side-drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
}

.drawer-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.drawer-content {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-section-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  padding: 2px 0;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s ease;
  width: fit-content;
}

/* 選択区間表示時: 横幅を短くした角丸円形（ピル型）のイエローゴールド強調バッジ */
.detail-section-badge.is-selected {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  padding: 4px 10px 4px 12px;
  background: #fef9c3;
  color: #854d0e;
  border: 1px solid #facc15;
  border-radius: 9999px;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(250, 204, 21, 0.3);
  gap: 8px;
}

@media (prefers-color-scheme: dark) {
  .detail-section-badge.is-selected {
    background: #422006;
    color: #fef08a;
    border: 1px solid #facc15;
    box-shadow: 0 2px 6px rgba(250, 204, 21, 0.2);
  }
}

.btn-clear-selection {
  background: rgba(0, 0, 0, 0.1);
  border: none;
  color: inherit;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  margin-left: 6px;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.btn-clear-selection:hover {
  background: #ef4444;
  color: #ffffff;
  transform: scale(1.15);
}

.detail-track-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-track-name-input {
  flex: 1;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 5px 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  outline: none;
}

.detail-group-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  row-gap: 5px;
  column-gap: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  padding: 2px 0;
  min-width: 0;
}

.detail-label {
  color: var(--text-secondary);
  font-size: 11px;
  width: 58px;
  flex-shrink: 0;
}

.detail-val {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 11px;
  white-space: nowrap;
}

.detail-val.up { color: var(--color-up); }
.detail-val.down { color: var(--color-down); }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.radio-row {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.radio-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.frame-info-box {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.drawer-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}

.full-width {
  width: 100%;
}

/* --- 下部：標高プロファイルグラフ常時ドック --- */
.elevation-dock {
  width: 100%;
  flex-shrink: 0;
  height: var(--dock-height);
  background-color: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  z-index: 600;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  transition: height 0.2s ease;
  position: relative;
}

.elevation-dock.collapsed {
  height: var(--dock-min-height);
}

.dock-header {
  height: var(--dock-min-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  cursor: pointer;
  user-select: none;
}

.dock-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dock-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dock-subinfo {
  font-size: 11px;
  font-weight: normal;
  color: var(--text-muted);
}

.dock-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-xaxis-select {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.chart-container {
  flex: 1;
  position: relative;
  padding: 4px 12px 6px 12px;
  overflow: hidden;
}

/* グラフ選択枠内に浮かぶ詳細分析ボタン */
.btn-chart-floating-detail {
  position: absolute;
  transform: translate(-50%, 0);
  background: var(--color-primary, #0284c7);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  z-index: 10;
  white-space: nowrap;
  pointer-events: auto;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.btn-chart-floating-detail:hover {
  background: #0369a1;
  transform: translate(-50%, -2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.btn-chart-floating-detail:active {
  transform: translate(-50%, 0);
}

/* ===================================================
   Leaflet 地図マーカー装飾スタイル
   =================================================== */

.start-marker-icon {
  background-color: #10b981;
  color: #ffffff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.goal-marker-icon {
  background-color: #ef4444;
  color: #ffffff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.peak-marker-icon, .col-marker-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.drag-point-icon {
  background-color: #0284c7;
  border: 2px solid #ffffff;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: grab;
}
.drag-point-icon:active {
  cursor: grabbing;
}

.add-point-guide-dot {
  background-color: #ffffff;
  border: 1.5px solid #0284c7;
  border-radius: 50%;
  width: 6px;
  height: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  pointer-events: none;
}

.print-frame-center-handle {
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast {
  position: fixed;
  bottom: 210px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(15, 23, 42, 0.9);
  color: #ffffff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-5px);
}

.toast.clickable {
  cursor: pointer;
  pointer-events: auto;
  border: 1px solid rgba(56, 189, 248, 0.6);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
  transition: all 0.2s ease;
}

.toast.clickable:hover {
  background-color: rgba(15, 23, 42, 0.98);
  transform: translateX(-50%) translateY(-7px) scale(1.02);
  border-color: #38bdf8;
}

/* ボタン強調パルスアニメーション（サジェスチョンタップ時の視線誘導） */
@keyframes pulseHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(2, 132, 199, 0);
    transform: scale(1.03);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(2, 132, 199, 0);
    transform: scale(1);
  }
}

.btn-highlight-pulse {
  animation: pulseHighlight 0.8s ease-in-out 3;
  border-color: #0284c7 !important;
  background-color: rgba(2, 132, 199, 0.15) !important;
}

.drop-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background-color: rgba(2, 132, 199, 0.4);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.drop-overlay.hidden { display: none; }
.drop-overlay-box {
  background: var(--bg-panel);
  border: 3px dashed var(--color-primary);
  border-radius: 16px;
  padding: 40px 60px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.drop-icon { font-size: 48px; margin-bottom: 12px; }
.drop-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.drop-sub { font-size: 13px; color: var(--text-muted); }

.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal.open { display: flex; }
.modal-content {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}
.modal-title { font-size: 14px; font-weight: 700; }
.close-btn { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.spec-table { width: 100%; border-collapse: collapse; font-size: 11px; margin-top: 8px; }
.spec-table th, .spec-table td { border: 1px solid var(--border-color); padding: 6px 8px; text-align: left; }
.spec-table th { background: var(--bg-subtle); font-weight: 600; }

/* --- アプリ情報・クレジット・免責事項モーダル --- */
.about-modal-content {
  max-width: 440px;
  padding: 14px 18px;
}
.about-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 0;
}
.about-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
  padding-bottom: 2px;
}
.about-app-icon {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  margin-bottom: 2px;
}
.about-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.about-app-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.3px;
}
.about-app-version {
  font-size: 10.5px;
  font-weight: 700;
  font-family: monospace;
  background-color: rgba(2, 132, 199, 0.1);
  color: var(--color-primary);
  padding: 1px 7px;
  border-radius: 10px;
  display: inline-block;
}
.about-app-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}
.about-creator-line {
  font-size: 11.5px;
  color: var(--text-secondary);
  margin-top: 8px;
}
.about-link {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}
.about-link:hover {
  text-decoration: underline;
}
.about-bmc-card {
  align-items: center;
  text-align: center;
  background: linear-gradient(135deg, rgba(255, 221, 0, 0.08), rgba(255, 221, 0, 0.02));
  border-color: rgba(255, 221, 0, 0.35);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.about-bmc-desc {
  font-size: 11.5px;
  margin: 0;
  color: var(--text-primary);
  font-weight: 500;
}
.btn-bmc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background-color: #FFDD00;
  color: #000000 !important;
  font-weight: 700;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  transition: all 0.15s ease;
}
.btn-bmc:hover {
  background-color: #f5d400;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  text-decoration: none;
}
.about-disclaimer-box {
  background-color: rgba(239, 68, 68, 0.04);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  padding: 8px 10px;
}
.about-disclaimer-header {
  font-size: 10.5px;
  font-weight: 700;
  color: #dc2626;
  margin-bottom: 2px;
}
@media (prefers-color-scheme: dark) {
  .about-disclaimer-header {
    color: #f87171;
  }
  .about-disclaimer-box {
    background-color: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.3);
  }
}
.about-disclaimer-text {
  font-size: 10.5px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
}

/* 公式BMCボタン（Cookieフォント）を上品に70%へ縮小 */
.about-bmc-card a.bmc-button,
.about-bmc-card #bmc-btn-container,
.about-bmc-card .bmc-btn-container {
  transform: scale(0.7) !important;
  transform-origin: center center !important;
  margin: -6px 0 !important;
}

/* アプリ情報モーダル最下部のコピーライト表示 */
.about-copyright {
  text-align: right;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.2px;
}

/* --- モバイル・狭小画面向け「PC推奨」案内モーダル（スマホ画面完全フィット） --- */
#mobile-notice-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  z-index: 9999999 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px !important;
  box-sizing: border-box !important;
  background: rgba(0, 0, 0, 0.78) !important;
  backdrop-filter: blur(4px);
  overflow-y: auto;
}
#mobile-notice-modal.open {
  display: flex !important;
}

.mobile-notice-content {
  max-width: 380px !important;
  width: min(380px, calc(100vw - 32px)) !important;
  margin: auto !important;
  padding: 20px 16px !important;
  border-radius: 14px !important;
  background-color: var(--bg-panel) !important;
  border: 1px solid var(--border-color) !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.3) !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 14px !important;
  text-align: center !important;
  box-sizing: border-box !important;
  animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-notice-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mobile-notice-icon {
  font-size: 36px;
  line-height: 1;
}

.mobile-notice-title {
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.mobile-notice-message {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  text-align: left;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0;
  box-sizing: border-box;
  word-break: break-word;
}

.mobile-notice-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}

.mobile-notice-btn {
  width: 100% !important;
  box-sizing: border-box !important;
  padding: 10px 14px !important;
  font-size: 13px !important;
  font-weight: 600;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

@keyframes modalPopIn {
  from {
    opacity: 0;
    transform: scale(0.92);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 画面右下 BMCウィジェット用の浮動ミニバッジ（常にウィジェット中心上に自動センタリング） */
.bmc-floating-label {
  position: fixed;
  right: 48px;
  transform: translateX(50%);
  bottom: 96px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  color: #10b981;
  z-index: 999998;
  pointer-events: none;
  white-space: nowrap;
  opacity: 0.95;
  transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  .bmc-floating-label {
    color: #40DCA5;
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(64, 220, 165, 0.35);
  }
}

/* 標高ドック最小化時（▼）はウィジェットとバッジを完全非表示にして邪魔にならないようにする */
body:has(.elevation-dock.collapsed) #bmc-wbtn,
body:has(.elevation-dock.collapsed) .bmc-floating-label {
  display: none !important;
}

/* --- 印刷枠のドラッグ用ボーダースタイル --- */
.print-frame-border {
  stroke-width: 6px;
  stroke: #0284c7;
  stroke-dasharray: 8, 5;
  cursor: grab !important;
  pointer-events: stroke !important;
  transition: stroke 0.2s, stroke-width 0.2s;
}
.print-frame-border:hover {
  stroke: #2563eb !important;
  stroke-width: 8px !important;
  filter: drop-shadow(0 0 4px rgba(37, 99, 235, 0.6));
}
.print-frame-border.dragging {
  cursor: grabbing !important;
  stroke: #1d4ed8 !important;
}

/* 印刷枠の内側（塗り）はマウスイベントを通過させ、地図の自由なパン・ズームを保証する */
.print-frame-fill {
  pointer-events: none !important;
}

/* 通常時の印刷メディアコンテナは非表示 */
.print-media-container {
  display: none;
}

/* ブラウザ印刷時（画面上のUIはすべて非表示にし、高解像度合成画像のみを用紙全面にピシッと印刷） */
@media print {
  @page {
    margin: 0;
  }
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
  }
  .app-header, .main-container, .elevation-dock, .drop-overlay, .toast, .modal {
    display: none !important;
  }
  .print-media-container {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100vw !important;
    height: 100vh !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    background: #ffffff !important;
    z-index: 999999 !important;
    page-break-inside: avoid;
  }
  .print-media-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }
}

/* ===================================================
   レスポンシブ・アダプティブデザイン（画面サイズ・ノートPC対応）
   =================================================== */

/* --- 横幅の段階的ボタン文字省略（優先順位順） --- */

/* 段階1: 詳細分析 ＆ 印刷 を早い段階でアイコンのみ化 (📊 / 🖨️) */
@media (max-width: 1540px) {
  .btn-text-print,
  .btn-text-detail {
    display: none;
  }
  .header-right .btn {
    padding: 6px 8px;
  }
  .header-left, .header-center, .header-right {
    gap: 8px;
  }
}

/* 段階2: 開く / ダウンロード / 新規 をアイコンのみ化 (📂 / 💾 / 📄)、戻す / 進む をアイコンのみ化 */
@media (max-width: 1440px) {
  .btn-text-undo,
  .btn-text-file {
    display: none;
  }
  .file-actions .btn {
    padding: 6px 8px;
  }
  .file-actions {
    gap: 3px;
  }
  .header-left, .header-center, .header-right {
    gap: 6px;
  }
  .app-header {
    padding: 0 10px;
  }
}

/* 段階3: 地図ドロップダウンボタンやトグルの余白をタイトに */
@media (max-width: 1280px) {
  .header-left, .header-center, .header-right {
    gap: 5px;
  }
  .toggle-group {
    gap: 5px;
  }
  .toggle-item {
    font-size: 11.5px;
    gap: 3px;
  }
  .lang-selector-wrapper {
    padding: 0 2px;
  }
  .lang-select {
    padding: 2px 2px;
  }
  .map-dropdown-btn {
    padding: 5px 8px;
    font-size: 12px;
  }
  .dock-bmc-box {
    width: 120px;
    padding: 6px 8px;
  }
  .dock-bmc-msg {
    display: none;
  }
}

/* 段階4: タイトル文字「Trailmap Viewer」を省略しアプリアイコン画像のみ化 */
@media (max-width: 1100px) {
  .logo-title {
    display: none;
  }
  .toggle-group {
    gap: 4px;
  }
  .toggle-item {
    font-size: 11px;
    gap: 2px;
  }
  .badge {
    font-size: 10px;
    padding: 1px 3px;
  }
  #bmc-wbtn {
    transform: scale(0.80) !important;
    transform-origin: bottom right !important;
    bottom: 34px !important;
    right: 14px !important;
  }
  .bmc-floating-label {
    bottom: 84px !important;
    right: 38px !important;
    transform: translateX(50%) !important;
    font-size: 9.5px !important;
  }
}

/* 段階5: スマホ・超狭画面ではBMCウィジェットを非表示にしてグラフ優先 */
@media (max-width: 800px) {
  #bmc-wbtn,
  .bmc-floating-label {
    display: none !important;
  }
}

/* 画面幅が狭い場合のサブメニュー左側展開（画面外突き抜け防止） */
@media (max-width: 900px) {
  .map-submenu {
    left: auto;
    right: 100%;
    margin-left: 0;
    margin-right: 4px;
  }
}

/* --- ノートPC環境（解像度2560pxの200%拡大＝論理幅1280px以下）でのペインスリム化＆カード引き締め --- */
@media (max-width: 1300px) {
  :root {
    --sidebar-width: 305px;
    --drawer-width: 350px;
  }
  .side-panel .section-box {
    padding: 10px;
  }
  .side-panel .metrics-grid {
    gap: 6px;
  }
  .side-panel .metric-card {
    padding: 6px 8px;
  }
  .side-panel .metric-value {
    font-size: 15px;
  }
  .side-panel .metric-label {
    font-size: 10px;
  }
}

/* 段階5: タイトル文字「Trailmap Viewer」を省略しアプリアイコン画像のみ化 */
@media (max-width: 960px) {
  .logo-title {
    display: none;
  }
  :root {
    --sidebar-width: 285px;
    --drawer-width: 330px;
  }
}

/* --- 縦幅の段階的レスポンシブ最適化（3段階） --- */

/* 中画面（高さ840px以下 / 一般的なノートPC環境）: やや引き締め */
@media (max-height: 840px) {
  :root {
    --header-height: 50px;
    --dock-height: 165px;
  }
  .app-header {
    padding: 0 12px;
  }
  .panel-tabs .tab-btn {
    padding: 8px 3px;
  }
  .panel-content {
    padding: 10px;
    gap: 10px;
  }
  .section-box {
    padding: 10px;
  }
  .metric-card {
    padding: 6px 8px;
  }
  .metric-value {
    font-size: 15px;
  }

  /* 画面が小さいときはウィジェットを適度に縮小し、底面の距離目盛り（1.0km等）と上部メニューの両方に被らない位置へ配置 */
  #bmc-wbtn {
    transform: scale(0.80) !important;
    transform-origin: bottom right !important;
    bottom: 34px !important;
    right: 14px !important;
  }
  .bmc-floating-label {
    bottom: 84px !important;
    right: 38px !important;
    transform: translateX(50%) !important;
    font-size: 9.5px !important;
  }
}

/* 小画面（高さ720px以下 / 200%拡大やブラウザバー表示時）: ギュッと凝縮 */
@media (max-height: 720px) {
  :root {
    --header-height: 44px;
    --dock-height: 140px;
    --dock-min-height: 30px;
  }

  /* 極小画面ではウィジェットをさらにコンパクト化 */
  #bmc-wbtn {
    transform: scale(0.68) !important;
    transform-origin: bottom right !important;
    bottom: 26px !important;
    right: 12px !important;
  }
  .bmc-floating-label {
    bottom: 72px !important;
    right: 32px !important;
    transform: translateX(50%) !important;
    font-size: 9px !important;
  }

  .app-header {
    padding: 0 8px;
  }
  .logo-img {
    width: 24px;
    height: 24px;
  }
  .btn {
    padding: 4px 8px;
    font-size: 12px;
  }
  .select-input, .text-input {
    padding: 4px 6px;
    font-size: 12px;
  }
  .lang-selector-wrapper {
    height: 24px;
    padding: 0 2px 0 4px;
  }
  .lang-select {
    font-size: 11px;
  }

  /* 左サイドペインの余白をギュッと引き締める */
  .panel-tabs .tab-btn {
    padding: 6px 2px;
    font-size: 11px;
  }
  .panel-content {
    padding: 6px 8px;
    gap: 6px;
  }
  .section-box {
    padding: 8px 10px;
  }
  .section-header {
    margin-bottom: 4px;
  }
  .metric-card {
    padding: 4px 6px;
  }
  .metric-label {
    font-size: 10px;
    margin-bottom: 0;
  }
  .metric-value {
    font-size: 13px;
  }
  .metric-value .unit {
    font-size: 10px;
  }
  .slope-bar-container {
    margin-top: 4px;
  }
  .slider-group {
    margin-top: 4px;
  }
  .action-btn-list {
    gap: 4px;
  }
  .action-btn-list .btn {
    padding: 4px 6px;
    font-size: 11px;
  }
  .drawer-content {
    padding: 10px;
    gap: 8px;
  }
  .drawer-header {
    padding: 8px 12px;
  }
}
