/* ===== 变量与重置 ===== */
:root {
  --bg-deep: #0c1222;
  --bg-panel: rgba(18, 28, 48, 0.82);
  --bg-panel-solid: #121c30;
  --accent: #ff9f43;
  --accent-soft: rgba(255, 159, 67, 0.35);
  --cyan: #00d4aa;
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --font: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* ===== 顶部标题栏 ===== */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(
    180deg,
    rgba(12, 18, 34, 0.95) 0%,
    rgba(12, 18, 34, 0.65) 70%,
    transparent 100%
  );
  pointer-events: none;
}

.app-header > * {
  pointer-events: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  background: linear-gradient(135deg, #fff 0%, var(--cyan) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-ghost {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-ghost:active {
  transform: scale(0.97);
}

/* ===== 地图容器 ===== */
#map {
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
}

.leaflet-container {
  font-family: var(--font);
  background: var(--bg-deep);
}

/* ===== 底图观感优化（去“方块”） ===== */
.leaflet-pane.leaflet-tile-pane {
  /* 轻微软化瓷砖边界，保持路线/标注清晰（路线在其他 pane 上层渲染） */
  filter: saturate(1.06) contrast(1.05) brightness(0.94) blur(0.25px);
}

.leaflet-tile {
  image-rendering: auto;
  opacity: 0.98;
}

/* 自定义缩放控件位置，避免挡内容 */
.leaflet-top.leaflet-left {
  top: auto;
  bottom: 100px;
  left: 12px;
}

@media (min-width: 900px) {
  .leaflet-top.leaflet-left {
    bottom: 24px;
    left: 24px;
  }
}

.leaflet-control-zoom {
  border: none !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  font-size: 20px !important;
  background: var(--bg-panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

.leaflet-control-zoom a:hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

.leaflet-control-attribution {
  background: rgba(12, 18, 34, 0.75) !important;
  color: var(--text-muted) !important;
  font-size: 10px !important;
  padding: 4px 8px !important;
  border-radius: 8px 0 0 0 !important;
}

.leaflet-control-attribution a {
  color: var(--cyan) !important;
}

/* Leaflet 自定义 divIcon 容器 */
.g318-marker-icon {
  background: none !important;
  border: none !important;
}

.g318-marker-icon .marker-wrap {
  cursor: pointer;
}

/* ===== 脉冲标注（Leaflet divIcon） ===== */
.marker-wrap {
  position: relative;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: marker-pulse 2.2s ease-out infinite;
  opacity: 0.85;
}

.marker-core {
  position: relative;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff5e6, var(--accent) 45%, #c45c1a);
  box-shadow:
    0 0 12px var(--accent-soft),
    0 0 24px rgba(255, 159, 67, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.5);
  z-index: 1;
}

.marker-wrap.is-active .marker-core {
  box-shadow:
    0 0 16px var(--cyan),
    0 0 32px rgba(0, 212, 170, 0.45),
    inset 0 1px 2px rgba(255, 255, 255, 0.6);
}

.marker-wrap.is-active .marker-pulse {
  border-color: var(--cyan);
  animation-duration: 1.4s;
}

@keyframes marker-pulse {
  0% {
    transform: scale(0.65);
    opacity: 0.95;
  }
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

/* ===== marker 地名标签（Leaflet tooltip） ===== */
.spot-label.leaflet-tooltip {
  background: rgba(18, 28, 48, 0.78) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: var(--text) !important;
  border-radius: 999px !important;
  padding: 6px 10px !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: none !important;
  margin-top: -2px;
}

.spot-label.leaflet-tooltip-top::before,
.spot-label.leaflet-tooltip-right::before,
.spot-label.leaflet-tooltip-left::before,
.spot-label.leaflet-tooltip-bottom::before {
  border: none !important;
}

.distance-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(18, 28, 48, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-weight: 700;
  font-size: 0.78rem;
  white-space: nowrap;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

@media (prefers-reduced-motion: reduce) {
  .marker-pulse {
    animation: none;
    opacity: 0.35;
    transform: scale(1.4);
  }

  .detail-panel,
  .detail-backdrop,
  .loading-screen {
    transition: none;
  }
}

/* ===== 底部图例 ===== */
.map-legend {
  position: fixed;
  z-index: 1000;
  left: 12px;
  bottom: max(16px, var(--safe-bottom));
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.map-legend > * {
  pointer-events: auto;
}

.legend-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-line {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--accent));
  box-shadow: 0 0 10px rgba(0, 212, 170, 0.5);
}

.legend-dot-demo {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.hint-swipe {
  display: none;
  align-items: center;
  gap: 6px;
}

@media (max-width: 768px) {
  .hint-swipe {
    display: flex;
  }
}

/* ===== 详情面板 ===== */
.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
  backdrop-filter: none;
}

.detail-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.detail-panel {
  position: fixed;
  z-index: 1210;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(420px, 100vw);
  max-width: 100%;
  background: linear-gradient(
    165deg,
    var(--bg-panel-solid) 0%,
    #0a1020 100%
  );
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 48px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: var(--safe-bottom);
}

.detail-panel.is-open {
  transform: translateX(0);
}

.detail-panel-header {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.detail-title-block h2 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 700;
}

.detail-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--cyan);
  font-weight: 500;
}

.btn-close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.detail-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 28px;
  -webkit-overflow-scrolling: touch;
}

.detail-hero {
  height: 120px;
  border-radius: 14px;
  margin-bottom: 18px;
  background:
    radial-gradient(ellipse 80% 60% at 20% 40%, rgba(0, 212, 170, 0.25), transparent),
    radial-gradient(ellipse 60% 50% at 80% 60%, rgba(255, 159, 67, 0.2), transparent),
    linear-gradient(135deg, #1a2840 0%, #0d1528 100%);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  padding: 14px 16px;
}

.detail-hero-label {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h3 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
}

.tag--food {
  border-color: rgba(255, 159, 67, 0.35);
  background: rgba(255, 159, 67, 0.1);
}

.tag--spot {
  border-color: rgba(0, 212, 170, 0.35);
  background: rgba(0, 212, 170, 0.1);
}

.tag--plan {
  border-color: rgba(0, 212, 170, 0.25);
  background: rgba(0, 212, 170, 0.08);
  box-shadow: 0 0 16px rgba(0, 212, 170, 0.12);
}

.detail-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.meta-item {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.meta-item span {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.06em;
}

.meta-item strong {
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 600;
}

/* 移动端：底部抽屉式 */
@media (max-width: 600px) {
  .detail-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 88vh;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    transform: translateY(110%);
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.55);
  }

  .detail-panel.is-open {
    transform: translateY(0);
  }

  .detail-panel-header {
    padding-top: 22px;
  }

  .detail-panel-header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.15);
  }
}

/* ===== 加载层 ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  transition: opacity 0.45s ease, visibility 0.45s;
}

.loading-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

.loading-text {
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.2em;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
