.vei-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(to right, #1d86ff 0%, #1d86ff 30%, #2c3a4f 30%, #2c3a4f 100%);
  outline: none;
  cursor: pointer;
}

.vei-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1d86ff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #1d86ff;
  cursor: pointer;
}

.vei-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1d86ff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #1d86ff;
  cursor: pointer;
}

.vei-range::-moz-range-track {
  height: 6px;
  background: #2c3a4f;
  border-radius: 4px;
}

.vei-range::-moz-range-progress {
  background: #1d86ff;
  height: 6px;
  border-radius: 4px;
}

.vei-range::-ms-track {
  height: 6px;
  background: transparent;
  border-color: transparent;
  color: transparent;
}

.vei-range::-ms-fill-lower {
  background: #1d86ff;
  border-radius: 4px;
}

.vei-range::-ms-fill-upper {
  background: #2c3a4f;
  border-radius: 4px;
}

.vei-range::-ms-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1d86ff;
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px #1d86ff;
  cursor: pointer;
}

/* === VEI テーブル === */
.vei-table-wrapper {
  position: relative;
  overflow-x: auto;
  background: #16263d;
  border: 1px solid #22364f;
  border-radius: 4px;
  /* box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); */
}

.vei-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  color: #141415;
}

.vei-table thead th {
  background: #FAFBFD;
  color: #5B5F66;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 8px 16px;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid #D2D5DA;
}

.vei-table tbody tr {
  background: #FAFBFD;
  transition: background 0.15s;
}

.vei-table tbody tr:hover {
  background: #DCDFE5;
}

.vei-table th,
.vei-table td {
  padding: 8px;
  border-right: 1px solid #FAFBFD;
  white-space: nowrap;
}

.vei-table th:last-child,
.vei-table td:last-child {
  border-right: none;
}

.vei-table tbody tr+tr td,
.vei-table tbody tr+tr th {
  border-top: 1px solid #223954;
}

.vei-table input[type="number"],
.vei-table select {
  background: #FAFBFD;
  border: 1px solid #D2D5DA;
  color: #141415;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 4px;
}

.vei-table input[type="number"]:focus,
.vei-table select:focus {
  outline: none;
  border-color: #3d82ff;
  box-shadow: 0 0 0 1px #3d82ff;
}

.vei-table .btn-outline-danger {
  border: none;
  background: transparent;
  color: #ff7892;
  padding: 0 6px;
  line-height: 1;
}

.vei-table .btn-outline-danger:hover {
  color: #ff466d;
}

.vei-table a {
  color: #4da3ff;
  text-decoration: none;
  font-weight: 500;
}

.vei-table a:hover {
  text-decoration: underline;
}

.vei-table-wrapper::-webkit-scrollbar {
  height: 5px;
}

.vei-table-wrapper::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

.vei-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* === VEI タブナビゲーション === */
.vei-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  border-bottom: 1px solid #243d5f;
  margin: 0 0 12px 0;
  padding: 0 4px;
}

.vei-tab {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  color: #9fb6d6;
  font-size: 14px;
  font-weight: 500;
  padding: 0 4px 4px;
  margin: 0;
  position: relative;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.25s;
  letter-spacing: 0.5px;
}

.vei-tab:hover {
  color: #c5d6e9;
}

.vei-tab.active {
  color: #141415;
  font-weight: 600;
  border-bottom-color: #3d82ff;
}

.vei-tab:focus-visible {
  outline: 2px solid #3d82ff;
  outline-offset: 2px;
  border-radius: 2px;
}

.vei-tab-panel {
  scrollbar-gutter: stable;
}

#vei-detail-content,
#vei-composition-content,
#vei-herbaceous-detail-content,
#vei-herbaceous-composition-content {
  gap: 16px;
  display: flex;
  flex-direction: column;
}

/* --- VEI 共通テキストエリア --- */

/* ラベルを必ず改行 */
.vei-tab-panel .form-label {
  display: block;
  margin-bottom: 4px;
}

/* Bootstrap .form-control の上書き */
.vei-textarea.form-control,
.vei-textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 6px 8px !important;
  font-size: 14px !important;
  line-height: 1.4;
  background: #FAFBFD !important;
  border: 1px solid #D2D5DA !important;
  border-radius: 4px !important;
  color: #141415 !important;
  box-shadow: none !important;
  resize: vertical;
  min-height: 64px;
}

/* スクロールバーのスタイル設定 */
.vei-textarea.form-control::-webkit-scrollbar {
  width: 6px;
  background: #0d1b36;
}

.vei-textarea.form-control::-webkit-scrollbar-track {
  background: #0d1b36;
  border-radius: 3px;
}

