:root {
  --bg: #080d12; --panel: #0f171e; --panel2: #141e27; --stroke: #2a3640; --stroke2: #3a4752;
  --text: #f2f3f4; --muted: #95a3b0; --dim: #6c7a86; --gold: #e4b980; --gold2: #b98a55; --goldglow: #e4b98055;
  --blue: #76c5ff; --danger: #ff8a7a;
  --top: 60px; --nav: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: 'DM Sans', system-ui, sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.gold { color: var(--gold); }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--top); z-index: 20; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: linear-gradient(#080d12f2, #080d12d9); border-bottom: 1px solid #1f2a33; backdrop-filter: blur(10px); }
.brand { display: flex; align-items: center; gap: 9px; font: 800 19px Manrope, sans-serif; letter-spacing: .16em; text-decoration: none; flex: none; }
.pin { width: 22px; height: 28px; overflow: visible; }
.pin path { stroke: var(--gold); stroke-width: 2.6; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pin circle { fill: var(--gold); }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; justify-content: center; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: none; background: #121b23; border: 1px solid var(--stroke2); color: #b9c6d0; padding: 7px 11px; font-size: 11px; letter-spacing: .06em; font-weight: 600; text-transform: uppercase; }
.chip.active { background: var(--gold); color: #14100c; border-color: var(--gold); }
.icon-btn { flex: none; width: 38px; height: 38px; display: grid; place-items: center; background: #121b23; border: 1px solid var(--stroke2); color: var(--gold); font-size: 19px; }
.acct { flex: none; height: 38px; padding: 0 12px; background: linear-gradient(110deg, #f3c993, #c8975f); color: #14100c; border: 0; font-size: 12px; font-weight: 700; letter-spacing: .04em; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct.in { background: #121b23; color: var(--gold); border: 1px solid #5a4a36; }
@media (max-width: 520px) { .topbar { gap: 8px; padding: 0 10px; } .chip { padding: 7px 8px; font-size: 10px; } .acct { padding: 0 10px; max-width: 92px; } .brand { font-size: 0; gap: 0; } .brand .gold { display: none; } }

/* ---------- Map ---------- */
#map { position: fixed; top: var(--top); left: 0; right: 0; bottom: calc(var(--nav) + var(--safe-b)); background: #0b1117; z-index: 1; }
.leaflet-container { background: #0b1117; font-family: 'DM Sans', sans-serif; }
.leaflet-control-attribution { background: #080d12cc !important; color: #7d8b97 !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #a8b5bf !important; }
.leaflet-control-zoom { border: 1px solid var(--stroke2) !important; border-radius: 0 !important; }
.leaflet-control-zoom a { background: #111a22 !important; color: var(--gold) !important; border-radius: 0 !important; border-bottom-color: var(--stroke) !important; }

.mk { position: relative; width: 30px; height: 30px; }
.mk .tear { position: absolute; left: 3px; top: 0; width: 24px; height: 24px; background: var(--gold); border: 3px solid #0e1820; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 0 16px var(--goldglow); transition: transform .2s; }
.mk .tear::after { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: #19232d; }
.mk.locked .tear { background: #8d7351; box-shadow: none; opacity: .85; }
.mk.locked .tear::after { background: #0e1820; }
.mk.mine .tear { background: #f7ead6; }
.mk.gf .tear { border-radius: 0; transform: rotate(45deg); background: linear-gradient(135deg, #fff2dc, var(--gold)); box-shadow: 0 0 22px #f3cf9a99; }
.mk.gf.locked .tear { background: linear-gradient(135deg, #c9b08b, #8d7351); box-shadow: 0 0 10px #e4b98033; }
.mk.sel .tear { transform: rotate(-45deg) scale(1.28); }
.mk.gf.sel .tear { transform: rotate(45deg) scale(1.28); }
.me-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 10px #76c5ff33, 0 0 20px #76c5ff; }

.gps-status { position: fixed; z-index: 15; top: calc(var(--top) + 10px); left: 50%; transform: translateX(-50%); background: #121b23f0; border: 1px solid var(--stroke2); padding: 8px 12px; font-size: 12px; color: #c7d2da; white-space: nowrap; }
.gps-status.warn { border-color: #8d6a3f; color: #f1cf9f; }

/* ---------- Panel ---------- */
.panel { position: fixed; z-index: 10; left: 0; right: 0; bottom: calc(var(--nav) + var(--safe-b)); max-height: 62vh; display: flex; flex-direction: column; background: linear-gradient(180deg, #111a22f7, #0c1319fa); border-top: 1px solid var(--stroke2); box-shadow: 0 -18px 50px #0009; transition: max-height .25s ease; }
.panel::before { content: ''; position: absolute; left: 0; right: 0; top: -1px; height: 1px; background: linear-gradient(90deg, transparent, var(--gold2), transparent); opacity: .7; }
.panel.min { max-height: 120px; }
.panel.full { max-height: calc(100vh - var(--top) - var(--nav) - var(--safe-b)); }
.grabber { border: 0; background: transparent; padding: 8px 0 4px; display: flex; justify-content: center; flex: none; }
.grabber span { width: 42px; height: 3px; background: #4a5762; }
.panel-body { overflow-y: auto; padding: 4px 18px 22px; overscroll-behavior: contain; }
@media (min-width: 900px) {
  .panel { top: var(--top); bottom: 0; right: auto; width: 420px; max-height: none !important; border-top: 0; border-right: 1px solid var(--stroke2); }
  .panel::before { top: 0; bottom: 0; left: auto; right: -1px; width: 1px; height: auto; background: linear-gradient(180deg, transparent, var(--gold2), transparent); }
  .grabber { display: none; }
  .panel-body { padding-top: 20px; padding-bottom: calc(var(--nav) + 24px); }
  #map { left: 420px; bottom: 0; }
  .bottomnav { width: 420px; right: auto; }
}

/* ---------- Typography / blocks ---------- */
.eyebrow { font-size: 10px; letter-spacing: .32em; color: var(--gold); font-weight: 700; text-transform: uppercase; }
h2.title { font: 600 24px/1.2 Manrope, sans-serif; letter-spacing: -.03em; margin: 8px 0 6px; }
h3.sub { font: 700 13px Manrope, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: #cfd7dd; margin: 26px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.fine { font-size: 11px; color: var(--dim); line-height: 1.6; }
.rule { height: 1px; background: linear-gradient(90deg, var(--gold2), transparent); margin: 16px 0; opacity: .6; }
.summary { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.summary b { font: 600 20px Manrope, sans-serif; letter-spacing: -.02em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--stroke); margin: 14px 0; }
.stats div { padding: 12px; border-right: 1px solid var(--stroke); }
.stats div:last-child { border-right: 0; }
.stats b { display: block; font: 700 20px Manrope, sans-serif; color: var(--gold); }
.stats span { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- List rows ---------- */
.rows { display: grid; gap: 8px; }
.row { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; text-align: left; width: 100%; background: linear-gradient(155deg, #131d25, #0e151c); border: 1px solid var(--stroke); padding: 12px; }
.row:hover { border-color: #57636d; }
.row .glyph { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid #4a3f30; color: var(--gold); font-size: 16px; background: #1a1712; }
.row.locked .glyph { color: #8d7d68; border-color: #2f3a43; background: #10171d; }
.row .txt { min-width: 0; }
.row .txt strong { display: block; font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .txt span { font-size: 11px; color: var(--muted); }
.row .dist { font-size: 11px; color: var(--gold); font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.empty { border: 1px dashed var(--stroke2); padding: 22px; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ---------- Gram detail ---------- */
.back { border: 0; background: none; color: var(--muted); padding: 4px 0; font-size: 13px; }
.gram { border: 1px solid #3e4a54; background: linear-gradient(160deg, #15202a, #0e161d); padding: 18px; margin-top: 8px; position: relative; }
.gram.gf { border-color: #8a6c47; background: linear-gradient(160deg, #221d16, #0f151b); box-shadow: inset 0 0 0 1px #e4b98022; }
.gram .tiny { display: flex; justify-content: space-between; gap: 10px; color: #dcb784; font-size: 10px; letter-spacing: .14em; font-weight: 700; text-transform: uppercase; }
.gram blockquote { margin: 14px 0; font: 500 19px/1.5 Manrope, sans-serif; letter-spacing: -.01em; overflow-wrap: anywhere; }
.gram .meta { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.gram .meta a { color: var(--gold); text-decoration: none; }
.lockbox { text-align: center; padding: 26px 10px 14px; }
.lockbox .big { font: 600 30px Manrope, sans-serif; color: var(--gold); }
.lockbox .arrow { display: inline-block; font-size: 28px; color: var(--gold); margin-bottom: 4px; transition: transform .3s; }
.meter { margin-top: 16px; }
.meter .lbl { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.meter .bar { height: 4px; background: #222d36; }
.meter .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn { border: 1px solid #57616a; background: transparent; padding: 11px 15px; font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.btn:hover { border-color: #8a96a0; }
.btn.primary { background: linear-gradient(110deg, #f3c993, #c8975f); color: #14100c; border: 0; }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { border-color: var(--stroke); color: var(--muted); font-weight: 600; }
.btn.danger { border-color: #6b3b35; color: var(--danger); }
.btn.on { border-color: var(--gold); color: var(--gold); }
.btn.block { width: 100%; padding: 14px; }

.echoes { margin-top: 6px; display: grid; gap: 0; }
.echo { border-left: 2px solid #5a4a36; padding: 10px 0 10px 14px; position: relative; }
.echo p { margin: 0 0 5px; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.echo .meta { font-size: 11px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.echo .meta a { color: var(--gold); text-decoration: none; }
.linkbtn { border: 0; background: none; color: var(--dim); font-size: 11px; padding: 0; text-decoration: underline; }

/* ---------- Forms ---------- */
label.f { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
input.in, textarea.in, select.in { width: 100%; background: #0a1218; border: 1px solid #3d4a55; padding: 13px; color: var(--text); border-radius: 0; outline: none; }
input.in:focus, textarea.in:focus { border-color: var(--gold2); }
textarea.in { min-height: 130px; resize: vertical; line-height: 1.55; font-size: 16px; }
.counter { text-align: right; font-size: 11px; color: var(--dim); margin-top: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-size: 13px; color: #c6d0d8; line-height: 1.5; }
.check input { margin-top: 3px; accent-color: var(--gold); width: 16px; height: 16px; }
.err { color: var(--danger); font-size: 13px; margin: 10px 0 0; min-height: 1px; }
.notice { border: 1px solid #4c4539; background: linear-gradient(112deg, #211f19, #111820); padding: 14px; font-size: 13px; color: #d5cbbd; line-height: 1.6; margin: 12px 0; }
.tabs2 { display: flex; border-bottom: 1px solid var(--stroke); margin: 18px 0 12px; }
.tabs2 button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.tabs2 button.active { color: var(--gold); border-color: var(--gold); }

/* ---------- Gate (location) ---------- */
.gate { padding: 8px 0 4px; }
.gate .ring { width: 58px; height: 58px; border: 1px solid var(--gold2); display: grid; place-items: center; font-size: 26px; color: var(--gold); margin-bottom: 14px; box-shadow: 0 0 30px #e4b98022; }
.gate p { color: #b8c4cc; line-height: 1.7; font-size: 14px; }

/* ---------- Bottom nav ---------- */
.bottomnav { position: fixed; z-index: 21; left: 0; right: 0; bottom: 0; height: calc(var(--nav) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; background: #070b0f; border-top: 1px solid #1f2a33; }
.bottomnav button { flex: 1; border: 0; background: none; color: #8e9dab; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; position: relative; }
.bottomnav button .g { font-size: 19px; letter-spacing: 0; }
.bottomnav button.active { color: var(--gold); }
.bottomnav button.active::before { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--gold); }
.bottomnav .dot { position: absolute; top: 12px; left: 58%; width: 7px; height: 7px; background: var(--gold); border-radius: 50%; }

/* ---------- Modal / toast ---------- */
.overlay { position: fixed; inset: 0; z-index: 40; background: #000c; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal { width: min(440px, 100%); max-height: 90vh; overflow-y: auto; background: #111a22; border: 1px solid #4e5b65; padding: 26px; position: relative; }
.modal::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: linear-gradient(90deg, var(--gold2), var(--gold), var(--gold2)); }
.close { position: absolute; right: 12px; top: 10px; background: none; border: 0; font-size: 26px; color: #c8d1d8; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: calc(var(--nav) + var(--safe-b) + 16px); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #e2b681; color: #111; padding: 12px 16px; font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px #000a; transition: .25s; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: #ff9d8f; }
@media (min-width: 900px) { .toast { left: 210px; } }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid #ffffff33; border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.celebrate { text-align: center; padding: 8px 0; }
.celebrate .gem { font-size: 46px; color: var(--gold); text-shadow: 0 0 30px #e4b980aa; }
