:root {
  --bg: #06060a;
  --surface: rgba(12, 12, 20, 0.92);
  --surface-hover: rgba(20, 20, 35, 0.95);
  --accent: #00ccff;
  --accent-glow: rgba(0, 204, 255, 0.4);
  --accent-dim: rgba(0, 204, 255, 0.1);
  --bg-dark: #0a0a0a;
  --glass-bg: rgba(12, 12, 20, 0.4);
  --glass-blur: blur(28px) saturate(200%);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: rgba(255, 255, 255, 0.06);
  --border-active: rgba(255, 255, 255, 0.12);
  --user-msg: rgba(99, 102, 241, 0.15);
  --agent-msg: rgba(255, 255, 255, 0.03);
  --error: #f87171;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Space Grotesk', -apple-system, sans-serif;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 24px;
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --ease: 350ms cubic-bezier(0.16, 1, 0.3, 1);
  --chat-w: 400px;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html, body {
  width:100%; height:100%; overflow:hidden;
  font-family: var(--font); background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; /* Kill blue flash on mobile tap */
}
.hidden { display: none !important; }

/* ─── GLOBAL TOUCH OPTIMIZATION ─── */
button, a, [role="button"], .lens-btn, .suggestion-chip, .add-btn, .star-btn,
.radial-item, .shop-close, .p2p-close-btn, #p2p-send, #chat-send, #chat-toggle,
#chat-close, #chat-clear, .style-toggle, .style-option, .checkout-btn,
.proactive-bubble, .map-link {
  touch-action: manipulation; /* Eliminate 300ms delay */
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}


/* ─── WORKSTATION LAYOUT ─── */
.sovereign-layout {
  display: flex; width: 100%; height: 100vh; overflow: hidden;
  flex-direction: row; transition: all 500ms var(--ease);
}
#territory-viewport {
  flex: 1; position: relative; overflow: hidden;
  background: var(--bg);
}
#map { width: 100%; height: 100%; background: #0a0e1a; }

/* ─── CHAT TOGGLE — Floating Neon + Pulse Beacon ─── */
#chat-toggle {
  position:fixed; bottom:24px; right:24px; z-index:11000;
  width:60px; height:60px; border-radius:50%;
  border:2px solid var(--accent);
  background: rgba(12, 12, 20, 0.95); backdrop-filter:blur(24px);
  color: var(--accent); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: all 400ms var(--ease);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px var(--accent-glow);
  pointer-events: auto; font-size: 24px;
  animation: chat-toggle-beacon 2s ease-in-out infinite, chat-toggle-entrance 1s 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes chat-toggle-beacon {
  0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 40px var(--accent-glow), 0 0 60px var(--accent-glow); }
}
@keyframes chat-toggle-entrance {
  0% { opacity: 0; transform: scale(0.3) translateY(20px); }
  60% { opacity: 1; transform: scale(1.15) translateY(-4px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
/* Floating label to make chat discoverable */
#chat-toggle::after {
  content: 'Ask Medellín';
  position: absolute; right: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--surface); color: var(--accent);
  padding: 6px 14px; border-radius: var(--radius-pill);
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  letter-spacing: 0.02em; white-space: nowrap;
  border: 1px solid var(--accent-dim);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  pointer-events: none;
  animation: label-fade 8s ease-in-out forwards;
}
@keyframes label-fade {
  0%  { opacity: 0; transform: translateY(-50%) translateX(8px); }
  10% { opacity: 1; transform: translateY(-50%) translateX(0); }
  75% { opacity: 1; }
  100% { opacity: 0; }
}
#chat-toggle:hover { transform: scale(1.1); box-shadow: 0 0 40px var(--accent), 0 0 60px var(--accent-glow); }
#chat-toggle:hover::after { animation: none; opacity: 1; transform: translateY(-50%); }
#chat-toggle:active { transform: scale(0.92); }
.panel-open #chat-toggle { transform: scale(0); opacity: 0; pointer-events: none; animation: none; }
.panel-open #chat-toggle::after { display: none; }

/* ─── CHAT PANEL — [DRAWER OVERLAY / GLASS] ─── */
#chat-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 450px; z-index: 10000;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-left: var(--glass-border);
  display:flex; flex-direction:column;
  transition: transform 500ms var(--ease);
  transform: translateX(100%);
  overflow:hidden;
  box-shadow: -10px 0 30px rgba(0,0,0,0.3);
}
.panel-open #chat-panel { transform: translateX(0); }

@media (max-width:767px) {
  #chat-panel { 
    top: auto; right: 0; left: 0; bottom: 0;
    width: 100%; height: 60vh; /* Shorter on mobile for more map visibility */
    border-left: none; border-top: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(100%);
    border-radius: 24px 24px 0 0;
    background: rgba(10, 10, 18, 0.85); /* More solid on mobile for readability */
  }
  .panel-open #chat-panel {
    transform: translateY(0) !important; /* Override translateX(0) from desktop rule */
  }
}

/* ─── CHAT HEADER ─── */
#chat-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px; border-bottom:1px solid var(--border); flex-shrink:0;
  cursor: grab;
}
.chat-identity { display:flex; align-items:center; gap:12px; }
.avatar-ring {
  width:40px; height:40px; border-radius:50%;
  background:linear-gradient(135deg, var(--accent-dim), #a78bfa);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 0 12px var(--accent-glow);
}
.avatar-emoji { font-size:20px; }
#chat-header h1 { font-family: var(--font-display); font-size:18px; font-weight:700; letter-spacing:-0.01em; }
.subtitle { font-size:11px; color:var(--text-dim); font-weight:400; letter-spacing:0.02em; text-transform:uppercase; font-family:var(--font); }

.chat-actions { display:flex; align-items:center; gap:4px; }
#chat-clear, #chat-close {
  width:32px; height:32px; border-radius:50%; border:none;
  background:transparent; color:var(--text-muted); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition:all 150ms ease;
}
#chat-clear:hover { background:rgba(239, 68, 68, 0.1); color:#f87171; }
#chat-voice:hover { background:rgba(64, 196, 255, 0.1); color:var(--accent); }
#chat-voice.active { background:var(--accent-dim); color:var(--accent); box-shadow:0 0 15px var(--accent-glow); animation:voice-pulse 2s infinite; }
#chat-close:hover { background:rgba(255,255,255,0.06); color:var(--text); }

