:root {
  --primary-blue: #0284C7;
  --primary-blue-dark: #0369A1;
  --accent-green: #10B981;
  --accent-orange: #F59E0B;
  --accent-red: #EF4444;
  --bg-light: #F8FAFC;
  --card-bg: rgba(255, 255, 255, 0.95);
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border-color: rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background: #E2E8F0;
  color: var(--text-main);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

#map-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* 頂部懸浮控制卡片 */
.webmap-top-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 410px;
  max-width: calc(100vw - 32px);
  z-index: 1000;
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 16px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  color: #0F172A;
}

.brand-logo .shield-icon {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #0284C7, #0369A1);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
}

/* 2D / 3D / 衛星模式切換器 */
.map-view-modes {
  display: flex;
  background: rgba(241, 245, 249, 0.95);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 3px;
}

.view-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-mode-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.6);
}

.view-mode-btn.active {
  background: #FFFFFF;
  color: var(--primary-blue);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

/* 中文 / 雙語 / 英文三段語言切換器 */
.map-lang-modes {
  display: flex;
  background: rgba(241, 245, 249, 0.95);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  gap: 2px;
}

.lang-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.lang-mode-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.6);
}

.lang-mode-btn.active {
  background: #FFFFFF;
  color: #0284C7;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.status-pill {
  font-size: 11px;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-green);
  padding: 3px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* 出行模式切換 */
.mode-tabs {
  display: flex;
  background: #F1F5F9;
  padding: 3px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}

.mode-tab {
  flex: 1;
  text-align: center;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  user-select: none;
}

.mode-tab.active {
  background: #FFFFFF;
  color: var(--primary-blue);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* 起終點輸入方塊 */
.input-group-box {
  display: flex;
  align-items: center;
  position: relative;
  background: #F8FAFC;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.input-dots {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-right: 12px;
  gap: 6px;
}

.dot-green {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.dot-line {
  width: 1.5px;
  height: 18px;
  background: #CBD5E1;
}

.dot-red {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-red);
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.input-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.webmap-input {
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: #0F172A;
  outline: none;
  padding: 4px 0;
  width: 100%;
}

.webmap-input::placeholder {
  color: #94A3B8;
  font-weight: 400;
}

.input-swap-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  color: var(--primary-blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: transform 0.2s ease;
  margin-left: 8px;
}

.input-swap-btn:hover {
  transform: rotate(180deg);
}

/* 算路按鈕 */
.search-btn {
  width: 100%;
  padding: 10px 0;
  background: linear-gradient(135deg, #0284C7, #0369A1);
  border: none;
  border-radius: var(--radius-md);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.search-btn:hover {
  background: linear-gradient(135deg, #0369A1, #075985);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.4);
}

.search-btn:active {
  transform: scale(0.98);
}

/* 底部路線方案抽屜 */
.webmap-route-drawer {
  position: absolute;
  bottom: 24px;
  left: 16px;
  width: 440px;
  max-width: calc(100vw - 32px);
  max-height: 48vh;
  z-index: 1000;
  background: var(--card-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 18px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.route-drawer-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.route-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.route-title {
  font-size: 19px;
  font-weight: 700;
  color: #0F172A;
}

.route-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
}

.route-meta {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.segment-capsule-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.transit-capsule {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #FFFFFF;
}

.arrow-icon {
  color: #94A3B8;
  font-size: 11px;
}

.stepper-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
  margin-bottom: 12px;
}

.stepper-item {
  display: flex;
  gap: 12px;
  position: relative;
  padding-bottom: 16px;
}

.stepper-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: #E2E8F0;
}

.stepper-icon-node {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  z-index: 2;
  flex-shrink: 0;
}

.stepper-content {
  flex: 1;
}

.stepper-title {
  font-size: 13px;
  font-weight: 600;
  color: #0F172A;
  margin-bottom: 2px;
}

.stepper-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.navigate-action-btn {
  width: 100%;
  padding: 12px 0;
  background: var(--primary-blue);
  border: none;
  border-radius: var(--radius-md);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
  transition: all 0.2s ease;
}

.navigate-action-btn:hover {
  background: var(--primary-blue-dark);
}
.navigate-action-btn:disabled {
  background: #64748B;
  cursor: not-allowed;
  box-shadow: none;
}

/* 右側浮動工具欄 */
.webmap-right-tools {
  position: absolute;
  top: 20px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-btn {
  width: 44px;
  height: 44px;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #334155;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.tool-btn:hover {
  transform: scale(1.06);
  color: var(--primary-blue);
}

.tool-btn.sos-btn {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
  animation: sos-glow 2s infinite;
}

@keyframes sos-glow {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.safepath-night-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #1E1B4B, #0F172A);
  color: #A5B4FC;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(165, 180, 252, 0.3);
}

.leaflet-control-zoom {
  display: none !important;
}

@media (max-width: 600px) {
  .webmap-top-panel {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
  }
  .webmap-route-drawer {
    left: 10px;
    right: 10px;
    bottom: 12px;
    width: auto;
  }
}
.route-strategy-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}
.route-strategy-card {
  min-width: 0;
  padding: 10px 8px;
  border: 1px solid #CBD5E1;
  border-radius: 12px;
  background: #F8FAFC;
  color: #0F172A;
  text-align: left;
  font: inherit;
}
.route-strategy-card[aria-pressed="true"] { border-color: #0284C7; box-shadow: inset 0 0 0 1px #0284C7; }
.route-strategy-card:disabled { color: #64748B; background: #F1F5F9; cursor: not-allowed; }
.route-strategy-label { display: block; font-weight: 800; font-size: 13px; }
.route-strategy-status { display: block; margin-top: 4px; font-size: 11px; line-height: 1.35; }
.place-candidate-dialog { width: min(92vw, 480px); max-height: 82vh; border: 0; border-radius: 16px; padding: 20px; color: #0F172A; box-shadow: 0 18px 60px #0F172A55; }
.place-candidate-dialog::backdrop { background: #0F172A88; }
.place-candidate-dialog h2 { margin: 0 0 8px; font-size: 18px; }
.place-candidate-dialog p { margin: 0 0 14px; color: #475569; font-size: 14px; }
.place-candidate-options { display: grid; gap: 8px; max-height: 48vh; overflow: auto; }
.place-candidate-option { display: flex; align-items: flex-start; gap: 10px; padding: 11px; border: 1px solid #CBD5E1; border-radius: 10px; cursor: pointer; }
.place-candidate-option input { margin-top: 4px; }
.place-candidate-option span, .place-candidate-option small { display: block; }
.place-candidate-option small { margin-top: 4px; color: #64748B; line-height: 1.4; }
.place-candidate-attribution { display: block; margin-top: 12px; color: #64748B; }
.place-candidate-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.place-candidate-actions button { padding: 9px 12px; border: 1px solid #CBD5E1; border-radius: 9px; background: #FFF; font: inherit; }
.place-candidate-actions button:last-child { border-color: #0284C7; background: #0284C7; color: #FFF; }
.place-candidate-actions button:disabled { opacity: .5; cursor: not-allowed; }

/* 右上角常駐 CWA 天氣資訊卡 (Zoom > 11 時自地圖淡出並轉移至此) */
.cwa-weather-card {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1000;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.7);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}
.cwa-weather-card.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.cwa-weather-card .weather-icon {
  font-size: 20px;
}
.cwa-weather-card .weather-details {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.cwa-weather-card .weather-title {
  font-size: 11px;
  color: var(--text-muted);
}
.cwa-weather-card .weather-val {
  font-size: 13px;
  font-weight: 700;
  color: #6001D2; /* 經典 Yahoo 紫色 */
}
