:root {
  --panel: rgba(18, 20, 24, 0.88);
  --line: rgba(255, 255, 255, 0.14);
  --accent: #2f7cf6;
  --ok: #35c46a;
  --warn: #f5a524;
  --danger: #f2544b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #e9e9e4;
  color: #fff;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ---------- 地图 ---------- */
#map {
  position: fixed;
  inset: 0;
  background: #eef0ee;
}
/* 高德自带版权信息淡一点 */
.amap-logo, .amap-copyright { opacity: 0.55; }

/* 底图样式选择 */
.style-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0 4px;
}
.style-grid button {
  padding: 11px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
}
.style-grid button.sel {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(47, 124, 246, 0.16);
  font-weight: 600;
}

/* 我的位置标记 */
.me-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ---------- 加载中 ---------- */
#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #14161a;
  color: rgba(255, 255, 255, 0.8);
  z-index: 50;
  transition: opacity 0.35s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
.spin {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sp 0.9s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- 顶部信息 ---------- */
#hud {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  background: linear-gradient(to bottom, rgba(10, 12, 16, 0.8), rgba(10, 12, 16, 0));
  pointer-events: none;
  z-index: 5;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: rgba(53, 196, 106, 0.5); }
.chip.warn { color: var(--warn); border-color: rgba(245, 165, 36, 0.5); }
.chip.bad { color: var(--danger); border-color: rgba(242, 84, 75, 0.5); }
.readout {
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  white-space: pre-line;
}

/* ---------- 底部按钮 ---------- */
#actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(10, 12, 16, 0.86), rgba(10, 12, 16, 0));
  z-index: 6;
  overflow-x: auto;
}
#actions button {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  backdrop-filter: blur(8px);
}
#actions button.primary { background: var(--accent); border-color: transparent; font-weight: 600; }
#actions button.on { border-color: var(--ok); color: var(--ok); }
#actions button:active { transform: scale(0.96); }

/* ---------- 横幅 ---------- */
#banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(72px + env(safe-area-inset-bottom));
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(245, 165, 36, 0.96);
  color: #201400;
  font-weight: 600;
  z-index: 7;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  font-size: 13.5px;
}
#banner.info { background: rgba(47, 124, 246, 0.96); color: #fff; }
#banner.bad { background: rgba(242, 84, 75, 0.96); color: #fff; }

/* ---------- 底部面板 ---------- */
#sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  z-index: 10;
}
.sheet-card {
  width: 100%;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  background: #1a1d23;
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
}
.sheet-head button {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  padding: 4px 8px;
  font-family: inherit;
}
.sheet-body {
  padding: 14px 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.9);
}
.sheet-body h4 { margin: 16px 0 6px; font-size: 14px; color: #fff; }
.sheet-body h4:first-child { margin-top: 0; }
.sheet-body p { margin: 6px 0; color: rgba(255, 255, 255, 0.78); }
.sheet-body ul { margin: 6px 0; padding-left: 20px; color: rgba(255, 255, 255, 0.78); }
.sheet-body li { margin: 4px 0; }
.sheet-body code {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12.5px;
}
.sheet-body .note {
  background: rgba(47, 124, 246, 0.14);
  border-left: 3px solid var(--accent);
  padding: 8px 10px;
  border-radius: 6px;
  margin: 10px 0;
  color: rgba(255, 255, 255, 0.85);
}

/* 滑块 */
.slider-row { margin: 14px 0; }
.slider-row label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 6px;
}
.slider-row input[type=range] {
  width: 100%;
  accent-color: var(--accent);
  height: 26px;
}

/* 微调方向盘 */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 240px;
  margin: 12px auto;
}
.dpad button {
  padding: 12px 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 16px;
  font-family: inherit;
}
.dpad .empty { visibility: hidden; }
.sheet-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.sheet-actions button {
  flex: 1 1 auto;
  min-width: 120px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
}
.sheet-actions button.danger { color: var(--danger); border-color: rgba(242, 84, 75, 0.4); }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: 92vw;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(24, 27, 33, 0.96);
  border: 1px solid var(--line);
  font-size: 13.5px;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.hidden { display: none !important; }
