/* 现代简洁风 —— 手机优先：大字号、紧凑面板、地图占主视区 */
:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --ink: #111827;
  --ink-2: #6b7280;
  --ink-3: #9ca3af;
  --line: #eceef1;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --start: #16a34a;
  --end: #ef4444;
  --radius: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  overflow: hidden;
}

@media (min-width: 560px) {
  .app {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}

/* 顶栏 */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.btn-text {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 16px;
  padding: 10px;
  cursor: pointer;
  font-family: inherit;
}

/* 地图区 */
.map-wrap {
  position: relative;
  flex: 1 1 50%;
  min-height: 230px;
  background: #eef0f3;
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
}

.search {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 14;
}

.search input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 15px;
  font-size: 16px;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.06);
  outline: none;
  color: var(--ink);
}

.search input:focus {
  border-color: var(--accent);
}

.suggest {
  list-style: none;
  margin-top: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, 0.12);
  overflow-y: auto;
  max-height: 250px;
}

.suggest li {
  padding: 12px 15px;
  font-size: 15.5px;
  color: var(--ink);
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.suggest li:first-child {
  border-top: 0;
}

.suggest li:active {
  background: var(--bg);
}

.suggest .sub {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* 地图浮动按钮 */
.map-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.1);
  font-size: 20px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  padding: 0;
}

.map-btn:active {
  background: var(--bg);
}

.map-controls {
  position: absolute;
  top: 70px;
  right: 12px;
  z-index: 11;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.locate-btn {
  position: absolute;
  right: 12px;
  bottom: 14px;
  z-index: 11;
}

.mode-hint {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  max-width: calc(100% - 120px);
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  padding: 9px 15px;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(17, 24, 39, 0.1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-switch {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 14px;
  z-index: 12;
  display: flex;
  gap: 6px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(17, 24, 39, 0.1);
}

.mode {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  height: 44px;
  padding: 0 13px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease;
}

.mode-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #d1d5db;
  transition: background 0.2s ease;
}

.mode-chk {
  display: none;
  font-size: 11px;
  font-weight: 500;
}

.mode.is-set .mode-chk {
  display: inline;
}

#mode-start.is-set .mode-dot {
  background: var(--start);
}

#mode-end.is-set .mode-dot {
  background: var(--end);
}

.mode.active {
  background: var(--accent);
  color: #fff;
}

.mode.active .mode-dot {
  background: rgba(255, 255, 255, 0.9);
}

.mode.active .mode-chk {
  color: rgba(255, 255, 255, 0.85);
}

.map-note {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 78px;
  z-index: 13;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-2);
  box-shadow: 0 6px 20px rgba(17, 24, 39, 0.1);
  overflow-wrap: anywhere;
}

.map-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--ink);
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 6px;
}

.hidden {
  display: none !important;
}

/* ---------- 地图上的 24 山罗盘大盘 ---------- */
.dial-wrap {
  pointer-events: none;
  line-height: 0;
}

.dial-wrap svg text {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* ---------- 自定义图钉 ---------- */
.pin-wrap {
  position: relative;
  width: 36px;
  height: 36px;
  pointer-events: none;
}

.pin-dot {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.28);
}

.pin-dot.start {
  background: var(--start);
}

.pin-dot.end {
  background: var(--end);
}

.pin-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
}

.pin-dot.start::after {
  color: var(--start);
}

.pin-dot.end::after {
  color: var(--end);
}

.pin-dot.pulse::after {
  animation: pin-ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pin-ping {
  0% {
    transform: scale(1);
    opacity: 0.55;
  }
  80%,
  100% {
    transform: scale(2.3);
    opacity: 0;
  }
}

.pin-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 6px;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.4;
  padding: 4px 9px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.16);
  max-width: 186px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pin-label.start {
  background: #dcfce7;
  color: #166534;
}

.pin-label.end {
  background: #fee2e2;
  color: #991b1b;
}

.pin-badge {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  width: 36px;
  height: 36px;
  background: #fff;
  border: 2px solid var(--end);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 700;
  color: #b91c1c;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.18);
}

/* ---------- 结果面板（可收起） ---------- */
.panel {
  flex: 0 1 auto;
  max-height: 52%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: var(--card);
}

.panel.collapsed {
  max-height: none;
}

.panel-toggle {
  flex: 0 0 auto;
  width: 100%;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 9px 16px 5px;
}

.panel-grip {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: #d1d5db;
}

.panel-toggle-row {
  display: none;
  width: 100%;
  align-items: center;
  gap: 10px;
}

.panel.collapsed .panel-toggle-row {
  display: flex;
}

.panel-summary {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 15.5px;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-bottom: 6px;
}

.panel-caret {
  flex: 0 0 auto;
  transition: transform 0.25s ease;
  margin-bottom: 6px;
}

.panel.collapsed .panel-caret {
  transform: rotate(180deg);
}

.panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 16px calc(16px + env(safe-area-inset-bottom));
}

.panel.collapsed .panel-body {
  display: none;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.compass-box {
  width: 96px;
  height: 96px;
  flex: 0 0 auto;
}

@media (min-width: 520px) {
  .compass-box {
    width: 150px;
    height: 150px;
  }
}

.compass-box #compass {
  width: 100%;
  height: 100%;
  display: block;
  transition: opacity 0.3s ease;
}

.compass-box.dim #compass {
  opacity: 0.4;
}

#compass text {
  font-family: inherit;
}

#compass .shan-label {
  transition: fill 0.3s ease;
}

#compass .shan-label.on {
  fill: #2563eb;
  font-weight: 600;
}

.readout {
  flex: 1 1 auto;
  min-width: 0;
}

.readout-main {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.shan-char {
  font-size: 48px;
  font-weight: 600;
  color: var(--accent);
  line-height: 1;
}

.bearing-text {
  font-size: 34px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.readout-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  margin-top: 10px;
}

.bagua-text {
  font-size: 16.5px;
  font-weight: 500;
  color: var(--ink);
}

.dist-text {
  font-size: 15px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.dist-text:not(:empty)::before {
  content: "·";
  margin-right: 6px;
  color: var(--ink-3);
}

.panel-meta {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 11px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px 12px;
}

.meta-row {
  display: flex;
  gap: 10px;
  font-size: 13.5px;
  line-height: 1.55;
}

.meta-label {
  flex: 0 0 auto;
  color: var(--ink-3);
}

.meta-val {
  flex: 1 1 auto;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.meta-grid .meta-val {
  word-break: break-word;
}

.meta-val small {
  display: block;
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* 轻提示（浮在地图内，不遮挡结果面板） */
.toast {
  position: absolute;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 14.5px;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 14;
  max-width: calc(100% - 48px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