.vei-textarea.form-control::-webkit-scrollbar-thumb {
  background-color: #4a5568;
  border-radius: 3px;
  border: 1px solid #2a4468;
}

.vei-textarea.form-control::-webkit-scrollbar-thumb:hover {
  background-color: #6b7280;
}

/* リサイズハンドルとスクロールバーが重ならないようにする */
.vei-textarea.form-control::-webkit-scrollbar-corner {
  background: #0d1b36;
}

/* --- VEI セレクト & インプット --- */
.VEI-model .vei-input,
#veiFilterModal .vei-input {
  background: #FAFBFD;
  border: 1px solid #D2D5DA;
  color: #141415;
  font-size: 14px;
  padding: 8px 34px 8px 12px;
  border-radius: 4px;
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: border-color .2s, box-shadow .2s, background-color .25s;
}

.vei-select {
  background: #FAFBFD;
  border: 1px solid #D2D5DA;
  color: #141415;
  font-size: 14px;
  padding: 8px 34px 8px 12px;
  border-radius: 4px;
  line-height: 1.4;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%239fb6d6' stroke-width='2' viewBox='0 0 24 24'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  transition: border-color .2s, box-shadow .2s, background-color .25s;
}

/* .vei-select:hover,
.VEI-model .vei-input:hover {
  background-color: #13233a;
} */

.vei-select:focus,
.VEI-model .vei-input:focus,
#veiFilterModal .vei-input:focus {
  outline: none;
  border: 1px solid #0D1B36;
  box-shadow: none;
  /* background-color: #152a46; */
  color: #141415;
}

.vei-select:disabled,
.VEI-model .vei-input:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.vei-select::-ms-expand {
  display: none;
}

/* セレクトオプション（ブラウザ依存） */
.vei-select option,
.vei-target-layer option,
.vei-target-species option {
  background: #1E293B;
  color: #d5dfed;
}

.vei-select option:checked,
.vei-target-layer option:checked,
.vei-target-species option:checked {
  background: #2b4a6d;
  color: #fff;
}

/* アクセシビリティ対応 */
@media (forced-colors: active) {

  .vei-select,
  .vei-textarea {
    forced-color-adjust: auto;
  }
}

/* タブパネルの表示制御 */
.vei-tab-panel {
  display: none !important;
}

.vei-tab-panel.active {
  display: flex !important;
  flex-direction: column;
}

/* ==== Responsive Layout for VEI Modal ==== */
.vei-flex-box {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  background: #EBEEF3;
  padding: 16px;
  border-radius: 6px;
  align-items: flex-start;
}

.vei-right-block {
  display: flex;
  flex-direction: column;
  flex: 1 1 360px;
  min-width: 280px;
  max-width: 100%;
}

.vei-left-block,
.vei-left-bottom-block {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1 1 360px;
  min-width: 280px;
  max-width: 100%;
}

.vei-left-block {
  max-width: 420px;
}

.vei-left-bottom-block {
  max-width: 450px;
}

#vei-tab-image canvas#vei-forest-canvas {
  width: 100%;
  height: 300px;
  display: block;
  background: linear-gradient(to bottom, #87CEEB 0%, #87CEEB 25%, #4c8a3d 25%, #1e4d24 100%);
  border-radius: 6px;
}

/* VEI スコアカード */
.vei-score-row {
  align-items: center;
}

.vei-score-card {
  background: #FAFBFD;
  border-radius: 8px;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 400px;
  height: 140px;
  gap: 8px;
  margin-left: auto;
  margin-right: auto;
}

.vei-score-label {
  color: #5B5F66;
  font-size: 14px;
  letter-spacing: .5px;
  text-align: center;
}

.vei-score-value {
  color: #141415;
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* タブパネルのレイアウト強化 */
.vei-tab-panel {
  flex-direction: column;
  gap: 8px;
  padding: 0 1rem;
  /* 非アクティブタブでもサイズ計算のため常にblock */
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  visibility: hidden !important;
  display: block !important;
  z-index: -1 !important;
}

.vei-tab-panel.active {
  position: relative !important;
  visibility: visible !important;
  display: flex !important;
  z-index: auto !important;
  top: auto !important;
  left: auto !important;
  width: auto !important;
  height: auto !important;
}

/* === レスポンシブデザイン === */
@media (max-width: 1200px) {

  .vei-left-block,
  .vei-right-block,
  .vei-left-bottom-block {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .vei-score-card {
    flex: 1 1 100%;
  }
}

@media (max-width: 640px) {
  .vei-flex-box {
    padding: 12px;
    gap: 20px;
  }

  .vei-score-card {
    padding: 20px 12px;
    max-width: 100%;
  }

  .vei-score-value {
    font-size: 28px;
  }
}

/* === モーダルスクロールバー === */
.modal-body::-webkit-scrollbar {
  width: 5px;
  height: 5px;
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background-color: #888;
  border-radius: 10px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background-color: #555;
}

/* VEIモデルモーダルのヘッダーフッター区切り線 */
.VEI-model .modal-header,
#veiFilterModal .modal-header,
#veiCommunitySelectModal .modal-header {
  border-bottom: 1px solid #D2D5DA;
  margin-bottom: 0;
}

.VEI-model .modal-footer,
#veiFilterModal .modal-footer,
#veiCommunitySelectModal .modal-footer {
  border-top: 1px solid #D2D5DA;
}