@keyframes voice-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); box-shadow: 0 0 25px var(--accent); }
  100% { transform: scale(1); }
}


/* ─── MESSAGES ─── */
#chat-messages {
  flex:1; overflow-y:auto; padding:16px 20px;
  display:flex; flex-direction:column; gap:12px;
  scrollbar-width:thin; scrollbar-color:rgba(255,255,255,0.08) transparent;
}
#chat-messages::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.08); border-radius:2px; }
#chat-messages::after { content: ""; display: block; min-height: 80px; flex-shrink: 0; }


.message { max-width:85%; animation: msg-in 300ms cubic-bezier(0.16,1,0.3,1); }
@keyframes msg-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.message.user { align-self:flex-end; }
.message.assistant { align-self:flex-start; }
.message-content {
  padding:10px 14px; border-radius:var(--radius-md);
  font-size:14px; line-height:1.5; letter-spacing:-0.005em; word-wrap:break-word;
}
.message.user .message-content {
  background:var(--user-msg); border:1px solid rgba(99,102,241,0.2);
  border-radius:var(--radius-md) var(--radius-md) 4px var(--radius-md);
}
.message.assistant .message-content {
  background:var(--agent-msg); border:1px solid var(--border);
  border-radius:var(--radius-md) var(--radius-md) var(--radius-md) 4px;
}

/* Typing indicator */
.typing-indicator { display:flex; gap:4px; padding:12px 16px; }
.typing-dot {
  width:6px; height:6px; border-radius:50%; background:var(--text-dim);
  animation:bounce 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay:0.2s; }
.typing-dot:nth-child(3) { animation-delay:0.4s; }
@keyframes bounce {
  0%,60%,100% { transform:translateY(0); opacity:0.4; }
  30% { transform:translateY(-6px); opacity:1; }
}

/* ─── MAP LINK — Touch-friendly POI taps ─── */
.map-link {
  color: var(--accent); cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted;
  text-underline-offset: 2px;
  padding: 2px 4px; border-radius: 4px;
  transition: all 150ms ease;
  display: inline;
}
.map-link:hover, .map-link:active {
  background: var(--accent-dim);
  text-decoration: none;
}

/* ─── INPUT AREA — [FIXED TO DRAWER BOTTOM] ─── */
#chat-input-area { 
  padding: 12px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  border-top: 1px solid var(--border); 
  flex-shrink: 0; 
  background: rgba(10, 10, 15, 0.85); 
  backdrop-filter: blur(20px);
  z-index: 1; /* Ensure it stacks above messages */
}
.input-wrapper {
  display:flex; align-items:center; gap:8px;
  background:rgba(255,255,255,0.04); border:1px solid var(--border);
  border-radius:var(--radius-pill); padding:4px 4px 4px 16px;
  transition:border-color 150ms ease;
}
.input-wrapper:focus-within { border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-glow); }
#chat-input {
  flex:1; background:transparent; border:none; outline:none;
  color:var(--text); font-family:var(--font); font-size:16px;
  line-height:1.4; resize:none; max-height:80px; padding:6px 0;
  touch-action: manipulation;
}
#chat-input::placeholder { color:var(--text-dim); }
#chat-send {
  width:44px; height:44px; border-radius:50%; border:none;
  background:var(--accent-dim); color:white; cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0; transition:all 150ms ease;
  min-width:44px; min-height:44px; /* Apple HIG minimum touch target */
  position: relative; /* Ensure tappable above siblings */
}
#chat-send:hover:not(.send-disabled) { background:var(--accent); box-shadow:0 0 20px var(--accent-glow); }
#chat-send:active:not(.send-disabled) { transform: scale(0.9); background:var(--accent); }
#chat-send.send-disabled { opacity:0.3; cursor:not-allowed; }
/* CRITICAL: Never use disabled attribute — it blocks touch events on mobile */
/* Instead we use .send-disabled CSS class for visual state */
.input-hint { font-size:11px; color:var(--text-dim); text-align:center; margin-top:8px; opacity:0.6; }

/* ─── V2.0 INTENT LENS BAR ─── */
#intent-lens-bar {
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%); z-index:11000;
  display:flex; gap:12px; padding:10px 16px; border-radius:var(--radius-xl);
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  box-shadow: 0 12px 48px rgba(0,0,0,0.8), 0 0 40px rgba(0,0,0,0.4);
  transition: all 400ms var(--ease);
}
.panel-open #intent-lens-bar { transform: translateX(-50%) translateY(120%); opacity: 0; }

.lens-btn {
  background:rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.1);
  border-radius:12px; width:48px; height:48px; font-size:22px;
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  transition:all 300ms var(--ease);
  position: relative;
  overflow: hidden;
}
.lens-btn::before {
  content: ''; position: absolute; inset: 0; background: white; opacity: 0; transition: opacity 0.3s;
}
.lens-btn:hover::before { opacity: 0.1; }
.lens-btn:active::before { opacity: 0.15; }
.lens-btn:hover { transform: translateY(-4px); border-color: rgba(255, 255, 255, 0.3); }

