
:root {
  --bg: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #d7dde6;
  --card: #ffffff;
  --accent: #0f766e;
  --sheet-height: max(42vh, 260px);
  --sheet-collapsed-height: 52px;
  --active-sheet-height: var(--sheet-height);
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; touch-action: none; }
body { margin: 0; font-family: Arial, "Microsoft YaHei", sans-serif; color: var(--ink); background: var(--bg); position: fixed; inset: 0; width: 100%; }
#app, #map { width: 100vw; height: 100vh; overflow: hidden; overscroll-behavior: none; }
.topbar {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; z-index: 900;
}
.search-row {
  display: grid; grid-template-columns: 1fr 40px; gap: 8px;
  background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 8px; padding: 8px;
  box-shadow: 0 8px 22px rgba(15,23,42,.16);
}
#searchInput { border: 0; outline: 0; font-size: 16px; min-width: 0; background: transparent; }
button, select {
  border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; min-height: 34px; font-size: 14px;
}
button:disabled { opacity: .65; }
#clearBtn { font-size: 24px; line-height: 1; }
.filters { display: grid; grid-template-columns: 1fr 1fr 1.2fr 1.4fr; gap: 8px; margin-top: 8px; }
.filters select { min-width: 0; padding: 0 6px; box-shadow: 0 5px 14px rgba(15,23,42,.10); }
.syncbar {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  margin-top: 8px; background: rgba(255,255,255,.96); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 8px; box-shadow: 0 5px 14px rgba(15,23,42,.10);
}
.syncbar[hidden] { display: none !important; }
.data-status { min-width: 0; color: #475467; font-size: 12px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#syncBtn { min-height: 30px; padding: 0 9px; font-weight: 700; color: #0f766e; }
.search-results {
  margin-top: 6px; max-height: 34vh; overflow: auto; background: #fff; border-radius: 8px; box-shadow: 0 8px 22px rgba(15,23,42,.16);
  display: none; border: 1px solid var(--line); overscroll-behavior: contain; touch-action: pan-y;
}
.result-item { padding: 9px 12px; border-bottom: 1px solid #edf1f5; }
.result-item:last-child { border-bottom: 0; }
.result-title { font-size: 14px; font-weight: 700; }
.result-meta { margin-top: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.actionbar {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--active-sheet-height) + max(10px, env(safe-area-inset-bottom))); z-index: 850; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px;
}
.actionbar button { background: rgba(255,255,255,.96); box-shadow: 0 5px 14px rgba(15,23,42,.12); font-weight: 700; min-width: 0; padding: 0 6px; }
.location-notice {
  position: fixed; left: 10px; right: 10px; top: 145px; z-index: 860;
  background: rgba(255,255,255,.97); border: 1px solid #f59e0b; color: #7c2d12;
  border-radius: 8px; padding: 9px 10px; box-shadow: 0 8px 22px rgba(15,23,42,.16);
  font-size: 13px; line-height: 1.45;
}
.toast {
  position: fixed; left: 50%; top: max(78px, calc(env(safe-area-inset-top) + 48px)); transform: translateX(-50%);
  z-index: 980; max-width: min(86vw, 360px); background: rgba(15,23,42,.92); color: #fff;
  border-radius: 999px; padding: 9px 14px; box-shadow: 0 8px 22px rgba(15,23,42,.22);
  font-size: 13px; line-height: 1.35; text-align: center; pointer-events: none;
}
.toast[hidden] { display: none !important; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 880; height: var(--active-sheet-height); background: rgba(255,255,255,.98);
  border-radius: 12px 12px 0 0; box-shadow: 0 -10px 26px rgba(15,23,42,.2); padding: 8px 14px max(18px, env(safe-area-inset-bottom)); overflow: auto; transition: height .22s ease; overscroll-behavior: contain; touch-action: pan-y;
}
.sheet-head { min-height: 34px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 2; background: rgba(255,255,255,.98); padding-bottom: 4px; }
.sheet-toggle { min-height: 30px; padding: 0 12px; font-weight: 700; color: #0f766e; }
.sheet-body { display: block; }
.sheet.collapsed { height: var(--sheet-collapsed-height); overflow: hidden; }
.sheet.collapsed .sheet-body { display: none; }
.sheet.collapsed .sheet-head { padding-bottom: 0; }
body.sheet-collapsed { --active-sheet-height: var(--sheet-collapsed-height); }
.grab { width: 42px; height: 4px; border-radius: 999px; background: #cbd5e1; margin: 0 auto 8px; }
.summary { font-size: 13px; color: var(--muted); line-height: 1.5; }
.name { font-size: 18px; font-weight: 800; line-height: 1.25; margin: 4px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; color: #fff; background: #64748b; }
.chip.A { background: #d7191c; } .chip.B { background: #f08b21; } .chip.C { background: #2878b5; } .chip.D { background: #777; }
.chip.quant-high { background: #6d28d9; } .chip.quant-medium { background: #0f766e; } .chip.quant-unknown { background: #64748b; }
.kv { display: grid; grid-template-columns: 92px 1fr; gap: 6px; font-size: 13px; padding: 4px 0; border-bottom: 1px solid #eef2f6; }
.kv b { color: #475467; }
.people, .near-list, .evidence { margin-top: 8px; }
.section-title { font-size: 14px; font-weight: 800; margin: 12px 0 6px; }
.person, .near-item, .evidence li { font-size: 13px; padding: 7px 0; border-bottom: 1px solid #eef2f6; }
.near-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.near-name { font-weight: 700; }
.near-meta { color: var(--muted); margin-top: 2px; }
.near-people { color: #344054; margin-top: 3px; line-height: 1.35; }
.empty { color: var(--muted); font-size: 13px; padding: 8px 0; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-container.pick-mode { cursor: crosshair; outline: 3px solid #0f766e; outline-offset: -3px; }
@media (max-width: 520px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .syncbar { grid-template-columns: 1fr; }
  .data-status { white-space: normal; }
}
@media (min-width: 760px) {
  .topbar { width: 460px; right: auto; }
  .sheet { left: auto; width: 430px; height: 72vh; border-radius: 12px 0 0 0; }
  .sheet.collapsed { height: var(--sheet-collapsed-height); }
  .actionbar { left: 10px; right: auto; width: 560px; bottom: 18px; }
}
