:root {
  --bg: #0b0b1a; --card: #17172e; --card2: #20203d; --ink: #f5f5ff; --muted: #9a9ac0;
  --accent: #a78bfa; --accent2: #7c3aed; --ok: #4ade80; --warn: #fbbf24; --bad: #f87171;
  --tab-h: 64px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body { font: 17px/1.35 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink); }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
#view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 24px; }
#mapwrap { flex: 1; position: relative; min-height: 0; }
#map { position: absolute; inset: 0; }
[hidden] { display: none !important; }
h1 { font-size: 26px; margin: 8px 0 4px; }
h2 { font-size: 20px; margin: 18px 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 15px; }
.center { text-align: center; }

#banner { padding: 8px 14px; font-size: 14px; text-align: center; background: #3b2f08; color: var(--warn); }
#banner.err { background: #3b1010; color: var(--bad); }
#banner button { margin-left: 8px; padding: 4px 10px; font-size: 14px; min-height: 0; }

#tabs { display: flex; background: #11112a; border-top: 1px solid #2a2a50; padding-bottom: env(safe-area-inset-bottom); }
#tabs button { flex: 1; height: var(--tab-h); background: none; border: 0; color: var(--muted); font: inherit; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 0; }
#tabs button span { font-size: 22px; line-height: 1; }
#tabs button.on { color: var(--accent); }

button, .btn { font: inherit; min-height: 48px; padding: 10px 16px; border-radius: 14px; border: 1px solid #3a3a68; background: var(--card2); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent2); border-color: var(--accent2); font-weight: 600; }
button.danger { color: var(--bad); border-color: #5b2b2b; background: transparent; }
button.small { min-height: 38px; padding: 6px 12px; font-size: 15px; }
button:disabled { opacity: .5; }
button.block { width: 100%; }
input[type=text], input[type=email], input:not([type]) { font: inherit; width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 14px; border: 1px solid #3a3a68; background: #0f0f26; color: var(--ink); }
input:focus { outline: 2px solid var(--accent); border-color: transparent; }
label { display: block; margin: 14px 0 6px; font-size: 14px; color: var(--muted); }
.card { background: var(--card); border-radius: 18px; padding: 14px; margin: 12px 0; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.err { color: var(--bad); margin: 8px 0; font-size: 15px; }
.ok { color: var(--ok); margin: 8px 0; font-size: 15px; }
.stack > * + * { margin-top: 10px; }

.colors { display: flex; flex-wrap: wrap; gap: 10px; }
.colors button { width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 50%; border: 3px solid transparent; }
.colors button.on { border-color: #fff; }

.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 20px; color: #111; flex: none; }
.friend { background: var(--card); border-radius: 18px; padding: 12px; margin: 10px 0; }
.friend .top { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.friend .name { font-weight: 600; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend .sub { color: var(--muted); font-size: 14px; }
.friend .dist { text-align: right; flex: none; }
.friend .dist b { font-size: 18px; }
.arrow { width: 34px; height: 34px; margin: 0 0 2px auto; display: block; transition: transform .3s; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; background: #555; }
.dot.fresh { background: var(--ok); } .dot.mid { background: var(--warn); } .dot.old { background: #777; }
.friend .more { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.status { color: var(--accent); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.qrbox { background: #fff; border-radius: 20px; padding: 14px; width: min(78vw, 320px); margin: 12px auto; }
.qrbox svg { display: block; width: 100%; height: auto; }
.code { font: 700 30px/1 ui-monospace, Menlo, monospace; letter-spacing: 2px; text-align: center; margin: 8px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips button { min-height: 38px; padding: 4px 12px; border-radius: 99px; font-size: 15px; }

.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.switch input { width: 52px; height: 30px; appearance: none; -webkit-appearance: none; border-radius: 99px; background: #3a3a68; position: relative; flex: none; min-height: 0; border: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch input:checked { background: var(--accent2); }
.switch input:checked::after { left: 25px; }

.hero { text-align: center; padding: 24px 0 8px; }
.hero img { width: 84px; height: 84px; border-radius: 22px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 20px + env(safe-area-inset-bottom)); background: #fff; color: #111; padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: 90vw; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,.5); }

.mapbtns { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.mapbtns button { width: 48px; height: 48px; padding: 0; font-size: 22px; background: #17172ecc; backdrop-filter: blur(6px); }
.pin { width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; display: grid; place-items: center; font-weight: 700; color: #111; box-shadow: 0 2px 8px rgba(0,0,0,.6); }
.pin.stale { opacity: .6; border-style: dashed; }
.pin.me { width: 20px; height: 20px; border-width: 3px; background: #38bdf8; box-shadow: 0 0 0 8px rgba(56,189,248,.3); }
.maplibregl-popup-content { background: #17172e; color: var(--ink); border-radius: 14px; padding: 12px 14px; font: 15px system-ui; }
.maplibregl-popup-tip { border-top-color: #17172e !important; border-bottom-color: #17172e !important; }
.maplibregl-popup-close-button { color: #fff; font-size: 20px; padding: 2px 8px; }
.maplibregl-popup-content a { color: var(--accent); }
.maplibregl-ctrl-attrib { font-size: 10px; }

.meicon { width: 90px; height: 90px; position: relative; pointer-events: none; }
.meicon .pin.me { position: absolute; left: 35px; top: 35px; }
.meicon .cone { display: none; position: absolute; inset: 0; transition: transform .2s linear;
  background: conic-gradient(from -30deg at 50% 50%, rgba(56,189,248,.55) 0deg, rgba(56,189,248,0) 60deg, transparent 60deg);
  -webkit-mask: radial-gradient(circle at 50% 50%, #000 0 45px, transparent 46px); mask: radial-gradient(circle at 50% 50%, #000 0 45px, transparent 46px); }
.pin.group { width: 44px; height: 44px; background: #fff; color: #4c1d95; font-size: 17px; border-color: #a78bfa; box-shadow: 0 0 0 6px rgba(167,139,250,.35), 0 2px 8px rgba(0,0,0,.6); }