@keyframes lens-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15) translateY(-8px); }
  100% { transform: scale(1.1) translateY(-6px); }
}
.lens-btn.active {
  background: var(--accent-dim); border-color: var(--accent);
  box-shadow: 0 0 25px var(--accent-glow), 0 0 5px var(--accent);
  transform: scale(1.1) translateY(-6px);
  animation: lens-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Agent-Specific Theme Overrides */
[data-agent="navigator"] { --accent: #00ccff; --accent-glow: rgba(0, 204, 255, 0.4); --agent-accent: #00ccff; }
[data-agent="concierge"] { --accent: #ffcc00; --accent-glow: rgba(255, 204, 0, 0.4); --agent-accent: #ffcc00; }
[data-agent="custodian"] { --accent: #ff3366; --accent-glow: rgba(255, 51, 102, 0.4); --agent-accent: #ff3366; }

[data-agent] #chat-panel { 
  border-left: 2px solid var(--accent);
  box-shadow: -10px 0 40px rgba(0,0,0,0.5), -5px 0 20px var(--accent-glow);
}
[data-agent] .avatar-ring {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  box-shadow: 0 0 20px var(--accent-glow);
}
[data-agent] .hud-layer {
  border-color: var(--accent-dim);
  box-shadow: 0 8px 32px rgba(0,0,0,0.8), 0 0 10px var(--accent-glow);
}


/* ─── MAP MARKERS — Neon Grounding ─── */
.map-marker { cursor:pointer; transition:transform 150ms ease; }
.map-marker:hover { transform:scale(1.2); }
.marker-dot {
  width:14px; height:14px; background:var(--accent);
  border:2px solid #fff; border-radius:50%;
  box-shadow:0 0 15px var(--accent-glow);
}
.map-marker.starred .marker-dot {
  background:#fbbf24; border-color:white;
  box-shadow:0 0 15px rgba(251, 191, 36, 0.5), 0 2px 4px rgba(0,0,0,0.3);
  animation:star-pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { box-shadow:0 0 12px var(--accent-glow), 0 2px 4px rgba(0,0,0,0.3); }
  50% { box-shadow:0 0 24px var(--accent-glow), 0 2px 4px rgba(0,0,0,0.3); }
}
@keyframes star-pulse {
  0%,100% { box-shadow:0 0 15px rgba(251, 191, 36, 0.5); transform:scale(1); }
  50% { box-shadow:0 0 25px rgba(251, 191, 36, 0.8); transform:scale(1.1); }
}
.marker-label {
  position:absolute; top:-28px; left:50%; transform:translateX(-50%);
  background:var(--surface); color:var(--text); font-size:11px; font-weight:500;
  padding:3px 8px; border-radius:6px; border:1px solid var(--border);
  white-space:nowrap; backdrop-filter:blur(10px); pointer-events:none;
}

/* MapLibre overrides */
.maplibregl-popup-content {
  background:rgba(12,12,20,0.95)!important; color:var(--text)!important;
  border:1px solid var(--border)!important; border-radius:8px!important;
  padding:8px 12px!important; font-family:var(--font)!important; font-size:13px!important;
  backdrop-filter:blur(10px)!important; box-shadow:var(--shadow-md)!important;
}
.maplibregl-popup-content strong { font-family: var(--font-display); font-size: 14px; font-weight: 700; display:block; margin-bottom:8px; }
.marker-popup-content { min-width:140px; padding:4px 0; }
.marker-actions { border-top:1px solid var(--border); margin-top:8px; padding-top:8px; display:flex; justify-content:flex-end; }
.star-btn {
  background:transparent; border:none; color:var(--text-dim); 
  font-size:20px; cursor:pointer; transition:all 150ms ease;
  line-height:1; display:flex; align-items:center; justify-content:center;
}
.star-btn:hover { color:#fbbf24; transform:scale(1.2); }
.star-btn.active { color:#fbbf24; text-shadow:0 0 10px rgba(251, 191, 36, 0.4); }

.maplibregl-popup-tip { border-top-color:rgba(12,12,20,0.95)!important; }
.maplibregl-popup-close-button { color:var(--text-muted)!important; font-size:16px!important; }
.maplibregl-ctrl-group {
  background:var(--surface)!important; border:1px solid var(--border)!important;
  backdrop-filter:blur(20px)!important; box-shadow:0 2px 8px rgba(0,0,0,0.3)!important;
}
.maplibregl-ctrl-group button+button { border-top:1px solid var(--border)!important; }
.maplibregl-ctrl-attrib {
  background: rgba(10, 14, 26, 0.7) !important;
  color: var(--text-dim) !important;
  border-radius: 8px !important;
  font-size: 10px !important;
  padding: 4px 10px !important;
  backdrop-filter: blur(12px) !important;
  border: 1px solid var(--border-active) !important;
  margin: 10px !important;
  transition: all 0.3s ease;
}
.maplibregl-ctrl-attrib a { color: var(--accent-dim) !important; text-decoration: none; }
.maplibregl-ctrl-attrib:hover { background: rgba(10, 14, 26, 0.95) !important; color: var(--text) !important; }


/* ─── WELCOME ─── */
.welcome-message { text-align:center; padding:24px 16px; color:var(--text-muted); }
.welcome-message .city-name { font-family: var(--font-display); font-size:28px; font-weight:700; color:var(--text); margin-bottom:4px; letter-spacing:-0.02em; }
.welcome-message .tagline { font-size:13px; color:var(--text-dim); margin-bottom:16px; }
.prompt-suggestions { display:flex; flex-direction:column; gap:6px; margin-top:12px; }
.suggestion-chip {
  padding:8px 14px; border-radius:var(--radius-pill);
  border:1px solid var(--border); background:rgba(255,255,255,0.02);
  color:var(--text-muted); font-size:13px; font-family:var(--font);
  cursor:pointer; transition:all 150ms ease; text-align:left;
}
.suggestion-chip:hover { background:rgba(255,255,255,0.06); color:var(--text); border-color:var(--border-active); }

.error-message {
  color:var(--error); font-size:13px; padding:8px 12px;
  background:rgba(248,113,113,0.1); border:1px solid rgba(248,113,113,0.2);
  border-radius:8px;
}

/* ═══ STYLE SWITCHER ═══ */
.style-switcher {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 900;
}

.style-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-active);
  background: var(--surface);
  backdrop-filter: blur(20px) saturate(180%);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 200ms ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.style-toggle:hover {
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4), 0 0 12px var(--accent-glow);
  transform: scale(1.05);
}
.style-switcher.expanded .style-toggle {
  color: var(--accent);
  border-color: var(--accent);
}

.style-panel {
  position: absolute;
  top: 48px;
  left: 0;
  min-width: 200px;
  background: linear-gradient(160deg, rgba(12, 14, 26, 0.97), rgba(18, 16, 32, 0.95));
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-active);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04) inset;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  pointer-events: none;
  transition: all 250ms cubic-bezier(0.16, 1, 0.3, 1);
}
.style-switcher.expanded .style-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.style-panel-header {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.style-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.02);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 200ms ease;
  font-family: var(--font);
}
.style-option:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--border-active);
  color: var(--text);
  transform: translateY(-1px);
}
.style-option.active {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--accent-dim);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.15);
}

