* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; color: #1f2329; background: #f3f5f8; }
.hidden { display: none !important; }
.page { position: fixed; inset: 0; }
input { font-size: 16px; padding: 12px 14px; border: 1px solid #d9dde3; border-radius: 10px; outline: none; width: 100%; background: #fff; }
input:focus { border-color: #1677ff; }
.btn { font-size: 16px; padding: 12px 16px; border: 1px solid #d9dde3; border-radius: 10px; background: #fff; color: #1f2329; cursor: pointer; white-space: nowrap; }
.btn.primary { background: #1677ff; border-color: #1677ff; color: #fff; width: 100%; font-weight: 600; }
.btn.small { font-size: 14px; padding: 8px 10px; flex: 1; }
.btn:active { opacity: .7; }
.link { background: none; border: 0; color: #1677ff; font-size: 14px; padding: 4px 8px; }

/* 入口 */
#entry { display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #e8f1ff, #f7f9fc 60%); padding: 20px; }
.entry-box { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.logo { font-size: 48px; text-align: center; }
h1 { margin: 0; text-align: center; font-size: 28px; }
.sub { margin: 0 0 8px; text-align: center; color: #646a73; font-size: 14px; }
label { font-size: 13px; color: #646a73; }
.row { display: flex; gap: 8px; }
.divider { text-align: center; color: #8f959e; font-size: 13px; position: relative; margin: 6px 0; }
.divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid #e3e6ea; }
.divider span { background: #f1f5fb; position: relative; padding: 0 10px; }
.tip { font-size: 12px; color: #8f959e; text-align: center; margin: 8px 0 0; }

/* 主界面 */
#map { position: absolute; inset: 0; z-index: 0; background: #e9eef3; }
.topbar { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 10px; right: 10px; z-index: 500; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.team { background: #fff; padding: 8px 12px; border-radius: 20px; box-shadow: 0 2px 8px rgba(0,0,0,.12); font-size: 14px; }
.team b { letter-spacing: 2px; font-size: 16px; }
.share { color: #1677ff; margin-left: 6px; }
.top-actions { display: flex; gap: 8px; }
.icon-btn, .fab { width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); font-size: 18px; display: flex; align-items: center; justify-content: center; }
.gps-state { position: absolute; z-index: 500; top: calc(60px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.65); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 12px; white-space: nowrap; }
.gps-state.ok { display: none; }
.gps-state.warn { background: #fa8c16; }
.gps-state.err { background: #ff4d4f; }
.fabs { position: absolute; right: 10px; bottom: calc(var(--sheet-h, 170px) + 12px); z-index: 500; display: flex; flex-direction: column; gap: 10px; transition: bottom .2s; }

/* 成员面板 */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 600; background: #fff; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 16px rgba(0,0,0,.1); max-height: 55vh; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.sheet.collapsed #memberList { display: none; }
.handle { width: 40px; height: 5px; border-radius: 3px; background: #d9dde3; margin: 8px auto 2px; padding: 6px 0; background-clip: content-box; cursor: pointer; }
.sheet-title { font-size: 14px; color: #646a73; padding: 2px 16px 6px; }
#memberList { list-style: none; margin: 0; padding: 0 8px 8px; overflow-y: auto; }
#memberList li { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-radius: 10px; }
#memberList li.active { background: #eef5ff; }
.avatar { width: 36px; height: 36px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.m-info { flex: 1; min-width: 0; }
.m-name { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-name .me { font-size: 11px; color: #fff; background: #8f959e; border-radius: 4px; padding: 0 4px; margin-left: 4px; font-weight: 400; }
.m-name .seek { font-size: 11px; color: #fa541c; margin-left: 4px; font-weight: 400; }
.m-sub { font-size: 12px; color: #8f959e; }
.m-sub.stale { color: #fa8c16; }
.go-btn { border: 0; background: #1677ff; color: #fff; border-radius: 16px; padding: 6px 14px; font-size: 14px; }
.go-btn.on { background: #ff4d4f; }

/* 导航卡片 */
.nav-card { position: absolute; z-index: 700; left: 10px; right: 10px; top: calc(60px + env(safe-area-inset-top)); background: #fff; border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,.18); padding: 10px 14px 12px; }
.nav-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: #646a73; }
.nav-head b { color: #1f2329; }
.nav-body { display: flex; align-items: center; gap: 16px; padding: 8px 0; }
.compass { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid #e3e6ea; background: radial-gradient(circle, #fff 55%, #f3f6fa); }
.arrow { position: absolute; inset: 8px; transition: transform .25s linear; }
.arrow::before { content: ""; position: absolute; left: 50%; top: 2px; transform: translateX(-50%); border-left: 22px solid transparent; border-right: 22px solid transparent; border-bottom: 52px solid var(--c, #1677ff); }
.arrow::after { content: ""; position: absolute; left: 50%; top: 40px; transform: translateX(-50%); width: 14px; height: 40px; border-radius: 0 0 7px 7px; background: var(--c, #1677ff); }
.compass.no-sensor .arrow { opacity: .35; }
.nav-info { flex: 1; min-width: 0; }
.dist { font-size: 34px; font-weight: 700; line-height: 1.1; }
.dir { font-size: 16px; margin-top: 4px; }
.meta { font-size: 12px; color: #8f959e; margin-top: 4px; }
.nav-actions { display: flex; gap: 8px; }

/* 地图标记 */
.pin { position: relative; }
.pin .dot { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); position: absolute; left: -9px; top: -9px; }
.pin .label { position: absolute; left: 50%; top: -34px; transform: translateX(-50%); white-space: nowrap; color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.pin.me .dot { width: 22px; height: 22px; left: -11px; top: -11px; }
.pin .cone { position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; background: conic-gradient(from -30deg, var(--c) 0deg, transparent 60deg, transparent 360deg); opacity: .35; }
.pin.stale .dot, .pin.stale .label { filter: grayscale(.8); opacity: .7; }

.toast { position: fixed; left: 50%; top: calc(110px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 2000; background: rgba(0,0,0,.8); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 86vw; text-align: center; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-box { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 340px; font-size: 15px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.code-big { font-size: 32px; font-weight: 700; letter-spacing: 6px; text-align: center; margin: 8px 0; }
.leaflet-control-attribution { font-size: 9px !important; }
