:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --panel-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --shadow: 0 12px 36px rgba(15, 23, 42, .18);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, .10);
  --radius: 16px;
  --topbar-h: 56px;
  --sheet-peek: 142px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

#app { position: fixed; inset: 0; overflow: hidden; }
#map { position: absolute; inset: 0; background: #e8edf3; }

/* ---------- 地图占位 ---------- */
.map-placeholder {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #eef4ff, #e8edf3 50%, #dfe7ef);
}
.map-placeholder__card {
  width: min(360px, 100%); background: rgba(255, 255, 255, .96);
  border-radius: 22px; padding: 26px 22px; text-align: center;
  box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, .8);
}
.map-placeholder__icon { font-size: 42px; margin-bottom: 8px; }
.map-placeholder h2 { margin: 0 0 6px; font-size: 20px; }
.map-placeholder p { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.link { display: inline-block; margin-top: 12px; color: var(--brand); font-size: 13px; text-decoration: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: absolute; z-index: 40;
  top: calc(var(--safe-top) + 8px);
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  display: flex; align-items: center; gap: 8px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.space-chip {
  max-width: 30vw; min-height: 44px;
  display: flex; align-items: center; gap: 7px;
  padding: 0 12px; border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 999px; background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow-sm); font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  backdrop-filter: blur(12px);
}
.space-chip__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: 0 0 auto; }
.searchbox {
  flex: 1; min-width: 0; min-height: 44px;
  display: flex; align-items: center; gap: 6px;
  padding: 0 12px; border-radius: 999px;
  background: rgba(255, 255, 255, .97);
  border: 1px solid rgba(226, 232, 240, .9);
  box-shadow: var(--shadow-sm); backdrop-filter: blur(12px);
}
.searchbox__icon { color: var(--muted); font-size: 20px; line-height: 1; }
.searchbox input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 16px; padding: 10px 0;
}
.searchbox input::-webkit-search-cancel-button { display: none; }
.searchbox__clear {
  border: 0; background: var(--panel-2); color: var(--muted);
  width: 26px; height: 26px; border-radius: 50%; line-height: 1;
  font-size: 18px;
}
.icon-btn {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 50%; border: 1px solid rgba(226, 232, 240, .9);
  background: rgba(255, 255, 255, .97); box-shadow: var(--shadow-sm);
  font-size: 19px; display: grid; place-items: center;
}

