﻿:root {
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --accent: #f97316;
  --success: #16a34a;
  --danger: #ef4444;
  --bg: #f8fafc;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #eff6ff;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body { touch-action: manipulation; }
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.map-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #dbeafe;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
}

.top-bar {
  position: fixed;
  z-index: 30;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.brand-pill, .icon-btn, .map-action-btn, .route-toast, .toast {
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(16px);
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  max-width: calc(100vw - 84px);
  padding: 8px 12px 8px 8px;
  border-radius: 999px;
  pointer-events: auto;
}

.brand-logo {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
}

.brand-pill strong { display: block; font-size: 16px; line-height: 1; }
.brand-pill span { display: block; max-width: 190px; margin-top: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: var(--primary);
  border-radius: 999px;
  pointer-events: auto;
}

.panel-toggle-btn {
  position: fixed;
  z-index: 55;
  right: 12px;
  top: calc(max(12px, env(safe-area-inset-top)) + 64px);
  min-width: 88px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 23, 42, 0.88);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(14px);
  font-size: 13px;
  font-weight: 900;
}

.nav-hud {
  position: fixed;
  z-index: 58;
  left: 12px;
  right: 12px;
  top: calc(max(12px, env(safe-area-inset-top)) + 66px);
  padding: 14px;
  border-radius: 22px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(18px);
}
.nav-hud-main {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  align-items: center;
}
.nav-step-distance {
  min-height: 62px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  font-size: 22px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}
.nav-hud strong {
  display: block;
  font-size: 20px;
  line-height: 1.25;
}
.nav-hud span {
  display: inline-block;
  color: rgba(255,255,255,.72);
  font-size: 13px;
  margin-top: 4px;
}
.nav-hud-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.12);
}
.nav-stop-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 12px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #dc2626, #f97316);
  font-weight: 900;
}

.app-shell.is-navigating .center-picker,
.app-shell.is-navigating .map-action-btn:not(.nav-toggle) {
  display: none !important;
}

.app-shell.is-navigating .panel-toggle-btn {
  top: auto;
  bottom: calc(18px + env(safe-area-inset-bottom));
}

.app-shell.is-navigating .route-toast {
  top: calc(max(12px, env(safe-area-inset-top)) + 226px);
}