.VEI-model .modal-content {
  border-radius: 16px !important;
}

/* === VEI プレースホルダ / セレクト状態カラー === */
.VEI-model .vei-input::placeholder,
#veiFilterModal .vei-input::placeholder,
.VEI-model .vei-select::placeholder {
  /* タイトル入力プレースホルダ */
  color: #d5dfed;
  font-size: 14px;
  opacity: 1;
  /* Firefox */
}

.VEI-model .vei-select {
  /* 未選択時(placeholder: value="") */
  color: #d5dfed;
  font-size: 14px;
}

.VEI-model .vei-select.has-value {
  /* 値選択後 */
  color: #141415;
}

/* iOS Safari 等で option カラーが残る場合のフォールバック */
.VEI-model .vei-select option {
  color: #ffffff;
}

.VEI-model .vei-select option[value=""] {
  color: #d5dfed;
}

/* === /VEI プレースホルダ / セレクト状態カラー === */

/* === VEI エラーメッセージスタイル === */
.vei-error-message {
  color: #ff4757;
  font-size: 11px;
  margin-top: 4px;
  margin-bottom: 0;
  padding-left: 2px;
  line-height: 1.3;
}

.vei-error-message:empty {
  display: none !important;
}

/* 入力エラー状態の枠線 */
.vei-input.error,
.vei-select.error {
  border-color: #ff4757 !important;
  box-shadow: 0 0 0 0.2rem rgba(255, 71, 87, 0.25) !important;
}

/* VEI ガイドメッセージ */
.vei-guide-message {
  color: #4da3ff;
  background: rgba(77, 163, 255, 0.1);
  border: 1px solid rgba(77, 163, 255, 0.3);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 12px;
  text-align: center;
  line-height: 1.4;
  width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* VEI警告メッセージ */
.vei-warning-message {
  color: #ffab00;
  background: rgba(255, 171, 0, 0.1);
  border: 1px solid rgba(255, 171, 0, 0.3);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  margin-bottom: 12px;
  text-align: center;
  line-height: 1.4;
  width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* === /VEI エラーメッセージスタイル === */

/* === VEI 群落選択リスト === */
.vei-community-item {
  background: #FAFBFD;
  border: 1px solid #D2D5DA;
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.vei-community-item:hover {
  background: #DCDFE5;
}

.vei-community-item:active {
  background: #F0F3FA;
}

.vei-community-item .community-label {
  color: #141415;
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 4px;
}

.vei-community-item .community-details {
  color: #5B5F66;
  font-size: 12px;
  line-height: 1.3;
}

.vei-community-item .community-species {
  color: #4da3ff;
  font-size: 11px;
  margin-top: 4px;
  max-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* AutoComplete.js スタイル */
.vei-autocomplete-wrapper {
  position: relative;
}



/* AutoComplete dropdown style - 既存セレクトボックスと同じスタイル */
[id^="autoComplete_list"] {
  background: #FAFBFD !important;
  border: 1px solid #D2D5DA !important;
  border-radius: 4px !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
  max-height: 200px !important;
  overflow-y: auto !important;
  margin-top: 2px !important;
  z-index: 1050 !important;
  font-size: 13px !important;
  font-family: inherit !important;
}

[id^="autoComplete_list"] li {
  background: #FAFBFD !important;
  color: #141415 !important;
  padding: 8px 12px !important;
  cursor: pointer !important;
  transition: background-color 0.2s ease !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  border-bottom: none !important;
  display: block !important;
  width: 100% !important;
}

[id^="autoComplete_list"] li:hover,
[id^="autoComplete_list"] li[aria-selected="true"] {
  background: #DCDFE5 !important;
  color: #141415 !important;
}

[id^="autoComplete_list"]::-webkit-scrollbar {
  width: 5px !important;
}

[id^="autoComplete_list"]::-webkit-scrollbar-thumb {
  background: #888 !important;
  border-radius: 10px !important;
}

[id^="autoComplete_list"]::-webkit-scrollbar-thumb:hover {
  background: #555 !important;
}

/* ハイライト機能を無効化 */
[id^="autoComplete_list"] li mark {
  background: transparent !important;
  color: inherit !important;
  font-weight: normal !important;
}

/* 検索結果なしメッセージ */
[id^="autoComplete_list"] .no_result {
  color: #9fb6d6 !important;
  font-style: italic !important;
  padding: 8px 12px !important;
  text-align: center !important;
  background: #FAFBFD !important;
}

/* AutoCompleteの入力フィールドにセレクトボックス風の矢印を追加 */
.vei-autocomplete {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 16px 16px !important;
  padding-right: 40px !important;
  cursor: text !important;
}

/* 矢印部分のホバーエフェクト */
.vei-autocomplete:hover {
  background-position: right 12px center, right 12px center !important;
}

/* AutoCompleteリスト用の追加スペース確保とモーダル内収納 */
[id^="autoComplete_list"] {
  max-height: 200px !important;
  min-width: 100% !important;
  position: relative !important;
  z-index: 1060 !important;
}

/* 絞り込みモーダル内のAutoCompleteコンテナ */
.vei-filter-modal-dialog .vei-autocomplete-wrapper {
  position: relative !important;
  z-index: 1 !important;
}

/* モーダル全体の動的サイズ調整 */
.vei-filter-modal-dialog .modal-content {
  overflow: visible !important;
  max-height: 90vh !important;
  display: flex !important;
  flex-direction: column !important;
}

.vei-filter-modal-dialog .modal-body {
  overflow: visible !important;
  flex-grow: 1 !important;
}

/* モーダルのオーバーレイスタイル強化 */
#veiFilterModal.modal.show,
#veiCommunitySelectModal.modal.show {
  background-color: rgba(0, 0, 0, 0.6) !important;
}

#veiFilterModal .modal-backdrop,
#veiCommunitySelectModal .modal-backdrop {
  background-color: rgba(0, 0, 0, 0.6) !important;
  z-index: 1040 !important;
}

/* 絞り込みモーダルのz-index調整 */
#veiFilterModal {
  z-index: 60000 !important;
}

#veiFilterModal .modal-backdrop {
  z-index: 59999 !important;
}