.style-icon {
  font-size: 20px;
  line-height: 1;
}

.style-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ═══ TERRITORY HUD [Phase 4] ═══ */
.hud-layer {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  z-index: 1100; display: flex; align-items: center; gap: 0;
  background: rgba(10, 14, 26, 0.9); backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--border-active); border-radius: var(--radius-pill);
  padding: 4px 10px; box-shadow: 0 8px 32px rgba(0,0,0,0.8);
  transition: all 400ms var(--ease);
  max-width: 95%;
  overflow-x: auto;
  scrollbar-width: none;
  animation: hud-glitch 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  pointer-events: none;
}
.hud-section { 
  padding: 4px 16px; display: flex; flex-direction: column; align-items: center; 
  min-width: 100px; pointer-events: auto;
}
.hud-label { font-size: 9px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 2px; }
.hud-value { font-family: var(--font-display); font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.hud-divider { width: 1px; height: 24px; background: var(--border); }

@keyframes hud-glitch {
  0% { opacity: 0; transform: translateX(-50%) translateY(-12px); }
  40% { opacity: 1; transform: translateX(-50%) translateY(2px); }
  60% { transform: translateX(-50%) translateY(-1px); }
  100% { transform: translateX(-50%) translateY(0); }
}

.hud-update-pulse {
  animation: hud-value-flash 0.6s ease-out;
}
@keyframes hud-value-flash {
  0% { color: #4ade80; transform: scale(1.15); }
  100% { color: inherit; transform: scale(1); }
}

.pulse-section .hud-value { color: #14b4be; text-shadow: 0 0 10px rgba(20, 180, 190, 0.4); }
.context-section .hud-value { color: #c8a55a; }
.vitals-section .hud-value { color: #f87171; text-shadow: 0 0 10px rgba(248, 113, 113, 0.3); font-family: monospace; }

/* ═══ GAMIFIED RADIAL UI ═══ */
.radial-menu {
  position: absolute;
  width: 200px;
  height: 200px;
  margin-left: -100px;
  margin-top: -100px;
  pointer-events: auto;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.radial-center {
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #40c4ff;
  box-shadow: 0 0 30px rgba(64, 196, 255, 0.4);
  animation: pulse-avatar 2s infinite ease-in-out;
}

.radial-item {
  position: absolute;
  width: 60px;
  height: 60px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: white;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s;
  overflow: visible; /* Prevent 'EDS' clipping */
  white-space: nowrap;
}

.radial-item:hover {
  background: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 0 20px var(--accent);
}

.slot-n { transform: translateY(-80px); }
.slot-h { transform: translateX(80px); }
.slot-r { transform: translateY(80px); }
.slot-o { transform: translateX(-80px); }

@keyframes pulse-avatar {
  0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(64, 196, 255, 0.4); }
  50% { transform: scale(1.1); box-shadow: 0 0 50px rgba(64, 196, 255, 0.6); }
}

[id="hud-level-up"] {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 40px var(--accent);
  pointer-events: none;
  z-index: 10000;
  animation: level-bloom 2s forwards;
}

@keyframes level-bloom {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; filter: blur(20px); }
  20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; filter: blur(0); }
  80% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; filter: blur(40px); }
}

/* ═══ PROACTIVE BUBBLES ═══ */
#proactive-bubble-container {
  position: fixed; top: 140px; left: 50%; transform: translateX(-50%);
  z-index: 850; pointer-events: none; width: 100%; max-width: 450px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.proactive-bubble {
  pointer-events: auto; background: var(--surface); color: var(--text);
  padding: 16px 20px; border-radius: var(--radius-xl);
  border: 1px solid var(--accent-dim); 
  box-shadow: var(--shadow-lg), 0 0 25px rgba(99, 102, 241, 0.3);
  font-size: 15px; line-height: 1.5; font-weight: 500;
  animation: bubble-pop 500ms cubic-bezier(0.175, 0.885, 0.32, 1.275), aura-pulse 3s ease-in-out infinite;
  position: relative; cursor: pointer; backdrop-filter: blur(20px);
}
@keyframes aura-pulse {
  0%, 100% { box-shadow: var(--shadow-lg), 0 0 25px rgba(99, 102, 241, 0.3); }
  50% { box-shadow: var(--shadow-lg), 0 0 40px rgba(99, 102, 241, 0.5); }
}
@keyframes bubble-pop {
  from { opacity: 0; transform: scale(0.8) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.proactive-bubble::after {
  content: ''; position: absolute; bottom: -10px; left: 50%;
  transform: translateX(-50%); border-left: 10px solid transparent;
  border-right: 10px solid transparent; border-top: 10px solid var(--accent-dim);
}

/* ═══ PIP WINDOW [Territory Compass] ═══ */
#pip-window {
  position: fixed; bottom: 100px; left: 24px; z-index: 1001;
  width: 200px; height: 140px; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--accent-dim); background: var(--bg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 20px var(--accent-glow);
  transition: all 400ms var(--ease);
  display: flex; flex-direction: column;
}
#pip-window.hidden { transform: translateX(-240px); opacity: 0; }

.pip-header {
  font-size: 10px; font-weight: 800; background: var(--accent-dim);
  color: white; padding: 4px 10px; text-transform: uppercase; 
  letter-spacing: 0.1em; display: flex; justify-content: space-between;
}
.pip-header::after { content: 'LIVE'; color: #4ade80; animation: pulse 1s infinite; }

#pip-map { flex: 1; pointer-events: none; opacity: 0.8; }

.pip-snap-btn {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 80%; padding: 6px; border: none; border-radius: 8px;
  background: var(--surface); color: var(--accent);
  font-family: var(--font-display); font-size: 9px; font-weight: 800;
  cursor: pointer; transition: all 0.2s; border: 1px solid var(--accent-dim);
  backdrop-filter: blur(10px);
}
.pip-snap-btn:hover { background: var(--accent-dim); color: white; transform: translateX(-50%) translateY(-2px); }

#pip-window::before {
  content: "STREAMING TERRITORY VITALS...";
  position: absolute; top: 22px; left: 10px; z-index: 10;
  font-size: 7px; color: var(--accent); opacity: 0.5;
  font-family: monospace; letter-spacing: 1px;
}

/* ─── FLASH SHOP [Spoppify Local] ─── */
.shop-panel {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.4); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s ease;
}
.shop-panel.hidden { opacity: 0; pointer-events: none; }

.shop-card {
  width: 90%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border-active);
  border-radius: 28px; padding: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8), 0 0 30px var(--accent-glow);
  transform: scale(1); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ─── ALIAS ONBOARDING MODAL ─── */
.alias-panel {
  position: fixed; inset: 0; z-index: 21000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s ease;
}
.alias-panel.hidden { opacity: 0; pointer-events: none; }
.alias-card {
  width: 90%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 24px; padding: 32px 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 40px var(--accent-glow);
  text-align: center;
  display: flex; flex-direction: column; gap: 16px;
  transform: scale(1); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.alias-panel.hidden .alias-card { transform: scale(0.9); }
.alias-card h3 { color: var(--accent); font-family: var(--font-display); font-size: 22px; margin: 0; letter-spacing: 0.05em; text-transform: uppercase; }
.alias-card p { font-size: 13px; color: var(--text-muted); margin: 0; line-height: 1.5; }

/* ─── PASSPORT MODAL (IDENTITY) ─── */
.passport-card {
  width: 90%; max-width: 360px;
  background: var(--surface); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px; padding: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 30px rgba(0,204,255,0.1);
  display: flex; flex-direction: column;
  transform: scale(1); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
  position: relative;
}
.passport-card::before {
  content: ''; position: absolute; top:0; left:0; right:0; height:4px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}
.alias-panel.hidden .passport-card { transform: scale(0.9); }
.passport-header {
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(0,0,0,0.2);
}
.passport-type { font-size: 10px; font-weight: 800; color: var(--accent); letter-spacing: 0.1em; }
.passport-body { display: flex; align-items: center; gap: 20px; padding: 24px 20px; }
.passport-avatar {
  width: 64px; height: 64px; border-radius: 16px; background: rgba(0,204,255,0.1);
  border: 1px solid rgba(0,204,255,0.3); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  flex-shrink: 0; box-shadow: inset 0 0 20px rgba(0,204,255,0.1);
}
.passport-info { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.passport-info h2 { font-family: var(--font-display); font-size: 24px; color: white; margin: 0; letter-spacing: -0.02em; }
.passport-id { font-family: monospace; font-size: 11px; color: var(--text-dim); }
.passport-stats { display: flex; gap: 16px; margin-top: 8px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-lbl { font-size: 9px; color: var(--text-dim); font-weight: 800; letter-spacing: 0.05em; }
.stat-val { font-size: 16px; color: white; font-weight: 700; font-family: var(--font-display); }

.passport-qr {
  padding: 24px; background: rgba(0,0,0,0.4); border-top: 1px solid rgba(255,255,255,0.05);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.passport-qr img {
  width: 160px; height: 160px; border-radius: 12px;
  background: white; padding: 8px; border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.qr-label { font-size: 10px; color: var(--text-dim); letter-spacing: 0.1em; font-weight: 800; }
#alias-input {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; color: var(--text); padding: 14px;
  outline: none; font-size: 16px; font-family: var(--font); text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
#alias-input:focus { border-color: var(--accent); box-shadow: 0 0 15px var(--accent-dim); }

#onb-alias-input {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; color: var(--text); padding: 14px;
  outline: none; font-size: 16px; font-family: var(--font); text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
#onb-alias-input:focus { border-color: var(--accent); box-shadow: 0 0 15px var(--accent-dim); }

.onboarding-icon { font-size: 40px; margin-bottom: -4px; filter: drop-shadow(0 0 10px rgba(0, 204, 255, 0.4)); }
.onboarding-dots { display: flex; center; gap: 8px; justify-content: center; margin: 4px 0; }
.onboarding-dots .dot { width: 8px; height: 8px; background: rgba(255,255,255,0.2); border-radius: 50%; transition: all 0.3s; }
.onboarding-dots .dot.active { background: var(--accent); transform: scale(1.3); box-shadow: 0 0 8px var(--accent); }
.onboarding-dots .dot.alias-dot { border-radius: 4px; width: 12px; }

.sovereign-search-hub {
  display: none !important; /* [REDUNDANT] Unified into Chat Bar */
  position: fixed;

  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  width: 420px;
  max-width: 90vw;
  background: rgba(15, 18, 32, 0.85);
  backdrop-filter: blur(32px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.9), 0 0 30px rgba(129, 140, 248, 0.2);
  overflow: hidden;
  transition: all 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.sovereign-search-hub:hover {
  background: rgba(10, 14, 26, 0.85);
  border-color: var(--accent-dim);
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.9), 0 0 40px var(--accent-glow);
}

.sovereign-search-hub:focus-within {
  border-color: var(--accent);
  width: 480px;
}

.search-inner {
  display: flex;
  align-items: center;
  padding: 0 20px;
}

.search-icon {
  font-size: 16px;
  margin-right: 14px;
  opacity: 0.8;
}

#map-search-input {
  flex: 1;
  height: 52px;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  outline: none;
}

#map-search-input::placeholder {
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Search Results / Feedback */
#search-results {
  background: rgba(12, 12, 20, 0.98);
  border-top: 1px solid var(--border);
  max-height: 300px;
  overflow-y: auto;
}

.search-pulse-marker {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  border: 2.5px solid var(--accent);
  animation: search-marker-ping 2s infinite ease-out;
}

@keyframes search-marker-ping {
  0% { transform: scale(0.2); opacity: 1; }
  100% { transform: scale(3); opacity: 0; }
}

.shop-panel.hidden .shop-card { transform: scale(0.9); }

.shop-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; position: relative; }
.shop-icon { font-size: 24px; color: var(--amber); }
.shop-meta h3 { font-family: var(--font-display); font-size: 18px; margin: 0; color: var(--text); }
.shop-meta p { font-size: 11px; color: var(--text-dim); margin: 0; text-transform: uppercase; letter-spacing: 0.05em; }
.shop-close { 
  position: absolute; right: 0; top: 0; background: none; border: none; 
  color: var(--text-dim); cursor: pointer; font-size: 18px; 
}

.shop-carousel { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.shop-item {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: rgba(255,255,255,0.03); border-radius: 16px; border: 1px solid var(--border);
}
.item-img {
  width: 40px; height: 40px; border-radius: 10px; background: var(--accent-dim);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: white;
}
.item-info { flex: 1; display: flex; flex-direction: column; }
.item-name { font-size: 14px; font-weight: 600; }
.item-price { font-size: 12px; color: var(--amber); font-weight: 700; }
.add-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--accent);
  background: transparent; color: var(--accent); cursor: pointer; font-size: 20px;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.add-btn:hover { background: var(--accent); color: white; }

.shop-footer { display: flex; flex-direction: column; gap: 12px; }
.logic-gate { 
  display: flex; justify-content: space-between; align-items: center; 
  padding: 8px 12px; background: rgba(0,0,0,0.2); border-radius: 12px;
}
.gate-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }
.gate-status.active { font-size: 10px; color: #10b981; font-weight: 800; }
.checkout-btn {
  padding: 14px; border-radius: 16px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: white; font-weight: 700; cursor: pointer; box-shadow: 0 4px 15px var(--accent-glow);
}

.pulse-green { animation: pulse-green 0.5s ease-in-out; }
@keyframes pulse-green {
  50% { color: #10b981; transform: scale(1.2); }
}

/* ─── INTENT AURAS [Presence] ─── */
@keyframes aura-pulse {
  0% { opacity: 0.2; transform: scale(0.9); }
  50% { opacity: 0.5; transform: scale(1.1); }
  100% { opacity: 0.2; transform: scale(0.9); }
}

.map-marker.reputation-glow .marker-dot {
  box-shadow: 0 0 15px #40c4ff, 0 0 30px rgba(64, 196, 255, 0.4);
  background: #fff;
}

/* ─── P2P MESH PANEL — Encrypted Peer Chat ─── */
.p2p-panel {
  position: fixed;
  z-index: 13000;
  background: rgba(8, 10, 20, 0.97);
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border: 1px solid rgba(0, 204, 255, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
  /* Desktop: floating panel */
  bottom: 100px; right: 24px;
  width: 340px; height: 480px;
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,204,255,0.08), 0 0 40px rgba(0,204,255,0.05);
}
/* Mobile: bottom sheet */
@media (max-width: 767px) {
  .p2p-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%; height: 70vh;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
  }
}
.p2p-panel.hidden {
  transform: translateY(48px);
  opacity: 0;
  pointer-events: none;
}
@media (max-width: 767px) {
  .p2p-panel.hidden { transform: translateY(100%); }
}

/* Drag handle (mobile) */
.p2p-panel::before {
  content: '';
  display: block;
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .p2p-panel::before { display: none; }
}

/* Header */
.p2p-header {
  padding: 12px 16px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.p2p-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.p2p-peer-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.p2p-peer-sub {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 1px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.p2p-close-btn {
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  font-size: 18px; padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}
.p2p-close-btn:hover { background: rgba(255,255,255,0.05); color: var(--text); }

/* Status dot */
.p2p-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #475569;
  transition: background 0.4s;
}
.p2p-status-dot.p2p-status-online { background: #4ade80; box-shadow: 0 0 8px #4ade80; animation: dot-pulse 2s infinite; }
.p2p-status-dot.p2p-status-connecting { background: var(--accent); animation: dot-blink 0.8s infinite; }
.p2p-status-dot.p2p-status-offline { background: #f87171; }
.p2p-status-dot.p2p-status-local { background: #fb923c; box-shadow: 0 0 8px #fb923c; }
@keyframes dot-pulse {
  0%, 100% { opacity: 1; } 50% { opacity: 0.5; }
}
@keyframes dot-blink {
  0%, 100% { opacity: 1; } 50% { opacity: 0.2; }
}

/* Messages body */
.p2p-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.p2p-body::-webkit-scrollbar { display: none; }

/* Empty state */
.p2p-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim);
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  padding: 24px;
  margin: auto;
}
.p2p-empty-icon { font-size: 32px; margin-bottom: 4px; }

/* Message bubbles */
.p2p-msg {
  max-width: 82%;
  align-self: flex-start;
  animation: msg-in 0.25s cubic-bezier(0.16,1,0.3,1) both;
}
.p2p-msg.sent { align-self: flex-end; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.p2p-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px 16px 16px 4px;
  font-size: 14px;
  line-height: 1.5;
  background: rgba(255,255,255,0.07);
  color: var(--text);
  word-break: break-word;
}
.p2p-msg.sent .p2p-msg-bubble {
  background: var(--accent);
  color: #000;
  border-radius: 16px 16px 4px 16px;
  font-weight: 500;
}
.p2p-msg-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 0 4px;
}
.p2p-msg.sent .p2p-msg-meta { justify-content: flex-end; }
.p2p-msg-time { font-size: 10px; color: var(--text-dim); }
.p2p-msg-status { font-size: 10px; }
.p2p-status-delivered { color: #4ade80; }
.p2p-status-sending   { color: var(--text-dim); }
.p2p-status-queued    { color: #fb923c; }
.p2p-status-failed    { color: var(--error); }

/* Footer / input */
.p2p-footer {
  padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  display: flex;
  gap: 8px;
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.p2p-footer input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: var(--text);
  padding: 10px 14px;
  outline: none;
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.2s;
  -webkit-appearance: none;
}
.p2p-footer input:focus { border-color: var(--accent); }
.p2p-footer input::placeholder { color: var(--text-dim); font-size: 13px; }
#p2p-send {
  background: var(--accent);
  border: none;
  color: #000;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
#p2p-send:hover { filter: brightness(1.2); transform: scale(1.05); }
#p2p-send:active { transform: scale(0.95); }

/* ─── PEER MAP MARKER ─── */
.sovereign-peer-marker {
  position: relative;
  cursor: pointer;
}
.sovereign-peer-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #40c4ff;
  border: 2.5px solid white;
  box-shadow: 0 0 12px rgba(64,196,255,0.6);
}
.sovereign-peer-ring {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(64,196,255,0.6);
  animation: peer-ring-pulse 2.5s infinite;
}
@keyframes peer-ring-pulse {
  0%   { width: 18px; height: 18px; opacity: 0.8; }
  100% { width: 48px; height: 48px; opacity: 0; }
}
.sovereign-peer-label {
  position: absolute;
  top: -22px; left: 50%;
  transform: translateX(-50%);
  background: rgba(8,10,20,0.9);
  border: 1px solid rgba(64,196,255,0.3);
  color: #40c4ff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
}

/* ─── P2P TOAST NOTIFICATION ─── */
.p2p-toast {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  opacity: 0;
  background: rgba(8,10,20,0.96);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(0,204,255,0.2);
  border-radius: 16px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 20000;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(0.16,1,0.3,1), opacity 0.3s;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  max-width: 90vw;
}
.p2p-toast.p2p-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.p2p-toast-icon { font-size: 20px; flex-shrink: 0; }
.p2p-toast-body { display: flex; flex-direction: column; gap: 2px; }
.p2p-toast-body strong { font-size: 13px; color: var(--accent); }
.p2p-toast-body span { font-size: 12px; color: var(--text-muted); }


@media (max-width: 767px) {
  .hud-layer { 
    top: calc(8px + env(safe-area-inset-top)); 
    left: 8px; right: 8px; width: auto; max-width: none;
    transform: none; border-radius: 12px;
    display: flex; flex-direction: row; align-items: center;
    padding: 4px 6px; gap: 0; overflow-x: auto;
    background: rgba(10, 14, 26, 0.95);
    scrollbar-width: none;
    height: 48px;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
  }
  .hud-layer.scrolled-end {
    mask-image: none;
    -webkit-mask-image: none;
  }

  .hud-layer::-webkit-scrollbar { display: none; }
  .hud-divider { display: none; }
  .hud-section { 
    padding: 4px 8px; min-width: 60px; flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.06);
    border-radius: 0;
  }
  .hud-section:last-child { border-right: none; }
  .hud-label { font-size: 8px; color: var(--accent); white-space: nowrap; }
  .hud-value { font-size: 11px; }
  
  .sovereign-search-hub {
    top: calc(64px + env(safe-area-inset-top)); 
    bottom: auto; left: 8px; right: 8px;
    width: auto; max-width: none; transform: none;
    z-index: 1050; border-radius: 12px;
    height: 52px;
  }

  .sovereign-search-hub:focus-within { width: auto; }
  
  .style-switcher { 
    top: calc(124px + env(safe-area-inset-top)); 
    left: auto; right: 12px; z-index: 1100;
  }

  .style-panel { left: auto; right: 0; }
  
  #chat-toggle {
    bottom: calc(90px + env(safe-area-inset-bottom)); right: 16px; left: auto;
    width: 62px; height: 62px;
  }
  #chat-toggle::after {
    font-size: 11px; padding: 5px 12px;
  }
  .panel-open #chat-panel { flex: 0 0 50vh; max-height: 50vh; }
  
  #pip-window { bottom: calc(85px + env(safe-area-inset-bottom)); left: 16px; width: 160px; height: 110px; }
}
/* ═══════════════════════════════════════════════════════════ */
/* SOVEREIGN CONTACTS PANEL (V3.0) */
/* ═══════════════════════════════════════════════════════════ */

.contacts-panel {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .contacts-panel {
    width: 320px;
    height: calc(100vh - 40px);
    top: 20px; left: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--shadow);
  }
}

.contacts-header {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.contacts-header h3 {
  margin: 0;
  font-family: 'Space Grotesk';
  font-size: 18px;
  color: white;
}

.contacts-close {
  background: none; border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.contacts-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.contacts-search input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  box-sizing: border-box;
}

.contacts-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px;
}

.contacts-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.contact-item {
  display: flex;
  align-items: center;
  padding: 12px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.contact-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent);
}