.center-picker {
  position: fixed;
  z-index: 20;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -100%);
  display: grid;
  justify-items: center;
  pointer-events: none;
}
.center-picker .pin { filter: drop-shadow(0 10px 16px rgba(37, 99, 235, 0.32)); transform-origin: bottom center; animation: floatPin 1.8s ease-in-out infinite; }
.pin-shadow { width: 18px; height: 7px; margin-top: -2px; border-radius: 999px; background: rgba(15,23,42,.22); filter: blur(2px); }
@keyframes floatPin { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.map-actions {
  position: fixed;
  z-index: 25;
  left: 50%;
  top: calc(42% + 14px);
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}
.map-action-btn {
  min-width: 86px;
  min-height: 44px;
  padding: 0 14px;
  color: var(--text);
  border-radius: 999px;
  font-weight: 800;
}
.map-action-btn.primary { color: #fff; background: linear-gradient(135deg, var(--primary), #38bdf8); border-color: transparent; }
.map-action-btn.nav-toggle { color: #fff; background: linear-gradient(135deg, #16a34a, #22c55e); border-color: transparent; }

.route-toast {
  position: fixed;
  z-index: 22;
  top: calc(max(12px, env(safe-area-inset-top)) + 64px);
  left: 50%;
  transform: translateX(-50%);
  max-width: min(92vw, 520px);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(330px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(90vw, 520px);
  padding: 11px 14px;
  border-radius: 14px;
  color: var(--text);
  font-size: 14px;
  text-align: center;
}

.bottom-sheet {
  position: fixed;
  z-index: 40;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: min(66dvh, 610px);
  overflow: auto;
  padding: 8px 14px calc(16px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  background: var(--surface);
  border: 1px solid rgba(226, 232, 240, 0.95);
  box-shadow: 0 -18px 48px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(18px);
  transition: transform .24s ease, opacity .24s ease;
  will-change: transform;
}

.bottom-sheet.is-hidden {
  transform: translateY(calc(100% + 18px));
  opacity: 0;
  pointer-events: none;
}

.sheet-handle {
  width: 48px;
  height: 5px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: #cbd5e1;
}

.sheet-header, .section-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-header { margin-bottom: 10px; }
.sheet-header h1 { margin: 0; font-size: 22px; line-height: 1.1; }
.sheet-header p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 800;
}
.status-badge.ok { background: #dcfce7; color: #15803d; }

.route-card, .play-card, .summary-card, .results-card {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.82);
}

.point-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
  padding: 4px;
  border-radius: 16px;
  background: #f1f5f9;
}
.point-tab {
  height: 42px;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}
.point-tab.active { color: #fff; background: var(--primary); box-shadow: 0 8px 20px rgba(37, 99, 235, 0.22); }

.field { display: grid; gap: 6px; margin-top: 10px; }
.field span, .range-field span, .summary-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.input-row { display: grid; grid-template-columns: 1fr 58px; gap: 8px; }
.field input, .field select {
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  outline: none;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 16px;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10); }
.mini-btn {
  min-height: 48px;
  border-radius: 14px;
  color: var(--primary);
  background: var(--soft);
  font-size: 13px;
  font-weight: 900;
}
.advanced-row { margin-top: 8px; color: var(--muted); font-size: 13px; }
.advanced-row summary { min-height: 38px; display: flex; align-items: center; cursor: pointer; font-weight: 700; }
.field.compact { margin-top: 8px; }

.primary-btn, .secondary-btn, .nav-btn {
  min-height: 50px;
  width: 100%;
  border-radius: 16px;
  color: #fff;
  font-weight: 900;
  transition: opacity .18s, transform .18s, filter .18s;
}
.primary-btn { background: linear-gradient(135deg, var(--primary), #38bdf8); box-shadow: 0 12px 28px rgba(37, 99, 235, 0.22); }
.secondary-btn { background: linear-gradient(135deg, #0f172a, #334155); }
.nav-btn { background: linear-gradient(135deg, #16a34a, #22c55e); box-shadow: 0 12px 28px rgba(22, 163, 74, 0.20); }
.nav-btn.active { background: linear-gradient(135deg, #dc2626, #f97316); }
.primary-btn:active, .secondary-btn:active, .nav-btn:active, .mini-btn:active, .icon-btn:active, .map-action-btn:active { transform: scale(0.98); }
.primary-btn:disabled, .secondary-btn:disabled, .nav-btn:disabled { opacity: .42; box-shadow: none; cursor: not-allowed; }
#planRouteBtn { margin-top: 10px; }

.play-card h2, .results-card h2 { margin: 0; font-size: 17px; }
.text-btn { min-height: 40px; padding: 0 8px; color: var(--primary); background: transparent; font-weight: 900; }

.poi-type-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.poi-chip {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  min-height: 70px;
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}
.poi-chip input { position: absolute; opacity: 0; pointer-events: none; }
.poi-chip svg { color: currentColor; }
.poi-chip:has(input:checked) { color: var(--primary); background: var(--soft); border-color: #93c5fd; }
.poi-chip:has(input:checked)::after {
  content: '';
  position: absolute;
  right: 8px;
  top: 8px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.range-field { display: grid; gap: 8px; margin-top: 14px; }
.range-field > div { display: flex; align-items: center; justify-content: space-between; }
.range-field strong { color: var(--accent); font-size: 16px; }
.range-field input { width: 100%; accent-color: var(--primary); }
.range-field small { color: var(--muted); font-size: 12px; }
.setting-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cta-row { display: grid; grid-template-columns: .78fr 1fr 1fr; gap: 8px; margin-top: 10px; }

.summary-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
}
.summary-card div { min-width: 0; padding: 9px; border-radius: 14px; background: #f8fafc; }
.summary-card span { display: block; margin-bottom: 4px; white-space: nowrap; }
.summary-card strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.result-list { display: grid; gap: 10px; margin-top: 10px; }
.result-list.empty { color: var(--muted); font-size: 14px; line-height: 1.5; }
.poi-card { padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: #fff; }
.poi-card.selected { border-color: #86efac; background: #f0fdf4; }
.poi-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.poi-card h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.poi-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.meta-pill { display: inline-flex; align-items: center; min-height: 26px; padding: 0 8px; border-radius: 999px; background: #f1f5f9; color: #334155; font-size: 12px; font-weight: 800; }
.meta-pill.score { color: #fff; background: var(--accent); }
.poi-address { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.poi-actions { display: grid; grid-template-columns: 1fr; margin-top: 10px; }
.poi-actions button { min-height: 44px; border-radius: 14px; font-weight: 900; }
.poi-actions .add { color: #fff; background: var(--primary); }
.poi-actions .remove { color: #b91c1c; background: #fee2e2; }

.loading-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-content: center;
  gap: 12px;
  background: rgba(248, 250, 252, 0.52);
  backdrop-filter: blur(3px);
  color: var(--text);
  font-weight: 900;
}
.spinner {
  width: 42px;
  height: 42px;
  justify-self: center;
  border-radius: 50%;
  border: 4px solid rgba(37, 99, 235, .18);
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.amap-sug-result {
  z-index: 10000 !important;
  border-radius: 14px !important;
  overflow: hidden;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
}
.amap-marker-label {
  border: 0 !important;
  padding: 4px 8px !important;
  border-radius: 999px !important;
  background: rgba(255, 255, 255, .94) !important;
  color: var(--text) !important;
  box-shadow: 0 8px 20px rgba(15,23,42,.14) !important;
}

@media (min-width: 768px) {
  .bottom-sheet {
    left: 18px;
    right: auto;
    bottom: 18px;
    width: 390px;
    max-height: calc(100dvh - 36px);
    border-radius: 26px;
  }
  .toast { bottom: 36px; }
  .center-picker { top: 50%; }
  .map-actions { top: calc(50% + 14px); }
}

@media (max-width: 370px) {
  .poi-type-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-card { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