#veiCommunitySelectModal {
  z-index: 55000 !important;
}

#veiCommunitySelectModal .modal-backdrop {
  z-index: 54999 !important;
}

/* 絞り込みリンクのスタイル */
.vei-filter-link {
  position: absolute !important;
  right: 0 !important;
  color: #3d82ff !important;
  font-size: 12px !important;
  cursor: pointer !important;
  padding: 2px 4px !important;
  border-radius: 3px !important;
  transition: background-color 0.2s ease, color 0.2s ease !important;
  user-select: none !important;
  white-space: nowrap !important;
}

.vei-filter-link:hover {
  color: #5a9cff !important;
}

.vei-filter-link:active {
  background-color: rgba(61, 130, 255, 0.2) !important;
}

/* 群落未選択時のプレースホルダースタイル */
.vei-tab-placeholder {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 200px !important;
  background: rgba(30, 41, 59, 0.1) !important;
  border-radius: 6px !important;
  border: 1px dashed #2e4c70 !important;
}

/* === 群落選択モーダル固定位置スタイル === */
#veiCommunitySelectModal .modal-dialog {
  position: fixed !important;
  top: 12rem !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  margin: 0 !important;
  width: 90% !important;
  max-width: 800px !important;
  height: calc(70vh - 6rem) !important;
  max-height: 80vh !important;
}

#veiCommunitySelectModal .modal-content {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

#veiCommunitySelectModal .modal-body {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  padding: 1rem !important;
}

#veiCommunitySelectModal .modal-body>div:first-child {
  flex-shrink: 0 !important;
  margin-bottom: 1rem !important;
}

#veiCommunitySelectModal .modal-body>div:last-child {
  flex: 1 !important;
  overflow-y: auto !important;
  padding-right: 0.5rem !important;
}

#veiCommunitySelectModal .modal-body>div:last-child::-webkit-scrollbar {
  width: 5px !important;
}

#veiCommunitySelectModal .modal-body>div:last-child::-webkit-scrollbar-thumb {
  background-color: #888 !important;
  border-radius: 4px !important;
}

#veiCommunitySelectModal .modal-body>div:last-child::-webkit-scrollbar-thumb:hover {
  background-color: #555 !important;
}

/* レスポンシブ調整 */
@media (max-width: 768px) {
  #veiCommunitySelectModal .modal-dialog {
    top: 1rem !important;
    width: 95% !important;
    height: calc(100vh - 2rem) !important;
    max-height: 95vh !important;
  }
}

/* === /VEI 群落選択リスト === */