.contact-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-right: 12px;
  position: relative;
}

.contact-status {
  position: absolute;
  bottom: 0; right: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg);
}
.status-online { background: #4ADE80; box-shadow: 0 0 8px rgba(74, 222, 128, 0.6); }
.status-offline { background: var(--text-dim); }

.contact-info {
  flex: 1;
  overflow: hidden;
}

.contact-name {
  font-weight: 600;
  color: white;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.contact-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

.contact-badge {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
}

.contact-chat-btn {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
  cursor: pointer;
}

.contacts-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.contacts-footer .checkout-btn {
  width: 100%;
}

/* ─── LOCALLIFY — SOVEREIGN COMMERCE STYLES ─── */

.shop-drawer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border-active);
  border-radius: 24px 24px 0 0;
  display: flex; flex-direction: column;
  max-height: 85vh; z-index: 10000;
  box-shadow: 0 -10px 40px rgba(0,0,0,0.5), 0 0 40px var(--accent-glow);
  transition: transform 400ms var(--ease);
}

.slide-up { animation: drawer-slide-up 450ms cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes drawer-slide-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.drawer-handle {
  width: 40px; height: 4px; background: rgba(255,255,255,0.2);
  border-radius: 2px; margin: 12px auto 4px;
}

.shop-header {
  padding: 12px 20px; display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid var(--border);
}
.shop-logo { font-size: 32px; flex-shrink: 0; }
.shop-meta h3 { font-family: var(--font-display); font-size: 20px; letter-spacing: -0.01em; }
.shop-meta p { font-size: 12px; color: var(--text-muted); }

.shop-body {
  padding: 20px; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 24px;
}

.hardware-badge {
  background: var(--accent-dim); color: var(--accent);
  padding: 6px 12px; border-radius: 8px; font-size: 11px; font-weight: 800;
  border: 1px solid var(--accent-glow); align-self: flex-start;
  letter-spacing: 0.05em; display: flex; align-items: center; gap: 6px;
}

.shop-section label {
  font-size: 10px; font-weight: 800; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.1em; display: block; margin-bottom: 12px;
}

.product-list { display: flex; flex-direction: column; gap: 8px; }
.product-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: rgba(255,255,255,0.03);
  border-radius: 16px; border: 1px solid rgba(255,255,255,0.05);
}
.product-name { font-weight: 600; font-size: 15px; }
.product-price { color: var(--accent); font-weight: 700; margin-left: 8px; }

