/* ============ 基础（浅色主题） ============ */
:root {
  --bg: #f5f7fb;
  --ink: #16233f;
  --muted: #64748f;
  --dim: #94a3b8;
  --card: #ffffff;
  --card-border: #e7ecf4;
  --accent: #2563eb;
  --accent2: #06b6d4;
  --ok: #16a34a;
  --err: #e11d48;
  --warn: #b45309;
  --radius: 20px;
  --shadow: 0 4px 22px rgba(15, 35, 95, 0.06);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 背景柔光 */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  background:
    radial-gradient(640px 420px at 10% -6%, rgba(37, 99, 235, 0.09), transparent 62%),
    radial-gradient(720px 520px at 92% 12%, rgba(6, 182, 212, 0.08), transparent 60%),
    radial-gradient(680px 620px at 50% 110%, rgba(99, 102, 241, 0.06), transparent 60%);
  pointer-events: none;
}

.page {
  max-width: 660px;
  margin: 0 auto;
  padding: 20px 16px calc(36px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ============ 顶栏 ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px 2px;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.32);
}

.brand-text h1 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: 0.01em; }
.brand-text .sub { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

.env-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 7px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.env-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.env-pill.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.14); }
.env-pill.ok { color: #15803d; }
.env-pill.warn .dot { background: #d97706; box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.14); }
.env-pill.warn { color: var(--warn); }

/* ============ 警示横幅 ============ */
.banner {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.65;
  color: #92400e;
  background: #fef7e6;
  border: 1px solid #f5dfa8;
}

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  animation: rise 0.45s ease both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 800; }
.hint { font-size: 11.5px; color: var(--dim); text-align: right; }

/* ============ 定位主卡片 ============ */
.hero-row { display: flex; align-items: center; gap: 18px; }

.status-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 7px;
}
.status-label .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.status-label.scanning { color: #1d4ed8; }
.status-label.scanning .live-dot { background: var(--accent); animation: blink 1s ease infinite; }
.status-label.ok { color: #15803d; }
.status-label.ok .live-dot { background: var(--ok); }
.status-label.err { color: #be123c; }
.status-label.err .live-dot { background: var(--err); }

@keyframes blink { 50% { opacity: 0.25; } }

.coords { display: flex; gap: 22px; margin: 7px 0 11px; flex-wrap: wrap; }
.coord .k {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--dim);
  margin-bottom: 3px;
  font-weight: 600;
}
.coord .v {
  font-family: var(--mono);
  font-size: clamp(20px, 6vw, 26px);
  font-weight: 700;
  color: #1e2f57;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: #3f5680;
  padding: 4.5px 10px;
  border-radius: 999px;
  background: #f0f4fb;
  border: 1px solid #e2e9f5;
}
.chip.hl { color: #1d4ed8; background: #eaf1ff; border-color: #d3e2ff; }
.chip.ok { color: #15803d; background: #e9f8ef; border-color: #d0efdd; }
.chip.warn { color: var(--warn); background: #fdf3df; border-color: #f3e2b2; }

/* ---- 雷达动画 ---- */
.radar {
  --rc: #a5b4cf;
  --rc-soft: rgba(148, 163, 184, 0.45);
  position: relative;
  flex: 0 0 auto;
  width: 106px;
  height: 106px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: 0.3s;
  background: radial-gradient(circle at 50% 50%, rgba(37, 99, 235, 0.05), transparent 70%);
}
.radar .ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--rc-soft);
}
.radar .r1 { inset: 0; }
.radar .r2 { inset: 15%; }
.radar .r3 { inset: 31%; }
.radar .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--rc);
  box-shadow: 0 0 12px var(--rc);
}
.radar .sweep {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0;
  background: conic-gradient(from 0deg, rgba(37, 99, 235, 0.35), transparent 75deg);
}
.radar .ping {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--rc);
  opacity: 0;
}

