html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f4f6;
}

#app {
  display: flex;
  height: 100vh;
}

.sidebar {
  overflow-y: auto;
  width: 340px;
  padding: 16px 18px;
  box-sizing: border-box;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  box-shadow: 0 0 30px rgba(15, 23, 42, 0.08);
  z-index: 1;
}

.sidebar h1 {
  font-size: 18px;
  margin: 0 0 8px;
  color: #111827;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

input[type="number"],
input[type="datetime-local"],
input[type="text"],
select {
  padding: 4px 6px;
  font-size: 14px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  background: #ffffff;
}

input[type="number"]:focus,
input[type="datetime-local"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  color: #333;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.buttons button {
  flex: 1 1 46%;
  white-space: nowrap;
  padding: 6px 6px;
  font-size: 13px;
}

.export-time-row span {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 11px;
}

button {
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 999px;
  border: none;
  background: #2563eb;
  color: #ffffff;
  transition: background 0.15s ease, transform 0.05s ease;
}

button:hover {
  background: #1d4ed8;
}

button:active {
  transform: scale(0.97);
}

#map {
  flex: 1;
  background: #e5e7eb;
}

.message {
  min-height: 20px;
  font-size: 13px;
  color: #333;
}

.message.error {
  color: #c62828;
}

.distance-info {
  min-height: 20px;
  font-size: 13px;
  color: #333;
}

.export-times {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.export-time-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.export-time-row span {
  font-size: 12px;
}

.export-time-row input[type="datetime-local"] {
  flex: 1 1 0;
  min-width: 0;
}

.export-pace-min,
.export-pace-sec {
  flex: 0 0 34px;
  width: 34px;
  padding: 4px 2px;
  font-size: 12px;
  text-align: center;
}

.live-info {
  min-height: 20px;
  font-size: 13px;
  color: #111827;
}

.tip {
  font-size: 12px;
  color: #666;
}

/* 版权区域整体样式 */
.leaflet-control-attribution {
  background: transparent !important;
  padding: 5px 10px 3px 10px !important;
  text-align: right !important;
  border: none !important;
  box-shadow: none !important;
}

/* 文字行背景 */
.leaflet-control-attribution::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 20px;
  background: rgba(255, 255, 255, 0.85);
  z-index: -1;
  border-radius: 3px;
}

/* 确保内容在背景之上 */
.leaflet-control-attribution > * {
  position: relative;
  z-index: 1;
}

/* 天地图logo悬停效果 */
.leaflet-control-attribution a:hover img {
  opacity: 0.8;
  transform: scale(1.05);
  transition: all 0.2s ease;
}

/* 当前位置标记样式 */
.current-location-marker {
  background: transparent;
  border: none;
}

.location-pulse {
  width: 20px;
  height: 20px;
  background: #4285f4;
  border: 3px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.7);
  animation: pulse 2s infinite;
  position: relative;
}

.location-pulse::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
}

@keyframes pulse {
  0% {
      box-shadow: 0 0 0 0 rgba(66, 133, 244, 0.7);
  }
  50% {
      box-shadow: 0 0 0 10px rgba(66, 133, 244, 0);
  }
  100% {
      box-shadow: 0 0 0 0 rgba(66, 133, 244, 0);
  }
}

/* 弹窗优化 */
.leaflet-popup-content {
  margin: 10px 15px;
  line-height: 1.6;
}

/* ===== 路线偏移控件 ===== */
.offset-value {
  font-weight: 600;
  color: #2563eb;
  margin-left: 4px;
}

.tip-inline {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.4;
}

input[type="range"] {
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  accent-color: #2563eb;
  cursor: pointer;
}

/* ===== 路线编辑（撤回 / 结点拖动 / 平移 / 导入导出） ===== */

.toolbar-buttons button {
  flex: 1 1 44%;
  padding: 5px 8px;
  font-size: 13px;
}

button.secondary {
  background: #eef2ff;
  color: #1d4ed8;
  border: 1px solid #c7d2fe;
}

button.secondary:hover {
  background: #e0e7ff;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary:disabled:hover {
  background: #eef2ff;
}

.route-line {
  cursor: grab;
}

.route-vertex {
  background: transparent;
  border: none;
}

.route-vertex span {
  display: block;
  width: 14px;
  height: 14px;
  margin: 1px;
  box-sizing: border-box;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #ff5722;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  cursor: grab;
}

.route-vertex span:hover {
  background: #ffe0d6;
}

/* ===== 分段路线（首圈 / 尾圈） ===== */
.seg-tabs {
  display: flex;
  gap: 6px;
}

.seg-tab {
  flex: 1 1 0;
  padding: 5px 4px;
  font-size: 13px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #374151;
}

.seg-tab:hover {
  background: #eef2ff;
}

.seg-tab.active {
  background: #ff5722;
  border-color: #ff5722;
  color: #ffffff;
}

.seg-tab.active:hover {
  background: #ff5722;
}

.seg-tab[data-segment="start"].active,
.seg-tab[data-segment="start"].active:hover {
  background: #16a34a;
  border-color: #16a34a;
}

.seg-tab[data-segment="end"].active,
.seg-tab[data-segment="end"].active:hover {
  background: #2563eb;
  border-color: #2563eb;
}

/* ===== 路线编辑工具 ===== */
.seg-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}

.seg-tools button {
  padding: 5px 4px;
  font-size: 12px;
  white-space: nowrap;
}

button.secondary.active {
  background: #ff5722;
  border-color: #ff5722;
  color: #ffffff;
}

.route-vertex-selected span {
  background: #ff5722;
  border-color: #7c2d12;
  transform: scale(1.3);
}

.route-vertex-cut span {
  background: #facc15;
  border-color: #a16207;
  transform: scale(1.25);
}

.route-vertex-head span {
  background: #16a34a;
  border-color: #14532d;
}

.route-vertex-tail span {
  background: #2563eb;
  border-color: #1e3a8a;
}

/* ===== 预览 ===== */
.leaflet-trail-layer {
  pointer-events: none;
}

.speed-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #6b7280;
}

.speed-legend i {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 55%, #22c55e 100%);
}

#exitPreviewBtn {
  margin-top: 4px;
  padding: 5px 8px;
  font-size: 13px;
}

/* ===== 侧栏：上面滚动、底部按钮固定 ===== */
.sidebar {
  padding: 12px 14px;
  gap: 0;
  overflow: hidden;
  height: 100vh;
}

.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.sidebar-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid #e5e7eb;
  background: #ffffff;
}

.sidebar-actions .buttons {
  margin: 0;
}

.sidebar-actions #distanceInfo {
  font-weight: 600;
  color: #111827;
}

/* 滚动条更明显，提示上面还有内容 */
.sidebar-scroll {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 8px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.sidebar-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
}

.sidebar-scroll {
  gap: 8px;
}

/* 底部操作按钮：四列排布，节省高度 */
.sidebar-actions .buttons button {
  flex: 1 1 20%;
  min-width: 0;
  font-size: 12px;
  padding: 6px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-actions .buttons {
  gap: 6px;
}

.sidebar-actions #message,
.sidebar-actions #liveInfo {
  min-height: 18px;
  line-height: 1.35;
}

/* 底部按钮行改为横向排布（否则会继承 form-group 的 column 方向） */
.sidebar-actions .buttons {
  flex-direction: row;
}