.add-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--accent-dim); color: var(--accent);
  font-size: 20px; cursor: pointer; transition: all 150ms ease;
}
.add-btn:active { transform: scale(0.9); background: var(--accent); color: white; }

.deal-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border: 1px solid var(--accent);
  background: linear-gradient(135deg, var(--accent-dim), transparent);
}
.deal-info h4 { font-family: var(--font-display); color: var(--accent); font-size: 18px; }
.deal-info p { font-size: 12px; color: var(--text-muted); }
.grab-btn {
  background: var(--accent); color: var(--bg); border: none;
  padding: 8px 16px; border-radius: 12px; font-weight: 800; cursor: pointer;
}

/* ─── CHECKOUT & PAIID ─── */
.order-summary { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.order-line { display: flex; justify-content: space-between; font-size: 14px; }
.order-line.total { font-size: 20px; font-weight: 800; margin-top: 8px; font-family: var(--font-display); }
.order-line.dim { color: var(--text-dim); }

.payment-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px;
}
.pay-tile {
  background: rgba(255,255,255,0.04); border: 1px solid var(--border);
  border-radius: 16px; padding: 12px; text-align: center; cursor: pointer;
  transition: all 200ms ease;
}
.pay-tile span { font-size: 24px; display: block; margin-bottom: 4px; }
.pay-tile p { font-size: 10px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; }
.pay-tile:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }
.pay-tile.active { border-color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 15px var(--accent-glow); }
.pay-tile.active p { color: var(--accent); }