.radar[data-state="scanning"] { --rc: #2563eb; --rc-soft: rgba(37, 99, 235, 0.4); }
.radar[data-state="scanning"] .sweep { opacity: 1; animation: spin 2.1s linear infinite; }
.radar[data-state="scanning"] .ping { animation: ping 1.9s cubic-bezier(0, 0, 0.2, 1) infinite; }
.radar[data-state="scanning"] .dot { animation: blink 1.1s ease infinite; }

.radar[data-state="ok"] { --rc: #16a34a; --rc-soft: rgba(22, 163, 74, 0.45); }
.radar[data-state="ok"] .dot { box-shadow: 0 0 14px var(--rc), 0 0 30px rgba(22, 163, 74, 0.3); }
.radar[data-state="ok"] .ping { animation: ping 2.6s cubic-bezier(0, 0, 0.2, 1) infinite; animation-delay: 0.6s; }

.radar[data-state="err"] { --rc: #e11d48; --rc-soft: rgba(225, 29, 72, 0.45); }
.radar[data-state="err"] .dot { animation: shake 0.5s ease; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ping {
  0% { transform: scale(0.55); opacity: 0.75; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-2.5px); }
  75% { transform: translateX(2.5px); }
}

/* ---- 按钮 ---- */
.actions { display: flex; gap: 10px; margin-top: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  flex: 1;
  min-height: 48px;
  border-radius: 15px;
  font-size: 15.5px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.32);
}
.btn-primary:not(:disabled):hover { box-shadow: 0 10px 26px rgba(37, 99, 235, 0.42); }

.btn-ghost {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: 700;
  color: #2c4a86;
  background: #f0f4fb;
  border: 1px solid #dde7f5;
}
.btn-ghost:hover { background: #e8eef9; }

/* ---- 错误框 ---- */
.err-box {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.7;
  color: #9f1239;
  background: #fff1f4;
  border: 1px solid #ffd7e0;
}
.err-box b { font-weight: 800; }
.err-box .raw { display: block; margin-top: 4px; font-size: 11px; color: rgba(159, 18, 57, 0.6); font-family: var(--mono); word-break: break-all; }

/* ============ 地图 ============ */
#map {
  height: 300px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  background: #eef2f8;
}
.map-fallback {
  height: 220px;
  border-radius: 16px;
  border: 1px dashed #cdd8ea;
  display: grid;
  place-items: center;
  text-align: center;
}
.fb-title { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--muted); }
.fb-sub { margin: 0; font-size: 12px; line-height: 1.7; color: var(--dim); }
.map-tip { margin: 10px 2px 0; font-size: 11.5px; color: var(--dim); text-align: center; }

/* 矢量/卫星分段控件 */
.seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: #f0f4fb;
  border: 1px solid #e2e9f5;
  border-radius: 999px;
}
.seg-btn {
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.18s;
}
.seg-btn.active { background: #fff; color: var(--accent); box-shadow: 0 1px 6px rgba(15, 35, 95, 0.12); }

/* ============ 地址 ============ */
.addr-recommend { margin: 0 0 7px; font-size: 17px; font-weight: 800; line-height: 1.55; color: #1a2b52; }
.addr-full { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.region-chips { margin-top: 12px; }

.landmark {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f6f9ff;
  border: 1px solid #e2ebfb;
}
.lm-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #e3edff;
  color: var(--accent);
}
.lm-text { font-size: 13px; font-weight: 600; color: #2c4a86; line-height: 1.5; }
.lm-text b { color: var(--accent); }

/* ============ 周边搜索 ============ */
.search-row { display: flex; gap: 10px; margin-bottom: 10px; }
#searchInput {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1.5px solid #dde7f5;
  background: #f8fafd;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
#searchInput::placeholder { color: var(--dim); }
#searchInput:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); background: #fff; }

.btn-search {
  flex: 0 0 auto;
  width: 48px;
  height: 44px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.kw-chips { margin-bottom: 12px; }
.chip-btn {
  border: 1px solid #e2e9f5;
  background: #f6f9fd;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: #3f5680;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.16s;
}
.chip-btn:hover { background: #eaf1ff; color: var(--accent); border-color: #d3e2ff; }

.poi-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.poi-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px dashed #e8edf6;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.poi-item:hover { background: #f6f9fd; }
.poi-item:last-child { border-bottom: 0; }
.poi-icon {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #eaf1ff;
  border: 1px solid #d8e6ff;
  color: var(--accent);
}
.poi-body { flex: 1; min-width: 0; }
.poi-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #1e2f57; }
.poi-cat { font-size: 11.5px; color: var(--dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-dist {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-weight: 700;
  color: #2c4a86;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f0f4fb;
  border: 1px solid #e2e9f5;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.empty { color: var(--dim); font-size: 13px; padding: 6px 2px; list-style: none; }

/* ============ 日志 ============ */
.log-card { padding-top: 15px; padding-bottom: 15px; }
.log-card summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.log-card summary::-webkit-details-marker { display: none; }
.log-card summary::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--dim);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.2s;
}
.log-card[open] summary::before { transform: rotate(90deg); }
.log-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.log-entry {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  display: flex;
  gap: 8px;
  word-break: break-all;
}
.log-entry .t { color: var(--dim); flex: 0 0 auto; }
.log-entry.ok { color: #15803d; }
.log-entry.err { color: #be123c; }

/* ============ 页脚 / Toast ============ */
footer { text-align: center; color: var(--dim); font-size: 11px; line-height: 1.9; margin-top: 4px; }
footer p { margin: 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(30px + env(safe-area-inset-bottom));
  transform: translate(-50%, 18px);
  opacity: 0;
  max-width: 82vw;
  padding: 11px 19px;
  border-radius: 999px;
  background: #16233f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 30px rgba(15, 35, 95, 0.28);
  color: #fff;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 99;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ============ 桌面端：地图 + 信息双栏 ============ */
@media (min-width: 960px) {
  .page { max-width: 1020px; padding-top: 40px; }
  .radar { width: 128px; height: 128px; }

  .cards-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 14px;
    align-items: start;
  }
  .map-card { grid-row: 1 / span 2; }
  #map { height: 520px; }
}

/* ============ 减弱动效 ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
