/* ===========================================================
   本地地图工具 · 移动端样式
   =========================================================== */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f0f2f5;
  --text: #1c1e21;
  --text-sub: #65676b;
  --line: #e2e5ea;
  --primary: #1a73e8;
  --primary-ink: #ffffff;
  --danger: #e53935;
  --shadow: 0 4px 18px rgba(0, 0, 0, .14);
  --radius: 14px;
  --sheet-h: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body.dark {
  --bg: #15171a;
  --panel: #22262b;
  --panel-2: #2c3138;
  --text: #eceff3;
  --text-sub: #9aa3ad;
  --line: #363c44;
  --primary: #4b94f3;
  --primary-ink: #0b1016;
  --shadow: 0 4px 18px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* 关键：本文件里多处给元素设了 display:flex，会覆盖浏览器默认的 [hidden]{display:none}，
   这里统一强制，确保 hidden 属性始终生效（否则弹窗遮罩会永久挡住整页）。 */
[hidden] { display: none !important; }


html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button, input, select, textarea { font-family: inherit; font-size: 15px; }

/* ---------------- 地图 ---------------- */
#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}
#map .amap-logo,
#map .amap-copyright { opacity: .55; }

.map-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: var(--bg);
  z-index: 1;
}
.map-placeholder .ph-icon { font-size: 46px; }
.map-placeholder .ph-title { font-size: 17px; font-weight: 600; }
.map-placeholder .ph-desc {
  font-size: 13px;
  color: var(--text-sub);
  max-width: 320px;
  white-space: pre-wrap;
  -webkit-user-select: text;
  user-select: text;
}

/* ---------------- 顶部搜索 ---------------- */
#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 12px 8px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 10px;
  background: var(--panel);
  border-radius: 21px;
  box-shadow: var(--shadow);
}
.search-icon { font-size: 14px; opacity: .7; }
#searchInput {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  height: 100%;
}
#searchInput::-webkit-search-cancel-button { display: none; }
.clear-btn {
  border: 0;
  background: var(--panel-2);
  color: var(--text-sub);
  width: 22px; height: 22px;
  border-radius: 50%;
  line-height: 1;
  font-size: 12px;
  cursor: pointer;
}
.icon-btn {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

/* ---------------- 分类筛选条 ---------------- */
.filter-bar {
  position: absolute;
  top: calc(58px + var(--safe-top));
  left: 0; right: 0;
  z-index: 19;
  display: flex;
  gap: 6px;
  padding: 2px 12px 6px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-bar:empty { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .08);
}
.chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #888;
}
.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
  font-weight: 600;
}
.chip.active .dot { display: none; }

/* ---------------- 选点提示 ---------------- */
.pick-hint {
  position: absolute;
  top: calc(96px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 21;
  max-width: 90vw;
  padding: 8px 14px;
  border-radius: 18px;
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 13px;
  box-shadow: var(--shadow);
  text-align: center;
}

/* ---------------- 悬浮按钮 ---------------- */
.fab-group {
  position: absolute;
  right: 14px;
  bottom: calc(90px + var(--safe-bottom));
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: bottom .28s cubic-bezier(.32, .72, 0, 1);
}
.fab {
  position: relative;
  width: 50px; height: 50px;
  border: 0;
  border-radius: 50%;
  background: var(--panel);
  color: var(--text);
  font-size: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.fab:active { transform: scale(.94); }
.fab-primary {
  background: var(--primary);
  color: var(--primary-ink);
  font-size: 26px;
  font-weight: 300;
}
.badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

/* ---------------- 底部面板 ---------------- */
.sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .18);
  transform: translateY(102%);
  transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  will-change: transform;
}
.sheet.open { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-handle {
  flex: 0 0 auto;
  padding: 8px 0 4px;
  display: flex;
  justify-content: center;
  cursor: pointer;
  touch-action: none;          /* 手柄区手势完全交给 JS，用于下拉关闭 */
}
.sheet-handle::before {
  content: '';
  width: 40px; height: 4px;
  border-radius: 2px;
  background: var(--line);
}
.sheet-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 14px calc(16px + var(--safe-bottom));
}