.checkout-primary-btn {
  width: 100%; padding: 18px; border-radius: 20px; border: none;
  background: var(--accent); color: var(--bg-dark);
  font-family: var(--font-display); font-size: 18px; font-weight: 800;
  cursor: pointer; transition: all 200ms ease; margin-top: 10px;
}
.checkout-primary-btn:active { transform: scale(0.98); brightness: 0.9; }
.pay-security { font-size: 10px; color: var(--text-dim); text-align: center; margin-top: 12px; }

/* ─── REGISTRATION FORM ─── */
.registration-form section { display: flex; flex-direction: column; gap: 8px; }
.registration-form label { font-size: 9px; margin-bottom: 4px; color: var(--accent); }
.glass-input {
  width: 100%; background: rgba(0,0,0,0.2); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px; color: white; font-family: var(--font);
  transition: all 200ms ease;
}
.glass-input:focus { border-color: var(--accent); outline: none; background: rgba(0,0,0,0.4); }

/* ─── STICKY FOOTER ─── */
.shop-footer-bar {
  padding: 20px; padding-bottom: max(20px, env(safe-area-inset-bottom, 20px));
  background: rgba(10, 10, 20, 0.9); backdrop-filter: blur(20px);
  border-top: 1px solid var(--border); display: flex; align-items: center; gap: 16px;
}
.cart-summary { display: flex; flex-direction: column; flex-shrink: 0; }
.cart-count { font-size: 12px; color: var(--text-muted); }
.cart-total { font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.checkout-btn-main {
  flex: 1; padding: 14px; border-radius: 16px; border: none;
  background: var(--accent); color: var(--bg-dark);
  font-family: var(--font-display); font-size: 15px; font-weight: 800;
  cursor: pointer;
}

/* ─── MERCHANT DASHBOARD ─── */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 24px; }
.stat-card {
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px; text-align: center;
}
.stat-card h2 { color: var(--accent); font-family: var(--font-display); font-size: 24px; margin-bottom: 4px; }
.stat-card p { font-size: 10px; color: var(--text-dim); text-transform: uppercase; font-weight: 700; letter-spacing: 0.1em; }

.live-orders-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.live-order-card {
  background: rgba(0,0,0,0.3); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: 12px; padding: 12px 16px;
}
.o-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.pending { background: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
.status-dot.preparing { background: #3b82f6; box-shadow: 0 0 10px #3b82f6; }
.status-dot.ready { background: #10b981; box-shadow: 0 0 10px #10b981; }

.o-items { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; }
.o-actions { display: flex; gap: 8px; }
.action-btn {
  flex: 1; padding: 8px; border-radius: 8px; border: none;
  font-weight: 700; font-size: 11px; cursor: pointer; transition: transform 150ms;
}
.action-btn:active { transform: scale(0.95); }
.action-btn.accept { background: rgba(251, 191, 36, 0.2); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.4); }
.action-btn.ready { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4); }
.action-btn.fulfill { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
