:root {
  --bg: #06060a;
  --surface: rgba(12, 12, 20, 0.92);
  --surface-hover: rgba(20, 20, 35, 0.95);
  --accent: #818cf8;
  --accent-glow: rgba(129, 140, 248, 0.3);
  --accent-dim: #6366f1;
  --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;
}
.hidden { display: none !important; }


/* ─── 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; }

@media (max-width:767px) {
  .sovereign-layout { flex-direction: column; }
}

/* ─── CHAT TOGGLE [Manual only if closed] ─── */
#chat-toggle {
  position:fixed; bottom:24px; left:24px; z-index:11000;
  width:50px; height:50px; border-radius:50%;
  border:1px solid var(--accent);
  background: rgba(129, 140, 248, 0.1); backdrop-filter:blur(20px);
  color: var(--accent); cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  transition: all 400ms var(--ease);
  box-shadow: 0 0 20px var(--accent-glow);
  pointer-events: auto;
}
.panel-open #chat-toggle { transform: scale(0); opacity: 0; pointer-events: none; }

/* ─── CHAT PANEL [Integrated Split] ─── */
#chat-panel {
  flex: 0 0 0;
  background: linear-gradient(145deg, #0c0c14, #141423);
  backdrop-filter:blur(24px);
  border-left: 1px solid var(--border-active);
  display:flex; flex-direction:column;
  transition: all 500ms var(--ease);
  overflow:hidden;
}

@media (min-width:768px) {
  .panel-open #chat-panel { flex: 0 0 450px; }
}

@media (max-width:767px) {
  #chat-panel { border-left: none; border-top: 1px solid var(--border-active); }
  .panel-open #chat-panel { flex: 0 0 55vh; }
}

/* ─── 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;
}
.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-close:hover { background:rgba(255,255,255,0.06); color:var(--text); }

/* ─── MESSAGES ─── */
#chat-messages {
  flex:1; overflow-y:auto; padding:16px 20px;
  display:flex; flex-direction:column; gap:16px;
  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.55; 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; }
}

/* ─── INPUT ─── */
#chat-input-area { padding:12px 20px 16px; border-top:1px solid var(--border); flex-shrink:0; }
.input-wrapper {
  display:flex; align-items:flex-end; 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.5; resize:none; max-height:120px; padding:8px 0;
}
#chat-input::placeholder { color:var(--text-dim); }
#chat-send {
  width:36px; height:36px; 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;
}
#chat-send:hover:not(:disabled) { background:var(--accent); box-shadow:0 0 20px var(--accent-glow); }
#chat-send:disabled { opacity:0.3; cursor:not-allowed; }
.input-hint { font-size:11px; color:var(--text-dim); text-align:center; margin-top:8px; opacity:0.6; }

/* ─── MAP MARKERS ─── */
.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:2.5px solid rgba(255,255,255,0.9); border-radius:50%;
  box-shadow:0 0 12px var(--accent-glow), 0 2px 4px rgba(0,0,0,0.3);
  animation:pulse 2.5s ease-in-out infinite;
}
.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); }

.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);
}

.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 ─── */
.p2p-panel {
  position: fixed; bottom: 100px; right: 24px;
  width: 320px; height: 420px;
  background: rgba(10, 14, 26, 0.95); backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 20px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6); z-index: 12000;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
}
.p2p-panel.hidden { transform: translateY(40px); opacity: 0; pointer-events: none; }
.p2p-header {
  padding: 14px 18px; background: rgba(255,255,255,0.03);
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.p2p-header span { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; color: var(--accent); }
.p2p-header button { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 18px; }
.p2p-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.p2p-msg { max-width: 85%; align-self: flex-start; }
.p2p-msg.sent { align-self: flex-end; }
.p2p-msg-bubble { 
  padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; 
  background: rgba(255,255,255,0.05); color: #e2e8f0;
}
.p2p-msg.sent .p2p-msg-bubble { background: var(--accent); color: white; }
.p2p-msg-time { font-size: 9px; color: #64748b; margin-top: 4px; padding: 0 4px; }
.p2p-msg.sent .p2p-msg-time { text-align: right; }
.p2p-footer { padding: 12px; display: flex; gap: 8px; background: rgba(0,0,0,0.2); }
.p2p-footer input { 
  flex: 1; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; color: white; padding: 8px 12px; outline: none; font-size: 13px;
}
.p2p-footer button { 
  background: var(--accent); border: none; color: white; width: 36px; height: 36px;
  border-radius: 10px; cursor: pointer; font-size: 16px; 
}


@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;
  }

  .hud-layer::-webkit-scrollbar { display: none; }
  .hud-divider { display: none; }
  .hud-section { 
    padding: 4px 10px; min-width: 80px; 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(20px + env(safe-area-inset-bottom)); left: 20px; }
  .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; }
}