.sheet-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0 10px;
  font-size: 16px;
  font-weight: 700;
}
.sheet-title .sub { font-size: 12px; font-weight: 400; color: var(--text-sub); }
.sheet-title > span:first-child {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-actions { flex: 0 0 auto; display: flex; gap: 6px; }

/* ---------------- 地点列表 ---------------- */
.place-list { list-style: none; margin: 0; padding: 0; }
.place-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.place-item:last-child { border-bottom: 0; }
.place-item .ico {
  flex: 0 0 34px;
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: #fff;
}
.place-item .main { flex: 1; min-width: 0; }
.place-item .name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.place-item .name .star { color: #f5a623; margin-right: 3px; }
.place-item .meta {
  font-size: 12px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.place-item .dist {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  padding-top: 2px;
}

.empty {
  padding: 34px 10px;
  text-align: center;
  color: var(--text-sub);
  font-size: 14px;
  line-height: 1.9;
}

/* ---------------- 详情 ---------------- */
.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}
.detail-head .ico {
  flex: 0 0 44px;
  width: 44px; height: 44px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
}
.detail-head h2 { margin: 0; font-size: 18px; }
.detail-head .cat { font-size: 12px; color: var(--text-sub); }

.kv { font-size: 13px; padding: 5px 0; display: flex; gap: 8px; }
.kv .k { flex: 0 0 58px; color: var(--text-sub); }
.kv .v {
  flex: 1;
  -webkit-user-select: text;
  user-select: text;
  word-break: break-all;
}

/* ---------------- 导航按钮组 ---------------- */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 4px;
}
.nav-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}
.nav-grid button .emo { font-size: 19px; }
.nav-grid button:active { background: var(--primary); color: var(--primary-ink); }

/* ---------------- 通用按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(18px + var(--safe-bottom));
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .25);
  animation: slideUp .24s cubic-bezier(.32, .72, 0, 1);
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal-card h3 { margin: 0 0 12px; font-size: 17px; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  color: var(--text-sub);
}
.field input[type="text"],
.field input[type="tel"],
.field input[type="number"],
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  outline: 0;
  -webkit-user-select: text;
  user-select: text;
}
.field textarea { resize: vertical; min-height: 62px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field .hint { margin-top: 4px; font-size: 12px; color: var(--text-sub); }

.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; min-width: 0; }

.cat-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cat-picker .cat-opt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.cat-picker .cat-opt.on {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
  font-weight: 600;
}

.icon-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-grid button {
  width: 36px; height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  font-size: 17px;
  cursor: pointer;
}
.icon-grid button.on { border-color: var(--primary); border-width: 2px; }

/* ---------------- 轻提示 ---------------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(120px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  max-width: 86vw;
  padding: 10px 16px;
  border-radius: 20px;
  background: rgba(0, 0, 0, .82);
  color: #fff;
  font-size: 13px;
  text-align: center;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------------- 桌面端收窄 ---------------- */
@media (min-width: 700px) {
  .fab-group { bottom: auto; top: 120px; }
  .modal { align-items: center; }
  .modal-card { border-radius: var(--radius); }
  .sheet { max-width: 420px; left: auto; right: 14px; bottom: 14px; border-radius: var(--radius); }
  .sheet.open { transform: none; }
}

/* ---------------- 地图标记 ---------------- */
.amk {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2f80ed;
  line-height: 1;
  cursor: pointer;
}
.amk .amk-ico { font-size: 15px; }
.amk .amk-fav {
  position: absolute;
  top: -7px;
  right: -7px;
  font-size: 12px;
  color: #f5a623;
  text-shadow: 0 0 3px #fff, 0 0 2px #fff;
}

/* 当前定位点 */
.amk-me {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1a73e8;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, .35), 0 2px 6px rgba(0, 0, 0, .4);
  animation: mePulse 2s ease-in-out infinite;
}
@keyframes mePulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(26, 115, 232, .35), 0 2px 6px rgba(0, 0, 0, .4); }
  50% { box-shadow: 0 0 0 9px rgba(26, 115, 232, .12), 0 2px 6px rgba(0, 0, 0, .4); }
}

/* ---------------- 紧凑图标按钮（✕ 收起等） ---------------- */
.btn-icon {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}

/* ---------------- 面板打开时：悬浮按钮上移并改为横排，避免被面板遮挡 ----------------
   仅在移动端生效；z-index 低于面板，但位置已在面板上方，因此始终可点。 */
@media (max-width: 699px) {
  body.sheet-open .fab-group {
    flex-direction: row;
    bottom: calc(var(--sheet-h, 0px) + 14px + var(--safe-bottom));
  }
}
