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 {
  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"] {
  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;
}

input[type="number"]:focus,
input[type="datetime-local"]:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.2);
}

.buttons {
  display: flex;
  gap: 8px;
}

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;
}

.export-time-row span {
  font-size: 12px;
}

.export-time-row input[type="datetime-local"] {
  flex: 1.2;
}

.export-pace-min,
.export-pace-sec {
  width: 40px;
  font-size: 12px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-chart {
  border: 1px solid #e5e7eb;
  padding: 4px 6px;
  border-radius: 4px;
  background: #f9fafb;
}

.preview-chart h2 {
  margin: 0 0 4px;
  font-size: 13px;
}

.preview-chart canvas {
  width: 100%;
  height: 120px;
}

.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;
}

/* ===== key modal ===== */
.key-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}
.key-modal.show { display: flex; }
.key-modal-card {
  background: #fff;
  border-radius: 14px;
  padding: 22px 22px 18px;
  width: min(420px, 100%);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.key-modal-card h2 { margin: 0 0 8px; font-size: 1.15rem; color: #0f172a; }
.key-tip { margin: 0 0 14px; font-size: 0.88rem; color: #475569; line-height: 1.55; }
.key-label { display: block; margin: 10px 0 4px; font-size: 0.82rem; color: #334155; }
.key-modal-card input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.92rem;
}
.key-modal-card input[type="text"]:focus {
  outline: 2px solid #2563eb33;
  border-color: #2563eb;
}
.key-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  font-size: 0.86rem;
  color: #334155;
}
.key-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.key-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}
.key-btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.key-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.key-status { margin-top: 10px; font-size: 0.85rem; min-height: 1.2em; }
.key-status.pending { color: #2563eb; }
.key-status.ok { color: #15803d; }
.key-status.error { color: #b91c1c; }
.key-help { margin-top: 12px; font-size: 0.82rem; color: #475569; }
.key-help summary { cursor: pointer; color: #2563eb; }
.key-help ol { margin: 8px 0 8px 18px; padding: 0; }
.key-help li { margin: 4px 0; }
.key-toolbar { display: flex; gap: 6px; margin-bottom: 10px; }
.mini-btn {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #334155;
  cursor: pointer;
}
.mini-btn:hover { background: #e2e8f0; }


/* Leaflet 需要明确高度 */
#map {
  flex: 1;
  min-height: 280px;
  height: 100%;
  background: #e5e7eb;
  z-index: 0;
}


/* 定位确认条 */
.loc-confirm {
  display: none;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.loc-confirm.show { display: block; }
.loc-confirm-text { margin-bottom: 8px; color: #9a3412; line-height: 1.5; }
.loc-confirm-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.loc-confirm .mini-btn { font-size: 12px; padding: 6px 10px; }

/* 地点搜索 */
.place-search-row {
  display: flex;
  gap: 6px;
}
.place-search-row input {
  flex: 1;
  min-width: 0;
}
.place-search-row .mini-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 13px;
}
.place-results {
  margin-top: 6px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.place-results:empty { display: none; }
.place-item {
  text-align: left;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.45;
}
.place-item:hover {
  background: #eef2ff;
  border-color: #6366f1;
}
.place-item .place-name {
  font-weight: 600;
  color: #111827;
  display: block;
}
.place-item .place-addr {
  color: #6b7280;
}
.place-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.4;
}
.place-status {
  margin-top: 6px;
  font-size: 12px;
  color: #2563eb;
}

/* ===== 侧栏放大（字号 / 控件） ===== */
body {
  font-size: 16px;
}

.sidebar {
  width: 400px;
  padding: 20px 22px;
  gap: 14px;
  overflow-y: auto;
}

.sidebar h1 {
  font-size: 22px;
  margin-bottom: 10px;
}

.sidebar label {
  font-size: 15px;
  font-weight: 500;
  color: #1f2937;
}

.form-group {
  gap: 6px;
}

.sidebar input[type="number"],
.sidebar input[type="datetime-local"],
.sidebar input[type="text"] {
  padding: 10px 12px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  width: 100%;
  box-sizing: border-box;
}

.sidebar button {
  padding: 12px 14px;
  font-size: 15px;
  border-radius: 10px;
  width: 100%;
}

.sidebar .buttons {
  flex-direction: column;
  gap: 10px;
}

.sidebar .mini-btn {
  padding: 10px 14px;
  font-size: 14px;
  border-radius: 8px;
  width: auto;
}

.message {
  min-height: 48px;
  font-size: 14px;
  line-height: 1.55;
}

.distance-info {
  font-size: 15px;
  font-weight: 500;
}

.tip {
  font-size: 13px;
  line-height: 1.55;
}

.place-search label {
  font-size: 15px;
}

.place-search-row input {
  padding: 10px 12px;
  font-size: 15px;
}

.place-item {
  padding: 10px 12px;
  font-size: 13px;
}

.place-item .place-name {
  font-size: 14px;
}

.place-hint {
  font-size: 12px;
}

.export-time-row span {
  font-size: 14px;
}

.export-time-row input {
  padding: 8px 10px;
  font-size: 14px;
}

.loc-confirm {
  padding: 12px 14px;
  font-size: 14px;
}

.loc-confirm .mini-btn {
  font-size: 14px;
  padding: 10px 14px;
}

.preview-panel h2,
.live-info {
  font-size: 14px;
}

/* ===== 手机适配：地图在上，控制面板在下 ===== */
@media (max-width: 768px) {
  html, body {
    height: auto;
    min-height: 100%;
    font-size: 15px;
  }

  #app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  #map {
    order: 1;
    width: 100%;
    height: 55vh;
    min-height: 280px;
    flex: none;
  }

  .sidebar {
    order: 2;
    width: 100%;
    height: auto;
    overflow: visible;
    border-right: none;
    border-top: 1px solid #e5e7eb;
    padding: 16px;
    box-shadow: none;
  }

  .sidebar h1 {
    font-size: 20px;
  }

  .sidebar .buttons {
    flex-direction: column;
    gap: 10px;
  }

  .sidebar button {
    width: 100%;
    padding: 14px 12px;
    font-size: 16px;
  }

  .sidebar input[type="number"],
  .sidebar input[type="datetime-local"],
  .sidebar input[type="text"],
  .place-search-row input {
    padding: 12px;
    font-size: 16px; /* iOS 不缩放 */
  }

  .place-search-row {
    flex-direction: row;
    gap: 8px;
  }

  .place-search-row .mini-btn {
    padding: 12px 16px;
    font-size: 15px;
  }

  .preview-panel {
    width: 100%;
  }

  .preview-chart canvas {
    max-width: 100%;
  }

  .export-time-row {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* 平板：侧栏略窄 */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 320px;
  }
}