/* ---------- 搜索结果 ---------- */
.search-results {
  position: absolute; z-index: 45;
  top: calc(var(--safe-top) + var(--topbar-h) + 10px);
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  max-height: 56vh; overflow: auto;
  background: var(--panel); border-radius: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: 6px;
}
.search-result {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 10px; border-radius: 12px; border: 0; background: transparent;
  width: 100%; text-align: left;
}
.search-result:active { background: var(--panel-2); }
.search-result__icon { width: 30px; height: 30px; border-radius: 9px; background: #eef4ff; color: var(--brand); display: grid; place-items: center; flex: 0 0 auto; font-size: 14px; }
.search-result__main { min-width: 0; }
.search-result__name { font-size: 14px; font-weight: 600; }
.search-result__addr { font-size: 12px; color: var(--muted); margin-top: 2px; word-break: break-all; }
.search-result__hint { font-size: 11px; color: var(--brand); margin-top: 3px; }
.search-empty { padding: 18px 12px; color: var(--muted); font-size: 13px; text-align: center; }

/* ---------- 地图控件 ---------- */
.map-controls {
  position: absolute; z-index: 35;
  right: calc(var(--safe-right) + 12px);
  bottom: calc(var(--sheet-peek) + var(--safe-bottom) + 18px);
  display: flex; flex-direction: column; gap: 8px;
  transition: opacity .2s, transform .2s;
}
.map-ctrl {
  width: 44px; height: 44px; border-radius: 13px;
  border: 1px solid rgba(226, 232, 240, .95);
  background: rgba(255, 255, 255, .97);
  box-shadow: var(--shadow-sm); font-size: 20px; font-weight: 600;
  display: grid; place-items: center; color: var(--text);
}
.map-ctrl.is-active { background: var(--brand); color: #fff; border-color: var(--brand); }
.map-ctrl:active { transform: scale(.95); }

.fab {
  position: absolute; z-index: 36;
  /* 放在地图控件列左侧，避免遮住定位/3D/图层/缩放按钮 */
  right: calc(var(--safe-right) + 12px + 44px + 12px);
  bottom: calc(var(--sheet-peek) + var(--safe-bottom) + 18px);
  width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--brand); color: #fff;
  font-size: 30px; line-height: 1; box-shadow: 0 10px 24px rgba(37, 99, 235, .4);
  transition: opacity .2s, transform .2s;
}
.fab:active { transform: scale(.95); }

body.sheet-open .map-controls,
body.sheet-open .fab { opacity: 0; pointer-events: none; transform: translateY(8px); }
body.picking .sheet,
body.picking .fab,
body.picking .map-controls,
body.picking .topbar { opacity: 0; pointer-events: none; }
body.correcting .sheet,
body.correcting .fab,
body.correcting .map-controls,
body.correcting .topbar { opacity: 0; pointer-events: none; }
body.click-add #map { cursor: crosshair; }
body.click-add .sheet,
body.click-add .fab,
body.click-add .map-controls,
body.click-add .topbar { opacity: 0; pointer-events: none; }

/* ---------- 同步状态 ---------- */
.sync-pill {
  position: absolute; z-index: 38;
  right: calc(var(--safe-right) + 12px);
  top: calc(var(--safe-top) + var(--topbar-h) + 14px);
  padding: 6px 10px; border-radius: 999px;
  background: rgba(15, 23, 42, .82); color: #e2e8f0;
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  backdrop-filter: blur(8px); user-select: none;
}
.sync-pill.is-ok { background: rgba(22, 163, 74, .92); }
.sync-pill.is-syncing { background: rgba(217, 119, 6, .94); }
.sync-pill.is-offline { background: rgba(220, 38, 38, .92); }
.sync-pill.is-idle { background: rgba(100, 116, 139, .85); }

/* ---------- 底部抽屉 ---------- */
.sheet {
  position: absolute; z-index: 30;
  left: 0; right: 0; bottom: 0;
  height: min(74vh, 680px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(15, 23, 42, .16);
  transform: translateY(calc(100% - var(--sheet-peek) - var(--safe-bottom)));
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-bottom);
  will-change: transform;
}
.sheet.is-open { transform: translateY(0); }
.sheet-handle {
  flex: 0 0 auto; height: 26px; display: grid; place-items: center;
  cursor: grab; touch-action: none;
}
.sheet-handle span { width: 40px; height: 4px; border-radius: 4px; background: #cbd5e1; }
.sheet-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 16px 10px;
}
.sheet-head__text h2 { margin: 0; font-size: 18px; line-height: 1.25; }
.sheet-head__text p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.sheet-collapse { display: none; }
.sheet-expand {
  display: none; position: absolute; z-index: 60; left: 16px; top: 112px;
  min-height: 44px; padding: 0 12px; border-radius: 0 12px 12px 0;
  border: 1px solid var(--line); border-left: 0; background: var(--panel);
  box-shadow: var(--shadow-sm); font-size: 12px; font-weight: 700; color: var(--text);
}
.sheet-list-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.filters { flex: 0 0 auto; padding: 0 16px 6px; }
.chips {
  display: flex; gap: 7px; overflow-x: auto; padding: 4px 0 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel); color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.is-active { background: var(--text); color: #fff; border-color: var(--text); }
.chip__dot { width: 7px; height: 7px; border-radius: 50%; }
.list-toolbar {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: 2px 16px 8px; gap: 8px;
}
.batch-bar {
  flex: 0 0 auto; padding: 8px 12px; border-top: 1px solid var(--line);
  background: var(--panel);
}
.batch-bar__head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--muted);
}
.batch-bar__head b { color: var(--brand); font-size: 14px; }
.batch-bar__actions {
  display: flex; gap: 6px; overflow-x: auto; padding-top: 6px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.batch-bar__actions::-webkit-scrollbar { display: none; }
.batch-bar .btn { flex: 0 0 auto; min-height: 34px; padding: 0 10px; font-size: 11px; }
.place-card__check {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #cbd5e1;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  color: #fff; flex: 0 0 auto; margin-top: 8px;
}
.place-card.is-batch { padding-left: 6px; }
.place-card.is-batch-selected .place-card__check { background: var(--brand); border-color: var(--brand); }
.place-card.is-batch-selected { background: #eef4ff; border-color: #bfdbfe; }
.place-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px 18px; -webkit-overflow-scrolling: touch; }
.place-card {
  display: flex; align-items: stretch; gap: 10px; width: 100%;
  padding: 11px 10px; margin: 4px 0;
  border: 1px solid transparent; border-radius: 14px;
  background: transparent; text-align: left;
}
.place-card.is-active { background: #eef4ff; border-color: #bfdbfe; }
.place-card:active { background: var(--panel-2); }
.place-card__bar { width: 4px; border-radius: 4px; background: var(--brand); flex: 0 0 auto; }
.place-card__icon {
  width: 38px; height: 38px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
  color: #fff; background: var(--brand);
}
.place-card__main { flex: 1; min-width: 0; }
.place-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.place-card__area {
  flex: 0 0 auto; max-width: 92px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; padding: 2px 6px; border-radius: 999px;
  background: var(--area-color, #2563eb); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1.3;
}
.place-card__name { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-card__dist { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.place-card__house { font-size: 12px; color: var(--brand); font-weight: 700; margin-top: 3px; }
.place-card__addr { font-size: 12px; color: var(--muted); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-card__tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 5px; }
.mini-tag { font-size: 10px; padding: 2px 6px; border-radius: 999px; background: var(--panel-2); color: var(--muted); }

/* ---------- 详情 ---------- */
.detail-view { flex: 1; min-height: 0; overflow-y: auto; padding: 0 16px 24px; -webkit-overflow-scrolling: touch; }
.detail-head { display: flex; align-items: flex-start; gap: 10px; padding: 2px 0 12px; }
.detail-head__back { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-size: 18px; flex: 0 0 auto; }
.detail-head__main { flex: 1; min-width: 0; }
.detail-head h3 { margin: 0; font-size: 18px; line-height: 1.3; word-break: break-word; }
.detail-head p { margin: 4px 0 0; font-size: 12px; color: var(--muted); word-break: break-all; }
.detail-photos { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.detail-photos::-webkit-scrollbar { display: none; }
.detail-photo { width: 112px; height: 84px; border-radius: 12px; object-fit: cover; background: var(--panel-2); flex: 0 0 auto; border: 1px solid var(--line); }
.detail-photo--empty { display: grid; place-items: center; color: var(--muted); font-size: 11px; text-align: center; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 12px; }
.detail-item { background: var(--panel-2); border-radius: 12px; padding: 9px 10px; min-width: 0; }
.detail-item--wide { grid-column: 1 / -1; }
.detail-item__label { font-size: 10px; color: var(--muted); letter-spacing: .04em; }
.detail-item__value { font-size: 13px; font-weight: 600; margin-top: 3px; word-break: break-word; white-space: pre-wrap; }
.detail-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.detail-action {
  min-height: 52px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--panel); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--text);
}
.detail-action span:first-child { font-size: 17px; line-height: 1; }
.detail-action.is-danger { color: var(--danger); }
.detail-section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.detail-section h4 { margin: 0 0 8px; font-size: 13px; }
.child-list { display: flex; flex-direction: column; gap: 6px; }
.child-item { display: flex; align-items: center; gap: 9px; padding: 9px; border-radius: 11px; background: var(--panel-2); border: 0; text-align: left; width: 100%; }
.child-item__icon { width: 28px; height: 28px; border-radius: 8px; background: #fef3c7; color: #b45309; display: grid; place-items: center; font-size: 12px; flex: 0 0 auto; }
.child-item__main { flex: 1; min-width: 0; }
.child-item__name { font-size: 13px; font-weight: 600; }
.child-item__note { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offset-note { margin-top: 8px; font-size: 12px; color: var(--warn); background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 8px 10px; }

/* ---------- 空状态 ---------- */
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px 24px; color: var(--muted); }
.empty__icon { font-size: 34px; margin-bottom: 8px; }
.empty p { margin: 0; font-size: 13px; line-height: 1.6; max-width: 260px; }

/* ---------- 按钮 ---------- */
.btn {
  min-height: 44px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel);
  font-size: 14px; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px;
}
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 12px; border-radius: 10px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-2); }
.btn.ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ---------- 选点 / 纠偏 ---------- */
.crosshair {
  position: absolute; z-index: 50; left: 50%; top: 44%;
  width: 46px; height: 46px; margin: -23px 0 0 -23px;
  pointer-events: none;
}
.crosshair::before, .crosshair::after {
  content: ""; position: absolute; background: rgba(37, 99, 235, .85);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .65);
}
.crosshair::before { left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; }
.crosshair::after { top: 50%; left: 0; right: 0; height: 2px; margin-top: -1px; }
.crosshair span {
  position: absolute; left: 50%; top: 50%; width: 16px; height: 16px;
  margin: -8px 0 0 -8px; border: 2px solid var(--brand);
  border-radius: 50%; background: rgba(255, 255, 255, .55);
}
.action-bar {
  position: absolute; z-index: 60;
  left: 10px; right: 10px;
  bottom: calc(var(--safe-bottom) + 10px);
  background: var(--panel); border-radius: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: 12px 14px;
}
.action-bar__hint { font-size: 12px; color: var(--muted); text-align: center; margin-bottom: 10px; }
.action-bar__buttons { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }

/* ---------- 弹窗 ---------- */
.modal-root { position: fixed; inset: 0; z-index: 100; pointer-events: none; }
.modal-root.is-open { pointer-events: auto; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .18s ease;
}
.modal-backdrop.is-center { align-items: center; }
.modal {
  width: 100%; max-height: 94vh; background: var(--panel);
  border-radius: 22px 22px 0 0; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: slideUp .22s cubic-bezier(.2, .8, .2, 1);
  padding-bottom: var(--safe-bottom);
}
.modal--confirm { max-width: 420px; border-radius: 20px; margin: 0 14px 20vh; padding-bottom: 0; }
.modal--confirm .modal-backdrop { align-items: center; }
.modal-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--panel); z-index: 2;
  border-radius: 22px 22px 0 0;
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-head__sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.modal-close { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--panel-2); font-size: 20px; }
.modal-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.modal-foot {
  flex: 0 0 auto; display: flex; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--line); background: var(--panel);
}
.modal-foot .btn { flex: 1; }
.modal-tabs { display: flex; gap: 6px; padding: 10px 16px 0; overflow-x: auto; }
.modal-tab { min-height: 36px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.modal-tab.is-active { background: var(--text); color: #fff; border-color: var(--text); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); font-size: 16px; outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.55; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 19px, calc(100% - 12px) 19px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.coord-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.coord-value { flex: 1; min-width: 140px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); background: var(--panel-2); border-radius: 10px; padding: 10px; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-option { min-height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); font-size: 12px; color: var(--muted); }
.tag-option.is-active { background: #eef4ff; border-color: #bfdbfe; color: var(--brand); font-weight: 700; }
.kind-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.kind-option { min-height: 54px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; color: var(--muted); }
.kind-option b { font-size: 14px; }
.kind-option.is-active { border-color: var(--brand); background: #eef4ff; color: var(--brand); font-weight: 700; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--panel-2); border: 1px solid var(--line); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile__remove { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(15, 23, 42, .7); color: #fff; font-size: 16px; line-height: 1; }
.photo-add { aspect-ratio: 4 / 3; border-radius: 12px; border: 1.5px dashed #cbd5e1; background: var(--panel-2); color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; }
.photo-add span { font-size: 22px; line-height: 1; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch { position: relative; width: 48px; height: 28px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- 空间 / 成员 ---------- */
.space-hero { background: linear-gradient(135deg, #eff6ff, #e0e7ff); border-radius: 16px; padding: 16px; margin-bottom: 16px; }
.space-hero h4 { margin: 0 0 4px; font-size: 16px; }
.space-hero p { margin: 0; font-size: 12px; color: var(--muted); }
.invite-code { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.invite-code__value { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 26px; font-weight: 800; letter-spacing: .18em; color: var(--brand); background: rgba(255, 255, 255, .8); border-radius: 12px; padding: 10px 14px; text-align: center; }
.member-list { display: flex; flex-direction: column; gap: 6px; }
.member-row { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 11px; background: var(--panel-2); }
.member-row__avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.member-row__main { flex: 1; min-width: 0; }
.member-row__name { font-size: 13px; font-weight: 700; }
.member-row__meta { font-size: 10px; color: var(--muted); }
.member-row__actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.member-row__actions .btn { min-height: 32px; padding: 0 8px; font-size: 11px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.history-row__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-row__action { font-size: 12px; font-weight: 700; }
.history-row__time { font-size: 10px; color: var(--muted); }
.history-row__by { font-size: 11px; color: var(--muted); margin-top: 3px; }
.history-row__body { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.5; word-break: break-all; }
.settings-section { margin-bottom: 20px; }
.settings-section h4 { margin: 0 0 10px; font-size: 14px; }
.settings-section p { font-size: 12px; color: var(--muted); line-height: 1.6; }
.settings-actions { display: flex; flex-direction: column; gap: 8px; }
.settings-actions .btn { justify-content: flex-start; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--muted); }
.kv__v { font-weight: 700; text-align: right; word-break: break-all; }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 12px; font-size: 11px; line-height: 1.6; color: #92400e; }

/* ---------- 提示 / 加载 ---------- */
.toast {
  position: absolute; z-index: 200;
  left: 50%; bottom: calc(var(--sheet-peek) + var(--safe-bottom) + 28px);
  transform: translate(-50%, 20px);
  max-width: min(92vw, 420px);
  background: rgba(15, 23, 42, .94); color: #fff;
  padding: 11px 15px; border-radius: 13px;
  font-size: 13px; line-height: 1.45; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: var(--shadow);
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: rgba(185, 28, 28, .96); }
.toast.is-ok { background: rgba(21, 128, 61, .96); }
.loading {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(15, 23, 42, .35); backdrop-filter: blur(2px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; color: #fff; font-size: 13px;
}
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: spin .8s linear infinite; }

/* ---------- 地图 marker ---------- */
.map-marker { display: flex; flex-direction: column; align-items: center; cursor: pointer; filter: drop-shadow(0 3px 6px rgba(15, 23, 42, .28)); }
.map-marker__bubble {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 5px;
  background: var(--mk, #2563eb); border: 2px solid #fff;
  transform: rotate(-45deg); display: grid; place-items: center;
}
.map-marker__bubble span { transform: rotate(45deg); color: #fff; font-size: 10px; font-weight: 800; line-height: 1; }
.map-marker__label {
  margin-top: 2px; max-width: 118px;
  background: rgba(15, 23, 42, .86); color: #fff;
  border-radius: 6px; padding: 2px 5px;
  font-size: 9px; line-height: 1.25; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  display: flex; flex-direction: column; align-items: center;
}
.map-marker__label b { font-size: 9px; font-weight: 700; max-width: 108px; overflow: hidden; text-overflow: ellipsis; }
.map-marker__label span { font-size: 8px; color: #fde68a; max-width: 108px; overflow: hidden; text-overflow: ellipsis; }
.map-marker.is-selected .map-marker__bubble { transform: rotate(-45deg) scale(1.08); box-shadow: 0 0 0 3px rgba(37, 99, 235, .22); }
.map-marker.is-child .map-marker__bubble { width: 21px; height: 21px; border-width: 1.5px; }
.map-marker.is-child .map-marker__bubble span { font-size: 8px; }
.map-marker.is-child .map-marker__label { font-size: 8px; padding: 1px 4px; }
.map-zoom-far .map-marker__bubble { width: 20px; height: 20px; }
.map-zoom-far .map-marker__bubble span { font-size: 8px; }
/* 缩远时保留名称，只隐藏门牌号，减少遮挡 */
.map-zoom-far .map-marker__label span { display: none; }
.corr-dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.corr-dot--official { background: #94a3b8; }
.corr-dot--actual { background: #ef4444; }
.search-pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 6px; background: #0ea5e9; border: 3px solid #fff; transform: rotate(-45deg); box-shadow: 0 3px 10px rgba(0, 0, 0, .3); }

/* 当前定位蓝点 */
.my-location {
  position: relative; width: 20px; height: 20px; pointer-events: none;
}
.my-location__dot {
  position: absolute; inset: 0; border-radius: 50%;
  background: #2563eb; border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .2), 0 2px 8px rgba(15, 23, 42, .35);
}
.my-location__pulse {
  position: absolute; left: 50%; top: 50%; width: 42px; height: 42px;
  margin: -21px 0 0 -21px; border-radius: 50%;
  background: rgba(37, 99, 235, .18);
  animation: my-location-pulse 2s ease-out infinite;
}
.my-location__label {
  position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  background: #2563eb; color: #fff; border-radius: 999px;
  padding: 2px 7px; font-size: 10px; font-weight: 700;
  line-height: 1.2; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .25);
}
@keyframes my-location-pulse {
  0% { transform: scale(.55); opacity: .7; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

/* ---------- 桌面 ---------- */
@media (max-width: 899px) {
  .map-marker__bubble { width: 22px; height: 22px; border-width: 1.5px; }
  .map-marker__bubble span { font-size: 9px; }
  .map-marker__label {
    margin-top: 1px; max-width: 104px; padding: 1px 4px;
    font-size: 8px; line-height: 1.2;
  }
  .map-marker__label b { font-size: 8px; max-width: 96px; }
  .map-marker__label span { font-size: 7px; max-width: 96px; }
  .map-marker.is-child .map-marker__bubble { width: 18px; height: 18px; }
  .map-marker.is-child .map-marker__bubble span { font-size: 7px; }
  .map-zoom-far .map-marker__bubble { width: 18px; height: 18px; }
  .map-zoom-far .map-marker__bubble span { font-size: 7px; }
}

@media (min-width: 900px) {
  .topbar { left: 16px; right: 16px; }
  .space-chip { max-width: 220px; }
  .sheet {
    left: 16px; bottom: 16px; width: 420px; right: auto;
    height: calc(100vh - 88px); max-height: 760px;
    border-radius: 20px; transform: none;
  }
  .sheet-collapse { display: grid; }
  .sheet-expand { display: flex; }
  body.desktop-panel-collapsed .sheet {
    transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none;
  }
  .filters {
    max-height: 34vh; overflow-y: auto; padding-right: 8px;
    scrollbar-width: thin; overscroll-behavior: contain;
  }
  .chips { flex-wrap: wrap; overflow-x: visible; }
  .chip { max-width: 100%; }
  .place-list { scrollbar-width: thin; overscroll-behavior: contain; }
  .place-list::-webkit-scrollbar, .filters::-webkit-scrollbar { width: 8px; }
  .place-list::-webkit-scrollbar-thumb, .filters::-webkit-scrollbar-thumb {
    background: #cbd5e1; border-radius: 8px;
  }
  .map-controls { right: 18px; bottom: 24px; }
  .fab { right: calc(18px + 44px + 12px); bottom: 24px; }
  .sync-pill { right: 18px; top: 76px; }
  .toast { bottom: 28px; }
  .modal { max-width: 560px; border-radius: 20px; margin-bottom: 4vh; }
  .modal-backdrop { align-items: center; }
  .detail-actions { grid-template-columns: repeat(3, 1fr); }
  .kind-picker { grid-template-columns: repeat(4, 1fr); }
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: #f8fafc; border-color: #cbd5e1; }
  .btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
  .btn.ghost:hover { background: var(--panel-2); }
  .btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
  .place-card:hover { background: var(--panel-2); }
  .map-ctrl:hover { background: #f8fafc; }
  .icon-btn:hover, .space-chip:hover { background: #fff; }
  .detail-action:hover { background: #f8fafc; border-color: #cbd5e1; }
  .member-row:hover { filter: brightness(.98); }
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
